Rename service worker runtime and scope route persistence

This commit is contained in:
Amer Agovic
2026-05-11 13:51:47 -05:00
parent f5a739ee35
commit 6fe23fae86
5 changed files with 87 additions and 107 deletions
+7 -8
View File
@@ -29,7 +29,7 @@ The library provides an `App` component that manages the application shell, rout
```jsx
import { App } from '@reliancy/bface/ui/App';
import { CONFIG_KEYS } from '@reliancy/bface/platform/env';
import { registerServiceWorker } from '@reliancy/bface/platform/sw-register';
import { sw } from '@reliancy/bface/platform/worker';
async function handleInit(services, { initialProfile } = {}) {
// Application profile (camelCase or snake_case field names are accepted where noted in env mapping)
@@ -49,7 +49,7 @@ async function handleInit(services, { initialProfile } = {}) {
// await loadModule(moduleName, services);
}
await registerServiceWorker();
await sw.registerServiceWorker();
return profile;
}
@@ -65,12 +65,11 @@ function MyApp() {
- **`services.api_client`** — HTTP client (`get`, `post`, …)
- **`services.storage`** — storage module (`getProvider`, …)
- **`services.api_router`** — placeholder for service-worker API routing (when available)
- **`services.ui_router`** — UI routing helpers
- **`services.menu`** — menu registration and queries
- **`services.env`** — `initEnv`, `getConfig`, `setConfig`, `CONFIG_KEYS`, tracing helpers, etc.
Service worker registration is **not** on `services`; import `registerServiceWorker` from `@reliancy/bface/platform/sw-register` (or the package root) and call it from `onInit` when you are ready.
Service worker registration is **not** on `services`; import `sw` from `@reliancy/bface/platform/worker` (or the package root) and call `sw.registerServiceWorker()` from `onInit` when you are ready. Service-worker API interception belongs in app/module `sw.js` files that run inside the worker.
```jsx
async function handleInit(services) {
@@ -138,7 +137,7 @@ const menuItems = queryMenuItems('/primary');
### Exports (`package.json` → `exports`)
- **`@reliancy/bface`** — main entry: platform, `App`, UI components index, general settings, security, and data helpers
- **`@reliancy/bface/platform/*`** — platform modules (`env`, `api`, `storage`, `menu`, `sw-register`, `compat`, `host`, …)
- **`@reliancy/bface/platform/*`** — platform modules (`env`, `api`, `storage`, `menu`, `worker`, `compat`, `host`, …)
- **`@reliancy/bface/ui/*`** — UI entry points such as `App` and `components`
Security and data types are re-exported from the root entry; there are no separate `exports` subpaths for `./security/*` or `./data/*` today—import them from `@reliancy/bface` or add deep links if your bundler resolves source.
@@ -149,7 +148,7 @@ Security and data types are re-exported from the root entry; there are no separa
- **`platform/api.js`** — API client
- **`platform/storage.js`** — storage abstraction (localStorage, IndexedDB, OPFS)
- **`platform/menu.js`** — menu model and queries
- **`platform/sw-register.js`** — service worker registration and cache helpers
- **`platform/worker.js`** — browser worker/runtime helpers, currently exposed through the `sw` namespace
- **`platform/compat.js`** — environment detection and compatibility
- **`platform/host.js`** — host detection (e.g. Electron)
@@ -195,7 +194,7 @@ Here's a complete example of using the library in a project:
// app.jsx
import { App } from '@reliancy/bface/ui/App';
import { CONFIG_KEYS } from '@reliancy/bface/platform/env';
import { registerServiceWorker } from '@reliancy/bface/platform/sw-register';
import { sw } from '@reliancy/bface/platform/worker';
async function loadProfile() {
// Load your app profile (from JSON, API, etc.)
@@ -225,7 +224,7 @@ async function handleInit(services, { initialProfile } = {}) {
}
// 4. Register service worker
await registerServiceWorker();
await sw.registerServiceWorker();
return profile;
}