fix(web-app): remove unused sqlite.worker.js and wasi-dummy.js, update Config.kt and service worker logic
- Deleted `sqlite.worker.js` and `wasi-dummy.js` to clean up outdated resources. - Updated `Config.kt` to use a shared `Json` instance for deserialization. - Revised service worker for cache versioning and to bypass caching of `web-app.js` and `.map` files. - Enhanced debug logging and improved handling of uncaught errors in new `sqlite.worker.js`. Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
parent
1db49970d1
commit
b6fda98c89
|
|
@ -21,12 +21,10 @@ BACKUP_RETENTION_DAYS=7
|
||||||
DOCKER_REGISTRY=git.mo-code.at/mocode-software/meldestelle
|
DOCKER_REGISTRY=git.mo-code.at/mocode-software/meldestelle
|
||||||
DOCKER_TAG=latest
|
DOCKER_TAG=latest
|
||||||
DOCKER_VERSION=1.0.0-SNAPSHOT
|
DOCKER_VERSION=1.0.0-SNAPSHOT
|
||||||
DOCKER_BUILD_DATE=2026-02-02T15:00:00Z
|
DOCKER_BUILD_DATE=2026-03-15T12:00:00Z
|
||||||
DOCKER_GRADLE_VERSION=9.3.1
|
DOCKER_GRADLE_VERSION=9.3.1
|
||||||
# Java 25 = Early Access; für LTS auf 21 setzen
|
|
||||||
DOCKER_JAVA_VERSION=25
|
DOCKER_JAVA_VERSION=25
|
||||||
DOCKER_NODE_VERSION=24.12.0
|
DOCKER_NODE_VERSION=24.12.0
|
||||||
# Caddy Version für den Web-App Container
|
|
||||||
DOCKER_CADDY_VERSION=2.11-alpine
|
DOCKER_CADDY_VERSION=2.11-alpine
|
||||||
# ARM64 spezifische JVM-Optionen (leer lassen auf x86/amd64, z.B. auf Apple Silicon)
|
# ARM64 spezifische JVM-Optionen (leer lassen auf x86/amd64, z.B. auf Apple Silicon)
|
||||||
# Beispiel ARM64: JVM_OPTS_ARM64=-XX:UseSVE=0
|
# Beispiel ARM64: JVM_OPTS_ARM64=-XX:UseSVE=0
|
||||||
|
|
@ -43,7 +41,7 @@ POSTGRES_DB_URL=jdbc:postgresql://postgres:5432/pg-meldestelle-db
|
||||||
POSTGRES_SHARED_BUFFERS=256MB
|
POSTGRES_SHARED_BUFFERS=256MB
|
||||||
POSTGRES_EFFECTIVE_CACHE_SIZE=768MB
|
POSTGRES_EFFECTIVE_CACHE_SIZE=768MB
|
||||||
|
|
||||||
# --- VALKEY (formerly Redis) ---
|
# --- VALKEY ---
|
||||||
VALKEY_IMAGE=valkey/valkey:9-alpine
|
VALKEY_IMAGE=valkey/valkey:9-alpine
|
||||||
VALKEY_PASSWORD=<SICHERES_PASSWORT>
|
VALKEY_PASSWORD=<SICHERES_PASSWORT>
|
||||||
VALKEY_PORT=6379:6379
|
VALKEY_PORT=6379:6379
|
||||||
|
|
|
||||||
|
|
@ -1,122 +1,123 @@
|
||||||
// Minimal debug worker
|
'use strict';
|
||||||
console.log("Worker: sqlite.worker.js loaded. Starting initialization...");
|
|
||||||
|
|
||||||
try {
|
// --- State ---
|
||||||
// We do NOT import from node_modules anymore to avoid Webpack bundling issues.
|
|
||||||
// import sqlite3InitModule from '@sqlite.org/sqlite-wasm';
|
|
||||||
|
|
||||||
// Message buffer for messages arriving before DB is ready
|
|
||||||
let messageQueue = [];
|
|
||||||
let db = null;
|
let db = null;
|
||||||
let isReady = false;
|
let isReady = false;
|
||||||
|
let initError = null;
|
||||||
|
const messageQueue = [];
|
||||||
|
|
||||||
// Minimal worker protocol compatible with SQLDelight's `web-worker-driver`.
|
// --- Message Handler ---
|
||||||
self.onmessage = (event) => {
|
self.onmessage = (event) => {
|
||||||
if (!isReady) {
|
if (!isReady) {
|
||||||
console.log("Worker: Buffering message (DB not ready)", event.data);
|
if (initError) {
|
||||||
|
postMessage({id: event.data?.id, error: `Worker not initialized: ${initError}`});
|
||||||
|
} else {
|
||||||
messageQueue.push(event);
|
messageQueue.push(event);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
processMessage(event);
|
processMessage(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.onerror = (event) => {
|
||||||
|
console.error('[sqlite.worker] Uncaught error:', event.message, `${event.filename}:${event.lineno}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- Message Processor ---
|
||||||
function processMessage(event) {
|
function processMessage(event) {
|
||||||
const data = event.data;
|
const data = event.data;
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (data && data.action) {
|
switch (data.action) {
|
||||||
case 'exec': {
|
case 'exec': {
|
||||||
if (!data.sql) throw new Error('exec: Missing query string');
|
if (!data.sql) throw new Error('exec: Missing sql string');
|
||||||
const rows = [];
|
const rows = [];
|
||||||
db.exec({
|
db.exec({
|
||||||
sql: data.sql,
|
sql: data.sql,
|
||||||
bind: data.params ?? [],
|
bind: data.params ?? [],
|
||||||
rowMode: 'array',
|
rowMode: 'array',
|
||||||
callback: (row) => rows.push(row)
|
callback: (row) => rows.push(row),
|
||||||
});
|
});
|
||||||
return postMessage({id: data.id, results: {values: rows}});
|
postMessage({id: data.id, results: {values: rows}});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case 'begin_transaction':
|
case 'begin_transaction':
|
||||||
db.exec('BEGIN TRANSACTION;');
|
db.exec('BEGIN TRANSACTION;');
|
||||||
return postMessage({id: data.id, results: []});
|
postMessage({id: data.id, results: []});
|
||||||
|
break;
|
||||||
case 'end_transaction':
|
case 'end_transaction':
|
||||||
db.exec('END TRANSACTION;');
|
db.exec('END TRANSACTION;');
|
||||||
return postMessage({id: data.id, results: []});
|
postMessage({id: data.id, results: []});
|
||||||
|
break;
|
||||||
case 'rollback_transaction':
|
case 'rollback_transaction':
|
||||||
db.exec('ROLLBACK TRANSACTION;');
|
db.exec('ROLLBACK TRANSACTION;');
|
||||||
return postMessage({id: data.id, results: []});
|
postMessage({id: data.id, results: []});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unsupported action: ${data && data.action}`);
|
throw new Error(`Unsupported action: ${data.action}`);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Worker: Error processing message", err);
|
console.error('[sqlite.worker] Error processing message:', err);
|
||||||
return postMessage({id: data && data.id, error: err?.message ?? String(err)});
|
postMessage({id: data.id, error: err?.message ?? String(err)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.onerror = function (event) {
|
// --- Initialization ---
|
||||||
console.error("Error in Web Worker (onerror):", event.message, event.filename, event.lineno);
|
|
||||||
// Don't postMessage here as it might confuse the driver if it expects a response to a query
|
|
||||||
};
|
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
try {
|
try {
|
||||||
// 1. Load the sqlite3.js library manually via importScripts.
|
// Load sqlite3.js via importScripts (avoids Webpack bundling issues)
|
||||||
console.log("Worker: Loading sqlite3.js via importScripts...");
|
|
||||||
try {
|
try {
|
||||||
importScripts('sqlite3.js');
|
importScripts('sqlite3.js');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Failed to importScripts('sqlite3.js'). Check if file exists at root. Error: " + e.message);
|
throw new Error(`importScripts('sqlite3.js') failed – is the file served at root? ${e.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof self.sqlite3InitModule !== 'function') {
|
if (typeof self.sqlite3InitModule !== 'function') {
|
||||||
throw new Error("sqlite3InitModule is not defined after importScripts. Check if sqlite3.js was loaded correctly.");
|
throw new Error('sqlite3InitModule not found after importScripts – sqlite3.js may be corrupt or wrong version.');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Worker: Fetching sqlite3.wasm manually...");
|
// Fetch WASM binary manually so we control the URL and can detect failures early
|
||||||
const response = await fetch('sqlite3.wasm');
|
const wasmResponse = await fetch('sqlite3.wasm');
|
||||||
if (!response.ok) {
|
if (!wasmResponse.ok) {
|
||||||
throw new Error(`Failed to fetch sqlite3.wasm: ${response.status} ${response.statusText}`);
|
throw new Error(`Failed to fetch sqlite3.wasm: ${wasmResponse.status} ${wasmResponse.statusText}`);
|
||||||
}
|
}
|
||||||
const wasmBinary = await response.arrayBuffer();
|
const wasmBinary = await wasmResponse.arrayBuffer();
|
||||||
console.log("Worker: sqlite3.wasm fetched successfully, size:", wasmBinary.byteLength);
|
|
||||||
|
|
||||||
console.log("Worker: Calling sqlite3InitModule with wasmBinary...");
|
|
||||||
const sqlite3 = await self.sqlite3InitModule({
|
const sqlite3 = await self.sqlite3InitModule({
|
||||||
print: console.log,
|
print: console.log,
|
||||||
printErr: console.error,
|
printErr: console.error,
|
||||||
wasmBinary: wasmBinary
|
wasmBinary,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Worker: sqlite3InitModule resolved successfully");
|
|
||||||
const opfsAvailable = 'opfs' in sqlite3;
|
const opfsAvailable = 'opfs' in sqlite3;
|
||||||
console.log("Worker: OPFS available:", opfsAvailable);
|
|
||||||
|
|
||||||
// Initialize DB
|
|
||||||
const dbName = 'app.db';
|
const dbName = 'app.db';
|
||||||
|
|
||||||
if (opfsAvailable) {
|
if (opfsAvailable) {
|
||||||
console.log("Initialisiere persistente OPFS Datenbank: " + dbName);
|
console.log(`[sqlite.worker] Using persistent OPFS database: ${dbName}`);
|
||||||
db = new sqlite3.oo1.OpfsDb(dbName);
|
db = new sqlite3.oo1.OpfsDb(dbName);
|
||||||
} else {
|
} else {
|
||||||
console.warn("OPFS nicht verfügbar, Fallback auf In-Memory");
|
console.warn('[sqlite.worker] OPFS not available – falling back to in-memory database');
|
||||||
db = new sqlite3.oo1.DB(dbName);
|
db = new sqlite3.oo1.DB(dbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark as ready and process queue
|
// Flush buffered messages
|
||||||
isReady = true;
|
isReady = true;
|
||||||
console.log("Worker: DB Ready. Processing " + messageQueue.length + " buffered messages.");
|
console.log(`[sqlite.worker] Ready. Flushing ${messageQueue.length} buffered message(s).`);
|
||||||
while (messageQueue.length > 0) {
|
while (messageQueue.length > 0) {
|
||||||
processMessage(messageQueue.shift());
|
processMessage(messageQueue.shift());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Database initialization error in worker:", e);
|
initError = e?.message ?? String(e);
|
||||||
// We can't easily communicate this back to the driver during init,
|
console.error('[sqlite.worker] Initialization failed:', e);
|
||||||
// but console.error should show up.
|
|
||||||
|
// Notify all buffered callers so they don't hang indefinitely
|
||||||
|
while (messageQueue.length > 0) {
|
||||||
|
const queued = messageQueue.shift();
|
||||||
|
postMessage({id: queued.data?.id, error: `Worker initialization failed: ${initError}`});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Critical Worker Error:", e);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package at.mocode.frontend.core.navigation
|
||||||
import at.mocode.frontend.core.domain.models.User
|
import at.mocode.frontend.core.domain.models.User
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstraction to obtain the current authenticated user (or null if guest).
|
* Abstraction to get the current authenticated user (or null if guest).
|
||||||
* Implementations live in shells/apps and provide access to the actual auth state.
|
* Implementations live in shells/apps and provide access to the actual auth state.
|
||||||
*/
|
*/
|
||||||
interface CurrentUserProvider {
|
interface CurrentUserProvider {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import at.mocode.frontend.core.domain.models.AppRoles
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deep link handling with minimal auth-aware guard via CurrentUserProvider.
|
* Deep link handling with minimal auth-aware guard via CurrentUserProvider.
|
||||||
* This version is self-contained in core:navigation and has no dependency on shared app store.
|
* This version is self-contained in core:navigation and has no dependency on the shared app store.
|
||||||
*/
|
*/
|
||||||
class DeepLinkHandler(
|
class DeepLinkHandler(
|
||||||
private val navigation: NavigationPort,
|
private val navigation: NavigationPort,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ actual object PlatformConfig {
|
||||||
return resolvedUrl
|
return resolvedUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3) Fallback to the local gateway directly (e.g. for tests without window)
|
// 3) Fallback to the local gateway directly (e.g., for tests without a window)
|
||||||
val fallbackUrl = "http://localhost:8081/api"
|
val fallbackUrl = "http://localhost:8081/api"
|
||||||
console.log("[PlatformConfig] Fallback API_BASE_URL: $fallbackUrl")
|
console.log("[PlatformConfig] Fallback API_BASE_URL: $fallbackUrl")
|
||||||
return fallbackUrl
|
return fallbackUrl
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ import kotlinx.coroutines.await
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
|
private val AppJson = Json { ignoreUnknownKeys = true }
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AppConfig(
|
data class AppConfig(
|
||||||
val apiBaseUrl: String,
|
val apiBaseUrl: String,
|
||||||
|
|
@ -18,7 +20,7 @@ suspend fun loadAppConfig(): AppConfig {
|
||||||
return fallbackFromGlobal()
|
return fallbackFromGlobal()
|
||||||
}
|
}
|
||||||
val text = response.text().await()
|
val text = response.text().await()
|
||||||
Json.decodeFromString(AppConfig.serializer(), text)
|
AppJson.decodeFromString(AppConfig.serializer(), text)
|
||||||
} catch (e: dynamic) {
|
} catch (e: dynamic) {
|
||||||
console.error("[Config] Error loading config:", e)
|
console.error("[Config] Error loading config:", e)
|
||||||
// Fallback: Caddy-injizierte Werte aus index.html (globalThis.API_BASE_URL / KEYCLOAK_URL)
|
// Fallback: Caddy-injizierte Werte aus index.html (globalThis.API_BASE_URL / KEYCLOAK_URL)
|
||||||
|
|
@ -28,10 +30,10 @@ suspend fun loadAppConfig(): AppConfig {
|
||||||
|
|
||||||
private fun fallbackFromGlobal(): AppConfig {
|
private fun fallbackFromGlobal(): AppConfig {
|
||||||
val apiBase = (js("globalThis.API_BASE_URL") as? String)
|
val apiBase = (js("globalThis.API_BASE_URL") as? String)
|
||||||
?.takeIf { it.isNotBlank() && !it.startsWith("\${") }
|
?.takeIf { it.isNotBlank() && !it.startsWith($$"${") }
|
||||||
?: window.location.origin
|
?: window.location.origin
|
||||||
val kcUrl = (js("globalThis.KEYCLOAK_URL") as? String)
|
val kcUrl = (js("globalThis.KEYCLOAK_URL") as? String)
|
||||||
?.takeIf { it.isNotBlank() && !it.startsWith("\${") }
|
?.takeIf { it.isNotBlank() && !it.startsWith($$"${") }
|
||||||
console.log("[Config] Fallback: apiBaseUrl=$apiBase, keycloakUrl=$kcUrl")
|
console.log("[Config] Fallback: apiBaseUrl=$apiBase, keycloakUrl=$kcUrl")
|
||||||
return AppConfig(apiBaseUrl = apiBase, keycloakUrl = kcUrl)
|
return AppConfig(apiBaseUrl = apiBase, keycloakUrl = kcUrl)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ fun main() {
|
||||||
val config = loadAppConfig()
|
val config = loadAppConfig()
|
||||||
console.log("[WebApp] Configuration loaded: apiBaseUrl=${config.apiBaseUrl}, keycloakUrl=${config.keycloakUrl}")
|
console.log("[WebApp] Configuration loaded: apiBaseUrl=${config.apiBaseUrl}, keycloakUrl=${config.keycloakUrl}")
|
||||||
|
|
||||||
// Inject config into global JS scope for PlatformConfig to find
|
// Inject config into the global JS scope for PlatformConfig to find
|
||||||
val global = js("typeof globalThis !== 'undefined' ? globalThis : window")
|
val global = js("typeof globalThis !== 'undefined' ? globalThis : window")
|
||||||
global.API_BASE_URL = config.apiBaseUrl
|
global.API_BASE_URL = config.apiBaseUrl
|
||||||
config.keycloakUrl?.let { global.KEYCLOAK_URL = it }
|
config.keycloakUrl?.let { global.KEYCLOAK_URL = it }
|
||||||
|
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
// Minimal debug worker
|
|
||||||
console.log("Worker: sqlite.worker.js loaded. Starting initialization...");
|
|
||||||
|
|
||||||
try {
|
|
||||||
// We do NOT import from node_modules anymore to avoid Webpack bundling issues.
|
|
||||||
// import sqlite3InitModule from '@sqlite.org/sqlite-wasm';
|
|
||||||
|
|
||||||
// Message buffer for messages arriving before DB is ready
|
|
||||||
let messageQueue = [];
|
|
||||||
let db = null;
|
|
||||||
let isReady = false;
|
|
||||||
|
|
||||||
// Minimal worker protocol compatible with SQLDelight's `web-worker-driver`.
|
|
||||||
self.onmessage = (event) => {
|
|
||||||
if (!isReady) {
|
|
||||||
console.log("Worker: Buffering message (DB not ready)", event.data);
|
|
||||||
messageQueue.push(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
processMessage(event);
|
|
||||||
};
|
|
||||||
|
|
||||||
function processMessage(event) {
|
|
||||||
const data = event.data;
|
|
||||||
try {
|
|
||||||
switch (data && data.action) {
|
|
||||||
case 'exec': {
|
|
||||||
if (!data.sql) throw new Error('exec: Missing query string');
|
|
||||||
const rows = [];
|
|
||||||
db.exec({
|
|
||||||
sql: data.sql,
|
|
||||||
bind: data.params ?? [],
|
|
||||||
rowMode: 'array',
|
|
||||||
callback: (row) => rows.push(row)
|
|
||||||
});
|
|
||||||
return postMessage({ id: data.id, results: { values: rows } });
|
|
||||||
}
|
|
||||||
case 'begin_transaction':
|
|
||||||
db.exec('BEGIN TRANSACTION;');
|
|
||||||
return postMessage({ id: data.id, results: [] });
|
|
||||||
case 'end_transaction':
|
|
||||||
db.exec('END TRANSACTION;');
|
|
||||||
return postMessage({ id: data.id, results: [] });
|
|
||||||
case 'rollback_transaction':
|
|
||||||
db.exec('ROLLBACK TRANSACTION;');
|
|
||||||
return postMessage({ id: data.id, results: [] });
|
|
||||||
default:
|
|
||||||
throw new Error(`Unsupported action: ${data && data.action}`);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Worker: Error processing message", err);
|
|
||||||
return postMessage({ id: data && data.id, error: err?.message ?? String(err) });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.onerror = function(event) {
|
|
||||||
console.error("Error in Web Worker (onerror):", event.message, event.filename, event.lineno);
|
|
||||||
// Don't postMessage here as it might confuse the driver if it expects a response to a query
|
|
||||||
};
|
|
||||||
|
|
||||||
async function init() {
|
|
||||||
try {
|
|
||||||
// 1. Load the sqlite3.js library manually via importScripts.
|
|
||||||
console.log("Worker: Loading sqlite3.js via importScripts...");
|
|
||||||
try {
|
|
||||||
importScripts('sqlite3.js');
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error("Failed to importScripts('sqlite3.js'). Check if file exists at root. Error: " + e.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof self.sqlite3InitModule !== 'function') {
|
|
||||||
throw new Error("sqlite3InitModule is not defined after importScripts. Check if sqlite3.js was loaded correctly.");
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Worker: Fetching sqlite3.wasm manually...");
|
|
||||||
const response = await fetch('sqlite3.wasm');
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch sqlite3.wasm: ${response.status} ${response.statusText}`);
|
|
||||||
}
|
|
||||||
const wasmBinary = await response.arrayBuffer();
|
|
||||||
console.log("Worker: sqlite3.wasm fetched successfully, size:", wasmBinary.byteLength);
|
|
||||||
|
|
||||||
console.log("Worker: Calling sqlite3InitModule with wasmBinary...");
|
|
||||||
const sqlite3 = await self.sqlite3InitModule({
|
|
||||||
print: console.log,
|
|
||||||
printErr: console.error,
|
|
||||||
wasmBinary: wasmBinary
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("Worker: sqlite3InitModule resolved successfully");
|
|
||||||
const opfsAvailable = 'opfs' in sqlite3;
|
|
||||||
console.log("Worker: OPFS available:", opfsAvailable);
|
|
||||||
|
|
||||||
// Initialize DB
|
|
||||||
const dbName = 'app.db';
|
|
||||||
if (opfsAvailable) {
|
|
||||||
console.log("Initialisiere persistente OPFS Datenbank: " + dbName);
|
|
||||||
db = new sqlite3.oo1.OpfsDb(dbName);
|
|
||||||
} else {
|
|
||||||
console.warn("OPFS nicht verfügbar, Fallback auf In-Memory");
|
|
||||||
db = new sqlite3.oo1.DB(dbName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark as ready and process queue
|
|
||||||
isReady = true;
|
|
||||||
console.log("Worker: DB Ready. Processing " + messageQueue.length + " buffered messages.");
|
|
||||||
while (messageQueue.length > 0) {
|
|
||||||
processMessage(messageQueue.shift());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Database initialization error in worker:", e);
|
|
||||||
// We can't easily communicate this back to the driver during init,
|
|
||||||
// but console.error should show up.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Critical Worker Error:", e);
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const IS_DEV = self.location.hostname === 'localhost' || self.location.hostname === '127.0.0.1' || self.location.hostname === '::1';
|
const IS_DEV = self.location.hostname === 'localhost' || self.location.hostname === '127.0.0.1' || self.location.hostname === '::1';
|
||||||
|
|
||||||
const CACHE_NAME = 'meldestelle-cache-v2';
|
const CACHE_NAME = 'meldestelle-cache-v3';
|
||||||
const PRECACHE_URLS = [
|
const PRECACHE_URLS = [
|
||||||
'/',
|
'/',
|
||||||
'/index.html',
|
'/index.html',
|
||||||
|
|
@ -10,7 +10,8 @@ const PRECACHE_URLS = [
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event) => {
|
||||||
if (IS_DEV) {
|
if (IS_DEV) {
|
||||||
// In dev, don't precache. Just activate the SW immediately.
|
// In dev, don't precache. Just activate the SW immediately.
|
||||||
self.skipWaiting();
|
self.skipWaiting().then(_ => {
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
|
|
@ -74,6 +75,12 @@ self.addEventListener('fetch', (event) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// App-Bundle immer vom Netzwerk – niemals aus dem Cache (verhindert veraltete JS-Versionen)
|
||||||
|
if (url.pathname.endsWith('web-app.js') || url.pathname.endsWith('web-app.js.map')) {
|
||||||
|
event.respondWith(fetch(req));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid noisy errors for favicon during dev/prod when missing
|
// Avoid noisy errors for favicon during dev/prod when missing
|
||||||
if (url.pathname === '/favicon.ico') {
|
if (url.pathname === '/favicon.ico') {
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
// Dummy module to satisfy WASI imports in Webpack
|
|
||||||
// Used for skiko.wasm and potentially others
|
|
||||||
|
|
||||||
export function abort() {
|
|
||||||
console.error("WASI abort called");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some WASM modules might look for these
|
|
||||||
export function emscripten_notify_memory_growth() {
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
abort,
|
|
||||||
emscripten_notify_memory_growth
|
|
||||||
};
|
|
||||||
Loading…
Reference in New Issue
Block a user