@celljs/ta-client 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/common/session-reducer.d.ts +5 -0
- package/esm/common/session-store.js +5 -1
- package/esm/common/ta-connection.d.ts +8 -2
- package/esm/common/ta-connection.js +27 -5
- package/lib/common/session-reducer.d.ts +5 -0
- package/lib/common/session-store.js +5 -1
- package/lib/common/ta-connection.d.ts +8 -2
- package/lib/common/ta-connection.js +26 -4
- package/package.json +2 -2
|
@@ -66,6 +66,11 @@ export interface SessionState {
|
|
|
66
66
|
retry?: RetryState;
|
|
67
67
|
/** What an extension says the agent does while it works (pi's `setWorkingMessage`). */
|
|
68
68
|
workingMessage?: string;
|
|
69
|
+
/**
|
|
70
|
+
* False while the state is not the session's of now: read from what this device kept, or of a store detached. How
|
|
71
|
+
* its last turn ended may be over (the agent went on since); undefined for a state that never was the session's.
|
|
72
|
+
*/
|
|
73
|
+
synced?: boolean;
|
|
69
74
|
/** Which of the last `messages` this client sent that the session does not have yet (SessionStore.send). */
|
|
70
75
|
outbox?: readonly OutboxMessage[];
|
|
71
76
|
}
|
|
@@ -29,7 +29,7 @@ export class SessionStore extends SessionClientTools {
|
|
|
29
29
|
this.holdMs = (_b = options.holdMs) !== null && _b !== void 0 ? _b : HOLD_MS;
|
|
30
30
|
if (options.initial) {
|
|
31
31
|
const { messages, start, tools } = options.initial;
|
|
32
|
-
this.current = this.shown = { ...this.current, messages, start, tools };
|
|
32
|
+
this.current = this.shown = { ...this.current, messages, start, tools, synced: false };
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
get state() {
|
|
@@ -53,6 +53,9 @@ export class SessionStore extends SessionClientTools {
|
|
|
53
53
|
for (const stop of this.stop.splice(0)) {
|
|
54
54
|
stop();
|
|
55
55
|
}
|
|
56
|
+
// Not through `update`: what it shows changes, the calls it runs do not.
|
|
57
|
+
this.current = { ...this.current, synced: false };
|
|
58
|
+
this.show();
|
|
56
59
|
await this.connection.server.detach(this.sessionId);
|
|
57
60
|
}
|
|
58
61
|
subscribe(listener) {
|
|
@@ -293,6 +296,7 @@ export class SessionStore extends SessionClientTools {
|
|
|
293
296
|
pendingUi: result.pendingUi,
|
|
294
297
|
pendingClientTools: result.pendingClientTools,
|
|
295
298
|
working: result.info.isStreaming,
|
|
299
|
+
synced: true,
|
|
296
300
|
};
|
|
297
301
|
if (result.shownUi) {
|
|
298
302
|
// What the extensions show now, whatever events were missed.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaPageServer, type TaPresenceServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaVoiceEvent, type TaVoiceServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
1
|
+
import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, type TaDesktopEvent, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaPageServer, type TaPresenceServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaScreenShareServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaVoiceEvent, type TaVoiceServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
2
2
|
import type { TaConnectionOptions, TaSocket } from './ta-connection-options.js';
|
|
3
3
|
interface PendingCall {
|
|
4
4
|
resolve(result: unknown): void;
|
|
@@ -57,6 +57,8 @@ export declare class TaConnection {
|
|
|
57
57
|
readonly gateway: TaGatewayServer;
|
|
58
58
|
readonly relay: TaRelayServer;
|
|
59
59
|
readonly remote: TaRemoteServer;
|
|
60
|
+
/** Desktops of other computers, seen and worked (docs/design/ta-desktop-remote.md). */
|
|
61
|
+
readonly screenShare: TaScreenShareServer;
|
|
60
62
|
readonly rooms: TaRoomServer;
|
|
61
63
|
/** What this page is at, for the others in the same Ta (docs/design/ta-team.md 7). */
|
|
62
64
|
readonly presence: TaPresenceServer;
|
|
@@ -77,6 +79,7 @@ export declare class TaConnection {
|
|
|
77
79
|
protected readonly remoteListeners: Set<RemoteEventListener>;
|
|
78
80
|
protected readonly roomListeners: Set<RoomEventListener>;
|
|
79
81
|
protected readonly voiceListeners: Set<VoiceEventListener>;
|
|
82
|
+
protected readonly desktopListeners: Set<(event: TaDesktopEvent) => void>;
|
|
80
83
|
protected pageAsk?: PageAskHandler;
|
|
81
84
|
protected readonly sessionsListeners: Set<SessionsListener>;
|
|
82
85
|
protected readonly openListeners: Set<OpenListener>;
|
|
@@ -110,6 +113,8 @@ export declare class TaConnection {
|
|
|
110
113
|
/** What the voices this connection opened tell (TaVoiceServer.openVoice). */
|
|
111
114
|
/** Answers what ta serve asks this page (TaClient.onPageAsk): one handler, the last set; without one, an error. */
|
|
112
115
|
onPageAsk(handler: PageAskHandler | undefined): void;
|
|
116
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
117
|
+
onScreenShareEvent(listener: (event: TaDesktopEvent) => void): () => void;
|
|
113
118
|
onVoiceEvent(listener: VoiceEventListener): () => void;
|
|
114
119
|
/** The open sessions as they change (TaClient.onSessions), once this connection called TaServer.watchSessions. */
|
|
115
120
|
onSessions(listener: SessionsListener): () => void;
|
|
@@ -138,7 +143,8 @@ export declare class TaConnection {
|
|
|
138
143
|
protected service<T extends object>(name: string): T;
|
|
139
144
|
/**
|
|
140
145
|
* Whether a call may go again after a lost connection, as doing it twice does what doing it once does:
|
|
141
|
-
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once
|
|
146
|
+
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once; of a desktop, a view
|
|
147
|
+
* opened or text pasted by its id, input by its seq, a view by its revision (docs/design/ta-desktop-remote.md 5.3).
|
|
142
148
|
*/
|
|
143
149
|
static resendable(service: string, method: string, params: readonly unknown[]): boolean;
|
|
144
150
|
protected call(service: string, method: string, params: unknown[]): Promise<unknown>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { TA_ACCESS_SERVICE, TA_AUTH_SERVICE, TA_CLIENT_SERVICE, TA_GATEWAY_SERVICE, TA_PACKAGE_SERVICE, TA_PAGE_SERVICE, TA_PRESENCE_SERVICE, TA_RELAY_SERVICE, TA_REMOTE_SERVICE, TA_ROOM_SERVICE, TA_SERVER_SERVICE, TA_SETTINGS_SERVICE, TA_TERMINAL_SERVICE, TA_VOICE_SERVICE, TA_WORKSPACE_SERVICE, TaErrorCode, } from '@celljs/ta-protocol';
|
|
1
|
+
import { TA_ACCESS_SERVICE, TA_AUTH_SERVICE, TA_CLIENT_SERVICE, TA_GATEWAY_SERVICE, TA_PACKAGE_SERVICE, TA_PAGE_SERVICE, TA_PRESENCE_SERVICE, TA_RELAY_SERVICE, TA_REMOTE_SERVICE, TA_ROOM_SERVICE, TA_SCREEN_SHARE_SERVICE, TA_SERVER_SERVICE, TA_SETTINGS_SERVICE, TA_TERMINAL_SERVICE, TA_VOICE_SERVICE, TA_WORKSPACE_SERVICE, TaErrorCode, } from '@celljs/ta-protocol';
|
|
2
2
|
import { TaRemoteError } from './ta-remote-error.js';
|
|
3
3
|
/** Methods that only read: sent again after a lost connection. */
|
|
4
4
|
const READ_METHOD = /^(get|list|read|find)[A-Z]/;
|
|
5
5
|
/** Methods whose input carries a clientMessageId, by which ta serve takes a message once however often it comes. */
|
|
6
6
|
const MESSAGE_METHODS = new Set(['prompt', 'steer', 'followUp']);
|
|
7
|
+
/** Calls of TaScreenShareServer that ta serve takes once (an id, a seq, a revision), so that they may go again. */
|
|
8
|
+
const DESKTOP_ONCE = new Set(['openDesktop', 'pasteToDesktop', 'sendDesktopInput', 'setDesktopView']);
|
|
7
9
|
/**
|
|
8
10
|
* A connection to `ta serve` on the `WebSocket` of the platform, with no other dependency, so that it
|
|
9
11
|
* fits a browser, Electron or a mobile app. It reconnects until closed; `onOpen` runs each time, for
|
|
@@ -31,6 +33,8 @@ export class TaConnection {
|
|
|
31
33
|
this.gateway = this.service(TA_GATEWAY_SERVICE);
|
|
32
34
|
this.relay = this.service(TA_RELAY_SERVICE);
|
|
33
35
|
this.remote = this.service(TA_REMOTE_SERVICE);
|
|
36
|
+
/** Desktops of other computers, seen and worked (docs/design/ta-desktop-remote.md). */
|
|
37
|
+
this.screenShare = this.service(TA_SCREEN_SHARE_SERVICE);
|
|
34
38
|
this.rooms = this.service(TA_ROOM_SERVICE);
|
|
35
39
|
/** What this page is at, for the others in the same Ta (docs/design/ta-team.md 7). */
|
|
36
40
|
this.presence = this.service(TA_PRESENCE_SERVICE);
|
|
@@ -49,6 +53,7 @@ export class TaConnection {
|
|
|
49
53
|
this.remoteListeners = new Set();
|
|
50
54
|
this.roomListeners = new Set();
|
|
51
55
|
this.voiceListeners = new Set();
|
|
56
|
+
this.desktopListeners = new Set();
|
|
52
57
|
this.sessionsListeners = new Set();
|
|
53
58
|
this.openListeners = new Set();
|
|
54
59
|
this.closeListeners = new Set();
|
|
@@ -107,6 +112,11 @@ export class TaConnection {
|
|
|
107
112
|
onPageAsk(handler) {
|
|
108
113
|
this.pageAsk = handler;
|
|
109
114
|
}
|
|
115
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
116
|
+
onScreenShareEvent(listener) {
|
|
117
|
+
this.desktopListeners.add(listener);
|
|
118
|
+
return () => this.desktopListeners.delete(listener);
|
|
119
|
+
}
|
|
110
120
|
onVoiceEvent(listener) {
|
|
111
121
|
this.voiceListeners.add(listener);
|
|
112
122
|
return () => this.voiceListeners.delete(listener);
|
|
@@ -285,13 +295,17 @@ export class TaConnection {
|
|
|
285
295
|
}
|
|
286
296
|
/**
|
|
287
297
|
* Whether a call may go again after a lost connection, as doing it twice does what doing it once does:
|
|
288
|
-
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once
|
|
298
|
+
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once; of a desktop, a view
|
|
299
|
+
* opened or text pasted by its id, input by its seq, a view by its revision (docs/design/ta-desktop-remote.md 5.3).
|
|
289
300
|
*/
|
|
290
301
|
static resendable(service, method, params) {
|
|
291
302
|
var _a;
|
|
292
303
|
if (READ_METHOD.test(method)) {
|
|
293
304
|
return true;
|
|
294
305
|
}
|
|
306
|
+
if (service === TA_SCREEN_SHARE_SERVICE) {
|
|
307
|
+
return DESKTOP_ONCE.has(method);
|
|
308
|
+
}
|
|
295
309
|
return service === TA_SERVER_SERVICE && MESSAGE_METHODS.has(method) && !!((_a = params[1]) === null || _a === void 0 ? void 0 : _a.clientMessageId);
|
|
296
310
|
}
|
|
297
311
|
async call(service, method, params) {
|
|
@@ -374,7 +388,7 @@ export class TaConnection {
|
|
|
374
388
|
}
|
|
375
389
|
}
|
|
376
390
|
receive(text) {
|
|
377
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
391
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
378
392
|
this.lastReceivedAt = Date.now();
|
|
379
393
|
const message = JSON.parse(text);
|
|
380
394
|
if (message.method === `${TA_CLIENT_SERVICE}/onEvents`) {
|
|
@@ -426,12 +440,20 @@ export class TaConnection {
|
|
|
426
440
|
(_f = this.socket) === null || _f === void 0 ? void 0 : _f.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
427
441
|
return;
|
|
428
442
|
}
|
|
443
|
+
if (message.method === `${TA_CLIENT_SERVICE}/onScreenShareEvent`) {
|
|
444
|
+
const [event] = message.params;
|
|
445
|
+
for (const listener of this.desktopListeners) {
|
|
446
|
+
listener(event);
|
|
447
|
+
}
|
|
448
|
+
(_g = this.socket) === null || _g === void 0 ? void 0 : _g.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
429
451
|
if (message.method === `${TA_CLIENT_SERVICE}/onVoiceEvent`) {
|
|
430
452
|
const [event] = message.params;
|
|
431
453
|
for (const listener of this.voiceListeners) {
|
|
432
454
|
listener(event);
|
|
433
455
|
}
|
|
434
|
-
(
|
|
456
|
+
(_h = this.socket) === null || _h === void 0 ? void 0 : _h.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
435
457
|
return;
|
|
436
458
|
}
|
|
437
459
|
if (message.method === `${TA_CLIENT_SERVICE}/onPageAsk`) {
|
|
@@ -444,7 +466,7 @@ export class TaConnection {
|
|
|
444
466
|
for (const listener of this.extensionDataListeners) {
|
|
445
467
|
listener(name, keys, cwd !== null && cwd !== void 0 ? cwd : undefined);
|
|
446
468
|
}
|
|
447
|
-
(
|
|
469
|
+
(_j = this.socket) === null || _j === void 0 ? void 0 : _j.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
448
470
|
return;
|
|
449
471
|
}
|
|
450
472
|
const call = this.pending.get(message.id);
|
|
@@ -66,6 +66,11 @@ export interface SessionState {
|
|
|
66
66
|
retry?: RetryState;
|
|
67
67
|
/** What an extension says the agent does while it works (pi's `setWorkingMessage`). */
|
|
68
68
|
workingMessage?: string;
|
|
69
|
+
/**
|
|
70
|
+
* False while the state is not the session's of now: read from what this device kept, or of a store detached. How
|
|
71
|
+
* its last turn ended may be over (the agent went on since); undefined for a state that never was the session's.
|
|
72
|
+
*/
|
|
73
|
+
synced?: boolean;
|
|
69
74
|
/** Which of the last `messages` this client sent that the session does not have yet (SessionStore.send). */
|
|
70
75
|
outbox?: readonly OutboxMessage[];
|
|
71
76
|
}
|
|
@@ -32,7 +32,7 @@ class SessionStore extends session_client_tools_1.SessionClientTools {
|
|
|
32
32
|
this.holdMs = (_b = options.holdMs) !== null && _b !== void 0 ? _b : session_store_options_1.HOLD_MS;
|
|
33
33
|
if (options.initial) {
|
|
34
34
|
const { messages, start, tools } = options.initial;
|
|
35
|
-
this.current = this.shown = { ...this.current, messages, start, tools };
|
|
35
|
+
this.current = this.shown = { ...this.current, messages, start, tools, synced: false };
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
get state() {
|
|
@@ -56,6 +56,9 @@ class SessionStore extends session_client_tools_1.SessionClientTools {
|
|
|
56
56
|
for (const stop of this.stop.splice(0)) {
|
|
57
57
|
stop();
|
|
58
58
|
}
|
|
59
|
+
// Not through `update`: what it shows changes, the calls it runs do not.
|
|
60
|
+
this.current = { ...this.current, synced: false };
|
|
61
|
+
this.show();
|
|
59
62
|
await this.connection.server.detach(this.sessionId);
|
|
60
63
|
}
|
|
61
64
|
subscribe(listener) {
|
|
@@ -296,6 +299,7 @@ class SessionStore extends session_client_tools_1.SessionClientTools {
|
|
|
296
299
|
pendingUi: result.pendingUi,
|
|
297
300
|
pendingClientTools: result.pendingClientTools,
|
|
298
301
|
working: result.info.isStreaming,
|
|
302
|
+
synced: true,
|
|
299
303
|
};
|
|
300
304
|
if (result.shownUi) {
|
|
301
305
|
// What the extensions show now, whatever events were missed.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaPageServer, type TaPresenceServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaVoiceEvent, type TaVoiceServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
1
|
+
import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, type TaDesktopEvent, type TaErrorData, type TaEventEnvelope, type TaGatewayServer, type TaPackageServer, type TaPageServer, type TaPresenceServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaRoomEvent, type TaRoomServer, type TaScreenShareServer, type TaServer, type TaSessionInfo, type TaSettingsServer, type TaTerminalServer, type TaVoiceEvent, type TaVoiceServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
|
|
2
2
|
import type { TaConnectionOptions, TaSocket } from './ta-connection-options';
|
|
3
3
|
interface PendingCall {
|
|
4
4
|
resolve(result: unknown): void;
|
|
@@ -57,6 +57,8 @@ export declare class TaConnection {
|
|
|
57
57
|
readonly gateway: TaGatewayServer;
|
|
58
58
|
readonly relay: TaRelayServer;
|
|
59
59
|
readonly remote: TaRemoteServer;
|
|
60
|
+
/** Desktops of other computers, seen and worked (docs/design/ta-desktop-remote.md). */
|
|
61
|
+
readonly screenShare: TaScreenShareServer;
|
|
60
62
|
readonly rooms: TaRoomServer;
|
|
61
63
|
/** What this page is at, for the others in the same Ta (docs/design/ta-team.md 7). */
|
|
62
64
|
readonly presence: TaPresenceServer;
|
|
@@ -77,6 +79,7 @@ export declare class TaConnection {
|
|
|
77
79
|
protected readonly remoteListeners: Set<RemoteEventListener>;
|
|
78
80
|
protected readonly roomListeners: Set<RoomEventListener>;
|
|
79
81
|
protected readonly voiceListeners: Set<VoiceEventListener>;
|
|
82
|
+
protected readonly desktopListeners: Set<(event: TaDesktopEvent) => void>;
|
|
80
83
|
protected pageAsk?: PageAskHandler;
|
|
81
84
|
protected readonly sessionsListeners: Set<SessionsListener>;
|
|
82
85
|
protected readonly openListeners: Set<OpenListener>;
|
|
@@ -110,6 +113,8 @@ export declare class TaConnection {
|
|
|
110
113
|
/** What the voices this connection opened tell (TaVoiceServer.openVoice). */
|
|
111
114
|
/** Answers what ta serve asks this page (TaClient.onPageAsk): one handler, the last set; without one, an error. */
|
|
112
115
|
onPageAsk(handler: PageAskHandler | undefined): void;
|
|
116
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
117
|
+
onScreenShareEvent(listener: (event: TaDesktopEvent) => void): () => void;
|
|
113
118
|
onVoiceEvent(listener: VoiceEventListener): () => void;
|
|
114
119
|
/** The open sessions as they change (TaClient.onSessions), once this connection called TaServer.watchSessions. */
|
|
115
120
|
onSessions(listener: SessionsListener): () => void;
|
|
@@ -138,7 +143,8 @@ export declare class TaConnection {
|
|
|
138
143
|
protected service<T extends object>(name: string): T;
|
|
139
144
|
/**
|
|
140
145
|
* Whether a call may go again after a lost connection, as doing it twice does what doing it once does:
|
|
141
|
-
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once
|
|
146
|
+
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once; of a desktop, a view
|
|
147
|
+
* opened or text pasted by its id, input by its seq, a view by its revision (docs/design/ta-desktop-remote.md 5.3).
|
|
142
148
|
*/
|
|
143
149
|
static resendable(service: string, method: string, params: readonly unknown[]): boolean;
|
|
144
150
|
protected call(service: string, method: string, params: unknown[]): Promise<unknown>;
|
|
@@ -7,6 +7,8 @@ const ta_remote_error_1 = require("./ta-remote-error");
|
|
|
7
7
|
const READ_METHOD = /^(get|list|read|find)[A-Z]/;
|
|
8
8
|
/** Methods whose input carries a clientMessageId, by which ta serve takes a message once however often it comes. */
|
|
9
9
|
const MESSAGE_METHODS = new Set(['prompt', 'steer', 'followUp']);
|
|
10
|
+
/** Calls of TaScreenShareServer that ta serve takes once (an id, a seq, a revision), so that they may go again. */
|
|
11
|
+
const DESKTOP_ONCE = new Set(['openDesktop', 'pasteToDesktop', 'sendDesktopInput', 'setDesktopView']);
|
|
10
12
|
/**
|
|
11
13
|
* A connection to `ta serve` on the `WebSocket` of the platform, with no other dependency, so that it
|
|
12
14
|
* fits a browser, Electron or a mobile app. It reconnects until closed; `onOpen` runs each time, for
|
|
@@ -34,6 +36,8 @@ class TaConnection {
|
|
|
34
36
|
this.gateway = this.service(ta_protocol_1.TA_GATEWAY_SERVICE);
|
|
35
37
|
this.relay = this.service(ta_protocol_1.TA_RELAY_SERVICE);
|
|
36
38
|
this.remote = this.service(ta_protocol_1.TA_REMOTE_SERVICE);
|
|
39
|
+
/** Desktops of other computers, seen and worked (docs/design/ta-desktop-remote.md). */
|
|
40
|
+
this.screenShare = this.service(ta_protocol_1.TA_SCREEN_SHARE_SERVICE);
|
|
37
41
|
this.rooms = this.service(ta_protocol_1.TA_ROOM_SERVICE);
|
|
38
42
|
/** What this page is at, for the others in the same Ta (docs/design/ta-team.md 7). */
|
|
39
43
|
this.presence = this.service(ta_protocol_1.TA_PRESENCE_SERVICE);
|
|
@@ -52,6 +56,7 @@ class TaConnection {
|
|
|
52
56
|
this.remoteListeners = new Set();
|
|
53
57
|
this.roomListeners = new Set();
|
|
54
58
|
this.voiceListeners = new Set();
|
|
59
|
+
this.desktopListeners = new Set();
|
|
55
60
|
this.sessionsListeners = new Set();
|
|
56
61
|
this.openListeners = new Set();
|
|
57
62
|
this.closeListeners = new Set();
|
|
@@ -110,6 +115,11 @@ class TaConnection {
|
|
|
110
115
|
onPageAsk(handler) {
|
|
111
116
|
this.pageAsk = handler;
|
|
112
117
|
}
|
|
118
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
119
|
+
onScreenShareEvent(listener) {
|
|
120
|
+
this.desktopListeners.add(listener);
|
|
121
|
+
return () => this.desktopListeners.delete(listener);
|
|
122
|
+
}
|
|
113
123
|
onVoiceEvent(listener) {
|
|
114
124
|
this.voiceListeners.add(listener);
|
|
115
125
|
return () => this.voiceListeners.delete(listener);
|
|
@@ -288,13 +298,17 @@ class TaConnection {
|
|
|
288
298
|
}
|
|
289
299
|
/**
|
|
290
300
|
* Whether a call may go again after a lost connection, as doing it twice does what doing it once does:
|
|
291
|
-
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once
|
|
301
|
+
* a read, or a message with its clientMessageId (TaPromptInput), which ta serve takes once; of a desktop, a view
|
|
302
|
+
* opened or text pasted by its id, input by its seq, a view by its revision (docs/design/ta-desktop-remote.md 5.3).
|
|
292
303
|
*/
|
|
293
304
|
static resendable(service, method, params) {
|
|
294
305
|
var _a;
|
|
295
306
|
if (READ_METHOD.test(method)) {
|
|
296
307
|
return true;
|
|
297
308
|
}
|
|
309
|
+
if (service === ta_protocol_1.TA_SCREEN_SHARE_SERVICE) {
|
|
310
|
+
return DESKTOP_ONCE.has(method);
|
|
311
|
+
}
|
|
298
312
|
return service === ta_protocol_1.TA_SERVER_SERVICE && MESSAGE_METHODS.has(method) && !!((_a = params[1]) === null || _a === void 0 ? void 0 : _a.clientMessageId);
|
|
299
313
|
}
|
|
300
314
|
async call(service, method, params) {
|
|
@@ -377,7 +391,7 @@ class TaConnection {
|
|
|
377
391
|
}
|
|
378
392
|
}
|
|
379
393
|
receive(text) {
|
|
380
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
394
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
381
395
|
this.lastReceivedAt = Date.now();
|
|
382
396
|
const message = JSON.parse(text);
|
|
383
397
|
if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onEvents`) {
|
|
@@ -429,12 +443,20 @@ class TaConnection {
|
|
|
429
443
|
(_f = this.socket) === null || _f === void 0 ? void 0 : _f.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
430
444
|
return;
|
|
431
445
|
}
|
|
446
|
+
if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onScreenShareEvent`) {
|
|
447
|
+
const [event] = message.params;
|
|
448
|
+
for (const listener of this.desktopListeners) {
|
|
449
|
+
listener(event);
|
|
450
|
+
}
|
|
451
|
+
(_g = this.socket) === null || _g === void 0 ? void 0 : _g.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
432
454
|
if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onVoiceEvent`) {
|
|
433
455
|
const [event] = message.params;
|
|
434
456
|
for (const listener of this.voiceListeners) {
|
|
435
457
|
listener(event);
|
|
436
458
|
}
|
|
437
|
-
(
|
|
459
|
+
(_h = this.socket) === null || _h === void 0 ? void 0 : _h.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
438
460
|
return;
|
|
439
461
|
}
|
|
440
462
|
if (message.method === `${ta_protocol_1.TA_CLIENT_SERVICE}/onPageAsk`) {
|
|
@@ -447,7 +469,7 @@ class TaConnection {
|
|
|
447
469
|
for (const listener of this.extensionDataListeners) {
|
|
448
470
|
listener(name, keys, cwd !== null && cwd !== void 0 ? cwd : undefined);
|
|
449
471
|
}
|
|
450
|
-
(
|
|
472
|
+
(_j = this.socket) === null || _j === void 0 ? void 0 : _j.send(JSON.stringify({ jsonrpc: '2.0', id: message.id, result: null }));
|
|
451
473
|
return;
|
|
452
474
|
}
|
|
453
475
|
const call = this.pending.get(message.id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.18.0",
|
|
4
4
|
"description": "A client of ta serve for any JavaScript runtime: connection and UI-independent session state",
|
|
5
5
|
"homepage": "https://github.com/cellbang/ta",
|
|
6
6
|
"bugs": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@celljs/ta-protocol": "4.
|
|
32
|
+
"@celljs/ta-protocol": "4.18.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@earendil-works/pi-ai": "^1.5.2",
|