Browse Source
- 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.side_step
13 changed files with 636 additions and 603 deletions
File diff suppressed because it is too large
@ -1,4 +1,4 @@ |
|||
import { initializeApp } from "./main.common"; |
|||
|
|||
const app = initializeApp(); |
|||
app.mount("#app"); |
|||
app.mount("#app"); |
|||
|
@ -1,4 +1,4 @@ |
|||
import { initializeApp } from "./main.common"; |
|||
|
|||
const app = initializeApp(); |
|||
app.mount("#app"); |
|||
app.mount("#app"); |
|||
|
@ -1,71 +1,80 @@ |
|||
import axios from 'axios'; |
|||
import axios from "axios"; |
|||
|
|||
interface PlanResponse { |
|||
data?: any; |
|||
data?: unknown; |
|||
status?: number; |
|||
error?: string; |
|||
} |
|||
|
|||
export const loadPlanWithRetry = async (handle: string, retries = 3): Promise<PlanResponse> => { |
|||
export const loadPlanWithRetry = async ( |
|||
handle: string, |
|||
retries = 3, |
|||
): Promise<PlanResponse> => { |
|||
try { |
|||
console.log(`[Plan Service] Loading plan ${handle}, attempt 1/${retries}`); |
|||
console.log(`[Plan Service] Context: Deep link handle=${handle}, isClaimFlow=${handle.includes('claim')}`); |
|||
|
|||
console.log( |
|||
`[Plan Service] Context: Deep link handle=${handle}, isClaimFlow=${handle.includes("claim")}`, |
|||
); |
|||
|
|||
// Different endpoint if this is a claim flow
|
|||
const response = await loadPlan(handle); |
|||
console.log(`[Plan Service] Plan ${handle} loaded successfully:`, { |
|||
status: response?.status, |
|||
headers: response?.headers, |
|||
data: response?.data |
|||
data: response?.data, |
|||
}); |
|||
|
|||
|
|||
return response; |
|||
} catch (error: any) { |
|||
} catch (error: unknown) { |
|||
console.error(`[Plan Service] Error loading plan ${handle}:`, { |
|||
message: error.message, |
|||
status: error.response?.status, |
|||
statusText: error.response?.statusText, |
|||
data: error.response?.data, |
|||
headers: error.response?.headers, |
|||
message: (error as Error).message, |
|||
status: (error as { response?: { status?: number } })?.response?.status, |
|||
statusText: (error as { response?: { statusText?: string } })?.response |
|||
?.statusText, |
|||
data: (error as { response?: { data?: unknown } })?.response?.data, |
|||
headers: (error as { response?: { headers?: unknown } })?.response |
|||
?.headers, |
|||
config: { |
|||
url: error.config?.url, |
|||
method: error.config?.method, |
|||
baseURL: error.config?.baseURL, |
|||
headers: error.config?.headers |
|||
} |
|||
url: (error as { config?: { url?: string } })?.config?.url, |
|||
method: (error as { config?: { method?: string } })?.config?.method, |
|||
baseURL: (error as { config?: { baseURL?: string } })?.config?.baseURL, |
|||
headers: (error as { config?: { headers?: unknown } })?.config?.headers, |
|||
}, |
|||
}); |
|||
|
|||
if (retries > 1) { |
|||
console.log(`[Plan Service] Retrying plan ${handle}, ${retries-1} attempts remaining`); |
|||
await new Promise(resolve => setTimeout(resolve, 1000)); |
|||
console.log( |
|||
`[Plan Service] Retrying plan ${handle}, ${retries - 1} attempts remaining`, |
|||
); |
|||
await new Promise((resolve) => setTimeout(resolve, 1000)); |
|||
return loadPlanWithRetry(handle, retries - 1); |
|||
} |
|||
|
|||
|
|||
return { |
|||
error: `Failed to load plan ${handle} after ${4-retries} attempts: ${error.message}`, |
|||
status: error.response?.status |
|||
error: `Failed to load plan ${handle} after ${4 - retries} attempts: ${(error as Error).message}`, |
|||
status: (error as { response?: { status?: number } })?.response?.status, |
|||
}; |
|||
} |
|||
}; |
|||
|
|||
export const loadPlan = async (handle: string): Promise<PlanResponse> => { |
|||
console.log(`[Plan Service] Making API request for plan ${handle}`); |
|||
|
|||
const endpoint = handle.includes('claim') |
|||
|
|||
const endpoint = handle.includes("claim") |
|||
? `/api/claims/${handle}` |
|||
: `/api/plans/${handle}`; |
|||
|
|||
|
|||
console.log(`[Plan Service] Using endpoint: ${endpoint}`); |
|||
|
|||
|
|||
try { |
|||
const response = await axios.get(endpoint); |
|||
return response; |
|||
} catch (error: any) { |
|||
} catch (error: unknown) { |
|||
console.error(`[Plan Service] API request failed for ${handle}:`, { |
|||
endpoint, |
|||
error: error.message, |
|||
response: error.response?.data |
|||
error: (error as Error).message, |
|||
response: (error as { response?: { data?: unknown } })?.response?.data, |
|||
}); |
|||
throw error; |
|||
} |
|||
}; |
|||
}; |
|||
|
@ -0,0 +1,4 @@ |
|||
import { defineConfig } from "vite"; |
|||
import { createBuildConfig } from "./vite.config.common.mts"; |
|||
|
|||
export default defineConfig(async () => createBuildConfig('development')); |
Loading…
Reference in new issue