@lavitre/apps 1.63.0 → 1.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/dist/Common/Site.d.ts +2 -0
- package/dist/Common/Site.js +26 -0
- package/dist/Common/Site.js.map +1 -0
- package/dist/Common/index.d.ts +1 -0
- package/dist/Common/index.js +1 -0
- package/dist/Common/index.js.map +1 -1
- package/dist/CompanionConnector/CompanionConnector.Model.d.ts +2 -0
- package/dist/CompanionConnector/CompanionConnector.Model.js.map +1 -1
- package/dist/CompanionConnector/CompanionConnector.d.ts +2 -0
- package/dist/CompanionConnector/CompanionConnector.js +20 -0
- package/dist/CompanionConnector/CompanionConnector.js.map +1 -1
- package/dist/CompanionFrame/CompanionFrame.d.ts +1 -1
- package/dist/CompanionFrame/CompanionFrame.js.map +1 -1
- package/dist/Connector/Connector.Model.d.ts +6 -0
- package/dist/Connector/Connector.Model.js.map +1 -1
- package/dist/Connector/Connector.d.ts +14 -0
- package/dist/Connector/Connector.js +26 -0
- package/dist/Connector/Connector.js.map +1 -1
- package/dist/Frame/Frame.Model.d.ts +16 -1
- package/dist/Frame/Frame.Model.js.map +1 -1
- package/dist/Frame/Frame.d.ts +18 -3
- package/dist/Frame/Frame.js +87 -9
- package/dist/Frame/Frame.js.map +1 -1
- package/dist/Frame/OutgoingStreamPeer.d.ts +8 -0
- package/dist/Frame/OutgoingStreamPeer.js +121 -0
- package/dist/Frame/OutgoingStreamPeer.js.map +1 -0
- package/dist/Version.d.ts +1 -1
- package/dist/Version.js +1 -1
- package/dist/Version.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -201,7 +201,7 @@ watchNfcTags((e) => {
|
|
|
201
201
|
- The message is read before the tag is reported: `tagPresent` comes a little later than the UID alone would (tens of ms for a small sticker, up to about half a second for a full NTAG216).
|
|
202
202
|
- Records: `{ tnf, type, id, payload: Uint8Array }`, chunked records joined. `parseNdefMessage` returns `null` for a malformed message.
|
|
203
203
|
|
|
204
|
-
### The app's own version and channel — `appVersion` / `appChannel` (SDK 1.63)
|
|
204
|
+
### The app's own version and channel — `appVersion` / `appChannel` (SDK 1.63, companion 1.64)
|
|
205
205
|
|
|
206
206
|
`connector.appVersion` / `frame.appVersion` is the version of the app the vitre loaded, as deployed (`'1.4.0'`); `connector.appChannel` / `frame.appChannel` the app channel that version was selected through (`'preview'`, `'beta'`…). Both come with the init message, beside `appId`:
|
|
207
207
|
|
|
@@ -213,7 +213,16 @@ connector.trackEvent('started', { version: connector.appVersion, channel: connec
|
|
|
213
213
|
- `appChannel` is `undefined` when the version is the team's own selection, a pinned version or a global one — the app runs outside any channel. A space following `preview` with the `newest` policy whose team runs a newer version gets that version, and no channel.
|
|
214
214
|
- Both are `undefined` on a host that predates them: treat them as optional.
|
|
215
215
|
- Not to be confused with `hostInformation.version`, the HOST's version (`'36.6.0-mainX64.7130'`), whose `mainX64` is the host's build channel.
|
|
216
|
-
-
|
|
216
|
+
- On the companion (SDK 1.64), `CompanionConnector` and `CompanionFrame` expose the same `appVersion` / `appChannel` — the values of the app on the Vitre the companion is connected to. `undefined` on a host that predates them.
|
|
217
|
+
|
|
218
|
+
### Sharing a frame's stream from another site — `frame.shareStream` (SDK 1.65)
|
|
219
|
+
|
|
220
|
+
`frame.shareStream(stream)` hands the frame's tracks to the Vitre, which shares them with the space. Two transports, chosen by the SDK:
|
|
221
|
+
|
|
222
|
+
- **Same site as the Vitre page, Chromium** (e.g. `*.apps.lavit.re` in `app.lavit.re`): the track readables are transferred, no re-encoding.
|
|
223
|
+
- **Otherwise** (a preview served from `*.netlify.app`, a browser without `MediaStreamTrackProcessor`): the stream goes over a local `RTCPeerConnection` to the Vitre, re-encoded once on the same machine. Only with a host that announces it (`shareStreamPeer`); `replaceShareStream` then swaps the tracks on the frame's own sender, for the kinds the share already carries.
|
|
224
|
+
|
|
225
|
+
A connector decides before opening the frame with `connector.canFrameShareStream()` (same checks, from the connector, which runs on the app's site too). `frame.canShareStream()` is `false` when neither works — an older Vitre with a frame on another site, where a transferred share would die on its first frame. Keep a fallback for that case (e.g. let the host open the camera with `connector.requestOpenStreamFrame`). `attachStream` and `Connector.shareStream` keep the readables transport only.
|
|
217
226
|
|
|
218
227
|
### Native or web host — `isNativeHost`
|
|
219
228
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Which site a frame or connector sits on, relative to the Vitre page that
|
|
2
|
+
// embeds it: track readables only cross between documents of the same site.
|
|
3
|
+
/// "Site" approximated by the scheme and the last two host labels, as the
|
|
4
|
+
/// host does (`sharingHost.canTransferTrackReadables`): it holds for every
|
|
5
|
+
/// la Vitre domain. Pure, for tests.
|
|
6
|
+
export function siteOf(origin) {
|
|
7
|
+
try {
|
|
8
|
+
const url = new URL(origin);
|
|
9
|
+
return `${url.protocol}//${url.hostname.split('.').slice(-2).join('.')}`;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/// Whether this frame can transfer track readables to the page that embeds
|
|
16
|
+
/// it: same site, judged from `location.ancestorOrigins` (Chromium). Without
|
|
17
|
+
/// that list (other engines) the answer is yes; those engines have no
|
|
18
|
+
/// `MediaStreamTrackProcessor` anyway, which is checked separately.
|
|
19
|
+
export function isSameSiteAsParent(ownOrigin, ancestorOrigins) {
|
|
20
|
+
const parent = ancestorOrigins?.[0];
|
|
21
|
+
if (parent == null)
|
|
22
|
+
return true;
|
|
23
|
+
const own = siteOf(ownOrigin);
|
|
24
|
+
return own != null && own === siteOf(parent);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=Site.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Site.js","sourceRoot":"","sources":["../../Common/Site.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,4EAA4E;AAE5E,0EAA0E;AAC1E,2EAA2E;AAC3E,qCAAqC;AACrC,MAAM,UAAU,MAAM,CAAC,MAAc;IACnC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;QAC3B,OAAO,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,2EAA2E;AAC3E,6EAA6E;AAC7E,sEAAsE;AACtE,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CAChC,SAAiB,EACjB,eAA8C;IAE9C,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC,CAAC,CAAC,CAAA;IACnC,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;IAC7B,OAAO,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,MAAM,CAAC,MAAM,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["// Which site a frame or connector sits on, relative to the Vitre page that\n// embeds it: track readables only cross between documents of the same site.\n\n/// \"Site\" approximated by the scheme and the last two host labels, as the\n/// host does (`sharingHost.canTransferTrackReadables`): it holds for every\n/// la Vitre domain. Pure, for tests.\nexport function siteOf(origin: string): string | undefined {\n try {\n const url = new URL(origin)\n return `${url.protocol}//${url.hostname.split('.').slice(-2).join('.')}`\n } catch {\n return undefined\n }\n}\n\n/// Whether this frame can transfer track readables to the page that embeds\n/// it: same site, judged from `location.ancestorOrigins` (Chromium). Without\n/// that list (other engines) the answer is yes; those engines have no\n/// `MediaStreamTrackProcessor` anyway, which is checked separately.\nexport function isSameSiteAsParent(\n ownOrigin: string,\n ancestorOrigins: ArrayLike<string> | undefined,\n): boolean {\n const parent = ancestorOrigins?.[0]\n if (parent == null) return true\n const own = siteOf(ownOrigin)\n return own != null && own === siteOf(parent)\n}\n"]}
|
package/dist/Common/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './Common.Model.js';
|
|
2
2
|
export { compareVersions, isMinVersion } from './Version.js';
|
|
3
|
+
export { isSameSiteAsParent, siteOf } from './Site.js';
|
|
3
4
|
export { CrdtChannel, MIN_CRDT_HOST_VERSION, type CrdtAttachment, type CrdtInboundMessage, type CrdtOutboundMessage, type CrdtPostMessage, } from './CrdtChannel.js';
|
|
4
5
|
export { BlobStore } from './BlobStore.js';
|
|
5
6
|
export { AppSettingsError, APP_SETTINGS_TIMEOUT_MS, type AppSettingsErrorCode, } from './AppSettings.js';
|
package/dist/Common/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './Common.Model.js';
|
|
2
2
|
export { compareVersions, isMinVersion } from './Version.js';
|
|
3
|
+
export { isSameSiteAsParent, siteOf } from './Site.js';
|
|
3
4
|
export { CrdtChannel, MIN_CRDT_HOST_VERSION, } from './CrdtChannel.js';
|
|
4
5
|
export { BlobStore } from './BlobStore.js';
|
|
5
6
|
export { AppSettingsError, APP_SETTINGS_TIMEOUT_MS, } from './AppSettings.js';
|
package/dist/Common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../Common/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EACL,WAAW,EACX,qBAAqB,GAKtB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,GAExB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,e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AC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACxC,KAAK,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;YAChE,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,OAAO,WAAW,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,CAAM,CAAA;AACzE,CAAC,CAAA;AACD,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './Common.Model.js'\nexport { compareVersions, isMinVersion } from './Version.js'\nexport {\n CrdtChannel,\n MIN_CRDT_HOST_VERSION,\n type CrdtAttachment,\n type CrdtInboundMessage,\n type CrdtOutboundMessage,\n type CrdtPostMessage,\n} from './CrdtChannel.js'\nexport { BlobStore } from './BlobStore.js'\nexport {\n AppSettingsError,\n APP_SETTINGS_TIMEOUT_MS,\n type AppSettingsErrorCode,\n} from './AppSettings.js'\nexport {\n SETTINGS_FILE_NAME,\n SettingsDefaultsResolver,\n defaultsOfProperties,\n mergeDefaults,\n parseSettingsFile,\n withoutDefaults,\n type SettingsFileDefaults,\n type SettingsFormLevel,\n} from './SettingsDefaults.js'\nexport {\n PublicStorageError,\n PUBLIC_STORAGE_TIMEOUT_MS,\n PUBLIC_STORAGE_PUT_TIMEOUT_MS,\n MAX_PUBLIC_FILE_SIZE_BYTES,\n MIN_PUBLIC_FILE_EXPIRES_IN_SECONDS,\n validateExpiresIn,\n putPublicFileExpiryField,\n withDownloadUrlFallback,\n type PublicStorageErrorCode,\n type PublicStorageApi,\n type PublicStoragePutOptions,\n} from './PublicStorage.js'\nexport {\n PrivateStorageError,\n PRIVATE_STORAGE_TIMEOUT_MS,\n PRIVATE_STORAGE_PUT_TIMEOUT_MS,\n PRIVATE_STORAGE_GET_TIMEOUT_MS,\n MAX_PRIVATE_FILE_SIZE_BYTES,\n MIN_PRIVATE_FILE_EXPIRES_IN_SECONDS,\n MAX_PRIVATE_LINK_EXPIRES_IN_SECONDS,\n DEFAULT_PRIVATE_LINK_EXPIRES_IN_SECONDS,\n MAX_PRIVATE_PATH_LENGTH,\n MAX_PRIVATE_PATH_SEGMENTS,\n validatePrivatePath,\n validatePrivateExpiresIn,\n validateLinkExpiresIn,\n privateFileExpiryField,\n type PrivateStorageErrorCode,\n type PrivateStorageApi,\n type PrivateStorageReadApi,\n type PrivateStoragePutOptions,\n type PrivateStorageGetLinkOptions,\n} from './PrivateStorage.js'\nexport {\n AiChannel,\n MIN_AI_HOST_VERSION,\n type AiTool,\n type AiToolHandler,\n type AiInboundMessage,\n type AiOutboundMessage,\n type AiPostMessage,\n} from './AiChannel.js'\n\nexport const ensureDefaultValue = <T>(\n value: Partial<T> | null,\n defaultValue: T,\n) => {\n const ensureValue = (value: any, defaultValue: any) => {\n if (defaultValue === undefined) {\n return value\n }\n\n if (typeof value !== typeof defaultValue) {\n return defaultValue\n }\n\n if (typeof defaultValue === 'object') {\n if (Array.isArray(defaultValue)) {\n if (!Array.isArray(value)) {\n return defaultValue\n } else {\n return value\n }\n }\n\n value = value === undefined || value == null ? {} : value\n Object.keys(defaultValue).forEach((key) => {\n value[key] = ensureDefaultValue(value[key], defaultValue[key])\n })\n }\n\n return value\n }\n\n return ensureValue(value === undefined ? {} : value, defaultValue) as T\n}\nexport * from './PreviewScaling.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../Common/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EACL,WAAW,EACX,qBAAqB,GAKtB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE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;gBACd,CAAC;YACH,CAAC;YAED,KAAK,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;YACzD,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACxC,KAAK,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;YAChE,CAAC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,OAAO,WAAW,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,CAAM,CAAA;AACzE,CAAC,CAAA;AACD,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './Common.Model.js'\nexport { compareVersions, isMinVersion } from './Version.js'\nexport { isSameSiteAsParent, siteOf } from './Site.js'\nexport {\n CrdtChannel,\n MIN_CRDT_HOST_VERSION,\n type CrdtAttachment,\n type CrdtInboundMessage,\n type CrdtOutboundMessage,\n type CrdtPostMessage,\n} from './CrdtChannel.js'\nexport { BlobStore } from './BlobStore.js'\nexport {\n AppSettingsError,\n APP_SETTINGS_TIMEOUT_MS,\n type AppSettingsErrorCode,\n} from './AppSettings.js'\nexport {\n SETTINGS_FILE_NAME,\n SettingsDefaultsResolver,\n defaultsOfProperties,\n mergeDefaults,\n parseSettingsFile,\n withoutDefaults,\n type SettingsFileDefaults,\n type SettingsFormLevel,\n} from './SettingsDefaults.js'\nexport {\n PublicStorageError,\n PUBLIC_STORAGE_TIMEOUT_MS,\n PUBLIC_STORAGE_PUT_TIMEOUT_MS,\n MAX_PUBLIC_FILE_SIZE_BYTES,\n MIN_PUBLIC_FILE_EXPIRES_IN_SECONDS,\n validateExpiresIn,\n putPublicFileExpiryField,\n withDownloadUrlFallback,\n type PublicStorageErrorCode,\n type PublicStorageApi,\n type PublicStoragePutOptions,\n} from './PublicStorage.js'\nexport {\n PrivateStorageError,\n PRIVATE_STORAGE_TIMEOUT_MS,\n PRIVATE_STORAGE_PUT_TIMEOUT_MS,\n PRIVATE_STORAGE_GET_TIMEOUT_MS,\n MAX_PRIVATE_FILE_SIZE_BYTES,\n MIN_PRIVATE_FILE_EXPIRES_IN_SECONDS,\n MAX_PRIVATE_LINK_EXPIRES_IN_SECONDS,\n DEFAULT_PRIVATE_LINK_EXPIRES_IN_SECONDS,\n MAX_PRIVATE_PATH_LENGTH,\n MAX_PRIVATE_PATH_SEGMENTS,\n validatePrivatePath,\n validatePrivateExpiresIn,\n validateLinkExpiresIn,\n privateFileExpiryField,\n type PrivateStorageErrorCode,\n type PrivateStorageApi,\n type PrivateStorageReadApi,\n type PrivateStoragePutOptions,\n type PrivateStorageGetLinkOptions,\n} from './PrivateStorage.js'\nexport {\n AiChannel,\n MIN_AI_HOST_VERSION,\n type AiTool,\n type AiToolHandler,\n type AiInboundMessage,\n type AiOutboundMessage,\n type AiPostMessage,\n} from './AiChannel.js'\n\nexport const ensureDefaultValue = <T>(\n value: Partial<T> | null,\n defaultValue: T,\n) => {\n const ensureValue = (value: any, defaultValue: any) => {\n if (defaultValue === undefined) {\n return value\n }\n\n if (typeof value !== typeof defaultValue) {\n return defaultValue\n }\n\n if (typeof defaultValue === 'object') {\n if (Array.isArray(defaultValue)) {\n if (!Array.isArray(value)) {\n return defaultValue\n } else {\n return value\n }\n }\n\n value = value === undefined || value == null ? {} : value\n Object.keys(defaultValue).forEach((key) => {\n value[key] = ensureDefaultValue(value[key], defaultValue[key])\n })\n }\n\n return value\n }\n\n return ensureValue(value === undefined ? {} : value, defaultValue) as T\n}\nexport * from './PreviewScaling.js'\n"]}
|
|
@@ -27,6 +27,8 @@ export type CompanionInitializeConnector = {
|
|
|
27
27
|
hostInfo: CompanionHostInformation;
|
|
28
28
|
companionInfo: CompanionInformation;
|
|
29
29
|
appId?: string;
|
|
30
|
+
appVersion?: string;
|
|
31
|
+
appChannel?: string;
|
|
30
32
|
};
|
|
31
33
|
export type CompanionConnectorInitialized = {
|
|
32
34
|
options: CompanionConnectorOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompanionConnector.Model.js","sourceRoot":"","sources":["../../CompanionConnector/CompanionConnector.Model.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,wEAAwE;AACxE,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,uEAAuE;AACvE,OAAO;AACP,EAAE;AACF,uEAAuE;AACvE,8DAA8D;AAC9D,4EAA4E;AAC5E,8CAA8C","sourcesContent":["// Distinct API for connectors hosted on a la Vitre Companion (the mobile /\n// web app a user runs alongside the Vitre). The companion runs the same\n// app code but in a very different context — it has no Vitre device, no\n// shared space awareness, no notifications, no settings persistence, …\n// Rather than exposing the full Vitre `Connector` API with empty stubs\n// (which would silently swallow `setShareTarget`, `showNotification`,\n// `setVitreSettings`, …), the companion connector exposes ONLY what\n// genuinely applies here: declaring a menu, opening frames, and exchanging\n// opaque app messages with the matching Vitre `Connector` for the same\n// app.\n//\n// Anything not listed here is intentionally absent. The Vitre side has\n// the same surface restriction in the other direction: it can\n// `sendMessageToCompanionConnector` but companion connectors do NOT receive\n// device events, knock-knocks, settings, etc.\n\nimport type {\n FileData,\n GetPrivateFile,\n GetPrivateFileLink,\n Language,\n ListPrivateFiles,\n MenuEntry,\n PrivateStorageResponse,\n CompanionUser,\n CompanionInformation,\n} from '../Common/index.js'\nimport type {\n CloseFrame,\n FrameOwnerChanged,\n OpenFrame,\n RootMenuEntry,\n SetFrameOwner,\n} from '../Connector/Connector.Model.js'\nimport type { OpenFrameOptions } from '../Common/Common.Model.js'\n\nexport type { Language }\n\n/// Snapshot of the authenticated companion user. Optional because the\n/// companion has guest sessions (no logged-in user) too.\n///\n/// Identity of the Vitre this companion is currently connected to. The\n/// connector only exists in the context of a live connection so this is\n/// always present once `initialize` fires.\n///\n/// `teamDomain` / `teamName` are optional because they aren't always\n/// known by the companion at the time the connector is initialized\n/// (e.g. guest sessions). The connector cannot observe later updates\n/// through this object — it is only refreshed on a new `initialize`.\n/// If you need the team identity and it is missing at init, fall back\n/// to `space` and accept the gap rather than waiting.\n/// The host of a companion connector IS the Vitre it is connected to, so\n/// `connector.hostInformation` carries the Vitre identity directly.\nexport type CompanionHostInformation = {\n id: string\n name: string\n color: string\n teamDomain?: string\n teamName?: string\n space: string\n}\n\n/**\n * @deprecated Use `CompanionHostInformation`. The host of a companion\n * connector IS the Vitre it is connected to, so `hostInformation` now\n * carries the Vitre identity directly (this used to be nested under\n * `CompanionHostInformation.connectedVitre`).\n */\nexport type ConnectedVitre = CompanionHostInformation\n\n/// `CompanionUser` / `CompanionInformation` now live in `Common` so the\n/// Frame module can surface `companionInformation` on companion-side frames\n/// too. Re-exported here for backward compatibility with existing\n/// `@lavitre/apps/CompanionConnector` consumers.\nexport type { CompanionUser, CompanionInformation }\n\n/// Declared by the companion connector at boot. Mirrors a subset of the\n/// Vitre `ConnectorOptions` — only `name`, `iconUrl` and `menu` apply.\n/// `shareTarget`, `settingsSchema`, `voiceActions` are Vitre-only and\n/// intentionally absent.\nexport type CompanionConnectorOptions = {\n name: string\n iconUrl?: string\n menu?: RootMenuEntry[]\n}\n\nexport type CompanionInitializeConnector = {\n hostInfo: CompanionHostInformation\n companionInfo: CompanionInformation\n /// Optional on purpose: a host may omit it for a generic connector that\n /// isn't tied to a single app. When present it is the routing key for\n /// `messageFromVitreConnector` / `sendMessageToVitreConnector`. The\n /// runtime warns (see `CompanionConnector` constructor) if it is missing\n /// so a misconfigured host surfaces at runtime rather than silently\n /// failing to route.\n appId?: string\n}\n\nexport type CompanionConnectorInitialized = {\n options: CompanionConnectorOptions\n}\n\n/// Payload a companion connector sends to the matching Vitre `Connector`\n/// (same `appId`). The Vitre connector receives the mirror message\n/// `messageFromCompanionConnector` with `fromCompanionId` set so it can\n/// reply targeted-back.\nexport type SendMessageToVitreConnector = {\n message: string\n fileData?: FileData\n}\n\n/// Payload the companion connector receives when its matching Vitre\n/// `Connector` calls `sendMessageToCompanionConnector`.\nexport type MessageFromVitreConnector = {\n message: string\n fileData?: FileData\n}\n\n/// Inbound to a companion connector (host → connector iframe).\nexport type CompanionConnectorApiMessagesIn =\n | ({ type: 'initialize' } & CompanionInitializeConnector)\n | {\n type: 'menuClicked'\n menuId: string\n isChecked: boolean\n tag: any\n }\n | { type: 'frameLoaded'; frameConnectorId: string }\n | { type: 'frameUnloaded'; frameConnectorId: string }\n | ({ type: 'frameOwnerChanged' } & FrameOwnerChanged)\n | ({ type: 'messageFromVitreConnector' } & MessageFromVitreConnector)\n | ({ type: 'privateStorageResponse' } & PrivateStorageResponse)\n\n/// How a companion connector's `setMenu` combines with the menu the\n/// Vitre-side `Connector` published for the same app.\n///\n/// `'replace'` (default, and the historical behaviour) — the companion\n/// connector's menu fully replaces the Vitre menu for this app on the\n/// companion: the Vitre-pushed entries are suppressed.\n///\n/// `'append'` — the companion connector's entries are added *after* the\n/// Vitre menu; both are rendered. Use this to contribute companion-only\n/// entries without hiding what the Vitre published.\nexport type SetMenuMode = 'replace' | 'append'\n\n/// Options for `CompanionConnector.setMenu`.\nexport type SetMenuOptions = {\n /// See `SetMenuMode`. Omitted ⇒ `'replace'`.\n mode?: SetMenuMode\n}\n\n/// Payload of the companion-side `openCompanionFrame` outbound. The\n/// companion's CompanionConnector calls this to ask the host to open\n/// (or focus) a frame full-page on this companion. If the Vitre is\n/// reachable the host also announces the open to it so a paired frame\n/// mounts there (same as the Vitre-driven open path, in reverse). The\n/// `frameConnectorId` MUST match the paired Vitre frame's id so the two\n/// frames bind on both sides.\nexport type OpenCompanionFrame = {\n frameConnectorId: string\n options: Omit<OpenFrameOptions, 'frameConnectorId'>\n}\n\n/// Outbound from a companion connector (connector iframe → host).\nexport type CompanionConnectorApiMessagesOut =\n | ({ type: 'connectorInitialized' } & CompanionConnectorInitialized)\n | { type: 'setRootMenu'; menu: RootMenuEntry[]; mode?: SetMenuMode }\n | ({ type: 'openFrame' } & OpenFrame)\n | ({ type: 'closeFrame' } & CloseFrame)\n | ({ type: 'setFrameOwner' } & SetFrameOwner)\n /// Open or focus a paired frame full-page on this companion. Distinct\n /// from `openFrame` because the host treats it as a navigation event\n /// (camera-share style) rather than a side-panel mount. See\n /// `OpenCompanionFrame`.\n | ({ type: 'openCompanionFrame' } & OpenCompanionFrame)\n | ({ type: 'sendMessageToVitreConnector' } & SendMessageToVitreConnector)\n /// Read-only private storage requests — list/get/getLink only (write\n /// stays vitre-only). See `CompanionConnector.privateStorage`.\n | ({ type: 'listPrivateFiles' } & ListPrivateFiles)\n | ({ type: 'getPrivateFile' } & GetPrivateFile)\n | ({ type: 'getPrivateFileLink' } & GetPrivateFileLink)\n\n/// Re-exported here for callers that want to declare `menu` entries\n/// without importing from two modules. `MenuEntry` originates in\n/// `../Common`; `RootMenuEntry` originates in `../Connector/Connector.Model`.\n/// Both are surfaced from here purely for caller convenience.\nexport type { MenuEntry, RootMenuEntry }\n"]}
|
|
1
|
+
{"version":3,"file":"CompanionConnector.Model.js","sourceRoot":"","sources":["../../CompanionConnector/CompanionConnector.Model.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,wEAAwE;AACxE,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,uEAAuE;AACvE,OAAO;AACP,EAAE;AACF,uEAAuE;AACvE,8DAA8D;AAC9D,4EAA4E;AAC5E,8CAA8C","sourcesContent":["// Distinct API for connectors hosted on a la Vitre Companion (the mobile /\n// web app a user runs alongside the Vitre). The companion runs the same\n// app code but in a very different context — it has no Vitre device, no\n// shared space awareness, no notifications, no settings persistence, …\n// Rather than exposing the full Vitre `Connector` API with empty stubs\n// (which would silently swallow `setShareTarget`, `showNotification`,\n// `setVitreSettings`, …), the companion connector exposes ONLY what\n// genuinely applies here: declaring a menu, opening frames, and exchanging\n// opaque app messages with the matching Vitre `Connector` for the same\n// app.\n//\n// Anything not listed here is intentionally absent. The Vitre side has\n// the same surface restriction in the other direction: it can\n// `sendMessageToCompanionConnector` but companion connectors do NOT receive\n// device events, knock-knocks, settings, etc.\n\nimport type {\n FileData,\n GetPrivateFile,\n GetPrivateFileLink,\n Language,\n ListPrivateFiles,\n MenuEntry,\n PrivateStorageResponse,\n CompanionUser,\n CompanionInformation,\n} from '../Common/index.js'\nimport type {\n CloseFrame,\n FrameOwnerChanged,\n OpenFrame,\n RootMenuEntry,\n SetFrameOwner,\n} from '../Connector/Connector.Model.js'\nimport type { OpenFrameOptions } from '../Common/Common.Model.js'\n\nexport type { Language }\n\n/// Snapshot of the authenticated companion user. Optional because the\n/// companion has guest sessions (no logged-in user) too.\n///\n/// Identity of the Vitre this companion is currently connected to. The\n/// connector only exists in the context of a live connection so this is\n/// always present once `initialize` fires.\n///\n/// `teamDomain` / `teamName` are optional because they aren't always\n/// known by the companion at the time the connector is initialized\n/// (e.g. guest sessions). The connector cannot observe later updates\n/// through this object — it is only refreshed on a new `initialize`.\n/// If you need the team identity and it is missing at init, fall back\n/// to `space` and accept the gap rather than waiting.\n/// The host of a companion connector IS the Vitre it is connected to, so\n/// `connector.hostInformation` carries the Vitre identity directly.\nexport type CompanionHostInformation = {\n id: string\n name: string\n color: string\n teamDomain?: string\n teamName?: string\n space: string\n}\n\n/**\n * @deprecated Use `CompanionHostInformation`. The host of a companion\n * connector IS the Vitre it is connected to, so `hostInformation` now\n * carries the Vitre identity directly (this used to be nested under\n * `CompanionHostInformation.connectedVitre`).\n */\nexport type ConnectedVitre = CompanionHostInformation\n\n/// `CompanionUser` / `CompanionInformation` now live in `Common` so the\n/// Frame module can surface `companionInformation` on companion-side frames\n/// too. Re-exported here for backward compatibility with existing\n/// `@lavitre/apps/CompanionConnector` consumers.\nexport type { CompanionUser, CompanionInformation }\n\n/// Declared by the companion connector at boot. Mirrors a subset of the\n/// Vitre `ConnectorOptions` — only `name`, `iconUrl` and `menu` apply.\n/// `shareTarget`, `settingsSchema`, `voiceActions` are Vitre-only and\n/// intentionally absent.\nexport type CompanionConnectorOptions = {\n name: string\n iconUrl?: string\n menu?: RootMenuEntry[]\n}\n\nexport type CompanionInitializeConnector = {\n hostInfo: CompanionHostInformation\n companionInfo: CompanionInformation\n /// Optional on purpose: a host may omit it for a generic connector that\n /// isn't tied to a single app. When present it is the routing key for\n /// `messageFromVitreConnector` / `sendMessageToVitreConnector`. The\n /// runtime warns (see `CompanionConnector` constructor) if it is missing\n /// so a misconfigured host surfaces at runtime rather than silently\n /// failing to route.\n appId?: string\n /// The version of this app the Vitre loaded, as deployed (`'1.4.0'`) —\n /// the Vitre's `connector.appVersion`. Omitted by hosts older than this\n /// field. Added 1.64.\n appVersion?: string\n /// The app channel that version was selected through (`'preview'`,\n /// `'beta'`…) — the Vitre's `connector.appChannel`. Omitted outside any\n /// channel and by hosts older than this field. Added 1.64.\n appChannel?: string\n}\n\nexport type CompanionConnectorInitialized = {\n options: CompanionConnectorOptions\n}\n\n/// Payload a companion connector sends to the matching Vitre `Connector`\n/// (same `appId`). The Vitre connector receives the mirror message\n/// `messageFromCompanionConnector` with `fromCompanionId` set so it can\n/// reply targeted-back.\nexport type SendMessageToVitreConnector = {\n message: string\n fileData?: FileData\n}\n\n/// Payload the companion connector receives when its matching Vitre\n/// `Connector` calls `sendMessageToCompanionConnector`.\nexport type MessageFromVitreConnector = {\n message: string\n fileData?: FileData\n}\n\n/// Inbound to a companion connector (host → connector iframe).\nexport type CompanionConnectorApiMessagesIn =\n | ({ type: 'initialize' } & CompanionInitializeConnector)\n | {\n type: 'menuClicked'\n menuId: string\n isChecked: boolean\n tag: any\n }\n | { type: 'frameLoaded'; frameConnectorId: string }\n | { type: 'frameUnloaded'; frameConnectorId: string }\n | ({ type: 'frameOwnerChanged' } & FrameOwnerChanged)\n | ({ type: 'messageFromVitreConnector' } & MessageFromVitreConnector)\n | ({ type: 'privateStorageResponse' } & PrivateStorageResponse)\n\n/// How a companion connector's `setMenu` combines with the menu the\n/// Vitre-side `Connector` published for the same app.\n///\n/// `'replace'` (default, and the historical behaviour) — the companion\n/// connector's menu fully replaces the Vitre menu for this app on the\n/// companion: the Vitre-pushed entries are suppressed.\n///\n/// `'append'` — the companion connector's entries are added *after* the\n/// Vitre menu; both are rendered. Use this to contribute companion-only\n/// entries without hiding what the Vitre published.\nexport type SetMenuMode = 'replace' | 'append'\n\n/// Options for `CompanionConnector.setMenu`.\nexport type SetMenuOptions = {\n /// See `SetMenuMode`. Omitted ⇒ `'replace'`.\n mode?: SetMenuMode\n}\n\n/// Payload of the companion-side `openCompanionFrame` outbound. The\n/// companion's CompanionConnector calls this to ask the host to open\n/// (or focus) a frame full-page on this companion. If the Vitre is\n/// reachable the host also announces the open to it so a paired frame\n/// mounts there (same as the Vitre-driven open path, in reverse). The\n/// `frameConnectorId` MUST match the paired Vitre frame's id so the two\n/// frames bind on both sides.\nexport type OpenCompanionFrame = {\n frameConnectorId: string\n options: Omit<OpenFrameOptions, 'frameConnectorId'>\n}\n\n/// Outbound from a companion connector (connector iframe → host).\nexport type CompanionConnectorApiMessagesOut =\n | ({ type: 'connectorInitialized' } & CompanionConnectorInitialized)\n | { type: 'setRootMenu'; menu: RootMenuEntry[]; mode?: SetMenuMode }\n | ({ type: 'openFrame' } & OpenFrame)\n | ({ type: 'closeFrame' } & CloseFrame)\n | ({ type: 'setFrameOwner' } & SetFrameOwner)\n /// Open or focus a paired frame full-page on this companion. Distinct\n /// from `openFrame` because the host treats it as a navigation event\n /// (camera-share style) rather than a side-panel mount. See\n /// `OpenCompanionFrame`.\n | ({ type: 'openCompanionFrame' } & OpenCompanionFrame)\n | ({ type: 'sendMessageToVitreConnector' } & SendMessageToVitreConnector)\n /// Read-only private storage requests — list/get/getLink only (write\n /// stays vitre-only). See `CompanionConnector.privateStorage`.\n | ({ type: 'listPrivateFiles' } & ListPrivateFiles)\n | ({ type: 'getPrivateFile' } & GetPrivateFile)\n | ({ type: 'getPrivateFileLink' } & GetPrivateFileLink)\n\n/// Re-exported here for callers that want to declare `menu` entries\n/// without importing from two modules. `MenuEntry` originates in\n/// `../Common`; `RootMenuEntry` originates in `../Connector/Connector.Model`.\n/// Both are surfaced from here purely for caller convenience.\nexport type { MenuEntry, RootMenuEntry }\n"]}
|
|
@@ -7,6 +7,8 @@ export declare class CompanionConnector {
|
|
|
7
7
|
hostInformation: CompanionHostInformation;
|
|
8
8
|
companionInformation: CompanionInformation;
|
|
9
9
|
appId: string;
|
|
10
|
+
appVersion?: string;
|
|
11
|
+
appChannel?: string;
|
|
10
12
|
options: CompanionConnectorOptions;
|
|
11
13
|
onMenuClicked?: (menuId: string, tag: any, isChecked: boolean) => void;
|
|
12
14
|
onFrameLoaded?: (frameConnectorId: string) => void;
|
|
@@ -36,6 +36,24 @@ export class CompanionConnector {
|
|
|
36
36
|
writable: true,
|
|
37
37
|
value: void 0
|
|
38
38
|
});
|
|
39
|
+
/// The version of this app the Vitre loaded (`'1.4.0'`), the same as the
|
|
40
|
+
/// Vitre `connector.appVersion`. Not the companion's version
|
|
41
|
+
/// (`companionInformation`). `undefined` on a host that does not send it.
|
|
42
|
+
Object.defineProperty(this, "appVersion", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
48
|
+
/// The app channel this version was selected through (`'preview'`,
|
|
49
|
+
/// `'beta'`…). `undefined` outside any channel, or on a host that does
|
|
50
|
+
/// not send it.
|
|
51
|
+
Object.defineProperty(this, "appChannel", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
39
57
|
Object.defineProperty(this, "options", {
|
|
40
58
|
enumerable: true,
|
|
41
59
|
configurable: true,
|
|
@@ -164,6 +182,8 @@ export class CompanionConnector {
|
|
|
164
182
|
'routing will not match');
|
|
165
183
|
}
|
|
166
184
|
this.appId = initMessage.appId ?? '';
|
|
185
|
+
this.appVersion = initMessage.appVersion;
|
|
186
|
+
this.appChannel = initMessage.appChannel;
|
|
167
187
|
this.options = options;
|
|
168
188
|
this.postMessage({
|
|
169
189
|
type: 'connectorInitialized',
|
|
@@ -1 +1 @@
|
|
|
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,eAAe,CAAA;AAe1C,sEAAsE;AACtE,wEAAwE;AACxE,2EAA2E;AAC3E,2BAA2B;AAC3B,MAAM,OAAO,kBAAkB;IA4F7B,YACmB,WAGR,EACT,WAAyC,EACzC,OAAkC;QALlC;;;;mBAAiB,WAAW;WAGnB;QA/FX,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;QAEzE;;;;;;;;WAQG;QACa;;;;mBAAwC;gBACtD,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE;oBACp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AI,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 { 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
|
+
{"version":3,"file":"CompanionConnector.js","sourceRoot":"","sources":["../../CompanionConnector/CompanionConnector.ts"],"names":[],"mappings":"AAAA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9D,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 { 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 /// The version of this app the Vitre loaded (`'1.4.0'`), the same as the\n /// Vitre `connector.appVersion`. Not the companion's version\n /// (`companionInformation`). `undefined` on a host that does not send it.\n public appVersion?: string\n /// The app channel this version was selected through (`'preview'`,\n /// `'beta'`…). `undefined` outside any channel, or on a host that does\n /// not send it.\n public appChannel?: 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.appVersion = initMessage.appVersion\n this.appChannel = initMessage.appChannel\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"]}
|
|
@@ -57,7 +57,7 @@ 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' | 'appVersion' | 'appChannel' | '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
61
|
/**
|
|
62
62
|
* Read-only private storage — `list`/`get`/`getLink` only. `put`/`delete`
|
|
63
63
|
* are intentionally absent at the type level: writes stay vitre-only, and
|
|
@@ -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;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
|
+
{"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;AAoHD;;;;;;;;;;;;;;;;;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 | 'appVersion'\n | 'appChannel'\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"]}
|
|
@@ -15,6 +15,12 @@ export type InitializeConnector = {
|
|
|
15
15
|
* older than this field. Added 1.63.
|
|
16
16
|
*/
|
|
17
17
|
appChannel?: string;
|
|
18
|
+
/**
|
|
19
|
+
* What the host can do beyond this message's shape. `'shareStreamPeer'`: a
|
|
20
|
+
* frame's `shareStream` reaches the host from another site, over a local
|
|
21
|
+
* peer connection. Omitted by hosts older than this field. Added 1.65.
|
|
22
|
+
*/
|
|
23
|
+
hostCapabilities?: string[];
|
|
18
24
|
state?: Record<string, any>;
|
|
19
25
|
};
|
|
20
26
|
export type RegExpDefinition = {
|