@aperture-browser/live-session 0.0.0-init.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.
@@ -0,0 +1,807 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Schema from "effect/Schema";
3
+ import { ApiCredentials, IceServer } from "@aperture-browser/api-client";
4
+
5
+ //#region src/browser-input.d.ts
6
+ type BrowserInputMessage = {
7
+ type: "input.mouse";
8
+ targetId: string;
9
+ action: "move" | "down" | "up" | "click" | "doubleClick";
10
+ x: number;
11
+ y: number;
12
+ button?: "left" | "middle" | "right" | "none";
13
+ buttons?: number;
14
+ clickCount?: number;
15
+ modifiers?: number;
16
+ } | {
17
+ type: "input.wheel";
18
+ targetId: string;
19
+ x: number;
20
+ y: number;
21
+ deltaX: number;
22
+ deltaY: number;
23
+ modifiers?: number;
24
+ } | {
25
+ type: "input.key";
26
+ targetId: string;
27
+ action: "down" | "up" | "char";
28
+ key?: string;
29
+ code?: string;
30
+ text?: string;
31
+ unmodifiedText?: string;
32
+ modifiers?: number;
33
+ windowsVirtualKeyCode?: number;
34
+ nativeVirtualKeyCode?: number;
35
+ location?: number;
36
+ autoRepeat?: boolean;
37
+ isKeypad?: boolean;
38
+ } | {
39
+ type: "clipboard.copy";
40
+ targetId: string;
41
+ } | {
42
+ type: "clipboard.cut";
43
+ targetId: string;
44
+ } | {
45
+ type: "clipboard.paste";
46
+ targetId: string;
47
+ items: Array<{
48
+ mimeType: string;
49
+ data: string;
50
+ }>;
51
+ };
52
+ //#endregion
53
+ //#region src/input-keycodes.d.ts
54
+ declare const evdevKeycodeByCode: Readonly<Record<string, number>>;
55
+ //#endregion
56
+ //#region src/keyboard.d.ts
57
+ type KeyboardInputMessage = Extract<BrowserInputMessage, {
58
+ type: "input.key";
59
+ }>;
60
+ declare function keyboardModifiers(event: KeyboardEvent | MouseEvent | WheelEvent): number;
61
+ declare function isPrintableKey(event: KeyboardEvent): boolean;
62
+ declare function keyboardInputMessage(event: KeyboardEvent, action: KeyboardInputMessage["action"]): Omit<KeyboardInputMessage, "type" | "targetId" | "action">;
63
+ declare function shouldForwardBrowserShortcut(event: KeyboardEvent): boolean;
64
+ declare function windowsVirtualKeyCodeForCodeOrKey(code: string | undefined, key: string | undefined): number;
65
+ //#endregion
66
+ //#region src/protocol.d.ts
67
+ declare const LIVE_SESSION_PROTOCOL = "aperture-session.v1";
68
+ type CollaborationRole = "owner" | "editor" | "viewer";
69
+ type CollaborationLeaseMode = "implicit" | "explicit";
70
+ type CollaborationPhase = "idle" | "connecting" | "connected" | "disconnected";
71
+ interface CollaborationCursor {
72
+ clientId: string;
73
+ targetId: string;
74
+ x: number;
75
+ y: number;
76
+ }
77
+ type CollaborationPaintPhase = "start" | "move" | "end";
78
+ interface CollaborationPaintPoint {
79
+ targetId: string;
80
+ strokeId: string;
81
+ color: string;
82
+ width: number;
83
+ phase: CollaborationPaintPhase;
84
+ x: number;
85
+ y: number;
86
+ }
87
+ type CollaborationPaintEvent = {
88
+ type: "point";
89
+ message: CollaborationPaintPoint & {
90
+ clientId: string;
91
+ };
92
+ } | {
93
+ type: "clear";
94
+ };
95
+ interface CollaborationError {
96
+ code: string;
97
+ message: string;
98
+ }
99
+ /**
100
+ * Server messages are decoded strictly: an unknown property means the server speaks a
101
+ * protocol revision this client does not understand.
102
+ */
103
+ declare const strictParseOptions: {
104
+ readonly onExcessProperty: "error";
105
+ };
106
+ declare const PresentationQuality: Schema.Struct<{
107
+ readonly profile: Schema.String;
108
+ readonly fps: Schema.Number;
109
+ readonly bitrateKbps: Schema.Number;
110
+ readonly keyframeInterval: Schema.Number;
111
+ }>;
112
+ declare const Presentation: Schema.Struct<{
113
+ readonly quality: Schema.optionalKey<Schema.Struct<{
114
+ readonly profile: Schema.String;
115
+ readonly fps: Schema.Number;
116
+ readonly bitrateKbps: Schema.Number;
117
+ readonly keyframeInterval: Schema.Number;
118
+ }>>;
119
+ readonly profiles: Schema.$Array<Schema.Struct<{
120
+ readonly id: Schema.String;
121
+ readonly label: Schema.String;
122
+ readonly codec: Schema.String;
123
+ readonly mimeType: Schema.String;
124
+ readonly sdpFmtpLine: Schema.String;
125
+ }>>;
126
+ readonly cursorVisible: Schema.Boolean;
127
+ }>;
128
+ declare const Target: Schema.Struct<{
129
+ readonly id: Schema.String;
130
+ readonly type: Schema.String;
131
+ readonly title: Schema.String;
132
+ readonly url: Schema.String;
133
+ readonly loading: Schema.Boolean;
134
+ readonly viewport: Schema.optionalKey<Schema.Struct<{
135
+ readonly width: Schema.Number;
136
+ readonly height: Schema.Number;
137
+ readonly contentWidth: Schema.Number;
138
+ readonly contentHeight: Schema.Number;
139
+ readonly canvasWidth: Schema.Number;
140
+ readonly canvasHeight: Schema.Number;
141
+ readonly deviceScaleFactor: Schema.Number;
142
+ }>>;
143
+ }>;
144
+ declare const Participant: Schema.Struct<{
145
+ readonly clientId: Schema.String;
146
+ readonly name: Schema.String;
147
+ readonly avatarHash: Schema.String;
148
+ readonly role: Schema.Literals<readonly ["owner", "editor", "viewer", "automation"]>;
149
+ readonly activeTargetId: Schema.optionalKey<Schema.String>;
150
+ readonly followingClientId: Schema.optionalKey<Schema.String>;
151
+ readonly holdingInput: Schema.Boolean;
152
+ readonly leaseMode: Schema.optionalKey<Schema.Literals<readonly ["implicit", "explicit"]>>;
153
+ readonly recovering: Schema.optionalKey<Schema.Boolean>;
154
+ }>;
155
+ declare const Snapshot: Schema.Struct<{
156
+ readonly type: Schema.Literal<"session.snapshot">;
157
+ readonly clientId: Schema.String;
158
+ readonly resumeSecret: Schema.String;
159
+ readonly role: Schema.Literals<readonly ["owner", "editor", "viewer"]>;
160
+ readonly transport: Schema.Literals<readonly ["webrtc", "websocket"]>;
161
+ readonly holderClientId: Schema.optionalKey<Schema.String>;
162
+ readonly mode: Schema.optionalKey<Schema.Literals<readonly ["implicit", "explicit"]>>;
163
+ readonly activeTargetId: Schema.optionalKey<Schema.String>;
164
+ readonly targets: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
165
+ readonly id: Schema.String;
166
+ readonly type: Schema.String;
167
+ readonly title: Schema.String;
168
+ readonly url: Schema.String;
169
+ readonly loading: Schema.Boolean;
170
+ readonly viewport: Schema.optionalKey<Schema.Struct<{
171
+ readonly width: Schema.Number;
172
+ readonly height: Schema.Number;
173
+ readonly contentWidth: Schema.Number;
174
+ readonly contentHeight: Schema.Number;
175
+ readonly canvasWidth: Schema.Number;
176
+ readonly canvasHeight: Schema.Number;
177
+ readonly deviceScaleFactor: Schema.Number;
178
+ }>>;
179
+ }>>, never>;
180
+ readonly participants: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
181
+ readonly clientId: Schema.String;
182
+ readonly name: Schema.String;
183
+ readonly avatarHash: Schema.String;
184
+ readonly role: Schema.Literals<readonly ["owner", "editor", "viewer", "automation"]>;
185
+ readonly activeTargetId: Schema.optionalKey<Schema.String>;
186
+ readonly followingClientId: Schema.optionalKey<Schema.String>;
187
+ readonly holdingInput: Schema.Boolean;
188
+ readonly leaseMode: Schema.optionalKey<Schema.Literals<readonly ["implicit", "explicit"]>>;
189
+ readonly recovering: Schema.optionalKey<Schema.Boolean>;
190
+ }>>, never>;
191
+ readonly recordings: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
192
+ readonly recordingId: Schema.String;
193
+ readonly mode: Schema.Literals<readonly ["tab", "viewer"]>;
194
+ readonly targetId: Schema.String;
195
+ readonly captureGeneration: Schema.Number;
196
+ readonly status: Schema.Literals<readonly ["starting", "running", "stopped", "failed"]>;
197
+ readonly stopReason: Schema.optionalKey<Schema.String>;
198
+ readonly path: Schema.String;
199
+ readonly startedAt: Schema.String;
200
+ readonly stoppedAt: Schema.optionalKey<Schema.String>;
201
+ readonly sizeBytes: Schema.optionalKey<Schema.Number>;
202
+ readonly fps: Schema.Number;
203
+ readonly bitrateKbps: Schema.Number;
204
+ readonly codec: Schema.String;
205
+ }>>, never>;
206
+ readonly presentation: Schema.Struct<{
207
+ readonly quality: Schema.optionalKey<Schema.Struct<{
208
+ readonly profile: Schema.String;
209
+ readonly fps: Schema.Number;
210
+ readonly bitrateKbps: Schema.Number;
211
+ readonly keyframeInterval: Schema.Number;
212
+ }>>;
213
+ readonly profiles: Schema.$Array<Schema.Struct<{
214
+ readonly id: Schema.String;
215
+ readonly label: Schema.String;
216
+ readonly codec: Schema.String;
217
+ readonly mimeType: Schema.String;
218
+ readonly sdpFmtpLine: Schema.String;
219
+ }>>;
220
+ readonly cursorVisible: Schema.Boolean;
221
+ }>;
222
+ }>;
223
+ declare const CommandResult: Schema.Struct<{
224
+ readonly type: Schema.Literals<readonly ["target.select.result", "target.create.result", "target.close.result", "page.navigate.result", "page.history-back.result", "page.history-forward.result", "page.reload.result", "page.stop-loading.result", "viewport.set.result", "presentation.quality.set.result", "presentation.cursor.set.result", "recording.start.result", "recording.stop.result", "recording.cancel.result"]>;
225
+ readonly requestId: Schema.String;
226
+ readonly ok: Schema.Boolean;
227
+ readonly code: Schema.optionalKey<Schema.String>;
228
+ readonly message: Schema.optionalKey<Schema.String>;
229
+ readonly targetId: Schema.optionalKey<Schema.String>;
230
+ readonly recording: Schema.optionalKey<Schema.Struct<{
231
+ readonly recordingId: Schema.String;
232
+ readonly mode: Schema.Literals<readonly ["tab", "viewer"]>;
233
+ readonly targetId: Schema.String;
234
+ readonly captureGeneration: Schema.Number;
235
+ readonly status: Schema.Literals<readonly ["starting", "running", "stopped", "failed"]>;
236
+ readonly stopReason: Schema.optionalKey<Schema.String>;
237
+ readonly path: Schema.String;
238
+ readonly startedAt: Schema.String;
239
+ readonly stoppedAt: Schema.optionalKey<Schema.String>;
240
+ readonly sizeBytes: Schema.optionalKey<Schema.Number>;
241
+ readonly fps: Schema.Number;
242
+ readonly bitrateKbps: Schema.Number;
243
+ readonly codec: Schema.String;
244
+ }>>;
245
+ readonly presentation: Schema.optionalKey<Schema.Struct<{
246
+ readonly quality: Schema.optionalKey<Schema.Struct<{
247
+ readonly profile: Schema.String;
248
+ readonly fps: Schema.Number;
249
+ readonly bitrateKbps: Schema.Number;
250
+ readonly keyframeInterval: Schema.Number;
251
+ }>>;
252
+ readonly profiles: Schema.$Array<Schema.Struct<{
253
+ readonly id: Schema.String;
254
+ readonly label: Schema.String;
255
+ readonly codec: Schema.String;
256
+ readonly mimeType: Schema.String;
257
+ readonly sdpFmtpLine: Schema.String;
258
+ }>>;
259
+ readonly cursorVisible: Schema.Boolean;
260
+ }>>;
261
+ }>;
262
+ declare const LiveSessionServerMessage: Schema.Union<readonly [Schema.Struct<{
263
+ readonly type: Schema.Literal<"session.snapshot">;
264
+ readonly clientId: Schema.String;
265
+ readonly resumeSecret: Schema.String;
266
+ readonly role: Schema.Literals<readonly ["owner", "editor", "viewer"]>;
267
+ readonly transport: Schema.Literals<readonly ["webrtc", "websocket"]>;
268
+ readonly holderClientId: Schema.optionalKey<Schema.String>;
269
+ readonly mode: Schema.optionalKey<Schema.Literals<readonly ["implicit", "explicit"]>>;
270
+ readonly activeTargetId: Schema.optionalKey<Schema.String>;
271
+ readonly targets: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
272
+ readonly id: Schema.String;
273
+ readonly type: Schema.String;
274
+ readonly title: Schema.String;
275
+ readonly url: Schema.String;
276
+ readonly loading: Schema.Boolean;
277
+ readonly viewport: Schema.optionalKey<Schema.Struct<{
278
+ readonly width: Schema.Number;
279
+ readonly height: Schema.Number;
280
+ readonly contentWidth: Schema.Number;
281
+ readonly contentHeight: Schema.Number;
282
+ readonly canvasWidth: Schema.Number;
283
+ readonly canvasHeight: Schema.Number;
284
+ readonly deviceScaleFactor: Schema.Number;
285
+ }>>;
286
+ }>>, never>;
287
+ readonly participants: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
288
+ readonly clientId: Schema.String;
289
+ readonly name: Schema.String;
290
+ readonly avatarHash: Schema.String;
291
+ readonly role: Schema.Literals<readonly ["owner", "editor", "viewer", "automation"]>;
292
+ readonly activeTargetId: Schema.optionalKey<Schema.String>;
293
+ readonly followingClientId: Schema.optionalKey<Schema.String>;
294
+ readonly holdingInput: Schema.Boolean;
295
+ readonly leaseMode: Schema.optionalKey<Schema.Literals<readonly ["implicit", "explicit"]>>;
296
+ readonly recovering: Schema.optionalKey<Schema.Boolean>;
297
+ }>>, never>;
298
+ readonly recordings: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
299
+ readonly recordingId: Schema.String;
300
+ readonly mode: Schema.Literals<readonly ["tab", "viewer"]>;
301
+ readonly targetId: Schema.String;
302
+ readonly captureGeneration: Schema.Number;
303
+ readonly status: Schema.Literals<readonly ["starting", "running", "stopped", "failed"]>;
304
+ readonly stopReason: Schema.optionalKey<Schema.String>;
305
+ readonly path: Schema.String;
306
+ readonly startedAt: Schema.String;
307
+ readonly stoppedAt: Schema.optionalKey<Schema.String>;
308
+ readonly sizeBytes: Schema.optionalKey<Schema.Number>;
309
+ readonly fps: Schema.Number;
310
+ readonly bitrateKbps: Schema.Number;
311
+ readonly codec: Schema.String;
312
+ }>>, never>;
313
+ readonly presentation: Schema.Struct<{
314
+ readonly quality: Schema.optionalKey<Schema.Struct<{
315
+ readonly profile: Schema.String;
316
+ readonly fps: Schema.Number;
317
+ readonly bitrateKbps: Schema.Number;
318
+ readonly keyframeInterval: Schema.Number;
319
+ }>>;
320
+ readonly profiles: Schema.$Array<Schema.Struct<{
321
+ readonly id: Schema.String;
322
+ readonly label: Schema.String;
323
+ readonly codec: Schema.String;
324
+ readonly mimeType: Schema.String;
325
+ readonly sdpFmtpLine: Schema.String;
326
+ }>>;
327
+ readonly cursorVisible: Schema.Boolean;
328
+ }>;
329
+ }>, Schema.Struct<{
330
+ readonly type: Schema.Literal<"presence.state">;
331
+ readonly participants: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
332
+ readonly clientId: Schema.String;
333
+ readonly name: Schema.String;
334
+ readonly avatarHash: Schema.String;
335
+ readonly role: Schema.Literals<readonly ["owner", "editor", "viewer", "automation"]>;
336
+ readonly activeTargetId: Schema.optionalKey<Schema.String>;
337
+ readonly followingClientId: Schema.optionalKey<Schema.String>;
338
+ readonly holdingInput: Schema.Boolean;
339
+ readonly leaseMode: Schema.optionalKey<Schema.Literals<readonly ["implicit", "explicit"]>>;
340
+ readonly recovering: Schema.optionalKey<Schema.Boolean>;
341
+ }>>, never>;
342
+ }>, Schema.Struct<{
343
+ readonly type: Schema.Literal<"input.state">;
344
+ readonly holderClientId: Schema.optionalKey<Schema.String>;
345
+ readonly mode: Schema.optionalKey<Schema.Literals<readonly ["implicit", "explicit"]>>;
346
+ }>, Schema.Struct<{
347
+ readonly type: Schema.Literal<"presence.cursor">;
348
+ readonly clientId: Schema.String;
349
+ readonly targetId: Schema.String;
350
+ readonly x: Schema.Number;
351
+ readonly y: Schema.Number;
352
+ readonly realtimeCounter: Schema.Number;
353
+ }>, Schema.Struct<{
354
+ readonly type: Schema.Literal<"presence.cursor.clear">;
355
+ readonly clientId: Schema.String;
356
+ readonly realtimeCounter: Schema.Number;
357
+ }>, Schema.Struct<{
358
+ readonly type: Schema.Literal<"paint.point">;
359
+ readonly clientId: Schema.String;
360
+ readonly targetId: Schema.String;
361
+ readonly strokeId: Schema.String;
362
+ readonly color: Schema.String;
363
+ readonly width: Schema.Number;
364
+ readonly phase: Schema.Literals<readonly ["start", "move", "end"]>;
365
+ readonly x: Schema.Number;
366
+ readonly y: Schema.Number;
367
+ readonly realtimeCounter: Schema.optionalKey<Schema.Number>;
368
+ }>, Schema.Struct<{
369
+ readonly type: Schema.Literal<"targets.state">;
370
+ readonly activeTargetId: Schema.optionalKey<Schema.String>;
371
+ readonly targets: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
372
+ readonly id: Schema.String;
373
+ readonly type: Schema.String;
374
+ readonly title: Schema.String;
375
+ readonly url: Schema.String;
376
+ readonly loading: Schema.Boolean;
377
+ readonly viewport: Schema.optionalKey<Schema.Struct<{
378
+ readonly width: Schema.Number;
379
+ readonly height: Schema.Number;
380
+ readonly contentWidth: Schema.Number;
381
+ readonly contentHeight: Schema.Number;
382
+ readonly canvasWidth: Schema.Number;
383
+ readonly canvasHeight: Schema.Number;
384
+ readonly deviceScaleFactor: Schema.Number;
385
+ }>>;
386
+ }>>, never>;
387
+ }>, Schema.Struct<{
388
+ readonly type: Schema.Literal<"recordings.state">;
389
+ readonly recordings: Schema.withDecodingDefaultKey<Schema.$Array<Schema.Struct<{
390
+ readonly recordingId: Schema.String;
391
+ readonly mode: Schema.Literals<readonly ["tab", "viewer"]>;
392
+ readonly targetId: Schema.String;
393
+ readonly captureGeneration: Schema.Number;
394
+ readonly status: Schema.Literals<readonly ["starting", "running", "stopped", "failed"]>;
395
+ readonly stopReason: Schema.optionalKey<Schema.String>;
396
+ readonly path: Schema.String;
397
+ readonly startedAt: Schema.String;
398
+ readonly stoppedAt: Schema.optionalKey<Schema.String>;
399
+ readonly sizeBytes: Schema.optionalKey<Schema.Number>;
400
+ readonly fps: Schema.Number;
401
+ readonly bitrateKbps: Schema.Number;
402
+ readonly codec: Schema.String;
403
+ }>>, never>;
404
+ }>, Schema.Struct<{
405
+ readonly type: Schema.Literal<"presentation.state">;
406
+ readonly presentation: Schema.Struct<{
407
+ readonly quality: Schema.optionalKey<Schema.Struct<{
408
+ readonly profile: Schema.String;
409
+ readonly fps: Schema.Number;
410
+ readonly bitrateKbps: Schema.Number;
411
+ readonly keyframeInterval: Schema.Number;
412
+ }>>;
413
+ readonly profiles: Schema.$Array<Schema.Struct<{
414
+ readonly id: Schema.String;
415
+ readonly label: Schema.String;
416
+ readonly codec: Schema.String;
417
+ readonly mimeType: Schema.String;
418
+ readonly sdpFmtpLine: Schema.String;
419
+ }>>;
420
+ readonly cursorVisible: Schema.Boolean;
421
+ }>;
422
+ }>, Schema.Struct<{
423
+ readonly type: Schema.Literal<"error">;
424
+ readonly code: Schema.String;
425
+ readonly message: Schema.String;
426
+ }>, Schema.Struct<{
427
+ readonly type: Schema.Literals<readonly ["target.select.result", "target.create.result", "target.close.result", "page.navigate.result", "page.history-back.result", "page.history-forward.result", "page.reload.result", "page.stop-loading.result", "viewport.set.result", "presentation.quality.set.result", "presentation.cursor.set.result", "recording.start.result", "recording.stop.result", "recording.cancel.result"]>;
428
+ readonly requestId: Schema.String;
429
+ readonly ok: Schema.Boolean;
430
+ readonly code: Schema.optionalKey<Schema.String>;
431
+ readonly message: Schema.optionalKey<Schema.String>;
432
+ readonly targetId: Schema.optionalKey<Schema.String>;
433
+ readonly recording: Schema.optionalKey<Schema.Struct<{
434
+ readonly recordingId: Schema.String;
435
+ readonly mode: Schema.Literals<readonly ["tab", "viewer"]>;
436
+ readonly targetId: Schema.String;
437
+ readonly captureGeneration: Schema.Number;
438
+ readonly status: Schema.Literals<readonly ["starting", "running", "stopped", "failed"]>;
439
+ readonly stopReason: Schema.optionalKey<Schema.String>;
440
+ readonly path: Schema.String;
441
+ readonly startedAt: Schema.String;
442
+ readonly stoppedAt: Schema.optionalKey<Schema.String>;
443
+ readonly sizeBytes: Schema.optionalKey<Schema.Number>;
444
+ readonly fps: Schema.Number;
445
+ readonly bitrateKbps: Schema.Number;
446
+ readonly codec: Schema.String;
447
+ }>>;
448
+ readonly presentation: Schema.optionalKey<Schema.Struct<{
449
+ readonly quality: Schema.optionalKey<Schema.Struct<{
450
+ readonly profile: Schema.String;
451
+ readonly fps: Schema.Number;
452
+ readonly bitrateKbps: Schema.Number;
453
+ readonly keyframeInterval: Schema.Number;
454
+ }>>;
455
+ readonly profiles: Schema.$Array<Schema.Struct<{
456
+ readonly id: Schema.String;
457
+ readonly label: Schema.String;
458
+ readonly codec: Schema.String;
459
+ readonly mimeType: Schema.String;
460
+ readonly sdpFmtpLine: Schema.String;
461
+ }>>;
462
+ readonly cursorVisible: Schema.Boolean;
463
+ }>>;
464
+ }>]>;
465
+ /** Decodes one JSON text frame from the server, or returns undefined when it is invalid. */
466
+ declare const decodeServerMessage: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Option").Option<{
467
+ readonly type: "target.select.result" | "target.create.result" | "target.close.result" | "page.navigate.result" | "page.history-back.result" | "page.history-forward.result" | "page.reload.result" | "page.stop-loading.result" | "viewport.set.result" | "presentation.quality.set.result" | "presentation.cursor.set.result" | "recording.start.result" | "recording.stop.result" | "recording.cancel.result";
468
+ readonly requestId: string;
469
+ readonly ok: boolean;
470
+ readonly message?: string | undefined;
471
+ readonly code?: string | undefined;
472
+ readonly targetId?: string | undefined;
473
+ readonly recording?: {
474
+ readonly targetId: string;
475
+ readonly mode: "tab" | "viewer";
476
+ readonly status: "starting" | "running" | "stopped" | "failed";
477
+ readonly recordingId: string;
478
+ readonly captureGeneration: number;
479
+ readonly path: string;
480
+ readonly startedAt: string;
481
+ readonly fps: number;
482
+ readonly bitrateKbps: number;
483
+ readonly codec: string;
484
+ readonly stopReason?: string | undefined;
485
+ readonly stoppedAt?: string | undefined;
486
+ readonly sizeBytes?: number | undefined;
487
+ } | undefined;
488
+ readonly presentation?: {
489
+ readonly profiles: readonly {
490
+ readonly id: string;
491
+ readonly label: string;
492
+ readonly codec: string;
493
+ readonly mimeType: string;
494
+ readonly sdpFmtpLine: string;
495
+ }[];
496
+ readonly cursorVisible: boolean;
497
+ readonly quality?: {
498
+ readonly profile: string;
499
+ readonly fps: number;
500
+ readonly bitrateKbps: number;
501
+ readonly keyframeInterval: number;
502
+ } | undefined;
503
+ } | undefined;
504
+ } | {
505
+ readonly type: "session.snapshot";
506
+ readonly presentation: {
507
+ readonly profiles: readonly {
508
+ readonly id: string;
509
+ readonly label: string;
510
+ readonly codec: string;
511
+ readonly mimeType: string;
512
+ readonly sdpFmtpLine: string;
513
+ }[];
514
+ readonly cursorVisible: boolean;
515
+ readonly quality?: {
516
+ readonly profile: string;
517
+ readonly fps: number;
518
+ readonly bitrateKbps: number;
519
+ readonly keyframeInterval: number;
520
+ } | undefined;
521
+ };
522
+ readonly role: "viewer" | "owner" | "editor";
523
+ readonly transport: "webrtc" | "websocket";
524
+ readonly targets: readonly {
525
+ readonly type: string;
526
+ readonly id: string;
527
+ readonly title: string;
528
+ readonly url: string;
529
+ readonly loading: boolean;
530
+ readonly viewport?: {
531
+ readonly width: number;
532
+ readonly height: number;
533
+ readonly contentWidth: number;
534
+ readonly contentHeight: number;
535
+ readonly canvasWidth: number;
536
+ readonly canvasHeight: number;
537
+ readonly deviceScaleFactor: number;
538
+ } | undefined;
539
+ }[];
540
+ readonly participants: readonly {
541
+ readonly role: "viewer" | "owner" | "editor" | "automation";
542
+ readonly clientId: string;
543
+ readonly name: string;
544
+ readonly avatarHash: string;
545
+ readonly holdingInput: boolean;
546
+ readonly activeTargetId?: string | undefined;
547
+ readonly followingClientId?: string | undefined;
548
+ readonly leaseMode?: "implicit" | "explicit" | undefined;
549
+ readonly recovering?: boolean | undefined;
550
+ }[];
551
+ readonly clientId: string;
552
+ readonly recordings: readonly {
553
+ readonly targetId: string;
554
+ readonly mode: "tab" | "viewer";
555
+ readonly status: "starting" | "running" | "stopped" | "failed";
556
+ readonly recordingId: string;
557
+ readonly captureGeneration: number;
558
+ readonly path: string;
559
+ readonly startedAt: string;
560
+ readonly fps: number;
561
+ readonly bitrateKbps: number;
562
+ readonly codec: string;
563
+ readonly stopReason?: string | undefined;
564
+ readonly stoppedAt?: string | undefined;
565
+ readonly sizeBytes?: number | undefined;
566
+ }[];
567
+ readonly resumeSecret: string;
568
+ readonly mode?: "implicit" | "explicit" | undefined;
569
+ readonly holderClientId?: string | undefined;
570
+ readonly activeTargetId?: string | undefined;
571
+ } | {
572
+ readonly type: "presence.state";
573
+ readonly participants: readonly {
574
+ readonly role: "viewer" | "owner" | "editor" | "automation";
575
+ readonly clientId: string;
576
+ readonly name: string;
577
+ readonly avatarHash: string;
578
+ readonly holdingInput: boolean;
579
+ readonly activeTargetId?: string | undefined;
580
+ readonly followingClientId?: string | undefined;
581
+ readonly leaseMode?: "implicit" | "explicit" | undefined;
582
+ readonly recovering?: boolean | undefined;
583
+ }[];
584
+ } | {
585
+ readonly type: "input.state";
586
+ readonly mode?: "implicit" | "explicit" | undefined;
587
+ readonly holderClientId?: string | undefined;
588
+ } | {
589
+ readonly type: "presence.cursor";
590
+ readonly clientId: string;
591
+ readonly targetId: string;
592
+ readonly x: number;
593
+ readonly y: number;
594
+ readonly realtimeCounter: number;
595
+ } | {
596
+ readonly type: "presence.cursor.clear";
597
+ readonly clientId: string;
598
+ readonly realtimeCounter: number;
599
+ } | {
600
+ readonly type: "paint.point";
601
+ readonly targetId: string;
602
+ readonly width: number;
603
+ readonly clientId: string;
604
+ readonly x: number;
605
+ readonly y: number;
606
+ readonly phase: "start" | "move" | "end";
607
+ readonly strokeId: string;
608
+ readonly color: string;
609
+ readonly realtimeCounter?: number | undefined;
610
+ } | {
611
+ readonly type: "targets.state";
612
+ readonly targets: readonly {
613
+ readonly type: string;
614
+ readonly id: string;
615
+ readonly title: string;
616
+ readonly url: string;
617
+ readonly loading: boolean;
618
+ readonly viewport?: {
619
+ readonly width: number;
620
+ readonly height: number;
621
+ readonly contentWidth: number;
622
+ readonly contentHeight: number;
623
+ readonly canvasWidth: number;
624
+ readonly canvasHeight: number;
625
+ readonly deviceScaleFactor: number;
626
+ } | undefined;
627
+ }[];
628
+ readonly activeTargetId?: string | undefined;
629
+ } | {
630
+ readonly type: "recordings.state";
631
+ readonly recordings: readonly {
632
+ readonly targetId: string;
633
+ readonly mode: "tab" | "viewer";
634
+ readonly status: "starting" | "running" | "stopped" | "failed";
635
+ readonly recordingId: string;
636
+ readonly captureGeneration: number;
637
+ readonly path: string;
638
+ readonly startedAt: string;
639
+ readonly fps: number;
640
+ readonly bitrateKbps: number;
641
+ readonly codec: string;
642
+ readonly stopReason?: string | undefined;
643
+ readonly stoppedAt?: string | undefined;
644
+ readonly sizeBytes?: number | undefined;
645
+ }[];
646
+ } | {
647
+ readonly type: "presentation.state";
648
+ readonly presentation: {
649
+ readonly profiles: readonly {
650
+ readonly id: string;
651
+ readonly label: string;
652
+ readonly codec: string;
653
+ readonly mimeType: string;
654
+ readonly sdpFmtpLine: string;
655
+ }[];
656
+ readonly cursorVisible: boolean;
657
+ readonly quality?: {
658
+ readonly profile: string;
659
+ readonly fps: number;
660
+ readonly bitrateKbps: number;
661
+ readonly keyframeInterval: number;
662
+ } | undefined;
663
+ };
664
+ } | {
665
+ readonly type: "error";
666
+ readonly code: string;
667
+ readonly message: string;
668
+ }>;
669
+ type LiveSessionServerMessage = typeof LiveSessionServerMessage.Type;
670
+ type LiveSessionSnapshot = typeof Snapshot.Type;
671
+ type LiveSessionTarget = typeof Target.Type;
672
+ type LiveSessionCommandResult = typeof CommandResult.Type;
673
+ type LiveSessionPresentation = typeof Presentation.Type;
674
+ type LiveSessionPresentationQuality = typeof PresentationQuality.Type;
675
+ type CollaborationParticipant = typeof Participant.Type;
676
+ declare const RasterFrameHeader: Schema.Struct<{
677
+ readonly type: Schema.Literal<"presentation.frame">;
678
+ readonly targetId: Schema.String;
679
+ readonly width: Schema.Number;
680
+ readonly height: Schema.Number;
681
+ }>;
682
+ type LiveSessionRasterFrame = Omit<typeof RasterFrameHeader.Type, "type"> & {
683
+ data: Blob;
684
+ };
685
+ //#endregion
686
+ //#region src/viewport.d.ts
687
+ interface ViewportPreset {
688
+ id: string;
689
+ label: string;
690
+ width: number;
691
+ height: number;
692
+ deviceScaleFactor: number;
693
+ }
694
+ declare const VIEWPORT_PRESETS: ViewportPreset[];
695
+ declare const DEFAULT_VIEWPORT: ViewportPreset;
696
+ declare const VIEWPORT_DEVICE_SCALE_FACTORS: readonly [1, 1.5, 2, 3];
697
+ declare const STALE_FRAME_MS = 3000;
698
+ interface RenderMetrics {
699
+ scale: number;
700
+ offsetX: number;
701
+ offsetY: number;
702
+ renderedWidth: number;
703
+ renderedHeight: number;
704
+ }
705
+ declare function createViewportPreset(width: number, height: number, deviceScaleFactor: number): ViewportPreset;
706
+ declare function formatViewportScale(deviceScaleFactor: number): string;
707
+ declare function computeRenderMetrics(containerWidth: number, containerHeight: number, viewportWidth: number, viewportHeight: number): RenderMetrics;
708
+ declare function mapClientToViewport(clientX: number, clientY: number, rect: DOMRect, viewportWidth: number, viewportHeight: number): {
709
+ x: number;
710
+ y: number;
711
+ } | null;
712
+ declare namespace connection_d_exports {
713
+ export { LiveSessionConnection, LiveSessionConnectionCallbacks, LiveSessionConnectionOptions, LiveSessionError, LiveSessionSnapshot, LiveSessionTransportKind, make };
714
+ }
715
+ declare const LiveSessionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
716
+ readonly _tag: "LiveSessionError";
717
+ } & Readonly<A>;
718
+ /** A live session operation that could not complete. */
719
+ declare class LiveSessionError extends LiveSessionError_base<{
720
+ readonly message: string;
721
+ }> {}
722
+ interface SessionHelloIdentity {
723
+ name: string;
724
+ avatarHash: string;
725
+ }
726
+ type LiveSessionTransportKind = "webrtc" | "websocket";
727
+ interface LiveSessionConnectionCallbacks {
728
+ onPhase: (phase: "connecting" | "connected" | "disconnected" | "error") => void;
729
+ onMessage: (message: LiveSessionServerMessage) => void;
730
+ onFrame: (frame: LiveSessionRasterFrame | null) => void;
731
+ onStream: (stream: MediaStream | null) => void;
732
+ onTransport: (transport: LiveSessionTransportKind | null) => void;
733
+ onError: (message: string) => void;
734
+ }
735
+ interface LiveSessionConnectionOptions {
736
+ baseUrl?: string;
737
+ sessionId: string;
738
+ credentials: ApiCredentials;
739
+ sessionToken?: string;
740
+ identity: SessionHelloIdentity;
741
+ iceServers: readonly IceServer[];
742
+ webrtcSupported: boolean;
743
+ callbacks: LiveSessionConnectionCallbacks;
744
+ }
745
+ interface LiveSessionConnection {
746
+ /** Replaces the current session transport with a fresh one. */
747
+ readonly reconnect: Effect.Effect<void>;
748
+ /** Switches presentation to the given transport once it is ready. */
749
+ readonly selectTransport: (kind: LiveSessionTransportKind) => Effect.Effect<void, LiveSessionError>;
750
+ readonly sendReliable: (message: Record<string, unknown>) => boolean;
751
+ readonly sendRealtime: (message: Record<string, unknown>) => boolean;
752
+ /** Sends a command and waits for its result message. */
753
+ readonly command: (type: string, payload?: Record<string, unknown>) => Effect.Effect<LiveSessionCommandResult, LiveSessionError>;
754
+ }
755
+ /**
756
+ * Opens a live session connection. It prefers WebRTC presentation, falls back to
757
+ * WebSocket raster frames, and keeps retrying WebRTC in the background. Closing the scope
758
+ * closes every transport and fails pending commands.
759
+ */
760
+ declare const make: (options: LiveSessionConnectionOptions) => Effect.Effect<{
761
+ reconnect: Effect.Effect<void, never, never>;
762
+ selectTransport: (kind: LiveSessionTransportKind) => Effect.Effect<void, LiveSessionError, never>;
763
+ sendReliable: (message: Record<string, unknown>) => boolean;
764
+ sendRealtime: (message: Record<string, unknown>) => boolean;
765
+ command: (type: string, payload?: Record<string, unknown> | undefined) => Effect.Effect<{
766
+ readonly type: "target.select.result" | "target.create.result" | "target.close.result" | "page.navigate.result" | "page.history-back.result" | "page.history-forward.result" | "page.reload.result" | "page.stop-loading.result" | "viewport.set.result" | "presentation.quality.set.result" | "presentation.cursor.set.result" | "recording.start.result" | "recording.stop.result" | "recording.cancel.result";
767
+ readonly requestId: string;
768
+ readonly ok: boolean;
769
+ readonly message?: string | undefined;
770
+ readonly code?: string | undefined;
771
+ readonly targetId?: string | undefined;
772
+ readonly recording?: {
773
+ readonly targetId: string;
774
+ readonly mode: "tab" | "viewer";
775
+ readonly status: "starting" | "running" | "stopped" | "failed";
776
+ readonly recordingId: string;
777
+ readonly captureGeneration: number;
778
+ readonly path: string;
779
+ readonly startedAt: string;
780
+ readonly fps: number;
781
+ readonly bitrateKbps: number;
782
+ readonly codec: string;
783
+ readonly stopReason?: string | undefined;
784
+ readonly stoppedAt?: string | undefined;
785
+ readonly sizeBytes?: number | undefined;
786
+ } | undefined;
787
+ readonly presentation?: {
788
+ readonly profiles: readonly {
789
+ readonly id: string;
790
+ readonly label: string;
791
+ readonly codec: string;
792
+ readonly mimeType: string;
793
+ readonly sdpFmtpLine: string;
794
+ }[];
795
+ readonly cursorVisible: boolean;
796
+ readonly quality?: {
797
+ readonly profile: string;
798
+ readonly fps: number;
799
+ readonly bitrateKbps: number;
800
+ readonly keyframeInterval: number;
801
+ } | undefined;
802
+ } | undefined;
803
+ }, LiveSessionError, never>;
804
+ }, never, import("effect/Scope").Scope>;
805
+ //#endregion
806
+ export { BrowserInputMessage, CollaborationCursor, CollaborationError, CollaborationLeaseMode, CollaborationPaintEvent, CollaborationPaintPhase, CollaborationPaintPoint, CollaborationParticipant, CollaborationPhase, CollaborationRole, DEFAULT_VIEWPORT, LIVE_SESSION_PROTOCOL, LiveSessionCommandResult, connection_d_exports as LiveSessionConnection, LiveSessionError, LiveSessionPresentation, LiveSessionPresentationQuality, LiveSessionRasterFrame, LiveSessionServerMessage, LiveSessionSnapshot, LiveSessionTarget, type LiveSessionTransportKind, RasterFrameHeader, RenderMetrics, STALE_FRAME_MS, VIEWPORT_DEVICE_SCALE_FACTORS, VIEWPORT_PRESETS, ViewportPreset, computeRenderMetrics, createViewportPreset, decodeServerMessage, evdevKeycodeByCode, formatViewportScale, isPrintableKey, keyboardInputMessage, keyboardModifiers, mapClientToViewport, shouldForwardBrowserShortcut, strictParseOptions, windowsVirtualKeyCodeForCodeOrKey };
807
+ //# sourceMappingURL=index.d.ts.map