@celljs/ta-web 4.21.0 → 4.23.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/browser/assistant/assistant-chat-list.js +5 -1
- package/esm/browser/assistant/assistant-conversation.js +1 -1
- package/esm/browser/assistant/assistant-initiative.d.ts +5 -1
- package/esm/browser/assistant/assistant-initiative.js +11 -3
- package/esm/browser/assistant/call-keeper.d.ts +2 -1
- package/esm/browser/assistant/call-keeper.js +4 -2
- package/esm/browser/assistant/call-screen.d.ts +1 -1
- package/esm/browser/assistant/call-turn-end.d.ts +11 -2
- package/esm/browser/assistant/call-turn-end.js +21 -5
- package/esm/browser/assistant/read-aloud.d.ts +1 -1
- package/esm/browser/assistant/realtime-voice.d.ts +1 -1
- package/esm/browser/assistant/voice-call-bar.d.ts +5 -2
- package/esm/browser/assistant/voice-call-bar.js +12 -0
- package/esm/browser/assistant/voice-call-protocol.d.ts +78 -0
- package/esm/browser/assistant/voice-call-protocol.js +2 -0
- package/esm/browser/assistant/voice-call.d.ts +17 -65
- package/esm/browser/assistant/voice-call.js +45 -1
- package/esm/browser/assistant/voice-reopen.d.ts +1 -1
- package/esm/browser/components/account-menu.js +28 -7
- package/esm/browser/components/chat-home-util.d.ts +13 -2
- package/esm/browser/components/chat-home-util.js +29 -0
- package/esm/browser/components/chat-home.d.ts +18 -4
- package/esm/browser/components/chat-home.js +11 -3
- package/esm/browser/components/chat-list.js +4 -2
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/earlier-messages.d.ts +4 -0
- package/esm/browser/components/earlier-messages.js +10 -2
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/message-footer.d.ts +0 -2
- package/esm/browser/components/message-footer.js +1 -8
- package/esm/browser/components/message-images.d.ts +22 -0
- package/esm/browser/components/message-images.js +90 -1
- package/esm/browser/components/message-steps.js +9 -0
- package/esm/browser/components/message-user.js +8 -1
- package/esm/browser/components/partner-row-util.d.ts +28 -0
- package/esm/browser/components/partner-row-util.js +45 -0
- package/esm/browser/components/partner-row.d.ts +18 -0
- package/esm/browser/components/partner-row.js +60 -0
- package/esm/browser/components/profile-view.d.ts +2 -2
- package/esm/browser/components/profile-view.js +6 -3
- package/esm/browser/components/web-composer.d.ts +5 -2
- package/esm/browser/components/web-composer.js +10 -5
- package/esm/browser/extension/extension-view.js +2 -2
- package/esm/browser/extension/icons.js +4 -1
- package/esm/browser/extension/web-api-call.d.ts +45 -0
- package/esm/browser/extension/web-api-call.js +2 -0
- package/esm/browser/extension/web-api-components.d.ts +37 -2
- package/esm/browser/extension/web-api-contributions.d.ts +2 -31
- package/esm/browser/extension/web-api-home.d.ts +1 -0
- package/esm/browser/extension/web-api-partners.d.ts +112 -0
- package/esm/browser/extension/web-api-partners.js +2 -0
- package/esm/browser/extension/web-extension-api.d.ts +12 -15
- package/esm/browser/extension/web-extension-context.d.ts +2 -3
- package/esm/browser/extension/web-extension-context.js +7 -7
- package/esm/browser/extension/web-extension-protocol.d.ts +8 -2
- package/esm/browser/extension/web-extension-run.d.ts +2 -1
- package/esm/browser/extension/web-extension-run.js +1 -0
- package/esm/browser/extension/web-extensions-running.d.ts +2 -0
- package/esm/browser/extension/web-extensions-running.js +3 -0
- package/esm/browser/extension/web-extensions.d.ts +1 -1
- package/esm/browser/extension/web-home.d.ts +11 -19
- package/esm/browser/extension/web-home.js +15 -68
- package/esm/browser/extension/web-partners.d.ts +8 -0
- package/esm/browser/extension/web-partners.js +13 -0
- package/esm/browser/extension/web-row-board.d.ts +38 -0
- package/esm/browser/extension/web-row-board.js +79 -0
- package/esm/browser/i18n/locales.d.ts +28 -1
- package/esm/browser/i18n/messages-ja.js +27 -0
- package/esm/browser/i18n/messages-zh-tw.js +27 -0
- package/esm/browser/i18n/messages.d.ts +27 -0
- package/esm/browser/i18n/messages.js +54 -0
- package/esm/browser/index.d.ts +4 -0
- package/esm/browser/index.js +4 -0
- package/esm/browser/partners/group-picker.d.ts +18 -0
- package/esm/browser/partners/group-picker.js +81 -0
- package/esm/browser/partners/partners-extension.d.ts +14 -0
- package/esm/browser/partners/partners-extension.js +78 -0
- package/esm/browser/partners/partners-util.d.ts +32 -0
- package/esm/browser/partners/partners-util.js +68 -0
- package/esm/browser/partners/partners-view.d.ts +32 -0
- package/esm/browser/partners/partners-view.js +103 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +21 -0
- package/esm/browser/style/conversation-column.d.ts +1 -1
- package/esm/browser/style/conversation-column.js +21 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +2 -2
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +1 -1
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +1 -1
- package/esm/browser/util/image-shrink.d.ts +26 -0
- package/esm/browser/util/image-shrink.js +60 -0
- package/esm/browser/util/process.d.ts +7 -3
- package/esm/browser/util/process.js +18 -18
- package/lib/browser/assistant/assistant-chat-list.js +5 -1
- package/lib/browser/assistant/assistant-conversation.js +1 -1
- package/lib/browser/assistant/assistant-initiative.d.ts +5 -1
- package/lib/browser/assistant/assistant-initiative.js +11 -3
- package/lib/browser/assistant/call-keeper.d.ts +2 -1
- package/lib/browser/assistant/call-keeper.js +4 -2
- package/lib/browser/assistant/call-screen.d.ts +1 -1
- package/lib/browser/assistant/call-turn-end.d.ts +11 -2
- package/lib/browser/assistant/call-turn-end.js +22 -6
- package/lib/browser/assistant/read-aloud.d.ts +1 -1
- package/lib/browser/assistant/realtime-voice.d.ts +1 -1
- package/lib/browser/assistant/voice-call-bar.d.ts +5 -2
- package/lib/browser/assistant/voice-call-bar.js +12 -0
- package/lib/browser/assistant/voice-call-protocol.d.ts +79 -0
- package/lib/browser/assistant/voice-call-protocol.js +3 -0
- package/lib/browser/assistant/voice-call.d.ts +17 -65
- package/lib/browser/assistant/voice-call.js +45 -1
- package/lib/browser/assistant/voice-reopen.d.ts +1 -1
- package/lib/browser/components/account-menu.js +27 -6
- package/lib/browser/components/chat-home-util.d.ts +13 -2
- package/lib/browser/components/chat-home-util.js +29 -0
- package/lib/browser/components/chat-home.d.ts +18 -4
- package/lib/browser/components/chat-home.js +12 -3
- package/lib/browser/components/chat-list.js +4 -2
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/earlier-messages.d.ts +4 -0
- package/lib/browser/components/earlier-messages.js +10 -2
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/message-footer.d.ts +0 -2
- package/lib/browser/components/message-footer.js +0 -8
- package/lib/browser/components/message-images.d.ts +22 -0
- package/lib/browser/components/message-images.js +92 -2
- package/lib/browser/components/message-steps.js +9 -0
- package/lib/browser/components/message-user.js +7 -0
- package/lib/browser/components/partner-row-util.d.ts +29 -0
- package/lib/browser/components/partner-row-util.js +48 -0
- package/lib/browser/components/partner-row.d.ts +19 -0
- package/lib/browser/components/partner-row.js +96 -0
- package/lib/browser/components/profile-view.d.ts +2 -2
- package/lib/browser/components/profile-view.js +6 -3
- package/lib/browser/components/web-composer.d.ts +5 -2
- package/lib/browser/components/web-composer.js +10 -5
- package/lib/browser/extension/extension-view.js +2 -2
- package/lib/browser/extension/icons.js +3 -0
- package/lib/browser/extension/web-api-call.d.ts +46 -0
- package/lib/browser/extension/web-api-call.js +3 -0
- package/lib/browser/extension/web-api-components.d.ts +37 -2
- package/lib/browser/extension/web-api-contributions.d.ts +2 -31
- package/lib/browser/extension/web-api-home.d.ts +1 -0
- package/lib/browser/extension/web-api-partners.d.ts +113 -0
- package/lib/browser/extension/web-api-partners.js +3 -0
- package/lib/browser/extension/web-extension-api.d.ts +12 -15
- package/lib/browser/extension/web-extension-context.d.ts +2 -3
- package/lib/browser/extension/web-extension-context.js +7 -7
- package/lib/browser/extension/web-extension-protocol.d.ts +8 -2
- package/lib/browser/extension/web-extension-run.d.ts +2 -1
- package/lib/browser/extension/web-extension-run.js +1 -0
- package/lib/browser/extension/web-extensions-running.d.ts +2 -0
- package/lib/browser/extension/web-extensions-running.js +3 -0
- package/lib/browser/extension/web-extensions.d.ts +1 -1
- package/lib/browser/extension/web-home.d.ts +11 -19
- package/lib/browser/extension/web-home.js +15 -68
- package/lib/browser/extension/web-partners.d.ts +9 -0
- package/lib/browser/extension/web-partners.js +17 -0
- package/lib/browser/extension/web-row-board.d.ts +39 -0
- package/lib/browser/extension/web-row-board.js +83 -0
- package/lib/browser/i18n/locales.d.ts +28 -1
- package/lib/browser/i18n/messages-ja.js +27 -0
- package/lib/browser/i18n/messages-zh-tw.js +27 -0
- package/lib/browser/i18n/messages.d.ts +27 -0
- package/lib/browser/i18n/messages.js +54 -0
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.js +4 -0
- package/lib/browser/partners/group-picker.d.ts +19 -0
- package/lib/browser/partners/group-picker.js +119 -0
- package/lib/browser/partners/partners-extension.d.ts +15 -0
- package/lib/browser/partners/partners-extension.js +114 -0
- package/lib/browser/partners/partners-util.d.ts +33 -0
- package/lib/browser/partners/partners-util.js +71 -0
- package/lib/browser/partners/partners-view.d.ts +33 -0
- package/lib/browser/partners/partners-view.js +144 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +21 -0
- package/lib/browser/style/conversation-column.d.ts +1 -1
- package/lib/browser/style/conversation-column.js +21 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +2 -2
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +1 -1
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +1 -1
- package/lib/browser/util/image-shrink.d.ts +27 -0
- package/lib/browser/util/image-shrink.js +63 -0
- package/lib/browser/util/process.d.ts +7 -3
- package/lib/browser/util/process.js +18 -18
- package/package.json +7 -7
|
@@ -1,70 +1,7 @@
|
|
|
1
1
|
import { Voice } from '../util/voice';
|
|
2
|
-
import { CallTurnEnd
|
|
2
|
+
import { CallTurnEnd } from './call-turn-end';
|
|
3
|
+
import type { CallDraft, CallEnd, CallOptions, CallPartner, CallState, CallVoice } from './voice-call-protocol';
|
|
3
4
|
import { VoiceReopen } from './voice-reopen';
|
|
4
|
-
/** Where a call is: Ta listens to the user, works on what they said, or says its answer. */
|
|
5
|
-
export type CallPhase = 'connecting' | 'listening' | 'thinking' | 'speaking';
|
|
6
|
-
export interface CallState {
|
|
7
|
-
active: boolean;
|
|
8
|
-
phase: CallPhase;
|
|
9
|
-
/** What the user has said so far, while Ta listens. */
|
|
10
|
-
heard: string;
|
|
11
|
-
/** What the user said last, kept while Ta works on it and answers, until they say more: the captions. */
|
|
12
|
-
said?: string;
|
|
13
|
-
/** The answer being read, by sentences, and the one being read now: the captions. Kept after, until the user says more. */
|
|
14
|
-
reading?: {
|
|
15
|
-
pieces: string[];
|
|
16
|
-
at: number;
|
|
17
|
-
};
|
|
18
|
-
/** The page is hidden (another app in front, the screen locked): Ta neither listens nor speaks until it shows again. */
|
|
19
|
-
paused?: boolean;
|
|
20
|
-
/** A partner answers in this call (CallPartner), and tells the news of the work itself. */
|
|
21
|
-
partnered?: boolean;
|
|
22
|
-
/** Its voice hears the user cut in while Ta speaks: no need to tap. */
|
|
23
|
-
bargeIn?: boolean;
|
|
24
|
-
}
|
|
25
|
-
/** What a call uses of the page's voice: Voice by default, a service of voices.json (RealtimeVoice), a fake in tests. */
|
|
26
|
-
export interface CallVoice {
|
|
27
|
-
listen: typeof Voice.listen;
|
|
28
|
-
speak(text: string, language: string, onEnd: () => void, voice?: string, onPiece?: (pieces: string[], index: number) => void): void;
|
|
29
|
-
hush(): void;
|
|
30
|
-
/** It hears the user begin to speak even while Ta reads: the call stops reading and listens (barge-in). */
|
|
31
|
-
onSpeech?(listener: () => void): () => void;
|
|
32
|
-
/** false: the user chose to stop Ta with a tap only, not by speaking (TaBargeIn.tap). */
|
|
33
|
-
readonly cutsIn?: boolean;
|
|
34
|
-
/** The call ended: it lets go of what it holds (the microphone, the service). */
|
|
35
|
-
stop?(): void;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Who answers in a call in place of the conversation itself: a front that only talks, handing the work to the
|
|
39
|
-
* conversation (docs/design/ta-call.md), opened as the call starts and closed as it ends.
|
|
40
|
-
*/
|
|
41
|
-
export interface CallPartner {
|
|
42
|
-
/** What the user said; the reply, as said aloud. `sent`: it went to the conversation already (let go over 通话). */
|
|
43
|
-
say(text: string, options?: {
|
|
44
|
-
sent?: boolean;
|
|
45
|
-
}): Promise<string | undefined>;
|
|
46
|
-
/** What it says by itself (news of the work), told as it comes, until it closes: the call announces it. */
|
|
47
|
-
news?(listener: (text: string) => void): void;
|
|
48
|
-
/** Whether it ended the call (WebCallSession.ending): Ta hangs up once its reply is said. */
|
|
49
|
-
ending?(): boolean;
|
|
50
|
-
close(): void;
|
|
51
|
-
}
|
|
52
|
-
/** Why a call ended by itself. */
|
|
53
|
-
export type CallEnd = 'silent' | 'denied' | 'unavailable' | 'failed';
|
|
54
|
-
export interface CallOptions extends CallTurnTimes {
|
|
55
|
-
language(): string;
|
|
56
|
-
voice(): string | undefined;
|
|
57
|
-
/** Sends what the user said to the conversation. */
|
|
58
|
-
send(text: string): Promise<unknown>;
|
|
59
|
-
/** The call ended by itself: why, for a notice; `detail` what the voice service said. */
|
|
60
|
-
ended?(reason: CallEnd, detail?: string): void;
|
|
61
|
-
/** The voice of a service the call opens as it starts; undefined for that of the device. */
|
|
62
|
-
openVoice?(): Promise<CallVoice | undefined> | undefined;
|
|
63
|
-
/** Who answers in its place, opened as the call starts; undefined (or failing) for the conversation itself. */
|
|
64
|
-
openPartner?(): Promise<CallPartner | undefined> | undefined;
|
|
65
|
-
/** How long nobody may speak before the call ends by itself; default SILENT_MS. */
|
|
66
|
-
silentMs?: number;
|
|
67
|
-
}
|
|
68
5
|
/**
|
|
69
6
|
* A call with a conversation (the double's, or any other), by the voice of the page: Ta listens until the user pauses, sends what they said, reads
|
|
70
7
|
* its answer out, then listens again, until the user hangs up or says nothing for a while. With the voice of the device
|
|
@@ -99,6 +36,13 @@ export declare class VoiceCall {
|
|
|
99
36
|
protected partner?: CallPartner;
|
|
100
37
|
/** Its voice service opening again (revoice). */
|
|
101
38
|
protected reopening?: VoiceReopen;
|
|
39
|
+
/** The answer begun on what the user said so far (CallPartner.draft), and those words. */
|
|
40
|
+
protected drafted?: {
|
|
41
|
+
text: string;
|
|
42
|
+
draft: CallDraft;
|
|
43
|
+
};
|
|
44
|
+
/** A partner whose draft failed (an older Ta): it answers once the user is done only. */
|
|
45
|
+
protected draftless?: CallPartner;
|
|
102
46
|
constructor(options: CallOptions, device?: CallVoice);
|
|
103
47
|
subscribe(listener: () => void): () => void;
|
|
104
48
|
/**
|
|
@@ -181,6 +125,14 @@ export declare class VoiceCall {
|
|
|
181
125
|
protected heard(said: string, error: string | undefined, waited?: boolean): void;
|
|
182
126
|
/** What the user said goes to the partner, or to the conversation. */
|
|
183
127
|
protected take(said: string): void;
|
|
128
|
+
/**
|
|
129
|
+
* The words heard stayed the same a little, and may be all the user says: the partner begins its answer, said only
|
|
130
|
+
* should they be done with these words (take), dropped as they say more (docs/design/ta-call.md 10).
|
|
131
|
+
*/
|
|
132
|
+
protected suspect(text: string): void;
|
|
133
|
+
/** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
|
|
134
|
+
protected kept(draft: CallDraft, said: string): void;
|
|
135
|
+
protected dropDraft(): void;
|
|
184
136
|
/** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
|
|
185
137
|
protected open(direct: boolean): Promise<[CallVoice | undefined, CallPartner | undefined]> | undefined;
|
|
186
138
|
/** The partner answers what the user said; its reply is read as a turn's is. */
|
|
@@ -30,7 +30,7 @@ class VoiceCall {
|
|
|
30
30
|
/** What waits to be said that the user did not ask for (a dialog, a task that ended), in order. */
|
|
31
31
|
this.announcements = [];
|
|
32
32
|
this.voice = device;
|
|
33
|
-
this.turnEnd = new call_turn_end_1.CallTurnEnd(options, () => this.quiet());
|
|
33
|
+
this.turnEnd = new call_turn_end_1.CallTurnEnd(options, () => this.quiet(), text => this.suspect(text));
|
|
34
34
|
}
|
|
35
35
|
subscribe(listener) {
|
|
36
36
|
this.listeners.add(listener);
|
|
@@ -145,6 +145,7 @@ class VoiceCall {
|
|
|
145
145
|
if (!this.state.active) {
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
+
this.dropDraft();
|
|
148
149
|
(_a = this.partner) === null || _a === void 0 ? void 0 : _a.close();
|
|
149
150
|
this.partner = undefined;
|
|
150
151
|
this.calls++;
|
|
@@ -192,6 +193,7 @@ class VoiceCall {
|
|
|
192
193
|
return;
|
|
193
194
|
}
|
|
194
195
|
this.stopListening();
|
|
196
|
+
this.dropDraft();
|
|
195
197
|
if (this.state.phase === 'speaking') {
|
|
196
198
|
this.voice.hush();
|
|
197
199
|
this.pending = this.speaking;
|
|
@@ -294,6 +296,7 @@ class VoiceCall {
|
|
|
294
296
|
*/
|
|
295
297
|
listen(announce = true, held) {
|
|
296
298
|
this.stopListening();
|
|
299
|
+
this.dropDraft();
|
|
297
300
|
if (this.state.paused) {
|
|
298
301
|
return;
|
|
299
302
|
}
|
|
@@ -313,6 +316,10 @@ class VoiceCall {
|
|
|
313
316
|
// The user says more: the captions are of what they say now, the last exchange gone.
|
|
314
317
|
this.set(text.trim() ? { heard: text, said: undefined, reading: undefined } : { heard: text });
|
|
315
318
|
if (more && text.trim()) {
|
|
319
|
+
// They say more than the answer begun was to: it goes.
|
|
320
|
+
if (this.drafted && this.drafted.text !== text.trim()) {
|
|
321
|
+
this.dropDraft();
|
|
322
|
+
}
|
|
316
323
|
this.turnEnd.heard(text);
|
|
317
324
|
}
|
|
318
325
|
}
|
|
@@ -402,6 +409,13 @@ class VoiceCall {
|
|
|
402
409
|
this.silent = 0;
|
|
403
410
|
this.spoke = Date.now();
|
|
404
411
|
this.set({ phase: 'thinking', heard: said, said, reading: undefined });
|
|
412
|
+
const drafted = this.drafted;
|
|
413
|
+
this.drafted = undefined;
|
|
414
|
+
if (this.partner && (drafted === null || drafted === void 0 ? void 0 : drafted.text) === said) {
|
|
415
|
+
this.kept(drafted.draft, said);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
drafted === null || drafted === void 0 ? void 0 : drafted.draft.drop();
|
|
405
419
|
if (this.partner) {
|
|
406
420
|
this.ask(said);
|
|
407
421
|
}
|
|
@@ -409,6 +423,36 @@ class VoiceCall {
|
|
|
409
423
|
this.options.send(said).catch(() => this.state.active && this.unsent());
|
|
410
424
|
}
|
|
411
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* The words heard stayed the same a little, and may be all the user says: the partner begins its answer, said only
|
|
428
|
+
* should they be done with these words (take), dropped as they say more (docs/design/ta-call.md 10).
|
|
429
|
+
*/
|
|
430
|
+
suspect(text) {
|
|
431
|
+
var _a;
|
|
432
|
+
const said = text.trim();
|
|
433
|
+
const partner = this.partner;
|
|
434
|
+
if (!(partner === null || partner === void 0 ? void 0 : partner.draft) || this.draftless === partner || this.listened() !== said || ((_a = this.drafted) === null || _a === void 0 ? void 0 : _a.text) === said) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
this.dropDraft();
|
|
438
|
+
const draft = partner.draft(said);
|
|
439
|
+
draft.reply.catch(() => {
|
|
440
|
+
this.draftless = partner;
|
|
441
|
+
});
|
|
442
|
+
this.drafted = { text: said, draft };
|
|
443
|
+
}
|
|
444
|
+
/** The user was done with the words of the draft: its answer is the reply; failing, the partner is asked as usual. */
|
|
445
|
+
kept(draft, said) {
|
|
446
|
+
const call = this.calls;
|
|
447
|
+
const partner = this.partner;
|
|
448
|
+
draft.keep();
|
|
449
|
+
draft.reply.then(reply => call === this.calls && this.turnEnded(reply), () => call === this.calls && this.state.active && this.partner === partner && this.ask(said));
|
|
450
|
+
}
|
|
451
|
+
dropDraft() {
|
|
452
|
+
const drafted = this.drafted;
|
|
453
|
+
this.drafted = undefined;
|
|
454
|
+
drafted === null || drafted === void 0 ? void 0 : drafted.draft.drop();
|
|
455
|
+
}
|
|
412
456
|
/** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
|
|
413
457
|
open(direct) {
|
|
414
458
|
var _a, _b, _c, _d, _e;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallVoice } from './voice-call';
|
|
1
|
+
import type { CallVoice } from './voice-call-protocol';
|
|
2
2
|
/**
|
|
3
3
|
* Opens the voice service of a call again once it went (ta serve restarted, the connection dropped): tries until it
|
|
4
4
|
* opens or MS passed, waiting RETRY_MS between tries; a voice that opens too late is let go.
|
|
@@ -177,25 +177,46 @@ function AccountFigure({ size, className }) {
|
|
|
177
177
|
return (React.createElement("span", { className: className },
|
|
178
178
|
React.createElement(face_1.Face, { double: true, size: size })));
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* The name and account last shown for each computer, so that the page opens with them rather than with the user of
|
|
182
|
+
* the computer and no account until they are read again.
|
|
183
|
+
*/
|
|
184
|
+
const SHOWN = {
|
|
185
|
+
key: 'account.shown',
|
|
186
|
+
tier: 'device',
|
|
187
|
+
initial: {},
|
|
188
|
+
parse: value => (value && typeof value === 'object' && !Array.isArray(value) ? value : undefined),
|
|
189
|
+
};
|
|
180
190
|
/** Who the user is (their name, their account), the machine in use (as named on this device), and whether the page is connected to it. */
|
|
181
191
|
function useAccount() {
|
|
182
|
-
var _a
|
|
192
|
+
var _a;
|
|
193
|
+
var _b, _c;
|
|
183
194
|
const t = (0, use_t_1.useT)();
|
|
184
|
-
const
|
|
185
|
-
const
|
|
195
|
+
const read = (_a = (0, profile_view_1.useIdentity)()) === null || _a === void 0 ? void 0 : _a.name;
|
|
196
|
+
const line = (0, profile_view_1.useAccountLine)();
|
|
186
197
|
const [{ status, server, offlineShown, hosts, host }] = (0, hooks_1.useWorkbench)();
|
|
198
|
+
const [shown, keepShown] = (0, hooks_1.usePersisted)(SHOWN);
|
|
199
|
+
const key = host !== null && host !== void 0 ? host : '';
|
|
200
|
+
const last = shown[key];
|
|
201
|
+
const name = read !== null && read !== void 0 ? read : last === null || last === void 0 ? void 0 : last.name;
|
|
202
|
+
const account = line === undefined ? last === null || last === void 0 ? void 0 : last.account : line;
|
|
203
|
+
React.useEffect(() => {
|
|
204
|
+
if ((read !== undefined || line !== undefined) && (name !== (last === null || last === void 0 ? void 0 : last.name) || account !== (last === null || last === void 0 ? void 0 : last.account))) {
|
|
205
|
+
keepShown(previous => ({ ...previous, [key]: { name, account } }));
|
|
206
|
+
}
|
|
207
|
+
}, [read, line, name, account, last, key, keepShown]);
|
|
187
208
|
const online = status === 'online';
|
|
188
209
|
const state = online ? t('ta.online') : t('ta.reconnecting');
|
|
189
210
|
const inUse = hosts.find(one => one.id === host);
|
|
190
|
-
const machine = ((
|
|
211
|
+
const machine = ((_b = inUse === null || inUse === void 0 ? void 0 : inUse.name) !== null && _b !== void 0 ? _b : server === null || server === void 0 ? void 0 : server.host) || undefined;
|
|
191
212
|
return {
|
|
192
213
|
server,
|
|
193
214
|
machine,
|
|
194
215
|
online,
|
|
195
216
|
offlineShown,
|
|
196
217
|
state,
|
|
197
|
-
name: (_c =
|
|
198
|
-
account,
|
|
218
|
+
name: (_c = name !== null && name !== void 0 ? name : server === null || server === void 0 ? void 0 : server.user) !== null && _c !== void 0 ? _c : t('ta.account'),
|
|
219
|
+
account: account !== null && account !== void 0 ? account : undefined,
|
|
199
220
|
service: server && online ? `${state} · v${server.version}` : state,
|
|
200
221
|
};
|
|
201
222
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebHomeEntry, WebMenuItem, WebTaskEntry, WebViewPreview } from '../extension/web-extension-api';
|
|
1
|
+
import type { WebHomeEntry, WebMenuItem, WebPartnerEntry, WebTaskEntry, WebViewPreview } from '../extension/web-extension-api';
|
|
2
2
|
import type { Translate } from '../i18n/use-t';
|
|
3
3
|
import type { ChatSeen } from './chat-seen';
|
|
4
4
|
import type { ContextMenuItem } from './context-menu';
|
|
@@ -11,6 +11,11 @@ export interface ChatHome {
|
|
|
11
11
|
double: ChatHomeDouble;
|
|
12
12
|
/** The rows extensions add to the double's list (ChatHomeUtil.items), pinned at first. */
|
|
13
13
|
items: readonly WebHomeEntry[];
|
|
14
|
+
/**
|
|
15
|
+
* The conversations with partners that are none of pi (PartnersUtil.chats): a chat of two, a group chat, rows of the
|
|
16
|
+
* list by their time as any conversation (docs/design/ta-partners.md).
|
|
17
|
+
*/
|
|
18
|
+
partners: readonly WebPartnerEntry[];
|
|
14
19
|
/** The key of the row whose page is in front, as a conversation of the list is (WebExtensionsState.pageFrom). */
|
|
15
20
|
shownItem?: string;
|
|
16
21
|
/** Opens a row: a page it shows is shown beside the list (TaWebExtensions.openHome). */
|
|
@@ -57,12 +62,14 @@ export interface ChatTaskRow {
|
|
|
57
62
|
task: WebTaskEntry;
|
|
58
63
|
updatedAt: number;
|
|
59
64
|
}
|
|
60
|
-
/** A row an extension adds to the double's list (registerHomeItems): pinned, or where its time is. */
|
|
65
|
+
/** A row an extension adds to the double's list (registerHomeItems), or a partner's conversation: pinned, or where its time is. */
|
|
61
66
|
export interface ChatHomeRow {
|
|
62
67
|
/** `home:<extension>/<id>`, as PINNED keeps it. */
|
|
63
68
|
key: string;
|
|
64
69
|
item: WebHomeEntry;
|
|
65
70
|
updatedAt: number;
|
|
71
|
+
/** The partner whose conversation it is: drawn as the partners draw it (PartnerRow). */
|
|
72
|
+
partner?: WebPartnerEntry;
|
|
66
73
|
}
|
|
67
74
|
export declare namespace ChatHomeUtil {
|
|
68
75
|
/** Those of the double's home: under it (`double`), or without a place nor a section. */
|
|
@@ -73,6 +80,10 @@ export declare namespace ChatHomeUtil {
|
|
|
73
80
|
function at(task: Pick<WebTaskEntry, 'startedAt' | 'endedAt'>): number;
|
|
74
81
|
function row(task: WebTaskEntry): ChatTaskRow;
|
|
75
82
|
function homeRow(item: WebHomeEntry): ChatHomeRow;
|
|
83
|
+
/** The rows of the home and of the partners' conversations that have the query, as the list places them by time. */
|
|
84
|
+
function homeRows(items: readonly WebHomeEntry[], partners: readonly WebPartnerEntry[], query: string): ChatHomeRow[];
|
|
85
|
+
/** The row of a partner's conversation, opened as a row of the home is (its page shown as from the list). */
|
|
86
|
+
function partnerRow(partner: WebPartnerEntry): ChatHomeRow;
|
|
76
87
|
/** The conversations rows of the home stand for (WebHomeItem.sessionFile): not listed again. */
|
|
77
88
|
function standIns(items: readonly WebHomeEntry[]): ReadonlySet<string>;
|
|
78
89
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ChatHomeUtil = void 0;
|
|
4
4
|
const web_tasks_1 = require("../extension/web-tasks");
|
|
5
|
+
const partners_util_1 = require("../partners/partners-util");
|
|
5
6
|
var ChatHomeUtil;
|
|
6
7
|
(function (ChatHomeUtil) {
|
|
7
8
|
/** Those of the double's home: under it (`double`), or without a place nor a section. */
|
|
@@ -36,6 +37,34 @@ var ChatHomeUtil;
|
|
|
36
37
|
return { key: `home:${item.key}`, item, updatedAt: (_a = item.at) !== null && _a !== void 0 ? _a : 0 };
|
|
37
38
|
}
|
|
38
39
|
ChatHomeUtil.homeRow = homeRow;
|
|
40
|
+
/** The rows of the home and of the partners' conversations that have the query, as the list places them by time. */
|
|
41
|
+
function homeRows(items, partners, query) {
|
|
42
|
+
return [
|
|
43
|
+
...items.filter(item => matches(query, item.title, item.detail)).map(homeRow),
|
|
44
|
+
...partners.filter(partner => { var _a; return matches(query, partner.name, (_a = partner.chat) === null || _a === void 0 ? void 0 : _a.last); }).map(partnerRow),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
ChatHomeUtil.homeRows = homeRows;
|
|
48
|
+
/** The row of a partner's conversation, opened as a row of the home is (its page shown as from the list). */
|
|
49
|
+
function partnerRow(partner) {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
var _d;
|
|
52
|
+
const item = {
|
|
53
|
+
id: partner.id,
|
|
54
|
+
key: partner.key,
|
|
55
|
+
extension: partner.extension,
|
|
56
|
+
tone: partner.tone,
|
|
57
|
+
title: partner.name,
|
|
58
|
+
detail: (_a = partner.chat) === null || _a === void 0 ? void 0 : _a.last,
|
|
59
|
+
icon: partner.icon,
|
|
60
|
+
face: partner.face,
|
|
61
|
+
at: (_b = partner.chat) === null || _b === void 0 ? void 0 : _b.at,
|
|
62
|
+
unseen: partners_util_1.PartnersUtil.unseen(partner),
|
|
63
|
+
open: partner.open,
|
|
64
|
+
};
|
|
65
|
+
return { key: `home:${partner.key}`, item, updatedAt: (_d = (_c = partner.chat) === null || _c === void 0 ? void 0 : _c.at) !== null && _d !== void 0 ? _d : 0, partner };
|
|
66
|
+
}
|
|
67
|
+
ChatHomeUtil.partnerRow = partnerRow;
|
|
39
68
|
/** The conversations rows of the home stand for (WebHomeItem.sessionFile): not listed again. */
|
|
40
69
|
function standIns(items) {
|
|
41
70
|
return new Set(items.flatMap(item => (item.sessionFile ? [item.sessionFile] : [])));
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import { type ChatHome, type ChatHomeCounts } from './chat-home-util';
|
|
2
|
+
import type { WebTaskEntry } from '../extension/web-extension-api';
|
|
3
|
+
import { type ChatHome, type ChatHomeCounts, type ChatHomeRow } from './chat-home-util';
|
|
4
|
+
/** The text of a row of the chats: its title and time, and under them its line, as a conversation's. */
|
|
5
|
+
export declare function RowText({ title, time, line, unseen, flag, busy, tag, badge, }: {
|
|
6
|
+
title: string;
|
|
7
|
+
time: string;
|
|
8
|
+
line: React.ReactNode;
|
|
9
|
+
unseen?: boolean;
|
|
10
|
+
/** Before the line, in its color: [Failed]. */
|
|
11
|
+
flag?: React.ReactNode;
|
|
12
|
+
busy?: boolean;
|
|
13
|
+
/** Before the title: Double, for what it does. */
|
|
14
|
+
tag?: React.ReactNode;
|
|
15
|
+
/** Just after the title, a small label of what it is: Friends, of a group chat with them. */
|
|
16
|
+
badge?: string;
|
|
17
|
+
}): React.JSX.Element;
|
|
4
18
|
/**
|
|
5
19
|
* The double at the top of its list, as a messenger's pinned conversation: its face, what needs the user and goes on
|
|
6
20
|
* (else, as a messenger, what it said last), a blue ? while something waits for them, an amber dot for news.
|
|
@@ -16,8 +30,8 @@ export declare function ChatDoubleItem({ home, counts, unseen, now }: {
|
|
|
16
30
|
* or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
|
|
17
31
|
* or the conversation it stands for is in front.
|
|
18
32
|
*/
|
|
19
|
-
export declare function ChatHomeItem({
|
|
20
|
-
|
|
33
|
+
export declare function ChatHomeItem({ row, time, home, selected, pinned, onPin, }: {
|
|
34
|
+
row: ChatHomeRow;
|
|
21
35
|
time: string;
|
|
22
36
|
home: ChatHome;
|
|
23
37
|
/** The conversation it stands for is shown (WebHomeItem.sessionFile). */
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ChatTaskItem = void 0;
|
|
37
|
+
exports.RowText = RowText;
|
|
37
38
|
exports.ChatDoubleItem = ChatDoubleItem;
|
|
38
39
|
exports.ChatHomeItem = ChatHomeItem;
|
|
39
40
|
exports.ChatHomeTop = ChatHomeTop;
|
|
@@ -44,14 +45,16 @@ const chat_home_util_1 = require("./chat-home-util");
|
|
|
44
45
|
const chat_list_row_1 = require("./chat-list-row");
|
|
45
46
|
const chat_list_util_1 = require("./chat-list-util");
|
|
46
47
|
const context_menu_1 = require("./context-menu");
|
|
48
|
+
const partner_row_1 = require("./partner-row");
|
|
47
49
|
const swipe_row_1 = require("./swipe-row");
|
|
48
50
|
const ta_avatar_1 = require("./ta-avatar");
|
|
49
51
|
/** The text of a row of the chats: its title and time, and under them its line, as a conversation's. */
|
|
50
|
-
function RowText({ title, time, line, unseen, flag, busy, tag, }) {
|
|
52
|
+
function RowText({ title, time, line, unseen, flag, busy, tag, badge, }) {
|
|
51
53
|
return (React.createElement("span", { className: "ta-chat-text" },
|
|
52
54
|
React.createElement("span", { className: "ta-chat-line" },
|
|
53
55
|
tag,
|
|
54
|
-
React.createElement("span", { className:
|
|
56
|
+
React.createElement("span", { className: `ta-chat-title${badge ? ' ta-badged' : ''}` }, title),
|
|
57
|
+
badge && React.createElement("span", { className: "ta-chat-badge" }, badge),
|
|
55
58
|
React.createElement("span", { className: "ta-chat-time" }, time)),
|
|
56
59
|
React.createElement("span", { className: "ta-chat-line" },
|
|
57
60
|
React.createElement("span", { className: `ta-chat-sub${unseen ? ' ta-unseen' : ''}` },
|
|
@@ -84,11 +87,17 @@ function ChatDoubleItem({ home, counts, unseen, now }) {
|
|
|
84
87
|
* or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
|
|
85
88
|
* or the conversation it stands for is in front.
|
|
86
89
|
*/
|
|
87
|
-
function ChatHomeItem({
|
|
90
|
+
function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
|
|
88
91
|
var _a;
|
|
89
92
|
const t = (0, use_t_1.useT)();
|
|
90
93
|
const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
|
|
91
94
|
const [opening, setOpening] = React.useState(false);
|
|
95
|
+
const { item, partner } = row;
|
|
96
|
+
if (partner) {
|
|
97
|
+
// A partner's conversation: the row the partners draw it with.
|
|
98
|
+
const opens = () => home.openItem(item);
|
|
99
|
+
return React.createElement(partner_row_1.PartnerRow, { partner: partner, time: time, selected: home.shownItem === partner.key, open: opens, pinned: pinned, onPin: onPin });
|
|
100
|
+
}
|
|
92
101
|
const Glyph = item.icon;
|
|
93
102
|
const Own = item.face;
|
|
94
103
|
const open = () => {
|
|
@@ -177,7 +177,9 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
|
|
|
177
177
|
const { folders: allFolders, rest } = React.useMemo(() => (searching ? { folders: [], rest: apart.rest } : chat_list_util_1.ChatListUtil.folders([...apart.rest, ...held], folderOf)), [apart.rest, held, folderOf, searching]);
|
|
178
178
|
// A folder pinned is a row of those pinned, as a conversation pinned; so is a row of the home.
|
|
179
179
|
const { pinned: pinnedFolders, rest: folders } = React.useMemo(() => chat_list_util_1.ChatListUtil.pinnedApart(allFolders, pinned), [allFolders, pinned]);
|
|
180
|
-
|
|
180
|
+
// With the conversations with partners that are none of pi (a chat of two, a group chat), by their time as any other.
|
|
181
|
+
const partners = home === null || home === void 0 ? void 0 : home.partners;
|
|
182
|
+
const homeRows = React.useMemo(() => chat_home_util_1.ChatHomeUtil.homeRows(homeItems, partners !== null && partners !== void 0 ? partners : [], query), [homeItems, partners, query]);
|
|
181
183
|
const { pinned: pinnedHome, rest: homeRest } = React.useMemo(() => chat_list_util_1.ChatListUtil.pinnedApart(homeRows, pinned), [homeRows, pinned]);
|
|
182
184
|
const pinnedRows = React.useMemo(() => chat_list_util_1.ChatListUtil.withFolders(apart.pinned, [...pinnedFolders, ...pinnedHome]), [apart.pinned, pinnedFolders, pinnedHome]);
|
|
183
185
|
(0, chat_list_hooks_1.useOfferPins)(listed, folderOf, homeItems);
|
|
@@ -306,7 +308,7 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
|
|
|
306
308
|
}, [folderShown, folder]);
|
|
307
309
|
const folderItem = (row, archived) => (React.createElement(chat_list_row_1.ChatFolderItem, { key: row.key, folder: row, time: chat_list_util_1.ChatListUtil.clock(row.updatedAt, now), selected: row.sessions.some(isSelected), unseen: row.sessions.filter(isUnseen), pinned: pinnedKeys.has(row.key), onOpen: () => openFolder(row.key, archived), onPin: pin => pinKey(row.key, pin), actions: actions }));
|
|
308
310
|
const taskItem = (row) => home && (React.createElement(chat_home_1.ChatTaskItem, { key: row.key, task: row.task, home: home, unseen: taskUnseen(row.task), time: chat_list_util_1.ChatListUtil.clock(row.updatedAt, now), onPicked: onPicked }));
|
|
309
|
-
const homeItem = (row) => { var _a; return home && (React.createElement(chat_home_1.ChatHomeItem, { key: row.key,
|
|
311
|
+
const homeItem = (row) => { var _a; return home && (React.createElement(chat_home_1.ChatHomeItem, { key: row.key, row: row, time: row.updatedAt ? chat_list_util_1.ChatListUtil.clock(row.updatedAt, now) : '', home: home, selected: !!row.item.sessionFile && isSelected((_a = byFile.get(row.item.sessionFile)) !== null && _a !== void 0 ? _a : row.item.sessionFile), pinned: pinnedKeys.has(row.key), onPin: pin => pinKey(row.key, pin) })); };
|
|
310
312
|
const rowItem = (row, compact) => chat_list_util_1.ChatListUtil.isFolder(row) ? folderItem(row) : chat_list_util_1.ChatListUtil.isTask(row) ? taskItem(row) : chat_list_util_1.ChatListUtil.isHome(row) ? homeItem(row) : item(row, compact);
|
|
311
313
|
// The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
|
|
312
314
|
const scroller = React.useRef(null);
|