@githolon/runtime 0.112.11 → 0.113.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/runner/build.ts CHANGED
@@ -47,17 +47,7 @@ const browserBuild = await build({
47
47
  });
48
48
  // Flutter web uses a small page bridge and a dedicated worker. The existing page entry
49
49
  // remains the WebView host, so native packaging keeps its existing physical shell.
50
- const browserWorkerPageBuild = await build({
51
- entryPoints: [here("../../../platform-shells/browser/worker_page_entry.ts")],
52
- preserveSymlinks: true,
53
- bundle: true,
54
- platform: "browser",
55
- format: "iife",
56
- target: "es2020",
57
- outfile: here("../dist/nomos-runner-web.js"),
58
- legalComments: "none",
59
- metafile: true,
60
- });
50
+ // The worker builds first: the page bridge carries its digest.
61
51
  const browserWorkerBuild = await build({
62
52
  entryPoints: [here("../../../platform-shells/browser/worker_entry.ts")],
63
53
  preserveSymlinks: true,
@@ -76,6 +66,21 @@ const browserWorkerBuild = await build({
76
66
  legalComments: "none",
77
67
  metafile: true,
78
68
  });
69
+ const workerSha256 = createHash("sha256").update(readFileSync(here("../dist/nomos-runner-worker.js"))).digest("hex");
70
+ const browserWorkerPageBuild = await build({
71
+ entryPoints: [here("../../../platform-shells/browser/worker_page_entry.ts")],
72
+ preserveSymlinks: true,
73
+ bundle: true,
74
+ platform: "browser",
75
+ format: "iife",
76
+ target: "es2020",
77
+ // The page names the worker by its content digest, so the worker URL is cacheable for ever and
78
+ // a deploy can never pair this page with a stale worker.
79
+ define: { __NOMOS_WORKER_SHA256__: JSON.stringify(workerSha256) },
80
+ outfile: here("../dist/nomos-runner-web.js"),
81
+ legalComments: "none",
82
+ metafile: true,
83
+ });
79
84
  copyFileSync(here("./nomos-runner.html"), here("../dist/nomos-runner.html"));
80
85
 
81
86
  // THE TYPED NATIVE RUNTIME — the shared Peer Office executed by the Apple
@@ -186,6 +191,13 @@ if (existsSync(FLUTTER_ASSETS)) {
186
191
  for (const f of ["nomos-runner.js", "nomos-runner-web.js", "nomos-runner-worker.js", "nomos-runner.html", "nomos-native-runtime.js"]) {
187
192
  copyFileSync(here(`../dist/${f}`), join(FLUTTER_ASSETS, f));
188
193
  }
194
+ // Dart names the page bridge by its digest (as the bridge names the worker), so both URLs are
195
+ // cacheable for ever and one deploy never mixes bridges.
196
+ const pageSha256 = createHash("sha256").update(readFileSync(here("../dist/nomos-runner-web.js"))).digest("hex");
197
+ writeFileSync(join(FLUTTER_ASSETS, "../lib/src/platform_shell/runner_digest.g.dart"),
198
+ "// GENERATED by peer-office/package/runner/build.ts. Do not edit.\n"
199
+ + "// The sha256 of the packaged nomos-runner-web.js this package ships.\n"
200
+ + `const String kNomosRunnerWebSha256 =\n '${pageSha256}';\n`);
189
201
  console.error("✓ synced browser shell and shared Peer Office assets → nomos_flutter/assets");
190
202
  }
191
203