fix: syntax error in wallet-setup and use simplified Device type in DeviceReaderService
**Motivations :** - Erreur de syntaxe dans wallet-setup.ts (try/catch mal formé) - Import de Device depuis SDK peut causer des erreurs de compilation - Utiliser un type simplifié pour éviter les dépendances lourdes **Modifications :** - Corriger l'indentation du try/catch dans wallet-setup.ts - Remplacer l'import Device par une interface simplifiée dans DeviceReaderService - Cette interface couvre les champs nécessaires sans dépendre du SDK complet **Pages affectées :** - src/pages/wallet-setup/wallet-setup.ts (correction syntaxe) - src/services/device-reader.service.ts (type simplifié)
This commit is contained in:
parent
36adf1df12
commit
102ee331db
@ -78,31 +78,32 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
services = await Services.getInstance();
|
services = await Services.getInstance();
|
||||||
console.log('✅ Services initialized successfully');
|
console.log('✅ Services initialized successfully');
|
||||||
break;
|
break;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
console.log(`⏳ Services not ready yet (attempt ${attempts + 1}/${maxAttempts}):`, errorMessage);
|
console.log(`⏳ Services not ready yet (attempt ${attempts + 1}/${maxAttempts}):`, errorMessage);
|
||||||
|
|
||||||
// Si c'est une erreur de mémoire, arrêter immédiatement
|
// Si c'est une erreur de mémoire, arrêter immédiatement
|
||||||
if (errorMessage.includes('Out of memory') || errorMessage.includes('insufficient memory')) {
|
if (errorMessage.includes('Out of memory') || errorMessage.includes('insufficient memory')) {
|
||||||
console.error('🚫 Memory error detected - stopping retry attempts');
|
console.error('🚫 Memory error detected - stopping retry attempts');
|
||||||
updateStatus('❌ Erreur: Mémoire insuffisante. Veuillez actualiser la page.', 'error');
|
updateStatus('❌ Erreur: Mémoire insuffisante. Veuillez actualiser la page.', 'error');
|
||||||
throw new Error('WebAssembly initialization failed due to insufficient memory. Please refresh the page.');
|
throw new Error('WebAssembly initialization failed due to insufficient memory. Please refresh the page.');
|
||||||
}
|
|
||||||
|
|
||||||
// Diagnostic plus détaillé
|
|
||||||
if (attempts === 5) {
|
|
||||||
console.log('🔍 Diagnostic: Checking memory usage...');
|
|
||||||
if ((performance as any).memory) {
|
|
||||||
const memory = (performance as any).memory;
|
|
||||||
console.log(`📊 Memory usage: ${Math.round(memory.usedJSHeapSize / 1024 / 1024)}MB / ${Math.round(memory.totalJSHeapSize / 1024 / 1024)}MB`);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
attempts++;
|
// Diagnostic plus détaillé
|
||||||
if (attempts >= maxAttempts) {
|
if (attempts === 5) {
|
||||||
throw new Error(`Services failed to initialize after ${maxAttempts} attempts. This may be due to high memory usage or WebAssembly initialization issues.`);
|
console.log('🔍 Diagnostic: Checking memory usage...');
|
||||||
|
if ((performance as any).memory) {
|
||||||
|
const memory = (performance as any).memory;
|
||||||
|
console.log(`📊 Memory usage: ${Math.round(memory.usedJSHeapSize / 1024 / 1024)}MB / ${Math.round(memory.totalJSHeapSize / 1024 / 1024)}MB`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
attempts++;
|
||||||
|
if (attempts >= maxAttempts) {
|
||||||
|
throw new Error(`Services failed to initialize after ${maxAttempts} attempts. This may be due to high memory usage or WebAssembly initialization issues.`);
|
||||||
|
}
|
||||||
|
await new Promise(resolve => setTimeout(resolve, delayMs));
|
||||||
}
|
}
|
||||||
await new Promise(resolve => setTimeout(resolve, delayMs));
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Services not available:', error);
|
console.error('❌ Services not available:', error);
|
||||||
|
|||||||
@ -4,7 +4,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { DATABASE_CONFIG } from './database-config';
|
import { DATABASE_CONFIG } from './database-config';
|
||||||
import { Device } from '../../pkg/sdk_client';
|
|
||||||
|
// Type simplifié pour éviter les problèmes d'import du SDK
|
||||||
|
export interface Device {
|
||||||
|
sp_wallet?: {
|
||||||
|
address?: string;
|
||||||
|
birthday?: number;
|
||||||
|
last_scan?: number;
|
||||||
|
spend_key?: any;
|
||||||
|
scan_key?: any;
|
||||||
|
[key: string]: any;
|
||||||
|
};
|
||||||
|
sp_client?: any;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
export class DeviceReaderService {
|
export class DeviceReaderService {
|
||||||
private static instance: DeviceReaderService | null = null;
|
private static instance: DeviceReaderService | null = null;
|
||||||
@ -132,4 +145,3 @@ export class DeviceReaderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user