@lavitre/apps 1.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -0
  3. package/dist/Common/AiChannel.d.ts +59 -0
  4. package/dist/Common/AiChannel.js +97 -0
  5. package/dist/Common/AiChannel.js.map +1 -0
  6. package/dist/Common/BlobStore.d.ts +44 -0
  7. package/dist/Common/BlobStore.js +186 -0
  8. package/dist/Common/BlobStore.js.map +1 -0
  9. package/dist/Common/Common.Model.d.ts +1020 -0
  10. package/dist/Common/Common.Model.js +21 -0
  11. package/dist/Common/Common.Model.js.map +1 -0
  12. package/dist/Common/CrdtChannel.d.ts +198 -0
  13. package/dist/Common/CrdtChannel.js +659 -0
  14. package/dist/Common/CrdtChannel.js.map +1 -0
  15. package/dist/Common/Version.d.ts +21 -0
  16. package/dist/Common/Version.js +62 -0
  17. package/dist/Common/Version.js.map +1 -0
  18. package/dist/Common/index.d.ts +6 -0
  19. package/dist/Common/index.js +32 -0
  20. package/dist/Common/index.js.map +1 -0
  21. package/dist/CompanionConnector/CompanionConnector.Model.d.ts +85 -0
  22. package/dist/CompanionConnector/CompanionConnector.Model.js +17 -0
  23. package/dist/CompanionConnector/CompanionConnector.Model.js.map +1 -0
  24. package/dist/CompanionConnector/CompanionConnector.d.ts +28 -0
  25. package/dist/CompanionConnector/CompanionConnector.js +385 -0
  26. package/dist/CompanionConnector/CompanionConnector.js.map +1 -0
  27. package/dist/CompanionConnector/index.d.ts +2 -0
  28. package/dist/CompanionConnector/index.js +3 -0
  29. package/dist/CompanionConnector/index.js.map +1 -0
  30. package/dist/CompanionFrame/CompanionFrame.d.ts +103 -0
  31. package/dist/CompanionFrame/CompanionFrame.js +100 -0
  32. package/dist/CompanionFrame/CompanionFrame.js.map +1 -0
  33. package/dist/CompanionFrame/index.d.ts +1 -0
  34. package/dist/CompanionFrame/index.js +2 -0
  35. package/dist/CompanionFrame/index.js.map +1 -0
  36. package/dist/Connector/Connector.Model.d.ts +567 -0
  37. package/dist/Connector/Connector.Model.js +2 -0
  38. package/dist/Connector/Connector.Model.js.map +1 -0
  39. package/dist/Connector/Connector.d.ts +227 -0
  40. package/dist/Connector/Connector.js +1337 -0
  41. package/dist/Connector/Connector.js.map +1 -0
  42. package/dist/Connector/index.d.ts +2 -0
  43. package/dist/Connector/index.js +3 -0
  44. package/dist/Connector/index.js.map +1 -0
  45. package/dist/Frame/Frame.Model.d.ts +533 -0
  46. package/dist/Frame/Frame.Model.js +2 -0
  47. package/dist/Frame/Frame.Model.js.map +1 -0
  48. package/dist/Frame/Frame.d.ts +309 -0
  49. package/dist/Frame/Frame.js +1408 -0
  50. package/dist/Frame/Frame.js.map +1 -0
  51. package/dist/Frame/SyncAdapter.d.ts +75 -0
  52. package/dist/Frame/SyncAdapter.js +134 -0
  53. package/dist/Frame/SyncAdapter.js.map +1 -0
  54. package/dist/Frame/index.d.ts +3 -0
  55. package/dist/Frame/index.js +4 -0
  56. package/dist/Frame/index.js.map +1 -0
  57. package/dist/MediaLink/MediaLink.d.ts +178 -0
  58. package/dist/MediaLink/MediaLink.js +1432 -0
  59. package/dist/MediaLink/MediaLink.js.map +1 -0
  60. package/dist/MediaLink/index.d.ts +1 -0
  61. package/dist/MediaLink/index.js +2 -0
  62. package/dist/MediaLink/index.js.map +1 -0
  63. package/dist/Native/index.d.ts +170 -0
  64. package/dist/Native/index.js +19 -0
  65. package/dist/Native/index.js.map +1 -0
  66. package/dist/Version.d.ts +1 -0
  67. package/dist/Version.js +2 -0
  68. package/dist/Version.js.map +1 -0
  69. package/package.json +76 -0
@@ -0,0 +1,309 @@
1
+ import type * as Y from 'yjs';
2
+ import { CrdtChannel } from '../Common/CrdtChannel.js';
3
+ import { BlobStore } from '../Common/BlobStore.js';
4
+ import { AiChannel } from '../Common/AiChannel.js';
5
+ import type { AppId, BluetoothFromApp, BluetoothToApp, BorderOptions, CompanionInformation, ConnectedMediaDevice, Device, DeviceFrameReference, DeviceFullscreenUpdated, DeviceMessageReceived, DeviceScalingUpdated, Field, FileData, FramePeer, HostInformation, KnockKnock, LayoutPosition, LoadedFrame, MessageTarget, NotificationButtonClicked, NotificationInfo, PositionUpdated, Privacy, Rect, ReplacedBy, RequestSerialPortAccess, RequestStreamSizeUpdate, SendKnockKnock, SendMessageTo, SendMessageToAll, SendToSerialPort, StatsResponse, StreamCapture, UpdatedStateEntry, UpdateStateEntry, Visibility, VisibilityChanged, VitreSettings, VitreSettingsSetter, VoiceAction, VoiceActionDetection } from '../Common/index.js';
6
+ import type { Connector, ShareStreamOptions } from '../Connector/index.js';
7
+ import type { MediaTrackInfo } from '../Connector/Connector.Model.js';
8
+ import type { ApplyStreamAdvancedConstraints, AvailableExportSource, ExportData, ExportRequest, FrameApiMessagesIn, FrameApiMessagesOut, FrameMenuEntry, IceServerConfig, InitFrameOptions, InitializeFrame, SharedStreamPlayState, ViewOptions } from './Frame.Model.js';
9
+ export type SharedStreamState = {
10
+ position: number;
11
+ duration: number;
12
+ volume: number;
13
+ state: SharedStreamPlayState;
14
+ };
15
+ export type SharedStream = {
16
+ lastState: SharedStreamState;
17
+ play: () => void;
18
+ pause: () => void;
19
+ seek: (position: number, isRelative?: boolean) => void;
20
+ setVolume: (volume: number) => void;
21
+ };
22
+ export declare class Frame {
23
+ protected readonly postMessage: PostMessageFrameApiOut;
24
+ options: ViewOptions;
25
+ onDeviceJoined?: (device: Device) => void;
26
+ onDeviceLeft?: (deviceId: string) => void;
27
+ onDeviceMessageReceived?: (message: DeviceMessageReceived) => void;
28
+ onLocalConnectorMessageReceived?: (message: any, from?: string, fileData?: FileData) => void;
29
+ onMenuClicked?: (menuId: string, tag: any, isChecked: boolean) => void;
30
+ onFieldUpdated?: (field: Field) => void;
31
+ onInteractingChanged?: (isInteracting: boolean) => void;
32
+ onPrivacyChanged?: (privacy: Privacy) => void;
33
+ onFileProgress?: (bytes: number, totalBytes: number) => void;
34
+ onFileLoaded?: (file: ArrayBufferLike) => void;
35
+ onExportRequest?: (request: ExportRequest, resolve: (data: ExportData) => void, reject: (error: string) => void) => void;
36
+ onKnockKnock?: (knockKnock: KnockKnock) => void;
37
+ onSettingsUpdated?: (settings: any) => void;
38
+ onVitreSettingsUpdated?: (settings: VitreSettings) => void;
39
+ onConnectionCodeUpdated?: (companionCode?: string) => void;
40
+ onNotificationDismissed?: (notificationId: string) => void;
41
+ onNotificationButtonClicked?: (notificationButton: NotificationButtonClicked) => void;
42
+ onDevicePrivacyChanged?: (device: Device) => void;
43
+ onDeviceFrameLoaded?: (deviceFrameReference: DeviceFrameReference) => void;
44
+ onDeviceFrameConnectorLoaded?: (deviceFrameReference: DeviceFrameReference) => void;
45
+ onDeviceFrameUnloaded?: (deviceFrameReference: DeviceFrameReference) => void;
46
+ onMessageReceived?: (msg: FrameApiMessagesIn) => void;
47
+ onPendingDevicesConnectionRequested?: (pendingClients: Device[]) => void;
48
+ /**
49
+ * Peer-presence events for the companion frame. `onCompanionFramePeersUpdated`
50
+ * is the AUTHORITATIVE full snapshot — it fires on every change with the
51
+ * complete current peer set. `onCompanionFramePeerJoined` /
52
+ * `onCompanionFramePeerLeft` are convenience incremental events derived
53
+ * from the same underlying stream.
54
+ *
55
+ * Subscribe to ONE model, not both: either consume the snapshot and
56
+ * recompute, or consume the incremental pair — wiring up both will
57
+ * double-count every transition.
58
+ */
59
+ onCompanionFramePeerJoined?: (peer: FramePeer) => void;
60
+ onCompanionFramePeerLeft?: (peerId: string) => void;
61
+ onCompanionFramePeersUpdated?: (peers: FramePeer[]) => void;
62
+ /**
63
+ * @deprecated Use onBorderOptionsUpdated
64
+ */
65
+ onBorderlessChanged?: (isBorderless: boolean) => void;
66
+ onFullscreenChanged?: (isFullscreen: boolean) => void;
67
+ onBorderOptionsUpdated?: (borderOptions: BorderOptions) => void;
68
+ onVoiceActionDetected?: (voiceAction: VoiceActionDetection) => void;
69
+ onStateReplaced?: (newState: Record<string, any>, oldState: Record<string, any>, replacedBy: ReplacedBy, delta: UpdatedStateEntry[]) => void;
70
+ onPositionUpdated?: (positionUpdate: PositionUpdated) => void;
71
+ onDeviceFullscreenUpdated?: (deviceFullscreenUpdated: DeviceFullscreenUpdated) => void;
72
+ onVisibilityChanged?: (msg: VisibilityChanged) => void;
73
+ onDeviceScalingUpdated?: (msg: DeviceScalingUpdated) => void;
74
+ onUpdateFrameName?: (name: string) => void;
75
+ onSharedStreamUpdate?: (msg: SharedStreamState) => void;
76
+ /**
77
+ * Reverse breakout box: fires when the Vitre host exposes a live
78
+ * `MediaStream` it owns INTO this frame (e.g. a received shared camera, or a
79
+ * companion stream routed to this frame for transformation). The stream is
80
+ * rebuilt locally via `MediaStreamTrackGenerator` from transferred readables
81
+ * — zero re-encode, same-site + Chromium only. `streamId` matches a later
82
+ * `onSharedStreamRemoved`. Inverse of {@link shareStream}.
83
+ */
84
+ onSharedStream?: (streamId: string, stream: MediaStream) => void;
85
+ onSharedStreamRemoved?: (streamId: string) => void;
86
+ onMediaDevicesChanged?: (devices: ConnectedMediaDevice[]) => void;
87
+ onBluetoothMessage?: (msg: BluetoothToApp) => void;
88
+ /** @deprecated Use `crdt.onSynced` */
89
+ onYjsSynced?: () => void;
90
+ /** @deprecated Subscribe via `crdt.doc.on('update', ...)` instead. */
91
+ onYjsUpdate?: (update: Uint8Array) => void;
92
+ hostInformation: HostInformation;
93
+ /**
94
+ * The companion's own identity/runtime context, present only when this
95
+ * frame is loaded by a la Vitre **companion** (`hostInformation.isCompanion`
96
+ * is then true). Undefined on Vitre-side frames. Mirrors
97
+ * `CompanionConnector.companionInformation`. Added 1.19.
98
+ */
99
+ companionInformation?: CompanionInformation;
100
+ initiator: Device;
101
+ id: string;
102
+ appId: string;
103
+ initOptions: InitFrameOptions;
104
+ /**
105
+ * @deprecated Use initOptions.border.modeinitOptions
106
+ */
107
+ isBorderless: boolean;
108
+ isFullscreen: boolean;
109
+ state: Record<string, any>;
110
+ /**
111
+ * CRDT channel — Yjs doc + Awareness piped over the la Vitre transport.
112
+ * Libraries (Carbone, …) can call `crdt.attach(doc, awareness)` to bring
113
+ * their own; simple apps use `crdt.doc` / `crdt.awareness` directly.
114
+ */
115
+ readonly crdt: CrdtChannel;
116
+ /**
117
+ * CRDT-backed blob store built on `crdt.attachSubdoc` — see Connector.blobs.
118
+ */
119
+ readonly blobs: BlobStore;
120
+ /**
121
+ * AI tool channel — publish a catalog of tools the on-prem agent's LLM can call
122
+ * on this frame: `ai.registerTools([{ name, description, parameters, sensitive }],
123
+ * (name, args) => …)`. Register SIMPLE local names; the host namespaces them as
124
+ * `<appId>__<name>`. Invocations run against the handler and reply automatically.
125
+ */
126
+ readonly ai: AiChannel;
127
+ /** @deprecated Use `crdt.doc`. See Connector.yjsDoc for the setter
128
+ * rationale (legacy field-assignment backward-compat). */
129
+ get yjsDoc(): Y.Doc;
130
+ set yjsDoc(doc: Y.Doc);
131
+ position: Rect;
132
+ zIndex: number;
133
+ constructor(postMessage: PostMessageFrameApiOut, initMessage: InitializeFrame, options: ViewOptions, initState?: Record<string, any>);
134
+ private resolveRequest;
135
+ raiseMessage(msg: FrameApiMessagesIn): void;
136
+ private _onStateReplaced;
137
+ sendMessageTo(message: SendMessageTo): void;
138
+ sendMessageToAll(message: SendMessageToAll): void;
139
+ sendKnockKnock(message: SendKnockKnock): void;
140
+ /** Release the resources owned by this frame. Tears the CRDT channel
141
+ * down (unbinds doc/awareness listeners, destroys the default Y.Doc +
142
+ * Awareness). Safe to call multiple times. */
143
+ destroy(): void;
144
+ setFullscreen(): void;
145
+ setMenu(menu: FrameMenuEntry[]): void;
146
+ /**
147
+ * SDK 1.47 — replace the frame's export sources after initialization.
148
+ *
149
+ * The initial set comes from the `ViewOptions.exportSources` returned by
150
+ * `initializeFrame`; this is the only way to change it afterwards, e.g.
151
+ * when a document gains a format, or to flip `availableForCompanion` on a
152
+ * source once it becomes too large to hand to a phone.
153
+ *
154
+ * The call REPLACES the whole list — pass every source you still want,
155
+ * not just the new ones. The host rebuilds both its own export menu and
156
+ * the companions' from it.
157
+ */
158
+ setExportSources(exportSources: AvailableExportSource[]): void;
159
+ applyStreamAdvancedConstraints(constraints: ApplyStreamAdvancedConstraints): void;
160
+ /**
161
+ * Replace the video track of this frame's shared stream with a fresh
162
+ * `getUserMedia` capture matching `constraints` (e.g. to switch camera),
163
+ * keeping the same share alive (`replaceTrack` on the host, no
164
+ * renegotiation). The host forces the requested `deviceId` as `{ exact }`.
165
+ * Resolves with the new track infos so the frame can rebuild its menu.
166
+ */
167
+ requestReplaceStream(constraints: MediaStreamConstraints): Promise<MediaTrackInfo[]>;
168
+ setWindowed(): void;
169
+ close(): void;
170
+ sendToLocalFrame(frameConnectorId: string, data: any, fileData?: FileData): void;
171
+ sendToLocalMainConnector(data: any, fileData?: FileData): void;
172
+ /**
173
+ * Convenience for companion frames: send a message to the paired Vitre
174
+ * frame (same `frameConnectorId`). Wraps `sendToLocalFrame` with the
175
+ * current frame's id so callers don't have to repeat it. The receiving
176
+ * Vitre frame surfaces it on `onLocalConnectorMessageReceived` (data,
177
+ * from, fileData). The same primitive works from a Vitre frame too,
178
+ * but on the Vitre most apps want `sendMessageTo` / `sendMessageToAll`
179
+ * to reach other devices instead — which the companion has no way to
180
+ * address. See `CompanionFrame` for the trimmed surface intended for
181
+ * apps running on a companion frame iframe.
182
+ */
183
+ sendToVitreFrame(data: any, fileData?: FileData): void;
184
+ stopInteracting(): void;
185
+ setPosition(position: LayoutPosition): void;
186
+ setVisibility(visibility: Visibility): void;
187
+ setReducedAudioMode(enabled: boolean): void;
188
+ startInteracting(): void;
189
+ sendToSerialPort(serialPort: SendToSerialPort): void;
190
+ requestSerialPortAccess(request?: RequestSerialPortAccess): Promise<string>;
191
+ sendBluetoothMessage(msg: BluetoothFromApp): void;
192
+ disconnectGuests(deviceIds: string[]): void;
193
+ requestStreamSizeUpdate(updates: RequestStreamSizeUpdate): void;
194
+ updateName(name: string): void;
195
+ /**
196
+ * Whether {@link shareStream} is available in this runtime (Chromium
197
+ * Insertable Streams + same-site hosting). Same gate as
198
+ * `Connector.canShareStream`.
199
+ */
200
+ canShareStream(): boolean;
201
+ private toShareTracks;
202
+ /**
203
+ * Share a `MediaStream` the frame produced (e.g. a WebGL-transformed track,
204
+ * or a camera the frame opened) TO the Vitre, which forwards it to the space
205
+ * peers. Frame-context counterpart of `Connector.shareStream`: needed because
206
+ * a transform frame builds its output track locally and must reshare it.
207
+ * Handed over zero-copy via the breakout box. Returns a `sharedStreamId` for
208
+ * {@link replaceShareStream} / {@link stopShareStream}.
209
+ */
210
+ shareStream(stream: MediaStream, options?: ShareStreamOptions): Promise<string>;
211
+ /**
212
+ * Swap the source of an open frame share WITHOUT closing it (no
213
+ * renegotiation blip). `sharedStreamId` is the value returned by
214
+ * {@link shareStream}. See `Connector.replaceShareStream`.
215
+ */
216
+ replaceShareStream(sharedStreamId: string, streamOrTrack: MediaStream | MediaStreamTrack): Promise<void>;
217
+ /** Stop a frame share. `sharedStreamId` is the value returned by {@link shareStream}. */
218
+ stopShareStream(sharedStreamId: string): void;
219
+ /**
220
+ * Attach a `MediaStream` produced by this frame to a target frame's standard
221
+ * sharing slot, WITHOUT opening a new `SharedContent` or establishing a new
222
+ * `RTCPeerConnection`. The stream is forwarded zero-copy (breakout box) from
223
+ * this frame's vitre to the already-open instances of `targetFrameConnectorId`
224
+ * on other vitres; those instances receive it via {@link onSharedStream} (the
225
+ * existing `sharedStreamAvailable` delivery arm — no new protocol arm).
226
+ *
227
+ * - Requires Chromium Insertable Streams (same guard as {@link shareStream}).
228
+ * - Default target: this frame's own `frameConnectorId`, i.e. the same app
229
+ * type running on peer vitres. Pass `opts.targetFrameConnectorId` to route
230
+ * to a different frame type.
231
+ * - Resolves when the host confirms delivery (or rejects with the host error).
232
+ *
233
+ * **Delivery semantics:**
234
+ * - When `targetFrameConnectorId` is absent (default, target == this frame
235
+ * type), the stream is delivered to peer vitres' instances of this frame via
236
+ * {@link onSharedStream}. The calling frame already holds `stream` and does
237
+ * NOT receive it back via `onSharedStream` (no loopback — intentional).
238
+ * - When `targetFrameConnectorId` designates a DIFFERENT frame type, that
239
+ * frame — including its instance on the emitting vitre — receives the stream
240
+ * via {@link onSharedStream}.
241
+ */
242
+ attachStream(stream: MediaStream, opts?: {
243
+ targetFrameConnectorId?: string;
244
+ }): Promise<void>;
245
+ /**
246
+ * Stop a stream previously attached with {@link attachStream} on the target
247
+ * frame. Receivers see {@link onSharedStreamRemoved}. Default target: this
248
+ * frame's own `frameConnectorId`.
249
+ */
250
+ detachStream(opts?: {
251
+ targetFrameConnectorId?: string;
252
+ }): void;
253
+ /**
254
+ * Fetch the ICE/TURN servers the HOST already uses for its own WebRTC P2P
255
+ * (the Vitre's `StartWebRTCOffer` config, or the companion's `WebRTCOffer`
256
+ * config — same relays, same credentials). The result feeds straight into
257
+ * `new RTCPeerConnection({ iceServers })`, letting an app stand up its OWN
258
+ * peer connection — e.g. a companion-camera frame connecting directly to its
259
+ * paired Vitre transform frame — that traverses NAT through the platform's
260
+ * TURN infrastructure without shipping its own credentials.
261
+ *
262
+ * Resolves to `[]` on hosts that predate this request (the caller should
263
+ * race a timeout and fall back to a public STUN-only config). See
264
+ * {@link IceServerConfig}.
265
+ */
266
+ getIceServers(): Promise<IceServerConfig[]>;
267
+ private requestResolvers;
268
+ private postRequest;
269
+ requestEnumerateLocalFrames(): Promise<LoadedFrame[]>;
270
+ /** @deprecated Use sendMessageToEmbed */
271
+ sendExtensionMessage(data: any, target: MessageTarget, fileData?: FileData): void;
272
+ /** @deprecated Use sendMessageToEmbed */
273
+ sendAppMessage(data: any, target: MessageTarget, fileData?: FileData): void;
274
+ sendMessageToEmbed(data: any, target: MessageTarget, fileData?: FileData): void;
275
+ requestVitreSettings(): Promise<VitreSettings>;
276
+ setVitreSettings(setters: VitreSettingsSetter): void;
277
+ /**
278
+ * Share a URL/data with the host, which routes it to a matching app.
279
+ * @param owner Optional device id (`HostInformation.devicesInSpace[].id`) to
280
+ * attribute the resulting shared content to. Drives the languette colour/info
281
+ * and the content appears already-owned on every vitre. Default: opener.
282
+ */
283
+ shareData(url: string, targetAppId?: AppId, owner?: string): void;
284
+ /**
285
+ * Share a file with the host, which routes it to a matching app.
286
+ * @param owner Optional device id to attribute the share to. See {@link shareData}.
287
+ */
288
+ shareFile(fileData: FileData, targetAppId: AppId, owner?: string): void;
289
+ saveSettings(settings: any): void;
290
+ changeTeamSpace(space: string): void;
291
+ changeTeamSpaceGuest(space: string, teamDomain: string): void;
292
+ showNotification(notification: NotificationInfo): void;
293
+ hideNotification(notificationId: string): void;
294
+ changePrivacy(privacy: Privacy): void;
295
+ trackEvent(name: string, properties?: Record<string, any>): void;
296
+ startTrackEvent(name: string): void;
297
+ stopTrackEvent(name: string, properties?: Record<string, any>): void;
298
+ getMainConnectorFrame(): Window | null;
299
+ getMainConnector(): Connector | null;
300
+ setBorderOptions(borderOptions: BorderOptions): void;
301
+ setVoiceActions(actions: VoiceAction[]): void;
302
+ requestStreamCapture(): Promise<StreamCapture>;
303
+ requestStats(): Promise<StatsResponse>;
304
+ updateState(updates: UpdateStateEntry[], forceApplyLocally?: boolean): void;
305
+ sharedStream: SharedStream;
306
+ }
307
+ type PostMessageFrameApiOut = (message: FrameApiMessagesOut, transfer?: Transferable[]) => void;
308
+ export declare function initializeFrame<T extends Frame>(init: (info: HostInformation, initiator: Device, options: InitFrameOptions, state?: Record<string, any>) => ViewOptions, createFrame?: new (postMessage: PostMessageFrameApiOut, initMessage: InitializeFrame, options: ViewOptions) => T): Promise<T>;
309
+ export {};