pcbjam/tests/collab/browser-entry.ts
2026-06-10 17:37:58 +02:00

33 lines
1.1 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,
opts: { channel: string; settleMs?: number },
): ReturnType<typeof startCollab> {
return startCollab(mod, win, {
provider: { kind: "broadcastchannel", settleMs: opts.settleMs },
room: opts.channel,
});
}
declare global {
interface Window {
KicadCollab?: { start: typeof start };
}
}
window.KicadCollab = { start };