@aperture-browser/session-client 0.0.0-init.0 → 0.0.0-nightly.150.87635522cd00

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,2895 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Exit from "effect/Exit";
4
+ import * as Scope from "effect/Scope";
5
+ import * as Context from "effect/Context";
6
+ import * as Equal from "effect/Equal";
7
+ import * as FiberSet from "effect/FiberSet";
8
+ import * as Layer from "effect/Layer";
9
+ import * as Queue from "effect/Queue";
10
+ import * as Result from "effect/Result";
11
+ import * as Stream from "effect/Stream";
12
+ import * as Schema from "effect/Schema";
13
+ import { enumDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
14
+ import { create, fromBinary, fromJsonString, toBinary } from "@bufbuild/protobuf";
15
+ //#region ../shared/src/url-path.ts
16
+ /**
17
+ * Request paths and urls built from values that may hold what a url treats specially
18
+ * (`/`, `?`, `#`, `%`, spaces): a file's name, a session's id, a ticket. Every
19
+ * interpolation is encoded unless it says otherwise, so a value cannot leave its segment
20
+ * because one call site forgot to encode it.
21
+ *
22
+ * Effect has no such builder: `HttpApiClient` encodes `:param` paths only for endpoints
23
+ * declared through `HttpApi`, and `Url.setPathname` leaves `/`, `?`, and `#` as they are.
24
+ */
25
+ var Raw = class {
26
+ text;
27
+ constructor(text) {
28
+ this.text = text;
29
+ }
30
+ };
31
+ var Segments = class {
32
+ path;
33
+ constructor(path) {
34
+ this.path = path;
35
+ }
36
+ };
37
+ /**
38
+ * A value that is itself several segments, `downloads/report.pdf`: each `/`-separated
39
+ * segment is encoded and the slashes stay.
40
+ */
41
+ const segments = (path) => new Segments(path);
42
+ const encode$1 = (part) => {
43
+ if (part instanceof Raw) return part.text;
44
+ if (part instanceof Segments) return part.path.split("/").map(encodeURIComponent).join("/");
45
+ return encodeURIComponent(part);
46
+ };
47
+ /** `` make`/sessions/${id}/files/${name}` ``: every interpolation encoded as one segment. */
48
+ const make$2 = (literals, ...parts) => {
49
+ let url = literals[0] ?? "";
50
+ parts.forEach((part, index) => {
51
+ url += encode$1(part) + (literals[index + 1] ?? "");
52
+ });
53
+ return url;
54
+ };
55
+ //#endregion
56
+ //#region src/address.ts
57
+ const based = (address, path) => {
58
+ const origin = globalThis.location?.href;
59
+ const base = new URL(address.url, origin);
60
+ base.pathname = `${base.pathname.replace(/\/+$/u, "")}${path}`;
61
+ return base;
62
+ };
63
+ /** A route below the session's base, for a request that carries the token in a header. */
64
+ const route = (address, path) => based(address, path).toString();
65
+ /**
66
+ * A route below the session's base that carries the token itself, for what cannot send a
67
+ * header: a link, a picture, the session socket.
68
+ */
69
+ const authenticated = (address, path) => {
70
+ const url = based(address, path);
71
+ if (address.token !== void 0) url.searchParams.set("token", address.token);
72
+ return url;
73
+ };
74
+ const socketUrl = (address) => {
75
+ const url = authenticated(address, "/ws");
76
+ if (address.name !== void 0 && address.name !== "") url.searchParams.set("name", address.name);
77
+ url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
78
+ return url.toString();
79
+ };
80
+ const fileUrl = (address, path) => authenticated(address, make$2`/files/${segments(path.replace(/^\/+/u, ""))}`).toString();
81
+ const screenshotUrl = (address, tab, width) => {
82
+ const url = authenticated(address, make$2`/targets/${tab}/screenshot.png`);
83
+ if (width !== void 0) url.searchParams.set("width", String(Math.round(width)));
84
+ return url.toString();
85
+ };
86
+ /** The tab as it looks now, small: for a list of the tabs. */
87
+ const previewUrl = (address, tab) => authenticated(address, make$2`/targets/${tab}/preview.png`).toString();
88
+ /**
89
+ * The icon of the tab's page, fetched by the session. `site` is what the page is of: the
90
+ * icon is kept by its address here, and another site's is another address.
91
+ */
92
+ const faviconUrl = (address, tab, site) => {
93
+ const url = authenticated(address, make$2`/targets/${tab}/favicon`);
94
+ url.searchParams.set("of", site);
95
+ return url.toString();
96
+ };
97
+ const headers = (address) => address.token === void 0 ? {} : { Authorization: `Bearer ${address.token}` };
98
+ //#endregion
99
+ //#region src/clipboard.ts
100
+ /** The forms of text a clipboard carries. */
101
+ const TEXTS = ["text/plain", "text/html"];
102
+ /** What of the session's clipboard a clipboard here takes. */
103
+ const TAKEN = /^(?:text\/(?:plain|html)|image\/.+)$/u;
104
+ const form = async (type, blob) => ({
105
+ type,
106
+ data: new Uint8Array(await blob.arrayBuffer())
107
+ });
108
+ const textForm = (type, text) => ({
109
+ type,
110
+ data: new TextEncoder().encode(text)
111
+ });
112
+ const blobOf = (one) => new Blob([new Uint8Array(one.data)], { type: one.type });
113
+ /** A picture drawn again as a PNG: what it looks like, and nothing else it carried. */
114
+ const drawn = async (picture) => {
115
+ const draw = (source, width, height) => {
116
+ const canvas = new OffscreenCanvas(width, height);
117
+ canvas.getContext("2d")?.drawImage(source, 0, 0, width, height);
118
+ return canvas.convertToBlob({ type: "image/png" });
119
+ };
120
+ try {
121
+ const bitmap = await createImageBitmap(picture);
122
+ try {
123
+ return await draw(bitmap, bitmap.width, bitmap.height);
124
+ } finally {
125
+ bitmap.close();
126
+ }
127
+ } catch {
128
+ const url = URL.createObjectURL(picture);
129
+ try {
130
+ const image = new Image();
131
+ image.src = url;
132
+ await image.decode();
133
+ return await draw(image, image.naturalWidth || 300, image.naturalHeight || 150);
134
+ } finally {
135
+ URL.revokeObjectURL(url);
136
+ }
137
+ }
138
+ };
139
+ /** A picture as the PNG clipboards carry. */
140
+ const png = (picture) => picture.type === "image/png" ? Promise.resolve(picture) : drawn(picture);
141
+ const blobs = async (forms) => {
142
+ const taken = forms.filter((one) => TAKEN.test(one.type));
143
+ const had = await Promise.all(taken.map(async (one) => {
144
+ const blob = blobOf(one);
145
+ return one.type.startsWith("image/") ? ["image/png", await png(blob)] : [one.type, blob];
146
+ }));
147
+ return Object.fromEntries(had);
148
+ };
149
+ /**
150
+ * Puts what the session copied on the clipboard here, which a browser lets a page do at
151
+ * any time or only in a click. Tells whether it did.
152
+ */
153
+ const write = async (forms) => {
154
+ if (typeof ClipboardItem === "undefined" || navigator.clipboard?.write === void 0) return false;
155
+ try {
156
+ const had = await blobs(forms);
157
+ if (Object.keys(had).length === 0) return false;
158
+ await navigator.clipboard.write([new ClipboardItem(had)]);
159
+ return true;
160
+ } catch {
161
+ return false;
162
+ }
163
+ };
164
+ /**
165
+ * Copies the old way, which is deprecated and the one way where the clipboard is not a
166
+ * page's to write: the browser is told to copy, and is handed the texts as it does.
167
+ */
168
+ const copyOldWay = (texts) => {
169
+ const from = document.createElement("textarea");
170
+ from.value = texts.get("text/plain") ?? "";
171
+ document.body.append(from);
172
+ from.focus();
173
+ from.select();
174
+ let handed = false;
175
+ const hand = (event) => {
176
+ for (const [type, text] of texts) event.clipboardData?.setData(type, text);
177
+ event.preventDefault();
178
+ event.stopImmediatePropagation();
179
+ handed = true;
180
+ };
181
+ window.addEventListener("copy", hand, { capture: true });
182
+ const copied = document.execCommand("copy");
183
+ window.removeEventListener("copy", hand, { capture: true });
184
+ from.remove();
185
+ return copied && (handed || from.value !== "");
186
+ };
187
+ /**
188
+ * Copies in a click what `write` could not: text is copied the old way, and a picture
189
+ * opens to be copied by hand.
190
+ *
191
+ * What the session copied is what a page there made of it, and nothing of it is opened
192
+ * as it came: a document made of it here would be this page's own, and run as whoever
193
+ * watches. Text stays text, and a picture opens as the PNG it is drawn to.
194
+ */
195
+ const writeByHand = async (forms) => {
196
+ if (await write(forms)) return true;
197
+ const texts = new Map(forms.filter((one) => TEXTS.some((type) => type === one.type)).map((one) => [one.type, new TextDecoder().decode(one.data)]));
198
+ const marked = texts.get("text/html");
199
+ if (marked !== void 0 && !texts.has("text/plain")) {
200
+ const read = new DOMParser().parseFromString(marked, "text/html");
201
+ for (const unread of read.querySelectorAll("script, style, template")) unread.remove();
202
+ texts.set("text/plain", read.body.textContent ?? "");
203
+ }
204
+ if (texts.size > 0) return copyOldWay(texts);
205
+ const picture = forms.find((one) => one.type.startsWith("image/"));
206
+ if (picture === void 0) return false;
207
+ try {
208
+ window.open(URL.createObjectURL(await drawn(blobOf(picture))));
209
+ return true;
210
+ } catch {
211
+ return false;
212
+ }
213
+ };
214
+ /** What the clipboard here has, where the browser lets a page read it. */
215
+ const read = async () => {
216
+ const items = await navigator.clipboard.read();
217
+ const forms = [];
218
+ for (const type of [...TEXTS, "image/png"]) {
219
+ const item = items.find((one) => one.types.includes(type));
220
+ if (item !== void 0) forms.push(await form(type, await item.getType(type)));
221
+ }
222
+ return forms;
223
+ };
224
+ /** The text a paste or a drag carries, in each form it has it. */
225
+ const texts = (carried) => TEXTS.map((type) => [type, carried.getData(type)]).filter(([, text]) => text !== "").map(([type, text]) => textForm(type, text));
226
+ //#endregion
227
+ //#region src/codecs.ts
228
+ /**
229
+ * What a decoder is asked for, by the form of the frames. Without a description the
230
+ * frames are read as Annex B, which they are.
231
+ */
232
+ const CODECS = {
233
+ h264: "avc1.42e01f",
234
+ "full-chroma": "avc1.f4001f",
235
+ h265: "hev1.1.6.L153.B0",
236
+ vp9: "vp09.00.51.08",
237
+ "vp9-full-chroma": "vp09.01.51.08.03",
238
+ av1: "av01.0.13M.08"
239
+ };
240
+ /** What a WebRTC connection calls the formats it carries; it carries no H.264 4:4:4. */
241
+ const RTC_CODECS = {
242
+ h264: (codec) => codec.mimeType === "video/H264",
243
+ h265: (codec) => codec.mimeType === "video/H265",
244
+ vp9: (codec) => codec.mimeType === "video/VP9" && /profile-id=0/u.test(codec.sdpFmtpLine ?? "profile-id=0"),
245
+ "vp9-full-chroma": (codec) => codec.mimeType === "video/VP9" && /profile-id=1/u.test(codec.sdpFmtpLine ?? ""),
246
+ av1: (codec) => codec.mimeType === "video/AV1"
247
+ };
248
+ const ALL = Object.keys(CODECS);
249
+ /** The ways this environment can take a picture, best first. */
250
+ const waysHere = () => {
251
+ const ways = [];
252
+ if (typeof RTCPeerConnection !== "undefined") ways.push("video");
253
+ if (typeof VideoDecoder !== "undefined") ways.push("frames");
254
+ ways.push("tiles");
255
+ return ways;
256
+ };
257
+ const decodes = async (format) => {
258
+ try {
259
+ const { supported } = await VideoDecoder.isConfigSupported({ codec: CODECS[format] });
260
+ return supported === true;
261
+ } catch {
262
+ return false;
263
+ }
264
+ };
265
+ /** The formats this browser takes the way the picture comes. */
266
+ const decodable = async (way) => {
267
+ if (way === "video") {
268
+ const codecs = RTCRtpReceiver.getCapabilities("video")?.codecs ?? [];
269
+ return ALL.filter((format) => {
270
+ const carries = RTC_CODECS[format];
271
+ return carries !== void 0 && codecs.some(carries);
272
+ });
273
+ }
274
+ if (way === "frames") {
275
+ const supported = await Promise.all(ALL.map(decodes));
276
+ return ALL.filter((_, at) => supported[at]);
277
+ }
278
+ return [];
279
+ };
280
+ //#endregion
281
+ //#region src/errors.ts
282
+ /** A request to the session that could not be made, or that the session refused. */
283
+ var SessionError = class extends Schema.TaggedError()("SessionError", {
284
+ message: Schema.String,
285
+ /** The HTTP status the session answered with, when it answered. */
286
+ status: Schema.optional(Schema.Number),
287
+ cause: Schema.optional(Schema.Defect())
288
+ }) {};
289
+ //#endregion
290
+ //#region src/http.ts
291
+ var http_exports = /* @__PURE__ */ __exportAll({
292
+ annotateRecording: () => annotateRecording,
293
+ downloads: () => downloads,
294
+ exportStorageState: () => exportStorageState,
295
+ getRecording: () => getRecording,
296
+ importStorageState: () => importStorageState,
297
+ listRecordings: () => listRecordings,
298
+ listScreenshots: () => listScreenshots,
299
+ removeUpload: () => removeUpload,
300
+ retargetRecording: () => retargetRecording,
301
+ setViewport: () => setViewport,
302
+ startRecording: () => startRecording,
303
+ stopRecording: () => stopRecording,
304
+ takeScreenshot: () => takeScreenshot,
305
+ targets: () => targets,
306
+ upload: () => upload,
307
+ uploads: () => uploads
308
+ });
309
+ const failed = (cause) => new SessionError({
310
+ message: cause instanceof Error ? cause.message : "the session could not be reached",
311
+ cause
312
+ });
313
+ const refused = (status, text) => new SessionError({
314
+ message: text === "" ? `the session answered ${status}` : text,
315
+ status
316
+ });
317
+ const request = Effect.fnUntraced(function* (address, path, asked = {}) {
318
+ const response = yield* Effect.tryPromise({
319
+ try: (signal) => fetch(route(address, path), {
320
+ method: asked.method ?? "GET",
321
+ headers: {
322
+ ...headers(address),
323
+ ...asked.json === void 0 ? {} : { "Content-Type": "application/json" }
324
+ },
325
+ body: asked.json === void 0 ? null : JSON.stringify(asked.json),
326
+ signal
327
+ }),
328
+ catch: failed
329
+ });
330
+ if (!response.ok) {
331
+ const text = yield* Effect.tryPromise({
332
+ try: () => response.text(),
333
+ catch: failed
334
+ });
335
+ return yield* refused(response.status, text);
336
+ }
337
+ return response;
338
+ });
339
+ const json = (address, path, asked) => request(address, path, asked).pipe(Effect.flatMap((response) => Effect.tryPromise({
340
+ try: () => response.json(),
341
+ catch: failed
342
+ })));
343
+ const named$1 = (name) => make$2`/uploads/${name}`;
344
+ const uploadTold = (address, file, onProgress) => Effect.callback((resume) => {
345
+ const sending = new XMLHttpRequest();
346
+ sending.open("PUT", route(address, named$1(file.name)));
347
+ for (const [name, value] of Object.entries(headers(address))) sending.setRequestHeader(name, value);
348
+ sending.upload.addEventListener("progress", (event) => {
349
+ onProgress({
350
+ loaded: event.loaded,
351
+ total: event.lengthComputable ? event.total : file.size
352
+ });
353
+ });
354
+ sending.addEventListener("error", () => {
355
+ resume(Effect.fail(new SessionError({ message: "the session could not be reached" })));
356
+ });
357
+ sending.addEventListener("load", () => {
358
+ if (sending.status < 200 || sending.status >= 300) {
359
+ resume(Effect.fail(refused(sending.status, sending.responseText)));
360
+ return;
361
+ }
362
+ resume(Effect.try({
363
+ try: () => JSON.parse(sending.responseText),
364
+ catch: failed
365
+ }));
366
+ });
367
+ sending.send(file);
368
+ return Effect.sync(() => sending.abort());
369
+ });
370
+ /** Every target of the session, oldest first. */
371
+ const targets = Effect.fn("SessionHttp.targets")((address) => json(address, "/targets"));
372
+ /** Gives a target its own viewport, as near to the one asked for as it can be given. */
373
+ const setViewport = Effect.fn("SessionHttp.setViewport")((address, tab, viewport) => request(address, make$2`/targets/${tab}/viewport`, {
374
+ method: "PUT",
375
+ json: viewport
376
+ }).pipe(Effect.asVoid));
377
+ const downloads = Effect.fn("SessionHttp.downloads")((address) => json(address, "/downloads"));
378
+ const uploads = Effect.fn("SessionHttp.uploads")((address) => json(address, "/uploads"));
379
+ /**
380
+ * Puts a file into the session's uploads under its own name, in place of one there was.
381
+ * Files get to the session's browser this way: they are put there, and the browser is
382
+ * told where they are.
383
+ */
384
+ const upload = Effect.fn("SessionHttp.upload")(function* (address, file, onProgress) {
385
+ if (onProgress !== void 0 && typeof XMLHttpRequest !== "undefined") return yield* uploadTold(address, file, onProgress);
386
+ const response = yield* Effect.tryPromise({
387
+ try: (signal) => fetch(route(address, named$1(file.name)), {
388
+ method: "PUT",
389
+ headers: headers(address),
390
+ body: file,
391
+ signal
392
+ }),
393
+ catch: failed
394
+ });
395
+ const text = yield* Effect.tryPromise({
396
+ try: () => response.text(),
397
+ catch: failed
398
+ });
399
+ if (!response.ok) return yield* refused(response.status, text);
400
+ const uploaded = yield* Effect.try({
401
+ try: () => JSON.parse(text),
402
+ catch: failed
403
+ });
404
+ onProgress?.({
405
+ loaded: uploaded.size,
406
+ total: uploaded.size
407
+ });
408
+ return uploaded;
409
+ });
410
+ const removeUpload = Effect.fn("SessionHttp.removeUpload")((address, name) => request(address, named$1(name), { method: "DELETE" }).pipe(Effect.asVoid));
411
+ const listRecordings = Effect.fn("SessionHttp.listRecordings")((address) => json(address, "/recordings"));
412
+ const getRecording = Effect.fn("SessionHttp.getRecording")((address, id) => json(address, make$2`/recordings/${id}`));
413
+ const startRecording = Effect.fn("SessionHttp.startRecording")((address, options = {}) => json(address, "/recordings", {
414
+ method: "POST",
415
+ json: options
416
+ }));
417
+ const stopRecording = Effect.fn("SessionHttp.stopRecording")((address, id) => json(address, make$2`/recordings/${id}/stop`, { method: "POST" }));
418
+ /** Has a running recording go on with another tab, in the same video. */
419
+ const retargetRecording = Effect.fn("SessionHttp.retargetRecording")((address, id, tab) => json(address, make$2`/recordings/${id}/retarget`, {
420
+ method: "POST",
421
+ json: { tab }
422
+ }));
423
+ /** Adds an annotation to a running recording: the one named, or the only one that runs. */
424
+ const annotateRecording = Effect.fn("SessionHttp.annotateRecording")((address, annotation, id) => {
425
+ const { kind, ...given } = annotation;
426
+ return request(address, make$2`/recordings/annotations/${kind}`, {
427
+ method: "POST",
428
+ json: id === void 0 ? given : {
429
+ ...given,
430
+ id
431
+ }
432
+ }).pipe(Effect.asVoid);
433
+ });
434
+ /** Takes cookies and the storage of origins out of the session's browser. */
435
+ const exportStorageState = Effect.fn("SessionHttp.exportStorageState")((address, asked = {}) => json(address, "/storage-state", {
436
+ method: "POST",
437
+ json: asked
438
+ }));
439
+ /**
440
+ * Puts cookies and the storage of origins into the session's browser: the cookies beside
441
+ * those there are, each origin's local storage in place of what the origin had, and each
442
+ * of its databases in place of the origin's one of that name.
443
+ */
444
+ const importStorageState = Effect.fn("SessionHttp.importStorageState")((address, state) => request(address, "/storage-state", {
445
+ method: "PUT",
446
+ json: state
447
+ }).pipe(Effect.asVoid));
448
+ const listScreenshots = Effect.fn("SessionHttp.listScreenshots")((address) => json(address, "/screenshots"));
449
+ /** Takes a screenshot of a tab, the newest one when none is named, and keeps it. */
450
+ const takeScreenshot = Effect.fn("SessionHttp.takeScreenshot")((address, tab) => json(address, "/screenshots", {
451
+ method: "POST",
452
+ json: { tab }
453
+ }));
454
+ //#endregion
455
+ //#region src/gen/aperture/live/v1/live_pb.ts
456
+ var live_pb_exports = /* @__PURE__ */ __exportAll({
457
+ Along: () => Along,
458
+ AlongSchema: () => AlongSchema,
459
+ Asked: () => Asked,
460
+ AskedSchema: () => AskedSchema,
461
+ AudioFrameSchema: () => AudioFrameSchema,
462
+ ClientMessageSchema: () => ClientMessageSchema,
463
+ ClipboardSchema: () => ClipboardSchema,
464
+ Clipboard_FormSchema: () => Clipboard_FormSchema,
465
+ CloseSchema: () => CloseSchema,
466
+ CopyPictureSchema: () => CopyPictureSchema,
467
+ CursorSchema: () => CursorSchema,
468
+ Cursor_HiddenSchema: () => Cursor_HiddenSchema,
469
+ DeviceSchema: () => DeviceSchema,
470
+ DownloadSchema: () => DownloadSchema,
471
+ DownloadState: () => DownloadState,
472
+ DownloadStateSchema: () => DownloadStateSchema,
473
+ DownloadsSchema: () => DownloadsSchema,
474
+ DrawSchema: () => DrawSchema,
475
+ DropSchema: () => DropSchema,
476
+ FailedSchema: () => FailedSchema,
477
+ FeaturesSchema: () => FeaturesSchema,
478
+ FileRequestSchema: () => FileRequestSchema,
479
+ FileRequestsSchema: () => FileRequestsSchema,
480
+ FilesChosenSchema: () => FilesChosenSchema,
481
+ FollowSchema: () => FollowSchema,
482
+ GoSchema: () => GoSchema,
483
+ GrantSchema: () => GrantSchema,
484
+ HeldTabSchema: () => HeldTabSchema,
485
+ HelloSchema: () => HelloSchema,
486
+ KeySchema: () => KeySchema,
487
+ LeaseAction: () => LeaseAction,
488
+ LeaseActionSchema: () => LeaseActionSchema,
489
+ LeaseSchema: () => LeaseSchema,
490
+ MemberSchema: () => MemberSchema,
491
+ MenuSchema: () => MenuSchema,
492
+ MouseButton: () => MouseButton,
493
+ MouseButtonSchema: () => MouseButtonSchema,
494
+ PageMode: () => PageMode,
495
+ PageModeSchema: () => PageModeSchema,
496
+ Pixels: () => Pixels,
497
+ PixelsSchema: () => PixelsSchema,
498
+ PointSchema: () => PointSchema,
499
+ PointerButtonSchema: () => PointerButtonSchema,
500
+ PointerLeaveSchema: () => PointerLeaveSchema,
501
+ PointerMotionSchema: () => PointerMotionSchema,
502
+ PointerSchema: () => PointerSchema,
503
+ PointerScrollSchema: () => PointerScrollSchema,
504
+ PointingSchema: () => PointingSchema,
505
+ PresenceSchema: () => PresenceSchema,
506
+ Role: () => Role,
507
+ RoleSchema: () => RoleSchema,
508
+ RtcAnswerSchema: () => RtcAnswerSchema,
509
+ RtcOfferSchema: () => RtcOfferSchema,
510
+ RtcRefusedSchema: () => RtcRefusedSchema,
511
+ SelectSchema: () => SelectSchema,
512
+ SelectedSchema: () => SelectedSchema,
513
+ ServerMessageSchema: () => ServerMessageSchema,
514
+ SetModeSchema: () => SetModeSchema,
515
+ StrokePhase: () => StrokePhase,
516
+ StrokePhaseSchema: () => StrokePhaseSchema,
517
+ StrokeSchema: () => StrokeSchema,
518
+ TargetSchema: () => TargetSchema,
519
+ TargetsSchema: () => TargetsSchema,
520
+ TextSchema: () => TextSchema,
521
+ TileSchema: () => TileSchema,
522
+ VideoFormat: () => VideoFormat,
523
+ VideoFormatSchema: () => VideoFormatSchema,
524
+ VideoFrameSchema: () => VideoFrameSchema,
525
+ VideoQuality: () => VideoQuality,
526
+ VideoQualitySchema: () => VideoQualitySchema,
527
+ VideoShownSchema: () => VideoShownSchema,
528
+ VideoStatusSchema: () => VideoStatusSchema,
529
+ ViewportSchema: () => ViewportSchema,
530
+ file_aperture_live_v1_live: () => file_aperture_live_v1_live
531
+ });
532
+ /**
533
+ * Describes the file aperture/live/v1/live.proto.
534
+ */
535
+ const file_aperture_live_v1_live = /*@__PURE__*/ fileDesc("ChthcGVydHVyZS9saXZlL3YxL2xpdmUucHJvdG8SEGFwZXJ0dXJlLmxpdmUudjEi3QgKDUNsaWVudE1lc3NhZ2USKgoGc2VsZWN0GAEgASgLMhguYXBlcnR1cmUubGl2ZS52MS5TZWxlY3RIABI5Cg5wb2ludGVyX21vdGlvbhgCIAEoCzIfLmFwZXJ0dXJlLmxpdmUudjEuUG9pbnRlck1vdGlvbkgAEjkKDnBvaW50ZXJfYnV0dG9uGAMgASgLMh8uYXBlcnR1cmUubGl2ZS52MS5Qb2ludGVyQnV0dG9uSAASOQoOcG9pbnRlcl9zY3JvbGwYBCABKAsyHy5hcGVydHVyZS5saXZlLnYxLlBvaW50ZXJTY3JvbGxIABI3Cg1wb2ludGVyX2xlYXZlGAUgASgLMh4uYXBlcnR1cmUubGl2ZS52MS5Qb2ludGVyTGVhdmVIABIkCgNrZXkYBiABKAsyFS5hcGVydHVyZS5saXZlLnYxLktleUgAEiYKBHRleHQYByABKAsyFi5hcGVydHVyZS5saXZ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TE9OR19VTlNQRUNJRklFRBAAEg4KCkFMT05HX0JBQ0sQARIRCg1BTE9OR19GT1JXQVJEEAISEAoMQUxPTkdfUkVMT0FEEAMqkwEKBUFza2VkEhUKEUFTS0VEX1VOU1BFQ0lGSUVEEAASDAoIQVNLRURfR08QARIPCgtBU0tFRF9DTE9TRRACEhYKEkFTS0VEX0NPUFlfUElDVFVSRRADEhYKEkFTS0VEX0ZJTEVTX0NIT1NFThAEEhAKDEFTS0VEX0ZPTExPVxAFEhIKDkFTS0VEX1NFVF9NT0RFEAYqZgoIUGFnZU1vZGUSGQoVUEFHRV9NT0RFX1VOU1BFQ0lGSUVEEAASEgoOUEFHRV9NT0RFX0FVVE8QARIVChFQQUdFX01PREVfREVTS1RPUBACEhQKEFBBR0VfTU9ERV9NT0JJTEUQA2IGcHJvdG8z");
536
+ /**
537
+ * Describes the message aperture.live.v1.ClientMessage.
538
+ * Use `create(ClientMessageSchema)` to create a new message.
539
+ */
540
+ const ClientMessageSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 0);
541
+ /**
542
+ * Describes the message aperture.live.v1.ServerMessage.
543
+ * Use `create(ServerMessageSchema)` to create a new message.
544
+ */
545
+ const ServerMessageSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 1);
546
+ /**
547
+ * Describes the message aperture.live.v1.Features.
548
+ * Use `create(FeaturesSchema)` to create a new message.
549
+ */
550
+ const FeaturesSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 2);
551
+ /**
552
+ * Describes the message aperture.live.v1.Grant.
553
+ * Use `create(GrantSchema)` to create a new message.
554
+ */
555
+ const GrantSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 3);
556
+ /**
557
+ * Describes the message aperture.live.v1.Hello.
558
+ * Use `create(HelloSchema)` to create a new message.
559
+ */
560
+ const HelloSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 4);
561
+ /**
562
+ * Describes the message aperture.live.v1.VideoStatus.
563
+ * Use `create(VideoStatusSchema)` to create a new message.
564
+ */
565
+ const VideoStatusSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 5);
566
+ /**
567
+ * Describes the message aperture.live.v1.AudioFrame.
568
+ * Use `create(AudioFrameSchema)` to create a new message.
569
+ */
570
+ const AudioFrameSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 6);
571
+ /**
572
+ * Describes the message aperture.live.v1.VideoShown.
573
+ * Use `create(VideoShownSchema)` to create a new message.
574
+ */
575
+ const VideoShownSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 7);
576
+ /**
577
+ * Describes the message aperture.live.v1.RtcOffer.
578
+ * Use `create(RtcOfferSchema)` to create a new message.
579
+ */
580
+ const RtcOfferSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 8);
581
+ /**
582
+ * Describes the message aperture.live.v1.RtcAnswer.
583
+ * Use `create(RtcAnswerSchema)` to create a new message.
584
+ */
585
+ const RtcAnswerSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 9);
586
+ /**
587
+ * Describes the message aperture.live.v1.RtcRefused.
588
+ * Use `create(RtcRefusedSchema)` to create a new message.
589
+ */
590
+ const RtcRefusedSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 10);
591
+ /**
592
+ * Describes the message aperture.live.v1.VideoFrame.
593
+ * Use `create(VideoFrameSchema)` to create a new message.
594
+ */
595
+ const VideoFrameSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 11);
596
+ /**
597
+ * Describes the message aperture.live.v1.Tile.
598
+ * Use `create(TileSchema)` to create a new message.
599
+ */
600
+ const TileSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 12);
601
+ /**
602
+ * Describes the message aperture.live.v1.Select.
603
+ * Use `create(SelectSchema)` to create a new message.
604
+ */
605
+ const SelectSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 13);
606
+ /**
607
+ * Describes the message aperture.live.v1.PointerMotion.
608
+ * Use `create(PointerMotionSchema)` to create a new message.
609
+ */
610
+ const PointerMotionSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 14);
611
+ /**
612
+ * Describes the message aperture.live.v1.PointerButton.
613
+ * Use `create(PointerButtonSchema)` to create a new message.
614
+ */
615
+ const PointerButtonSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 15);
616
+ /**
617
+ * Describes the message aperture.live.v1.PointerScroll.
618
+ * Use `create(PointerScrollSchema)` to create a new message.
619
+ */
620
+ const PointerScrollSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 16);
621
+ /**
622
+ * Describes the message aperture.live.v1.PointerLeave.
623
+ * Use `create(PointerLeaveSchema)` to create a new message.
624
+ */
625
+ const PointerLeaveSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 17);
626
+ /**
627
+ * Describes the message aperture.live.v1.Key.
628
+ * Use `create(KeySchema)` to create a new message.
629
+ */
630
+ const KeySchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 18);
631
+ /**
632
+ * Describes the message aperture.live.v1.Text.
633
+ * Use `create(TextSchema)` to create a new message.
634
+ */
635
+ const TextSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 19);
636
+ /**
637
+ * Describes the message aperture.live.v1.Downloads.
638
+ * Use `create(DownloadsSchema)` to create a new message.
639
+ */
640
+ const DownloadsSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 20);
641
+ /**
642
+ * Describes the message aperture.live.v1.Download.
643
+ * Use `create(DownloadSchema)` to create a new message.
644
+ */
645
+ const DownloadSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 21);
646
+ /**
647
+ * Describes the message aperture.live.v1.Presence.
648
+ * Use `create(PresenceSchema)` to create a new message.
649
+ */
650
+ const PresenceSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 22);
651
+ /**
652
+ * Describes the message aperture.live.v1.Member.
653
+ * Use `create(MemberSchema)` to create a new message.
654
+ */
655
+ const MemberSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 23);
656
+ /**
657
+ * Describes the message aperture.live.v1.Follow.
658
+ * Use `create(FollowSchema)` to create a new message.
659
+ */
660
+ const FollowSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 24);
661
+ /**
662
+ * Describes the message aperture.live.v1.Pointer.
663
+ * Use `create(PointerSchema)` to create a new message.
664
+ */
665
+ const PointerSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 25);
666
+ /**
667
+ * Describes the message aperture.live.v1.Point.
668
+ * Use `create(PointSchema)` to create a new message.
669
+ */
670
+ const PointSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 26);
671
+ /**
672
+ * Describes the message aperture.live.v1.Pointing.
673
+ * Use `create(PointingSchema)` to create a new message.
674
+ */
675
+ const PointingSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 27);
676
+ /**
677
+ * Describes the message aperture.live.v1.Draw.
678
+ * Use `create(DrawSchema)` to create a new message.
679
+ */
680
+ const DrawSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 28);
681
+ /**
682
+ * Describes the message aperture.live.v1.Stroke.
683
+ * Use `create(StrokeSchema)` to create a new message.
684
+ */
685
+ const StrokeSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 29);
686
+ /**
687
+ * Describes the message aperture.live.v1.HeldTab.
688
+ * Use `create(HeldTabSchema)` to create a new message.
689
+ */
690
+ const HeldTabSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 30);
691
+ /**
692
+ * Describes the message aperture.live.v1.Lease.
693
+ * Use `create(LeaseSchema)` to create a new message.
694
+ */
695
+ const LeaseSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 31);
696
+ /**
697
+ * Describes the message aperture.live.v1.Menu.
698
+ * Use `create(MenuSchema)` to create a new message.
699
+ */
700
+ const MenuSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 32);
701
+ /**
702
+ * Describes the message aperture.live.v1.Go.
703
+ * Use `create(GoSchema)` to create a new message.
704
+ */
705
+ const GoSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 33);
706
+ /**
707
+ * Describes the message aperture.live.v1.Close.
708
+ * Use `create(CloseSchema)` to create a new message.
709
+ */
710
+ const CloseSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 34);
711
+ /**
712
+ * Describes the message aperture.live.v1.Failed.
713
+ * Use `create(FailedSchema)` to create a new message.
714
+ */
715
+ const FailedSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 35);
716
+ /**
717
+ * Describes the message aperture.live.v1.Device.
718
+ * Use `create(DeviceSchema)` to create a new message.
719
+ */
720
+ const DeviceSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 36);
721
+ /**
722
+ * Describes the message aperture.live.v1.SetMode.
723
+ * Use `create(SetModeSchema)` to create a new message.
724
+ */
725
+ const SetModeSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 37);
726
+ /**
727
+ * Describes the message aperture.live.v1.CopyPicture.
728
+ * Use `create(CopyPictureSchema)` to create a new message.
729
+ */
730
+ const CopyPictureSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 38);
731
+ /**
732
+ * Describes the message aperture.live.v1.FileRequests.
733
+ * Use `create(FileRequestsSchema)` to create a new message.
734
+ */
735
+ const FileRequestsSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 39);
736
+ /**
737
+ * Describes the message aperture.live.v1.FileRequest.
738
+ * Use `create(FileRequestSchema)` to create a new message.
739
+ */
740
+ const FileRequestSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 40);
741
+ /**
742
+ * Describes the message aperture.live.v1.FilesChosen.
743
+ * Use `create(FilesChosenSchema)` to create a new message.
744
+ */
745
+ const FilesChosenSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 41);
746
+ /**
747
+ * Describes the message aperture.live.v1.Drop.
748
+ * Use `create(DropSchema)` to create a new message.
749
+ */
750
+ const DropSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 42);
751
+ /**
752
+ * Describes the message aperture.live.v1.Clipboard.
753
+ * Use `create(ClipboardSchema)` to create a new message.
754
+ */
755
+ const ClipboardSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 43);
756
+ /**
757
+ * Describes the message aperture.live.v1.Clipboard.Form.
758
+ * Use `create(Clipboard_FormSchema)` to create a new message.
759
+ */
760
+ const Clipboard_FormSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 43, 0);
761
+ /**
762
+ * Describes the message aperture.live.v1.Viewport.
763
+ * Use `create(ViewportSchema)` to create a new message.
764
+ */
765
+ const ViewportSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 44);
766
+ /**
767
+ * Describes the message aperture.live.v1.Target.
768
+ * Use `create(TargetSchema)` to create a new message.
769
+ */
770
+ const TargetSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 45);
771
+ /**
772
+ * Describes the message aperture.live.v1.Targets.
773
+ * Use `create(TargetsSchema)` to create a new message.
774
+ */
775
+ const TargetsSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 46);
776
+ /**
777
+ * Describes the message aperture.live.v1.Selected.
778
+ * Use `create(SelectedSchema)` to create a new message.
779
+ */
780
+ const SelectedSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 47);
781
+ /**
782
+ * Describes the message aperture.live.v1.Cursor.
783
+ * Use `create(CursorSchema)` to create a new message.
784
+ */
785
+ const CursorSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 48);
786
+ /**
787
+ * Describes the message aperture.live.v1.Cursor.Hidden.
788
+ * Use `create(Cursor_HiddenSchema)` to create a new message.
789
+ */
790
+ const Cursor_HiddenSchema = /*@__PURE__*/ messageDesc(file_aperture_live_v1_live, 48, 0);
791
+ /**
792
+ * The form a target's video takes.
793
+ *
794
+ * @generated from enum aperture.live.v1.VideoFormat
795
+ */
796
+ let VideoFormat = /* @__PURE__ */ function(VideoFormat) {
797
+ /**
798
+ * @generated from enum value: VIDEO_FORMAT_UNSPECIFIED = 0;
799
+ */
800
+ VideoFormat[VideoFormat["UNSPECIFIED"] = 0] = "UNSPECIFIED";
801
+ /**
802
+ * H.264 constrained baseline, 4:2:0. Everything decodes it; colored text loses detail.
803
+ *
804
+ * @generated from enum value: VIDEO_FORMAT_H264 = 1;
805
+ */
806
+ VideoFormat[VideoFormat["H264"] = 1] = "H264";
807
+ /**
808
+ * H.264 High 4:4:4, in BT.709: color as sharp as light. For frames on the session
809
+ * socket, where the client's decoder takes it; WebRTC does not carry it.
810
+ *
811
+ * @generated from enum value: VIDEO_FORMAT_FULL_CHROMA = 2;
812
+ */
813
+ VideoFormat[VideoFormat["FULL_CHROMA"] = 2] = "FULL_CHROMA";
814
+ /**
815
+ * H.265 Main, 4:2:0: fewer bits than H.264 for the same picture.
816
+ *
817
+ * @generated from enum value: VIDEO_FORMAT_H265 = 3;
818
+ */
819
+ VideoFormat[VideoFormat["H265"] = 3] = "H265";
820
+ /**
821
+ * VP9 profile 0, 4:2:0.
822
+ *
823
+ * @generated from enum value: VIDEO_FORMAT_VP9 = 4;
824
+ */
825
+ VideoFormat[VideoFormat["VP9"] = 4] = "VP9";
826
+ /**
827
+ * VP9 profile 1, 4:4:4: color as sharp as light, also over WebRTC.
828
+ *
829
+ * @generated from enum value: VIDEO_FORMAT_VP9_FULL_CHROMA = 5;
830
+ */
831
+ VideoFormat[VideoFormat["VP9_FULL_CHROMA"] = 5] = "VP9_FULL_CHROMA";
832
+ /**
833
+ * AV1 main, 4:2:0.
834
+ *
835
+ * @generated from enum value: VIDEO_FORMAT_AV1 = 6;
836
+ */
837
+ VideoFormat[VideoFormat["AV1"] = 6] = "AV1";
838
+ return VideoFormat;
839
+ }({});
840
+ /**
841
+ * Describes the enum aperture.live.v1.VideoFormat.
842
+ */
843
+ const VideoFormatSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 0);
844
+ /**
845
+ * How much a target's video costs the client's link. The session picks it, by what the
846
+ * link carries, and changes it as that changes: over WebRTC by the connection's own
847
+ * estimate, on the session socket by how late the client shows frames (`video_shown`).
848
+ *
849
+ * @generated from enum aperture.live.v1.VideoQuality
850
+ */
851
+ let VideoQuality = /* @__PURE__ */ function(VideoQuality) {
852
+ /**
853
+ * @generated from enum value: VIDEO_QUALITY_UNSPECIFIED = 0;
854
+ */
855
+ VideoQuality[VideoQuality["UNSPECIFIED"] = 0] = "UNSPECIFIED";
856
+ /**
857
+ * Up to 0.7 Mbit/s, 15 frames a second. Bitrates are for a picture of 1280x720 pixels;
858
+ * larger ones get more.
859
+ *
860
+ * @generated from enum value: VIDEO_QUALITY_LOW = 1;
861
+ */
862
+ VideoQuality[VideoQuality["LOW"] = 1] = "LOW";
863
+ /**
864
+ * Up to 2.5 Mbit/s, 30 frames a second.
865
+ *
866
+ * @generated from enum value: VIDEO_QUALITY_MEDIUM = 2;
867
+ */
868
+ VideoQuality[VideoQuality["MEDIUM"] = 2] = "MEDIUM";
869
+ /**
870
+ * A constant quality whatever it takes, 60 frames a second.
871
+ *
872
+ * @generated from enum value: VIDEO_QUALITY_FULL = 3;
873
+ */
874
+ VideoQuality[VideoQuality["FULL"] = 3] = "FULL";
875
+ return VideoQuality;
876
+ }({});
877
+ /**
878
+ * Describes the enum aperture.live.v1.VideoQuality.
879
+ */
880
+ const VideoQualitySchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 1);
881
+ /**
882
+ * How the pixels of the watched target reach a client.
883
+ *
884
+ * @generated from enum aperture.live.v1.Pixels
885
+ */
886
+ let Pixels = /* @__PURE__ */ function(Pixels) {
887
+ /**
888
+ * None: the client only controls, or has yet to say.
889
+ *
890
+ * @generated from enum value: PIXELS_UNSPECIFIED = 0;
891
+ */
892
+ Pixels[Pixels["UNSPECIFIED"] = 0] = "UNSPECIFIED";
893
+ /**
894
+ * Video over WebRTC, once the client has offered a connection.
895
+ *
896
+ * @generated from enum value: PIXELS_VIDEO = 1;
897
+ */
898
+ Pixels[Pixels["VIDEO"] = 1] = "VIDEO";
899
+ /**
900
+ * Tiles on the session socket.
901
+ *
902
+ * @generated from enum value: PIXELS_TILES = 2;
903
+ */
904
+ Pixels[Pixels["TILES"] = 2] = "TILES";
905
+ /**
906
+ * Video frames on the session socket.
907
+ *
908
+ * @generated from enum value: PIXELS_FRAMES = 3;
909
+ */
910
+ Pixels[Pixels["FRAMES"] = 3] = "FRAMES";
911
+ return Pixels;
912
+ }({});
913
+ /**
914
+ * Describes the enum aperture.live.v1.Pixels.
915
+ */
916
+ const PixelsSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 2);
917
+ /**
918
+ * @generated from enum aperture.live.v1.MouseButton
919
+ */
920
+ let MouseButton = /* @__PURE__ */ function(MouseButton) {
921
+ /**
922
+ * @generated from enum value: MOUSE_BUTTON_UNSPECIFIED = 0;
923
+ */
924
+ MouseButton[MouseButton["UNSPECIFIED"] = 0] = "UNSPECIFIED";
925
+ /**
926
+ * @generated from enum value: MOUSE_BUTTON_LEFT = 1;
927
+ */
928
+ MouseButton[MouseButton["LEFT"] = 1] = "LEFT";
929
+ /**
930
+ * @generated from enum value: MOUSE_BUTTON_RIGHT = 2;
931
+ */
932
+ MouseButton[MouseButton["RIGHT"] = 2] = "RIGHT";
933
+ /**
934
+ * @generated from enum value: MOUSE_BUTTON_MIDDLE = 3;
935
+ */
936
+ MouseButton[MouseButton["MIDDLE"] = 3] = "MIDDLE";
937
+ /**
938
+ * @generated from enum value: MOUSE_BUTTON_BACK = 4;
939
+ */
940
+ MouseButton[MouseButton["BACK"] = 4] = "BACK";
941
+ /**
942
+ * @generated from enum value: MOUSE_BUTTON_FORWARD = 5;
943
+ */
944
+ MouseButton[MouseButton["FORWARD"] = 5] = "FORWARD";
945
+ return MouseButton;
946
+ }({});
947
+ /**
948
+ * Describes the enum aperture.live.v1.MouseButton.
949
+ */
950
+ const MouseButtonSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 3);
951
+ /**
952
+ * @generated from enum aperture.live.v1.DownloadState
953
+ */
954
+ let DownloadState = /* @__PURE__ */ function(DownloadState) {
955
+ /**
956
+ * @generated from enum value: DOWNLOAD_STATE_UNSPECIFIED = 0;
957
+ */
958
+ DownloadState[DownloadState["UNSPECIFIED"] = 0] = "UNSPECIFIED";
959
+ /**
960
+ * @generated from enum value: DOWNLOAD_STATE_RUNNING = 1;
961
+ */
962
+ DownloadState[DownloadState["RUNNING"] = 1] = "RUNNING";
963
+ /**
964
+ * @generated from enum value: DOWNLOAD_STATE_DONE = 2;
965
+ */
966
+ DownloadState[DownloadState["DONE"] = 2] = "DONE";
967
+ /**
968
+ * @generated from enum value: DOWNLOAD_STATE_FAILED = 3;
969
+ */
970
+ DownloadState[DownloadState["FAILED"] = 3] = "FAILED";
971
+ return DownloadState;
972
+ }({});
973
+ /**
974
+ * Describes the enum aperture.live.v1.DownloadState.
975
+ */
976
+ const DownloadStateSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 4);
977
+ /**
978
+ * @generated from enum aperture.live.v1.StrokePhase
979
+ */
980
+ let StrokePhase = /* @__PURE__ */ function(StrokePhase) {
981
+ /**
982
+ * @generated from enum value: STROKE_PHASE_UNSPECIFIED = 0;
983
+ */
984
+ StrokePhase[StrokePhase["UNSPECIFIED"] = 0] = "UNSPECIFIED";
985
+ /**
986
+ * @generated from enum value: STROKE_PHASE_START = 1;
987
+ */
988
+ StrokePhase[StrokePhase["START"] = 1] = "START";
989
+ /**
990
+ * @generated from enum value: STROKE_PHASE_MOVE = 2;
991
+ */
992
+ StrokePhase[StrokePhase["MOVE"] = 2] = "MOVE";
993
+ /**
994
+ * @generated from enum value: STROKE_PHASE_END = 3;
995
+ */
996
+ StrokePhase[StrokePhase["END"] = 3] = "END";
997
+ return StrokePhase;
998
+ }({});
999
+ /**
1000
+ * Describes the enum aperture.live.v1.StrokePhase.
1001
+ */
1002
+ const StrokePhaseSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 5);
1003
+ /**
1004
+ * @generated from enum aperture.live.v1.Role
1005
+ */
1006
+ let Role = /* @__PURE__ */ function(Role) {
1007
+ /**
1008
+ * @generated from enum value: ROLE_UNSPECIFIED = 0;
1009
+ */
1010
+ Role[Role["UNSPECIFIED"] = 0] = "UNSPECIFIED";
1011
+ /**
1012
+ * Watches.
1013
+ *
1014
+ * @generated from enum value: ROLE_VIEW = 1;
1015
+ */
1016
+ Role[Role["VIEW"] = 1] = "VIEW";
1017
+ /**
1018
+ * Gives input.
1019
+ *
1020
+ * @generated from enum value: ROLE_CONTROL = 2;
1021
+ */
1022
+ Role[Role["CONTROL"] = 2] = "CONTROL";
1023
+ /**
1024
+ * Takes a tab from whoever holds it.
1025
+ *
1026
+ * @generated from enum value: ROLE_ADMIN = 3;
1027
+ */
1028
+ Role[Role["ADMIN"] = 3] = "ADMIN";
1029
+ return Role;
1030
+ }({});
1031
+ /**
1032
+ * Describes the enum aperture.live.v1.Role.
1033
+ */
1034
+ const RoleSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 6);
1035
+ /**
1036
+ * @generated from enum aperture.live.v1.LeaseAction
1037
+ */
1038
+ let LeaseAction = /* @__PURE__ */ function(LeaseAction) {
1039
+ /**
1040
+ * @generated from enum value: LEASE_ACTION_UNSPECIFIED = 0;
1041
+ */
1042
+ LeaseAction[LeaseAction["UNSPECIFIED"] = 0] = "UNSPECIFIED";
1043
+ /**
1044
+ * Asks for the tab. One nobody holds is the client's at once, and so is any an admin
1045
+ * asks for. Another holder is asked, and the tab is the client's when the holder allows
1046
+ * it or does not answer for ten seconds.
1047
+ *
1048
+ * @generated from enum value: LEASE_ACTION_TAKE = 1;
1049
+ */
1050
+ LeaseAction[LeaseAction["TAKE"] = 1] = "TAKE";
1051
+ /**
1052
+ * Lets go of the tab the client holds.
1053
+ *
1054
+ * @generated from enum value: LEASE_ACTION_RELEASE = 2;
1055
+ */
1056
+ LeaseAction[LeaseAction["RELEASE"] = 2] = "RELEASE";
1057
+ /**
1058
+ * Answers the member who asks for the tab the client holds.
1059
+ *
1060
+ * @generated from enum value: LEASE_ACTION_ALLOW = 3;
1061
+ */
1062
+ LeaseAction[LeaseAction["ALLOW"] = 3] = "ALLOW";
1063
+ /**
1064
+ * @generated from enum value: LEASE_ACTION_KEEP = 4;
1065
+ */
1066
+ LeaseAction[LeaseAction["KEEP"] = 4] = "KEEP";
1067
+ return LeaseAction;
1068
+ }({});
1069
+ /**
1070
+ * Describes the enum aperture.live.v1.LeaseAction.
1071
+ */
1072
+ const LeaseActionSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 7);
1073
+ /**
1074
+ * Where along a page's history.
1075
+ *
1076
+ * @generated from enum aperture.live.v1.Along
1077
+ */
1078
+ let Along = /* @__PURE__ */ function(Along) {
1079
+ /**
1080
+ * @generated from enum value: ALONG_UNSPECIFIED = 0;
1081
+ */
1082
+ Along[Along["UNSPECIFIED"] = 0] = "UNSPECIFIED";
1083
+ /**
1084
+ * @generated from enum value: ALONG_BACK = 1;
1085
+ */
1086
+ Along[Along["BACK"] = 1] = "BACK";
1087
+ /**
1088
+ * @generated from enum value: ALONG_FORWARD = 2;
1089
+ */
1090
+ Along[Along["FORWARD"] = 2] = "FORWARD";
1091
+ /**
1092
+ * @generated from enum value: ALONG_RELOAD = 3;
1093
+ */
1094
+ Along[Along["RELOAD"] = 3] = "RELOAD";
1095
+ return Along;
1096
+ }({});
1097
+ /**
1098
+ * Describes the enum aperture.live.v1.Along.
1099
+ */
1100
+ const AlongSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 8);
1101
+ /**
1102
+ * @generated from enum aperture.live.v1.Asked
1103
+ */
1104
+ let Asked = /* @__PURE__ */ function(Asked) {
1105
+ /**
1106
+ * @generated from enum value: ASKED_UNSPECIFIED = 0;
1107
+ */
1108
+ Asked[Asked["UNSPECIFIED"] = 0] = "UNSPECIFIED";
1109
+ /**
1110
+ * @generated from enum value: ASKED_GO = 1;
1111
+ */
1112
+ Asked[Asked["GO"] = 1] = "GO";
1113
+ /**
1114
+ * @generated from enum value: ASKED_CLOSE = 2;
1115
+ */
1116
+ Asked[Asked["CLOSE"] = 2] = "CLOSE";
1117
+ /**
1118
+ * @generated from enum value: ASKED_COPY_PICTURE = 3;
1119
+ */
1120
+ Asked[Asked["COPY_PICTURE"] = 3] = "COPY_PICTURE";
1121
+ /**
1122
+ * @generated from enum value: ASKED_FILES_CHOSEN = 4;
1123
+ */
1124
+ Asked[Asked["FILES_CHOSEN"] = 4] = "FILES_CHOSEN";
1125
+ /**
1126
+ * @generated from enum value: ASKED_FOLLOW = 5;
1127
+ */
1128
+ Asked[Asked["FOLLOW"] = 5] = "FOLLOW";
1129
+ /**
1130
+ * @generated from enum value: ASKED_SET_MODE = 6;
1131
+ */
1132
+ Asked[Asked["SET_MODE"] = 6] = "SET_MODE";
1133
+ return Asked;
1134
+ }({});
1135
+ /**
1136
+ * Describes the enum aperture.live.v1.Asked.
1137
+ */
1138
+ const AskedSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 9);
1139
+ /**
1140
+ * How a tab's pages are shown.
1141
+ *
1142
+ * @generated from enum aperture.live.v1.PageMode
1143
+ */
1144
+ let PageMode = /* @__PURE__ */ function(PageMode) {
1145
+ /**
1146
+ * @generated from enum value: PAGE_MODE_UNSPECIFIED = 0;
1147
+ */
1148
+ PageMode[PageMode["UNSPECIFIED"] = 0] = "UNSPECIFIED";
1149
+ /**
1150
+ * As on what its holder uses: as on a phone once a client that is a phone holds the
1151
+ * tab, and as on a desktop once one that is none does. Watching changes nothing, and
1152
+ * neither does the session's automation, which has no device: the tab stays as it was.
1153
+ * A page that is there when this changes is left as it loaded; the pages that load
1154
+ * after are asked for as the tab is by then.
1155
+ *
1156
+ * @generated from enum value: PAGE_MODE_AUTO = 1;
1157
+ */
1158
+ PageMode[PageMode["AUTO"] = 1] = "AUTO";
1159
+ /**
1160
+ * @generated from enum value: PAGE_MODE_DESKTOP = 2;
1161
+ */
1162
+ PageMode[PageMode["DESKTOP"] = 2] = "DESKTOP";
1163
+ /**
1164
+ * As on a phone: a phone's user agent and client hints, touch in place of a mouse, and
1165
+ * a viewport pages lay themselves out for as for a phone's.
1166
+ *
1167
+ * @generated from enum value: PAGE_MODE_MOBILE = 3;
1168
+ */
1169
+ PageMode[PageMode["MOBILE"] = 3] = "MOBILE";
1170
+ return PageMode;
1171
+ }({});
1172
+ /**
1173
+ * Describes the enum aperture.live.v1.PageMode.
1174
+ */
1175
+ const PageModeSchema = /*@__PURE__*/ enumDesc(file_aperture_live_v1_live, 10);
1176
+ //#endregion
1177
+ //#region src/keys.ts
1178
+ /** `KeyboardEvent.code` to Linux evdev key codes. */
1179
+ const KEYS = {
1180
+ Escape: 1,
1181
+ Digit1: 2,
1182
+ Digit2: 3,
1183
+ Digit3: 4,
1184
+ Digit4: 5,
1185
+ Digit5: 6,
1186
+ Digit6: 7,
1187
+ Digit7: 8,
1188
+ Digit8: 9,
1189
+ Digit9: 10,
1190
+ Digit0: 11,
1191
+ Minus: 12,
1192
+ Equal: 13,
1193
+ Backspace: 14,
1194
+ Tab: 15,
1195
+ KeyQ: 16,
1196
+ KeyW: 17,
1197
+ KeyE: 18,
1198
+ KeyR: 19,
1199
+ KeyT: 20,
1200
+ KeyY: 21,
1201
+ KeyU: 22,
1202
+ KeyI: 23,
1203
+ KeyO: 24,
1204
+ KeyP: 25,
1205
+ BracketLeft: 26,
1206
+ BracketRight: 27,
1207
+ Enter: 28,
1208
+ ControlLeft: 29,
1209
+ KeyA: 30,
1210
+ KeyS: 31,
1211
+ KeyD: 32,
1212
+ KeyF: 33,
1213
+ KeyG: 34,
1214
+ KeyH: 35,
1215
+ KeyJ: 36,
1216
+ KeyK: 37,
1217
+ KeyL: 38,
1218
+ Semicolon: 39,
1219
+ Quote: 40,
1220
+ Backquote: 41,
1221
+ ShiftLeft: 42,
1222
+ Backslash: 43,
1223
+ KeyZ: 44,
1224
+ KeyX: 45,
1225
+ KeyC: 46,
1226
+ KeyV: 47,
1227
+ KeyB: 48,
1228
+ KeyN: 49,
1229
+ KeyM: 50,
1230
+ Comma: 51,
1231
+ Period: 52,
1232
+ Slash: 53,
1233
+ ShiftRight: 54,
1234
+ NumpadMultiply: 55,
1235
+ AltLeft: 56,
1236
+ Space: 57,
1237
+ CapsLock: 58,
1238
+ F1: 59,
1239
+ F2: 60,
1240
+ F3: 61,
1241
+ F4: 62,
1242
+ F5: 63,
1243
+ F6: 64,
1244
+ F7: 65,
1245
+ F8: 66,
1246
+ F9: 67,
1247
+ F10: 68,
1248
+ NumLock: 69,
1249
+ ScrollLock: 70,
1250
+ Numpad7: 71,
1251
+ Numpad8: 72,
1252
+ Numpad9: 73,
1253
+ NumpadSubtract: 74,
1254
+ Numpad4: 75,
1255
+ Numpad5: 76,
1256
+ Numpad6: 77,
1257
+ NumpadAdd: 78,
1258
+ Numpad1: 79,
1259
+ Numpad2: 80,
1260
+ Numpad3: 81,
1261
+ Numpad0: 82,
1262
+ NumpadDecimal: 83,
1263
+ IntlBackslash: 86,
1264
+ F11: 87,
1265
+ F12: 88,
1266
+ NumpadEnter: 96,
1267
+ ControlRight: 97,
1268
+ NumpadDivide: 98,
1269
+ AltRight: 100,
1270
+ Home: 102,
1271
+ ArrowUp: 103,
1272
+ PageUp: 104,
1273
+ ArrowLeft: 105,
1274
+ ArrowRight: 106,
1275
+ End: 107,
1276
+ ArrowDown: 108,
1277
+ PageDown: 109,
1278
+ Insert: 110,
1279
+ Delete: 111,
1280
+ MetaLeft: 125,
1281
+ MetaRight: 126,
1282
+ ContextMenu: 127
1283
+ };
1284
+ const KEY = {
1285
+ enter: 28,
1286
+ backspace: 14,
1287
+ delete: 111,
1288
+ a: 30,
1289
+ c: 46,
1290
+ v: 47
1291
+ };
1292
+ const CONTROLS = [29, 97];
1293
+ const METAS = [125, 126];
1294
+ const DIGITS = "1!2@3#4$5%6^7&8*9(0)";
1295
+ const LETTERS = "abcdefghijklmnopqrstuvwxyz";
1296
+ const layout = () => {
1297
+ const written = {
1298
+ Space: " ",
1299
+ Minus: "-_",
1300
+ Equal: "=+",
1301
+ BracketLeft: "[{",
1302
+ BracketRight: "]}",
1303
+ Backslash: "\\|",
1304
+ Semicolon: ";:",
1305
+ Quote: "'\"",
1306
+ Backquote: "`~",
1307
+ Comma: ",<",
1308
+ Period: ".>",
1309
+ Slash: "/?"
1310
+ };
1311
+ for (let at = 0; at < 20; at += 2) written[`Digit${DIGITS[at]}`] = DIGITS.slice(at, at + 2);
1312
+ for (const letter of LETTERS) written[`Key${letter.toUpperCase()}`] = letter + letter.toUpperCase();
1313
+ return written;
1314
+ };
1315
+ /**
1316
+ * What the keys of a US keyboard write, plain and with Shift, by `KeyboardEvent.code`.
1317
+ * The session's keyboard is a US one.
1318
+ */
1319
+ const US = layout();
1320
+ const makeKeyboard = (send) => {
1321
+ const held = /* @__PURE__ */ new Set();
1322
+ const press = (code, pressed) => {
1323
+ if (pressed) held.add(code);
1324
+ else if (!held.delete(code)) return;
1325
+ send(code, pressed);
1326
+ };
1327
+ const tap = (code) => {
1328
+ press(code, true);
1329
+ press(code, false);
1330
+ };
1331
+ return {
1332
+ press,
1333
+ tap,
1334
+ chord: (code) => {
1335
+ press(CONTROLS[0], true);
1336
+ tap(code);
1337
+ press(CONTROLS[0], false);
1338
+ },
1339
+ paste: () => {
1340
+ for (const code of METAS) press(code, false);
1341
+ const controlled = CONTROLS.some((code) => held.has(code));
1342
+ if (!controlled) press(CONTROLS[0], true);
1343
+ tap(KEY.v);
1344
+ if (!controlled) press(CONTROLS[0], false);
1345
+ },
1346
+ releaseAll: () => {
1347
+ for (const code of held) press(code, false);
1348
+ }
1349
+ };
1350
+ };
1351
+ //#endregion
1352
+ //#region src/input.ts
1353
+ /** `MouseEvent.button` to the protocol's buttons. */
1354
+ const BUTTONS = [
1355
+ 1,
1356
+ 3,
1357
+ 2,
1358
+ 4,
1359
+ 5
1360
+ ];
1361
+ /** How long the stage has to keep a size before the viewport follows it. */
1362
+ const RESIZE_SETTLES_MS = 200;
1363
+ /** Pixels and lines of a wheel to a notch of it. */
1364
+ const NOTCH = {
1365
+ pixels: 100,
1366
+ lines: 3
1367
+ };
1368
+ /** How far a finger may stray, in pixels here, and still be a tap and not a drag. */
1369
+ const TAP_SLOP = 10;
1370
+ /** How long a finger rests in place before it is a press of the right button. */
1371
+ const LONG_PRESS_MS = 500;
1372
+ /** What a page that was flung keeps of its speed after each millisecond, and where it stops. */
1373
+ const FLING = {
1374
+ keeps: .996,
1375
+ least: .05,
1376
+ stops: .01
1377
+ };
1378
+ /**
1379
+ * The part of an element's box its picture covers. An element whose box has not the
1380
+ * picture's proportions shows it whole and centred when it is told to contain it, as a
1381
+ * `video` is unless told otherwise.
1382
+ */
1383
+ const covered = (view, picture) => {
1384
+ const box = view.getBoundingClientRect();
1385
+ const fit = getComputedStyle(view).objectFit;
1386
+ if (!(fit === "contain" || fit === "scale-down") || picture.width === 0 || picture.height === 0) return box;
1387
+ const most = fit === "scale-down" ? 1 : Number.POSITIVE_INFINITY;
1388
+ const scale = Math.min(box.width / picture.width, box.height / picture.height, most);
1389
+ const width = picture.width * scale;
1390
+ const height = picture.height * scale;
1391
+ return {
1392
+ left: box.left + (box.width - width) / 2,
1393
+ top: box.top + (box.height - height) / 2,
1394
+ width,
1395
+ height
1396
+ };
1397
+ };
1398
+ /**
1399
+ * Wires the pointer, the wheel, the keyboard, input methods, the clipboard and dragging
1400
+ * of the surfaces to a session. Closing the scope unwires them and releases the keys
1401
+ * that are held.
1402
+ */
1403
+ const wire = Effect.fn("Input.wire")(function* (surfaces, wiring) {
1404
+ const { video, canvas, keys, stage } = surfaces;
1405
+ const { send, keyboard } = wiring;
1406
+ const { signal } = yield* Effect.acquireRelease(Effect.sync(() => new AbortController()), (controller) => Effect.sync(() => {
1407
+ controller.abort();
1408
+ keyboard.releaseAll();
1409
+ }));
1410
+ const position = (event) => {
1411
+ const shows = wiring.way() === "video";
1412
+ const picture = shows ? {
1413
+ width: video.videoWidth,
1414
+ height: video.videoHeight
1415
+ } : {
1416
+ width: canvas.width,
1417
+ height: canvas.height
1418
+ };
1419
+ const box = covered(shows ? video : canvas, picture);
1420
+ const { width, height } = wiring.watched() ?? picture;
1421
+ if (box.width === 0 || box.height === 0) return;
1422
+ return {
1423
+ x: (event.clientX - box.left) * (width / box.width),
1424
+ y: (event.clientY - box.top) * (height / box.height)
1425
+ };
1426
+ };
1427
+ const focus = () => keys.focus({ preventScroll: true });
1428
+ const button = (surface, pressed) => (event) => {
1429
+ focus();
1430
+ if (pressed) {
1431
+ wiring.dismissMenu();
1432
+ surface.setPointerCapture(event.pointerId);
1433
+ }
1434
+ if (event.button === 2) wiring.menuAt({
1435
+ x: event.clientX,
1436
+ y: event.clientY
1437
+ });
1438
+ const at = position(event);
1439
+ const pressedButton = BUTTONS[event.button];
1440
+ if (at !== void 0 && pressedButton !== void 0) send({
1441
+ case: "pointerButton",
1442
+ value: {
1443
+ ...at,
1444
+ button: pressedButton,
1445
+ pressed
1446
+ }
1447
+ });
1448
+ event.preventDefault();
1449
+ };
1450
+ /**
1451
+ * A finger is no mouse: it has no buttons and nothing to turn. One that is put down and
1452
+ * lifted in place is a click of the left button; one that rests is a click of the right;
1453
+ * one that moves turns the wheel, so that the page scrolls under it as a page under a
1454
+ * finger does, and goes on for a while when it is flung. More fingers move the page as
1455
+ * one does: nothing is pressed while they are down.
1456
+ */
1457
+ const touches = (surface) => {
1458
+ const fingers = /* @__PURE__ */ new Map();
1459
+ let gesture;
1460
+ let resting;
1461
+ let flung;
1462
+ const still = () => {
1463
+ clearTimeout(resting);
1464
+ if (flung !== void 0) {
1465
+ cancelAnimationFrame(flung);
1466
+ flung = void 0;
1467
+ }
1468
+ };
1469
+ signal.addEventListener("abort", still);
1470
+ /** The middle of the fingers, in the target's pixels. */
1471
+ const middle = () => {
1472
+ let clientX = 0;
1473
+ let clientY = 0;
1474
+ for (const finger of fingers.values()) {
1475
+ clientX += finger.clientX / fingers.size;
1476
+ clientY += finger.clientY / fingers.size;
1477
+ }
1478
+ return position({
1479
+ clientX,
1480
+ clientY
1481
+ });
1482
+ };
1483
+ const click = (at, pressedButton) => {
1484
+ send({
1485
+ case: "pointerMotion",
1486
+ value: at
1487
+ });
1488
+ send({
1489
+ case: "pointerButton",
1490
+ value: {
1491
+ ...at,
1492
+ button: pressedButton,
1493
+ pressed: true
1494
+ }
1495
+ });
1496
+ send({
1497
+ case: "pointerButton",
1498
+ value: {
1499
+ ...at,
1500
+ button: pressedButton,
1501
+ pressed: false
1502
+ }
1503
+ });
1504
+ };
1505
+ const scroll = (at, by) => {
1506
+ send({
1507
+ case: "pointerScroll",
1508
+ value: {
1509
+ ...at,
1510
+ dx: by.x / NOTCH.pixels,
1511
+ dy: by.y / NOTCH.pixels
1512
+ }
1513
+ });
1514
+ wiring.dragged(by);
1515
+ };
1516
+ const fling = (at, speed) => {
1517
+ let before = performance.now();
1518
+ let going = speed;
1519
+ const step = (now) => {
1520
+ const elapsed = Math.min(now - before, 50);
1521
+ before = now;
1522
+ const kept = FLING.keeps ** elapsed;
1523
+ going = {
1524
+ x: going.x * kept,
1525
+ y: going.y * kept
1526
+ };
1527
+ if (Math.hypot(going.x, going.y) < FLING.stops) {
1528
+ flung = void 0;
1529
+ return;
1530
+ }
1531
+ scroll(at, {
1532
+ x: going.x * elapsed,
1533
+ y: going.y * elapsed
1534
+ });
1535
+ flung = requestAnimationFrame(step);
1536
+ };
1537
+ flung = requestAnimationFrame(step);
1538
+ };
1539
+ const down = (event) => {
1540
+ event.preventDefault();
1541
+ still();
1542
+ wiring.dismissMenu();
1543
+ surface.setPointerCapture(event.pointerId);
1544
+ fingers.set(event.pointerId, event);
1545
+ const at = position(event);
1546
+ if (fingers.size > 1 || at === void 0) {
1547
+ if (gesture !== void 0) {
1548
+ gesture.kind = gesture.kind === "held" ? "held" : "scroll";
1549
+ gesture.middle = void 0;
1550
+ }
1551
+ return;
1552
+ }
1553
+ const began = {
1554
+ clientX: event.clientX,
1555
+ clientY: event.clientY
1556
+ };
1557
+ gesture = {
1558
+ kind: "tap",
1559
+ began,
1560
+ at,
1561
+ middle: at,
1562
+ moved: 0,
1563
+ speed: {
1564
+ x: 0,
1565
+ y: 0
1566
+ }
1567
+ };
1568
+ send({
1569
+ case: "pointerMotion",
1570
+ value: at
1571
+ });
1572
+ resting = setTimeout(() => {
1573
+ if (gesture?.kind === "tap") {
1574
+ gesture.kind = "held";
1575
+ wiring.menuAt({
1576
+ x: began.clientX,
1577
+ y: began.clientY
1578
+ });
1579
+ click(at, 2);
1580
+ }
1581
+ }, LONG_PRESS_MS);
1582
+ };
1583
+ const move = (event) => {
1584
+ if (gesture === void 0 || !fingers.has(event.pointerId)) return;
1585
+ fingers.set(event.pointerId, event);
1586
+ if (gesture.kind === "tap") {
1587
+ if (Math.hypot(event.clientX - gesture.began.clientX, event.clientY - gesture.began.clientY) <= TAP_SLOP) return;
1588
+ clearTimeout(resting);
1589
+ gesture.kind = "scroll";
1590
+ gesture.middle = void 0;
1591
+ }
1592
+ if (gesture.kind !== "scroll") return;
1593
+ const now = middle();
1594
+ const before = gesture.middle;
1595
+ gesture.middle = now;
1596
+ if (now === void 0 || before === void 0) {
1597
+ gesture.moved = event.timeStamp;
1598
+ return;
1599
+ }
1600
+ const by = {
1601
+ x: before.x - now.x,
1602
+ y: before.y - now.y
1603
+ };
1604
+ scroll(gesture.at, by);
1605
+ const elapsed = Math.max(event.timeStamp - gesture.moved, 1);
1606
+ gesture.moved = event.timeStamp;
1607
+ gesture.speed = {
1608
+ x: gesture.speed.x * .6 + by.x / elapsed * .4,
1609
+ y: gesture.speed.y * .6 + by.y / elapsed * .4
1610
+ };
1611
+ };
1612
+ const up = (lifted) => (event) => {
1613
+ if (!fingers.delete(event.pointerId) || gesture === void 0) return;
1614
+ event.preventDefault();
1615
+ if (fingers.size > 0) {
1616
+ gesture.middle = void 0;
1617
+ return;
1618
+ }
1619
+ clearTimeout(resting);
1620
+ const ended = gesture;
1621
+ gesture = void 0;
1622
+ if (!lifted) return;
1623
+ if (ended.kind === "tap") click(ended.at, 1);
1624
+ else if (ended.kind === "scroll" && event.timeStamp - ended.moved < 100 && Math.hypot(ended.speed.x, ended.speed.y) > FLING.least) fling(ended.at, ended.speed);
1625
+ };
1626
+ return {
1627
+ down,
1628
+ move,
1629
+ up: up(true),
1630
+ cancel: up(false)
1631
+ };
1632
+ };
1633
+ const dropped = async (at, files, carried) => {
1634
+ const forms = files.length > 0 ? [await wiring.listed(files)] : carried;
1635
+ if (forms.length > 0) send({
1636
+ case: "drop",
1637
+ value: {
1638
+ ...at,
1639
+ content: { forms: [...forms] }
1640
+ }
1641
+ });
1642
+ };
1643
+ const pictures = [video, canvas];
1644
+ for (const surface of pictures) {
1645
+ const finger = touches(surface);
1646
+ const byFinger = (event) => event.pointerType === "touch";
1647
+ const pressed = button(surface, true);
1648
+ const released = button(surface, false);
1649
+ surface.addEventListener("pointermove", (event) => {
1650
+ if (byFinger(event)) {
1651
+ finger.move(event);
1652
+ return;
1653
+ }
1654
+ const at = position(event);
1655
+ if (at !== void 0) send({
1656
+ case: "pointerMotion",
1657
+ value: at
1658
+ });
1659
+ }, { signal });
1660
+ surface.addEventListener("pointerleave", () => send({
1661
+ case: "pointerLeave",
1662
+ value: {}
1663
+ }), { signal });
1664
+ surface.addEventListener("pointerdown", (event) => byFinger(event) ? finger.down(event) : pressed(event), { signal });
1665
+ surface.addEventListener("pointerup", (event) => byFinger(event) ? finger.up(event) : released(event), { signal });
1666
+ surface.addEventListener("pointercancel", (event) => byFinger(event) ? finger.cancel(event) : void 0, { signal });
1667
+ surface.addEventListener("contextmenu", (event) => event.preventDefault(), { signal });
1668
+ surface.addEventListener("wheel", (event) => {
1669
+ const at = position(event);
1670
+ const notch = event.deltaMode === WheelEvent.DOM_DELTA_PIXEL ? NOTCH.pixels : NOTCH.lines;
1671
+ if (at !== void 0) {
1672
+ const scrolled = {
1673
+ ...at,
1674
+ dx: event.deltaX / notch,
1675
+ dy: event.deltaY / notch
1676
+ };
1677
+ send({
1678
+ case: "pointerScroll",
1679
+ value: scrolled
1680
+ });
1681
+ }
1682
+ event.preventDefault();
1683
+ }, {
1684
+ passive: false,
1685
+ signal
1686
+ });
1687
+ surface.addEventListener("dragover", (event) => {
1688
+ event.preventDefault();
1689
+ if (event.dataTransfer !== null) event.dataTransfer.dropEffect = "copy";
1690
+ }, { signal });
1691
+ surface.addEventListener("drop", (event) => {
1692
+ event.preventDefault();
1693
+ const at = position(event);
1694
+ const carried = event.dataTransfer;
1695
+ if (at === void 0 || carried === null) return;
1696
+ dropped(at, [...carried.files], texts(carried)).catch((cause) => wiring.failed("a drop", cause));
1697
+ }, { signal });
1698
+ }
1699
+ const text = (written, composing = false) => send({
1700
+ case: "text",
1701
+ value: {
1702
+ text: written,
1703
+ composing
1704
+ }
1705
+ });
1706
+ const rest = () => {
1707
+ keys.value = " ";
1708
+ };
1709
+ rest();
1710
+ keys.addEventListener("keydown", (event) => {
1711
+ if (event.key === "Escape") wiring.dismissMenu();
1712
+ if (event.isComposing || event.keyCode === 229) return;
1713
+ const code = KEYS[event.code];
1714
+ if (code === void 0) return;
1715
+ const shortcut = event.ctrlKey || event.metaKey;
1716
+ if (shortcut && event.code === "KeyV") return;
1717
+ const written = Array.from(event.key).length === 1 && !shortcut ? event.key : void 0;
1718
+ const same = US[event.code]?.[event.shiftKey ? 1 : 0] === written;
1719
+ if (written === void 0 || same) keyboard.press(code, true);
1720
+ else text(written);
1721
+ event.preventDefault();
1722
+ }, { signal });
1723
+ keys.addEventListener("keyup", (event) => {
1724
+ const code = KEYS[event.code];
1725
+ if (code !== void 0) keyboard.press(code, false);
1726
+ event.preventDefault();
1727
+ }, { signal });
1728
+ keys.addEventListener("blur", () => keyboard.releaseAll(), { signal });
1729
+ keys.addEventListener("compositionupdate", (event) => text(event.data, true), { signal });
1730
+ keys.addEventListener("compositionend", (event) => {
1731
+ text(event.data);
1732
+ rest();
1733
+ }, { signal });
1734
+ keys.addEventListener("beforeinput", (event) => {
1735
+ if (event.isComposing || /Composition/u.test(event.inputType)) return;
1736
+ event.preventDefault();
1737
+ if (/^insert(?:Text|ReplacementText)$/u.test(event.inputType) && event.data) text(event.data);
1738
+ if (/^insert(?:LineBreak|Paragraph)$/u.test(event.inputType)) keyboard.tap(KEY.enter);
1739
+ if (event.inputType === "deleteContentBackward") keyboard.tap(KEY.backspace);
1740
+ if (event.inputType === "deleteContentForward") keyboard.tap(KEY.delete);
1741
+ }, { signal });
1742
+ keys.addEventListener("input", rest, { signal });
1743
+ const pasted = async (carried, files) => {
1744
+ const forms = [...carried];
1745
+ const [only] = files;
1746
+ const picture = files.length === 1 && only?.type.startsWith("image/") ? only : void 0;
1747
+ if (picture !== void 0) forms.push(await form("image/png", await png(picture)));
1748
+ else if (files.length > 0) forms.push(await wiring.listed(files));
1749
+ if (forms.length === 0) return;
1750
+ send({
1751
+ case: "clipboard",
1752
+ value: { forms }
1753
+ });
1754
+ keyboard.paste();
1755
+ };
1756
+ keys.addEventListener("paste", (event) => {
1757
+ event.preventDefault();
1758
+ const carried = event.clipboardData;
1759
+ if (carried === null) return;
1760
+ pasted(texts(carried), [...carried.files]).catch((cause) => wiring.failed("a paste", cause));
1761
+ }, { signal });
1762
+ if (typeof ResizeObserver !== "undefined") {
1763
+ let settling;
1764
+ const sizes = new ResizeObserver(() => {
1765
+ clearTimeout(settling);
1766
+ settling = setTimeout(wiring.resized, RESIZE_SETTLES_MS);
1767
+ });
1768
+ sizes.observe(stage);
1769
+ signal.addEventListener("abort", () => {
1770
+ clearTimeout(settling);
1771
+ sizes.disconnect();
1772
+ });
1773
+ }
1774
+ });
1775
+ //#endregion
1776
+ //#region src/model.ts
1777
+ const NOTHING = {
1778
+ read: false,
1779
+ write: false
1780
+ };
1781
+ /** What a client may do before the session has told: nothing. */
1782
+ const NO_FEATURES = {
1783
+ input: NOTHING,
1784
+ tabs: NOTHING,
1785
+ lease: NOTHING,
1786
+ sound: NOTHING,
1787
+ clipboard: NOTHING,
1788
+ uploads: NOTHING,
1789
+ downloads: NOTHING,
1790
+ recordings: NOTHING,
1791
+ mcp: NOTHING,
1792
+ cdp: NOTHING,
1793
+ tunnel: NOTHING
1794
+ };
1795
+ const grantOf = (grant) => grant === void 0 ? NOTHING : {
1796
+ read: grant.read,
1797
+ write: grant.write
1798
+ };
1799
+ const featuresOf = (features) => ({
1800
+ input: grantOf(features.input),
1801
+ tabs: grantOf(features.tabs),
1802
+ lease: grantOf(features.lease),
1803
+ sound: grantOf(features.sound),
1804
+ clipboard: grantOf(features.clipboard),
1805
+ uploads: grantOf(features.uploads),
1806
+ downloads: grantOf(features.downloads),
1807
+ recordings: grantOf(features.recordings),
1808
+ mcp: grantOf(features.mcp),
1809
+ cdp: grantOf(features.cdp),
1810
+ tunnel: grantOf(features.tunnel)
1811
+ });
1812
+ const FORMATS = {
1813
+ h264: 1,
1814
+ "full-chroma": 2,
1815
+ h265: 3,
1816
+ vp9: 4,
1817
+ "vp9-full-chroma": 5,
1818
+ av1: 6
1819
+ };
1820
+ const QUALITIES = {
1821
+ low: 1,
1822
+ medium: 2,
1823
+ full: 3
1824
+ };
1825
+ const PIXELS = {
1826
+ video: 1,
1827
+ frames: 3,
1828
+ tiles: 2
1829
+ };
1830
+ const ALONGS = {
1831
+ back: 1,
1832
+ forward: 2,
1833
+ reload: 3
1834
+ };
1835
+ const LEASE_ACTIONS = {
1836
+ take: 1,
1837
+ release: 2,
1838
+ allow: 3,
1839
+ keep: 4
1840
+ };
1841
+ const PAGE_MODES = {
1842
+ auto: 1,
1843
+ desktop: 2,
1844
+ mobile: 3
1845
+ };
1846
+ const ROLES = {
1847
+ [1]: "view",
1848
+ [2]: "control",
1849
+ [3]: "admin"
1850
+ };
1851
+ const ASKED = {
1852
+ [1]: "go",
1853
+ [2]: "close",
1854
+ [3]: "copyPicture",
1855
+ [4]: "chooseFiles",
1856
+ [5]: "follow",
1857
+ [6]: "setMode"
1858
+ };
1859
+ const STROKE_PHASES = {
1860
+ [1]: "start",
1861
+ [2]: "move",
1862
+ [3]: "end"
1863
+ };
1864
+ const STROKE_PHASE = {
1865
+ start: 1,
1866
+ move: 2,
1867
+ end: 3
1868
+ };
1869
+ const pointerOf = (pointer) => ({
1870
+ member: Number(pointer.member),
1871
+ at: pointer.at === void 0 ? void 0 : {
1872
+ x: pointer.at.x,
1873
+ y: pointer.at.y
1874
+ }
1875
+ });
1876
+ /** None for a point of a phase this client does not know. */
1877
+ const strokeOf = (stroke) => {
1878
+ const phase = STROKE_PHASES[stroke.phase];
1879
+ return phase === void 0 ? void 0 : {
1880
+ member: Number(stroke.member),
1881
+ stroke: stroke.stroke,
1882
+ phase,
1883
+ x: stroke.x,
1884
+ y: stroke.y
1885
+ };
1886
+ };
1887
+ const failureOf = (failed) => ({
1888
+ asked: ASKED[failed.asked],
1889
+ reason: failed.reason
1890
+ });
1891
+ const DOWNLOAD_STATES = {
1892
+ [1]: "running",
1893
+ [2]: "done",
1894
+ [3]: "failed"
1895
+ };
1896
+ const named = (names, value) => {
1897
+ return Object.entries(names).find(([, one]) => one === value)?.[0];
1898
+ };
1899
+ const formatOf = (format) => named(FORMATS, format);
1900
+ const qualityOf = (quality) => named(QUALITIES, quality);
1901
+ const count = (id) => id === void 0 ? void 0 : Number(id);
1902
+ const targetOf = (target) => ({
1903
+ id: target.id,
1904
+ tab: target.tab,
1905
+ title: target.title,
1906
+ url: target.url,
1907
+ width: target.width,
1908
+ height: target.height,
1909
+ scale: target.scale,
1910
+ mode: named(PAGE_MODES, target.mode) ?? "auto",
1911
+ mobile: target.mobile,
1912
+ sounds: target.sounds,
1913
+ goesBack: target.goesBack,
1914
+ goesForward: target.goesForward
1915
+ });
1916
+ const presenceOf = (presence) => ({
1917
+ you: Number(presence.you),
1918
+ members: presence.members.map((member) => ({
1919
+ id: Number(member.id),
1920
+ name: member.name,
1921
+ role: ROLES[member.role],
1922
+ tab: member.tab,
1923
+ agent: member.agent,
1924
+ follows: count(member.follows)
1925
+ })),
1926
+ held: presence.held.map((held) => ({
1927
+ tab: held.tab,
1928
+ holder: Number(held.holder),
1929
+ askedBy: count(held.askedBy)
1930
+ }))
1931
+ });
1932
+ const downloadOf = (download) => ({
1933
+ id: download.id,
1934
+ name: download.name,
1935
+ url: download.url,
1936
+ receivedBytes: Number(download.receivedBytes),
1937
+ totalBytes: count(download.totalBytes),
1938
+ state: DOWNLOAD_STATES[download.state]
1939
+ });
1940
+ const fileRequestOf = (request) => ({
1941
+ id: Number(request.id),
1942
+ tab: request.tab,
1943
+ multiple: request.multiple
1944
+ });
1945
+ const menuOf = (menu) => ({
1946
+ link: menu.link,
1947
+ image: menu.image,
1948
+ text: menu.text,
1949
+ editable: menu.editable
1950
+ });
1951
+ const statusOf = (status) => ({
1952
+ format: formatOf(status.format),
1953
+ quality: qualityOf(status.quality),
1954
+ fps: status.fps
1955
+ });
1956
+ //#endregion
1957
+ //#region src/socket.ts
1958
+ const encode = (message) => toBinary(ClientMessageSchema, create(ClientMessageSchema, { message }));
1959
+ const decode = (data) => {
1960
+ if (typeof data === "string") return fromJsonString(ServerMessageSchema, data, { ignoreUnknownFields: true });
1961
+ if (data instanceof ArrayBuffer) return fromBinary(ServerMessageSchema, new Uint8Array(data));
1962
+ };
1963
+ /** Opens the session socket. Closing the scope closes it, and `closed` is not told then. */
1964
+ const open = Effect.fn("Socket.open")(function* (url, handlers) {
1965
+ const listening = new AbortController();
1966
+ const socket = yield* Effect.acquireRelease(Effect.sync(() => {
1967
+ const opened = new WebSocket(url);
1968
+ opened.binaryType = "arraybuffer";
1969
+ return opened;
1970
+ }), (opened) => Effect.sync(() => {
1971
+ listening.abort();
1972
+ opened.close();
1973
+ }));
1974
+ const { signal } = listening;
1975
+ socket.addEventListener("open", () => handlers.opened(), { signal });
1976
+ socket.addEventListener("message", (event) => {
1977
+ let decoded;
1978
+ try {
1979
+ decoded = decode(event.data);
1980
+ } catch {
1981
+ return;
1982
+ }
1983
+ const message = decoded?.message;
1984
+ if (message !== void 0 && message.case !== void 0) handlers.message(message);
1985
+ }, { signal });
1986
+ socket.addEventListener("close", (event) => handlers.closed(event.reason === "" ? void 0 : event.reason), { signal });
1987
+ return {
1988
+ isOpen: () => socket.readyState === WebSocket.OPEN,
1989
+ send: (message) => {
1990
+ if (socket.readyState !== WebSocket.OPEN) return false;
1991
+ socket.send(encode(message));
1992
+ return true;
1993
+ }
1994
+ };
1995
+ });
1996
+ //#endregion
1997
+ //#region src/sound.ts
1998
+ /** How far ahead of now sound starts that came too late for its turn, in seconds. */
1999
+ const AHEAD = .06;
2000
+ /** Sound that would wait longer than this is left out: it stays with the picture. */
2001
+ const WAIT_MOST = .4;
2002
+ /**
2003
+ * The session's sound. With a WebRTC connection it comes on a track of that; otherwise as
2004
+ * packets on the session socket, which are decoded and played one after the other.
2005
+ */
2006
+ const make$1 = Effect.fn("Sound.make")(function* () {
2007
+ const speaker = typeof Audio === "undefined" ? void 0 : new Audio();
2008
+ if (speaker !== void 0) {
2009
+ speaker.autoplay = true;
2010
+ speaker.muted = true;
2011
+ }
2012
+ let on = false;
2013
+ let context;
2014
+ let decoder;
2015
+ let playAt = 0;
2016
+ const play = (ears, audio) => {
2017
+ const buffer = ears.createBuffer(audio.numberOfChannels, audio.numberOfFrames, audio.sampleRate);
2018
+ for (let channel = 0; channel < audio.numberOfChannels; channel++) audio.copyTo(buffer.getChannelData(channel), {
2019
+ planeIndex: channel,
2020
+ format: "f32-planar"
2021
+ });
2022
+ audio.close();
2023
+ const now = ears.currentTime;
2024
+ if (playAt < now) playAt = now + AHEAD;
2025
+ if (playAt > now + WAIT_MOST) return;
2026
+ const source = ears.createBufferSource();
2027
+ source.buffer = buffer;
2028
+ source.connect(ears.destination);
2029
+ source.start(playAt);
2030
+ playAt += buffer.duration;
2031
+ };
2032
+ const listen = () => {
2033
+ if (typeof AudioContext === "undefined" || typeof AudioDecoder === "undefined") return;
2034
+ context ??= new AudioContext({
2035
+ sampleRate: 48e3,
2036
+ latencyHint: "interactive"
2037
+ });
2038
+ const ears = context;
2039
+ if (decoder?.state !== "configured") {
2040
+ decoder = new AudioDecoder({
2041
+ output: (audio) => play(ears, audio),
2042
+ error: () => {}
2043
+ });
2044
+ decoder.configure({
2045
+ codec: "opus",
2046
+ sampleRate: 48e3,
2047
+ numberOfChannels: 2
2048
+ });
2049
+ }
2050
+ return decoder;
2051
+ };
2052
+ const start = () => {
2053
+ if (!on) return;
2054
+ speaker?.play().catch(() => {});
2055
+ context?.resume().catch(() => {});
2056
+ };
2057
+ const gestures = new AbortController();
2058
+ if (typeof document !== "undefined") for (const gesture of ["pointerdown", "keydown"]) document.addEventListener(gesture, start, {
2059
+ capture: true,
2060
+ signal: gestures.signal
2061
+ });
2062
+ yield* Effect.addFinalizer(() => Effect.sync(() => {
2063
+ on = false;
2064
+ gestures.abort();
2065
+ if (decoder !== void 0 && decoder.state !== "closed") decoder.close();
2066
+ context?.close().catch(() => {});
2067
+ if (speaker !== void 0) {
2068
+ speaker.pause();
2069
+ speaker.srcObject = null;
2070
+ }
2071
+ }));
2072
+ return {
2073
+ turn: (wanted) => {
2074
+ on = wanted;
2075
+ if (speaker !== void 0) speaker.muted = !wanted;
2076
+ start();
2077
+ },
2078
+ track: (track) => {
2079
+ if (speaker !== void 0) speaker.srcObject = track === void 0 ? null : new MediaStream([track]);
2080
+ },
2081
+ hear: (timeUs, data) => {
2082
+ if (!on) return;
2083
+ const heard = listen();
2084
+ if (heard === void 0) return;
2085
+ try {
2086
+ heard.decode(new EncodedAudioChunk({
2087
+ type: "key",
2088
+ timestamp: Number(timeUs),
2089
+ data
2090
+ }));
2091
+ } catch {}
2092
+ }
2093
+ };
2094
+ });
2095
+ //#endregion
2096
+ //#region src/surface.ts
2097
+ const context = (canvas) => canvas instanceof HTMLCanvasElement ? canvas.getContext("2d") : canvas.getContext("2d");
2098
+ const makeSurface = () => {
2099
+ let canvas;
2100
+ let attached = false;
2101
+ return {
2102
+ size: () => ({
2103
+ width: canvas?.width ?? 0,
2104
+ height: canvas?.height ?? 0
2105
+ }),
2106
+ draw: (image, x, y, width, height) => {
2107
+ if (canvas === void 0 && typeof OffscreenCanvas !== "undefined") canvas = new OffscreenCanvas(width, height);
2108
+ const onto = canvas;
2109
+ if (onto === void 0) return;
2110
+ if (onto.width !== width || onto.height !== height) {
2111
+ onto.width = width;
2112
+ onto.height = height;
2113
+ }
2114
+ context(onto)?.drawImage(image, x, y);
2115
+ },
2116
+ attach: (element) => {
2117
+ const kept = canvas;
2118
+ if (kept !== void 0 && kept !== element && kept.width > 0 && kept.height > 0) {
2119
+ element.width = kept.width;
2120
+ element.height = kept.height;
2121
+ context(element)?.drawImage(kept, 0, 0);
2122
+ }
2123
+ canvas = element;
2124
+ attached = true;
2125
+ },
2126
+ detach: () => {
2127
+ if (!attached) return;
2128
+ const shown = canvas;
2129
+ canvas = void 0;
2130
+ attached = false;
2131
+ if (shown === void 0 || !(typeof OffscreenCanvas !== "undefined") || shown.width === 0 || shown.height === 0) return;
2132
+ canvas = new OffscreenCanvas(shown.width, shown.height);
2133
+ context(canvas)?.drawImage(shown, 0, 0);
2134
+ }
2135
+ };
2136
+ };
2137
+ //#endregion
2138
+ //#region src/session.ts
2139
+ /** A WebRTC connection that says nothing for this long is taken not to connect. */
2140
+ const RTC_CONNECTS_WITHIN = "8 seconds";
2141
+ /**
2142
+ * What frames are asked for when the choice is left to this client: sharp color where
2143
+ * frames are decoded here. Over WebRTC the session picks what every browser takes.
2144
+ */
2145
+ const BEST_FRAMES = ["full-chroma", "h264"];
2146
+ /** How long sound that was sent before a tab was to be heard keeps arriving. */
2147
+ const SOUND_SETTLES_MS = 300;
2148
+ const pixels = (side) => Math.max(0, Math.round(side));
2149
+ /** The widest the shorter side of a phone's window is, in CSS pixels. */
2150
+ const PHONE_WITHIN = 600;
2151
+ /**
2152
+ * The most pixels a page shown as on a phone draws to one of its own, unless it is given
2153
+ * another scale: a phone's screen has three and more, and a picture of that many is three
2154
+ * times the video of one of two, which reads as well on a screen that small.
2155
+ */
2156
+ const SHARPEST = 2;
2157
+ /**
2158
+ * Whether this is a phone: a finger is what points, and the window is narrow. A tablet
2159
+ * and a laptop with a touch screen are none.
2160
+ */
2161
+ const onPhone = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(pointer: coarse)").matches && Math.min(window.innerWidth, window.innerHeight) <= PHONE_WITHIN;
2162
+ /**
2163
+ * Connects to a session. Closing the scope unwires what is attached, ends the picture's
2164
+ * WebRTC connection and decoder, then the sound, then the session socket.
2165
+ */
2166
+ const make = Effect.fn("Session.make")(function* (options) {
2167
+ const address = {
2168
+ url: options.url,
2169
+ token: options.token,
2170
+ name: options.name
2171
+ };
2172
+ const ways = waysHere();
2173
+ let way = ways[Math.max(0, ways.indexOf(options.pixels ?? "video"))] ?? "tiles";
2174
+ let settings = {};
2175
+ let closed = false;
2176
+ let sounds = false;
2177
+ let fitting = false;
2178
+ let attached;
2179
+ let menuAt = {
2180
+ x: 0,
2181
+ y: 0
2182
+ };
2183
+ let snapshot = {
2184
+ connection: { state: "connecting" },
2185
+ targets: [],
2186
+ selected: void 0,
2187
+ presence: void 0,
2188
+ downloads: [],
2189
+ fileRequests: [],
2190
+ cursor: "default",
2191
+ picture: {
2192
+ way,
2193
+ ways,
2194
+ status: void 0,
2195
+ formats: [],
2196
+ settings,
2197
+ rtc: void 0
2198
+ },
2199
+ features: NO_FEATURES,
2200
+ muted: [],
2201
+ menu: void 0,
2202
+ fit: false,
2203
+ phone: onPhone()
2204
+ };
2205
+ const listeners = /* @__PURE__ */ new Set();
2206
+ const clipboardListeners = /* @__PURE__ */ new Set();
2207
+ const update = (change) => {
2208
+ const changed = Object.entries(change).filter(([key, value]) => !Equal.equals(snapshot[key], value));
2209
+ if (changed.length === 0) return;
2210
+ snapshot = {
2211
+ ...snapshot,
2212
+ ...Object.fromEntries(changed)
2213
+ };
2214
+ for (const listener of listeners) listener();
2215
+ };
2216
+ const updatePicture = (change) => {
2217
+ update({ picture: {
2218
+ ...snapshot.picture,
2219
+ ...change
2220
+ } });
2221
+ };
2222
+ const listening = (listeners) => (listener) => {
2223
+ listeners.add(listener);
2224
+ return () => {
2225
+ listeners.delete(listener);
2226
+ };
2227
+ };
2228
+ const subscribe = listening(listeners);
2229
+ const onClipboard = listening(clipboardListeners);
2230
+ const draggedListeners = /* @__PURE__ */ new Set();
2231
+ const onDragged = listening(draggedListeners);
2232
+ const failureListeners = /* @__PURE__ */ new Set();
2233
+ const onFailure = listening(failureListeners);
2234
+ const pointerListeners = /* @__PURE__ */ new Set();
2235
+ const strokeListeners = /* @__PURE__ */ new Set();
2236
+ const watched = () => snapshot.targets.find((target) => target.tab === snapshot.selected);
2237
+ const socket = yield* open(socketUrl(address), {
2238
+ opened: () => {
2239
+ update({ connection: { state: "open" } });
2240
+ socket.send({
2241
+ case: "device",
2242
+ value: { phone: snapshot.phone }
2243
+ });
2244
+ runFork(start());
2245
+ },
2246
+ message: (message) => receive(message),
2247
+ closed: (reason) => {
2248
+ update({ connection: reason === void 0 ? { state: "closed" } : {
2249
+ state: "closed",
2250
+ reason
2251
+ } });
2252
+ runFork(stop());
2253
+ }
2254
+ });
2255
+ const sound = yield* make$1();
2256
+ const surface = makeSurface();
2257
+ const scope = yield* Effect.scope;
2258
+ const pictureScope = yield* Scope.fork(scope);
2259
+ const runFork = yield* FiberSet.makeRuntime();
2260
+ let peer;
2261
+ let stream;
2262
+ let decoder;
2263
+ let decodes;
2264
+ let wayScope;
2265
+ let turns = 0;
2266
+ const send = (message) => {
2267
+ const pointer = peer?.pointer;
2268
+ if (message.case === "pointerMotion" && pointer?.readyState === "open") {
2269
+ pointer.send(new Uint8Array(encode(message)));
2270
+ return;
2271
+ }
2272
+ socket.send(message);
2273
+ };
2274
+ const keyboard = makeKeyboard((code, pressed) => send({
2275
+ case: "key",
2276
+ value: {
2277
+ code,
2278
+ pressed
2279
+ }
2280
+ }));
2281
+ /** Says how the picture is to come: again whenever something changes that. */
2282
+ const hello = Effect.fn("Session.hello")(function* () {
2283
+ const asked = way;
2284
+ const decoded = yield* Effect.tryPromise(() => decodable(asked)).pipe(Effect.orElseSucceed(() => []));
2285
+ if (closed || asked !== way) return;
2286
+ if (settings.format !== void 0 && !decoded.includes(settings.format)) {
2287
+ const { format: _, ...kept } = settings;
2288
+ settings = kept;
2289
+ }
2290
+ updatePicture({
2291
+ formats: decoded,
2292
+ settings
2293
+ });
2294
+ const best = asked === "frames" ? BEST_FRAMES.filter((format) => decoded.includes(format)) : [];
2295
+ const wanted = settings.format === void 0 ? best : [settings.format];
2296
+ send({
2297
+ case: "hello",
2298
+ value: {
2299
+ pixels: PIXELS[asked],
2300
+ formats: wanted.map((format) => FORMATS[format]),
2301
+ quality: settings.quality === void 0 ? void 0 : QUALITIES[settings.quality],
2302
+ fps: settings.fps,
2303
+ audio: sounds && asked !== "video"
2304
+ }
2305
+ });
2306
+ });
2307
+ const closeDecoder = () => {
2308
+ if (decoder !== void 0 && decoder.state !== "closed") decoder.close();
2309
+ decoder = void 0;
2310
+ decodes = void 0;
2311
+ };
2312
+ /** What fails falls to the next way: video over WebRTC, the same video as frames, tiles. */
2313
+ const fall = (reason) => {
2314
+ const failed = way;
2315
+ const next = ways[ways.indexOf(failed) + 1];
2316
+ if (closed || next === void 0 || !socket.isOpen()) return;
2317
+ way = next;
2318
+ runFork(Effect.logWarning(`${failed}: ${reason}`).pipe(Effect.andThen(start())));
2319
+ };
2320
+ const watchVideo = Effect.fn("Session.watchVideo")(function* (turn, within) {
2321
+ const connection = yield* Effect.acquireRelease(Effect.sync(() => new RTCPeerConnection()), (made) => Effect.sync(() => {
2322
+ made.close();
2323
+ if (peer?.connection === made) peer = void 0;
2324
+ stream = void 0;
2325
+ sound.track(void 0);
2326
+ if (attached !== void 0) attached.video.srcObject = null;
2327
+ })).pipe(Scope.provide(within));
2328
+ connection.addTransceiver("video", { direction: "recvonly" });
2329
+ connection.addTransceiver("audio", { direction: "recvonly" });
2330
+ peer = {
2331
+ connection,
2332
+ pointer: connection.createDataChannel("pointer", {
2333
+ ordered: true,
2334
+ maxRetransmits: 0
2335
+ })
2336
+ };
2337
+ connection.addEventListener("track", (event) => {
2338
+ if (event.track.kind === "audio") {
2339
+ sound.track(event.track);
2340
+ return;
2341
+ }
2342
+ const receiver = event.receiver;
2343
+ receiver.jitterBufferTarget = 0;
2344
+ receiver.playoutDelayHint = 0;
2345
+ stream = new MediaStream([event.track]);
2346
+ if (attached !== void 0) attached.video.srcObject = stream;
2347
+ });
2348
+ connection.addEventListener("connectionstatechange", () => {
2349
+ if (peer?.connection !== connection) return;
2350
+ updatePicture({ rtc: connection.connectionState });
2351
+ if (connection.connectionState === "failed") fall("WebRTC failed");
2352
+ });
2353
+ const offer = yield* Effect.tryPromise(async () => {
2354
+ await connection.setLocalDescription(await connection.createOffer());
2355
+ return connection.localDescription?.sdp;
2356
+ }).pipe(Effect.result);
2357
+ if (closed || turn !== turns) return;
2358
+ if (Result.isFailure(offer) || offer.success === void 0) {
2359
+ const cause = Result.isFailure(offer) ? offer.failure.cause : void 0;
2360
+ fall(cause instanceof Error ? cause.message : "WebRTC made no offer");
2361
+ return;
2362
+ }
2363
+ send({
2364
+ case: "rtcOffer",
2365
+ value: { sdp: offer.success }
2366
+ });
2367
+ const waiting = runFork(Effect.sleep(RTC_CONNECTS_WITHIN).pipe(Effect.andThen(Effect.sync(() => {
2368
+ if (turn === turns && connection.connectionState !== "connected") fall("WebRTC did not connect");
2369
+ }))));
2370
+ yield* Scope.addFinalizer(within, Effect.sync(() => waiting.interruptUnsafe()));
2371
+ });
2372
+ /** Ends however the picture comes. */
2373
+ const stop = Effect.fn("Session.stop")(function* () {
2374
+ turns += 1;
2375
+ const before = wayScope;
2376
+ wayScope = void 0;
2377
+ if (before !== void 0) yield* Scope.close(before, Exit.void);
2378
+ });
2379
+ /** Starts the picture the way it is to come, in place of however it came before. */
2380
+ const start = Effect.fn("Session.start")(function* () {
2381
+ yield* stop();
2382
+ const turn = turns;
2383
+ if (closed) return;
2384
+ const within = yield* Scope.fork(pictureScope);
2385
+ wayScope = within;
2386
+ updatePicture({
2387
+ way,
2388
+ status: void 0,
2389
+ rtc: void 0
2390
+ });
2391
+ yield* Scope.addFinalizer(within, Effect.sync(closeDecoder));
2392
+ yield* hello();
2393
+ if (closed || turn !== turns || way !== "video") return;
2394
+ yield* watchVideo(turn, within);
2395
+ });
2396
+ const answer = (sdp) => {
2397
+ const connection = peer?.connection;
2398
+ if (connection === void 0) return;
2399
+ connection.setRemoteDescription({
2400
+ type: "answer",
2401
+ sdp
2402
+ }).catch((cause) => {
2403
+ if (peer?.connection === connection) fall(cause instanceof Error ? cause.message : "WebRTC took no answer");
2404
+ });
2405
+ };
2406
+ const shown = (timeUs) => send({
2407
+ case: "videoShown",
2408
+ value: { timeUs }
2409
+ });
2410
+ const decodeFrame = (frame) => {
2411
+ const format = formatOf(frame.format);
2412
+ if (!(frame.tab === snapshot.selected && way === "frames") || format === void 0 || typeof VideoDecoder === "undefined") {
2413
+ shown(frame.timeUs);
2414
+ return;
2415
+ }
2416
+ if (decoder?.state !== "configured" || decodes !== format) {
2417
+ if (!frame.keyframe) {
2418
+ shown(frame.timeUs);
2419
+ return;
2420
+ }
2421
+ closeDecoder();
2422
+ const made = new VideoDecoder({
2423
+ output: (picture) => {
2424
+ surface.draw(picture, 0, 0, picture.displayWidth, picture.displayHeight);
2425
+ shown(BigInt(picture.timestamp));
2426
+ picture.close();
2427
+ },
2428
+ error: (error) => {
2429
+ if (decoder === made) fall(error.message);
2430
+ }
2431
+ });
2432
+ made.configure({
2433
+ codec: CODECS[format],
2434
+ optimizeForLatency: true
2435
+ });
2436
+ decoder = made;
2437
+ decodes = format;
2438
+ }
2439
+ try {
2440
+ decoder.decode(new EncodedVideoChunk({
2441
+ type: frame.keyframe ? "key" : "delta",
2442
+ timestamp: Number(frame.timeUs),
2443
+ data: frame.data
2444
+ }));
2445
+ } catch (cause) {
2446
+ shown(frame.timeUs);
2447
+ fall(cause instanceof Error ? cause.message : "a frame was not decoded");
2448
+ }
2449
+ };
2450
+ const tiles = yield* Queue.unbounded();
2451
+ const drawTile = Effect.fnUntraced(function* (tile) {
2452
+ const image = yield* Effect.tryPromise(() => createImageBitmap(new Blob([new Uint8Array(tile.png)], { type: "image/png" }))).pipe(Effect.catch((cause) => Effect.sync(() => console.warn("A tile of the session's picture was not decoded", cause))));
2453
+ if (image === void 0) return;
2454
+ if (tile.tab === snapshot.selected && way === "tiles") surface.draw(image, tile.x, tile.y, tile.width, tile.height);
2455
+ image.close();
2456
+ });
2457
+ runFork(Effect.forever(Queue.take(tiles).pipe(Effect.flatMap(drawTile))));
2458
+ /** What the session copied goes to the clipboard here, where the browser lets it. */
2459
+ const copied = (forms) => {
2460
+ if (forms.length === 0) return;
2461
+ runFork(Effect.promise(() => write(forms)).pipe(Effect.andThen((written) => Effect.sync(() => {
2462
+ for (const listener of clipboardListeners) listener({
2463
+ forms,
2464
+ written
2465
+ });
2466
+ }))));
2467
+ };
2468
+ const receive = (message) => {
2469
+ take(message);
2470
+ follow();
2471
+ tune();
2472
+ };
2473
+ let unmuting;
2474
+ /** Hears the watched tab unless it is muted here, and stops hearing as that changes. */
2475
+ const tune = () => {
2476
+ const target = watched();
2477
+ const on = snapshot.features.sound.read && target !== void 0 && !snapshot.muted.includes(target.tab);
2478
+ if (on === sounds) return;
2479
+ sounds = on;
2480
+ clearTimeout(unmuting);
2481
+ if (on) unmuting = setTimeout(() => sound.turn(sounds), SOUND_SETTLES_MS);
2482
+ else sound.turn(false);
2483
+ if (way !== "video" && socket.isOpen()) runFork(hello());
2484
+ };
2485
+ const take = (message) => {
2486
+ switch (message.case) {
2487
+ case "rtcAnswer":
2488
+ answer(message.value.sdp);
2489
+ break;
2490
+ case "rtcRefused":
2491
+ fall(message.value.reason);
2492
+ break;
2493
+ case "videoStatus":
2494
+ updatePicture({ status: statusOf(message.value) });
2495
+ break;
2496
+ case "failed": {
2497
+ const failure = failureOf(message.value);
2498
+ for (const listener of failureListeners) listener(failure);
2499
+ break;
2500
+ }
2501
+ case "pointer": {
2502
+ const pointer = pointerOf(message.value);
2503
+ for (const listener of pointerListeners) listener(pointer);
2504
+ break;
2505
+ }
2506
+ case "stroke": {
2507
+ const point = strokeOf(message.value);
2508
+ if (point !== void 0) for (const listener of strokeListeners) listener(point);
2509
+ break;
2510
+ }
2511
+ case "features":
2512
+ update({ features: featuresOf(message.value) });
2513
+ break;
2514
+ case "presence":
2515
+ update({ presence: presenceOf(message.value) });
2516
+ break;
2517
+ case "menu":
2518
+ update({ menu: {
2519
+ ...menuOf(message.value),
2520
+ ...menuAt
2521
+ } });
2522
+ break;
2523
+ case "clipboard":
2524
+ copied(message.value.forms.map(({ type, data }) => ({
2525
+ type,
2526
+ data
2527
+ })));
2528
+ break;
2529
+ case "downloads":
2530
+ update({ downloads: message.value.downloads.map(downloadOf) });
2531
+ break;
2532
+ case "fileRequests":
2533
+ update({ fileRequests: message.value.requests.map(fileRequestOf) });
2534
+ break;
2535
+ case "tile":
2536
+ if (typeof createImageBitmap !== "undefined") Queue.offerUnsafe(tiles, message.value);
2537
+ break;
2538
+ case "audio":
2539
+ if (way !== "video") sound.hear(message.value.timeUs, message.value.data);
2540
+ break;
2541
+ case "videoFrame":
2542
+ decodeFrame(message.value);
2543
+ break;
2544
+ case "targets":
2545
+ update({ targets: message.value.targets.map(targetOf) });
2546
+ break;
2547
+ case "selected":
2548
+ update({ selected: message.value.tab });
2549
+ break;
2550
+ case "cursor": {
2551
+ const { cursor } = message.value;
2552
+ const named = cursor.case === "named" && cursor.value !== "" ? cursor.value : "default";
2553
+ update({ cursor: cursor.case === "hidden" ? "none" : named });
2554
+ break;
2555
+ }
2556
+ }
2557
+ };
2558
+ /**
2559
+ * Whether the watched tab is this member's to size without being asked to: it holds the
2560
+ * tab, or nobody holds it and nobody else watches it. A tab has one size for everyone, so
2561
+ * a window that merely opens or changes its size does not take the tab from those at work
2562
+ * in it.
2563
+ */
2564
+ const free = () => {
2565
+ const target = watched();
2566
+ if (target === void 0) return false;
2567
+ const presence = snapshot.presence;
2568
+ if (presence === void 0) return true;
2569
+ const held = presence.held.find((one) => one.tab === target.tab);
2570
+ if (held !== void 0) return held.holder === presence.you;
2571
+ return !presence.members.some((one) => one.id !== presence.you && one.tab === target.tab);
2572
+ };
2573
+ /**
2574
+ * The target that was last fitted because it was this member's to size, and whether it
2575
+ * was shown as on a phone then: it is fitted another way once that changes.
2576
+ */
2577
+ let followed;
2578
+ /** Fits the watched target once it becomes this member's to size, and each one that does. */
2579
+ const follow = () => {
2580
+ const target = watched();
2581
+ const mine = fitting && target !== void 0 && free() ? `${target.tab} ${target.mobile}` : void 0;
2582
+ if (mine === followed) return;
2583
+ followed = mine;
2584
+ if (mine !== void 0) fit(false);
2585
+ };
2586
+ /**
2587
+ * Gives the watched target the size of the stage, while the viewport is to fit it.
2588
+ * `unasked` is for what no one chose just now, such as the window changing its size.
2589
+ */
2590
+ const fit = (unasked) => {
2591
+ const target = watched();
2592
+ if (!fitting || attached === void 0 || target === void 0) return;
2593
+ if (unasked && !free()) return;
2594
+ const { clientWidth, clientHeight } = attached.stage;
2595
+ if (clientWidth <= 0 || clientHeight <= 0) return;
2596
+ if (target.mobile) {
2597
+ if (snapshot.phone) {
2598
+ const scale = Math.min(Math.max(window.devicePixelRatio, 1), SHARPEST);
2599
+ send({
2600
+ case: "viewport",
2601
+ value: {
2602
+ width: clientWidth,
2603
+ height: clientHeight,
2604
+ scale
2605
+ }
2606
+ });
2607
+ } else if (target.mode === "auto") send({
2608
+ case: "lease",
2609
+ value: { action: LEASE_ACTIONS.take }
2610
+ });
2611
+ return;
2612
+ }
2613
+ const widened = Math.max(1, NARROWEST / clientWidth);
2614
+ send({
2615
+ case: "viewport",
2616
+ value: {
2617
+ width: Math.round(clientWidth * widened),
2618
+ height: Math.round(clientHeight * widened)
2619
+ }
2620
+ });
2621
+ };
2622
+ const listed = async (files) => {
2623
+ const uris = (await Promise.all(files.map((file) => Effect.runPromise(upload(address, file))))).map((file) => {
2624
+ return `${make$2`file://${segments(file.path)}`}\r\n`;
2625
+ });
2626
+ return textForm("text/uri-list", uris.join(""));
2627
+ };
2628
+ const wiring = {
2629
+ send,
2630
+ keyboard,
2631
+ way: () => way,
2632
+ watched,
2633
+ listed,
2634
+ menuAt: (at) => {
2635
+ menuAt = at;
2636
+ },
2637
+ dismissMenu: () => update({ menu: void 0 }),
2638
+ dragged: (by) => {
2639
+ for (const listener of draggedListeners) listener(by);
2640
+ },
2641
+ resized: () => fit(true),
2642
+ failed: (what, cause) => {
2643
+ runFork(Effect.logWarning(`${what} did not reach the session`, cause));
2644
+ }
2645
+ };
2646
+ const attach = Effect.fn("Session.attach")(function* (surfaces) {
2647
+ yield* Effect.acquireRelease(Effect.sync(() => {
2648
+ attached = surfaces;
2649
+ surface.attach(surfaces.canvas);
2650
+ surfaces.video.muted = true;
2651
+ surfaces.video.autoplay = true;
2652
+ surfaces.video.playsInline = true;
2653
+ surfaces.video.srcObject = stream ?? null;
2654
+ }), () => Effect.sync(() => {
2655
+ surfaces.video.srcObject = null;
2656
+ if (attached === surfaces) {
2657
+ attached = void 0;
2658
+ surface.detach();
2659
+ }
2660
+ }));
2661
+ yield* wire(surfaces, wiring);
2662
+ });
2663
+ const paste = Effect.fn("Session.paste")(function* (given) {
2664
+ const forms = given ?? (yield* Effect.tryPromise(() => read()).pipe(Effect.orElseSucceed(() => [])));
2665
+ if (forms.length === 0) return false;
2666
+ send({
2667
+ case: "clipboard",
2668
+ value: { forms: [...forms] }
2669
+ });
2670
+ keyboard.chord(KEY.v);
2671
+ return true;
2672
+ });
2673
+ const setPicture = (change) => {
2674
+ const { way: asked, ...changed } = change;
2675
+ settings = {
2676
+ ...settings,
2677
+ ...changed
2678
+ };
2679
+ updatePicture({ settings });
2680
+ if (!socket.isOpen()) {
2681
+ if (asked !== void 0 && ways.includes(asked)) {
2682
+ way = asked;
2683
+ updatePicture({ way });
2684
+ }
2685
+ return;
2686
+ }
2687
+ if (asked !== void 0 && asked !== way && ways.includes(asked)) {
2688
+ way = asked;
2689
+ runFork(start());
2690
+ return;
2691
+ }
2692
+ runFork(hello());
2693
+ };
2694
+ if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
2695
+ const coarse = window.matchMedia("(pointer: coarse)");
2696
+ const looked = () => {
2697
+ const phone = onPhone();
2698
+ if (phone === snapshot.phone) return;
2699
+ update({ phone });
2700
+ socket.send({
2701
+ case: "device",
2702
+ value: { phone }
2703
+ });
2704
+ followed = void 0;
2705
+ follow();
2706
+ };
2707
+ yield* Effect.acquireRelease(Effect.sync(() => {
2708
+ window.addEventListener("resize", looked);
2709
+ coarse.addEventListener("change", looked);
2710
+ }), () => Effect.sync(() => {
2711
+ window.removeEventListener("resize", looked);
2712
+ coarse.removeEventListener("change", looked);
2713
+ }));
2714
+ }
2715
+ yield* Effect.addFinalizer(() => Effect.sync(() => {
2716
+ closed = true;
2717
+ clearTimeout(unmuting);
2718
+ if (snapshot.connection.state !== "closed") update({ connection: { state: "closed" } });
2719
+ update({ menu: void 0 });
2720
+ }));
2721
+ return {
2722
+ store: {
2723
+ get: () => snapshot,
2724
+ subscribe
2725
+ },
2726
+ snapshot: Effect.sync(() => snapshot),
2727
+ changes: Stream.callback((queue) => Effect.acquireRelease(Effect.sync(() => {
2728
+ Queue.offerUnsafe(queue, snapshot);
2729
+ return subscribe(() => Queue.offerUnsafe(queue, snapshot));
2730
+ }), (unsubscribe) => Effect.sync(unsubscribe))),
2731
+ clipboard: Stream.callback((queue) => Effect.acquireRelease(Effect.sync(() => onClipboard((event) => Queue.offerUnsafe(queue, event))), (unsubscribe) => Effect.sync(unsubscribe))),
2732
+ onClipboard,
2733
+ failures: Stream.callback((queue) => Effect.acquireRelease(Effect.sync(() => onFailure((failure) => Queue.offerUnsafe(queue, failure))), (unsubscribe) => Effect.sync(unsubscribe))),
2734
+ onFailure,
2735
+ onDragged,
2736
+ onPointer: listening(pointerListeners),
2737
+ onStroke: listening(strokeListeners),
2738
+ follow: (member) => Effect.sync(() => send({
2739
+ case: "follow",
2740
+ value: member === void 0 ? {} : { member: BigInt(member) }
2741
+ })),
2742
+ draw: (stroke, phase, at) => Effect.sync(() => send({
2743
+ case: "draw",
2744
+ value: {
2745
+ stroke,
2746
+ phase: STROKE_PHASE[phase],
2747
+ x: at.x,
2748
+ y: at.y
2749
+ }
2750
+ })),
2751
+ point: (at) => Effect.sync(() => send({
2752
+ case: "pointing",
2753
+ value: at === void 0 ? {} : { at }
2754
+ })),
2755
+ select: (tab) => Effect.sync(() => send({
2756
+ case: "select",
2757
+ value: { tab }
2758
+ })),
2759
+ go: (to, { newTab = false } = {}) => Effect.sync(() => {
2760
+ const destination = "url" in to ? {
2761
+ case: "url",
2762
+ value: to.url
2763
+ } : {
2764
+ case: "along",
2765
+ value: ALONGS[to.along]
2766
+ };
2767
+ send({
2768
+ case: "go",
2769
+ value: {
2770
+ to: destination,
2771
+ newTab
2772
+ }
2773
+ });
2774
+ }),
2775
+ newTab: Effect.sync(() => send({
2776
+ case: "go",
2777
+ value: {
2778
+ to: {
2779
+ case: "url",
2780
+ value: ""
2781
+ },
2782
+ newTab: true
2783
+ }
2784
+ })),
2785
+ closeTab: (tab) => Effect.sync(() => send({
2786
+ case: "close",
2787
+ value: { tab }
2788
+ })),
2789
+ setViewport: (viewport, options) => Effect.sync(() => {
2790
+ fitting = viewport === "fit";
2791
+ update({ fit: fitting });
2792
+ if (viewport === "fit") {
2793
+ followed = void 0;
2794
+ if (options?.whenFree === true) follow();
2795
+ else fit(false);
2796
+ return;
2797
+ }
2798
+ const { width, height, scale } = viewport;
2799
+ send({
2800
+ case: "viewport",
2801
+ value: {
2802
+ width: pixels(width),
2803
+ height: pixels(height),
2804
+ scale
2805
+ }
2806
+ });
2807
+ }),
2808
+ setScale: (scale) => Effect.sync(() => {
2809
+ const target = watched();
2810
+ if (target !== void 0) {
2811
+ const { width, height } = target;
2812
+ send({
2813
+ case: "viewport",
2814
+ value: {
2815
+ width,
2816
+ height,
2817
+ scale
2818
+ }
2819
+ });
2820
+ }
2821
+ }),
2822
+ setMode: (mode) => Effect.sync(() => send({
2823
+ case: "setMode",
2824
+ value: { mode: PAGE_MODES[mode] }
2825
+ })),
2826
+ setPicture: (change) => Effect.sync(() => setPicture(change)),
2827
+ setMuted: (tab, muted) => Effect.sync(() => {
2828
+ const others = snapshot.muted.filter((one) => one !== tab);
2829
+ update({ muted: muted ? [...others, tab] : others });
2830
+ tune();
2831
+ }),
2832
+ lease: (action) => Effect.sync(() => send({
2833
+ case: "lease",
2834
+ value: { action: LEASE_ACTIONS[action] }
2835
+ })),
2836
+ attach,
2837
+ focus: Effect.sync(() => attached?.keys.focus({ preventScroll: true })),
2838
+ dismissMenu: Effect.sync(() => update({ menu: void 0 })),
2839
+ copyPicture: (url) => Effect.sync(() => send({
2840
+ case: "copyPicture",
2841
+ value: { url }
2842
+ })),
2843
+ writeClipboard: (forms) => Effect.sync(() => send({
2844
+ case: "clipboard",
2845
+ value: { forms: [...forms] }
2846
+ })),
2847
+ paste,
2848
+ copySelection: Effect.sync(() => keyboard.chord(KEY.c)),
2849
+ selectAll: Effect.sync(() => keyboard.chord(KEY.a)),
2850
+ copyHere: (forms) => Effect.promise(() => writeByHand(forms)),
2851
+ upload: (file, onProgress) => upload(address, file, onProgress),
2852
+ uploads: uploads(address),
2853
+ removeUpload: (name) => removeUpload(address, name),
2854
+ chooseFiles: (request, names) => Effect.sync(() => send({
2855
+ case: "filesChosen",
2856
+ value: {
2857
+ id: BigInt(request),
2858
+ files: [...names]
2859
+ }
2860
+ })),
2861
+ fileUrl: (path) => fileUrl(address, path),
2862
+ screenshotUrl: (tab, width) => screenshotUrl(address, tab, width),
2863
+ previewUrl: (tab) => previewUrl(address, tab),
2864
+ faviconUrl: (target) => {
2865
+ const site = /^https?:\/\/[^/?#]+/u.exec(target.url)?.[0];
2866
+ return site === void 0 ? void 0 : faviconUrl(address, target.tab, site);
2867
+ },
2868
+ recordings: {
2869
+ list: listRecordings(address),
2870
+ get: (id) => getRecording(address, id),
2871
+ start: (started) => startRecording(address, started),
2872
+ stop: (id) => stopRecording(address, id),
2873
+ retarget: (id, tab) => retargetRecording(address, id, tab),
2874
+ annotate: (annotation, id) => annotateRecording(address, annotation, id)
2875
+ },
2876
+ storageState: {
2877
+ export: (asked) => exportStorageState(address, asked),
2878
+ import: (state) => importStorageState(address, state)
2879
+ },
2880
+ screenshots: {
2881
+ list: listScreenshots(address),
2882
+ take: (tab) => takeScreenshot(address, tab)
2883
+ }
2884
+ };
2885
+ });
2886
+ /** One session's client, for programs that pass it along as a service. */
2887
+ var Session = class extends Context.Service()("@aperture-browser/session-client/Session") {};
2888
+ /** Connects to a session for as long as the layer lives. */
2889
+ const layer = (options) => Layer.effect(Session, make(options));
2890
+ /** The narrowest the session's browser makes a window: asked for less, it stays this wide. */
2891
+ const NARROWEST = 500;
2892
+ //#endregion
2893
+ export { live_pb_exports as a, KEYS as i, layer as n, http_exports as o, make as r, SessionError as s, Session as t };
2894
+
2895
+ //# sourceMappingURL=session-C7RtpAVE.js.map