import { readFile } from "node:fs/promises"; import { hash as blake3 } from "blake3-wasm"; // Native asset addressing for the distinct API fixture asset, calculated by the // same public package as production packaging, outside the customer runtime. export async function upgradeAssetHash() { const manifest = JSON.parse( await readFile("dist/release/manifest.json", "utf8"), ); const file = manifest.files.find( (f) => f.path.startsWith("assets/") && f.path.endsWith(".js"), ); const bytes = Buffer.concat([ await readFile(`dist/release/${file.path}`), Buffer.from("\n// immutable upgrade asset TWO\n"), ]); return blake3(bytes.toString("base64") + "js") .toString("hex") .slice(0, 32); }