@lavitre/apps 1.65.0 → 1.66.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/README.md +22 -1
- package/dist/Frame/Frame.Model.d.ts +2 -2
- package/dist/Frame/Frame.Model.js.map +1 -1
- package/dist/Frame/Frame.d.ts +36 -3
- package/dist/Frame/Frame.js +150 -13
- package/dist/Frame/Frame.js.map +1 -1
- package/dist/Frame/OutgoingStreamPeer.js +26 -7
- package/dist/Frame/OutgoingStreamPeer.js.map +1 -1
- package/dist/Version.d.ts +1 -1
- package/dist/Version.js +1 -1
- package/dist/Version.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -222,7 +222,28 @@ connector.trackEvent('started', { version: connector.appVersion, channel: connec
|
|
|
222
222
|
- **Same site as the Vitre page, Chromium** (e.g. `*.apps.lavit.re` in `app.lavit.re`): the track readables are transferred, no re-encoding.
|
|
223
223
|
- **Otherwise** (a preview served from `*.netlify.app`, a browser without `MediaStreamTrackProcessor`): the stream goes over a local `RTCPeerConnection` to the Vitre, re-encoded once on the same machine. Only with a host that announces it (`shareStreamPeer`); `replaceShareStream` then swaps the tracks on the frame's own sender, for the kinds the share already carries.
|
|
224
224
|
|
|
225
|
-
A connector decides before opening the frame with `connector.canFrameShareStream()` (same checks, from the connector, which runs on the app's site too). `frame.canShareStream()` is `false` when neither works — an older Vitre with a frame on another site, where a transferred share would die on its first frame. Keep a fallback for that case (e.g. let the host open the camera with `connector.requestOpenStreamFrame`). `attachStream`
|
|
225
|
+
A connector decides before opening the frame with `connector.canFrameShareStream()` (same checks, from the connector, which runs on the app's site too). `frame.canShareStream()` is `false` when neither works — an older Vitre with a frame on another site, where a transferred share would die on its first frame. Keep a fallback for that case (e.g. let the host open the camera with `connector.requestOpenStreamFrame`). `attachStream` takes the same two transports since SDK 1.66 (`frame.canAttachStream()`); `Connector.shareStream` keeps the readables transport only.
|
|
226
|
+
|
|
227
|
+
### Showing a frame's own stream on every vitre — `frame.attachStream` (SDK 1.66)
|
|
228
|
+
|
|
229
|
+
A frame opened with `openFrame` already appears on every vitre of the space. To show a stream it produces (a camera it opened, a canvas it draws) inside **that same frame** everywhere, attach the stream to it:
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
if (frame.initiator.id === frame.hostInformation.device.id) {
|
|
233
|
+
const stream = await navigator.mediaDevices.getUserMedia({ video: true })
|
|
234
|
+
video.srcObject = stream // the source renders its own stream
|
|
235
|
+
await frame.attachStream(stream) // the other vitres' instances get it
|
|
236
|
+
// camera switch: await frame.replaceAttachedStream(otherStream)
|
|
237
|
+
// stop: frame.detachStream()
|
|
238
|
+
} else {
|
|
239
|
+
frame.onSharedStream = (_id, stream) => { video.srcObject = stream }
|
|
240
|
+
frame.onSharedStreamRemoved = () => { video.srcObject = null }
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Do not use `shareStream(stream, { receiverDisplay: 'appFrame' })` for this: it opens a SECOND shared content that loads the frame's page again, with the same `data` and a `streamId`, on the sharing vitre too. Each vitre then shows two frames, and an instance that cannot tell it is the share's display opens the camera a second time. `shareStream` is for a stream that becomes a share of its own.
|
|
245
|
+
|
|
246
|
+
`replaceAttachedStream` swaps the tracks on the peer connection's senders when the stream went over one; with readables it detaches and attaches again (receivers see `onSharedStreamRemoved` then `onSharedStream`).
|
|
226
247
|
|
|
227
248
|
### Native or web host — `isNativeHost`
|
|
228
249
|
|
|
@@ -90,7 +90,7 @@ export type InitializeFrame = {
|
|
|
90
90
|
appChannel?: string;
|
|
91
91
|
/**
|
|
92
92
|
* What the host can do beyond this message's shape. `'shareStreamPeer'`:
|
|
93
|
-
* `shareStream`
|
|
93
|
+
* `shareStream` and `attachStream` accept a {@link ShareStreamPeerTransport}. Omitted by hosts
|
|
94
94
|
* older than this field. Added 1.65.
|
|
95
95
|
*/
|
|
96
96
|
hostCapabilities?: string[];
|
|
@@ -562,7 +562,7 @@ export type FrameApiMessagesOut = ({
|
|
|
562
562
|
type: 'attachStream';
|
|
563
563
|
requestId: string;
|
|
564
564
|
targetFrameConnectorId?: string;
|
|
565
|
-
tracks: ShareStreamTrack[];
|
|
565
|
+
tracks: ShareStreamTrack[] | ShareStreamPeerTransport;
|
|
566
566
|
} | {
|
|
567
567
|
type: 'detachStream';
|
|
568
568
|
targetFrameConnectorId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Frame.Model.js","sourceRoot":"","sources":["../../Frame/Frame.Model.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AiInboundMessage,\n AiOutboundMessage,\n AppMessage,\n AppSettingsChanged,\n AppSettingsResponse,\n BluetoothFromApp,\n BluetoothToApp,\n BorderOptions,\n ChangePrivacy,\n ChangeTeamSpace,\n ChangeTeamSpaceGuest,\n CompanionFramePeerJoined,\n CompanionFramePeerLeft,\n CompanionFramePeersUpdated,\n ConnectedMediaDevice,\n ConnectionCodeUpdated,\n DeletePublicFile,\n DeletePrivateFile,\n GetPrivateFile,\n GetPrivateFileLink,\n ListPrivateFiles,\n PrivateStorageResponse,\n PutPrivateFile,\n Device,\n DeviceFrameReference,\n DeviceFullscreenUpdated,\n DeviceJoined,\n DeviceLeft,\n DeviceMessageReceived,\n DevicePrivacyChanged,\n DeviceScalingUpdated,\n DisconnectGuests,\n EnumerateLoadedFrames,\n EnumerateLoadedFramesCompleted,\n EventTelemetry,\n FieldUpdated,\n FileData,\n CompanionInformation,\n FrameTouchMode,\n GetAppSettings,\n GetStats,\n HideNotification,\n HostInformation,\n I18nMap,\n Interaction,\n KnockKnock,\n LayoutPosition,\n ListPublicFiles,\n LocalConnectorMessageReceived,\n MenuClicked,\n MenuEntry,\n NotificationButtonClicked,\n NotificationDismissed,\n NotificationInfo,\n PendingDevicesInfo,\n PositionUpdated,\n SafeAreaInsets,\n SafeAreaInsetsUpdated,\n PrivacyChanged,\n PublicStorageResponse,\n PutPublicFile,\n Rect,\n RequestSerialPortAccess,\n SerialPortAccessResult,\n RequestStreamSizeUpdate,\n ResizeMode,\n SaveSettings,\n SendKnockKnock,\n SendMessageTo,\n SendMessageToAll,\n SendToLocalFrame,\n SendToSerialPort,\n SetAppSettings,\n SetReducedAudioMode,\n SettingsUpdated,\n SetVisibility,\n ShareDataRequest,\n ShareFileRequest,\n Size,\n StartEventTelemetry,\n StateReplaced,\n StatsResponse,\n StreamCapture,\n UpdateState,\n VideoContentHint,\n ViewMode,\n VisibilityChanged,\n VitreSettings,\n VitreSettingsSetter,\n VoiceAction,\n VoiceActionDetection,\n} from '../Common/index.js'\nimport type {\n MediaTrackInfo,\n ReplaceShareStream,\n ShareStream,\n ShareStreamCompleted,\n ShareStreamTrack,\n StopShareStream,\n} from '../Connector/Connector.Model.js'\n\n/// Host → Frame (reverse breakout box): the Vitre exposes a live `MediaStream`\n/// it owns into a frame. Each track carries a transferable `readable`\n/// (MediaStreamTrackProcessor output); the frame rebuilds a live\n/// MediaStreamTrack via MediaStreamTrackGenerator. `streamId` lets the frame\n/// match a later `sharedStreamRemoved`. Symmetric inverse of `ShareStream`.\nexport type SharedStreamAvailable = {\n streamId: string\n tracks: ShareStreamTrack[]\n}\n\n/// Frame → host `shareStream` over a local RTCPeerConnection, in place of the\n/// readables array, when the frame cannot transfer readables to the host page\n/// (another site, or no MediaStreamTrackProcessor). The frame offers over\n/// `port` (signaling as in `OutgoingStreamPeer.ts`); `video`/`audio` are the\n/// settings of the tracks sent. Only to a host announcing `shareStreamPeer`\n/// in `InitializeFrame.hostCapabilities`.\nexport type ShareStreamPeerTransport = {\n transport: 'peer'\n port: MessagePort\n video?: MediaTrackSettings\n audio?: MediaTrackSettings\n}\n\nexport type FrameShareStream = Omit<ShareStream, 'tracks'> & {\n tracks: ShareStreamTrack[] | ShareStreamPeerTransport\n}\n\nexport type SharedStreamRemoved = {\n streamId: string\n}\n\n/// Host → Frame, fallback for `SharedStreamAvailable` when the host cannot\n/// transfer track readables into this frame (frame on another site, or no\n/// MediaStreamTrackProcessor). The stream travels over a local\n/// RTCPeerConnection signaled through `port` (see SharedStreamPeer.ts).\nexport type SharedStreamOffer = {\n streamId: string\n port: MessagePort\n}\n\nexport type AvailableExportSource = {\n supportedFormats: string[]\n label: I18nMap\n fileSuffix?: string\n fileExtension?: string\n binaryHeader?: ArrayBufferLike\n tag?: any\n id: string\n menu?: MenuEntry[]\n /**\n * SDK 1.46 — whether this export source is offered to connected\n * companions. Defaults to `true`.\n *\n * When `false` the Vitre never advertises the source to a companion, so\n * it appears in no companion menu: neither \"share to another app\" nor\n * \"download to this device\". The Vitre's own export menu is unaffected.\n *\n * Use it for sources that only make sense on the Vitre (huge payloads,\n * formats a phone cannot open, host-local side effects).\n */\n availableForCompanion?: boolean\n}\n\nexport type LoadingFileData = {\n id: string\n name: string\n mime: string\n}\n\nexport type InitFrameOptions = {\n frameConnectorId: string\n streamId?: string\n name: string\n url: string\n size: Size\n minSize?: Size\n maxSize?: Size\n touchMode: FrameTouchMode\n allowFullscreen: boolean\n resizeMode: ResizeMode\n data?: any\n file?: FileData\n border: BorderOptions\n syncedTimeOffset: number\n}\n\nexport type InitializeFrame = {\n hostInfo: HostInformation\n /**\n * The companion's own identity/runtime context, present only when this\n * frame is loaded by a la Vitre **companion** (mirrors\n * `hostInfo.isCompanion`). Surfaced as `frame.companionInformation`.\n * Undefined on Vitre-side frames. Added 1.19.\n */\n companionInfo?: CompanionInformation\n initiator: Device\n id: string\n appId?: string\n /**\n * The version of this app the vitre loaded — the semver it was deployed\n * under (`begin_deploy`), e.g. `'1.4.0'`. Not the host version\n * (`hostInfo.version`). Omitted by hosts older than this field. Added 1.63.\n */\n appVersion?: string\n /**\n * The app channel that version was selected through (`'preview'`, `'beta'`…),\n * when a team or space follows a channel for this app. Omitted when the version\n * is the team's own selection, a pinned version or a global one, and by hosts\n * older than this field. Added 1.63.\n */\n appChannel?: string\n /**\n * What the host can do beyond this message's shape. `'shareStreamPeer'`:\n * `shareStream` accepts a {@link ShareStreamPeerTransport}. Omitted by hosts\n * older than this field. Added 1.65.\n */\n hostCapabilities?: string[]\n options: InitFrameOptions\n isFullscreen: boolean\n /**\n * @deprecated Use options.border.mode\n */\n isBorderless: boolean\n state?: Record<string, any>\n position: Rect\n /**\n * Insets the frame must keep its controls clear of, when the host runs it\n * edge-to-edge (`CompanionFrameOption.edgeToEdge`); later changes arrive\n * as `safeAreaInsetsUpdated`. Absent from hosts before 1.51 — read as all\n * zero. Added 1.51.\n */\n safeAreaInsets?: SafeAreaInsets\n}\n\nexport type FrameDefaultMenuCategory = {\n type: 'defaultMenu'\n label?: string\n description?: string\n order?: number\n}\n\nexport type FrameMenuCategory = { type: 'iconMenu' } | FrameDefaultMenuCategory\n\nexport type FrameMenuEntry = Omit<MenuEntry, 'category'> & {\n category?: FrameMenuCategory\n}\n\nexport type SetFrameMenu = {\n menu: FrameMenuEntry[]\n}\n\nexport type ViewOptions = {\n name: string\n minSize?: Size\n maxSize?: Size\n size?: Size\n /**\n * @deprecated Use interaction property\n */\n touchMode?: FrameTouchMode\n allowFullscreen?: boolean\n hideMenu?: boolean\n resizeMode?: ResizeMode\n menu?: FrameMenuEntry[]\n exportSources?: AvailableExportSource[]\n /**\n * @deprecated Use interaction property\n */\n interactionEnabled?: boolean\n interaction?: Interaction\n mode?: ViewMode\n closable?: boolean\n closeLabel?: string\n}\n\nexport type FrameInitialized = {\n options: ViewOptions\n}\n\nexport type SetFullscreen = {\n type: 'setFullscreen'\n}\n\nexport type SetWindowed = {\n type: 'setWindowed'\n}\n\n/**\n * Replace the video track of THIS frame's shared stream with a new\n * `getUserMedia` capture (e.g. switch camera) while keeping the same share\n * (same `sharedStreamId`) — results in a `replaceTrack` on the host, no\n * WebRTC renegotiation. The host applies an `{ exact }` deviceId constraint.\n */\nexport type ReplaceFrameStream = {\n requestId: string\n constraints: MediaStreamConstraints\n}\n\nexport type ApplyStreamAdvancedConstraints = {\n streamId?: string\n contentHint?: VideoContentHint\n whiteBalanceMode?: string\n focusMode?: string\n resizeMode?: string\n exposureMode?: string\n\n colorTemperature?: number\n exposureCompensation?: number\n brightness?: number\n contrast?: number\n exposureTime?: number\n saturation?: number\n sharpness?: number\n focusDistance?: number\n width?: number\n height?: number\n mirror?: boolean\n}\n\nexport type IsInteractingChanged = {\n isInteracting: boolean\n}\n\nexport type FileProgress = {\n bytes: number\n totalBytes: number\n}\n\nexport type FileLoaded = {\n file: ArrayBufferLike\n}\n\nexport type SetExportSources = {\n /**\n * The full replacement list. Was mistyped as a single\n * `AvailableExportSource` until 1.47; the host has always decoded an\n * array here (`Decode.array` on the `setExportSources` message), so no\n * emitter can have relied on the singular form — nothing shipped could\n * send this message before 1.47 anyway, `Frame.setExportSources` being\n * the first emitter.\n */\n exportSources: AvailableExportSource[]\n}\n\nexport type ExportRequest = {\n id: string\n format?: string\n tag?: any\n exportSourceId: string\n menuId?: string\n}\n\nexport type ExportData = {\n format: string\n name: string\n buffer: ArrayBufferLike\n}\n\nexport type ExportDone = {\n request: ExportRequest\n data?: ExportData\n error?: string\n}\n\nexport type SetSize = {\n width: number\n height: number\n}\n\nexport type BorderlessUpdated = {\n isBorderless: boolean\n}\n\nexport type FullscreenUpdated = {\n isFullscreen: boolean\n}\n\nexport type UpdateFrameName = { name: string }\n\nexport type UpdateName = { name: string }\n\nexport type SharedStreamPlayState = 'playing' | 'paused'\n\nexport type LocalSharedStreamUpdate = {\n volume: number\n}\n\nexport type StreamAction =\n | { action: 'play' }\n | { action: 'pause' }\n | { action: 'seek'; position: number; isRelative: boolean }\n | { action: 'volume'; volume: number; muted: boolean }\n\nexport type FrameApiMessagesIn =\n | ({\n type: 'enumerateLoadedFramesCompleted'\n } & EnumerateLoadedFramesCompleted)\n | ({ type: 'initialize' } & InitializeFrame)\n | ({ type: 'deviceJoined' } & DeviceJoined)\n | ({ type: 'deviceLeft' } & DeviceLeft)\n | ({ type: 'deviceMessageReceived' } & DeviceMessageReceived)\n | ({ type: 'localConnectorMessageReceived' } & LocalConnectorMessageReceived)\n | ({ type: 'menuClicked' } & MenuClicked)\n | ({ type: 'fieldUpdated' } & FieldUpdated)\n | ({ type: 'privacyChanged' } & PrivacyChanged)\n | ({ type: 'isInteractingChanged' } & IsInteractingChanged)\n | ({ type: 'fileLoaded' } & FileLoaded)\n | ({ type: 'fileProgress' } & FileProgress)\n | ({ type: 'exportRequest' } & ExportRequest)\n | ({ type: 'vitreSettingsResponse' } & VitreSettings)\n | ({ type: 'knockKnockReceived' } & KnockKnock)\n | ({ type: 'settingsUpdated' } & SettingsUpdated)\n | ({ type: 'appSettingsResponse' } & AppSettingsResponse)\n | ({ type: 'appSettingsChanged' } & AppSettingsChanged)\n | ({ type: 'publicStorageResponse' } & PublicStorageResponse)\n | ({ type: 'privateStorageResponse' } & PrivateStorageResponse)\n | ({ type: 'vitreSettingsUpdated' } & VitreSettings)\n | ({ type: 'notificationDismissed' } & NotificationDismissed)\n | ({ type: 'notificationButtonClicked' } & NotificationButtonClicked)\n | ({ type: 'devicePrivacyChanged' } & DevicePrivacyChanged)\n | ({ type: 'deviceFrameUnloaded' } & DeviceFrameReference)\n | ({ type: 'deviceFrameLoaded' } & DeviceFrameReference)\n | ({ type: 'deviceFrameConnectorLoaded' } & DeviceFrameReference)\n | ({ type: 'pendingDevicesConnectionRequested' } & PendingDevicesInfo)\n | ({ type: 'borderlessUpdated' } & BorderlessUpdated)\n | ({ type: 'fullscreenUpdated' } & FullscreenUpdated)\n | ({ type: 'borderOptionsUpdated' } & BorderOptions)\n | ({ type: 'voiceActionDetected' } & VoiceActionDetection)\n | {\n type: 'streamFrameCapturedResponse'\n requestId: string\n response?: StreamCapture\n error: string\n }\n | {\n type: 'replaceFrameStreamCompleted'\n requestId: string\n tracks?: MediaTrackInfo[]\n error?: string\n }\n | ({ type: 'stateReplaced' } & StateReplaced)\n | ({ type: 'deviceFullscreenUpdated' } & DeviceFullscreenUpdated)\n | ({ type: 'visibilityChanged' } & VisibilityChanged)\n | ({ type: 'positionUpdated' } & PositionUpdated)\n | ({ type: 'safeAreaInsetsUpdated' } & SafeAreaInsetsUpdated)\n | ({ type: 'deviceScalingUpdated' } & DeviceScalingUpdated)\n | ({ type: 'updateFrameName' } & UpdateFrameName)\n | ({ type: 'localSharedStreamUpdate' } & LocalSharedStreamUpdate)\n | ({ type: 'statsResponse' } & StatsResponse)\n | { type: 'iceServersResponse'; requestId: string; iceServers: IceServerConfig[] }\n | ({ type: 'serialPortAccessResult'; requestId: string } & SerialPortAccessResult)\n | ({ type: 'connectionCodeUpdated' } & ConnectionCodeUpdated)\n | ({ type: 'mediaDevicesChanged' } & MediaDevicesChanged)\n | ({ type: 'bluetooth' } & BluetoothToApp)\n | { type: 'crdtUpdate'; update: ArrayBufferLike }\n | { type: 'crdtSyncComplete' }\n | { type: 'crdtRequestSync' }\n | { type: 'crdtAwarenessUpdate'; update: ArrayBufferLike }\n | { type: 'crdtSubdocUpdate'; guid: string; update: ArrayBufferLike }\n | { type: 'crdtSubdocSyncComplete'; guid: string }\n | {\n type: 'crdtSubdocTransferProgress'\n guid: string\n receivedBytes: number\n totalBytes: number\n }\n | { type: 'crdtSubdocRequestSync'; guid: string }\n | ({ type: 'companionFramePeerJoined' } & CompanionFramePeerJoined)\n | ({ type: 'companionFramePeerLeft' } & CompanionFramePeerLeft)\n | ({ type: 'companionFramePeersUpdated' } & CompanionFramePeersUpdated)\n | ({ type: 'shareStreamCompleted' } & ShareStreamCompleted)\n | ({ type: 'sharedStreamAvailable' } & SharedStreamAvailable)\n | ({ type: 'sharedStreamRemoved' } & SharedStreamRemoved)\n | ({ type: 'sharedStreamOffer' } & SharedStreamOffer)\n | { type: 'attachStreamCompleted'; requestId: string; error?: string }\n // AI tool channel: the host asks this frame to run one of its registered tools.\n | AiInboundMessage\n\nexport type MediaDevicesChanged = {\n devices: ConnectedMediaDevice[]\n}\n\n/** Companion frame → Vitre main connector (see CompanionFrame.sendMessageToVitreConnector). */\nexport type SendToVitreConnector = {\n frameConnectorId: string\n message: string\n fileData?: FileData\n}\n\n/**\n * ICE / TURN server config the HOST already uses for its own WebRTC P2P,\n * sourced from the connection handshake (`StartWebRTCOffer.IceServers` on a\n * Vitre, `WebRTCOffer.iceServers` on a companion). The shape matches the\n * browser `RTCIceServer` so the result of {@link Frame.getIceServers} can be\n * passed straight to `new RTCPeerConnection({ iceServers })` — letting an app\n * stand up its own peer connection (e.g. a companion-camera frame connecting\n * directly to its paired Vitre transform frame) that traverses NAT through the\n * same TURN relays as the platform, without shipping its own credentials.\n */\nexport type IceServerConfig = {\n urls: string[]\n username?: string\n credential?: string\n}\n\nexport type FrameApiMessagesOut =\n | ({ type: 'sendMessageTo' } & SendMessageTo)\n | ({ type: 'sendMessageToAll' } & SendMessageToAll)\n | ({ type: 'frameInitialized' } & FrameInitialized)\n | { type: 'setFullscreen' }\n | { type: 'setWindowed' }\n | { type: 'close' }\n | ({ type: 'setFrameMenu' } & SetFrameMenu)\n | ({ type: 'sendToLocalFrame' } & SendToLocalFrame)\n | ({ type: 'sendToVitreConnector' } & SendToVitreConnector)\n | ({ type: 'enumerateLoadedFrames' } & EnumerateLoadedFrames)\n | ({ type: 'setExportSources' } & SetExportSources)\n | ({\n type: 'applyStreamAdvancedConstraints'\n } & ApplyStreamAdvancedConstraints)\n | ({ type: 'replaceFrameStream' } & ReplaceFrameStream)\n | { type: 'stopInteracting' }\n | { type: 'startInteracting' }\n | ({ type: 'exportDone' } & ExportDone)\n | ({ type: 'setSize' } & SetSize)\n | { type: 'getVitreSettings' }\n | ({ type: 'setVitreSettings' } & VitreSettingsSetter)\n | ({ type: 'shareFile' } & ShareFileRequest)\n | ({ type: 'shareData' } & ShareDataRequest)\n | ({ type: 'saveSettings' } & SaveSettings)\n | ({ type: 'getAppSettings' } & GetAppSettings)\n | ({ type: 'setAppSettings' } & SetAppSettings)\n | ({ type: 'putPublicFile' } & PutPublicFile)\n | ({ type: 'deletePublicFile' } & DeletePublicFile)\n | ({ type: 'listPublicFiles' } & ListPublicFiles)\n | ({ type: 'putPrivateFile' } & PutPrivateFile)\n | ({ type: 'deletePrivateFile' } & DeletePrivateFile)\n | ({ type: 'listPrivateFiles' } & ListPrivateFiles)\n | ({ type: 'getPrivateFile' } & GetPrivateFile)\n | ({ type: 'getPrivateFileLink' } & GetPrivateFileLink)\n | ({ type: 'changeTeamSpace' } & ChangeTeamSpace)\n | ({ type: 'changeTeamSpaceGuest' } & ChangeTeamSpaceGuest)\n | ({ type: 'showNotification' } & NotificationInfo)\n | ({ type: 'hideNotification' } & HideNotification)\n | ({ type: 'changePrivacy' } & ChangePrivacy)\n | ({ type: 'appMessage' } & AppMessage)\n | ({ type: 'extensionMessage' } & AppMessage)\n | ({ type: 'trackEvent' } & EventTelemetry)\n | ({ type: 'startTrackEvent' } & StartEventTelemetry)\n | ({ type: 'stopTrackEvent' } & EventTelemetry)\n | ({ type: 'setBorderOptions' } & BorderOptions)\n | { type: 'setVoiceActions'; actions: VoiceAction[] }\n | { type: 'streamFrameCaptureRequest'; requestId: string }\n | ({ type: 'updateState' } & UpdateState)\n | ({ type: 'setPosition' } & LayoutPosition)\n | ({ type: 'setVisibility' } & SetVisibility)\n | ({ type: 'sharedStreamAction' } & StreamAction)\n | ({ type: 'sendKnockKnock' } & SendKnockKnock)\n | ({ type: 'getStats' } & GetStats)\n | { type: 'getIceServers'; requestId: string }\n | ({ type: 'setReducedAudioMode' } & SetReducedAudioMode)\n | ({ type: 'sendToSerialPort' } & SendToSerialPort)\n | ({\n type: 'requestSerialPortAccess'\n requestId: string\n } & RequestSerialPortAccess)\n | ({ type: 'bluetooth' } & BluetoothFromApp)\n | ({ type: 'disconnectGuests' } & DisconnectGuests)\n | ({ type: 'requestStreamSizeUpdate' } & RequestStreamSizeUpdate)\n | ({ type: 'updateName' } & UpdateName)\n | ({ type: 'shareStream' } & FrameShareStream)\n | ({ type: 'replaceShareStream' } & ReplaceShareStream)\n | ({ type: 'stopShareStream' } & StopShareStream)\n | {\n type: 'attachStream'\n requestId: string\n targetFrameConnectorId?: string\n tracks: ShareStreamTrack[]\n }\n | { type: 'detachStream'; targetFrameConnectorId?: string }\n | { type: 'crdtUpdate'; update: ArrayBufferLike }\n | { type: 'crdtRequestSync' }\n | { type: 'crdtAwarenessUpdate'; update: ArrayBufferLike }\n | { type: 'crdtRequestAwareness' }\n | { type: 'crdtSubdocUpdate'; guid: string; update: ArrayBufferLike }\n | { type: 'crdtSubdocRequestSync'; guid: string }\n /**\n * Companion-frame-only: close the iframe locally on the companion and\n * remove this companion from the per-frame `framePresence` on the Vitre,\n * WITHOUT closing the Vitre's own frame (which keeps showing for other\n * peers + the local Vitre app). The companion's resulting state matches\n * \"frame was open on the Vitre when I late-joined the space\": iframe\n * unmounted, not in framePresence, can be re-opened by clicking the\n * matching menu entry again or by autoOpen on next reconnect.\n *\n * Sent by `CompanionFrame.closeOnCompanion()`. The Vitre host's path is\n * the existing `CompanionToVitreReq.FrameClosed` — semantics are\n * \"remove from presence, don't kill the Vitre frame\" so no new wire\n * case is needed. The `close` arm of this union remains the global\n * close (deprecated for use on companion frames).\n */\n | { type: 'closeOnCompanion' }\n // AI tool channel: publish/withdraw this frame's tool catalog + answer invocations.\n | AiOutboundMessage\n"]}
|
|
1
|
+
{"version":3,"file":"Frame.Model.js","sourceRoot":"","sources":["../../Frame/Frame.Model.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AiInboundMessage,\n AiOutboundMessage,\n AppMessage,\n AppSettingsChanged,\n AppSettingsResponse,\n BluetoothFromApp,\n BluetoothToApp,\n BorderOptions,\n ChangePrivacy,\n ChangeTeamSpace,\n ChangeTeamSpaceGuest,\n CompanionFramePeerJoined,\n CompanionFramePeerLeft,\n CompanionFramePeersUpdated,\n ConnectedMediaDevice,\n ConnectionCodeUpdated,\n DeletePublicFile,\n DeletePrivateFile,\n GetPrivateFile,\n GetPrivateFileLink,\n ListPrivateFiles,\n PrivateStorageResponse,\n PutPrivateFile,\n Device,\n DeviceFrameReference,\n DeviceFullscreenUpdated,\n DeviceJoined,\n DeviceLeft,\n DeviceMessageReceived,\n DevicePrivacyChanged,\n DeviceScalingUpdated,\n DisconnectGuests,\n EnumerateLoadedFrames,\n EnumerateLoadedFramesCompleted,\n EventTelemetry,\n FieldUpdated,\n FileData,\n CompanionInformation,\n FrameTouchMode,\n GetAppSettings,\n GetStats,\n HideNotification,\n HostInformation,\n I18nMap,\n Interaction,\n KnockKnock,\n LayoutPosition,\n ListPublicFiles,\n LocalConnectorMessageReceived,\n MenuClicked,\n MenuEntry,\n NotificationButtonClicked,\n NotificationDismissed,\n NotificationInfo,\n PendingDevicesInfo,\n PositionUpdated,\n SafeAreaInsets,\n SafeAreaInsetsUpdated,\n PrivacyChanged,\n PublicStorageResponse,\n PutPublicFile,\n Rect,\n RequestSerialPortAccess,\n SerialPortAccessResult,\n RequestStreamSizeUpdate,\n ResizeMode,\n SaveSettings,\n SendKnockKnock,\n SendMessageTo,\n SendMessageToAll,\n SendToLocalFrame,\n SendToSerialPort,\n SetAppSettings,\n SetReducedAudioMode,\n SettingsUpdated,\n SetVisibility,\n ShareDataRequest,\n ShareFileRequest,\n Size,\n StartEventTelemetry,\n StateReplaced,\n StatsResponse,\n StreamCapture,\n UpdateState,\n VideoContentHint,\n ViewMode,\n VisibilityChanged,\n VitreSettings,\n VitreSettingsSetter,\n VoiceAction,\n VoiceActionDetection,\n} from '../Common/index.js'\nimport type {\n MediaTrackInfo,\n ReplaceShareStream,\n ShareStream,\n ShareStreamCompleted,\n ShareStreamTrack,\n StopShareStream,\n} from '../Connector/Connector.Model.js'\n\n/// Host → Frame (reverse breakout box): the Vitre exposes a live `MediaStream`\n/// it owns into a frame. Each track carries a transferable `readable`\n/// (MediaStreamTrackProcessor output); the frame rebuilds a live\n/// MediaStreamTrack via MediaStreamTrackGenerator. `streamId` lets the frame\n/// match a later `sharedStreamRemoved`. Symmetric inverse of `ShareStream`.\nexport type SharedStreamAvailable = {\n streamId: string\n tracks: ShareStreamTrack[]\n}\n\n/// Frame → host `shareStream` over a local RTCPeerConnection, in place of the\n/// readables array, when the frame cannot transfer readables to the host page\n/// (another site, or no MediaStreamTrackProcessor). The frame offers over\n/// `port` (signaling as in `OutgoingStreamPeer.ts`); `video`/`audio` are the\n/// settings of the tracks sent. Only to a host announcing `shareStreamPeer`\n/// in `InitializeFrame.hostCapabilities`. `attachStream` carries it too: such\n/// a host passes both messages' tracks to the same share session (SDK 1.66).\nexport type ShareStreamPeerTransport = {\n transport: 'peer'\n port: MessagePort\n video?: MediaTrackSettings\n audio?: MediaTrackSettings\n}\n\nexport type FrameShareStream = Omit<ShareStream, 'tracks'> & {\n tracks: ShareStreamTrack[] | ShareStreamPeerTransport\n}\n\nexport type SharedStreamRemoved = {\n streamId: string\n}\n\n/// Host → Frame, fallback for `SharedStreamAvailable` when the host cannot\n/// transfer track readables into this frame (frame on another site, or no\n/// MediaStreamTrackProcessor). The stream travels over a local\n/// RTCPeerConnection signaled through `port` (see SharedStreamPeer.ts).\nexport type SharedStreamOffer = {\n streamId: string\n port: MessagePort\n}\n\nexport type AvailableExportSource = {\n supportedFormats: string[]\n label: I18nMap\n fileSuffix?: string\n fileExtension?: string\n binaryHeader?: ArrayBufferLike\n tag?: any\n id: string\n menu?: MenuEntry[]\n /**\n * SDK 1.46 — whether this export source is offered to connected\n * companions. Defaults to `true`.\n *\n * When `false` the Vitre never advertises the source to a companion, so\n * it appears in no companion menu: neither \"share to another app\" nor\n * \"download to this device\". The Vitre's own export menu is unaffected.\n *\n * Use it for sources that only make sense on the Vitre (huge payloads,\n * formats a phone cannot open, host-local side effects).\n */\n availableForCompanion?: boolean\n}\n\nexport type LoadingFileData = {\n id: string\n name: string\n mime: string\n}\n\nexport type InitFrameOptions = {\n frameConnectorId: string\n streamId?: string\n name: string\n url: string\n size: Size\n minSize?: Size\n maxSize?: Size\n touchMode: FrameTouchMode\n allowFullscreen: boolean\n resizeMode: ResizeMode\n data?: any\n file?: FileData\n border: BorderOptions\n syncedTimeOffset: number\n}\n\nexport type InitializeFrame = {\n hostInfo: HostInformation\n /**\n * The companion's own identity/runtime context, present only when this\n * frame is loaded by a la Vitre **companion** (mirrors\n * `hostInfo.isCompanion`). Surfaced as `frame.companionInformation`.\n * Undefined on Vitre-side frames. Added 1.19.\n */\n companionInfo?: CompanionInformation\n initiator: Device\n id: string\n appId?: string\n /**\n * The version of this app the vitre loaded — the semver it was deployed\n * under (`begin_deploy`), e.g. `'1.4.0'`. Not the host version\n * (`hostInfo.version`). Omitted by hosts older than this field. Added 1.63.\n */\n appVersion?: string\n /**\n * The app channel that version was selected through (`'preview'`, `'beta'`…),\n * when a team or space follows a channel for this app. Omitted when the version\n * is the team's own selection, a pinned version or a global one, and by hosts\n * older than this field. Added 1.63.\n */\n appChannel?: string\n /**\n * What the host can do beyond this message's shape. `'shareStreamPeer'`:\n * `shareStream` and `attachStream` accept a {@link ShareStreamPeerTransport}. Omitted by hosts\n * older than this field. Added 1.65.\n */\n hostCapabilities?: string[]\n options: InitFrameOptions\n isFullscreen: boolean\n /**\n * @deprecated Use options.border.mode\n */\n isBorderless: boolean\n state?: Record<string, any>\n position: Rect\n /**\n * Insets the frame must keep its controls clear of, when the host runs it\n * edge-to-edge (`CompanionFrameOption.edgeToEdge`); later changes arrive\n * as `safeAreaInsetsUpdated`. Absent from hosts before 1.51 — read as all\n * zero. Added 1.51.\n */\n safeAreaInsets?: SafeAreaInsets\n}\n\nexport type FrameDefaultMenuCategory = {\n type: 'defaultMenu'\n label?: string\n description?: string\n order?: number\n}\n\nexport type FrameMenuCategory = { type: 'iconMenu' } | FrameDefaultMenuCategory\n\nexport type FrameMenuEntry = Omit<MenuEntry, 'category'> & {\n category?: FrameMenuCategory\n}\n\nexport type SetFrameMenu = {\n menu: FrameMenuEntry[]\n}\n\nexport type ViewOptions = {\n name: string\n minSize?: Size\n maxSize?: Size\n size?: Size\n /**\n * @deprecated Use interaction property\n */\n touchMode?: FrameTouchMode\n allowFullscreen?: boolean\n hideMenu?: boolean\n resizeMode?: ResizeMode\n menu?: FrameMenuEntry[]\n exportSources?: AvailableExportSource[]\n /**\n * @deprecated Use interaction property\n */\n interactionEnabled?: boolean\n interaction?: Interaction\n mode?: ViewMode\n closable?: boolean\n closeLabel?: string\n}\n\nexport type FrameInitialized = {\n options: ViewOptions\n}\n\nexport type SetFullscreen = {\n type: 'setFullscreen'\n}\n\nexport type SetWindowed = {\n type: 'setWindowed'\n}\n\n/**\n * Replace the video track of THIS frame's shared stream with a new\n * `getUserMedia` capture (e.g. switch camera) while keeping the same share\n * (same `sharedStreamId`) — results in a `replaceTrack` on the host, no\n * WebRTC renegotiation. The host applies an `{ exact }` deviceId constraint.\n */\nexport type ReplaceFrameStream = {\n requestId: string\n constraints: MediaStreamConstraints\n}\n\nexport type ApplyStreamAdvancedConstraints = {\n streamId?: string\n contentHint?: VideoContentHint\n whiteBalanceMode?: string\n focusMode?: string\n resizeMode?: string\n exposureMode?: string\n\n colorTemperature?: number\n exposureCompensation?: number\n brightness?: number\n contrast?: number\n exposureTime?: number\n saturation?: number\n sharpness?: number\n focusDistance?: number\n width?: number\n height?: number\n mirror?: boolean\n}\n\nexport type IsInteractingChanged = {\n isInteracting: boolean\n}\n\nexport type FileProgress = {\n bytes: number\n totalBytes: number\n}\n\nexport type FileLoaded = {\n file: ArrayBufferLike\n}\n\nexport type SetExportSources = {\n /**\n * The full replacement list. Was mistyped as a single\n * `AvailableExportSource` until 1.47; the host has always decoded an\n * array here (`Decode.array` on the `setExportSources` message), so no\n * emitter can have relied on the singular form — nothing shipped could\n * send this message before 1.47 anyway, `Frame.setExportSources` being\n * the first emitter.\n */\n exportSources: AvailableExportSource[]\n}\n\nexport type ExportRequest = {\n id: string\n format?: string\n tag?: any\n exportSourceId: string\n menuId?: string\n}\n\nexport type ExportData = {\n format: string\n name: string\n buffer: ArrayBufferLike\n}\n\nexport type ExportDone = {\n request: ExportRequest\n data?: ExportData\n error?: string\n}\n\nexport type SetSize = {\n width: number\n height: number\n}\n\nexport type BorderlessUpdated = {\n isBorderless: boolean\n}\n\nexport type FullscreenUpdated = {\n isFullscreen: boolean\n}\n\nexport type UpdateFrameName = { name: string }\n\nexport type UpdateName = { name: string }\n\nexport type SharedStreamPlayState = 'playing' | 'paused'\n\nexport type LocalSharedStreamUpdate = {\n volume: number\n}\n\nexport type StreamAction =\n | { action: 'play' }\n | { action: 'pause' }\n | { action: 'seek'; position: number; isRelative: boolean }\n | { action: 'volume'; volume: number; muted: boolean }\n\nexport type FrameApiMessagesIn =\n | ({\n type: 'enumerateLoadedFramesCompleted'\n } & EnumerateLoadedFramesCompleted)\n | ({ type: 'initialize' } & InitializeFrame)\n | ({ type: 'deviceJoined' } & DeviceJoined)\n | ({ type: 'deviceLeft' } & DeviceLeft)\n | ({ type: 'deviceMessageReceived' } & DeviceMessageReceived)\n | ({ type: 'localConnectorMessageReceived' } & LocalConnectorMessageReceived)\n | ({ type: 'menuClicked' } & MenuClicked)\n | ({ type: 'fieldUpdated' } & FieldUpdated)\n | ({ type: 'privacyChanged' } & PrivacyChanged)\n | ({ type: 'isInteractingChanged' } & IsInteractingChanged)\n | ({ type: 'fileLoaded' } & FileLoaded)\n | ({ type: 'fileProgress' } & FileProgress)\n | ({ type: 'exportRequest' } & ExportRequest)\n | ({ type: 'vitreSettingsResponse' } & VitreSettings)\n | ({ type: 'knockKnockReceived' } & KnockKnock)\n | ({ type: 'settingsUpdated' } & SettingsUpdated)\n | ({ type: 'appSettingsResponse' } & AppSettingsResponse)\n | ({ type: 'appSettingsChanged' } & AppSettingsChanged)\n | ({ type: 'publicStorageResponse' } & PublicStorageResponse)\n | ({ type: 'privateStorageResponse' } & PrivateStorageResponse)\n | ({ type: 'vitreSettingsUpdated' } & VitreSettings)\n | ({ type: 'notificationDismissed' } & NotificationDismissed)\n | ({ type: 'notificationButtonClicked' } & NotificationButtonClicked)\n | ({ type: 'devicePrivacyChanged' } & DevicePrivacyChanged)\n | ({ type: 'deviceFrameUnloaded' } & DeviceFrameReference)\n | ({ type: 'deviceFrameLoaded' } & DeviceFrameReference)\n | ({ type: 'deviceFrameConnectorLoaded' } & DeviceFrameReference)\n | ({ type: 'pendingDevicesConnectionRequested' } & PendingDevicesInfo)\n | ({ type: 'borderlessUpdated' } & BorderlessUpdated)\n | ({ type: 'fullscreenUpdated' } & FullscreenUpdated)\n | ({ type: 'borderOptionsUpdated' } & BorderOptions)\n | ({ type: 'voiceActionDetected' } & VoiceActionDetection)\n | {\n type: 'streamFrameCapturedResponse'\n requestId: string\n response?: StreamCapture\n error: string\n }\n | {\n type: 'replaceFrameStreamCompleted'\n requestId: string\n tracks?: MediaTrackInfo[]\n error?: string\n }\n | ({ type: 'stateReplaced' } & StateReplaced)\n | ({ type: 'deviceFullscreenUpdated' } & DeviceFullscreenUpdated)\n | ({ type: 'visibilityChanged' } & VisibilityChanged)\n | ({ type: 'positionUpdated' } & PositionUpdated)\n | ({ type: 'safeAreaInsetsUpdated' } & SafeAreaInsetsUpdated)\n | ({ type: 'deviceScalingUpdated' } & DeviceScalingUpdated)\n | ({ type: 'updateFrameName' } & UpdateFrameName)\n | ({ type: 'localSharedStreamUpdate' } & LocalSharedStreamUpdate)\n | ({ type: 'statsResponse' } & StatsResponse)\n | { type: 'iceServersResponse'; requestId: string; iceServers: IceServerConfig[] }\n | ({ type: 'serialPortAccessResult'; requestId: string } & SerialPortAccessResult)\n | ({ type: 'connectionCodeUpdated' } & ConnectionCodeUpdated)\n | ({ type: 'mediaDevicesChanged' } & MediaDevicesChanged)\n | ({ type: 'bluetooth' } & BluetoothToApp)\n | { type: 'crdtUpdate'; update: ArrayBufferLike }\n | { type: 'crdtSyncComplete' }\n | { type: 'crdtRequestSync' }\n | { type: 'crdtAwarenessUpdate'; update: ArrayBufferLike }\n | { type: 'crdtSubdocUpdate'; guid: string; update: ArrayBufferLike }\n | { type: 'crdtSubdocSyncComplete'; guid: string }\n | {\n type: 'crdtSubdocTransferProgress'\n guid: string\n receivedBytes: number\n totalBytes: number\n }\n | { type: 'crdtSubdocRequestSync'; guid: string }\n | ({ type: 'companionFramePeerJoined' } & CompanionFramePeerJoined)\n | ({ type: 'companionFramePeerLeft' } & CompanionFramePeerLeft)\n | ({ type: 'companionFramePeersUpdated' } & CompanionFramePeersUpdated)\n | ({ type: 'shareStreamCompleted' } & ShareStreamCompleted)\n | ({ type: 'sharedStreamAvailable' } & SharedStreamAvailable)\n | ({ type: 'sharedStreamRemoved' } & SharedStreamRemoved)\n | ({ type: 'sharedStreamOffer' } & SharedStreamOffer)\n | { type: 'attachStreamCompleted'; requestId: string; error?: string }\n // AI tool channel: the host asks this frame to run one of its registered tools.\n | AiInboundMessage\n\nexport type MediaDevicesChanged = {\n devices: ConnectedMediaDevice[]\n}\n\n/** Companion frame → Vitre main connector (see CompanionFrame.sendMessageToVitreConnector). */\nexport type SendToVitreConnector = {\n frameConnectorId: string\n message: string\n fileData?: FileData\n}\n\n/**\n * ICE / TURN server config the HOST already uses for its own WebRTC P2P,\n * sourced from the connection handshake (`StartWebRTCOffer.IceServers` on a\n * Vitre, `WebRTCOffer.iceServers` on a companion). The shape matches the\n * browser `RTCIceServer` so the result of {@link Frame.getIceServers} can be\n * passed straight to `new RTCPeerConnection({ iceServers })` — letting an app\n * stand up its own peer connection (e.g. a companion-camera frame connecting\n * directly to its paired Vitre transform frame) that traverses NAT through the\n * same TURN relays as the platform, without shipping its own credentials.\n */\nexport type IceServerConfig = {\n urls: string[]\n username?: string\n credential?: string\n}\n\nexport type FrameApiMessagesOut =\n | ({ type: 'sendMessageTo' } & SendMessageTo)\n | ({ type: 'sendMessageToAll' } & SendMessageToAll)\n | ({ type: 'frameInitialized' } & FrameInitialized)\n | { type: 'setFullscreen' }\n | { type: 'setWindowed' }\n | { type: 'close' }\n | ({ type: 'setFrameMenu' } & SetFrameMenu)\n | ({ type: 'sendToLocalFrame' } & SendToLocalFrame)\n | ({ type: 'sendToVitreConnector' } & SendToVitreConnector)\n | ({ type: 'enumerateLoadedFrames' } & EnumerateLoadedFrames)\n | ({ type: 'setExportSources' } & SetExportSources)\n | ({\n type: 'applyStreamAdvancedConstraints'\n } & ApplyStreamAdvancedConstraints)\n | ({ type: 'replaceFrameStream' } & ReplaceFrameStream)\n | { type: 'stopInteracting' }\n | { type: 'startInteracting' }\n | ({ type: 'exportDone' } & ExportDone)\n | ({ type: 'setSize' } & SetSize)\n | { type: 'getVitreSettings' }\n | ({ type: 'setVitreSettings' } & VitreSettingsSetter)\n | ({ type: 'shareFile' } & ShareFileRequest)\n | ({ type: 'shareData' } & ShareDataRequest)\n | ({ type: 'saveSettings' } & SaveSettings)\n | ({ type: 'getAppSettings' } & GetAppSettings)\n | ({ type: 'setAppSettings' } & SetAppSettings)\n | ({ type: 'putPublicFile' } & PutPublicFile)\n | ({ type: 'deletePublicFile' } & DeletePublicFile)\n | ({ type: 'listPublicFiles' } & ListPublicFiles)\n | ({ type: 'putPrivateFile' } & PutPrivateFile)\n | ({ type: 'deletePrivateFile' } & DeletePrivateFile)\n | ({ type: 'listPrivateFiles' } & ListPrivateFiles)\n | ({ type: 'getPrivateFile' } & GetPrivateFile)\n | ({ type: 'getPrivateFileLink' } & GetPrivateFileLink)\n | ({ type: 'changeTeamSpace' } & ChangeTeamSpace)\n | ({ type: 'changeTeamSpaceGuest' } & ChangeTeamSpaceGuest)\n | ({ type: 'showNotification' } & NotificationInfo)\n | ({ type: 'hideNotification' } & HideNotification)\n | ({ type: 'changePrivacy' } & ChangePrivacy)\n | ({ type: 'appMessage' } & AppMessage)\n | ({ type: 'extensionMessage' } & AppMessage)\n | ({ type: 'trackEvent' } & EventTelemetry)\n | ({ type: 'startTrackEvent' } & StartEventTelemetry)\n | ({ type: 'stopTrackEvent' } & EventTelemetry)\n | ({ type: 'setBorderOptions' } & BorderOptions)\n | { type: 'setVoiceActions'; actions: VoiceAction[] }\n | { type: 'streamFrameCaptureRequest'; requestId: string }\n | ({ type: 'updateState' } & UpdateState)\n | ({ type: 'setPosition' } & LayoutPosition)\n | ({ type: 'setVisibility' } & SetVisibility)\n | ({ type: 'sharedStreamAction' } & StreamAction)\n | ({ type: 'sendKnockKnock' } & SendKnockKnock)\n | ({ type: 'getStats' } & GetStats)\n | { type: 'getIceServers'; requestId: string }\n | ({ type: 'setReducedAudioMode' } & SetReducedAudioMode)\n | ({ type: 'sendToSerialPort' } & SendToSerialPort)\n | ({\n type: 'requestSerialPortAccess'\n requestId: string\n } & RequestSerialPortAccess)\n | ({ type: 'bluetooth' } & BluetoothFromApp)\n | ({ type: 'disconnectGuests' } & DisconnectGuests)\n | ({ type: 'requestStreamSizeUpdate' } & RequestStreamSizeUpdate)\n | ({ type: 'updateName' } & UpdateName)\n | ({ type: 'shareStream' } & FrameShareStream)\n | ({ type: 'replaceShareStream' } & ReplaceShareStream)\n | ({ type: 'stopShareStream' } & StopShareStream)\n | {\n type: 'attachStream'\n requestId: string\n targetFrameConnectorId?: string\n tracks: ShareStreamTrack[] | ShareStreamPeerTransport\n }\n | { type: 'detachStream'; targetFrameConnectorId?: string }\n | { type: 'crdtUpdate'; update: ArrayBufferLike }\n | { type: 'crdtRequestSync' }\n | { type: 'crdtAwarenessUpdate'; update: ArrayBufferLike }\n | { type: 'crdtRequestAwareness' }\n | { type: 'crdtSubdocUpdate'; guid: string; update: ArrayBufferLike }\n | { type: 'crdtSubdocRequestSync'; guid: string }\n /**\n * Companion-frame-only: close the iframe locally on the companion and\n * remove this companion from the per-frame `framePresence` on the Vitre,\n * WITHOUT closing the Vitre's own frame (which keeps showing for other\n * peers + the local Vitre app). The companion's resulting state matches\n * \"frame was open on the Vitre when I late-joined the space\": iframe\n * unmounted, not in framePresence, can be re-opened by clicking the\n * matching menu entry again or by autoOpen on next reconnect.\n *\n * Sent by `CompanionFrame.closeOnCompanion()`. The Vitre host's path is\n * the existing `CompanionToVitreReq.FrameClosed` — semantics are\n * \"remove from presence, don't kill the Vitre frame\" so no new wire\n * case is needed. The `close` arm of this union remains the global\n * close (deprecated for use on companion frames).\n */\n | { type: 'closeOnCompanion' }\n // AI tool channel: publish/withdraw this frame's tool catalog + answer invocations.\n | AiOutboundMessage\n"]}
|
package/dist/Frame/Frame.d.ts
CHANGED
|
@@ -203,6 +203,17 @@ export declare class Frame {
|
|
|
203
203
|
private sharedStreamPeers;
|
|
204
204
|
/** Frame shares sent over a local peer connection, by `sharedStreamId`. */
|
|
205
205
|
private outgoingStreamPeers;
|
|
206
|
+
/** Streams attached over a local peer connection, by target frame connector
|
|
207
|
+
* id ('' = this frame's own). */
|
|
208
|
+
private attachedStreamPeers;
|
|
209
|
+
/** The stream last attached to each target, to restore it when a
|
|
210
|
+
* {@link replaceAttachedStream} over readables fails half-way. */
|
|
211
|
+
private attachedStreams;
|
|
212
|
+
/** Bumped by every attach and detach of a target: an attach that resolves
|
|
213
|
+
* after a later detach or attach does not record its stream. */
|
|
214
|
+
private attachGenerations;
|
|
215
|
+
/** Replaces of a target run one after the other. */
|
|
216
|
+
private attachReplaceChains;
|
|
206
217
|
/**
|
|
207
218
|
* What the host announces it can do (`'shareStreamPeer'`…). Empty on a host
|
|
208
219
|
* older than this field. Added 1.65.
|
|
@@ -291,8 +302,13 @@ export declare class Frame {
|
|
|
291
302
|
* site: there the share would die on its first frame.
|
|
292
303
|
*/
|
|
293
304
|
canShareStream(): boolean;
|
|
294
|
-
/**
|
|
295
|
-
*
|
|
305
|
+
/**
|
|
306
|
+
* Whether {@link attachStream} is available. Same conditions as
|
|
307
|
+
* {@link canShareStream}: readables reach the host, or the host takes the
|
|
308
|
+
* stream over a local peer connection (SDK 1.66).
|
|
309
|
+
*/
|
|
310
|
+
canAttachStream(): boolean;
|
|
311
|
+
/** Readables reach the host: Chromium, and the same site as the Vitre page. */
|
|
296
312
|
private canTransferStreamReadables;
|
|
297
313
|
private hostTakesStreamPeer;
|
|
298
314
|
/** Normalize `publicStorage.put`'s payload to a plain `ArrayBuffer` —
|
|
@@ -329,7 +345,9 @@ export declare class Frame {
|
|
|
329
345
|
* on other vitres; those instances receive it via {@link onSharedStream} (the
|
|
330
346
|
* existing `sharedStreamAvailable` delivery arm — no new protocol arm).
|
|
331
347
|
*
|
|
332
|
-
* -
|
|
348
|
+
* - Same requirements as {@link shareStream}, peer-connection fallback
|
|
349
|
+
* included ({@link canAttachStream}). Swap the stream with
|
|
350
|
+
* {@link replaceAttachedStream}.
|
|
333
351
|
* - Default target: this frame's own `frameConnectorId`, i.e. the same app
|
|
334
352
|
* type running on peer vitres. Pass `opts.targetFrameConnectorId` to route
|
|
335
353
|
* to a different frame type.
|
|
@@ -347,6 +365,21 @@ export declare class Frame {
|
|
|
347
365
|
attachStream(stream: MediaStream, opts?: {
|
|
348
366
|
targetFrameConnectorId?: string;
|
|
349
367
|
}): Promise<void>;
|
|
368
|
+
/**
|
|
369
|
+
* Swap the stream attached with {@link attachStream} for another one (e.g. a
|
|
370
|
+
* camera switch). Over a peer connection the tracks are swapped on their
|
|
371
|
+
* senders, with no gap. With readables the stream is detached and attached
|
|
372
|
+
* again: receivers see {@link onSharedStreamRemoved} then
|
|
373
|
+
* {@link onSharedStream}. The host may briefly hold the freed slot, so a
|
|
374
|
+
* `SHARES_FULL` refusal is retried for up to two seconds; if the new stream
|
|
375
|
+
* still cannot be attached, the previous one is attached again and the
|
|
376
|
+
* error is thrown, with `detached: true` when that failed too (nothing is
|
|
377
|
+
* attached any more). Calls on the same target run one after the other.
|
|
378
|
+
*/
|
|
379
|
+
replaceAttachedStream(stream: MediaStream, opts?: {
|
|
380
|
+
targetFrameConnectorId?: string;
|
|
381
|
+
}): Promise<void>;
|
|
382
|
+
private replaceAttachedStreamNow;
|
|
350
383
|
/**
|
|
351
384
|
* Stop a stream previously attached with {@link attachStream} on the target
|
|
352
385
|
* frame. Receivers see {@link onSharedStreamRemoved}. Default target: this
|
package/dist/Frame/Frame.js
CHANGED
|
@@ -718,6 +718,37 @@ export class Frame {
|
|
|
718
718
|
writable: true,
|
|
719
719
|
value: new Map()
|
|
720
720
|
});
|
|
721
|
+
/** Streams attached over a local peer connection, by target frame connector
|
|
722
|
+
* id ('' = this frame's own). */
|
|
723
|
+
Object.defineProperty(this, "attachedStreamPeers", {
|
|
724
|
+
enumerable: true,
|
|
725
|
+
configurable: true,
|
|
726
|
+
writable: true,
|
|
727
|
+
value: new Map()
|
|
728
|
+
});
|
|
729
|
+
/** The stream last attached to each target, to restore it when a
|
|
730
|
+
* {@link replaceAttachedStream} over readables fails half-way. */
|
|
731
|
+
Object.defineProperty(this, "attachedStreams", {
|
|
732
|
+
enumerable: true,
|
|
733
|
+
configurable: true,
|
|
734
|
+
writable: true,
|
|
735
|
+
value: new Map()
|
|
736
|
+
});
|
|
737
|
+
/** Bumped by every attach and detach of a target: an attach that resolves
|
|
738
|
+
* after a later detach or attach does not record its stream. */
|
|
739
|
+
Object.defineProperty(this, "attachGenerations", {
|
|
740
|
+
enumerable: true,
|
|
741
|
+
configurable: true,
|
|
742
|
+
writable: true,
|
|
743
|
+
value: new Map()
|
|
744
|
+
});
|
|
745
|
+
/** Replaces of a target run one after the other. */
|
|
746
|
+
Object.defineProperty(this, "attachReplaceChains", {
|
|
747
|
+
enumerable: true,
|
|
748
|
+
configurable: true,
|
|
749
|
+
writable: true,
|
|
750
|
+
value: new Map()
|
|
751
|
+
});
|
|
721
752
|
/**
|
|
722
753
|
* What the host announces it can do (`'shareStreamPeer'`…). Empty on a host
|
|
723
754
|
* older than this field. Added 1.65.
|
|
@@ -1371,8 +1402,15 @@ export class Frame {
|
|
|
1371
1402
|
canShareStream() {
|
|
1372
1403
|
return this.canTransferStreamReadables() || this.hostTakesStreamPeer();
|
|
1373
1404
|
}
|
|
1374
|
-
/**
|
|
1375
|
-
*
|
|
1405
|
+
/**
|
|
1406
|
+
* Whether {@link attachStream} is available. Same conditions as
|
|
1407
|
+
* {@link canShareStream}: readables reach the host, or the host takes the
|
|
1408
|
+
* stream over a local peer connection (SDK 1.66).
|
|
1409
|
+
*/
|
|
1410
|
+
canAttachStream() {
|
|
1411
|
+
return this.canTransferStreamReadables() || this.hostTakesStreamPeer();
|
|
1412
|
+
}
|
|
1413
|
+
/** Readables reach the host: Chromium, and the same site as the Vitre page. */
|
|
1376
1414
|
canTransferStreamReadables() {
|
|
1377
1415
|
return (typeof MediaStreamTrackProcessor !== 'undefined' &&
|
|
1378
1416
|
isSameSiteAsParent(location.origin, location.ancestorOrigins));
|
|
@@ -1521,7 +1559,9 @@ export class Frame {
|
|
|
1521
1559
|
* on other vitres; those instances receive it via {@link onSharedStream} (the
|
|
1522
1560
|
* existing `sharedStreamAvailable` delivery arm — no new protocol arm).
|
|
1523
1561
|
*
|
|
1524
|
-
* -
|
|
1562
|
+
* - Same requirements as {@link shareStream}, peer-connection fallback
|
|
1563
|
+
* included ({@link canAttachStream}). Swap the stream with
|
|
1564
|
+
* {@link replaceAttachedStream}.
|
|
1525
1565
|
* - Default target: this frame's own `frameConnectorId`, i.e. the same app
|
|
1526
1566
|
* type running on peer vitres. Pass `opts.targetFrameConnectorId` to route
|
|
1527
1567
|
* to a different frame type.
|
|
@@ -1537,25 +1577,118 @@ export class Frame {
|
|
|
1537
1577
|
* via {@link onSharedStream}.
|
|
1538
1578
|
*/
|
|
1539
1579
|
async attachStream(stream, opts) {
|
|
1540
|
-
if (!this.
|
|
1541
|
-
throw new Error('attachStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)');
|
|
1580
|
+
if (!this.canAttachStream()) {
|
|
1581
|
+
throw new Error('attachStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting, or a host taking the stream over a peer connection)');
|
|
1542
1582
|
}
|
|
1583
|
+
const target = opts?.targetFrameConnectorId ?? '';
|
|
1584
|
+
const generation = (this.attachGenerations.get(target) ?? 0) + 1;
|
|
1585
|
+
this.attachGenerations.set(target, generation);
|
|
1586
|
+
const current = () => this.attachGenerations.get(target) === generation;
|
|
1587
|
+
// Over a peer connection a new attach replaces the previous one on the
|
|
1588
|
+
// same target (its peer closes, the host frees its slot). With readables
|
|
1589
|
+
// it would take a second slot: swap with replaceAttachedStream instead.
|
|
1590
|
+
this.attachedStreamPeers.get(target)?.close();
|
|
1543
1591
|
const requestId = randomUuid();
|
|
1592
|
+
const resolveCompleted = (msg, resolve, reject) => {
|
|
1593
|
+
if (msg.type === 'attachStreamCompleted' && msg.requestId === requestId) {
|
|
1594
|
+
if (msg.error != null)
|
|
1595
|
+
reject(msg.error);
|
|
1596
|
+
else
|
|
1597
|
+
resolve(undefined);
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
if (!this.canTransferStreamReadables()) {
|
|
1601
|
+
// From another site the readables would die on their first frame: the
|
|
1602
|
+
// host takes the stream over a local peer connection instead (same
|
|
1603
|
+
// signaling as shareStream's fallback).
|
|
1604
|
+
const { port1, port2 } = new MessageChannel();
|
|
1605
|
+
const peer = offerStreamToHost(port1, stream, () => {
|
|
1606
|
+
if (this.attachedStreamPeers.get(target) === peer)
|
|
1607
|
+
this.attachedStreamPeers.delete(target);
|
|
1608
|
+
});
|
|
1609
|
+
this.attachedStreamPeers.set(target, peer);
|
|
1610
|
+
try {
|
|
1611
|
+
await this.postRequest({
|
|
1612
|
+
type: 'attachStream',
|
|
1613
|
+
requestId,
|
|
1614
|
+
targetFrameConnectorId: opts?.targetFrameConnectorId,
|
|
1615
|
+
tracks: {
|
|
1616
|
+
transport: 'peer',
|
|
1617
|
+
port: port2,
|
|
1618
|
+
video: stream.getVideoTracks()[0]?.getSettings(),
|
|
1619
|
+
audio: stream.getAudioTracks()[0]?.getSettings(),
|
|
1620
|
+
},
|
|
1621
|
+
}, resolveCompleted, [port2]);
|
|
1622
|
+
}
|
|
1623
|
+
catch (e) {
|
|
1624
|
+
peer.close();
|
|
1625
|
+
throw e;
|
|
1626
|
+
}
|
|
1627
|
+
if (current())
|
|
1628
|
+
this.attachedStreams.set(target, stream);
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1544
1631
|
const { tracks, transfer } = this.toShareTracks(stream);
|
|
1545
1632
|
await this.postRequest({
|
|
1546
1633
|
type: 'attachStream',
|
|
1547
1634
|
requestId,
|
|
1548
1635
|
targetFrameConnectorId: opts?.targetFrameConnectorId,
|
|
1549
1636
|
tracks,
|
|
1550
|
-
},
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1637
|
+
}, resolveCompleted, transfer);
|
|
1638
|
+
if (current())
|
|
1639
|
+
this.attachedStreams.set(target, stream);
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Swap the stream attached with {@link attachStream} for another one (e.g. a
|
|
1643
|
+
* camera switch). Over a peer connection the tracks are swapped on their
|
|
1644
|
+
* senders, with no gap. With readables the stream is detached and attached
|
|
1645
|
+
* again: receivers see {@link onSharedStreamRemoved} then
|
|
1646
|
+
* {@link onSharedStream}. The host may briefly hold the freed slot, so a
|
|
1647
|
+
* `SHARES_FULL` refusal is retried for up to two seconds; if the new stream
|
|
1648
|
+
* still cannot be attached, the previous one is attached again and the
|
|
1649
|
+
* error is thrown, with `detached: true` when that failed too (nothing is
|
|
1650
|
+
* attached any more). Calls on the same target run one after the other.
|
|
1651
|
+
*/
|
|
1652
|
+
async replaceAttachedStream(stream, opts) {
|
|
1653
|
+
const target = opts?.targetFrameConnectorId ?? '';
|
|
1654
|
+
const run = (this.attachReplaceChains.get(target) ?? Promise.resolve())
|
|
1655
|
+
.catch(() => { })
|
|
1656
|
+
.then(() => this.replaceAttachedStreamNow(stream, target, opts));
|
|
1657
|
+
this.attachReplaceChains.set(target, run);
|
|
1658
|
+
return run;
|
|
1659
|
+
}
|
|
1660
|
+
async replaceAttachedStreamNow(stream, target, opts) {
|
|
1661
|
+
const peer = this.attachedStreamPeers.get(target);
|
|
1662
|
+
if (peer) {
|
|
1663
|
+
await peer.replaceTracks(stream);
|
|
1664
|
+
this.attachedStreams.set(target, stream);
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
const previous = this.attachedStreams.get(target);
|
|
1668
|
+
this.detachStream(opts);
|
|
1669
|
+
const attachRetrying = async (s) => {
|
|
1670
|
+
for (let attempt = 0;; attempt++) {
|
|
1671
|
+
try {
|
|
1672
|
+
await this.attachStream(s, opts);
|
|
1673
|
+
return;
|
|
1674
|
+
}
|
|
1675
|
+
catch (e) {
|
|
1676
|
+
if (String(e) !== 'SHARES_FULL' || attempt >= 10)
|
|
1677
|
+
throw e;
|
|
1678
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
1679
|
+
}
|
|
1557
1680
|
}
|
|
1558
|
-
}
|
|
1681
|
+
};
|
|
1682
|
+
try {
|
|
1683
|
+
await attachRetrying(stream);
|
|
1684
|
+
}
|
|
1685
|
+
catch (e) {
|
|
1686
|
+
const restored = previous != null &&
|
|
1687
|
+
(await attachRetrying(previous).then(() => true, () => false));
|
|
1688
|
+
throw Object.assign(e instanceof Error ? e : new Error(String(e)), {
|
|
1689
|
+
detached: !restored,
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1559
1692
|
}
|
|
1560
1693
|
/**
|
|
1561
1694
|
* Stop a stream previously attached with {@link attachStream} on the target
|
|
@@ -1563,6 +1696,10 @@ export class Frame {
|
|
|
1563
1696
|
* frame's own `frameConnectorId`.
|
|
1564
1697
|
*/
|
|
1565
1698
|
detachStream(opts) {
|
|
1699
|
+
const target = opts?.targetFrameConnectorId ?? '';
|
|
1700
|
+
this.attachGenerations.set(target, (this.attachGenerations.get(target) ?? 0) + 1);
|
|
1701
|
+
this.attachedStreamPeers.get(target)?.close();
|
|
1702
|
+
this.attachedStreams.delete(target);
|
|
1566
1703
|
this.postMessage({
|
|
1567
1704
|
type: 'detachStream',
|
|
1568
1705
|
targetFrameConnectorId: opts?.targetFrameConnectorId,
|
package/dist/Frame/Frame.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Frame.js","sourceRoot":"","sources":["../../Frame/Frame.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,0BAA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C,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 { randomUuid } from '../Common/Uuid.js'\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 { AppSettingsError, APP_SETTINGS_TIMEOUT_MS } from '../Common/AppSettings.js'\nimport { SettingsDefaultsResolver, defaultSettingsFileUrl } from '../Common/SettingsDefaults.js'\nimport {\n PublicStorageError,\n PUBLIC_STORAGE_TIMEOUT_MS,\n PUBLIC_STORAGE_PUT_TIMEOUT_MS,\n MAX_PUBLIC_FILE_SIZE_BYTES,\n validateExpiresIn,\n putPublicFileExpiryField,\n withDownloadUrlFallback,\n} from '../Common/PublicStorage.js'\nimport type { PublicStorageApi } from '../Common/PublicStorage.js'\nimport {\n PrivateStorageError,\n PRIVATE_STORAGE_TIMEOUT_MS,\n PRIVATE_STORAGE_PUT_TIMEOUT_MS,\n PRIVATE_STORAGE_GET_TIMEOUT_MS,\n MAX_PRIVATE_FILE_SIZE_BYTES,\n validatePrivatePath,\n validatePrivateExpiresIn,\n validateLinkExpiresIn,\n privateFileExpiryField,\n} from '../Common/PrivateStorage.js'\nimport type { PrivateStorageApi } from '../Common/PrivateStorage.js'\nimport type {\n AppId,\n AppSettingsLevel,\n AppSettingsValue,\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 SafeAreaInsets,\n SafeAreaInsetsUpdated,\n Privacy,\n PrivateFile,\n PrivateFileLink,\n PrivateStorageListResult,\n PublicFile,\n PublicStorageListResult,\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 {\n acceptSharedStreamOffer,\n type SharedStreamPeer,\n} from './SharedStreamPeer.js'\nimport {\n offerStreamToHost,\n type OutgoingStreamPeer,\n} from './OutgoingStreamPeer.js'\nimport { isSameSiteAsParent } from '../Common/Site.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 /**\n * Pushed whenever the AppSettings value at a given level changes — see\n * {@link getSettings} / {@link setSettings}. Fires for changes made by\n * this app itself as well as by another vitre/app instance sharing the\n * same team/space. Added 1.52. Since 1.58 `value` carries the defaults of\n * `lavitre.settings.json` for `team` and `space`, like {@link getSettings}.\n */\n public onSettingsChanged?: (change: AppSettingsValue) => void\n /**\n * Since 1.58: where {@link getSettings} reads the defaults of the team and\n * space forms — `lavitre.settings.json` next to this document by default\n * (the version root, for `connector.html` and the frames beside it). A\n * document in a sub-folder points it at the root; `null` turns the merge\n * off. Read once, on the first settings call.\n */\n public settingsFileUrl: string | null = defaultSettingsFileUrl()\n private readonly settingsDefaults = new SettingsDefaultsResolver(() => this.settingsFileUrl)\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 /**\n * The host moved a system bar over an edge-to-edge frame (device rotated,\n * navigation mode switched). `safeAreaInsets` and the\n * `--lavitre-safe-area-inset-*` CSS variables are already updated when\n * this fires. Added 1.51.\n */\n public onSafeAreaInsetsUpdated?: (msg: SafeAreaInsetsUpdated) => 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. Elsewhere (a web guest whose\n * page is on another site than the app, Safari, Firefox) the host sends it\n * over a local RTCPeerConnection instead; the callback is the same.\n * `streamId` matches a later `onSharedStreamRemoved`. Inverse of\n * {@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 * Distances from the frame's edges to the area free of system UI, in CSS\n * px. Non-zero only for a companion frame declared\n * `CompanionFrameOption.edgeToEdge`, on a host drawing under the system\n * bars (Android). Also exposed as `--lavitre-safe-area-inset-top|right|\n * bottom|left` on `document.documentElement`, so plain CSS can use them:\n * `padding-bottom: var(--lavitre-safe-area-inset-bottom, 0px)`. Updated in\n * place before `onSafeAreaInsetsUpdated` fires. Added 1.51.\n */\n public safeAreaInsets: SafeAreaInsets = {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n }\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 /**\n * The version of this app the vitre loaded (`'1.4.0'`), as deployed — not\n * the host version (`hostInformation.version`). `undefined` on a host older\n * than 1.63's init message, or for an app the host has no version for.\n */\n public appVersion?: string\n /**\n * The app channel this version was selected through (`'preview'`,\n * `'beta'`…). `undefined` when the version is the team's own selection, a\n * pinned or a global version — or on a host that does not send it.\n */\n public appChannel?: 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 * Public, unauthenticated file storage scoped to the vitre's TEAM — see\n * the README \"Public storage\" section for the full semantics (scopes,\n * allowed file types, size cap, path rules). Files are readable by\n * ANYONE at the returned URL — never put private data here. Only a\n * Vitre-hosted frame has this — a companion frame cannot write.\n */\n public readonly publicStorage: PublicStorageApi = {\n put: async (path, data, contentType, scope = 'app', options) => {\n validateExpiresIn(options?.expiresIn)\n const buffer = await this.toPublicFileBuffer(data)\n if (buffer.byteLength > MAX_PUBLIC_FILE_SIZE_BYTES) {\n throw new PublicStorageError('tooLarge')\n }\n const requestId = randomUuid()\n return await this.postRequest<PublicFile>(\n {\n type: 'putPublicFile',\n requestId,\n scope,\n path,\n contentType,\n data: buffer,\n ...putPublicFileExpiryField(options?.expiresIn),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'publicStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve(\n withDownloadUrlFallback(\n msg.file ?? { path, url: msg.url ?? '', size: buffer.byteLength },\n ),\n )\n } else {\n reject(new PublicStorageError(msg.error ?? 'failed'))\n }\n }\n },\n [buffer],\n { ms: PUBLIC_STORAGE_PUT_TIMEOUT_MS, onTimeout: () => new PublicStorageError('unsupported') },\n )\n },\n delete: async (path, scope = 'app') => {\n const requestId = randomUuid()\n await this.postRequest<void>(\n { type: 'deletePublicFile', requestId, scope, path },\n (msg, resolve, reject) => {\n if (msg.type === 'publicStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) resolve(undefined)\n else reject(new PublicStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PUBLIC_STORAGE_TIMEOUT_MS, onTimeout: () => new PublicStorageError('unsupported') },\n )\n },\n list: async (prefix, scope = 'app') => {\n const requestId = randomUuid()\n return await this.postRequest<PublicStorageListResult>(\n { type: 'listPublicFiles', requestId, scope, prefix },\n (msg, resolve, reject) => {\n if (msg.type === 'publicStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve({\n baseUrl: msg.baseUrl ?? '',\n files: (msg.files ?? []).map(withDownloadUrlFallback),\n })\n } else reject(new PublicStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PUBLIC_STORAGE_TIMEOUT_MS, onTimeout: () => new PublicStorageError('unsupported') },\n )\n },\n }\n\n /**\n * Private file storage scoped to the vitre's TEAM — see the README\n * \"Private storage\" section for the full semantics. Unlike\n * `publicStorage`, files here have no public link: readable by any\n * vitre or companion of the team via `get` or a temporary `getLink`\n * signed link, never by an anonymous visitor. Full (put/delete/list/\n * get/getLink) on a Vitre-hosted frame; a companion frame only has\n * `list`/`get`/`getLink` (see the `CompanionFrame` exported type).\n */\n public readonly privateStorage: PrivateStorageApi = {\n put: async (path, data, contentType, scope = 'app', options) => {\n validatePrivatePath(path)\n validatePrivateExpiresIn(options?.expiresIn)\n const buffer = await this.toPrivateFileBuffer(data)\n if (buffer.byteLength > MAX_PRIVATE_FILE_SIZE_BYTES) {\n throw new PrivateStorageError('tooLarge')\n }\n const requestId = randomUuid()\n return await this.postRequest<PrivateFile>(\n {\n type: 'putPrivateFile',\n requestId,\n scope,\n path,\n contentType,\n data: buffer,\n ...privateFileExpiryField(options?.expiresIn),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve(msg.file ?? { path, size: buffer.byteLength, contentType })\n } else {\n reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n }\n },\n [buffer],\n { ms: PRIVATE_STORAGE_PUT_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n delete: async (path, scope = 'app') => {\n const requestId = randomUuid()\n await this.postRequest<void>(\n { type: 'deletePrivateFile', requestId, scope, path },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) resolve(undefined)\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n list: async (prefix, scope = 'app') => {\n const requestId = randomUuid()\n return await this.postRequest<PrivateStorageListResult>(\n { type: 'listPrivateFiles', requestId, scope, prefix },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) resolve({ scope, files: msg.files ?? [] })\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n get: async (path, scope = 'app') => {\n const requestId = randomUuid()\n return await this.postRequest<{ data: ArrayBuffer; contentType: string }>(\n { type: 'getPrivateFile', requestId, scope, path },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok && msg.data) resolve({ data: msg.data, contentType: msg.contentType ?? '' })\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_GET_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n getLink: async (path, options) => {\n validateLinkExpiresIn(options?.expiresIn)\n const scope = options?.scope ?? 'app'\n const requestId = randomUuid()\n return await this.postRequest<PrivateFileLink>(\n {\n type: 'getPrivateFileLink',\n requestId,\n scope,\n path,\n ...privateFileExpiryField(options?.expiresIn),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok && msg.link) resolve(msg.link)\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n }\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 private deviceStateListeners = new Set<() => void>()\n private sharedStreamPeers = new Map<string, SharedStreamPeer>()\n /** Frame shares sent over a local peer connection, by `sharedStreamId`. */\n private outgoingStreamPeers = new Map<string, OutgoingStreamPeer>()\n /**\n * What the host announces it can do (`'shareStreamPeer'`…). Empty on a host\n * older than this field. Added 1.65.\n */\n public readonly hostCapabilities: string[]\n\n /**\n * Called after any change of `hostInformation.device`,\n * `hostInformation.devicesInSpace` or the available media devices (device\n * joined or left, privacy, fullscreen, scaling, media devices, Vitre\n * settings), once the matching `on…` callback has run. Unlike those callbacks, several\n * listeners can coexist: SDK helpers use this so they never replace a\n * handler the app assigned. Returns the unsubscribe function. Added 1.52.\n */\n public addDeviceStateListener(listener: () => void): () => void {\n this.deviceStateListeners.add(listener)\n return () => this.deviceStateListeners.delete(listener)\n }\n\n private notifyDeviceState() {\n for (const listener of this.deviceStateListeners) {\n try {\n listener()\n } catch (error) {\n console.error('[Frame] device state listener failed', error)\n }\n }\n }\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.appVersion = initMessage.appVersion\n this.appChannel = initMessage.appChannel\n this.hostCapabilities = initMessage.hostCapabilities ?? []\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 if (initMessage.safeAreaInsets)\n this.applySafeAreaInsets(initMessage.safeAreaInsets)\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 this.notifyDeviceState()\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 this.notifyDeviceState()\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 'appSettingsResponse':\n // Handled by requestResolvers (postRequest pattern)\n break\n case 'appSettingsChanged':\n void this.settingsDefaults\n .merged(msg.level, msg.value ?? {}, msg.version)\n .then((change) => this.onSettingsChanged?.(change))\n break\n case 'publicStorageResponse':\n // Handled by requestResolvers (postRequest pattern)\n break\n case 'privateStorageResponse':\n // Handled by requestResolvers (postRequest pattern)\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 this.notifyDeviceState()\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 this.notifyDeviceState()\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 'safeAreaInsetsUpdated':\n this.applySafeAreaInsets(msg.safeAreaInsets)\n this.onSafeAreaInsetsUpdated?.(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 this.notifyDeviceState()\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 this.notifyDeviceState()\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 'sharedStreamOffer': {\n this.sharedStreamPeers.get(msg.streamId)?.close()\n const peer = acceptSharedStreamOffer(\n msg.port,\n (stream) => this.onSharedStream?.(msg.streamId, stream),\n () => {\n if (this.sharedStreamPeers.get(msg.streamId) === peer)\n this.sharedStreamPeers.delete(msg.streamId)\n },\n )\n this.sharedStreamPeers.set(msg.streamId, peer)\n break\n }\n case 'sharedStreamRemoved':\n this.sharedStreamPeers.get(msg.streamId)?.close()\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 this.notifyDeviceState()\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 /** Stores the insets and mirrors them as `--lavitre-safe-area-inset-*` on `<html>`. */\n private applySafeAreaInsets(insets: SafeAreaInsets) {\n this.safeAreaInsets = insets\n const root =\n typeof document !== 'undefined' ? document.documentElement : undefined\n if (!root) return\n for (const edge of ['top', 'right', 'bottom', 'left'] as const) {\n root.style.setProperty(\n `--lavitre-safe-area-inset-${edge}`,\n `${insets[edge]}px`,\n )\n }\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 = randomUuid()\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 = randomUuid()\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: track readables can be handed to\n * the host (Chromium `MediaStreamTrackProcessor` and a frame on the same\n * site as the Vitre page), or the host takes the stream over a local\n * `RTCPeerConnection` instead (it announces `shareStreamPeer` in the init\n * message; SDK 1.65). False on an older host when the frame is on another\n * site: there the share would die on its first frame.\n */\n public canShareStream(): boolean {\n return this.canTransferStreamReadables() || this.hostTakesStreamPeer()\n }\n\n /** Readables reach the host: Chromium, and the same site as the Vitre page.\n * {@link attachStream} needs it (no peer-connection fallback). */\n private canTransferStreamReadables(): boolean {\n return (\n typeof MediaStreamTrackProcessor !== 'undefined' &&\n isSameSiteAsParent(location.origin, location.ancestorOrigins)\n )\n }\n\n private hostTakesStreamPeer(): boolean {\n return (\n this.hostCapabilities.includes('shareStreamPeer') &&\n typeof RTCPeerConnection !== 'undefined'\n )\n }\n\n /** Normalize `publicStorage.put`'s payload to a plain `ArrayBuffer` —\n * slicing out exactly a typed array's view (not its whole underlying\n * buffer, in case it's a subarray) so the transferred bytes match the\n * size the caller intended. */\n private async toPublicFileBuffer(\n data: ArrayBuffer | Blob | Uint8Array,\n ): Promise<ArrayBuffer> {\n if (data instanceof ArrayBuffer) return data\n if (data instanceof Blob) return await data.arrayBuffer()\n return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) as ArrayBuffer\n }\n\n /** Same normalization as {@link toPublicFileBuffer}, for `privateStorage.put`. */\n private async toPrivateFileBuffer(\n data: ArrayBuffer | Blob | Uint8Array,\n ): Promise<ArrayBuffer> {\n if (data instanceof ArrayBuffer) return data\n if (data instanceof Blob) return await data.arrayBuffer()\n return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) as ArrayBuffer\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, or a host taking the stream over a peer connection)',\n )\n }\n const sharedStreamId = randomUuid()\n const requestId = randomUuid()\n if (!this.canTransferStreamReadables()) {\n await this.shareStreamOverPeer(sharedStreamId, requestId, stream, options)\n return sharedStreamId\n }\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 (\n msg.type === 'shareStreamCompleted' &&\n msg.requestId === requestId\n ) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n return sharedStreamId\n }\n\n private async shareStreamOverPeer(\n sharedStreamId: string,\n requestId: string,\n stream: MediaStream,\n options: ShareStreamOptions | undefined,\n ): Promise<void> {\n const { port1, port2 } = new MessageChannel()\n const peer = offerStreamToHost(port1, stream, () => {\n if (this.outgoingStreamPeers.get(sharedStreamId) === peer)\n this.outgoingStreamPeers.delete(sharedStreamId)\n })\n this.outgoingStreamPeers.set(sharedStreamId, peer)\n try {\n await this.postRequest<void>(\n {\n type: 'shareStream',\n requestId,\n sharedStreamId,\n options,\n tracks: {\n transport: 'peer',\n port: port2,\n video: stream.getVideoTracks()[0]?.getSettings(),\n audio: stream.getAudioTracks()[0]?.getSettings(),\n },\n },\n (msg, resolve, reject) => {\n if (\n msg.type === 'shareStreamCompleted' &&\n msg.requestId === requestId\n ) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n [port2],\n )\n } catch (e) {\n peer.close()\n throw e\n }\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 const stream =\n streamOrTrack instanceof MediaStream\n ? streamOrTrack\n : new MediaStream([streamOrTrack])\n // A share over a peer connection swaps its tracks on its own sender.\n const peer = this.outgoingStreamPeers.get(sharedStreamId)\n if (peer) {\n await peer.replaceTracks(stream)\n return\n }\n if (!this.canTransferStreamReadables()) {\n throw new Error('replaceShareStream is not supported in this runtime')\n }\n const requestId = randomUuid()\n const { tracks, transfer } = this.toShareTracks(stream)\n await this.postRequest<void>(\n { type: 'replaceShareStream', requestId, sharedStreamId, tracks },\n (msg, resolve, reject) => {\n if (\n msg.type === 'shareStreamCompleted' &&\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 /** Stop a frame share. `sharedStreamId` is the value returned by {@link shareStream}. */\n public stopShareStream(sharedStreamId: string): void {\n this.outgoingStreamPeers.get(sharedStreamId)?.close()\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.canTransferStreamReadables()) {\n throw new Error(\n 'attachStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)',\n )\n }\n const requestId = randomUuid()\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 = randomUuid()\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 // `any` (not `string`) so callers can reject with a typed Error, e.g.\n // AppSettingsError — most existing handlers still reject with a plain\n // string message.\n reject: (error: any) => void,\n ) => void,\n transfer?: Transferable[],\n // When set, rejects with `onTimeout()` if no matching response arrives\n // within `ms` — AND removes the pending resolver from\n // `requestResolvers`. Without that removal a host that never answers\n // (e.g. one that predates the message type) would leak the resolver\n // forever, since the only other removal path is a matching response.\n timeout?: { ms: number; onTimeout: () => any },\n ) {\n return await new Promise<Data>((resolve, reject) => {\n let isHandled = false\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const handleAndResolve = (data: Data) => {\n isHandled = true\n if (timer !== undefined) clearTimeout(timer)\n resolve(data)\n }\n\n const handleAndReject = (error: any) => {\n isHandled = true\n if (timer !== undefined) clearTimeout(timer)\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\n if (timeout) {\n timer = setTimeout(() => {\n if (isHandled) return\n this.requestResolvers = this.requestResolvers.filter((rr) => rr !== resolver)\n handleAndReject(timeout.onTimeout())\n }, timeout.ms)\n }\n\n this.postMessage(data, transfer)\n })\n }\n\n public async requestEnumerateLocalFrames(): Promise<LoadedFrame[]> {\n const requestId = randomUuid()\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 /**\n * Read the app's settings at one of the three levels — `vitre` (this\n * vitre), `team` (the vitre's team), or `space` (the space the vitre is\n * currently in). Every vitre/app instance of the team can read the same\n * value; values are JSON objects capped at 64 KB — never store secrets.\n *\n * Distinct from the legacy `saveSettings`/`onSettingsUpdated` mechanism,\n * which is a single vitre-scoped blob rendered by the host's settings\n * form (see `Connector.setSettingsSchema`).\n *\n * Rejects with an {@link AppSettingsError} of code `'unsupported'` if the\n * host doesn't answer within 10s — a vitre host older than this feature\n * never responds to `getAppSettings`.\n *\n * Since 1.58, for `team` and `space`, `value` is the defaults of the app's\n * `lavitre.settings.json` (see {@link settingsFileUrl}) overlaid with what is\n * stored, and `stored` is the stored value alone. {@link setSettings} drops\n * the defaults again before writing, so writing back `{ ...value, key }` does\n * not freeze today's defaults into the store.\n */\n public async getSettings(level: AppSettingsLevel): Promise<AppSettingsValue> {\n const requestId = randomUuid()\n const read = await this.postRequest<AppSettingsValue>(\n { type: 'getAppSettings', requestId, level },\n (msg, resolve, reject) => {\n if (msg.type === 'appSettingsResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve({ level: msg.level, value: msg.value ?? {}, version: msg.version ?? 0 })\n } else {\n reject(new AppSettingsError(msg.error ?? 'failed', level))\n }\n }\n },\n undefined,\n { ms: APP_SETTINGS_TIMEOUT_MS, onTimeout: () => new AppSettingsError('unsupported', level) },\n )\n return await this.settingsDefaults.merged(read.level, read.value, read.version)\n }\n\n /**\n * Write the app's settings at `level`, with optimistic concurrency:\n * `expectedVersion` must be the version last observed for that level (from\n * {@link getSettings} or {@link onSettingsChanged}) — `0` if never\n * written. A stale version rejects with an {@link AppSettingsError} of\n * code `'conflict'`; re-read and retry. An oversized `value` (> 64 KB)\n * rejects with `'tooLarge'`.\n *\n * Rejects with code `'unsupported'` if the host doesn't answer within\n * 10s — see {@link getSettings}.\n */\n public async setSettings(\n level: AppSettingsLevel,\n value: Record<string, unknown>,\n expectedVersion: number,\n ): Promise<AppSettingsValue> {\n const requestId = randomUuid()\n const write = await this.settingsDefaults.forWrite(level, value)\n const written = await this.postRequest<AppSettingsValue>(\n {\n type: 'setAppSettings',\n requestId,\n level,\n value: write.value,\n expectedVersion,\n ...(write.schemaVersion !== undefined ? { schemaVersion: write.schemaVersion } : {}),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'appSettingsResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve({\n level: msg.level,\n value: msg.value ?? write.value,\n version: msg.version ?? expectedVersion,\n })\n } else {\n reject(new AppSettingsError(msg.error ?? 'failed', level))\n }\n }\n },\n undefined,\n { ms: APP_SETTINGS_TIMEOUT_MS, onTimeout: () => new AppSettingsError('unsupported', level) },\n )\n return await this.settingsDefaults.merged(written.level, written.value, written.version)\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 = randomUuid()\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 = randomUuid()\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 // A shared stream can reach the frame before `initialize` (the host posts\n // it on the window while the init travels on the port). Keep those until the\n // app has had its turn to set `onSharedStream` after `await initializeFrame`.\n const earlyStreams: FrameApiMessagesIn[] = []\n const messageHandler =\n (createPostMessage: (origin: string) => PostMessageFrameApiOut) =>\n (e: MessageEvent<FrameApiMessagesIn | null>): any => {\n // Any script can post to this window, and a message whose payload\n // cannot be deserialized here arrives with `data === null`.\n if (e.data == null || typeof e.data !== 'object') return\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 if (earlyStreams.length > 0) {\n const created = frame\n setTimeout(() => {\n for (const msg of earlyStreams.splice(0))\n created.raiseMessage(msg)\n })\n }\n }\n break\n case 'sharedStreamAvailable':\n case 'sharedStreamOffer':\n if (frame === null) earlyStreams.push(e.data)\n else frame.raiseMessage(e.data)\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"]}
|
|
1
|
+
{"version":3,"file":"Frame.js","sourceRoot":"","sources":["../../Frame/Frame.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,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,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AACpF,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAChG,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,6BAA6B,EAC7B,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,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,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 { randomUuid } from '../Common/Uuid.js'\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 { AppSettingsError, APP_SETTINGS_TIMEOUT_MS } from '../Common/AppSettings.js'\nimport { SettingsDefaultsResolver, defaultSettingsFileUrl } from '../Common/SettingsDefaults.js'\nimport {\n PublicStorageError,\n PUBLIC_STORAGE_TIMEOUT_MS,\n PUBLIC_STORAGE_PUT_TIMEOUT_MS,\n MAX_PUBLIC_FILE_SIZE_BYTES,\n validateExpiresIn,\n putPublicFileExpiryField,\n withDownloadUrlFallback,\n} from '../Common/PublicStorage.js'\nimport type { PublicStorageApi } from '../Common/PublicStorage.js'\nimport {\n PrivateStorageError,\n PRIVATE_STORAGE_TIMEOUT_MS,\n PRIVATE_STORAGE_PUT_TIMEOUT_MS,\n PRIVATE_STORAGE_GET_TIMEOUT_MS,\n MAX_PRIVATE_FILE_SIZE_BYTES,\n validatePrivatePath,\n validatePrivateExpiresIn,\n validateLinkExpiresIn,\n privateFileExpiryField,\n} from '../Common/PrivateStorage.js'\nimport type { PrivateStorageApi } from '../Common/PrivateStorage.js'\nimport type {\n AppId,\n AppSettingsLevel,\n AppSettingsValue,\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 SafeAreaInsets,\n SafeAreaInsetsUpdated,\n Privacy,\n PrivateFile,\n PrivateFileLink,\n PrivateStorageListResult,\n PublicFile,\n PublicStorageListResult,\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 {\n acceptSharedStreamOffer,\n type SharedStreamPeer,\n} from './SharedStreamPeer.js'\nimport {\n offerStreamToHost,\n type OutgoingStreamPeer,\n} from './OutgoingStreamPeer.js'\nimport { isSameSiteAsParent } from '../Common/Site.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 /**\n * Pushed whenever the AppSettings value at a given level changes — see\n * {@link getSettings} / {@link setSettings}. Fires for changes made by\n * this app itself as well as by another vitre/app instance sharing the\n * same team/space. Added 1.52. Since 1.58 `value` carries the defaults of\n * `lavitre.settings.json` for `team` and `space`, like {@link getSettings}.\n */\n public onSettingsChanged?: (change: AppSettingsValue) => void\n /**\n * Since 1.58: where {@link getSettings} reads the defaults of the team and\n * space forms — `lavitre.settings.json` next to this document by default\n * (the version root, for `connector.html` and the frames beside it). A\n * document in a sub-folder points it at the root; `null` turns the merge\n * off. Read once, on the first settings call.\n */\n public settingsFileUrl: string | null = defaultSettingsFileUrl()\n private readonly settingsDefaults = new SettingsDefaultsResolver(() => this.settingsFileUrl)\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 /**\n * The host moved a system bar over an edge-to-edge frame (device rotated,\n * navigation mode switched). `safeAreaInsets` and the\n * `--lavitre-safe-area-inset-*` CSS variables are already updated when\n * this fires. Added 1.51.\n */\n public onSafeAreaInsetsUpdated?: (msg: SafeAreaInsetsUpdated) => 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. Elsewhere (a web guest whose\n * page is on another site than the app, Safari, Firefox) the host sends it\n * over a local RTCPeerConnection instead; the callback is the same.\n * `streamId` matches a later `onSharedStreamRemoved`. Inverse of\n * {@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 * Distances from the frame's edges to the area free of system UI, in CSS\n * px. Non-zero only for a companion frame declared\n * `CompanionFrameOption.edgeToEdge`, on a host drawing under the system\n * bars (Android). Also exposed as `--lavitre-safe-area-inset-top|right|\n * bottom|left` on `document.documentElement`, so plain CSS can use them:\n * `padding-bottom: var(--lavitre-safe-area-inset-bottom, 0px)`. Updated in\n * place before `onSafeAreaInsetsUpdated` fires. Added 1.51.\n */\n public safeAreaInsets: SafeAreaInsets = {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n }\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 /**\n * The version of this app the vitre loaded (`'1.4.0'`), as deployed — not\n * the host version (`hostInformation.version`). `undefined` on a host older\n * than 1.63's init message, or for an app the host has no version for.\n */\n public appVersion?: string\n /**\n * The app channel this version was selected through (`'preview'`,\n * `'beta'`…). `undefined` when the version is the team's own selection, a\n * pinned or a global version — or on a host that does not send it.\n */\n public appChannel?: 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 * Public, unauthenticated file storage scoped to the vitre's TEAM — see\n * the README \"Public storage\" section for the full semantics (scopes,\n * allowed file types, size cap, path rules). Files are readable by\n * ANYONE at the returned URL — never put private data here. Only a\n * Vitre-hosted frame has this — a companion frame cannot write.\n */\n public readonly publicStorage: PublicStorageApi = {\n put: async (path, data, contentType, scope = 'app', options) => {\n validateExpiresIn(options?.expiresIn)\n const buffer = await this.toPublicFileBuffer(data)\n if (buffer.byteLength > MAX_PUBLIC_FILE_SIZE_BYTES) {\n throw new PublicStorageError('tooLarge')\n }\n const requestId = randomUuid()\n return await this.postRequest<PublicFile>(\n {\n type: 'putPublicFile',\n requestId,\n scope,\n path,\n contentType,\n data: buffer,\n ...putPublicFileExpiryField(options?.expiresIn),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'publicStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve(\n withDownloadUrlFallback(\n msg.file ?? { path, url: msg.url ?? '', size: buffer.byteLength },\n ),\n )\n } else {\n reject(new PublicStorageError(msg.error ?? 'failed'))\n }\n }\n },\n [buffer],\n { ms: PUBLIC_STORAGE_PUT_TIMEOUT_MS, onTimeout: () => new PublicStorageError('unsupported') },\n )\n },\n delete: async (path, scope = 'app') => {\n const requestId = randomUuid()\n await this.postRequest<void>(\n { type: 'deletePublicFile', requestId, scope, path },\n (msg, resolve, reject) => {\n if (msg.type === 'publicStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) resolve(undefined)\n else reject(new PublicStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PUBLIC_STORAGE_TIMEOUT_MS, onTimeout: () => new PublicStorageError('unsupported') },\n )\n },\n list: async (prefix, scope = 'app') => {\n const requestId = randomUuid()\n return await this.postRequest<PublicStorageListResult>(\n { type: 'listPublicFiles', requestId, scope, prefix },\n (msg, resolve, reject) => {\n if (msg.type === 'publicStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve({\n baseUrl: msg.baseUrl ?? '',\n files: (msg.files ?? []).map(withDownloadUrlFallback),\n })\n } else reject(new PublicStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PUBLIC_STORAGE_TIMEOUT_MS, onTimeout: () => new PublicStorageError('unsupported') },\n )\n },\n }\n\n /**\n * Private file storage scoped to the vitre's TEAM — see the README\n * \"Private storage\" section for the full semantics. Unlike\n * `publicStorage`, files here have no public link: readable by any\n * vitre or companion of the team via `get` or a temporary `getLink`\n * signed link, never by an anonymous visitor. Full (put/delete/list/\n * get/getLink) on a Vitre-hosted frame; a companion frame only has\n * `list`/`get`/`getLink` (see the `CompanionFrame` exported type).\n */\n public readonly privateStorage: PrivateStorageApi = {\n put: async (path, data, contentType, scope = 'app', options) => {\n validatePrivatePath(path)\n validatePrivateExpiresIn(options?.expiresIn)\n const buffer = await this.toPrivateFileBuffer(data)\n if (buffer.byteLength > MAX_PRIVATE_FILE_SIZE_BYTES) {\n throw new PrivateStorageError('tooLarge')\n }\n const requestId = randomUuid()\n return await this.postRequest<PrivateFile>(\n {\n type: 'putPrivateFile',\n requestId,\n scope,\n path,\n contentType,\n data: buffer,\n ...privateFileExpiryField(options?.expiresIn),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve(msg.file ?? { path, size: buffer.byteLength, contentType })\n } else {\n reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n }\n },\n [buffer],\n { ms: PRIVATE_STORAGE_PUT_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n delete: async (path, scope = 'app') => {\n const requestId = randomUuid()\n await this.postRequest<void>(\n { type: 'deletePrivateFile', requestId, scope, path },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) resolve(undefined)\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n list: async (prefix, scope = 'app') => {\n const requestId = randomUuid()\n return await this.postRequest<PrivateStorageListResult>(\n { type: 'listPrivateFiles', requestId, scope, prefix },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) resolve({ scope, files: msg.files ?? [] })\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n get: async (path, scope = 'app') => {\n const requestId = randomUuid()\n return await this.postRequest<{ data: ArrayBuffer; contentType: string }>(\n { type: 'getPrivateFile', requestId, scope, path },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok && msg.data) resolve({ data: msg.data, contentType: msg.contentType ?? '' })\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_GET_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n getLink: async (path, options) => {\n validateLinkExpiresIn(options?.expiresIn)\n const scope = options?.scope ?? 'app'\n const requestId = randomUuid()\n return await this.postRequest<PrivateFileLink>(\n {\n type: 'getPrivateFileLink',\n requestId,\n scope,\n path,\n ...privateFileExpiryField(options?.expiresIn),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok && msg.link) resolve(msg.link)\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n }\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 private deviceStateListeners = new Set<() => void>()\n private sharedStreamPeers = new Map<string, SharedStreamPeer>()\n /** Frame shares sent over a local peer connection, by `sharedStreamId`. */\n private outgoingStreamPeers = new Map<string, OutgoingStreamPeer>()\n /** Streams attached over a local peer connection, by target frame connector\n * id ('' = this frame's own). */\n private attachedStreamPeers = new Map<string, OutgoingStreamPeer>()\n /** The stream last attached to each target, to restore it when a\n * {@link replaceAttachedStream} over readables fails half-way. */\n private attachedStreams = new Map<string, MediaStream>()\n /** Bumped by every attach and detach of a target: an attach that resolves\n * after a later detach or attach does not record its stream. */\n private attachGenerations = new Map<string, number>()\n /** Replaces of a target run one after the other. */\n private attachReplaceChains = new Map<string, Promise<void>>()\n /**\n * What the host announces it can do (`'shareStreamPeer'`…). Empty on a host\n * older than this field. Added 1.65.\n */\n public readonly hostCapabilities: string[]\n\n /**\n * Called after any change of `hostInformation.device`,\n * `hostInformation.devicesInSpace` or the available media devices (device\n * joined or left, privacy, fullscreen, scaling, media devices, Vitre\n * settings), once the matching `on…` callback has run. Unlike those callbacks, several\n * listeners can coexist: SDK helpers use this so they never replace a\n * handler the app assigned. Returns the unsubscribe function. Added 1.52.\n */\n public addDeviceStateListener(listener: () => void): () => void {\n this.deviceStateListeners.add(listener)\n return () => this.deviceStateListeners.delete(listener)\n }\n\n private notifyDeviceState() {\n for (const listener of this.deviceStateListeners) {\n try {\n listener()\n } catch (error) {\n console.error('[Frame] device state listener failed', error)\n }\n }\n }\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.appVersion = initMessage.appVersion\n this.appChannel = initMessage.appChannel\n this.hostCapabilities = initMessage.hostCapabilities ?? []\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 if (initMessage.safeAreaInsets)\n this.applySafeAreaInsets(initMessage.safeAreaInsets)\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 this.notifyDeviceState()\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 this.notifyDeviceState()\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 'appSettingsResponse':\n // Handled by requestResolvers (postRequest pattern)\n break\n case 'appSettingsChanged':\n void this.settingsDefaults\n .merged(msg.level, msg.value ?? {}, msg.version)\n .then((change) => this.onSettingsChanged?.(change))\n break\n case 'publicStorageResponse':\n // Handled by requestResolvers (postRequest pattern)\n break\n case 'privateStorageResponse':\n // Handled by requestResolvers (postRequest pattern)\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 this.notifyDeviceState()\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 this.notifyDeviceState()\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 'safeAreaInsetsUpdated':\n this.applySafeAreaInsets(msg.safeAreaInsets)\n this.onSafeAreaInsetsUpdated?.(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 this.notifyDeviceState()\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 this.notifyDeviceState()\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 'sharedStreamOffer': {\n this.sharedStreamPeers.get(msg.streamId)?.close()\n const peer = acceptSharedStreamOffer(\n msg.port,\n (stream) => this.onSharedStream?.(msg.streamId, stream),\n () => {\n if (this.sharedStreamPeers.get(msg.streamId) === peer)\n this.sharedStreamPeers.delete(msg.streamId)\n },\n )\n this.sharedStreamPeers.set(msg.streamId, peer)\n break\n }\n case 'sharedStreamRemoved':\n this.sharedStreamPeers.get(msg.streamId)?.close()\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 this.notifyDeviceState()\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 /** Stores the insets and mirrors them as `--lavitre-safe-area-inset-*` on `<html>`. */\n private applySafeAreaInsets(insets: SafeAreaInsets) {\n this.safeAreaInsets = insets\n const root =\n typeof document !== 'undefined' ? document.documentElement : undefined\n if (!root) return\n for (const edge of ['top', 'right', 'bottom', 'left'] as const) {\n root.style.setProperty(\n `--lavitre-safe-area-inset-${edge}`,\n `${insets[edge]}px`,\n )\n }\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 = randomUuid()\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 = randomUuid()\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: track readables can be handed to\n * the host (Chromium `MediaStreamTrackProcessor` and a frame on the same\n * site as the Vitre page), or the host takes the stream over a local\n * `RTCPeerConnection` instead (it announces `shareStreamPeer` in the init\n * message; SDK 1.65). False on an older host when the frame is on another\n * site: there the share would die on its first frame.\n */\n public canShareStream(): boolean {\n return this.canTransferStreamReadables() || this.hostTakesStreamPeer()\n }\n\n /**\n * Whether {@link attachStream} is available. Same conditions as\n * {@link canShareStream}: readables reach the host, or the host takes the\n * stream over a local peer connection (SDK 1.66).\n */\n public canAttachStream(): boolean {\n return this.canTransferStreamReadables() || this.hostTakesStreamPeer()\n }\n\n /** Readables reach the host: Chromium, and the same site as the Vitre page. */\n private canTransferStreamReadables(): boolean {\n return (\n typeof MediaStreamTrackProcessor !== 'undefined' &&\n isSameSiteAsParent(location.origin, location.ancestorOrigins)\n )\n }\n\n private hostTakesStreamPeer(): boolean {\n return (\n this.hostCapabilities.includes('shareStreamPeer') &&\n typeof RTCPeerConnection !== 'undefined'\n )\n }\n\n /** Normalize `publicStorage.put`'s payload to a plain `ArrayBuffer` —\n * slicing out exactly a typed array's view (not its whole underlying\n * buffer, in case it's a subarray) so the transferred bytes match the\n * size the caller intended. */\n private async toPublicFileBuffer(\n data: ArrayBuffer | Blob | Uint8Array,\n ): Promise<ArrayBuffer> {\n if (data instanceof ArrayBuffer) return data\n if (data instanceof Blob) return await data.arrayBuffer()\n return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) as ArrayBuffer\n }\n\n /** Same normalization as {@link toPublicFileBuffer}, for `privateStorage.put`. */\n private async toPrivateFileBuffer(\n data: ArrayBuffer | Blob | Uint8Array,\n ): Promise<ArrayBuffer> {\n if (data instanceof ArrayBuffer) return data\n if (data instanceof Blob) return await data.arrayBuffer()\n return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) as ArrayBuffer\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, or a host taking the stream over a peer connection)',\n )\n }\n const sharedStreamId = randomUuid()\n const requestId = randomUuid()\n if (!this.canTransferStreamReadables()) {\n await this.shareStreamOverPeer(sharedStreamId, requestId, stream, options)\n return sharedStreamId\n }\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 (\n msg.type === 'shareStreamCompleted' &&\n msg.requestId === requestId\n ) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n return sharedStreamId\n }\n\n private async shareStreamOverPeer(\n sharedStreamId: string,\n requestId: string,\n stream: MediaStream,\n options: ShareStreamOptions | undefined,\n ): Promise<void> {\n const { port1, port2 } = new MessageChannel()\n const peer = offerStreamToHost(port1, stream, () => {\n if (this.outgoingStreamPeers.get(sharedStreamId) === peer)\n this.outgoingStreamPeers.delete(sharedStreamId)\n })\n this.outgoingStreamPeers.set(sharedStreamId, peer)\n try {\n await this.postRequest<void>(\n {\n type: 'shareStream',\n requestId,\n sharedStreamId,\n options,\n tracks: {\n transport: 'peer',\n port: port2,\n video: stream.getVideoTracks()[0]?.getSettings(),\n audio: stream.getAudioTracks()[0]?.getSettings(),\n },\n },\n (msg, resolve, reject) => {\n if (\n msg.type === 'shareStreamCompleted' &&\n msg.requestId === requestId\n ) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n [port2],\n )\n } catch (e) {\n peer.close()\n throw e\n }\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 const stream =\n streamOrTrack instanceof MediaStream\n ? streamOrTrack\n : new MediaStream([streamOrTrack])\n // A share over a peer connection swaps its tracks on its own sender.\n const peer = this.outgoingStreamPeers.get(sharedStreamId)\n if (peer) {\n await peer.replaceTracks(stream)\n return\n }\n if (!this.canTransferStreamReadables()) {\n throw new Error('replaceShareStream is not supported in this runtime')\n }\n const requestId = randomUuid()\n const { tracks, transfer } = this.toShareTracks(stream)\n await this.postRequest<void>(\n { type: 'replaceShareStream', requestId, sharedStreamId, tracks },\n (msg, resolve, reject) => {\n if (\n msg.type === 'shareStreamCompleted' &&\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 /** Stop a frame share. `sharedStreamId` is the value returned by {@link shareStream}. */\n public stopShareStream(sharedStreamId: string): void {\n this.outgoingStreamPeers.get(sharedStreamId)?.close()\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 * - Same requirements as {@link shareStream}, peer-connection fallback\n * included ({@link canAttachStream}). Swap the stream with\n * {@link replaceAttachedStream}.\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.canAttachStream()) {\n throw new Error(\n 'attachStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting, or a host taking the stream over a peer connection)',\n )\n }\n const target = opts?.targetFrameConnectorId ?? ''\n const generation = (this.attachGenerations.get(target) ?? 0) + 1\n this.attachGenerations.set(target, generation)\n const current = () => this.attachGenerations.get(target) === generation\n // Over a peer connection a new attach replaces the previous one on the\n // same target (its peer closes, the host frees its slot). With readables\n // it would take a second slot: swap with replaceAttachedStream instead.\n this.attachedStreamPeers.get(target)?.close()\n const requestId = randomUuid()\n const resolveCompleted = (\n msg: FrameApiMessagesIn,\n resolve: (v: void) => void,\n reject: (e: unknown) => void,\n ) => {\n if (msg.type === 'attachStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n }\n if (!this.canTransferStreamReadables()) {\n // From another site the readables would die on their first frame: the\n // host takes the stream over a local peer connection instead (same\n // signaling as shareStream's fallback).\n const { port1, port2 } = new MessageChannel()\n const peer = offerStreamToHost(port1, stream, () => {\n if (this.attachedStreamPeers.get(target) === peer)\n this.attachedStreamPeers.delete(target)\n })\n this.attachedStreamPeers.set(target, peer)\n try {\n await this.postRequest<void>(\n {\n type: 'attachStream',\n requestId,\n targetFrameConnectorId: opts?.targetFrameConnectorId,\n tracks: {\n transport: 'peer',\n port: port2,\n video: stream.getVideoTracks()[0]?.getSettings(),\n audio: stream.getAudioTracks()[0]?.getSettings(),\n },\n },\n resolveCompleted,\n [port2],\n )\n } catch (e) {\n peer.close()\n throw e\n }\n if (current()) this.attachedStreams.set(target, stream)\n return\n }\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 resolveCompleted,\n transfer,\n )\n if (current()) this.attachedStreams.set(target, stream)\n }\n\n /**\n * Swap the stream attached with {@link attachStream} for another one (e.g. a\n * camera switch). Over a peer connection the tracks are swapped on their\n * senders, with no gap. With readables the stream is detached and attached\n * again: receivers see {@link onSharedStreamRemoved} then\n * {@link onSharedStream}. The host may briefly hold the freed slot, so a\n * `SHARES_FULL` refusal is retried for up to two seconds; if the new stream\n * still cannot be attached, the previous one is attached again and the\n * error is thrown, with `detached: true` when that failed too (nothing is\n * attached any more). Calls on the same target run one after the other.\n */\n public async replaceAttachedStream(\n stream: MediaStream,\n opts?: { targetFrameConnectorId?: string },\n ): Promise<void> {\n const target = opts?.targetFrameConnectorId ?? ''\n const run = (this.attachReplaceChains.get(target) ?? Promise.resolve())\n .catch(() => {})\n .then(() => this.replaceAttachedStreamNow(stream, target, opts))\n this.attachReplaceChains.set(target, run)\n return run\n }\n\n private async replaceAttachedStreamNow(\n stream: MediaStream,\n target: string,\n opts: { targetFrameConnectorId?: string } | undefined,\n ): Promise<void> {\n const peer = this.attachedStreamPeers.get(target)\n if (peer) {\n await peer.replaceTracks(stream)\n this.attachedStreams.set(target, stream)\n return\n }\n const previous = this.attachedStreams.get(target)\n this.detachStream(opts)\n const attachRetrying = async (s: MediaStream) => {\n for (let attempt = 0; ; attempt++) {\n try {\n await this.attachStream(s, opts)\n return\n } catch (e) {\n if (String(e) !== 'SHARES_FULL' || attempt >= 10) throw e\n await new Promise((r) => setTimeout(r, 200))\n }\n }\n }\n try {\n await attachRetrying(stream)\n } catch (e) {\n const restored =\n previous != null &&\n (await attachRetrying(previous).then(\n () => true,\n () => false,\n ))\n throw Object.assign(e instanceof Error ? e : new Error(String(e)), {\n detached: !restored,\n })\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 const target = opts?.targetFrameConnectorId ?? ''\n this.attachGenerations.set(target, (this.attachGenerations.get(target) ?? 0) + 1)\n this.attachedStreamPeers.get(target)?.close()\n this.attachedStreams.delete(target)\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 = randomUuid()\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 // `any` (not `string`) so callers can reject with a typed Error, e.g.\n // AppSettingsError — most existing handlers still reject with a plain\n // string message.\n reject: (error: any) => void,\n ) => void,\n transfer?: Transferable[],\n // When set, rejects with `onTimeout()` if no matching response arrives\n // within `ms` — AND removes the pending resolver from\n // `requestResolvers`. Without that removal a host that never answers\n // (e.g. one that predates the message type) would leak the resolver\n // forever, since the only other removal path is a matching response.\n timeout?: { ms: number; onTimeout: () => any },\n ) {\n return await new Promise<Data>((resolve, reject) => {\n let isHandled = false\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const handleAndResolve = (data: Data) => {\n isHandled = true\n if (timer !== undefined) clearTimeout(timer)\n resolve(data)\n }\n\n const handleAndReject = (error: any) => {\n isHandled = true\n if (timer !== undefined) clearTimeout(timer)\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\n if (timeout) {\n timer = setTimeout(() => {\n if (isHandled) return\n this.requestResolvers = this.requestResolvers.filter((rr) => rr !== resolver)\n handleAndReject(timeout.onTimeout())\n }, timeout.ms)\n }\n\n this.postMessage(data, transfer)\n })\n }\n\n public async requestEnumerateLocalFrames(): Promise<LoadedFrame[]> {\n const requestId = randomUuid()\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 /**\n * Read the app's settings at one of the three levels — `vitre` (this\n * vitre), `team` (the vitre's team), or `space` (the space the vitre is\n * currently in). Every vitre/app instance of the team can read the same\n * value; values are JSON objects capped at 64 KB — never store secrets.\n *\n * Distinct from the legacy `saveSettings`/`onSettingsUpdated` mechanism,\n * which is a single vitre-scoped blob rendered by the host's settings\n * form (see `Connector.setSettingsSchema`).\n *\n * Rejects with an {@link AppSettingsError} of code `'unsupported'` if the\n * host doesn't answer within 10s — a vitre host older than this feature\n * never responds to `getAppSettings`.\n *\n * Since 1.58, for `team` and `space`, `value` is the defaults of the app's\n * `lavitre.settings.json` (see {@link settingsFileUrl}) overlaid with what is\n * stored, and `stored` is the stored value alone. {@link setSettings} drops\n * the defaults again before writing, so writing back `{ ...value, key }` does\n * not freeze today's defaults into the store.\n */\n public async getSettings(level: AppSettingsLevel): Promise<AppSettingsValue> {\n const requestId = randomUuid()\n const read = await this.postRequest<AppSettingsValue>(\n { type: 'getAppSettings', requestId, level },\n (msg, resolve, reject) => {\n if (msg.type === 'appSettingsResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve({ level: msg.level, value: msg.value ?? {}, version: msg.version ?? 0 })\n } else {\n reject(new AppSettingsError(msg.error ?? 'failed', level))\n }\n }\n },\n undefined,\n { ms: APP_SETTINGS_TIMEOUT_MS, onTimeout: () => new AppSettingsError('unsupported', level) },\n )\n return await this.settingsDefaults.merged(read.level, read.value, read.version)\n }\n\n /**\n * Write the app's settings at `level`, with optimistic concurrency:\n * `expectedVersion` must be the version last observed for that level (from\n * {@link getSettings} or {@link onSettingsChanged}) — `0` if never\n * written. A stale version rejects with an {@link AppSettingsError} of\n * code `'conflict'`; re-read and retry. An oversized `value` (> 64 KB)\n * rejects with `'tooLarge'`.\n *\n * Rejects with code `'unsupported'` if the host doesn't answer within\n * 10s — see {@link getSettings}.\n */\n public async setSettings(\n level: AppSettingsLevel,\n value: Record<string, unknown>,\n expectedVersion: number,\n ): Promise<AppSettingsValue> {\n const requestId = randomUuid()\n const write = await this.settingsDefaults.forWrite(level, value)\n const written = await this.postRequest<AppSettingsValue>(\n {\n type: 'setAppSettings',\n requestId,\n level,\n value: write.value,\n expectedVersion,\n ...(write.schemaVersion !== undefined ? { schemaVersion: write.schemaVersion } : {}),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'appSettingsResponse' && msg.requestId === requestId) {\n if (msg.ok) {\n resolve({\n level: msg.level,\n value: msg.value ?? write.value,\n version: msg.version ?? expectedVersion,\n })\n } else {\n reject(new AppSettingsError(msg.error ?? 'failed', level))\n }\n }\n },\n undefined,\n { ms: APP_SETTINGS_TIMEOUT_MS, onTimeout: () => new AppSettingsError('unsupported', level) },\n )\n return await this.settingsDefaults.merged(written.level, written.value, written.version)\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 = randomUuid()\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 = randomUuid()\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 // A shared stream can reach the frame before `initialize` (the host posts\n // it on the window while the init travels on the port). Keep those until the\n // app has had its turn to set `onSharedStream` after `await initializeFrame`.\n const earlyStreams: FrameApiMessagesIn[] = []\n const messageHandler =\n (createPostMessage: (origin: string) => PostMessageFrameApiOut) =>\n (e: MessageEvent<FrameApiMessagesIn | null>): any => {\n // Any script can post to this window, and a message whose payload\n // cannot be deserialized here arrives with `data === null`.\n if (e.data == null || typeof e.data !== 'object') return\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 if (earlyStreams.length > 0) {\n const created = frame\n setTimeout(() => {\n for (const msg of earlyStreams.splice(0))\n created.raiseMessage(msg)\n })\n }\n }\n break\n case 'sharedStreamAvailable':\n case 'sharedStreamOffer':\n if (frame === null) earlyStreams.push(e.data)\n else frame.raiseMessage(e.data)\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"]}
|
|
@@ -32,10 +32,24 @@ const tuneSenders = async (pc) => {
|
|
|
32
32
|
export function offerStreamToHost(port, stream, onClosed) {
|
|
33
33
|
const pc = new RTCPeerConnection();
|
|
34
34
|
let closed = false;
|
|
35
|
-
|
|
35
|
+
// A source track that ends (camera unplugged, track stopped) closes the
|
|
36
|
+
// share: the host only sees the remote track go silent, never `ended`, and
|
|
37
|
+
// would keep the share and its slot on a frozen picture.
|
|
38
|
+
let watched = [];
|
|
39
|
+
const onSourceEnded = () => close(true, 'a shared track ended');
|
|
40
|
+
const watch = (tracks) => {
|
|
41
|
+
for (const t of watched)
|
|
42
|
+
t.removeEventListener('ended', onSourceEnded);
|
|
43
|
+
watched = tracks;
|
|
44
|
+
for (const t of watched)
|
|
45
|
+
t.addEventListener('ended', onSourceEnded);
|
|
46
|
+
};
|
|
47
|
+
const close = (notifyHost, reason) => {
|
|
36
48
|
if (closed)
|
|
37
49
|
return;
|
|
38
50
|
closed = true;
|
|
51
|
+
console.info('[lavitre/apps] shareStream peer closed:', reason);
|
|
52
|
+
watch([]);
|
|
39
53
|
if (notifyHost) {
|
|
40
54
|
try {
|
|
41
55
|
port.postMessage({ type: 'close' });
|
|
@@ -51,6 +65,7 @@ export function offerStreamToHost(port, stream, onClosed) {
|
|
|
51
65
|
for (const track of stream.getTracks()) {
|
|
52
66
|
pc.addTransceiver(track, { direction: 'sendonly', streams: [stream] });
|
|
53
67
|
}
|
|
68
|
+
watch(stream.getTracks());
|
|
54
69
|
pc.onicecandidate = (e) => {
|
|
55
70
|
if (e.candidate && !closed) {
|
|
56
71
|
port.postMessage({
|
|
@@ -61,7 +76,7 @@ export function offerStreamToHost(port, stream, onClosed) {
|
|
|
61
76
|
};
|
|
62
77
|
pc.onconnectionstatechange = () => {
|
|
63
78
|
if (pc.connectionState === 'failed')
|
|
64
|
-
close(true);
|
|
79
|
+
close(true, 'connection failed');
|
|
65
80
|
};
|
|
66
81
|
// Candidates must not overtake the answer they belong to: handle in order.
|
|
67
82
|
let chain = Promise.resolve();
|
|
@@ -79,11 +94,11 @@ export function offerStreamToHost(port, stream, onClosed) {
|
|
|
79
94
|
await pc.addIceCandidate(signal.candidate);
|
|
80
95
|
break;
|
|
81
96
|
case 'close':
|
|
82
|
-
close(false);
|
|
97
|
+
close(false, 'closed by the host');
|
|
83
98
|
break;
|
|
84
99
|
}
|
|
85
100
|
})
|
|
86
|
-
.catch(() => close(true));
|
|
101
|
+
.catch((err) => close(true, `signaling failed: ${err?.message ?? err}`));
|
|
87
102
|
};
|
|
88
103
|
void (async () => {
|
|
89
104
|
try {
|
|
@@ -96,8 +111,8 @@ export function offerStreamToHost(port, stream, onClosed) {
|
|
|
96
111
|
});
|
|
97
112
|
}
|
|
98
113
|
}
|
|
99
|
-
catch {
|
|
100
|
-
close(true);
|
|
114
|
+
catch (err) {
|
|
115
|
+
close(true, `offer failed: ${err?.message ?? err}`);
|
|
101
116
|
}
|
|
102
117
|
})();
|
|
103
118
|
return {
|
|
@@ -113,9 +128,13 @@ export function offerStreamToHost(port, stream, onClosed) {
|
|
|
113
128
|
}
|
|
114
129
|
await sender.replaceTrack(track);
|
|
115
130
|
}
|
|
131
|
+
watch(pc
|
|
132
|
+
.getSenders()
|
|
133
|
+
.map((s) => s.track)
|
|
134
|
+
.filter((t) => t != null));
|
|
116
135
|
await tuneSenders(pc);
|
|
117
136
|
},
|
|
118
|
-
close: () => close(true),
|
|
137
|
+
close: () => close(true, 'stopped by the app'),
|
|
119
138
|
};
|
|
120
139
|
}
|
|
121
140
|
//# sourceMappingURL=OutgoingStreamPeer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutgoingStreamPeer.js","sourceRoot":"","sources":["../../Frame/OutgoingStreamPeer.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,yCAAyC;AACzC,GAAG;AACH,mEAAmE;AACnE,iEAAiE;AACjE,yCAAyC;AACzC,iGAAiG;AACjG,kGAAkG;AAYlG;kDACkD;AAClD,MAAM,WAAW,GAAG,OAAS,CAAA;AAE7B,MAAM,WAAW,GAAG,KAAK,EAAE,EAAqB,EAAE,EAAE;IAClD,KAAK,MAAM,MAAM,IAAI,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC;QACrC,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,KAAK,OAAO;YAAE,SAAQ;QAC5C,MAAM,MAAM,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AI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;gBACrC,MAAM,MAAM,GAAG,EAAE;qBACd,eAAe,EAAE;qBACjB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;gBAC5D,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,IAAI,KAAK,CACb,6CAA6C,KAAK,CAAC,IAAI,QAAQ,CAChE,CAAA;gBACH,CAAC;gBACD,MAAM,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;YAClC,CAAC;YACD,KAAK,CACH,EAAE;iBACC,UAAU,EAAE;iBACZ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;iBACnB,MAAM,CAAC,CAAC,CAAC,EAAyB,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CACnD,CAAA;YACD,MAAM,WAAW,CAAC,EAAE,CAAC,CAAA;QACvB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,oBAAoB,CAAC;KAC/C,CAAA;AACH,CAAC","sourcesContent":["/// Sending end of a frame → host shared stream carried over a local\n/// `RTCPeerConnection` (`Frame.shareStream`'s fallback). Track readables only\n/// reach the Vitre page when the frame is on the same site: from another site\n/// the first `VideoFrame` chunk fails with `DataCloneError` and the share dies.\n/// Browsers without `MediaStreamTrackProcessor` cannot transfer them at all.\n/// Re-encoded once, on the same machine.\n///\n/// Signaling runs over the `MessagePort` whose twin travels in the\n/// `shareStream` message (`ShareStreamPeerTransport`). Mirror of\n/// `SharedStreamPeer.ts`, roles swapped:\n/// frame → host { type: 'offer', sdp } | { type: 'candidate', candidate } | { type: 'close' }\n/// host → frame { type: 'answer', sdp } | { type: 'candidate', candidate } | { type: 'close' }\n\nimport type { SharedStreamSignal } from './SharedStreamPeer.js'\n\nexport type OutgoingStreamPeer = {\n /** Swap the tracks sent without renegotiating (`replaceTrack`). Only kinds the\n * share already carries: a new kind would need a new negotiation. */\n replaceTracks: (stream: MediaStream) => Promise<void>\n /** Close from this side, telling the host. */\n close: () => void\n}\n\n/** Same ceiling as the host's reverse direction: the encoder and the decoder\n * run on the same machine, the link is local. */\nconst MAX_BITRATE = 8_000_000\n\nconst tuneSenders = async (pc: RTCPeerConnection) => {\n for (const sender of pc.getSenders()) {\n if (sender.track?.kind !== 'video') continue\n const params = sender.getParameters()\n const encoding = params.encodings?.[0]\n if (!encoding) continue\n encoding.maxBitrate = MAX_BITRATE\n encoding.maxFramerate = 30\n ;(\n params as RTCRtpSendParameters & { degradationPreference?: string }\n ).degradationPreference = 'maintain-resolution'\n await sender.setParameters(params).catch(() => {\n // A browser refusing a field keeps its defaults.\n })\n }\n}\n\nexport function offerStreamToHost(\n port: MessagePort,\n stream: MediaStream,\n onClosed: () => void,\n): OutgoingStreamPeer {\n const pc = new RTCPeerConnection()\n let closed = false\n // A source track that ends (camera unplugged, track stopped) closes the\n // share: the host only sees the remote track go silent, never `ended`, and\n // would keep the share and its slot on a frozen picture.\n let watched: MediaStreamTrack[] = []\n const onSourceEnded = () => close(true, 'a shared track ended')\n const watch = (tracks: MediaStreamTrack[]) => {\n for (const t of watched) t.removeEventListener('ended', onSourceEnded)\n watched = tracks\n for (const t of watched) t.addEventListener('ended', onSourceEnded)\n }\n const close = (notifyHost: boolean, reason: string) => {\n if (closed) return\n closed = true\n console.info('[lavitre/apps] shareStream peer closed:', reason)\n watch([])\n if (notifyHost) {\n try {\n port.postMessage({ type: 'close' } satisfies SharedStreamSignal)\n } catch {\n // Port already gone.\n }\n }\n port.close()\n pc.close()\n onClosed()\n }\n\n for (const track of stream.getTracks()) {\n pc.addTransceiver(track, { direction: 'sendonly', streams: [stream] })\n }\n watch(stream.getTracks())\n pc.onicecandidate = (e) => {\n if (e.candidate && !closed) {\n port.postMessage({\n type: 'candidate',\n candidate: e.candidate.toJSON(),\n } satisfies SharedStreamSignal)\n }\n }\n pc.onconnectionstatechange = () => {\n if (pc.connectionState === 'failed') close(true, 'connection failed')\n }\n\n // Candidates must not overtake the answer they belong to: handle in order.\n let chain = Promise.resolve()\n port.onmessage = (e: MessageEvent<SharedStreamSignal | null>) => {\n const signal = e.data\n chain = chain\n .then(async () => {\n if (closed || signal == null) return\n switch (signal.type) {\n case 'answer':\n await pc.setRemoteDescription({ type: 'answer', sdp: signal.sdp })\n break\n case 'candidate':\n await pc.addIceCandidate(signal.candidate)\n break\n case 'close':\n close(false, 'closed by the host')\n break\n }\n })\n .catch((err) => close(true, `signaling failed: ${err?.message ?? err}`))\n }\n\n void (async () => {\n try {\n await pc.setLocalDescription(await pc.createOffer())\n await tuneSenders(pc)\n if (!closed) {\n port.postMessage({\n type: 'offer',\n sdp: pc.localDescription?.sdp ?? '',\n } satisfies SharedStreamSignal)\n }\n } catch (err) {\n close(true, `offer failed: ${(err as Error)?.message ?? err}`)\n }\n })()\n\n return {\n replaceTracks: async (next: MediaStream) => {\n if (closed) throw new Error('replaceShareStream: the share is closed')\n for (const track of next.getTracks()) {\n const sender = pc\n .getTransceivers()\n .find((t) => t.receiver.track.kind === track.kind)?.sender\n if (!sender) {\n throw new Error(\n `replaceShareStream: this share carries no ${track.kind} track`,\n )\n }\n await sender.replaceTrack(track)\n }\n watch(\n pc\n .getSenders()\n .map((s) => s.track)\n .filter((t): t is MediaStreamTrack => t != null),\n )\n await tuneSenders(pc)\n },\n close: () => close(true, 'stopped by the app'),\n }\n}\n"]}
|
package/dist/Version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const apiVersion = "1.
|
|
1
|
+
export declare const apiVersion = "1.66.0";
|
package/dist/Version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const apiVersion = '1.
|
|
1
|
+
export const apiVersion = '1.66.0';
|
|
2
2
|
//# sourceMappingURL=Version.js.map
|
package/dist/Version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Version.js","sourceRoot":"","sources":["../Version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAA","sourcesContent":["export const apiVersion = '1.
|
|
1
|
+
{"version":3,"file":"Version.js","sourceRoot":"","sources":["../Version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAA","sourcesContent":["export const apiVersion = '1.66.0'"]}
|