@tokenoftrust/storefront-runner 2.2.15 → 2.2.17
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.
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
* passes — the client pass included — runs with `build.ssr === true`, so a Vite plugin
|
|
22
22
|
* cannot tell them apart, while `config.build.client` says it outright.
|
|
23
23
|
*/
|
|
24
|
-
import {
|
|
24
|
+
import { createHash } from "node:crypto";
|
|
25
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
25
26
|
import { createRequire } from "node:module";
|
|
26
27
|
import { dirname } from "node:path";
|
|
27
28
|
import { fileURLToPath } from "node:url";
|
|
@@ -29,6 +30,7 @@ import {
|
|
|
29
30
|
LIFECYCLE_HOST_ASSET_PATH,
|
|
30
31
|
LIFECYCLE_HOST_COMPATIBILITY_ASSET_PATHS,
|
|
31
32
|
} from "@tot/public-runtime/integration/lifecycle-host-asset";
|
|
33
|
+
import { decideLifecycleHostLock, formatLifecycleHostLockReport } from "../../../scripts/lib/lifecycle-host-lock.mjs";
|
|
32
34
|
|
|
33
35
|
const HOST_ASSET_PATHS = Object.freeze([
|
|
34
36
|
...LIFECYCLE_HOST_COMPATIBILITY_ASSET_PATHS,
|
|
@@ -42,6 +44,11 @@ const HOST_ENTRY = fileURLToPath(
|
|
|
42
44
|
),
|
|
43
45
|
);
|
|
44
46
|
|
|
47
|
+
const LOCK_URL = new URL(
|
|
48
|
+
"../../../packages/public-runtime/src/integration/lifecycle-host-asset.lock.json",
|
|
49
|
+
import.meta.url,
|
|
50
|
+
);
|
|
51
|
+
|
|
45
52
|
/**
|
|
46
53
|
* Bundle the host to a single self-contained ES module.
|
|
47
54
|
*
|
|
@@ -124,6 +131,30 @@ export function lifecycleHostAsset() {
|
|
|
124
131
|
if (!clientDir) throw new Error("the lifecycle host has no resolved client output dir");
|
|
125
132
|
const outputDir = clientDir;
|
|
126
133
|
const code = await bundleLifecycleHost();
|
|
134
|
+
const hash = createHash("sha256").update(code, "utf8").digest("hex");
|
|
135
|
+
|
|
136
|
+
// Every HOST_ASSET_PATH is served under an `immutable, max-age=1yr` Cache-Control
|
|
137
|
+
// (scripts/publish/lib/s3-publish.mjs PLATFORM_ASSET_PREFIX) — once published, a
|
|
138
|
+
// path's bytes may never change, or visitors who already cached it are stuck on
|
|
139
|
+
// stale tracking/consent behavior for up to a year with nothing to notice it. This
|
|
140
|
+
// is the guard for that: refuse the build rather than silently rewrite a path that
|
|
141
|
+
// already shipped different bytes.
|
|
142
|
+
const lock = JSON.parse(await readFile(LOCK_URL, "utf8"));
|
|
143
|
+
const decision = decideLifecycleHostLock(
|
|
144
|
+
lock,
|
|
145
|
+
HOST_ASSET_PATHS.map((assetPath) => ({ assetPath, hash })),
|
|
146
|
+
);
|
|
147
|
+
if (!decision.ok) {
|
|
148
|
+
throw new Error(formatLifecycleHostLockReport(decision));
|
|
149
|
+
}
|
|
150
|
+
if (JSON.stringify(decision.nextLock) !== JSON.stringify(lock)) {
|
|
151
|
+
await writeFile(LOCK_URL, `${JSON.stringify(decision.nextLock, null, 2)}\n`, "utf8");
|
|
152
|
+
logger.warn(
|
|
153
|
+
"lifecycle host lock recorded a new path — commit " +
|
|
154
|
+
"packages/public-runtime/src/integration/lifecycle-host-asset.lock.json",
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
127
158
|
await Promise.all(HOST_ASSET_PATHS.map(async (assetPath) => {
|
|
128
159
|
const target = fileURLToPath(new URL(assetPath, outputDir));
|
|
129
160
|
await mkdir(dirname(target), { recursive: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.17",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|