@lavitre/apps 1.49.1 → 1.51.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.
@@ -1,9 +1,10 @@
1
1
  /// <reference path="./insertable-streams.d.ts" />
2
- import { v4 as uuid } from 'uuid';
2
+ import { randomUuid } from '../Common/Uuid.js';
3
3
  import { CrdtChannel, MIN_CRDT_HOST_VERSION } from '../Common/CrdtChannel.js';
4
4
  import { BlobStore } from '../Common/BlobStore.js';
5
5
  import { isMinVersion } from '../Common/index.js';
6
6
  import { apiVersion } from '../Version.js';
7
+ import { normalizeSettingsSchema } from './SettingsSchema.js';
7
8
  export class Connector {
8
9
  /** @deprecated Use `crdt.doc`. The setter forwards to `crdt.attach(doc)`
9
10
  * so legacy callers that ever assigned `connector.yjsDoc = myDoc` keep
@@ -392,6 +393,7 @@ export class Connector {
392
393
  // New hosts prefer `shareTargets` and ignore the mirrored singular.
393
394
  this.options = {
394
395
  ...options,
396
+ settingsSchema: normalizeSettingsSchema(options.settingsSchema),
395
397
  shareTarget: options.shareTarget ??
396
398
  (options.shareTargets?.length ? options.shareTargets[0] : undefined),
397
399
  };
@@ -665,7 +667,7 @@ export class Connector {
665
667
  }
666
668
  }
667
669
  async requestAppToken() {
668
- const requestId = uuid();
670
+ const requestId = randomUuid();
669
671
  const token = await this.postRequest({ type: 'requestAppToken', requestId }, (msg, resolve, reject) => {
670
672
  if (msg.type === 'appTokenReceived' && msg.requestId === requestId) {
671
673
  const tokenMsg = msg;
@@ -693,7 +695,7 @@ export class Connector {
693
695
  * own frame subtree.
694
696
  */
695
697
  async executeInFrame(frameName, code) {
696
- const requestId = uuid();
698
+ const requestId = randomUuid();
697
699
  const json = await this.postRequest({ type: 'executeInFrame', requestId, frameName, code }, (msg, resolve, reject) => {
698
700
  if (msg.type === 'executeInFrameResult' &&
699
701
  msg.requestId === requestId) {
@@ -787,7 +789,7 @@ export class Connector {
787
789
  });
788
790
  }
789
791
  async requestStats() {
790
- const requestId = uuid();
792
+ const requestId = randomUuid();
791
793
  return await this.postRequest({ type: 'getStats', requestId }, (msg, resolve, _reject) => {
792
794
  if (msg.type === 'statsResponse' && msg.requestId === requestId) {
793
795
  resolve(msg);
@@ -795,7 +797,7 @@ export class Connector {
795
797
  });
796
798
  }
797
799
  async requestEnumerateDevices() {
798
- const requestId = uuid();
800
+ const requestId = randomUuid();
799
801
  return await this.postRequest({ type: 'enumerateMediaDevices', requestId }, async (msg, resolve, _reject) => {
800
802
  if (msg.type === 'enumerateMediaDevicesCompleted' &&
801
803
  msg.requestId === requestId) {
@@ -824,7 +826,7 @@ export class Connector {
824
826
  });
825
827
  }
826
828
  async requestOpenStream(streamId, constraints) {
827
- const requestId = uuid();
829
+ const requestId = randomUuid();
828
830
  return await this.postRequest({ type: 'openStream', requestId, streamId, constraints }, (msg, resolve, reject) => {
829
831
  if (msg.type === 'openStreamCompleted' && msg.requestId === requestId) {
830
832
  if (msg.error != null || msg.tracks == null) {
@@ -863,7 +865,7 @@ export class Connector {
863
865
  return mappedConstraint;
864
866
  }
865
867
  async requestOpenStreamFrame(openStreamFrame) {
866
- const requestId = uuid();
868
+ const requestId = randomUuid();
867
869
  const constraints = openStreamFrame.constraints
868
870
  ? await this.convertConstraintsToVitreConstraints(openStreamFrame.constraints)
869
871
  : undefined;
@@ -917,8 +919,8 @@ export class Connector {
917
919
  if (!this.canShareStream()) {
918
920
  throw new Error('shareStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)');
919
921
  }
920
- const sharedStreamId = uuid();
921
- const requestId = uuid();
922
+ const sharedStreamId = randomUuid();
923
+ const requestId = randomUuid();
922
924
  const { tracks, transfer } = this.toShareTracks(stream);
923
925
  await this.postRequest({ type: 'shareStream', requestId, sharedStreamId, options, tracks }, (msg, resolve, reject) => {
924
926
  if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {
@@ -943,7 +945,7 @@ export class Connector {
943
945
  const stream = streamOrTrack instanceof MediaStream
944
946
  ? streamOrTrack
945
947
  : new MediaStream([streamOrTrack]);
946
- const requestId = uuid();
948
+ const requestId = randomUuid();
947
949
  const { tracks, transfer } = this.toShareTracks(stream);
948
950
  await this.postRequest({ type: 'replaceShareStream', requestId, sharedStreamId, tracks }, (msg, resolve, reject) => {
949
951
  if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {
@@ -1143,14 +1145,15 @@ export class Connector {
1143
1145
  });
1144
1146
  }
1145
1147
  setSettingsSchema(schema) {
1148
+ const normalized = { ...schema, schema: normalizeSettingsSchema(schema.schema) };
1146
1149
  this.options = {
1147
1150
  ...this.options,
1148
- settingsSchema: schema.schema,
1149
- settingsSchemaUI: schema.schemaUI,
1151
+ settingsSchema: normalized.schema,
1152
+ settingsSchemaUI: normalized.schemaUI,
1150
1153
  };
1151
1154
  this.postMessage({
1152
1155
  type: 'setSettingsSchema',
1153
- ...schema,
1156
+ ...normalized,
1154
1157
  });
1155
1158
  }
1156
1159
  /**
@@ -1273,7 +1276,7 @@ export class Connector {
1273
1276
  /// the port the user chose (also pre-granted).
1274
1277
  /// Honoured only when the app holds the WebSerial authorization.
1275
1278
  async requestSerialPortAccess(request) {
1276
- const requestId = uuid();
1279
+ const requestId = randomUuid();
1277
1280
  return await this.postRequest({ type: 'requestSerialPortAccess', requestId, port: request?.port }, (msg, resolve, reject) => {
1278
1281
  if (msg.type === 'serialPortAccessResult' &&
1279
1282
  msg.requestId === requestId) {
@@ -1 +1 @@
1
- {"version":3,"file":"Connector.js","sourceRoot":"","sources":["../../Connector/Connector.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAsCjD,OAA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Z,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=\"./insertable-streams.d.ts\" />\nimport { v4 as uuid } from 'uuid'\nimport type * as Y from 'yjs'\nimport { CrdtChannel, MIN_CRDT_HOST_VERSION } from '../Common/CrdtChannel.js'\nimport { BlobStore } from '../Common/BlobStore.js'\nimport { isMinVersion } from '../Common/index.js'\nimport type {\n AppId,\n AppMessage,\n ChromeStyle,\n ConnectedMediaDevice,\n Device,\n DeviceFrameReference,\n DeviceFullscreenUpdated,\n DeviceMessageReceived,\n DeviceScalingUpdated,\n Field,\n FileData,\n HostInformation,\n KnockKnock,\n LayoutPosition,\n MessageTarget,\n NotificationButtonClicked,\n NotificationInfo,\n OpenFrameOptions,\n Privacy,\n ReplacedBy,\n RequestSerialPortAccess,\n SendKnockKnock,\n SendMessageTo,\n SendMessageToAll,\n SendToSerialPort,\n Size,\n StateReplaced,\n StatsResponse,\n UpdatedStateEntry,\n UpdateStateEntry,\n VitreSettings,\n VitreSettingsSetter,\n VoiceAction,\n VoiceActionDetection,\n} from '../Common/index.js'\nimport type { Frame } from '../Frame/index.js'\nimport { apiVersion } from '../Version.js'\nimport type {\n AppTokenReceivedData,\n ExecuteInFrameResultData,\n CompanionConnectorTarget,\n ExternalMessageReceived,\n ConnectorApiMessagesIn,\n ConnectorApiMessagesOut,\n ConnectorOptions,\n FrameInfo,\n FramePositionUpdated,\n InitializeConnector,\n MediaTrackInfo,\n OpenStreamFrame,\n RootMenuEntry,\n SettingsSchema,\n ShareData,\n ShareStreamOptions,\n ShareStreamTrack,\n ShareTargetOptions,\n} from './Connector.Model.js'\n\ninterface RequestResolver {\n isHandled: (msg: ConnectorApiMessagesIn) => boolean\n}\n\nexport class Connector {\n public onDeviceJoined?: (device: Device) => void\n public onDeviceLeft?: (deviceId: string) => void\n public onDeviceMessageReceived?: (message: DeviceMessageReceived) => void\n public onMenuClicked?: (menuId: string, tag: any, isChecked: boolean) => void\n public onFieldUpdated?: (field: Field) => void\n public onFrameConnectorLoading?: (options: OpenFrameOptions) => void\n public onShareDataReceived?: (shareData: ShareData) => void\n public onShareFileReceived?: (shareData: FileData) => void\n public onFrameLoaded?: (frameConnectorId: string) => void\n public onFrameConnectorLoaded?: (frameConnectorId: string) => void\n public onFrameUnloaded?: (frameConnectorId: string) => void\n public onLocalConnectorMessageReceived?: (\n message: any,\n from?: string,\n fileData?: FileData,\n ) => void\n public onPrivacyChanged?: (privacy: Privacy) => void\n /** @deprecated Use onEmbedMessage */\n public onExtensionMessage?: (extensionMessage: AppMessage) => void\n /** @deprecated Use onEmbedMessage */\n public onAppMessage?: (appMessage: AppMessage) => void\n public onEmbedMessage?: (embedMessage: AppMessage) => void\n public onKnockKnockReceived?: (knockKnock: KnockKnock) => void\n public onPendingDevicesConnectionRequested?: (\n pendingClients: Device[],\n ) => void\n public onSettingsUpdated?: (settings: any) => void\n public onVitreSettingsUpdated?: (settings: VitreSettings) => void\n public onConnectionCodeUpdated?: (companionCode?: string) => void\n public onNotificationDismissed?: (notificationId: string) => void\n public onNotificationButtonClicked?: (\n notificationButton: NotificationButtonClicked,\n ) => void\n public onDevicePrivacyChanged?: (device: Device) => void\n public onFrameZIndexChanged?: (frameInfo: FrameInfo) => 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: ConnectorApiMessagesIn) => void\n public onVoiceActionDetected?: (voiceAction: VoiceActionDetection) => void\n public onDeviceFullscreenUpdated?: (msg: DeviceFullscreenUpdated) => void\n public onDeviceScalingUpdated?: (msg: DeviceScalingUpdated) => void\n public onFramePositionUpdated?: (msg: FramePositionUpdated) => void\n public onStateReplaced?: (\n newState: Record<string, any>,\n oldState: Record<string, any>,\n replacedBy: ReplacedBy,\n delta: UpdatedStateEntry[],\n ) => void\n public onExternalMessageReceived?: (msg: ExternalMessageReceived) => any | Promise<any> | void\n public onAppTokenRefreshed?: (token: string) => void\n public onMediaDevicesChanged?: (devices: ConnectedMediaDevice[]) => void\n /// Called when an already-open shared frame's owner is reassigned via\n /// `setFrameOwner` — INCLUDING a change initiated by another device in the\n /// space (every vitre/companion running this app is notified). The owner\n /// drives the languette colour and (when a Vitre) hosting/survival, and is\n /// what an app should key its per-frame stored state on. `owner` is the new\n /// owner's device id (`HostInformation.devicesInSpace[].id`). Not fired for\n /// the initial open: a frame opened with `OpenFrameOptions.owner` is created\n /// already-owned, so the opener already knows its owner.\n public onFrameOwnerChanged?: (frameConnectorId: string, owner: string) => void\n /// Called when the companion-side `CompanionConnector` for the same\n /// `appId` sent a message via `sendMessageToVitreConnector`. The\n /// `fromCompanionId` identifies which companion sent it so the Vitre\n /// connector can reply targeted-back via `sendMessageToCompanionConnector`.\n public onMessageFromCompanionConnector?: (\n fromCompanionId: string,\n message: string,\n fileData?: FileData,\n ) => void\n /// Called when a companion FRAME of this app sent a message via\n /// `CompanionFrame.sendMessageToVitreConnector` — including a local\n /// companion frame with no paired Vitre frame. `frameConnectorId` is the\n /// companion frame that spoke; `fromCompanionId` is the companion. Reply\n /// targeted-back via `sendMessageToCompanionConnector`.\n public onMessageFromCompanionFrame?: (\n fromCompanionId: string,\n frameConnectorId: string,\n message: string,\n fileData?: FileData,\n ) => void\n /// Called when a companion clicked a menu entry that lives on one of\n /// THIS app's frames' options menu AND was declared with\n /// `availability: 'companion'` (or `'companionAdmin'`). The click never\n /// reaches the Vitre-side UI — it is intercepted on the companion and\n /// routed here so the app can decide what to do (typically: dispatch\n /// the companion's main connector to call `openCompanionFrame` for the\n /// matching frame).\n ///\n /// `frameConnectorId` is the frame whose menu entry was clicked.\n /// `fromCompanionId` is the connection-id of the clicker so the app\n /// can target a targeted reply back. The remaining fields mirror the\n /// regular `onMenuClicked` shape.\n public onFrameMenuClickedOnCompanion?: (\n frameConnectorId: string,\n fromCompanionId: string,\n menuId: string,\n isChecked: boolean,\n tag: any,\n ) => 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\n public appId: string\n public hostInformation: HostInformation\n public openedFrames: FrameInfo[] = []\n public state: Record<string, any> = {}\n public appToken: string | null = null\n private appTokenRefreshTimer: ReturnType<typeof setInterval> | null = null\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`. `put` / `get` /\n * `list` / `onProgress` for heavy binaries (images, PDFs, 3D, …) that\n * must be retrievable by anyone joining the doc, even late. Opinionated\n * but bare — see BlobStore.\n */\n public readonly blobs: BlobStore\n\n /** @deprecated Use `crdt.doc`. The setter forwards to `crdt.attach(doc)`\n * so legacy callers that ever assigned `connector.yjsDoc = myDoc` keep\n * working — without it, getter-only would throw `TypeError: Cannot set\n * property yjsDoc which has only a getter` under strict mode / ESM. */\n get yjsDoc() {\n return this.crdt.doc\n }\n set yjsDoc(doc: Y.Doc) {\n this.crdt.attach(doc)\n }\n\n constructor(\n private readonly postMessage: (\n message: ConnectorApiMessagesOut,\n transfer?: Transferable[],\n ) => void,\n initMessage: InitializeConnector,\n public options: ConnectorOptions,\n ) {\n this.hostInformation = initMessage.hostInfo\n this.appId = initMessage.appId ?? ''\n this.state = initMessage.state ?? {}\n // Mirror the first of `shareTargets` onto the deprecated singular `shareTarget`\n // so older Vitres (which only read `shareTarget`) still get the primary target.\n // New hosts prefer `shareTargets` and ignore the mirrored singular.\n this.options = {\n ...options,\n shareTarget:\n options.shareTarget ??\n (options.shareTargets?.length ? options.shareTargets[0] : undefined),\n }\n this.postMessage({\n type: 'connectorInitialized',\n options: this.options,\n })\n\n // Older Vitres reject unknown message types and fail the whole parse,\n // so never emit `crdt*` toward a host below the supported version. The\n // channel still constructs and works locally; emission is just dropped\n // (graceful degradation — onSynced never fires on old hosts, by design).\n const crdtSupported = isMinVersion(\n this.hostInformation.version,\n MIN_CRDT_HOST_VERSION,\n )\n this.crdt = new CrdtChannel((message, transfer) => {\n // No cast: `ConnectorApiMessagesOut` already includes the four `crdt*`\n // arms (Connector.Model.ts), so the union narrows naturally and TS\n // will flag any drift between the two definitions.\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\n private resolveRequest(msg: ConnectorApiMessagesIn) {\n this.requestResolvers = this.requestResolvers.filter(\n (rr) => !rr.isHandled(msg),\n )\n }\n\n raiseMessage(msg: ConnectorApiMessagesIn) {\n this.resolveRequest(msg)\n\n switch (msg.type) {\n case 'privacyChanged':\n this.hostInformation = {\n ...this.hostInformation,\n device: { ...this.hostInformation.device, privacy: msg.privacy },\n }\n this.onPrivacyChanged?.(msg.privacy)\n break\n case 'deviceJoined':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: [\n ...this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.device.id,\n ),\n msg.device,\n ],\n }\n this.onDeviceJoined?.(msg.device)\n break\n case 'deviceLeft':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.deviceId,\n ),\n }\n this.onDeviceLeft?.(msg.deviceId)\n break\n case 'deviceMessageReceived':\n this.onDeviceMessageReceived?.(msg)\n break\n case 'menuClicked':\n this.onMenuClicked?.(msg.menuId, msg.tag, msg.isChecked)\n break\n case 'fieldUpdated':\n this.onFieldUpdated?.(msg.field)\n break\n case 'frameConnectorLoading':\n this.onFrameConnectorLoading?.(msg.options)\n break\n case 'shareDataReceived':\n this.onShareDataReceived?.(msg.data)\n break\n case 'fileShareDataReceived':\n this.onShareFileReceived?.(msg.data)\n break\n case 'frameLoaded':\n this.openedFrames.push(msg)\n this.onFrameLoaded?.(msg.frameConnectorId)\n break\n case 'frameConnectorLoaded':\n {\n const idx = this.openedFrames.findIndex(\n (f) => f.frameConnectorId === msg.frameConnectorId,\n )\n if (idx >= 0) {\n this.openedFrames[idx] = msg\n }\n this.onFrameConnectorLoaded?.(msg.frameConnectorId)\n }\n break\n case 'frameUnloaded':\n {\n const idx = this.openedFrames.findIndex(\n (f) => f.frameConnectorId === msg.frameConnectorId,\n )\n if (idx >= 0) {\n this.openedFrames.splice(idx, 1)\n }\n this.onFrameUnloaded?.(msg.frameConnectorId)\n }\n break\n case 'localConnectorMessageReceived':\n this.onLocalConnectorMessageReceived?.(msg.data, msg.from, msg.fileData)\n break\n case 'extensionMessage':\n this.onExtensionMessage?.(msg)\n this.onAppMessage?.(msg)\n this.onEmbedMessage?.(msg)\n break\n case 'appMessage':\n this.onAppMessage?.(msg)\n this.onEmbedMessage?.(msg)\n break\n\n case 'knockKnockReceived':\n this.onKnockKnockReceived?.(msg)\n break\n case 'pendingDevicesConnectionRequested':\n this.onPendingDevicesConnectionRequested?.(msg.pendingDevices)\n break\n case 'settingsUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n settings: msg.settings,\n }\n this.onSettingsUpdated?.(msg.settings)\n break\n case 'vitreSettingsUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n space: msg.currentSpace,\n vitreSettings: msg,\n device: {\n ...this.hostInformation.device,\n name: msg.name ?? this.hostInformation.device.name,\n color: msg.color,\n },\n }\n this.onVitreSettingsUpdated?.(msg)\n break\n case 'notificationButtonClicked':\n this.onNotificationButtonClicked?.(msg)\n break\n case 'notificationDismissed':\n this.onNotificationDismissed?.(msg.id)\n break\n case 'devicePrivacyChanged':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: [\n ...this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.device.id,\n ),\n msg.device,\n ],\n }\n this.onDevicePrivacyChanged?.(msg.device)\n break\n case 'frameZIndexChanged':\n {\n const idx = this.openedFrames.findIndex(\n (f) => f.frameConnectorId === msg.frameConnectorId,\n )\n if (idx >= 0) {\n this.openedFrames[idx] = msg\n }\n this.onFrameZIndexChanged?.(msg)\n }\n break\n\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 'voiceActionDetected':\n this.onVoiceActionDetected?.(msg)\n break\n\n case 'deviceFullscreenUpdated':\n this.onDeviceFullscreenUpdated?.(msg)\n break\n case 'framePositionUpdated':\n this.onFramePositionUpdated?.(msg)\n break\n case 'deviceScalingUpdated':\n if (msg.deviceId === this.hostInformation.device.id) {\n this.hostInformation.device.sendingScaling = msg.sendingScaling\n this.hostInformation.device.orientation = msg.orientation\n this.hostInformation.device.orientationBy = msg.orientationBy\n }\n this.hostInformation.devicesInSpace =\n this.hostInformation.devicesInSpace.map((d) =>\n d.id === msg.deviceId\n ? {\n ...d,\n sendingScaling: msg.sendingScaling,\n orientation: msg.orientation,\n orientationBy: msg.orientationBy,\n }\n : d,\n )\n this.onDeviceScalingUpdated?.(msg)\n break\n case 'connectionCodeUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n companionCode: msg.companionCode,\n }\n this.onConnectionCodeUpdated?.(msg.companionCode)\n break\n case 'stateReplaced':\n this._onStateReplaced(msg)\n break\n case 'externalMessageReceived':\n this._onExternalMessageReceived(msg)\n break\n case 'appTokenReceived':\n // Handled by requestResolvers (postRequest pattern)\n break\n case 'mediaDevicesChanged':\n this.hostInformation = {\n ...this.hostInformation,\n vitreSettings: {\n ...this.hostInformation.vitreSettings,\n availableMediaDevices: msg.devices,\n },\n }\n this.onMediaDevicesChanged?.(msg.devices)\n break\n case '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 'frameOwnerChanged':\n this.onFrameOwnerChanged?.(msg.frameConnectorId, msg.owner)\n break\n case 'messageFromCompanionConnector':\n this.onMessageFromCompanionConnector?.(\n msg.fromCompanionId,\n msg.message,\n msg.fileData,\n )\n break\n case 'messageFromCompanionFrame':\n this.onMessageFromCompanionFrame?.(\n msg.fromCompanionId,\n msg.frameConnectorId,\n msg.message,\n msg.fileData,\n )\n break\n case 'frameMenuClickedOnCompanion':\n this.onFrameMenuClickedOnCompanion?.(\n msg.frameConnectorId,\n msg.fromCompanionId,\n msg.menuId,\n msg.isChecked,\n msg.tag,\n )\n break\n }\n this.onMessageReceived?.(msg)\n }\n\n private _onStateReplaced(msg: StateReplaced) {\n const oldState = this.state\n this.state = msg.state\n this.onStateReplaced?.(this.state, oldState, msg.replacedBy, msg.delta)\n }\n\n private _onExternalMessageReceived(msg: ExternalMessageReceived) {\n if (this.onExternalMessageReceived) {\n const result = this.onExternalMessageReceived(msg)\n\n // If handler returns a value (sync or Promise), automatically send response\n if (result !== undefined && result !== null) {\n const sendResponse = (response: any) => {\n this.postMessage({\n type: 'externalMessageResponse',\n requestId: msg.requestId,\n response,\n })\n }\n\n if (result instanceof Promise || (result && typeof result.then === 'function')) {\n ;(result as Promise<any>).then(sendResponse).catch(() => {\n sendResponse(null)\n })\n } else {\n sendResponse(result)\n }\n }\n }\n }\n\n public async requestAppToken(): Promise<string> {\n const requestId = uuid()\n const token = await this.postRequest<string>(\n { type: 'requestAppToken', requestId },\n (msg, resolve, reject) => {\n if (msg.type === 'appTokenReceived' && (msg as AppTokenReceivedData).requestId === requestId) {\n const tokenMsg = msg as AppTokenReceivedData\n if (tokenMsg.token) {\n resolve(tokenMsg.token)\n } else {\n reject(tokenMsg.error ?? 'Failed to get app token')\n }\n }\n },\n )\n this.appToken = token\n return token\n }\n\n /**\n * Run JavaScript inside a (cross-origin) child iframe this app embeds in its\n * frame.html, and resolve with the JSON-parsed return value.\n *\n * The iframe must carry a `name` attribute (e.g. `<iframe name=\"my-target\">`)\n * matching `frameName`. `code` runs as a function body — use `return <expr>` to\n * produce a value (any JSON-serializable value round-trips; `undefined` → `null`).\n *\n * Requires the `injectScriptIntoFrame` app authorization and the native (CEF)\n * host (rejects on a web host). The host also restricts the target to this app's\n * own frame subtree.\n */\n public async executeInFrame<T = unknown>(frameName: string, code: string): Promise<T> {\n const requestId = uuid()\n const json = await this.postRequest<string | undefined>(\n { type: 'executeInFrame', requestId, frameName, code },\n (msg, resolve, reject) => {\n if (\n msg.type === 'executeInFrameResult' &&\n (msg as ExecuteInFrameResultData).requestId === requestId\n ) {\n const resultMsg = msg as ExecuteInFrameResultData\n if (resultMsg.error) {\n reject(resultMsg.error)\n } else {\n resolve(resultMsg.result)\n }\n }\n },\n )\n return (json === undefined ? undefined : JSON.parse(json)) as T\n }\n\n public startAppTokenRefresh(intervalMs = 3600000): void {\n this.stopAppTokenRefresh()\n // Request initial token\n this.requestAppToken().catch(() => {})\n // Refresh periodically\n this.appTokenRefreshTimer = setInterval(async () => {\n try {\n const token = await this.requestAppToken()\n this.onAppTokenRefreshed?.(token)\n } catch (_error) {\n // Will retry on next interval\n }\n }, intervalMs)\n }\n\n public stopAppTokenRefresh(): void {\n if (this.appTokenRefreshTimer) {\n clearInterval(this.appTokenRefreshTimer)\n this.appTokenRefreshTimer = null\n }\n }\n\n /** Release the resources owned by this connector. Stops the app-token\n * refresh timer and tears the CRDT channel down (unbinds doc/awareness\n * listeners, destroys the default Y.Doc + Awareness). Safe to call\n * multiple times. */\n public destroy(): void {\n this.stopAppTokenRefresh()\n this.crdt.destroy()\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 private requestResolvers: RequestResolver[] = []\n private async postRequest<Data>(\n data: ConnectorApiMessagesOut,\n handler: (\n msg: ConnectorApiMessagesIn,\n resolve: (data: Data) => void,\n reject: (error: string) => void,\n ) => void,\n transfer?: Transferable[],\n ) {\n return await new Promise<Data>((resolve, reject) => {\n let isHandled = false\n const handleAndResolve = (data: Data) => {\n isHandled = true\n resolve(data)\n }\n\n const handleAndReject = (error: any) => {\n isHandled = true\n reject(error)\n }\n\n const resolver = {\n isHandled: (msg: ConnectorApiMessagesIn) => {\n try {\n handler(msg, handleAndResolve, handleAndReject)\n } catch (error) {\n handleAndReject(error)\n }\n return isHandled\n },\n }\n this.requestResolvers.push(resolver)\n this.postMessage(data, transfer)\n })\n }\n\n public async requestStats() {\n const requestId = uuid()\n return await this.postRequest<StatsResponse>(\n { type: 'getStats', requestId },\n (msg, resolve, _reject) => {\n if (msg.type === 'statsResponse' && msg.requestId === requestId) {\n resolve(msg)\n }\n },\n )\n }\n\n public async requestEnumerateDevices() {\n const requestId = uuid()\n return await this.postRequest<ConnectedMediaDevice[]>(\n { type: 'enumerateMediaDevices', requestId },\n async (msg, resolve, _reject) => {\n if (\n msg.type === 'enumerateMediaDevicesCompleted' &&\n msg.requestId === requestId\n ) {\n const localDevices = await navigator.mediaDevices.enumerateDevices()\n\n const cleanName = (name: string) => {\n if (!name) return name\n return name.replace(/\\s*\\([0-9a-f]{4}:[0-9a-f]{4}\\)\\s*$/gi, '')\n }\n\n const mappedDevices = msg.devices.map((d) => {\n const localDevice = localDevices.find(\n (ld) =>\n cleanName(ld.label) === cleanName(d.label) &&\n ld.kind === d.kind,\n )\n if (localDevice) {\n return {\n ...d,\n deviceId: localDevice.deviceId,\n groupId: localDevice.groupId,\n vitreId: d.deviceId,\n vitreGroupId: d.groupId,\n }\n }\n return d\n })\n\n resolve(mappedDevices)\n }\n },\n )\n }\n\n public async requestOpenStream(\n streamId: string,\n constraints: MediaStreamConstraints,\n ) {\n const requestId = uuid()\n return await this.postRequest<MediaTrackInfo[]>(\n { type: 'openStream', requestId, streamId, constraints },\n (msg, resolve, reject) => {\n if (msg.type === 'openStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null || msg.tracks == null) {\n reject(msg.error ?? 'openStream failed')\n } else {\n resolve(msg.tracks)\n }\n }\n },\n )\n }\n\n private async convertConstraintsToVitreConstraints(\n constraints: MediaStreamConstraints,\n ): Promise<MediaStreamConstraints> {\n const vitreDevices = await this.requestEnumerateDevices()\n\n const videoConstraint = (typeof constraints.video === 'object' &&\n constraints.video) as MediaTrackConstraints | null\n const audioConstraint = (typeof constraints.audio === 'object' &&\n constraints.audio) as MediaTrackConstraints | null\n const videoDeviceId = videoConstraint?.deviceId\n const audioDeviceId = audioConstraint?.deviceId\n\n const mappedVideoDevice = vitreDevices.find(\n (d) => d.deviceId === videoDeviceId && d.kind === 'videoinput',\n ) as any\n const mappedVideoDeviceId =\n mappedVideoDevice?.vitreId ?? mappedVideoDevice?.deviceId\n const mappedAudioDevice = vitreDevices.find(\n (d) => d.deviceId === audioDeviceId && d.kind === 'audioinput',\n ) as any\n const mappedAudioDeviceId =\n mappedAudioDevice?.vitreId ?? mappedAudioDevice?.deviceId\n\n let mappedConstraint = videoDeviceId\n ? {\n ...constraints,\n video: { ...videoConstraint, deviceId: mappedVideoDeviceId },\n }\n : constraints\n mappedConstraint = audioDeviceId\n ? {\n ...mappedConstraint,\n audio: { ...audioConstraint, deviceId: mappedAudioDeviceId },\n }\n : mappedConstraint\n return mappedConstraint\n }\n\n public async requestOpenStreamFrame(\n openStreamFrame: Omit<OpenStreamFrame, 'requestId'>,\n ) {\n const requestId = uuid()\n\n const constraints = openStreamFrame.constraints\n ? await this.convertConstraintsToVitreConstraints(\n openStreamFrame.constraints,\n )\n : undefined\n\n return await this.postRequest<MediaTrackInfo[]>(\n { type: 'openStreamFrame', requestId, ...openStreamFrame, constraints },\n (msg, resolve, reject) => {\n if (\n msg.type === 'openStreamFrameCompleted' &&\n msg.requestId === requestId\n ) {\n if (msg.error != null || msg.tracks == null) {\n reject(msg.error ?? 'openStream failed')\n } else {\n resolve(msg.tracks)\n }\n }\n },\n )\n }\n\n /**\n * Whether {@link shareStream} is available in this runtime. Requires the\n * MediaStreamTrack Insertable Streams API (Chromium-only) and the app being\n * served same-site as the Vitre host (so the transferred stream survives the\n * iframe boundary zero-copy). Apps should feature-detect before offering a\n * share action.\n */\n public canShareStream(): boolean {\n return typeof MediaStreamTrackProcessor !== 'undefined'\n }\n\n private toShareTracks(stream: MediaStream): {\n tracks: ShareStreamTrack[]\n transfer: Transferable[]\n } {\n const tracks: ShareStreamTrack[] = []\n const transfer: Transferable[] = []\n for (const track of stream.getTracks()) {\n const { readable } = new MediaStreamTrackProcessor({ track })\n tracks.push({\n kind: track.kind as ShareStreamTrack['kind'],\n readable,\n settings: track.getSettings(),\n })\n transfer.push(readable)\n }\n return { tracks, transfer }\n }\n\n /**\n * Share a camera/microphone (or any) `MediaStream` the app controls TO the\n * Vitre, which forwards it to the other peers in the space like a regular\n * shared stream. The stream is handed over zero-copy (no re-encode) via the\n * breakout box; the app keeps ownership of its tracks and can stop them\n * independently.\n *\n * Returns a `sharedStreamId` to pass to {@link replaceShareStream} /\n * {@link stopShareStream}. Throws if {@link canShareStream} is false.\n */\n public async shareStream(\n stream: MediaStream,\n options?: ShareStreamOptions,\n ): Promise<string> {\n if (!this.canShareStream()) {\n throw new Error(\n 'shareStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)',\n )\n }\n const sharedStreamId = uuid()\n const requestId = uuid()\n const { tracks, transfer } = this.toShareTracks(stream)\n await this.postRequest<void>(\n { type: 'shareStream', requestId, sharedStreamId, options, tracks },\n (msg, resolve, reject) => {\n if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n return sharedStreamId\n }\n\n /**\n * Swap the source of an open share WITHOUT closing it (e.g. switch camera,\n * or camera→screen). Peers keep receiving on the same slot with no\n * renegotiation blip. `sharedStreamId` is the value returned by\n * {@link shareStream}.\n */\n public async replaceShareStream(\n sharedStreamId: string,\n streamOrTrack: MediaStream | MediaStreamTrack,\n ): Promise<void> {\n if (!this.canShareStream()) {\n throw new Error('replaceShareStream is not supported in this runtime')\n }\n const stream =\n streamOrTrack instanceof MediaStream\n ? streamOrTrack\n : new MediaStream([streamOrTrack])\n const requestId = uuid()\n const { tracks, transfer } = this.toShareTracks(stream)\n await this.postRequest<void>(\n { type: 'replaceShareStream', requestId, sharedStreamId, tracks },\n (msg, resolve, reject) => {\n if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n }\n\n /** Stop an app share. `sharedStreamId` is the value returned by {@link shareStream}. */\n public stopShareStream(sharedStreamId: string): void {\n this.postMessage({ type: 'stopShareStream', sharedStreamId })\n }\n\n public getFrame(frameConnectorId: string): Window | null {\n try {\n const frameId = `${this.appId}|${frameConnectorId}`\n return (window.parent.frames as any)[frameId]\n } catch (_error) {\n return null\n }\n }\n\n public getFrameConnector(frameConnector: string): Frame | null {\n const frame = this.getFrame(frameConnector) as any\n return frame?.frameConnector as Frame\n }\n\n public async openFrame(frameOptions: OpenFrameOptions) {\n return await this.postRequest<FrameInfo>(\n {\n type: 'openFrame',\n options: frameOptions,\n },\n (msg, resolve, _reject) => {\n if (\n msg.type === 'frameConnectorLoaded' &&\n msg.frameConnectorId === frameOptions.frameConnectorId\n ) {\n resolve(msg)\n }\n },\n )\n }\n\n public async openLocalFrame(frameOptions: OpenFrameOptions) {\n return await this.postRequest<FrameInfo>(\n {\n type: 'openLocalFrame',\n options: frameOptions,\n },\n (msg, resolve, _reject) => {\n if (\n msg.type === 'frameConnectorLoaded' &&\n msg.frameConnectorId === frameOptions.frameConnectorId\n ) {\n resolve(msg)\n }\n },\n )\n }\n\n public sendMessageTo(message: SendMessageTo) {\n this.postMessage({ type: 'sendMessageTo', ...message })\n }\n\n public sendMessageToAll(message: SendMessageToAll) {\n this.postMessage({\n type: 'sendMessageToAll',\n ...message,\n })\n }\n\n public sendKnockKnock(message: SendKnockKnock) {\n this.postMessage({ type: 'sendKnockKnock', ...message })\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 setMenu(menu: RootMenuEntry[]) {\n this.postMessage({\n type: 'setRootMenu',\n menu,\n })\n }\n\n /**\n * @deprecated Use sendAppMessage on vitre v18\n */\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. The owner drives the languette\n * colour/info and the content appears already-owned on every vitre. When\n * omitted the share is owned by the opener (default).\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 (`HostInformation.devicesInSpace[].id`) to\n * attribute the resulting shared content to. See {@link shareData}.\n */\n public shareFile(fileData: FileData, targetAppId: AppId, owner?: string) {\n this.postMessage({\n type: 'shareFile',\n fileData,\n targetAppId,\n owner,\n })\n }\n\n public saveSettings(settings: any) {\n this.postMessage({\n type: 'saveSettings',\n settings,\n })\n }\n\n public changeTeamSpace(space: string) {\n this.postMessage({\n type: 'changeTeamSpace',\n space,\n })\n }\n\n public changeTeamSpaceGuest(space: string, teamDomain: string) {\n this.postMessage({\n type: 'changeTeamSpaceGuest',\n space,\n teamDomain,\n })\n }\n\n public showNotification(notification: NotificationInfo) {\n this.postMessage({\n ...notification,\n type: 'showNotification',\n })\n }\n\n public hideNotification(notificationId: string) {\n this.postMessage({\n id: notificationId,\n type: 'hideNotification',\n })\n }\n\n public changePrivacy(privacy: Privacy) {\n this.postMessage({\n type: 'changePrivacy',\n privacy,\n })\n }\n\n public trackEvent(name: string, properties?: Record<string, any>) {\n this.postMessage({\n type: 'trackEvent',\n name,\n properties,\n })\n }\n\n public startTrackEvent(name: string) {\n this.postMessage({\n type: 'startTrackEvent',\n name,\n })\n }\n\n public stopTrackEvent(name: string, properties?: Record<string, any>) {\n this.postMessage({\n type: 'stopTrackEvent',\n name,\n properties,\n })\n }\n\n public setSettingsSchema(schema: SettingsSchema) {\n this.options = {\n ...this.options,\n settingsSchema: schema.schema,\n settingsSchemaUI: schema.schemaUI,\n }\n this.postMessage({\n type: 'setSettingsSchema',\n ...schema,\n })\n }\n\n /**\n * Update the app's share target at any time. The new share target replaces\n * the one provided at initialization (ConnectorOptions.shareTarget) and is\n * applied immediately by the host. Can be called repeatedly.\n *\n * @deprecated Use `setShareTargets` to advertise one or more share targets.\n */\n public setShareTarget(shareTarget: ShareTargetOptions) {\n this.options = {\n ...this.options,\n shareTarget,\n shareTargets: [shareTarget],\n }\n this.postMessage({\n type: 'setShareTarget',\n shareTarget,\n })\n }\n\n /**\n * Update the app's share targets at any time. The new array replaces the ones\n * provided at initialization (ConnectorOptions.shareTargets) and is applied\n * immediately by the host. Can be called repeatedly.\n */\n public setShareTargets(shareTargets: ShareTargetOptions[]) {\n this.options = {\n ...this.options,\n shareTargets,\n // Mirror the first target onto the deprecated singular for older Vitres.\n shareTarget: shareTargets[0],\n }\n // Emit the legacy singular first so older Vitres (which only handle\n // `setShareTarget`) still get the primary target at runtime, then the full\n // array which new hosts apply (and which supersedes the singular there).\n if (shareTargets[0]) {\n this.postMessage({\n type: 'setShareTarget',\n shareTarget: shareTargets[0],\n })\n }\n this.postMessage({\n type: 'setShareTargets',\n shareTargets,\n })\n }\n\n public setVoiceActions(actions: VoiceAction[]) {\n this.postMessage({\n type: 'setVoiceActions',\n actions,\n })\n }\n\n public setFramePosition(frameConnectorId: string, position: LayoutPosition) {\n this.postMessage({\n type: 'setFramePosition',\n frameConnectorId,\n position,\n })\n }\n\n public closeFrame(frameConnectorId: string) {\n this.postMessage({\n type: 'closeFrame',\n frameConnectorId,\n })\n }\n\n /**\n * Reassign the owner of an already-opened shared frame. `owner` is a\n * device id from `HostInformation.devicesInSpace[].id`. The new owner\n * drives the languette colour, and when it is a Vitre it takes over\n * hosting the frame so it survives the opener disconnecting.\n */\n public setFrameOwner(frameConnectorId: string, owner: string) {\n this.postMessage({\n type: 'setFrameOwner',\n frameConnectorId,\n owner,\n })\n }\n\n /**\n * Update the visual style of an already-open frame's shared content at any\n * time — the same surface styling and companion icon that\n * `OpenFrameOptions` sets at open time, but applied live. Only the fields you\n * pass change; omitted fields keep their current value. Pass an empty string\n * to clear an override back to the host default (e.g. `{ background: '' }`).\n * The host re-renders the surface on this Vitre, on peer Vitres / tableaux\n * showing the frame, and re-propagates the icon to connected companions.\n */\n public setChromeStyle(frameConnectorId: string, style: ChromeStyle) {\n this.postMessage({\n type: 'setChromeStyle',\n frameConnectorId,\n ...style,\n })\n }\n\n public setReducedAudioMode(enabled: boolean) {\n this.postMessage({\n type: 'setReducedAudioMode',\n enabled,\n })\n }\n\n public setFrameSize(frameId: string, size: Size) {\n this.postMessage({\n type: 'setFrameSize',\n frameId,\n size,\n })\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. Resolves with the granted port name\n /// (empty string if denied or cancelled).\n /// - `{ port }` given: the host pre-grants that port and resolves with it,\n /// so a following `navigator.serial.requestPort()` resolves to it with no\n /// picker.\n /// - no argument (or `{}`): the host shows its port-picker and resolves with\n /// the port the user chose (also pre-granted).\n /// Honoured only when the app holds the WebSerial authorization.\n public async requestSerialPortAccess(\n request?: RequestSerialPortAccess,\n ): Promise<string> {\n const requestId = uuid()\n return await this.postRequest<string>(\n { type: 'requestSerialPortAccess', requestId, port: request?.port },\n (msg, resolve, reject) => {\n if (\n msg.type === 'serialPortAccessResult' &&\n msg.requestId === requestId\n ) {\n if (msg.port) {\n resolve(msg.port)\n } else {\n reject(msg.reason ?? 'cancelled')\n }\n }\n },\n )\n }\n\n /// Send an opaque message to the companion-side `CompanionConnector`\n /// for the same `appId`. `target` selects one or all companions\n /// currently connected to this Vitre — `{ kind: 'all' }` broadcasts to\n /// every connected companion, `{ kind: 'one', companionId }` addresses a\n /// single one. The message is forwarded unchanged; the receiving side\n /// gets it as `onMessageFromVitreConnector`.\n public sendMessageToCompanionConnector(\n target: CompanionConnectorTarget,\n message: string,\n fileData?: FileData,\n ) {\n this.postMessage({\n type: 'sendMessageToCompanionConnector',\n target,\n message,\n fileData,\n })\n }\n}\n\ntype PostMessageConnectorApiOut = (\n message: ConnectorApiMessagesOut,\n transfer?: Transferable[],\n) => void\n\nexport async function initializeConnector<T extends Connector>(\n init: (info: HostInformation) => ConnectorOptions,\n createConnector?: new (\n postMessage: (\n message: ConnectorApiMessagesOut,\n transfer?: Transferable[] | undefined,\n ) => void,\n initializeMessage: InitializeConnector,\n options: ConnectorOptions,\n ) => T,\n) {\n return await new Promise<T>((resolve) => {\n const channel = new MessageChannel()\n let mainConnector: T | null = null\n const messageHandler =\n (createPostMessage: (origin: string) => PostMessageConnectorApiOut) =>\n (e: MessageEvent<ConnectorApiMessagesIn>): any => {\n switch (e.data.type) {\n case 'initialize':\n if (mainConnector == null) {\n const initializeMsg = e.data\n const options = init(initializeMsg.hostInfo)\n mainConnector = new (createConnector ?? Connector)(\n createPostMessage(initializeMsg.hostInfo.origin),\n initializeMsg,\n options,\n ) as T\n const w = window as any\n w.mainConnector = mainConnector\n resolve(mainConnector)\n }\n break\n default:\n mainConnector?.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":"Connector.js","sourceRoot":"","sources":["../../Connector/Connector.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,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,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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=\"./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 { isMinVersion } from '../Common/index.js'\nimport type {\n AppId,\n AppMessage,\n ChromeStyle,\n ConnectedMediaDevice,\n Device,\n DeviceFrameReference,\n DeviceFullscreenUpdated,\n DeviceMessageReceived,\n DeviceScalingUpdated,\n Field,\n FileData,\n HostInformation,\n KnockKnock,\n LayoutPosition,\n MessageTarget,\n NotificationButtonClicked,\n NotificationInfo,\n OpenFrameOptions,\n Privacy,\n ReplacedBy,\n RequestSerialPortAccess,\n SendKnockKnock,\n SendMessageTo,\n SendMessageToAll,\n SendToSerialPort,\n Size,\n StateReplaced,\n StatsResponse,\n UpdatedStateEntry,\n UpdateStateEntry,\n VitreSettings,\n VitreSettingsSetter,\n VoiceAction,\n VoiceActionDetection,\n} from '../Common/index.js'\nimport type { Frame } from '../Frame/index.js'\nimport { apiVersion } from '../Version.js'\nimport { normalizeSettingsSchema } from './SettingsSchema.js'\nimport type {\n AppTokenReceivedData,\n ExecuteInFrameResultData,\n CompanionConnectorTarget,\n ExternalMessageReceived,\n ConnectorApiMessagesIn,\n ConnectorApiMessagesOut,\n ConnectorOptions,\n FrameInfo,\n FramePositionUpdated,\n InitializeConnector,\n MediaTrackInfo,\n OpenStreamFrame,\n RootMenuEntry,\n SettingsSchema,\n ShareData,\n ShareStreamOptions,\n ShareStreamTrack,\n ShareTargetOptions,\n} from './Connector.Model.js'\n\ninterface RequestResolver {\n isHandled: (msg: ConnectorApiMessagesIn) => boolean\n}\n\nexport class Connector {\n public onDeviceJoined?: (device: Device) => void\n public onDeviceLeft?: (deviceId: string) => void\n public onDeviceMessageReceived?: (message: DeviceMessageReceived) => void\n public onMenuClicked?: (menuId: string, tag: any, isChecked: boolean) => void\n public onFieldUpdated?: (field: Field) => void\n public onFrameConnectorLoading?: (options: OpenFrameOptions) => void\n public onShareDataReceived?: (shareData: ShareData) => void\n public onShareFileReceived?: (shareData: FileData) => void\n public onFrameLoaded?: (frameConnectorId: string) => void\n public onFrameConnectorLoaded?: (frameConnectorId: string) => void\n public onFrameUnloaded?: (frameConnectorId: string) => void\n public onLocalConnectorMessageReceived?: (\n message: any,\n from?: string,\n fileData?: FileData,\n ) => void\n public onPrivacyChanged?: (privacy: Privacy) => void\n /** @deprecated Use onEmbedMessage */\n public onExtensionMessage?: (extensionMessage: AppMessage) => void\n /** @deprecated Use onEmbedMessage */\n public onAppMessage?: (appMessage: AppMessage) => void\n public onEmbedMessage?: (embedMessage: AppMessage) => void\n public onKnockKnockReceived?: (knockKnock: KnockKnock) => void\n public onPendingDevicesConnectionRequested?: (\n pendingClients: Device[],\n ) => void\n public onSettingsUpdated?: (settings: any) => void\n public onVitreSettingsUpdated?: (settings: VitreSettings) => void\n public onConnectionCodeUpdated?: (companionCode?: string) => void\n public onNotificationDismissed?: (notificationId: string) => void\n public onNotificationButtonClicked?: (\n notificationButton: NotificationButtonClicked,\n ) => void\n public onDevicePrivacyChanged?: (device: Device) => void\n public onFrameZIndexChanged?: (frameInfo: FrameInfo) => 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: ConnectorApiMessagesIn) => void\n public onVoiceActionDetected?: (voiceAction: VoiceActionDetection) => void\n public onDeviceFullscreenUpdated?: (msg: DeviceFullscreenUpdated) => void\n public onDeviceScalingUpdated?: (msg: DeviceScalingUpdated) => void\n public onFramePositionUpdated?: (msg: FramePositionUpdated) => void\n public onStateReplaced?: (\n newState: Record<string, any>,\n oldState: Record<string, any>,\n replacedBy: ReplacedBy,\n delta: UpdatedStateEntry[],\n ) => void\n public onExternalMessageReceived?: (msg: ExternalMessageReceived) => any | Promise<any> | void\n public onAppTokenRefreshed?: (token: string) => void\n public onMediaDevicesChanged?: (devices: ConnectedMediaDevice[]) => void\n /// Called when an already-open shared frame's owner is reassigned via\n /// `setFrameOwner` — INCLUDING a change initiated by another device in the\n /// space (every vitre/companion running this app is notified). The owner\n /// drives the languette colour and (when a Vitre) hosting/survival, and is\n /// what an app should key its per-frame stored state on. `owner` is the new\n /// owner's device id (`HostInformation.devicesInSpace[].id`). Not fired for\n /// the initial open: a frame opened with `OpenFrameOptions.owner` is created\n /// already-owned, so the opener already knows its owner.\n public onFrameOwnerChanged?: (frameConnectorId: string, owner: string) => void\n /// Called when the companion-side `CompanionConnector` for the same\n /// `appId` sent a message via `sendMessageToVitreConnector`. The\n /// `fromCompanionId` identifies which companion sent it so the Vitre\n /// connector can reply targeted-back via `sendMessageToCompanionConnector`.\n public onMessageFromCompanionConnector?: (\n fromCompanionId: string,\n message: string,\n fileData?: FileData,\n ) => void\n /// Called when a companion FRAME of this app sent a message via\n /// `CompanionFrame.sendMessageToVitreConnector` — including a local\n /// companion frame with no paired Vitre frame. `frameConnectorId` is the\n /// companion frame that spoke; `fromCompanionId` is the companion. Reply\n /// targeted-back via `sendMessageToCompanionConnector`.\n public onMessageFromCompanionFrame?: (\n fromCompanionId: string,\n frameConnectorId: string,\n message: string,\n fileData?: FileData,\n ) => void\n /// Called when a companion clicked a menu entry that lives on one of\n /// THIS app's frames' options menu AND was declared with\n /// `availability: 'companion'` (or `'companionAdmin'`). The click never\n /// reaches the Vitre-side UI — it is intercepted on the companion and\n /// routed here so the app can decide what to do (typically: dispatch\n /// the companion's main connector to call `openCompanionFrame` for the\n /// matching frame).\n ///\n /// `frameConnectorId` is the frame whose menu entry was clicked.\n /// `fromCompanionId` is the connection-id of the clicker so the app\n /// can target a targeted reply back. The remaining fields mirror the\n /// regular `onMenuClicked` shape.\n public onFrameMenuClickedOnCompanion?: (\n frameConnectorId: string,\n fromCompanionId: string,\n menuId: string,\n isChecked: boolean,\n tag: any,\n ) => 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\n public appId: string\n public hostInformation: HostInformation\n public openedFrames: FrameInfo[] = []\n public state: Record<string, any> = {}\n public appToken: string | null = null\n private appTokenRefreshTimer: ReturnType<typeof setInterval> | null = null\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`. `put` / `get` /\n * `list` / `onProgress` for heavy binaries (images, PDFs, 3D, …) that\n * must be retrievable by anyone joining the doc, even late. Opinionated\n * but bare — see BlobStore.\n */\n public readonly blobs: BlobStore\n\n /** @deprecated Use `crdt.doc`. The setter forwards to `crdt.attach(doc)`\n * so legacy callers that ever assigned `connector.yjsDoc = myDoc` keep\n * working — without it, getter-only would throw `TypeError: Cannot set\n * property yjsDoc which has only a getter` under strict mode / ESM. */\n get yjsDoc() {\n return this.crdt.doc\n }\n set yjsDoc(doc: Y.Doc) {\n this.crdt.attach(doc)\n }\n\n constructor(\n private readonly postMessage: (\n message: ConnectorApiMessagesOut,\n transfer?: Transferable[],\n ) => void,\n initMessage: InitializeConnector,\n public options: ConnectorOptions,\n ) {\n this.hostInformation = initMessage.hostInfo\n this.appId = initMessage.appId ?? ''\n this.state = initMessage.state ?? {}\n // Mirror the first of `shareTargets` onto the deprecated singular `shareTarget`\n // so older Vitres (which only read `shareTarget`) still get the primary target.\n // New hosts prefer `shareTargets` and ignore the mirrored singular.\n this.options = {\n ...options,\n settingsSchema: normalizeSettingsSchema(options.settingsSchema),\n shareTarget:\n options.shareTarget ??\n (options.shareTargets?.length ? options.shareTargets[0] : undefined),\n }\n this.postMessage({\n type: 'connectorInitialized',\n options: this.options,\n })\n\n // Older Vitres reject unknown message types and fail the whole parse,\n // so never emit `crdt*` toward a host below the supported version. The\n // channel still constructs and works locally; emission is just dropped\n // (graceful degradation — onSynced never fires on old hosts, by design).\n const crdtSupported = isMinVersion(\n this.hostInformation.version,\n MIN_CRDT_HOST_VERSION,\n )\n this.crdt = new CrdtChannel((message, transfer) => {\n // No cast: `ConnectorApiMessagesOut` already includes the four `crdt*`\n // arms (Connector.Model.ts), so the union narrows naturally and TS\n // will flag any drift between the two definitions.\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\n private resolveRequest(msg: ConnectorApiMessagesIn) {\n this.requestResolvers = this.requestResolvers.filter(\n (rr) => !rr.isHandled(msg),\n )\n }\n\n raiseMessage(msg: ConnectorApiMessagesIn) {\n this.resolveRequest(msg)\n\n switch (msg.type) {\n case 'privacyChanged':\n this.hostInformation = {\n ...this.hostInformation,\n device: { ...this.hostInformation.device, privacy: msg.privacy },\n }\n this.onPrivacyChanged?.(msg.privacy)\n break\n case 'deviceJoined':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: [\n ...this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.device.id,\n ),\n msg.device,\n ],\n }\n this.onDeviceJoined?.(msg.device)\n break\n case 'deviceLeft':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.deviceId,\n ),\n }\n this.onDeviceLeft?.(msg.deviceId)\n break\n case 'deviceMessageReceived':\n this.onDeviceMessageReceived?.(msg)\n break\n case 'menuClicked':\n this.onMenuClicked?.(msg.menuId, msg.tag, msg.isChecked)\n break\n case 'fieldUpdated':\n this.onFieldUpdated?.(msg.field)\n break\n case 'frameConnectorLoading':\n this.onFrameConnectorLoading?.(msg.options)\n break\n case 'shareDataReceived':\n this.onShareDataReceived?.(msg.data)\n break\n case 'fileShareDataReceived':\n this.onShareFileReceived?.(msg.data)\n break\n case 'frameLoaded':\n this.openedFrames.push(msg)\n this.onFrameLoaded?.(msg.frameConnectorId)\n break\n case 'frameConnectorLoaded':\n {\n const idx = this.openedFrames.findIndex(\n (f) => f.frameConnectorId === msg.frameConnectorId,\n )\n if (idx >= 0) {\n this.openedFrames[idx] = msg\n }\n this.onFrameConnectorLoaded?.(msg.frameConnectorId)\n }\n break\n case 'frameUnloaded':\n {\n const idx = this.openedFrames.findIndex(\n (f) => f.frameConnectorId === msg.frameConnectorId,\n )\n if (idx >= 0) {\n this.openedFrames.splice(idx, 1)\n }\n this.onFrameUnloaded?.(msg.frameConnectorId)\n }\n break\n case 'localConnectorMessageReceived':\n this.onLocalConnectorMessageReceived?.(msg.data, msg.from, msg.fileData)\n break\n case 'extensionMessage':\n this.onExtensionMessage?.(msg)\n this.onAppMessage?.(msg)\n this.onEmbedMessage?.(msg)\n break\n case 'appMessage':\n this.onAppMessage?.(msg)\n this.onEmbedMessage?.(msg)\n break\n\n case 'knockKnockReceived':\n this.onKnockKnockReceived?.(msg)\n break\n case 'pendingDevicesConnectionRequested':\n this.onPendingDevicesConnectionRequested?.(msg.pendingDevices)\n break\n case 'settingsUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n settings: msg.settings,\n }\n this.onSettingsUpdated?.(msg.settings)\n break\n case 'vitreSettingsUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n space: msg.currentSpace,\n vitreSettings: msg,\n device: {\n ...this.hostInformation.device,\n name: msg.name ?? this.hostInformation.device.name,\n color: msg.color,\n },\n }\n this.onVitreSettingsUpdated?.(msg)\n break\n case 'notificationButtonClicked':\n this.onNotificationButtonClicked?.(msg)\n break\n case 'notificationDismissed':\n this.onNotificationDismissed?.(msg.id)\n break\n case 'devicePrivacyChanged':\n this.hostInformation = {\n ...this.hostInformation,\n devicesInSpace: [\n ...this.hostInformation.devicesInSpace.filter(\n (d) => d.id !== msg.device.id,\n ),\n msg.device,\n ],\n }\n this.onDevicePrivacyChanged?.(msg.device)\n break\n case 'frameZIndexChanged':\n {\n const idx = this.openedFrames.findIndex(\n (f) => f.frameConnectorId === msg.frameConnectorId,\n )\n if (idx >= 0) {\n this.openedFrames[idx] = msg\n }\n this.onFrameZIndexChanged?.(msg)\n }\n break\n\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 'voiceActionDetected':\n this.onVoiceActionDetected?.(msg)\n break\n\n case 'deviceFullscreenUpdated':\n this.onDeviceFullscreenUpdated?.(msg)\n break\n case 'framePositionUpdated':\n this.onFramePositionUpdated?.(msg)\n break\n case 'deviceScalingUpdated':\n if (msg.deviceId === this.hostInformation.device.id) {\n this.hostInformation.device.sendingScaling = msg.sendingScaling\n this.hostInformation.device.orientation = msg.orientation\n this.hostInformation.device.orientationBy = msg.orientationBy\n }\n this.hostInformation.devicesInSpace =\n this.hostInformation.devicesInSpace.map((d) =>\n d.id === msg.deviceId\n ? {\n ...d,\n sendingScaling: msg.sendingScaling,\n orientation: msg.orientation,\n orientationBy: msg.orientationBy,\n }\n : d,\n )\n this.onDeviceScalingUpdated?.(msg)\n break\n case 'connectionCodeUpdated':\n this.hostInformation = {\n ...this.hostInformation,\n companionCode: msg.companionCode,\n }\n this.onConnectionCodeUpdated?.(msg.companionCode)\n break\n case 'stateReplaced':\n this._onStateReplaced(msg)\n break\n case 'externalMessageReceived':\n this._onExternalMessageReceived(msg)\n break\n case 'appTokenReceived':\n // Handled by requestResolvers (postRequest pattern)\n break\n case 'mediaDevicesChanged':\n this.hostInformation = {\n ...this.hostInformation,\n vitreSettings: {\n ...this.hostInformation.vitreSettings,\n availableMediaDevices: msg.devices,\n },\n }\n this.onMediaDevicesChanged?.(msg.devices)\n break\n case '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 'frameOwnerChanged':\n this.onFrameOwnerChanged?.(msg.frameConnectorId, msg.owner)\n break\n case 'messageFromCompanionConnector':\n this.onMessageFromCompanionConnector?.(\n msg.fromCompanionId,\n msg.message,\n msg.fileData,\n )\n break\n case 'messageFromCompanionFrame':\n this.onMessageFromCompanionFrame?.(\n msg.fromCompanionId,\n msg.frameConnectorId,\n msg.message,\n msg.fileData,\n )\n break\n case 'frameMenuClickedOnCompanion':\n this.onFrameMenuClickedOnCompanion?.(\n msg.frameConnectorId,\n msg.fromCompanionId,\n msg.menuId,\n msg.isChecked,\n msg.tag,\n )\n break\n }\n this.onMessageReceived?.(msg)\n }\n\n private _onStateReplaced(msg: StateReplaced) {\n const oldState = this.state\n this.state = msg.state\n this.onStateReplaced?.(this.state, oldState, msg.replacedBy, msg.delta)\n }\n\n private _onExternalMessageReceived(msg: ExternalMessageReceived) {\n if (this.onExternalMessageReceived) {\n const result = this.onExternalMessageReceived(msg)\n\n // If handler returns a value (sync or Promise), automatically send response\n if (result !== undefined && result !== null) {\n const sendResponse = (response: any) => {\n this.postMessage({\n type: 'externalMessageResponse',\n requestId: msg.requestId,\n response,\n })\n }\n\n if (result instanceof Promise || (result && typeof result.then === 'function')) {\n ;(result as Promise<any>).then(sendResponse).catch(() => {\n sendResponse(null)\n })\n } else {\n sendResponse(result)\n }\n }\n }\n }\n\n public async requestAppToken(): Promise<string> {\n const requestId = randomUuid()\n const token = await this.postRequest<string>(\n { type: 'requestAppToken', requestId },\n (msg, resolve, reject) => {\n if (msg.type === 'appTokenReceived' && (msg as AppTokenReceivedData).requestId === requestId) {\n const tokenMsg = msg as AppTokenReceivedData\n if (tokenMsg.token) {\n resolve(tokenMsg.token)\n } else {\n reject(tokenMsg.error ?? 'Failed to get app token')\n }\n }\n },\n )\n this.appToken = token\n return token\n }\n\n /**\n * Run JavaScript inside a (cross-origin) child iframe this app embeds in its\n * frame.html, and resolve with the JSON-parsed return value.\n *\n * The iframe must carry a `name` attribute (e.g. `<iframe name=\"my-target\">`)\n * matching `frameName`. `code` runs as a function body — use `return <expr>` to\n * produce a value (any JSON-serializable value round-trips; `undefined` → `null`).\n *\n * Requires the `injectScriptIntoFrame` app authorization and the native (CEF)\n * host (rejects on a web host). The host also restricts the target to this app's\n * own frame subtree.\n */\n public async executeInFrame<T = unknown>(frameName: string, code: string): Promise<T> {\n const requestId = randomUuid()\n const json = await this.postRequest<string | undefined>(\n { type: 'executeInFrame', requestId, frameName, code },\n (msg, resolve, reject) => {\n if (\n msg.type === 'executeInFrameResult' &&\n (msg as ExecuteInFrameResultData).requestId === requestId\n ) {\n const resultMsg = msg as ExecuteInFrameResultData\n if (resultMsg.error) {\n reject(resultMsg.error)\n } else {\n resolve(resultMsg.result)\n }\n }\n },\n )\n return (json === undefined ? undefined : JSON.parse(json)) as T\n }\n\n public startAppTokenRefresh(intervalMs = 3600000): void {\n this.stopAppTokenRefresh()\n // Request initial token\n this.requestAppToken().catch(() => {})\n // Refresh periodically\n this.appTokenRefreshTimer = setInterval(async () => {\n try {\n const token = await this.requestAppToken()\n this.onAppTokenRefreshed?.(token)\n } catch (_error) {\n // Will retry on next interval\n }\n }, intervalMs)\n }\n\n public stopAppTokenRefresh(): void {\n if (this.appTokenRefreshTimer) {\n clearInterval(this.appTokenRefreshTimer)\n this.appTokenRefreshTimer = null\n }\n }\n\n /** Release the resources owned by this connector. Stops the app-token\n * refresh timer and tears the CRDT channel down (unbinds doc/awareness\n * listeners, destroys the default Y.Doc + Awareness). Safe to call\n * multiple times. */\n public destroy(): void {\n this.stopAppTokenRefresh()\n this.crdt.destroy()\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 private requestResolvers: RequestResolver[] = []\n private async postRequest<Data>(\n data: ConnectorApiMessagesOut,\n handler: (\n msg: ConnectorApiMessagesIn,\n resolve: (data: Data) => void,\n reject: (error: string) => void,\n ) => void,\n transfer?: Transferable[],\n ) {\n return await new Promise<Data>((resolve, reject) => {\n let isHandled = false\n const handleAndResolve = (data: Data) => {\n isHandled = true\n resolve(data)\n }\n\n const handleAndReject = (error: any) => {\n isHandled = true\n reject(error)\n }\n\n const resolver = {\n isHandled: (msg: ConnectorApiMessagesIn) => {\n try {\n handler(msg, handleAndResolve, handleAndReject)\n } catch (error) {\n handleAndReject(error)\n }\n return isHandled\n },\n }\n this.requestResolvers.push(resolver)\n this.postMessage(data, transfer)\n })\n }\n\n public async 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 async requestEnumerateDevices() {\n const requestId = randomUuid()\n return await this.postRequest<ConnectedMediaDevice[]>(\n { type: 'enumerateMediaDevices', requestId },\n async (msg, resolve, _reject) => {\n if (\n msg.type === 'enumerateMediaDevicesCompleted' &&\n msg.requestId === requestId\n ) {\n const localDevices = await navigator.mediaDevices.enumerateDevices()\n\n const cleanName = (name: string) => {\n if (!name) return name\n return name.replace(/\\s*\\([0-9a-f]{4}:[0-9a-f]{4}\\)\\s*$/gi, '')\n }\n\n const mappedDevices = msg.devices.map((d) => {\n const localDevice = localDevices.find(\n (ld) =>\n cleanName(ld.label) === cleanName(d.label) &&\n ld.kind === d.kind,\n )\n if (localDevice) {\n return {\n ...d,\n deviceId: localDevice.deviceId,\n groupId: localDevice.groupId,\n vitreId: d.deviceId,\n vitreGroupId: d.groupId,\n }\n }\n return d\n })\n\n resolve(mappedDevices)\n }\n },\n )\n }\n\n public async requestOpenStream(\n streamId: string,\n constraints: MediaStreamConstraints,\n ) {\n const requestId = randomUuid()\n return await this.postRequest<MediaTrackInfo[]>(\n { type: 'openStream', requestId, streamId, constraints },\n (msg, resolve, reject) => {\n if (msg.type === 'openStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null || msg.tracks == null) {\n reject(msg.error ?? 'openStream failed')\n } else {\n resolve(msg.tracks)\n }\n }\n },\n )\n }\n\n private async convertConstraintsToVitreConstraints(\n constraints: MediaStreamConstraints,\n ): Promise<MediaStreamConstraints> {\n const vitreDevices = await this.requestEnumerateDevices()\n\n const videoConstraint = (typeof constraints.video === 'object' &&\n constraints.video) as MediaTrackConstraints | null\n const audioConstraint = (typeof constraints.audio === 'object' &&\n constraints.audio) as MediaTrackConstraints | null\n const videoDeviceId = videoConstraint?.deviceId\n const audioDeviceId = audioConstraint?.deviceId\n\n const mappedVideoDevice = vitreDevices.find(\n (d) => d.deviceId === videoDeviceId && d.kind === 'videoinput',\n ) as any\n const mappedVideoDeviceId =\n mappedVideoDevice?.vitreId ?? mappedVideoDevice?.deviceId\n const mappedAudioDevice = vitreDevices.find(\n (d) => d.deviceId === audioDeviceId && d.kind === 'audioinput',\n ) as any\n const mappedAudioDeviceId =\n mappedAudioDevice?.vitreId ?? mappedAudioDevice?.deviceId\n\n let mappedConstraint = videoDeviceId\n ? {\n ...constraints,\n video: { ...videoConstraint, deviceId: mappedVideoDeviceId },\n }\n : constraints\n mappedConstraint = audioDeviceId\n ? {\n ...mappedConstraint,\n audio: { ...audioConstraint, deviceId: mappedAudioDeviceId },\n }\n : mappedConstraint\n return mappedConstraint\n }\n\n public async requestOpenStreamFrame(\n openStreamFrame: Omit<OpenStreamFrame, 'requestId'>,\n ) {\n const requestId = randomUuid()\n\n const constraints = openStreamFrame.constraints\n ? await this.convertConstraintsToVitreConstraints(\n openStreamFrame.constraints,\n )\n : undefined\n\n return await this.postRequest<MediaTrackInfo[]>(\n { type: 'openStreamFrame', requestId, ...openStreamFrame, constraints },\n (msg, resolve, reject) => {\n if (\n msg.type === 'openStreamFrameCompleted' &&\n msg.requestId === requestId\n ) {\n if (msg.error != null || msg.tracks == null) {\n reject(msg.error ?? 'openStream failed')\n } else {\n resolve(msg.tracks)\n }\n }\n },\n )\n }\n\n /**\n * Whether {@link shareStream} is available in this runtime. Requires the\n * MediaStreamTrack Insertable Streams API (Chromium-only) and the app being\n * served same-site as the Vitre host (so the transferred stream survives the\n * iframe boundary zero-copy). Apps should feature-detect before offering a\n * share action.\n */\n public canShareStream(): boolean {\n return typeof MediaStreamTrackProcessor !== 'undefined'\n }\n\n private toShareTracks(stream: MediaStream): {\n tracks: ShareStreamTrack[]\n transfer: Transferable[]\n } {\n const tracks: ShareStreamTrack[] = []\n const transfer: Transferable[] = []\n for (const track of stream.getTracks()) {\n const { readable } = new MediaStreamTrackProcessor({ track })\n tracks.push({\n kind: track.kind as ShareStreamTrack['kind'],\n readable,\n settings: track.getSettings(),\n })\n transfer.push(readable)\n }\n return { tracks, transfer }\n }\n\n /**\n * Share a camera/microphone (or any) `MediaStream` the app controls TO the\n * Vitre, which forwards it to the other peers in the space like a regular\n * shared stream. The stream is handed over zero-copy (no re-encode) via the\n * breakout box; the app keeps ownership of its tracks and can stop them\n * independently.\n *\n * Returns a `sharedStreamId` to pass to {@link replaceShareStream} /\n * {@link stopShareStream}. Throws if {@link canShareStream} is false.\n */\n public async shareStream(\n stream: MediaStream,\n options?: ShareStreamOptions,\n ): Promise<string> {\n if (!this.canShareStream()) {\n throw new Error(\n 'shareStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)',\n )\n }\n const sharedStreamId = randomUuid()\n const requestId = randomUuid()\n const { tracks, transfer } = this.toShareTracks(stream)\n await this.postRequest<void>(\n { type: 'shareStream', requestId, sharedStreamId, options, tracks },\n (msg, resolve, reject) => {\n if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n return sharedStreamId\n }\n\n /**\n * Swap the source of an open share WITHOUT closing it (e.g. switch camera,\n * or camera→screen). Peers keep receiving on the same slot with no\n * renegotiation blip. `sharedStreamId` is the value returned by\n * {@link shareStream}.\n */\n public async replaceShareStream(\n sharedStreamId: string,\n streamOrTrack: MediaStream | MediaStreamTrack,\n ): Promise<void> {\n if (!this.canShareStream()) {\n throw new Error('replaceShareStream is not supported in this runtime')\n }\n const stream =\n streamOrTrack instanceof MediaStream\n ? streamOrTrack\n : new MediaStream([streamOrTrack])\n const requestId = 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 (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {\n if (msg.error != null) reject(msg.error)\n else resolve(undefined)\n }\n },\n transfer,\n )\n }\n\n /** Stop an app share. `sharedStreamId` is the value returned by {@link shareStream}. */\n public stopShareStream(sharedStreamId: string): void {\n this.postMessage({ type: 'stopShareStream', sharedStreamId })\n }\n\n public getFrame(frameConnectorId: string): Window | null {\n try {\n const frameId = `${this.appId}|${frameConnectorId}`\n return (window.parent.frames as any)[frameId]\n } catch (_error) {\n return null\n }\n }\n\n public getFrameConnector(frameConnector: string): Frame | null {\n const frame = this.getFrame(frameConnector) as any\n return frame?.frameConnector as Frame\n }\n\n public async openFrame(frameOptions: OpenFrameOptions) {\n return await this.postRequest<FrameInfo>(\n {\n type: 'openFrame',\n options: frameOptions,\n },\n (msg, resolve, _reject) => {\n if (\n msg.type === 'frameConnectorLoaded' &&\n msg.frameConnectorId === frameOptions.frameConnectorId\n ) {\n resolve(msg)\n }\n },\n )\n }\n\n public async openLocalFrame(frameOptions: OpenFrameOptions) {\n return await this.postRequest<FrameInfo>(\n {\n type: 'openLocalFrame',\n options: frameOptions,\n },\n (msg, resolve, _reject) => {\n if (\n msg.type === 'frameConnectorLoaded' &&\n msg.frameConnectorId === frameOptions.frameConnectorId\n ) {\n resolve(msg)\n }\n },\n )\n }\n\n public sendMessageTo(message: SendMessageTo) {\n this.postMessage({ type: 'sendMessageTo', ...message })\n }\n\n public sendMessageToAll(message: SendMessageToAll) {\n this.postMessage({\n type: 'sendMessageToAll',\n ...message,\n })\n }\n\n public sendKnockKnock(message: SendKnockKnock) {\n this.postMessage({ type: 'sendKnockKnock', ...message })\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 setMenu(menu: RootMenuEntry[]) {\n this.postMessage({\n type: 'setRootMenu',\n menu,\n })\n }\n\n /**\n * @deprecated Use sendAppMessage on vitre v18\n */\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. The owner drives the languette\n * colour/info and the content appears already-owned on every vitre. When\n * omitted the share is owned by the opener (default).\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 (`HostInformation.devicesInSpace[].id`) to\n * attribute the resulting shared content to. See {@link shareData}.\n */\n public shareFile(fileData: FileData, targetAppId: AppId, owner?: string) {\n this.postMessage({\n type: 'shareFile',\n fileData,\n targetAppId,\n owner,\n })\n }\n\n public saveSettings(settings: any) {\n this.postMessage({\n type: 'saveSettings',\n settings,\n })\n }\n\n public changeTeamSpace(space: string) {\n this.postMessage({\n type: 'changeTeamSpace',\n space,\n })\n }\n\n public changeTeamSpaceGuest(space: string, teamDomain: string) {\n this.postMessage({\n type: 'changeTeamSpaceGuest',\n space,\n teamDomain,\n })\n }\n\n public showNotification(notification: NotificationInfo) {\n this.postMessage({\n ...notification,\n type: 'showNotification',\n })\n }\n\n public hideNotification(notificationId: string) {\n this.postMessage({\n id: notificationId,\n type: 'hideNotification',\n })\n }\n\n public changePrivacy(privacy: Privacy) {\n this.postMessage({\n type: 'changePrivacy',\n privacy,\n })\n }\n\n public trackEvent(name: string, properties?: Record<string, any>) {\n this.postMessage({\n type: 'trackEvent',\n name,\n properties,\n })\n }\n\n public startTrackEvent(name: string) {\n this.postMessage({\n type: 'startTrackEvent',\n name,\n })\n }\n\n public stopTrackEvent(name: string, properties?: Record<string, any>) {\n this.postMessage({\n type: 'stopTrackEvent',\n name,\n properties,\n })\n }\n\n public setSettingsSchema(schema: SettingsSchema) {\n const normalized = { ...schema, schema: normalizeSettingsSchema(schema.schema) }\n this.options = {\n ...this.options,\n settingsSchema: normalized.schema,\n settingsSchemaUI: normalized.schemaUI,\n }\n this.postMessage({\n type: 'setSettingsSchema',\n ...normalized,\n })\n }\n\n /**\n * Update the app's share target at any time. The new share target replaces\n * the one provided at initialization (ConnectorOptions.shareTarget) and is\n * applied immediately by the host. Can be called repeatedly.\n *\n * @deprecated Use `setShareTargets` to advertise one or more share targets.\n */\n public setShareTarget(shareTarget: ShareTargetOptions) {\n this.options = {\n ...this.options,\n shareTarget,\n shareTargets: [shareTarget],\n }\n this.postMessage({\n type: 'setShareTarget',\n shareTarget,\n })\n }\n\n /**\n * Update the app's share targets at any time. The new array replaces the ones\n * provided at initialization (ConnectorOptions.shareTargets) and is applied\n * immediately by the host. Can be called repeatedly.\n */\n public setShareTargets(shareTargets: ShareTargetOptions[]) {\n this.options = {\n ...this.options,\n shareTargets,\n // Mirror the first target onto the deprecated singular for older Vitres.\n shareTarget: shareTargets[0],\n }\n // Emit the legacy singular first so older Vitres (which only handle\n // `setShareTarget`) still get the primary target at runtime, then the full\n // array which new hosts apply (and which supersedes the singular there).\n if (shareTargets[0]) {\n this.postMessage({\n type: 'setShareTarget',\n shareTarget: shareTargets[0],\n })\n }\n this.postMessage({\n type: 'setShareTargets',\n shareTargets,\n })\n }\n\n public setVoiceActions(actions: VoiceAction[]) {\n this.postMessage({\n type: 'setVoiceActions',\n actions,\n })\n }\n\n public setFramePosition(frameConnectorId: string, position: LayoutPosition) {\n this.postMessage({\n type: 'setFramePosition',\n frameConnectorId,\n position,\n })\n }\n\n public closeFrame(frameConnectorId: string) {\n this.postMessage({\n type: 'closeFrame',\n frameConnectorId,\n })\n }\n\n /**\n * Reassign the owner of an already-opened shared frame. `owner` is a\n * device id from `HostInformation.devicesInSpace[].id`. The new owner\n * drives the languette colour, and when it is a Vitre it takes over\n * hosting the frame so it survives the opener disconnecting.\n */\n public setFrameOwner(frameConnectorId: string, owner: string) {\n this.postMessage({\n type: 'setFrameOwner',\n frameConnectorId,\n owner,\n })\n }\n\n /**\n * Update the visual style of an already-open frame's shared content at any\n * time — the same surface styling and companion icon that\n * `OpenFrameOptions` sets at open time, but applied live. Only the fields you\n * pass change; omitted fields keep their current value. Pass an empty string\n * to clear an override back to the host default (e.g. `{ background: '' }`).\n * The host re-renders the surface on this Vitre, on peer Vitres / tableaux\n * showing the frame, and re-propagates the icon to connected companions.\n */\n public setChromeStyle(frameConnectorId: string, style: ChromeStyle) {\n this.postMessage({\n type: 'setChromeStyle',\n frameConnectorId,\n ...style,\n })\n }\n\n public setReducedAudioMode(enabled: boolean) {\n this.postMessage({\n type: 'setReducedAudioMode',\n enabled,\n })\n }\n\n public setFrameSize(frameId: string, size: Size) {\n this.postMessage({\n type: 'setFrameSize',\n frameId,\n size,\n })\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. Resolves with the granted port name\n /// (empty string if denied or cancelled).\n /// - `{ port }` given: the host pre-grants that port and resolves with it,\n /// so a following `navigator.serial.requestPort()` resolves to it with no\n /// picker.\n /// - no argument (or `{}`): the host shows its port-picker and resolves with\n /// the port the user chose (also pre-granted).\n /// Honoured only when the app holds the WebSerial authorization.\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 /// Send an opaque message to the companion-side `CompanionConnector`\n /// for the same `appId`. `target` selects one or all companions\n /// currently connected to this Vitre — `{ kind: 'all' }` broadcasts to\n /// every connected companion, `{ kind: 'one', companionId }` addresses a\n /// single one. The message is forwarded unchanged; the receiving side\n /// gets it as `onMessageFromVitreConnector`.\n public sendMessageToCompanionConnector(\n target: CompanionConnectorTarget,\n message: string,\n fileData?: FileData,\n ) {\n this.postMessage({\n type: 'sendMessageToCompanionConnector',\n target,\n message,\n fileData,\n })\n }\n}\n\ntype PostMessageConnectorApiOut = (\n message: ConnectorApiMessagesOut,\n transfer?: Transferable[],\n) => void\n\nexport async function initializeConnector<T extends Connector>(\n init: (info: HostInformation) => ConnectorOptions,\n createConnector?: new (\n postMessage: (\n message: ConnectorApiMessagesOut,\n transfer?: Transferable[] | undefined,\n ) => void,\n initializeMessage: InitializeConnector,\n options: ConnectorOptions,\n ) => T,\n) {\n return await new Promise<T>((resolve) => {\n const channel = new MessageChannel()\n let mainConnector: T | null = null\n const messageHandler =\n (createPostMessage: (origin: string) => PostMessageConnectorApiOut) =>\n (e: MessageEvent<ConnectorApiMessagesIn>): any => {\n switch (e.data.type) {\n case 'initialize':\n if (mainConnector == null) {\n const initializeMsg = e.data\n const options = init(initializeMsg.hostInfo)\n mainConnector = new (createConnector ?? Connector)(\n createPostMessage(initializeMsg.hostInfo.origin),\n initializeMsg,\n options,\n ) as T\n const w = window as any\n w.mainConnector = mainConnector\n resolve(mainConnector)\n }\n break\n default:\n mainConnector?.raiseMessage(e.data)\n break\n }\n }\n\n channel.port1.onmessage = messageHandler(\n (_origin: string) => (message, transfer?: Transferable[]) => {\n channel.port1.postMessage(message, transfer ?? [])\n },\n )\n\n window.parent.postMessage(\n {\n type: 'connectorInitializationRequest',\n version: apiVersion,\n },\n '*',\n [channel.port2],\n )\n\n window.addEventListener(\n 'message',\n messageHandler(\n (origin: string) => (message, transfer?: Transferable[]) => {\n window.parent.postMessage(message, origin, transfer)\n },\n ),\n false,\n )\n })\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Apps written in plain JS get no help from the `SettingsSchemaProperties` type. The one mistake seen
3
+ * in the wild — a full JSON schema where the fields map is expected — used to
4
+ * crash the settings form of every vitre loading the app, and hosts already
5
+ * deployed do not defend against it: unwrap it here, loudly.
6
+ */
7
+ export declare function normalizeSettingsSchema<T>(schema: T): T;
@@ -0,0 +1,19 @@
1
+ const isPlainObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
2
+ /**
3
+ * Apps written in plain JS get no help from the `SettingsSchemaProperties` type. The one mistake seen
4
+ * in the wild — a full JSON schema where the fields map is expected — used to
5
+ * crash the settings form of every vitre loading the app, and hosts already
6
+ * deployed do not defend against it: unwrap it here, loudly.
7
+ */
8
+ export function normalizeSettingsSchema(schema) {
9
+ let result = schema;
10
+ while (isPlainObject(result) &&
11
+ typeof result.type === 'string' &&
12
+ isPlainObject(result.properties)) {
13
+ console.error("[lavitre/apps] settingsSchema must be a map of fields ({ city: { type: 'string' } }), " +
14
+ "not a full JSON schema ({ type: 'object', properties: { … } }). Using its `properties`.");
15
+ result = result.properties;
16
+ }
17
+ return result;
18
+ }
19
+ //# sourceMappingURL=SettingsSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SettingsSchema.js","sourceRoot":"","sources":["../../Connector/SettingsSchema.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,CAAC,KAAc,EAAoC,EAAE,CACzE,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAEtE;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAI,MAAS;IAClD,IAAI,MAAM,GAAY,MAAM,CAAA;IAC5B,OACE,aAAa,CAAC,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC/B,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,EAChC,CAAC;QACD,OAAO,CAAC,KAAK,CACX,wFAAwF;YACtF,yFAAyF,CAC5F,CAAA;QACD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAA;IAC5B,CAAC;IACD,OAAO,MAAW,CAAA;AACpB,CAAC","sourcesContent":["const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value)\n\n/**\n * Apps written in plain JS get no help from the `SettingsSchemaProperties` type. The one mistake seen\n * in the wild — a full JSON schema where the fields map is expected — used to\n * crash the settings form of every vitre loading the app, and hosts already\n * deployed do not defend against it: unwrap it here, loudly.\n */\nexport function normalizeSettingsSchema<T>(schema: T): T {\n let result: unknown = schema\n while (\n isPlainObject(result) &&\n typeof result.type === 'string' &&\n isPlainObject(result.properties)\n ) {\n console.error(\n \"[lavitre/apps] settingsSchema must be a map of fields ({ city: { type: 'string' } }), \" +\n \"not a full JSON schema ({ type: 'object', properties: { … } }). Using its `properties`.\",\n )\n result = result.properties\n }\n return result as T\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { AiInboundMessage, AiOutboundMessage, AppMessage, BluetoothFromApp, BluetoothToApp, BorderOptions, ChangePrivacy, ChangeTeamSpace, ChangeTeamSpaceGuest, CompanionFramePeerJoined, CompanionFramePeerLeft, CompanionFramePeersUpdated, ConnectedMediaDevice, ConnectionCodeUpdated, Device, DeviceFrameReference, DeviceFullscreenUpdated, DeviceJoined, DeviceLeft, DeviceMessageReceived, DevicePrivacyChanged, DeviceScalingUpdated, DisconnectGuests, EnumerateLoadedFrames, EnumerateLoadedFramesCompleted, EventTelemetry, FieldUpdated, FileData, CompanionInformation, FrameTouchMode, GetStats, HideNotification, HostInformation, I18nMap, Interaction, KnockKnock, LayoutPosition, LocalConnectorMessageReceived, MenuClicked, MenuEntry, NotificationButtonClicked, NotificationDismissed, NotificationInfo, PendingDevicesInfo, PositionUpdated, PrivacyChanged, Rect, RequestSerialPortAccess, SerialPortAccessResult, RequestStreamSizeUpdate, ResizeMode, SaveSettings, SendKnockKnock, SendMessageTo, SendMessageToAll, SendToLocalFrame, SendToSerialPort, SetReducedAudioMode, SettingsUpdated, SetVisibility, ShareDataRequest, ShareFileRequest, Size, StartEventTelemetry, StateReplaced, StatsResponse, StreamCapture, UpdateState, VideoContentHint, ViewMode, VisibilityChanged, VitreSettings, VitreSettingsSetter, VoiceAction, VoiceActionDetection } from '../Common/index.js';
1
+ import type { AiInboundMessage, AiOutboundMessage, AppMessage, BluetoothFromApp, BluetoothToApp, BorderOptions, ChangePrivacy, ChangeTeamSpace, ChangeTeamSpaceGuest, CompanionFramePeerJoined, CompanionFramePeerLeft, CompanionFramePeersUpdated, ConnectedMediaDevice, ConnectionCodeUpdated, Device, DeviceFrameReference, DeviceFullscreenUpdated, DeviceJoined, DeviceLeft, DeviceMessageReceived, DevicePrivacyChanged, DeviceScalingUpdated, DisconnectGuests, EnumerateLoadedFrames, EnumerateLoadedFramesCompleted, EventTelemetry, FieldUpdated, FileData, CompanionInformation, FrameTouchMode, GetStats, HideNotification, HostInformation, I18nMap, Interaction, KnockKnock, LayoutPosition, LocalConnectorMessageReceived, MenuClicked, MenuEntry, NotificationButtonClicked, NotificationDismissed, NotificationInfo, PendingDevicesInfo, PositionUpdated, SafeAreaInsets, SafeAreaInsetsUpdated, PrivacyChanged, Rect, RequestSerialPortAccess, SerialPortAccessResult, RequestStreamSizeUpdate, ResizeMode, SaveSettings, SendKnockKnock, SendMessageTo, SendMessageToAll, SendToLocalFrame, SendToSerialPort, SetReducedAudioMode, SettingsUpdated, SetVisibility, ShareDataRequest, ShareFileRequest, Size, StartEventTelemetry, StateReplaced, StatsResponse, StreamCapture, UpdateState, VideoContentHint, ViewMode, VisibilityChanged, VitreSettings, VitreSettingsSetter, VoiceAction, VoiceActionDetection } from '../Common/index.js';
2
2
  import type { MediaTrackInfo, ReplaceShareStream, ShareStream, ShareStreamCompleted, ShareStreamTrack, StopShareStream } from '../Connector/Connector.Model.js';
3
3
  export type SharedStreamAvailable = {
4
4
  streamId: string;
@@ -70,6 +70,13 @@ export type InitializeFrame = {
70
70
  isBorderless: boolean;
71
71
  state?: Record<string, any>;
72
72
  position: Rect;
73
+ /**
74
+ * Insets the frame must keep its controls clear of, when the host runs it
75
+ * edge-to-edge (`CompanionFrameOption.edgeToEdge`); later changes arrive
76
+ * as `safeAreaInsetsUpdated`. Absent from hosts before 1.51 — read as all
77
+ * zero. Added 1.51.
78
+ */
79
+ safeAreaInsets?: SafeAreaInsets;
73
80
  };
74
81
  export type FrameDefaultMenuCategory = {
75
82
  type: 'defaultMenu';
@@ -293,6 +300,8 @@ export type FrameApiMessagesIn = ({
293
300
  } & VisibilityChanged) | ({
294
301
  type: 'positionUpdated';
295
302
  } & PositionUpdated) | ({
303
+ type: 'safeAreaInsetsUpdated';
304
+ } & SafeAreaInsetsUpdated) | ({
296
305
  type: 'deviceScalingUpdated';
297
306
  } & DeviceScalingUpdated) | ({
298
307
  type: 'updateFrameName';