@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
package/lib/node/relay-bridge.js
CHANGED
|
@@ -241,6 +241,7 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
241
241
|
const url = node_1.RelayServiceUtil.isRelay(service) ? service.url : undefined;
|
|
242
242
|
return [feature, service.id || ((_a = services.find(each => each.type === 'ta-relay' && each.url === url)) === null || _a === void 0 ? void 0 : _a.id) || ''];
|
|
243
243
|
}));
|
|
244
|
+
const deployment = this.relays.deployment(config);
|
|
244
245
|
const drives = node_1.RelayServiceUtil.drives().filter(drive => !services.some(service => service.type === 'folder' && service.path === drive.path));
|
|
245
246
|
const types = [...this.types].map(([type, { title, hint, icon, options }]) => ({
|
|
246
247
|
type,
|
|
@@ -256,6 +257,7 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
256
257
|
...(drives.length ? { drives } : {}),
|
|
257
258
|
...(types.length ? { types } : {}),
|
|
258
259
|
...(error ? { error } : {}),
|
|
260
|
+
...(deployment ? { deployment } : {}),
|
|
259
261
|
};
|
|
260
262
|
}
|
|
261
263
|
/** The store of a service of a type a package registered. */
|
|
@@ -427,6 +429,38 @@ let TaRelayServerImpl = class TaRelayServerImpl {
|
|
|
427
429
|
return this.bridge.listRelays();
|
|
428
430
|
});
|
|
429
431
|
}
|
|
432
|
+
joinDeployment(url) {
|
|
433
|
+
return ta_errors_1.TaErrors.guard(async () => {
|
|
434
|
+
var _a, _b;
|
|
435
|
+
const address = ta_protocol_1.TaDeploymentUtil.url(url);
|
|
436
|
+
if (!address) {
|
|
437
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${url} is not an address of http or https.`, 'Pass the address of the gateway or the relay of the deployment, https://….');
|
|
438
|
+
}
|
|
439
|
+
let deployment;
|
|
440
|
+
try {
|
|
441
|
+
deployment = await ta_protocol_1.TaDeploymentUtil.discover(address);
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
throw ta_errors_1.TaErrors.invalidArgument(error instanceof Error ? error.message : String(error), 'Check the address: a service of a deployment answers /.well-known/ta. A relay alone is added as a relay.');
|
|
445
|
+
}
|
|
446
|
+
if (deployment.relay) {
|
|
447
|
+
const probe = await node_1.RelayInfoUtil.probe(deployment.relay);
|
|
448
|
+
if (!probe.online) {
|
|
449
|
+
throw ta_errors_1.TaErrors.invalidArgument(`The relay of ${(_a = deployment.name) !== null && _a !== void 0 ? _a : address}, ${deployment.relay}, does not answer: ${(_b = probe.error) !== null && _b !== void 0 ? _b : 'no answer'}.`, 'Ask whoever runs the deployment whether its relay runs.');
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
this.relaysCall(() => this.bridge.relays.join(address, deployment));
|
|
453
|
+
this.bridge.relaysChanged();
|
|
454
|
+
return this.bridge.listRelays();
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
leaveDeployment() {
|
|
458
|
+
return ta_errors_1.TaErrors.guard(async () => {
|
|
459
|
+
this.relaysCall(() => this.bridge.relays.leave());
|
|
460
|
+
this.bridge.relaysChanged();
|
|
461
|
+
return this.bridge.listRelays();
|
|
462
|
+
});
|
|
463
|
+
}
|
|
430
464
|
async probeRelay(idOrUrl) {
|
|
431
465
|
var _a, _b, _c;
|
|
432
466
|
const text = String(idOrUrl !== null && idOrUrl !== void 0 ? idOrUrl : '');
|
|
@@ -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';
|
|
@@ -53,6 +53,9 @@ export declare class TaRoomServerImpl implements TaRoomServer {
|
|
|
53
53
|
listRequests(): Promise<TaRoomRequest[]>;
|
|
54
54
|
answer(room: string, ask: string, accept: boolean): Promise<void>;
|
|
55
55
|
removeMember(room: string, member: string): Promise<void>;
|
|
56
|
+
configureRoom(room: string, options: {
|
|
57
|
+
members?: number;
|
|
58
|
+
}): Promise<TaRoomInfo>;
|
|
56
59
|
leave(room: string): Promise<void>;
|
|
57
60
|
send(room: string, data: unknown, to?: string): Promise<void>;
|
|
58
61
|
getState(room: string, prefix?: string): Promise<Record<string, TaRoomValue>>;
|
|
@@ -67,6 +70,15 @@ export declare class TaRoomServerImpl implements TaRoomServer {
|
|
|
67
70
|
}>;
|
|
68
71
|
addFriend(link: string): Promise<void>;
|
|
69
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>;
|
|
70
82
|
listFriendRequests(): Promise<TaFriendRequest[]>;
|
|
71
83
|
answerFriend(id: string, accept: boolean): Promise<void>;
|
|
72
84
|
removeFriend(id: string): Promise<boolean>;
|
package/lib/node/rooms-bridge.js
CHANGED
|
@@ -35,6 +35,7 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
35
35
|
listRooms: async () => this.hubs.list(),
|
|
36
36
|
createRoom: input => this.hubs.create(input),
|
|
37
37
|
invite: (room, options) => this.hubs.invite(room, options !== null && options !== void 0 ? options : {}),
|
|
38
|
+
configureRoom: async (room, options) => this.hubs.configure(room, options !== null && options !== void 0 ? options : {}),
|
|
38
39
|
join: link => this.hubs.join(link),
|
|
39
40
|
listRequests: () => this.hubs.requests(),
|
|
40
41
|
answer: (room, ask, accept) => this.hubs.answer(room, ask, accept),
|
|
@@ -47,6 +48,12 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
47
48
|
friendLink: renew => this.hubs.friendLink(renew === true),
|
|
48
49
|
addFriend: link => this.hubs.addFriend(link),
|
|
49
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),
|
|
50
57
|
listFriendRequests: async () => this.hubs.friendRequests(),
|
|
51
58
|
answerFriend: (id, accept) => this.hubs.answerFriend(id, accept),
|
|
52
59
|
removeFriend: id => this.hubs.removeFriend(id),
|
|
@@ -152,6 +159,9 @@ let TaRoomServerImpl = class TaRoomServerImpl {
|
|
|
152
159
|
removeMember(room, member) {
|
|
153
160
|
return ta_errors_1.TaErrors.guard(() => this.rooms.removeMember(room, member));
|
|
154
161
|
}
|
|
162
|
+
configureRoom(room, options) {
|
|
163
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.configureRoom(room, { members: options === null || options === void 0 ? void 0 : options.members }));
|
|
164
|
+
}
|
|
155
165
|
leave(room) {
|
|
156
166
|
return ta_errors_1.TaErrors.guard(() => this.rooms.leave(room));
|
|
157
167
|
}
|
|
@@ -176,6 +186,25 @@ let TaRoomServerImpl = class TaRoomServerImpl {
|
|
|
176
186
|
offerFriend(room, member) {
|
|
177
187
|
return ta_errors_1.TaErrors.guard(() => this.rooms.offerFriend(room, member));
|
|
178
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
|
+
}
|
|
179
208
|
listFriendRequests() {
|
|
180
209
|
return ta_errors_1.TaErrors.guard(() => this.rooms.listFriendRequests());
|
|
181
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
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { ExecSocket } from '@celljs/ta-exec';
|
|
2
|
+
import type { TaDesktopCapabilities, TaDesktopControl, TaDesktopFrames, TaDesktopInput, TaDesktopLink, TaDesktopScreen, TaDesktopWatcher } from '@celljs/ta-protocol';
|
|
3
|
+
import type { DesktopViewer } from './desktop-viewer';
|
|
4
|
+
import { RfbClient } from './rfb-client';
|
|
5
|
+
import type { RfbCredentials, RfbCursor, RfbRect, RfbScreen } from './rfb-protocol';
|
|
6
|
+
import { RfbAuthError } from './rfb-security';
|
|
7
|
+
/** How long a desktop stays connected once no page looks at it: a page that comes back within it has a picture at once. */
|
|
8
|
+
export declare const DESKTOP_LINGER_MS = 30000;
|
|
9
|
+
/** Control given back to no one after this long without input (docs/design/ta-desktop-remote.md 6.4). */
|
|
10
|
+
export declare const DESKTOP_CONTROL_IDLE_MS: number;
|
|
11
|
+
/**
|
|
12
|
+
* How long a desktop may keep Ta waiting while it connects (the TCP connection, then each step of signing in), the
|
|
13
|
+
* time the user takes to give the password aside: a server that never answers is lost, and says so.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DESKTOP_CONNECT_TIMEOUT_MS = 20000;
|
|
16
|
+
/** How many times a desktop that refuses a sign-in is asked again while a page waits for it. */
|
|
17
|
+
export declare const DESKTOP_SIGN_INS = 5;
|
|
18
|
+
/** The desktop refused the password (and account) it was given. */
|
|
19
|
+
export declare class RfbRefusedError extends RfbAuthError {
|
|
20
|
+
}
|
|
21
|
+
/** What a session needs of the service that made it. */
|
|
22
|
+
export interface DesktopSessionHost {
|
|
23
|
+
/** A TCP connection to the desktop's VNC server, through the ExecEnvironment of its machine. */
|
|
24
|
+
connect(): Promise<ExecSocket>;
|
|
25
|
+
/**
|
|
26
|
+
* The password (and an account) to sign in with, kept or asked of whoever is there; undefined when no one
|
|
27
|
+
* answered. `refused`: the desktop refused the last one, and it is asked again.
|
|
28
|
+
*/
|
|
29
|
+
credentials(need: {
|
|
30
|
+
username: boolean;
|
|
31
|
+
refused: boolean;
|
|
32
|
+
}): Promise<RfbCredentials | undefined>;
|
|
33
|
+
/** Whether the desktop took the sign-in it was given last: told once signing in ends. */
|
|
34
|
+
signedIn(taken: boolean): void;
|
|
35
|
+
/** The display name of a principal. */
|
|
36
|
+
nameOf(principal: string): string;
|
|
37
|
+
/** The session has no viewer and lingered: the service drops it. */
|
|
38
|
+
idle(): void;
|
|
39
|
+
}
|
|
40
|
+
type PngCursor = {
|
|
41
|
+
hotX: number;
|
|
42
|
+
hotY: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
png: string;
|
|
46
|
+
} | null;
|
|
47
|
+
/**
|
|
48
|
+
* One desktop connected (docs/design/ta-desktop-remote.md 5.1, 9): one RFB connection for every page that looks at
|
|
49
|
+
* it, each a DesktopViewer with its own view and frames, and one of them, at most, in control.
|
|
50
|
+
*/
|
|
51
|
+
export declare class DesktopSession {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly name: string;
|
|
54
|
+
protected readonly host: DesktopSessionHost;
|
|
55
|
+
readonly viewers: Map<string, DesktopViewer>;
|
|
56
|
+
link: TaDesktopLink;
|
|
57
|
+
error?: string;
|
|
58
|
+
title: string;
|
|
59
|
+
protected controller?: {
|
|
60
|
+
viewerId: string;
|
|
61
|
+
since: number;
|
|
62
|
+
};
|
|
63
|
+
protected client?: RfbClient;
|
|
64
|
+
protected connecting?: Promise<void>;
|
|
65
|
+
protected cursor: PngCursor;
|
|
66
|
+
protected screens: RfbScreen[];
|
|
67
|
+
protected sawScreens: boolean;
|
|
68
|
+
protected sawCursor: boolean;
|
|
69
|
+
protected lingerTimer?: ReturnType<typeof setTimeout>;
|
|
70
|
+
protected idleTimer?: ReturnType<typeof setInterval>;
|
|
71
|
+
/** Where the pointer was put last: where held buttons are let go. */
|
|
72
|
+
protected pointerAt: {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
};
|
|
76
|
+
/** The first pixels came: before them the framebuffer is black, and no tile of it goes. */
|
|
77
|
+
protected painted: boolean;
|
|
78
|
+
connectTimeoutMs: number;
|
|
79
|
+
constructor(id: string, name: string, host: DesktopSessionHost);
|
|
80
|
+
get framebuffer(): {
|
|
81
|
+
width: number;
|
|
82
|
+
height: number;
|
|
83
|
+
};
|
|
84
|
+
/** Connected, with a whole screen to show. */
|
|
85
|
+
get showing(): boolean;
|
|
86
|
+
/** Connects once; a session that was lost connects again when a page comes. */
|
|
87
|
+
start(): Promise<void>;
|
|
88
|
+
add(viewer: DesktopViewer): void;
|
|
89
|
+
remove(viewerId: string): void;
|
|
90
|
+
close(): void;
|
|
91
|
+
/** Frame `want` of a viewer (docs/design/ta-desktop-remote.md 5.4). */
|
|
92
|
+
read(viewer: DesktopViewer, want: number): Promise<TaDesktopFrames>;
|
|
93
|
+
/** Who works it, as a page sees it: `self` for the page of `viewer`. */
|
|
94
|
+
controlFor(viewerId?: string): TaDesktopControl | null;
|
|
95
|
+
watchers(viewerId?: string): TaDesktopWatcher[];
|
|
96
|
+
get controlled(): boolean;
|
|
97
|
+
/** The screens as the protocol says them. */
|
|
98
|
+
screensOf(): TaDesktopScreen[];
|
|
99
|
+
capabilities(): TaDesktopCapabilities;
|
|
100
|
+
/** The viewer takes control: from another page of the same person, or when no one has it. */
|
|
101
|
+
take(viewer: DesktopViewer, may: (holder: DesktopViewer) => boolean): TaDesktopControl | null;
|
|
102
|
+
release(viewer: DesktopViewer): void;
|
|
103
|
+
/** Input of the viewer in control, taken once by its seq. */
|
|
104
|
+
input(viewer: DesktopViewer, batch: {
|
|
105
|
+
seq: number;
|
|
106
|
+
events: TaDesktopInput[];
|
|
107
|
+
}): void;
|
|
108
|
+
/** Text into the clipboard of the desktop, then the keys that paste on its system when asked. */
|
|
109
|
+
paste(viewer: DesktopViewer, text: string, press: boolean, clientMessageId: string): void;
|
|
110
|
+
protected mustControl(viewer: DesktopViewer): void;
|
|
111
|
+
protected live(): RfbClient;
|
|
112
|
+
/** The rectangle of a screen of the framebuffer: the one named, else the primary one. */
|
|
113
|
+
screenOf(id?: string): RfbRect | undefined;
|
|
114
|
+
protected screenRect(id?: string): RfbRect | undefined;
|
|
115
|
+
protected frame(viewer: DesktopViewer, made: {
|
|
116
|
+
seq: number;
|
|
117
|
+
whole: boolean;
|
|
118
|
+
waited: number;
|
|
119
|
+
}): Promise<TaDesktopFrames>;
|
|
120
|
+
/** Connects, asking again while the desktop refuses what it is given and a page still waits for it. */
|
|
121
|
+
protected signIn(): Promise<void>;
|
|
122
|
+
protected connect(refused?: boolean): Promise<void>;
|
|
123
|
+
protected lose(error: Error): void;
|
|
124
|
+
protected tellAll(): void;
|
|
125
|
+
protected checkIdle(): void;
|
|
126
|
+
static cursorPng(cursor: RfbCursor | null): PngCursor;
|
|
127
|
+
}
|
|
128
|
+
export {};
|
|
129
|
+
//# sourceMappingURL=desktop-session.d.ts.map
|