@lavitre/apps 1.53.0 → 1.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +180 -0
  2. package/dist/Common/AppSettings.d.ts +34 -0
  3. package/dist/Common/AppSettings.js +35 -0
  4. package/dist/Common/AppSettings.js.map +1 -0
  5. package/dist/Common/Common.Model.d.ts +271 -0
  6. package/dist/Common/Common.Model.js.map +1 -1
  7. package/dist/Common/PrivateStorage.d.ts +249 -0
  8. package/dist/Common/PrivateStorage.js +158 -0
  9. package/dist/Common/PrivateStorage.js.map +1 -0
  10. package/dist/Common/PublicStorage.d.ts +140 -0
  11. package/dist/Common/PublicStorage.js +88 -0
  12. package/dist/Common/PublicStorage.js.map +1 -0
  13. package/dist/Common/index.d.ts +3 -0
  14. package/dist/Common/index.js +3 -0
  15. package/dist/Common/index.js.map +1 -1
  16. package/dist/CompanionConnector/CompanionConnector.Model.d.ts +11 -3
  17. package/dist/CompanionConnector/CompanionConnector.Model.js.map +1 -1
  18. package/dist/CompanionConnector/CompanionConnector.d.ts +14 -0
  19. package/dist/CompanionConnector/CompanionConnector.js +122 -0
  20. package/dist/CompanionConnector/CompanionConnector.js.map +1 -1
  21. package/dist/CompanionFrame/CompanionFrame.d.ts +13 -2
  22. package/dist/CompanionFrame/CompanionFrame.js.map +1 -1
  23. package/dist/Connector/Connector.Model.d.ts +29 -1
  24. package/dist/Connector/Connector.Model.js.map +1 -1
  25. package/dist/Connector/Connector.d.ts +60 -1
  26. package/dist/Connector/Connector.js +280 -1
  27. package/dist/Connector/Connector.js.map +1 -1
  28. package/dist/Frame/Frame.Model.d.ts +36 -2
  29. package/dist/Frame/Frame.Model.js.map +1 -1
  30. package/dist/Frame/Frame.d.ts +68 -3
  31. package/dist/Frame/Frame.js +326 -3
  32. package/dist/Frame/Frame.js.map +1 -1
  33. package/dist/Frame/SharedStreamPeer.d.ts +16 -0
  34. package/dist/Frame/SharedStreamPeer.js +74 -0
  35. package/dist/Frame/SharedStreamPeer.js.map +1 -0
  36. package/dist/Version.d.ts +1 -1
  37. package/dist/Version.js +1 -1
  38. package/dist/Version.js.map +1 -1
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CompanionConnector.js","sourceRoot":"","sources":["../../CompanionConnector/CompanionConnector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAW1C,sEAAsE;AACtE,wEAAwE;AACxE,2EAA2E;AAC3E,2BAA2B;AAC3B,MAAM,OAAO,kBAAkB;IA8B7B,YACmB,WAGR,EACT,WAAyC,EACzC,OAAkC;QALlC;;;;mBAAiB,WAAW;WAGnB;QAjCX,oEAAoE;QACpE,qEAAqE;QACrE,4BAA4B;QACrB;;;;;WAAyC;QAChD,kEAAkE;QAClE,wEAAwE;QACjE;;;;;WAA0C;QAC1C;;;;;WAAa;QACb;;;;;WAAkC;QAEzC,qDAAqD;QAC9C;;;;;WAAsE;QACtE;;;;;WAAkD;QAClD;;;;;WAAoD;QAC3D,wEAAwE;QACxE,sEAAsE;QACtE,wEAAwE;QACxE,oCAAoC;QAC7B;;;;;WAAuE;QAC9E,oEAAoE;QACpE,qEAAqE;QACrE,kEAAkE;QAClE,uCAAuC;QAChC;;;;;WAGE;QACF;;;;;WAAkE;QAUvE,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAA;QAC3C,IAAI,CAAC,oBAAoB,GAAG,WAAW,CAAC,aAAa,CAAA;QACrD,sEAAsE;QACtE,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,WAAW,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YAC9B,OAAO,CAAC,IAAI,CACV,wDAAwD;gBACtD,4DAA4D;gBAC5D,wBAAwB,CAC3B,CAAA;QACH,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE,CAAA;QACpC,IAAI,CAAC,OAAO,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CAC1E,KAAK,aAAa,CAChB,CAAC,EACD,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,QAAyB,EAAE,EAAE;YACzD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;QACtD,CAAC,EACD,IAAI,CACL,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC,CAAA;QAE9D,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,CAAA;QAEzD,iEAAiE;QACjE,kEAAkE;QAClE,gCAAgC;QAChC,IAAI,eAAe,GAAyC,UAAU,CACpE,GAAG,EAAE;YACH,eAAe,GAAG,IAAI,CAAA;YACtB,IAAI,SAAS,IAAI,IAAI,IAAI,YAAY;gBAAE,OAAM;YAC7C,OAAO,EAAE,CAAA;YACT,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,qDAAqD;gBACnD,GAAG,qBAAqB,IAAI,CAC/B,CAAA;YACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACzB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,EACD,qBAAqB,CACtB,CAAA;QAED,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB;YACE,IAAI,EAAE,yCAAyC;YAC/C,OAAO,EAAE,UAAU;SACpB,EACD,iBAAiB,EACjB,CAAC,OAAO,CAAC,KAAK,CAAC,CAChB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import type { FileData, OpenFrameOptions } from '../Common/index.js'\nimport type { RootMenuEntry } from '../Connector/Connector.Model.js'\nimport { apiVersion } from '../Version.js'\nimport type {\n CompanionConnectorApiMessagesIn,\n CompanionConnectorApiMessagesOut,\n CompanionConnectorOptions,\n CompanionHostInformation,\n CompanionInformation,\n CompanionInitializeConnector,\n SetMenuOptions,\n} from './CompanionConnector.Model.js'\n\n/// Runtime instance handed to a companion connector once the host has\n/// finished the `initialize` handshake. The shape is intentionally much\n/// smaller than the Vitre `Connector` — anything not in this class doesn't\n/// apply on the companion.\nexport class CompanionConnector {\n /// Identity of the Vitre this companion connector is hosted against\n /// (the host). Read-only — the host pushes updates by reinitializing\n /// the connector if needed.\n public hostInformation: CompanionHostInformation\n /// This companion's own identity and runtime context (name, user,\n /// language, origin, version). Distinct from `hostInformation` (Vitre).\n public companionInformation: CompanionInformation\n public appId: string\n public options: CompanionConnectorOptions\n\n // Callbacks — host → connector events. All optional.\n public onMenuClicked?: (menuId: string, tag: any, isChecked: boolean) => void\n public onFrameLoaded?: (frameConnectorId: string) => void\n public onFrameUnloaded?: (frameConnectorId: string) => void\n /// Called when a shared frame's owner was (re)assigned (at open time or\n /// post-hoc, including by another device). `owner` is the new owner's\n /// device id (`HostInformation.devicesInSpace[].id`). Mirrors the Vitre\n /// `Connector.onFrameOwnerChanged`.\n public onFrameOwnerChanged?: (frameConnectorId: string, owner: string) => void\n /// Called when the matching Vitre `Connector` (same `appId`) sent a\n /// message via `sendMessageToCompanionConnector`. The companion side\n /// does not know which Vitre user sent the message — it is always\n /// \"the\" Vitre connector for that app.\n public onMessageFromVitreConnector?: (\n message: string,\n fileData?: FileData,\n ) => void\n public onMessageReceived?: (msg: CompanionConnectorApiMessagesIn) => void\n\n constructor(\n private readonly postMessage: (\n message: CompanionConnectorApiMessagesOut,\n transfer?: Transferable[],\n ) => void,\n initMessage: CompanionInitializeConnector,\n options: CompanionConnectorOptions,\n ) {\n this.hostInformation = initMessage.hostInfo\n this.companionInformation = initMessage.companionInfo\n // `appId` is optional — a host may legitimately omit it for a generic\n // connector — but message routing keys on it, so warn when the empty\n // fallback is hit to surface a misconfigured host.\n if (initMessage.appId == null) {\n console.warn(\n '[CompanionConnector] initialize message has no appId; ' +\n 'falling back to an empty string — Vitre-connector message ' +\n 'routing will not match',\n )\n }\n this.appId = initMessage.appId ?? ''\n this.options = options\n this.postMessage({\n type: 'connectorInitialized',\n options,\n })\n }\n\n /// Handler called by `initializeCompanionConnector` for every inbound\n /// message after the initial `initialize`. Exposed for testing and for\n /// hosts that drive the connector through a side channel.\n raiseMessage(msg: CompanionConnectorApiMessagesIn) {\n switch (msg.type) {\n case 'menuClicked':\n this.onMenuClicked?.(msg.menuId, msg.tag, msg.isChecked)\n break\n case 'frameLoaded':\n this.onFrameLoaded?.(msg.frameConnectorId)\n break\n case 'frameUnloaded':\n this.onFrameUnloaded?.(msg.frameConnectorId)\n break\n case 'frameOwnerChanged':\n this.onFrameOwnerChanged?.(msg.frameConnectorId, msg.owner)\n break\n case 'messageFromVitreConnector':\n this.onMessageFromVitreConnector?.(msg.message, msg.fileData)\n break\n // `initialize` is handled by the bootstrap, not here. Return early\n // so the public `onMessageReceived` callback is NOT invoked with it\n // — the SDK documents `initialize` as not delivered through this\n // handler, and falling through would break that contract.\n case 'initialize':\n return\n }\n this.onMessageReceived?.(msg)\n }\n\n /// Publish this companion connector's menu for the app.\n ///\n /// By default (`mode: 'replace'`, or no options) the menu fully replaces\n /// what the Vitre-side `Connector` published for this app on the\n /// companion. Pass `{ mode: 'append' }` to instead *add* these entries\n /// after the Vitre menu without hiding it — useful for contributing\n /// companion-only entries on top of a Vitre-managed menu.\n public setMenu(menu: RootMenuEntry[], options?: SetMenuOptions) {\n this.postMessage({ type: 'setRootMenu', menu, mode: options?.mode })\n }\n\n public openFrame(options: OpenFrameOptions) {\n this.postMessage({ type: 'openFrame', options })\n }\n\n public closeFrame(frameConnectorId: string) {\n this.postMessage({ type: 'closeFrame', frameConnectorId })\n }\n\n /// Reassign the owner of an already-opened shared frame. `owner` is a\n /// device id from `HostInformation.devicesInSpace[].id`. Drives the\n /// languette colour and, when the owner is a Vitre, hosting transfer so\n /// the frame survives the opener disconnecting.\n public setFrameOwner(frameConnectorId: string, owner: string) {\n this.postMessage({ type: 'setFrameOwner', frameConnectorId, owner })\n }\n\n /// Open (or focus) the paired frame full-page on this companion. The\n /// host treats this as a navigation event: any current SubPage\n /// (camera-share, another frame, etc.) is closed in favour of the new\n /// frame, mirroring the behaviour when a Vitre-driven open triggers\n /// `autoOpen` on the main page. If the Vitre side is reachable the\n /// host also announces the open to it so a paired Vitre frame mounts.\n ///\n /// `frameConnectorId` MUST match the paired Vitre frame's id so both\n /// sides bind to the same frame (per-frame messages + yjs subdoc relay\n /// rely on this).\n public openCompanionFrame(\n frameConnectorId: string,\n options: Omit<OpenFrameOptions, 'frameConnectorId'>,\n ) {\n this.postMessage({\n type: 'openCompanionFrame',\n frameConnectorId,\n options,\n })\n }\n\n /// Send an opaque message to the matching Vitre-side `Connector`. The\n /// payload is forwarded unchanged. There is no targeted addressing —\n /// the message goes to \"the\" Vitre connector for this app.\n public sendMessageToVitreConnector(message: string, fileData?: FileData) {\n this.postMessage({\n type: 'sendMessageToVitreConnector',\n message,\n fileData,\n })\n }\n}\n\ntype PostMessageOut = (\n message: CompanionConnectorApiMessagesOut,\n transfer?: Transferable[],\n) => void\n\n/// Hard cap on the pre-`initialize` queue. A host that floods messages\n/// before/while `initialize` is in flight (or one that never sends it)\n/// must not grow this buffer without bound. On overflow we drop the\n/// oldest queued message and warn once.\nconst MAX_PENDING_MESSAGES = 200\n\n/// Client-side bail-out: if `initialize` never arrives (host crash,\n/// protocol mismatch, dropped postMessage) the outer Promise rejects\n/// after this delay instead of dangling forever.\nconst INITIALIZE_TIMEOUT_MS = 30_000\n\n/// Bootstrap a companion connector. Mirrors `initializeConnector` from\n/// `../Connector/Connector.ts`: posts a request to the parent window,\n/// waits for the host's `initialize`, then resolves with a ready instance.\n///\n/// `buildOptions` is invoked once when the host pushes `initialize`. It\n/// returns the connector's declared name, optional icon, and optional\n/// initial menu. The returned options are echoed back to the host inside\n/// `connectorInitialized`.\n///\n/// Two overloads: when `createConnector` is supplied the resolved\n/// instance is the caller's `T extends CompanionConnector`; when it is\n/// omitted the resolved instance is a plain `CompanionConnector`. This\n/// keeps the return type sound — the omitted-factory path genuinely\n/// builds a base `CompanionConnector`, never a `T`.\nexport async function initializeCompanionConnector<\n T extends CompanionConnector,\n>(\n buildOptions: (\n host: CompanionHostInformation,\n ) => CompanionConnectorOptions | Promise<CompanionConnectorOptions>,\n createConnector: new (\n postMessage: PostMessageOut,\n initMessage: CompanionInitializeConnector,\n options: CompanionConnectorOptions,\n ) => T,\n): Promise<T>\nexport async function initializeCompanionConnector(\n buildOptions: (\n host: CompanionHostInformation,\n ) => CompanionConnectorOptions | Promise<CompanionConnectorOptions>,\n): Promise<CompanionConnector>\nexport async function initializeCompanionConnector<\n T extends CompanionConnector,\n>(\n buildOptions: (\n host: CompanionHostInformation,\n ) => CompanionConnectorOptions | Promise<CompanionConnectorOptions>,\n createConnector?: new (\n postMessage: PostMessageOut,\n initMessage: CompanionInitializeConnector,\n options: CompanionConnectorOptions,\n ) => T,\n): Promise<T | CompanionConnector> {\n return await new Promise<T | CompanionConnector>((resolve, reject) => {\n const channel = new MessageChannel()\n let connector: T | CompanionConnector | null = null\n // Set synchronously the moment the first `initialize` arrives so a\n // second one delivered between the await and the assignment below\n // is ignored instead of constructing a second instance.\n let initializing = false\n // Trusted origin learned from the first initialize message. Until\n // it is set, the window listener only accepts messages whose\n // `source === window.parent`. After it is set, the channel port is\n // the only ingress and the window listener is detached.\n let trustedOrigin: string | null = null\n // Whether overflow on `pendingMessages` has already been warned about,\n // so a flood produces a single warning rather than one per drop.\n let pendingOverflowWarned = false\n // Messages received before `connector` is constructed are queued\n // here and flushed in arrival order once construction finishes.\n const pendingMessages: CompanionConnectorApiMessagesIn[] = []\n\n // Best-effort guess of the parent origin so we don't transfer the\n // MessagePort with `targetOrigin: '*'`. `document.referrer` is the\n // URL of the page that loaded this iframe (the parent in our setup\n // since CompanionConnector iframes are always direct children of\n // the companion host). Falls back to '*' only if the referrer is\n // empty (Referrer-Policy: no-referrer or sandbox).\n const parentOriginGuess = (() => {\n try {\n if (document.referrer) return new URL(document.referrer).origin\n } catch {\n // ignore — referrer wasn't a valid URL\n }\n return '*'\n })()\n\n // Detach the spoofable surface only: the window listener and the\n // no-initialize timeout. Used on the SUCCESS path, where `channel.port1`\n // MUST stay open with its `onmessage` handler installed — it is the\n // connector's live ingress (host → connector events) and the egress\n // captured by the `postMessage` closure (connector → host). Closing it\n // here would silently sever every subsequent `setMenu` / `openFrame` /\n // `closeFrame` / `sendMessageToVitreConnector` and inbound\n // `menuClicked` / `frameLoaded` / `messageFromVitreConnector`.\n const cleanupListeners = () => {\n window.removeEventListener('message', windowListener, false)\n if (initializeTimer != null) {\n clearTimeout(initializeTimer)\n initializeTimer = null\n }\n }\n\n // Full teardown: also tear down the channel port. Used on the timeout /\n // failure / reject paths only, where no connector was constructed (or the\n // outer Promise has already rejected), so the port has no live consumer\n // and must not dangle.\n const cleanup = () => {\n cleanupListeners()\n channel.port1.onmessage = null\n channel.port1.close()\n }\n\n const handleMessage = async (\n e: MessageEvent<CompanionConnectorApiMessagesIn>,\n createPostMessage: (origin: string) => PostMessageOut,\n fromWindow: boolean,\n ) => {\n // Guard against malformed inbound payloads (null/undefined/primitive\n // `e.data`) before touching `.type`, so a single bad postMessage\n // can't crash the switch / surface as an unhandled rejection.\n if (!e.data || typeof e.data !== 'object') return\n\n // Origin / source validation for messages arriving via the window\n // listener. The channel port is implicitly trusted (only the host\n // has the matching port2). The `e.source === window.parent` guard\n // stays active for the lifetime of the window listener — during the\n // `await buildOptions` window the listener is still attached, so the\n // source check (which a forging same-origin frame cannot satisfy)\n // must keep applying alongside the origin check.\n if (fromWindow) {\n if (e.source !== window.parent) return\n if (trustedOrigin != null && e.origin !== trustedOrigin) return\n }\n\n switch (e.data.type) {\n case 'initialize':\n if (initializing || connector != null) {\n console.warn(\n '[CompanionConnector] ignoring duplicate initialize message',\n )\n break\n }\n initializing = true\n try {\n const initMsg = e.data\n // Trust the browser-asserted origin (`e.origin`), not the\n // payload-supplied `companionInfo.origin` which the sender\n // controls and could mis-declare. The origin posting these\n // messages is the companion runtime, so the companion-scoped\n // `companionInfo.origin` is the relevant claim (the Vitre\n // `hostInfo` has no origin). On the channel-port path\n // `e.origin` is empty/meaningless, so fall back to the payload.\n const browserOrigin = fromWindow ? e.origin : ''\n if (\n fromWindow &&\n browserOrigin &&\n initMsg.companionInfo.origin &&\n initMsg.companionInfo.origin !== browserOrigin\n ) {\n console.warn(\n '[CompanionConnector] companionInfo.origin does not match ' +\n 'the browser-asserted parent origin; trusting the latter',\n {\n claimed: initMsg.companionInfo.origin,\n actual: browserOrigin,\n },\n )\n }\n trustedOrigin = browserOrigin || initMsg.companionInfo.origin\n const options = await buildOptions(initMsg.hostInfo)\n connector = new (createConnector ?? CompanionConnector)(\n createPostMessage(trustedOrigin),\n initMsg,\n options,\n )\n // Non-enumerable so it doesn't show up in iteration / JSON of\n // `window`, while keeping parity with the Vitre `Connector`\n // which sets a `mainConnector` global for the same reason\n // (host-side debugging hook).\n Object.defineProperty(window, 'companionConnector', {\n value: connector,\n enumerable: false,\n configurable: true,\n writable: true,\n })\n for (const queued of pendingMessages) {\n connector.raiseMessage(queued)\n }\n pendingMessages.length = 0\n // Once the MessageChannel is established and the connector is\n // built, drop the window listener and the timeout — port1 is\n // the only legitimate ingress from here on, and detaching\n // removes the spoofable surface. Keep port1 OPEN: it is the\n // connector's live ingress/egress for the rest of its lifetime.\n cleanupListeners()\n resolve(connector)\n } catch (err) {\n // Initialization failed. Reject the outer Promise so the caller\n // learns about it (instead of dangling as an unhandled\n // rejection), and tear everything down. Retries are NOT\n // supported: the outer Promise has already settled, so a later\n // `initialize` could only wire up `window.companionConnector`\n // while the awaited handle stays rejected — a silent\n // inconsistent state. Keeping `initializing` true makes any\n // subsequent `initialize` ignored as a duplicate, and `cleanup()`\n // detaches the listener, port, and timer.\n console.error('[CompanionConnector] initialize failed', err)\n cleanup()\n reject(err)\n }\n break\n default:\n if (connector != null) {\n connector.raiseMessage(e.data)\n } else {\n // Cap the pre-init queue: drop the oldest on overflow so a\n // misbehaving host can't grow it without bound. Warn once.\n if (pendingMessages.length >= MAX_PENDING_MESSAGES) {\n pendingMessages.shift()\n if (!pendingOverflowWarned) {\n pendingOverflowWarned = true\n console.warn(\n '[CompanionConnector] pending-message queue exceeded ' +\n `${MAX_PENDING_MESSAGES} before initialize; dropping oldest`,\n )\n }\n }\n pendingMessages.push(e.data)\n }\n break\n }\n }\n\n channel.port1.onmessage = (e) =>\n void handleMessage(\n e,\n (_origin: string) => (message, transfer?: Transferable[]) => {\n channel.port1.postMessage(message, transfer ?? [])\n },\n false,\n ).catch((err) => console.error('[CompanionConnector]', err))\n\n const windowListener = (e: MessageEvent<CompanionConnectorApiMessagesIn>) =>\n void handleMessage(\n e,\n (origin: string) => (message, transfer?: Transferable[]) => {\n window.parent.postMessage(message, origin, transfer)\n },\n true,\n ).catch((err) => console.error('[CompanionConnector]', err))\n\n window.addEventListener('message', windowListener, false)\n\n // Bail out if the host never sends `initialize` (crash, protocol\n // mismatch, dropped message). Detach everything and reject so the\n // caller doesn't await forever.\n let initializeTimer: ReturnType<typeof setTimeout> | null = setTimeout(\n () => {\n initializeTimer = null\n if (connector != null || initializing) return\n cleanup()\n const err = new Error(\n `[CompanionConnector] no initialize received within ` +\n `${INITIALIZE_TIMEOUT_MS}ms`,\n )\n console.warn(err.message)\n reject(err)\n },\n INITIALIZE_TIMEOUT_MS,\n )\n\n window.parent.postMessage(\n {\n type: 'companionConnectorInitializationRequest',\n version: apiVersion,\n },\n parentOriginGuess,\n [channel.port2],\n )\n })\n}\n"]}
1
+ {"version":3,"file":"CompanionConnector.js","sourceRoot":"","sources":["../../CompanionConnector/CompanionConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,6BAA6B,CAAA;AAIpC,OAAO,EAAE,UAAU,EAAE,MAAM,e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MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,EACD,qBAAqB,CACtB,CAAA;QAED,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB;YACE,IAAI,EAAE,yCAAyC;YAC/C,OAAO,EAAE,UAAU;SACpB,EACD,iBAAiB,EACjB,CAAC,OAAO,CAAC,KAAK,CAAC,CAChB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { randomUuid } from '../Common/Uuid.js'\nimport type { FileData, OpenFrameOptions } from '../Common/index.js'\nimport {\n PrivateStorageError,\n PRIVATE_STORAGE_TIMEOUT_MS,\n PRIVATE_STORAGE_GET_TIMEOUT_MS,\n validateLinkExpiresIn,\n privateFileExpiryField,\n} from '../Common/PrivateStorage.js'\nimport type { PrivateStorageReadApi } from '../Common/PrivateStorage.js'\nimport type { PrivateFileLink, PrivateStorageListResult } from '../Common/Common.Model.js'\nimport type { RootMenuEntry } from '../Connector/Connector.Model.js'\nimport { apiVersion } from '../Version.js'\nimport type {\n CompanionConnectorApiMessagesIn,\n CompanionConnectorApiMessagesOut,\n CompanionConnectorOptions,\n CompanionHostInformation,\n CompanionInformation,\n CompanionInitializeConnector,\n SetMenuOptions,\n} from './CompanionConnector.Model.js'\n\ninterface RequestResolver {\n isHandled: (msg: CompanionConnectorApiMessagesIn) => boolean\n}\n\n/// Runtime instance handed to a companion connector once the host has\n/// finished the `initialize` handshake. The shape is intentionally much\n/// smaller than the Vitre `Connector` — anything not in this class doesn't\n/// apply on the companion.\nexport class CompanionConnector {\n /// Identity of the Vitre this companion connector is hosted against\n /// (the host). Read-only — the host pushes updates by reinitializing\n /// the connector if needed.\n public hostInformation: CompanionHostInformation\n /// This companion's own identity and runtime context (name, user,\n /// language, origin, version). Distinct from `hostInformation` (Vitre).\n public companionInformation: CompanionInformation\n public appId: string\n public options: CompanionConnectorOptions\n\n // Callbacks — host → connector events. All optional.\n public onMenuClicked?: (menuId: string, tag: any, isChecked: boolean) => void\n public onFrameLoaded?: (frameConnectorId: string) => void\n public onFrameUnloaded?: (frameConnectorId: string) => void\n /// Called when a shared frame's owner was (re)assigned (at open time or\n /// post-hoc, including by another device). `owner` is the new owner's\n /// device id (`HostInformation.devicesInSpace[].id`). Mirrors the Vitre\n /// `Connector.onFrameOwnerChanged`.\n public onFrameOwnerChanged?: (frameConnectorId: string, owner: string) => void\n /// Called when the matching Vitre `Connector` (same `appId`) sent a\n /// message via `sendMessageToCompanionConnector`. The companion side\n /// does not know which Vitre user sent the message — it is always\n /// \"the\" Vitre connector for that app.\n public onMessageFromVitreConnector?: (\n message: string,\n fileData?: FileData,\n ) => void\n public onMessageReceived?: (msg: CompanionConnectorApiMessagesIn) => void\n\n /**\n * Read-only private storage — `list`/`get`/`getLink` only. The companion\n * connects to a single Vitre's team, so scoping is the same as on the\n * Vitre side (`'app'` default, `'shared'`). Writes stay vitre-only: a\n * Vitre host that DOES support private storage still answers a\n * `putPrivateFile`/`deletePrivateFile` from a companion with\n * `error: 'unsupported'` — which is moot here since this type doesn't\n * even expose `put`/`delete`. See the README \"Private storage\" section.\n */\n public readonly privateStorage: PrivateStorageReadApi = {\n list: async (prefix, scope = 'app') => {\n const requestId = randomUuid()\n return await this.postRequest<PrivateStorageListResult>(\n { type: 'listPrivateFiles', requestId, scope, prefix },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok) resolve({ scope, files: msg.files ?? [] })\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n get: async (path, scope = 'app') => {\n const requestId = randomUuid()\n return await this.postRequest<{ data: ArrayBuffer; contentType: string }>(\n { type: 'getPrivateFile', requestId, scope, path },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok && msg.data) resolve({ data: msg.data, contentType: msg.contentType ?? '' })\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_GET_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n getLink: async (path, options) => {\n validateLinkExpiresIn(options?.expiresIn)\n const scope = options?.scope ?? 'app'\n const requestId = randomUuid()\n return await this.postRequest<PrivateFileLink>(\n {\n type: 'getPrivateFileLink',\n requestId,\n scope,\n path,\n ...privateFileExpiryField(options?.expiresIn),\n },\n (msg, resolve, reject) => {\n if (msg.type === 'privateStorageResponse' && msg.requestId === requestId) {\n if (msg.ok && msg.link) resolve(msg.link)\n else reject(new PrivateStorageError(msg.error ?? 'failed'))\n }\n },\n undefined,\n { ms: PRIVATE_STORAGE_TIMEOUT_MS, onTimeout: () => new PrivateStorageError('unsupported') },\n )\n },\n }\n\n constructor(\n private readonly postMessage: (\n message: CompanionConnectorApiMessagesOut,\n transfer?: Transferable[],\n ) => void,\n initMessage: CompanionInitializeConnector,\n options: CompanionConnectorOptions,\n ) {\n this.hostInformation = initMessage.hostInfo\n this.companionInformation = initMessage.companionInfo\n // `appId` is optional — a host may legitimately omit it for a generic\n // connector — but message routing keys on it, so warn when the empty\n // fallback is hit to surface a misconfigured host.\n if (initMessage.appId == null) {\n console.warn(\n '[CompanionConnector] initialize message has no appId; ' +\n 'falling back to an empty string — Vitre-connector message ' +\n 'routing will not match',\n )\n }\n this.appId = initMessage.appId ?? ''\n this.options = options\n this.postMessage({\n type: 'connectorInitialized',\n options,\n })\n }\n\n /// Pending `postRequest` resolvers, matched by `requestId` inside each\n /// resolver's own `isHandled` closure — same request/response correlation\n /// pattern as the Vitre `Connector`/`Frame` (see `postRequest` below).\n private requestResolvers: RequestResolver[] = []\n\n private resolveRequest(msg: CompanionConnectorApiMessagesIn) {\n this.requestResolvers = this.requestResolvers.filter((rr) => !rr.isHandled(msg))\n }\n\n /// Handler called by `initializeCompanionConnector` for every inbound\n /// message after the initial `initialize`. Exposed for testing and for\n /// hosts that drive the connector through a side channel.\n raiseMessage(msg: CompanionConnectorApiMessagesIn) {\n this.resolveRequest(msg)\n\n switch (msg.type) {\n case 'menuClicked':\n this.onMenuClicked?.(msg.menuId, msg.tag, msg.isChecked)\n break\n case 'frameLoaded':\n this.onFrameLoaded?.(msg.frameConnectorId)\n break\n case 'frameUnloaded':\n this.onFrameUnloaded?.(msg.frameConnectorId)\n break\n case 'frameOwnerChanged':\n this.onFrameOwnerChanged?.(msg.frameConnectorId, msg.owner)\n break\n case 'messageFromVitreConnector':\n this.onMessageFromVitreConnector?.(msg.message, msg.fileData)\n break\n case 'privateStorageResponse':\n // Handled by requestResolvers (postRequest pattern, see above)\n break\n // `initialize` is handled by the bootstrap, not here. Return early\n // so the public `onMessageReceived` callback is NOT invoked with it\n // — the SDK documents `initialize` as not delivered through this\n // handler, and falling through would break that contract.\n case 'initialize':\n return\n }\n this.onMessageReceived?.(msg)\n }\n\n /// Publish this companion connector's menu for the app.\n ///\n /// By default (`mode: 'replace'`, or no options) the menu fully replaces\n /// what the Vitre-side `Connector` published for this app on the\n /// companion. Pass `{ mode: 'append' }` to instead *add* these entries\n /// after the Vitre menu without hiding it — useful for contributing\n /// companion-only entries on top of a Vitre-managed menu.\n public setMenu(menu: RootMenuEntry[], options?: SetMenuOptions) {\n this.postMessage({ type: 'setRootMenu', menu, mode: options?.mode })\n }\n\n public openFrame(options: OpenFrameOptions) {\n this.postMessage({ type: 'openFrame', options })\n }\n\n public closeFrame(frameConnectorId: string) {\n this.postMessage({ type: 'closeFrame', frameConnectorId })\n }\n\n /// Reassign the owner of an already-opened shared frame. `owner` is a\n /// device id from `HostInformation.devicesInSpace[].id`. Drives the\n /// languette colour and, when the owner is a Vitre, hosting transfer so\n /// the frame survives the opener disconnecting.\n public setFrameOwner(frameConnectorId: string, owner: string) {\n this.postMessage({ type: 'setFrameOwner', frameConnectorId, owner })\n }\n\n /// Open (or focus) the paired frame full-page on this companion. The\n /// host treats this as a navigation event: any current SubPage\n /// (camera-share, another frame, etc.) is closed in favour of the new\n /// frame, mirroring the behaviour when a Vitre-driven open triggers\n /// `autoOpen` on the main page. If the Vitre side is reachable the\n /// host also announces the open to it so a paired Vitre frame mounts.\n ///\n /// `frameConnectorId` MUST match the paired Vitre frame's id so both\n /// sides bind to the same frame (per-frame messages + yjs subdoc relay\n /// rely on this).\n public openCompanionFrame(\n frameConnectorId: string,\n options: Omit<OpenFrameOptions, 'frameConnectorId'>,\n ) {\n this.postMessage({\n type: 'openCompanionFrame',\n frameConnectorId,\n options,\n })\n }\n\n /// Send an opaque message to the matching Vitre-side `Connector`. The\n /// payload is forwarded unchanged. There is no targeted addressing —\n /// the message goes to \"the\" Vitre connector for this app.\n public sendMessageToVitreConnector(message: string, fileData?: FileData) {\n this.postMessage({\n type: 'sendMessageToVitreConnector',\n message,\n fileData,\n })\n }\n\n /// Request/response correlation for `privateStorage` — mirrors\n /// `Connector`/`Frame`'s private `postRequest`. `handler` is invoked for\n /// EVERY inbound message (via `requestResolvers`, driven from\n /// `raiseMessage`) until it calls `resolve`/`reject`, matching on its own\n /// `requestId`. When `timeout` is set and no match arrives within `ms`,\n /// the pending resolver is removed and `onTimeout()` rejects the\n /// promise — without that removal a host that never answers (e.g. one\n /// that predates the feature) would leak the resolver forever.\n private async postRequest<Data>(\n data: CompanionConnectorApiMessagesOut,\n handler: (\n msg: CompanionConnectorApiMessagesIn,\n resolve: (data: Data) => void,\n reject: (error: any) => void,\n ) => void,\n transfer?: Transferable[],\n timeout?: { ms: number; onTimeout: () => any },\n ) {\n return await new Promise<Data>((resolve, reject) => {\n let isHandled = false\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const handleAndResolve = (data: Data) => {\n isHandled = true\n if (timer !== undefined) clearTimeout(timer)\n resolve(data)\n }\n\n const handleAndReject = (error: any) => {\n isHandled = true\n if (timer !== undefined) clearTimeout(timer)\n reject(error)\n }\n\n const resolver = {\n isHandled: (msg: CompanionConnectorApiMessagesIn) => {\n try {\n handler(msg, handleAndResolve, handleAndReject)\n } catch (error) {\n handleAndReject(error)\n }\n return isHandled\n },\n }\n this.requestResolvers.push(resolver)\n\n if (timeout) {\n timer = setTimeout(() => {\n if (isHandled) return\n this.requestResolvers = this.requestResolvers.filter((rr) => rr !== resolver)\n handleAndReject(timeout.onTimeout())\n }, timeout.ms)\n }\n\n this.postMessage(data, transfer)\n })\n }\n}\n\ntype PostMessageOut = (\n message: CompanionConnectorApiMessagesOut,\n transfer?: Transferable[],\n) => void\n\n/// Hard cap on the pre-`initialize` queue. A host that floods messages\n/// before/while `initialize` is in flight (or one that never sends it)\n/// must not grow this buffer without bound. On overflow we drop the\n/// oldest queued message and warn once.\nconst MAX_PENDING_MESSAGES = 200\n\n/// Client-side bail-out: if `initialize` never arrives (host crash,\n/// protocol mismatch, dropped postMessage) the outer Promise rejects\n/// after this delay instead of dangling forever.\nconst INITIALIZE_TIMEOUT_MS = 30_000\n\n/// Bootstrap a companion connector. Mirrors `initializeConnector` from\n/// `../Connector/Connector.ts`: posts a request to the parent window,\n/// waits for the host's `initialize`, then resolves with a ready instance.\n///\n/// `buildOptions` is invoked once when the host pushes `initialize`. It\n/// returns the connector's declared name, optional icon, and optional\n/// initial menu. The returned options are echoed back to the host inside\n/// `connectorInitialized`.\n///\n/// Two overloads: when `createConnector` is supplied the resolved\n/// instance is the caller's `T extends CompanionConnector`; when it is\n/// omitted the resolved instance is a plain `CompanionConnector`. This\n/// keeps the return type sound — the omitted-factory path genuinely\n/// builds a base `CompanionConnector`, never a `T`.\nexport async function initializeCompanionConnector<\n T extends CompanionConnector,\n>(\n buildOptions: (\n host: CompanionHostInformation,\n ) => CompanionConnectorOptions | Promise<CompanionConnectorOptions>,\n createConnector: new (\n postMessage: PostMessageOut,\n initMessage: CompanionInitializeConnector,\n options: CompanionConnectorOptions,\n ) => T,\n): Promise<T>\nexport async function initializeCompanionConnector(\n buildOptions: (\n host: CompanionHostInformation,\n ) => CompanionConnectorOptions | Promise<CompanionConnectorOptions>,\n): Promise<CompanionConnector>\nexport async function initializeCompanionConnector<\n T extends CompanionConnector,\n>(\n buildOptions: (\n host: CompanionHostInformation,\n ) => CompanionConnectorOptions | Promise<CompanionConnectorOptions>,\n createConnector?: new (\n postMessage: PostMessageOut,\n initMessage: CompanionInitializeConnector,\n options: CompanionConnectorOptions,\n ) => T,\n): Promise<T | CompanionConnector> {\n return await new Promise<T | CompanionConnector>((resolve, reject) => {\n const channel = new MessageChannel()\n let connector: T | CompanionConnector | null = null\n // Set synchronously the moment the first `initialize` arrives so a\n // second one delivered between the await and the assignment below\n // is ignored instead of constructing a second instance.\n let initializing = false\n // Trusted origin learned from the first initialize message. Until\n // it is set, the window listener only accepts messages whose\n // `source === window.parent`. After it is set, the channel port is\n // the only ingress and the window listener is detached.\n let trustedOrigin: string | null = null\n // Whether overflow on `pendingMessages` has already been warned about,\n // so a flood produces a single warning rather than one per drop.\n let pendingOverflowWarned = false\n // Messages received before `connector` is constructed are queued\n // here and flushed in arrival order once construction finishes.\n const pendingMessages: CompanionConnectorApiMessagesIn[] = []\n\n // Best-effort guess of the parent origin so we don't transfer the\n // MessagePort with `targetOrigin: '*'`. `document.referrer` is the\n // URL of the page that loaded this iframe (the parent in our setup\n // since CompanionConnector iframes are always direct children of\n // the companion host). Falls back to '*' only if the referrer is\n // empty (Referrer-Policy: no-referrer or sandbox).\n const parentOriginGuess = (() => {\n try {\n if (document.referrer) return new URL(document.referrer).origin\n } catch {\n // ignore — referrer wasn't a valid URL\n }\n return '*'\n })()\n\n // Detach the spoofable surface only: the window listener and the\n // no-initialize timeout. Used on the SUCCESS path, where `channel.port1`\n // MUST stay open with its `onmessage` handler installed — it is the\n // connector's live ingress (host → connector events) and the egress\n // captured by the `postMessage` closure (connector → host). Closing it\n // here would silently sever every subsequent `setMenu` / `openFrame` /\n // `closeFrame` / `sendMessageToVitreConnector` and inbound\n // `menuClicked` / `frameLoaded` / `messageFromVitreConnector`.\n const cleanupListeners = () => {\n window.removeEventListener('message', windowListener, false)\n if (initializeTimer != null) {\n clearTimeout(initializeTimer)\n initializeTimer = null\n }\n }\n\n // Full teardown: also tear down the channel port. Used on the timeout /\n // failure / reject paths only, where no connector was constructed (or the\n // outer Promise has already rejected), so the port has no live consumer\n // and must not dangle.\n const cleanup = () => {\n cleanupListeners()\n channel.port1.onmessage = null\n channel.port1.close()\n }\n\n const handleMessage = async (\n e: MessageEvent<CompanionConnectorApiMessagesIn>,\n createPostMessage: (origin: string) => PostMessageOut,\n fromWindow: boolean,\n ) => {\n // Guard against malformed inbound payloads (null/undefined/primitive\n // `e.data`) before touching `.type`, so a single bad postMessage\n // can't crash the switch / surface as an unhandled rejection.\n if (!e.data || typeof e.data !== 'object') return\n\n // Origin / source validation for messages arriving via the window\n // listener. The channel port is implicitly trusted (only the host\n // has the matching port2). The `e.source === window.parent` guard\n // stays active for the lifetime of the window listener — during the\n // `await buildOptions` window the listener is still attached, so the\n // source check (which a forging same-origin frame cannot satisfy)\n // must keep applying alongside the origin check.\n if (fromWindow) {\n if (e.source !== window.parent) return\n if (trustedOrigin != null && e.origin !== trustedOrigin) return\n }\n\n switch (e.data.type) {\n case 'initialize':\n if (initializing || connector != null) {\n console.warn(\n '[CompanionConnector] ignoring duplicate initialize message',\n )\n break\n }\n initializing = true\n try {\n const initMsg = e.data\n // Trust the browser-asserted origin (`e.origin`), not the\n // payload-supplied `companionInfo.origin` which the sender\n // controls and could mis-declare. The origin posting these\n // messages is the companion runtime, so the companion-scoped\n // `companionInfo.origin` is the relevant claim (the Vitre\n // `hostInfo` has no origin). On the channel-port path\n // `e.origin` is empty/meaningless, so fall back to the payload.\n const browserOrigin = fromWindow ? e.origin : ''\n if (\n fromWindow &&\n browserOrigin &&\n initMsg.companionInfo.origin &&\n initMsg.companionInfo.origin !== browserOrigin\n ) {\n console.warn(\n '[CompanionConnector] companionInfo.origin does not match ' +\n 'the browser-asserted parent origin; trusting the latter',\n {\n claimed: initMsg.companionInfo.origin,\n actual: browserOrigin,\n },\n )\n }\n trustedOrigin = browserOrigin || initMsg.companionInfo.origin\n const options = await buildOptions(initMsg.hostInfo)\n connector = new (createConnector ?? CompanionConnector)(\n createPostMessage(trustedOrigin),\n initMsg,\n options,\n )\n // Non-enumerable so it doesn't show up in iteration / JSON of\n // `window`, while keeping parity with the Vitre `Connector`\n // which sets a `mainConnector` global for the same reason\n // (host-side debugging hook).\n Object.defineProperty(window, 'companionConnector', {\n value: connector,\n enumerable: false,\n configurable: true,\n writable: true,\n })\n for (const queued of pendingMessages) {\n connector.raiseMessage(queued)\n }\n pendingMessages.length = 0\n // Once the MessageChannel is established and the connector is\n // built, drop the window listener and the timeout — port1 is\n // the only legitimate ingress from here on, and detaching\n // removes the spoofable surface. Keep port1 OPEN: it is the\n // connector's live ingress/egress for the rest of its lifetime.\n cleanupListeners()\n resolve(connector)\n } catch (err) {\n // Initialization failed. Reject the outer Promise so the caller\n // learns about it (instead of dangling as an unhandled\n // rejection), and tear everything down. Retries are NOT\n // supported: the outer Promise has already settled, so a later\n // `initialize` could only wire up `window.companionConnector`\n // while the awaited handle stays rejected — a silent\n // inconsistent state. Keeping `initializing` true makes any\n // subsequent `initialize` ignored as a duplicate, and `cleanup()`\n // detaches the listener, port, and timer.\n console.error('[CompanionConnector] initialize failed', err)\n cleanup()\n reject(err)\n }\n break\n default:\n if (connector != null) {\n connector.raiseMessage(e.data)\n } else {\n // Cap the pre-init queue: drop the oldest on overflow so a\n // misbehaving host can't grow it without bound. Warn once.\n if (pendingMessages.length >= MAX_PENDING_MESSAGES) {\n pendingMessages.shift()\n if (!pendingOverflowWarned) {\n pendingOverflowWarned = true\n console.warn(\n '[CompanionConnector] pending-message queue exceeded ' +\n `${MAX_PENDING_MESSAGES} before initialize; dropping oldest`,\n )\n }\n }\n pendingMessages.push(e.data)\n }\n break\n }\n }\n\n channel.port1.onmessage = (e) =>\n void handleMessage(\n e,\n (_origin: string) => (message, transfer?: Transferable[]) => {\n channel.port1.postMessage(message, transfer ?? [])\n },\n false,\n ).catch((err) => console.error('[CompanionConnector]', err))\n\n const windowListener = (e: MessageEvent<CompanionConnectorApiMessagesIn>) =>\n void handleMessage(\n e,\n (origin: string) => (message, transfer?: Transferable[]) => {\n window.parent.postMessage(message, origin, transfer)\n },\n true,\n ).catch((err) => console.error('[CompanionConnector]', err))\n\n window.addEventListener('message', windowListener, false)\n\n // Bail out if the host never sends `initialize` (crash, protocol\n // mismatch, dropped message). Detach everything and reject so the\n // caller doesn't await forever.\n let initializeTimer: ReturnType<typeof setTimeout> | null = setTimeout(\n () => {\n initializeTimer = null\n if (connector != null || initializing) return\n cleanup()\n const err = new Error(\n `[CompanionConnector] no initialize received within ` +\n `${INITIALIZE_TIMEOUT_MS}ms`,\n )\n console.warn(err.message)\n reject(err)\n },\n INITIALIZE_TIMEOUT_MS,\n )\n\n window.parent.postMessage(\n {\n type: 'companionConnectorInitializationRequest',\n version: apiVersion,\n },\n parentOriginGuess,\n [channel.port2],\n )\n })\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Frame } from '../Frame/Frame.js';
2
2
  import type { InitFrameOptions, ViewOptions } from '../Frame/Frame.Model.js';
3
- import type { Device, FileData, HostInformation } from '../Common/index.js';
3
+ import type { Device, FileData, HostInformation, PrivateStorageReadApi } from '../Common/index.js';
4
4
  /**
5
5
  * Runtime class for a frame iframe loaded by the la Vitre **companion**.
6
6
  * Extends the shared `Frame` runtime (same wire, same lifecycle) with the two
@@ -57,7 +57,18 @@ declare class CompanionFrameImpl extends Frame {
57
57
  * using `createVitreSyncAdapter(frame)` unchanged — the adapter only touches
58
58
  * `frame.crdt`.
59
59
  */
60
- export type CompanionFrame = Pick<CompanionFrameImpl, 'id' | 'appId' | 'options' | 'initOptions' | 'initiator' | 'hostInformation' | 'companionInformation' | 'state' | 'crdt' | 'blobs' | 'yjsDoc' | 'isFullscreen' | 'isBorderless' | 'position' | 'zIndex' | 'safeAreaInsets' | 'setFullscreen' | 'setWindowed' | 'setMenu' | 'sendToVitreFrame' | 'sendMessageToVitreConnector' | 'canShareStream' | 'shareStream' | 'replaceShareStream' | 'stopShareStream' | 'attachStream' | 'detachStream' | 'getIceServers' | 'onSharedStream' | 'onSharedStreamRemoved' | 'close' | 'closeOnCompanion' | 'onLocalConnectorMessageReceived' | 'onMessageReceived' | 'onMenuClicked' | 'onFieldUpdated' | 'onFullscreenChanged' | 'onBorderlessChanged' | 'onSafeAreaInsetsUpdated' | 'onYjsSynced' | 'onYjsUpdate'>;
60
+ export type CompanionFrame = Pick<CompanionFrameImpl, 'id' | 'appId' | 'options' | 'initOptions' | 'initiator' | 'hostInformation' | 'companionInformation' | 'state' | 'crdt' | 'blobs' | 'yjsDoc' | 'isFullscreen' | 'isBorderless' | 'position' | 'zIndex' | 'safeAreaInsets' | 'setFullscreen' | 'setWindowed' | 'setMenu' | 'sendToVitreFrame' | 'sendMessageToVitreConnector' | 'canShareStream' | 'shareStream' | 'replaceShareStream' | 'stopShareStream' | 'attachStream' | 'detachStream' | 'getIceServers' | 'onSharedStream' | 'onSharedStreamRemoved' | 'close' | 'closeOnCompanion' | 'onLocalConnectorMessageReceived' | 'onMessageReceived' | 'onMenuClicked' | 'onFieldUpdated' | 'onFullscreenChanged' | 'onBorderlessChanged' | 'onSafeAreaInsetsUpdated' | 'onYjsSynced' | 'onYjsUpdate'> & {
61
+ /**
62
+ * Read-only private storage — `list`/`get`/`getLink` only. `put`/`delete`
63
+ * are intentionally absent at the type level: writes stay vitre-only, and
64
+ * the companion host answers them with `error: 'unsupported'` anyway (the
65
+ * runtime instance inherits the full `Frame.privateStorage`, but this
66
+ * narrower type is what a companion frame app sees — same pattern as the
67
+ * rest of this `Pick`, which hides Vitre-only members that still exist on
68
+ * the underlying `CompanionFrameImpl`).
69
+ */
70
+ privateStorage: PrivateStorageReadApi;
71
+ };
61
72
  /**
62
73
  * Mirror of `initializeFrame` for the companion side. Same wire-level
63
74
  * handshake (`connectorInitializationRequest` posted with a MessageChannel
@@ -1 +1 @@
1
- {"version":3,"file":"CompanionFrame.js","sourceRoot":"","sources":["../../CompanionFrame/CompanionFrame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAI1D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,kBAAmB,SAAQ,KAAK;IACpC;;;;;;;;OAQG;IACI,2BAA2B,CAAC,OAAe,EAAE,QAAmB;QACrE,IAAI,CAAC,WAAW,CAAC;YACf,IAAI,EAAE,sBAAsB;YAC5B,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACzB,OAAO;YACP,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACI,gBAAgB;QACrB,IAAI,CAAC,WAAW,CAAC;YACf,IAAI,EAAE,kBAAkB;SACzB,CAAC,CAAA;IACJ,CAAC;CACF;AAuGD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,IAKgB;IAEhB,6EAA6E;IAC7E,6EAA6E;IAC7E,8EAA8E;IAC9E,kDAAkD;IAClD,OAAO,MAAM,eAAe,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAA;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,gBAAgB,CAAC,eAAgC;IAC/D,OAAO,eAAe,CAAC,WAAW,KAAK,IAAI,CAAA;AAC7C,CAAC","sourcesContent":["import { Frame, initializeFrame } from '../Frame/Frame.js'\nimport type { InitFrameOptions, ViewOptions } from '../Frame/Frame.Model.js'\nimport type { Device, FileData, HostInformation } from '../Common/index.js'\n\n/**\n * Runtime class for a frame iframe loaded by the la Vitre **companion**.\n * Extends the shared `Frame` runtime (same wire, same lifecycle) with the two\n * send methods that ONLY make sense — and are ONLY decoded by the host — on the\n * companion side:\n *\n * - `sendMessageToVitreConnector` → host message `sendToVitreConnector`, which\n * the companion host relays to the app's Vitre-side main `Connector`\n * (`onMessageFromCompanionFrame`).\n * - `closeOnCompanion` → host message `closeOnCompanion` (local companion\n * close; the Vitre keeps its own frame).\n *\n * Both live HERE, not on `Frame`: the Vitre host does NOT decode those message\n * types, so calling them from a Vitre frame produced a \"case type not found\"\n * parse error on the Vitre. Keeping them off `Frame` makes that misuse a\n * compile error. A Vitre frame that needs to reach its own connector uses\n * `sendToLocalMainConnector` instead.\n */\nclass CompanionFrameImpl extends Frame {\n /**\n * Send a message straight to this app's Vitre-side main `Connector` — even\n * when there is NO paired Vitre frame (a local companion frame). The Vitre\n * connector receives it on `onMessageFromCompanionFrame(fromCompanionId,\n * frameConnectorId, message, fileData)`, `frameConnectorId` set to this\n * frame's id so the app can tell which companion frame spoke. Frame-side\n * counterpart of `CompanionConnector.sendMessageToVitreConnector` (which has\n * no frame id).\n */\n public sendMessageToVitreConnector(message: string, fileData?: FileData) {\n this.postMessage({\n type: 'sendToVitreConnector',\n frameConnectorId: this.id,\n message,\n fileData,\n })\n }\n\n /**\n * Close the iframe locally on the companion and remove this companion from\n * the per-frame `framePresence` on the Vitre. The Vitre keeps its own frame\n * open (`openFrame` re-shows the same frame); use `close()` to close globally.\n * See `FrameApiMessagesOut`'s `closeOnCompanion` arm doc for the rationale.\n */\n public closeOnCompanion() {\n this.postMessage({\n type: 'closeOnCompanion',\n })\n }\n}\n\n/**\n * SDK surface intended for apps running inside a frame iframe loaded by the\n * la Vitre **companion** (not by a Vitre). Mirrors the `Connector` /\n * `CompanionConnector` split: a companion frame talks to its paired Vitre frame\n * and to its own host, but has no notion of other Vitres in the space — so the\n * broadcast-style send methods (`sendMessageTo`, `sendMessageToAll`,\n * `sendKnockKnock`) and the Vitre-only side effects (`setVitreSettings`,\n * `setShareTarget`, the device-event callbacks) are deliberately not exposed.\n * Conversely, the companion-only `sendMessageToVitreConnector` /\n * `closeOnCompanion` (see {@link CompanionFrameImpl}) are exposed HERE and\n * nowhere else — in particular NOT on the Vitre `Frame`.\n *\n * `crdt` flows through the la Vitre Yjs transport identical to the Vitre side —\n * the same Y.Doc and Awareness end up in sync on the Vitre frame, on other\n * companions of the same `(appId, frameId)` presence set, and on this\n * companion. Apps using carbone or any other Y-doc-backed library can keep\n * using `createVitreSyncAdapter(frame)` unchanged — the adapter only touches\n * `frame.crdt`.\n */\nexport type CompanionFrame = Pick<\n CompanionFrameImpl,\n // Identity\n | 'id'\n | 'appId'\n | 'options'\n | 'initOptions'\n | 'initiator'\n | 'hostInformation'\n | 'companionInformation'\n | 'state'\n\n // CRDT\n | 'crdt'\n | 'blobs'\n | 'yjsDoc'\n\n // Lifecycle and visual state\n | 'isFullscreen'\n | 'isBorderless'\n | 'position'\n | 'zIndex'\n | 'safeAreaInsets'\n | 'setFullscreen'\n | 'setWindowed'\n | 'setMenu'\n\n // Send to paired Vitre frame (the only useful peer for a companion frame)\n | 'sendToVitreFrame'\n\n // Companion-only: send straight to the app's Vitre-side main Connector —\n // works even with no paired Vitre frame (a local companion frame). Lands on\n // the Vitre connector's `onMessageFromCompanionFrame`.\n | 'sendMessageToVitreConnector'\n\n // Stream share — a companion frame (e.g. a camera page opened via\n // `openCompanionFrame`) can originate a MediaStream toward the Vitre. The\n // companion host forwards it over its Vitre P2P, tagged for this app; the\n // app's Vitre frame then receives it via `onSharedStream` (reverse\n // exposure), optionally transforms it, and reshares to the space. Same\n // runtime as the Vitre `Frame` — only surfaced here in the type.\n | 'canShareStream'\n | 'shareStream'\n | 'replaceShareStream'\n | 'stopShareStream'\n | 'attachStream'\n | 'detachStream'\n // ICE/TURN config the companion host already holds (from its `WebRTCOffer`)\n // — lets a companion-camera frame open its own RTCPeerConnection directly to\n // the paired Vitre transform frame, NAT-traversing via the same relays.\n | 'getIceServers'\n // Receive a stream the host exposes into this companion frame (symmetric\n // to the Vitre side; harmless if the host never pushes one).\n | 'onSharedStream'\n | 'onSharedStreamRemoved'\n\n // Close behaviours\n // - `close` is the existing GLOBAL close (kills the Vitre frame too —\n // the same as `connector.closeFrame(frameConnectorId)`). Keep it\n // exposed for the rare app that genuinely wants to close for\n // everyone from the companion side.\n | 'close'\n // - `closeOnCompanion` is the *local* close: companion's iframe\n // unmounts + companion is removed from the frame's `framePresence`\n // on the Vitre, but the Vitre keeps its own frame open. Equivalent\n // to the late-join state: `openFrame` will re-show the same frame.\n | 'closeOnCompanion'\n\n // Inbound surface — same as Frame but only the events that fire on a\n // companion frame are useful in practice. Apps wire whichever they\n // need; the unused callbacks stay `undefined`.\n | 'onLocalConnectorMessageReceived' // messages from the paired Vitre frame\n | 'onMessageReceived' // catch-all (every inbound type)\n | 'onMenuClicked'\n | 'onFieldUpdated'\n | 'onFullscreenChanged'\n | 'onBorderlessChanged'\n | 'onSafeAreaInsetsUpdated'\n | 'onYjsSynced'\n | 'onYjsUpdate'\n>\n\n/**\n * Mirror of `initializeFrame` for the companion side. Same wire-level\n * handshake (`connectorInitializationRequest` posted with a MessageChannel\n * `port2` transferred to the parent) — the companion host's behaviour is\n * identical to the Vitre's at that protocol point (see\n * `lavitre-companion/.../CompanionApps.State.fs:postFrameInit`). It instantiates\n * the companion runtime subclass `CompanionFrameImpl`, so the returned\n * `CompanionFrame` carries the companion-only send methods; existing helpers\n * like `createVitreSyncAdapter` keep working (they only touch `frame.crdt`).\n *\n * Usage:\n * const frame = await initializeCompanionFrame((host, initiator, opts) => ({\n * name: 'My App',\n * allowFullscreen: true,\n * }))\n * frame.sendToVitreFrame({ kind: 'hello', from: 'companion' })\n * frame.closeOnCompanion()\n */\nexport async function initializeCompanionFrame(\n init: (\n info: HostInformation,\n initiator: Device,\n options: InitFrameOptions,\n state?: Record<string, any>,\n ) => ViewOptions,\n): Promise<CompanionFrame> {\n // Instantiate the companion runtime subclass. The wire protocol is identical\n // to the Vitre side at the `connectorInitializationRequest` boundary, so the\n // host (Vitre or companion) routes by its own context; the subclass just adds\n // the companion-only send methods to the surface.\n return await initializeFrame(init, CompanionFrameImpl)\n}\n\n/**\n * Convenience guard for apps that ship a single `frame.tsx` entry but want to\n * branch behaviour based on context. Reads the dedicated\n * `hostInformation.isCompanion` flag set by `lavitre-companion`\n * (CompanionApps.State.fs:buildVitreLikeHostInformation). Old hosts that\n * predate the flag omit it, in which case we conservatively return `false` and\n * the caller behaves as on a Vitre — the safer default since the Vitre surface\n * is the superset.\n *\n * Note: to USE the companion-only send methods (`sendMessageToVitreConnector`,\n * `closeOnCompanion`) you need a `CompanionFrame` from `initializeCompanionFrame`\n * (ship a dedicated companion entry). This guard only narrows behaviour/UX, not\n * the static type — a value from `initializeFrame` stays a Vitre `Frame`.\n *\n * Usage:\n * const frame = await initializeFrame(init)\n * if (isCompanionFrame(frame.hostInformation)) {\n * // Apply companion-only UX (e.g. a \"Leave this frame\" button)\n * } else {\n * // Vitre surface: sendMessageTo / sendKnockKnock / setVitreSettings / …\n * }\n */\nexport function isCompanionFrame(hostInformation: HostInformation): boolean {\n return hostInformation.isCompanion === true\n}\n"]}
1
+ {"version":3,"file":"CompanionFrame.js","sourceRoot":"","sources":["../../CompanionFrame/CompanionFrame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAI1D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,kBAAmB,SAAQ,KAAK;IACpC;;;;;;;;OAQG;IACI,2BAA2B,CAAC,OAAe,EAAE,QAAmB;QACrE,IAAI,CAAC,WAAW,CAAC;YACf,IAAI,EAAE,sBAAsB;YAC5B,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACzB,OAAO;YACP,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACI,gBAAgB;QACrB,IAAI,CAAC,WAAW,CAAC;YACf,IAAI,EAAE,kBAAkB;SACzB,CAAC,CAAA;IACJ,CAAC;CACF;AAkHD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,IAKgB;IAEhB,6EAA6E;IAC7E,6EAA6E;IAC7E,8EAA8E;IAC9E,kDAAkD;IAClD,OAAO,MAAM,eAAe,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAA;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,gBAAgB,CAAC,eAAgC;IAC/D,OAAO,eAAe,CAAC,WAAW,KAAK,IAAI,CAAA;AAC7C,CAAC","sourcesContent":["import { Frame, initializeFrame } from '../Frame/Frame.js'\nimport type { InitFrameOptions, ViewOptions } from '../Frame/Frame.Model.js'\nimport type { Device, FileData, HostInformation, PrivateStorageReadApi } from '../Common/index.js'\n\n/**\n * Runtime class for a frame iframe loaded by the la Vitre **companion**.\n * Extends the shared `Frame` runtime (same wire, same lifecycle) with the two\n * send methods that ONLY make sense — and are ONLY decoded by the host — on the\n * companion side:\n *\n * - `sendMessageToVitreConnector` → host message `sendToVitreConnector`, which\n * the companion host relays to the app's Vitre-side main `Connector`\n * (`onMessageFromCompanionFrame`).\n * - `closeOnCompanion` → host message `closeOnCompanion` (local companion\n * close; the Vitre keeps its own frame).\n *\n * Both live HERE, not on `Frame`: the Vitre host does NOT decode those message\n * types, so calling them from a Vitre frame produced a \"case type not found\"\n * parse error on the Vitre. Keeping them off `Frame` makes that misuse a\n * compile error. A Vitre frame that needs to reach its own connector uses\n * `sendToLocalMainConnector` instead.\n */\nclass CompanionFrameImpl extends Frame {\n /**\n * Send a message straight to this app's Vitre-side main `Connector` — even\n * when there is NO paired Vitre frame (a local companion frame). The Vitre\n * connector receives it on `onMessageFromCompanionFrame(fromCompanionId,\n * frameConnectorId, message, fileData)`, `frameConnectorId` set to this\n * frame's id so the app can tell which companion frame spoke. Frame-side\n * counterpart of `CompanionConnector.sendMessageToVitreConnector` (which has\n * no frame id).\n */\n public sendMessageToVitreConnector(message: string, fileData?: FileData) {\n this.postMessage({\n type: 'sendToVitreConnector',\n frameConnectorId: this.id,\n message,\n fileData,\n })\n }\n\n /**\n * Close the iframe locally on the companion and remove this companion from\n * the per-frame `framePresence` on the Vitre. The Vitre keeps its own frame\n * open (`openFrame` re-shows the same frame); use `close()` to close globally.\n * See `FrameApiMessagesOut`'s `closeOnCompanion` arm doc for the rationale.\n */\n public closeOnCompanion() {\n this.postMessage({\n type: 'closeOnCompanion',\n })\n }\n}\n\n/**\n * SDK surface intended for apps running inside a frame iframe loaded by the\n * la Vitre **companion** (not by a Vitre). Mirrors the `Connector` /\n * `CompanionConnector` split: a companion frame talks to its paired Vitre frame\n * and to its own host, but has no notion of other Vitres in the space — so the\n * broadcast-style send methods (`sendMessageTo`, `sendMessageToAll`,\n * `sendKnockKnock`) and the Vitre-only side effects (`setVitreSettings`,\n * `setShareTarget`, the device-event callbacks) are deliberately not exposed.\n * Conversely, the companion-only `sendMessageToVitreConnector` /\n * `closeOnCompanion` (see {@link CompanionFrameImpl}) are exposed HERE and\n * nowhere else — in particular NOT on the Vitre `Frame`.\n *\n * `crdt` flows through the la Vitre Yjs transport identical to the Vitre side —\n * the same Y.Doc and Awareness end up in sync on the Vitre frame, on other\n * companions of the same `(appId, frameId)` presence set, and on this\n * companion. Apps using carbone or any other Y-doc-backed library can keep\n * using `createVitreSyncAdapter(frame)` unchanged — the adapter only touches\n * `frame.crdt`.\n */\nexport type CompanionFrame = Pick<\n CompanionFrameImpl,\n // Identity\n | 'id'\n | 'appId'\n | 'options'\n | 'initOptions'\n | 'initiator'\n | 'hostInformation'\n | 'companionInformation'\n | 'state'\n\n // CRDT\n | 'crdt'\n | 'blobs'\n | 'yjsDoc'\n\n // Lifecycle and visual state\n | 'isFullscreen'\n | 'isBorderless'\n | 'position'\n | 'zIndex'\n | 'safeAreaInsets'\n | 'setFullscreen'\n | 'setWindowed'\n | 'setMenu'\n\n // Send to paired Vitre frame (the only useful peer for a companion frame)\n | 'sendToVitreFrame'\n\n // Companion-only: send straight to the app's Vitre-side main Connector —\n // works even with no paired Vitre frame (a local companion frame). Lands on\n // the Vitre connector's `onMessageFromCompanionFrame`.\n | 'sendMessageToVitreConnector'\n\n // Stream share — a companion frame (e.g. a camera page opened via\n // `openCompanionFrame`) can originate a MediaStream toward the Vitre. The\n // companion host forwards it over its Vitre P2P, tagged for this app; the\n // app's Vitre frame then receives it via `onSharedStream` (reverse\n // exposure), optionally transforms it, and reshares to the space. Same\n // runtime as the Vitre `Frame` — only surfaced here in the type.\n | 'canShareStream'\n | 'shareStream'\n | 'replaceShareStream'\n | 'stopShareStream'\n | 'attachStream'\n | 'detachStream'\n // ICE/TURN config the companion host already holds (from its `WebRTCOffer`)\n // — lets a companion-camera frame open its own RTCPeerConnection directly to\n // the paired Vitre transform frame, NAT-traversing via the same relays.\n | 'getIceServers'\n // Receive a stream the host exposes into this companion frame (symmetric\n // to the Vitre side; harmless if the host never pushes one).\n | 'onSharedStream'\n | 'onSharedStreamRemoved'\n\n // Close behaviours\n // - `close` is the existing GLOBAL close (kills the Vitre frame too —\n // the same as `connector.closeFrame(frameConnectorId)`). Keep it\n // exposed for the rare app that genuinely wants to close for\n // everyone from the companion side.\n | 'close'\n // - `closeOnCompanion` is the *local* close: companion's iframe\n // unmounts + companion is removed from the frame's `framePresence`\n // on the Vitre, but the Vitre keeps its own frame open. Equivalent\n // to the late-join state: `openFrame` will re-show the same frame.\n | 'closeOnCompanion'\n\n // Inbound surface — same as Frame but only the events that fire on a\n // companion frame are useful in practice. Apps wire whichever they\n // need; the unused callbacks stay `undefined`.\n | 'onLocalConnectorMessageReceived' // messages from the paired Vitre frame\n | 'onMessageReceived' // catch-all (every inbound type)\n | 'onMenuClicked'\n | 'onFieldUpdated'\n | 'onFullscreenChanged'\n | 'onBorderlessChanged'\n | 'onSafeAreaInsetsUpdated'\n | 'onYjsSynced'\n | 'onYjsUpdate'\n> & {\n /**\n * Read-only private storage — `list`/`get`/`getLink` only. `put`/`delete`\n * are intentionally absent at the type level: writes stay vitre-only, and\n * the companion host answers them with `error: 'unsupported'` anyway (the\n * runtime instance inherits the full `Frame.privateStorage`, but this\n * narrower type is what a companion frame app sees — same pattern as the\n * rest of this `Pick`, which hides Vitre-only members that still exist on\n * the underlying `CompanionFrameImpl`).\n */\n privateStorage: PrivateStorageReadApi\n}\n\n/**\n * Mirror of `initializeFrame` for the companion side. Same wire-level\n * handshake (`connectorInitializationRequest` posted with a MessageChannel\n * `port2` transferred to the parent) — the companion host's behaviour is\n * identical to the Vitre's at that protocol point (see\n * `lavitre-companion/.../CompanionApps.State.fs:postFrameInit`). It instantiates\n * the companion runtime subclass `CompanionFrameImpl`, so the returned\n * `CompanionFrame` carries the companion-only send methods; existing helpers\n * like `createVitreSyncAdapter` keep working (they only touch `frame.crdt`).\n *\n * Usage:\n * const frame = await initializeCompanionFrame((host, initiator, opts) => ({\n * name: 'My App',\n * allowFullscreen: true,\n * }))\n * frame.sendToVitreFrame({ kind: 'hello', from: 'companion' })\n * frame.closeOnCompanion()\n */\nexport async function initializeCompanionFrame(\n init: (\n info: HostInformation,\n initiator: Device,\n options: InitFrameOptions,\n state?: Record<string, any>,\n ) => ViewOptions,\n): Promise<CompanionFrame> {\n // Instantiate the companion runtime subclass. The wire protocol is identical\n // to the Vitre side at the `connectorInitializationRequest` boundary, so the\n // host (Vitre or companion) routes by its own context; the subclass just adds\n // the companion-only send methods to the surface.\n return await initializeFrame(init, CompanionFrameImpl)\n}\n\n/**\n * Convenience guard for apps that ship a single `frame.tsx` entry but want to\n * branch behaviour based on context. Reads the dedicated\n * `hostInformation.isCompanion` flag set by `lavitre-companion`\n * (CompanionApps.State.fs:buildVitreLikeHostInformation). Old hosts that\n * predate the flag omit it, in which case we conservatively return `false` and\n * the caller behaves as on a Vitre — the safer default since the Vitre surface\n * is the superset.\n *\n * Note: to USE the companion-only send methods (`sendMessageToVitreConnector`,\n * `closeOnCompanion`) you need a `CompanionFrame` from `initializeCompanionFrame`\n * (ship a dedicated companion entry). This guard only narrows behaviour/UX, not\n * the static type — a value from `initializeFrame` stays a Vitre `Frame`.\n *\n * Usage:\n * const frame = await initializeFrame(init)\n * if (isCompanionFrame(frame.hostInformation)) {\n * // Apply companion-only UX (e.g. a \"Leave this frame\" button)\n * } else {\n * // Vitre surface: sendMessageTo / sendKnockKnock / setVitreSettings / …\n * }\n */\nexport function isCompanionFrame(hostInformation: HostInformation): boolean {\n return hostInformation.isCompanion === true\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { AppMessage, BorderOptions, ChangePrivacy, ChangeTeamSpace, ChangeTeamSpaceGuest, ChromeStyle, ConnectedMediaDevice, ConnectionCodeUpdated, DeviceFrameReference, DeviceFullscreenUpdated, DeviceJoined, DeviceLeft, DeviceMessageReceived, DevicePrivacyChanged, DeviceScalingUpdated, EnumerateLoadedFrames, EnumerateLoadedFramesCompleted, EventTelemetry, FieldUpdated, FileData, FramePrivacy, GetStats, HideNotification, HostInformation, Interaction, KnockKnock, LayoutPosition, LayoutPositionWithRules, LocalConnectorMessageReceived, MenuClicked, MenuEntry, MenuVisibility, NotificationButtonClicked, NotificationDismissed, NotificationInfo, OpenFrameOptions, PendingDevicesInfo, PositionType, PositionUpdated, PrivacyChanged, RequestSerialPortAccess, SerialPortAccessResult, ResizeMode, SaveSettings, SendKnockKnock, SendMessageTo, SendMessageToAll, SendToLocalFrame, SendToSerialPort, SetReducedAudioMode, SettingsUpdated, ShareDataRequest, ShareFileRequest, Size, StartEventTelemetry, StateReplaced, StatsResponse, UpdateState, ViewMode, Visibility, VitreSettings, VitreSettingsSetter, VoiceAction, VoiceActionDetection } from '../Common/index.js';
1
+ import type { AppMessage, AppSettingsChanged, AppSettingsResponse, BorderOptions, ChangePrivacy, ChangeTeamSpace, ChangeTeamSpaceGuest, ChromeStyle, ConnectedMediaDevice, ConnectionCodeUpdated, DeletePublicFile, DeviceFrameReference, DeviceFullscreenUpdated, DeviceJoined, DeviceLeft, DeviceMessageReceived, DevicePrivacyChanged, DeviceScalingUpdated, EnumerateLoadedFrames, EnumerateLoadedFramesCompleted, EventTelemetry, FieldUpdated, FileData, FramePrivacy, GetAppSettings, GetStats, HideNotification, HostInformation, Interaction, KnockKnock, LayoutPosition, LayoutPositionWithRules, ListPublicFiles, LocalConnectorMessageReceived, MenuClicked, MenuEntry, MenuVisibility, NotificationButtonClicked, NotificationDismissed, NotificationInfo, OpenFrameOptions, PendingDevicesInfo, PositionType, PositionUpdated, PrivacyChanged, PublicStorageResponse, PutPublicFile, DeletePrivateFile, GetPrivateFile, GetPrivateFileLink, ListPrivateFiles, PrivateStorageResponse, PutPrivateFile, RequestSerialPortAccess, SerialPortAccessResult, ResizeMode, SaveSettings, SendKnockKnock, SendMessageTo, SendMessageToAll, SendToLocalFrame, SendToSerialPort, SetAppSettings, SetReducedAudioMode, SettingsUpdated, ShareDataRequest, ShareFileRequest, Size, StartEventTelemetry, StateReplaced, StatsResponse, UpdateState, ViewMode, Visibility, VitreSettings, VitreSettingsSetter, VoiceAction, VoiceActionDetection } from '../Common/index.js';
2
2
  export type InitializeConnector = {
3
3
  hostInfo: HostInformation;
4
4
  appId?: string;
@@ -454,6 +454,14 @@ export type ConnectorApiMessagesIn = ({
454
454
  } & ExternalMessageReceived) | ({
455
455
  type: 'appTokenReceived';
456
456
  } & AppTokenReceivedData) | ({
457
+ type: 'appSettingsResponse';
458
+ } & AppSettingsResponse) | ({
459
+ type: 'appSettingsChanged';
460
+ } & AppSettingsChanged) | ({
461
+ type: 'publicStorageResponse';
462
+ } & PublicStorageResponse) | ({
463
+ type: 'privateStorageResponse';
464
+ } & PrivateStorageResponse) | ({
457
465
  type: 'executeInFrameResult';
458
466
  } & ExecuteInFrameResultData) | ({
459
467
  type: 'mediaDevicesChanged';
@@ -539,6 +547,26 @@ export type ConnectorApiMessagesOut = ({
539
547
  } & ShareDataRequest) | ({
540
548
  type: 'saveSettings';
541
549
  } & SaveSettings) | ({
550
+ type: 'getAppSettings';
551
+ } & GetAppSettings) | ({
552
+ type: 'setAppSettings';
553
+ } & SetAppSettings) | ({
554
+ type: 'putPublicFile';
555
+ } & PutPublicFile) | ({
556
+ type: 'deletePublicFile';
557
+ } & DeletePublicFile) | ({
558
+ type: 'listPublicFiles';
559
+ } & ListPublicFiles) | ({
560
+ type: 'putPrivateFile';
561
+ } & PutPrivateFile) | ({
562
+ type: 'deletePrivateFile';
563
+ } & DeletePrivateFile) | ({
564
+ type: 'listPrivateFiles';
565
+ } & ListPrivateFiles) | ({
566
+ type: 'getPrivateFile';
567
+ } & GetPrivateFile) | ({
568
+ type: 'getPrivateFileLink';
569
+ } & GetPrivateFileLink) | ({
542
570
  type: 'changeTeamSpace';
543
571
  } & ChangeTeamSpace) | ({
544
572
  type: 'changeTeamSpaceGuest';
@@ -1 +1 @@
1
- {"version":3,"file":"Connector.Model.js","sourceRoot":"","sources":["../../Connector/Connector.Model.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AppMessage,\n BorderOptions,\n ChangePrivacy,\n ChangeTeamSpace,\n ChangeTeamSpaceGuest,\n ChromeStyle,\n ConnectedMediaDevice,\n ConnectionCodeUpdated,\n DeviceFrameReference,\n DeviceFullscreenUpdated,\n DeviceJoined,\n DeviceLeft,\n DeviceMessageReceived,\n DevicePrivacyChanged,\n DeviceScalingUpdated,\n EnumerateLoadedFrames,\n EnumerateLoadedFramesCompleted,\n EventTelemetry,\n FieldUpdated,\n FileData,\n FramePrivacy,\n GetStats,\n HideNotification,\n HostInformation,\n Interaction,\n KnockKnock,\n LayoutPosition,\n LayoutPositionWithRules,\n LocalConnectorMessageReceived,\n MenuClicked,\n MenuEntry,\n MenuVisibility,\n NotificationButtonClicked,\n NotificationDismissed,\n NotificationInfo,\n OpenFrameOptions,\n PendingDevicesInfo,\n PositionType,\n PositionUpdated,\n PrivacyChanged,\n RequestSerialPortAccess,\n SerialPortAccessResult,\n ResizeMode,\n SaveSettings,\n SendKnockKnock,\n SendMessageTo,\n SendMessageToAll,\n SendToLocalFrame,\n SendToSerialPort,\n SetReducedAudioMode,\n SettingsUpdated,\n ShareDataRequest,\n ShareFileRequest,\n Size,\n StartEventTelemetry,\n StateReplaced,\n StatsResponse,\n UpdateState,\n ViewMode,\n Visibility,\n VitreSettings,\n VitreSettingsSetter,\n VoiceAction,\n VoiceActionDetection,\n} from '../Common/index.js'\n\nexport type InitializeConnector = {\n hostInfo: HostInformation\n appId?: string\n state?: Record<string, any>\n}\n\nexport type RegExpDefinition = {\n pattern: string\n options: string\n}\n\nexport type ShareTargetOptions = {\n name?: string\n urlDomains?: string[]\n urlRegex?: string[]\n urlRegexWithOptions?: RegExpDefinition[]\n files?: FileShareTarget[]\n /**\n * Icon shown for this share target in the companion import picker. A bitmap\n * (full colour). May be a path relative to the connector URL — the host\n * resolves it to an absolute URL. When both `iconUrl` and `maskIconUrl` are\n * set, the companion prefers `maskIconUrl`. When neither is set the picker\n * falls back to the app icon (`ConnectorOptions.iconUrl`).\n */\n iconUrl?: string\n /**\n * Monochrome mask icon for this share target, tinted by the companion theme\n * (CSS `mask`). May be relative to the connector URL — resolved absolute by\n * the host. Preferred over `iconUrl` when both are set.\n */\n maskIconUrl?: string\n}\n\nexport type FileShareTarget = {\n fileExtension?: string\n fileExtensionRegex?: RegExpDefinition\n binaryHeader?: ArrayBufferLike\n mimeTypes?: string[]\n tag?: any\n id: string\n}\n\nexport type MenuCategoryInfo = {\n type: 'mainMenu'\n label?: string\n description?: string\n order?: number\n}\n\nexport type SettingsMenuCategoryInfo = {\n type: 'settingsMenu'\n label?: string\n description?: string\n}\n\nexport type MainMenuQuickActions = {\n type: 'mainMenuQuickActions'\n label?: string\n description?: string\n order?: number\n}\n\nexport type ExportMenuCategory = {\n type: 'exportMenu'\n label?: string\n description?: string\n order?: number\n}\n\nexport type RootMenuCategory =\n | { type: 'desktopIcons' }\n | MainMenuQuickActions\n | MenuCategoryInfo\n | SettingsMenuCategoryInfo\n | ExportMenuCategory\n\nexport type RootMenuEntry = Omit<MenuEntry, 'category'> & {\n category?: RootMenuCategory\n}\n\nexport type ConnectorOptions = {\n name: string\n iconUrl?: string\n menu?: RootMenuEntry[]\n /**\n * @deprecated Use `shareTargets`. When `shareTargets` is set the host uses it\n * and ignores this field. Kept on the wire for older Vitres that only read a\n * single share target — the SDK mirrors `shareTargets[0]` here automatically.\n */\n shareTarget?: ShareTargetOptions\n /**\n * Share targets advertised by this app. Several may be declared so an app can\n * receive distinct kinds of content (each with its own `name`/matchers). When\n * provided, this supersedes the deprecated singular `shareTarget`.\n */\n shareTargets?: ShareTargetOptions[]\n /**\n * The app's settings, rendered by the la Vitre settings form and read back from\n * `hostInformation.settings`.\n *\n * This is a **map of fields**, NOT a full JSON schema: one key per setting, the\n * same keys as `hostInformation.settings`. The host builds the enclosing\n * `{ type: 'object', title: <app name>, properties: … }` itself.\n *\n * ```ts\n * // RIGHT\n * settingsSchema: {\n * city: { type: 'string', title: 'City', default: 'Paris' },\n * layout: { type: 'object', title: 'Layout', properties: { columns: { type: 'number' } } },\n * }\n * // WRONG — a full JSON schema\n * settingsSchema: { type: 'object', properties: { city: { type: 'string' } } }\n * ```\n */\n settingsSchema?: SettingsSchemaProperties\n /** react-jsonschema-form `uiSchema`, keyed like `settingsSchema` (one entry per field). */\n settingsSchemaUI?: any\n voiceActions?: VoiceAction[]\n}\n\n/**\n * One setting: the JSON-Schema subset the la Vitre settings form renders\n * (`string`, `number`, `boolean`, `enum`, `array` with `items`, `object` with\n * `properties`). Every nested `properties` value and `items` is itself a\n * `SettingsFieldSchema` object, never a bare string; `required` is a list of key\n * names on the enclosing object, never `required: true` on a field.\n */\nexport type SettingsFieldSchema = {\n type?: string\n title?: string\n description?: string\n default?: unknown\n enum?: unknown[]\n enumNames?: string[]\n items?: SettingsFieldSchema | SettingsFieldSchema[]\n properties?: SettingsSchemaProperties\n required?: string[]\n [keyword: string]: unknown\n}\n\n/** A map of fields — see `ConnectorOptions.settingsSchema`. */\nexport type SettingsSchemaProperties = { [field: string]: SettingsFieldSchema }\n\nexport type ConnectorInitialized = {\n options: ConnectorOptions\n}\n\nexport type OpenFrame = {\n options: OpenFrameOptions\n}\n\nexport type OpenLocalFrame = {\n options: OpenFrameOptions\n}\n\nexport type EnumerateMediaDevices = {\n requestId: string\n}\n\nexport type OpenStream = {\n requestId: string\n streamId: string\n constraints: MediaStreamConstraints\n}\n\nexport type OpenStreamFrame = {\n constraints?: MediaStreamConstraints\n streamSourceUrl?: string\n requestId: string\n frameConnectorId: string\n name: string\n url: string\n allowFullscreen?: boolean\n /**\n * @deprecated Use menuVisibility property vitre v20\n */\n hideMenu?: boolean\n startPosition?: LayoutPosition\n startPositions?: LayoutPositionWithRules[]\n interaction?: Interaction\n resizeMode?: ResizeMode\n mode?: ViewMode\n data?: any\n file?: FileData\n privacy?: FramePrivacy\n mirrorInitiatorStream?: boolean\n size?: Size\n minSize?: Size\n maxSize?: Size\n startInteractive?: boolean\n border?: BorderOptions\n positionType?: PositionType\n voiceActions?: VoiceAction[]\n visibility?: Visibility\n menuVisibility?: MenuVisibility\n closable?: boolean\n closeLabel?: string\n}\n\nexport type SetRootMenu = {\n menu: RootMenuEntry[]\n}\n\nexport type SettingsSchema = {\n /** A map of fields, NOT a full JSON schema — see `ConnectorOptions.settingsSchema`. */\n schema: SettingsSchemaProperties\n schemaUI: any\n}\n\nexport type SetFramePosition = {\n frameConnectorId: string\n position: LayoutPosition\n}\n\nexport type CloseFrame = {\n frameConnectorId: string\n}\n\nexport type SetFrameOwner = {\n frameConnectorId: string\n /** Device id of the new owner (HostInformation.devicesInSpace[].id). */\n owner: string\n}\n\n/// Live update of an already-open frame's shared-content style (background /\n/// box-shadow / drop-shadow surface, and companion icon). Emitted by\n/// `connector.setChromeStyle`. Only the provided fields are changed; the others\n/// keep their current value.\nexport type SetChromeStyle = {\n frameConnectorId: string\n} & ChromeStyle\n\n/// Host→app notification that an already-open shared frame's owner was\n/// reassigned via `setFrameOwner`, INCLUDING changes initiated by another\n/// device in the space. Surfaced on the SDK `Connector` as\n/// `onFrameOwnerChanged`. `owner` is the new owner's device id\n/// (HostInformation.devicesInSpace[].id).\nexport type FrameOwnerChanged = {\n frameConnectorId: string\n owner: string\n}\n\n/**\n * @deprecated Use `SetShareTargets` (`setShareTargets`).\n */\nexport type SetShareTarget = {\n shareTarget: ShareTargetOptions\n}\n\nexport type SetShareTargets = {\n shareTargets: ShareTargetOptions[]\n}\n\nexport type FrameUnloaded = {\n frameConnectorId: string\n}\n\nexport type FrameInfo = {\n frameConnectorId: string\n zIndex: number\n}\n\nexport type ShareDataReceived = {\n data: ShareData\n}\n\nexport type FileShareDataReceived = {\n data: FileData\n}\n\nexport type ShareData = {\n url: string\n}\n\nexport type TrackKind = 'audio' | 'video'\n\nexport type MediaTrackInfo = {\n id: string\n kind: TrackKind\n deviceName: string\n capabilities: MediaTrackCapabilities\n settings: MediaTrackSettings\n}\n\nexport type OpenStreamCompleted = {\n requestId: string\n streamId: string\n error?: string\n tracks?: MediaTrackInfo[]\n}\n\n/// One track of an app-provided shared stream. `readable` is the transferable\n/// output of a `MediaStreamTrackProcessor` (breakout box) — the host rebuilds a\n/// live `MediaStreamTrack` from it via `MediaStreamTrackGenerator`. Listed in\n/// the postMessage transfer list, so the host receives the SAME stream\n/// zero-copy (no re-encode) — works only when app and host are same-site\n/// (e.g. `*.apps.lavit.re` ↔ `app.lavit.re`) and Chromium.\nexport type ShareStreamTrack = {\n kind: TrackKind\n readable: ReadableStream\n settings?: MediaTrackSettings\n}\n\nexport type ShareStreamOptions = {\n /** Display label for the share (defaults to the app name). */\n name?: string\n /** Source resolution hint, used by the host to size the share. */\n width?: number\n height?: number\n /**\n * Controls how remote peers render this shared stream.\n *\n * - `'appFrame'` (default when absent): receivers load the app iframe, exactly\n * as before this field existed. N-1 receivers that do not know this field\n * will behave as `'appFrame'` automatically (backward-compatible).\n * - `'standard'`: receivers render a classic shared-video languette without\n * loading the app iframe. Use when the app provides raw video/audio and the\n * frame UI is not meaningful on the receiver side (e.g. a camera feed).\n */\n receiverDisplay?: 'standard' | 'appFrame'\n}\n\nexport type ShareStream = {\n requestId: string\n sharedStreamId: string\n options?: ShareStreamOptions\n tracks: ShareStreamTrack[]\n}\n\n/// Swap the source track(s) of an already-open app share WITHOUT closing it.\n/// The host swaps the underlying track in place (sender.replaceTrack on the\n/// vitre→peer side, no renegotiation), so peers see continuity.\nexport type ReplaceShareStream = {\n requestId: string\n sharedStreamId: string\n tracks: ShareStreamTrack[]\n}\n\nexport type StopShareStream = {\n sharedStreamId: string\n}\n\nexport type ShareStreamCompleted = {\n requestId: string\n sharedStreamId: string\n error?: string\n}\n\nexport type OpenStreamFrameCompleted = {\n requestId: string\n error?: string\n tracks?: MediaTrackInfo[]\n streamSourceUrl?: string\n}\n\nexport type EnumerateMediaDevicesCompleted = {\n requestId: string\n devices: ConnectedMediaDevice[]\n}\n\nexport type FramePositionUpdated = {\n frameConnectorId: string\n} & PositionUpdated\n\nexport type ExternalMessageReceived = {\n requestId: string\n appId: string\n message: any\n apiKeyId: string\n apiKeyName: string\n}\n\nexport type ExternalMessageResponseData = {\n requestId: string\n response?: any\n}\n\nexport type RequestAppTokenData = {\n requestId: string\n}\n\nexport type AppTokenReceivedData = {\n requestId: string\n token?: string\n error?: string\n}\n\nexport type ExecuteInFrameData = {\n requestId: string\n /** Must match the `name` attribute of the <iframe> embedded in frame.html. */\n frameName: string\n /** Runs as a function body — use `return <expr>` to yield a value. */\n code: string\n}\n\nexport type ExecuteInFrameResultData = {\n requestId: string\n /** JSON string of the injected code's return value; absent on error. */\n result?: string\n error?: string\n}\n\nexport type SetFrameSize = {\n frameId: string\n size: Size\n}\n\n/// Inbound to a Vitre `Connector` from a companion-side\n/// `CompanionConnector` (same `appId`). `fromCompanionId` is the\n/// connection-id of the sending companion so the Vitre connector can reply\n/// targeted-back via `sendMessageToCompanionConnector`.\nexport type MessageFromCompanionConnector = {\n fromCompanionId: string\n message: string\n fileData?: FileData\n}\n\n/// Inbound to a Vitre `Connector` when a companion FRAME sent a message via\n/// `CompanionFrame.sendMessageToVitreConnector` (works for a local companion\n/// frame with no paired Vitre frame). Carries the `frameConnectorId` of the\n/// companion frame that spoke, on top of the connector-message shape.\nexport type MessageFromCompanionFrame = {\n fromCompanionId: string\n frameConnectorId: string\n message: string\n fileData?: FileData\n}\n\n/// Inbound to a Vitre `Connector` when a connected companion clicks a\n/// menu entry that lives on a frame's options menu AND was declared with\n/// `availability: 'companion'` (or `'companionAdmin'`). The click did NOT\n/// fire on the Vitre — it fired on the companion-side render of the\n/// frame's options. The Vitre-side connector receives this so the app\n/// can react (typically: call `openCompanionFrame` from the companion's\n/// main connector, or push state into the frame). Distinct from\n/// `menuClicked` so apps that only care about Vitre-side menu clicks\n/// don't get woken up by companion clicks.\n///\n/// `frameConnectorId` is the id of the frame whose options menu was\n/// clicked; `fromCompanionId` is the connection-id of the clicker so\n/// targeted reactions are possible.\nexport type FrameMenuClickedOnCompanion = {\n frameConnectorId: string\n fromCompanionId: string\n menuId: string\n isChecked: boolean\n tag?: any\n}\n\n/// Target for `sendMessageToCompanionConnector` — broadcast to every\n/// companion currently connected to the Vitre, or address a single\n/// companion by id. Discriminated on `kind` so the union is unambiguous\n/// for callers and for the host that routes on this shape (a structural\n/// `{ all: true } | { companionId }` would let `{ all: true, companionId }`\n/// slip past the type system via an intermediate variable).\nexport type CompanionConnectorTarget =\n | { kind: 'all' }\n | { kind: 'one'; companionId: string }\n\n/// Payload emitted by a Vitre `Connector` when it wants to talk to the\n/// companion-side `CompanionConnector` for the same `appId`.\nexport type SendMessageToCompanionConnector = {\n target: CompanionConnectorTarget\n message: string\n fileData?: FileData\n}\n\nexport type ConnectorApiMessagesIn =\n | ({ type: 'devicePrivacyChanged' } & DevicePrivacyChanged)\n | ({ type: 'initialize' } & InitializeConnector)\n | ({ type: 'deviceJoined' } & DeviceJoined)\n | ({ type: 'deviceLeft' } & DeviceLeft)\n | ({ type: 'deviceMessageReceived' } & DeviceMessageReceived)\n | ({ type: 'deviceFullscreenUpdated' } & DeviceFullscreenUpdated)\n | ({ type: 'menuClicked' } & MenuClicked)\n | ({ type: 'fieldUpdated' } & FieldUpdated)\n | ({ type: 'shareDataReceived' } & ShareDataReceived)\n | ({ type: 'fileShareDataReceived' } & FileShareDataReceived)\n | ({ type: 'frameLoaded' } & FrameInfo)\n | ({ type: 'frameConnectorLoaded' } & FrameInfo)\n | ({ type: 'frameConnectorLoading' } & OpenFrame)\n | ({ type: 'privacyChanged' } & PrivacyChanged)\n | ({ type: 'frameUnloaded' } & FrameUnloaded)\n | ({\n type: 'enumerateMediaDevicesCompleted'\n } & EnumerateMediaDevicesCompleted)\n | ({ type: 'openStreamCompleted' } & OpenStreamCompleted)\n | ({ type: 'openStreamFrameCompleted' } & OpenStreamFrameCompleted)\n | ({ type: 'shareStreamCompleted' } & ShareStreamCompleted)\n | ({\n type: 'enumerateLoadedFramesCompleted'\n } & EnumerateLoadedFramesCompleted)\n | ({ type: 'localConnectorMessageReceived' } & LocalConnectorMessageReceived)\n | ({ type: 'extensionMessage' } & AppMessage)\n | ({ type: 'vitreSettingsResponse' } & VitreSettings)\n | ({ type: 'knockKnockReceived' } & KnockKnock)\n | ({ type: 'settingsUpdated' } & SettingsUpdated)\n | ({ type: 'vitreSettingsUpdated' } & VitreSettings)\n | ({ type: 'notificationDismissed' } & NotificationDismissed)\n | ({ type: 'notificationButtonClicked' } & NotificationButtonClicked)\n | ({ type: 'frameZIndexChanged' } & FrameInfo)\n | ({ type: 'deviceFrameLoaded' } & DeviceFrameReference)\n | ({ type: 'deviceFrameUnloaded' } & DeviceFrameReference)\n | ({ type: 'deviceFrameConnectorLoaded' } & DeviceFrameReference)\n | ({ type: 'pendingDevicesConnectionRequested' } & PendingDevicesInfo)\n | ({ type: 'appMessage' } & AppMessage)\n | ({ type: 'voiceActionDetected' } & VoiceActionDetection)\n | ({ type: 'framePositionUpdated' } & FramePositionUpdated)\n | ({ type: 'deviceScalingUpdated' } & DeviceScalingUpdated)\n | ({ type: 'stateReplaced' } & StateReplaced)\n | ({ type: 'statsResponse' } & StatsResponse)\n | ({ type: 'serialPortAccessResult'; requestId: string } & SerialPortAccessResult)\n | ({ type: 'frameOwnerChanged' } & FrameOwnerChanged)\n | ({ type: 'connectionCodeUpdated' } & ConnectionCodeUpdated)\n | ({ type: 'externalMessageReceived' } & ExternalMessageReceived)\n | ({ type: 'appTokenReceived' } & AppTokenReceivedData)\n | ({ type: 'executeInFrameResult' } & ExecuteInFrameResultData)\n | ({ type: 'mediaDevicesChanged' } & MediaDevicesChanged)\n | { type: 'crdtUpdate'; update: ArrayBufferLike }\n | { type: 'crdtSyncComplete' }\n | { type: 'crdtRequestSync' }\n | { type: 'crdtAwarenessUpdate'; update: ArrayBufferLike }\n | { type: 'crdtSubdocUpdate'; guid: string; update: ArrayBufferLike }\n | { type: 'crdtSubdocSyncComplete'; guid: string }\n | {\n type: 'crdtSubdocTransferProgress'\n guid: string\n receivedBytes: number\n totalBytes: number\n }\n | { type: 'crdtSubdocRequestSync'; guid: string }\n | ({\n type: 'messageFromCompanionConnector'\n } & MessageFromCompanionConnector)\n | ({\n type: 'messageFromCompanionFrame'\n } & MessageFromCompanionFrame)\n | ({\n type: 'frameMenuClickedOnCompanion'\n } & FrameMenuClickedOnCompanion)\n\nexport type MediaDevicesChanged = {\n devices: ConnectedMediaDevice[]\n}\n\nexport type ConnectorApiMessagesOut =\n | ({ type: 'sendMessageTo' } & SendMessageTo)\n | ({ type: 'sendMessageToAll' } & SendMessageToAll)\n | ({ type: 'connectorInitialized' } & ConnectorInitialized)\n | ({ type: 'openFrame' } & OpenFrame)\n | ({ type: 'openLocalFrame' } & OpenLocalFrame)\n | ({ type: 'sendToLocalFrame' } & SendToLocalFrame)\n | ({ type: 'enumerateMediaDevices' } & EnumerateMediaDevices)\n | ({ type: 'openStream' } & OpenStream)\n | ({ type: 'openStreamFrame' } & OpenStreamFrame)\n | ({ type: 'shareStream' } & ShareStream)\n | ({ type: 'replaceShareStream' } & ReplaceShareStream)\n | ({ type: 'stopShareStream' } & StopShareStream)\n | ({ type: 'setRootMenu' } & SetRootMenu)\n | ({ type: 'enumerateLoadedFrames' } & EnumerateLoadedFrames)\n | ({ type: 'setShareTarget' } & SetShareTarget)\n | ({ type: 'setShareTargets' } & SetShareTargets)\n | ({ type: 'extensionMessage' } & AppMessage)\n | ({ type: 'appMessage' } & AppMessage)\n | { type: 'getVitreSettings' }\n | ({ type: 'setVitreSettings' } & VitreSettingsSetter)\n | ({ type: 'shareFile' } & ShareFileRequest)\n | ({ type: 'shareData' } & ShareDataRequest)\n | ({ type: 'saveSettings' } & SaveSettings)\n | ({ type: 'changeTeamSpace' } & ChangeTeamSpace)\n | ({ type: 'changeTeamSpaceGuest' } & ChangeTeamSpaceGuest)\n | ({ type: 'showNotification' } & NotificationInfo)\n | ({ type: 'hideNotification' } & HideNotification)\n | ({ type: 'changePrivacy' } & ChangePrivacy)\n | ({ type: 'trackEvent' } & EventTelemetry)\n | ({ type: 'startTrackEvent' } & StartEventTelemetry)\n | ({ type: 'stopTrackEvent' } & EventTelemetry)\n | ({ type: 'setSettingsSchema' } & SettingsSchema)\n | { type: 'setVoiceActions'; actions: VoiceAction[] }\n | ({ type: 'closeFrame' } & CloseFrame)\n | ({ type: 'setFrameOwner' } & SetFrameOwner)\n | ({ type: 'setChromeStyle' } & SetChromeStyle)\n | ({ type: 'setFramePosition' } & SetFramePosition)\n | ({ type: 'updateState' } & UpdateState)\n | ({ type: 'sendKnockKnock' } & SendKnockKnock)\n | ({ type: 'getStats' } & GetStats)\n | ({ type: 'setReducedAudioMode' } & SetReducedAudioMode)\n | ({ type: 'externalMessageResponse' } & ExternalMessageResponseData)\n | ({ type: 'requestAppToken' } & RequestAppTokenData)\n | ({ type: 'executeInFrame' } & ExecuteInFrameData)\n | ({ type: 'setFrameSize' } & SetFrameSize)\n | ({ type: 'sendToSerialPort' } & SendToSerialPort)\n | ({ type: 'requestSerialPortAccess'; requestId: string } & RequestSerialPortAccess)\n | { type: 'crdtUpdate'; update: ArrayBufferLike }\n | { type: 'crdtRequestSync' }\n | { type: 'crdtAwarenessUpdate'; update: ArrayBufferLike }\n | { type: 'crdtRequestAwareness' }\n | { type: 'crdtSubdocUpdate'; guid: string; update: ArrayBufferLike }\n | { type: 'crdtSubdocRequestSync'; guid: string }\n | ({\n type: 'sendMessageToCompanionConnector'\n } & SendMessageToCompanionConnector)\n"]}
1
+ {"version":3,"file":"Connector.Model.js","sourceRoot":"","sources":["../../Connector/Connector.Model.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AppMessage,\n AppSettingsChanged,\n AppSettingsResponse,\n BorderOptions,\n ChangePrivacy,\n ChangeTeamSpace,\n ChangeTeamSpaceGuest,\n ChromeStyle,\n ConnectedMediaDevice,\n ConnectionCodeUpdated,\n DeletePublicFile,\n DeviceFrameReference,\n DeviceFullscreenUpdated,\n DeviceJoined,\n DeviceLeft,\n DeviceMessageReceived,\n DevicePrivacyChanged,\n DeviceScalingUpdated,\n EnumerateLoadedFrames,\n EnumerateLoadedFramesCompleted,\n EventTelemetry,\n FieldUpdated,\n FileData,\n FramePrivacy,\n GetAppSettings,\n GetStats,\n HideNotification,\n HostInformation,\n Interaction,\n KnockKnock,\n LayoutPosition,\n LayoutPositionWithRules,\n ListPublicFiles,\n LocalConnectorMessageReceived,\n MenuClicked,\n MenuEntry,\n MenuVisibility,\n NotificationButtonClicked,\n NotificationDismissed,\n NotificationInfo,\n OpenFrameOptions,\n PendingDevicesInfo,\n PositionType,\n PositionUpdated,\n PrivacyChanged,\n PublicStorageResponse,\n PutPublicFile,\n DeletePrivateFile,\n GetPrivateFile,\n GetPrivateFileLink,\n ListPrivateFiles,\n PrivateStorageResponse,\n PutPrivateFile,\n RequestSerialPortAccess,\n SerialPortAccessResult,\n ResizeMode,\n SaveSettings,\n SendKnockKnock,\n SendMessageTo,\n SendMessageToAll,\n SendToLocalFrame,\n SendToSerialPort,\n SetAppSettings,\n SetReducedAudioMode,\n SettingsUpdated,\n ShareDataRequest,\n ShareFileRequest,\n Size,\n StartEventTelemetry,\n StateReplaced,\n StatsResponse,\n UpdateState,\n ViewMode,\n Visibility,\n VitreSettings,\n VitreSettingsSetter,\n VoiceAction,\n VoiceActionDetection,\n} from '../Common/index.js'\n\nexport type InitializeConnector = {\n hostInfo: HostInformation\n appId?: string\n state?: Record<string, any>\n}\n\nexport type RegExpDefinition = {\n pattern: string\n options: string\n}\n\nexport type ShareTargetOptions = {\n name?: string\n urlDomains?: string[]\n urlRegex?: string[]\n urlRegexWithOptions?: RegExpDefinition[]\n files?: FileShareTarget[]\n /**\n * Icon shown for this share target in the companion import picker. A bitmap\n * (full colour). May be a path relative to the connector URL — the host\n * resolves it to an absolute URL. When both `iconUrl` and `maskIconUrl` are\n * set, the companion prefers `maskIconUrl`. When neither is set the picker\n * falls back to the app icon (`ConnectorOptions.iconUrl`).\n */\n iconUrl?: string\n /**\n * Monochrome mask icon for this share target, tinted by the companion theme\n * (CSS `mask`). May be relative to the connector URL — resolved absolute by\n * the host. Preferred over `iconUrl` when both are set.\n */\n maskIconUrl?: string\n}\n\nexport type FileShareTarget = {\n fileExtension?: string\n fileExtensionRegex?: RegExpDefinition\n binaryHeader?: ArrayBufferLike\n mimeTypes?: string[]\n tag?: any\n id: string\n}\n\nexport type MenuCategoryInfo = {\n type: 'mainMenu'\n label?: string\n description?: string\n order?: number\n}\n\nexport type SettingsMenuCategoryInfo = {\n type: 'settingsMenu'\n label?: string\n description?: string\n}\n\nexport type MainMenuQuickActions = {\n type: 'mainMenuQuickActions'\n label?: string\n description?: string\n order?: number\n}\n\nexport type ExportMenuCategory = {\n type: 'exportMenu'\n label?: string\n description?: string\n order?: number\n}\n\nexport type RootMenuCategory =\n | { type: 'desktopIcons' }\n | MainMenuQuickActions\n | MenuCategoryInfo\n | SettingsMenuCategoryInfo\n | ExportMenuCategory\n\nexport type RootMenuEntry = Omit<MenuEntry, 'category'> & {\n category?: RootMenuCategory\n}\n\nexport type ConnectorOptions = {\n name: string\n iconUrl?: string\n menu?: RootMenuEntry[]\n /**\n * @deprecated Use `shareTargets`. When `shareTargets` is set the host uses it\n * and ignores this field. Kept on the wire for older Vitres that only read a\n * single share target — the SDK mirrors `shareTargets[0]` here automatically.\n */\n shareTarget?: ShareTargetOptions\n /**\n * Share targets advertised by this app. Several may be declared so an app can\n * receive distinct kinds of content (each with its own `name`/matchers). When\n * provided, this supersedes the deprecated singular `shareTarget`.\n */\n shareTargets?: ShareTargetOptions[]\n /**\n * The app's settings, rendered by the la Vitre settings form and read back from\n * `hostInformation.settings`.\n *\n * This is a **map of fields**, NOT a full JSON schema: one key per setting, the\n * same keys as `hostInformation.settings`. The host builds the enclosing\n * `{ type: 'object', title: <app name>, properties: … }` itself.\n *\n * ```ts\n * // RIGHT\n * settingsSchema: {\n * city: { type: 'string', title: 'City', default: 'Paris' },\n * layout: { type: 'object', title: 'Layout', properties: { columns: { type: 'number' } } },\n * }\n * // WRONG — a full JSON schema\n * settingsSchema: { type: 'object', properties: { city: { type: 'string' } } }\n * ```\n */\n settingsSchema?: SettingsSchemaProperties\n /** react-jsonschema-form `uiSchema`, keyed like `settingsSchema` (one entry per field). */\n settingsSchemaUI?: any\n voiceActions?: VoiceAction[]\n}\n\n/**\n * One setting: the JSON-Schema subset the la Vitre settings form renders\n * (`string`, `number`, `boolean`, `enum`, `array` with `items`, `object` with\n * `properties`). Every nested `properties` value and `items` is itself a\n * `SettingsFieldSchema` object, never a bare string; `required` is a list of key\n * names on the enclosing object, never `required: true` on a field.\n */\nexport type SettingsFieldSchema = {\n type?: string\n title?: string\n description?: string\n default?: unknown\n enum?: unknown[]\n enumNames?: string[]\n items?: SettingsFieldSchema | SettingsFieldSchema[]\n properties?: SettingsSchemaProperties\n required?: string[]\n [keyword: string]: unknown\n}\n\n/** A map of fields — see `ConnectorOptions.settingsSchema`. */\nexport type SettingsSchemaProperties = { [field: string]: SettingsFieldSchema }\n\nexport type ConnectorInitialized = {\n options: ConnectorOptions\n}\n\nexport type OpenFrame = {\n options: OpenFrameOptions\n}\n\nexport type OpenLocalFrame = {\n options: OpenFrameOptions\n}\n\nexport type EnumerateMediaDevices = {\n requestId: string\n}\n\nexport type OpenStream = {\n requestId: string\n streamId: string\n constraints: MediaStreamConstraints\n}\n\nexport type OpenStreamFrame = {\n constraints?: MediaStreamConstraints\n streamSourceUrl?: string\n requestId: string\n frameConnectorId: string\n name: string\n url: string\n allowFullscreen?: boolean\n /**\n * @deprecated Use menuVisibility property vitre v20\n */\n hideMenu?: boolean\n startPosition?: LayoutPosition\n startPositions?: LayoutPositionWithRules[]\n interaction?: Interaction\n resizeMode?: ResizeMode\n mode?: ViewMode\n data?: any\n file?: FileData\n privacy?: FramePrivacy\n mirrorInitiatorStream?: boolean\n size?: Size\n minSize?: Size\n maxSize?: Size\n startInteractive?: boolean\n border?: BorderOptions\n positionType?: PositionType\n voiceActions?: VoiceAction[]\n visibility?: Visibility\n menuVisibility?: MenuVisibility\n closable?: boolean\n closeLabel?: string\n}\n\nexport type SetRootMenu = {\n menu: RootMenuEntry[]\n}\n\nexport type SettingsSchema = {\n /** A map of fields, NOT a full JSON schema — see `ConnectorOptions.settingsSchema`. */\n schema: SettingsSchemaProperties\n schemaUI: any\n}\n\nexport type SetFramePosition = {\n frameConnectorId: string\n position: LayoutPosition\n}\n\nexport type CloseFrame = {\n frameConnectorId: string\n}\n\nexport type SetFrameOwner = {\n frameConnectorId: string\n /** Device id of the new owner (HostInformation.devicesInSpace[].id). */\n owner: string\n}\n\n/// Live update of an already-open frame's shared-content style (background /\n/// box-shadow / drop-shadow surface, and companion icon). Emitted by\n/// `connector.setChromeStyle`. Only the provided fields are changed; the others\n/// keep their current value.\nexport type SetChromeStyle = {\n frameConnectorId: string\n} & ChromeStyle\n\n/// Host→app notification that an already-open shared frame's owner was\n/// reassigned via `setFrameOwner`, INCLUDING changes initiated by another\n/// device in the space. Surfaced on the SDK `Connector` as\n/// `onFrameOwnerChanged`. `owner` is the new owner's device id\n/// (HostInformation.devicesInSpace[].id).\nexport type FrameOwnerChanged = {\n frameConnectorId: string\n owner: string\n}\n\n/**\n * @deprecated Use `SetShareTargets` (`setShareTargets`).\n */\nexport type SetShareTarget = {\n shareTarget: ShareTargetOptions\n}\n\nexport type SetShareTargets = {\n shareTargets: ShareTargetOptions[]\n}\n\nexport type FrameUnloaded = {\n frameConnectorId: string\n}\n\nexport type FrameInfo = {\n frameConnectorId: string\n zIndex: number\n}\n\nexport type ShareDataReceived = {\n data: ShareData\n}\n\nexport type FileShareDataReceived = {\n data: FileData\n}\n\nexport type ShareData = {\n url: string\n}\n\nexport type TrackKind = 'audio' | 'video'\n\nexport type MediaTrackInfo = {\n id: string\n kind: TrackKind\n deviceName: string\n capabilities: MediaTrackCapabilities\n settings: MediaTrackSettings\n}\n\nexport type OpenStreamCompleted = {\n requestId: string\n streamId: string\n error?: string\n tracks?: MediaTrackInfo[]\n}\n\n/// One track of an app-provided shared stream. `readable` is the transferable\n/// output of a `MediaStreamTrackProcessor` (breakout box) — the host rebuilds a\n/// live `MediaStreamTrack` from it via `MediaStreamTrackGenerator`. Listed in\n/// the postMessage transfer list, so the host receives the SAME stream\n/// zero-copy (no re-encode) — works only when app and host are same-site\n/// (e.g. `*.apps.lavit.re` ↔ `app.lavit.re`) and Chromium.\nexport type ShareStreamTrack = {\n kind: TrackKind\n readable: ReadableStream\n settings?: MediaTrackSettings\n}\n\nexport type ShareStreamOptions = {\n /** Display label for the share (defaults to the app name). */\n name?: string\n /** Source resolution hint, used by the host to size the share. */\n width?: number\n height?: number\n /**\n * Controls how remote peers render this shared stream.\n *\n * - `'appFrame'` (default when absent): receivers load the app iframe, exactly\n * as before this field existed. N-1 receivers that do not know this field\n * will behave as `'appFrame'` automatically (backward-compatible).\n * - `'standard'`: receivers render a classic shared-video languette without\n * loading the app iframe. Use when the app provides raw video/audio and the\n * frame UI is not meaningful on the receiver side (e.g. a camera feed).\n */\n receiverDisplay?: 'standard' | 'appFrame'\n}\n\nexport type ShareStream = {\n requestId: string\n sharedStreamId: string\n options?: ShareStreamOptions\n tracks: ShareStreamTrack[]\n}\n\n/// Swap the source track(s) of an already-open app share WITHOUT closing it.\n/// The host swaps the underlying track in place (sender.replaceTrack on the\n/// vitre→peer side, no renegotiation), so peers see continuity.\nexport type ReplaceShareStream = {\n requestId: string\n sharedStreamId: string\n tracks: ShareStreamTrack[]\n}\n\nexport type StopShareStream = {\n sharedStreamId: string\n}\n\nexport type ShareStreamCompleted = {\n requestId: string\n sharedStreamId: string\n error?: string\n}\n\nexport type OpenStreamFrameCompleted = {\n requestId: string\n error?: string\n tracks?: MediaTrackInfo[]\n streamSourceUrl?: string\n}\n\nexport type EnumerateMediaDevicesCompleted = {\n requestId: string\n devices: ConnectedMediaDevice[]\n}\n\nexport type FramePositionUpdated = {\n frameConnectorId: string\n} & PositionUpdated\n\nexport type ExternalMessageReceived = {\n requestId: string\n appId: string\n message: any\n apiKeyId: string\n apiKeyName: string\n}\n\nexport type ExternalMessageResponseData = {\n requestId: string\n response?: any\n}\n\nexport type RequestAppTokenData = {\n requestId: string\n}\n\nexport type AppTokenReceivedData = {\n requestId: string\n token?: string\n error?: string\n}\n\nexport type ExecuteInFrameData = {\n requestId: string\n /** Must match the `name` attribute of the <iframe> embedded in frame.html. */\n frameName: string\n /** Runs as a function body — use `return <expr>` to yield a value. */\n code: string\n}\n\nexport type ExecuteInFrameResultData = {\n requestId: string\n /** JSON string of the injected code's return value; absent on error. */\n result?: string\n error?: string\n}\n\nexport type SetFrameSize = {\n frameId: string\n size: Size\n}\n\n/// Inbound to a Vitre `Connector` from a companion-side\n/// `CompanionConnector` (same `appId`). `fromCompanionId` is the\n/// connection-id of the sending companion so the Vitre connector can reply\n/// targeted-back via `sendMessageToCompanionConnector`.\nexport type MessageFromCompanionConnector = {\n fromCompanionId: string\n message: string\n fileData?: FileData\n}\n\n/// Inbound to a Vitre `Connector` when a companion FRAME sent a message via\n/// `CompanionFrame.sendMessageToVitreConnector` (works for a local companion\n/// frame with no paired Vitre frame). Carries the `frameConnectorId` of the\n/// companion frame that spoke, on top of the connector-message shape.\nexport type MessageFromCompanionFrame = {\n fromCompanionId: string\n frameConnectorId: string\n message: string\n fileData?: FileData\n}\n\n/// Inbound to a Vitre `Connector` when a connected companion clicks a\n/// menu entry that lives on a frame's options menu AND was declared with\n/// `availability: 'companion'` (or `'companionAdmin'`). The click did NOT\n/// fire on the Vitre — it fired on the companion-side render of the\n/// frame's options. The Vitre-side connector receives this so the app\n/// can react (typically: call `openCompanionFrame` from the companion's\n/// main connector, or push state into the frame). Distinct from\n/// `menuClicked` so apps that only care about Vitre-side menu clicks\n/// don't get woken up by companion clicks.\n///\n/// `frameConnectorId` is the id of the frame whose options menu was\n/// clicked; `fromCompanionId` is the connection-id of the clicker so\n/// targeted reactions are possible.\nexport type FrameMenuClickedOnCompanion = {\n frameConnectorId: string\n fromCompanionId: string\n menuId: string\n isChecked: boolean\n tag?: any\n}\n\n/// Target for `sendMessageToCompanionConnector` — broadcast to every\n/// companion currently connected to the Vitre, or address a single\n/// companion by id. Discriminated on `kind` so the union is unambiguous\n/// for callers and for the host that routes on this shape (a structural\n/// `{ all: true } | { companionId }` would let `{ all: true, companionId }`\n/// slip past the type system via an intermediate variable).\nexport type CompanionConnectorTarget =\n | { kind: 'all' }\n | { kind: 'one'; companionId: string }\n\n/// Payload emitted by a Vitre `Connector` when it wants to talk to the\n/// companion-side `CompanionConnector` for the same `appId`.\nexport type SendMessageToCompanionConnector = {\n target: CompanionConnectorTarget\n message: string\n fileData?: FileData\n}\n\nexport type ConnectorApiMessagesIn =\n | ({ type: 'devicePrivacyChanged' } & DevicePrivacyChanged)\n | ({ type: 'initialize' } & InitializeConnector)\n | ({ type: 'deviceJoined' } & DeviceJoined)\n | ({ type: 'deviceLeft' } & DeviceLeft)\n | ({ type: 'deviceMessageReceived' } & DeviceMessageReceived)\n | ({ type: 'deviceFullscreenUpdated' } & DeviceFullscreenUpdated)\n | ({ type: 'menuClicked' } & MenuClicked)\n | ({ type: 'fieldUpdated' } & FieldUpdated)\n | ({ type: 'shareDataReceived' } & ShareDataReceived)\n | ({ type: 'fileShareDataReceived' } & FileShareDataReceived)\n | ({ type: 'frameLoaded' } & FrameInfo)\n | ({ type: 'frameConnectorLoaded' } & FrameInfo)\n | ({ type: 'frameConnectorLoading' } & OpenFrame)\n | ({ type: 'privacyChanged' } & PrivacyChanged)\n | ({ type: 'frameUnloaded' } & FrameUnloaded)\n | ({\n type: 'enumerateMediaDevicesCompleted'\n } & EnumerateMediaDevicesCompleted)\n | ({ type: 'openStreamCompleted' } & OpenStreamCompleted)\n | ({ type: 'openStreamFrameCompleted' } & OpenStreamFrameCompleted)\n | ({ type: 'shareStreamCompleted' } & ShareStreamCompleted)\n | ({\n type: 'enumerateLoadedFramesCompleted'\n } & EnumerateLoadedFramesCompleted)\n | ({ type: 'localConnectorMessageReceived' } & LocalConnectorMessageReceived)\n | ({ type: 'extensionMessage' } & AppMessage)\n | ({ type: 'vitreSettingsResponse' } & VitreSettings)\n | ({ type: 'knockKnockReceived' } & KnockKnock)\n | ({ type: 'settingsUpdated' } & SettingsUpdated)\n | ({ type: 'vitreSettingsUpdated' } & VitreSettings)\n | ({ type: 'notificationDismissed' } & NotificationDismissed)\n | ({ type: 'notificationButtonClicked' } & NotificationButtonClicked)\n | ({ type: 'frameZIndexChanged' } & FrameInfo)\n | ({ type: 'deviceFrameLoaded' } & DeviceFrameReference)\n | ({ type: 'deviceFrameUnloaded' } & DeviceFrameReference)\n | ({ type: 'deviceFrameConnectorLoaded' } & DeviceFrameReference)\n | ({ type: 'pendingDevicesConnectionRequested' } & PendingDevicesInfo)\n | ({ type: 'appMessage' } & AppMessage)\n | ({ type: 'voiceActionDetected' } & VoiceActionDetection)\n | ({ type: 'framePositionUpdated' } & FramePositionUpdated)\n | ({ type: 'deviceScalingUpdated' } & DeviceScalingUpdated)\n | ({ type: 'stateReplaced' } & StateReplaced)\n | ({ type: 'statsResponse' } & StatsResponse)\n | ({ type: 'serialPortAccessResult'; requestId: string } & SerialPortAccessResult)\n | ({ type: 'frameOwnerChanged' } & FrameOwnerChanged)\n | ({ type: 'connectionCodeUpdated' } & ConnectionCodeUpdated)\n | ({ type: 'externalMessageReceived' } & ExternalMessageReceived)\n | ({ type: 'appTokenReceived' } & AppTokenReceivedData)\n | ({ type: 'appSettingsResponse' } & AppSettingsResponse)\n | ({ type: 'appSettingsChanged' } & AppSettingsChanged)\n | ({ type: 'publicStorageResponse' } & PublicStorageResponse)\n | ({ type: 'privateStorageResponse' } & PrivateStorageResponse)\n | ({ type: 'executeInFrameResult' } & ExecuteInFrameResultData)\n | ({ type: 'mediaDevicesChanged' } & MediaDevicesChanged)\n | { type: 'crdtUpdate'; update: ArrayBufferLike }\n | { type: 'crdtSyncComplete' }\n | { type: 'crdtRequestSync' }\n | { type: 'crdtAwarenessUpdate'; update: ArrayBufferLike }\n | { type: 'crdtSubdocUpdate'; guid: string; update: ArrayBufferLike }\n | { type: 'crdtSubdocSyncComplete'; guid: string }\n | {\n type: 'crdtSubdocTransferProgress'\n guid: string\n receivedBytes: number\n totalBytes: number\n }\n | { type: 'crdtSubdocRequestSync'; guid: string }\n | ({\n type: 'messageFromCompanionConnector'\n } & MessageFromCompanionConnector)\n | ({\n type: 'messageFromCompanionFrame'\n } & MessageFromCompanionFrame)\n | ({\n type: 'frameMenuClickedOnCompanion'\n } & FrameMenuClickedOnCompanion)\n\nexport type MediaDevicesChanged = {\n devices: ConnectedMediaDevice[]\n}\n\nexport type ConnectorApiMessagesOut =\n | ({ type: 'sendMessageTo' } & SendMessageTo)\n | ({ type: 'sendMessageToAll' } & SendMessageToAll)\n | ({ type: 'connectorInitialized' } & ConnectorInitialized)\n | ({ type: 'openFrame' } & OpenFrame)\n | ({ type: 'openLocalFrame' } & OpenLocalFrame)\n | ({ type: 'sendToLocalFrame' } & SendToLocalFrame)\n | ({ type: 'enumerateMediaDevices' } & EnumerateMediaDevices)\n | ({ type: 'openStream' } & OpenStream)\n | ({ type: 'openStreamFrame' } & OpenStreamFrame)\n | ({ type: 'shareStream' } & ShareStream)\n | ({ type: 'replaceShareStream' } & ReplaceShareStream)\n | ({ type: 'stopShareStream' } & StopShareStream)\n | ({ type: 'setRootMenu' } & SetRootMenu)\n | ({ type: 'enumerateLoadedFrames' } & EnumerateLoadedFrames)\n | ({ type: 'setShareTarget' } & SetShareTarget)\n | ({ type: 'setShareTargets' } & SetShareTargets)\n | ({ type: 'extensionMessage' } & AppMessage)\n | ({ type: 'appMessage' } & AppMessage)\n | { type: 'getVitreSettings' }\n | ({ type: 'setVitreSettings' } & VitreSettingsSetter)\n | ({ type: 'shareFile' } & ShareFileRequest)\n | ({ type: 'shareData' } & ShareDataRequest)\n | ({ type: 'saveSettings' } & SaveSettings)\n | ({ type: 'getAppSettings' } & GetAppSettings)\n | ({ type: 'setAppSettings' } & SetAppSettings)\n | ({ type: 'putPublicFile' } & PutPublicFile)\n | ({ type: 'deletePublicFile' } & DeletePublicFile)\n | ({ type: 'listPublicFiles' } & ListPublicFiles)\n | ({ type: 'putPrivateFile' } & PutPrivateFile)\n | ({ type: 'deletePrivateFile' } & DeletePrivateFile)\n | ({ type: 'listPrivateFiles' } & ListPrivateFiles)\n | ({ type: 'getPrivateFile' } & GetPrivateFile)\n | ({ type: 'getPrivateFileLink' } & GetPrivateFileLink)\n | ({ type: 'changeTeamSpace' } & ChangeTeamSpace)\n | ({ type: 'changeTeamSpaceGuest' } & ChangeTeamSpaceGuest)\n | ({ type: 'showNotification' } & NotificationInfo)\n | ({ type: 'hideNotification' } & HideNotification)\n | ({ type: 'changePrivacy' } & ChangePrivacy)\n | ({ type: 'trackEvent' } & EventTelemetry)\n | ({ type: 'startTrackEvent' } & StartEventTelemetry)\n | ({ type: 'stopTrackEvent' } & EventTelemetry)\n | ({ type: 'setSettingsSchema' } & SettingsSchema)\n | { type: 'setVoiceActions'; actions: VoiceAction[] }\n | ({ type: 'closeFrame' } & CloseFrame)\n | ({ type: 'setFrameOwner' } & SetFrameOwner)\n | ({ type: 'setChromeStyle' } & SetChromeStyle)\n | ({ type: 'setFramePosition' } & SetFramePosition)\n | ({ type: 'updateState' } & UpdateState)\n | ({ type: 'sendKnockKnock' } & SendKnockKnock)\n | ({ type: 'getStats' } & GetStats)\n | ({ type: 'setReducedAudioMode' } & SetReducedAudioMode)\n | ({ type: 'externalMessageResponse' } & ExternalMessageResponseData)\n | ({ type: 'requestAppToken' } & RequestAppTokenData)\n | ({ type: 'executeInFrame' } & ExecuteInFrameData)\n | ({ type: 'setFrameSize' } & SetFrameSize)\n | ({ type: 'sendToSerialPort' } & SendToSerialPort)\n | ({ type: 'requestSerialPortAccess'; requestId: string } & RequestSerialPortAccess)\n | { type: 'crdtUpdate'; update: ArrayBufferLike }\n | { type: 'crdtRequestSync' }\n | { type: 'crdtAwarenessUpdate'; update: ArrayBufferLike }\n | { type: 'crdtRequestAwareness' }\n | { type: 'crdtSubdocUpdate'; guid: string; update: ArrayBufferLike }\n | { type: 'crdtSubdocRequestSync'; guid: string }\n | ({\n type: 'sendMessageToCompanionConnector'\n } & SendMessageToCompanionConnector)\n"]}
@@ -1,7 +1,9 @@
1
1
  import type * as Y from 'yjs';
2
2
  import { CrdtChannel } from '../Common/CrdtChannel.js';
3
3
  import { BlobStore } from '../Common/BlobStore.js';
4
- import type { AppId, AppMessage, ChromeStyle, ConnectedMediaDevice, Device, DeviceFrameReference, DeviceFullscreenUpdated, DeviceMessageReceived, DeviceScalingUpdated, Field, FileData, HostInformation, KnockKnock, LayoutPosition, MessageTarget, NotificationButtonClicked, NotificationInfo, OpenFrameOptions, Privacy, ReplacedBy, RequestSerialPortAccess, SendKnockKnock, SendMessageTo, SendMessageToAll, SendToSerialPort, Size, StatsResponse, UpdatedStateEntry, UpdateStateEntry, VitreSettings, VitreSettingsSetter, VoiceAction, VoiceActionDetection } from '../Common/index.js';
4
+ import type { PublicStorageApi } from '../Common/PublicStorage.js';
5
+ import type { PrivateStorageApi } from '../Common/PrivateStorage.js';
6
+ import type { AppId, AppMessage, AppSettingsLevel, AppSettingsValue, ChromeStyle, ConnectedMediaDevice, Device, DeviceFrameReference, DeviceFullscreenUpdated, DeviceMessageReceived, DeviceScalingUpdated, Field, FileData, HostInformation, KnockKnock, LayoutPosition, MessageTarget, NotificationButtonClicked, NotificationInfo, OpenFrameOptions, Privacy, ReplacedBy, RequestSerialPortAccess, SendKnockKnock, SendMessageTo, SendMessageToAll, SendToSerialPort, Size, StatsResponse, UpdatedStateEntry, UpdateStateEntry, VitreSettings, VitreSettingsSetter, VoiceAction, VoiceActionDetection } from '../Common/index.js';
5
7
  import type { Frame } from '../Frame/index.js';
6
8
  import type { CompanionConnectorTarget, ExternalMessageReceived, ConnectorApiMessagesIn, ConnectorApiMessagesOut, ConnectorOptions, FrameInfo, FramePositionUpdated, InitializeConnector, MediaTrackInfo, OpenStreamFrame, RootMenuEntry, SettingsSchema, ShareData, ShareStreamOptions, ShareTargetOptions } from './Connector.Model.js';
7
9
  export declare class Connector {
@@ -28,6 +30,13 @@ export declare class Connector {
28
30
  onKnockKnockReceived?: (knockKnock: KnockKnock) => void;
29
31
  onPendingDevicesConnectionRequested?: (pendingClients: Device[]) => void;
30
32
  onSettingsUpdated?: (settings: any) => void;
33
+ /**
34
+ * Pushed whenever the AppSettings value at a given level changes — see
35
+ * {@link getSettings} / {@link setSettings}. Fires for changes made by
36
+ * this app itself as well as by another vitre/app instance sharing the
37
+ * same team/space. Added 1.52.
38
+ */
39
+ onSettingsChanged?: (change: AppSettingsValue) => void;
31
40
  onVitreSettingsUpdated?: (settings: VitreSettings) => void;
32
41
  onConnectionCodeUpdated?: (companionCode?: string) => void;
33
42
  onNotificationDismissed?: (notificationId: string) => void;
@@ -73,6 +82,22 @@ export declare class Connector {
73
82
  * but bare — see BlobStore.
74
83
  */
75
84
  readonly blobs: BlobStore;
85
+ /**
86
+ * Public, unauthenticated file storage scoped to the vitre's TEAM — see
87
+ * the README "Public storage" section for the full semantics (scopes,
88
+ * allowed file types, size cap, path rules). Files are readable by
89
+ * ANYONE at the returned URL — never put private data here.
90
+ */
91
+ readonly publicStorage: PublicStorageApi;
92
+ /**
93
+ * Private file storage scoped to the vitre's TEAM — see the README
94
+ * "Private storage" section for the full semantics. Unlike
95
+ * `publicStorage`, files here have no public link: readable by any
96
+ * vitre or companion of the team via `get` or a temporary `getLink`
97
+ * signed link, never by an anonymous visitor. Write-only on a
98
+ * Vitre-hosted app — `CompanionConnector` only has `list`/`get`/`getLink`.
99
+ */
100
+ readonly privateStorage: PrivateStorageApi;
76
101
  /** @deprecated Use `crdt.doc`. The setter forwards to `crdt.attach(doc)`
77
102
  * so legacy callers that ever assigned `connector.yjsDoc = myDoc` keep
78
103
  * working — without it, getter-only would throw `TypeError: Cannot set
@@ -121,6 +146,13 @@ export declare class Connector {
121
146
  * share action.
122
147
  */
123
148
  canShareStream(): boolean;
149
+ /** Normalize `publicStorage.put`'s payload to a plain `ArrayBuffer` —
150
+ * slicing out exactly a typed array's view (not its whole underlying
151
+ * buffer, in case it's a subarray) so the transferred bytes match the
152
+ * size the caller intended. */
153
+ private toPublicFileBuffer;
154
+ /** Same normalization as {@link toPublicFileBuffer}, for `privateStorage.put`. */
155
+ private toPrivateFileBuffer;
124
156
  private toShareTracks;
125
157
  /**
126
158
  * Share a camera/microphone (or any) `MediaStream` the app controls TO the
@@ -175,6 +207,33 @@ export declare class Connector {
175
207
  */
176
208
  shareFile(fileData: FileData, targetAppId: AppId, owner?: string): void;
177
209
  saveSettings(settings: any): void;
210
+ /**
211
+ * Read the app's settings at one of the three levels — `vitre` (this
212
+ * vitre), `team` (the vitre's team), or `space` (the space the vitre is
213
+ * currently in). Every vitre/app instance of the team can read the same
214
+ * value; values are JSON objects capped at 64 KB — never store secrets.
215
+ *
216
+ * Distinct from the legacy `settingsSchema`/`saveSettings` mechanism (see
217
+ * {@link setSettingsSchema}, {@link saveSettings}), which is a single
218
+ * vitre-scoped blob rendered by the host's settings form.
219
+ *
220
+ * Rejects with an {@link AppSettingsError} of code `'unsupported'` if the
221
+ * host doesn't answer within 10s — a vitre host older than this feature
222
+ * never responds to `getAppSettings`.
223
+ */
224
+ getSettings(level: AppSettingsLevel): Promise<AppSettingsValue>;
225
+ /**
226
+ * Write the app's settings at `level`, with optimistic concurrency:
227
+ * `expectedVersion` must be the version last observed for that level (from
228
+ * {@link getSettings} or {@link onSettingsChanged}) — `0` if never
229
+ * written. A stale version rejects with an {@link AppSettingsError} of
230
+ * code `'conflict'`; re-read and retry. An oversized `value` (> 64 KB)
231
+ * rejects with `'tooLarge'`.
232
+ *
233
+ * Rejects with code `'unsupported'` if the host doesn't answer within
234
+ * 10s — see {@link getSettings}.
235
+ */
236
+ setSettings(level: AppSettingsLevel, value: Record<string, unknown>, expectedVersion: number): Promise<AppSettingsValue>;
178
237
  changeTeamSpace(space: string): void;
179
238
  changeTeamSpaceGuest(space: string, teamDomain: string): void;
180
239
  showNotification(notification: NotificationInfo): void;