forked from jsnbuchanan/crowd-funder-for-time-pwa
Fix Vue property conflicts in PlatformServiceMixin implementation
- Remove duplicate property declarations from TopMessage component - Use (this as any) type assertion for mixin methods - Resolves 'Data property already defined' warnings - Fixes 'this.dbQuery is not a function' runtime errors
This commit is contained in:
@@ -47,14 +47,16 @@ export class WebPlatformService implements PlatformService {
|
||||
|
||||
constructor() {
|
||||
WebPlatformService.instanceCount++;
|
||||
|
||||
|
||||
// Only warn if multiple instances (which shouldn't happen with singleton)
|
||||
if (WebPlatformService.instanceCount > 1) {
|
||||
console.error(`[WebPlatformService] ERROR: Multiple instances created! Count: ${WebPlatformService.instanceCount}`);
|
||||
console.error(
|
||||
`[WebPlatformService] ERROR: Multiple instances created! Count: ${WebPlatformService.instanceCount}`,
|
||||
);
|
||||
} else {
|
||||
console.log(`[WebPlatformService] Initializing web platform service`);
|
||||
}
|
||||
|
||||
|
||||
// Start worker initialization but don't await it in constructor
|
||||
this.workerInitPromise = this.initializeWorker();
|
||||
}
|
||||
@@ -74,19 +76,26 @@ export class WebPlatformService implements PlatformService {
|
||||
// This is required for Safari compatibility with nested workers
|
||||
// It installs a handler that proxies web worker creation through the main thread
|
||||
// CRITICAL: Only call initBackend from main thread, not from worker context
|
||||
const isMainThread = typeof window !== 'undefined';
|
||||
const isMainThread = typeof window !== "undefined";
|
||||
if (isMainThread) {
|
||||
// We're in the main thread - safe to dynamically import and call initBackend
|
||||
try {
|
||||
const { initBackend } = await import("absurd-sql/dist/indexeddb-main-thread");
|
||||
const { initBackend } = await import(
|
||||
"absurd-sql/dist/indexeddb-main-thread"
|
||||
);
|
||||
initBackend(this.worker);
|
||||
} catch (error) {
|
||||
console.error("[WebPlatformService] Failed to import/call initBackend:", error);
|
||||
console.error(
|
||||
"[WebPlatformService] Failed to import/call initBackend:",
|
||||
error,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
} else {
|
||||
// We're in a worker context - skip initBackend call
|
||||
console.log("[WebPlatformService] Skipping initBackend call in worker context");
|
||||
console.log(
|
||||
"[WebPlatformService] Skipping initBackend call in worker context",
|
||||
);
|
||||
}
|
||||
|
||||
this.worker.onmessage = (event) => {
|
||||
@@ -120,13 +129,16 @@ export class WebPlatformService implements PlatformService {
|
||||
const { id, type } = message;
|
||||
|
||||
// Handle absurd-sql internal messages (these are normal, don't log)
|
||||
if (!id && message.type?.startsWith('__absurd:')) {
|
||||
if (!id && message.type?.startsWith("__absurd:")) {
|
||||
return; // Internal absurd-sql message, ignore silently
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
// logger.warn("[WebPlatformService] Received message without ID:", message); // DISABLED
|
||||
console.warn("[WebPlatformService] Received message without ID:", message);
|
||||
console.warn(
|
||||
"[WebPlatformService] Received message without ID:",
|
||||
message,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user