@uppercut-labs/app-shell-service-worker 0.0.0-stage → 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Uppercut Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,77 @@
1
- # Temporary Holding Version
1
+ # @uppercut-labs/app-shell-service-worker
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Generates the source of a service worker that precaches an app shell. The worker removes old caches when it activates, serves a cached page when a navigation cannot reach the network, caches other same-origin files, and leaves cross-origin, non-GET and bypassed requests to the browser. Use it as a function in a build script or as a command.
4
+
5
+ ```sh
6
+ npm install --save-dev @uppercut-labs/app-shell-service-worker
7
+ ```
8
+
9
+ ```ts
10
+ import { writeFileSync } from 'node:fs';
11
+ import { generateServiceWorker } from '@uppercut-labs/app-shell-service-worker';
12
+
13
+ writeFileSync(
14
+ 'dist/sw.js',
15
+ generateServiceWorker({
16
+ cacheName: 'my-app',
17
+ version: '12',
18
+ precache: ['/', '/app.js', '/styles.css', '/manifest.webmanifest'],
19
+ bypassPrefixes: ['/api/'],
20
+ skipWaiting: 'message',
21
+ }),
22
+ );
23
+ ```
24
+
25
+ Command line:
26
+
27
+ ```sh
28
+ npx app-shell-service-worker --cache-name my-app --version 12 \
29
+ --precache /,/app.js,/styles.css --bypass-prefix /api/ --out dist/sw.js
30
+ ```
31
+
32
+ The worker must be served from the origin root (or the scope you register it with), so write it into your public output folder.
33
+
34
+ ## generateServiceWorker(options)
35
+
36
+ Returns the script as a string. Throws `ShellServiceWorkerError` when an option is invalid.
37
+
38
+ | Option | Default | Meaning |
39
+ | --- | --- | --- |
40
+ | `cacheName` | required | Base name of the cache |
41
+ | `version` | none | Appended as `name-version`; change it to ship a fresh shell |
42
+ | `precache` | `[]` | URLs stored at install. If one fails, the install fails and the old worker stays |
43
+ | `navigationFallback` | `/` | Cached page served when a navigation cannot reach the network |
44
+ | `navigationStrategy` | `network-first` | `network-first` returns whatever the network answers, even a 404, and uses the cache only on a network error. `cache-first` serves the cached page first |
45
+ | `assetStrategy` | `cache-first` | For other same-origin GET requests: `cache-first`, or `network-first` with cache fallback |
46
+ | `bypassPrefixes` | `[]` | Paths starting with these are left to the browser, such as `/api/` |
47
+ | `bypassAuthorized` | `true` | Leave requests with an `Authorization` header to the browser |
48
+ | `navigationAllowlist` | none | When set, only navigations to exactly these paths are handled |
49
+ | `ignoreSearch` | `true` | Match cached responses without the query string |
50
+ | `runtimeCache` | `true` | Store successful responses fetched at runtime |
51
+ | `runtimeDestinations` | none | When set, store runtime responses only for these request destinations, such as `script`, `style`, `image`, `font` |
52
+ | `cleanup` | `prefix` | On activate, delete other caches whose name starts with `cleanupPrefix` (`prefix`), or every other cache (`all`) |
53
+ | `cleanupPrefix` | `cacheName` | Prefix used by `cleanup: 'prefix'` |
54
+ | `skipWaiting` | `immediate` | `immediate`: take over as soon as installed. `message`: wait for the page to post `{ type: 'SKIP_WAITING' }` |
55
+
56
+ When the network fails and nothing is cached, the worker answers `503` with the text `Offline`.
57
+
58
+ ## Command line
59
+
60
+ `app-shell-service-worker [options]` prints the script to standard output, or to `--out <file>`. Options can come from a JSON file with `--config <file>` using the same names as the function; flags override the file.
61
+
62
+ | Flag | Option |
63
+ | --- | --- |
64
+ | `--cache-name`, `--version` | `cacheName`, `version` |
65
+ | `--precache <url>[,<url>...]` | `precache` (repeatable) |
66
+ | `--navigation-fallback`, `--navigation-strategy`, `--asset-strategy` | the options of the same name |
67
+ | `--bypass-prefix <path>` | `bypassPrefixes` (repeatable) |
68
+ | `--allow-navigation <path>` | `navigationAllowlist` (repeatable) |
69
+ | `--runtime-destination <kind>` | `runtimeDestinations` (repeatable) |
70
+ | `--cleanup`, `--cleanup-prefix`, `--skip-waiting` | the options of the same name |
71
+ | `--no-ignore-search`, `--no-runtime-cache`, `--no-bypass-authorized` | set that option to `false` |
72
+
73
+ Exit codes: `0` success, `1` invalid options or an unreadable config file, `2` unknown flag or missing value.
74
+
75
+ ## License
76
+
77
+ MIT
@@ -0,0 +1,9 @@
1
+ export interface CliIo {
2
+ readFile(path: string): string;
3
+ writeFile(path: string, content: string): void;
4
+ stdout(text: string): void;
5
+ stderr(text: string): void;
6
+ }
7
+ export declare const HELP = "Usage: app-shell-service-worker [options]\n\nGenerates a service worker script. Options from --config are overridden by flags.\n\n --config <file> JSON file with the options (same names as the function)\n --out <file> Write the script here instead of stdout\n --cache-name <name>\n --version <value>\n --precache <url>[,<url>...] Repeatable\n --navigation-fallback <url>\n --navigation-strategy <network-first|cache-first>\n --asset-strategy <cache-first|network-first>\n --bypass-prefix <path> Repeatable\n --allow-navigation <path> Repeatable; only these paths are handled\n --runtime-destination <kind> Repeatable (script, style, image, font, ...)\n --cleanup <prefix|all>\n --cleanup-prefix <prefix>\n --skip-waiting <immediate|message>\n --no-ignore-search\n --no-runtime-cache\n --no-bypass-authorized\n -h, --help\n";
8
+ /** Runs the command line. Returns the process exit code: 0 on success, 1 on bad input, 2 on usage errors. */
9
+ export declare function runCli(argv: string[], io: CliIo): number;
@@ -0,0 +1,104 @@
1
+ import { generateServiceWorker, ShellServiceWorkerError } from './generate.js';
2
+ export const HELP = `Usage: app-shell-service-worker [options]
3
+
4
+ Generates a service worker script. Options from --config are overridden by flags.
5
+
6
+ --config <file> JSON file with the options (same names as the function)
7
+ --out <file> Write the script here instead of stdout
8
+ --cache-name <name>
9
+ --version <value>
10
+ --precache <url>[,<url>...] Repeatable
11
+ --navigation-fallback <url>
12
+ --navigation-strategy <network-first|cache-first>
13
+ --asset-strategy <cache-first|network-first>
14
+ --bypass-prefix <path> Repeatable
15
+ --allow-navigation <path> Repeatable; only these paths are handled
16
+ --runtime-destination <kind> Repeatable (script, style, image, font, ...)
17
+ --cleanup <prefix|all>
18
+ --cleanup-prefix <prefix>
19
+ --skip-waiting <immediate|message>
20
+ --no-ignore-search
21
+ --no-runtime-cache
22
+ --no-bypass-authorized
23
+ -h, --help
24
+ `;
25
+ const VALUE_FLAGS = {
26
+ '--config': 'config',
27
+ '--out': 'out',
28
+ '--cache-name': 'cacheName',
29
+ '--version': 'version',
30
+ '--precache': 'precache',
31
+ '--navigation-fallback': 'navigationFallback',
32
+ '--navigation-strategy': 'navigationStrategy',
33
+ '--asset-strategy': 'assetStrategy',
34
+ '--bypass-prefix': 'bypassPrefixes',
35
+ '--allow-navigation': 'navigationAllowlist',
36
+ '--runtime-destination': 'runtimeDestinations',
37
+ '--cleanup': 'cleanup',
38
+ '--cleanup-prefix': 'cleanupPrefix',
39
+ '--skip-waiting': 'skipWaiting',
40
+ };
41
+ const LIST_FLAGS = new Set(['precache', 'bypassPrefixes', 'navigationAllowlist', 'runtimeDestinations']);
42
+ const NEGATIVE_FLAGS = {
43
+ '--no-ignore-search': 'ignoreSearch',
44
+ '--no-runtime-cache': 'runtimeCache',
45
+ '--no-bypass-authorized': 'bypassAuthorized',
46
+ };
47
+ /** Runs the command line. Returns the process exit code: 0 on success, 1 on bad input, 2 on usage errors. */
48
+ export function runCli(argv, io) {
49
+ const flags = {};
50
+ let config;
51
+ let out;
52
+ for (let i = 0; i < argv.length; i += 1) {
53
+ const arg = argv[i];
54
+ if (arg === '-h' || arg === '--help') {
55
+ io.stdout(HELP);
56
+ return 0;
57
+ }
58
+ if (arg in NEGATIVE_FLAGS) {
59
+ flags[NEGATIVE_FLAGS[arg]] = false;
60
+ continue;
61
+ }
62
+ const key = VALUE_FLAGS[arg];
63
+ if (!key) {
64
+ io.stderr(`Unknown option: ${arg}\n\n${HELP}`);
65
+ return 2;
66
+ }
67
+ const value = argv[i + 1];
68
+ if (value === undefined || value.startsWith('--')) {
69
+ io.stderr(`Missing value for ${arg}\n`);
70
+ return 2;
71
+ }
72
+ i += 1;
73
+ if (key === 'config')
74
+ config = value;
75
+ else if (key === 'out')
76
+ out = value;
77
+ else if (LIST_FLAGS.has(key)) {
78
+ const items = value.split(',').filter((item) => item !== '');
79
+ flags[key] = [...(flags[key] ?? []), ...items];
80
+ }
81
+ else
82
+ flags[key] = value;
83
+ }
84
+ try {
85
+ let options = {};
86
+ if (config !== undefined) {
87
+ const parsed = JSON.parse(io.readFile(config));
88
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
89
+ throw new ShellServiceWorkerError('config file must contain a JSON object');
90
+ }
91
+ options = parsed;
92
+ }
93
+ const script = generateServiceWorker({ ...options, ...flags });
94
+ if (out !== undefined)
95
+ io.writeFile(out, script);
96
+ else
97
+ io.stdout(script);
98
+ return 0;
99
+ }
100
+ catch (error) {
101
+ io.stderr(`${error instanceof Error ? error.message : String(error)}\n`);
102
+ return 1;
103
+ }
104
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync, writeFileSync } from 'node:fs';
3
+ import { runCli } from './cli-core.js';
4
+ process.exitCode = runCli(process.argv.slice(2), {
5
+ readFile: (path) => readFileSync(path, 'utf8'),
6
+ writeFile: (path, content) => writeFileSync(path, content),
7
+ stdout: (text) => process.stdout.write(text),
8
+ stderr: (text) => process.stderr.write(text),
9
+ });
@@ -0,0 +1,65 @@
1
+ export interface ShellServiceWorkerOptions {
2
+ /** Base name of the cache. Required. */
3
+ cacheName: string;
4
+ /** Appended to the cache name (`name-version`). Change it to make clients fetch a fresh shell. */
5
+ version?: string;
6
+ /** URLs fetched and stored when the worker installs. Installation fails if any of them fails. */
7
+ precache?: string[];
8
+ /** Cached page served for navigations that cannot reach the network. Default `/`. */
9
+ navigationFallback?: string;
10
+ /**
11
+ * `network-first` (default): navigations go to the network, and only a network error falls back to the cache,
12
+ * so a real 404 from the host is never hidden. `cache-first`: serve the cached page, then the network.
13
+ */
14
+ navigationStrategy?: 'network-first' | 'cache-first';
15
+ /** Other same-origin GET requests. `cache-first` (default) or `network-first` with cache fallback. */
16
+ assetStrategy?: 'cache-first' | 'network-first';
17
+ /** Requests whose path starts with one of these are left to the browser, for example `/api/`. */
18
+ bypassPrefixes?: string[];
19
+ /** Leave requests that carry an Authorization header to the browser. Default true. */
20
+ bypassAuthorized?: boolean;
21
+ /** If set, only navigations to exactly these paths are handled. Others go to the browser. */
22
+ navigationAllowlist?: string[];
23
+ /** Ignore the query string when matching cached responses. Default true. */
24
+ ignoreSearch?: boolean;
25
+ /** Store successful responses fetched at runtime. Default true. */
26
+ runtimeCache?: boolean;
27
+ /** If set, only responses for these request destinations (`script`, `style`, `image`, `font`, ...) are stored at runtime. */
28
+ runtimeDestinations?: string[];
29
+ /** Which old caches the activate step deletes. `prefix` (default): names starting with `cleanupPrefix`. `all`: every other cache. */
30
+ cleanup?: 'prefix' | 'all';
31
+ /** Default: `cacheName`. */
32
+ cleanupPrefix?: string;
33
+ /**
34
+ * `immediate` (default): the new worker takes over as soon as it installs.
35
+ * `message`: it waits until the page sends `{ type: 'SKIP_WAITING' }`.
36
+ */
37
+ skipWaiting?: 'immediate' | 'message';
38
+ }
39
+ export declare class ShellServiceWorkerError extends Error {
40
+ constructor(message: string);
41
+ }
42
+ interface Resolved {
43
+ cache: string;
44
+ precache: string[];
45
+ navigationFallback: string;
46
+ navigationStrategy: 'network-first' | 'cache-first';
47
+ assetStrategy: 'cache-first' | 'network-first';
48
+ bypassPrefixes: string[];
49
+ bypassAuthorized: boolean;
50
+ navigationAllowlist: string[] | null;
51
+ ignoreSearch: boolean;
52
+ runtimeCache: boolean;
53
+ runtimeDestinations: string[] | null;
54
+ cleanup: 'prefix' | 'all';
55
+ cleanupPrefix: string;
56
+ skipWaiting: 'immediate' | 'message';
57
+ }
58
+ /** Validates options and applies defaults. Throws `ShellServiceWorkerError` on bad input. */
59
+ export declare function resolveOptions(options: ShellServiceWorkerOptions): Resolved;
60
+ /**
61
+ * Returns the source of a service worker that precaches an app shell, removes old caches on activate,
62
+ * serves the shell when the network is unavailable, and leaves cross-origin, non-GET and bypassed requests alone.
63
+ */
64
+ export declare function generateServiceWorker(options: ShellServiceWorkerOptions): string;
65
+ export {};
@@ -0,0 +1,173 @@
1
+ export class ShellServiceWorkerError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'ShellServiceWorkerError';
5
+ }
6
+ }
7
+ function stringList(name, value) {
8
+ if (!Array.isArray(value) || value.some((item) => typeof item !== 'string' || item === '')) {
9
+ throw new ShellServiceWorkerError(`${name} must be an array of non-empty strings`);
10
+ }
11
+ return [...value];
12
+ }
13
+ function oneOf(name, value, allowed, fallback) {
14
+ if (value === undefined)
15
+ return fallback;
16
+ if (!allowed.includes(value)) {
17
+ throw new ShellServiceWorkerError(`${name} must be one of: ${allowed.join(', ')}`);
18
+ }
19
+ return value;
20
+ }
21
+ function flag(name, value, fallback) {
22
+ if (value === undefined)
23
+ return fallback;
24
+ if (typeof value !== 'boolean')
25
+ throw new ShellServiceWorkerError(`${name} must be a boolean`);
26
+ return value;
27
+ }
28
+ /** Validates options and applies defaults. Throws `ShellServiceWorkerError` on bad input. */
29
+ export function resolveOptions(options) {
30
+ if (!options || typeof options !== 'object')
31
+ throw new ShellServiceWorkerError('options must be an object');
32
+ const { cacheName, version } = options;
33
+ if (typeof cacheName !== 'string' || cacheName.trim() === '') {
34
+ throw new ShellServiceWorkerError('cacheName must be a non-empty string');
35
+ }
36
+ if (version !== undefined && (typeof version !== 'string' || version === '')) {
37
+ throw new ShellServiceWorkerError('version must be a non-empty string');
38
+ }
39
+ const fallback = options.navigationFallback ?? '/';
40
+ if (typeof fallback !== 'string' || fallback === '') {
41
+ throw new ShellServiceWorkerError('navigationFallback must be a non-empty string');
42
+ }
43
+ if (options.cleanupPrefix !== undefined && typeof options.cleanupPrefix !== 'string') {
44
+ throw new ShellServiceWorkerError('cleanupPrefix must be a string');
45
+ }
46
+ return {
47
+ cache: version ? `${cacheName}-${version}` : cacheName,
48
+ precache: options.precache === undefined ? [] : stringList('precache', options.precache),
49
+ navigationFallback: fallback,
50
+ navigationStrategy: oneOf('navigationStrategy', options.navigationStrategy, ['network-first', 'cache-first'], 'network-first'),
51
+ assetStrategy: oneOf('assetStrategy', options.assetStrategy, ['cache-first', 'network-first'], 'cache-first'),
52
+ bypassPrefixes: options.bypassPrefixes === undefined ? [] : stringList('bypassPrefixes', options.bypassPrefixes),
53
+ bypassAuthorized: flag('bypassAuthorized', options.bypassAuthorized, true),
54
+ navigationAllowlist: options.navigationAllowlist === undefined ? null : stringList('navigationAllowlist', options.navigationAllowlist),
55
+ ignoreSearch: flag('ignoreSearch', options.ignoreSearch, true),
56
+ runtimeCache: flag('runtimeCache', options.runtimeCache, true),
57
+ runtimeDestinations: options.runtimeDestinations === undefined ? null : stringList('runtimeDestinations', options.runtimeDestinations),
58
+ cleanup: oneOf('cleanup', options.cleanup, ['prefix', 'all'], 'prefix'),
59
+ cleanupPrefix: options.cleanupPrefix ?? cacheName,
60
+ skipWaiting: oneOf('skipWaiting', options.skipWaiting, ['immediate', 'message'], 'immediate'),
61
+ };
62
+ }
63
+ const BODY = `
64
+ const CACHE = CONFIG.cache;
65
+ const MATCH = { ignoreSearch: CONFIG.ignoreSearch };
66
+
67
+ function offline() {
68
+ return new Response('Offline', {
69
+ status: 503,
70
+ statusText: 'Service Unavailable',
71
+ headers: { 'Content-Type': 'text/plain; charset=utf-8' },
72
+ });
73
+ }
74
+
75
+ function cached(request) {
76
+ return caches.open(CACHE).then((cache) => cache.match(request, MATCH));
77
+ }
78
+
79
+ function fallbackPage() {
80
+ return cached(CONFIG.navigationFallback);
81
+ }
82
+
83
+ function store(event, request, response) {
84
+ if (!CONFIG.runtimeCache || !response || !response.ok) return;
85
+ if (CONFIG.runtimeDestinations && CONFIG.runtimeDestinations.indexOf(request.destination) === -1) return;
86
+ const copy = response.clone();
87
+ event.waitUntil(caches.open(CACHE).then((cache) => cache.put(request, copy)));
88
+ }
89
+
90
+ self.addEventListener('install', (event) => {
91
+ event.waitUntil(
92
+ caches
93
+ .open(CACHE)
94
+ .then((cache) => cache.addAll(CONFIG.precache))
95
+ .then(() => (CONFIG.skipWaiting === 'immediate' ? self.skipWaiting() : undefined)),
96
+ );
97
+ });
98
+
99
+ self.addEventListener('activate', (event) => {
100
+ event.waitUntil(
101
+ caches
102
+ .keys()
103
+ .then((keys) =>
104
+ Promise.all(
105
+ keys
106
+ .filter((key) => key !== CACHE && (CONFIG.cleanup === 'all' || key.indexOf(CONFIG.cleanupPrefix) === 0))
107
+ .map((key) => caches.delete(key)),
108
+ ),
109
+ )
110
+ .then(() => self.clients.claim()),
111
+ );
112
+ });
113
+
114
+ self.addEventListener('message', (event) => {
115
+ const data = event.data;
116
+ if (data === 'SKIP_WAITING' || (data && data.type === 'SKIP_WAITING')) self.skipWaiting();
117
+ });
118
+
119
+ self.addEventListener('fetch', (event) => {
120
+ const request = event.request;
121
+ if (request.method !== 'GET') return;
122
+ const url = new URL(request.url);
123
+ if (url.origin !== self.location.origin) return;
124
+ if (CONFIG.bypassAuthorized && request.headers.has('authorization')) return;
125
+ if (CONFIG.bypassPrefixes.some((prefix) => url.pathname.indexOf(prefix) === 0)) return;
126
+
127
+ if (request.mode === 'navigate') {
128
+ if (CONFIG.navigationAllowlist && CONFIG.navigationAllowlist.indexOf(url.pathname) === -1) return;
129
+ if (CONFIG.navigationStrategy === 'cache-first') {
130
+ event.respondWith(
131
+ fallbackPage().then((page) => page || fetch(request)).catch(offline),
132
+ );
133
+ } else {
134
+ event.respondWith(
135
+ fetch(request).catch(() => fallbackPage().then((page) => page || offline())),
136
+ );
137
+ }
138
+ return;
139
+ }
140
+
141
+ if (CONFIG.assetStrategy === 'network-first') {
142
+ event.respondWith(
143
+ fetch(request)
144
+ .then((response) => {
145
+ store(event, request, response);
146
+ return response;
147
+ })
148
+ .catch(() => cached(request).then((hit) => hit || offline())),
149
+ );
150
+ return;
151
+ }
152
+
153
+ event.respondWith(
154
+ cached(request).then(
155
+ (hit) =>
156
+ hit ||
157
+ fetch(request).then((response) => {
158
+ store(event, request, response);
159
+ return response;
160
+ }),
161
+ ).catch(offline),
162
+ );
163
+ });
164
+ `;
165
+ /**
166
+ * Returns the source of a service worker that precaches an app shell, removes old caches on activate,
167
+ * serves the shell when the network is unavailable, and leaves cross-origin, non-GET and bypassed requests alone.
168
+ */
169
+ export function generateServiceWorker(options) {
170
+ const config = resolveOptions(options);
171
+ const json = JSON.stringify(config, null, 2).replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
172
+ return `// Generated by @uppercut-labs/app-shell-service-worker. Edit the options and regenerate instead of editing this file.\nconst CONFIG = ${json};\n${BODY}`;
173
+ }
@@ -0,0 +1,2 @@
1
+ export { generateServiceWorker, resolveOptions, ShellServiceWorkerError, type ShellServiceWorkerOptions, } from './generate.js';
2
+ export { runCli, type CliIo } from './cli-core.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { generateServiceWorker, resolveOptions, ShellServiceWorkerError, } from './generate.js';
2
+ export { runCli } from './cli-core.js';
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@uppercut-labs/app-shell-service-worker",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Generate an app-shell service worker script from options: precache list, navigation fallback, cache versioning and update behavior. Function and CLI.",
5
+ "license": "MIT",
6
+ "author": "Uppercut Labs <packages@uppercut-labs.com>",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "bin": {
17
+ "app-shell-service-worker": "./dist/cli.js"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "sideEffects": false,
25
+ "scripts": {
26
+ "build": "tsc -p tsconfig.json",
27
+ "prepack": "node -e \"require('fs').copyFileSync('../../LICENSE','LICENSE')\""
28
+ },
29
+ "keywords": [
30
+ "service-worker",
31
+ "pwa",
32
+ "offline",
33
+ "app-shell",
34
+ "precache",
35
+ "generator"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/uppercut-labs/js-kit.git",
40
+ "directory": "packages/app-shell-service-worker"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/uppercut-labs/js-kit/issues"
44
+ },
45
+ "homepage": "https://github.com/uppercut-labs/js-kit/tree/main/packages/app-shell-service-worker#readme",
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ }
52
+ }