feat(standalone): env-selected Yjs provider abstraction (ysync 0004)
Generalize the collab transport into a provider registry (none |
broadcastchannel | partykit | hocuspocus), one active per env. startCollab
takes { provider, room } and awaits provider.whenSynced() before seed/adopt.
Network libs lazily imported; room id from @pcbjam/shared collabRoomId.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cf18efcf66
commit
285efe7a06
9 changed files with 308 additions and 28 deletions
|
|
@ -7,3 +7,21 @@ export const API_BASE_URL =
|
|||
// to also satisfy the worker/COEP constraints.
|
||||
export const WASM_ASSET_BASE_URL =
|
||||
import.meta.env.VITE_WASM_ASSET_BASE_URL ?? "/wasm";
|
||||
|
||||
import type { ProviderConfig, ProviderKind } from "@/wasm/collab";
|
||||
|
||||
/**
|
||||
* Which Yjs collab provider this deployment uses (one active per env), and its
|
||||
* endpoint/token. Defaults to `broadcastchannel` so a vanilla checkout keeps
|
||||
* the cross-tab-only behavior with no backend. Built here at the composition
|
||||
* root and passed into `startCollab`, so `wasm/collab` stays env-agnostic.
|
||||
*/
|
||||
export function yjsProviderConfig(): ProviderConfig {
|
||||
const kind = (import.meta.env.VITE_YJS_PROVIDER ?? "broadcastchannel") as ProviderKind;
|
||||
const token = import.meta.env.VITE_YJS_TOKEN;
|
||||
return {
|
||||
kind,
|
||||
endpoint: import.meta.env.VITE_YJS_ENDPOINT,
|
||||
params: token ? { token } : undefined,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue