@celljs/ta-host 4.17.0 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/node/app-commands.d.ts +1 -1
- package/esm/node/app-commands.js +46 -29
- package/esm/node/credentials.d.ts +12 -0
- package/esm/node/credentials.js +35 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/node/keep-awake.d.ts +3 -0
- package/esm/node/keep-awake.js +6 -1
- package/esm/node/package-hosts.d.ts +2 -0
- package/esm/node/package-hosts.js +6 -0
- package/esm/node/rooms-bridge.d.ts +10 -1
- package/esm/node/rooms-bridge.js +25 -0
- package/esm/node/screen-share/desktop-picture.d.ts +51 -0
- package/esm/node/screen-share/desktop-picture.js +133 -0
- package/esm/node/screen-share/desktop-session.d.ts +128 -0
- package/esm/node/screen-share/desktop-session.js +437 -0
- package/esm/node/screen-share/desktop-targets.d.ts +24 -0
- package/esm/node/screen-share/desktop-targets.js +80 -0
- package/esm/node/screen-share/desktop-viewer.d.ts +146 -0
- package/esm/node/screen-share/desktop-viewer.js +339 -0
- package/esm/node/screen-share/index.d.ts +8 -0
- package/esm/node/screen-share/index.js +9 -0
- package/esm/node/screen-share/rfb-client.d.ts +54 -0
- package/esm/node/screen-share/rfb-client.js +179 -0
- package/esm/node/screen-share/rfb-des.d.ts +11 -0
- package/esm/node/screen-share/rfb-des.js +143 -0
- package/esm/node/screen-share/rfb-encodings.d.ts +71 -0
- package/esm/node/screen-share/rfb-encodings.js +288 -0
- package/esm/node/screen-share/rfb-framebuffer.d.ts +16 -0
- package/esm/node/screen-share/rfb-framebuffer.js +53 -0
- package/esm/node/screen-share/rfb-protocol.d.ts +90 -0
- package/esm/node/screen-share/rfb-protocol.js +36 -0
- package/esm/node/screen-share/rfb-reader.d.ts +34 -0
- package/esm/node/screen-share/rfb-reader.js +110 -0
- package/esm/node/screen-share/rfb-security.d.ts +30 -0
- package/esm/node/screen-share/rfb-security.js +136 -0
- package/esm/node/screen-share/rfb-test-server.d.ts +37 -0
- package/esm/node/screen-share/rfb-test-server.js +116 -0
- package/esm/node/screen-share/screen-share-server-impl.d.ts +37 -0
- package/esm/node/screen-share/screen-share-server-impl.js +76 -0
- package/esm/node/screen-share/screen-shares.d.ts +123 -0
- package/esm/node/screen-share/screen-shares.js +463 -0
- package/esm/node/session-info-util.d.ts +10 -11
- package/esm/node/session-info-util.js +16 -94
- package/esm/node/settings-store.d.ts +1 -1
- package/esm/node/settings-store.js +7 -4
- package/esm/node/sign-in/access-store.d.ts +1 -1
- package/esm/node/sign-in/access-store.js +4 -1
- package/esm/node/sign-in/index.d.ts +2 -0
- package/esm/node/sign-in/index.js +2 -0
- package/esm/node/sign-in/polled-sign-in.d.ts +50 -0
- package/esm/node/sign-in/polled-sign-in.js +83 -0
- package/esm/node/sign-in/sign-in-devices.d.ts +55 -0
- package/esm/node/sign-in/sign-in-devices.js +113 -0
- package/esm/node/sign-in/sign-in-flow.d.ts +38 -4
- package/esm/node/sign-in/sign-in-flow.js +79 -4
- package/esm/node/sign-in/sign-in-pages.d.ts +8 -0
- package/esm/node/sign-in/sign-in-pages.js +137 -8
- package/esm/node/sign-in/sign-in-provider.d.ts +6 -0
- package/esm/node/sign-in/sign-in-provider.js +15 -0
- package/esm/node/sources-extension.d.ts +10 -0
- package/esm/node/sources-extension.js +18 -0
- package/esm/node/ta-server-impl.js +3 -3
- package/esm/node/ta-session-factory.js +2 -0
- package/esm/node/team/team-calls.js +27 -0
- package/esm/node/voice-bridge.d.ts +3 -1
- package/esm/node/voice-bridge.js +10 -3
- package/esm/node/voices-file.d.ts +5 -0
- package/esm/node/voices-file.js +14 -3
- package/esm/node/working-directory.d.ts +8 -2
- package/esm/node/working-directory.js +7 -0
- package/lib/node/app-commands.d.ts +1 -1
- package/lib/node/app-commands.js +46 -29
- package/lib/node/credentials.d.ts +13 -0
- package/lib/node/credentials.js +38 -0
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.js +2 -0
- package/lib/node/keep-awake.d.ts +3 -0
- package/lib/node/keep-awake.js +6 -1
- package/lib/node/package-hosts.d.ts +2 -0
- package/lib/node/package-hosts.js +6 -0
- package/lib/node/rooms-bridge.d.ts +10 -1
- package/lib/node/rooms-bridge.js +25 -0
- package/lib/node/screen-share/desktop-picture.d.ts +52 -0
- package/lib/node/screen-share/desktop-picture.js +136 -0
- package/lib/node/screen-share/desktop-session.d.ts +129 -0
- package/lib/node/screen-share/desktop-session.js +442 -0
- package/lib/node/screen-share/desktop-targets.d.ts +25 -0
- package/lib/node/screen-share/desktop-targets.js +84 -0
- package/lib/node/screen-share/desktop-viewer.d.ts +147 -0
- package/lib/node/screen-share/desktop-viewer.js +343 -0
- package/lib/node/screen-share/index.d.ts +9 -0
- package/lib/node/screen-share/index.js +25 -0
- package/lib/node/screen-share/rfb-client.d.ts +55 -0
- package/lib/node/screen-share/rfb-client.js +183 -0
- package/lib/node/screen-share/rfb-des.d.ts +12 -0
- package/lib/node/screen-share/rfb-des.js +146 -0
- package/lib/node/screen-share/rfb-encodings.d.ts +72 -0
- package/lib/node/screen-share/rfb-encodings.js +295 -0
- package/lib/node/screen-share/rfb-framebuffer.d.ts +17 -0
- package/lib/node/screen-share/rfb-framebuffer.js +57 -0
- package/lib/node/screen-share/rfb-protocol.d.ts +91 -0
- package/lib/node/screen-share/rfb-protocol.js +39 -0
- package/lib/node/screen-share/rfb-reader.d.ts +35 -0
- package/lib/node/screen-share/rfb-reader.js +115 -0
- package/lib/node/screen-share/rfb-security.d.ts +31 -0
- package/lib/node/screen-share/rfb-security.js +141 -0
- package/lib/node/screen-share/rfb-test-server.d.ts +38 -0
- package/lib/node/screen-share/rfb-test-server.js +120 -0
- package/lib/node/screen-share/screen-share-server-impl.d.ts +38 -0
- package/lib/node/screen-share/screen-share-server-impl.js +79 -0
- package/lib/node/screen-share/screen-shares.d.ts +124 -0
- package/lib/node/screen-share/screen-shares.js +464 -0
- package/lib/node/session-info-util.d.ts +10 -11
- package/lib/node/session-info-util.js +15 -93
- package/lib/node/settings-store.d.ts +1 -1
- package/lib/node/settings-store.js +6 -3
- package/lib/node/sign-in/access-store.d.ts +1 -1
- package/lib/node/sign-in/access-store.js +4 -1
- package/lib/node/sign-in/index.d.ts +2 -0
- package/lib/node/sign-in/index.js +2 -0
- package/lib/node/sign-in/polled-sign-in.d.ts +51 -0
- package/lib/node/sign-in/polled-sign-in.js +87 -0
- package/lib/node/sign-in/sign-in-devices.d.ts +56 -0
- package/lib/node/sign-in/sign-in-devices.js +117 -0
- package/lib/node/sign-in/sign-in-flow.d.ts +38 -4
- package/lib/node/sign-in/sign-in-flow.js +80 -5
- package/lib/node/sign-in/sign-in-pages.d.ts +8 -0
- package/lib/node/sign-in/sign-in-pages.js +136 -7
- package/lib/node/sign-in/sign-in-provider.d.ts +6 -0
- package/lib/node/sign-in/sign-in-provider.js +15 -0
- package/lib/node/sources-extension.d.ts +11 -0
- package/lib/node/sources-extension.js +22 -0
- package/lib/node/ta-server-impl.js +2 -2
- package/lib/node/ta-session-factory.js +2 -0
- package/lib/node/team/team-calls.js +27 -0
- package/lib/node/voice-bridge.d.ts +3 -1
- package/lib/node/voice-bridge.js +9 -2
- package/lib/node/voices-file.d.ts +5 -0
- package/lib/node/voices-file.js +14 -3
- package/lib/node/working-directory.d.ts +8 -2
- package/lib/node/working-directory.js +7 -0
- package/package.json +14 -10
|
@@ -21,7 +21,7 @@ export interface AppCommandAccess {
|
|
|
21
21
|
* Whether `principal` agrees, on a screen of theirs, to a danger action asked for by the run of `sessionFile`;
|
|
22
22
|
* undefined when they have no page open to ask on.
|
|
23
23
|
*/
|
|
24
|
-
confirm?(principal: string, what: string, sessionFile?: string): Promise<boolean | undefined>;
|
|
24
|
+
confirm?(principal: string, what: string, sessionFile?: string, detail?: string): Promise<boolean | undefined>;
|
|
25
25
|
}
|
|
26
26
|
type Json = Record<string, unknown>;
|
|
27
27
|
/** The actions by id, and who may run them: pure, for TaAppCommandsImpl and its tests. */
|
package/esm/node/app-commands.js
CHANGED
|
@@ -61,8 +61,8 @@ export class AppCommandRegistry {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
async run(id, input = {}, options = {}) {
|
|
64
|
-
var _a, _b, _c;
|
|
65
|
-
var
|
|
64
|
+
var _a, _b, _c, _d;
|
|
65
|
+
var _e, _f;
|
|
66
66
|
const command = (_a = this.commands.get(id)) === null || _a === void 0 ? void 0 : _a.command;
|
|
67
67
|
if (!command) {
|
|
68
68
|
throw TaErrors.invalidArgument(`There is no action ${JSON.stringify(id)}.`, 'See app_commands for the actions there are.');
|
|
@@ -75,10 +75,12 @@ export class AppCommandRegistry {
|
|
|
75
75
|
if (refused) {
|
|
76
76
|
throw TaErrors.invalidArgument(`Who asked this may not do ${id} (${command.action}).`, 'Ask the owner of this Ta to let them, or to do it.');
|
|
77
77
|
}
|
|
78
|
-
const principal = (
|
|
78
|
+
const principal = (_e = principals.find(one => one !== TA_OWNER)) !== null && _e !== void 0 ? _e : TA_OWNER;
|
|
79
|
+
const context = { principal, language: this.language(), ...(options.sessionFile ? { sessionFile: options.sessionFile } : {}) };
|
|
79
80
|
// What cannot be undone, or acts for the user, waits for them to agree on their screen; a page's tap is theirs already.
|
|
80
81
|
if (command.risk === 'danger' && !options.principal) {
|
|
81
|
-
const
|
|
82
|
+
const detail = await ((_b = command.detail) === null || _b === void 0 ? void 0 : _b.call(command, input, context));
|
|
83
|
+
const agreed = await ((_d = (_c = this.access).confirm) === null || _d === void 0 ? void 0 : _d.call(_c, principal, (_f = command.title[context.language]) !== null && _f !== void 0 ? _f : command.title['en-US'], options.sessionFile, detail));
|
|
82
84
|
if (agreed === undefined) {
|
|
83
85
|
throw TaErrors.invalidArgument(`${id} needs the user to agree on their screen, and no page of Ta is open.`, 'Tell the user to open Ta, or to do it themselves.');
|
|
84
86
|
}
|
|
@@ -86,11 +88,7 @@ export class AppCommandRegistry {
|
|
|
86
88
|
throw TaErrors.invalidArgument(`The user did not agree to ${id}.`, 'Do not do it another way; ask them what they want instead.');
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
|
-
return command.run(input,
|
|
90
|
-
principal,
|
|
91
|
-
language: this.language(),
|
|
92
|
-
...(options.sessionFile ? { sessionFile: options.sessionFile } : {}),
|
|
93
|
-
});
|
|
91
|
+
return command.run(input, context);
|
|
94
92
|
}
|
|
95
93
|
/** Each who asked: the principal given, or those of the run of the conversation; the owner for a run nobody asked. */
|
|
96
94
|
principals(options) {
|
|
@@ -431,34 +429,53 @@ export var CoreAppCommands;
|
|
|
431
429
|
return {
|
|
432
430
|
id: 'asks.answer',
|
|
433
431
|
title: words('Answer for you', '替你回答', '替你回答', 'あなたの代わりに回答'),
|
|
434
|
-
description: "Answers what waits for the user (asks.list) with what the user said: file of the conversation; answer: one of a dialog's choices (or its number), yes or no for a confirmation, any text for an input or a question. Only what the user said: never decide for them.",
|
|
432
|
+
description: "Answers what waits for the user (asks.list) with what the user said: file of the conversation; answer: one of a dialog's choices (or its number), yes or no for a confirmation, any text for an input or a question. Only what the user said: never decide for them. The user agrees on their screen before it is answered.",
|
|
435
433
|
input: { type: 'object', properties: { file: { type: 'string' }, answer: { type: 'string' } }, required: ['file', 'answer'] },
|
|
436
|
-
|
|
434
|
+
// It may answer a confirmation of another conversation (delete, publish): the user agrees on their screen first.
|
|
435
|
+
risk: 'danger',
|
|
437
436
|
action: 'chat.send',
|
|
437
|
+
detail: async (input, context) => {
|
|
438
|
+
const { ask, said } = await answering(deps, input, context.language);
|
|
439
|
+
return `${ask.name}:${ask.question} → ${said}`;
|
|
440
|
+
},
|
|
438
441
|
run: async (input, context) => {
|
|
439
|
-
const ask =
|
|
440
|
-
if (!ask) {
|
|
441
|
-
throw TaErrors.invalidArgument('That conversation waits for nothing.', 'See asks.list for what waits.');
|
|
442
|
-
}
|
|
442
|
+
const { ask, response, said } = await answering(deps, input, context.language);
|
|
443
443
|
const notice = TaLanguageUtil.pick(context.language, words('Answered for you', '替你回答了', '替你回答了', 'あなたの代わりに回答しました'));
|
|
444
|
-
if (ask.dialog && ask.sessionId) {
|
|
445
|
-
const response = answerOf(ask.dialog, input.answer);
|
|
446
|
-
if (!response) {
|
|
447
|
-
throw TaErrors.invalidArgument(`"${String(input.answer)}" does not answer it${ask.choices ? `: it takes one of ${ask.choices.join(', ')}` : ''}.`, 'Ask the user again.');
|
|
448
|
-
}
|
|
444
|
+
if (response && ask.dialog && ask.sessionId) {
|
|
449
445
|
await deps.respondUi(ask.sessionId, { type: 'extension_ui_response', id: ask.dialog.id, ...response });
|
|
450
|
-
const said = 'value' in response ? response.value : TaAppUtil.shown(response.confirmed, context.language);
|
|
451
446
|
return { text: `Answered ${ask.name}: ${said}.`, notice, changes: [{ label: ask.question, after: said }] };
|
|
452
447
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
throw TaErrors.invalidArgument('answer is what the user said.', 'Pass their words.');
|
|
456
|
-
}
|
|
457
|
-
await deps.send(ask.file, ask.cwd, text);
|
|
458
|
-
return { text: `Told ${ask.name}: ${text}`, notice, changes: [{ label: ask.question, after: text }] };
|
|
448
|
+
await deps.send(ask.file, ask.cwd, said);
|
|
449
|
+
return { text: `Told ${ask.name}: ${said}`, notice, changes: [{ label: ask.question, after: said }] };
|
|
459
450
|
},
|
|
460
451
|
};
|
|
461
452
|
}
|
|
453
|
+
/** What asks.answer would answer, and how, as the user reads it; throws for what waits for nothing or no answer of it. */
|
|
454
|
+
async function answering(deps, input, language) {
|
|
455
|
+
const ask = (await asks(deps)).find(one => one.file === input.file);
|
|
456
|
+
if (!ask) {
|
|
457
|
+
throw TaErrors.invalidArgument('That conversation waits for nothing.', 'See asks.list for what waits.');
|
|
458
|
+
}
|
|
459
|
+
if (ask.dialog && ask.sessionId) {
|
|
460
|
+
const response = answerOf(ask.dialog, input.answer);
|
|
461
|
+
if (!response) {
|
|
462
|
+
throw TaErrors.invalidArgument(`"${String(input.answer)}" does not answer it${ask.choices ? `: it takes one of ${ask.choices.join(', ')}` : ''}.`, 'Ask the user again.');
|
|
463
|
+
}
|
|
464
|
+
if ('value' in response) {
|
|
465
|
+
return { ask, response, said: response.value };
|
|
466
|
+
}
|
|
467
|
+
return {
|
|
468
|
+
ask,
|
|
469
|
+
response,
|
|
470
|
+
said: TaLanguageUtil.pick(language, response.confirmed ? words('yes', '是', '是', 'はい') : words('no', '否', '否', 'いいえ')),
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
const text = typeof input.answer === 'string' ? input.answer.trim() : '';
|
|
474
|
+
if (!text) {
|
|
475
|
+
throw TaErrors.invalidArgument('answer is what the user said.', 'Pass their words.');
|
|
476
|
+
}
|
|
477
|
+
return { ask, said: text };
|
|
478
|
+
}
|
|
462
479
|
function onOff(on, language) {
|
|
463
480
|
return TaAppUtil.shown(on, language);
|
|
464
481
|
}
|
|
@@ -557,12 +574,12 @@ let TaAppCommandsImpl = class TaAppCommandsImpl {
|
|
|
557
574
|
can: (principal, action) => team().can(principal, action),
|
|
558
575
|
actorsOf: file => team().actorsOf(file),
|
|
559
576
|
current: () => team().current(),
|
|
560
|
-
confirm: async (principal, what, sessionFile) => {
|
|
577
|
+
confirm: async (principal, what, sessionFile, detail) => {
|
|
561
578
|
if (!this.pages.has(principal, TA_PAGE_CONFIRM)) {
|
|
562
579
|
return undefined;
|
|
563
580
|
}
|
|
564
581
|
const session = sessionFile ? (await this.server.listSessions()).find(one => one.sessionFile === sessionFile) : undefined;
|
|
565
|
-
const ask = { who: (session === null || session === void 0 ? void 0 : session.sessionName) || (session === null || session === void 0 ? void 0 : session.firstMessage) || 'Ta', what };
|
|
582
|
+
const ask = { who: (session === null || session === void 0 ? void 0 : session.sessionName) || (session === null || session === void 0 ? void 0 : session.firstMessage) || 'Ta', what, ...(detail ? { detail } : {}) };
|
|
566
583
|
return (await this.pages.ask(principal, TA_PAGE_CONFIRM, ask, CONFIRM_MS)) === true;
|
|
567
584
|
},
|
|
568
585
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TaCredentialStore, TaExtensionCredentials } from '@celljs/ta-protocol';
|
|
2
|
+
/**
|
|
3
|
+
* The store of the sign-ins Ta gives by itself (TaExtensionHost.credentials): a package registers it (the vault of
|
|
4
|
+
* ta-secrets); without one, nothing is kept and every sign-in is asked.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TaCredentials {
|
|
7
|
+
protected registered?: TaCredentialStore;
|
|
8
|
+
/** The store there is now; undefined while no package keeps sign-ins. */
|
|
9
|
+
get store(): TaCredentialStore | undefined;
|
|
10
|
+
/** For the server side of packages (TaExtensionHost.credentials). */
|
|
11
|
+
readonly extension: TaExtensionCredentials;
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Component } from '@celljs/core';
|
|
8
|
+
/**
|
|
9
|
+
* The store of the sign-ins Ta gives by itself (TaExtensionHost.credentials): a package registers it (the vault of
|
|
10
|
+
* ta-secrets); without one, nothing is kept and every sign-in is asked.
|
|
11
|
+
*/
|
|
12
|
+
let TaCredentials = class TaCredentials {
|
|
13
|
+
constructor() {
|
|
14
|
+
/** For the server side of packages (TaExtensionHost.credentials). */
|
|
15
|
+
this.extension = {
|
|
16
|
+
register: store => {
|
|
17
|
+
this.registered = store;
|
|
18
|
+
return () => {
|
|
19
|
+
if (this.registered === store) {
|
|
20
|
+
this.registered = undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** The store there is now; undefined while no package keeps sign-ins. */
|
|
27
|
+
get store() {
|
|
28
|
+
return this.registered;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
TaCredentials = __decorate([
|
|
32
|
+
Component()
|
|
33
|
+
], TaCredentials);
|
|
34
|
+
export { TaCredentials };
|
|
35
|
+
//# sourceMappingURL=credentials.js.map
|
package/esm/node/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './app-commands.js';
|
|
|
2
2
|
export * from './auth-server-impl.js';
|
|
3
3
|
export * from './client-channel.js';
|
|
4
4
|
export * from './client-tool-broker.js';
|
|
5
|
+
export * from './credentials.js';
|
|
5
6
|
export * from './directory-relocator.js';
|
|
6
7
|
export * from './event-log.js';
|
|
7
8
|
export * from './exec-endpoint.js';
|
|
@@ -24,6 +25,7 @@ export * from './relay-bridge.js';
|
|
|
24
25
|
export * from './remote/index.js';
|
|
25
26
|
export * from './remote-ui-context.js';
|
|
26
27
|
export * from './rooms-bridge.js';
|
|
28
|
+
export * from './screen-share/index.js';
|
|
27
29
|
export * from './serve-updates.js';
|
|
28
30
|
export * from './session-catalog.js';
|
|
29
31
|
export * from './session-files.js';
|
package/esm/node/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './app-commands.js';
|
|
|
2
2
|
export * from './auth-server-impl.js';
|
|
3
3
|
export * from './client-channel.js';
|
|
4
4
|
export * from './client-tool-broker.js';
|
|
5
|
+
export * from './credentials.js';
|
|
5
6
|
export * from './directory-relocator.js';
|
|
6
7
|
export * from './event-log.js';
|
|
7
8
|
export * from './exec-endpoint.js';
|
|
@@ -24,6 +25,7 @@ export * from './relay-bridge.js';
|
|
|
24
25
|
export * from './remote/index.js';
|
|
25
26
|
export * from './remote-ui-context.js';
|
|
26
27
|
export * from './rooms-bridge.js';
|
|
28
|
+
export * from './screen-share/index.js';
|
|
27
29
|
export * from './serve-updates.js';
|
|
28
30
|
export * from './session-catalog.js';
|
|
29
31
|
export * from './session-files.js';
|
package/esm/node/keep-awake.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type ChildProcess } from 'node:child_process';
|
|
|
2
2
|
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
3
3
|
import { KeepAwake, TaSessionRegistry } from './host-protocol.js';
|
|
4
4
|
import { type RelayBridge } from './relay-bridge.js';
|
|
5
|
+
import { ScreenShares } from './screen-share/screen-shares.js';
|
|
5
6
|
/** What KeepAwakeUtil.wanted weighs. */
|
|
6
7
|
export interface KeepAwakeState {
|
|
7
8
|
/** Not turned off (RelayConfig.keepAwake). */
|
|
@@ -30,6 +31,8 @@ export declare namespace KeepAwakeUtil {
|
|
|
30
31
|
export declare class KeepAwakeImpl implements KeepAwake, ApplicationLifecycle<Application> {
|
|
31
32
|
protected readonly bridge: RelayBridge;
|
|
32
33
|
protected readonly sessions: TaSessionRegistry;
|
|
34
|
+
/** A page looking at a desktop keeps the computer awake as a session that runs does. */
|
|
35
|
+
protected readonly desktops: ScreenShares;
|
|
33
36
|
protected deviceAt: number;
|
|
34
37
|
protected timer?: ReturnType<typeof setInterval>;
|
|
35
38
|
protected child?: ChildProcess;
|
package/esm/node/keep-awake.js
CHANGED
|
@@ -11,6 +11,7 @@ import { spawn } from 'node:child_process';
|
|
|
11
11
|
import { ApplicationLifecycle, Autowired, Component } from '@celljs/core';
|
|
12
12
|
import { KeepAwake, TaSessionRegistry } from './host-protocol.js';
|
|
13
13
|
import { RELAY_BRIDGE } from './relay-bridge.js';
|
|
14
|
+
import { ScreenShares } from './screen-share/screen-shares.js';
|
|
14
15
|
export var KeepAwakeUtil;
|
|
15
16
|
(function (KeepAwakeUtil) {
|
|
16
17
|
/** How long after a device left the computer stays awake: a phone put away a while comes back to a Ta that answers. */
|
|
@@ -75,7 +76,7 @@ let KeepAwakeImpl = class KeepAwakeImpl {
|
|
|
75
76
|
if (this.bridge.devicesOpen > 0) {
|
|
76
77
|
this.deviceAt = now;
|
|
77
78
|
}
|
|
78
|
-
const running = this.sessions.list().some(session => session.pi.isStreaming);
|
|
79
|
+
const running = this.sessions.list().some(session => session.pi.isStreaming) || this.desktops.watched;
|
|
79
80
|
const enabled = this.bridge.store.read().keepAwake !== false;
|
|
80
81
|
if (KeepAwakeUtil.wanted({ enabled, running, deviceAt: this.deviceAt, now })) {
|
|
81
82
|
this.hold();
|
|
@@ -121,6 +122,10 @@ __decorate([
|
|
|
121
122
|
Autowired(TaSessionRegistry),
|
|
122
123
|
__metadata("design:type", Object)
|
|
123
124
|
], KeepAwakeImpl.prototype, "sessions", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
Autowired(ScreenShares),
|
|
127
|
+
__metadata("design:type", ScreenShares)
|
|
128
|
+
], KeepAwakeImpl.prototype, "desktops", void 0);
|
|
124
129
|
KeepAwakeImpl = __decorate([
|
|
125
130
|
Component([KeepAwake, ApplicationLifecycle])
|
|
126
131
|
], KeepAwakeImpl);
|
|
@@ -2,6 +2,7 @@ import { type CodingAgentOptions } from '@celljs/ai-coding-agent';
|
|
|
2
2
|
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
3
3
|
import { type TaExtensionHost, type TaHostAnswer, type TaHostSessionEvent, TaPackageServer, type TaPackageService, TaServer } from '@celljs/ta-protocol';
|
|
4
4
|
import { TaAppCommands } from './app-commands.js';
|
|
5
|
+
import { TaCredentials } from './credentials.js';
|
|
5
6
|
import { ExtensionDataStore } from './extension-data.js';
|
|
6
7
|
import { TaPresenceBook, TaSessionRegistry } from './host-protocol.js';
|
|
7
8
|
import { TaPageBook } from './page-book.js';
|
|
@@ -58,6 +59,7 @@ export declare class PackageHostsImpl implements PackageHosts, ApplicationLifecy
|
|
|
58
59
|
protected readonly relay: RelayBridge;
|
|
59
60
|
protected readonly roomsBridge: RoomsBridge;
|
|
60
61
|
protected readonly voiceBridge: VoiceBridge;
|
|
62
|
+
protected readonly credentials: TaCredentials;
|
|
61
63
|
protected readonly settings: TaSettingsStore;
|
|
62
64
|
protected readonly sessions: TaSessionRegistry;
|
|
63
65
|
protected readonly presenceBook: TaPresenceBook;
|
|
@@ -17,6 +17,7 @@ import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
|
17
17
|
import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
|
|
18
18
|
import { TaMessageSource, TaPackageServer, TaServer, } from '@celljs/ta-protocol';
|
|
19
19
|
import { TaAppCommands } from './app-commands.js';
|
|
20
|
+
import { TaCredentials } from './credentials.js';
|
|
20
21
|
import { ExtensionDataStore } from './extension-data.js';
|
|
21
22
|
import { TaPresenceBook, TaSessionRegistry } from './host-protocol.js';
|
|
22
23
|
import { TaPageBook } from './page-book.js';
|
|
@@ -200,6 +201,7 @@ let PackageHostsImpl = class PackageHostsImpl {
|
|
|
200
201
|
rooms: this.roomsBridge.rooms,
|
|
201
202
|
relays: this.relay.extensionRelays,
|
|
202
203
|
voices: this.voiceBridge.extensionVoices,
|
|
204
|
+
credentials: this.credentials.extension,
|
|
203
205
|
sessionMessages: file => this.sessionMessages(file),
|
|
204
206
|
sessionRole: async (file) => SessionCatalogUtil.roleOf((await PiSdkUtil.load()).SessionManager.open(file).getEntries()),
|
|
205
207
|
createSession: (cwd, messages, name) => this.createSession(cwd, messages, name),
|
|
@@ -300,6 +302,10 @@ __decorate([
|
|
|
300
302
|
Autowired({ id: VOICE_BRIDGE, detached: true }),
|
|
301
303
|
__metadata("design:type", Function)
|
|
302
304
|
], PackageHostsImpl.prototype, "voiceBridge", void 0);
|
|
305
|
+
__decorate([
|
|
306
|
+
Autowired(TaCredentials),
|
|
307
|
+
__metadata("design:type", TaCredentials)
|
|
308
|
+
], PackageHostsImpl.prototype, "credentials", void 0);
|
|
303
309
|
__decorate([
|
|
304
310
|
Autowired({ id: TaSettingsStore, detached: true }),
|
|
305
311
|
__metadata("design:type", Object)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
2
2
|
import { type RpcConnection } from '@celljs/rpc/lib/node';
|
|
3
|
-
import { type TaFriend, type TaFriendRequest, type TaIdentity, type TaRoomEvent, type TaRoomInfo, type TaRoomRequest, TaRoomServer, type TaRooms, type TaRoomValue, type TaRoomWatch } from '@celljs/ta-protocol';
|
|
3
|
+
import { type TaFriend, type TaFriendRequest, type TaFriendShare, type TaGroupInvite, type TaIdentity, type TaRoomEvent, type TaRoomInfo, type TaRoomRequest, TaRoomServer, type TaRooms, type TaRoomValue, type TaRoomWatch } from '@celljs/ta-protocol';
|
|
4
4
|
import type { RelayHubs } from '@celljs/ta-relay/lib/node';
|
|
5
5
|
import { ExtensionDataStore } from './extension-data.js';
|
|
6
6
|
import { type RelayBridge } from './relay-bridge.js';
|
|
@@ -70,6 +70,15 @@ export declare class TaRoomServerImpl implements TaRoomServer {
|
|
|
70
70
|
}>;
|
|
71
71
|
addFriend(link: string): Promise<void>;
|
|
72
72
|
offerFriend(room: string, member: string): Promise<void>;
|
|
73
|
+
inviteFriends(room: string, friends: string[]): Promise<number>;
|
|
74
|
+
listGroupInvites(): Promise<TaGroupInvite[]>;
|
|
75
|
+
answerGroupInvite(room: string, accept: boolean): Promise<void>;
|
|
76
|
+
sendToFriends(friends: string[], item: {
|
|
77
|
+
link: string;
|
|
78
|
+
title: string;
|
|
79
|
+
}): Promise<number>;
|
|
80
|
+
listFriendShares(): Promise<TaFriendShare[]>;
|
|
81
|
+
answerFriendShare(id: string, keep: boolean): Promise<void>;
|
|
73
82
|
listFriendRequests(): Promise<TaFriendRequest[]>;
|
|
74
83
|
answerFriend(id: string, accept: boolean): Promise<void>;
|
|
75
84
|
removeFriend(id: string): Promise<boolean>;
|
package/esm/node/rooms-bridge.js
CHANGED
|
@@ -45,6 +45,12 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
45
45
|
friendLink: renew => this.hubs.friendLink(renew === true),
|
|
46
46
|
addFriend: link => this.hubs.addFriend(link),
|
|
47
47
|
offerFriend: (room, member) => this.hubs.offerFriend(room, member),
|
|
48
|
+
inviteFriends: (room, friends) => this.hubs.inviteFriends(room, friends),
|
|
49
|
+
listGroupInvites: () => this.hubs.groupInvites(),
|
|
50
|
+
answerGroupInvite: (room, accept) => this.hubs.answerGroupInvite(room, accept),
|
|
51
|
+
sendToFriends: (friends, item) => this.hubs.sendToFriends(friends, item),
|
|
52
|
+
listFriendShares: () => this.hubs.friendShares(),
|
|
53
|
+
answerFriendShare: async (id, keep) => this.hubs.answerFriendShare(id, keep),
|
|
48
54
|
listFriendRequests: async () => this.hubs.friendRequests(),
|
|
49
55
|
answerFriend: (id, accept) => this.hubs.answerFriend(id, accept),
|
|
50
56
|
removeFriend: id => this.hubs.removeFriend(id),
|
|
@@ -177,6 +183,25 @@ let TaRoomServerImpl = class TaRoomServerImpl {
|
|
|
177
183
|
offerFriend(room, member) {
|
|
178
184
|
return TaErrors.guard(() => this.rooms.offerFriend(room, member));
|
|
179
185
|
}
|
|
186
|
+
inviteFriends(room, friends) {
|
|
187
|
+
return TaErrors.guard(() => this.rooms.inviteFriends(room, Array.isArray(friends) ? friends.map(String) : []));
|
|
188
|
+
}
|
|
189
|
+
listGroupInvites() {
|
|
190
|
+
return TaErrors.guard(() => this.rooms.listGroupInvites());
|
|
191
|
+
}
|
|
192
|
+
answerGroupInvite(room, accept) {
|
|
193
|
+
return TaErrors.guard(() => this.rooms.answerGroupInvite(room, accept === true));
|
|
194
|
+
}
|
|
195
|
+
sendToFriends(friends, item) {
|
|
196
|
+
const ids = Array.isArray(friends) ? friends.map(String) : [];
|
|
197
|
+
return TaErrors.guard(() => { var _a, _b; return this.rooms.sendToFriends(ids, { link: String((_a = item === null || item === void 0 ? void 0 : item.link) !== null && _a !== void 0 ? _a : ''), title: String((_b = item === null || item === void 0 ? void 0 : item.title) !== null && _b !== void 0 ? _b : '') }); });
|
|
198
|
+
}
|
|
199
|
+
listFriendShares() {
|
|
200
|
+
return TaErrors.guard(() => this.rooms.listFriendShares());
|
|
201
|
+
}
|
|
202
|
+
answerFriendShare(id, keep) {
|
|
203
|
+
return TaErrors.guard(() => this.rooms.answerFriendShare(String(id), keep === true));
|
|
204
|
+
}
|
|
180
205
|
listFriendRequests() {
|
|
181
206
|
return TaErrors.guard(() => this.rooms.listFriendRequests());
|
|
182
207
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { RfbFramebuffer } from './rfb-framebuffer.js';
|
|
2
|
+
import type { RfbRect } from './rfb-protocol.js';
|
|
3
|
+
/** The side of a tile of a view, in its pixels: each changed tile goes as a JPEG of its own. */
|
|
4
|
+
export declare const DESKTOP_TILE = 128;
|
|
5
|
+
/** The most a view may be on a side, whatever a page asks. */
|
|
6
|
+
export declare const DESKTOP_MAX_VIEW = 4096;
|
|
7
|
+
/** What part of the framebuffer a page looks at, in how many of its pixels. */
|
|
8
|
+
export interface DesktopViewSize {
|
|
9
|
+
rect: RfbRect;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export declare namespace DesktopPicture {
|
|
14
|
+
/**
|
|
15
|
+
* The view a page asked for, made safe: a part inside the framebuffer (all of it by default), drawn in at most as
|
|
16
|
+
* many pixels as it has (the page scales up itself) and at most DESKTOP_MAX_VIEW, keeping its proportions.
|
|
17
|
+
*/
|
|
18
|
+
function fit(framebuffer: {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}, asked: {
|
|
22
|
+
rect?: RfbRect;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}): DesktopViewSize;
|
|
26
|
+
/** The tiles of a view (columns, rows). */
|
|
27
|
+
function grid(view: DesktopViewSize): {
|
|
28
|
+
columns: number;
|
|
29
|
+
rows: number;
|
|
30
|
+
};
|
|
31
|
+
/** The tiles a changed part of the framebuffer touches, as indices of the grid of the view. */
|
|
32
|
+
function touched(view: DesktopViewSize, changed: RfbRect): number[];
|
|
33
|
+
/**
|
|
34
|
+
* The pixels of a tile of the view, RGBA: each the average of the pixels of the framebuffer it covers (at most 4
|
|
35
|
+
* by 4 of them, evenly spread), so that text scaled down stays readable rather than broken up.
|
|
36
|
+
*/
|
|
37
|
+
function sample(framebuffer: RfbFramebuffer, view: DesktopViewSize, tile: RfbRect): Uint8Array;
|
|
38
|
+
/** The rectangle of a tile of the grid, in the pixels of the view. */
|
|
39
|
+
function tileRect(view: DesktopViewSize, index: number): RfbRect;
|
|
40
|
+
/**
|
|
41
|
+
* The tiles as JPEGs, in base64. Encoding a whole screen takes about 90 ms of a core, so it yields to the event loop
|
|
42
|
+
* every SLICE_MS; `still` says whether the view is still the one asked for, and stops when it is not.
|
|
43
|
+
*/
|
|
44
|
+
function encode(framebuffer: RfbFramebuffer, view: DesktopViewSize, tiles: number[], quality: number, still?: () => boolean): Promise<{
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
w: number;
|
|
48
|
+
h: number;
|
|
49
|
+
jpeg: string;
|
|
50
|
+
}[]>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { JpegEncoder } from '../jpeg-encoder.js';
|
|
2
|
+
/** The side of a tile of a view, in its pixels: each changed tile goes as a JPEG of its own. */
|
|
3
|
+
export const DESKTOP_TILE = 128;
|
|
4
|
+
/** The most a view may be on a side, whatever a page asks. */
|
|
5
|
+
export const DESKTOP_MAX_VIEW = 4096;
|
|
6
|
+
/** Work done between two turns of the event loop while tiles are encoded: sessions and terminals go on meanwhile. */
|
|
7
|
+
const SLICE_MS = 8;
|
|
8
|
+
export var DesktopPicture;
|
|
9
|
+
(function (DesktopPicture) {
|
|
10
|
+
/**
|
|
11
|
+
* The view a page asked for, made safe: a part inside the framebuffer (all of it by default), drawn in at most as
|
|
12
|
+
* many pixels as it has (the page scales up itself) and at most DESKTOP_MAX_VIEW, keeping its proportions.
|
|
13
|
+
*/
|
|
14
|
+
function fit(framebuffer, asked) {
|
|
15
|
+
var _a;
|
|
16
|
+
const rect = clampRect((_a = asked.rect) !== null && _a !== void 0 ? _a : { x: 0, y: 0, w: framebuffer.width, h: framebuffer.height }, framebuffer);
|
|
17
|
+
const wanted = Math.max(1, Math.round(Number(asked.width) || rect.w));
|
|
18
|
+
const scale = Math.min(1, wanted / rect.w, Math.max(1, Math.round(Number(asked.height) || rect.h)) / rect.h, DESKTOP_MAX_VIEW / rect.w, DESKTOP_MAX_VIEW / rect.h);
|
|
19
|
+
return { rect, width: Math.max(1, Math.round(rect.w * scale)), height: Math.max(1, Math.round(rect.h * scale)) };
|
|
20
|
+
}
|
|
21
|
+
DesktopPicture.fit = fit;
|
|
22
|
+
function clampRect(rect, framebuffer) {
|
|
23
|
+
const x = Math.max(0, Math.min(framebuffer.width - 1, Math.floor(Number(rect.x) || 0)));
|
|
24
|
+
const y = Math.max(0, Math.min(framebuffer.height - 1, Math.floor(Number(rect.y) || 0)));
|
|
25
|
+
const w = Math.max(1, Math.min(framebuffer.width - x, Math.ceil(Number(rect.w) || framebuffer.width)));
|
|
26
|
+
const h = Math.max(1, Math.min(framebuffer.height - y, Math.ceil(Number(rect.h) || framebuffer.height)));
|
|
27
|
+
return { x, y, w, h };
|
|
28
|
+
}
|
|
29
|
+
/** The tiles of a view (columns, rows). */
|
|
30
|
+
function grid(view) {
|
|
31
|
+
return { columns: Math.ceil(view.width / DESKTOP_TILE), rows: Math.ceil(view.height / DESKTOP_TILE) };
|
|
32
|
+
}
|
|
33
|
+
DesktopPicture.grid = grid;
|
|
34
|
+
/** The tiles a changed part of the framebuffer touches, as indices of the grid of the view. */
|
|
35
|
+
function touched(view, changed) {
|
|
36
|
+
const { rect } = view;
|
|
37
|
+
const left = Math.max(changed.x, rect.x);
|
|
38
|
+
const top = Math.max(changed.y, rect.y);
|
|
39
|
+
const right = Math.min(changed.x + changed.w, rect.x + rect.w);
|
|
40
|
+
const bottom = Math.min(changed.y + changed.h, rect.y + rect.h);
|
|
41
|
+
if (right <= left || bottom <= top) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const sx = view.width / rect.w;
|
|
45
|
+
const sy = view.height / rect.h;
|
|
46
|
+
const { columns, rows } = grid(view);
|
|
47
|
+
const c0 = Math.max(0, Math.floor(((left - rect.x) * sx) / DESKTOP_TILE));
|
|
48
|
+
const c1 = Math.min(columns - 1, Math.floor(((right - rect.x) * sx - 1e-6) / DESKTOP_TILE));
|
|
49
|
+
const r0 = Math.max(0, Math.floor(((top - rect.y) * sy) / DESKTOP_TILE));
|
|
50
|
+
const r1 = Math.min(rows - 1, Math.floor(((bottom - rect.y) * sy - 1e-6) / DESKTOP_TILE));
|
|
51
|
+
const out = [];
|
|
52
|
+
for (let row = r0; row <= r1; row++) {
|
|
53
|
+
for (let column = c0; column <= c1; column++) {
|
|
54
|
+
out.push(row * columns + column);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
DesktopPicture.touched = touched;
|
|
60
|
+
/**
|
|
61
|
+
* The pixels of a tile of the view, RGBA: each the average of the pixels of the framebuffer it covers (at most 4
|
|
62
|
+
* by 4 of them, evenly spread), so that text scaled down stays readable rather than broken up.
|
|
63
|
+
*/
|
|
64
|
+
function sample(framebuffer, view, tile) {
|
|
65
|
+
const out = new Uint8Array(tile.w * tile.h * 4);
|
|
66
|
+
const { rect } = view;
|
|
67
|
+
const sx = rect.w / view.width;
|
|
68
|
+
const sy = rect.h / view.height;
|
|
69
|
+
const source = framebuffer.rgba;
|
|
70
|
+
const stride = framebuffer.width;
|
|
71
|
+
let at = 0;
|
|
72
|
+
for (let y = 0; y < tile.h; y++) {
|
|
73
|
+
const y0 = rect.y + Math.floor((tile.y + y) * sy);
|
|
74
|
+
const y1 = Math.max(y0 + 1, Math.min(rect.y + rect.h, rect.y + Math.floor((tile.y + y + 1) * sy)));
|
|
75
|
+
const stepY = Math.max(1, Math.floor((y1 - y0) / 4));
|
|
76
|
+
for (let x = 0; x < tile.w; x++) {
|
|
77
|
+
const x0 = rect.x + Math.floor((tile.x + x) * sx);
|
|
78
|
+
const x1 = Math.max(x0 + 1, Math.min(rect.x + rect.w, rect.x + Math.floor((tile.x + x + 1) * sx)));
|
|
79
|
+
const stepX = Math.max(1, Math.floor((x1 - x0) / 4));
|
|
80
|
+
let r = 0;
|
|
81
|
+
let g = 0;
|
|
82
|
+
let b = 0;
|
|
83
|
+
let count = 0;
|
|
84
|
+
for (let py = y0; py < y1; py += stepY) {
|
|
85
|
+
let index = (py * stride + x0) * 4;
|
|
86
|
+
for (let px = x0; px < x1; px += stepX, index += stepX * 4) {
|
|
87
|
+
r += source[index];
|
|
88
|
+
g += source[index + 1];
|
|
89
|
+
b += source[index + 2];
|
|
90
|
+
count++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
out[at++] = r / count;
|
|
94
|
+
out[at++] = g / count;
|
|
95
|
+
out[at++] = b / count;
|
|
96
|
+
out[at++] = 255;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
DesktopPicture.sample = sample;
|
|
102
|
+
/** The rectangle of a tile of the grid, in the pixels of the view. */
|
|
103
|
+
function tileRect(view, index) {
|
|
104
|
+
const { columns } = grid(view);
|
|
105
|
+
const x = (index % columns) * DESKTOP_TILE;
|
|
106
|
+
const y = Math.floor(index / columns) * DESKTOP_TILE;
|
|
107
|
+
return { x, y, w: Math.min(DESKTOP_TILE, view.width - x), h: Math.min(DESKTOP_TILE, view.height - y) };
|
|
108
|
+
}
|
|
109
|
+
DesktopPicture.tileRect = tileRect;
|
|
110
|
+
/**
|
|
111
|
+
* The tiles as JPEGs, in base64. Encoding a whole screen takes about 90 ms of a core, so it yields to the event loop
|
|
112
|
+
* every SLICE_MS; `still` says whether the view is still the one asked for, and stops when it is not.
|
|
113
|
+
*/
|
|
114
|
+
async function encode(framebuffer, view, tiles, quality, still = () => true) {
|
|
115
|
+
const out = [];
|
|
116
|
+
let slice = performance.now();
|
|
117
|
+
for (const index of tiles) {
|
|
118
|
+
if (performance.now() - slice > SLICE_MS) {
|
|
119
|
+
await new Promise(resolve => setImmediate(resolve));
|
|
120
|
+
slice = performance.now();
|
|
121
|
+
if (!still()) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const rect = tileRect(view, index);
|
|
126
|
+
const jpeg = JpegEncoder.encode(sample(framebuffer, view, rect), rect.w, rect.h, quality);
|
|
127
|
+
out.push({ ...rect, jpeg: Buffer.from(jpeg).toString('base64') });
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
DesktopPicture.encode = encode;
|
|
132
|
+
})(DesktopPicture || (DesktopPicture = {}));
|
|
133
|
+
//# sourceMappingURL=desktop-picture.js.map
|