@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,24 +1,29 @@
|
|
|
1
|
-
import { Globe, Laptop,
|
|
1
|
+
import { ClipboardPaste, Cloud, Globe, Laptop, ScanLine, Smartphone, Trash2, X } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { useAccountInfo, useAccountSide } from '../account/account-side.js';
|
|
5
|
+
import { DeviceAccount } from '../account/device-account.js';
|
|
5
6
|
import { useBackLayer } from '../device/back-stack.js';
|
|
6
7
|
import { ConsoleUtil } from '../gateway/console-util.js';
|
|
7
8
|
import { useNotices, useWorkbench } from '../hooks.js';
|
|
9
|
+
import { HostUtil } from '../hosts.js';
|
|
8
10
|
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
9
11
|
import { WorkbenchUtil } from '../workbench-util.js';
|
|
10
12
|
import { BusyMark, useBusy } from './busy.js';
|
|
11
13
|
import { Callout } from './callout.js';
|
|
12
|
-
import { CodeBox } from './cloud-sign-in-view.js';
|
|
14
|
+
import { CloudSignInEntry, CloudSignInFlow, CodeBox } from './cloud-sign-in-view.js';
|
|
15
|
+
import { useContextMenu } from './context-menu.js';
|
|
16
|
+
import { HostRow, LinkForm, useAddHost } from './host-view.js';
|
|
13
17
|
import { Icon, IconButton } from './icon.js';
|
|
14
18
|
import { Loading } from './loading.js';
|
|
15
19
|
import { SignInMark } from './sign-in-marks.js';
|
|
16
20
|
/*
|
|
17
|
-
* The user's account and
|
|
18
|
-
* device in after comparing its code, and
|
|
19
|
-
*
|
|
21
|
+
* The user's account and the devices of it (docs/design/ta-account.md, ta-me.md): signing in, waiting to be let in,
|
|
22
|
+
* letting a new device in after comparing its code, and one list of the devices, the computers this device connects to
|
|
23
|
+
* (of the account, a code or a link, a Ta in the cloud) with the other devices of the account. The same on a computer
|
|
24
|
+
* (its ta serve's account) and in the app (the phone's own).
|
|
20
25
|
*/
|
|
21
|
-
const KIND_ICONS = { computer: Laptop, phone: Smartphone, browser: Globe };
|
|
26
|
+
const KIND_ICONS = { computer: Laptop, phone: Smartphone, browser: Globe, cloud: Cloud };
|
|
22
27
|
/** The code of six digits, split in two for the eye: 482 913. */
|
|
23
28
|
function codeText(code) {
|
|
24
29
|
return `${code.slice(0, 3)} ${code.slice(3)}`;
|
|
@@ -28,8 +33,23 @@ function providerName(info, id) {
|
|
|
28
33
|
var _b;
|
|
29
34
|
return (_b = (_a = info.providers.find(one => one.id === id)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : (id === 'github' ? 'GitHub' : id);
|
|
30
35
|
}
|
|
31
|
-
/**
|
|
32
|
-
function
|
|
36
|
+
/** The ways an account's id tells (`github:42`, `iam:su`), as the user knows them: GitHub, the company account. */
|
|
37
|
+
export function useAccountWay() {
|
|
38
|
+
const t = useT();
|
|
39
|
+
return id => {
|
|
40
|
+
const way = id.split(':')[0];
|
|
41
|
+
return way === 'github' ? 'GitHub' : way === 'google' ? 'Google' : way === 'wechat' ? t('ta.signin.wechat') : t('ta.me.companyAccount');
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** What the user is called in an account: its name, without the way it came by (`iam:su` is su). */
|
|
45
|
+
export function accountName(account) {
|
|
46
|
+
return account.name.replace(/^[a-z][\w-]*:/i, '');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 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
|
|
50
|
+
* account as to its Ta in the cloud (CloudSignInFlow), not here.
|
|
51
|
+
*/
|
|
52
|
+
export function SignInPart({ info, act }) {
|
|
33
53
|
const t = useT();
|
|
34
54
|
const [busy, run] = useBusy();
|
|
35
55
|
const [, notices] = useNotices();
|
|
@@ -46,10 +66,11 @@ function SignInPart({ info, act }) {
|
|
|
46
66
|
t('ta.myDevices.openProvider', { name })),
|
|
47
67
|
React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => go(side => side.cancelSignIn()) }, t('ta.cancel'))));
|
|
48
68
|
}
|
|
49
|
-
|
|
50
|
-
|
|
69
|
+
const ways = WorkbenchUtil.isApp() ? info.providers.filter(one => !one.gateway) : info.providers;
|
|
70
|
+
if (ways.length === 0) {
|
|
71
|
+
return null;
|
|
51
72
|
}
|
|
52
|
-
return (React.createElement("div", { className: "ta-account-ways" },
|
|
73
|
+
return (React.createElement("div", { className: "ta-account-ways" }, ways.map(provider => (React.createElement("button", { key: `${provider.service} ${provider.id}`, type: "button", className: busy ? 'ta-button ta-primary ta-wide ta-busy' : 'ta-button ta-primary ta-wide', "aria-busy": busy || undefined, onClick: () => go(async (side) => {
|
|
53
74
|
const next = await side.signIn(provider.id, provider.service);
|
|
54
75
|
if (next.signingIn) {
|
|
55
76
|
window.open(next.signingIn.url, '_blank', 'noopener,noreferrer');
|
|
@@ -62,7 +83,7 @@ function SignInPart({ info, act }) {
|
|
|
62
83
|
React.createElement(BusyMark, { busy: busy }))))));
|
|
63
84
|
}
|
|
64
85
|
/** This device waits to be let in by another of the account: the code both show. */
|
|
65
|
-
function WaitingPart({ code }) {
|
|
86
|
+
export function WaitingPart({ code }) {
|
|
66
87
|
const t = useT();
|
|
67
88
|
return (React.createElement("div", { className: "ta-account-waiting" },
|
|
68
89
|
React.createElement("strong", null, t('ta.myDevices.waitingTitle')),
|
|
@@ -93,82 +114,137 @@ function DeviceRow({ device, onApprove, onRemove, onOpen }) {
|
|
|
93
114
|
onOpen && (React.createElement("button", { type: "button", className: "ta-button", onClick: onOpen }, t('ta.myDevices.open'))),
|
|
94
115
|
!device.self && React.createElement(IconButton, { icon: Trash2, label: t('ta.myDevices.remove'), onClick: onRemove })))));
|
|
95
116
|
}
|
|
96
|
-
/**
|
|
97
|
-
export function
|
|
98
|
-
var _a;
|
|
117
|
+
/** The ways to the account on the sign-in of the app, or where it stands: the code to enter, waiting, signed in. */
|
|
118
|
+
export function AccountWays({ info, act }) {
|
|
99
119
|
const t = useT();
|
|
100
|
-
const
|
|
120
|
+
const way = useAccountWay();
|
|
101
121
|
const [, notices] = useNotices();
|
|
102
|
-
|
|
103
|
-
const app = WorkbenchUtil.isApp();
|
|
104
|
-
const go = (action) => void act(action).catch((error) => notices.error(error));
|
|
105
|
-
if (!info) {
|
|
106
|
-
return failed ? React.createElement(Callout, { level: "error" }, String((_a = failed.message) !== null && _a !== void 0 ? _a : failed)) : React.createElement(Loading, { compact: true });
|
|
107
|
-
}
|
|
108
|
-
if (!info.account) {
|
|
122
|
+
if (info.signingIn || !info.account) {
|
|
109
123
|
return (React.createElement(React.Fragment, null,
|
|
110
|
-
React.createElement("p", { className: "ta-account-hint" }, t('ta.myDevices.hint')),
|
|
111
124
|
info.error && React.createElement(Callout, { level: "error" }, info.error),
|
|
112
125
|
React.createElement(SignInPart, { info: info, act: act })));
|
|
113
126
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
};
|
|
127
|
+
if (info.waiting && info.code) {
|
|
128
|
+
return React.createElement(WaitingPart, { code: info.code });
|
|
129
|
+
}
|
|
130
|
+
// Signed in, no computer of the account yet: they come by themselves once signed in there.
|
|
120
131
|
const signOut = async () => {
|
|
121
|
-
if (await notices.confirm({
|
|
122
|
-
|
|
123
|
-
confirmLabel: t('ta.myDevices.signOut'),
|
|
124
|
-
danger: true,
|
|
125
|
-
})) {
|
|
126
|
-
go(one => one.signOut());
|
|
132
|
+
if (await notices.confirm({ title: t('ta.myDevices.signOutConfirm'), confirmLabel: t('ta.settings.signOut'), danger: true })) {
|
|
133
|
+
void act(side => side.signOut()).catch((error) => notices.error(error));
|
|
127
134
|
}
|
|
128
135
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
React.createElement("span", { className: "ta-
|
|
148
|
-
React.createElement(
|
|
149
|
-
React.createElement("span", { className: "ta-ellipsis" },
|
|
150
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => void signOut() },
|
|
151
|
-
React.createElement(Icon, { icon: LogOut, size: 14 }),
|
|
152
|
-
" ",
|
|
153
|
-
t('ta.myDevices.signOut')))));
|
|
136
|
+
return (React.createElement("div", { className: "ta-account-signed" },
|
|
137
|
+
React.createElement("span", { className: "ta-account-who" },
|
|
138
|
+
React.createElement(SignInMark, { provider: info.account.id.split(':')[0], size: 16 }),
|
|
139
|
+
React.createElement("span", { className: "ta-ellipsis" },
|
|
140
|
+
way(info.account.id),
|
|
141
|
+
" \u00B7 ",
|
|
142
|
+
accountName(info.account))),
|
|
143
|
+
React.createElement("p", { className: "ta-account-hint" }, t('ta.myDevices.computersComing')),
|
|
144
|
+
React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => void signOut() }, t('ta.settings.signOut'))));
|
|
145
|
+
}
|
|
146
|
+
/** The accounts this device switched away from, on its sign-in: a tap goes back to one, its computers with it. */
|
|
147
|
+
export function RecentAccounts() {
|
|
148
|
+
const way = useAccountWay();
|
|
149
|
+
const [recent] = React.useState(() => (WorkbenchUtil.isApp() ? DeviceAccount.recent() : []));
|
|
150
|
+
return (React.createElement(React.Fragment, null, recent.map(one => (React.createElement("li", { key: one.kept.account.id, className: "ta-host-row" },
|
|
151
|
+
React.createElement("button", { type: "button", className: "ta-host-item", onClick: () => { var _a; return (_a = DeviceAccount.current()) === null || _a === void 0 ? void 0 : _a.resume(one.kept.account.id); } },
|
|
152
|
+
React.createElement("span", { className: "ta-chat-avatar ta-account-recent-mark", "aria-hidden": "true" },
|
|
153
|
+
React.createElement(SignInMark, { provider: one.kept.account.id.split(':')[0], size: 18 })),
|
|
154
|
+
React.createElement("span", { className: "ta-host-text" },
|
|
155
|
+
React.createElement("span", { className: "ta-host-name ta-ellipsis" }, accountName(one.kept.account)),
|
|
156
|
+
React.createElement("span", { className: "ta-host-detail ta-ellipsis" }, way(one.kept.account.id)))))))));
|
|
154
157
|
}
|
|
155
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* My devices, over the page (docs/design/ta-me.md 2): the one list of the computers this device uses, the one in use
|
|
160
|
+
* checked, a tap switching to another; the other devices of the account under them, those waiting to be let in first;
|
|
161
|
+
* and the ways to add one: the account, a code, a link, a Ta in the cloud.
|
|
162
|
+
*/
|
|
156
163
|
export function DevicesDialog({ onClose }) {
|
|
164
|
+
var _a, _b;
|
|
157
165
|
const t = useT();
|
|
166
|
+
const language = useLanguage();
|
|
158
167
|
const side = useAccountSide();
|
|
168
|
+
const { info, failed, act } = useAccountInfo(side);
|
|
169
|
+
const [{ hosts, host: currentId, switching }, bench] = useWorkbench();
|
|
170
|
+
const [, notices] = useNotices();
|
|
171
|
+
const [menu, openMenu] = useContextMenu();
|
|
172
|
+
const [adding, setAdding] = React.useState();
|
|
173
|
+
const add = useAddHost();
|
|
159
174
|
useBackLayer(true, onClose);
|
|
160
175
|
React.useEffect(() => {
|
|
161
176
|
const onKey = (event) => event.key === 'Escape' && onClose();
|
|
162
177
|
document.addEventListener('keydown', onKey);
|
|
163
178
|
return () => document.removeEventListener('keydown', onKey);
|
|
164
179
|
}, [onClose]);
|
|
180
|
+
const go = (action) => void act(action).catch((error) => notices.error(error));
|
|
181
|
+
const devices = (info === null || info === void 0 ? void 0 : info.account) && !info.waiting ? info.devices : [];
|
|
182
|
+
const ofAccount = (host) => (host.account ? devices.find(one => one.id === host.account) : undefined);
|
|
183
|
+
const seen = (device) => device.online ? t('ta.myDevices.online') : t('ta.myDevices.seen', { time: ConsoleUtil.ago(device.seenAt, language) });
|
|
184
|
+
const others = devices
|
|
185
|
+
.filter(one => !one.self && !hosts.some(host => host.account === one.id))
|
|
186
|
+
.sort((a, b) => Number(b.waiting) - Number(a.waiting) || a.addedAt - b.addedAt);
|
|
187
|
+
const removeDevice = async (device) => {
|
|
188
|
+
if (device.waiting ||
|
|
189
|
+
(await notices.confirm({ title: t('ta.myDevices.removeConfirm', { name: device.name }), confirmLabel: t('ta.myDevices.remove'), danger: true }))) {
|
|
190
|
+
go(one => one.remove(device.id));
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const removeHost = async (host) => {
|
|
194
|
+
const device = ofAccount(host);
|
|
195
|
+
if (device) {
|
|
196
|
+
await removeDevice(device);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const name = HostUtil.label(host) || t('ta.hosts.thisServer');
|
|
200
|
+
if (await notices.confirm({ title: t('ta.hosts.removeConfirm', { name }), confirmLabel: t('ta.hosts.remove'), danger: true })) {
|
|
201
|
+
bench.forget(host.id);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const rename = async (host) => {
|
|
205
|
+
var _a;
|
|
206
|
+
const name = await notices.input({ title: t('ta.hosts.rename'), value: HostUtil.label(host), placeholder: (_a = host.server) === null || _a === void 0 ? void 0 : _a.host });
|
|
207
|
+
if (name !== undefined) {
|
|
208
|
+
bench.rename(host.id, name);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const signedOut = info && !info.account && !info.signingIn;
|
|
165
212
|
return createPortal(React.createElement("div", { className: "ta-modal-scrim" },
|
|
166
213
|
React.createElement("button", { type: "button", className: "ta-overlay-close", "aria-label": t('ta.close'), tabIndex: -1, onClick: onClose }),
|
|
167
|
-
React.createElement("div", { className: "ta-modal ta-account-dialog", role: "dialog", "aria-modal": "true", "aria-label": t('ta.myDevices.title') },
|
|
214
|
+
React.createElement("div", { className: "ta-modal ta-hosts-dialog ta-account-dialog", role: "dialog", "aria-modal": "true", "aria-label": t('ta.myDevices.title') },
|
|
168
215
|
React.createElement("div", { className: "ta-modal-head" },
|
|
169
216
|
React.createElement("span", { className: "ta-modal-title" }, t('ta.myDevices.title')),
|
|
170
217
|
React.createElement(IconButton, { icon: X, label: t('ta.close'), onClick: onClose })),
|
|
171
|
-
|
|
218
|
+
(info === null || info === void 0 ? void 0 : info.waiting) && info.code ? React.createElement(WaitingPart, { code: info.code }) : null,
|
|
219
|
+
(info === null || info === void 0 ? void 0 : info.error) || failed ? React.createElement(Callout, { level: "error" }, (_a = info === null || info === void 0 ? void 0 : info.error) !== null && _a !== void 0 ? _a : String((_b = failed.message) !== null && _b !== void 0 ? _b : failed)) : null,
|
|
220
|
+
React.createElement("ul", { className: "ta-host-list", hidden: adding === 'cloud' }, hosts.map(host => {
|
|
221
|
+
const device = ofAccount(host);
|
|
222
|
+
return (React.createElement(HostRow, { key: host.id, host: host, detail: device && seen(device), current: host.id === currentId, switching: host.id === switching, onPick: () => bench.switchTo(host.id), onRemove: () => void removeHost(host), onMenu: event => openMenu(event, [
|
|
223
|
+
{ label: t('ta.hosts.rename'), run: () => void rename(host) },
|
|
224
|
+
{ label: t('ta.hosts.remove'), run: () => void removeHost(host) },
|
|
225
|
+
]) }));
|
|
226
|
+
})),
|
|
227
|
+
others.length > 0 && adding !== 'cloud' && (React.createElement("section", { className: "ta-account-others" },
|
|
228
|
+
React.createElement("h2", null, t('ta.myDevices.others')),
|
|
229
|
+
React.createElement("ul", { className: "ta-account-devices" }, others.map(device => (React.createElement(DeviceRow, { key: device.id, device: device, onApprove: () => go(one => one.approve(device.id)), onRemove: () => void removeDevice(device) })))))),
|
|
230
|
+
add.error && React.createElement(Callout, { level: "error" }, t(add.error)),
|
|
231
|
+
adding === 'cloud' ? (React.createElement(CloudSignInFlow, { onBack: () => setAdding(undefined) })) : adding === 'paste' ? (React.createElement(LinkForm, { busy: add.busy, autoFocus: true, placeholder: t('ta.signin.pairing'), onSubmit: text => void add.add(text) })) : adding === 'account' && info ? (React.createElement(SignInPart, { info: info, act: act })) : (React.createElement(React.Fragment, null,
|
|
232
|
+
signedOut && (React.createElement("div", { className: "ta-account-offer" },
|
|
233
|
+
React.createElement("p", { className: "ta-account-hint" }, t('ta.myDevices.hint')),
|
|
234
|
+
React.createElement("button", { type: "button", className: "ta-button ta-wide", onClick: () => setAdding('account') }, t('ta.myDevices.signInAccount')))),
|
|
235
|
+
(info === null || info === void 0 ? void 0 : info.signingIn) && React.createElement(SignInPart, { info: info, act: act }),
|
|
236
|
+
!info && side && React.createElement(Loading, { compact: true }),
|
|
237
|
+
React.createElement("div", { className: "ta-host-actions" },
|
|
238
|
+
add.canScan && (React.createElement("button", { type: "button", className: "ta-button ta-primary", disabled: add.busy, onClick: () => void add.scan() },
|
|
239
|
+
add.busy ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: ScanLine, size: 16 }),
|
|
240
|
+
" ",
|
|
241
|
+
t('ta.hosts.scanShort'))),
|
|
242
|
+
React.createElement("button", { type: "button", className: "ta-button", disabled: add.busy, onClick: () => setAdding('paste') },
|
|
243
|
+
React.createElement(Icon, { icon: ClipboardPaste, size: 16 }),
|
|
244
|
+
" ",
|
|
245
|
+
t('ta.hosts.paste'))),
|
|
246
|
+
React.createElement(CloudSignInEntry, { onPick: () => setAdding('cloud') }))),
|
|
247
|
+
menu)), document.body);
|
|
172
248
|
}
|
|
173
249
|
/**
|
|
174
250
|
* A device asks to join the account: whichever device of it the user has at hand says so, with the code to compare,
|
|
@@ -198,19 +274,4 @@ export function AccountAsk() {
|
|
|
198
274
|
React.createElement("button", { type: "button", className: "ta-button", onClick: () => go(one => one.remove(asking.id)) }, t('ta.myDevices.notMe')),
|
|
199
275
|
React.createElement("button", { type: "button", className: "ta-button ta-primary", onClick: () => go(one => one.approve(asking.id)) }, t('ta.myDevices.allow')))), document.body);
|
|
200
276
|
}
|
|
201
|
-
/** On the sign-in of the app: sign in to the account, and the computers of it come by themselves. */
|
|
202
|
-
export function AccountSignInEntry() {
|
|
203
|
-
const t = useT();
|
|
204
|
-
const side = useAccountSide();
|
|
205
|
-
const [open, setOpen] = React.useState(false);
|
|
206
|
-
const { info } = useAccountInfo(side);
|
|
207
|
-
if (!side || !info || (!info.account && info.providers.length === 0 && !info.signingIn)) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
if (open || info.account || info.signingIn) {
|
|
211
|
-
return (React.createElement("section", { className: "ta-account-sign-in" },
|
|
212
|
-
React.createElement(AccountPanel, { side: side })));
|
|
213
|
-
}
|
|
214
|
-
return (React.createElement("button", { type: "button", className: "ta-button ta-wide", onClick: () => setOpen(true) }, t('ta.myDevices.signInAccount')));
|
|
215
|
-
}
|
|
216
277
|
//# sourceMappingURL=account-view.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebHomeEntry, WebMenuItem, WebTaskEntry, WebViewPreview } from '../extension/web-extension-api.js';
|
|
1
|
+
import type { WebHomeEntry, WebMenuItem, WebPartnerEntry, WebTaskEntry, WebViewPreview } from '../extension/web-extension-api.js';
|
|
2
2
|
import type { Translate } from '../i18n/use-t.js';
|
|
3
3
|
import type { ChatSeen } from './chat-seen.js';
|
|
4
4
|
import type { ContextMenuItem } from './context-menu.js';
|
|
@@ -11,6 +11,11 @@ export interface ChatHome {
|
|
|
11
11
|
double: ChatHomeDouble;
|
|
12
12
|
/** The rows extensions add to the double's list (ChatHomeUtil.items), pinned at first. */
|
|
13
13
|
items: readonly WebHomeEntry[];
|
|
14
|
+
/**
|
|
15
|
+
* The conversations with partners that are none of pi (PartnersUtil.chats): a chat of two, a group chat, rows of the
|
|
16
|
+
* list by their time as any conversation (docs/design/ta-partners.md).
|
|
17
|
+
*/
|
|
18
|
+
partners: readonly WebPartnerEntry[];
|
|
14
19
|
/** The key of the row whose page is in front, as a conversation of the list is (WebExtensionsState.pageFrom). */
|
|
15
20
|
shownItem?: string;
|
|
16
21
|
/** Opens a row: a page it shows is shown beside the list (TaWebExtensions.openHome). */
|
|
@@ -57,12 +62,14 @@ export interface ChatTaskRow {
|
|
|
57
62
|
task: WebTaskEntry;
|
|
58
63
|
updatedAt: number;
|
|
59
64
|
}
|
|
60
|
-
/** A row an extension adds to the double's list (registerHomeItems): pinned, or where its time is. */
|
|
65
|
+
/** A row an extension adds to the double's list (registerHomeItems), or a partner's conversation: pinned, or where its time is. */
|
|
61
66
|
export interface ChatHomeRow {
|
|
62
67
|
/** `home:<extension>/<id>`, as PINNED keeps it. */
|
|
63
68
|
key: string;
|
|
64
69
|
item: WebHomeEntry;
|
|
65
70
|
updatedAt: number;
|
|
71
|
+
/** The partner whose conversation it is: drawn as the partners draw it (PartnerRow). */
|
|
72
|
+
partner?: WebPartnerEntry;
|
|
66
73
|
}
|
|
67
74
|
export declare namespace ChatHomeUtil {
|
|
68
75
|
/** Those of the double's home: under it (`double`), or without a place nor a section. */
|
|
@@ -73,6 +80,10 @@ export declare namespace ChatHomeUtil {
|
|
|
73
80
|
function at(task: Pick<WebTaskEntry, 'startedAt' | 'endedAt'>): number;
|
|
74
81
|
function row(task: WebTaskEntry): ChatTaskRow;
|
|
75
82
|
function homeRow(item: WebHomeEntry): ChatHomeRow;
|
|
83
|
+
/** The rows of the home and of the partners' conversations that have the query, as the list places them by time. */
|
|
84
|
+
function homeRows(items: readonly WebHomeEntry[], partners: readonly WebPartnerEntry[], query: string): ChatHomeRow[];
|
|
85
|
+
/** The row of a partner's conversation, opened as a row of the home is (its page shown as from the list). */
|
|
86
|
+
function partnerRow(partner: WebPartnerEntry): ChatHomeRow;
|
|
76
87
|
/** The conversations rows of the home stand for (WebHomeItem.sessionFile): not listed again. */
|
|
77
88
|
function standIns(items: readonly WebHomeEntry[]): ReadonlySet<string>;
|
|
78
89
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WebTaskUtil } from '../extension/web-tasks.js';
|
|
2
|
+
import { PartnersUtil } from '../partners/partners-util.js';
|
|
2
3
|
export var ChatHomeUtil;
|
|
3
4
|
(function (ChatHomeUtil) {
|
|
4
5
|
/** Those of the double's home: under it (`double`), or without a place nor a section. */
|
|
@@ -33,6 +34,34 @@ export var ChatHomeUtil;
|
|
|
33
34
|
return { key: `home:${item.key}`, item, updatedAt: (_a = item.at) !== null && _a !== void 0 ? _a : 0 };
|
|
34
35
|
}
|
|
35
36
|
ChatHomeUtil.homeRow = homeRow;
|
|
37
|
+
/** The rows of the home and of the partners' conversations that have the query, as the list places them by time. */
|
|
38
|
+
function homeRows(items, partners, query) {
|
|
39
|
+
return [
|
|
40
|
+
...items.filter(item => matches(query, item.title, item.detail)).map(homeRow),
|
|
41
|
+
...partners.filter(partner => { var _a; return matches(query, partner.name, (_a = partner.chat) === null || _a === void 0 ? void 0 : _a.last); }).map(partnerRow),
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
ChatHomeUtil.homeRows = homeRows;
|
|
45
|
+
/** The row of a partner's conversation, opened as a row of the home is (its page shown as from the list). */
|
|
46
|
+
function partnerRow(partner) {
|
|
47
|
+
var _a, _b, _c;
|
|
48
|
+
var _d;
|
|
49
|
+
const item = {
|
|
50
|
+
id: partner.id,
|
|
51
|
+
key: partner.key,
|
|
52
|
+
extension: partner.extension,
|
|
53
|
+
tone: partner.tone,
|
|
54
|
+
title: partner.name,
|
|
55
|
+
detail: (_a = partner.chat) === null || _a === void 0 ? void 0 : _a.last,
|
|
56
|
+
icon: partner.icon,
|
|
57
|
+
face: partner.face,
|
|
58
|
+
at: (_b = partner.chat) === null || _b === void 0 ? void 0 : _b.at,
|
|
59
|
+
unseen: PartnersUtil.unseen(partner),
|
|
60
|
+
open: partner.open,
|
|
61
|
+
};
|
|
62
|
+
return { key: `home:${partner.key}`, item, updatedAt: (_d = (_c = partner.chat) === null || _c === void 0 ? void 0 : _c.at) !== null && _d !== void 0 ? _d : 0, partner };
|
|
63
|
+
}
|
|
64
|
+
ChatHomeUtil.partnerRow = partnerRow;
|
|
36
65
|
/** The conversations rows of the home stand for (WebHomeItem.sessionFile): not listed again. */
|
|
37
66
|
function standIns(items) {
|
|
38
67
|
return new Set(items.flatMap(item => (item.sessionFile ? [item.sessionFile] : [])));
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import { type ChatHome, type ChatHomeCounts } from './chat-home-util.js';
|
|
2
|
+
import type { WebTaskEntry } from '../extension/web-extension-api.js';
|
|
3
|
+
import { type ChatHome, type ChatHomeCounts, type ChatHomeRow } from './chat-home-util.js';
|
|
4
|
+
/** The text of a row of the chats: its title and time, and under them its line, as a conversation's. */
|
|
5
|
+
export declare function RowText({ title, time, line, unseen, flag, busy, tag, }: {
|
|
6
|
+
title: string;
|
|
7
|
+
time: string;
|
|
8
|
+
line: React.ReactNode;
|
|
9
|
+
unseen?: boolean;
|
|
10
|
+
/** Before the line, in its color: [Failed]. */
|
|
11
|
+
flag?: React.ReactNode;
|
|
12
|
+
busy?: boolean;
|
|
13
|
+
/** Before the title: Double, for what it does. */
|
|
14
|
+
tag?: React.ReactNode;
|
|
15
|
+
}): React.JSX.Element;
|
|
4
16
|
/**
|
|
5
17
|
* The double at the top of its list, as a messenger's pinned conversation: its face, what needs the user and goes on
|
|
6
18
|
* (else, as a messenger, what it said last), a blue ? while something waits for them, an amber dot for news.
|
|
@@ -16,8 +28,8 @@ export declare function ChatDoubleItem({ home, counts, unseen, now }: {
|
|
|
16
28
|
* or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
|
|
17
29
|
* or the conversation it stands for is in front.
|
|
18
30
|
*/
|
|
19
|
-
export declare function ChatHomeItem({
|
|
20
|
-
|
|
31
|
+
export declare function ChatHomeItem({ row, time, home, selected, pinned, onPin, }: {
|
|
32
|
+
row: ChatHomeRow;
|
|
21
33
|
time: string;
|
|
22
34
|
home: ChatHome;
|
|
23
35
|
/** The conversation it stands for is shown (WebHomeItem.sessionFile). */
|
|
@@ -5,10 +5,11 @@ import { ChatHomeUtil } from './chat-home-util.js';
|
|
|
5
5
|
import { ChatDot } from './chat-list-row.js';
|
|
6
6
|
import { ChatListUtil } from './chat-list-util.js';
|
|
7
7
|
import { ContextMenuUtil, useContextMenu } from './context-menu.js';
|
|
8
|
+
import { PartnerRow } from './partner-row.js';
|
|
8
9
|
import { SwipeRow } from './swipe-row.js';
|
|
9
10
|
import { DinoFace } from './ta-avatar.js';
|
|
10
11
|
/** The text of a row of the chats: its title and time, and under them its line, as a conversation's. */
|
|
11
|
-
function RowText({ title, time, line, unseen, flag, busy, tag, }) {
|
|
12
|
+
export function RowText({ title, time, line, unseen, flag, busy, tag, }) {
|
|
12
13
|
return (React.createElement("span", { className: "ta-chat-text" },
|
|
13
14
|
React.createElement("span", { className: "ta-chat-line" },
|
|
14
15
|
tag,
|
|
@@ -45,11 +46,17 @@ export function ChatDoubleItem({ home, counts, unseen, now }) {
|
|
|
45
46
|
* or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
|
|
46
47
|
* or the conversation it stands for is in front.
|
|
47
48
|
*/
|
|
48
|
-
export function ChatHomeItem({
|
|
49
|
+
export function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
|
|
49
50
|
var _a;
|
|
50
51
|
const t = useT();
|
|
51
52
|
const [menu, openMenu] = useContextMenu();
|
|
52
53
|
const [opening, setOpening] = React.useState(false);
|
|
54
|
+
const { item, partner } = row;
|
|
55
|
+
if (partner) {
|
|
56
|
+
// A partner's conversation: the row the partners draw it with.
|
|
57
|
+
const opens = () => home.openItem(item);
|
|
58
|
+
return React.createElement(PartnerRow, { partner: partner, time: time, selected: home.shownItem === partner.key, open: opens, pinned: pinned, onPin: onPin });
|
|
59
|
+
}
|
|
53
60
|
const Glyph = item.icon;
|
|
54
61
|
const Own = item.face;
|
|
55
62
|
const open = () => {
|
|
@@ -141,7 +141,9 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
|
|
|
141
141
|
const { folders: allFolders, rest } = React.useMemo(() => (searching ? { folders: [], rest: apart.rest } : ChatListUtil.folders([...apart.rest, ...held], folderOf)), [apart.rest, held, folderOf, searching]);
|
|
142
142
|
// A folder pinned is a row of those pinned, as a conversation pinned; so is a row of the home.
|
|
143
143
|
const { pinned: pinnedFolders, rest: folders } = React.useMemo(() => ChatListUtil.pinnedApart(allFolders, pinned), [allFolders, pinned]);
|
|
144
|
-
|
|
144
|
+
// With the conversations with partners that are none of pi (a chat of two, a group chat), by their time as any other.
|
|
145
|
+
const partners = home === null || home === void 0 ? void 0 : home.partners;
|
|
146
|
+
const homeRows = React.useMemo(() => ChatHomeUtil.homeRows(homeItems, partners !== null && partners !== void 0 ? partners : [], query), [homeItems, partners, query]);
|
|
145
147
|
const { pinned: pinnedHome, rest: homeRest } = React.useMemo(() => ChatListUtil.pinnedApart(homeRows, pinned), [homeRows, pinned]);
|
|
146
148
|
const pinnedRows = React.useMemo(() => ChatListUtil.withFolders(apart.pinned, [...pinnedFolders, ...pinnedHome]), [apart.pinned, pinnedFolders, pinnedHome]);
|
|
147
149
|
useOfferPins(listed, folderOf, homeItems);
|
|
@@ -270,7 +272,7 @@ export function ChatList({ sessions, saved, removed: removedFiles, archived: arc
|
|
|
270
272
|
}, [folderShown, folder]);
|
|
271
273
|
const folderItem = (row, archived) => (React.createElement(ChatFolderItem, { key: row.key, folder: row, time: ChatListUtil.clock(row.updatedAt, now), selected: row.sessions.some(isSelected), unseen: row.sessions.filter(isUnseen), pinned: pinnedKeys.has(row.key), onOpen: () => openFolder(row.key, archived), onPin: pin => pinKey(row.key, pin), actions: actions }));
|
|
272
274
|
const taskItem = (row) => home && (React.createElement(ChatTaskItem, { key: row.key, task: row.task, home: home, unseen: taskUnseen(row.task), time: ChatListUtil.clock(row.updatedAt, now), onPicked: onPicked }));
|
|
273
|
-
const homeItem = (row) => { var _a; return home && (React.createElement(ChatHomeItem, { key: row.key,
|
|
275
|
+
const homeItem = (row) => { var _a; return home && (React.createElement(ChatHomeItem, { key: row.key, row: row, time: row.updatedAt ? ChatListUtil.clock(row.updatedAt, now) : '', home: home, selected: !!row.item.sessionFile && isSelected((_a = byFile.get(row.item.sessionFile)) !== null && _a !== void 0 ? _a : row.item.sessionFile), pinned: pinnedKeys.has(row.key), onPin: pin => pinKey(row.key, pin) })); };
|
|
274
276
|
const rowItem = (row, compact) => ChatListUtil.isFolder(row) ? folderItem(row) : ChatListUtil.isTask(row) ? taskItem(row) : ChatListUtil.isHome(row) ? homeItem(row) : item(row, compact);
|
|
275
277
|
// The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
|
|
276
278
|
const scroller = React.useRef(null);
|