pcbjam/tests/collab/browser-entry.ts
Gergő Törcsvári b69ba09ebd
feat: adopt shared wasm wire schemas; resurrect collab e2e bundle (ysync 0008 A)
- standalone wasm/collab/types.ts: the CollabItem/CollabDelta data shapes now
  come from MIT @pcbjam/shared (collab-wire zod schemas) via re-export; the
  RUNTIME adapter interface (CollabBridge) stays here. emptyDelta/isEmptyDelta
  alias the shared helpers — reconciler untouched.
- tests/collab/browser-entry.ts: fix the import path stale since the repo
  restructure (web/apps/frontend → web/standalone) — the collab bundle had been
  silently unbuildable; its opts type now tracks startCollab's real signature.
- tests/kicad/*-collab.spec.ts: update KicadCollab.start calls from the
  pre-ysync-0004 { channel, settleMs } API to { provider: { kind:
  "broadcastchannel", settleMs }, room } — the drift the broken bundle hid.

Verified: pl_editor 2/2, eeschema 2 passed, pcbnew 7 passed (skips pre-existing);
shared 47 unit tests; both typechecks clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 14:05:40 +02:00

34 lines
1.2 KiB
TypeScript

// Browser bundle entry for the collab e2e: bundles the generic reconciler + Yjs +
// BroadcastChannel transport (from the web standalone editor) into a single IIFE
// that the pl_editor static harness page can load via <script>. esbuild resolves
// `yjs` from tests/node_modules.
//
// Build: npm run build:collab (tests/) → tests/apps/kicad/collab-bundle.js
import {
startCollab,
type CollabModule,
type CollabWindow,
} from "../../web/standalone/src/wasm/collab/index";
// The e2e harness API predates the provider abstraction: specs pass a flat
// { channel, settleMs }. Translate to startCollab's ProviderConfig form here so
// the spec/harness callsites stay stable across web-side API evolution.
function start(
mod: CollabModule,
win: CollabWindow,
// Same opts as startCollab itself (ysync 0004: { provider, room }).
opts: Parameters<typeof startCollab>[2],
): ReturnType<typeof startCollab> {
return startCollab(mod, win, {
provider: { kind: "broadcastchannel", settleMs: opts.settleMs },
room: opts.room,
});
}
declare global {
interface Window {
KicadCollab?: { start: typeof start };
}
}
window.KicadCollab = { start };