Compare commits
4
Commits
0afa61cc5c
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5423ca70f4 | ||
|
|
89d4d9b071 | ||
|
|
a2b929dbec | ||
|
|
4dd6d60457 |
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
"lint": "eslint"
|
"lint": "eslint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@valknar/vpinball-wasm": "0.3.3",
|
"@valknar/vpinball-wasm": "0.3.4",
|
||||||
"next": "16.3.2",
|
"next": "16.3.2",
|
||||||
"react": "19.2.8",
|
"react": "19.2.8",
|
||||||
"react-dom": "19.2.8"
|
"react-dom": "19.2.8"
|
||||||
|
|||||||
Generated
+5
-5
@@ -9,8 +9,8 @@ importers:
|
|||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@valknar/vpinball-wasm':
|
'@valknar/vpinball-wasm':
|
||||||
specifier: 0.3.3
|
specifier: 0.3.4
|
||||||
version: 0.3.3
|
version: 0.3.4
|
||||||
next:
|
next:
|
||||||
specifier: 16.3.2
|
specifier: 16.3.2
|
||||||
version: 16.3.2(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@20.19.43)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
|
version: 16.3.2(@babel/core@7.29.7(supports-color@7.2.0))(@types/node@20.19.43)(react-dom@19.2.8(react@19.2.8))(react@19.2.8)
|
||||||
@@ -754,8 +754,8 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@valknar/vpinball-wasm@0.3.3':
|
'@valknar/vpinball-wasm@0.3.4':
|
||||||
resolution: {integrity: sha512-It2VO8FrmBa7u+aom4m+JCWaVv6ZOhRn0x8BqqrFbGo2ptTb64G8SgqRXuGU8GldhIvgl3/ug+PsSg3EhETZpg==, tarball: https://dev.pivoine.art/api/packages/valknar/npm/%40valknar%2Fvpinball-wasm/-/0.3.3/vpinball-wasm-0.3.3.tgz}
|
resolution: {integrity: sha512-ULJ8jF3Q8sxmkkSdC70SSKzkvaNHORPZEFuJzQbmfH9aeqh4kYmqj59KX7bNywmAxLz4yLtr8r4i/oWEo8bbSw==, tarball: https://dev.pivoine.art/api/packages/valknar/npm/%40valknar%2Fvpinball-wasm/-/0.3.4/vpinball-wasm-0.3.4.tgz}
|
||||||
|
|
||||||
acorn-jsx@5.3.2:
|
acorn-jsx@5.3.2:
|
||||||
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
|
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
|
||||||
@@ -2645,7 +2645,7 @@ snapshots:
|
|||||||
'@unrs/resolver-binding-win32-x64-msvc@1.12.2':
|
'@unrs/resolver-binding-win32-x64-msvc@1.12.2':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@valknar/vpinball-wasm@0.3.3': {}
|
'@valknar/vpinball-wasm@0.3.4': {}
|
||||||
|
|
||||||
acorn-jsx@5.3.2(acorn@8.18.0):
|
acorn-jsx@5.3.2(acorn@8.18.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
+1
-1
@@ -2,5 +2,5 @@ allowBuilds:
|
|||||||
sharp: false
|
sharp: false
|
||||||
unrs-resolver: false
|
unrs-resolver: false
|
||||||
minimumReleaseAgeExclude:
|
minimumReleaseAgeExclude:
|
||||||
- '@valknar/vpinball-wasm@0.2.0 || 0.3.1 || 0.3.2 || 0.3.3'
|
- '@valknar/vpinball-wasm@0.2.0 || 0.3.1 || 0.3.2 || 0.3.3 || 0.3.4'
|
||||||
updateNotifier: false
|
updateNotifier: false
|
||||||
|
|||||||
+12
-5
@@ -1,9 +1,16 @@
|
|||||||
// Bump this on every release that changes the app shell or the vendored
|
// Bump manually (via `pnpm sw:bump`) whenever SHELL_ASSETS or the shell's
|
||||||
// engine build — it's the only thing that invalidates old caches, since
|
// caching behavior changes — nothing else invalidates the shell cache, since
|
||||||
// none of the cached URLs below are content-hashed by us.
|
// none of the cached URLs below are content-hashed by us.
|
||||||
const CACHE_VERSION = "v2";
|
const SHELL_VERSION = "v2";
|
||||||
const SHELL_CACHE = `shell-${CACHE_VERSION}`;
|
// Written automatically by scripts/copy-engine-assets.mjs from the installed
|
||||||
const ENGINE_CACHE = `engine-${CACHE_VERSION}`;
|
// @valknar/vpinball-wasm version — do not edit by hand. Ties the engine
|
||||||
|
// cache key to the actual engine build, so a version bump always busts
|
||||||
|
// stale caches instead of relying on a human to remember a separate step
|
||||||
|
// (which is exactly how returning visitors ended up on a stale, and
|
||||||
|
// possibly internally inconsistent, engine bundle before this existed).
|
||||||
|
const ENGINE_VERSION = "0.3.4";
|
||||||
|
const SHELL_CACHE = `shell-${SHELL_VERSION}`;
|
||||||
|
const ENGINE_CACHE = `engine-${ENGINE_VERSION}`;
|
||||||
|
|
||||||
const SHELL_ASSETS = [
|
const SHELL_ASSETS = [
|
||||||
"/",
|
"/",
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
// Bumps public/sw.js's CACHE_VERSION so a deploy invalidates old caches —
|
// Bumps public/sw.js's SHELL_VERSION so a deploy invalidates old shell
|
||||||
// run this before cutting a release that changes the app shell or updates
|
// caches — run this before cutting a release that changes SHELL_ASSETS or
|
||||||
// the vendored vpinball-wasm engine build.
|
// the shell's caching behavior. (The engine cache busts itself automatically
|
||||||
|
// from the installed vpinball-wasm version — see copy-engine-assets.mjs.)
|
||||||
import { readFile, writeFile } from "node:fs/promises";
|
import { readFile, writeFile } from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
@@ -10,12 +11,12 @@ const rootDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|||||||
const swPath = path.join(rootDir, "public", "sw.js");
|
const swPath = path.join(rootDir, "public", "sw.js");
|
||||||
|
|
||||||
const contents = await readFile(swPath, "utf8");
|
const contents = await readFile(swPath, "utf8");
|
||||||
const match = contents.match(/CACHE_VERSION = "v(\d+)"/);
|
const match = contents.match(/SHELL_VERSION = "v(\d+)"/);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
console.error(`Couldn't find CACHE_VERSION in ${swPath}`);
|
console.error(`Couldn't find SHELL_VERSION in ${swPath}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const next = Number(match[1]) + 1;
|
const next = Number(match[1]) + 1;
|
||||||
const updated = contents.replace(/CACHE_VERSION = "v\d+"/, `CACHE_VERSION = "v${next}"`);
|
const updated = contents.replace(/SHELL_VERSION = "v\d+"/, `SHELL_VERSION = "v${next}"`);
|
||||||
await writeFile(swPath, updated);
|
await writeFile(swPath, updated);
|
||||||
console.log(`Bumped service worker CACHE_VERSION to v${next}`);
|
console.log(`Bumped service worker SHELL_VERSION to v${next}`);
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
// so it's served as plain static files (see lib/pinball/usePinballInstance.ts for why:
|
// so it's served as plain static files (see lib/pinball/usePinballInstance.ts for why:
|
||||||
// the package's own loadPinball() does a dynamic import() of its glue script that must
|
// the package's own loadPinball() does a dynamic import() of its glue script that must
|
||||||
// never pass through webpack's module graph).
|
// never pass through webpack's module graph).
|
||||||
import { cp, mkdir, rm } from "node:fs/promises";
|
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
||||||
import { existsSync } from "node:fs";
|
import { existsSync } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
const rootDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
const rootDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||||
const pkgDistDir = path.join(rootDir, "node_modules", "@valknar", "vpinball-wasm", "dist");
|
const pkgDir = path.join(rootDir, "node_modules", "@valknar", "vpinball-wasm");
|
||||||
|
const pkgDistDir = path.join(pkgDir, "dist");
|
||||||
const targetDir = path.join(rootDir, "public", "vendor", "vpinball-wasm");
|
const targetDir = path.join(rootDir, "public", "vendor", "vpinball-wasm");
|
||||||
|
|
||||||
if (!existsSync(pkgDistDir)) {
|
if (!existsSync(pkgDistDir)) {
|
||||||
@@ -24,3 +25,16 @@ await mkdir(targetDir, { recursive: true });
|
|||||||
await cp(pkgDistDir, targetDir, { recursive: true });
|
await cp(pkgDistDir, targetDir, { recursive: true });
|
||||||
|
|
||||||
console.log(`Copied vpinball-wasm engine assets to ${path.relative(rootDir, targetDir)}/`);
|
console.log(`Copied vpinball-wasm engine assets to ${path.relative(rootDir, targetDir)}/`);
|
||||||
|
|
||||||
|
// Keep the service worker's engine cache key in lockstep with the installed
|
||||||
|
// engine version, so a version bump always busts stale caches for returning
|
||||||
|
// visitors — see sw.js's ENGINE_VERSION comment for why this must not be a
|
||||||
|
// manual step.
|
||||||
|
const { version: engineVersion } = JSON.parse(await readFile(path.join(pkgDir, "package.json"), "utf8"));
|
||||||
|
const swPath = path.join(rootDir, "public", "sw.js");
|
||||||
|
const swContents = await readFile(swPath, "utf8");
|
||||||
|
const updatedSw = swContents.replace(/ENGINE_VERSION = "[^"]*"/, `ENGINE_VERSION = "${engineVersion}"`);
|
||||||
|
if (updatedSw !== swContents) {
|
||||||
|
await writeFile(swPath, updatedSw);
|
||||||
|
console.log(`Set sw.js ENGINE_VERSION to ${engineVersion}`);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user