@swimmesberger/elarion-pwa 0.0.0 → 0.2.11-preview.165.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -60
- package/package.json +62 -62
package/README.md
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
# @swimmesberger/elarion-pwa
|
|
2
|
-
|
|
3
|
-
The installable-app shell for Elarion frontends — what turns "Add to Home Screen" into an app that opens offline,
|
|
4
|
-
loads its assets from the cache, and moves to a new deploy without throwing away what the user was typing. Guide:
|
|
5
|
-
[Installable apps (PWA)](https://elarion.wimmesberger.dev/docs/capabilities/pwa).
|
|
6
|
-
|
|
7
|
-
- **Install** — `createInstallPrompt()` captures Chromium's `beforeinstallprompt` and reports `availability()`:
|
|
8
|
-
`'prompt' | 'ios' | 'none'` (`ios` = show the "Share → Add to Home Screen" instructions). `isStandalone()`,
|
|
9
|
-
`isAppleTouchDevice()` and the pure `installOption()` are exported too.
|
|
10
|
-
- **Updates** — `createUpdateWatcher({ currentVersion })` asks the server which web build is live when the app returns
|
|
11
|
-
to the foreground and reloads into a new one **on the next navigation that changed the path**, never on the
|
|
12
|
-
foreground return itself, never while a dialog is open or a field is focused, at most once a minute.
|
|
13
|
-
- **Registration** — `registerServiceWorker('/sw.js')` with `updateViaCache: 'none'`; resolves `null` instead of
|
|
14
|
-
throwing where there is no service worker.
|
|
15
|
-
- **`/sw`** — `registerShellRouter(self, …)`: network-only or network-first navigations, cache-first hashed assets,
|
|
16
|
-
stale-while-revalidate icons and manifest; never touches the API (`ELARION_SERVER_PREFIXES`), non-GET, cross-origin
|
|
17
|
-
or `no-store` requests, and never stores a redirected, opaque, partial, `no-store`, or (outside the shell) HTML answer.
|
|
18
|
-
Composes with `registerWebPushHandlers(self)` from `@swimmesberger/elarion-webpush/sw` in the same worker.
|
|
19
|
-
- **`/vite`** — `appVersionFile({ version, define })` emits `/app-version.json` and bakes the same version into the
|
|
20
|
-
bundle.
|
|
21
|
-
|
|
22
|
-
## Page
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
import { createInstallPrompt, createUpdateWatcher, registerServiceWorker } from '@swimmesberger/elarion-pwa'
|
|
26
|
-
|
|
27
|
-
if (import.meta.env.PROD) void registerServiceWorker('/sw.js')
|
|
28
|
-
|
|
29
|
-
export const install = createInstallPrompt() // at module load: the prompt event fires early
|
|
30
|
-
|
|
31
|
-
export const updates = createUpdateWatcher({ currentVersion: __APP_VERSION__, enabled: import.meta.env.PROD })
|
|
32
|
-
router.subscribe('onResolved', (event) => updates.navigationResolved({ pathChanged: event.pathChanged }))
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Service worker
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import { ELARION_SERVER_PREFIXES, registerShellRouter } from '@swimmesberger/elarion-pwa/sw'
|
|
39
|
-
import { registerWebPushHandlers } from '@swimmesberger/elarion-webpush/sw'
|
|
40
|
-
|
|
41
|
-
registerShellRouter(self, {
|
|
42
|
-
cacheName: 'myapp-v1',
|
|
43
|
-
serverPrefixes: [...ELARION_SERVER_PREFIXES, '/auth'],
|
|
44
|
-
navigation: { mode: 'network-only', offlineUrl: '/offline.html' }, // or { mode: 'network-first' } for an SPA shell
|
|
45
|
-
staticFiles: ['/manifest.webmanifest', '/icon-192.png', '/icon-512.png', '/apple-touch-icon.png'],
|
|
46
|
-
})
|
|
47
|
-
registerWebPushHandlers(self, { icon: '/icon-192.png' })
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
The module is ESM: bundle the worker into one classic script served at `/sw.js` (for example a second
|
|
51
|
-
`vite build` with `build.lib.formats: ['iife']`), or register it with `{ type: 'module' }`.
|
|
52
|
-
|
|
53
|
-
## Vite
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
import { appVersionFile } from '@swimmesberger/elarion-pwa/vite'
|
|
57
|
-
|
|
58
|
-
const version = process.env.APP_VERSION?.trim() || 'dev'
|
|
59
|
-
export default defineConfig({ plugins: [appVersionFile({ version, define: '__APP_VERSION__' })] })
|
|
60
|
-
```
|
|
1
|
+
# @swimmesberger/elarion-pwa
|
|
2
|
+
|
|
3
|
+
The installable-app shell for Elarion frontends — what turns "Add to Home Screen" into an app that opens offline,
|
|
4
|
+
loads its assets from the cache, and moves to a new deploy without throwing away what the user was typing. Guide:
|
|
5
|
+
[Installable apps (PWA)](https://elarion.wimmesberger.dev/docs/capabilities/pwa).
|
|
6
|
+
|
|
7
|
+
- **Install** — `createInstallPrompt()` captures Chromium's `beforeinstallprompt` and reports `availability()`:
|
|
8
|
+
`'prompt' | 'ios' | 'none'` (`ios` = show the "Share → Add to Home Screen" instructions). `isStandalone()`,
|
|
9
|
+
`isAppleTouchDevice()` and the pure `installOption()` are exported too.
|
|
10
|
+
- **Updates** — `createUpdateWatcher({ currentVersion })` asks the server which web build is live when the app returns
|
|
11
|
+
to the foreground and reloads into a new one **on the next navigation that changed the path**, never on the
|
|
12
|
+
foreground return itself, never while a dialog is open or a field is focused, at most once a minute.
|
|
13
|
+
- **Registration** — `registerServiceWorker('/sw.js')` with `updateViaCache: 'none'`; resolves `null` instead of
|
|
14
|
+
throwing where there is no service worker.
|
|
15
|
+
- **`/sw`** — `registerShellRouter(self, …)`: network-only or network-first navigations, cache-first hashed assets,
|
|
16
|
+
stale-while-revalidate icons and manifest; never touches the API (`ELARION_SERVER_PREFIXES`), non-GET, cross-origin
|
|
17
|
+
or `no-store` requests, and never stores a redirected, opaque, partial, `no-store`, or (outside the shell) HTML answer.
|
|
18
|
+
Composes with `registerWebPushHandlers(self)` from `@swimmesberger/elarion-webpush/sw` in the same worker.
|
|
19
|
+
- **`/vite`** — `appVersionFile({ version, define })` emits `/app-version.json` and bakes the same version into the
|
|
20
|
+
bundle.
|
|
21
|
+
|
|
22
|
+
## Page
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createInstallPrompt, createUpdateWatcher, registerServiceWorker } from '@swimmesberger/elarion-pwa'
|
|
26
|
+
|
|
27
|
+
if (import.meta.env.PROD) void registerServiceWorker('/sw.js')
|
|
28
|
+
|
|
29
|
+
export const install = createInstallPrompt() // at module load: the prompt event fires early
|
|
30
|
+
|
|
31
|
+
export const updates = createUpdateWatcher({ currentVersion: __APP_VERSION__, enabled: import.meta.env.PROD })
|
|
32
|
+
router.subscribe('onResolved', (event) => updates.navigationResolved({ pathChanged: event.pathChanged }))
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Service worker
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { ELARION_SERVER_PREFIXES, registerShellRouter } from '@swimmesberger/elarion-pwa/sw'
|
|
39
|
+
import { registerWebPushHandlers } from '@swimmesberger/elarion-webpush/sw'
|
|
40
|
+
|
|
41
|
+
registerShellRouter(self, {
|
|
42
|
+
cacheName: 'myapp-v1',
|
|
43
|
+
serverPrefixes: [...ELARION_SERVER_PREFIXES, '/auth'],
|
|
44
|
+
navigation: { mode: 'network-only', offlineUrl: '/offline.html' }, // or { mode: 'network-first' } for an SPA shell
|
|
45
|
+
staticFiles: ['/manifest.webmanifest', '/icon-192.png', '/icon-512.png', '/apple-touch-icon.png'],
|
|
46
|
+
})
|
|
47
|
+
registerWebPushHandlers(self, { icon: '/icon-192.png' })
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The module is ESM: bundle the worker into one classic script served at `/sw.js` (for example a second
|
|
51
|
+
`vite build` with `build.lib.formats: ['iife']`), or register it with `{ type: 'module' }`.
|
|
52
|
+
|
|
53
|
+
## Vite
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { appVersionFile } from '@swimmesberger/elarion-pwa/vite'
|
|
57
|
+
|
|
58
|
+
const version = process.env.APP_VERSION?.trim() || 'dev'
|
|
59
|
+
export default defineConfig({ plugins: [appVersionFile({ version, define: '__APP_VERSION__' })] })
|
|
60
|
+
```
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@swimmesberger/elarion-pwa",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The installable-app shell for Elarion frontends: install-prompt capture with iOS Home Screen instructions, a deploy-update watcher that reloads only on a safe page change, service-worker registration, a /sw module whose shell router never caches the API, HTML, redirects, or no-store answers, and a /vite plugin that publishes the build version.",
|
|
5
|
-
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"import": "./dist/index.js"
|
|
11
|
-
},
|
|
12
|
-
"./sw": {
|
|
13
|
-
"types": "./dist/sw.d.ts",
|
|
14
|
-
"import": "./dist/sw.js"
|
|
15
|
-
},
|
|
16
|
-
"./vite": {
|
|
17
|
-
"types": "./dist/vite.d.ts",
|
|
18
|
-
"import": "./dist/vite.js"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist",
|
|
23
|
-
"README.md"
|
|
24
|
-
],
|
|
25
|
-
"sideEffects": false,
|
|
26
|
-
"scripts": {
|
|
27
|
-
"build": "tsc -p tsconfig.json",
|
|
28
|
-
"typecheck": "tsc --noEmit -p tsconfig.test.json && tsc --noEmit -p tsconfig.sw-test.json",
|
|
29
|
-
"test": "npm run typecheck && vitest run",
|
|
30
|
-
"prepack": "npm run build",
|
|
31
|
-
"prepare": "npm run build"
|
|
32
|
-
},
|
|
33
|
-
"repository": {
|
|
34
|
-
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/swimmesberger/Elarion.git",
|
|
36
|
-
"directory": "src/elarion-pwa"
|
|
37
|
-
},
|
|
38
|
-
"bugs": {
|
|
39
|
-
"url": "https://github.com/swimmesberger/Elarion/issues"
|
|
40
|
-
},
|
|
41
|
-
"homepage": "https://github.com/swimmesberger/Elarion#readme",
|
|
42
|
-
"publishConfig": {
|
|
43
|
-
"access": "public",
|
|
44
|
-
"registry": "https://registry.npmjs.org/"
|
|
45
|
-
},
|
|
46
|
-
"engines": {
|
|
47
|
-
"node": ">=20.11"
|
|
48
|
-
},
|
|
49
|
-
"peerDependencies": {
|
|
50
|
-
"vite": ">=5"
|
|
51
|
-
},
|
|
52
|
-
"peerDependenciesMeta": {
|
|
53
|
-
"vite": {
|
|
54
|
-
"optional": true
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"devDependencies": {
|
|
58
|
-
"typescript": "^6.0.3",
|
|
59
|
-
"vite": "^8.3.1",
|
|
60
|
-
"vitest": "^5.0.2"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@swimmesberger/elarion-pwa",
|
|
3
|
+
"version": "0.2.11-preview.165.3",
|
|
4
|
+
"description": "The installable-app shell for Elarion frontends: install-prompt capture with iOS Home Screen instructions, a deploy-update watcher that reloads only on a safe page change, service-worker registration, a /sw module whose shell router never caches the API, HTML, redirects, or no-store answers, and a /vite plugin that publishes the build version.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./sw": {
|
|
13
|
+
"types": "./dist/sw.d.ts",
|
|
14
|
+
"import": "./dist/sw.js"
|
|
15
|
+
},
|
|
16
|
+
"./vite": {
|
|
17
|
+
"types": "./dist/vite.d.ts",
|
|
18
|
+
"import": "./dist/vite.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.json",
|
|
28
|
+
"typecheck": "tsc --noEmit -p tsconfig.test.json && tsc --noEmit -p tsconfig.sw-test.json",
|
|
29
|
+
"test": "npm run typecheck && vitest run",
|
|
30
|
+
"prepack": "npm run build",
|
|
31
|
+
"prepare": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/swimmesberger/Elarion.git",
|
|
36
|
+
"directory": "src/elarion-pwa"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/swimmesberger/Elarion/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/swimmesberger/Elarion#readme",
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"registry": "https://registry.npmjs.org/"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20.11"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"vite": ">=5"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"vite": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"typescript": "^6.0.3",
|
|
59
|
+
"vite": "^8.3.1",
|
|
60
|
+
"vitest": "^5.0.2"
|
|
61
|
+
}
|
|
62
|
+
}
|