@ultimat3/pwa 31.35.0 → 31.36.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/pwa",
3
- "version": "31.35.0",
3
+ "version": "31.36.0",
4
4
  "description": "Generated service worker, web manifest, icons, push and version-skew handling.",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -45,10 +45,10 @@
45
45
  "test": "bun test"
46
46
  },
47
47
  "dependencies": {
48
- "@ultimat3/action": "31.35.0",
49
- "@ultimat3/core": "31.35.0",
50
- "@ultimat3/i18n": "31.35.0",
51
- "@ultimat3/policy": "31.35.0",
52
- "@ultimat3/schema": "31.35.0"
48
+ "@ultimat3/action": "31.36.0",
49
+ "@ultimat3/core": "31.36.0",
50
+ "@ultimat3/i18n": "31.36.0",
51
+ "@ultimat3/policy": "31.36.0",
52
+ "@ultimat3/schema": "31.36.0"
53
53
  }
54
54
  }
package/src/errors.ts CHANGED
@@ -143,7 +143,7 @@ export class PwaStrategyExhaustedError extends UltimateError {
143
143
  super({
144
144
  code: PwaStrategyExhaustedError.code,
145
145
  cause: `no cached response and the network failed for "${input.cacheName}"`,
146
- fix: 'pass options.fallback to staleWhileRevalidate(request, env, options), or set pwa.offline.fallback in app.config.ts',
146
+ fix: "staleWhileRevalidate(request, env, { ...options, fallback }) // a () => Promise<Response> served when both fail — or pwa: { offline: { fallback: '/offline' } } in app.config.ts",
147
147
  });
148
148
  }
149
149
  }
package/src/icons.ts CHANGED
@@ -131,7 +131,7 @@ export function requireSourceIcon(config: IconSourceConfig): string {
131
131
  throw new PwaIconMissingError(
132
132
  'no source icon: pwa.sourceIcon is unset, so no manifest icon can be generated and ' +
133
133
  'the app is not installable',
134
- "add a 1024x1024 square PNG at assets/icon.png and set pwa.sourceIcon: 'assets/icon.png'",
134
+ "planIcons({ sourceIcon: 'apps/web/site/icon.png' }) // a 1024x1024 square PNG — under x build, that file is the source",
135
135
  );
136
136
  }
137
137
  return source;
package/src/manifest.ts CHANGED
@@ -212,7 +212,7 @@ function assertValid(config: WebManifestInput): void {
212
212
  if (config.name.trim() === '') {
213
213
  throw new PwaManifestInvalidError(
214
214
  'pwa.name is empty, so the install prompt would have no title',
215
- 'set pwa.name in app.config.ts',
215
+ "pwa: { name: 'My App' } // in app.config.ts",
216
216
  );
217
217
  }
218
218
  const scope = config.scope ?? '/';
@@ -221,7 +221,7 @@ function assertValid(config: WebManifestInput): void {
221
221
  throw new PwaManifestInvalidError(
222
222
  `pwa.startUrl ${JSON.stringify(startUrl)} is outside pwa.scope ${JSON.stringify(scope)}, ` +
223
223
  'so the installed app would open out of scope',
224
- `set pwa.startUrl to a path under ${scope} in app.config.ts`,
224
+ `generateWebManifest({ ...config, startUrl: '${scope}' }) // a start URL under the scope ${scope}`,
225
225
  );
226
226
  }
227
227
  for (const scheme of ['light', 'dark'] as const) {
@@ -229,7 +229,7 @@ function assertValid(config: WebManifestInput): void {
229
229
  if (colors.themeColor.trim() === '' || colors.backgroundColor.trim() === '') {
230
230
  throw new PwaManifestInvalidError(
231
231
  `pwa.tokens.${scheme} is missing themeColor or backgroundColor`,
232
- `resolve the ${scheme} theme tokens in app.config.ts — both schemes are required`,
232
+ `pwa: { colors: { ${scheme}: { themeColor: '<colour>', backgroundColor: '<colour>' } } } // in app.config.ts, beside the other scheme — both are required`,
233
233
  );
234
234
  }
235
235
  }
@@ -50,7 +50,7 @@ export interface OfflineFallback {
50
50
  * command writes `apps/web/site/offline/page.tsx`, which is what `x new` scaffolds.
51
51
  */
52
52
  const FIX =
53
- "set pwa: { offline: { fallback: '/offline' } } in app.config.ts, then create the route it names: x g route offline --surface site";
53
+ "pwa: { offline: { fallback: '/offline' } } // in app.config.ts, then create the route it names: x g route offline --surface site";
54
54
 
55
55
  /**
56
56
  * Build-time gate, called by `generateServiceWorker` and by `x doctor`. The fix line is
@@ -76,7 +76,7 @@ export function requireOfflineFallback(
76
76
  if (!fallback.startsWith('/')) {
77
77
  throw new PwaNoOfflineFallbackError(
78
78
  `offline.fallback is ${JSON.stringify(fallback)}, which is not an absolute route path`,
79
- `set pwa.offline.fallback to '/${fallback.replace(/^\/+/, '')}' in app.config.ts`,
79
+ `pwa: { offline: { fallback: '/${fallback.replace(/^\/+/, '')}' } } // in app.config.ts — an absolute route path`,
80
80
  );
81
81
  }
82
82
  // Core's predicate, judged by resolution: every URL here is precached at install and served as
@@ -126,7 +126,7 @@ export function assetRules(prefixes: readonly string[], scope: string): readonly
126
126
  throw new SwScopeInvalidError(
127
127
  `runtime asset prefix ${JSON.stringify(prefix)} is not an absolute path under the ` +
128
128
  `worker's scope ${scope}, so no request pathname would ever match it`,
129
- `name the prefix as the browser requests it, e.g. '${scope}islands/'`,
129
+ `assetRules(['${scope}islands/'], '${scope}') // each prefix as the browser requests it, under the worker's scope`,
130
130
  );
131
131
  }
132
132
  return {
@@ -92,7 +92,7 @@ export function assertScope(swPath: string, scope: string): void {
92
92
  throw new SwScopeInvalidError(
93
93
  `sw.js is served from ${swPath}, which is relative, so the directory it can control is ` +
94
94
  `unknown at build time; the configured scope is ${scope}`,
95
- `set pwa.swPath to an absolute path — '${scope}sw.js' serves scope ${scope}`,
95
+ `generateServiceWorker(routes, { ...config, swPath: '${scope}sw.js' }, buildId) // an absolute path — this one serves scope ${scope}`,
96
96
  );
97
97
  }
98
98
  const directory = swPath.slice(0, swPath.lastIndexOf('/') + 1);
@@ -100,7 +100,7 @@ export function assertScope(swPath: string, scope: string): void {
100
100
  throw new SwScopeInvalidError(
101
101
  `sw.js is served from ${swPath}, which can only control ${directory}, but the ` +
102
102
  `configured scope is ${scope}`,
103
- `serve the service worker from ${scope}sw.js, or set pwa.scope to '${directory}'`,
103
+ `generateServiceWorker(routes, { ...config, swPath: '${scope}sw.js' }, buildId) // serve it from inside the scope — or scope: '${directory}'`,
104
104
  );
105
105
  }
106
106
  }
@@ -38,7 +38,7 @@ export function buildId(input: BuildIdInput = {}): string {
38
38
  if (base === '' || base === '0') {
39
39
  throw new BuildIdMissingError(
40
40
  'cannot derive a build id: no gitSha and no timestamp',
41
- 'set GIT_SHA in the build environment (docker build --build-arg GIT_SHA=$(git rev-parse HEAD))',
41
+ 'docker build --build-arg GIT_SHA="$(git rev-parse HEAD)" . # or set GIT_SHA in the build environment some other way',
42
42
  );
43
43
  }
44
44
  const short = base.slice(0, 12);
@@ -58,7 +58,7 @@ export function assertBuildId(value: string | undefined | null): asserts value i
58
58
  if (value === undefined || value === null || value.trim() === '') {
59
59
  throw new BuildIdMissingError(
60
60
  'the build id is empty, so caches cannot be keyed and skew cannot be detected',
61
- 'set GIT_SHA in the build environment and pass it to generateServiceWorker(routes, config, buildId)',
61
+ 'generateServiceWorker(routes, config, buildId({ gitSha: process.env.GIT_SHA })) // with GIT_SHA set in the build environment',
62
62
  );
63
63
  }
64
64
  }