@celljs/ta-web 4.19.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 (145) 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/assistant-chat-list.js +2 -1
  4. package/esm/browser/assistant/call-turn-end.d.ts +55 -0
  5. package/esm/browser/assistant/call-turn-end.js +68 -0
  6. package/esm/browser/assistant/realtime-voice.js +3 -3
  7. package/esm/browser/assistant/voice-call.d.ts +19 -28
  8. package/esm/browser/assistant/voice-call.js +64 -51
  9. package/esm/browser/components/account-menu.d.ts +9 -4
  10. package/esm/browser/components/account-menu.js +59 -20
  11. package/esm/browser/components/account-view.d.ts +33 -7
  12. package/esm/browser/components/account-view.js +140 -79
  13. package/esm/browser/components/app-view.js +2 -2
  14. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  15. package/esm/browser/components/cloud-sign-in-view.js +4 -1
  16. package/esm/browser/components/dino-look.d.ts +9 -1
  17. package/esm/browser/components/dino-look.js +46 -1
  18. package/esm/browser/components/environment-view.js +12 -1
  19. package/esm/browser/components/face-pictures.d.ts +10 -0
  20. package/esm/browser/components/face-pictures.js +24 -0
  21. package/esm/browser/components/face.d.ts +4 -1
  22. package/esm/browser/components/face.js +16 -1
  23. package/esm/browser/components/host-view.d.ts +15 -8
  24. package/esm/browser/components/host-view.js +23 -70
  25. package/esm/browser/components/me-view.d.ts +2 -2
  26. package/esm/browser/components/me-view.js +7 -6
  27. package/esm/browser/components/picture-dialog.d.ts +18 -0
  28. package/esm/browser/components/picture-dialog.js +116 -0
  29. package/esm/browser/components/profile-view.d.ts +11 -0
  30. package/esm/browser/components/profile-view.js +85 -0
  31. package/esm/browser/components/workbench-view.js +42 -7
  32. package/esm/browser/extension/icons.js +2 -1
  33. package/esm/browser/extension/web-api-components.d.ts +2 -2
  34. package/esm/browser/extension/web-api-home.d.ts +13 -0
  35. package/esm/browser/extension/web-api-home.js +2 -0
  36. package/esm/browser/extension/web-extension-api.d.ts +4 -4
  37. package/esm/browser/extension/web-extension-context.js +2 -1
  38. package/esm/browser/extension/web-home.d.ts +8 -0
  39. package/esm/browser/extension/web-home.js +20 -0
  40. package/esm/browser/gateway/console-limits.d.ts +15 -0
  41. package/esm/browser/gateway/console-limits.js +2 -2
  42. package/esm/browser/gateway/console-tenant.js +33 -2
  43. package/esm/browser/gateway/console-updates.d.ts +12 -0
  44. package/esm/browser/gateway/console-updates.js +76 -0
  45. package/esm/browser/gateway/console-util.d.ts +7 -1
  46. package/esm/browser/gateway/console-util.js +18 -0
  47. package/esm/browser/gateway/console-view.js +9 -2
  48. package/esm/browser/i18n/locales.d.ts +55 -3
  49. package/esm/browser/i18n/locales.js +9 -3
  50. package/esm/browser/i18n/messages-all.d.ts +7 -0
  51. package/esm/browser/i18n/messages-all.js +14 -0
  52. package/esm/browser/i18n/messages-ja.js +54 -4
  53. package/esm/browser/i18n/messages-zh-tw.js +54 -4
  54. package/esm/browser/i18n/messages.d.ts +56 -8
  55. package/esm/browser/i18n/messages.js +141 -19
  56. package/esm/browser/i18n/use-t.js +4 -3
  57. package/esm/browser/settings/settings.js +3 -1
  58. package/esm/browser/style/conversation-column.d.ts +1 -1
  59. package/esm/browser/style/conversation-column.js +2 -1
  60. package/esm/browser/style/dialogs.d.ts +1 -1
  61. package/esm/browser/style/dialogs.js +6 -0
  62. package/esm/browser/style/pages.d.ts +1 -1
  63. package/esm/browser/style/pages.js +11 -0
  64. package/esm/browser/style/surfaces.d.ts +1 -1
  65. package/esm/browser/style/surfaces.js +1 -0
  66. package/esm/browser/util/picture.d.ts +5 -0
  67. package/esm/browser/util/picture.js +43 -0
  68. package/esm/browser/util/turn-end.d.ts +8 -0
  69. package/esm/browser/util/turn-end.js +78 -35
  70. package/esm/browser/workbench-hosts.d.ts +4 -1
  71. package/esm/browser/workbench-hosts.js +17 -0
  72. package/esm/browser/workbench-protocol.d.ts +8 -0
  73. package/lib/browser/account/device-account.d.ts +65 -1
  74. package/lib/browser/account/device-account.js +206 -6
  75. package/lib/browser/assistant/assistant-chat-list.js +2 -1
  76. package/lib/browser/assistant/call-turn-end.d.ts +56 -0
  77. package/lib/browser/assistant/call-turn-end.js +72 -0
  78. package/lib/browser/assistant/realtime-voice.js +3 -3
  79. package/lib/browser/assistant/voice-call.d.ts +19 -28
  80. package/lib/browser/assistant/voice-call.js +67 -54
  81. package/lib/browser/components/account-menu.d.ts +9 -4
  82. package/lib/browser/components/account-menu.js +57 -18
  83. package/lib/browser/components/account-view.d.ts +33 -7
  84. package/lib/browser/components/account-view.js +142 -77
  85. package/lib/browser/components/app-view.js +1 -1
  86. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  87. package/lib/browser/components/cloud-sign-in-view.js +4 -1
  88. package/lib/browser/components/dino-look.d.ts +9 -1
  89. package/lib/browser/components/dino-look.js +48 -1
  90. package/lib/browser/components/environment-view.js +11 -0
  91. package/lib/browser/components/face-pictures.d.ts +11 -0
  92. package/lib/browser/components/face-pictures.js +60 -0
  93. package/lib/browser/components/face.d.ts +4 -1
  94. package/lib/browser/components/face.js +16 -1
  95. package/lib/browser/components/host-view.d.ts +15 -8
  96. package/lib/browser/components/host-view.js +22 -68
  97. package/lib/browser/components/me-view.d.ts +2 -2
  98. package/lib/browser/components/me-view.js +7 -6
  99. package/lib/browser/components/picture-dialog.d.ts +19 -0
  100. package/lib/browser/components/picture-dialog.js +153 -0
  101. package/lib/browser/components/profile-view.d.ts +12 -0
  102. package/lib/browser/components/profile-view.js +123 -0
  103. package/lib/browser/components/workbench-view.js +39 -4
  104. package/lib/browser/extension/icons.js +1 -0
  105. package/lib/browser/extension/web-api-components.d.ts +2 -2
  106. package/lib/browser/extension/web-api-home.d.ts +14 -0
  107. package/lib/browser/extension/web-api-home.js +3 -0
  108. package/lib/browser/extension/web-extension-api.d.ts +4 -4
  109. package/lib/browser/extension/web-extension-context.js +2 -1
  110. package/lib/browser/extension/web-home.d.ts +8 -0
  111. package/lib/browser/extension/web-home.js +54 -1
  112. package/lib/browser/gateway/console-limits.d.ts +15 -0
  113. package/lib/browser/gateway/console-limits.js +2 -0
  114. package/lib/browser/gateway/console-tenant.js +32 -1
  115. package/lib/browser/gateway/console-updates.d.ts +13 -0
  116. package/lib/browser/gateway/console-updates.js +113 -0
  117. package/lib/browser/gateway/console-util.d.ts +7 -1
  118. package/lib/browser/gateway/console-util.js +18 -0
  119. package/lib/browser/gateway/console-view.js +9 -2
  120. package/lib/browser/i18n/locales.d.ts +55 -3
  121. package/lib/browser/i18n/locales.js +8 -2
  122. package/lib/browser/i18n/messages-all.d.ts +8 -0
  123. package/lib/browser/i18n/messages-all.js +17 -0
  124. package/lib/browser/i18n/messages-ja.js +54 -4
  125. package/lib/browser/i18n/messages-zh-tw.js +54 -4
  126. package/lib/browser/i18n/messages.d.ts +56 -8
  127. package/lib/browser/i18n/messages.js +143 -21
  128. package/lib/browser/i18n/use-t.js +4 -3
  129. package/lib/browser/settings/settings.js +3 -1
  130. package/lib/browser/style/conversation-column.d.ts +1 -1
  131. package/lib/browser/style/conversation-column.js +2 -1
  132. package/lib/browser/style/dialogs.d.ts +1 -1
  133. package/lib/browser/style/dialogs.js +6 -0
  134. package/lib/browser/style/pages.d.ts +1 -1
  135. package/lib/browser/style/pages.js +11 -0
  136. package/lib/browser/style/surfaces.d.ts +1 -1
  137. package/lib/browser/style/surfaces.js +1 -0
  138. package/lib/browser/util/picture.d.ts +6 -0
  139. package/lib/browser/util/picture.js +46 -0
  140. package/lib/browser/util/turn-end.d.ts +8 -0
  141. package/lib/browser/util/turn-end.js +78 -35
  142. package/lib/browser/workbench-hosts.d.ts +4 -1
  143. package/lib/browser/workbench-hosts.js +17 -0
  144. package/lib/browser/workbench-protocol.d.ts +8 -0
  145. package/package.json +7 -7
@@ -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,12 +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");
57
+ const profile_view_1 = require("./profile-view");
55
58
  const relay_view_1 = require("./relay-view");
56
59
  const serve_restart_1 = require("./serve-restart");
57
60
  const settings_controls_1 = require("./settings-controls");
58
- const ta_avatar_1 = require("./ta-avatar");
59
61
  const working_directory_1 = require("./working-directory");
60
62
  const THEMES = [
61
63
  ['system', 'ta.settings.theme.system'],
@@ -79,6 +81,31 @@ function useAccountEntries(onSettings, onDialog) {
79
81
  // A finger has no keys to learn; a phone is not the computer that pairs phones.
80
82
  const { touch, handheld } = (0, device_1.useDevice)();
81
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
+ };
82
109
  const entry = (key, label, icon, run, more = {}) => ({
83
110
  key,
84
111
  label,
@@ -94,8 +121,9 @@ function useAccountEntries(onSettings, onDialog) {
94
121
  ...(touch ? [] : [entry('shortcuts', t('ta.manage.shortcuts'), lucide_react_1.Keyboard, () => onSettings('shortcuts'))]),
95
122
  ],
96
123
  [
97
- entry('devices', t('ta.myDevices.title'), lucide_react_1.MonitorSmartphone, () => onDialog('devices')),
98
- 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
+ }),
99
127
  entry('accounts', t('ta.manage.accounts'), lucide_react_1.KeyRound, () => onDialog('accounts')),
100
128
  entry('directory', t('ta.manage.workingDirectory'), lucide_react_1.FolderOpen, () => onDialog('directory')),
101
129
  ...(workbench_util_1.WorkbenchUtil.isApp() || handheld ? [] : [entry('relay', t('ta.manage.relay'), lucide_react_1.Smartphone, () => onDialog('relay'))]),
@@ -126,29 +154,35 @@ function useAccountEntries(onSettings, onDialog) {
126
154
  ]
127
155
  : []),
128
156
  entry('about', t('ta.manage.about'), lucide_react_1.Info, () => onSettings('about')),
129
- // As WeChat's: the computer in use kept, to come back to in one tap; signing out forgets it.
130
- entry('switchSignIn', t('ta.account.switchSignIn'), lucide_react_1.ArrowLeftRight, () => workbench.switchSignIn()),
131
- 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 }),
132
160
  ],
133
161
  ];
134
162
  }
135
163
  /** What the entries of the account open over the page. */
136
- function AccountDialogs({ dialog, onClose }) {
164
+ function AccountDialogs({ dialog, onClose, onDialog }) {
137
165
  return (React.createElement(React.Fragment, null,
166
+ dialog === 'profile' && React.createElement(profile_view_1.ProfileDialog, { onClose: onClose, onDevices: () => onDialog('devices') }),
138
167
  dialog === 'accounts' && React.createElement(auth_view_1.AuthDialog, { onClose: onClose }),
139
168
  dialog === 'directory' && React.createElement(working_directory_1.WorkingDirectoryPicker, { onClose: onClose }),
140
169
  dialog === 'relay' && React.createElement(relay_view_1.RelayDialog, { onClose: onClose }),
141
- dialog === 'hosts' && React.createElement(host_view_1.HostsDialog, { onClose: onClose }),
142
170
  dialog === 'devices' && React.createElement(account_view_1.DevicesDialog, { onClose: onClose })));
143
171
  }
144
- /** 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
+ */
145
176
  function AccountFigure({ size, className }) {
146
- 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 })));
147
179
  }
148
- /** 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. */
149
181
  function useAccount() {
150
- var _a, _b;
182
+ var _a, _b, _c;
151
183
  const t = (0, use_t_1.useT)();
184
+ const identity = (0, profile_view_1.useIdentity)();
185
+ const account = (0, profile_view_1.useAccountLine)();
152
186
  const [{ status, server, offlineShown, hosts, host }] = (0, hooks_1.useWorkbench)();
153
187
  const online = status === 'online';
154
188
  const state = online ? t('ta.online') : t('ta.reconnecting');
@@ -160,7 +194,8 @@ function useAccount() {
160
194
  online,
161
195
  offlineShown,
162
196
  state,
163
- 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,
164
199
  service: server && online ? `${state} · v${server.version}` : state,
165
200
  };
166
201
  }
@@ -181,6 +216,7 @@ function onArrows(event) {
181
216
  * the language a step away, in a second menu beside the first. A phone has them as its tab Me (me-view.tsx).
182
217
  */
183
218
  function AccountMenu({ onSettings, active }) {
219
+ var _a, _b;
184
220
  const t = (0, use_t_1.useT)();
185
221
  const account = useAccount();
186
222
  const [open, setOpen] = React.useState(false);
@@ -221,11 +257,14 @@ function AccountMenu({ onSettings, active }) {
221
257
  React.createElement(AccountFigure, { size: 28, className: "ta-account-figure" }),
222
258
  account.offlineShown && React.createElement("span", { className: "ta-account-dot" })),
223
259
  open && (React.createElement("div", { className: "ta-account-menu", id: id, role: "menu", "aria-label": t('ta.account.menu'), onKeyDown: onArrows },
224
- 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
+ } },
225
264
  React.createElement(AccountFigure, { size: 36, className: "ta-account-figure" }),
226
- React.createElement("div", { className: "ta-account-text" },
265
+ React.createElement("span", { className: "ta-account-text" },
227
266
  React.createElement("span", { className: "ta-account-title ta-ellipsis" }, account.name),
228
- 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))),
229
268
  React.createElement("div", { className: "ta-account-service", title: account.server ? `Ta v${account.server.version}` : undefined },
230
269
  React.createElement("span", { className: `ta-account-state ${account.online ? 'ta-ok' : 'ta-warn'}` }),
231
270
  React.createElement("span", { className: "ta-account-service-name" }, t('ta.account.service')),
@@ -235,6 +274,6 @@ function AccountMenu({ onSettings, active }) {
235
274
  .map(group => (React.createElement(React.Fragment, { key: group[0].key },
236
275
  React.createElement("div", { className: "ta-account-sep" }),
237
276
  group.map(item)))))),
238
- React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined) })));
277
+ React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined), onDialog: setDialog })));
239
278
  }
240
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