diff --git a/scripts/patch-reactive-resume-glalie-layout.sh b/scripts/patch-reactive-resume-glalie-layout.sh index 747afac..a8c3119 100755 --- a/scripts/patch-reactive-resume-glalie-layout.sh +++ b/scripts/patch-reactive-resume-glalie-layout.sh @@ -9,7 +9,7 @@ set -eu SSR_FILE="/app/apps/web/.output/server/_ssr/pdf-document-COfeOLVC.mjs" PUBLIC_FILE="/app/apps/web/.output/public/assets/pdf-document-BplbXx-0.js" SERVER_INDEX_FILE="/app/apps/web/.output/server/index.mjs" -CACHE_BUST="rr-glalie-layout-20260518" +CACHE_BUST="rr-glalie-layout-20260519" test -f "$SSR_FILE.bak-glalie-layout" || cp "$SSR_FILE" "$SSR_FILE.bak-glalie-layout" 2>/dev/null || true test -f "$PUBLIC_FILE.bak-glalie-layout" || cp "$PUBLIC_FILE" "$PUBLIC_FILE.bak-glalie-layout" 2>/dev/null || true @@ -22,7 +22,8 @@ const crypto = require("crypto"); const ssrFile = "/app/apps/web/.output/server/_ssr/pdf-document-COfeOLVC.mjs"; const publicFile = "/app/apps/web/.output/public/assets/pdf-document-BplbXx-0.js"; const serverIndexFile = "/app/apps/web/.output/server/index.mjs"; -const cacheBust = "rr-glalie-layout-20260518"; +const cacheBust = "rr-glalie-layout-20260519"; +const browserBufferPolyfill = "var Buffer=globalThis.Buffer??{isBuffer:()=>false,allocUnsafe:e=>new Uint8Array(e),alloc:e=>new Uint8Array(e)};/* rr-browser-buffer-polyfill */"; function replaceOnce(source, from, to, label) { if (source.includes(to)) return source; @@ -103,7 +104,20 @@ function patchSsr(source) { .replace(/metrics\.gapY\(2\.2\)/g, "metrics.gapY(3.0)"); } +function ensureBrowserBufferPolyfill(source) { + if (source.includes("rr-browser-buffer-polyfill")) return source; + + const insertAt = source.indexOf(";") + 1; + if (insertAt <= 0 || !source.startsWith("import")) { + throw new Error("public PDF bundle import prelude not found"); + } + + return source.slice(0, insertAt) + browserBufferPolyfill + source.slice(insertAt); +} + function patchPublic(source) { + source = ensureBrowserBufferPolyfill(source); + source = source .replace(/([A-Za-z_$][\w$]*)=([A-Za-z_$][\w$]*)\*\.(?:2|08);return\{paragraph:\{marginTop:\1,marginBottom:\1\},listItem:\{marginTop:\1,marginBottom:\1\}\}/, "$1=$2*.08;return{paragraph:{marginTop:$1,marginBottom:$1},listItem:{marginTop:$1,marginBottom:$1}}") @@ -158,7 +172,7 @@ function patchImporters() { for (const file of files) { let source = fs.readFileSync(file, "utf8"); - source = source.replace(/\.\/pdf-document-BplbXx-0\.js(?:\?v=rr-glalie-layout-20260518)?/g, `./pdf-document-BplbXx-0.js?v=${cacheBust}`); + source = source.replace(/\.\/pdf-document-BplbXx-0\.js(?:\?v=rr-[^"'`]+)?/g, `./pdf-document-BplbXx-0.js?v=${cacheBust}`); fs.writeFileSync(file, source); } @@ -207,3 +221,16 @@ node --check "$SSR_FILE" >/dev/null node --check "$PUBLIC_FILE" >/dev/null node --check "$SERVER_INDEX_FILE" >/dev/null SH + +# Nitro loads the static asset manifest into memory at process startup. Restart +# after patching so updated content-length/etag values are used immediately. +docker restart "$CONTAINER" >/dev/null + +for _ in $(seq 1 60); do + health="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$CONTAINER")" + [ "$health" = "healthy" ] && exit 0 + sleep 2 +done + +docker logs --tail 80 "$CONTAINER" >&2 +exit 1