@lavitre/apps 1.49.0 → 1.49.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -111,11 +111,3 @@ frame.crdt.onSynced(cb) // fires once when the initial doc snaps
111
111
  ## Versioning
112
112
 
113
113
  The package ships compiled ESM + `.d.ts` (`pnpm build` → `dist/`); import paths (`@lavitre/apps/<Module>`) are unchanged. `Version.ts` carries `apiVersion`, refreshed at build time by `replaceVersion.js`. The host enforces a minimum SDK version on initialize — bumping a breaking change requires a major-version bump in `package.json`.
114
-
115
- ## Releasing
116
-
117
- 1. Bump `version` in `package.json` and run `node ./replaceVersion.js` (also run by `pnpm prebuild`) so `Version.ts` matches. Commit both files.
118
- 2. Merge to `main`.
119
- 3. Tag the merge commit and push the tag: `git tag v1.50.0 && git push origin v1.50.0`.
120
-
121
- GitLab push-mirrors `main` and tags to `github.com/lavitre/apps`. The `publish.yml` workflow there checks that the tag matches `package.json`, type-checks, and runs `npm publish` with trusted publishing (OIDC, no token stored anywhere). A version already on npmjs is skipped, never overwritten. The GitLab `build` job remains the pre-merge gate; nothing on gitlab.ucaya.com publishes anymore.
@@ -0,0 +1 @@
1
+ export declare const randomUuid: () => string;
@@ -0,0 +1,17 @@
1
+ // RFC 4122 version 4 UUID, without the `uuid` package.
2
+ //
3
+ // `crypto.randomUUID()` is the native equivalent of `uuid.v4()`, but it only
4
+ // exists in secure contexts (HTTPS, localhost). `crypto.getRandomValues()` is
5
+ // available everywhere, so we fall back to assembling the v4 layout from 16
6
+ // random bytes: version nibble `4` in byte 6, variant `10xx` in byte 8.
7
+ export const randomUuid = () => {
8
+ const c = globalThis.crypto;
9
+ if (typeof c.randomUUID === 'function')
10
+ return c.randomUUID();
11
+ const bytes = c.getRandomValues(new Uint8Array(16));
12
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
13
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
14
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
15
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
16
+ };
17
+ //# sourceMappingURL=Uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Uuid.js","sourceRoot":"","sources":["../../Common/Uuid.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,wEAAwE;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,GAAW,EAAE;IACrC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAA;IAC3B,IAAI,OAAO,CAAC,CAAC,UAAU,KAAK,UAAU;QAAE,OAAO,CAAC,CAAC,UAAU,EAAE,CAAA;IAC7D,MAAM,KAAK,GAAG,CAAC,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAA;IACnD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IACnC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IACnC,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC9E,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;AAC5G,CAAC,CAAA","sourcesContent":["// RFC 4122 version 4 UUID, without the `uuid` package.\n//\n// `crypto.randomUUID()` is the native equivalent of `uuid.v4()`, but it only\n// exists in secure contexts (HTTPS, localhost). `crypto.getRandomValues()` is\n// available everywhere, so we fall back to assembling the v4 layout from 16\n// random bytes: version nibble `4` in byte 6, variant `10xx` in byte 8.\nexport const randomUuid = (): string => {\n const c = globalThis.crypto\n if (typeof c.randomUUID === 'function') return c.randomUUID()\n const bytes = c.getRandomValues(new Uint8Array(16))\n bytes[6] = (bytes[6] & 0x0f) | 0x40\n bytes[8] = (bytes[8] & 0x3f) | 0x80\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('')\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`\n}\n"]}
@@ -1,5 +1,5 @@
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';
@@ -665,7 +665,7 @@ export class Connector {
665
665
  }
666
666
  }
667
667
  async requestAppToken() {
668
- const requestId = uuid();
668
+ const requestId = randomUuid();
669
669
  const token = await this.postRequest({ type: 'requestAppToken', requestId }, (msg, resolve, reject) => {
670
670
  if (msg.type === 'appTokenReceived' && msg.requestId === requestId) {
671
671
  const tokenMsg = msg;
@@ -693,7 +693,7 @@ export class Connector {
693
693
  * own frame subtree.
694
694
  */
695
695
  async executeInFrame(frameName, code) {
696
- const requestId = uuid();
696
+ const requestId = randomUuid();
697
697
  const json = await this.postRequest({ type: 'executeInFrame', requestId, frameName, code }, (msg, resolve, reject) => {
698
698
  if (msg.type === 'executeInFrameResult' &&
699
699
  msg.requestId === requestId) {
@@ -787,7 +787,7 @@ export class Connector {
787
787
  });
788
788
  }
789
789
  async requestStats() {
790
- const requestId = uuid();
790
+ const requestId = randomUuid();
791
791
  return await this.postRequest({ type: 'getStats', requestId }, (msg, resolve, _reject) => {
792
792
  if (msg.type === 'statsResponse' && msg.requestId === requestId) {
793
793
  resolve(msg);
@@ -795,7 +795,7 @@ export class Connector {
795
795
  });
796
796
  }
797
797
  async requestEnumerateDevices() {
798
- const requestId = uuid();
798
+ const requestId = randomUuid();
799
799
  return await this.postRequest({ type: 'enumerateMediaDevices', requestId }, async (msg, resolve, _reject) => {
800
800
  if (msg.type === 'enumerateMediaDevicesCompleted' &&
801
801
  msg.requestId === requestId) {
@@ -824,7 +824,7 @@ export class Connector {
824
824
  });
825
825
  }
826
826
  async requestOpenStream(streamId, constraints) {
827
- const requestId = uuid();
827
+ const requestId = randomUuid();
828
828
  return await this.postRequest({ type: 'openStream', requestId, streamId, constraints }, (msg, resolve, reject) => {
829
829
  if (msg.type === 'openStreamCompleted' && msg.requestId === requestId) {
830
830
  if (msg.error != null || msg.tracks == null) {
@@ -863,7 +863,7 @@ export class Connector {
863
863
  return mappedConstraint;
864
864
  }
865
865
  async requestOpenStreamFrame(openStreamFrame) {
866
- const requestId = uuid();
866
+ const requestId = randomUuid();
867
867
  const constraints = openStreamFrame.constraints
868
868
  ? await this.convertConstraintsToVitreConstraints(openStreamFrame.constraints)
869
869
  : undefined;
@@ -917,8 +917,8 @@ export class Connector {
917
917
  if (!this.canShareStream()) {
918
918
  throw new Error('shareStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)');
919
919
  }
920
- const sharedStreamId = uuid();
921
- const requestId = uuid();
920
+ const sharedStreamId = randomUuid();
921
+ const requestId = randomUuid();
922
922
  const { tracks, transfer } = this.toShareTracks(stream);
923
923
  await this.postRequest({ type: 'shareStream', requestId, sharedStreamId, options, tracks }, (msg, resolve, reject) => {
924
924
  if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {
@@ -943,7 +943,7 @@ export class Connector {
943
943
  const stream = streamOrTrack instanceof MediaStream
944
944
  ? streamOrTrack
945
945
  : new MediaStream([streamOrTrack]);
946
- const requestId = uuid();
946
+ const requestId = randomUuid();
947
947
  const { tracks, transfer } = this.toShareTracks(stream);
948
948
  await this.postRequest({ type: 'replaceShareStream', requestId, sharedStreamId, tracks }, (msg, resolve, reject) => {
949
949
  if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {
@@ -1273,7 +1273,7 @@ export class Connector {
1273
1273
  /// the port the user chose (also pre-granted).
1274
1274
  /// Honoured only when the app holds the WebSerial authorization.
1275
1275
  async requestSerialPortAccess(request) {
1276
- const requestId = uuid();
1276
+ const requestId = randomUuid();
1277
1277
  return await this.postRequest({ type: 'requestSerialPortAccess', requestId, port: request?.port }, (msg, resolve, reject) => {
1278
1278
  if (msg.type === 'serialPortAccessResult' &&
1279
1279
  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,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AA0B1C,MAAM,OAAO,SAAS;IAsIpB;;;2EAGuE;IACvE,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;IACtB,CAAC;IACD,IAAI,MAAM,CAAC,GAAU;QACnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACvB,C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ams.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,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAsCjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AA0B1C,MAAM,OAAO,SAAS;IAsIpB;;;2EAGuE;IACvE,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;IACtB,CAAC;IACD,IAAI,MAAM,CAAC,GAAU;QACnB,IAAI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AA;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 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 = 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 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 = 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"]}
@@ -1,5 +1,5 @@
1
1
  /// <reference path="../Connector/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 { AiChannel, MIN_AI_HOST_VERSION } from '../Common/AiChannel.js';
@@ -871,7 +871,7 @@ export class Frame {
871
871
  * Resolves with the new track infos so the frame can rebuild its menu.
872
872
  */
873
873
  async requestReplaceStream(constraints) {
874
- const requestId = uuid();
874
+ const requestId = randomUuid();
875
875
  return await this.postRequest({ type: 'replaceFrameStream', requestId, constraints }, (msg, resolve, reject) => {
876
876
  if (msg.type === 'replaceFrameStreamCompleted' &&
877
877
  msg.requestId === requestId) {
@@ -968,7 +968,7 @@ export class Frame {
968
968
  /// With `{ port }` the host pre-grants it; with no argument the host shows
969
969
  /// its port-picker and resolves with the chosen port.
970
970
  async requestSerialPortAccess(request) {
971
- const requestId = uuid();
971
+ const requestId = randomUuid();
972
972
  return await this.postRequest({ type: 'requestSerialPortAccess', requestId, port: request?.port }, (msg, resolve, reject) => {
973
973
  if (msg.type === 'serialPortAccessResult' &&
974
974
  msg.requestId === requestId) {
@@ -1036,8 +1036,8 @@ export class Frame {
1036
1036
  if (!this.canShareStream()) {
1037
1037
  throw new Error('shareStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)');
1038
1038
  }
1039
- const sharedStreamId = uuid();
1040
- const requestId = uuid();
1039
+ const sharedStreamId = randomUuid();
1040
+ const requestId = randomUuid();
1041
1041
  const { tracks, transfer } = this.toShareTracks(stream);
1042
1042
  await this.postRequest({ type: 'shareStream', requestId, sharedStreamId, options, tracks }, (msg, resolve, reject) => {
1043
1043
  if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {
@@ -1061,7 +1061,7 @@ export class Frame {
1061
1061
  const stream = streamOrTrack instanceof MediaStream
1062
1062
  ? streamOrTrack
1063
1063
  : new MediaStream([streamOrTrack]);
1064
- const requestId = uuid();
1064
+ const requestId = randomUuid();
1065
1065
  const { tracks, transfer } = this.toShareTracks(stream);
1066
1066
  await this.postRequest({ type: 'replaceShareStream', requestId, sharedStreamId, tracks }, (msg, resolve, reject) => {
1067
1067
  if (msg.type === 'shareStreamCompleted' && msg.requestId === requestId) {
@@ -1103,7 +1103,7 @@ export class Frame {
1103
1103
  if (!this.canShareStream()) {
1104
1104
  throw new Error('attachStream is not supported in this runtime (requires Chromium MediaStreamTrackProcessor and same-site hosting)');
1105
1105
  }
1106
- const requestId = uuid();
1106
+ const requestId = randomUuid();
1107
1107
  const { tracks, transfer } = this.toShareTracks(stream);
1108
1108
  await this.postRequest({
1109
1109
  type: 'attachStream',
@@ -1145,7 +1145,7 @@ export class Frame {
1145
1145
  * {@link IceServerConfig}.
1146
1146
  */
1147
1147
  async getIceServers() {
1148
- const requestId = uuid();
1148
+ const requestId = randomUuid();
1149
1149
  return await this.postRequest({ type: 'getIceServers', requestId }, (msg, resolve, _reject) => {
1150
1150
  if (msg.type === 'iceServersResponse' && msg.requestId === requestId) {
1151
1151
  resolve(msg.iceServers ?? []);
@@ -1179,7 +1179,7 @@ export class Frame {
1179
1179
  });
1180
1180
  }
1181
1181
  async requestEnumerateLocalFrames() {
1182
- const requestId = uuid();
1182
+ const requestId = randomUuid();
1183
1183
  return await this.postRequest({ type: 'enumerateLoadedFrames', requestId }, (msg, resolve, _reject) => {
1184
1184
  if (msg.type === 'enumerateLoadedFramesCompleted' &&
1185
1185
  msg.requestId === requestId) {
@@ -1329,7 +1329,7 @@ export class Frame {
1329
1329
  });
1330
1330
  }
1331
1331
  async requestStreamCapture() {
1332
- const requestId = uuid();
1332
+ const requestId = randomUuid();
1333
1333
  return await this.postRequest({ type: 'streamFrameCaptureRequest', requestId }, (msg, resolve, reject) => {
1334
1334
  if (msg.type === 'streamFrameCapturedResponse' &&
1335
1335
  msg.requestId === requestId) {
@@ -1343,7 +1343,7 @@ export class Frame {
1343
1343
  });
1344
1344
  }
1345
1345
  async requestStats() {
1346
- const requestId = uuid();
1346
+ const requestId = randomUuid();
1347
1347
  return await this.postRequest({ type: 'getStats', requestId }, (msg, resolve, _reject) => {
1348
1348
  if (msg.type === 'statsResponse' && msg.requestId === requestId) {
1349
1349
  resolve(msg);