@celljs/ta-web 4.20.0 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/browser/account/device-account.d.ts +65 -1
- package/esm/browser/account/device-account.js +206 -6
- package/esm/browser/assistant/assistant-chat-list.js +5 -1
- package/esm/browser/assistant/call-turn-end.d.ts +55 -0
- package/esm/browser/assistant/call-turn-end.js +68 -0
- package/esm/browser/assistant/realtime-voice.js +3 -3
- package/esm/browser/assistant/voice-call.d.ts +19 -28
- package/esm/browser/assistant/voice-call.js +64 -51
- package/esm/browser/components/account-menu.d.ts +9 -4
- package/esm/browser/components/account-menu.js +59 -22
- package/esm/browser/components/account-view.d.ts +33 -7
- package/esm/browser/components/account-view.js +140 -79
- package/esm/browser/components/chat-home-util.d.ts +13 -2
- package/esm/browser/components/chat-home-util.js +29 -0
- package/esm/browser/components/chat-home.d.ts +16 -4
- package/esm/browser/components/chat-home.js +9 -2
- package/esm/browser/components/chat-list.js +4 -2
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/cloud-sign-in-view.js +4 -1
- package/esm/browser/components/host-view.d.ts +15 -8
- package/esm/browser/components/host-view.js +23 -70
- package/esm/browser/components/me-view.d.ts +2 -2
- package/esm/browser/components/me-view.js +7 -6
- package/esm/browser/components/partner-row.d.ts +17 -0
- package/esm/browser/components/partner-row.js +48 -0
- package/esm/browser/components/profile-view.d.ts +11 -0
- package/esm/browser/components/profile-view.js +85 -0
- package/esm/browser/components/workbench-view.js +42 -7
- package/esm/browser/extension/web-api-components.d.ts +2 -2
- package/esm/browser/extension/web-api-home.d.ts +1 -0
- package/esm/browser/extension/web-api-partners.d.ts +95 -0
- package/esm/browser/extension/web-api-partners.js +2 -0
- package/esm/browser/extension/web-extension-api.d.ts +3 -3
- package/esm/browser/extension/web-extension-context.js +2 -2
- package/esm/browser/extension/web-extension-protocol.d.ts +8 -2
- package/esm/browser/extension/web-extension-run.d.ts +2 -1
- package/esm/browser/extension/web-extension-run.js +1 -0
- package/esm/browser/extension/web-extensions-running.d.ts +2 -0
- package/esm/browser/extension/web-extensions-running.js +3 -0
- package/esm/browser/extension/web-extensions.d.ts +1 -1
- package/esm/browser/extension/web-home.d.ts +11 -19
- package/esm/browser/extension/web-home.js +15 -68
- package/esm/browser/extension/web-partners.d.ts +8 -0
- package/esm/browser/extension/web-partners.js +13 -0
- package/esm/browser/extension/web-row-board.d.ts +38 -0
- package/esm/browser/extension/web-row-board.js +79 -0
- package/esm/browser/i18n/locales.d.ts +31 -1
- package/esm/browser/i18n/messages-ja.js +34 -4
- package/esm/browser/i18n/messages-zh-tw.js +34 -4
- package/esm/browser/i18n/messages.d.ts +30 -0
- package/esm/browser/i18n/messages.js +68 -8
- package/esm/browser/index.d.ts +4 -0
- package/esm/browser/index.js +4 -0
- package/esm/browser/partners/group-picker.d.ts +18 -0
- package/esm/browser/partners/group-picker.js +81 -0
- package/esm/browser/partners/partners-extension.d.ts +14 -0
- package/esm/browser/partners/partners-extension.js +61 -0
- package/esm/browser/partners/partners-util.d.ts +32 -0
- package/esm/browser/partners/partners-util.js +68 -0
- package/esm/browser/partners/partners-view.d.ts +32 -0
- package/esm/browser/partners/partners-view.js +103 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +18 -0
- package/esm/browser/style/conversation-column.d.ts +1 -1
- package/esm/browser/style/conversation-column.js +2 -1
- package/esm/browser/style/dialogs.d.ts +1 -1
- package/esm/browser/style/dialogs.js +6 -0
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +1 -1
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +6 -0
- package/esm/browser/util/turn-end.d.ts +8 -0
- package/esm/browser/util/turn-end.js +78 -35
- package/esm/browser/workbench-hosts.d.ts +4 -1
- package/esm/browser/workbench-hosts.js +17 -0
- package/esm/browser/workbench-protocol.d.ts +8 -0
- package/lib/browser/account/device-account.d.ts +65 -1
- package/lib/browser/account/device-account.js +206 -6
- package/lib/browser/assistant/assistant-chat-list.js +5 -1
- package/lib/browser/assistant/call-turn-end.d.ts +56 -0
- package/lib/browser/assistant/call-turn-end.js +72 -0
- package/lib/browser/assistant/realtime-voice.js +3 -3
- package/lib/browser/assistant/voice-call.d.ts +19 -28
- package/lib/browser/assistant/voice-call.js +67 -54
- package/lib/browser/components/account-menu.d.ts +9 -4
- package/lib/browser/components/account-menu.js +57 -20
- package/lib/browser/components/account-view.d.ts +33 -7
- package/lib/browser/components/account-view.js +142 -77
- package/lib/browser/components/chat-home-util.d.ts +13 -2
- package/lib/browser/components/chat-home-util.js +29 -0
- package/lib/browser/components/chat-home.d.ts +16 -4
- package/lib/browser/components/chat-home.js +9 -1
- package/lib/browser/components/chat-list.js +4 -2
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/cloud-sign-in-view.js +4 -1
- package/lib/browser/components/host-view.d.ts +15 -8
- package/lib/browser/components/host-view.js +22 -68
- package/lib/browser/components/me-view.d.ts +2 -2
- package/lib/browser/components/me-view.js +7 -6
- package/lib/browser/components/partner-row.d.ts +18 -0
- package/lib/browser/components/partner-row.js +84 -0
- package/lib/browser/components/profile-view.d.ts +12 -0
- package/lib/browser/components/profile-view.js +123 -0
- package/lib/browser/components/workbench-view.js +39 -4
- package/lib/browser/extension/web-api-components.d.ts +2 -2
- package/lib/browser/extension/web-api-home.d.ts +1 -0
- package/lib/browser/extension/web-api-partners.d.ts +96 -0
- package/lib/browser/extension/web-api-partners.js +3 -0
- package/lib/browser/extension/web-extension-api.d.ts +3 -3
- package/lib/browser/extension/web-extension-context.js +2 -2
- package/lib/browser/extension/web-extension-protocol.d.ts +8 -2
- package/lib/browser/extension/web-extension-run.d.ts +2 -1
- package/lib/browser/extension/web-extension-run.js +1 -0
- package/lib/browser/extension/web-extensions-running.d.ts +2 -0
- package/lib/browser/extension/web-extensions-running.js +3 -0
- package/lib/browser/extension/web-extensions.d.ts +1 -1
- package/lib/browser/extension/web-home.d.ts +11 -19
- package/lib/browser/extension/web-home.js +15 -68
- package/lib/browser/extension/web-partners.d.ts +9 -0
- package/lib/browser/extension/web-partners.js +17 -0
- package/lib/browser/extension/web-row-board.d.ts +39 -0
- package/lib/browser/extension/web-row-board.js +83 -0
- package/lib/browser/i18n/locales.d.ts +31 -1
- package/lib/browser/i18n/messages-ja.js +34 -4
- package/lib/browser/i18n/messages-zh-tw.js +34 -4
- package/lib/browser/i18n/messages.d.ts +30 -0
- package/lib/browser/i18n/messages.js +68 -8
- package/lib/browser/index.d.ts +4 -0
- package/lib/browser/index.js +4 -0
- package/lib/browser/partners/group-picker.d.ts +19 -0
- package/lib/browser/partners/group-picker.js +119 -0
- package/lib/browser/partners/partners-extension.d.ts +15 -0
- package/lib/browser/partners/partners-extension.js +97 -0
- package/lib/browser/partners/partners-util.d.ts +33 -0
- package/lib/browser/partners/partners-util.js +71 -0
- package/lib/browser/partners/partners-view.d.ts +33 -0
- package/lib/browser/partners/partners-view.js +144 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +18 -0
- package/lib/browser/style/conversation-column.d.ts +1 -1
- package/lib/browser/style/conversation-column.js +2 -1
- package/lib/browser/style/dialogs.d.ts +1 -1
- package/lib/browser/style/dialogs.js +6 -0
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +1 -1
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +6 -0
- package/lib/browser/util/turn-end.d.ts +8 -0
- package/lib/browser/util/turn-end.js +78 -35
- package/lib/browser/workbench-hosts.d.ts +4 -1
- package/lib/browser/workbench-hosts.js +17 -0
- package/lib/browser/workbench-protocol.d.ts +8 -0
- 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
|
-
/**
|
|
303
|
-
|
|
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(),
|
|
317
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
357
|
-
if (
|
|
358
|
-
|
|
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
|
-
/**
|
|
364
|
-
|
|
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
|
-
|
|
372
|
-
|
|
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.
|
|
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
|
-
|
|
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' | '
|
|
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
|
-
/**
|
|
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
|
|
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,
|
|
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,13 +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 {
|
|
15
|
+
import { Face } from './face.js';
|
|
14
16
|
import { Icon } from './icon.js';
|
|
15
|
-
import {
|
|
17
|
+
import { ProfileDialog, useAccountLine, useIdentity } from './profile-view.js';
|
|
16
18
|
import { RelayDialog } from './relay-view.js';
|
|
17
19
|
import { ServeRestartUtil, useRestartTa } from './serve-restart.js';
|
|
18
20
|
import { Keys } from './settings-controls.js';
|
|
19
|
-
import { DinoFace } from './ta-avatar.js';
|
|
20
21
|
import { WorkingDirectoryPicker } from './working-directory.js';
|
|
21
22
|
const THEMES = [
|
|
22
23
|
['system', 'ta.settings.theme.system'],
|
|
@@ -40,6 +41,31 @@ export function useAccountEntries(onSettings, onDialog) {
|
|
|
40
41
|
// A finger has no keys to learn; a phone is not the computer that pairs phones.
|
|
41
42
|
const { touch, handheld } = useDevice();
|
|
42
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
|
+
};
|
|
43
69
|
const entry = (key, label, icon, run, more = {}) => ({
|
|
44
70
|
key,
|
|
45
71
|
label,
|
|
@@ -49,15 +75,15 @@ export function useAccountEntries(onSettings, onDialog) {
|
|
|
49
75
|
});
|
|
50
76
|
return [
|
|
51
77
|
[
|
|
52
|
-
entry('picture', t('ta.picture.title'), CircleUserRound, () => PicturePicker.open()),
|
|
53
78
|
entry('look', t('ta.look.title'), Sparkles, () => DinoLookPicker.open()),
|
|
54
79
|
entry('settings', t('ta.settings'), Settings2, () => onSettings(), { keys: touch ? undefined : 'Mod+,' }),
|
|
55
80
|
entry('packages', t('ta.manage.packages'), Puzzle, () => onSettings('packages')),
|
|
56
81
|
...(touch ? [] : [entry('shortcuts', t('ta.manage.shortcuts'), Keyboard, () => onSettings('shortcuts'))]),
|
|
57
82
|
],
|
|
58
83
|
[
|
|
59
|
-
entry('devices', t('ta.myDevices.title'), MonitorSmartphone, () => onDialog('devices')
|
|
60
|
-
|
|
84
|
+
entry('devices', t('ta.myDevices.title'), MonitorSmartphone, () => onDialog('devices'), {
|
|
85
|
+
detail: inUse && (HostUtil.label(inUse) || t('ta.hosts.thisServer')),
|
|
86
|
+
}),
|
|
61
87
|
entry('accounts', t('ta.manage.accounts'), KeyRound, () => onDialog('accounts')),
|
|
62
88
|
entry('directory', t('ta.manage.workingDirectory'), FolderOpen, () => onDialog('directory')),
|
|
63
89
|
...(WorkbenchUtil.isApp() || handheld ? [] : [entry('relay', t('ta.manage.relay'), Smartphone, () => onDialog('relay'))]),
|
|
@@ -88,29 +114,35 @@ export function useAccountEntries(onSettings, onDialog) {
|
|
|
88
114
|
]
|
|
89
115
|
: []),
|
|
90
116
|
entry('about', t('ta.manage.about'), Info, () => onSettings('about')),
|
|
91
|
-
// As WeChat's: the
|
|
92
|
-
entry('
|
|
93
|
-
entry('signOut', t('ta.settings.signOut'), LogOut, () =>
|
|
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 }),
|
|
94
120
|
],
|
|
95
121
|
];
|
|
96
122
|
}
|
|
97
123
|
/** What the entries of the account open over the page. */
|
|
98
|
-
export function AccountDialogs({ dialog, onClose }) {
|
|
124
|
+
export function AccountDialogs({ dialog, onClose, onDialog }) {
|
|
99
125
|
return (React.createElement(React.Fragment, null,
|
|
126
|
+
dialog === 'profile' && React.createElement(ProfileDialog, { onClose: onClose, onDevices: () => onDialog('devices') }),
|
|
100
127
|
dialog === 'accounts' && React.createElement(AuthDialog, { onClose: onClose }),
|
|
101
128
|
dialog === 'directory' && React.createElement(WorkingDirectoryPicker, { onClose: onClose }),
|
|
102
129
|
dialog === 'relay' && React.createElement(RelayDialog, { onClose: onClose }),
|
|
103
|
-
dialog === 'hosts' && React.createElement(HostsDialog, { onClose: onClose }),
|
|
104
130
|
dialog === 'devices' && React.createElement(DevicesDialog, { onClose: onClose })));
|
|
105
131
|
}
|
|
106
|
-
/**
|
|
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
|
+
*/
|
|
107
136
|
export function AccountFigure({ size, className }) {
|
|
108
|
-
return React.createElement(
|
|
137
|
+
return (React.createElement("span", { className: className },
|
|
138
|
+
React.createElement(Face, { double: true, size: size })));
|
|
109
139
|
}
|
|
110
|
-
/** Who is
|
|
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. */
|
|
111
141
|
export function useAccount() {
|
|
112
|
-
var _a, _b;
|
|
142
|
+
var _a, _b, _c;
|
|
113
143
|
const t = useT();
|
|
144
|
+
const identity = useIdentity();
|
|
145
|
+
const account = useAccountLine();
|
|
114
146
|
const [{ status, server, offlineShown, hosts, host }] = useWorkbench();
|
|
115
147
|
const online = status === 'online';
|
|
116
148
|
const state = online ? t('ta.online') : t('ta.reconnecting');
|
|
@@ -122,7 +154,8 @@ export function useAccount() {
|
|
|
122
154
|
online,
|
|
123
155
|
offlineShown,
|
|
124
156
|
state,
|
|
125
|
-
name: (_b = server === null || server === void 0 ? void 0 : server.user) !== null &&
|
|
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,
|
|
126
159
|
service: server && online ? `${state} · v${server.version}` : state,
|
|
127
160
|
};
|
|
128
161
|
}
|
|
@@ -143,6 +176,7 @@ function onArrows(event) {
|
|
|
143
176
|
* the language a step away, in a second menu beside the first. A phone has them as its tab Me (me-view.tsx).
|
|
144
177
|
*/
|
|
145
178
|
export function AccountMenu({ onSettings, active }) {
|
|
179
|
+
var _a, _b;
|
|
146
180
|
const t = useT();
|
|
147
181
|
const account = useAccount();
|
|
148
182
|
const [open, setOpen] = React.useState(false);
|
|
@@ -183,11 +217,14 @@ export function AccountMenu({ onSettings, active }) {
|
|
|
183
217
|
React.createElement(AccountFigure, { size: 28, className: "ta-account-figure" }),
|
|
184
218
|
account.offlineShown && React.createElement("span", { className: "ta-account-dot" })),
|
|
185
219
|
open && (React.createElement("div", { className: "ta-account-menu", id: id, role: "menu", "aria-label": t('ta.account.menu'), onKeyDown: onArrows },
|
|
186
|
-
React.createElement("
|
|
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
|
+
} },
|
|
187
224
|
React.createElement(AccountFigure, { size: 36, className: "ta-account-figure" }),
|
|
188
|
-
React.createElement("
|
|
225
|
+
React.createElement("span", { className: "ta-account-text" },
|
|
189
226
|
React.createElement("span", { className: "ta-account-title ta-ellipsis" }, account.name),
|
|
190
|
-
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))),
|
|
191
228
|
React.createElement("div", { className: "ta-account-service", title: account.server ? `Ta v${account.server.version}` : undefined },
|
|
192
229
|
React.createElement("span", { className: `ta-account-state ${account.online ? 'ta-ok' : 'ta-warn'}` }),
|
|
193
230
|
React.createElement("span", { className: "ta-account-service-name" }, t('ta.account.service')),
|
|
@@ -197,6 +234,6 @@ export function AccountMenu({ onSettings, active }) {
|
|
|
197
234
|
.map(group => (React.createElement(React.Fragment, { key: group[0].key },
|
|
198
235
|
React.createElement("div", { className: "ta-account-sep" }),
|
|
199
236
|
group.map(item)))))),
|
|
200
|
-
React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined) })));
|
|
237
|
+
React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined), onDialog: setDialog })));
|
|
201
238
|
}
|
|
202
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
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
|
-
|
|
17
|
-
export declare function AccountSignInEntry(): React.JSX.Element | null;
|
|
43
|
+
export {};
|