@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,22 +1,7 @@
1
1
  import { TurnEnd } from '../util/turn-end.js';
2
2
  import { Voice } from '../util/voice.js';
3
+ import { CallTurnEnd, RETRY_MS, SILENT_MS, SILENT_ROUNDS } from './call-turn-end.js';
3
4
  import { VoiceReopen } from './voice-reopen.js';
4
- /** Listens heard nothing this many times in a row, and for SILENT_MS: nobody is there, the call ends. */
5
- export const SILENT_ROUNDS = 4;
6
- /**
7
- * How long nobody spoke, the user nor Ta, before the call ends by itself: a recognizer ends a listen after a few
8
- * seconds of silence, and a user who waits for the work to answer is still there.
9
- */
10
- export const SILENT_MS = 3 * 60000;
11
- /**
12
- * The words heard stay the same this long: the user is done, though the recognizer goes on (it hears voices around them
13
- * and waits for a silence that never comes).
14
- */
15
- export const END_MS = 1300;
16
- /** At most this long a turn, from the first words: talk around the user that keeps the words coming ends there too. */
17
- export const TURN_MS = 15000;
18
- /** After a failure of the recognizer (not a denial), before it listens again. */
19
- const RETRY_MS = 600;
20
5
  const IDLE = { active: false, phase: 'listening', heard: '' };
21
6
  /**
22
7
  * 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
@@ -42,6 +27,7 @@ export class VoiceCall {
42
27
  /** What waits to be said that the user did not ask for (a dialog, a task that ended), in order. */
43
28
  this.announcements = [];
44
29
  this.voice = device;
30
+ this.turnEnd = new CallTurnEnd(options, () => this.quiet());
45
31
  }
46
32
  subscribe(listener) {
47
33
  this.listeners.add(listener);
@@ -299,8 +285,11 @@ export class VoiceCall {
299
285
  }
300
286
  }, this.options.voice(), (pieces, at) => this.state.active && round === this.round && this.set({ reading: { pieces, at } }));
301
287
  }
302
- /** Listens; first says what waits to be said, unless the user just cut in to speak (`announce` false). */
303
- listen(announce = true) {
288
+ /**
289
+ * Listens; first says what waits to be said, unless the user just cut in to speak (`announce` false). `held`: sounds
290
+ * alone a listen ended on, which what is heard now follows, gone or sent once it waited FILLER_MS for words.
291
+ */
292
+ listen(announce = true, held) {
304
293
  this.stopListening();
305
294
  if (this.state.paused) {
306
295
  return;
@@ -311,20 +300,17 @@ export class VoiceCall {
311
300
  return;
312
301
  }
313
302
  const round = ++this.round;
314
- let heard = '';
315
- this.set({ phase: 'listening', heard: '' });
316
- const listening = this.voice.listen(this.options.language(), text => {
317
- var _a, _b, _c;
303
+ let heard = held !== null && held !== void 0 ? held : '';
304
+ this.set({ phase: 'listening', heard });
305
+ const listening = this.voice.listen(this.options.language(), words => {
306
+ const text = held ? TurnEnd.join(held, words) : words;
318
307
  if (round === this.round) {
319
308
  const more = text.trim() !== heard.trim();
320
309
  heard = text;
321
310
  // The user says more: the captions are of what they say now, the last exchange gone.
322
311
  this.set(text.trim() ? { heard: text, said: undefined, reading: undefined } : { heard: text });
323
312
  if (more && text.trim()) {
324
- clearTimeout(this.endTimer);
325
- // Sooner once a sentence ended, later while the user hesitates ("那个…", "and").
326
- this.endTimer = setTimeout(() => this.endTurn(), TurnEnd.waitMs(text, (_a = this.options.endMs) !== null && _a !== void 0 ? _a : END_MS));
327
- (_b = this.turnTimer) !== null && _b !== void 0 ? _b : (this.turnTimer = setTimeout(() => this.endTurn(), (_c = this.options.turnMs) !== null && _c !== void 0 ? _c : TURN_MS));
313
+ this.turnEnd.heard(text);
328
314
  }
329
315
  }
330
316
  }, error => {
@@ -332,9 +318,7 @@ export class VoiceCall {
332
318
  return;
333
319
  }
334
320
  this.listening = undefined;
335
- clearTimeout(this.endTimer);
336
- clearTimeout(this.turnTimer);
337
- this.endTimer = this.turnTimer = undefined;
321
+ this.turnEnd.stop();
338
322
  this.heard(heard.trim(), error);
339
323
  });
340
324
  if (!listening) {
@@ -347,38 +331,58 @@ export class VoiceCall {
347
331
  return;
348
332
  }
349
333
  this.listening = listening;
334
+ if (held) {
335
+ this.turnEnd.hold();
336
+ }
350
337
  }
351
- /**
352
- * The user is done speaking (a pause after their words, or the mark of the bar tapped): what was heard goes now,
353
- * the recognizer stopped, whatever it would still hear.
354
- */
338
+ /** The user says they are done (the mark of the bar tapped): what was heard goes now as it is, sounds alone too. */
355
339
  endTurn() {
356
- const said = this.state.heard.trim();
357
- if (!this.state.active || this.state.paused || this.state.phase !== 'listening' || !said || !this.listening) {
358
- return;
340
+ const said = this.listened();
341
+ if (said) {
342
+ this.stopListening();
343
+ this.take(said);
344
+ }
345
+ }
346
+ /** The words heard stayed the same a while, or the turn is at its longest (CallTurnEnd): the user is done. */
347
+ quiet() {
348
+ const said = this.listened();
349
+ if (said) {
350
+ this.stopListening();
351
+ this.heard(said, undefined, true);
359
352
  }
360
- this.stopListening();
361
- this.heard(said, undefined);
362
353
  }
363
- /** A listen ended: what was said goes to the double; nothing, Ta listens again, a few times. */
364
- heard(said, error) {
354
+ /** What was heard of a listen going on, while Ta listens; undefined else. */
355
+ listened() {
356
+ const said = this.state.heard.trim();
357
+ return this.state.active && !this.state.paused && this.state.phase === 'listening' && said && this.listening ? said : undefined;
358
+ }
359
+ /**
360
+ * A listen ended: what was said goes to the double; nothing, Ta listens again, a few times. Sounds alone wait on in
361
+ * the next listen until they waited FILLER_MS (`waited`); then a hesitation is dropped and a backchannel goes.
362
+ */
363
+ heard(said, error, waited = false) {
365
364
  var _a;
366
365
  if (error && Voice.denied(error)) {
367
366
  this.end('denied');
368
367
  return;
369
368
  }
370
- if (said) {
371
- this.silent = 0;
372
- this.spoke = Date.now();
373
- this.set({ phase: 'thinking', heard: said, said, reading: undefined });
374
- if (this.partner) {
375
- this.ask(said);
369
+ if (said && !waited && this.turnEnd.waits(said)) {
370
+ if (error) {
371
+ this.retry = setTimeout(() => this.state.active && this.state.phase === 'listening' && this.listen(false, said), RETRY_MS);
376
372
  }
377
373
  else {
378
- this.options.send(said).catch(() => this.state.active && this.unsent());
374
+ this.listen(false, said);
379
375
  }
380
376
  return;
381
377
  }
378
+ if (said && TurnEnd.sounds(said) === 'hesitation') {
379
+ said = '';
380
+ this.set({ heard: '' });
381
+ }
382
+ if (said) {
383
+ this.take(said);
384
+ return;
385
+ }
382
386
  if (++this.silent >= SILENT_ROUNDS && Date.now() - this.spoke >= ((_a = this.options.silentMs) !== null && _a !== void 0 ? _a : SILENT_MS)) {
383
387
  this.end('silent');
384
388
  return;
@@ -390,6 +394,18 @@ export class VoiceCall {
390
394
  this.listen();
391
395
  }
392
396
  }
397
+ /** What the user said goes to the partner, or to the conversation. */
398
+ take(said) {
399
+ this.silent = 0;
400
+ this.spoke = Date.now();
401
+ this.set({ phase: 'thinking', heard: said, said, reading: undefined });
402
+ if (this.partner) {
403
+ this.ask(said);
404
+ }
405
+ else {
406
+ this.options.send(said).catch(() => this.state.active && this.unsent());
407
+ }
408
+ }
393
409
  /** The voice and the partner the call opens as it starts; undefined when it opens neither. A partner that fails is none. */
394
410
  open(direct) {
395
411
  var _a, _b, _c, _d, _e;
@@ -450,10 +466,7 @@ export class VoiceCall {
450
466
  }
451
467
  stopListening() {
452
468
  clearTimeout(this.retry);
453
- clearTimeout(this.endTimer);
454
- clearTimeout(this.turnTimer);
455
- this.endTimer = undefined;
456
- this.turnTimer = undefined;
469
+ this.turnEnd.stop();
457
470
  this.round++;
458
471
  const listening = this.listening;
459
472
  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.js';
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 {
@@ -1,8 +1,10 @@
1
1
  import { TaLanguageUtil } from '@celljs/ta-protocol';
2
- import { ArrowLeftRight, Check, ChevronRight, Download, FolderOpen, Info, Keyboard, KeyRound, Languages, LogOut, Monitor, MonitorSmartphone, Palette, Puzzle, RotateCw, Settings2, Smartphone, Sparkles, } from 'lucide-react';
2
+ import { ArrowLeftRight, Check, ChevronRight, Download, FolderOpen, Info, Keyboard, KeyRound, Languages, LogOut, MonitorSmartphone, Palette, Puzzle, RotateCw, Settings2, Smartphone, Sparkles, } from 'lucide-react';
3
3
  import * as React from 'react';
4
+ import { useAccountInfo, useAccountSide } from '../account/account-side.js';
5
+ import { DeviceAccount } from '../account/device-account.js';
4
6
  import { useDevice } from '../device/device.js';
5
- import { usePwa, useSettings, useWorkbench } from '../hooks.js';
7
+ import { useNotices, usePwa, useSettings, useWorkbench } from '../hooks.js';
6
8
  import { HostUtil } from '../hosts.js';
7
9
  import { useT } from '../i18n/use-t.js';
8
10
  import { WorkbenchUtil } from '../workbench-util.js';
@@ -10,12 +12,12 @@ import { DevicesDialog } from './account-view.js';
10
12
  import { AuthDialog } from './auth-view.js';
11
13
  import { DinoLookPicker } from './dino-look-picker.js';
12
14
  import { useDismiss } from './dismiss.js';
13
- import { HostsDialog } from './host-view.js';
15
+ import { Face } from './face.js';
14
16
  import { Icon } from './icon.js';
17
+ import { ProfileDialog, useAccountLine, useIdentity } from './profile-view.js';
15
18
  import { RelayDialog } from './relay-view.js';
16
19
  import { ServeRestartUtil, useRestartTa } from './serve-restart.js';
17
20
  import { Keys } from './settings-controls.js';
18
- import { DinoFace } from './ta-avatar.js';
19
21
  import { WorkingDirectoryPicker } from './working-directory.js';
20
22
  const THEMES = [
21
23
  ['system', 'ta.settings.theme.system'],
@@ -39,6 +41,31 @@ export function useAccountEntries(onSettings, onDialog) {
39
41
  // A finger has no keys to learn; a phone is not the computer that pairs phones.
40
42
  const { touch, handheld } = useDevice();
41
43
  const restartTa = useRestartTa();
44
+ const [, notices] = useNotices();
45
+ const side = useAccountSide();
46
+ const { info } = useAccountInfo(side, 15000);
47
+ const signedIn = Boolean(info === null || info === void 0 ? void 0 : info.account);
48
+ const app = WorkbenchUtil.isApp();
49
+ // Signed in, out of the account (its computers go, those connected by a code stay); else out of the computer in use.
50
+ const signOut = async () => {
51
+ if (!signedIn || !side) {
52
+ workbench.signOut();
53
+ return;
54
+ }
55
+ const title = t(app ? 'ta.myDevices.signOutConfirm' : 'ta.myDevices.signOutConfirmComputer');
56
+ if (!(await notices.confirm({ title, confirmLabel: t('ta.settings.signOut'), danger: true }))) {
57
+ return;
58
+ }
59
+ try {
60
+ await side.signOut();
61
+ if (app && workbench.state.status !== 'signed-out') {
62
+ workbench.switchSignIn();
63
+ }
64
+ }
65
+ catch (error) {
66
+ notices.error(error);
67
+ }
68
+ };
42
69
  const entry = (key, label, icon, run, more = {}) => ({
43
70
  key,
44
71
  label,
@@ -54,8 +81,9 @@ export function useAccountEntries(onSettings, onDialog) {
54
81
  ...(touch ? [] : [entry('shortcuts', t('ta.manage.shortcuts'), Keyboard, () => onSettings('shortcuts'))]),
55
82
  ],
56
83
  [
57
- entry('devices', t('ta.myDevices.title'), MonitorSmartphone, () => onDialog('devices')),
58
- entry('hosts', t('ta.hosts.title'), Monitor, () => onDialog('hosts'), { detail: inUse && (HostUtil.label(inUse) || t('ta.hosts.thisServer')) }),
84
+ entry('devices', t('ta.myDevices.title'), MonitorSmartphone, () => onDialog('devices'), {
85
+ detail: inUse && (HostUtil.label(inUse) || t('ta.hosts.thisServer')),
86
+ }),
59
87
  entry('accounts', t('ta.manage.accounts'), KeyRound, () => onDialog('accounts')),
60
88
  entry('directory', t('ta.manage.workingDirectory'), FolderOpen, () => onDialog('directory')),
61
89
  ...(WorkbenchUtil.isApp() || handheld ? [] : [entry('relay', t('ta.manage.relay'), Smartphone, () => onDialog('relay'))]),
@@ -86,29 +114,35 @@ export function useAccountEntries(onSettings, onDialog) {
86
114
  ]
87
115
  : []),
88
116
  entry('about', t('ta.manage.about'), Info, () => onSettings('about')),
89
- // As WeChat's: the computer in use kept, to come back to in one tap; signing out forgets it.
90
- entry('switchSignIn', t('ta.account.switchSignIn'), ArrowLeftRight, () => workbench.switchSignIn()),
91
- entry('signOut', t('ta.settings.signOut'), LogOut, () => workbench.signOut(), { danger: true }),
117
+ // As WeChat's: the account in use kept, with its computers, to come back to in one tap (docs/design/ta-me.md 4).
118
+ ...(app && signedIn ? [entry('switchAccount', t('ta.account.switchSignIn'), ArrowLeftRight, () => { var _a; return (_a = DeviceAccount.current()) === null || _a === void 0 ? void 0 : _a.switchAccount(); })] : []),
119
+ entry('signOut', t('ta.settings.signOut'), LogOut, () => void signOut(), { danger: true }),
92
120
  ],
93
121
  ];
94
122
  }
95
123
  /** What the entries of the account open over the page. */
96
- export function AccountDialogs({ dialog, onClose }) {
124
+ export function AccountDialogs({ dialog, onClose, onDialog }) {
97
125
  return (React.createElement(React.Fragment, null,
126
+ dialog === 'profile' && React.createElement(ProfileDialog, { onClose: onClose, onDevices: () => onDialog('devices') }),
98
127
  dialog === 'accounts' && React.createElement(AuthDialog, { onClose: onClose }),
99
128
  dialog === 'directory' && React.createElement(WorkingDirectoryPicker, { onClose: onClose }),
100
129
  dialog === 'relay' && React.createElement(RelayDialog, { onClose: onClose }),
101
- dialog === 'hosts' && React.createElement(HostsDialog, { onClose: onClose }),
102
130
  dialog === 'devices' && React.createElement(DevicesDialog, { onClose: onClose })));
103
131
  }
104
- /** The round figure of the account: a close-up of the double, the dinosaur the user picked for it (a T. rex until then). */
132
+ /**
133
+ * The round figure of the user: the picture they gave themselves (docs/design/ta-me.md 3), else the close-up of the
134
+ * double, the dinosaur they picked for it (a T. rex until then).
135
+ */
105
136
  export function AccountFigure({ size, className }) {
106
- return React.createElement(DinoFace, { size: size, className: className });
137
+ return (React.createElement("span", { className: className },
138
+ React.createElement(Face, { double: true, size: size })));
107
139
  }
108
- /** Who is signed in, to which machine (as named on this device), and whether the page is connected to it. */
140
+ /** 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. */
109
141
  export function useAccount() {
110
- var _a, _b;
142
+ var _a, _b, _c;
111
143
  const t = useT();
144
+ const identity = useIdentity();
145
+ const account = useAccountLine();
112
146
  const [{ status, server, offlineShown, hosts, host }] = useWorkbench();
113
147
  const online = status === 'online';
114
148
  const state = online ? t('ta.online') : t('ta.reconnecting');
@@ -120,7 +154,8 @@ export function useAccount() {
120
154
  online,
121
155
  offlineShown,
122
156
  state,
123
- name: (_b = server === null || server === void 0 ? void 0 : server.user) !== null && _b !== void 0 ? _b : t('ta.account'),
157
+ 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'),
158
+ account,
124
159
  service: server && online ? `${state} · v${server.version}` : state,
125
160
  };
126
161
  }
@@ -141,6 +176,7 @@ function onArrows(event) {
141
176
  * the language a step away, in a second menu beside the first. A phone has them as its tab Me (me-view.tsx).
142
177
  */
143
178
  export function AccountMenu({ onSettings, active }) {
179
+ var _a, _b;
144
180
  const t = useT();
145
181
  const account = useAccount();
146
182
  const [open, setOpen] = React.useState(false);
@@ -181,11 +217,14 @@ export function AccountMenu({ onSettings, active }) {
181
217
  React.createElement(AccountFigure, { size: 28, className: "ta-account-figure" }),
182
218
  account.offlineShown && React.createElement("span", { className: "ta-account-dot" })),
183
219
  open && (React.createElement("div", { className: "ta-account-menu", id: id, role: "menu", "aria-label": t('ta.account.menu'), onKeyDown: onArrows },
184
- React.createElement("div", { className: "ta-account-head" },
220
+ React.createElement("button", { type: "button", role: "menuitem", className: "ta-account-head", "aria-label": t('ta.me.profile'), onClick: () => {
221
+ close();
222
+ setDialog('profile');
223
+ } },
185
224
  React.createElement(AccountFigure, { size: 36, className: "ta-account-figure" }),
186
- React.createElement("div", { className: "ta-account-text" },
225
+ React.createElement("span", { className: "ta-account-text" },
187
226
  React.createElement("span", { className: "ta-account-title ta-ellipsis" }, account.name),
188
- account.machine && React.createElement("span", { className: "ta-account-sub ta-ellipsis" }, account.machine))),
227
+ ((_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))),
189
228
  React.createElement("div", { className: "ta-account-service", title: account.server ? `Ta v${account.server.version}` : undefined },
190
229
  React.createElement("span", { className: `ta-account-state ${account.online ? 'ta-ok' : 'ta-warn'}` }),
191
230
  React.createElement("span", { className: "ta-account-service-name" }, t('ta.account.service')),
@@ -195,6 +234,6 @@ export function AccountMenu({ onSettings, active }) {
195
234
  .map(group => (React.createElement(React.Fragment, { key: group[0].key },
196
235
  React.createElement("div", { className: "ta-account-sep" }),
197
236
  group.map(item)))))),
198
- React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined) })));
237
+ React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined), onDialog: setDialog })));
199
238
  }
200
239
  //# 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.js';
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.js';
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,5 +40,4 @@ 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 {};