@celljs/ta-host 4.16.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 +111 -0
- package/esm/node/app-commands.js +646 -0
- package/esm/node/credentials.d.ts +12 -0
- package/esm/node/credentials.js +35 -0
- package/esm/node/delegate-extension.d.ts +11 -0
- package/esm/node/delegate-extension.js +33 -0
- package/esm/node/directory-relocator.d.ts +49 -0
- package/esm/node/directory-relocator.js +267 -0
- package/esm/node/extension-providers.d.ts +16 -1
- package/esm/node/extension-providers.js +23 -3
- package/esm/node/index.d.ts +8 -0
- package/esm/node/index.js +8 -0
- package/esm/node/keep-awake.d.ts +8 -1
- package/esm/node/keep-awake.js +24 -3
- package/esm/node/message-page.d.ts +6 -1
- package/esm/node/message-page.js +50 -2
- package/esm/node/package-hosts.d.ts +8 -0
- package/esm/node/package-hosts.js +41 -0
- package/esm/node/package-webhooks.d.ts +26 -0
- package/esm/node/package-webhooks.js +101 -0
- package/esm/node/page-book.d.ts +48 -0
- package/esm/node/page-book.js +117 -0
- package/esm/node/relay-bridge.d.ts +2 -0
- package/esm/node/relay-bridge.js +35 -1
- package/esm/node/rooms-bridge.d.ts +13 -1
- package/esm/node/rooms-bridge.js +29 -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 -9
- package/esm/node/session-info-util.js +16 -68
- 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.d.ts +5 -1
- package/esm/node/ta-server-impl.js +25 -3
- package/esm/node/ta-session-factory.d.ts +13 -1
- package/esm/node/ta-session-factory.js +41 -4
- package/esm/node/ta-session.d.ts +2 -0
- package/esm/node/ta-session.js +1 -0
- package/esm/node/team/team-calls.js +49 -0
- package/esm/node/voice-bridge.d.ts +70 -0
- package/esm/node/voice-bridge.js +280 -0
- package/esm/node/voices-file.d.ts +38 -0
- package/esm/node/voices-file.js +100 -0
- package/esm/node/working-directory.d.ts +8 -2
- package/esm/node/working-directory.js +7 -0
- package/lib/node/app-commands.d.ts +112 -0
- package/lib/node/app-commands.js +650 -0
- package/lib/node/credentials.d.ts +13 -0
- package/lib/node/credentials.js +38 -0
- package/lib/node/delegate-extension.d.ts +12 -0
- package/lib/node/delegate-extension.js +37 -0
- package/lib/node/directory-relocator.d.ts +50 -0
- package/lib/node/directory-relocator.js +270 -0
- package/lib/node/extension-providers.d.ts +16 -1
- package/lib/node/extension-providers.js +23 -3
- package/lib/node/index.d.ts +8 -0
- package/lib/node/index.js +8 -0
- package/lib/node/keep-awake.d.ts +8 -1
- package/lib/node/keep-awake.js +24 -3
- package/lib/node/message-page.d.ts +6 -1
- package/lib/node/message-page.js +50 -2
- package/lib/node/package-hosts.d.ts +8 -0
- package/lib/node/package-hosts.js +41 -0
- package/lib/node/package-webhooks.d.ts +27 -0
- package/lib/node/package-webhooks.js +104 -0
- package/lib/node/page-book.d.ts +49 -0
- package/lib/node/page-book.js +120 -0
- package/lib/node/relay-bridge.d.ts +2 -0
- package/lib/node/relay-bridge.js +34 -0
- package/lib/node/rooms-bridge.d.ts +13 -1
- package/lib/node/rooms-bridge.js +29 -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 -9
- package/lib/node/session-info-util.js +15 -67
- 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.d.ts +5 -1
- package/lib/node/ta-server-impl.js +24 -2
- package/lib/node/ta-session-factory.d.ts +13 -1
- package/lib/node/ta-session-factory.js +40 -3
- package/lib/node/ta-session.d.ts +2 -0
- package/lib/node/ta-session.js +1 -0
- package/lib/node/team/team-calls.js +49 -0
- package/lib/node/voice-bridge.d.ts +71 -0
- package/lib/node/voice-bridge.js +281 -0
- package/lib/node/voices-file.d.ts +39 -0
- package/lib/node/voices-file.js +104 -0
- package/lib/node/working-directory.d.ts +8 -2
- package/lib/node/working-directory.js +7 -0
- package/package.json +14 -10
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { PngThumbnail } from '../png-thumbnail.js';
|
|
2
|
+
import { TaErrors } from '../ta-errors.js';
|
|
3
|
+
import { DesktopPicture } from './desktop-picture.js';
|
|
4
|
+
import { RfbClient } from './rfb-client.js';
|
|
5
|
+
import { RfbAuthError } from './rfb-security.js';
|
|
6
|
+
/** How long a desktop stays connected once no page looks at it: a page that comes back within it has a picture at once. */
|
|
7
|
+
export const DESKTOP_LINGER_MS = 30000;
|
|
8
|
+
/** Control given back to no one after this long without input (docs/design/ta-desktop-remote.md 6.4). */
|
|
9
|
+
export const DESKTOP_CONTROL_IDLE_MS = 15 * 60000;
|
|
10
|
+
/**
|
|
11
|
+
* How long a desktop may keep Ta waiting while it connects (the TCP connection, then each step of signing in), the
|
|
12
|
+
* time the user takes to give the password aside: a server that never answers is lost, and says so.
|
|
13
|
+
*/
|
|
14
|
+
export const DESKTOP_CONNECT_TIMEOUT_MS = 20000;
|
|
15
|
+
/** How many times a desktop that refuses a sign-in is asked again while a page waits for it. */
|
|
16
|
+
export const DESKTOP_SIGN_INS = 5;
|
|
17
|
+
/** The most frames a second a page gets (docs/design/ta-desktop-remote.md 8.3). */
|
|
18
|
+
const MAX_FPS = 30;
|
|
19
|
+
/** The desktop refused the password (and account) it was given. */
|
|
20
|
+
export class RfbRefusedError extends RfbAuthError {
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One desktop connected (docs/design/ta-desktop-remote.md 5.1, 9): one RFB connection for every page that looks at
|
|
24
|
+
* it, each a DesktopViewer with its own view and frames, and one of them, at most, in control.
|
|
25
|
+
*/
|
|
26
|
+
export class DesktopSession {
|
|
27
|
+
constructor(id, name, host) {
|
|
28
|
+
this.id = id;
|
|
29
|
+
this.name = name;
|
|
30
|
+
this.host = host;
|
|
31
|
+
this.viewers = new Map();
|
|
32
|
+
this.link = 'connecting';
|
|
33
|
+
this.title = '';
|
|
34
|
+
this.cursor = null;
|
|
35
|
+
this.screens = [];
|
|
36
|
+
this.sawScreens = false;
|
|
37
|
+
this.sawCursor = false;
|
|
38
|
+
/** Where the pointer was put last: where held buttons are let go. */
|
|
39
|
+
this.pointerAt = { x: 0, y: 0 };
|
|
40
|
+
/** The first pixels came: before them the framebuffer is black, and no tile of it goes. */
|
|
41
|
+
this.painted = false;
|
|
42
|
+
this.connectTimeoutMs = DESKTOP_CONNECT_TIMEOUT_MS;
|
|
43
|
+
}
|
|
44
|
+
get framebuffer() {
|
|
45
|
+
var _a;
|
|
46
|
+
var _b;
|
|
47
|
+
return (_b = (_a = this.client) === null || _a === void 0 ? void 0 : _a.framebuffer) !== null && _b !== void 0 ? _b : { width: 0, height: 0 };
|
|
48
|
+
}
|
|
49
|
+
/** Connected, with a whole screen to show. */
|
|
50
|
+
get showing() {
|
|
51
|
+
return this.link === 'live' && this.painted;
|
|
52
|
+
}
|
|
53
|
+
/** Connects once; a session that was lost connects again when a page comes. */
|
|
54
|
+
start() {
|
|
55
|
+
if (this.connecting && this.link !== 'lost') {
|
|
56
|
+
return this.connecting;
|
|
57
|
+
}
|
|
58
|
+
this.link = 'connecting';
|
|
59
|
+
this.error = undefined;
|
|
60
|
+
this.connecting = this.signIn().catch(error => this.lose(error));
|
|
61
|
+
return this.connecting;
|
|
62
|
+
}
|
|
63
|
+
add(viewer) {
|
|
64
|
+
var _a;
|
|
65
|
+
clearTimeout(this.lingerTimer);
|
|
66
|
+
this.lingerTimer = undefined;
|
|
67
|
+
this.viewers.set(viewer.id, viewer);
|
|
68
|
+
viewer.fit(this.framebuffer, this.screenRect(viewer.asked.screen));
|
|
69
|
+
void this.start();
|
|
70
|
+
(_a = this.idleTimer) !== null && _a !== void 0 ? _a : (this.idleTimer = setInterval(() => this.checkIdle(), 60000));
|
|
71
|
+
}
|
|
72
|
+
remove(viewerId) {
|
|
73
|
+
var _a;
|
|
74
|
+
const viewer = this.viewers.get(viewerId);
|
|
75
|
+
if (!viewer) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (((_a = this.controller) === null || _a === void 0 ? void 0 : _a.viewerId) === viewerId) {
|
|
79
|
+
this.release(viewer);
|
|
80
|
+
}
|
|
81
|
+
viewer.stop();
|
|
82
|
+
this.viewers.delete(viewerId);
|
|
83
|
+
if (this.viewers.size > 0) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
clearInterval(this.idleTimer);
|
|
87
|
+
this.idleTimer = undefined;
|
|
88
|
+
if (this.link !== 'live') {
|
|
89
|
+
// No one waits for it: a connection still signing in (a password asked) ends now.
|
|
90
|
+
this.close();
|
|
91
|
+
this.host.idle();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.lingerTimer = setTimeout(() => {
|
|
95
|
+
if (this.viewers.size === 0) {
|
|
96
|
+
this.close();
|
|
97
|
+
this.host.idle();
|
|
98
|
+
}
|
|
99
|
+
}, DESKTOP_LINGER_MS);
|
|
100
|
+
}
|
|
101
|
+
close() {
|
|
102
|
+
var _a;
|
|
103
|
+
clearTimeout(this.lingerTimer);
|
|
104
|
+
clearInterval(this.idleTimer);
|
|
105
|
+
for (const viewer of this.viewers.values()) {
|
|
106
|
+
viewer.stop();
|
|
107
|
+
}
|
|
108
|
+
this.viewers.clear();
|
|
109
|
+
this.controller = undefined;
|
|
110
|
+
(_a = this.client) === null || _a === void 0 ? void 0 : _a.end();
|
|
111
|
+
this.client = undefined;
|
|
112
|
+
}
|
|
113
|
+
/** Frame `want` of a viewer (docs/design/ta-desktop-remote.md 5.4). */
|
|
114
|
+
read(viewer, want) {
|
|
115
|
+
return viewer.claim(want, (one, frame) => this.frame(one, frame), { minGapMs: 1000 / MAX_FPS, showing: () => this.showing });
|
|
116
|
+
}
|
|
117
|
+
/** Who works it, as a page sees it: `self` for the page of `viewer`. */
|
|
118
|
+
controlFor(viewerId) {
|
|
119
|
+
const holder = this.controller && this.viewers.get(this.controller.viewerId);
|
|
120
|
+
if (!holder || !this.controller) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
by: holder.principal,
|
|
125
|
+
name: this.host.nameOf(holder.principal),
|
|
126
|
+
device: holder.device,
|
|
127
|
+
self: holder.id === viewerId,
|
|
128
|
+
since: this.controller.since,
|
|
129
|
+
until: Math.max(holder.lastInputAt, this.controller.since) + DESKTOP_CONTROL_IDLE_MS,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
watchers(viewerId) {
|
|
133
|
+
return [...this.viewers.values()].map(viewer => ({
|
|
134
|
+
by: viewer.principal,
|
|
135
|
+
name: this.host.nameOf(viewer.principal),
|
|
136
|
+
device: viewer.device,
|
|
137
|
+
self: viewer.id === viewerId,
|
|
138
|
+
since: viewer.since,
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
get controlled() {
|
|
142
|
+
return !!this.controller;
|
|
143
|
+
}
|
|
144
|
+
/** The screens as the protocol says them. */
|
|
145
|
+
screensOf() {
|
|
146
|
+
var _a;
|
|
147
|
+
const { width, height } = this.framebuffer;
|
|
148
|
+
const scale = this.capabilities().system === 'mac' && width >= 2560 ? 2 : 1;
|
|
149
|
+
const list = this.sawScreens && this.screens.length ? this.screens : [{ id: -1, x: 0, y: 0, width, height }];
|
|
150
|
+
const primary = (_a = list.find(screen => screen.x === 0 && screen.y === 0)) !== null && _a !== void 0 ? _a : list[0];
|
|
151
|
+
return list.map(screen => ({
|
|
152
|
+
id: screen.id < 0 ? 'whole' : String(screen.id),
|
|
153
|
+
x: screen.x,
|
|
154
|
+
y: screen.y,
|
|
155
|
+
width: screen.width,
|
|
156
|
+
height: screen.height,
|
|
157
|
+
scale,
|
|
158
|
+
primary: screen === primary,
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
capabilities() {
|
|
162
|
+
const title = this.title;
|
|
163
|
+
const system = /mac|apple/i.test(title) ? 'mac' : /windows/i.test(title) ? 'windows' : /:\d+$/.test(title) ? 'linux' : undefined;
|
|
164
|
+
return {
|
|
165
|
+
keyboard: 'keysym',
|
|
166
|
+
unicodeKeys: null,
|
|
167
|
+
clipboardWrite: true,
|
|
168
|
+
clipboardRead: false,
|
|
169
|
+
cursor: this.sawCursor,
|
|
170
|
+
screens: this.sawScreens,
|
|
171
|
+
...(system ? { system } : {}),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** The viewer takes control: from another page of the same person, or when no one has it. */
|
|
175
|
+
take(viewer, may) {
|
|
176
|
+
var _a;
|
|
177
|
+
const holder = this.controller && this.viewers.get(this.controller.viewerId);
|
|
178
|
+
if (holder && holder.id !== viewer.id) {
|
|
179
|
+
if (!may(holder)) {
|
|
180
|
+
throw TaErrors.invalidArgument(`${this.host.nameOf(holder.principal) || 'Someone'} works this desktop now.`, 'Ask them to let go of it first.');
|
|
181
|
+
}
|
|
182
|
+
holder.letGo(this.client, this.pointerAt);
|
|
183
|
+
}
|
|
184
|
+
if (((_a = this.controller) === null || _a === void 0 ? void 0 : _a.viewerId) !== viewer.id) {
|
|
185
|
+
this.controller = { viewerId: viewer.id, since: Date.now() };
|
|
186
|
+
}
|
|
187
|
+
viewer.lastInputAt = Date.now();
|
|
188
|
+
this.tellAll();
|
|
189
|
+
return this.controlFor(viewer.id);
|
|
190
|
+
}
|
|
191
|
+
release(viewer) {
|
|
192
|
+
var _a;
|
|
193
|
+
if (((_a = this.controller) === null || _a === void 0 ? void 0 : _a.viewerId) !== viewer.id) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
viewer.letGo(this.client, this.pointerAt);
|
|
197
|
+
this.controller = undefined;
|
|
198
|
+
this.tellAll();
|
|
199
|
+
}
|
|
200
|
+
/** Input of the viewer in control, taken once by its seq. */
|
|
201
|
+
input(viewer, batch) {
|
|
202
|
+
this.mustControl(viewer);
|
|
203
|
+
if (typeof (batch === null || batch === void 0 ? void 0 : batch.seq) !== 'number' || batch.seq <= viewer.inputSeq) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
viewer.inputSeq = batch.seq;
|
|
207
|
+
const client = this.live();
|
|
208
|
+
const events = Array.isArray(batch.events) ? batch.events.slice(0, 200) : [];
|
|
209
|
+
viewer.apply(client, events);
|
|
210
|
+
const last = [...events].reverse().find(event => event.kind !== 'key');
|
|
211
|
+
if (last) {
|
|
212
|
+
this.pointerAt = { x: Number(last.x) || 0, y: Number(last.y) || 0 };
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Text into the clipboard of the desktop, then the keys that paste on its system when asked. */
|
|
216
|
+
paste(viewer, text, press, clientMessageId) {
|
|
217
|
+
this.mustControl(viewer);
|
|
218
|
+
if (viewer.pastes.has(clientMessageId)) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
viewer.pastes.add(clientMessageId);
|
|
222
|
+
const client = this.live();
|
|
223
|
+
client.clipboard(String(text !== null && text !== void 0 ? text : ''));
|
|
224
|
+
if (press) {
|
|
225
|
+
// macOS pastes with the command key, the others with control.
|
|
226
|
+
const modifier = this.capabilities().system === 'mac' ? 0xffe7 : 0xffe3;
|
|
227
|
+
client.key(modifier, true);
|
|
228
|
+
client.key(0x76, true);
|
|
229
|
+
client.key(0x76, false);
|
|
230
|
+
client.key(modifier, false);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
mustControl(viewer) {
|
|
234
|
+
var _a;
|
|
235
|
+
if (((_a = this.controller) === null || _a === void 0 ? void 0 : _a.viewerId) !== viewer.id) {
|
|
236
|
+
throw TaErrors.invalidArgument('This page does not work the desktop now.', 'Take control of it first (takeDesktopControl).');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
live() {
|
|
240
|
+
if (!this.client || this.link !== 'live') {
|
|
241
|
+
throw TaErrors.invalidArgument('The desktop is not connected.', 'Wait until it is, or open it again.');
|
|
242
|
+
}
|
|
243
|
+
return this.client;
|
|
244
|
+
}
|
|
245
|
+
/** The rectangle of a screen of the framebuffer: the one named, else the primary one. */
|
|
246
|
+
screenOf(id) {
|
|
247
|
+
return this.screenRect(id);
|
|
248
|
+
}
|
|
249
|
+
screenRect(id) {
|
|
250
|
+
var _a;
|
|
251
|
+
const screens = this.screensOf();
|
|
252
|
+
const screen = (_a = screens.find(one => one.id === id)) !== null && _a !== void 0 ? _a : screens.find(one => one.primary);
|
|
253
|
+
return screen && screen.width > 0 ? { x: screen.x, y: screen.y, w: screen.width, h: screen.height } : undefined;
|
|
254
|
+
}
|
|
255
|
+
async frame(viewer, made) {
|
|
256
|
+
var _a;
|
|
257
|
+
const taken = viewer.take();
|
|
258
|
+
const control = this.controlFor(viewer.id);
|
|
259
|
+
const controlKey = JSON.stringify(control && { by: control.by, self: control.self, device: control.device });
|
|
260
|
+
const out = { seq: made.seq, base: made.whole ? 0 : made.seq - 1, waited: made.waited, tiles: [] };
|
|
261
|
+
if (made.whole || viewer.told.control !== controlKey) {
|
|
262
|
+
viewer.told.control = controlKey;
|
|
263
|
+
out.control = control;
|
|
264
|
+
}
|
|
265
|
+
if (made.whole || viewer.told.state !== this.link) {
|
|
266
|
+
viewer.told.state = this.link;
|
|
267
|
+
out.state = this.link;
|
|
268
|
+
if (this.error) {
|
|
269
|
+
out.error = this.error;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const framebuffer = (_a = this.client) === null || _a === void 0 ? void 0 : _a.framebuffer;
|
|
273
|
+
if (!framebuffer || framebuffer.width < 1 || !viewer.view || !this.showing) {
|
|
274
|
+
// Nothing to draw yet: what was to be told goes with the first frame once there is.
|
|
275
|
+
viewer.putBack({ ...taken, news: false });
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
if (made.whole || taken.size) {
|
|
279
|
+
out.size = { width: framebuffer.width, height: framebuffer.height, screens: this.screensOf() };
|
|
280
|
+
}
|
|
281
|
+
if (made.whole || taken.cursor) {
|
|
282
|
+
out.cursor = this.cursor;
|
|
283
|
+
}
|
|
284
|
+
const holder = this.controller && this.viewers.get(this.controller.viewerId);
|
|
285
|
+
if (holder && holder.id !== viewer.id) {
|
|
286
|
+
out.pointer = { ...this.pointerAt };
|
|
287
|
+
}
|
|
288
|
+
const view = viewer.view;
|
|
289
|
+
const { columns, rows } = DesktopPicture.grid(view);
|
|
290
|
+
const all = made.whole || taken.all ? Array.from({ length: columns * rows }, (_, index) => index) : [...taken.tiles];
|
|
291
|
+
out.view = { rect: view.rect, width: view.width, height: view.height };
|
|
292
|
+
out.tiles = await DesktopPicture.encode(framebuffer, view, all, viewer.qualityFor(all.length), () => viewer.view === view);
|
|
293
|
+
if (out.tiles.length < all.length) {
|
|
294
|
+
// The view changed while its tiles were made: all of the new one goes with the next frame.
|
|
295
|
+
viewer.putBack({ tiles: new Set(), all: true, size: false, cursor: false, news: false });
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
/** Connects, asking again while the desktop refuses what it is given and a page still waits for it. */
|
|
300
|
+
async signIn() {
|
|
301
|
+
for (let tries = 1;; tries++) {
|
|
302
|
+
try {
|
|
303
|
+
return await this.connect(tries > 1);
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
if (!(error instanceof RfbRefusedError) || tries >= DESKTOP_SIGN_INS || this.viewers.size === 0) {
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async connect(refused = false) {
|
|
313
|
+
this.painted = false;
|
|
314
|
+
let asked = false;
|
|
315
|
+
const seconds = Math.round(this.connectTimeoutMs / 1000);
|
|
316
|
+
const timedOut = new Error(`The desktop did not answer in ${seconds} seconds: is its screen sharing on, and the address right?`);
|
|
317
|
+
let expired = false;
|
|
318
|
+
let timer;
|
|
319
|
+
const arm = (onExpire) => {
|
|
320
|
+
clearTimeout(timer);
|
|
321
|
+
timer = setTimeout(() => {
|
|
322
|
+
expired = true;
|
|
323
|
+
onExpire();
|
|
324
|
+
}, this.connectTimeoutMs);
|
|
325
|
+
};
|
|
326
|
+
const socket = await new Promise((resolve, reject) => {
|
|
327
|
+
arm(() => reject(timedOut));
|
|
328
|
+
this.host.connect().then(connected => (expired ? connected.end() : resolve(connected)), error => reject(error));
|
|
329
|
+
}).finally(() => clearTimeout(timer));
|
|
330
|
+
// Waiting on the server, not on the user: the clock stops while the password is asked.
|
|
331
|
+
const client = new RfbClient(socket, {
|
|
332
|
+
credentials: async (need) => {
|
|
333
|
+
clearTimeout(timer);
|
|
334
|
+
asked = true;
|
|
335
|
+
const given = await this.host.credentials({ ...need, refused });
|
|
336
|
+
if (!given) {
|
|
337
|
+
throw new Error('No one gave the password of the desktop.');
|
|
338
|
+
}
|
|
339
|
+
stall();
|
|
340
|
+
return given;
|
|
341
|
+
},
|
|
342
|
+
});
|
|
343
|
+
const stall = () => arm(() => client.end());
|
|
344
|
+
this.client = client;
|
|
345
|
+
stall();
|
|
346
|
+
try {
|
|
347
|
+
this.title = (await client.connect()).name;
|
|
348
|
+
this.host.signedIn(true);
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
client.end();
|
|
352
|
+
if (error instanceof RfbAuthError && asked) {
|
|
353
|
+
this.host.signedIn(false);
|
|
354
|
+
throw new RfbRefusedError(error.message);
|
|
355
|
+
}
|
|
356
|
+
throw expired ? timedOut : error;
|
|
357
|
+
}
|
|
358
|
+
finally {
|
|
359
|
+
clearTimeout(timer);
|
|
360
|
+
}
|
|
361
|
+
this.link = 'live';
|
|
362
|
+
this.tellAll();
|
|
363
|
+
void client.run({
|
|
364
|
+
size: (width, height, screens) => {
|
|
365
|
+
this.screens = screens;
|
|
366
|
+
this.sawScreens || (this.sawScreens = client.extended);
|
|
367
|
+
for (const viewer of this.viewers.values()) {
|
|
368
|
+
viewer.sized();
|
|
369
|
+
viewer.fit({ width, height }, this.screenRect(viewer.asked.screen));
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
damage: rect => {
|
|
373
|
+
// The first update of a server may only tell the screens; pixels come in a later one.
|
|
374
|
+
this.painted = true;
|
|
375
|
+
for (const viewer of this.viewers.values()) {
|
|
376
|
+
viewer.damage(rect);
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
update: () => {
|
|
380
|
+
for (const viewer of this.viewers.values()) {
|
|
381
|
+
viewer.updated();
|
|
382
|
+
}
|
|
383
|
+
// The next update is asked once the last came: a server never sends more than Ta takes.
|
|
384
|
+
client.request();
|
|
385
|
+
},
|
|
386
|
+
cursor: cursor => {
|
|
387
|
+
this.sawCursor = true;
|
|
388
|
+
this.cursor = DesktopSession.cursorPng(cursor);
|
|
389
|
+
for (const viewer of this.viewers.values()) {
|
|
390
|
+
viewer.cursorChanged();
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
clipboard: () => undefined,
|
|
394
|
+
bell: () => undefined,
|
|
395
|
+
closed: error => {
|
|
396
|
+
if (this.client === client) {
|
|
397
|
+
this.client = undefined;
|
|
398
|
+
if (error) {
|
|
399
|
+
this.lose(error);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
lose(error) {
|
|
406
|
+
this.link = 'lost';
|
|
407
|
+
this.error = error.message;
|
|
408
|
+
this.controller = undefined;
|
|
409
|
+
this.tellAll();
|
|
410
|
+
}
|
|
411
|
+
tellAll() {
|
|
412
|
+
for (const viewer of this.viewers.values()) {
|
|
413
|
+
viewer.news();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
checkIdle() {
|
|
417
|
+
var _a;
|
|
418
|
+
var _b;
|
|
419
|
+
const holder = this.controller && this.viewers.get(this.controller.viewerId);
|
|
420
|
+
if (holder && Date.now() - Math.max(holder.lastInputAt, (_b = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.since) !== null && _b !== void 0 ? _b : 0) > DESKTOP_CONTROL_IDLE_MS) {
|
|
421
|
+
this.release(holder);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
static cursorPng(cursor) {
|
|
425
|
+
if (!cursor) {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
hotX: cursor.hotX,
|
|
430
|
+
hotY: cursor.hotY,
|
|
431
|
+
width: cursor.width,
|
|
432
|
+
height: cursor.height,
|
|
433
|
+
png: Buffer.from(PngThumbnail.encode(cursor.rgba, cursor.width, cursor.height)).toString('base64'),
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
//# sourceMappingURL=desktop-session.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type TaDesktopInfo, type TaDesktopTarget } from '@celljs/ta-protocol';
|
|
2
|
+
import type { TaWorkingDirectory } from '../working-directory.js';
|
|
3
|
+
/** A desktop the user added, as ta.json keeps it under `desktops`. */
|
|
4
|
+
export interface DesktopEntry {
|
|
5
|
+
via: string;
|
|
6
|
+
host: string;
|
|
7
|
+
port: number;
|
|
8
|
+
name?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Which desktops there are (docs/design/ta-desktop-remote.md 4.1): this computer's own, that of each host of ssh
|
|
12
|
+
* directories, and those the user added. Only these are ever connected to, so that a page cannot have ta serve open
|
|
13
|
+
* a port of any machine it names.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DesktopTargets {
|
|
16
|
+
protected readonly store: Pick<TaWorkingDirectory, 'desktops' | 'setDesktops'>;
|
|
17
|
+
constructor(store: Pick<TaWorkingDirectory, 'desktops' | 'setDesktops'>);
|
|
18
|
+
list(computer: string, sshHosts: string[]): TaDesktopInfo[];
|
|
19
|
+
add(target: TaDesktopTarget): TaDesktopInfo;
|
|
20
|
+
remove(desktopId: string): void;
|
|
21
|
+
/** A desktop added: of this computer (by loopback), of a host of ssh, or of the network. */
|
|
22
|
+
protected static info(entry: DesktopEntry): TaDesktopInfo;
|
|
23
|
+
protected entries(): DesktopEntry[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { TaDesktopUtil, TaLocation } from '@celljs/ta-protocol';
|
|
2
|
+
import { TaErrors } from '../ta-errors.js';
|
|
3
|
+
/** The most desktops kept. */
|
|
4
|
+
const MAX_DESKTOPS = 50;
|
|
5
|
+
/**
|
|
6
|
+
* Which desktops there are (docs/design/ta-desktop-remote.md 4.1): this computer's own, that of each host of ssh
|
|
7
|
+
* directories, and those the user added. Only these are ever connected to, so that a page cannot have ta serve open
|
|
8
|
+
* a port of any machine it names.
|
|
9
|
+
*/
|
|
10
|
+
export class DesktopTargets {
|
|
11
|
+
constructor(store) {
|
|
12
|
+
this.store = store;
|
|
13
|
+
}
|
|
14
|
+
list(computer, sshHosts) {
|
|
15
|
+
const idle = { state: 'idle', control: null, viewers: [] };
|
|
16
|
+
const own = { id: TaDesktopUtil.id({ via: '' }), target: { via: '' }, name: computer, source: 'this', ...idle };
|
|
17
|
+
const hosts = sshHosts.map(host => {
|
|
18
|
+
const target = { via: TaLocation.ssh(host) };
|
|
19
|
+
return { id: TaDesktopUtil.id(target), target, name: TaLocation.hostLabel(host), source: 'ssh', ...idle };
|
|
20
|
+
});
|
|
21
|
+
const added = this.entries().map(entry => DesktopTargets.info(entry));
|
|
22
|
+
const seen = new Set();
|
|
23
|
+
return [own, ...added, ...hosts].filter(info => !seen.has(info.id) && seen.add(info.id));
|
|
24
|
+
}
|
|
25
|
+
add(target) {
|
|
26
|
+
const name = target === null || target === void 0 ? void 0 : target.name;
|
|
27
|
+
const via = typeof (target === null || target === void 0 ? void 0 : target.via) === 'string' ? target.via.trim() : '';
|
|
28
|
+
if (via && (!TaLocation.isRemote(via) || TaLocation.isCloud(TaLocation.host(via)) || TaLocation.path(via) !== '')) {
|
|
29
|
+
throw TaErrors.invalidArgument(`${JSON.stringify(via)} is not a machine.`, 'Leave it empty for this computer, or write ssh://<host>.');
|
|
30
|
+
}
|
|
31
|
+
const host = TaDesktopUtil.host(target);
|
|
32
|
+
const port = TaDesktopUtil.port(target);
|
|
33
|
+
if (!TaDesktopUtil.validHost(host)) {
|
|
34
|
+
throw TaErrors.invalidArgument(`${JSON.stringify(host)} is not a host name or an address.`, 'Write the name or the IP address of the computer.');
|
|
35
|
+
}
|
|
36
|
+
if (!TaDesktopUtil.validPort(port)) {
|
|
37
|
+
throw TaErrors.invalidArgument(`${port} is not a port of a VNC server.`, 'VNC listens on 5900, or 5900 + the number of the display.');
|
|
38
|
+
}
|
|
39
|
+
const entry = { via, host, port, ...(typeof name === 'string' && name.trim() ? { name: name.trim().slice(0, 80) } : {}) };
|
|
40
|
+
const id = TaDesktopUtil.id(entry);
|
|
41
|
+
const others = this.entries().filter(one => TaDesktopUtil.id(one) !== id);
|
|
42
|
+
if (others.length >= MAX_DESKTOPS) {
|
|
43
|
+
throw TaErrors.invalidArgument(`${MAX_DESKTOPS} desktops are kept already.`, 'Remove one first.');
|
|
44
|
+
}
|
|
45
|
+
this.store.setDesktops([entry, ...others]);
|
|
46
|
+
return DesktopTargets.info(entry);
|
|
47
|
+
}
|
|
48
|
+
remove(desktopId) {
|
|
49
|
+
const entries = this.entries();
|
|
50
|
+
const left = entries.filter(one => TaDesktopUtil.id(one) !== desktopId);
|
|
51
|
+
if (left.length === entries.length) {
|
|
52
|
+
throw TaErrors.invalidArgument(`${desktopId} was not added.`, 'Only the desktops added can be removed.');
|
|
53
|
+
}
|
|
54
|
+
this.store.setDesktops(left);
|
|
55
|
+
}
|
|
56
|
+
/** A desktop added: of this computer (by loopback), of a host of ssh, or of the network. */
|
|
57
|
+
static info(entry) {
|
|
58
|
+
const target = { via: entry.via, host: entry.host, port: entry.port, ...(entry.name ? { name: entry.name } : {}) };
|
|
59
|
+
const source = entry.via ? 'ssh' : TaDesktopUtil.loopback(entry.host) ? 'this' : 'lan';
|
|
60
|
+
return {
|
|
61
|
+
id: TaDesktopUtil.id(target),
|
|
62
|
+
target,
|
|
63
|
+
name: entry.name || `${entry.host}:${entry.port}`,
|
|
64
|
+
source,
|
|
65
|
+
state: 'idle',
|
|
66
|
+
control: null,
|
|
67
|
+
viewers: [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
entries() {
|
|
71
|
+
const kept = this.store.desktops();
|
|
72
|
+
return Array.isArray(kept)
|
|
73
|
+
? kept.filter((one) => {
|
|
74
|
+
const entry = one;
|
|
75
|
+
return !!entry && typeof entry.via === 'string' && TaDesktopUtil.validHost(entry.host) && TaDesktopUtil.validPort(entry.port);
|
|
76
|
+
})
|
|
77
|
+
: [];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=desktop-targets.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { RpcConnection } from '@celljs/rpc/lib/node';
|
|
2
|
+
import type { TaDesktopFrames, TaDesktopInput, TaDesktopView } from '@celljs/ta-protocol';
|
|
3
|
+
import { type DesktopViewSize } from './desktop-picture.js';
|
|
4
|
+
import type { RfbClient } from './rfb-client.js';
|
|
5
|
+
import type { RfbRect } from './rfb-protocol.js';
|
|
6
|
+
/** How long a claim of the next frame waits for something to change before it answers `idle`. */
|
|
7
|
+
export declare const DESKTOP_READ_WAIT_MS = 10000;
|
|
8
|
+
/** Frames a viewer keeps, for a claim sent again: as many as a page may have claimed (its window). */
|
|
9
|
+
export declare const DESKTOP_KEPT_FRAMES = 4;
|
|
10
|
+
/** The least time between two changes of the mouse buttons sent to a desktop (apply). */
|
|
11
|
+
export declare const DESKTOP_BUTTON_GAP_MS = 20;
|
|
12
|
+
/** Input as it goes to the desktop: a state of the pointer, or a key. */
|
|
13
|
+
type DesktopOutgoing = {
|
|
14
|
+
kind: 'pointer';
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
buttons: number;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'key';
|
|
20
|
+
keysym: number;
|
|
21
|
+
down: boolean;
|
|
22
|
+
};
|
|
23
|
+
/** What a viewer has yet to tell its page. */
|
|
24
|
+
export interface DesktopPending {
|
|
25
|
+
/** Tiles of the view that changed. */
|
|
26
|
+
tiles: Set<number>;
|
|
27
|
+
/** Every tile: a new view, a new size, a page that starts again. */
|
|
28
|
+
all: boolean;
|
|
29
|
+
size: boolean;
|
|
30
|
+
cursor: boolean;
|
|
31
|
+
/** Control or the link changed: a frame goes even without pictures. */
|
|
32
|
+
news: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** How a frame is made of what changed: the session's. */
|
|
35
|
+
export type DesktopFrameMaker = (viewer: DesktopViewer, frame: {
|
|
36
|
+
seq: number;
|
|
37
|
+
whole: boolean;
|
|
38
|
+
waited: number;
|
|
39
|
+
}) => Promise<TaDesktopFrames>;
|
|
40
|
+
/**
|
|
41
|
+
* One page looking at a desktop (docs/design/ta-desktop-remote.md 5.4): its view, what changed in it since its last
|
|
42
|
+
* frame, and its frames numbered from 1. A page claims frames by number, several at once: the next waits for a change,
|
|
43
|
+
* one beyond waits for the one before, so that no two claims get the same picture; the last frames are kept, so that a
|
|
44
|
+
* claim sent again gets what it got. Its input once it works the desktop.
|
|
45
|
+
*/
|
|
46
|
+
export declare class DesktopViewer {
|
|
47
|
+
readonly id: string;
|
|
48
|
+
connection: RpcConnection;
|
|
49
|
+
readonly principal: string;
|
|
50
|
+
readonly clientMessageId: string;
|
|
51
|
+
readonly device: string;
|
|
52
|
+
view?: DesktopViewSize;
|
|
53
|
+
asked: TaDesktopView;
|
|
54
|
+
quality: 'auto' | 'crisp' | 'smooth';
|
|
55
|
+
/** The last frame made. */
|
|
56
|
+
built: number;
|
|
57
|
+
readonly since: number;
|
|
58
|
+
/** The largest batch of input taken. */
|
|
59
|
+
inputSeq: number;
|
|
60
|
+
readonly pastes: Set<string>;
|
|
61
|
+
/** Mouse buttons held and keys down: let go when it loses control or goes. */
|
|
62
|
+
buttons: number;
|
|
63
|
+
readonly keys: Set<number>;
|
|
64
|
+
lastInputAt: number;
|
|
65
|
+
/** Input not sent yet, and what of the buttons went last and when (apply). */
|
|
66
|
+
protected outgoing: DesktopOutgoing[];
|
|
67
|
+
protected client?: RfbClient;
|
|
68
|
+
protected sentButtons: number;
|
|
69
|
+
protected buttonsAt: number;
|
|
70
|
+
protected pacing?: ReturnType<typeof setTimeout>;
|
|
71
|
+
/** What its last frame told of control and the link: told again only when it changes. */
|
|
72
|
+
told: {
|
|
73
|
+
control?: string;
|
|
74
|
+
state?: string;
|
|
75
|
+
};
|
|
76
|
+
protected pending: DesktopPending;
|
|
77
|
+
protected readonly frames: Map<number, Promise<TaDesktopFrames>>;
|
|
78
|
+
protected building?: {
|
|
79
|
+
seq: number;
|
|
80
|
+
frame: Promise<TaDesktopFrames>;
|
|
81
|
+
};
|
|
82
|
+
/** A claim came for a frame dropped: the next is whole. */
|
|
83
|
+
protected needsFull: boolean;
|
|
84
|
+
protected wake?: () => void;
|
|
85
|
+
protected stopped: boolean;
|
|
86
|
+
protected lastBuiltAt: number;
|
|
87
|
+
constructor(id: string, connection: RpcConnection, principal: string, clientMessageId: string, device: string, view: TaDesktopView);
|
|
88
|
+
/**
|
|
89
|
+
* Frame `want`, as docs/design/ta-desktop-remote.md 5.4 answers it. `minGapMs` keeps frames apart (the cap of
|
|
90
|
+
* frames a second); `showing` says whether the desktop has pictures to give.
|
|
91
|
+
*/
|
|
92
|
+
claim(want: number, make: DesktopFrameMaker, options: {
|
|
93
|
+
minGapMs: number;
|
|
94
|
+
showing: () => boolean;
|
|
95
|
+
}): Promise<TaDesktopFrames>;
|
|
96
|
+
protected build(want: number, arrived: number, make: DesktopFrameMaker, options: {
|
|
97
|
+
minGapMs: number;
|
|
98
|
+
showing: () => boolean;
|
|
99
|
+
}): Promise<TaDesktopFrames>;
|
|
100
|
+
/** The view a page asks for; a later revision only. */
|
|
101
|
+
setView(view: TaDesktopView, framebuffer: {
|
|
102
|
+
width: number;
|
|
103
|
+
height: number;
|
|
104
|
+
}, screen?: RfbRect): boolean;
|
|
105
|
+
/** The view fitted to the framebuffer (and the screen asked for): again whenever its size changes. */
|
|
106
|
+
fit(framebuffer: {
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
}, screen?: RfbRect): void;
|
|
110
|
+
damage(rect: RfbRect): void;
|
|
111
|
+
sized(): void;
|
|
112
|
+
cursorChanged(): void;
|
|
113
|
+
/** Something its page should hear of (control, the link). */
|
|
114
|
+
news(): void;
|
|
115
|
+
/** An update of the desktop ended: a claim that waits answers now. */
|
|
116
|
+
updated(): void;
|
|
117
|
+
get ready(): boolean;
|
|
118
|
+
/** Ends what waits: the viewer closed. */
|
|
119
|
+
stop(): void;
|
|
120
|
+
/** What it has to tell, taken: the next frame starts from nothing. */
|
|
121
|
+
take(): DesktopPending;
|
|
122
|
+
/** What it took and could not tell (the view changed while it was made): told with the next. */
|
|
123
|
+
putBack(taken: DesktopPending): void;
|
|
124
|
+
/**
|
|
125
|
+
* The JPEG quality for this many tiles of the view: the whole screen changing (a scroll, a video) at less, so that
|
|
126
|
+
* frames keep coming; a little change crisper. `crisp` and `smooth` hold it up or down.
|
|
127
|
+
*/
|
|
128
|
+
qualityFor(tiles: number): number;
|
|
129
|
+
/**
|
|
130
|
+
* Input of a batch into RFB, in the framebuffer's coordinates; keys and buttons it holds are remembered. It goes in
|
|
131
|
+
* order, each change of the buttons (a press, a release, a notch of the wheel) DESKTOP_BUTTON_GAP_MS after the one
|
|
132
|
+
* before: the Screen Sharing of macOS keeps only the last state of the pointer of what comes at once, so that a
|
|
133
|
+
* click sent in one batch never clicked.
|
|
134
|
+
*/
|
|
135
|
+
apply(client: RfbClient, events: TaDesktopInput[]): void;
|
|
136
|
+
/** Lets go of what it holds: it lost control, or closed. */
|
|
137
|
+
letGo(client: RfbClient | undefined, at: {
|
|
138
|
+
x: number;
|
|
139
|
+
y: number;
|
|
140
|
+
}): void;
|
|
141
|
+
/** Sends what waits, up to a change of the buttons too soon after the last: the rest goes when it may. */
|
|
142
|
+
protected send(): void;
|
|
143
|
+
protected wait(ms: number): Promise<void>;
|
|
144
|
+
protected notify(): void;
|
|
145
|
+
}
|
|
146
|
+
export {};
|