@celljs/ta-web 4.20.0 → 4.21.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.
Files changed (75) hide show
  1. package/esm/browser/account/device-account.d.ts +65 -1
  2. package/esm/browser/account/device-account.js +206 -6
  3. package/esm/browser/assistant/call-turn-end.d.ts +55 -0
  4. package/esm/browser/assistant/call-turn-end.js +68 -0
  5. package/esm/browser/assistant/realtime-voice.js +3 -3
  6. package/esm/browser/assistant/voice-call.d.ts +19 -28
  7. package/esm/browser/assistant/voice-call.js +64 -51
  8. package/esm/browser/components/account-menu.d.ts +9 -4
  9. package/esm/browser/components/account-menu.js +59 -22
  10. package/esm/browser/components/account-view.d.ts +33 -7
  11. package/esm/browser/components/account-view.js +140 -79
  12. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  13. package/esm/browser/components/cloud-sign-in-view.js +4 -1
  14. package/esm/browser/components/host-view.d.ts +15 -8
  15. package/esm/browser/components/host-view.js +23 -70
  16. package/esm/browser/components/me-view.d.ts +2 -2
  17. package/esm/browser/components/me-view.js +7 -6
  18. package/esm/browser/components/profile-view.d.ts +11 -0
  19. package/esm/browser/components/profile-view.js +85 -0
  20. package/esm/browser/components/workbench-view.js +42 -7
  21. package/esm/browser/extension/web-api-components.d.ts +2 -2
  22. package/esm/browser/i18n/locales.d.ts +12 -1
  23. package/esm/browser/i18n/messages-ja.js +15 -4
  24. package/esm/browser/i18n/messages-zh-tw.js +15 -4
  25. package/esm/browser/i18n/messages.d.ts +11 -0
  26. package/esm/browser/i18n/messages.js +30 -8
  27. package/esm/browser/style/conversation-column.d.ts +1 -1
  28. package/esm/browser/style/conversation-column.js +2 -1
  29. package/esm/browser/style/dialogs.d.ts +1 -1
  30. package/esm/browser/style/dialogs.js +6 -0
  31. package/esm/browser/style/pages.d.ts +1 -1
  32. package/esm/browser/style/pages.js +6 -0
  33. package/esm/browser/util/turn-end.d.ts +8 -0
  34. package/esm/browser/util/turn-end.js +78 -35
  35. package/esm/browser/workbench-hosts.d.ts +4 -1
  36. package/esm/browser/workbench-hosts.js +17 -0
  37. package/esm/browser/workbench-protocol.d.ts +8 -0
  38. package/lib/browser/account/device-account.d.ts +65 -1
  39. package/lib/browser/account/device-account.js +206 -6
  40. package/lib/browser/assistant/call-turn-end.d.ts +56 -0
  41. package/lib/browser/assistant/call-turn-end.js +72 -0
  42. package/lib/browser/assistant/realtime-voice.js +3 -3
  43. package/lib/browser/assistant/voice-call.d.ts +19 -28
  44. package/lib/browser/assistant/voice-call.js +67 -54
  45. package/lib/browser/components/account-menu.d.ts +9 -4
  46. package/lib/browser/components/account-menu.js +57 -20
  47. package/lib/browser/components/account-view.d.ts +33 -7
  48. package/lib/browser/components/account-view.js +142 -77
  49. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  50. package/lib/browser/components/cloud-sign-in-view.js +4 -1
  51. package/lib/browser/components/host-view.d.ts +15 -8
  52. package/lib/browser/components/host-view.js +22 -68
  53. package/lib/browser/components/me-view.d.ts +2 -2
  54. package/lib/browser/components/me-view.js +7 -6
  55. package/lib/browser/components/profile-view.d.ts +12 -0
  56. package/lib/browser/components/profile-view.js +123 -0
  57. package/lib/browser/components/workbench-view.js +39 -4
  58. package/lib/browser/extension/web-api-components.d.ts +2 -2
  59. package/lib/browser/i18n/locales.d.ts +12 -1
  60. package/lib/browser/i18n/messages-ja.js +15 -4
  61. package/lib/browser/i18n/messages-zh-tw.js +15 -4
  62. package/lib/browser/i18n/messages.d.ts +11 -0
  63. package/lib/browser/i18n/messages.js +30 -8
  64. package/lib/browser/style/conversation-column.d.ts +1 -1
  65. package/lib/browser/style/conversation-column.js +2 -1
  66. package/lib/browser/style/dialogs.d.ts +1 -1
  67. package/lib/browser/style/dialogs.js +6 -0
  68. package/lib/browser/style/pages.d.ts +1 -1
  69. package/lib/browser/style/pages.js +6 -0
  70. package/lib/browser/util/turn-end.d.ts +8 -0
  71. package/lib/browser/util/turn-end.js +78 -35
  72. package/lib/browser/workbench-hosts.d.ts +4 -1
  73. package/lib/browser/workbench-hosts.js +17 -0
  74. package/lib/browser/workbench-protocol.d.ts +8 -0
  75. package/package.json +7 -7
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CallTurnEnd = exports.TURN_MS = exports.FILLER_MS = exports.END_MS = exports.RETRY_MS = exports.SILENT_MS = exports.SILENT_ROUNDS = void 0;
4
+ const turn_end_1 = require("../util/turn-end");
5
+ /** Listens heard nothing this many times in a row, and for SILENT_MS: nobody is there, the call ends. */
6
+ exports.SILENT_ROUNDS = 4;
7
+ /**
8
+ * How long nobody spoke, the user nor Ta, before the call ends by itself: a recognizer ends a listen after a few
9
+ * seconds of silence, and a user who waits for the work to answer is still there.
10
+ */
11
+ exports.SILENT_MS = 3 * 60000;
12
+ /** After a failure of the recognizer (not a denial), before it listens again. */
13
+ exports.RETRY_MS = 600;
14
+ /**
15
+ * The words heard stay the same this long: the user is done, though the recognizer goes on (it hears voices around them
16
+ * and waits for a silence that never comes).
17
+ */
18
+ exports.END_MS = 1300;
19
+ /**
20
+ * What was heard holds sounds alone ("哎", "嗯", "那个", TurnEnd.sounds): Ta waits this long without new words before it
21
+ * takes the user to be done, and what they say meanwhile, in this listen or the next, goes with it as one sentence. Then
22
+ * a hesitation is dropped and a backchannel ("嗯", "好好", an answer maybe) goes as said.
23
+ */
24
+ exports.FILLER_MS = 3000;
25
+ /** At most this long a turn, from the first words: talk around the user that keeps the words coming ends there too. */
26
+ exports.TURN_MS = 15000;
27
+ /**
28
+ * When the user is done with their turn in a call, by the words heard as they come (TurnEnd): once they stayed the same
29
+ * a while (END_MS, sooner after a sentence, later while they hesitate, FILLER_MS for sounds alone), and at the latest
30
+ * TURN_MS from the first words. It calls `done` then.
31
+ */
32
+ class CallTurnEnd {
33
+ constructor(times, done) {
34
+ this.times = times;
35
+ this.done = done;
36
+ /** When the words heard last changed: sounds alone wait FILLER_MS from it, over listens. */
37
+ this.wordsAt = 0;
38
+ }
39
+ /** The words heard are `text` now. */
40
+ heard(text) {
41
+ var _a, _b;
42
+ this.wordsAt = Date.now();
43
+ clearTimeout(this.endTimer);
44
+ this.endTimer = setTimeout(this.done, this.waitMs(text));
45
+ (_a = this.turnTimer) !== null && _a !== void 0 ? _a : (this.turnTimer = setTimeout(this.done, (_b = this.times.turnMs) !== null && _b !== void 0 ? _b : exports.TURN_MS));
46
+ }
47
+ /** A listen goes on from sounds alone the one before ended on: done once they waited FILLER_MS, unless words come. */
48
+ hold() {
49
+ clearTimeout(this.endTimer);
50
+ this.endTimer = setTimeout(this.done, Math.max(0, this.fillerMs - (Date.now() - this.wordsAt)));
51
+ }
52
+ /** `said` is sounds alone that did not wait FILLER_MS yet: they wait on for words. */
53
+ waits(said) {
54
+ return !!turn_end_1.TurnEnd.sounds(said) && Date.now() - this.wordsAt < this.fillerMs;
55
+ }
56
+ stop() {
57
+ clearTimeout(this.endTimer);
58
+ clearTimeout(this.turnTimer);
59
+ this.endTimer = this.turnTimer = undefined;
60
+ }
61
+ get fillerMs() {
62
+ var _a;
63
+ return (_a = this.times.fillerMs) !== null && _a !== void 0 ? _a : exports.FILLER_MS;
64
+ }
65
+ /** How long the words heard should stay the same before the user is taken to be done. */
66
+ waitMs(text) {
67
+ var _a;
68
+ return turn_end_1.TurnEnd.sounds(text) ? this.fillerMs : turn_end_1.TurnEnd.waitMs(text, (_a = this.times.endMs) !== null && _a !== void 0 ? _a : exports.END_MS);
69
+ }
70
+ }
71
+ exports.CallTurnEnd = CallTurnEnd;
72
+ //# sourceMappingURL=call-turn-end.js.map
@@ -273,11 +273,11 @@ class RealtimeVoice {
273
273
  const text = turn_end_1.TurnEnd.join((_d = hearing.before) !== null && _d !== void 0 ? _d : '', event.text);
274
274
  hearing.onText(text, event.final);
275
275
  if (event.final) {
276
- // A sentence the service ended on a word that leads on ("然后", "and"): the user is still to say
277
- // more, and the call waits for it, as long as TurnEnd.waitMs says.
276
+ // A sentence the service ended on a word that leads on ("然后", "and"), or on sounds alone ("哎",
277
+ // "嗯"): the user is still to say more, and the call waits for it, as long as it says (waitMs).
278
278
  // Nor one the user's voice went on from, a short pause (TaBargeIn.joinMs) ago at most.
279
279
  const goesOn = this.clock - this.voiceAt <= this.barge.joinMs;
280
- if (event.text.trim() && !turn_end_1.TurnEnd.hesitates(text) && !goesOn) {
280
+ if (event.text.trim() && !turn_end_1.TurnEnd.hesitates(text) && !turn_end_1.TurnEnd.sounds(text) && !goesOn) {
281
281
  this.endHearing();
282
282
  hearing.onEnd();
283
283
  }
@@ -1,4 +1,5 @@
1
1
  import { Voice } from '../util/voice';
2
+ import { CallTurnEnd, type CallTurnTimes } from './call-turn-end';
2
3
  import { VoiceReopen } from './voice-reopen';
3
4
  /** Where a call is: Ta listens to the user, works on what they said, or says its answer. */
4
5
  export type CallPhase = 'connecting' | 'listening' | 'thinking' | 'speaking';
@@ -50,7 +51,7 @@ export interface CallPartner {
50
51
  }
51
52
  /** Why a call ended by itself. */
52
53
  export type CallEnd = 'silent' | 'denied' | 'unavailable' | 'failed';
53
- export interface CallOptions {
54
+ export interface CallOptions extends CallTurnTimes {
54
55
  language(): string;
55
56
  voice(): string | undefined;
56
57
  /** Sends what the user said to the conversation. */
@@ -61,27 +62,9 @@ export interface CallOptions {
61
62
  openVoice?(): Promise<CallVoice | undefined> | undefined;
62
63
  /** Who answers in its place, opened as the call starts; undefined (or failing) for the conversation itself. */
63
64
  openPartner?(): Promise<CallPartner | undefined> | undefined;
64
- /** How long the words heard stay the same before the user is taken to be done; default END_MS. */
65
- endMs?: number;
66
- /** How long the user may speak in one turn; default TURN_MS. */
67
- turnMs?: number;
68
65
  /** How long nobody may speak before the call ends by itself; default SILENT_MS. */
69
66
  silentMs?: number;
70
67
  }
71
- /** Listens heard nothing this many times in a row, and for SILENT_MS: nobody is there, the call ends. */
72
- export declare const SILENT_ROUNDS = 4;
73
- /**
74
- * How long nobody spoke, the user nor Ta, before the call ends by itself: a recognizer ends a listen after a few
75
- * seconds of silence, and a user who waits for the work to answer is still there.
76
- */
77
- export declare const SILENT_MS: number;
78
- /**
79
- * The words heard stay the same this long: the user is done, though the recognizer goes on (it hears voices around them
80
- * and waits for a silence that never comes).
81
- */
82
- export declare const END_MS = 1300;
83
- /** At most this long a turn, from the first words: talk around the user that keeps the words coming ends there too. */
84
- export declare const TURN_MS = 15000;
85
68
  /**
86
69
  * 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
87
70
  * its answer out, then listens again, until the user hangs up or says nothing for a while. With the voice of the device
@@ -100,9 +83,8 @@ export declare class VoiceCall {
100
83
  /** When someone last spoke (the user, or Ta): the silence that ends the call counts from it. */
101
84
  protected spoke: number;
102
85
  protected retry?: ReturnType<typeof setTimeout>;
103
- /** The user is done when it fires (END_MS), and at the latest when the other does (TURN_MS). */
104
- protected endTimer?: ReturnType<typeof setTimeout>;
105
- protected turnTimer?: ReturnType<typeof setTimeout>;
86
+ /** When the user is done with what they say. */
87
+ protected readonly turnEnd: CallTurnEnd;
106
88
  /** An answer that came while paused: read once the page shows again. */
107
89
  protected pending?: string;
108
90
  /** The voice of this call: the device's, or a service's opened as it started. */
@@ -181,15 +163,24 @@ export declare class VoiceCall {
181
163
  /** What is being read now, to read again after a pause. */
182
164
  protected speaking?: string;
183
165
  protected read(said: string): void;
184
- /** Listens; first says what waits to be said, unless the user just cut in to speak (`announce` false). */
185
- protected listen(announce?: boolean): void;
186
166
  /**
187
- * The user is done speaking (a pause after their words, or the mark of the bar tapped): what was heard goes now,
188
- * the recognizer stopped, whatever it would still hear.
167
+ * Listens; first says what waits to be said, unless the user just cut in to speak (`announce` false). `held`: sounds
168
+ * alone a listen ended on, which what is heard now follows, gone or sent once it waited FILLER_MS for words.
189
169
  */
170
+ protected listen(announce?: boolean, held?: string): void;
171
+ /** The user says they are done (the mark of the bar tapped): what was heard goes now as it is, sounds alone too. */
190
172
  endTurn(): void;
191
- /** A listen ended: what was said goes to the double; nothing, Ta listens again, a few times. */
192
- protected heard(said: string, error: string | undefined): void;
173
+ /** The words heard stayed the same a while, or the turn is at its longest (CallTurnEnd): the user is done. */
174
+ protected quiet(): void;
175
+ /** What was heard of a listen going on, while Ta listens; undefined else. */
176
+ protected listened(): string | undefined;
177
+ /**
178
+ * A listen ended: what was said goes to the double; nothing, Ta listens again, a few times. Sounds alone wait on in
179
+ * the next listen until they waited FILLER_MS (`waited`); then a hesitation is dropped and a backchannel goes.
180
+ */
181
+ protected heard(said: string, error: string | undefined, waited?: boolean): void;
182
+ /** What the user said goes to the partner, or to the conversation. */
183
+ protected take(said: string): void;
193
184
  /** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
194
185
  protected open(direct: boolean): Promise<[CallVoice | undefined, CallPartner | undefined]> | undefined;
195
186
  /** The partner answers what the user said; its reply is read as a turn's is. */
@@ -1,25 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VoiceCall = exports.TURN_MS = exports.END_MS = exports.SILENT_MS = exports.SILENT_ROUNDS = void 0;
3
+ exports.VoiceCall = void 0;
4
4
  const turn_end_1 = require("../util/turn-end");
5
5
  const voice_1 = require("../util/voice");
6
+ const call_turn_end_1 = require("./call-turn-end");
6
7
  const voice_reopen_1 = require("./voice-reopen");
7
- /** Listens heard nothing this many times in a row, and for SILENT_MS: nobody is there, the call ends. */
8
- exports.SILENT_ROUNDS = 4;
9
- /**
10
- * How long nobody spoke, the user nor Ta, before the call ends by itself: a recognizer ends a listen after a few
11
- * seconds of silence, and a user who waits for the work to answer is still there.
12
- */
13
- exports.SILENT_MS = 3 * 60000;
14
- /**
15
- * The words heard stay the same this long: the user is done, though the recognizer goes on (it hears voices around them
16
- * and waits for a silence that never comes).
17
- */
18
- exports.END_MS = 1300;
19
- /** At most this long a turn, from the first words: talk around the user that keeps the words coming ends there too. */
20
- exports.TURN_MS = 15000;
21
- /** After a failure of the recognizer (not a denial), before it listens again. */
22
- const RETRY_MS = 600;
23
8
  const IDLE = { active: false, phase: 'listening', heard: '' };
24
9
  /**
25
10
  * 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
@@ -45,6 +30,7 @@ class VoiceCall {
45
30
  /** What waits to be said that the user did not ask for (a dialog, a task that ended), in order. */
46
31
  this.announcements = [];
47
32
  this.voice = device;
33
+ this.turnEnd = new call_turn_end_1.CallTurnEnd(options, () => this.quiet());
48
34
  }
49
35
  subscribe(listener) {
50
36
  this.listeners.add(listener);
@@ -302,8 +288,11 @@ class VoiceCall {
302
288
  }
303
289
  }, this.options.voice(), (pieces, at) => this.state.active && round === this.round && this.set({ reading: { pieces, at } }));
304
290
  }
305
- /** Listens; first says what waits to be said, unless the user just cut in to speak (`announce` false). */
306
- listen(announce = true) {
291
+ /**
292
+ * Listens; first says what waits to be said, unless the user just cut in to speak (`announce` false). `held`: sounds
293
+ * alone a listen ended on, which what is heard now follows, gone or sent once it waited FILLER_MS for words.
294
+ */
295
+ listen(announce = true, held) {
307
296
  this.stopListening();
308
297
  if (this.state.paused) {
309
298
  return;
@@ -314,20 +303,17 @@ class VoiceCall {
314
303
  return;
315
304
  }
316
305
  const round = ++this.round;
317
- let heard = '';
318
- this.set({ phase: 'listening', heard: '' });
319
- const listening = this.voice.listen(this.options.language(), text => {
320
- var _a, _b, _c;
306
+ let heard = held !== null && held !== void 0 ? held : '';
307
+ this.set({ phase: 'listening', heard });
308
+ const listening = this.voice.listen(this.options.language(), words => {
309
+ const text = held ? turn_end_1.TurnEnd.join(held, words) : words;
321
310
  if (round === this.round) {
322
311
  const more = text.trim() !== heard.trim();
323
312
  heard = text;
324
313
  // The user says more: the captions are of what they say now, the last exchange gone.
325
314
  this.set(text.trim() ? { heard: text, said: undefined, reading: undefined } : { heard: text });
326
315
  if (more && text.trim()) {
327
- clearTimeout(this.endTimer);
328
- // Sooner once a sentence ended, later while the user hesitates ("那个…", "and").
329
- this.endTimer = setTimeout(() => this.endTurn(), turn_end_1.TurnEnd.waitMs(text, (_a = this.options.endMs) !== null && _a !== void 0 ? _a : exports.END_MS));
330
- (_b = this.turnTimer) !== null && _b !== void 0 ? _b : (this.turnTimer = setTimeout(() => this.endTurn(), (_c = this.options.turnMs) !== null && _c !== void 0 ? _c : exports.TURN_MS));
316
+ this.turnEnd.heard(text);
331
317
  }
332
318
  }
333
319
  }, error => {
@@ -335,9 +321,7 @@ class VoiceCall {
335
321
  return;
336
322
  }
337
323
  this.listening = undefined;
338
- clearTimeout(this.endTimer);
339
- clearTimeout(this.turnTimer);
340
- this.endTimer = this.turnTimer = undefined;
324
+ this.turnEnd.stop();
341
325
  this.heard(heard.trim(), error);
342
326
  });
343
327
  if (!listening) {
@@ -350,49 +334,81 @@ class VoiceCall {
350
334
  return;
351
335
  }
352
336
  this.listening = listening;
337
+ if (held) {
338
+ this.turnEnd.hold();
339
+ }
353
340
  }
354
- /**
355
- * The user is done speaking (a pause after their words, or the mark of the bar tapped): what was heard goes now,
356
- * the recognizer stopped, whatever it would still hear.
357
- */
341
+ /** The user says they are done (the mark of the bar tapped): what was heard goes now as it is, sounds alone too. */
358
342
  endTurn() {
359
- const said = this.state.heard.trim();
360
- if (!this.state.active || this.state.paused || this.state.phase !== 'listening' || !said || !this.listening) {
361
- return;
343
+ const said = this.listened();
344
+ if (said) {
345
+ this.stopListening();
346
+ this.take(said);
347
+ }
348
+ }
349
+ /** The words heard stayed the same a while, or the turn is at its longest (CallTurnEnd): the user is done. */
350
+ quiet() {
351
+ const said = this.listened();
352
+ if (said) {
353
+ this.stopListening();
354
+ this.heard(said, undefined, true);
362
355
  }
363
- this.stopListening();
364
- this.heard(said, undefined);
365
356
  }
366
- /** A listen ended: what was said goes to the double; nothing, Ta listens again, a few times. */
367
- heard(said, error) {
357
+ /** What was heard of a listen going on, while Ta listens; undefined else. */
358
+ listened() {
359
+ const said = this.state.heard.trim();
360
+ return this.state.active && !this.state.paused && this.state.phase === 'listening' && said && this.listening ? said : undefined;
361
+ }
362
+ /**
363
+ * A listen ended: what was said goes to the double; nothing, Ta listens again, a few times. Sounds alone wait on in
364
+ * the next listen until they waited FILLER_MS (`waited`); then a hesitation is dropped and a backchannel goes.
365
+ */
366
+ heard(said, error, waited = false) {
368
367
  var _a;
369
368
  if (error && voice_1.Voice.denied(error)) {
370
369
  this.end('denied');
371
370
  return;
372
371
  }
373
- if (said) {
374
- this.silent = 0;
375
- this.spoke = Date.now();
376
- this.set({ phase: 'thinking', heard: said, said, reading: undefined });
377
- if (this.partner) {
378
- this.ask(said);
372
+ if (said && !waited && this.turnEnd.waits(said)) {
373
+ if (error) {
374
+ this.retry = setTimeout(() => this.state.active && this.state.phase === 'listening' && this.listen(false, said), call_turn_end_1.RETRY_MS);
379
375
  }
380
376
  else {
381
- this.options.send(said).catch(() => this.state.active && this.unsent());
377
+ this.listen(false, said);
382
378
  }
383
379
  return;
384
380
  }
385
- if (++this.silent >= exports.SILENT_ROUNDS && Date.now() - this.spoke >= ((_a = this.options.silentMs) !== null && _a !== void 0 ? _a : exports.SILENT_MS)) {
381
+ if (said && turn_end_1.TurnEnd.sounds(said) === 'hesitation') {
382
+ said = '';
383
+ this.set({ heard: '' });
384
+ }
385
+ if (said) {
386
+ this.take(said);
387
+ return;
388
+ }
389
+ if (++this.silent >= call_turn_end_1.SILENT_ROUNDS && Date.now() - this.spoke >= ((_a = this.options.silentMs) !== null && _a !== void 0 ? _a : call_turn_end_1.SILENT_MS)) {
386
390
  this.end('silent');
387
391
  return;
388
392
  }
389
393
  if (error) {
390
- this.retry = setTimeout(() => this.state.active && this.state.phase === 'listening' && this.listen(), RETRY_MS);
394
+ this.retry = setTimeout(() => this.state.active && this.state.phase === 'listening' && this.listen(), call_turn_end_1.RETRY_MS);
391
395
  }
392
396
  else {
393
397
  this.listen();
394
398
  }
395
399
  }
400
+ /** What the user said goes to the partner, or to the conversation. */
401
+ take(said) {
402
+ this.silent = 0;
403
+ this.spoke = Date.now();
404
+ this.set({ phase: 'thinking', heard: said, said, reading: undefined });
405
+ if (this.partner) {
406
+ this.ask(said);
407
+ }
408
+ else {
409
+ this.options.send(said).catch(() => this.state.active && this.unsent());
410
+ }
411
+ }
396
412
  /** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
397
413
  open(direct) {
398
414
  var _a, _b, _c, _d, _e;
@@ -453,10 +469,7 @@ class VoiceCall {
453
469
  }
454
470
  stopListening() {
455
471
  clearTimeout(this.retry);
456
- clearTimeout(this.endTimer);
457
- clearTimeout(this.turnTimer);
458
- this.endTimer = undefined;
459
- this.turnTimer = undefined;
472
+ this.turnEnd.stop();
460
473
  this.round++;
461
474
  const listening = this.listening;
462
475
  this.listening = undefined;
@@ -2,7 +2,7 @@ import { type LucideIcon } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import type { SettingsSection } from './settings-view';
4
4
  /** What an entry of the account opens over the page. */
5
- export type AccountDialog = 'accounts' | 'directory' | 'relay' | 'hosts' | 'devices';
5
+ export type AccountDialog = 'accounts' | 'directory' | 'relay' | 'devices' | 'profile';
6
6
  export interface AccountChoice {
7
7
  key: string;
8
8
  label: string;
@@ -29,16 +29,20 @@ export interface AccountEntry {
29
29
  */
30
30
  export declare function useAccountEntries(onSettings: (section?: SettingsSection) => void, onDialog: (dialog: AccountDialog) => void): AccountEntry[][];
31
31
  /** What the entries of the account open over the page. */
32
- export declare function AccountDialogs({ dialog, onClose }: {
32
+ export declare function AccountDialogs({ dialog, onClose, onDialog }: {
33
33
  dialog?: AccountDialog;
34
34
  onClose(): void;
35
+ onDialog(dialog: AccountDialog): void;
35
36
  }): React.JSX.Element;
36
- /** The round figure of the account: a close-up of the double, the dinosaur the user picked for it (a T. rex until then). */
37
+ /**
38
+ * The round figure of the user: the picture they gave themselves (docs/design/ta-me.md 3), else the close-up of the
39
+ * double, the dinosaur they picked for it (a T. rex until then).
40
+ */
37
41
  export declare function AccountFigure({ size, className }: {
38
42
  size: number;
39
43
  className: string;
40
44
  }): React.JSX.Element;
41
- /** Who is signed in, to which machine (as named on this device), and whether the page is connected to it. */
45
+ /** 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. */
42
46
  export declare function useAccount(): {
43
47
  server: import("@celljs/ta-protocol").TaServerInfo | undefined;
44
48
  machine: string | undefined;
@@ -46,6 +50,7 @@ export declare function useAccount(): {
46
50
  offlineShown: boolean | undefined;
47
51
  state: string;
48
52
  name: string;
53
+ account: string | undefined;
49
54
  service: string;
50
55
  };
51
56
  export interface AccountMenuProps {
@@ -41,6 +41,8 @@ exports.AccountMenu = AccountMenu;
41
41
  const ta_protocol_1 = require("@celljs/ta-protocol");
42
42
  const lucide_react_1 = require("lucide-react");
43
43
  const React = __importStar(require("react"));
44
+ const account_side_1 = require("../account/account-side");
45
+ const device_account_1 = require("../account/device-account");
44
46
  const device_1 = require("../device/device");
45
47
  const hooks_1 = require("../hooks");
46
48
  const hosts_1 = require("../hosts");
@@ -50,13 +52,12 @@ const account_view_1 = require("./account-view");
50
52
  const auth_view_1 = require("./auth-view");
51
53
  const dino_look_picker_1 = require("./dino-look-picker");
52
54
  const dismiss_1 = require("./dismiss");
53
- const host_view_1 = require("./host-view");
55
+ const face_1 = require("./face");
54
56
  const icon_1 = require("./icon");
55
- const picture_dialog_1 = require("./picture-dialog");
57
+ const profile_view_1 = require("./profile-view");
56
58
  const relay_view_1 = require("./relay-view");
57
59
  const serve_restart_1 = require("./serve-restart");
58
60
  const settings_controls_1 = require("./settings-controls");
59
- const ta_avatar_1 = require("./ta-avatar");
60
61
  const working_directory_1 = require("./working-directory");
61
62
  const THEMES = [
62
63
  ['system', 'ta.settings.theme.system'],
@@ -80,6 +81,31 @@ function useAccountEntries(onSettings, onDialog) {
80
81
  // A finger has no keys to learn; a phone is not the computer that pairs phones.
81
82
  const { touch, handheld } = (0, device_1.useDevice)();
82
83
  const restartTa = (0, serve_restart_1.useRestartTa)();
84
+ const [, notices] = (0, hooks_1.useNotices)();
85
+ const side = (0, account_side_1.useAccountSide)();
86
+ const { info } = (0, account_side_1.useAccountInfo)(side, 15000);
87
+ const signedIn = Boolean(info === null || info === void 0 ? void 0 : info.account);
88
+ const app = workbench_util_1.WorkbenchUtil.isApp();
89
+ // Signed in, out of the account (its computers go, those connected by a code stay); else out of the computer in use.
90
+ const signOut = async () => {
91
+ if (!signedIn || !side) {
92
+ workbench.signOut();
93
+ return;
94
+ }
95
+ const title = t(app ? 'ta.myDevices.signOutConfirm' : 'ta.myDevices.signOutConfirmComputer');
96
+ if (!(await notices.confirm({ title, confirmLabel: t('ta.settings.signOut'), danger: true }))) {
97
+ return;
98
+ }
99
+ try {
100
+ await side.signOut();
101
+ if (app && workbench.state.status !== 'signed-out') {
102
+ workbench.switchSignIn();
103
+ }
104
+ }
105
+ catch (error) {
106
+ notices.error(error);
107
+ }
108
+ };
83
109
  const entry = (key, label, icon, run, more = {}) => ({
84
110
  key,
85
111
  label,
@@ -89,15 +115,15 @@ function useAccountEntries(onSettings, onDialog) {
89
115
  });
90
116
  return [
91
117
  [
92
- entry('picture', t('ta.picture.title'), lucide_react_1.CircleUserRound, () => picture_dialog_1.PicturePicker.open()),
93
118
  entry('look', t('ta.look.title'), lucide_react_1.Sparkles, () => dino_look_picker_1.DinoLookPicker.open()),
94
119
  entry('settings', t('ta.settings'), lucide_react_1.Settings2, () => onSettings(), { keys: touch ? undefined : 'Mod+,' }),
95
120
  entry('packages', t('ta.manage.packages'), lucide_react_1.Puzzle, () => onSettings('packages')),
96
121
  ...(touch ? [] : [entry('shortcuts', t('ta.manage.shortcuts'), lucide_react_1.Keyboard, () => onSettings('shortcuts'))]),
97
122
  ],
98
123
  [
99
- entry('devices', t('ta.myDevices.title'), lucide_react_1.MonitorSmartphone, () => onDialog('devices')),
100
- entry('hosts', t('ta.hosts.title'), lucide_react_1.Monitor, () => onDialog('hosts'), { detail: inUse && (hosts_1.HostUtil.label(inUse) || t('ta.hosts.thisServer')) }),
124
+ entry('devices', t('ta.myDevices.title'), lucide_react_1.MonitorSmartphone, () => onDialog('devices'), {
125
+ detail: inUse && (hosts_1.HostUtil.label(inUse) || t('ta.hosts.thisServer')),
126
+ }),
101
127
  entry('accounts', t('ta.manage.accounts'), lucide_react_1.KeyRound, () => onDialog('accounts')),
102
128
  entry('directory', t('ta.manage.workingDirectory'), lucide_react_1.FolderOpen, () => onDialog('directory')),
103
129
  ...(workbench_util_1.WorkbenchUtil.isApp() || handheld ? [] : [entry('relay', t('ta.manage.relay'), lucide_react_1.Smartphone, () => onDialog('relay'))]),
@@ -128,29 +154,35 @@ function useAccountEntries(onSettings, onDialog) {
128
154
  ]
129
155
  : []),
130
156
  entry('about', t('ta.manage.about'), lucide_react_1.Info, () => onSettings('about')),
131
- // As WeChat's: the computer in use kept, to come back to in one tap; signing out forgets it.
132
- entry('switchSignIn', t('ta.account.switchSignIn'), lucide_react_1.ArrowLeftRight, () => workbench.switchSignIn()),
133
- entry('signOut', t('ta.settings.signOut'), lucide_react_1.LogOut, () => workbench.signOut(), { danger: true }),
157
+ // As WeChat's: the account in use kept, with its computers, to come back to in one tap (docs/design/ta-me.md 4).
158
+ ...(app && signedIn ? [entry('switchAccount', t('ta.account.switchSignIn'), lucide_react_1.ArrowLeftRight, () => { var _a; return (_a = device_account_1.DeviceAccount.current()) === null || _a === void 0 ? void 0 : _a.switchAccount(); })] : []),
159
+ entry('signOut', t('ta.settings.signOut'), lucide_react_1.LogOut, () => void signOut(), { danger: true }),
134
160
  ],
135
161
  ];
136
162
  }
137
163
  /** What the entries of the account open over the page. */
138
- function AccountDialogs({ dialog, onClose }) {
164
+ function AccountDialogs({ dialog, onClose, onDialog }) {
139
165
  return (React.createElement(React.Fragment, null,
166
+ dialog === 'profile' && React.createElement(profile_view_1.ProfileDialog, { onClose: onClose, onDevices: () => onDialog('devices') }),
140
167
  dialog === 'accounts' && React.createElement(auth_view_1.AuthDialog, { onClose: onClose }),
141
168
  dialog === 'directory' && React.createElement(working_directory_1.WorkingDirectoryPicker, { onClose: onClose }),
142
169
  dialog === 'relay' && React.createElement(relay_view_1.RelayDialog, { onClose: onClose }),
143
- dialog === 'hosts' && React.createElement(host_view_1.HostsDialog, { onClose: onClose }),
144
170
  dialog === 'devices' && React.createElement(account_view_1.DevicesDialog, { onClose: onClose })));
145
171
  }
146
- /** The round figure of the account: a close-up of the double, the dinosaur the user picked for it (a T. rex until then). */
172
+ /**
173
+ * The round figure of the user: the picture they gave themselves (docs/design/ta-me.md 3), else the close-up of the
174
+ * double, the dinosaur they picked for it (a T. rex until then).
175
+ */
147
176
  function AccountFigure({ size, className }) {
148
- return React.createElement(ta_avatar_1.DinoFace, { size: size, className: className });
177
+ return (React.createElement("span", { className: className },
178
+ React.createElement(face_1.Face, { double: true, size: size })));
149
179
  }
150
- /** Who is signed in, to which machine (as named on this device), and whether the page is connected to it. */
180
+ /** 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. */
151
181
  function useAccount() {
152
- var _a, _b;
182
+ var _a, _b, _c;
153
183
  const t = (0, use_t_1.useT)();
184
+ const identity = (0, profile_view_1.useIdentity)();
185
+ const account = (0, profile_view_1.useAccountLine)();
154
186
  const [{ status, server, offlineShown, hosts, host }] = (0, hooks_1.useWorkbench)();
155
187
  const online = status === 'online';
156
188
  const state = online ? t('ta.online') : t('ta.reconnecting');
@@ -162,7 +194,8 @@ function useAccount() {
162
194
  online,
163
195
  offlineShown,
164
196
  state,
165
- name: (_b = server === null || server === void 0 ? void 0 : server.user) !== null && _b !== void 0 ? _b : t('ta.account'),
197
+ name: (_c = (_b = identity === null || identity === void 0 ? void 0 : identity.name) !== null && _b !== void 0 ? _b : server === null || server === void 0 ? void 0 : server.user) !== null && _c !== void 0 ? _c : t('ta.account'),
198
+ account,
166
199
  service: server && online ? `${state} · v${server.version}` : state,
167
200
  };
168
201
  }
@@ -183,6 +216,7 @@ function onArrows(event) {
183
216
  * the language a step away, in a second menu beside the first. A phone has them as its tab Me (me-view.tsx).
184
217
  */
185
218
  function AccountMenu({ onSettings, active }) {
219
+ var _a, _b;
186
220
  const t = (0, use_t_1.useT)();
187
221
  const account = useAccount();
188
222
  const [open, setOpen] = React.useState(false);
@@ -223,11 +257,14 @@ function AccountMenu({ onSettings, active }) {
223
257
  React.createElement(AccountFigure, { size: 28, className: "ta-account-figure" }),
224
258
  account.offlineShown && React.createElement("span", { className: "ta-account-dot" })),
225
259
  open && (React.createElement("div", { className: "ta-account-menu", id: id, role: "menu", "aria-label": t('ta.account.menu'), onKeyDown: onArrows },
226
- React.createElement("div", { className: "ta-account-head" },
260
+ React.createElement("button", { type: "button", role: "menuitem", className: "ta-account-head", "aria-label": t('ta.me.profile'), onClick: () => {
261
+ close();
262
+ setDialog('profile');
263
+ } },
227
264
  React.createElement(AccountFigure, { size: 36, className: "ta-account-figure" }),
228
- React.createElement("div", { className: "ta-account-text" },
265
+ React.createElement("span", { className: "ta-account-text" },
229
266
  React.createElement("span", { className: "ta-account-title ta-ellipsis" }, account.name),
230
- account.machine && React.createElement("span", { className: "ta-account-sub ta-ellipsis" }, account.machine))),
267
+ ((_a = account.account) !== null && _a !== void 0 ? _a : account.machine) && React.createElement("span", { className: "ta-account-sub ta-ellipsis" }, (_b = account.account) !== null && _b !== void 0 ? _b : account.machine))),
231
268
  React.createElement("div", { className: "ta-account-service", title: account.server ? `Ta v${account.server.version}` : undefined },
232
269
  React.createElement("span", { className: `ta-account-state ${account.online ? 'ta-ok' : 'ta-warn'}` }),
233
270
  React.createElement("span", { className: "ta-account-service-name" }, t('ta.account.service')),
@@ -237,6 +274,6 @@ function AccountMenu({ onSettings, active }) {
237
274
  .map(group => (React.createElement(React.Fragment, { key: group[0].key },
238
275
  React.createElement("div", { className: "ta-account-sep" }),
239
276
  group.map(item)))))),
240
- React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined) })));
277
+ React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined), onDialog: setDialog })));
241
278
  }
242
279
  //# sourceMappingURL=account-menu.js.map
@@ -1,10 +1,37 @@
1
+ import type { TaAccountInfo } from '@celljs/ta-protocol';
1
2
  import * as React from 'react';
2
- import type { AccountSide } from '../account/device-account';
3
- /** What the account panel shows: signing in, waiting, or the devices. */
4
- export declare function AccountPanel({ side }: {
5
- side: AccountSide;
3
+ import { type AccountSide } from '../account/device-account';
4
+ type Act = (run: (side: AccountSide) => Promise<TaAccountInfo>) => Promise<void>;
5
+ /** The ways an account's id tells (`github:42`, `iam:su`), as the user knows them: GitHub, the company account. */
6
+ export declare function useAccountWay(): (id: string) => string;
7
+ /** What the user is called in an account: its name, without the way it came by (`iam:su` is su). */
8
+ export declare function accountName(account: {
9
+ name: string;
10
+ }): string;
11
+ /**
12
+ * Signing in: the ways of the service, then the code to enter on the provider's page. The app signs in to a company's
13
+ * account as to its Ta in the cloud (CloudSignInFlow), not here.
14
+ */
15
+ export declare function SignInPart({ info, act }: {
16
+ info: TaAccountInfo;
17
+ act: Act;
18
+ }): React.JSX.Element | null;
19
+ /** This device waits to be let in by another of the account: the code both show. */
20
+ export declare function WaitingPart({ code }: {
21
+ code: string;
22
+ }): React.JSX.Element;
23
+ /** The ways to the account on the sign-in of the app, or where it stands: the code to enter, waiting, signed in. */
24
+ export declare function AccountWays({ info, act }: {
25
+ info: TaAccountInfo;
26
+ act: Act;
6
27
  }): React.JSX.Element;
7
- /** The account and its devices, over the page: from Me, the menu of the account, the settings. */
28
+ /** The accounts this device switched away from, on its sign-in: a tap goes back to one, its computers with it. */
29
+ export declare function RecentAccounts(): React.JSX.Element;
30
+ /**
31
+ * My devices, over the page (docs/design/ta-me.md 2): the one list of the computers this device uses, the one in use
32
+ * checked, a tap switching to another; the other devices of the account under them, those waiting to be let in first;
33
+ * and the ways to add one: the account, a code, a link, a Ta in the cloud.
34
+ */
8
35
  export declare function DevicesDialog({ onClose }: {
9
36
  onClose(): void;
10
37
  }): React.ReactPortal;
@@ -13,6 +40,5 @@ export declare function DevicesDialog({ onClose }: {
13
40
  * until it is let in, refused, or put off for now.
14
41
  */
15
42
  export declare function AccountAsk(): React.ReactPortal | null;
16
- /** On the sign-in of the app: sign in to the account, and the computers of it come by themselves. */
17
- export declare function AccountSignInEntry(): React.JSX.Element | null;
43
+ export {};
18
44
  //# sourceMappingURL=account-view.d.ts.map