Rename Database class to DatabaseService
This commit is contained in:
parent
a15abb8a33
commit
833ea5227a
@ -2,12 +2,12 @@
|
|||||||
* Database service managing IndexedDB operations via Web Worker
|
* Database service managing IndexedDB operations via Web Worker
|
||||||
* Pure Data Store Layer
|
* Pure Data Store Layer
|
||||||
*/
|
*/
|
||||||
export class Database {
|
export class DatabaseService {
|
||||||
// ============================================
|
// ============================================
|
||||||
// PRIVATE PROPERTIES
|
// PRIVATE PROPERTIES
|
||||||
// ============================================
|
// ============================================
|
||||||
|
|
||||||
private static instance: Database;
|
private static instance: DatabaseService;
|
||||||
private indexedDBWorker: Worker | null = null;
|
private indexedDBWorker: Worker | null = null;
|
||||||
private messageIdCounter: number = 0;
|
private messageIdCounter: number = 0;
|
||||||
private pendingMessages: Map<
|
private pendingMessages: Map<
|
||||||
@ -23,12 +23,12 @@ export class Database {
|
|||||||
this.initIndexedDBWorker();
|
this.initIndexedDBWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async getInstance(): Promise<Database> {
|
public static async getInstance(): Promise<DatabaseService> {
|
||||||
if (!Database.instance) {
|
if (!DatabaseService.instance) {
|
||||||
Database.instance = new Database();
|
DatabaseService.instance = new DatabaseService();
|
||||||
await Database.instance.waitForWorkerReady();
|
await DatabaseService.instance.waitForWorkerReady();
|
||||||
}
|
}
|
||||||
return Database.instance;
|
return DatabaseService.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
@ -57,7 +57,7 @@ export class Database {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.indexedDBWorker.onerror = (error) => {
|
this.indexedDBWorker.onerror = (error) => {
|
||||||
console.error("[Database] IndexedDB Worker error:", error);
|
console.error("[DatabaseService] IndexedDB Worker error:", error);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,4 +288,4 @@ export class Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Database;
|
export default DatabaseService;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { BackUp } from "../types/index";
|
|||||||
import { APP_CONFIG } from "../config/constants";
|
import { APP_CONFIG } from "../config/constants";
|
||||||
import { NetworkService } from "./network.service";
|
import { NetworkService } from "./network.service";
|
||||||
import type { CoreBackend } from "../workers/core.worker";
|
import type { CoreBackend } from "../workers/core.worker";
|
||||||
import Database from "./database.service";
|
import DatabaseService from "./database.service";
|
||||||
import WasmService from "./wasm.service";
|
import WasmService from "./wasm.service";
|
||||||
|
|
||||||
export default class Services {
|
export default class Services {
|
||||||
@ -55,7 +55,7 @@ export default class Services {
|
|||||||
console.log("[Services] 🚀 Démarrage Proxy...");
|
console.log("[Services] 🚀 Démarrage Proxy...");
|
||||||
|
|
||||||
// 1. Initialiser les Services dans le Main Thread (Hub)
|
// 1. Initialiser les Services dans le Main Thread (Hub)
|
||||||
const db = await Database.getInstance();
|
const db = await DatabaseService.getInstance();
|
||||||
const wasmService = await WasmService.getInstance();
|
const wasmService = await WasmService.getInstance();
|
||||||
|
|
||||||
// 2. Passer les Services au Core Worker via Comlink proxy (BEFORE init)
|
// 2. Passer les Services au Core Worker via Comlink proxy (BEFORE init)
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import {
|
|||||||
SecretsStore,
|
SecretsStore,
|
||||||
UserDiff,
|
UserDiff,
|
||||||
} from "../../pkg/sdk_client";
|
} from "../../pkg/sdk_client";
|
||||||
import Database from "../services/database.service";
|
import DatabaseService from "../services/database.service";
|
||||||
import { storeData, retrieveData } from "../services/storage.service";
|
import { storeData, retrieveData } from "../services/storage.service";
|
||||||
import { BackUp } from "../types/index";
|
import { BackUp } from "../types/index";
|
||||||
import { APP_CONFIG } from "../config/constants";
|
import { APP_CONFIG } from "../config/constants";
|
||||||
@ -145,7 +145,7 @@ export class CoreBackend {
|
|||||||
// Initialize domain services with WASM and Database proxies
|
// Initialize domain services with WASM and Database proxies
|
||||||
this.cryptoService = new CryptoService(this.wasmService);
|
this.cryptoService = new CryptoService(this.wasmService);
|
||||||
this.walletService = new WalletService(this.wasmService, this.db);
|
this.walletService = new WalletService(this.wasmService, this.db);
|
||||||
// @ts-ignore - ProcessService accepts DatabaseServiceProxy via Comlink but TypeScript sees Database type
|
// @ts-ignore - ProcessService accepts DatabaseServiceProxy via Comlink but TypeScript sees DatabaseService type
|
||||||
this.processService = new ProcessService(this.db);
|
this.processService = new ProcessService(this.db);
|
||||||
|
|
||||||
this.notifications = this.getNotifications();
|
this.notifications = this.getNotifications();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user