WIP: certificate view and dependency updates

- Update certificate view canvas rendering and QR code generation
- Upgrade dependencies (expo-file-system, expo-font, expo-keep-awake)
- Fix type imports for nostr-tools and dexie-export-import
- Update vite config for better dependency resolution
- Clean up main entry points (capacitor, electron, pywebview)
- Improve error handling in API and plan services
- Add type safety to API error handling
- Update build configuration for platform-specific builds

This is a work in progress commit focusing on certificate view improvements
and dependency maintenance. Some type definitions and build configurations
may need further refinement.
This commit is contained in:
Matthew Raymer
2025-02-21 09:47:24 +00:00
parent b5b5d45b99
commit f33d1f0af3
13 changed files with 636 additions and 603 deletions

View File

@@ -2,21 +2,16 @@ import { initializeApp } from "./main.common";
import { App } from "@capacitor/app";
import router from "./router";
import { handleApiError } from "./services/api";
import { loadPlanWithRetry } from "./services/plan";
import { Capacitor } from '@capacitor/core';
console.log("[Capacitor] Starting initialization");
console.log("[Capacitor] Platform:", process.env.VITE_PLATFORM);
const app = initializeApp();
// Store initial deep link if app is not ready
let pendingDeepLink: string | null = null;
// Initialize API error handling
window.addEventListener('unhandledrejection', (event) => {
window.addEventListener("unhandledrejection", (event) => {
if (event.reason?.response) {
handleApiError(event.reason, event.reason.config?.url || 'unknown');
handleApiError(event.reason, event.reason.config?.url || "unknown");
}
});
@@ -25,41 +20,43 @@ const handleDeepLink = async (data: { url: string }) => {
try {
console.log("[Capacitor Deep Link] START Handler");
console.log("[Capacitor Deep Link] Received URL:", data.url);
// Wait for router to be ready
await router.isReady();
// Parse the custom URL scheme
const parts = data.url.split('://');
const parts = data.url.split("://");
if (parts.length !== 2) {
throw new Error('Invalid URL format');
throw new Error("Invalid URL format");
}
const path = parts[1]; // This will be "claim/01JMAAFZRNSRTQ0EBSD70A8E1H"
const path = parts[1]; // This will be "claim/01JMAAFZRNSRTQ0EBSD70A8E1H"
console.log("[Capacitor Deep Link] Parsed path:", path);
// Map parameterized routes
const paramRoutes = {
'claim': /^claim\/(.+)$/, // Updated pattern without leading slash
claim: /^claim\/(.+)$/, // Updated pattern without leading slash
};
// Check if path matches any parameterized route
for (const [routeName, pattern] of Object.entries(paramRoutes)) {
const match = path.match(pattern);
if (match) {
console.log(`[Capacitor Deep Link] Matched route: ${routeName}, param: ${match[1]}`);
await router.replace({
console.log(
`[Capacitor Deep Link] Matched route: ${routeName}, param: ${match[1]}`,
);
await router.replace({
name: routeName,
params: { id: match[1] }
params: { id: match[1] },
});
return;
}
}
await router.replace('/' + path);
await router.replace("/" + path);
} catch (error) {
console.error("[Capacitor Deep Link] Error:", error);
handleApiError(error, 'deep-link');
handleApiError(error, "deep-link");
}
};
@@ -68,4 +65,4 @@ App.addListener("appUrlOpen", handleDeepLink);
console.log("[Capacitor] Mounting app");
app.mount("#app");
console.log("[Capacitor] App mounted");
console.log("[Capacitor] App mounted");