2026-07-08 10:50:49 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
// Build the GPL standalone for the BACKED editor deployment (editor.pcbjam.com):
|
|
|
|
|
// remote mode against the closed API (projects, libs, auth session cookie) with
|
|
|
|
|
// Yjs board rooms on the same API host (path-routed to the sync worker), pinned
|
|
|
|
|
// to the same CDN WASM root + per-tag manifest as the demo. The mirror of the
|
|
|
|
|
// closed repo's scripts/dev-all.mjs standalone env, with prod origins.
|
|
|
|
|
//
|
|
|
|
|
// node scripts/deploy/build-editor.mjs --tag v1.2.3 --api-base https://api.pcbjam.com
|
|
|
|
|
//
|
|
|
|
|
// Unlike build-demo.mjs there is NO static gallery, NO IDB project layer and NO
|
|
|
|
|
// CDN libs pin: projects and libraries come from the backend (VITE_LIBS_SOURCE=
|
|
|
|
|
// synced → the server's r2-idb-sync bridge). WASM still comes from the CDN.
|
|
|
|
|
|
|
|
|
|
import { execFileSync } from "node:child_process";
|
|
|
|
|
import {
|
|
|
|
|
copyFileSync,
|
|
|
|
|
existsSync,
|
|
|
|
|
lstatSync,
|
|
|
|
|
renameSync,
|
|
|
|
|
rmSync,
|
|
|
|
|
} from "node:fs";
|
|
|
|
|
import { join, resolve } from "node:path";
|
|
|
|
|
|
|
|
|
|
function parseArgs(argv) {
|
|
|
|
|
const a = {
|
|
|
|
|
tag: null,
|
|
|
|
|
cdn: "https://cdn.pcbjam.com",
|
|
|
|
|
apiBase: null,
|
fix: point GPL corresponding-source URLs at the PCBJam org
Every repo moved from emergence-engineering/ to PCBJam/, but the published
source pointers still named the old org. GitHub's transfer redirect resolves
them (all six checked, 301 -> 200), so nothing is broken today — but it stops
working the moment anyone creates a repo at an old path, and a GPLv3
corresponding-source pointer is a poor thing to leave depending on a redirect.
CI never passes --repo, so the hardcoded default is what actually ships: the
editor's version badge on editor.pcbjam.com has been linking users to the old
org for their source.
Covers the source pointers (licenses.md, terms.md 12.4, REPO_URL and its doc
comment, the three build-script --repo defaults, the site footer's build-commit
link) and the two "our GitHub" org links. Bumps the pcbjam-shared pointer for
the same fix there.
Deliberately untouched: emergence-engineering.com, the company domain behind
contact@ and the EE credit block — the trailing slash in the substitution keeps
it out. And docs/security-audit-glm/, which describes a finding rather than
linking anywhere.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 12:19:54 +02:00
|
|
|
repo: "https://github.com/PCBJam/pcbjam",
|
2026-07-08 10:50:49 +02:00
|
|
|
// Yjs endpoint: defaults to the API origin — board rooms are path-routed
|
|
|
|
|
// (`/parties/board-room/*`) to the sync worker on the same hostname, so the
|
|
|
|
|
// same-site session cookie rides the WS handshake.
|
|
|
|
|
yjsEndpoint: null,
|
|
|
|
|
// kicad-packages3D snapshot (libs/kicad-models/<tag>/); omitted ⇒ 3D models off.
|
|
|
|
|
modelsTag: null,
|
|
|
|
|
plausible: null,
|
feat(editor): report uncaught errors to Better Stack
The editor reported nothing when a session died. Evidence lived only in-tab —
an 800-line React array behind a "Show console" button — so diagnosis meant
asking a user to paste a screenshot.
Better Stack's Error Tracking ingests the Sentry wire protocol, so this runs
the stock @sentry/browser against a Better Stack DSN. Sentry.init installs its
own window error/unhandledrejection handlers, so uncaught main-thread errors
and the wasm traps that escape emscripten's DOM event handlers are captured
with no instrumentation at the throw sites. Not their JS tag: it has no
beforeSend or fingerprint hooks, its runtime spawns workers from cross-origin
CDN hosts (this page is COEP: require-corp), and it ships session replay on by
default — which on a CAD canvas records customers' board geometry.
@sentry/browser is imported in exactly one file so the vendor stays swappable,
mirroring how lib/analytics.ts isolates Plausible.
Also replaces the terminal-signature regex with a shared, unit-tested predicate
(wasm/terminal-error.ts) used by BOTH the fatal overlay and the reporter, so
they cannot disagree. The regex was a type check written as a string match and
had three live holes: `RuntimeError` was listed but never appears IN
`.message`; Chrome's bare "unreachable" and "null function" matched nothing
(the v0.1.20 prod log is exactly those); and narrowing "table index is out of
bounds" to `\bindex out of bounds` for Firefox in 197f317 silently stopped
matching Chrome's spelling. Checking the TYPE — every trap in this family is a
WebAssembly.RuntimeError — covers all engines and ends the spelling chase; the
message patterns remain as a fallback for paths that lose the Error object,
such as a worker ErrorEvent crossing the realm boundary with error: null.
197f317's pthread-worker tap, promote() and Firefox findings are kept as-is.
Notes:
- Off unless VITE_ERRORS_DSN is set AND VITE_ALLOW_USER_OVERRIDE !== "1" (dev
servers and every Playwright harness set the latter, and production builds
never do), so a production DSN in a local .env still cannot report. With no
DSN the whole SDK is const-folded out: 1,193,080 vs 1,282,463 bytes of JS.
- browserApiErrors integration removed. It wraps setTimeout/rAF/addEventListener
in try/catch, which is exactly how KiCad-on-Emscripten drives its main loop.
- Console breadcrumbs off (collab/debug.ts's clog fires per Yjs update and would
evict the ring before any crash); dom/fetch/navigation breadcrumbs kept.
- beforeSend redacts token/apiKey/Bearer — collab/provider.ts puts the collab
token in the y-partyserver URL, so a connection-failure string carries a live
credential — and guards the cascade: one wedge produced 8 errors in prod, and
after the first terminal event the rest are dropped into cascade_count.
Verified end to end against the real EU host from a cross-origin-isolated page:
POST /api/<id>/envelope/ -> 200, and 4 terminal throws produce 1 event
(control: 1 throw, same count).
Privacy policy 9, cookie policy 6 and the licenses page are updated: Better
Stack is disclosed as an EU processor, and the licenses page now describes the
browser app's own JS dependencies, which it never did.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 12:24:30 +02:00
|
|
|
// Better Stack error-tracking DSN (Sentry wire format). Omitted ⇒ no error
|
|
|
|
|
// reporting from this build.
|
|
|
|
|
errorsDsn: null,
|
|
|
|
|
errorsEnv: "production",
|
2026-07-16 14:24:31 +02:00
|
|
|
// Companion mgmt app origin; set ⇒ non-editor routes redirect there
|
|
|
|
|
// (standalone-hardening 0006). Omitted ⇒ every route renders locally.
|
|
|
|
|
appBase: null,
|
2026-07-08 10:50:49 +02:00
|
|
|
};
|
|
|
|
|
for (let i = 2; i < argv.length; i++) {
|
|
|
|
|
const next = () => argv[++i];
|
|
|
|
|
switch (argv[i]) {
|
|
|
|
|
case "--tag": a.tag = next(); break;
|
|
|
|
|
case "--cdn": a.cdn = next(); break;
|
|
|
|
|
case "--api-base": a.apiBase = next(); break;
|
|
|
|
|
case "--repo": a.repo = next(); break;
|
|
|
|
|
case "--yjs-endpoint": a.yjsEndpoint = next(); break;
|
|
|
|
|
case "--models-tag": a.modelsTag = next(); break;
|
|
|
|
|
case "--plausible": a.plausible = next(); break;
|
feat(editor): report uncaught errors to Better Stack
The editor reported nothing when a session died. Evidence lived only in-tab —
an 800-line React array behind a "Show console" button — so diagnosis meant
asking a user to paste a screenshot.
Better Stack's Error Tracking ingests the Sentry wire protocol, so this runs
the stock @sentry/browser against a Better Stack DSN. Sentry.init installs its
own window error/unhandledrejection handlers, so uncaught main-thread errors
and the wasm traps that escape emscripten's DOM event handlers are captured
with no instrumentation at the throw sites. Not their JS tag: it has no
beforeSend or fingerprint hooks, its runtime spawns workers from cross-origin
CDN hosts (this page is COEP: require-corp), and it ships session replay on by
default — which on a CAD canvas records customers' board geometry.
@sentry/browser is imported in exactly one file so the vendor stays swappable,
mirroring how lib/analytics.ts isolates Plausible.
Also replaces the terminal-signature regex with a shared, unit-tested predicate
(wasm/terminal-error.ts) used by BOTH the fatal overlay and the reporter, so
they cannot disagree. The regex was a type check written as a string match and
had three live holes: `RuntimeError` was listed but never appears IN
`.message`; Chrome's bare "unreachable" and "null function" matched nothing
(the v0.1.20 prod log is exactly those); and narrowing "table index is out of
bounds" to `\bindex out of bounds` for Firefox in 197f317 silently stopped
matching Chrome's spelling. Checking the TYPE — every trap in this family is a
WebAssembly.RuntimeError — covers all engines and ends the spelling chase; the
message patterns remain as a fallback for paths that lose the Error object,
such as a worker ErrorEvent crossing the realm boundary with error: null.
197f317's pthread-worker tap, promote() and Firefox findings are kept as-is.
Notes:
- Off unless VITE_ERRORS_DSN is set AND VITE_ALLOW_USER_OVERRIDE !== "1" (dev
servers and every Playwright harness set the latter, and production builds
never do), so a production DSN in a local .env still cannot report. With no
DSN the whole SDK is const-folded out: 1,193,080 vs 1,282,463 bytes of JS.
- browserApiErrors integration removed. It wraps setTimeout/rAF/addEventListener
in try/catch, which is exactly how KiCad-on-Emscripten drives its main loop.
- Console breadcrumbs off (collab/debug.ts's clog fires per Yjs update and would
evict the ring before any crash); dom/fetch/navigation breadcrumbs kept.
- beforeSend redacts token/apiKey/Bearer — collab/provider.ts puts the collab
token in the y-partyserver URL, so a connection-failure string carries a live
credential — and guards the cascade: one wedge produced 8 errors in prod, and
after the first terminal event the rest are dropped into cascade_count.
Verified end to end against the real EU host from a cross-origin-isolated page:
POST /api/<id>/envelope/ -> 200, and 4 terminal throws produce 1 event
(control: 1 throw, same count).
Privacy policy 9, cookie policy 6 and the licenses page are updated: Better
Stack is disclosed as an EU processor, and the licenses page now describes the
browser app's own JS dependencies, which it never did.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 12:24:30 +02:00
|
|
|
case "--errors-dsn": a.errorsDsn = next(); break;
|
|
|
|
|
case "--errors-env": a.errorsEnv = next(); break;
|
2026-07-16 14:24:31 +02:00
|
|
|
case "--app-base": a.appBase = next(); break;
|
2026-07-08 10:50:49 +02:00
|
|
|
default: throw new Error(`unknown arg: ${argv[i]}`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!a.tag) throw new Error("--tag <release tag> is required");
|
|
|
|
|
if (!a.apiBase) throw new Error("--api-base <closed API origin> is required");
|
|
|
|
|
a.cdn = a.cdn.replace(/\/+$/, "");
|
|
|
|
|
a.apiBase = a.apiBase.replace(/\/+$/, "");
|
|
|
|
|
a.repo = a.repo.replace(/\/+$/, "");
|
|
|
|
|
a.yjsEndpoint = (a.yjsEndpoint || a.apiBase).replace(/\/+$/, "");
|
2026-07-16 14:24:31 +02:00
|
|
|
if (a.appBase) a.appBase = a.appBase.replace(/\/+$/, "");
|
2026-07-08 10:50:49 +02:00
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Best-effort source commit for the version badge's corresponding-source link
|
|
|
|
|
// (GPLv3): empty string if git isn't available.
|
|
|
|
|
function gitSha(cwd) {
|
|
|
|
|
try {
|
|
|
|
|
return execFileSync("git", ["rev-parse", "HEAD"], { cwd })
|
|
|
|
|
.toString()
|
|
|
|
|
.trim();
|
|
|
|
|
} catch {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
|
const a = parseArgs(process.argv);
|
|
|
|
|
const repoRoot = resolve(process.cwd());
|
|
|
|
|
const standalone = join(repoRoot, "web/standalone");
|
|
|
|
|
const dist = join(standalone, "dist");
|
|
|
|
|
const publicWasm = join(standalone, "public/wasm");
|
2026-08-07 11:52:25 +02:00
|
|
|
// Keep the temporary symlink OUTSIDE public/. Vite copies every public entry,
|
|
|
|
|
// including dot-directories; stashing it under public previously smuggled the
|
|
|
|
|
// full local WASM tree into dist under `.wasm.editor-stashed/`.
|
|
|
|
|
const stash = join(standalone, ".wasm.editor-stashed");
|
2026-07-08 10:50:49 +02:00
|
|
|
|
|
|
|
|
const env = {
|
|
|
|
|
...process.env,
|
|
|
|
|
// Versioned CDN WASM — identical mechanism to the demo build.
|
|
|
|
|
VITE_WASM_ROOT: `${a.cdn}/wasm`,
|
|
|
|
|
VITE_WASM_MANIFEST: `manifest-${a.tag}.json`,
|
|
|
|
|
// Remote mode: projects, files and auth all come from the closed API.
|
|
|
|
|
// (No VITE_PROJECT_SOURCE ⇒ "remote"; no VITE_LOCAL_PROJECTS.)
|
|
|
|
|
VITE_API_BASE_URL: a.apiBase,
|
|
|
|
|
// Live collab: Y.Doc rooms on the sync worker, reached through the API
|
|
|
|
|
// host's path route; documents load from their ydoc.
|
|
|
|
|
VITE_YJS_PROVIDER: "partykit",
|
|
|
|
|
VITE_YJS_ENDPOINT: a.yjsEndpoint,
|
|
|
|
|
VITE_DOC_SOURCE: "ydoc",
|
|
|
|
|
// Libraries through the server's r2-idb-sync bridge (one /bundle per lib,
|
|
|
|
|
// IndexedDB-cached) — NOT the CDN static libs the demo uses.
|
|
|
|
|
VITE_LIBS_SOURCE: "synced",
|
|
|
|
|
// 3D models stay CDN-static when a snapshot tag is given (same as demo).
|
|
|
|
|
...(a.modelsTag
|
|
|
|
|
? {
|
|
|
|
|
VITE_MODELS_MANIFEST_URL: `${a.cdn}/libs/kicad-models/${a.modelsTag}/manifest.json`,
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
// Build identity for the version badge (GPLv3 corresponding source).
|
|
|
|
|
VITE_APP_TAG: a.tag,
|
|
|
|
|
VITE_GIT_SHA: gitSha(repoRoot),
|
|
|
|
|
VITE_REPO_URL: a.repo,
|
analytics: consolidate everything onto one shared Plausible pa- script
All pcbjam properties now load the same new-format Plausible script
(https://plausible.io/js/pa-KjNS9YmidydULZTstsjRg.js — one dashboard,
segment by hostname) instead of per-domain data-domain sites:
- site: replace Vercel Analytics with the pa- snippet in BaseLayout
(is:inline, prod-only, crossorigin="anonymous" for the COEP
require-corp routes in vercel.json); drop @vercel/analytics dep.
Legal pages (cookies/privacy) rewritten Vercel -> Plausible.
- standalone: initAnalytics() rewritten for the new script format
(queue shim + plausible.init(), async, no data-domain). The gate is
now VITE_PLAUSIBLE_SRC (script URL, deploy-time opt-in) — unset means
no tracking, so dev checkouts and third-party GPL builds stay clean.
VITE_PLAUSIBLE_DOMAIN is gone.
- deploy: build-demo/build-editor --plausible now takes the script URL;
release.yml/deploy-demo.yml hardcode the (public) pa- URL, so the
repo Actions variable PLAUSIBLE_DOMAIN is no longer used.
Verified: standalone tsc + vite build (pa- URL present with env, absent
without, crossOrigin kept); astro build has the snippet on all layout
pages and no vercel/insights references; astro dev stays untracked.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 19:34:09 +02:00
|
|
|
...(a.plausible ? { VITE_PLAUSIBLE_SRC: a.plausible } : {}),
|
feat(editor): report uncaught errors to Better Stack
The editor reported nothing when a session died. Evidence lived only in-tab —
an 800-line React array behind a "Show console" button — so diagnosis meant
asking a user to paste a screenshot.
Better Stack's Error Tracking ingests the Sentry wire protocol, so this runs
the stock @sentry/browser against a Better Stack DSN. Sentry.init installs its
own window error/unhandledrejection handlers, so uncaught main-thread errors
and the wasm traps that escape emscripten's DOM event handlers are captured
with no instrumentation at the throw sites. Not their JS tag: it has no
beforeSend or fingerprint hooks, its runtime spawns workers from cross-origin
CDN hosts (this page is COEP: require-corp), and it ships session replay on by
default — which on a CAD canvas records customers' board geometry.
@sentry/browser is imported in exactly one file so the vendor stays swappable,
mirroring how lib/analytics.ts isolates Plausible.
Also replaces the terminal-signature regex with a shared, unit-tested predicate
(wasm/terminal-error.ts) used by BOTH the fatal overlay and the reporter, so
they cannot disagree. The regex was a type check written as a string match and
had three live holes: `RuntimeError` was listed but never appears IN
`.message`; Chrome's bare "unreachable" and "null function" matched nothing
(the v0.1.20 prod log is exactly those); and narrowing "table index is out of
bounds" to `\bindex out of bounds` for Firefox in 197f317 silently stopped
matching Chrome's spelling. Checking the TYPE — every trap in this family is a
WebAssembly.RuntimeError — covers all engines and ends the spelling chase; the
message patterns remain as a fallback for paths that lose the Error object,
such as a worker ErrorEvent crossing the realm boundary with error: null.
197f317's pthread-worker tap, promote() and Firefox findings are kept as-is.
Notes:
- Off unless VITE_ERRORS_DSN is set AND VITE_ALLOW_USER_OVERRIDE !== "1" (dev
servers and every Playwright harness set the latter, and production builds
never do), so a production DSN in a local .env still cannot report. With no
DSN the whole SDK is const-folded out: 1,193,080 vs 1,282,463 bytes of JS.
- browserApiErrors integration removed. It wraps setTimeout/rAF/addEventListener
in try/catch, which is exactly how KiCad-on-Emscripten drives its main loop.
- Console breadcrumbs off (collab/debug.ts's clog fires per Yjs update and would
evict the ring before any crash); dom/fetch/navigation breadcrumbs kept.
- beforeSend redacts token/apiKey/Bearer — collab/provider.ts puts the collab
token in the y-partyserver URL, so a connection-failure string carries a live
credential — and guards the cascade: one wedge produced 8 errors in prod, and
after the first terminal event the rest are dropped into cascade_count.
Verified end to end against the real EU host from a cross-origin-isolated page:
POST /api/<id>/envelope/ -> 200, and 4 terminal throws produce 1 event
(control: 1 throw, same count).
Privacy policy 9, cookie policy 6 and the licenses page are updated: Better
Stack is disclosed as an EU processor, and the licenses page now describes the
browser app's own JS dependencies, which it never did.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 12:24:30 +02:00
|
|
|
// Error tracking. The env tag rides along only when a DSN is given, so a
|
|
|
|
|
// DSN-less build cannot report under a production label.
|
|
|
|
|
...(a.errorsDsn
|
|
|
|
|
? { VITE_ERRORS_DSN: a.errorsDsn, VITE_ERRORS_ENV: a.errorsEnv }
|
|
|
|
|
: {}),
|
2026-07-16 14:24:31 +02:00
|
|
|
// Non-editor surfaces bounce to the mgmt app (mirror of the closed repo's
|
|
|
|
|
// VITE_STANDALONE_URL pointing the other way).
|
|
|
|
|
...(a.appBase ? { VITE_APP_URL: a.appBase } : {}),
|
2026-07-08 10:50:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
console.log(`build-editor: tag=${a.tag} api=${a.apiBase} cdn=${a.cdn}`);
|
|
|
|
|
console.log(` VITE_WASM_ROOT=${env.VITE_WASM_ROOT}`);
|
|
|
|
|
console.log(` VITE_WASM_MANIFEST=${env.VITE_WASM_MANIFEST}`);
|
|
|
|
|
console.log(` VITE_API_BASE_URL=${env.VITE_API_BASE_URL}`);
|
|
|
|
|
console.log(` VITE_YJS_ENDPOINT=${env.VITE_YJS_ENDPOINT} (provider=${env.VITE_YJS_PROVIDER}, doc=${env.VITE_DOC_SOURCE})`);
|
|
|
|
|
console.log(` VITE_LIBS_SOURCE=${env.VITE_LIBS_SOURCE}`);
|
|
|
|
|
console.log(` VITE_MODELS_MANIFEST_URL=${env.VITE_MODELS_MANIFEST_URL ?? "(unset — 3D models off)"}`);
|
|
|
|
|
console.log(` VITE_APP_TAG=${env.VITE_APP_TAG} VITE_GIT_SHA=${env.VITE_GIT_SHA || "(none)"}`);
|
analytics: consolidate everything onto one shared Plausible pa- script
All pcbjam properties now load the same new-format Plausible script
(https://plausible.io/js/pa-KjNS9YmidydULZTstsjRg.js — one dashboard,
segment by hostname) instead of per-domain data-domain sites:
- site: replace Vercel Analytics with the pa- snippet in BaseLayout
(is:inline, prod-only, crossorigin="anonymous" for the COEP
require-corp routes in vercel.json); drop @vercel/analytics dep.
Legal pages (cookies/privacy) rewritten Vercel -> Plausible.
- standalone: initAnalytics() rewritten for the new script format
(queue shim + plausible.init(), async, no data-domain). The gate is
now VITE_PLAUSIBLE_SRC (script URL, deploy-time opt-in) — unset means
no tracking, so dev checkouts and third-party GPL builds stay clean.
VITE_PLAUSIBLE_DOMAIN is gone.
- deploy: build-demo/build-editor --plausible now takes the script URL;
release.yml/deploy-demo.yml hardcode the (public) pa- URL, so the
repo Actions variable PLAUSIBLE_DOMAIN is no longer used.
Verified: standalone tsc + vite build (pa- URL present with env, absent
without, crossOrigin kept); astro build has the snippet on all layout
pages and no vercel/insights references; astro dev stays untracked.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 19:34:09 +02:00
|
|
|
console.log(` VITE_PLAUSIBLE_SRC=${env.VITE_PLAUSIBLE_SRC || "(off)"}`);
|
feat(editor): report uncaught errors to Better Stack
The editor reported nothing when a session died. Evidence lived only in-tab —
an 800-line React array behind a "Show console" button — so diagnosis meant
asking a user to paste a screenshot.
Better Stack's Error Tracking ingests the Sentry wire protocol, so this runs
the stock @sentry/browser against a Better Stack DSN. Sentry.init installs its
own window error/unhandledrejection handlers, so uncaught main-thread errors
and the wasm traps that escape emscripten's DOM event handlers are captured
with no instrumentation at the throw sites. Not their JS tag: it has no
beforeSend or fingerprint hooks, its runtime spawns workers from cross-origin
CDN hosts (this page is COEP: require-corp), and it ships session replay on by
default — which on a CAD canvas records customers' board geometry.
@sentry/browser is imported in exactly one file so the vendor stays swappable,
mirroring how lib/analytics.ts isolates Plausible.
Also replaces the terminal-signature regex with a shared, unit-tested predicate
(wasm/terminal-error.ts) used by BOTH the fatal overlay and the reporter, so
they cannot disagree. The regex was a type check written as a string match and
had three live holes: `RuntimeError` was listed but never appears IN
`.message`; Chrome's bare "unreachable" and "null function" matched nothing
(the v0.1.20 prod log is exactly those); and narrowing "table index is out of
bounds" to `\bindex out of bounds` for Firefox in 197f317 silently stopped
matching Chrome's spelling. Checking the TYPE — every trap in this family is a
WebAssembly.RuntimeError — covers all engines and ends the spelling chase; the
message patterns remain as a fallback for paths that lose the Error object,
such as a worker ErrorEvent crossing the realm boundary with error: null.
197f317's pthread-worker tap, promote() and Firefox findings are kept as-is.
Notes:
- Off unless VITE_ERRORS_DSN is set AND VITE_ALLOW_USER_OVERRIDE !== "1" (dev
servers and every Playwright harness set the latter, and production builds
never do), so a production DSN in a local .env still cannot report. With no
DSN the whole SDK is const-folded out: 1,193,080 vs 1,282,463 bytes of JS.
- browserApiErrors integration removed. It wraps setTimeout/rAF/addEventListener
in try/catch, which is exactly how KiCad-on-Emscripten drives its main loop.
- Console breadcrumbs off (collab/debug.ts's clog fires per Yjs update and would
evict the ring before any crash); dom/fetch/navigation breadcrumbs kept.
- beforeSend redacts token/apiKey/Bearer — collab/provider.ts puts the collab
token in the y-partyserver URL, so a connection-failure string carries a live
credential — and guards the cascade: one wedge produced 8 errors in prod, and
after the first terminal event the rest are dropped into cascade_count.
Verified end to end against the real EU host from a cross-origin-isolated page:
POST /api/<id>/envelope/ -> 200, and 4 terminal throws produce 1 event
(control: 1 throw, same count).
Privacy policy 9, cookie policy 6 and the licenses page are updated: Better
Stack is disclosed as an EU processor, and the licenses page now describes the
browser app's own JS dependencies, which it never did.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 12:24:30 +02:00
|
|
|
console.log(` VITE_ERRORS_DSN=${env.VITE_ERRORS_DSN ? `(set, env=${env.VITE_ERRORS_ENV})` : "(off)"}`);
|
2026-07-16 14:24:31 +02:00
|
|
|
console.log(` VITE_APP_URL=${env.VITE_APP_URL || "(unset — no non-editor redirect)"}`);
|
2026-07-08 10:50:49 +02:00
|
|
|
|
|
|
|
|
// Keep the dev-only WASM symlink out of the bundle (CDN serves it).
|
|
|
|
|
const hadWasm = existsSync(publicWasm) || isSymlink(publicWasm);
|
|
|
|
|
if (hadWasm) renameSync(publicWasm, stash);
|
|
|
|
|
try {
|
|
|
|
|
execFileSync(
|
|
|
|
|
"pnpm",
|
|
|
|
|
["--dir", "web", "--filter", "@pcbjam/standalone", "build"],
|
|
|
|
|
{ cwd: repoRoot, env, stdio: "inherit" },
|
|
|
|
|
);
|
|
|
|
|
} finally {
|
|
|
|
|
if (hadWasm) renameSync(stash, publicWasm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Belt-and-suspenders: never ship local wasm even if a copy slipped through.
|
|
|
|
|
rmSync(join(dist, "wasm"), { recursive: true, force: true });
|
2026-08-07 11:52:25 +02:00
|
|
|
rmSync(join(dist, ".wasm.editor-stashed"), { recursive: true, force: true });
|
2026-07-08 10:50:49 +02:00
|
|
|
|
|
|
|
|
// Same Pages headers as the demo: COOP/COEP for WASM threads (the API's CORS
|
|
|
|
|
// satisfies COEP for credentialed cross-origin fetches) + SPA fallback.
|
|
|
|
|
for (const f of ["_headers", "_redirects"]) {
|
|
|
|
|
copyFileSync(join(repoRoot, "deploy/demo", f), join(dist, f));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(`done → ${dist} (ready for: wrangler pages deploy)`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isSymlink(p) {
|
|
|
|
|
try {
|
|
|
|
|
return lstatSync(p).isSymbolicLink();
|
|
|
|
|
} catch {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main();
|