@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
|
@@ -33,31 +33,40 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.useAccountWay = useAccountWay;
|
|
37
|
+
exports.accountName = accountName;
|
|
38
|
+
exports.SignInPart = SignInPart;
|
|
39
|
+
exports.WaitingPart = WaitingPart;
|
|
40
|
+
exports.AccountWays = AccountWays;
|
|
41
|
+
exports.RecentAccounts = RecentAccounts;
|
|
37
42
|
exports.DevicesDialog = DevicesDialog;
|
|
38
43
|
exports.AccountAsk = AccountAsk;
|
|
39
|
-
exports.AccountSignInEntry = AccountSignInEntry;
|
|
40
44
|
const lucide_react_1 = require("lucide-react");
|
|
41
45
|
const React = __importStar(require("react"));
|
|
42
46
|
const react_dom_1 = require("react-dom");
|
|
43
47
|
const account_side_1 = require("../account/account-side");
|
|
48
|
+
const device_account_1 = require("../account/device-account");
|
|
44
49
|
const back_stack_1 = require("../device/back-stack");
|
|
45
50
|
const console_util_1 = require("../gateway/console-util");
|
|
46
51
|
const hooks_1 = require("../hooks");
|
|
52
|
+
const hosts_1 = require("../hosts");
|
|
47
53
|
const use_t_1 = require("../i18n/use-t");
|
|
48
54
|
const workbench_util_1 = require("../workbench-util");
|
|
49
55
|
const busy_1 = require("./busy");
|
|
50
56
|
const callout_1 = require("./callout");
|
|
51
57
|
const cloud_sign_in_view_1 = require("./cloud-sign-in-view");
|
|
58
|
+
const context_menu_1 = require("./context-menu");
|
|
59
|
+
const host_view_1 = require("./host-view");
|
|
52
60
|
const icon_1 = require("./icon");
|
|
53
61
|
const loading_1 = require("./loading");
|
|
54
62
|
const sign_in_marks_1 = require("./sign-in-marks");
|
|
55
63
|
/*
|
|
56
|
-
* The user's account and
|
|
57
|
-
* device in after comparing its code, and
|
|
58
|
-
*
|
|
64
|
+
* The user's account and the devices of it (docs/design/ta-account.md, ta-me.md): signing in, waiting to be let in,
|
|
65
|
+
* letting a new device in after comparing its code, and one list of the devices, the computers this device connects to
|
|
66
|
+
* (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
|
|
67
|
+
* (its ta serve's account) and in the app (the phone's own).
|
|
59
68
|
*/
|
|
60
|
-
const KIND_ICONS = { computer: lucide_react_1.Laptop, phone: lucide_react_1.Smartphone, browser: lucide_react_1.Globe };
|
|
69
|
+
const KIND_ICONS = { computer: lucide_react_1.Laptop, phone: lucide_react_1.Smartphone, browser: lucide_react_1.Globe, cloud: lucide_react_1.Cloud };
|
|
61
70
|
/** The code of six digits, split in two for the eye: 482 913. */
|
|
62
71
|
function codeText(code) {
|
|
63
72
|
return `${code.slice(0, 3)} ${code.slice(3)}`;
|
|
@@ -67,7 +76,22 @@ function providerName(info, id) {
|
|
|
67
76
|
var _b;
|
|
68
77
|
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);
|
|
69
78
|
}
|
|
70
|
-
/**
|
|
79
|
+
/** The ways an account's id tells (`github:42`, `iam:su`), as the user knows them: GitHub, the company account. */
|
|
80
|
+
function useAccountWay() {
|
|
81
|
+
const t = (0, use_t_1.useT)();
|
|
82
|
+
return id => {
|
|
83
|
+
const way = id.split(':')[0];
|
|
84
|
+
return way === 'github' ? 'GitHub' : way === 'google' ? 'Google' : way === 'wechat' ? t('ta.signin.wechat') : t('ta.me.companyAccount');
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** What the user is called in an account: its name, without the way it came by (`iam:su` is su). */
|
|
88
|
+
function accountName(account) {
|
|
89
|
+
return account.name.replace(/^[a-z][\w-]*:/i, '');
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 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
|
|
93
|
+
* account as to its Ta in the cloud (CloudSignInFlow), not here.
|
|
94
|
+
*/
|
|
71
95
|
function SignInPart({ info, act }) {
|
|
72
96
|
const t = (0, use_t_1.useT)();
|
|
73
97
|
const [busy, run] = (0, busy_1.useBusy)();
|
|
@@ -85,10 +109,11 @@ function SignInPart({ info, act }) {
|
|
|
85
109
|
t('ta.myDevices.openProvider', { name })),
|
|
86
110
|
React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => go(side => side.cancelSignIn()) }, t('ta.cancel'))));
|
|
87
111
|
}
|
|
88
|
-
|
|
89
|
-
|
|
112
|
+
const ways = workbench_util_1.WorkbenchUtil.isApp() ? info.providers.filter(one => !one.gateway) : info.providers;
|
|
113
|
+
if (ways.length === 0) {
|
|
114
|
+
return null;
|
|
90
115
|
}
|
|
91
|
-
return (React.createElement("div", { className: "ta-account-ways" },
|
|
116
|
+
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) => {
|
|
92
117
|
const next = await side.signIn(provider.id, provider.service);
|
|
93
118
|
if (next.signingIn) {
|
|
94
119
|
window.open(next.signingIn.url, '_blank', 'noopener,noreferrer');
|
|
@@ -132,82 +157,137 @@ function DeviceRow({ device, onApprove, onRemove, onOpen }) {
|
|
|
132
157
|
onOpen && (React.createElement("button", { type: "button", className: "ta-button", onClick: onOpen }, t('ta.myDevices.open'))),
|
|
133
158
|
!device.self && React.createElement(icon_1.IconButton, { icon: lucide_react_1.Trash2, label: t('ta.myDevices.remove'), onClick: onRemove })))));
|
|
134
159
|
}
|
|
135
|
-
/**
|
|
136
|
-
function
|
|
137
|
-
var _a;
|
|
160
|
+
/** The ways to the account on the sign-in of the app, or where it stands: the code to enter, waiting, signed in. */
|
|
161
|
+
function AccountWays({ info, act }) {
|
|
138
162
|
const t = (0, use_t_1.useT)();
|
|
139
|
-
const
|
|
163
|
+
const way = useAccountWay();
|
|
140
164
|
const [, notices] = (0, hooks_1.useNotices)();
|
|
141
|
-
|
|
142
|
-
const app = workbench_util_1.WorkbenchUtil.isApp();
|
|
143
|
-
const go = (action) => void act(action).catch((error) => notices.error(error));
|
|
144
|
-
if (!info) {
|
|
145
|
-
return failed ? React.createElement(callout_1.Callout, { level: "error" }, String((_a = failed.message) !== null && _a !== void 0 ? _a : failed)) : React.createElement(loading_1.Loading, { compact: true });
|
|
146
|
-
}
|
|
147
|
-
if (!info.account) {
|
|
165
|
+
if (info.signingIn || !info.account) {
|
|
148
166
|
return (React.createElement(React.Fragment, null,
|
|
149
|
-
React.createElement("p", { className: "ta-account-hint" }, t('ta.myDevices.hint')),
|
|
150
167
|
info.error && React.createElement(callout_1.Callout, { level: "error" }, info.error),
|
|
151
168
|
React.createElement(SignInPart, { info: info, act: act })));
|
|
152
169
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
};
|
|
170
|
+
if (info.waiting && info.code) {
|
|
171
|
+
return React.createElement(WaitingPart, { code: info.code });
|
|
172
|
+
}
|
|
173
|
+
// Signed in, no computer of the account yet: they come by themselves once signed in there.
|
|
159
174
|
const signOut = async () => {
|
|
160
|
-
if (await notices.confirm({
|
|
161
|
-
|
|
162
|
-
confirmLabel: t('ta.myDevices.signOut'),
|
|
163
|
-
danger: true,
|
|
164
|
-
})) {
|
|
165
|
-
go(one => one.signOut());
|
|
175
|
+
if (await notices.confirm({ title: t('ta.myDevices.signOutConfirm'), confirmLabel: t('ta.settings.signOut'), danger: true })) {
|
|
176
|
+
void act(side => side.signOut()).catch((error) => notices.error(error));
|
|
166
177
|
}
|
|
167
178
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
React.createElement("span", { className: "ta-
|
|
187
|
-
React.createElement(
|
|
188
|
-
React.createElement("span", { className: "ta-ellipsis" },
|
|
189
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => void signOut() },
|
|
190
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.LogOut, size: 14 }),
|
|
191
|
-
" ",
|
|
192
|
-
t('ta.myDevices.signOut')))));
|
|
179
|
+
return (React.createElement("div", { className: "ta-account-signed" },
|
|
180
|
+
React.createElement("span", { className: "ta-account-who" },
|
|
181
|
+
React.createElement(sign_in_marks_1.SignInMark, { provider: info.account.id.split(':')[0], size: 16 }),
|
|
182
|
+
React.createElement("span", { className: "ta-ellipsis" },
|
|
183
|
+
way(info.account.id),
|
|
184
|
+
" \u00B7 ",
|
|
185
|
+
accountName(info.account))),
|
|
186
|
+
React.createElement("p", { className: "ta-account-hint" }, t('ta.myDevices.computersComing')),
|
|
187
|
+
React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => void signOut() }, t('ta.settings.signOut'))));
|
|
188
|
+
}
|
|
189
|
+
/** The accounts this device switched away from, on its sign-in: a tap goes back to one, its computers with it. */
|
|
190
|
+
function RecentAccounts() {
|
|
191
|
+
const way = useAccountWay();
|
|
192
|
+
const [recent] = React.useState(() => (workbench_util_1.WorkbenchUtil.isApp() ? device_account_1.DeviceAccount.recent() : []));
|
|
193
|
+
return (React.createElement(React.Fragment, null, recent.map(one => (React.createElement("li", { key: one.kept.account.id, className: "ta-host-row" },
|
|
194
|
+
React.createElement("button", { type: "button", className: "ta-host-item", onClick: () => { var _a; return (_a = device_account_1.DeviceAccount.current()) === null || _a === void 0 ? void 0 : _a.resume(one.kept.account.id); } },
|
|
195
|
+
React.createElement("span", { className: "ta-chat-avatar ta-account-recent-mark", "aria-hidden": "true" },
|
|
196
|
+
React.createElement(sign_in_marks_1.SignInMark, { provider: one.kept.account.id.split(':')[0], size: 18 })),
|
|
197
|
+
React.createElement("span", { className: "ta-host-text" },
|
|
198
|
+
React.createElement("span", { className: "ta-host-name ta-ellipsis" }, accountName(one.kept.account)),
|
|
199
|
+
React.createElement("span", { className: "ta-host-detail ta-ellipsis" }, way(one.kept.account.id)))))))));
|
|
193
200
|
}
|
|
194
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* My devices, over the page (docs/design/ta-me.md 2): the one list of the computers this device uses, the one in use
|
|
203
|
+
* checked, a tap switching to another; the other devices of the account under them, those waiting to be let in first;
|
|
204
|
+
* and the ways to add one: the account, a code, a link, a Ta in the cloud.
|
|
205
|
+
*/
|
|
195
206
|
function DevicesDialog({ onClose }) {
|
|
207
|
+
var _a, _b;
|
|
196
208
|
const t = (0, use_t_1.useT)();
|
|
209
|
+
const language = (0, use_t_1.useLanguage)();
|
|
197
210
|
const side = (0, account_side_1.useAccountSide)();
|
|
211
|
+
const { info, failed, act } = (0, account_side_1.useAccountInfo)(side);
|
|
212
|
+
const [{ hosts, host: currentId, switching }, bench] = (0, hooks_1.useWorkbench)();
|
|
213
|
+
const [, notices] = (0, hooks_1.useNotices)();
|
|
214
|
+
const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
|
|
215
|
+
const [adding, setAdding] = React.useState();
|
|
216
|
+
const add = (0, host_view_1.useAddHost)();
|
|
198
217
|
(0, back_stack_1.useBackLayer)(true, onClose);
|
|
199
218
|
React.useEffect(() => {
|
|
200
219
|
const onKey = (event) => event.key === 'Escape' && onClose();
|
|
201
220
|
document.addEventListener('keydown', onKey);
|
|
202
221
|
return () => document.removeEventListener('keydown', onKey);
|
|
203
222
|
}, [onClose]);
|
|
223
|
+
const go = (action) => void act(action).catch((error) => notices.error(error));
|
|
224
|
+
const devices = (info === null || info === void 0 ? void 0 : info.account) && !info.waiting ? info.devices : [];
|
|
225
|
+
const ofAccount = (host) => (host.account ? devices.find(one => one.id === host.account) : undefined);
|
|
226
|
+
const seen = (device) => device.online ? t('ta.myDevices.online') : t('ta.myDevices.seen', { time: console_util_1.ConsoleUtil.ago(device.seenAt, language) });
|
|
227
|
+
const others = devices
|
|
228
|
+
.filter(one => !one.self && !hosts.some(host => host.account === one.id))
|
|
229
|
+
.sort((a, b) => Number(b.waiting) - Number(a.waiting) || a.addedAt - b.addedAt);
|
|
230
|
+
const removeDevice = async (device) => {
|
|
231
|
+
if (device.waiting ||
|
|
232
|
+
(await notices.confirm({ title: t('ta.myDevices.removeConfirm', { name: device.name }), confirmLabel: t('ta.myDevices.remove'), danger: true }))) {
|
|
233
|
+
go(one => one.remove(device.id));
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const removeHost = async (host) => {
|
|
237
|
+
const device = ofAccount(host);
|
|
238
|
+
if (device) {
|
|
239
|
+
await removeDevice(device);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const name = hosts_1.HostUtil.label(host) || t('ta.hosts.thisServer');
|
|
243
|
+
if (await notices.confirm({ title: t('ta.hosts.removeConfirm', { name }), confirmLabel: t('ta.hosts.remove'), danger: true })) {
|
|
244
|
+
bench.forget(host.id);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
const rename = async (host) => {
|
|
248
|
+
var _a;
|
|
249
|
+
const name = await notices.input({ title: t('ta.hosts.rename'), value: hosts_1.HostUtil.label(host), placeholder: (_a = host.server) === null || _a === void 0 ? void 0 : _a.host });
|
|
250
|
+
if (name !== undefined) {
|
|
251
|
+
bench.rename(host.id, name);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const signedOut = info && !info.account && !info.signingIn;
|
|
204
255
|
return (0, react_dom_1.createPortal)(React.createElement("div", { className: "ta-modal-scrim" },
|
|
205
256
|
React.createElement("button", { type: "button", className: "ta-overlay-close", "aria-label": t('ta.close'), tabIndex: -1, onClick: onClose }),
|
|
206
|
-
React.createElement("div", { className: "ta-modal ta-account-dialog", role: "dialog", "aria-modal": "true", "aria-label": t('ta.myDevices.title') },
|
|
257
|
+
React.createElement("div", { className: "ta-modal ta-hosts-dialog ta-account-dialog", role: "dialog", "aria-modal": "true", "aria-label": t('ta.myDevices.title') },
|
|
207
258
|
React.createElement("div", { className: "ta-modal-head" },
|
|
208
259
|
React.createElement("span", { className: "ta-modal-title" }, t('ta.myDevices.title')),
|
|
209
260
|
React.createElement(icon_1.IconButton, { icon: lucide_react_1.X, label: t('ta.close'), onClick: onClose })),
|
|
210
|
-
|
|
261
|
+
(info === null || info === void 0 ? void 0 : info.waiting) && info.code ? React.createElement(WaitingPart, { code: info.code }) : null,
|
|
262
|
+
(info === null || info === void 0 ? void 0 : info.error) || failed ? React.createElement(callout_1.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,
|
|
263
|
+
React.createElement("ul", { className: "ta-host-list", hidden: adding === 'cloud' }, hosts.map(host => {
|
|
264
|
+
const device = ofAccount(host);
|
|
265
|
+
return (React.createElement(host_view_1.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, [
|
|
266
|
+
{ label: t('ta.hosts.rename'), run: () => void rename(host) },
|
|
267
|
+
{ label: t('ta.hosts.remove'), run: () => void removeHost(host) },
|
|
268
|
+
]) }));
|
|
269
|
+
})),
|
|
270
|
+
others.length > 0 && adding !== 'cloud' && (React.createElement("section", { className: "ta-account-others" },
|
|
271
|
+
React.createElement("h2", null, t('ta.myDevices.others')),
|
|
272
|
+
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) })))))),
|
|
273
|
+
add.error && React.createElement(callout_1.Callout, { level: "error" }, t(add.error)),
|
|
274
|
+
adding === 'cloud' ? (React.createElement(cloud_sign_in_view_1.CloudSignInFlow, { onBack: () => setAdding(undefined) })) : adding === 'paste' ? (React.createElement(host_view_1.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,
|
|
275
|
+
signedOut && (React.createElement("div", { className: "ta-account-offer" },
|
|
276
|
+
React.createElement("p", { className: "ta-account-hint" }, t('ta.myDevices.hint')),
|
|
277
|
+
React.createElement("button", { type: "button", className: "ta-button ta-wide", onClick: () => setAdding('account') }, t('ta.myDevices.signInAccount')))),
|
|
278
|
+
(info === null || info === void 0 ? void 0 : info.signingIn) && React.createElement(SignInPart, { info: info, act: act }),
|
|
279
|
+
!info && side && React.createElement(loading_1.Loading, { compact: true }),
|
|
280
|
+
React.createElement("div", { className: "ta-host-actions" },
|
|
281
|
+
add.canScan && (React.createElement("button", { type: "button", className: "ta-button ta-primary", disabled: add.busy, onClick: () => void add.scan() },
|
|
282
|
+
add.busy ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(icon_1.Icon, { icon: lucide_react_1.ScanLine, size: 16 }),
|
|
283
|
+
" ",
|
|
284
|
+
t('ta.hosts.scanShort'))),
|
|
285
|
+
React.createElement("button", { type: "button", className: "ta-button", disabled: add.busy, onClick: () => setAdding('paste') },
|
|
286
|
+
React.createElement(icon_1.Icon, { icon: lucide_react_1.ClipboardPaste, size: 16 }),
|
|
287
|
+
" ",
|
|
288
|
+
t('ta.hosts.paste'))),
|
|
289
|
+
React.createElement(cloud_sign_in_view_1.CloudSignInEntry, { onPick: () => setAdding('cloud') }))),
|
|
290
|
+
menu)), document.body);
|
|
211
291
|
}
|
|
212
292
|
/**
|
|
213
293
|
* A device asks to join the account: whichever device of it the user has at hand says so, with the code to compare,
|
|
@@ -237,19 +317,4 @@ function AccountAsk() {
|
|
|
237
317
|
React.createElement("button", { type: "button", className: "ta-button", onClick: () => go(one => one.remove(asking.id)) }, t('ta.myDevices.notMe')),
|
|
238
318
|
React.createElement("button", { type: "button", className: "ta-button ta-primary", onClick: () => go(one => one.approve(asking.id)) }, t('ta.myDevices.allow')))), document.body);
|
|
239
319
|
}
|
|
240
|
-
/** On the sign-in of the app: sign in to the account, and the computers of it come by themselves. */
|
|
241
|
-
function AccountSignInEntry() {
|
|
242
|
-
const t = (0, use_t_1.useT)();
|
|
243
|
-
const side = (0, account_side_1.useAccountSide)();
|
|
244
|
-
const [open, setOpen] = React.useState(false);
|
|
245
|
-
const { info } = (0, account_side_1.useAccountInfo)(side);
|
|
246
|
-
if (!side || !info || (!info.account && info.providers.length === 0 && !info.signingIn)) {
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
if (open || info.account || info.signingIn) {
|
|
250
|
-
return (React.createElement("section", { className: "ta-account-sign-in" },
|
|
251
|
-
React.createElement(AccountPanel, { side: side })));
|
|
252
|
-
}
|
|
253
|
-
return (React.createElement("button", { type: "button", className: "ta-button ta-wide", onClick: () => setOpen(true) }, t('ta.myDevices.signInAccount')));
|
|
254
|
-
}
|
|
255
320
|
//# sourceMappingURL=account-view.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebHomeEntry, WebMenuItem, WebTaskEntry, WebViewPreview } from '../extension/web-extension-api';
|
|
1
|
+
import type { WebHomeEntry, WebMenuItem, WebPartnerEntry, WebTaskEntry, WebViewPreview } from '../extension/web-extension-api';
|
|
2
2
|
import type { Translate } from '../i18n/use-t';
|
|
3
3
|
import type { ChatSeen } from './chat-seen';
|
|
4
4
|
import type { ContextMenuItem } from './context-menu';
|
|
@@ -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
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ChatHomeUtil = void 0;
|
|
4
4
|
const web_tasks_1 = require("../extension/web-tasks");
|
|
5
|
+
const partners_util_1 = require("../partners/partners-util");
|
|
5
6
|
var ChatHomeUtil;
|
|
6
7
|
(function (ChatHomeUtil) {
|
|
7
8
|
/** Those of the double's home: under it (`double`), or without a place nor a section. */
|
|
@@ -36,6 +37,34 @@ var ChatHomeUtil;
|
|
|
36
37
|
return { key: `home:${item.key}`, item, updatedAt: (_a = item.at) !== null && _a !== void 0 ? _a : 0 };
|
|
37
38
|
}
|
|
38
39
|
ChatHomeUtil.homeRow = homeRow;
|
|
40
|
+
/** The rows of the home and of the partners' conversations that have the query, as the list places them by time. */
|
|
41
|
+
function homeRows(items, partners, query) {
|
|
42
|
+
return [
|
|
43
|
+
...items.filter(item => matches(query, item.title, item.detail)).map(homeRow),
|
|
44
|
+
...partners.filter(partner => { var _a; return matches(query, partner.name, (_a = partner.chat) === null || _a === void 0 ? void 0 : _a.last); }).map(partnerRow),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
ChatHomeUtil.homeRows = homeRows;
|
|
48
|
+
/** The row of a partner's conversation, opened as a row of the home is (its page shown as from the list). */
|
|
49
|
+
function partnerRow(partner) {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
var _d;
|
|
52
|
+
const item = {
|
|
53
|
+
id: partner.id,
|
|
54
|
+
key: partner.key,
|
|
55
|
+
extension: partner.extension,
|
|
56
|
+
tone: partner.tone,
|
|
57
|
+
title: partner.name,
|
|
58
|
+
detail: (_a = partner.chat) === null || _a === void 0 ? void 0 : _a.last,
|
|
59
|
+
icon: partner.icon,
|
|
60
|
+
face: partner.face,
|
|
61
|
+
at: (_b = partner.chat) === null || _b === void 0 ? void 0 : _b.at,
|
|
62
|
+
unseen: partners_util_1.PartnersUtil.unseen(partner),
|
|
63
|
+
open: partner.open,
|
|
64
|
+
};
|
|
65
|
+
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 };
|
|
66
|
+
}
|
|
67
|
+
ChatHomeUtil.partnerRow = partnerRow;
|
|
39
68
|
/** The conversations rows of the home stand for (WebHomeItem.sessionFile): not listed again. */
|
|
40
69
|
function standIns(items) {
|
|
41
70
|
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';
|
|
2
|
+
import type { WebTaskEntry } from '../extension/web-extension-api';
|
|
3
|
+
import { type ChatHome, type ChatHomeCounts, type ChatHomeRow } from './chat-home-util';
|
|
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). */
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ChatTaskItem = void 0;
|
|
37
|
+
exports.RowText = RowText;
|
|
37
38
|
exports.ChatDoubleItem = ChatDoubleItem;
|
|
38
39
|
exports.ChatHomeItem = ChatHomeItem;
|
|
39
40
|
exports.ChatHomeTop = ChatHomeTop;
|
|
@@ -44,6 +45,7 @@ const chat_home_util_1 = require("./chat-home-util");
|
|
|
44
45
|
const chat_list_row_1 = require("./chat-list-row");
|
|
45
46
|
const chat_list_util_1 = require("./chat-list-util");
|
|
46
47
|
const context_menu_1 = require("./context-menu");
|
|
48
|
+
const partner_row_1 = require("./partner-row");
|
|
47
49
|
const swipe_row_1 = require("./swipe-row");
|
|
48
50
|
const ta_avatar_1 = require("./ta-avatar");
|
|
49
51
|
/** The text of a row of the chats: its title and time, and under them its line, as a conversation's. */
|
|
@@ -84,11 +86,17 @@ function ChatDoubleItem({ home, counts, unseen, now }) {
|
|
|
84
86
|
* or unpinned as a folder is. What it opens shows as a conversation of the list does, the row selected while its page
|
|
85
87
|
* or the conversation it stands for is in front.
|
|
86
88
|
*/
|
|
87
|
-
function ChatHomeItem({
|
|
89
|
+
function ChatHomeItem({ row, time, home, selected, pinned, onPin, }) {
|
|
88
90
|
var _a;
|
|
89
91
|
const t = (0, use_t_1.useT)();
|
|
90
92
|
const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
|
|
91
93
|
const [opening, setOpening] = React.useState(false);
|
|
94
|
+
const { item, partner } = row;
|
|
95
|
+
if (partner) {
|
|
96
|
+
// A partner's conversation: the row the partners draw it with.
|
|
97
|
+
const opens = () => home.openItem(item);
|
|
98
|
+
return React.createElement(partner_row_1.PartnerRow, { partner: partner, time: time, selected: home.shownItem === partner.key, open: opens, pinned: pinned, onPin: onPin });
|
|
99
|
+
}
|
|
92
100
|
const Glyph = item.icon;
|
|
93
101
|
const Own = item.face;
|
|
94
102
|
const open = () => {
|
|
@@ -177,7 +177,9 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
|
|
|
177
177
|
const { folders: allFolders, rest } = React.useMemo(() => (searching ? { folders: [], rest: apart.rest } : chat_list_util_1.ChatListUtil.folders([...apart.rest, ...held], folderOf)), [apart.rest, held, folderOf, searching]);
|
|
178
178
|
// A folder pinned is a row of those pinned, as a conversation pinned; so is a row of the home.
|
|
179
179
|
const { pinned: pinnedFolders, rest: folders } = React.useMemo(() => chat_list_util_1.ChatListUtil.pinnedApart(allFolders, pinned), [allFolders, pinned]);
|
|
180
|
-
|
|
180
|
+
// With the conversations with partners that are none of pi (a chat of two, a group chat), by their time as any other.
|
|
181
|
+
const partners = home === null || home === void 0 ? void 0 : home.partners;
|
|
182
|
+
const homeRows = React.useMemo(() => chat_home_util_1.ChatHomeUtil.homeRows(homeItems, partners !== null && partners !== void 0 ? partners : [], query), [homeItems, partners, query]);
|
|
181
183
|
const { pinned: pinnedHome, rest: homeRest } = React.useMemo(() => chat_list_util_1.ChatListUtil.pinnedApart(homeRows, pinned), [homeRows, pinned]);
|
|
182
184
|
const pinnedRows = React.useMemo(() => chat_list_util_1.ChatListUtil.withFolders(apart.pinned, [...pinnedFolders, ...pinnedHome]), [apart.pinned, pinnedFolders, pinnedHome]);
|
|
183
185
|
(0, chat_list_hooks_1.useOfferPins)(listed, folderOf, homeItems);
|
|
@@ -306,7 +308,7 @@ function ChatList({ sessions, saved, removed: removedFiles, archived: archivedSa
|
|
|
306
308
|
}, [folderShown, folder]);
|
|
307
309
|
const folderItem = (row, archived) => (React.createElement(chat_list_row_1.ChatFolderItem, { key: row.key, folder: row, time: chat_list_util_1.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 }));
|
|
308
310
|
const taskItem = (row) => home && (React.createElement(chat_home_1.ChatTaskItem, { key: row.key, task: row.task, home: home, unseen: taskUnseen(row.task), time: chat_list_util_1.ChatListUtil.clock(row.updatedAt, now), onPicked: onPicked }));
|
|
309
|
-
const homeItem = (row) => { var _a; return home && (React.createElement(chat_home_1.ChatHomeItem, { key: row.key,
|
|
311
|
+
const homeItem = (row) => { var _a; return home && (React.createElement(chat_home_1.ChatHomeItem, { key: row.key, row: row, time: row.updatedAt ? chat_list_util_1.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) })); };
|
|
310
312
|
const rowItem = (row, compact) => chat_list_util_1.ChatListUtil.isFolder(row) ? folderItem(row) : chat_list_util_1.ChatListUtil.isTask(row) ? taskItem(row) : chat_list_util_1.ChatListUtil.isHome(row) ? homeItem(row) : item(row, compact);
|
|
311
313
|
// The conversation shown is found in the list, however it came to be shown: out of a search that hides it, and scrolled to.
|
|
312
314
|
const scroller = React.useRef(null);
|