@powerhousedao/builder-tools 6.2.3-staging.0 → 6.3.0-dev.1

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.
@@ -36,6 +36,7 @@ import {
36
36
  // the worker bundle. The IDB schema constants are shared with the SPA writer
37
37
  // (apps/connect/src/utils/pwa-idb.ts) so the two can't desync.
38
38
  import {
39
+ isAppShellNavigation,
39
40
  mergeManifest,
40
41
  type PHConnectPwaUrlPattern,
41
42
  PWA_IDB_KEY,
@@ -48,6 +49,7 @@ import {
48
49
  EMBEDDED_BASE_MANIFEST,
49
50
  EXTRA_RUNTIME_CACHING,
50
51
  NAVIGATE_FALLBACK_DENYLIST_EXTRA,
52
+ STATIC_FILES,
51
53
  } from "virtual:ph-sw-config";
52
54
 
53
55
  declare const self: ServiceWorkerGlobalScope &
@@ -174,28 +176,12 @@ registerRoute(
174
176
  // producer at that URL. The __WB_MANIFEST property below is the injectManifest
175
177
  // injection point — workbox-build replaces it with the precache list at build
176
178
  // time (the token is written once, on the code line, never in prose).
177
- precacheAndRoute(self.__WB_MANIFEST);
179
+ // `v` versions the reactor worker URLs; the precached copy is that same build's.
180
+ precacheAndRoute(self.__WB_MANIFEST, {
181
+ ignoreURLParametersMatching: [/^utm_/, /^fbclid$/, /^v$/],
182
+ });
178
183
 
179
- // ── runtime caching (ported 1:1 from the old BASE_WORKBOX, same order) ───────
180
- // Inter font stays on Google's CDN; cache it after the first online load.
181
- registerRoute(
182
- ({ url }) => url.origin === "https://fonts.googleapis.com",
183
- new StaleWhileRevalidate({ cacheName: "google-fonts-stylesheets" }),
184
- );
185
- registerRoute(
186
- ({ url }) => url.origin === "https://fonts.gstatic.com",
187
- new CacheFirst({
188
- cacheName: "google-fonts-webfonts",
189
- plugins: [
190
- new ExpirationPlugin({
191
- maxEntries: 30,
192
- maxAgeSeconds: 60 * 60 * 24 * 365,
193
- }),
194
- // statuses [0, 200]: 0 permits opaque cross-origin font responses.
195
- new CacheableResponsePlugin({ statuses: [0, 200] }),
196
- ],
197
- }),
198
- );
184
+ // ── runtime caching ──────────────────────────────────────────────────────────
199
185
  // Document-model editors/packages loaded at runtime from the registry CDN. The
200
186
  // registry ORIGIN is a runtime value, so match the stable "/-/cdn/" path. Two
201
187
  // rules (order matters): unversioned ENTRY points first (SWR — a newer editor
@@ -203,6 +189,14 @@ registerRoute(
203
189
  // for the content-hashed (immutable) assets. statuses [0, 200] on both — the
204
190
  // editor JS is a CORS import (200) but its stylesheet/assets are no-cors
205
191
  // (opaque/0); [200] alone silently dropped those and broke styles offline.
192
+ // A no-cors request (a stylesheet's @import) caches an opaque copy; a CORS one
193
+ // (a module import, fetch) fails on it, so it goes to the network instead.
194
+ const noOpaqueForCors: WorkboxPlugin = {
195
+ cachedResponseWillBeUsed: async ({ request, cachedResponse }) =>
196
+ request.mode === "cors" && cachedResponse?.type === "opaque"
197
+ ? null
198
+ : (cachedResponse ?? null),
199
+ };
206
200
  registerRoute(
207
201
  ({ url }) =>
208
202
  url.pathname.includes("/-/cdn/") &&
@@ -217,6 +211,7 @@ registerRoute(
217
211
  maxAgeSeconds: 60 * 60 * 24 * 30,
218
212
  }),
219
213
  new CacheableResponsePlugin({ statuses: [0, 200] }),
214
+ noOpaqueForCors,
220
215
  ],
221
216
  }),
222
217
  );
@@ -230,6 +225,7 @@ registerRoute(
230
225
  maxAgeSeconds: 60 * 60 * 24 * 30,
231
226
  }),
232
227
  new CacheableResponsePlugin({ statuses: [0, 200] }),
228
+ noOpaqueForCors,
233
229
  ],
234
230
  }),
235
231
  );
@@ -341,10 +337,14 @@ const stripQueryCacheKey: WorkboxPlugin = {
341
337
  return request.url;
342
338
  },
343
339
  };
340
+ // A navigation to a file (icon.svg, a public/ file) is not the app's: it falls
341
+ // through to the precache or the network, as a fetch of it would.
342
+ const scopePath = new URL(self.registration.scope).pathname;
344
343
  registerRoute(
345
344
  new Route(
346
345
  ({ request, url }) =>
347
346
  request.mode === "navigate" &&
347
+ isAppShellNavigation(url.pathname, scopePath, STATIC_FILES) &&
348
348
  !denylist.some((re) => re.test(url.pathname + url.search)),
349
349
  new NetworkFirst({
350
350
  cacheName: "ph-shell",
@@ -19,4 +19,7 @@ declare module "virtual:ph-sw-config" {
19
19
 
20
20
  /** Extra SPA navigate-fallback denylist patterns. */
21
21
  export const NAVIGATE_FALLBACK_DENYLIST_EXTRA: PHConnectPwaUrlPattern[];
22
+
23
+ /** The project's public/ files, by path: a navigation to one is not the shell's. */
24
+ export const STATIC_FILES: string[];
22
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/builder-tools",
3
- "version": "6.2.3-staging.0",
3
+ "version": "6.3.0-dev.1",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0-only",
6
6
  "publishConfig": {
@@ -23,14 +23,17 @@
23
23
  },
24
24
  "sideEffects": false,
25
25
  "dependencies": {
26
- "@powerhousedao/config": "6.2.3-staging.0",
27
- "@powerhousedao/shared": "6.2.3-staging.0",
26
+ "@powerhousedao/config": "6.3.0-dev.1",
27
+ "@powerhousedao/shared": "6.3.0-dev.1",
28
28
  "@tailwindcss/vite": "4.2.2",
29
+ "@tanstack/router-generator": "1.167.40",
30
+ "@tanstack/router-plugin": "1.168.42",
31
+ "@tanstack/virtual-file-routes": "1.162.0",
29
32
  "@vitejs/plugin-react": "6.1.1",
30
- "document-model": "6.2.3-staging.0",
33
+ "document-model": "6.3.0-dev.1",
34
+ "es-module-lexer": "^2.0.0",
31
35
  "magic-string": "^0.30.21",
32
- "vite": "8.3.0",
33
- "vite-plugin-html": "3.2.2",
36
+ "vite": "8.3.4",
34
37
  "vite-plugin-pwa": "1.3.0",
35
38
  "workbox-cacheable-response": "7.4.1",
36
39
  "workbox-core": "7.4.1",
@@ -44,8 +47,8 @@
44
47
  "tsdown": "0.23.0",
45
48
  "tsx": "4.23.13",
46
49
  "vite-plugin-externalize-dependencies": "^1.0.1",
47
- "vitest": "4.1.1",
48
- "zod": "4.3.6"
50
+ "vitest": "5.0.3",
51
+ "zod": "^4.5.4"
49
52
  },
50
53
  "peerDependencies": {
51
54
  "@sentry/vite-plugin": "^4.3.0",