@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
package/lib/node/app-commands.js
CHANGED
|
@@ -64,8 +64,8 @@ class AppCommandRegistry {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
async run(id, input = {}, options = {}) {
|
|
67
|
-
var _a, _b, _c;
|
|
68
|
-
var
|
|
67
|
+
var _a, _b, _c, _d;
|
|
68
|
+
var _e, _f;
|
|
69
69
|
const command = (_a = this.commands.get(id)) === null || _a === void 0 ? void 0 : _a.command;
|
|
70
70
|
if (!command) {
|
|
71
71
|
throw ta_errors_1.TaErrors.invalidArgument(`There is no action ${JSON.stringify(id)}.`, 'See app_commands for the actions there are.');
|
|
@@ -78,10 +78,12 @@ class AppCommandRegistry {
|
|
|
78
78
|
if (refused) {
|
|
79
79
|
throw ta_errors_1.TaErrors.invalidArgument(`Who asked this may not do ${id} (${command.action}).`, 'Ask the owner of this Ta to let them, or to do it.');
|
|
80
80
|
}
|
|
81
|
-
const principal = (
|
|
81
|
+
const principal = (_e = principals.find(one => one !== ta_protocol_1.TA_OWNER)) !== null && _e !== void 0 ? _e : ta_protocol_1.TA_OWNER;
|
|
82
|
+
const context = { principal, language: this.language(), ...(options.sessionFile ? { sessionFile: options.sessionFile } : {}) };
|
|
82
83
|
// What cannot be undone, or acts for the user, waits for them to agree on their screen; a page's tap is theirs already.
|
|
83
84
|
if (command.risk === 'danger' && !options.principal) {
|
|
84
|
-
const
|
|
85
|
+
const detail = await ((_b = command.detail) === null || _b === void 0 ? void 0 : _b.call(command, input, context));
|
|
86
|
+
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));
|
|
85
87
|
if (agreed === undefined) {
|
|
86
88
|
throw ta_errors_1.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.');
|
|
87
89
|
}
|
|
@@ -89,11 +91,7 @@ class AppCommandRegistry {
|
|
|
89
91
|
throw ta_errors_1.TaErrors.invalidArgument(`The user did not agree to ${id}.`, 'Do not do it another way; ask them what they want instead.');
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
|
-
return command.run(input,
|
|
93
|
-
principal,
|
|
94
|
-
language: this.language(),
|
|
95
|
-
...(options.sessionFile ? { sessionFile: options.sessionFile } : {}),
|
|
96
|
-
});
|
|
94
|
+
return command.run(input, context);
|
|
97
95
|
}
|
|
98
96
|
/** Each who asked: the principal given, or those of the run of the conversation; the owner for a run nobody asked. */
|
|
99
97
|
principals(options) {
|
|
@@ -435,34 +433,53 @@ var CoreAppCommands;
|
|
|
435
433
|
return {
|
|
436
434
|
id: 'asks.answer',
|
|
437
435
|
title: words('Answer for you', '替你回答', '替你回答', 'あなたの代わりに回答'),
|
|
438
|
-
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.",
|
|
436
|
+
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.",
|
|
439
437
|
input: { type: 'object', properties: { file: { type: 'string' }, answer: { type: 'string' } }, required: ['file', 'answer'] },
|
|
440
|
-
|
|
438
|
+
// It may answer a confirmation of another conversation (delete, publish): the user agrees on their screen first.
|
|
439
|
+
risk: 'danger',
|
|
441
440
|
action: 'chat.send',
|
|
441
|
+
detail: async (input, context) => {
|
|
442
|
+
const { ask, said } = await answering(deps, input, context.language);
|
|
443
|
+
return `${ask.name}:${ask.question} → ${said}`;
|
|
444
|
+
},
|
|
442
445
|
run: async (input, context) => {
|
|
443
|
-
const ask =
|
|
444
|
-
if (!ask) {
|
|
445
|
-
throw ta_errors_1.TaErrors.invalidArgument('That conversation waits for nothing.', 'See asks.list for what waits.');
|
|
446
|
-
}
|
|
446
|
+
const { ask, response, said } = await answering(deps, input, context.language);
|
|
447
447
|
const notice = ta_protocol_1.TaLanguageUtil.pick(context.language, words('Answered for you', '替你回答了', '替你回答了', 'あなたの代わりに回答しました'));
|
|
448
|
-
if (ask.dialog && ask.sessionId) {
|
|
449
|
-
const response = answerOf(ask.dialog, input.answer);
|
|
450
|
-
if (!response) {
|
|
451
|
-
throw ta_errors_1.TaErrors.invalidArgument(`"${String(input.answer)}" does not answer it${ask.choices ? `: it takes one of ${ask.choices.join(', ')}` : ''}.`, 'Ask the user again.');
|
|
452
|
-
}
|
|
448
|
+
if (response && ask.dialog && ask.sessionId) {
|
|
453
449
|
await deps.respondUi(ask.sessionId, { type: 'extension_ui_response', id: ask.dialog.id, ...response });
|
|
454
|
-
const said = 'value' in response ? response.value : ta_protocol_1.TaAppUtil.shown(response.confirmed, context.language);
|
|
455
450
|
return { text: `Answered ${ask.name}: ${said}.`, notice, changes: [{ label: ask.question, after: said }] };
|
|
456
451
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
throw ta_errors_1.TaErrors.invalidArgument('answer is what the user said.', 'Pass their words.');
|
|
460
|
-
}
|
|
461
|
-
await deps.send(ask.file, ask.cwd, text);
|
|
462
|
-
return { text: `Told ${ask.name}: ${text}`, notice, changes: [{ label: ask.question, after: text }] };
|
|
452
|
+
await deps.send(ask.file, ask.cwd, said);
|
|
453
|
+
return { text: `Told ${ask.name}: ${said}`, notice, changes: [{ label: ask.question, after: said }] };
|
|
463
454
|
},
|
|
464
455
|
};
|
|
465
456
|
}
|
|
457
|
+
/** What asks.answer would answer, and how, as the user reads it; throws for what waits for nothing or no answer of it. */
|
|
458
|
+
async function answering(deps, input, language) {
|
|
459
|
+
const ask = (await asks(deps)).find(one => one.file === input.file);
|
|
460
|
+
if (!ask) {
|
|
461
|
+
throw ta_errors_1.TaErrors.invalidArgument('That conversation waits for nothing.', 'See asks.list for what waits.');
|
|
462
|
+
}
|
|
463
|
+
if (ask.dialog && ask.sessionId) {
|
|
464
|
+
const response = answerOf(ask.dialog, input.answer);
|
|
465
|
+
if (!response) {
|
|
466
|
+
throw ta_errors_1.TaErrors.invalidArgument(`"${String(input.answer)}" does not answer it${ask.choices ? `: it takes one of ${ask.choices.join(', ')}` : ''}.`, 'Ask the user again.');
|
|
467
|
+
}
|
|
468
|
+
if ('value' in response) {
|
|
469
|
+
return { ask, response, said: response.value };
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
ask,
|
|
473
|
+
response,
|
|
474
|
+
said: ta_protocol_1.TaLanguageUtil.pick(language, response.confirmed ? words('yes', '是', '是', 'はい') : words('no', '否', '否', 'いいえ')),
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
const text = typeof input.answer === 'string' ? input.answer.trim() : '';
|
|
478
|
+
if (!text) {
|
|
479
|
+
throw ta_errors_1.TaErrors.invalidArgument('answer is what the user said.', 'Pass their words.');
|
|
480
|
+
}
|
|
481
|
+
return { ask, said: text };
|
|
482
|
+
}
|
|
466
483
|
function onOff(on, language) {
|
|
467
484
|
return ta_protocol_1.TaAppUtil.shown(on, language);
|
|
468
485
|
}
|
|
@@ -561,12 +578,12 @@ let TaAppCommandsImpl = class TaAppCommandsImpl {
|
|
|
561
578
|
can: (principal, action) => team().can(principal, action),
|
|
562
579
|
actorsOf: file => team().actorsOf(file),
|
|
563
580
|
current: () => team().current(),
|
|
564
|
-
confirm: async (principal, what, sessionFile) => {
|
|
581
|
+
confirm: async (principal, what, sessionFile, detail) => {
|
|
565
582
|
if (!this.pages.has(principal, ta_protocol_1.TA_PAGE_CONFIRM)) {
|
|
566
583
|
return undefined;
|
|
567
584
|
}
|
|
568
585
|
const session = sessionFile ? (await this.server.listSessions()).find(one => one.sessionFile === sessionFile) : undefined;
|
|
569
|
-
const ask = { who: (session === null || session === void 0 ? void 0 : session.sessionName) || (session === null || session === void 0 ? void 0 : session.firstMessage) || 'Ta', what };
|
|
586
|
+
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 } : {}) };
|
|
570
587
|
return (await this.pages.ask(principal, ta_protocol_1.TA_PAGE_CONFIRM, ask, CONFIRM_MS)) === true;
|
|
571
588
|
},
|
|
572
589
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
13
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.TaCredentials = void 0;
|
|
10
|
+
const core_1 = require("@celljs/core");
|
|
11
|
+
/**
|
|
12
|
+
* The store of the sign-ins Ta gives by itself (TaExtensionHost.credentials): a package registers it (the vault of
|
|
13
|
+
* ta-secrets); without one, nothing is kept and every sign-in is asked.
|
|
14
|
+
*/
|
|
15
|
+
let TaCredentials = class TaCredentials {
|
|
16
|
+
constructor() {
|
|
17
|
+
/** For the server side of packages (TaExtensionHost.credentials). */
|
|
18
|
+
this.extension = {
|
|
19
|
+
register: store => {
|
|
20
|
+
this.registered = store;
|
|
21
|
+
return () => {
|
|
22
|
+
if (this.registered === store) {
|
|
23
|
+
this.registered = undefined;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The store there is now; undefined while no package keeps sign-ins. */
|
|
30
|
+
get store() {
|
|
31
|
+
return this.registered;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.TaCredentials = TaCredentials;
|
|
35
|
+
exports.TaCredentials = TaCredentials = __decorate([
|
|
36
|
+
(0, core_1.Component)()
|
|
37
|
+
], TaCredentials);
|
|
38
|
+
//# sourceMappingURL=credentials.js.map
|
package/lib/node/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './app-commands';
|
|
|
2
2
|
export * from './auth-server-impl';
|
|
3
3
|
export * from './client-channel';
|
|
4
4
|
export * from './client-tool-broker';
|
|
5
|
+
export * from './credentials';
|
|
5
6
|
export * from './directory-relocator';
|
|
6
7
|
export * from './event-log';
|
|
7
8
|
export * from './exec-endpoint';
|
|
@@ -24,6 +25,7 @@ export * from './relay-bridge';
|
|
|
24
25
|
export * from './remote';
|
|
25
26
|
export * from './remote-ui-context';
|
|
26
27
|
export * from './rooms-bridge';
|
|
28
|
+
export * from './screen-share';
|
|
27
29
|
export * from './serve-updates';
|
|
28
30
|
export * from './session-catalog';
|
|
29
31
|
export * from './session-files';
|
package/lib/node/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./app-commands"), exports);
|
|
|
18
18
|
__exportStar(require("./auth-server-impl"), exports);
|
|
19
19
|
__exportStar(require("./client-channel"), exports);
|
|
20
20
|
__exportStar(require("./client-tool-broker"), exports);
|
|
21
|
+
__exportStar(require("./credentials"), exports);
|
|
21
22
|
__exportStar(require("./directory-relocator"), exports);
|
|
22
23
|
__exportStar(require("./event-log"), exports);
|
|
23
24
|
__exportStar(require("./exec-endpoint"), exports);
|
|
@@ -40,6 +41,7 @@ __exportStar(require("./relay-bridge"), exports);
|
|
|
40
41
|
__exportStar(require("./remote"), exports);
|
|
41
42
|
__exportStar(require("./remote-ui-context"), exports);
|
|
42
43
|
__exportStar(require("./rooms-bridge"), exports);
|
|
44
|
+
__exportStar(require("./screen-share"), exports);
|
|
43
45
|
__exportStar(require("./serve-updates"), exports);
|
|
44
46
|
__exportStar(require("./session-catalog"), exports);
|
|
45
47
|
__exportStar(require("./session-files"), exports);
|
package/lib/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';
|
|
4
4
|
import { type RelayBridge } from './relay-bridge';
|
|
5
|
+
import { ScreenShares } from './screen-share/screen-shares';
|
|
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/lib/node/keep-awake.js
CHANGED
|
@@ -14,6 +14,7 @@ const node_child_process_1 = require("node:child_process");
|
|
|
14
14
|
const core_1 = require("@celljs/core");
|
|
15
15
|
const host_protocol_1 = require("./host-protocol");
|
|
16
16
|
const relay_bridge_1 = require("./relay-bridge");
|
|
17
|
+
const screen_shares_1 = require("./screen-share/screen-shares");
|
|
17
18
|
var KeepAwakeUtil;
|
|
18
19
|
(function (KeepAwakeUtil) {
|
|
19
20
|
/** How long after a device left the computer stays awake: a phone put away a while comes back to a Ta that answers. */
|
|
@@ -78,7 +79,7 @@ let KeepAwakeImpl = class KeepAwakeImpl {
|
|
|
78
79
|
if (this.bridge.devicesOpen > 0) {
|
|
79
80
|
this.deviceAt = now;
|
|
80
81
|
}
|
|
81
|
-
const running = this.sessions.list().some(session => session.pi.isStreaming);
|
|
82
|
+
const running = this.sessions.list().some(session => session.pi.isStreaming) || this.desktops.watched;
|
|
82
83
|
const enabled = this.bridge.store.read().keepAwake !== false;
|
|
83
84
|
if (KeepAwakeUtil.wanted({ enabled, running, deviceAt: this.deviceAt, now })) {
|
|
84
85
|
this.hold();
|
|
@@ -125,6 +126,10 @@ __decorate([
|
|
|
125
126
|
(0, core_1.Autowired)(host_protocol_1.TaSessionRegistry),
|
|
126
127
|
__metadata("design:type", Object)
|
|
127
128
|
], KeepAwakeImpl.prototype, "sessions", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
(0, core_1.Autowired)(screen_shares_1.ScreenShares),
|
|
131
|
+
__metadata("design:type", screen_shares_1.ScreenShares)
|
|
132
|
+
], KeepAwakeImpl.prototype, "desktops", void 0);
|
|
128
133
|
exports.KeepAwakeImpl = KeepAwakeImpl = __decorate([
|
|
129
134
|
(0, core_1.Component)([host_protocol_1.KeepAwake, core_1.ApplicationLifecycle])
|
|
130
135
|
], 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';
|
|
5
|
+
import { TaCredentials } from './credentials';
|
|
5
6
|
import { ExtensionDataStore } from './extension-data';
|
|
6
7
|
import { TaPresenceBook, TaSessionRegistry } from './host-protocol';
|
|
7
8
|
import { TaPageBook } from './page-book';
|
|
@@ -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;
|
|
@@ -20,6 +20,7 @@ const ta_brand_1 = require("@celljs/ta-harness/lib/node/ta-brand");
|
|
|
20
20
|
const ta_packages_1 = require("@celljs/ta-harness/lib/node/ta-packages");
|
|
21
21
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
22
22
|
const app_commands_1 = require("./app-commands");
|
|
23
|
+
const credentials_1 = require("./credentials");
|
|
23
24
|
const extension_data_1 = require("./extension-data");
|
|
24
25
|
const host_protocol_1 = require("./host-protocol");
|
|
25
26
|
const page_book_1 = require("./page-book");
|
|
@@ -203,6 +204,7 @@ let PackageHostsImpl = class PackageHostsImpl {
|
|
|
203
204
|
rooms: this.roomsBridge.rooms,
|
|
204
205
|
relays: this.relay.extensionRelays,
|
|
205
206
|
voices: this.voiceBridge.extensionVoices,
|
|
207
|
+
credentials: this.credentials.extension,
|
|
206
208
|
sessionMessages: file => this.sessionMessages(file),
|
|
207
209
|
sessionRole: async (file) => session_catalog_1.SessionCatalogUtil.roleOf((await ai_coding_agent_1.PiSdkUtil.load()).SessionManager.open(file).getEntries()),
|
|
208
210
|
createSession: (cwd, messages, name) => this.createSession(cwd, messages, name),
|
|
@@ -304,6 +306,10 @@ __decorate([
|
|
|
304
306
|
(0, core_1.Autowired)({ id: voice_bridge_1.VOICE_BRIDGE, detached: true }),
|
|
305
307
|
__metadata("design:type", Function)
|
|
306
308
|
], PackageHostsImpl.prototype, "voiceBridge", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
(0, core_1.Autowired)(credentials_1.TaCredentials),
|
|
311
|
+
__metadata("design:type", credentials_1.TaCredentials)
|
|
312
|
+
], PackageHostsImpl.prototype, "credentials", void 0);
|
|
307
313
|
__decorate([
|
|
308
314
|
(0, core_1.Autowired)({ id: settings_store_1.TaSettingsStore, detached: true }),
|
|
309
315
|
__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';
|
|
6
6
|
import { type RelayBridge } from './relay-bridge';
|
|
@@ -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/lib/node/rooms-bridge.js
CHANGED
|
@@ -48,6 +48,12 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
48
48
|
friendLink: renew => this.hubs.friendLink(renew === true),
|
|
49
49
|
addFriend: link => this.hubs.addFriend(link),
|
|
50
50
|
offerFriend: (room, member) => this.hubs.offerFriend(room, member),
|
|
51
|
+
inviteFriends: (room, friends) => this.hubs.inviteFriends(room, friends),
|
|
52
|
+
listGroupInvites: () => this.hubs.groupInvites(),
|
|
53
|
+
answerGroupInvite: (room, accept) => this.hubs.answerGroupInvite(room, accept),
|
|
54
|
+
sendToFriends: (friends, item) => this.hubs.sendToFriends(friends, item),
|
|
55
|
+
listFriendShares: () => this.hubs.friendShares(),
|
|
56
|
+
answerFriendShare: async (id, keep) => this.hubs.answerFriendShare(id, keep),
|
|
51
57
|
listFriendRequests: async () => this.hubs.friendRequests(),
|
|
52
58
|
answerFriend: (id, accept) => this.hubs.answerFriend(id, accept),
|
|
53
59
|
removeFriend: id => this.hubs.removeFriend(id),
|
|
@@ -180,6 +186,25 @@ let TaRoomServerImpl = class TaRoomServerImpl {
|
|
|
180
186
|
offerFriend(room, member) {
|
|
181
187
|
return ta_errors_1.TaErrors.guard(() => this.rooms.offerFriend(room, member));
|
|
182
188
|
}
|
|
189
|
+
inviteFriends(room, friends) {
|
|
190
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.inviteFriends(room, Array.isArray(friends) ? friends.map(String) : []));
|
|
191
|
+
}
|
|
192
|
+
listGroupInvites() {
|
|
193
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.listGroupInvites());
|
|
194
|
+
}
|
|
195
|
+
answerGroupInvite(room, accept) {
|
|
196
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.answerGroupInvite(room, accept === true));
|
|
197
|
+
}
|
|
198
|
+
sendToFriends(friends, item) {
|
|
199
|
+
const ids = Array.isArray(friends) ? friends.map(String) : [];
|
|
200
|
+
return ta_errors_1.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 : '') }); });
|
|
201
|
+
}
|
|
202
|
+
listFriendShares() {
|
|
203
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.listFriendShares());
|
|
204
|
+
}
|
|
205
|
+
answerFriendShare(id, keep) {
|
|
206
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.answerFriendShare(String(id), keep === true));
|
|
207
|
+
}
|
|
183
208
|
listFriendRequests() {
|
|
184
209
|
return ta_errors_1.TaErrors.guard(() => this.rooms.listFriendRequests());
|
|
185
210
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { RfbFramebuffer } from './rfb-framebuffer';
|
|
2
|
+
import type { RfbRect } from './rfb-protocol';
|
|
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
|
+
}
|
|
52
|
+
//# sourceMappingURL=desktop-picture.d.ts.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DesktopPicture = exports.DESKTOP_MAX_VIEW = exports.DESKTOP_TILE = void 0;
|
|
4
|
+
const jpeg_encoder_1 = require("../jpeg-encoder");
|
|
5
|
+
/** The side of a tile of a view, in its pixels: each changed tile goes as a JPEG of its own. */
|
|
6
|
+
exports.DESKTOP_TILE = 128;
|
|
7
|
+
/** The most a view may be on a side, whatever a page asks. */
|
|
8
|
+
exports.DESKTOP_MAX_VIEW = 4096;
|
|
9
|
+
/** Work done between two turns of the event loop while tiles are encoded: sessions and terminals go on meanwhile. */
|
|
10
|
+
const SLICE_MS = 8;
|
|
11
|
+
var DesktopPicture;
|
|
12
|
+
(function (DesktopPicture) {
|
|
13
|
+
/**
|
|
14
|
+
* The view a page asked for, made safe: a part inside the framebuffer (all of it by default), drawn in at most as
|
|
15
|
+
* many pixels as it has (the page scales up itself) and at most DESKTOP_MAX_VIEW, keeping its proportions.
|
|
16
|
+
*/
|
|
17
|
+
function fit(framebuffer, asked) {
|
|
18
|
+
var _a;
|
|
19
|
+
const rect = clampRect((_a = asked.rect) !== null && _a !== void 0 ? _a : { x: 0, y: 0, w: framebuffer.width, h: framebuffer.height }, framebuffer);
|
|
20
|
+
const wanted = Math.max(1, Math.round(Number(asked.width) || rect.w));
|
|
21
|
+
const scale = Math.min(1, wanted / rect.w, Math.max(1, Math.round(Number(asked.height) || rect.h)) / rect.h, exports.DESKTOP_MAX_VIEW / rect.w, exports.DESKTOP_MAX_VIEW / rect.h);
|
|
22
|
+
return { rect, width: Math.max(1, Math.round(rect.w * scale)), height: Math.max(1, Math.round(rect.h * scale)) };
|
|
23
|
+
}
|
|
24
|
+
DesktopPicture.fit = fit;
|
|
25
|
+
function clampRect(rect, framebuffer) {
|
|
26
|
+
const x = Math.max(0, Math.min(framebuffer.width - 1, Math.floor(Number(rect.x) || 0)));
|
|
27
|
+
const y = Math.max(0, Math.min(framebuffer.height - 1, Math.floor(Number(rect.y) || 0)));
|
|
28
|
+
const w = Math.max(1, Math.min(framebuffer.width - x, Math.ceil(Number(rect.w) || framebuffer.width)));
|
|
29
|
+
const h = Math.max(1, Math.min(framebuffer.height - y, Math.ceil(Number(rect.h) || framebuffer.height)));
|
|
30
|
+
return { x, y, w, h };
|
|
31
|
+
}
|
|
32
|
+
/** The tiles of a view (columns, rows). */
|
|
33
|
+
function grid(view) {
|
|
34
|
+
return { columns: Math.ceil(view.width / exports.DESKTOP_TILE), rows: Math.ceil(view.height / exports.DESKTOP_TILE) };
|
|
35
|
+
}
|
|
36
|
+
DesktopPicture.grid = grid;
|
|
37
|
+
/** The tiles a changed part of the framebuffer touches, as indices of the grid of the view. */
|
|
38
|
+
function touched(view, changed) {
|
|
39
|
+
const { rect } = view;
|
|
40
|
+
const left = Math.max(changed.x, rect.x);
|
|
41
|
+
const top = Math.max(changed.y, rect.y);
|
|
42
|
+
const right = Math.min(changed.x + changed.w, rect.x + rect.w);
|
|
43
|
+
const bottom = Math.min(changed.y + changed.h, rect.y + rect.h);
|
|
44
|
+
if (right <= left || bottom <= top) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
const sx = view.width / rect.w;
|
|
48
|
+
const sy = view.height / rect.h;
|
|
49
|
+
const { columns, rows } = grid(view);
|
|
50
|
+
const c0 = Math.max(0, Math.floor(((left - rect.x) * sx) / exports.DESKTOP_TILE));
|
|
51
|
+
const c1 = Math.min(columns - 1, Math.floor(((right - rect.x) * sx - 1e-6) / exports.DESKTOP_TILE));
|
|
52
|
+
const r0 = Math.max(0, Math.floor(((top - rect.y) * sy) / exports.DESKTOP_TILE));
|
|
53
|
+
const r1 = Math.min(rows - 1, Math.floor(((bottom - rect.y) * sy - 1e-6) / exports.DESKTOP_TILE));
|
|
54
|
+
const out = [];
|
|
55
|
+
for (let row = r0; row <= r1; row++) {
|
|
56
|
+
for (let column = c0; column <= c1; column++) {
|
|
57
|
+
out.push(row * columns + column);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
DesktopPicture.touched = touched;
|
|
63
|
+
/**
|
|
64
|
+
* The pixels of a tile of the view, RGBA: each the average of the pixels of the framebuffer it covers (at most 4
|
|
65
|
+
* by 4 of them, evenly spread), so that text scaled down stays readable rather than broken up.
|
|
66
|
+
*/
|
|
67
|
+
function sample(framebuffer, view, tile) {
|
|
68
|
+
const out = new Uint8Array(tile.w * tile.h * 4);
|
|
69
|
+
const { rect } = view;
|
|
70
|
+
const sx = rect.w / view.width;
|
|
71
|
+
const sy = rect.h / view.height;
|
|
72
|
+
const source = framebuffer.rgba;
|
|
73
|
+
const stride = framebuffer.width;
|
|
74
|
+
let at = 0;
|
|
75
|
+
for (let y = 0; y < tile.h; y++) {
|
|
76
|
+
const y0 = rect.y + Math.floor((tile.y + y) * sy);
|
|
77
|
+
const y1 = Math.max(y0 + 1, Math.min(rect.y + rect.h, rect.y + Math.floor((tile.y + y + 1) * sy)));
|
|
78
|
+
const stepY = Math.max(1, Math.floor((y1 - y0) / 4));
|
|
79
|
+
for (let x = 0; x < tile.w; x++) {
|
|
80
|
+
const x0 = rect.x + Math.floor((tile.x + x) * sx);
|
|
81
|
+
const x1 = Math.max(x0 + 1, Math.min(rect.x + rect.w, rect.x + Math.floor((tile.x + x + 1) * sx)));
|
|
82
|
+
const stepX = Math.max(1, Math.floor((x1 - x0) / 4));
|
|
83
|
+
let r = 0;
|
|
84
|
+
let g = 0;
|
|
85
|
+
let b = 0;
|
|
86
|
+
let count = 0;
|
|
87
|
+
for (let py = y0; py < y1; py += stepY) {
|
|
88
|
+
let index = (py * stride + x0) * 4;
|
|
89
|
+
for (let px = x0; px < x1; px += stepX, index += stepX * 4) {
|
|
90
|
+
r += source[index];
|
|
91
|
+
g += source[index + 1];
|
|
92
|
+
b += source[index + 2];
|
|
93
|
+
count++;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
out[at++] = r / count;
|
|
97
|
+
out[at++] = g / count;
|
|
98
|
+
out[at++] = b / count;
|
|
99
|
+
out[at++] = 255;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
DesktopPicture.sample = sample;
|
|
105
|
+
/** The rectangle of a tile of the grid, in the pixels of the view. */
|
|
106
|
+
function tileRect(view, index) {
|
|
107
|
+
const { columns } = grid(view);
|
|
108
|
+
const x = (index % columns) * exports.DESKTOP_TILE;
|
|
109
|
+
const y = Math.floor(index / columns) * exports.DESKTOP_TILE;
|
|
110
|
+
return { x, y, w: Math.min(exports.DESKTOP_TILE, view.width - x), h: Math.min(exports.DESKTOP_TILE, view.height - y) };
|
|
111
|
+
}
|
|
112
|
+
DesktopPicture.tileRect = tileRect;
|
|
113
|
+
/**
|
|
114
|
+
* The tiles as JPEGs, in base64. Encoding a whole screen takes about 90 ms of a core, so it yields to the event loop
|
|
115
|
+
* every SLICE_MS; `still` says whether the view is still the one asked for, and stops when it is not.
|
|
116
|
+
*/
|
|
117
|
+
async function encode(framebuffer, view, tiles, quality, still = () => true) {
|
|
118
|
+
const out = [];
|
|
119
|
+
let slice = performance.now();
|
|
120
|
+
for (const index of tiles) {
|
|
121
|
+
if (performance.now() - slice > SLICE_MS) {
|
|
122
|
+
await new Promise(resolve => setImmediate(resolve));
|
|
123
|
+
slice = performance.now();
|
|
124
|
+
if (!still()) {
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const rect = tileRect(view, index);
|
|
129
|
+
const jpeg = jpeg_encoder_1.JpegEncoder.encode(sample(framebuffer, view, rect), rect.w, rect.h, quality);
|
|
130
|
+
out.push({ ...rect, jpeg: Buffer.from(jpeg).toString('base64') });
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
DesktopPicture.encode = encode;
|
|
135
|
+
})(DesktopPicture || (exports.DesktopPicture = DesktopPicture = {}));
|
|
136
|
+
//# sourceMappingURL=desktop-picture.js.map
|