Rename service worker runtime and scope route persistence
This commit is contained in:
+8
-30
@@ -7,12 +7,8 @@
|
||||
import React, { createContext, useContext, useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
||||
import { TamaguiProvider, Theme, createTamagui, YStack } from 'tamagui';
|
||||
import {
|
||||
clearPWACache,
|
||||
clearAllCaches,
|
||||
clearAllStorage,
|
||||
getServiceWorkerStatus,
|
||||
unregisterAllServiceWorkers
|
||||
} from '../platform/sw-register.js';
|
||||
sw
|
||||
} from '../platform/worker.js';
|
||||
import { getProvider } from '../platform/storage.js';
|
||||
import * as apiClient from '../platform/api.js';
|
||||
import * as storageModuleRef from '../platform/storage.js';
|
||||
@@ -215,27 +211,9 @@ function App({
|
||||
console.warn('[App] Failed to import Router module:', error);
|
||||
}
|
||||
|
||||
// Get API router from service worker (if available)
|
||||
let api_router = null;
|
||||
if (typeof window !== 'undefined' && 'serviceWorker' in navigator) {
|
||||
// API Router is in service worker, modules will register via message passing
|
||||
// or we expose a registration function
|
||||
api_router = {
|
||||
register: (path, handler) => {
|
||||
// Register endpoint in SW router
|
||||
// Note: For now, we'll need to handle this differently since
|
||||
// functions can't be serialized. Modules should register routes
|
||||
// in their routes.js files which get loaded into the SW.
|
||||
console.log(`[API Router] Register endpoint: ${path}`);
|
||||
// TODO: Implement proper SW router registration
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
api_client: apiClient.api, // Renamed from api
|
||||
storage: storageModuleRef,
|
||||
api_router,
|
||||
ui_router,
|
||||
menu: menuRef,
|
||||
env: envModuleRef // New service
|
||||
@@ -313,7 +291,7 @@ function App({
|
||||
appLogger.warn('Menu service not available');
|
||||
}
|
||||
|
||||
setSwStatus(await getServiceWorkerStatus());
|
||||
setSwStatus(await sw.getServiceWorkerStatus());
|
||||
|
||||
setInitialized(true);
|
||||
initTrace.end({
|
||||
@@ -533,12 +511,12 @@ export { useApp, useTheme, THEME_MODES, themeManager as ThemeManager };
|
||||
|
||||
// Expose PWA utilities globally for console access
|
||||
if (typeof window !== 'undefined') {
|
||||
window.clearPWACache = clearPWACache;
|
||||
window.clearPWACache = sw.clearPWACache;
|
||||
window.__PWA_UTILS__ = {
|
||||
clearPWACache,
|
||||
clearAllCaches,
|
||||
unregisterAllServiceWorkers,
|
||||
clearAllStorage
|
||||
clearPWACache: sw.clearPWACache,
|
||||
clearAllCaches: sw.clearAllCaches,
|
||||
unregisterAllServiceWorkers: sw.unregisterAllServiceWorkers,
|
||||
clearAllStorage: sw.clearAllStorage
|
||||
};
|
||||
|
||||
console.log('💡 PWA Utilities available:');
|
||||
|
||||
Reference in New Issue
Block a user