@powerhousedao/builder-tools 6.2.3-dev.9 → 6.2.3-dev.90

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/") &&
@@ -212,8 +206,12 @@ registerRoute(
212
206
  new StaleWhileRevalidate({
213
207
  cacheName: "ph-package-cdn-entry",
214
208
  plugins: [
215
- new ExpirationPlugin({ maxEntries: 60, maxAgeSeconds: 60 * 60 * 24 * 30 }),
209
+ new ExpirationPlugin({
210
+ maxEntries: 60,
211
+ maxAgeSeconds: 60 * 60 * 24 * 30,
212
+ }),
216
213
  new CacheableResponsePlugin({ statuses: [0, 200] }),
214
+ noOpaqueForCors,
217
215
  ],
218
216
  }),
219
217
  );
@@ -227,6 +225,7 @@ registerRoute(
227
225
  maxAgeSeconds: 60 * 60 * 24 * 30,
228
226
  }),
229
227
  new CacheableResponsePlugin({ statuses: [0, 200] }),
228
+ noOpaqueForCors,
230
229
  ],
231
230
  }),
232
231
  );
@@ -235,7 +234,10 @@ registerRoute(
235
234
  // boot until the browser's own fetch timeout.
236
235
  registerRoute(
237
236
  ({ url }) => url.pathname.endsWith("/powerhouse.config.json"),
238
- new NetworkFirst({ cacheName: "ph-runtime-config", networkTimeoutSeconds: 5 }),
237
+ new NetworkFirst({
238
+ cacheName: "ph-runtime-config",
239
+ networkTimeoutSeconds: 5,
240
+ }),
239
241
  );
240
242
 
241
243
  // ── extra runtime caching ────────────────────────────────────────────────────
@@ -335,10 +337,14 @@ const stripQueryCacheKey: WorkboxPlugin = {
335
337
  return request.url;
336
338
  },
337
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;
338
343
  registerRoute(
339
344
  new Route(
340
345
  ({ request, url }) =>
341
346
  request.mode === "navigate" &&
347
+ isAppShellNavigation(url.pathname, scopePath, STATIC_FILES) &&
342
348
  !denylist.some((re) => re.test(url.pathname + url.search)),
343
349
  new NetworkFirst({
344
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-dev.9",
3
+ "version": "6.2.3-dev.90",
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-dev.9",
27
- "@powerhousedao/shared": "6.2.3-dev.9",
26
+ "@powerhousedao/config": "6.2.3-dev.90",
27
+ "@powerhousedao/shared": "6.2.3-dev.90",
28
28
  "@tailwindcss/vite": "4.2.2",
29
- "@vitejs/plugin-react": "6.0.1",
30
- "document-model": "6.2.3-dev.9",
29
+ "@tanstack/router-generator": "1.167.40",
30
+ "@tanstack/router-plugin": "1.168.42",
31
+ "@tanstack/virtual-file-routes": "1.162.0",
32
+ "@vitejs/plugin-react": "6.1.1",
33
+ "document-model": "6.2.3-dev.90",
34
+ "es-module-lexer": "^2.0.0",
31
35
  "magic-string": "^0.30.21",
32
- "vite": "8.0.10",
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",
@@ -41,11 +44,11 @@
41
44
  },
42
45
  "devDependencies": {
43
46
  "@sentry/vite-plugin": "^4.3.0",
44
- "tsdown": "0.21.1",
45
- "tsx": "4.21.0",
47
+ "tsdown": "0.23.0",
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",
@@ -75,7 +78,7 @@
75
78
  "homepage": "https://academy.vetra.io",
76
79
  "scripts": {
77
80
  "tsc": "tsc",
78
- "lint": "eslint",
81
+ "lint": "cd ../.. && oxlint packages/builder-tools",
79
82
  "build": "tsdown",
80
83
  "test": "vitest --run"
81
84
  }