@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,19 +1,17 @@
|
|
|
1
|
-
import { Check,
|
|
1
|
+
import { Check, Link2, ScanLine } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import {
|
|
4
|
+
import { DeviceAccount } from '../account/device-account.js';
|
|
5
5
|
import { CodeScan } from '../device/code-scan.js';
|
|
6
6
|
import { ScanError } from '../device/scanner.js';
|
|
7
|
-
import {
|
|
7
|
+
import { useWebExtensions, useWorkbench } from '../hooks.js';
|
|
8
8
|
import { HostUtil } from '../hosts.js';
|
|
9
9
|
import { useT } from '../i18n/use-t.js';
|
|
10
|
-
import { WorkbenchError, WorkbenchUtil } from '../workbench-util.js';
|
|
10
|
+
import { pageHost, WorkbenchError, WorkbenchUtil } from '../workbench-util.js';
|
|
11
11
|
import { AccountAsk } from './account-view.js';
|
|
12
12
|
import { Callout } from './callout.js';
|
|
13
13
|
import { ChatListUtil } from './chat-list-util.js';
|
|
14
|
-
import {
|
|
15
|
-
import { useContextMenu } from './context-menu.js';
|
|
16
|
-
import { Icon, IconButton } from './icon.js';
|
|
14
|
+
import { Icon } from './icon.js';
|
|
17
15
|
import { SwipeRow } from './swipe-row.js';
|
|
18
16
|
import { TaAvatar } from './ta-avatar.js';
|
|
19
17
|
/*
|
|
@@ -27,6 +25,7 @@ export function useAddHost() {
|
|
|
27
25
|
const [busy, setBusy] = React.useState(false);
|
|
28
26
|
const [error, setError] = React.useState();
|
|
29
27
|
const add = React.useCallback(async (text, scanned = false) => {
|
|
28
|
+
var _a;
|
|
30
29
|
const credential = WorkbenchUtil.credential(text);
|
|
31
30
|
// The app has no ta serve of its page to give a token to; a code is always a pairing.
|
|
32
31
|
if (!('pairing' in credential) && (scanned || WorkbenchUtil.isApp())) {
|
|
@@ -37,6 +36,10 @@ export function useAddHost() {
|
|
|
37
36
|
setError(undefined);
|
|
38
37
|
try {
|
|
39
38
|
await bench.signIn(text);
|
|
39
|
+
if ('pairing' in credential) {
|
|
40
|
+
// Signed in to an account: the computer joins it (docs/design/ta-me.md 4).
|
|
41
|
+
(_a = DeviceAccount.current()) === null || _a === void 0 ? void 0 : _a.bringIn(WorkbenchUtil.serverOf(credential, pageHost()));
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
44
|
catch (failure) {
|
|
42
45
|
setError(failure instanceof WorkbenchError && failure.reason === 'refused' ? 'ta.hosts.refused' : 'ta.hosts.unreachable');
|
|
@@ -66,7 +69,7 @@ function hostDetail(host) {
|
|
|
66
69
|
return [(_a = host.server) === null || _a === void 0 ? void 0 : _a.user, way].filter(Boolean).join(' · ');
|
|
67
70
|
}
|
|
68
71
|
/** A computer, as a conversation of the list: its letter, its name and the way to it; a finger swipes it to Remove. */
|
|
69
|
-
export function HostRow({ host, current, switching, onPick, onMenu, onRemove }) {
|
|
72
|
+
export function HostRow({ host, detail, current, switching, onPick, onMenu, onRemove }) {
|
|
70
73
|
const t = useT();
|
|
71
74
|
const label = HostUtil.label(host) || t('ta.hosts.thisServer');
|
|
72
75
|
return (React.createElement(SwipeRow, { as: "li", className: `ta-host-row${current ? ' ta-selected' : ''}`, actions: onRemove && [{ key: 'remove', label: t('ta.hosts.remove'), danger: true, run: onRemove }], onContextMenu: onMenu },
|
|
@@ -74,11 +77,11 @@ export function HostRow({ host, current, switching, onPick, onMenu, onRemove })
|
|
|
74
77
|
React.createElement("span", { className: `ta-chat-avatar ta-tone-${ChatListUtil.tone(host.id)}`, "aria-hidden": "true" }, HostUtil.initial({ ...host, name: label })),
|
|
75
78
|
React.createElement("span", { className: "ta-host-text" },
|
|
76
79
|
React.createElement("span", { className: "ta-host-name ta-ellipsis" }, label),
|
|
77
|
-
React.createElement("span", { className: "ta-host-detail ta-ellipsis" }, hostDetail(host))),
|
|
80
|
+
React.createElement("span", { className: "ta-host-detail ta-ellipsis" }, detail !== null && detail !== void 0 ? detail : hostDetail(host))),
|
|
78
81
|
switching ? React.createElement("span", { className: "ta-spinner" }) : current && React.createElement(Icon, { icon: Check, size: 18, className: "ta-host-check" }))));
|
|
79
82
|
}
|
|
80
83
|
/** A link pasted by hand, for where there is no camera or the code cannot be read. */
|
|
81
|
-
function LinkForm({ busy, onSubmit, placeholder, autoFocus }) {
|
|
84
|
+
export function LinkForm({ busy, onSubmit, placeholder, autoFocus, }) {
|
|
82
85
|
const t = useT();
|
|
83
86
|
const [text, setText] = React.useState('');
|
|
84
87
|
return (React.createElement("form", { className: "ta-host-form", onSubmit: event => {
|
|
@@ -90,57 +93,6 @@ function LinkForm({ busy, onSubmit, placeholder, autoFocus }) {
|
|
|
90
93
|
React.createElement("input", { type: "password", autoFocus: autoFocus, placeholder: placeholder, value: text, onChange: event => setText(event.target.value) })),
|
|
91
94
|
React.createElement("button", { type: "submit", className: "ta-button ta-primary", disabled: busy || !text.trim() }, busy ? React.createElement("span", { className: "ta-spinner" }) : t('ta.signin.connect'))));
|
|
92
95
|
}
|
|
93
|
-
/** The computers of this device, the one in use checked: a tap switches, a hold or a right click renames or removes. */
|
|
94
|
-
export function HostsDialog({ onClose }) {
|
|
95
|
-
const t = useT();
|
|
96
|
-
const [{ hosts, host: currentId, switching }, bench] = useWorkbench();
|
|
97
|
-
const [, notices] = useNotices();
|
|
98
|
-
const [menu, openMenu] = useContextMenu();
|
|
99
|
-
const [pasting, setPasting] = React.useState(false);
|
|
100
|
-
const [cloud, setCloud] = React.useState(false);
|
|
101
|
-
const adding = useAddHost();
|
|
102
|
-
useBackLayer(true, onClose);
|
|
103
|
-
React.useEffect(() => {
|
|
104
|
-
const onKey = (event) => event.key === 'Escape' && onClose();
|
|
105
|
-
document.addEventListener('keydown', onKey);
|
|
106
|
-
return () => document.removeEventListener('keydown', onKey);
|
|
107
|
-
}, [onClose]);
|
|
108
|
-
const remove = async (host) => {
|
|
109
|
-
const name = HostUtil.label(host) || t('ta.hosts.thisServer');
|
|
110
|
-
if (await notices.confirm({ title: t('ta.hosts.removeConfirm', { name }), confirmLabel: t('ta.hosts.remove'), danger: true })) {
|
|
111
|
-
bench.forget(host.id);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const rename = async (host) => {
|
|
115
|
-
var _a;
|
|
116
|
-
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 });
|
|
117
|
-
if (name !== undefined) {
|
|
118
|
-
bench.rename(host.id, name);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
return createPortal(React.createElement("div", { className: "ta-modal-scrim" },
|
|
122
|
-
React.createElement("button", { type: "button", className: "ta-overlay-close", "aria-label": t('ta.close'), tabIndex: -1, onClick: onClose }),
|
|
123
|
-
React.createElement("div", { className: "ta-modal ta-hosts-dialog", role: "dialog", "aria-modal": "true", "aria-label": t('ta.hosts.title') },
|
|
124
|
-
React.createElement("div", { className: "ta-modal-head" },
|
|
125
|
-
React.createElement("span", { className: "ta-modal-title" }, t('ta.hosts.title')),
|
|
126
|
-
React.createElement(IconButton, { icon: X, label: t('ta.close'), onClick: onClose })),
|
|
127
|
-
React.createElement("ul", { className: "ta-host-list", hidden: cloud }, hosts.map(host => (React.createElement(HostRow, { key: host.id, host: host, current: host.id === currentId, switching: host.id === switching, onPick: () => bench.switchTo(host.id), onRemove: () => void remove(host), onMenu: event => openMenu(event, [
|
|
128
|
-
{ label: t('ta.hosts.rename'), run: () => void rename(host) },
|
|
129
|
-
{ label: t('ta.hosts.remove'), run: () => void remove(host) },
|
|
130
|
-
]) })))),
|
|
131
|
-
adding.error && React.createElement(Callout, { level: "error" }, t(adding.error)),
|
|
132
|
-
cloud ? (React.createElement(CloudSignInFlow, { onBack: () => setCloud(false) })) : pasting ? (React.createElement(LinkForm, { busy: adding.busy, autoFocus: true, placeholder: t('ta.signin.pairing'), onSubmit: text => void adding.add(text) })) : (React.createElement("div", { className: "ta-host-actions" },
|
|
133
|
-
adding.canScan && (React.createElement("button", { type: "button", className: "ta-button ta-primary", disabled: adding.busy, onClick: () => void adding.scan() },
|
|
134
|
-
adding.busy ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: ScanLine, size: 16 }),
|
|
135
|
-
" ",
|
|
136
|
-
t('ta.hosts.scanShort'))),
|
|
137
|
-
React.createElement("button", { type: "button", className: "ta-button", disabled: adding.busy, onClick: () => setPasting(true) },
|
|
138
|
-
React.createElement(Icon, { icon: ClipboardPaste, size: 16 }),
|
|
139
|
-
" ",
|
|
140
|
-
t('ta.hosts.paste')))),
|
|
141
|
-
!cloud && !pasting && React.createElement(CloudSignInEntry, { onPick: () => setCloud(true) }),
|
|
142
|
-
menu)), document.body);
|
|
143
|
-
}
|
|
144
96
|
/** How long the page waits under the veil for its extensions, the first time on this device, before it shows as it is. */
|
|
145
97
|
const ARRIVAL_MS = 3000;
|
|
146
98
|
/** How long the veil takes to fade. */
|
|
@@ -191,11 +143,10 @@ export function DeviceOverlays() {
|
|
|
191
143
|
React.createElement(PageVeil, null),
|
|
192
144
|
React.createElement(AccountAsk, null)));
|
|
193
145
|
}
|
|
194
|
-
/**
|
|
195
|
-
export function
|
|
146
|
+
/** Connecting a computer on the sign-in: scan the code its Ta shows (in the app), or paste its link or a token. */
|
|
147
|
+
export function ConnectComputer({ error, children }) {
|
|
196
148
|
var _a;
|
|
197
149
|
const t = useT();
|
|
198
|
-
const [{ hosts }, bench] = useWorkbench();
|
|
199
150
|
const adding = useAddHost();
|
|
200
151
|
const [pasting, setPasting] = React.useState(!adding.canScan);
|
|
201
152
|
const shown = (_a = adding.error) !== null && _a !== void 0 ? _a : error;
|
|
@@ -206,11 +157,13 @@ export function AddHostPanel({ error, children }) {
|
|
|
206
157
|
t('ta.hosts.scan'))),
|
|
207
158
|
pasting ? (React.createElement(LinkForm, { busy: adding.busy, autoFocus: !adding.canScan, placeholder: t(WorkbenchUtil.isApp() ? 'ta.signin.pairing' : 'ta.signin.token'), onSubmit: text => void adding.add(text) })) : (React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => setPasting(true) }, t('ta.hosts.paste'))),
|
|
208
159
|
shown && React.createElement(Callout, { level: "error" }, t(shown)),
|
|
209
|
-
children
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
160
|
+
children));
|
|
161
|
+
}
|
|
162
|
+
/** The computers used before, on the sign-in, the latest first: a tap goes back to one. */
|
|
163
|
+
export function SavedHosts() {
|
|
164
|
+
const [{ hosts }, bench] = useWorkbench();
|
|
165
|
+
return (React.createElement(React.Fragment, null, [...hosts]
|
|
166
|
+
.sort((a, b) => b.usedAt - a.usedAt)
|
|
167
|
+
.map(host => (React.createElement(HostRow, { key: host.id, host: host, current: false, switching: false, onPick: () => bench.switchTo(host.id) })))));
|
|
215
168
|
}
|
|
216
169
|
//# sourceMappingURL=host-view.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { SettingsSection } from './settings-view.js';
|
|
3
3
|
/**
|
|
4
|
-
* Me, the last tab of a phone, as in a messaging app:
|
|
5
|
-
* connected, then the entries the rail of a computer has in the menu of its account (account-menu.tsx).
|
|
4
|
+
* Me, the last tab of a phone, as in a messaging app: the user's profile (their picture, name and account, which it
|
|
5
|
+
* opens), the machine in use and whether the app is connected, then the entries the rail of a computer has in the menu of its account (account-menu.tsx).
|
|
6
6
|
*/
|
|
7
7
|
export declare function MeView({ onSettings }: {
|
|
8
8
|
onSettings(section?: SettingsSection): void;
|
|
@@ -5,10 +5,11 @@ import { AccountDialogs, AccountFigure, useAccount, useAccountEntries } from './
|
|
|
5
5
|
import { Icon } from './icon.js';
|
|
6
6
|
import { ListGroup, ListRow } from './list-rows.js';
|
|
7
7
|
/**
|
|
8
|
-
* Me, the last tab of a phone, as in a messaging app:
|
|
9
|
-
* connected, then the entries the rail of a computer has in the menu of its account (account-menu.tsx).
|
|
8
|
+
* Me, the last tab of a phone, as in a messaging app: the user's profile (their picture, name and account, which it
|
|
9
|
+
* opens), the machine in use and whether the app is connected, then the entries the rail of a computer has in the menu of its account (account-menu.tsx).
|
|
10
10
|
*/
|
|
11
11
|
export function MeView({ onSettings }) {
|
|
12
|
+
var _a, _b;
|
|
12
13
|
const t = useT();
|
|
13
14
|
const account = useAccount();
|
|
14
15
|
const [dialog, setDialog] = React.useState();
|
|
@@ -16,20 +17,20 @@ export function MeView({ onSettings }) {
|
|
|
16
17
|
return (React.createElement("section", { className: "ta-list-page ta-me", "aria-label": t('ta.me') },
|
|
17
18
|
React.createElement("div", { className: "ta-list-scroll" },
|
|
18
19
|
React.createElement("div", { className: "ta-list-content" },
|
|
19
|
-
React.createElement("button", { type: "button", className: "ta-me-card", "aria-label": t('ta.
|
|
20
|
+
React.createElement("button", { type: "button", className: "ta-me-card", "aria-label": t('ta.me.profile'), onClick: () => setDialog('profile') },
|
|
20
21
|
React.createElement(AccountFigure, { size: 56, className: "ta-account-figure ta-me-figure" }),
|
|
21
22
|
React.createElement("span", { className: "ta-me-text" },
|
|
22
23
|
React.createElement("span", { className: "ta-me-name ta-ellipsis" }, account.name),
|
|
23
|
-
account.machine && React.createElement("span", { className: "ta-me-host ta-ellipsis" }, account.machine),
|
|
24
|
+
((_a = account.account) !== null && _a !== void 0 ? _a : account.machine) && React.createElement("span", { className: "ta-me-host ta-ellipsis" }, (_b = account.account) !== null && _b !== void 0 ? _b : account.machine),
|
|
24
25
|
React.createElement("span", { className: "ta-me-state" },
|
|
25
26
|
React.createElement("span", { className: `ta-account-state ${account.online ? 'ta-ok' : 'ta-warn'}` }),
|
|
26
|
-
t('ta.account.service'),
|
|
27
|
+
account.account && account.machine ? account.machine : t('ta.account.service'),
|
|
27
28
|
" \u00B7 ",
|
|
28
29
|
account.service)),
|
|
29
30
|
React.createElement(Icon, { icon: ChevronRight, size: 18, className: "ta-list-chevron" })),
|
|
30
31
|
groups
|
|
31
32
|
.filter(group => group.length > 0)
|
|
32
33
|
.map(group => (React.createElement(ListGroup, { key: group[0].key }, group.map(entry => { var _a, _b; var _c; return (React.createElement(ListRow, { key: entry.key, icon: entry.danger ? undefined : entry.icon, label: entry.label, detail: (_c = entry.detail) !== null && _c !== void 0 ? _c : (_b = (_a = entry.choices) === null || _a === void 0 ? void 0 : _a.find(choice => choice.checked)) === null || _b === void 0 ? void 0 : _b.label, danger: entry.danger, action: entry.danger || entry.key === 'install', onClick: entry.run })); })))))),
|
|
33
|
-
React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined) })));
|
|
34
|
+
React.createElement(AccountDialogs, { dialog: dialog, onClose: () => setDialog(undefined), onDialog: setDialog })));
|
|
34
35
|
}
|
|
35
36
|
//# sourceMappingURL=me-view.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { WebPartnerEntry } from '../extension/web-api-partners.js';
|
|
3
|
+
/**
|
|
4
|
+
* A partner (docs/design/ta-partners.md), the same row wherever it is: on the page of the partners as a contact, in the
|
|
5
|
+
* double's list as a conversation. Its face (or its icon on a tile of its tint), its name, what was said last (else
|
|
6
|
+
* what it is), when; an amber dot for what the user has not seen or one asking, a blue ? while it waits for them, a
|
|
7
|
+
* spinner while it answers. Its menu is Open, then its own; pinned as a conversation is where `onPin` is given.
|
|
8
|
+
*/
|
|
9
|
+
export declare function PartnerRow({ partner, time, selected, open, pinned, onPin, }: {
|
|
10
|
+
partner: WebPartnerEntry;
|
|
11
|
+
time: string;
|
|
12
|
+
selected: boolean;
|
|
13
|
+
/** Opens it as the list does (TaWebExtensions.openHome): a promise keeps it busy. */
|
|
14
|
+
open(partner: WebPartnerEntry): Promise<void>;
|
|
15
|
+
pinned?: boolean;
|
|
16
|
+
onPin?(pinned: boolean): void;
|
|
17
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useT } from '../i18n/use-t.js';
|
|
3
|
+
import { PartnersUtil } from '../partners/partners-util.js';
|
|
4
|
+
import { RowText } from './chat-home.js';
|
|
5
|
+
import { ChatHomeUtil } from './chat-home-util.js';
|
|
6
|
+
import { ChatDot } from './chat-list-row.js';
|
|
7
|
+
import { ContextMenuUtil, useContextMenu } from './context-menu.js';
|
|
8
|
+
import { HostTag } from './host-tag.js';
|
|
9
|
+
import { SwipeRow } from './swipe-row.js';
|
|
10
|
+
/**
|
|
11
|
+
* A partner (docs/design/ta-partners.md), the same row wherever it is: on the page of the partners as a contact, in the
|
|
12
|
+
* double's list as a conversation. Its face (or its icon on a tile of its tint), its name, what was said last (else
|
|
13
|
+
* what it is), when; an amber dot for what the user has not seen or one asking, a blue ? while it waits for them, a
|
|
14
|
+
* spinner while it answers. Its menu is Open, then its own; pinned as a conversation is where `onPin` is given.
|
|
15
|
+
*/
|
|
16
|
+
export function PartnerRow({ partner, time, selected, open, pinned, onPin, }) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const t = useT();
|
|
19
|
+
const [menu, openMenu] = useContextMenu();
|
|
20
|
+
const [opening, setOpening] = React.useState(false);
|
|
21
|
+
const Glyph = partner.icon;
|
|
22
|
+
const Own = partner.face;
|
|
23
|
+
const unseen = PartnersUtil.unseen(partner);
|
|
24
|
+
const asks = !partner.status && !!((_a = partner.chat) === null || _a === void 0 ? void 0 : _a.asks);
|
|
25
|
+
const go = () => {
|
|
26
|
+
setOpening(true);
|
|
27
|
+
void open(partner)
|
|
28
|
+
.catch(error => console.error(`A partner of ${partner.extension} failed to open:`, error))
|
|
29
|
+
.finally(() => setOpening(false));
|
|
30
|
+
};
|
|
31
|
+
const pin = onPin && { label: t(pinned ? 'ta.chat.unpin' : 'ta.chat.pin'), run: () => onPin(!pinned) };
|
|
32
|
+
const own = () => (partner.menu ? ChatHomeUtil.menu(partner.menu()) : []);
|
|
33
|
+
return (React.createElement(SwipeRow, { as: "li", className: `ta-chat-row ta-partner-row${selected ? ' ta-selected' : ''}`, "data-unseen": unseen && !asks ? '' : undefined, "data-asks": asks ? '' : undefined, actions: pin ? [{ key: 'pin', ...pin }] : undefined, overlay: menu, onContextMenu: event => {
|
|
34
|
+
const items = own();
|
|
35
|
+
openMenu(event, [
|
|
36
|
+
...ContextMenuUtil.sections([{ label: t('ta.chat.open'), run: go }], pin ? [pin] : []),
|
|
37
|
+
...(items.length ? ['-', ...items] : []),
|
|
38
|
+
]);
|
|
39
|
+
} },
|
|
40
|
+
React.createElement("button", { type: "button", className: "ta-chat-item", title: partner.name, "aria-current": selected ? 'true' : undefined, onClick: go },
|
|
41
|
+
React.createElement("span", { className: "ta-chat-avatar-box" },
|
|
42
|
+
Own && !opening ? (React.createElement("span", { className: "ta-chat-face", style: { width: 38, height: 38 }, "aria-hidden": "true" },
|
|
43
|
+
React.createElement(Own, { size: 38 }))) : (React.createElement("span", { className: "ta-chat-avatar ta-chat-icon", style: { background: `var(--ta-tint-${partner.tone})`, color: `var(--ta-tint-ink-${partner.tone})`, width: 38, height: 38 }, "aria-hidden": "true" }, opening ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Glyph, { size: 18, strokeWidth: 1.8 }))),
|
|
44
|
+
partner.online && React.createElement("span", { className: "ta-partner-online", "aria-hidden": "true" }),
|
|
45
|
+
React.createElement(ChatDot, { unseen: unseen, asks: asks })),
|
|
46
|
+
React.createElement(RowText, { title: partner.name, time: time, line: PartnersUtil.line(partner, t('ta.partners.waiting')), unseen: unseen, busy: !partner.status && !!((_b = partner.chat) === null || _b === void 0 ? void 0 : _b.busy), tag: partner.location ? React.createElement(HostTag, { location: partner.location }) : undefined }))));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=partner-row.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TaIdentity } from '@celljs/ta-protocol';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/** The identity of the computer in use, its name and picture: read once connected, and again when it changes. */
|
|
4
|
+
export declare function useIdentity(): TaIdentity | undefined;
|
|
5
|
+
/** The account in use as a line: "Company account · su", or none while signed out. */
|
|
6
|
+
export declare function useAccountLine(): string | undefined;
|
|
7
|
+
/** The profile, over the page: the picture, the name, and the account, which opens My devices. */
|
|
8
|
+
export declare function ProfileDialog({ onClose, onDevices }: {
|
|
9
|
+
onClose(): void;
|
|
10
|
+
onDevices(): void;
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CircleUserRound, KeyRound, PenLine } from 'lucide-react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useAccountInfo, useAccountSide } from '../account/account-side.js';
|
|
4
|
+
import { useNotices, useWorkbench } from '../hooks.js';
|
|
5
|
+
import { useT } from '../i18n/use-t.js';
|
|
6
|
+
import { accountName, useAccountWay } from './account-view.js';
|
|
7
|
+
import { Face } from './face.js';
|
|
8
|
+
import { ListGroup, ListRow } from './list-rows.js';
|
|
9
|
+
import { PicturePicker } from './picture-dialog.js';
|
|
10
|
+
import { WebDialog } from './web-dialog.js';
|
|
11
|
+
/*
|
|
12
|
+
* The user's profile (docs/design/ta-me.md 3): the picture and the name others see of them in group chats and among
|
|
13
|
+
* friends, and the account they are signed in to. One place to change them, which Me and the menu of the account open;
|
|
14
|
+
* the computers of the account share them.
|
|
15
|
+
*/
|
|
16
|
+
const changed = new Set();
|
|
17
|
+
/** The identity of the computer in use, its name and picture: read once connected, and again when it changes. */
|
|
18
|
+
export function useIdentity() {
|
|
19
|
+
const [{ status }, workbench] = useWorkbench();
|
|
20
|
+
const [identity, setIdentity] = React.useState();
|
|
21
|
+
const online = status === 'online';
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (!online) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let live = true;
|
|
27
|
+
const read = () => void Promise.resolve()
|
|
28
|
+
.then(() => workbench.rooms.getIdentity())
|
|
29
|
+
.then(next => live && setIdentity(next), () => undefined);
|
|
30
|
+
read();
|
|
31
|
+
changed.add(read);
|
|
32
|
+
const stop = workbench.onRoomEvent(event => event.type === 'rooms' && read(), { messages: false });
|
|
33
|
+
return () => {
|
|
34
|
+
live = false;
|
|
35
|
+
changed.delete(read);
|
|
36
|
+
stop();
|
|
37
|
+
};
|
|
38
|
+
}, [online, workbench]);
|
|
39
|
+
return identity;
|
|
40
|
+
}
|
|
41
|
+
/** The account in use as a line: "Company account · su", or none while signed out. */
|
|
42
|
+
export function useAccountLine() {
|
|
43
|
+
const side = useAccountSide();
|
|
44
|
+
const { info } = useAccountInfo(side, 15000);
|
|
45
|
+
const way = useAccountWay();
|
|
46
|
+
return (info === null || info === void 0 ? void 0 : info.account) && !info.waiting ? `${way(info.account.id)} · ${accountName(info.account)}` : undefined;
|
|
47
|
+
}
|
|
48
|
+
/** The profile, over the page: the picture, the name, and the account, which opens My devices. */
|
|
49
|
+
export function ProfileDialog({ onClose, onDevices }) {
|
|
50
|
+
var _a;
|
|
51
|
+
const t = useT();
|
|
52
|
+
const [, workbench] = useWorkbench();
|
|
53
|
+
const [, notices] = useNotices();
|
|
54
|
+
const identity = useIdentity();
|
|
55
|
+
const account = useAccountLine();
|
|
56
|
+
const rename = async () => {
|
|
57
|
+
var _a;
|
|
58
|
+
const name = await notices.input({ title: t('ta.me.name'), value: (_a = identity === null || identity === void 0 ? void 0 : identity.name) !== null && _a !== void 0 ? _a : '', placeholder: t('ta.me.nameHint') });
|
|
59
|
+
if ((name === null || name === void 0 ? void 0 : name.trim()) && name.trim() !== (identity === null || identity === void 0 ? void 0 : identity.name)) {
|
|
60
|
+
try {
|
|
61
|
+
await workbench.rooms.setName(name.trim());
|
|
62
|
+
for (const read of changed) {
|
|
63
|
+
read();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
notices.error(error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return (React.createElement(WebDialog, { title: t('ta.me.profile'), onClose: onClose },
|
|
72
|
+
React.createElement("div", { className: "ta-profile" },
|
|
73
|
+
React.createElement("button", { type: "button", className: "ta-profile-picture", "aria-label": t('ta.picture.title'), onClick: () => PicturePicker.open() },
|
|
74
|
+
React.createElement(Face, { double: true, size: 84 })),
|
|
75
|
+
React.createElement("span", { className: "ta-profile-name ta-ellipsis" }, (_a = identity === null || identity === void 0 ? void 0 : identity.name) !== null && _a !== void 0 ? _a : ''),
|
|
76
|
+
React.createElement(ListGroup, null,
|
|
77
|
+
React.createElement(ListRow, { icon: CircleUserRound, label: t('ta.me.picture'), onClick: () => PicturePicker.open() }),
|
|
78
|
+
React.createElement(ListRow, { icon: PenLine, label: t('ta.me.name'), detail: identity === null || identity === void 0 ? void 0 : identity.name, onClick: () => void rename() }),
|
|
79
|
+
React.createElement(ListRow, { icon: KeyRound, label: t('ta.me.account'), detail: account !== null && account !== void 0 ? account : t('ta.me.noAccount'), onClick: () => {
|
|
80
|
+
onClose();
|
|
81
|
+
onDevices();
|
|
82
|
+
} })),
|
|
83
|
+
React.createElement("p", { className: "ta-profile-hint" }, t('ta.me.profileHint')))));
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=profile-view.js.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { useAccountInfo, useAccountSide } from '../account/account-side.js';
|
|
3
|
+
import { DeviceAccount } from '../account/device-account.js';
|
|
2
4
|
import { CodeScan } from '../device/code-scan.js';
|
|
3
5
|
import { Device } from '../device/device.js';
|
|
4
|
-
import { usePwa, useSettings } from '../hooks.js';
|
|
6
|
+
import { usePwa, useSettings, useWorkbench } from '../hooks.js';
|
|
5
7
|
import { useT } from '../i18n/use-t.js';
|
|
6
8
|
import { STYLE } from '../style.js';
|
|
7
9
|
import { WorkbenchUtil } from '../workbench-util.js';
|
|
8
|
-
import { AccountAsk,
|
|
10
|
+
import { AccountAsk, AccountWays, RecentAccounts } from './account-view.js';
|
|
9
11
|
import { BuiltInSignIn, CloudSignInEntry, CloudSignInFlow, useBuiltInState } from './cloud-sign-in-view.js';
|
|
10
12
|
import { dinoFavicon } from './dino.js';
|
|
11
|
-
import {
|
|
13
|
+
import { ConnectComputer, SavedHosts } from './host-view.js';
|
|
12
14
|
import { ScanReader } from './scan-screen.js';
|
|
13
15
|
import { SignInAccounts, useSignInWays } from './sign-in-accounts.js';
|
|
14
16
|
import { ConnectPicture } from './sign-in-picture.js';
|
|
@@ -57,6 +59,24 @@ export function SignIn(props) {
|
|
|
57
59
|
React.createElement(ScanReader, null),
|
|
58
60
|
React.createElement(AccountAsk, null)));
|
|
59
61
|
}
|
|
62
|
+
/** The accounts and the computers this device signed in to before, the latest first: a tap goes back to one. */
|
|
63
|
+
function RecentSignIns() {
|
|
64
|
+
const t = useT();
|
|
65
|
+
const [{ hosts }] = useWorkbench();
|
|
66
|
+
const accounts = WorkbenchUtil.isApp() ? DeviceAccount.recent().length : 0;
|
|
67
|
+
if (hosts.length === 0 && accounts === 0) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return (React.createElement("section", { className: "ta-host-saved" },
|
|
71
|
+
React.createElement("h2", null, t('ta.me.recent')),
|
|
72
|
+
React.createElement("ul", { className: "ta-host-list" },
|
|
73
|
+
React.createElement(RecentAccounts, null),
|
|
74
|
+
React.createElement(SavedHosts, null))));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The sign-in (docs/design/ta-me.md 5): the accounts first (a company's, which brings its Ta in the cloud; GitHub),
|
|
78
|
+
* then the accounts and computers signed in to before, then a computer of one's own by its code or link.
|
|
79
|
+
*/
|
|
60
80
|
function SignInPage({ error }) {
|
|
61
81
|
const t = useT();
|
|
62
82
|
const app = WorkbenchUtil.isApp();
|
|
@@ -70,6 +90,10 @@ function SignInPage({ error }) {
|
|
|
70
90
|
const { known: builtIn, settled: builtInSettled } = useBuiltInState();
|
|
71
91
|
// Its ways, or, out of reach from inside the company's network, the way to it.
|
|
72
92
|
const company = !accounts && builtIn && (builtIn.providers.length > 0 || builtIn.unreachable) ? builtIn : undefined;
|
|
93
|
+
// The app's own account: its ways, or where it stands.
|
|
94
|
+
const side = useAccountSide();
|
|
95
|
+
const { info: account, act } = useAccountInfo(app ? side : undefined);
|
|
96
|
+
const refused = error === 'refused' ? (app ? 'ta.signin.pairRefused' : 'ta.signin.refused') : undefined;
|
|
73
97
|
useDocument();
|
|
74
98
|
if (!settled || !builtInSettled) {
|
|
75
99
|
// Drawn once, as it will stay: not a page of a computer, then one of a company's accounts.
|
|
@@ -80,6 +104,15 @@ function SignInPage({ error }) {
|
|
|
80
104
|
React.createElement("div", { className: "ta-card" },
|
|
81
105
|
React.createElement(CloudSignInFlow, { page: true, onBack: () => setCloud(undefined), provider: cloud.provider, typing: cloud.typing }))));
|
|
82
106
|
}
|
|
107
|
+
if (account && (account.signingIn || (account.account && account.waiting))) {
|
|
108
|
+
// The code to enter on the provider's page, or the one another device of the account compares: the whole card.
|
|
109
|
+
return (React.createElement("div", { className: "ta-signin" },
|
|
110
|
+
React.createElement("div", { className: "ta-card" },
|
|
111
|
+
React.createElement(TaAvatar, { size: 72 }),
|
|
112
|
+
React.createElement(AccountWays, { info: account, act: act }))));
|
|
113
|
+
}
|
|
114
|
+
const ways = account && (React.createElement("section", { className: "ta-account-sign-in" },
|
|
115
|
+
React.createElement(AccountWays, { info: account, act: act })));
|
|
83
116
|
if (company) {
|
|
84
117
|
// A build for a deployment: its accounts first, the ways to a computer of one's own under them.
|
|
85
118
|
return (React.createElement("div", { className: "ta-signin" },
|
|
@@ -88,9 +121,10 @@ function SignInPage({ error }) {
|
|
|
88
121
|
React.createElement("h1", null, t('ta.signin.title')),
|
|
89
122
|
React.createElement("p", null, t('ta.cloud.builtInHint')),
|
|
90
123
|
React.createElement(BuiltInSignIn, { known: company, onPick: provider => setCloud({ provider }), onOther: () => setCloud({ typing: true }) }),
|
|
124
|
+
ways,
|
|
125
|
+
React.createElement(RecentSignIns, null),
|
|
91
126
|
React.createElement("div", { className: "ta-sign-in-or" }, t('ta.cloud.orComputer')),
|
|
92
|
-
|
|
93
|
-
React.createElement(AddHostPanel, { error: error === 'refused' ? (app ? 'ta.signin.pairRefused' : 'ta.signin.refused') : undefined }))));
|
|
127
|
+
React.createElement(ConnectComputer, { error: refused }))));
|
|
94
128
|
}
|
|
95
129
|
return (React.createElement("div", { className: "ta-signin" },
|
|
96
130
|
React.createElement("div", { className: "ta-card" },
|
|
@@ -107,7 +141,8 @@ function SignInPage({ error }) {
|
|
|
107
141
|
: 'ta.signin.hint')),
|
|
108
142
|
!accounts && React.createElement(ConnectPicture, { way: way }),
|
|
109
143
|
React.createElement(SignInAccounts, { providers: providers, outcome: outcome }),
|
|
110
|
-
|
|
111
|
-
React.createElement(
|
|
144
|
+
ways,
|
|
145
|
+
React.createElement(ConnectComputer, { error: refused }, !accounts && React.createElement(CloudSignInEntry, { onPick: () => setCloud({}) })),
|
|
146
|
+
React.createElement(RecentSignIns, null))));
|
|
112
147
|
}
|
|
113
148
|
//# sourceMappingURL=workbench-view.js.map
|
|
@@ -13,8 +13,8 @@ export interface WebModelPickerProps {
|
|
|
13
13
|
label?: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* Without
|
|
17
|
-
*
|
|
16
|
+
* Without the coding agents that cannot do without their own tools (`TaSettingsSnapshot.agents`), for what keeps
|
|
17
|
+
* to some of Ta's tools (the front of a call).
|
|
18
18
|
*/
|
|
19
19
|
noAgents?: boolean;
|
|
20
20
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WebHomeEntry } from './web-api-contributions.js';
|
|
2
|
+
export type * from './web-api-partners.js';
|
|
2
3
|
/** What the page offers of the rows of the double's home (registerHomeItems), for a list of an extension to show them as its own do. */
|
|
3
4
|
export interface WebHomeUI {
|
|
4
5
|
/** A React hook: the rows extensions add to the double's home (registerHomeItems), in the order they loaded. */
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { WebMenuItem } from './web-api-contributions.js';
|
|
3
|
+
import type { WebIcon } from './web-extension-api.js';
|
|
4
|
+
/**
|
|
5
|
+
* Those the user works with (docs/design/ta-partners.md): an agent, a friend, a group chat. Each is someone (or some
|
|
6
|
+
* ones) with a name and a face, a relation to the user, and one conversation with them; what is said there is a
|
|
7
|
+
* conversation of the double's list, as any other, and the page of the partners lists them, by kind, as contacts.
|
|
8
|
+
*/
|
|
9
|
+
export type WebPartnerKind = 'agent' | 'friend' | 'group';
|
|
10
|
+
/** One the user works with, as the extension that keeps them gives them (WebExtensionAPI.registerPartners). */
|
|
11
|
+
export interface WebPartner {
|
|
12
|
+
/** Unique in the extension: an agent's, a friend's identity, a group chat's. */
|
|
13
|
+
id: string;
|
|
14
|
+
kind: WebPartnerKind;
|
|
15
|
+
name: string;
|
|
16
|
+
/** Drawn `size` wide; else `icon` on a tile of its tint. */
|
|
17
|
+
face?: React.ComponentType<{
|
|
18
|
+
size: number;
|
|
19
|
+
}>;
|
|
20
|
+
icon: WebIcon;
|
|
21
|
+
/** Tints its tile, the same for the same text; default: the extension's name. */
|
|
22
|
+
tint?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Not a partner yet: `asking`, one asks the user (to be a friend, to join a group chat of theirs); `invited`, the
|
|
25
|
+
* user is asked into a group chat; `waiting`, the user asked, the other has not answered. Opening it answers.
|
|
26
|
+
*/
|
|
27
|
+
status?: 'asking' | 'invited' | 'waiting';
|
|
28
|
+
/** What it is, under its name when nothing was said with it: an agent's role, who asks and why. */
|
|
29
|
+
about?: string;
|
|
30
|
+
/** The conversation with it; none before there is one. */
|
|
31
|
+
chat?: WebPartnerChat;
|
|
32
|
+
/** A friend online now: the green dot of a contact. */
|
|
33
|
+
online?: boolean;
|
|
34
|
+
/** Where it works (an agent's directory): a remote one is marked by its host. */
|
|
35
|
+
location?: string;
|
|
36
|
+
/** Opens its conversation (or, while not a partner yet, what to answer). A promise keeps the row busy. */
|
|
37
|
+
open(): unknown;
|
|
38
|
+
/** Its menu (stop, delete…), after Open. */
|
|
39
|
+
menu?(): WebMenuItem[][];
|
|
40
|
+
}
|
|
41
|
+
/** The conversation with a partner. */
|
|
42
|
+
export interface WebPartnerChat {
|
|
43
|
+
/** A conversation of pi (an agent's): the double's list has its row already, this only names whose it is. */
|
|
44
|
+
sessionFile?: string;
|
|
45
|
+
/** What was said last, with who said it where it is not the partner. */
|
|
46
|
+
last?: string;
|
|
47
|
+
/** `Date.now()` time of it: where the conversation is in the double's list. */
|
|
48
|
+
at?: number;
|
|
49
|
+
/** Said since the user last looked: the amber dot. */
|
|
50
|
+
unseen?: boolean;
|
|
51
|
+
/** Answers now: the green dot that breathes. */
|
|
52
|
+
busy?: boolean;
|
|
53
|
+
/** Waits for the user to answer: the blue ?. */
|
|
54
|
+
asks?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** The partners of an extension (WebExtensionAPI.registerPartners). */
|
|
57
|
+
export interface WebPartnerSource {
|
|
58
|
+
partners(): readonly WebPartner[];
|
|
59
|
+
subscribe(listener: () => void): () => void;
|
|
60
|
+
/** What it adds to the + of the partners, to have a new one: an agent, a friend. */
|
|
61
|
+
add?(): WebMenuItem[];
|
|
62
|
+
/**
|
|
63
|
+
* Starts a group chat of these, two or more of the user's agents and friends (of every extension) the user picked:
|
|
64
|
+
* true once it did, false when it does not make such a group chat (one of the members is none it knows), for the
|
|
65
|
+
* next source to try.
|
|
66
|
+
*/
|
|
67
|
+
group?(members: readonly WebPartnerEntry[]): Promise<boolean>;
|
|
68
|
+
}
|
|
69
|
+
/** What an extension gives of the partners (WebExtensionAPI). */
|
|
70
|
+
export interface WebPartnersAPI {
|
|
71
|
+
/**
|
|
72
|
+
* Those the user works with that the extension keeps (agents, friends, group chats): the page lists them on the
|
|
73
|
+
* page of the partners, and what is said with each among the conversations of the double's list
|
|
74
|
+
* (docs/design/ta-partners.md). Newer than some Ta apps: `pi.registerPartners?.(…)`; without it, an extension shows
|
|
75
|
+
* them itself.
|
|
76
|
+
*/
|
|
77
|
+
registerPartners(source: WebPartnerSource): void;
|
|
78
|
+
}
|
|
79
|
+
/** What the page offers of the partners (WebExtensionUI). */
|
|
80
|
+
export interface WebPartnersUI {
|
|
81
|
+
/**
|
|
82
|
+
* Starts a chat as the + of the partners does: the user picks among their agents and friends, one is the conversation
|
|
83
|
+
* with them, two or more a group chat (WebPartnerSource.group). `partner`, the id of one of this extension's
|
|
84
|
+
* partners picked already (the friend of a chat of two). Newer than some Ta apps: `pi.ui.startGroup?.(…)`.
|
|
85
|
+
*/
|
|
86
|
+
startGroup(partner?: string): void;
|
|
87
|
+
}
|
|
88
|
+
/** A partner as the page lists it. */
|
|
89
|
+
export interface WebPartnerEntry extends WebPartner {
|
|
90
|
+
/** `<extension name>/<id>`. */
|
|
91
|
+
key: string;
|
|
92
|
+
extension: string;
|
|
93
|
+
/** The tint of its tile: `var(--ta-tint-<n>)`, `var(--ta-tint-ink-<n>)`. */
|
|
94
|
+
tone: number;
|
|
95
|
+
}
|
|
@@ -9,7 +9,7 @@ import type { Language, Theme } from '../settings/settings-protocol.js';
|
|
|
9
9
|
import type { CodeEditorProps, DiffEditorProps, WebComposerProps, WebConversationViewProps, WebDialogProps, WebEmptyProps, WebFaceProps, WebFolderPickerProps, WebFullScreenProps, WebGroupFaceProps, WebHoldToTalkProps, WebImageViewerProps, WebLoadingProps, WebModelPickerProps, WebPictureCardsProps, WebPictureProps, WebSelectBarProps, WebSelectCheckProps, WebShareSheetProps, WebStackProps, WebSwipeRowProps, WebSwitchProps, WebTaskIconProps, WebVoice } from './web-api-components.js';
|
|
10
10
|
import type { WebAsk, WebCallPartner, WebChatIconSource, WebCodeRendererOptions, WebCodeRendererProps, WebComposerAddon, WebCustomMessage, WebEditor, WebHomeSource, WebInitiative, WebMenuItem, WebOpener, WebOpenerOptions, WebRoomAddon, WebRoomAddonEntry, WebSearchSource, WebSessionMenu, WebSessionNotice, WebSettingsSection, WebShareTarget, WebTaskEntry, WebTaskRemoval, WebTaskSource, WebTool, WebToolRendererResolver, WebView, WebViewInfo, WidgetOptions } from './web-api-contributions.js';
|
|
11
11
|
import type { WebDesktop, WebFileDrag } from './web-api-desktop.js';
|
|
12
|
-
import type { WebHomeUI } from './web-api-home.js';
|
|
12
|
+
import type { WebHomeUI, WebPartnersAPI, WebPartnersUI } from './web-api-home.js';
|
|
13
13
|
import type { WebServices } from './web-api-services.js';
|
|
14
14
|
import type { WebTerminal, WebTerminalOptions } from './web-api-terminal.js';
|
|
15
15
|
import type { WebPageInfo } from './web-pages.js';
|
|
@@ -31,7 +31,7 @@ export type { WebPageInfo, WebPageState } from './web-pages.js';
|
|
|
31
31
|
* the two mean the same. A web extension is one ES module without imports, the `web` part of a pi
|
|
32
32
|
* package (see TaWebExtensionInfo); it exports a {@link WebExtensionFactory}.
|
|
33
33
|
*/
|
|
34
|
-
export interface WebExtensionAPI extends WebServices {
|
|
34
|
+
export interface WebExtensionAPI extends WebServices, WebPartnersAPI {
|
|
35
35
|
/** The React of the page: an extension brings no React of its own. */
|
|
36
36
|
readonly React: typeof React;
|
|
37
37
|
readonly ui: WebExtensionUI;
|
|
@@ -230,7 +230,7 @@ export interface WebNotifyOptions {
|
|
|
230
230
|
export type { ScreenAction, ScreenItem, ScreenPartSpec, ScreenPartView, ScreenPlace, ScreenScrollable, ScreenScrollTo } from '../screen/screen-protocol.js';
|
|
231
231
|
/** What web extensions see of TaScreen. */
|
|
232
232
|
export type WebScreen = Pick<TaScreen, 'agent' | 'parts' | 'act' | 'element' | 'where' | 'places' | 'go' | 'pageScroll' | 'scroll'>;
|
|
233
|
-
export interface WebExtensionUI extends WebHomeUI {
|
|
233
|
+
export interface WebExtensionUI extends WebHomeUI, WebPartnersUI {
|
|
234
234
|
/** A widget around the message box, as pi's, or a card in the workbench on the right; `undefined` removes it. */
|
|
235
235
|
setWidget(key: string, widget: React.ComponentType | undefined, options?: WidgetOptions): void;
|
|
236
236
|
/**
|