@lavitre/apps 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/dist/Common/AiChannel.d.ts +59 -0
- package/dist/Common/AiChannel.js +97 -0
- package/dist/Common/AiChannel.js.map +1 -0
- package/dist/Common/BlobStore.d.ts +44 -0
- package/dist/Common/BlobStore.js +186 -0
- package/dist/Common/BlobStore.js.map +1 -0
- package/dist/Common/Common.Model.d.ts +1020 -0
- package/dist/Common/Common.Model.js +21 -0
- package/dist/Common/Common.Model.js.map +1 -0
- package/dist/Common/CrdtChannel.d.ts +198 -0
- package/dist/Common/CrdtChannel.js +659 -0
- package/dist/Common/CrdtChannel.js.map +1 -0
- package/dist/Common/Version.d.ts +21 -0
- package/dist/Common/Version.js +62 -0
- package/dist/Common/Version.js.map +1 -0
- package/dist/Common/index.d.ts +6 -0
- package/dist/Common/index.js +32 -0
- package/dist/Common/index.js.map +1 -0
- package/dist/CompanionConnector/CompanionConnector.Model.d.ts +85 -0
- package/dist/CompanionConnector/CompanionConnector.Model.js +17 -0
- package/dist/CompanionConnector/CompanionConnector.Model.js.map +1 -0
- package/dist/CompanionConnector/CompanionConnector.d.ts +28 -0
- package/dist/CompanionConnector/CompanionConnector.js +385 -0
- package/dist/CompanionConnector/CompanionConnector.js.map +1 -0
- package/dist/CompanionConnector/index.d.ts +2 -0
- package/dist/CompanionConnector/index.js +3 -0
- package/dist/CompanionConnector/index.js.map +1 -0
- package/dist/CompanionFrame/CompanionFrame.d.ts +103 -0
- package/dist/CompanionFrame/CompanionFrame.js +100 -0
- package/dist/CompanionFrame/CompanionFrame.js.map +1 -0
- package/dist/CompanionFrame/index.d.ts +1 -0
- package/dist/CompanionFrame/index.js +2 -0
- package/dist/CompanionFrame/index.js.map +1 -0
- package/dist/Connector/Connector.Model.d.ts +567 -0
- package/dist/Connector/Connector.Model.js +2 -0
- package/dist/Connector/Connector.Model.js.map +1 -0
- package/dist/Connector/Connector.d.ts +227 -0
- package/dist/Connector/Connector.js +1337 -0
- package/dist/Connector/Connector.js.map +1 -0
- package/dist/Connector/index.d.ts +2 -0
- package/dist/Connector/index.js +3 -0
- package/dist/Connector/index.js.map +1 -0
- package/dist/Frame/Frame.Model.d.ts +533 -0
- package/dist/Frame/Frame.Model.js +2 -0
- package/dist/Frame/Frame.Model.js.map +1 -0
- package/dist/Frame/Frame.d.ts +309 -0
- package/dist/Frame/Frame.js +1408 -0
- package/dist/Frame/Frame.js.map +1 -0
- package/dist/Frame/SyncAdapter.d.ts +75 -0
- package/dist/Frame/SyncAdapter.js +134 -0
- package/dist/Frame/SyncAdapter.js.map +1 -0
- package/dist/Frame/index.d.ts +3 -0
- package/dist/Frame/index.js +4 -0
- package/dist/Frame/index.js.map +1 -0
- package/dist/MediaLink/MediaLink.d.ts +178 -0
- package/dist/MediaLink/MediaLink.js +1432 -0
- package/dist/MediaLink/MediaLink.js.map +1 -0
- package/dist/MediaLink/index.d.ts +1 -0
- package/dist/MediaLink/index.js +2 -0
- package/dist/MediaLink/index.js.map +1 -0
- package/dist/Native/index.d.ts +170 -0
- package/dist/Native/index.js +19 -0
- package/dist/Native/index.js.map +1 -0
- package/dist/Version.d.ts +1 -0
- package/dist/Version.js +2 -0
- package/dist/Version.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Frame.js","sourceRoot":"","sources":["../../Frame/Frame.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MA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QACH,CAAC,CAAA;QAEH,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,cAAc,CACtC,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,QAAyB,EAAE,EAAE;YAC1D,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAA;QACpD,CAAC,CACF,CAAA;QAED,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB;YACE,IAAI,EAAE,gCAAgC;YACtC,OAAO,EAAE,UAAU;SACpB,EACD,GAAG,EACH,CAAC,OAAO,CAAC,KAAK,CAAC,CAChB,CAAA;QAED,MAAM,CAAC,gBAAgB,CACrB,SAAS,EACT,cAAc,CACZ,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,QAAyB,EAAE,EAAE;YACzD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;QACtD,CAAC,CACF,EACD,KAAK,CACN,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/// <reference path=\"../Connector/insertable-streams.d.ts\" />\nimport { v4 as uuid } from 'uuid'\nimport type * as Y from 'yjs'\nimport { CrdtChannel, MIN_CRDT_HOST_VERSION } from '../Common/CrdtChannel.js'\nimport { BlobStore } from '../Common/BlobStore.js'\nimport { AiChannel, MIN_AI_HOST_VERSION } from '../Common/AiChannel.js'\nimport { isMinVersion } from '../Common/index.js'\nimport type {\n AppId,\n BluetoothFromApp,\n BluetoothToApp,\n BorderOptions,\n CompanionInformation,\n ConnectedMediaDevice,\n Device,\n DeviceFrameReference,\n DeviceFullscreenUpdated,\n DeviceMessageReceived,\n DeviceScalingUpdated,\n Field,\n FileData,\n FramePeer,\n HostInformation,\n KnockKnock,\n LayoutPosition,\n LoadedFrame,\n MessageTarget,\n NotificationButtonClicked,\n NotificationInfo,\n PositionUpdated,\n Privacy,\n Rect,\n ReplacedBy,\n RequestSerialPortAccess,\n RequestStreamSizeUpdate,\n SendKnockKnock,\n SendMessageTo,\n SendMessageToAll,\n SendToSerialPort,\n StateReplaced,\n StatsResponse,\n StreamCapture,\n UpdatedStateEntry,\n UpdateStateEntry,\n Visibility,\n VisibilityChanged,\n VitreSettings,\n VitreSettingsSetter,\n VoiceAction,\n VoiceActionDetection,\n} from '../Common/index.js'\nimport type {\n Connector,\n ShareStreamOptions,\n ShareStreamTrack,\n} from '../Connector/index.js'\nimport type { MediaTrackInfo } from '../Connector/Connector.Model.js'\nimport { apiVersion } from '../Version.js'\nimport type {\n ApplyStreamAdvancedConstraints,\n AvailableExportSource,\n ExportData,\n ExportRequest,\n FrameApiMessagesIn,\n FrameApiMessagesOut,\n FrameMenuEntry,\n IceServerConfig,\n InitFrameOptions,\n InitializeFrame,\n SharedStreamPlayState,\n ViewOptions,\n} from './Frame.Model.js'\n\ninterface RequestResolver {\n isHandled: (msg: FrameApiMessagesIn) => boolean\n}\n\nexport type SharedStreamState = {\n position: number\n duration: number\n volume: number\n state: SharedStreamPlayState\n}\n\nexport type SharedStream = {\n lastState: SharedStreamState\n play: () => void\n pause: () => void\n seek: (position: number, isRelative?: boolean) => void\n setVolume: (volume: number) => void\n}\n\nexport class Frame {\n public onDeviceJoined?: (device: Device) => void\n public onDeviceLeft?: (deviceId: string) => void\n public onDeviceMessageReceived?: (message: DeviceMessageReceived) => void\n public onLocalConnectorMessageReceived?: (\n message: any,\n from?: string,\n fileData?: FileData,\n ) => void\n public onMenuClicked?: (menuId: string, tag: any, isChecked: boolean) => void\n public onFieldUpdated?: (field: Field) => void\n public onInteractingChanged?: (isInteracting: boolean) => void\n public onPrivacyChanged?: (privacy: Privacy) => void\n public onFileProgress?: (bytes: number, totalBytes: number) => void\n public onFileLoaded?: (file: ArrayBufferLike) => void\n public onExportRequest?: (\n request: ExportRequest,\n resolve: (data: ExportData) => void,\n reject: (error: string) => void,\n ) => void\n public onKnockKnock?: (knockKnock: KnockKnock) => void\n public onSettingsUpdated?: (settings: any) => void\n public onVitreSettingsUpdated?: (settings: VitreSettings) => void\n public onConnectionCodeUpdated?: (companionCode?: string) => void\n public onNotificationDismissed?: (notificationId: string) => void\n public onNotificationButtonClicked?: (\n notificationButton: NotificationButtonClicked,\n ) => void\n public onDevicePrivacyChanged?: (device: Device) => void\n public onDeviceFrameLoaded?: (\n deviceFrameReference: DeviceFrameReference,\n ) => void\n public onDeviceFrameConnectorLoaded?: (\n deviceFrameReference: DeviceFrameReference,\n ) => void\n public onDeviceFrameUnloaded?: (\n deviceFrameReference: DeviceFrameReference,\n ) => void\n public onMessageReceived?: (msg: FrameApiMessagesIn) => void\n public onPendingDevicesConnectionRequested?: (\n pendingClients: Device[],\n ) => void\n /**\n * Peer-presence events for the companion frame. `onCompanionFramePeersUpdated`\n * is the AUTHORITATIVE full snapshot — it fires on every change with the\n * complete current peer set. `onCompanionFramePeerJoined` /\n * `onCompanionFramePeerLeft` are convenience incremental events derived\n * from the same underlying stream.\n *\n * Subscribe to ONE model, not both: either consume the snapshot and\n * recompute, or consume the incremental pair — wiring up both will\n * double-count every transition.\n */\n public onCompanionFramePeerJoined?: (peer: FramePeer) => void\n public onCompanionFramePeerLeft?: (peerId: string) => void\n public onCompanionFramePeersUpdated?: (peers: FramePeer[]) => void\n /**\n * @deprecated Use onBorderOptionsUpdated\n */\n public onBorderlessChanged?: (isBorderless: boolean) => void\n public onFullscreenChanged?: (isFullscreen: boolean) => void\n public onBorderOptionsUpdated?: (borderOptions: BorderOptions) => void\n public onVoiceActionDetected?: (voiceAction: VoiceActionDetection) => void\n public onStateReplaced?: (\n newState: Record<string, any>,\n oldState: Record<string, any>,\n replacedBy: ReplacedBy,\n delta: UpdatedStateEntry[],\n ) => void\n public onPositionUpdated?: (positionUpdate: PositionUpdated) => void\n public onDeviceFullscreenUpdated?: (\n deviceFullscreenUpdated: DeviceFullscreenUpdated,\n ) => void\n public onVisibilityChanged?: (msg: VisibilityChanged) => void\n public onDeviceScalingUpdated?: (msg: DeviceScalingUpdated) => void\n public onUpdateFrameName?: (name: string) => void\n public onSharedStreamUpdate?: (msg: SharedStreamState) => void\n /**\n * Reverse breakout box: fires when the Vitre host exposes a live\n * `MediaStream` it owns INTO this frame (e.g. a received shared camera, or a\n * companion stream routed to this frame for transformation). The stream is\n * rebuilt locally via `MediaStreamTrackGenerator` from transferred readables\n * — zero re-encode, same-site + Chromium only. `streamId` matches a later\n * `onSharedStreamRemoved`. Inverse of {@link shareStream}.\n */\n public onSharedStream?: (streamId: string, stream: MediaStream) => void\n public onSharedStreamRemoved?: (streamId: string) => void\n public onMediaDevicesChanged?: (devices: ConnectedMediaDevice[]) => void\n public onBluetoothMessage?: (msg: BluetoothToApp) => void\n /** @deprecated Use `crdt.onSynced` */\n public onYjsSynced?: () => void\n /** @deprecated Subscribe via `crdt.doc.on('update', ...)` instead. */\n public onYjsUpdate?: (update: Uint8Array) => void\n public hostInformation: HostInformation\n /**\n * The companion's own identity/runtime context, present only when this\n * frame is loaded by a la Vitre **companion** (`hostInformation.isCompanion`\n * is then true). Undefined on Vitre-side frames. Mirrors\n * `CompanionConnector.companionInformation`. Added 1.19.\n */\n public companionInformation?: CompanionInformation\n public initiator: Device\n public id: string\n public appId: string\n public initOptions: InitFrameOptions\n /**\n * @deprecated Use initOptions.border.modeinitOptions\n */\n public isBorderless: boolean\n public isFullscreen: boolean\n public state: Record<string, any> = {}\n\n /**\n * CRDT channel — Yjs doc + Awareness piped over the la Vitre transport.\n * Libraries (Carbone, …) can call `crdt.attach(doc, awareness)` to bring\n * their own; simple apps use `crdt.doc` / `crdt.awareness` directly.\n */\n public readonly crdt: CrdtChannel\n\n /**\n * CRDT-backed blob store built on `crdt.attachSubdoc` — see Connector.blobs.\n */\n public readonly blobs: BlobStore\n\n /**\n * AI tool channel — publish a catalog of tools the on-prem agent's LLM can call\n * on this frame: `ai.registerTools([{ name, description, parameters, sensitive }],\n * (name, args) => …)`. Register SIMPLE local names; the host namespaces them as\n * `<appId>__<name>`. Invocations run against the handler and reply automatically.\n */\n public readonly ai: AiChannel\n\n /** @deprecated Use `crdt.doc`. See Connector.yjsDoc for the setter\n * rationale (legacy field-assignment backward-compat). */\n get yjsDoc() {\n return this.crdt.doc\n }\n set yjsDoc(doc: Y.Doc) {\n this.crdt.attach(doc)\n }\n\n public position: Rect\n public zIndex: number\n\n constructor(\n // `protected` (not `private`) so the companion-only subclass\n // `CompanionFrameImpl` (CompanionFrame.ts) can post its companion-frame\n // messages while keeping those methods off the Vitre `Frame` surface.\n protected readonly postMessage: PostMessageFrameApiOut,\n initMessage: InitializeFrame,\n public options: ViewOptions,\n initState?: Record<string, any>,\n ) {\n this.hostInformation = initMessage.hostInfo\n this.companionInformation = initMessage.companionInfo\n this.initiator = initMessage.initiator\n this.id = initMessage.id\n this.appId = initMessage.appId ?? ''\n this.initOptions = initMessage.options\n this.isBorderless = initMessage.isBorderless\n this.isFullscreen = initMessage.isFullscreen\n this.position = initMessage.position\n this.zIndex = 0\n this.isFullscreen = initMessage.isFullscreen\n\n this.postMessage({\n type: 'frameInitialized',\n options,\n })\n\n const w = window as any\n w.frameConnector = this\n w.connector = this\n this.state = initState ?? {}\n\n // Mirror of the Connector guard — both connectors must behave\n // identically. See MIN_CRDT_HOST_VERSION for the rationale.\n //\n // Exception: a companion frame (`hostInformation.isCompanion`) is never\n // gated. Its host is the la-Vitre companion, which is deployed centrally\n // and always runs HEAD, so it always carries the CRDT relay. Gating it is\n // also actively harmful: the version it advertises is the companion's OWN\n // build version, and a misconfigured deploy can ship a stale placeholder\n // (a preview build shipped `1.2.0.0`), which silently disables Yjs sync\n // for every companion frame. The real sync peer is the Vitre, whose own\n // gate still applies on its side.\n const crdtSupported =\n this.hostInformation.isCompanion === true ||\n isMinVersion(this.hostInformation.version, MIN_CRDT_HOST_VERSION)\n this.crdt = new CrdtChannel((message, transfer) => {\n // Same as Connector: `FrameApiMessagesOut` already includes the four\n // `crdt*` arms (Frame.Model.ts), so no cast is needed.\n if (!crdtSupported) return\n this.postMessage(message, transfer)\n })\n this.crdt.onSynced(() => this.onYjsSynced?.())\n this.crdt.onUpdate((update) => this.onYjsUpdate?.(update))\n this.blobs = new BlobStore(this.crdt)\n\n // AI tool channel — same companion-exception + version gate as CRDT (a host\n // that predates the ai bridge ignores the unknown arms and never invokes).\n const aiSupported =\n this.hostInformation.isCompanion === true ||\n isMinVersion(this.hostInformation.version, MIN_AI_HOST_VERSION)\n this.ai = new AiChannel((message) => {\n if (!aiSupported) return\n this.postMessage(message)\n })\n\n if (this.state['@sharedStreamState.state']) {\n this.sharedStream.lastState = {\n ...this.sharedStream.lastState,\n state: this.state['@sharedStreamState.state'] as SharedStreamPlayState,\n }\n }\n if (typeof this.state['@sharedStreamState.duration'] === 'number') {\n this.sharedStream.lastState = {\n ...this.sharedStream.lastState,\n duration: this.state['@sharedStreamState.duration'] as number,\n }\n }\n if (typeof this.state['@sharedStreamState.position'] === 'number') {\n this.sharedStream.lastState = {\n ...this.sharedStream.lastState,\n position: this.state['@sharedStreamState.position'] as number,\n }\n }\n }\n\n private resolveRequest(msg: FrameApiMessagesIn) {\n this.requestResolvers = this.requestResolvers.filter(\n (rr) => !rr.isHandled(msg),\n )\n }\n\n raiseMessage(msg: FrameApiMessagesIn) {\n this.resolveRequest(msg)\n\n switch (msg.type) {\n case 'privacyChanged':\n this.hostInformation = {\n ...this.hostInformation,\n device: { ...this.hostInformation.device, privacy: msg.privacy },\n }\n this.onPrivacyChanged?.(msg.privacy)\n break\n case 'deviceJoined':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: [\n ...this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.device.id,\n ),\n msg.device,\n ],\n }\n this.onDeviceJoined?.(msg.device)\n break\n case 'deviceLeft':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.deviceId,\n ),\n }\n this.onDeviceLeft?.(msg.deviceId)\n break\n case 'deviceMessageReceived':\n this.onDeviceMessageReceived?.(msg)\n break\n case 'localConnectorMessageReceived':\n this.onLocalConnectorMessageReceived?.(msg.data, msg.from, msg.fileData)\n break\n case 'menuClicked':\n this.onMenuClicked?.(msg.menuId, msg.tag, msg.isChecked)\n break\n case 'fieldUpdated':\n this.onFieldUpdated?.(msg.field)\n break\n case 'isInteractingChanged':\n this.onInteractingChanged?.(msg.isInteracting)\n break\n case 'borderlessUpdated':\n this.isBorderless = msg.isBorderless\n this.onBorderlessChanged?.(msg.isBorderless)\n break\n case 'fullscreenUpdated':\n this.isFullscreen = msg.isFullscreen\n this.onFullscreenChanged?.(msg.isFullscreen)\n break\n case 'fileLoaded':\n this.onFileLoaded?.(msg.file)\n break\n case 'fileProgress':\n this.onFileProgress?.(msg.bytes, msg.totalBytes)\n break\n case 'exportRequest':\n {\n const resolve = (data: ExportData) => {\n this.postMessage({\n type: 'exportDone',\n request: msg,\n data,\n })\n }\n\n const reject = (error: string) => {\n this.postMessage({\n type: 'exportDone',\n request: msg,\n error,\n })\n }\n this.onExportRequest?.(msg, resolve, reject)\n }\n break\n case 'knockKnockReceived':\n this.onKnockKnock?.(msg)\n break\n case 'settingsUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n settings: msg.settings,\n }\n this.onSettingsUpdated?.(msg.settings)\n break\n case 'vitreSettingsUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n space: msg.currentSpace,\n vitreSettings: msg,\n device: {\n ...this.hostInformation.device,\n name: msg.name ?? this.hostInformation.device.name,\n color: msg.color,\n },\n }\n this.onVitreSettingsUpdated?.(msg)\n break\n case 'connectionCodeUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n companionCode: msg.companionCode,\n }\n this.onConnectionCodeUpdated?.(msg.companionCode)\n break\n case 'notificationButtonClicked':\n this.onNotificationButtonClicked?.(msg)\n break\n case 'notificationDismissed':\n this.onNotificationDismissed?.(msg.id)\n break\n case 'devicePrivacyChanged':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: [\n ...this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.device.id,\n ),\n msg.device,\n ],\n }\n this.onDevicePrivacyChanged?.(msg.device)\n break\n case 'deviceFrameLoaded':\n this.onDeviceFrameLoaded?.(msg)\n break\n case 'deviceFrameUnloaded':\n this.onDeviceFrameUnloaded?.(msg)\n break\n case 'deviceFrameConnectorLoaded':\n this.onDeviceFrameConnectorLoaded?.(msg)\n break\n case 'pendingDevicesConnectionRequested':\n this.onPendingDevicesConnectionRequested?.(msg.pendingDevices)\n break\n case 'borderOptionsUpdated':\n this.onBorderOptionsUpdated?.(msg)\n break\n case 'voiceActionDetected':\n this.onVoiceActionDetected?.(msg)\n break\n case 'stateReplaced':\n this._onStateReplaced(msg)\n break\n case 'positionUpdated':\n this.position = msg.position\n this.zIndex = msg.zIndex\n this.isFullscreen = msg.isFullscreen\n this.onPositionUpdated?.(msg)\n break\n case 'deviceFullscreenUpdated':\n this.hostInformation.devicesInSpace =\n this.hostInformation.devicesInSpace.map((d) =>\n d.id === msg.deviceId ? { ...d, fullscreen: msg.fullscreen } : d,\n )\n this.onDeviceFullscreenUpdated?.(msg)\n break\n case 'visibilityChanged':\n this.onVisibilityChanged?.(msg)\n break\n case 'deviceScalingUpdated':\n if (msg.deviceId === this.hostInformation.device.id) {\n this.hostInformation.device.sendingScaling = msg.sendingScaling\n this.hostInformation.device.orientation = msg.orientation\n this.hostInformation.device.orientationBy = msg.orientationBy\n }\n this.hostInformation.devicesInSpace =\n this.hostInformation.devicesInSpace.map((d) =>\n d.id === msg.deviceId\n ? {\n ...d,\n sendingScaling: msg.sendingScaling,\n orientation: msg.orientation,\n orientationBy: msg.orientationBy,\n }\n : d,\n )\n this.onDeviceScalingUpdated?.(msg)\n break\n case 'updateFrameName':\n this.options.name = msg.name\n this.onUpdateFrameName?.(msg.name)\n break\n case 'localSharedStreamUpdate':\n this.sharedStream.lastState = {\n ...this.sharedStream.lastState,\n volume: msg.volume,\n }\n this.onSharedStreamUpdate?.(this.sharedStream.lastState)\n break\n case 'sharedStreamAvailable': {\n // Reverse breakout box — rebuild a live MediaStream from the readables\n // the host transferred into this frame (one MediaStreamTrackGenerator\n // per track; pipe the readable into its writable). Mirrors the host's\n // tracksFromReadables / SDK toShareTracks on the share side.\n const tracks = msg.tracks.map((t) => {\n const generator = new MediaStreamTrackGenerator({ kind: t.kind })\n t.readable.pipeTo(generator.writable).catch(() => {})\n return generator as MediaStreamTrack\n })\n this.onSharedStream?.(msg.streamId, new MediaStream(tracks))\n break\n }\n case 'sharedStreamRemoved':\n this.onSharedStreamRemoved?.(msg.streamId)\n break\n case 'mediaDevicesChanged':\n this.hostInformation = {\n ...this.hostInformation,\n vitreSettings: {\n ...this.hostInformation.vitreSettings,\n availableMediaDevices: msg.devices,\n },\n }\n this.onMediaDevicesChanged?.(msg.devices)\n break\n case 'bluetooth':\n this.onBluetoothMessage?.(msg)\n break\n case 'crdtUpdate':\n case 'crdtSyncComplete':\n case 'crdtRequestSync':\n case 'crdtAwarenessUpdate':\n case 'crdtSubdocUpdate':\n case 'crdtSubdocSyncComplete':\n case 'crdtSubdocTransferProgress':\n case 'crdtSubdocRequestSync':\n this.crdt.handleMessage(msg)\n break\n case 'aiInvoke':\n void this.ai.handleInvoke(msg.id, msg.name, msg.args)\n break\n case 'companionFramePeerJoined':\n this.onCompanionFramePeerJoined?.(msg.peer)\n break\n case 'companionFramePeerLeft':\n this.onCompanionFramePeerLeft?.(msg.peerId)\n break\n case 'companionFramePeersUpdated':\n this.onCompanionFramePeersUpdated?.(msg.peers)\n break\n }\n\n this.onMessageReceived?.(msg)\n }\n\n private _onStateReplaced(msg: StateReplaced) {\n const oldState = this.state\n this.state = msg.state\n\n let hasSharedStreamUpdate = false\n\n msg.delta.forEach((update) => {\n if (\n update.key === '@sharedStreamState.state' &&\n update.action === 'add'\n ) {\n this.sharedStream.lastState = {\n ...this.sharedStream.lastState,\n state: update.value as SharedStreamPlayState,\n }\n hasSharedStreamUpdate = true\n } else if (\n update.key === '@sharedStreamState.duration' &&\n update.action === 'add'\n ) {\n this.sharedStream.lastState = {\n ...this.sharedStream.lastState,\n duration: update.value as number,\n }\n hasSharedStreamUpdate = true\n } else if (\n update.key === '@sharedStreamState.position' &&\n update.action === 'add'\n ) {\n this.sharedStream.lastState = {\n ...this.sharedStream.lastState,\n position: update.value as number,\n }\n hasSharedStreamUpdate = true\n }\n })\n\n if (hasSharedStreamUpdate) {\n this.onSharedStreamUpdate?.(this.sharedStream.lastState)\n }\n\n this.onStateReplaced?.(this.state, oldState, msg.replacedBy, msg.delta)\n }\n\n public sendMessageTo(message: SendMessageTo) {\n this.postMessage({ type: 'sendMessageTo', ...message })\n }\n\n public sendMessageToAll(message: SendMessageToAll) {\n this.postMessage({ type: 'sendMessageToAll', ...message })\n }\n\n public sendKnockKnock(message: SendKnockKnock) {\n this.postMessage({ type: 'sendKnockKnock', ...message })\n }\n\n /** Release the resources owned by this frame. Tears the CRDT channel\n * down (unbinds doc/awareness listeners, destroys the default Y.Doc +\n * Awareness). Safe to call multiple times. */\n public destroy(): void {\n this.crdt.destroy()\n }\n\n public setFullscreen() {\n this.postMessage({\n type: 'setFullscreen',\n })\n }\n\n public setMenu(menu: FrameMenuEntry[]) {\n this.postMessage({\n type: 'setFrameMenu',\n menu,\n })\n }\n\n /**\n * SDK 1.47 — replace the frame's export sources after initialization.\n *\n * The initial set comes from the `ViewOptions.exportSources` returned by\n * `initializeFrame`; this is the only way to change it afterwards, e.g.\n * when a document gains a format, or to flip `availableForCompanion` on a\n * source once it becomes too large to hand to a phone.\n *\n * The call REPLACES the whole list — pass every source you still want,\n * not just the new ones. The host rebuilds both its own export menu and\n * the companions' from it.\n */\n public setExportSources(exportSources: AvailableExportSource[]) {\n this.postMessage({\n type: 'setExportSources',\n exportSources,\n })\n }\n\n public applyStreamAdvancedConstraints(\n constraints: ApplyStreamAdvancedConstraints,\n ) {\n this.postMessage({\n ...constraints,\n type: 'applyStreamAdvancedConstraints',\n })\n }\n\n /**\n * Replace the video track of this frame's shared stream with a fresh\n * `getUserMedia` capture matching `constraints` (e.g. to switch camera),\n * keeping the same share alive (`replaceTrack` on the host, no\n * renegotiation). The host forces the requested `deviceId` as `{ exact }`.\n * Resolves with the new track infos so the frame can rebuild its menu.\n */\n public async requestReplaceStream(\n constraints: MediaStreamConstraints,\n ): Promise<MediaTrackInfo[]> {\n const requestId = uuid()\n return await this.postRequest<MediaTrackInfo[]>(\n { type: 'replaceFrameStream', requestId, constraints },\n (msg, resolve, reject) => {\n if (\n msg.type === 'replaceFrameStreamCompleted' &&\n msg.requestId === requestId\n ) {\n if (msg.error != null || msg.tracks == null) {\n reject(msg.error ?? 'replaceFrameStream failed')\n } else {\n resolve(msg.tracks)\n }\n }\n },\n )\n }\n\n public setWindowed() {\n this.postMessage({\n type: 'setWindowed',\n })\n }\n\n public close() {\n this.postMessage({\n type: 'close',\n })\n }\n\n public sendToLocalFrame(\n frameConnectorId: string,\n data: any,\n fileData?: FileData,\n ) {\n this.postMessage({\n type: 'sendToLocalFrame',\n frameConnectorId,\n data,\n fileData,\n })\n }\n\n public sendToLocalMainConnector(data: any, fileData?: FileData) {\n this.postMessage({\n type: 'sendToLocalFrame',\n frameConnectorId: undefined,\n data,\n fileData,\n })\n }\n\n /**\n * Convenience for companion frames: send a message to the paired Vitre\n * frame (same `frameConnectorId`). Wraps `sendToLocalFrame` with the\n * current frame's id so callers don't have to repeat it. The receiving\n * Vitre frame surfaces it on `onLocalConnectorMessageReceived` (data,\n * from, fileData). The same primitive works from a Vitre frame too,\n * but on the Vitre most apps want `sendMessageTo` / `sendMessageToAll`\n * to reach other devices instead — which the companion has no way to\n * address. See `CompanionFrame` for the trimmed surface intended for\n * apps running on a companion frame iframe.\n */\n public sendToVitreFrame(data: any, fileData?: FileData) {\n this.sendToLocalFrame(this.id, data, fileData)\n }\n\n // The companion-only send methods `sendMessageToVitreConnector` and\n // `closeOnCompanion` deliberately do NOT live on the Vitre `Frame`. They post\n // host messages (`sendToVitreConnector` / `closeOnCompanion`) that ONLY the\n // companion host decodes — a Vitre host rejects them with \"case type not\n // found\". They live on `CompanionFrame` (the subclass returned by\n // `initializeCompanionFrame`, see CompanionFrame.ts). A Vitre frame that needs\n // to reach its own connector uses `sendToLocalMainConnector` instead.\n\n public stopInteracting() {\n this.postMessage({\n type: 'stopInteracting',\n })\n }\n\n public setPosition(position: LayoutPosition) {\n this.postMessage({\n type: 'setPosition',\n ...position,\n })\n }\n\n public setVisibility(visibility: Visibility) {\n this.postMessage({\n type: 'setVisibility',\n visibility,\n })\n }\n\n public setReducedAudioMode(enabled: boolean) {\n this.postMessage({\n type: 'setReducedAudioMode',\n enabled,\n })\n }\n\n public startInteracting() {\n this.postMessage({ type: 'startInteracting' })\n }\n\n public sendToSerialPort(serialPort: SendToSerialPort) {\n this.postMessage({\n type: 'sendToSerialPort',\n ...serialPort,\n })\n }\n\n /// Request access to a serial port (see `Connector.requestSerialPortAccess`).\n /// Resolves with the granted port name (empty string if denied/cancelled).\n /// With `{ port }` the host pre-grants it; with no argument the host shows\n /// its port-picker and resolves with the chosen port.\n public async requestSerialPortAccess(\n request?: RequestSerialPortAccess,\n ): Promise<string> {\n const requestId = uuid()\n return await this.postRequest<string>(\n { type: 'requestSerialPortAccess', requestId, port: request?.port },\n (msg, resolve, reject) => {\n if (\n msg.type === 'serialPortAccessResult' &&\n msg.requestId === requestId\n ) {\n if (msg.port) {\n resolve(msg.port)\n } else {\n reject(msg.reason ?? 'cancelled')\n }\n }\n },\n )\n }\n\n public sendBluetoothMessage(msg: BluetoothFromApp) {\n this.postMessage({ ...msg, type: 'bluetooth' } as any)\n }\n\n public disconnectGuests(deviceIds: string[]) {\n this.postMessage({\n type: 'disconnectGuests',\n deviceIds,\n })\n }\n\n public requestStreamSizeUpdate(updates: RequestStreamSizeUpdate) {\n this.postMessage({\n type: 'requestStreamSizeUpdate',\n ...updates,\n })\n }\n\n public updateName(name: string) {\n this.postMessage({\n type: 'updateName',\n name,\n })\n }\n\n /**\n * Whether {@link shareStream} is available in this runtime (Chromium\n * Insertable Streams + same-site hosting). Same gate as\n * `Connector.canShareStream`.\n */\n public canShareStream(): boolean {\n return typeof MediaStreamTrackProcessor !== 'undefined'\n }\n\n private toShareTracks(stream: MediaStream): {\n tracks: ShareStreamTrack[]\n transfer: Transferable[]\n } {\n const tracks: ShareStreamTrack[] = []\n const transfer: Transferable[] = []\n for (const track of stream.getTracks()) {\n const { readable } = new MediaStreamTrackProcessor({ track })\n tracks.push({\n kind: track.kind as ShareStreamTrack['kind'],\n readable,\n settings: track.getSettings(),\n })\n transfer.push(readable)\n }\n return { tracks, transfer }\n }\n\n /**\n * Share a `MediaStream` the frame produced (e.g. a WebGL-transformed track,\n * or a camera the frame opened) TO the Vitre, which forwards it to the space\n * peers. Frame-context counterpart of `Connector.shareStream`: needed because\n * a transform frame builds its output track locally and must reshare it.\n * Handed over zero-copy via the breakout box. Returns a `sharedStreamId` for\n * {@link replaceShareStream} / {@link stopShareStream}.\n */\n public async shareStream(\n stream: MediaStream,\n options?: ShareStreamOptions,\n ): Promise<string> {\n if (!this.canShareStream()) {\n throw new Error(\n 'shareStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)',\n )\n }\n const sharedStreamId = uuid()\n const requestId = uuid()\n const { tracks, transfer } = this.toShareTracks(stream)\n await this.postRequest<void>(\n { type: 'shareStream', requestId, sharedStreamId, options, tracks },\n (msg, resolve, reject) => {\n if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n return sharedStreamId\n }\n\n /**\n * Swap the source of an open frame share WITHOUT closing it (no\n * renegotiation blip). `sharedStreamId` is the value returned by\n * {@link shareStream}. See `Connector.replaceShareStream`.\n */\n public async replaceShareStream(\n sharedStreamId: string,\n streamOrTrack: MediaStream | MediaStreamTrack,\n ): Promise<void> {\n if (!this.canShareStream()) {\n throw new Error('replaceShareStream is not supported in this runtime')\n }\n const stream =\n streamOrTrack instanceof MediaStream\n ? streamOrTrack\n : new MediaStream([streamOrTrack])\n const requestId = uuid()\n const { tracks, transfer } = this.toShareTracks(stream)\n await this.postRequest<void>(\n { type: 'replaceShareStream', requestId, sharedStreamId, tracks },\n (msg, resolve, reject) => {\n if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n }\n\n /** Stop a frame share. `sharedStreamId` is the value returned by {@link shareStream}. */\n public stopShareStream(sharedStreamId: string): void {\n this.postMessage({ type: 'stopShareStream', sharedStreamId })\n }\n\n /**\n * Attach a `MediaStream` produced by this frame to a target frame's standard\n * sharing slot, WITHOUT opening a new `SharedContent` or establishing a new\n * `RTCPeerConnection`. The stream is forwarded zero-copy (breakout box) from\n * this frame's vitre to the already-open instances of `targetFrameConnectorId`\n * on other vitres; those instances receive it via {@link onSharedStream} (the\n * existing `sharedStreamAvailable` delivery arm — no new protocol arm).\n *\n * - Requires Chromium Insertable Streams (same guard as {@link shareStream}).\n * - Default target: this frame's own `frameConnectorId`, i.e. the same app\n * type running on peer vitres. Pass `opts.targetFrameConnectorId` to route\n * to a different frame type.\n * - Resolves when the host confirms delivery (or rejects with the host error).\n *\n * **Delivery semantics:**\n * - When `targetFrameConnectorId` is absent (default, target == this frame\n * type), the stream is delivered to peer vitres' instances of this frame via\n * {@link onSharedStream}. The calling frame already holds `stream` and does\n * NOT receive it back via `onSharedStream` (no loopback — intentional).\n * - When `targetFrameConnectorId` designates a DIFFERENT frame type, that\n * frame — including its instance on the emitting vitre — receives the stream\n * via {@link onSharedStream}.\n */\n public async attachStream(\n stream: MediaStream,\n opts?: { targetFrameConnectorId?: string },\n ): Promise<void> {\n if (!this.canShareStream()) {\n throw new Error(\n 'attachStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)',\n )\n }\n const requestId = uuid()\n const { tracks, transfer } = this.toShareTracks(stream)\n await this.postRequest<void>(\n {\n type: 'attachStream',\n requestId,\n targetFrameConnectorId: opts?.targetFrameConnectorId,\n tracks,\n },\n (msg, resolve, reject) => {\n if (\n msg.type === 'attachStreamCompleted' &&\n msg.requestId === requestId\n ) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n }\n\n /**\n * Stop a stream previously attached with {@link attachStream} on the target\n * frame. Receivers see {@link onSharedStreamRemoved}. Default target: this\n * frame's own `frameConnectorId`.\n */\n public detachStream(opts?: { targetFrameConnectorId?: string }): void {\n this.postMessage({\n type: 'detachStream',\n targetFrameConnectorId: opts?.targetFrameConnectorId,\n })\n }\n\n /**\n * Fetch the ICE/TURN servers the HOST already uses for its own WebRTC P2P\n * (the Vitre's `StartWebRTCOffer` config, or the companion's `WebRTCOffer`\n * config — same relays, same credentials). The result feeds straight into\n * `new RTCPeerConnection({ iceServers })`, letting an app stand up its OWN\n * peer connection — e.g. a companion-camera frame connecting directly to its\n * paired Vitre transform frame — that traverses NAT through the platform's\n * TURN infrastructure without shipping its own credentials.\n *\n * Resolves to `[]` on hosts that predate this request (the caller should\n * race a timeout and fall back to a public STUN-only config). See\n * {@link IceServerConfig}.\n */\n public async getIceServers(): Promise<IceServerConfig[]> {\n const requestId = uuid()\n return await this.postRequest<IceServerConfig[]>(\n { type: 'getIceServers', requestId },\n (msg, resolve, _reject) => {\n if (msg.type === 'iceServersResponse' && msg.requestId === requestId) {\n resolve(msg.iceServers ?? [])\n }\n },\n )\n }\n\n private requestResolvers: RequestResolver[] = []\n private async postRequest<Data>(\n data: FrameApiMessagesOut,\n handler: (\n msg: FrameApiMessagesIn,\n resolve: (data: Data) => void,\n reject: (error: string) => void,\n ) => void,\n transfer?: Transferable[],\n ) {\n return await new Promise<Data>((resolve, reject) => {\n let isHandled = false\n const handleAndResolve = (data: Data) => {\n isHandled = true\n resolve(data)\n }\n\n const handleAndReject = (error: any) => {\n isHandled = true\n reject(error)\n }\n\n const resolver = {\n isHandled: (msg: FrameApiMessagesIn) => {\n try {\n handler(msg, handleAndResolve, handleAndReject)\n } catch (error) {\n handleAndReject(error)\n }\n return isHandled\n },\n }\n this.requestResolvers.push(resolver)\n this.postMessage(data, transfer)\n })\n }\n\n public async requestEnumerateLocalFrames(): Promise<LoadedFrame[]> {\n const requestId = uuid()\n return await this.postRequest<LoadedFrame[]>(\n { type: 'enumerateLoadedFrames', requestId },\n (msg, resolve, _reject) => {\n if (\n msg.type === 'enumerateLoadedFramesCompleted' &&\n msg.requestId === requestId\n ) {\n resolve(msg.frames)\n }\n },\n )\n }\n\n /** @deprecated Use sendMessageToEmbed */\n public sendExtensionMessage(\n data: any,\n target: MessageTarget,\n fileData?: FileData,\n ) {\n this.postMessage({\n type: 'extensionMessage',\n data,\n target,\n fileData,\n })\n }\n\n /** @deprecated Use sendMessageToEmbed */\n public sendAppMessage(data: any, target: MessageTarget, fileData?: FileData) {\n this.postMessage({\n type: 'appMessage',\n data,\n target,\n fileData,\n })\n }\n\n public sendMessageToEmbed(\n data: any,\n target: MessageTarget,\n fileData?: FileData,\n ) {\n this.postMessage({\n type: 'appMessage',\n data,\n target,\n fileData,\n })\n }\n\n public async requestVitreSettings() {\n return await this.postRequest<VitreSettings>(\n { type: 'getVitreSettings' },\n (msg, resolve, _reject) => {\n if (msg.type === 'vitreSettingsResponse') {\n resolve(msg as VitreSettings)\n }\n },\n )\n }\n\n public setVitreSettings(setters: VitreSettingsSetter) {\n this.postMessage({ type: 'setVitreSettings', ...setters })\n }\n\n /**\n * Share a URL/data with the host, which routes it to a matching app.\n * @param owner Optional device id (`HostInformation.devicesInSpace[].id`) to\n * attribute the resulting shared content to. Drives the languette colour/info\n * and the content appears already-owned on every vitre. Default: opener.\n */\n public shareData(url: string, targetAppId?: AppId, owner?: string) {\n this.postMessage({\n type: 'shareData',\n url,\n targetAppId,\n owner,\n })\n }\n\n /**\n * Share a file with the host, which routes it to a matching app.\n * @param owner Optional device id to attribute the share to. See {@link shareData}.\n */\n public shareFile(fileData: FileData, targetAppId: AppId, owner?: string) {\n this.postMessage({\n type: 'shareFile',\n fileData,\n targetAppId,\n owner,\n })\n }\n\n public saveSettings(settings: any) {\n this.postMessage({\n type: 'saveSettings',\n settings,\n })\n }\n\n public changeTeamSpace(space: string) {\n this.postMessage({\n type: 'changeTeamSpace',\n space,\n })\n }\n\n public changeTeamSpaceGuest(space: string, teamDomain: string) {\n this.postMessage({\n type: 'changeTeamSpaceGuest',\n space,\n teamDomain,\n })\n }\n\n public showNotification(notification: NotificationInfo) {\n this.postMessage({\n ...notification,\n type: 'showNotification',\n })\n }\n\n public hideNotification(notificationId: string) {\n this.postMessage({\n id: notificationId,\n type: 'hideNotification',\n })\n }\n\n public changePrivacy(privacy: Privacy) {\n this.postMessage({\n type: 'changePrivacy',\n privacy,\n })\n }\n\n public trackEvent(name: string, properties?: Record<string, any>) {\n this.postMessage({\n type: 'trackEvent',\n name,\n properties,\n })\n }\n\n public startTrackEvent(name: string) {\n this.postMessage({\n type: 'startTrackEvent',\n name,\n })\n }\n\n public stopTrackEvent(name: string, properties?: Record<string, any>) {\n this.postMessage({\n type: 'stopTrackEvent',\n name,\n properties,\n })\n }\n\n public getMainConnectorFrame(): Window | null {\n try {\n const mainFrameId = `${this.appId}|${this.appId}`\n return (window.parent.frames as any)[mainFrameId]\n } catch (_error) {\n return null\n }\n }\n\n public getMainConnector(): Connector | null {\n const mainFrame = this.getMainConnectorFrame() as any\n return mainFrame?.mainConnector as Connector\n }\n\n public setBorderOptions(borderOptions: BorderOptions) {\n this.postMessage({ type: 'setBorderOptions', ...borderOptions })\n }\n\n public setVoiceActions(actions: VoiceAction[]) {\n this.postMessage({\n type: 'setVoiceActions',\n actions,\n })\n }\n\n public async requestStreamCapture() {\n const requestId = uuid()\n return await this.postRequest<StreamCapture>(\n { type: 'streamFrameCaptureRequest', requestId },\n (msg, resolve, reject) => {\n if (\n msg.type === 'streamFrameCapturedResponse' &&\n msg.requestId === requestId\n ) {\n if (msg.response == null) {\n reject(msg.error ?? 'failed to get streamFrameCapturedResponse')\n } else {\n resolve(msg.response)\n }\n }\n },\n )\n }\n\n public async requestStats() {\n const requestId = uuid()\n return await this.postRequest<StatsResponse>(\n { type: 'getStats', requestId },\n (msg, resolve, _reject) => {\n if (msg.type === 'statsResponse' && msg.requestId === requestId) {\n resolve(msg)\n }\n },\n )\n }\n\n public updateState(updates: UpdateStateEntry[], forceApplyLocally = true) {\n updates.forEach((update) => {\n //Compat fix, add value for remove action\n if (update.action === 'remove') {\n ;(update as any).value = null\n }\n })\n\n this.postMessage({\n type: 'updateState',\n updates,\n })\n\n if (forceApplyLocally) {\n updates.forEach((update) => {\n if (update.action === 'add') {\n this.state[update.key] = update.value\n } else {\n delete this.state[update.key]\n }\n })\n }\n }\n\n public sharedStream: SharedStream = {\n lastState: {\n position: 0,\n duration: 0,\n volume: 1,\n state: 'paused',\n },\n play: () => {\n this.postMessage({\n type: 'sharedStreamAction',\n action: 'play',\n })\n },\n\n pause: () => {\n this.postMessage({\n type: 'sharedStreamAction',\n action: 'pause',\n })\n },\n\n seek: (position: number, isRelative: boolean = false) => {\n this.postMessage({\n type: 'sharedStreamAction',\n action: 'seek',\n position,\n isRelative,\n })\n },\n\n setVolume: (volume: number, muted: boolean = false) => {\n this.postMessage({\n type: 'sharedStreamAction',\n action: 'volume',\n volume,\n muted,\n })\n },\n }\n}\n\ntype PostMessageFrameApiOut = (\n message: FrameApiMessagesOut,\n transfer?: Transferable[],\n) => void\n\nexport async function initializeFrame<T extends Frame>(\n init: (\n info: HostInformation,\n initiator: Device,\n options: InitFrameOptions,\n state?: Record<string, any>,\n ) => ViewOptions,\n createFrame?: new (\n postMessage: PostMessageFrameApiOut,\n initMessage: InitializeFrame,\n options: ViewOptions,\n ) => T,\n) {\n return await new Promise<T>((resolve) => {\n const channel = new MessageChannel()\n let frame: T | null = null\n const messageHandler =\n (createPostMessage: (origin: string) => PostMessageFrameApiOut) =>\n (e: MessageEvent<FrameApiMessagesIn>): any => {\n switch (e.data.type) {\n case 'initialize':\n if (frame === null) {\n const initializeMsg = e.data\n const options = init(\n initializeMsg.hostInfo,\n initializeMsg.initiator,\n initializeMsg.options,\n initializeMsg.state,\n )\n frame = new (createFrame ?? Frame)(\n createPostMessage(initializeMsg.hostInfo.origin),\n initializeMsg,\n options,\n initializeMsg.state,\n ) as T\n resolve(frame)\n }\n break\n default:\n frame?.raiseMessage(e.data)\n break\n }\n }\n\n channel.port1.onmessage = messageHandler(\n (_origin: string) => (message, transfer?: Transferable[]) => {\n channel.port1.postMessage(message, transfer ?? [])\n },\n )\n\n window.parent.postMessage(\n {\n type: 'connectorInitializationRequest',\n version: apiVersion,\n },\n '*',\n [channel.port2],\n )\n\n window.addEventListener(\n 'message',\n messageHandler(\n (origin: string) => (message, transfer?: Transferable[]) => {\n window.parent.postMessage(message, origin, transfer)\n },\n ),\n false,\n )\n })\n}\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type * as Y from 'yjs';
|
|
2
|
+
import type { Frame } from './Frame.js';
|
|
3
|
+
/**
|
|
4
|
+
* Generic Yjs sync adapter contract piped over the la Vitre apps SDK CRDT
|
|
5
|
+
* transport. Structurally compatible with Carbone's `SyncAdapter` (same
|
|
6
|
+
* field names, same shapes) so an app can pass a `VitreSyncAdapter`
|
|
7
|
+
* straight into Carbone's `attachSyncAdapter`. The compatibility is
|
|
8
|
+
* checked at the call site by TS structural assignment — neither side
|
|
9
|
+
* has to import the other's type.
|
|
10
|
+
*
|
|
11
|
+
* Not Carbone-specific: any app that brings its own `Y.Doc` + `Awareness`
|
|
12
|
+
* (instead of using `frame.crdt.doc` / `frame.crdt.awareness` directly)
|
|
13
|
+
* benefits from the same glue. Lives in the SDK so apps don't reinvent
|
|
14
|
+
* the bridging logic for every Y-based content type.
|
|
15
|
+
*/
|
|
16
|
+
export type Peer = {
|
|
17
|
+
clientId: number;
|
|
18
|
+
user?: {
|
|
19
|
+
id?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
color?: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type ConnectionState = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
25
|
+
/**
|
|
26
|
+
* Structural shape of `y-protocols/awareness`'s `Awareness`. Kept structural
|
|
27
|
+
* so `y-protocols` stays an app-side concern: the SDK doesn't depend on
|
|
28
|
+
* the package, callers pass their own instance.
|
|
29
|
+
*/
|
|
30
|
+
export type AwarenessLike = {
|
|
31
|
+
readonly clientID: number;
|
|
32
|
+
setLocalState(state: unknown): void;
|
|
33
|
+
getStates(): Map<number, Record<string, unknown>>;
|
|
34
|
+
on(event: string, cb: (...args: never[]) => void): void;
|
|
35
|
+
off(event: string, cb: (...args: never[]) => void): void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
};
|
|
38
|
+
export type SyncAdapter = {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
connect(doc: Y.Doc, awareness?: AwarenessLike): Promise<void>;
|
|
41
|
+
disconnect(): Promise<void>;
|
|
42
|
+
onPeersChange(cb: (peers: Peer[]) => void): () => void;
|
|
43
|
+
onConnectionState(cb: (s: ConnectionState) => void): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Fires `true` EXACTLY ONCE per `connect()` cycle, when the initial
|
|
46
|
+
* state-vector exchange with currently-reachable peers is done. The
|
|
47
|
+
* underlying `frame.crdt.onSynced` fires on every handshake (initial +
|
|
48
|
+
* each `attach()`); this adapter gates with a per-cycle flag so the
|
|
49
|
+
* external contract stays "once per cycle".
|
|
50
|
+
*
|
|
51
|
+
* The argument is always `true`; the parameter is kept so a future
|
|
52
|
+
* adapter could surface a "lost sync" signal without breaking the
|
|
53
|
+
* contract.
|
|
54
|
+
*/
|
|
55
|
+
onSynced(cb: (synced: boolean) => void): () => void;
|
|
56
|
+
/**
|
|
57
|
+
* Connect a Yjs SUBDOCUMENT on its own channel keyed by `subdoc.guid`.
|
|
58
|
+
* Returns an async disposer.
|
|
59
|
+
*/
|
|
60
|
+
connectSubdoc?(subdoc: Y.Doc): Promise<() => Promise<void>>;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Build a `SyncAdapter` backed by the la Vitre apps SDK CRDT transport on
|
|
64
|
+
* a given `Frame`.
|
|
65
|
+
*
|
|
66
|
+
* `connect(doc, awareness)` hands the pair to `frame.crdt.attach(...)` —
|
|
67
|
+
* no bridging of two docs, the caller's `Y.Doc` becomes the one la Vitre
|
|
68
|
+
* forwards over the WebRTC data channels between vitres. `connectSubdoc`
|
|
69
|
+
* delegates to `frame.crdt.attachSubdoc(...)` for heavy assets that
|
|
70
|
+
* should stream deferred.
|
|
71
|
+
*
|
|
72
|
+
* Re-entrancy: calling `connect` without first `disconnect` tears down
|
|
73
|
+
* the previous cycle first (mirrors WebRTCAdapter's defence).
|
|
74
|
+
*/
|
|
75
|
+
export declare const createVitreSyncAdapter: (frame: Frame) => SyncAdapter;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a `SyncAdapter` backed by the la Vitre apps SDK CRDT transport on
|
|
3
|
+
* a given `Frame`.
|
|
4
|
+
*
|
|
5
|
+
* `connect(doc, awareness)` hands the pair to `frame.crdt.attach(...)` —
|
|
6
|
+
* no bridging of two docs, the caller's `Y.Doc` becomes the one la Vitre
|
|
7
|
+
* forwards over the WebRTC data channels between vitres. `connectSubdoc`
|
|
8
|
+
* delegates to `frame.crdt.attachSubdoc(...)` for heavy assets that
|
|
9
|
+
* should stream deferred.
|
|
10
|
+
*
|
|
11
|
+
* Re-entrancy: calling `connect` without first `disconnect` tears down
|
|
12
|
+
* the previous cycle first (mirrors WebRTCAdapter's defence).
|
|
13
|
+
*/
|
|
14
|
+
export const createVitreSyncAdapter = (frame) => {
|
|
15
|
+
let dispose = null;
|
|
16
|
+
let awarenessRef = null;
|
|
17
|
+
// N-subscriber listener sets — match the rest of the Carbone adapter
|
|
18
|
+
// family (WebRTC / WebSocket / BroadcastChannel / Local), which all
|
|
19
|
+
// support multiple consumers per signal. A single-slot store would
|
|
20
|
+
// silently drop the second subscriber.
|
|
21
|
+
const stateListeners = new Set();
|
|
22
|
+
const peersListeners = new Set();
|
|
23
|
+
const syncedListeners = new Set();
|
|
24
|
+
let syncedThisCycle = false;
|
|
25
|
+
const emitState = (s) => {
|
|
26
|
+
for (const cb of [...stateListeners])
|
|
27
|
+
cb(s);
|
|
28
|
+
};
|
|
29
|
+
const emitPeers = () => {
|
|
30
|
+
if (!awarenessRef || peersListeners.size === 0)
|
|
31
|
+
return;
|
|
32
|
+
const peers = [];
|
|
33
|
+
for (const [clientId, state] of awarenessRef.getStates()) {
|
|
34
|
+
if (clientId === awarenessRef.clientID)
|
|
35
|
+
continue;
|
|
36
|
+
const user = state.user;
|
|
37
|
+
peers.push(user ? { clientId, user } : { clientId });
|
|
38
|
+
}
|
|
39
|
+
for (const cb of [...peersListeners])
|
|
40
|
+
cb(peers);
|
|
41
|
+
};
|
|
42
|
+
const awarenessChangeHandler = () => emitPeers();
|
|
43
|
+
return {
|
|
44
|
+
id: 'lavitre-vitre',
|
|
45
|
+
async connect(doc, awareness) {
|
|
46
|
+
// Tear down the previous cycle first so its onSynced sub +
|
|
47
|
+
// awareness 'change' listener + attachment don't leak.
|
|
48
|
+
dispose?.();
|
|
49
|
+
dispose = null;
|
|
50
|
+
syncedThisCycle = false;
|
|
51
|
+
emitState('connecting');
|
|
52
|
+
// Callers pass a real y-protocols `Awareness` here; the parameter
|
|
53
|
+
// is typed structurally so the SDK doesn't pull y-protocols in.
|
|
54
|
+
const real = awareness;
|
|
55
|
+
// Wrap the attach + wire-up: if any of these throws we want to
|
|
56
|
+
// emit the `'error'` ConnectionState before rethrowing, matching
|
|
57
|
+
// the contract (`WebRTCAdapter` does the same). Without this the
|
|
58
|
+
// adapter rethrows silently and subscribers never observe the
|
|
59
|
+
// transition out of `'connecting'`.
|
|
60
|
+
let attachment;
|
|
61
|
+
try {
|
|
62
|
+
attachment = frame.crdt.attach(doc, real);
|
|
63
|
+
// `frame.crdt.awareness` is the getter over the channel's
|
|
64
|
+
// CURRENT awareness: `attach(doc, real)` set it to `real` (or,
|
|
65
|
+
// if `real` was omitted, to the fresh one `attach` minted). So
|
|
66
|
+
// this is exactly the attached instance and avoids a null when
|
|
67
|
+
// awareness is omitted.
|
|
68
|
+
awarenessRef = frame.crdt.awareness;
|
|
69
|
+
awarenessRef.on('change', awarenessChangeHandler);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
emitState('error');
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
const unsubSync = frame.crdt.onSynced(() => {
|
|
76
|
+
// `frame.crdt.onSynced` fires on every handshake (initial +
|
|
77
|
+
// each subdoc attach). Gate both the state emission and the
|
|
78
|
+
// listener fan-out to once per `connect()` cycle so
|
|
79
|
+
// `onConnectionState` consumers don't see 'connected' spammed.
|
|
80
|
+
if (syncedThisCycle)
|
|
81
|
+
return;
|
|
82
|
+
syncedThisCycle = true;
|
|
83
|
+
emitState('connected');
|
|
84
|
+
for (const cb of [...syncedListeners])
|
|
85
|
+
cb(true);
|
|
86
|
+
});
|
|
87
|
+
emitPeers();
|
|
88
|
+
dispose = () => {
|
|
89
|
+
unsubSync();
|
|
90
|
+
awarenessRef?.off('change', awarenessChangeHandler);
|
|
91
|
+
awarenessRef = null;
|
|
92
|
+
syncedThisCycle = false;
|
|
93
|
+
emitState('disconnected');
|
|
94
|
+
attachment.dispose();
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
async disconnect() {
|
|
98
|
+
dispose?.();
|
|
99
|
+
dispose = null;
|
|
100
|
+
},
|
|
101
|
+
async connectSubdoc(subdoc) {
|
|
102
|
+
// The SDK primitive is fire-and-forget + returns a sync disposer;
|
|
103
|
+
// the contract wants an async disposer.
|
|
104
|
+
const detach = frame.crdt.attachSubdoc(subdoc);
|
|
105
|
+
return async () => {
|
|
106
|
+
detach();
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
onPeersChange(cb) {
|
|
110
|
+
peersListeners.add(cb);
|
|
111
|
+
emitPeers();
|
|
112
|
+
return () => {
|
|
113
|
+
peersListeners.delete(cb);
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
onConnectionState(cb) {
|
|
117
|
+
stateListeners.add(cb);
|
|
118
|
+
return () => {
|
|
119
|
+
stateListeners.delete(cb);
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
onSynced(cb) {
|
|
123
|
+
syncedListeners.add(cb);
|
|
124
|
+
// If this cycle already synced before the subscription landed,
|
|
125
|
+
// honour the once-per-cycle contract by replaying it.
|
|
126
|
+
if (syncedThisCycle)
|
|
127
|
+
cb(true);
|
|
128
|
+
return () => {
|
|
129
|
+
syncedListeners.delete(cb);
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=SyncAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncAdapter.js","sourceRoot":"","sources":["../../Frame/SyncAdapter.ts"],"names":[],"mappings":"AAoEA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAY,EAAe,EAAE;IAClE,IAAI,OAAO,GAAwB,IAAI,CAAA;IACvC,IAAI,YAAY,GAAqB,IAAI,CAAA;IAEzC,qEAAqE;IACrE,oEAAoE;IACpE,mEAAmE;IACnE,uCAAuC;IACvC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAgC,CAAA;IAC9D,MAAM,cAAc,GAAG,IAAI,GAAG,EAAuB,CAAA;IACrD,MAAM,eAAe,GAAG,IAAI,GAAG,EAA6B,CAAA;IAC5D,IAAI,eAAe,GAAG,KAAK,CAAA;IAE3B,MAAM,SAAS,GAAG,CAAC,CAAkB,EAAE,EAAE;QACvC,KAAK,MAAM,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC;YAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7C,CAAC,CAAA;IAED,MAAM,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AED,aAAa,CAAC,EAAE;YACd,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACtB,SAAS,EAAE,CAAA;YACX,OAAO,GAAG,EAAE;gBACV,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC3B,CAAC,CAAA;QACH,CAAC;QAED,iBAAiB,CAAC,EAAE;YAClB,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACtB,OAAO,GAAG,EAAE;gBACV,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC3B,CAAC,CAAA;QACH,CAAC;QAED,QAAQ,CAAC,EAAE;YACT,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACvB,+DAA+D;YAC/D,sDAAsD;YACtD,IAAI,eAAe;gBAAE,EAAE,CAAC,IAAI,CAAC,CAAA;YAC7B,OAAO,GAAG,EAAE;gBACV,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAC5B,CAAC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type * as Y from 'yjs'\nimport type { Awareness } from 'y-protocols/awareness'\nimport type { Frame } from './Frame.js'\n\n/**\n * Generic Yjs sync adapter contract piped over the la Vitre apps SDK CRDT\n * transport. Structurally compatible with Carbone's `SyncAdapter` (same\n * field names, same shapes) so an app can pass a `VitreSyncAdapter`\n * straight into Carbone's `attachSyncAdapter`. The compatibility is\n * checked at the call site by TS structural assignment — neither side\n * has to import the other's type.\n *\n * Not Carbone-specific: any app that brings its own `Y.Doc` + `Awareness`\n * (instead of using `frame.crdt.doc` / `frame.crdt.awareness` directly)\n * benefits from the same glue. Lives in the SDK so apps don't reinvent\n * the bridging logic for every Y-based content type.\n */\n\nexport type Peer = {\n clientId: number\n user?: { id?: string; name?: string; color?: string }\n}\n\nexport type ConnectionState =\n | 'connecting'\n | 'connected'\n | 'disconnected'\n | 'error'\n\n/**\n * Structural shape of `y-protocols/awareness`'s `Awareness`. Kept structural\n * so `y-protocols` stays an app-side concern: the SDK doesn't depend on\n * the package, callers pass their own instance.\n */\nexport type AwarenessLike = {\n readonly clientID: number\n setLocalState(state: unknown): void\n getStates(): Map<number, Record<string, unknown>>\n on(event: string, cb: (...args: never[]) => void): void\n off(event: string, cb: (...args: never[]) => void): void\n destroy(): void\n}\n\nexport type SyncAdapter = {\n readonly id: string\n connect(doc: Y.Doc, awareness?: AwarenessLike): Promise<void>\n disconnect(): Promise<void>\n onPeersChange(cb: (peers: Peer[]) => void): () => void\n onConnectionState(cb: (s: ConnectionState) => void): () => void\n /**\n * Fires `true` EXACTLY ONCE per `connect()` cycle, when the initial\n * state-vector exchange with currently-reachable peers is done. The\n * underlying `frame.crdt.onSynced` fires on every handshake (initial +\n * each `attach()`); this adapter gates with a per-cycle flag so the\n * external contract stays \"once per cycle\".\n *\n * The argument is always `true`; the parameter is kept so a future\n * adapter could surface a \"lost sync\" signal without breaking the\n * contract.\n */\n onSynced(cb: (synced: boolean) => void): () => void\n /**\n * Connect a Yjs SUBDOCUMENT on its own channel keyed by `subdoc.guid`.\n * Returns an async disposer.\n */\n connectSubdoc?(subdoc: Y.Doc): Promise<() => Promise<void>>\n}\n\n/**\n * Build a `SyncAdapter` backed by the la Vitre apps SDK CRDT transport on\n * a given `Frame`.\n *\n * `connect(doc, awareness)` hands the pair to `frame.crdt.attach(...)` —\n * no bridging of two docs, the caller's `Y.Doc` becomes the one la Vitre\n * forwards over the WebRTC data channels between vitres. `connectSubdoc`\n * delegates to `frame.crdt.attachSubdoc(...)` for heavy assets that\n * should stream deferred.\n *\n * Re-entrancy: calling `connect` without first `disconnect` tears down\n * the previous cycle first (mirrors WebRTCAdapter's defence).\n */\nexport const createVitreSyncAdapter = (frame: Frame): SyncAdapter => {\n let dispose: (() => void) | null = null\n let awarenessRef: Awareness | null = null\n\n // N-subscriber listener sets — match the rest of the Carbone adapter\n // family (WebRTC / WebSocket / BroadcastChannel / Local), which all\n // support multiple consumers per signal. A single-slot store would\n // silently drop the second subscriber.\n const stateListeners = new Set<(s: ConnectionState) => void>()\n const peersListeners = new Set<(p: Peer[]) => void>()\n const syncedListeners = new Set<(synced: boolean) => void>()\n let syncedThisCycle = false\n\n const emitState = (s: ConnectionState) => {\n for (const cb of [...stateListeners]) cb(s)\n }\n\n const emitPeers = () => {\n if (!awarenessRef || peersListeners.size === 0) return\n const peers: Peer[] = []\n for (const [clientId, state] of awarenessRef.getStates()) {\n if (clientId === awarenessRef.clientID) continue\n const user = (state as { user?: Peer['user'] }).user\n peers.push(user ? { clientId, user } : { clientId })\n }\n for (const cb of [...peersListeners]) cb(peers)\n }\n\n const awarenessChangeHandler = () => emitPeers()\n\n return {\n id: 'lavitre-vitre',\n\n async connect(doc: Y.Doc, awareness?: AwarenessLike) {\n // Tear down the previous cycle first so its onSynced sub +\n // awareness 'change' listener + attachment don't leak.\n dispose?.()\n dispose = null\n\n syncedThisCycle = false\n emitState('connecting')\n\n // Callers pass a real y-protocols `Awareness` here; the parameter\n // is typed structurally so the SDK doesn't pull y-protocols in.\n const real = awareness as unknown as Awareness | undefined\n\n // Wrap the attach + wire-up: if any of these throws we want to\n // emit the `'error'` ConnectionState before rethrowing, matching\n // the contract (`WebRTCAdapter` does the same). Without this the\n // adapter rethrows silently and subscribers never observe the\n // transition out of `'connecting'`.\n let attachment: ReturnType<Frame['crdt']['attach']>\n try {\n attachment = frame.crdt.attach(doc, real)\n // `frame.crdt.awareness` is the getter over the channel's\n // CURRENT awareness: `attach(doc, real)` set it to `real` (or,\n // if `real` was omitted, to the fresh one `attach` minted). So\n // this is exactly the attached instance and avoids a null when\n // awareness is omitted.\n awarenessRef = frame.crdt.awareness\n awarenessRef.on('change', awarenessChangeHandler)\n } catch (err) {\n emitState('error')\n throw err\n }\n\n const unsubSync = frame.crdt.onSynced(() => {\n // `frame.crdt.onSynced` fires on every handshake (initial +\n // each subdoc attach). Gate both the state emission and the\n // listener fan-out to once per `connect()` cycle so\n // `onConnectionState` consumers don't see 'connected' spammed.\n if (syncedThisCycle) return\n syncedThisCycle = true\n emitState('connected')\n for (const cb of [...syncedListeners]) cb(true)\n })\n\n emitPeers()\n\n dispose = () => {\n unsubSync()\n awarenessRef?.off('change', awarenessChangeHandler)\n awarenessRef = null\n syncedThisCycle = false\n emitState('disconnected')\n attachment.dispose()\n }\n },\n\n async disconnect() {\n dispose?.()\n dispose = null\n },\n\n async connectSubdoc(subdoc: Y.Doc) {\n // The SDK primitive is fire-and-forget + returns a sync disposer;\n // the contract wants an async disposer.\n const detach = frame.crdt.attachSubdoc(subdoc)\n return async () => {\n detach()\n }\n },\n\n onPeersChange(cb) {\n peersListeners.add(cb)\n emitPeers()\n return () => {\n peersListeners.delete(cb)\n }\n },\n\n onConnectionState(cb) {\n stateListeners.add(cb)\n return () => {\n stateListeners.delete(cb)\n }\n },\n\n onSynced(cb) {\n syncedListeners.add(cb)\n // If this cycle already synced before the subscription landed,\n // honour the once-per-cycle contract by replaying it.\n if (syncedThisCycle) cb(true)\n return () => {\n syncedListeners.delete(cb)\n }\n },\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../Frame/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './Frame.js'\nexport * from './Frame.Model.js'\nexport * from './SyncAdapter.js'\n"]}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { Frame } from '../Frame/Frame.js';
|
|
2
|
+
import type { CompanionFrame } from '../CompanionFrame/CompanionFrame.js';
|
|
3
|
+
import type { Connector } from '../Connector/Connector.js';
|
|
4
|
+
export type MediaLinkState = 'connecting' | 'connected' | 'reconnecting' | 'ended' | 'failed';
|
|
5
|
+
export type MediaLinkEndReason = 'user' | 'remote-user' | 'failure';
|
|
6
|
+
export type MediaLinkRetryOptions = {
|
|
7
|
+
/** Grace period after 'disconnected' before starting ICE restart. Default 3000 ms. */
|
|
8
|
+
graceMs?: number;
|
|
9
|
+
/** Maximum ICE restart attempts before giving up. Default 3. */
|
|
10
|
+
attempts?: number;
|
|
11
|
+
/** Per-attempt backoff delays in ms. Default [2000, 4000, 8000]. */
|
|
12
|
+
backoffMs?: number[];
|
|
13
|
+
};
|
|
14
|
+
export type StartMediaLinkOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* Communicated to the answerer frame; tells the Vitre how to display the
|
|
17
|
+
* incoming stream (standard shared-video slot vs. an app-frame overlay).
|
|
18
|
+
*/
|
|
19
|
+
receiverDisplay?: 'standard' | 'appFrame';
|
|
20
|
+
/** Opaque app data delivered to the answerer along with the link. */
|
|
21
|
+
metadata?: unknown;
|
|
22
|
+
retry?: MediaLinkRetryOptions;
|
|
23
|
+
/**
|
|
24
|
+
* When true (default), the offerer sends a control message to the app's
|
|
25
|
+
* Vitre main Connector via `frame.sendMessageToVitreConnector` requesting
|
|
26
|
+
* that the answerer frame be opened.
|
|
27
|
+
*/
|
|
28
|
+
requestAnswererFrame?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* How long (ms) the offerer waits for the Vitre answerer to publish its ICE
|
|
31
|
+
* server list before falling back to the companion-side `getIceServers()` or
|
|
32
|
+
* public STUN. Default 8000 ms (accounts for frame-open latency + CRDT sync).
|
|
33
|
+
*
|
|
34
|
+
* The Vitre is the source of authority for TURN credentials; a longer timeout
|
|
35
|
+
* yields better NAT traversal for peers behind symmetric NAT.
|
|
36
|
+
*/
|
|
37
|
+
vitreIceTimeoutMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Attached to the link BEFORE the connection starts — unlike assigning
|
|
40
|
+
* `link.onStateChange` after `startMediaLink` resolves, this cannot miss a
|
|
41
|
+
* fast transition (e.g. an instant 'connected' on loopback / late-join).
|
|
42
|
+
*/
|
|
43
|
+
onStateChange?: (state: MediaLinkState) => void;
|
|
44
|
+
/** Same early-attachment rationale as {@link onStateChange}. */
|
|
45
|
+
onEnded?: (reason: MediaLinkEndReason) => void;
|
|
46
|
+
};
|
|
47
|
+
/** Handle returned to the companion-frame (offerer) side. */
|
|
48
|
+
export interface MediaLink {
|
|
49
|
+
readonly state: MediaLinkState;
|
|
50
|
+
readonly sessionId: string;
|
|
51
|
+
/**
|
|
52
|
+
* Swap the video (and audio, if present) tracks on the existing senders
|
|
53
|
+
* via `replaceTrack` — no renegotiation. The answerer keeps receiving on
|
|
54
|
+
* the same transceiver; the remote track object is unchanged so
|
|
55
|
+
* `AnsweredMediaLink.onStreamChanged` will NOT fire on the Vitre side.
|
|
56
|
+
*/
|
|
57
|
+
replaceStream(stream: MediaStream): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Voluntary stop: writes a session-tagged `ended: 'user'` control entry to
|
|
60
|
+
* the CRDT doc BEFORE closing the PC. The other side tears down immediately
|
|
61
|
+
* with `onEnded('remote-user')` — no retry.
|
|
62
|
+
*/
|
|
63
|
+
stop(): void;
|
|
64
|
+
onStateChange?: (state: MediaLinkState) => void;
|
|
65
|
+
onEnded?: (reason: MediaLinkEndReason) => void;
|
|
66
|
+
}
|
|
67
|
+
/** Handle returned to the Vitre-frame (answerer) side. */
|
|
68
|
+
export interface AnsweredMediaLink {
|
|
69
|
+
readonly sessionId: string;
|
|
70
|
+
/** Remote stream surfaced via `ontrack`. */
|
|
71
|
+
readonly stream: MediaStream;
|
|
72
|
+
readonly receiverDisplay?: 'standard' | 'appFrame';
|
|
73
|
+
readonly metadata?: unknown;
|
|
74
|
+
/**
|
|
75
|
+
* Called after the offerer invokes `replaceStream`. NOTE: because
|
|
76
|
+
* `replaceStream` uses `replaceTrack` (no renegotiation), the remote
|
|
77
|
+
* `MediaStreamTrack` object is the SAME object — browsers do NOT fire a
|
|
78
|
+
* new `ontrack` and the track's content simply switches. This callback
|
|
79
|
+
* will therefore NOT fire in current browser implementations. It is
|
|
80
|
+
* provided as a forward-compatibility hook and for documentation purposes.
|
|
81
|
+
*/
|
|
82
|
+
onStreamChanged?: (stream: MediaStream) => void;
|
|
83
|
+
onStateChange?: (state: MediaLinkState) => void;
|
|
84
|
+
onEnded?: (reason: MediaLinkEndReason) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Vitre-side voluntary stop: writes `ended: 'user'` toward the offerer.
|
|
87
|
+
* No retry on either side.
|
|
88
|
+
*/
|
|
89
|
+
stop(): void;
|
|
90
|
+
}
|
|
91
|
+
export type MediaLinkOpenAnswererMessage = {
|
|
92
|
+
type: 'lavitre-media-link';
|
|
93
|
+
action: 'open-answerer' | 'close-answerer';
|
|
94
|
+
frameConnectorId: string;
|
|
95
|
+
sessionId: string;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Companion-frame side — the offerer.
|
|
99
|
+
*
|
|
100
|
+
* Acquires ICE servers, creates an `RTCPeerConnection` with the given stream,
|
|
101
|
+
* publishes the offer over the frame CRDT doc, and optionally requests that
|
|
102
|
+
* the answerer frame be opened on the Vitre via
|
|
103
|
+
* `frame.sendMessageToVitreConnector`. Resolves with a {@link MediaLink}
|
|
104
|
+
* handle once the local description is set (i.e. signalling is in flight).
|
|
105
|
+
*
|
|
106
|
+
* Call `connector.openFrame(frameConnectorId, ...)` on the Vitre side (or use
|
|
107
|
+
* {@link enableMediaLinkAnswerer}) BEFORE calling this so the answerer frame
|
|
108
|
+
* is ready to receive the offer when the CRDT syncs. If `requestAnswererFrame`
|
|
109
|
+
* is true (default) the SDK sends the control message automatically.
|
|
110
|
+
*
|
|
111
|
+
* @param frame The companion frame (`CompanionFrame`, from `initializeCompanionFrame`).
|
|
112
|
+
* @param stream The `MediaStream` to send to the Vitre frame.
|
|
113
|
+
* @param options Optional configuration (retry, metadata, display mode…).
|
|
114
|
+
*/
|
|
115
|
+
export declare function startMediaLink(frame: CompanionFrame, stream: MediaStream, options?: StartMediaLinkOptions): Promise<MediaLink>;
|
|
116
|
+
/**
|
|
117
|
+
* Vitre-frame side — subscribe to incoming media link sessions.
|
|
118
|
+
*
|
|
119
|
+
* The handler fires once per session (including sessions already present in
|
|
120
|
+
* the CRDT doc at the time of subscription — late-join). Each invocation
|
|
121
|
+
* provides an {@link AnsweredMediaLink} with the remote stream and teardown
|
|
122
|
+
* handle. The caller is responsible for calling `frame.shareStream(link.stream)`
|
|
123
|
+
* (or equivalent) to route the stream to the space.
|
|
124
|
+
*
|
|
125
|
+
* Returns an unsubscribe function that stops watching for new sessions. Existing
|
|
126
|
+
* {@link AnsweredMediaLink} handles are NOT torn down by unsubscribing — each
|
|
127
|
+
* must be ended explicitly via `link.stop()` or via the offerer's `stop()`.
|
|
128
|
+
*
|
|
129
|
+
* @param frame The Vitre-side frame (`Frame`).
|
|
130
|
+
* @param handler Called for every new (or already-present) incoming session.
|
|
131
|
+
* @returns Unsubscribe function.
|
|
132
|
+
*/
|
|
133
|
+
export declare function onMediaLink(frame: Frame, handler: (link: AnsweredMediaLink) => void): () => void;
|
|
134
|
+
/**
|
|
135
|
+
* Vitre CONNECTOR helper — automatically opens the answerer frame when a
|
|
136
|
+
* companion frame requests it via the `lavitre-media-link` control message,
|
|
137
|
+
* and closes it again when the last link of that frame ends (configurable).
|
|
138
|
+
*
|
|
139
|
+
* Wire this in the Connector's `onMessageFromCompanionFrame` on the Vitre side:
|
|
140
|
+
* ```ts
|
|
141
|
+
* const unsub = enableMediaLinkAnswerer(connector, {
|
|
142
|
+
* url: 'https://my-app.apps.lavit.re/frame.html',
|
|
143
|
+
* name: 'My App',
|
|
144
|
+
* })
|
|
145
|
+
* // Later:
|
|
146
|
+
* unsub()
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* **Frame id matching**: the companion mints a per-session id of the form
|
|
150
|
+
* `<appId>-<uuid>` and sends it in the `open-answerer` message. This helper
|
|
151
|
+
* matches incoming messages by prefix:
|
|
152
|
+
* - exact match: `msgFrameConnectorId === prefix`
|
|
153
|
+
* - prefix match: `msgFrameConnectorId.startsWith(prefix + '-')`
|
|
154
|
+
*
|
|
155
|
+
* `frameConnectorId` (optional): the match prefix. Defaults to `connector.appId`
|
|
156
|
+
* so apps that omit it work without any configuration. An app can still pass a
|
|
157
|
+
* fixed string for backward compatibility — it matches via the `===` arm.
|
|
158
|
+
*
|
|
159
|
+
* The answerer frame is opened with the **companion-minted id** received in the
|
|
160
|
+
* message (not a fixed constant), so re-share / concurrent sessions each get a
|
|
161
|
+
* distinct frame and SharedContentId — stale state never leaks across sessions.
|
|
162
|
+
*
|
|
163
|
+
* `closeOnEnd` (default `true`): when the last active session for this frame
|
|
164
|
+
* ends, the connector calls `connector.closeFrame(currentFrameId)`.
|
|
165
|
+
*
|
|
166
|
+
* @returns Unsubscribe function.
|
|
167
|
+
*/
|
|
168
|
+
export declare function enableMediaLinkAnswerer(connector: Connector, opts: {
|
|
169
|
+
/** Match prefix. Defaults to `connector.appId`. */
|
|
170
|
+
frameConnectorId?: string;
|
|
171
|
+
url: string;
|
|
172
|
+
name?: string;
|
|
173
|
+
closeOnEnd?: boolean;
|
|
174
|
+
size?: {
|
|
175
|
+
width: number;
|
|
176
|
+
height: number;
|
|
177
|
+
};
|
|
178
|
+
}): () => void;
|