@celljs/ta-web 4.37.0 → 4.39.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/README.en.md +1 -1
- package/README.md +1 -1
- package/esm/browser/assistant/assistant-thread.d.ts +1 -1
- package/esm/browser/assistant/chat-task-source.js +2 -1
- package/esm/browser/components/app-contexts.js +11 -9
- package/esm/browser/components/chat-asks.d.ts +4 -1
- package/esm/browser/components/chat-asks.js +10 -0
- package/esm/browser/components/chat-list-row.js +5 -3
- package/esm/browser/components/cloud-network.d.ts +17 -0
- package/esm/browser/components/cloud-network.js +105 -0
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/composer-box-protocol.d.ts +5 -0
- package/esm/browser/components/composer-box.js +11 -14
- package/esm/browser/components/composer-media.d.ts +26 -0
- package/esm/browser/components/composer-media.js +37 -0
- package/esm/browser/components/composer-target.d.ts +2 -2
- package/esm/browser/components/composer-target.js +3 -3
- package/esm/browser/components/composer.js +1 -0
- package/esm/browser/components/folder-picker.d.ts +3 -3
- package/esm/browser/components/folder-picker.js +5 -15
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/link.d.ts +7 -1
- package/esm/browser/components/link.js +24 -5
- package/esm/browser/components/markdown.d.ts +2 -2
- package/esm/browser/components/markdown.js +77 -5
- package/esm/browser/components/relay-services.d.ts +0 -2
- package/esm/browser/components/relay-services.js +1 -11
- package/esm/browser/components/remote-hosts.d.ts +11 -7
- package/esm/browser/components/remote-hosts.js +94 -50
- package/esm/browser/components/remote-machines.d.ts +21 -0
- package/esm/browser/components/remote-machines.js +56 -0
- package/esm/browser/components/remote-prompts.d.ts +2 -3
- package/esm/browser/components/remote-prompts.js +3 -15
- package/esm/browser/components/remote-steps.d.ts +19 -0
- package/esm/browser/components/remote-steps.js +26 -0
- package/esm/browser/components/session-view.js +10 -6
- package/esm/browser/components/settings-controls.d.ts +3 -1
- package/esm/browser/components/settings-controls.js +2 -2
- package/esm/browser/components/web-composer.d.ts +1 -1
- package/esm/browser/components/web-composer.js +12 -3
- package/esm/browser/device/photo-picker.d.ts +11 -3
- package/esm/browser/device/photo-picker.js +26 -9
- package/esm/browser/device/video-picks.d.ts +24 -0
- package/esm/browser/device/video-picks.js +104 -0
- package/esm/browser/extension/icons.js +3 -1
- package/esm/browser/extension/web-access.js +4 -1
- package/esm/browser/extension/web-api-code.d.ts +36 -0
- package/esm/browser/extension/web-api-code.js +3 -0
- package/esm/browser/extension/web-api-components.d.ts +22 -0
- package/esm/browser/extension/web-api-contributions.d.ts +0 -31
- package/esm/browser/extension/web-api-menus.d.ts +29 -3
- package/esm/browser/extension/web-api-play.d.ts +29 -0
- package/esm/browser/extension/web-api-play.js +2 -0
- package/esm/browser/extension/web-api-services.d.ts +6 -0
- package/esm/browser/extension/web-api-spec.js +5 -0
- package/esm/browser/extension/web-api-terminal.d.ts +20 -0
- package/esm/browser/extension/web-extension-api.d.ts +12 -17
- package/esm/browser/extension/web-extension-context.d.ts +1 -1
- package/esm/browser/extension/web-extension-context.js +6 -3
- package/esm/browser/extension/web-extension-protocol.d.ts +5 -1
- package/esm/browser/extension/web-extension-protocol.js +2 -0
- package/esm/browser/extension/web-extension-run.d.ts +6 -4
- package/esm/browser/extension/web-extension-run.js +18 -9
- package/esm/browser/extension/web-extensions-running.js +38 -7
- package/esm/browser/extension/web-on-demand.d.ts +5 -0
- package/esm/browser/extension/web-on-demand.js +11 -0
- package/esm/browser/i18n/en/assistant.d.ts +3 -0
- package/esm/browser/i18n/en/assistant.js +3 -0
- package/esm/browser/i18n/en/chat.d.ts +1 -0
- package/esm/browser/i18n/en/chat.js +1 -0
- package/esm/browser/i18n/en/common.d.ts +1 -0
- package/esm/browser/i18n/en/common.js +1 -0
- package/esm/browser/i18n/en/discover.d.ts +2 -0
- package/esm/browser/i18n/en/discover.js +2 -0
- package/esm/browser/i18n/en/service.d.ts +26 -2
- package/esm/browser/i18n/en/service.js +34 -10
- package/esm/browser/i18n/ja/assistant.js +3 -0
- package/esm/browser/i18n/ja/chat.js +1 -0
- package/esm/browser/i18n/ja/common.js +1 -0
- package/esm/browser/i18n/ja/discover.js +2 -0
- package/esm/browser/i18n/ja/service.js +34 -10
- package/esm/browser/i18n/locales.d.ts +34 -3
- package/esm/browser/i18n/messages.d.ts +33 -2
- package/esm/browser/i18n/zh/assistant.js +3 -0
- package/esm/browser/i18n/zh/chat.js +1 -0
- package/esm/browser/i18n/zh/common.js +1 -0
- package/esm/browser/i18n/zh/discover.js +2 -0
- package/esm/browser/i18n/zh/service.js +34 -10
- package/esm/browser/i18n/zh-tw/assistant.js +3 -0
- package/esm/browser/i18n/zh-tw/chat.js +1 -0
- package/esm/browser/i18n/zh-tw/common.js +1 -0
- package/esm/browser/i18n/zh-tw/discover.js +2 -0
- package/esm/browser/i18n/zh-tw/service.js +34 -10
- package/esm/browser/markdown/code-renderers.d.ts +6 -1
- package/esm/browser/markdown/code-renderers.js +4 -0
- package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
- package/esm/browser/sandbox/work/work-api.d.ts +113 -0
- package/esm/browser/sandbox/work/work-api.js +95 -0
- package/esm/browser/sandbox/work/work-docs.d.ts +18 -0
- package/esm/browser/sandbox/work/work-docs.js +66 -0
- package/esm/browser/sandbox/work/work-frame.d.ts +27 -0
- package/esm/browser/sandbox/work/work-frame.js +124 -0
- package/esm/browser/share/shared-extensions.d.ts +2 -1
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +10 -0
- package/esm/browser/style/dialogs.d.ts +1 -1
- package/esm/browser/style/dialogs.js +1 -4
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +10 -1
- package/esm/browser/terminal/terminal-osc.d.ts +15 -0
- package/esm/browser/terminal/terminal-osc.js +91 -0
- package/esm/browser/terminal/web-terminal.d.ts +4 -7
- package/esm/browser/terminal/web-terminal.js +22 -26
- package/esm/browser/util/link.d.ts +6 -1
- package/esm/browser/util/link.js +11 -0
- package/esm/browser/workbench-protocol.d.ts +2 -0
- package/esm/browser/workbench-services.d.ts +2 -0
- package/esm/browser/workbench-services.js +5 -0
- package/esm/browser/workbench.js +3 -0
- package/lib/browser/assistant/assistant-thread.d.ts +1 -1
- package/lib/browser/assistant/chat-task-source.js +2 -1
- package/lib/browser/components/app-contexts.js +10 -8
- package/lib/browser/components/chat-asks.d.ts +4 -1
- package/lib/browser/components/chat-asks.js +10 -0
- package/lib/browser/components/chat-list-row.js +5 -3
- package/lib/browser/components/cloud-network.d.ts +18 -0
- package/lib/browser/components/cloud-network.js +142 -0
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/composer-box-protocol.d.ts +5 -0
- package/lib/browser/components/composer-box.js +9 -12
- package/lib/browser/components/composer-media.d.ts +27 -0
- package/lib/browser/components/composer-media.js +74 -0
- package/lib/browser/components/composer-target.d.ts +2 -2
- package/lib/browser/components/composer-target.js +3 -3
- package/lib/browser/components/composer.js +1 -0
- package/lib/browser/components/folder-picker.d.ts +3 -3
- package/lib/browser/components/folder-picker.js +5 -15
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/link.d.ts +7 -1
- package/lib/browser/components/link.js +25 -6
- package/lib/browser/components/markdown.d.ts +2 -2
- package/lib/browser/components/markdown.js +75 -3
- package/lib/browser/components/relay-services.d.ts +0 -2
- package/lib/browser/components/relay-services.js +1 -11
- package/lib/browser/components/remote-hosts.d.ts +11 -7
- package/lib/browser/components/remote-hosts.js +92 -48
- package/lib/browser/components/remote-machines.d.ts +22 -0
- package/lib/browser/components/remote-machines.js +59 -0
- package/lib/browser/components/remote-prompts.d.ts +2 -3
- package/lib/browser/components/remote-prompts.js +3 -15
- package/lib/browser/components/remote-steps.d.ts +20 -0
- package/lib/browser/components/remote-steps.js +63 -0
- package/lib/browser/components/session-view.js +8 -4
- package/lib/browser/components/settings-controls.d.ts +3 -1
- package/lib/browser/components/settings-controls.js +2 -2
- package/lib/browser/components/web-composer.d.ts +1 -1
- package/lib/browser/components/web-composer.js +12 -3
- package/lib/browser/device/photo-picker.d.ts +11 -3
- package/lib/browser/device/photo-picker.js +26 -9
- package/lib/browser/device/video-picks.d.ts +25 -0
- package/lib/browser/device/video-picks.js +107 -0
- package/lib/browser/extension/icons.js +2 -0
- package/lib/browser/extension/web-access.js +4 -1
- package/lib/browser/extension/web-api-code.d.ts +37 -0
- package/lib/browser/extension/web-api-code.js +4 -0
- package/lib/browser/extension/web-api-components.d.ts +22 -0
- package/lib/browser/extension/web-api-contributions.d.ts +0 -31
- package/lib/browser/extension/web-api-menus.d.ts +29 -3
- package/lib/browser/extension/web-api-play.d.ts +30 -0
- package/lib/browser/extension/web-api-play.js +3 -0
- package/lib/browser/extension/web-api-services.d.ts +6 -0
- package/lib/browser/extension/web-api-spec.js +5 -0
- package/lib/browser/extension/web-api-terminal.d.ts +20 -0
- package/lib/browser/extension/web-extension-api.d.ts +12 -17
- package/lib/browser/extension/web-extension-context.d.ts +1 -1
- package/lib/browser/extension/web-extension-context.js +6 -3
- package/lib/browser/extension/web-extension-protocol.d.ts +5 -1
- package/lib/browser/extension/web-extension-protocol.js +2 -0
- package/lib/browser/extension/web-extension-run.d.ts +6 -4
- package/lib/browser/extension/web-extension-run.js +18 -9
- package/lib/browser/extension/web-extensions-running.js +38 -7
- package/lib/browser/extension/web-on-demand.d.ts +5 -0
- package/lib/browser/extension/web-on-demand.js +11 -0
- package/lib/browser/i18n/en/assistant.d.ts +3 -0
- package/lib/browser/i18n/en/assistant.js +3 -0
- package/lib/browser/i18n/en/chat.d.ts +1 -0
- package/lib/browser/i18n/en/chat.js +1 -0
- package/lib/browser/i18n/en/common.d.ts +1 -0
- package/lib/browser/i18n/en/common.js +1 -0
- package/lib/browser/i18n/en/discover.d.ts +2 -0
- package/lib/browser/i18n/en/discover.js +2 -0
- package/lib/browser/i18n/en/service.d.ts +26 -2
- package/lib/browser/i18n/en/service.js +34 -10
- package/lib/browser/i18n/ja/assistant.js +3 -0
- package/lib/browser/i18n/ja/chat.js +1 -0
- package/lib/browser/i18n/ja/common.js +1 -0
- package/lib/browser/i18n/ja/discover.js +2 -0
- package/lib/browser/i18n/ja/service.js +34 -10
- package/lib/browser/i18n/locales.d.ts +34 -3
- package/lib/browser/i18n/messages.d.ts +33 -2
- package/lib/browser/i18n/zh/assistant.js +3 -0
- package/lib/browser/i18n/zh/chat.js +1 -0
- package/lib/browser/i18n/zh/common.js +1 -0
- package/lib/browser/i18n/zh/discover.js +2 -0
- package/lib/browser/i18n/zh/service.js +34 -10
- package/lib/browser/i18n/zh-tw/assistant.js +3 -0
- package/lib/browser/i18n/zh-tw/chat.js +1 -0
- package/lib/browser/i18n/zh-tw/common.js +1 -0
- package/lib/browser/i18n/zh-tw/discover.js +2 -0
- package/lib/browser/i18n/zh-tw/service.js +34 -10
- package/lib/browser/markdown/code-renderers.d.ts +6 -1
- package/lib/browser/markdown/code-renderers.js +5 -1
- package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
- package/lib/browser/sandbox/work/work-api.d.ts +114 -0
- package/lib/browser/sandbox/work/work-api.js +99 -0
- package/lib/browser/sandbox/work/work-docs.d.ts +19 -0
- package/lib/browser/sandbox/work/work-docs.js +69 -0
- package/lib/browser/sandbox/work/work-frame.d.ts +28 -0
- package/lib/browser/sandbox/work/work-frame.js +160 -0
- package/lib/browser/share/shared-extensions.d.ts +2 -1
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +10 -0
- package/lib/browser/style/dialogs.d.ts +1 -1
- package/lib/browser/style/dialogs.js +1 -4
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +10 -1
- package/lib/browser/terminal/terminal-osc.d.ts +16 -0
- package/lib/browser/terminal/terminal-osc.js +94 -0
- package/lib/browser/terminal/web-terminal.d.ts +4 -7
- package/lib/browser/terminal/web-terminal.js +25 -29
- package/lib/browser/util/link.d.ts +6 -1
- package/lib/browser/util/link.js +11 -0
- package/lib/browser/workbench-protocol.d.ts +2 -0
- package/lib/browser/workbench-services.d.ts +2 -0
- package/lib/browser/workbench-services.js +5 -0
- package/lib/browser/workbench.js +3 -0
- package/package.json +12 -12
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { TaLocation } from '@celljs/ta-protocol';
|
|
2
|
-
import { Cloud, ExternalLink, KeyRound, Link2, Plug, Plus, Server,
|
|
2
|
+
import { Cloud, ExternalLink, KeyRound, Link2, Plug, Plus, Server, Trash2, Unplug, X } from 'lucide-react';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { useNotices, useWorkbench } from '../hooks.js';
|
|
5
5
|
import { useT } from '../i18n/use-t.js';
|
|
6
|
+
import { CloudNetworkRow } from './cloud-network.js';
|
|
6
7
|
import { RemotePicture } from './empty-pictures.js';
|
|
7
8
|
import { RemoteHostsUtil } from './folder-picker.js';
|
|
8
9
|
import { Icon, IconButton } from './icon.js';
|
|
9
|
-
import {
|
|
10
|
+
import { RemoteMachinesUtil } from './remote-machines.js';
|
|
11
|
+
import { useRemoteSteps } from './remote-steps.js';
|
|
12
|
+
import { EmptyRow, Row, Switch } from './settings-controls.js';
|
|
10
13
|
/** The hosts and forwarded ports of TaRemoteServer, read again when a host connects or disconnects. */
|
|
11
14
|
function useRemote() {
|
|
12
15
|
const [workbench, bench] = useWorkbench();
|
|
@@ -24,23 +27,25 @@ function useRemote() {
|
|
|
24
27
|
read().catch(() => undefined);
|
|
25
28
|
return bench.onRemoteEvent(event => event.type === 'connection' && void read().catch(() => undefined));
|
|
26
29
|
}, [workbench.status, bench, read]);
|
|
27
|
-
return { bench, hosts, ports, read };
|
|
30
|
+
return { bench, hosts, ports, read, steps: useRemoteSteps(bench) };
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
|
-
* A cloud workspace to add: the address of
|
|
31
|
-
* its directories
|
|
32
|
-
* it with the address of its gateway and a name filled in.
|
|
33
|
+
* A cloud workspace of a Ta gateway to add: the address of the gateway and a token of one's account there; its name,
|
|
34
|
+
* for its directories (`ta://<name>/…`), from the address. Checked by connecting before it is kept. A deployment
|
|
35
|
+
* joined (RelayServices) opens it with the address of its gateway and a name filled in.
|
|
33
36
|
*/
|
|
34
|
-
export function AddCloudHost({ onAdded, url: givenUrl = '', name: givenName =
|
|
37
|
+
export function AddCloudHost({ onAdded, url: givenUrl = '', name: givenName, taken = [], onOpenChange, }) {
|
|
35
38
|
const t = useT();
|
|
36
39
|
const [, bench] = useWorkbench();
|
|
37
40
|
const [, notices] = useNotices();
|
|
38
|
-
const [open,
|
|
39
|
-
const
|
|
41
|
+
const [open, setOpenState] = React.useState(false);
|
|
42
|
+
const setOpen = (value) => {
|
|
43
|
+
setOpenState(value);
|
|
44
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(value);
|
|
45
|
+
};
|
|
40
46
|
const [url, setUrl] = React.useState(givenUrl);
|
|
41
47
|
const [token, setToken] = React.useState('');
|
|
42
48
|
const [busy, setBusy] = React.useState(false);
|
|
43
|
-
const nameOk = TaLocation.isCloudName(name.trim());
|
|
44
49
|
if (!open) {
|
|
45
50
|
return (React.createElement("button", { type: "button", className: "ta-button", onClick: () => setOpen(true) },
|
|
46
51
|
React.createElement(Icon, { icon: Cloud, size: 14 }),
|
|
@@ -51,10 +56,10 @@ export function AddCloudHost({ onAdded, url: givenUrl = '', name: givenName = ''
|
|
|
51
56
|
event.preventDefault();
|
|
52
57
|
setBusy(true);
|
|
53
58
|
try {
|
|
54
|
-
const
|
|
59
|
+
const name = givenName || RemoteMachinesUtil.cloudName(url, taken);
|
|
60
|
+
const added = await bench.remote.addCloudHost(name, url.trim(), token.trim());
|
|
55
61
|
notices.notify(t('ta.remote.cloudAdded', { name: TaLocation.hostLabel(added.host) }), { level: 'success' });
|
|
56
62
|
setOpen(false);
|
|
57
|
-
setName(givenName);
|
|
58
63
|
setUrl(givenUrl);
|
|
59
64
|
setToken('');
|
|
60
65
|
await onAdded();
|
|
@@ -72,25 +77,31 @@ export function AddCloudHost({ onAdded, url: givenUrl = '', name: givenName = ''
|
|
|
72
77
|
React.createElement("label", { className: "ta-field" },
|
|
73
78
|
React.createElement(Icon, { icon: KeyRound, size: 16 }),
|
|
74
79
|
React.createElement("input", { type: "password", value: token, placeholder: t('ta.remote.cloudToken'), "aria-label": t('ta.remote.cloudToken'), autoComplete: "off", onChange: event => setToken(event.target.value) })),
|
|
75
|
-
React.createElement("label", { className: "ta-field" },
|
|
76
|
-
React.createElement(Icon, { icon: Tag, size: 16 }),
|
|
77
|
-
React.createElement("input", { value: name, placeholder: t('ta.remote.cloudName'), "aria-label": t('ta.remote.cloudName'), "aria-invalid": name.trim() && !nameOk ? true : undefined, spellCheck: false, autoCapitalize: "off", onChange: event => setName(event.target.value.toLowerCase()) })),
|
|
78
80
|
React.createElement("p", { className: "ta-environment-hint" }, t('ta.remote.cloudHint')),
|
|
79
81
|
React.createElement("div", { className: "ta-auth-actions" },
|
|
80
82
|
React.createElement("button", { type: "button", className: "ta-button", onClick: () => setOpen(false) }, t('ta.cancel')),
|
|
81
|
-
React.createElement("button", { type: "submit", className: "ta-button ta-primary", disabled: busy || !
|
|
83
|
+
React.createElement("button", { type: "submit", className: "ta-button ta-primary", disabled: busy || !url.trim() || !token.trim() }, busy ? React.createElement("span", { className: "ta-spinner" }) : t('ta.remote.cloudConnect')))));
|
|
84
|
+
}
|
|
85
|
+
/** Whether a host is connected, or the step it is at, with its light. */
|
|
86
|
+
function HostState({ host, step, extra }) {
|
|
87
|
+
const t = useT();
|
|
88
|
+
return (React.createElement("span", { className: "ta-remote-state" },
|
|
89
|
+
step ? React.createElement("span", { className: "ta-spinner" }) : React.createElement("span", { className: `ta-remote-light${host.connected ? ' ta-on' : ''}` }),
|
|
90
|
+
[RemoteMachinesUtil.state(host, step, t), extra].filter(Boolean).join(' · ')));
|
|
82
91
|
}
|
|
83
92
|
/**
|
|
84
|
-
* The machines conversations can work on (`ssh://` directories)
|
|
85
|
-
*
|
|
86
|
-
*
|
|
93
|
+
* The machines conversations can work on (`ssh://` directories) and go on on while this computer is away (cloud
|
|
94
|
+
* workspaces), one row each with what belongs to it under it: whether conversations go on there (a cloud workspace
|
|
95
|
+
* made on it), how far its commands reach, the ports forwarded from it. Connecting checks a host the way a
|
|
96
|
+
* conversation would: ssh signs in, Ta installs what it needs there. A Ta gateway, which few have, comes last.
|
|
87
97
|
*/
|
|
88
98
|
export function RemoteHosts() {
|
|
89
99
|
const t = useT();
|
|
90
100
|
const [, notices] = useNotices();
|
|
91
|
-
const { bench, hosts, ports, read } = useRemote();
|
|
101
|
+
const { bench, hosts, ports, read, steps } = useRemote();
|
|
92
102
|
const [text, setText] = React.useState('');
|
|
93
103
|
const [busy, setBusy] = React.useState();
|
|
104
|
+
const [gateway, setGateway] = React.useState(false);
|
|
94
105
|
const run = async (host, action) => {
|
|
95
106
|
setBusy(host);
|
|
96
107
|
try {
|
|
@@ -113,6 +124,42 @@ export function RemoteHosts() {
|
|
|
113
124
|
setText('');
|
|
114
125
|
void run(read.host, () => bench.remote.addHost(read.host));
|
|
115
126
|
};
|
|
127
|
+
const relay = async (host, on, current) => {
|
|
128
|
+
try {
|
|
129
|
+
if (on) {
|
|
130
|
+
await bench.remote.addSshCloudHost('', host.host);
|
|
131
|
+
notices.notify(t('ta.remote.madeCloud', { host: TaLocation.hostLabel(host.host) }), { level: 'success' });
|
|
132
|
+
}
|
|
133
|
+
else if (current) {
|
|
134
|
+
const sure = await notices.confirm({
|
|
135
|
+
title: t('ta.remote.relay.stopTitle', { host: TaLocation.hostLabel(host.host) }),
|
|
136
|
+
message: t('ta.remote.relay.stopHint'),
|
|
137
|
+
confirmLabel: t('ta.remote.relay.stop'),
|
|
138
|
+
});
|
|
139
|
+
if (sure) {
|
|
140
|
+
await bench.remote.removeHost(current.host);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
notices.error(error);
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
await read().catch(() => undefined);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const connection = (host) => host.connected ? (React.createElement("button", { type: "button", className: "ta-button", disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.disconnect(host.host)) },
|
|
152
|
+
React.createElement(Icon, { icon: Unplug, size: 14 }),
|
|
153
|
+
" ",
|
|
154
|
+
t('ta.remote.disconnect'))) : (React.createElement("button", { type: "button", className: "ta-button", disabled: busy === host.host, onClick: () => run(host.host, async () => {
|
|
155
|
+
await bench.remote.resolveLocation(TaLocation.ssh(host.host));
|
|
156
|
+
notices.notify(t('ta.remote.connectedTo', { host: TaLocation.hostLabel(host.host) }), { level: 'success' });
|
|
157
|
+
}) },
|
|
158
|
+
busy === host.host ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: Plug, size: 14 }),
|
|
159
|
+
" ",
|
|
160
|
+
t('ta.remote.connect')));
|
|
161
|
+
const machines = RemoteMachinesUtil.machines(hosts);
|
|
162
|
+
const taken = hosts.flatMap(host => { var _a; return (_a = TaLocation.cloudName(host.host)) !== null && _a !== void 0 ? _a : []; });
|
|
116
163
|
return (React.createElement(React.Fragment, null,
|
|
117
164
|
React.createElement(Row, { label: t('ta.remote.add'), description: t('ta.remote.description'), stacked: true },
|
|
118
165
|
React.createElement("form", { className: "ta-trusted-add", onSubmit: event => {
|
|
@@ -123,35 +170,32 @@ export function RemoteHosts() {
|
|
|
123
170
|
React.createElement("button", { type: "submit", className: "ta-button", disabled: !text.trim() },
|
|
124
171
|
React.createElement(Icon, { icon: Plus, size: 14 }),
|
|
125
172
|
" ",
|
|
126
|
-
t('ta.remote.
|
|
127
|
-
React.createElement(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
t(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
React.createElement(
|
|
140
|
-
|
|
141
|
-
t('ta.remote.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
ports.map(port => (React.createElement(Row, { key: `${port.host}:${port.remotePort}`, label: t('ta.remote.port', { host: port.host, port: port.remotePort }), description: `localhost:${port.localPort}` },
|
|
154
|
-
React.createElement(Icon, { icon: Server, size: 14, className: "ta-muted" }),
|
|
155
|
-
React.createElement(IconButton, { icon: X, label: t('ta.remote.closePort'), onClick: () => run(port.host, () => bench.remote.closeForwardedPort(port.host, port.remotePort)) }))))));
|
|
173
|
+
t('ta.remote.addConfirm')))),
|
|
174
|
+
machines.length === 0 && React.createElement(EmptyRow, { picture: React.createElement(RemotePicture, null), title: t('ta.remote.none'), hint: t('ta.remote.noneHint') }),
|
|
175
|
+
machines.map(({ host, relay: current }) => { var _a, _b; return host.source === 'cloud' ? (React.createElement(React.Fragment, { key: host.host },
|
|
176
|
+
React.createElement(Row, { icon: Cloud, label: TaLocation.hostLabel(host.host), description: React.createElement(HostState, { host: host, step: steps[host.host], extra: ((_a = host.url) !== null && _a !== void 0 ? _a : '').replace(/^https?:\/\//, '') }) },
|
|
177
|
+
/^https?:/.test((_b = host.url) !== null && _b !== void 0 ? _b : '') && (React.createElement("a", { className: "ta-button", href: host.url, target: "_blank", rel: "noreferrer noopener", title: t('ta.remote.openCloudHint') },
|
|
178
|
+
React.createElement(Icon, { icon: ExternalLink, size: 14 }),
|
|
179
|
+
" ",
|
|
180
|
+
t('ta.remote.openCloud'))),
|
|
181
|
+
connection(host),
|
|
182
|
+
React.createElement(IconButton, { icon: Trash2, label: t('ta.remote.remove', { host: host.host }), disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.removeHost(host.host)) })),
|
|
183
|
+
React.createElement(CloudNetworkRow, { host: host, onChanged: read }))) : (React.createElement(React.Fragment, { key: host.host },
|
|
184
|
+
React.createElement(Row, { icon: current ? Cloud : Server, label: RemoteHostsUtil.breakable(host.host), description: React.createElement(HostState, { host: host, step: RemoteMachinesUtil.relayStep(steps[host.host]) ? undefined : steps[host.host], extra: host.source === 'config' ? t('ta.remote.fromConfig') : undefined }) },
|
|
185
|
+
connection(host),
|
|
186
|
+
host.source !== 'config' && !current && (React.createElement(IconButton, { icon: Trash2, label: t('ta.remote.remove', { host: host.host }), disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.removeHost(host.host)) }))),
|
|
187
|
+
React.createElement(Row, { inset: true, label: t('ta.remote.relay'), description: RemoteMachinesUtil.relayStep(steps[host.host]) ? (React.createElement(HostState, { host: host, step: steps[host.host] })) : (t(current ? 'ta.remote.relay.on' : 'ta.remote.relay.off')) },
|
|
188
|
+
React.createElement(Switch, { label: t('ta.remote.relay'), checked: !!current, onChange: on => relay(host, on, current) })),
|
|
189
|
+
current && React.createElement(CloudNetworkRow, { host: current, onChanged: read }),
|
|
190
|
+
ports
|
|
191
|
+
.filter(port => port.host === host.host)
|
|
192
|
+
.map(port => (React.createElement(Row, { inset: true, key: `${port.host}:${port.remotePort}`, label: t('ta.remote.port', { port: port.remotePort }), description: t('ta.remote.portLocal', { port: port.localPort }) },
|
|
193
|
+
React.createElement(IconButton, { icon: X, label: t('ta.remote.closePort'), onClick: () => run(port.host, () => bench.remote.closeForwardedPort(port.host, port.remotePort)) })))))); }),
|
|
194
|
+
ports
|
|
195
|
+
.filter(port => !machines.some(machine => machine.host.host === port.host))
|
|
196
|
+
.map(port => (React.createElement(Row, { key: `${port.host}:${port.remotePort}`, label: `${TaLocation.hostLabel(port.host)} · ${t('ta.remote.port', { port: port.remotePort })}`, description: t('ta.remote.portLocal', { port: port.localPort }) },
|
|
197
|
+
React.createElement(IconButton, { icon: X, label: t('ta.remote.closePort'), onClick: () => run(port.host, () => bench.remote.closeForwardedPort(port.host, port.remotePort)) })))),
|
|
198
|
+
React.createElement(Row, { label: t('ta.remote.cloudTitle'), description: t('ta.remote.cloudDescription'), stacked: gateway },
|
|
199
|
+
React.createElement(AddCloudHost, { onAdded: read, taken: taken, onOpenChange: setGateway }))));
|
|
156
200
|
}
|
|
157
201
|
//# sourceMappingURL=remote-hosts.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type TaRemoteHost } from '@celljs/ta-protocol';
|
|
2
|
+
import type { Translate } from '../i18n/use-t.js';
|
|
3
|
+
import type { RemoteStepInfo } from './remote-steps.js';
|
|
4
|
+
/** A machine of the list: a host of ssh with the cloud workspace made on it (`relay`), or a cloud workspace of a gateway. */
|
|
5
|
+
export interface RemoteMachine {
|
|
6
|
+
host: TaRemoteHost;
|
|
7
|
+
relay?: TaRemoteHost;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace RemoteMachinesUtil {
|
|
10
|
+
/**
|
|
11
|
+
* The machines of the list, each once: a cloud workspace on a host of ssh is that host's `relay` (the host made
|
|
12
|
+
* up, not connected, when it is no longer listed); those of gateways after the hosts.
|
|
13
|
+
*/
|
|
14
|
+
function machines(hosts: readonly TaRemoteHost[]): RemoteMachine[];
|
|
15
|
+
/** The name of the cloud workspace of a gateway, from its address: its first label, free among `taken`. */
|
|
16
|
+
function cloudName(gateway: string, taken?: readonly string[]): string;
|
|
17
|
+
/** Whether a step is of making a host of ssh a cloud workspace, which the row of its handover shows, not that of the host. */
|
|
18
|
+
function relayStep(step: RemoteStepInfo | undefined): boolean;
|
|
19
|
+
/** What a host does now, in words: the step it is at, connected or not. */
|
|
20
|
+
function state(host: TaRemoteHost, step: RemoteStepInfo | undefined, t: Translate): string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TaLocation } from '@celljs/ta-protocol';
|
|
2
|
+
export var RemoteMachinesUtil;
|
|
3
|
+
(function (RemoteMachinesUtil) {
|
|
4
|
+
/**
|
|
5
|
+
* The machines of the list, each once: a cloud workspace on a host of ssh is that host's `relay` (the host made
|
|
6
|
+
* up, not connected, when it is no longer listed); those of gateways after the hosts.
|
|
7
|
+
*/
|
|
8
|
+
function machines(hosts) {
|
|
9
|
+
const relays = new Map(hosts.filter(host => host.source === 'cloud' && host.via).map(host => [host.via, host]));
|
|
10
|
+
const ssh = hosts.filter(host => host.source !== 'cloud');
|
|
11
|
+
const missing = [...relays.keys()].filter(via => !ssh.some(host => host.host === via));
|
|
12
|
+
return [
|
|
13
|
+
...ssh.map(host => ({ host, relay: relays.get(host.host) })),
|
|
14
|
+
...missing.map(via => ({ host: { host: via, source: 'recent', connected: false }, relay: relays.get(via) })),
|
|
15
|
+
...hosts.filter(host => host.source === 'cloud' && !host.via).map(host => ({ host })),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
RemoteMachinesUtil.machines = machines;
|
|
19
|
+
/** The name of the cloud workspace of a gateway, from its address: its first label, free among `taken`. */
|
|
20
|
+
function cloudName(gateway, taken = []) {
|
|
21
|
+
var _a;
|
|
22
|
+
let host = gateway.trim();
|
|
23
|
+
try {
|
|
24
|
+
host = new URL(/^[a-z]+:\/\//i.test(host) ? host : `https://${host}`).hostname;
|
|
25
|
+
}
|
|
26
|
+
catch (_b) {
|
|
27
|
+
// What the user is typing: its first word is enough.
|
|
28
|
+
}
|
|
29
|
+
const first = ((_a = host.split(/[.:/]/)[0]) !== null && _a !== void 0 ? _a : '')
|
|
30
|
+
.toLowerCase()
|
|
31
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
32
|
+
.replace(/^-+|-+$/g, '')
|
|
33
|
+
.slice(0, 36);
|
|
34
|
+
const base = /^[a-z0-9]/.test(first) ? first : 'cloud';
|
|
35
|
+
let name = base;
|
|
36
|
+
for (let n = 2; taken.includes(name); n++) {
|
|
37
|
+
name = `${base}-${n}`;
|
|
38
|
+
}
|
|
39
|
+
return name;
|
|
40
|
+
}
|
|
41
|
+
RemoteMachinesUtil.cloudName = cloudName;
|
|
42
|
+
/** Whether a step is of making a host of ssh a cloud workspace, which the row of its handover shows, not that of the host. */
|
|
43
|
+
function relayStep(step) {
|
|
44
|
+
return (step === null || step === void 0 ? void 0 : step.step) === 'installing-ta' || (step === null || step === void 0 ? void 0 : step.step) === 'starting-ta';
|
|
45
|
+
}
|
|
46
|
+
RemoteMachinesUtil.relayStep = relayStep;
|
|
47
|
+
/** What a host does now, in words: the step it is at, connected or not. */
|
|
48
|
+
function state(host, step, t) {
|
|
49
|
+
var _a;
|
|
50
|
+
return step
|
|
51
|
+
? t(`ta.remote.step.${step.step}`, { host: TaLocation.hostLabel(host.host), detail: (_a = step.detail) !== null && _a !== void 0 ? _a : '' })
|
|
52
|
+
: t(host.connected ? 'ta.remote.connected' : 'ta.remote.disconnected');
|
|
53
|
+
}
|
|
54
|
+
RemoteMachinesUtil.state = state;
|
|
55
|
+
})(RemoteMachinesUtil || (RemoteMachinesUtil = {}));
|
|
56
|
+
//# sourceMappingURL=remote-machines.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* What ssh asks while ta serve connects to a host, one question at a time, in every page that is open (the
|
|
4
|
-
* first answer counts);
|
|
5
|
-
* time (it installs Node.js there); and a notice when a connection is lost.
|
|
4
|
+
* first answer counts); and a notice when a connection is lost.
|
|
6
5
|
*/
|
|
7
|
-
export declare function RemotePrompts(): React.JSX.Element;
|
|
6
|
+
export declare function RemotePrompts(): React.JSX.Element | null;
|
|
@@ -29,15 +29,13 @@ function PromptDialog({ prompt, onAnswer }) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* What ssh asks while ta serve connects to a host, one question at a time, in every page that is open (the
|
|
32
|
-
* first answer counts);
|
|
33
|
-
* time (it installs Node.js there); and a notice when a connection is lost.
|
|
32
|
+
* first answer counts); and a notice when a connection is lost.
|
|
34
33
|
*/
|
|
35
34
|
export function RemotePrompts() {
|
|
36
35
|
const t = useT();
|
|
37
36
|
const [, bench] = useWorkbench();
|
|
38
37
|
const [, notices] = useNotices();
|
|
39
38
|
const [prompts, setPrompts] = React.useState([]);
|
|
40
|
-
const [steps, setSteps] = React.useState({});
|
|
41
39
|
const connected = React.useRef(new Set());
|
|
42
40
|
React.useEffect(() => bench.onRemoteEvent((event) => {
|
|
43
41
|
if (event.type === 'prompt') {
|
|
@@ -46,11 +44,7 @@ export function RemotePrompts() {
|
|
|
46
44
|
else if (event.type === 'prompt_closed') {
|
|
47
45
|
setPrompts(shown => shown.filter(prompt => prompt.promptId !== event.promptId));
|
|
48
46
|
}
|
|
49
|
-
else if (event.type === '
|
|
50
|
-
setSteps(shown => { var _a; return ({ ...shown, [event.host]: t(`ta.remote.step.${event.step}`, { host: event.host, detail: (_a = event.detail) !== null && _a !== void 0 ? _a : '' }) }); });
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
setSteps(({ [event.host]: _gone, ...rest }) => rest);
|
|
47
|
+
else if (event.type === 'connection') {
|
|
54
48
|
// Lost, not closed on purpose; a connection that failed is the caller's to tell.
|
|
55
49
|
if (!event.connected && event.error && connected.current.has(event.host)) {
|
|
56
50
|
notices.notify(t('ta.remote.lost', { host: event.host }), { level: 'warning', detail: event.error });
|
|
@@ -63,12 +57,6 @@ export function RemotePrompts() {
|
|
|
63
57
|
setPrompts(shown => shown.slice(1));
|
|
64
58
|
void bench.remote.answer(prompt.promptId, value).catch(() => undefined);
|
|
65
59
|
};
|
|
66
|
-
|
|
67
|
-
return (React.createElement(React.Fragment, null,
|
|
68
|
-
prompt && React.createElement(PromptDialog, { key: prompt.promptId, prompt: prompt, onAnswer: answer }),
|
|
69
|
-
lines.length > 0 &&
|
|
70
|
-
createPortal(React.createElement("div", { className: "ta-remote-status", role: "status" },
|
|
71
|
-
React.createElement("span", { className: "ta-spinner" }),
|
|
72
|
-
lines.join(' · ')), document.body)));
|
|
60
|
+
return prompt ? React.createElement(PromptDialog, { key: prompt.promptId, prompt: prompt, onAnswer: answer }) : null;
|
|
73
61
|
}
|
|
74
62
|
//# sourceMappingURL=remote-prompts.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TaRemoteEvent, TaRemoteStep } from '@celljs/ta-protocol';
|
|
2
|
+
/** What a host is doing that takes a while: a step of connecting, or of making it a cloud workspace. */
|
|
3
|
+
export interface RemoteStepInfo {
|
|
4
|
+
step: TaRemoteStep;
|
|
5
|
+
detail?: string;
|
|
6
|
+
}
|
|
7
|
+
/** What gives the events of TaRemoteServer: the workbench. */
|
|
8
|
+
export interface RemoteEvents {
|
|
9
|
+
onRemoteEvent(listener: (event: TaRemoteEvent) => void): () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare namespace RemoteSteps {
|
|
12
|
+
/** The steps by host after `event`: a step until the host connects, fails or its work ends. */
|
|
13
|
+
function next(steps: Readonly<Record<string, RemoteStepInfo>>, event: TaRemoteEvent): Readonly<Record<string, RemoteStepInfo>>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* What the hosts do now, by host, shown where the user looks at them (a row of Remote hosts, the picker of folders),
|
|
17
|
+
* never over the page.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useRemoteSteps(events: RemoteEvents | undefined): Readonly<Record<string, RemoteStepInfo>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export var RemoteSteps;
|
|
3
|
+
(function (RemoteSteps) {
|
|
4
|
+
/** The steps by host after `event`: a step until the host connects, fails or its work ends. */
|
|
5
|
+
function next(steps, event) {
|
|
6
|
+
if (event.type === 'progress') {
|
|
7
|
+
return { ...steps, [event.host]: { step: event.step, ...(event.detail ? { detail: event.detail } : {}) } };
|
|
8
|
+
}
|
|
9
|
+
if ((event.type === 'connection' || event.type === 'progress_end') && event.host in steps) {
|
|
10
|
+
const { [event.host]: _over, ...rest } = steps;
|
|
11
|
+
return rest;
|
|
12
|
+
}
|
|
13
|
+
return steps;
|
|
14
|
+
}
|
|
15
|
+
RemoteSteps.next = next;
|
|
16
|
+
})(RemoteSteps || (RemoteSteps = {}));
|
|
17
|
+
/**
|
|
18
|
+
* What the hosts do now, by host, shown where the user looks at them (a row of Remote hosts, the picker of folders),
|
|
19
|
+
* never over the page.
|
|
20
|
+
*/
|
|
21
|
+
export function useRemoteSteps(events) {
|
|
22
|
+
const [steps, setSteps] = React.useState({});
|
|
23
|
+
React.useEffect(() => events === null || events === void 0 ? void 0 : events.onRemoteEvent(event => setSteps(shown => RemoteSteps.next(shown, event))), [events]);
|
|
24
|
+
return steps;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=remote-steps.js.map
|
|
@@ -7,7 +7,7 @@ import { CallBar, callAction, callEndedNotice, dialogAnnouncements, talkCall, us
|
|
|
7
7
|
import { useKeyboardDismiss } from '../device/device.js';
|
|
8
8
|
import { DraftPlaces } from '../drafts/drafts-protocol.js';
|
|
9
9
|
import { TaFiles } from '../files/files-protocol.js';
|
|
10
|
-
import { useNotices, useOpenLink, usePersisted, useSessionState, useSettings, useSettingsServer } from '../hooks.js';
|
|
10
|
+
import { useNotices, useOpenLink, usePersisted, useSessionState, useSettings, useSettingsServer, useWebExtensions } from '../hooks.js';
|
|
11
11
|
import { useT } from '../i18n/use-t.js';
|
|
12
12
|
import { CodeConversation, CodeReply } from '../markdown/code-renderers.js';
|
|
13
13
|
import { ScreenUtil } from '../screen/screen-protocol.js';
|
|
@@ -33,7 +33,7 @@ import { DialogView } from './dialog-view.js';
|
|
|
33
33
|
import { useAsked, useEarlierMessages, useRowWindow } from './earlier-messages.js';
|
|
34
34
|
import { GrowBox } from './grow-box.js';
|
|
35
35
|
import { Icon } from './icon.js';
|
|
36
|
-
import { OpenLink } from './link.js';
|
|
36
|
+
import { FileMenu, OpenLink } from './link.js';
|
|
37
37
|
import { FileUrls } from './media.js';
|
|
38
38
|
import { useMessageActions } from './message-actions.js';
|
|
39
39
|
import { MessageActions } from './message-footer.js';
|
|
@@ -200,11 +200,14 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
200
200
|
text: () => { var _a; var _b; return (_b = (_a = composer.current) === null || _a === void 0 ? void 0 : _a.text()) !== null && _b !== void 0 ? _b : ''; },
|
|
201
201
|
setText: text => { var _a; return (_a = composer.current) === null || _a === void 0 ? void 0 : _a.setText(text); },
|
|
202
202
|
addFiles: files => { var _a, _b; return (_b = (_a = composer.current) === null || _a === void 0 ? void 0 : _a.addFiles) === null || _b === void 0 ? void 0 : _b.call(_a, files); },
|
|
203
|
+
shown: () => { var _a; var _b; return (_b = (_a = composer.current) === null || _a === void 0 ? void 0 : _a.shown()) !== null && _b !== void 0 ? _b : false; },
|
|
203
204
|
}), [compact]);
|
|
204
205
|
const files = useInject(TaFiles);
|
|
205
206
|
const fileUrl = React.useCallback(async (path, box) => files.loadable(ThumbnailUtil.boxed(await workspace.fileUrl(path, cwd), box)), [workspace, cwd, files]);
|
|
206
207
|
const namedPaths = React.useCallback(() => MessageUtil.namedPaths(store.state.messages), [store]);
|
|
207
208
|
const openLink = useOpenLink(cwd, namedPaths);
|
|
209
|
+
const [{ fileMenus }] = useWebExtensions();
|
|
210
|
+
const fileMenu = React.useCallback((path) => (cwd ? fileMenus.flatMap(menu => menu(LinkUtil.fileRef(cwd, path))) : []), [cwd, fileMenus]);
|
|
208
211
|
// biome-ignore lint/correctness/useExhaustiveDependencies: runs when a run starts or settles
|
|
209
212
|
React.useEffect(() => onActivity(), [state.working, onActivity]);
|
|
210
213
|
React.useEffect(() => {
|
|
@@ -366,10 +369,11 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
366
369
|
React.createElement(MessageActions.Provider, { value: messageActions },
|
|
367
370
|
React.createElement(FileUrls.Provider, { value: fileUrl },
|
|
368
371
|
React.createElement(OpenLink.Provider, { value: openLink },
|
|
369
|
-
React.createElement(
|
|
370
|
-
React.createElement(
|
|
371
|
-
React.createElement(
|
|
372
|
-
React.createElement(
|
|
372
|
+
React.createElement(FileMenu.Provider, { value: fileMenu },
|
|
373
|
+
React.createElement(MessageImages.Provider, { value: images },
|
|
374
|
+
React.createElement(CodeReply.Provider, { value: reply },
|
|
375
|
+
React.createElement(CodeConversation.Provider, { value: info === null || info === void 0 ? void 0 : info.sessionFile },
|
|
376
|
+
React.createElement(MessageList, { state: state, outbox: outbox, rows: rows })))))))))))),
|
|
373
377
|
React.createElement("div", { className: "ta-bottom" },
|
|
374
378
|
away &&
|
|
375
379
|
(asking ? (React.createElement("button", { type: "button", className: "ta-to-bottom ta-to-ask", title: t('ta.chat.toAsk', { question: asking.question }), onClick: toBottom },
|
|
@@ -38,10 +38,12 @@ export interface RowProps {
|
|
|
38
38
|
stacked?: boolean;
|
|
39
39
|
/** Set in the file shown: a bar on its left, as in an IDE. */
|
|
40
40
|
modified?: boolean;
|
|
41
|
+
/** Belongs to the row above (a setting of a host listed there): it starts under that row's label. */
|
|
42
|
+
inset?: boolean;
|
|
41
43
|
children?: React.ReactNode;
|
|
42
44
|
}
|
|
43
45
|
/** Label and description on the left, the control on the right; stacked when the control is wide. */
|
|
44
|
-
export declare function Row({ label, icon, description, stacked, modified, children }: RowProps): React.JSX.Element;
|
|
46
|
+
export declare function Row({ label, icon, description, stacked, modified, inset, children }: RowProps): React.JSX.Element;
|
|
45
47
|
/** A choice of several as a row of its own, checked on its right: a phone's Segmented when the labels are too many to fit. */
|
|
46
48
|
export declare function ChoiceRow({ label, checked, onPick }: {
|
|
47
49
|
label: string;
|
|
@@ -26,8 +26,8 @@ export function Switch({ checked, onChange, label, disabled }) {
|
|
|
26
26
|
} }));
|
|
27
27
|
}
|
|
28
28
|
/** Label and description on the left, the control on the right; stacked when the control is wide. */
|
|
29
|
-
export function Row({ label, icon, description, stacked, modified, children }) {
|
|
30
|
-
return (React.createElement("div", { className: `ta-setting-row${stacked ? ' ta-stacked' : ''}${modified ? ' ta-modified' : ''}` },
|
|
29
|
+
export function Row({ label, icon, description, stacked, modified, inset, children }) {
|
|
30
|
+
return (React.createElement("div", { className: `ta-setting-row${stacked ? ' ta-stacked' : ''}${modified ? ' ta-modified' : ''}${inset ? ' ta-inset' : ''}` },
|
|
31
31
|
icon && (React.createElement("span", { className: "ta-setting-icon", "aria-hidden": "true" },
|
|
32
32
|
React.createElement(Icon, { icon: icon, size: 16 }))),
|
|
33
33
|
(label || description) && (React.createElement("div", { className: "ta-setting-text" },
|
|
@@ -19,4 +19,4 @@ export interface WebComposerHostProps extends WebComposerProps {
|
|
|
19
19
|
* The message box as web extensions get it (`pi.ui.Composer`): text, and pictures when it takes them (shrunk within
|
|
20
20
|
* the limits given), `@` for the names they give; a failure is a notice of the page.
|
|
21
21
|
*/
|
|
22
|
-
export declare function WebComposer({ notices, placeholder, onSend, images, emoji, autoFocus, mentions, mentionLabel, actions, cwd, onPickCwd, commands, working, onStop, voiceSends, onTalkSent, onListening, after, draft, server, listDirectory, serverCwd, remote, }: WebComposerHostProps): React.JSX.Element;
|
|
22
|
+
export declare function WebComposer({ notices, placeholder, onSend, images, videos, emoji, autoFocus, mentions, mentionLabel, actions, cwd, onPickCwd, commands, working, onStop, voiceSends, onTalkSent, onListening, after, draft, server, listDirectory, serverCwd, remote, }: WebComposerHostProps): React.JSX.Element;
|
|
@@ -4,22 +4,31 @@ import { ComposerUtil } from '../util/composer.js';
|
|
|
4
4
|
import { ImageShrink } from '../util/image-shrink.js';
|
|
5
5
|
import { ComposerAddonUtil } from './composer-addon-util.js';
|
|
6
6
|
import { ComposerBox } from './composer-box.js';
|
|
7
|
+
import { ComposerTarget } from './composer-target.js';
|
|
7
8
|
import { useDirectoryCommands } from './directory-commands.js';
|
|
8
9
|
import { DirectoryButton } from './folder-picker.js';
|
|
9
10
|
/**
|
|
10
11
|
* The message box as web extensions get it (`pi.ui.Composer`): text, and pictures when it takes them (shrunk within
|
|
11
12
|
* the limits given), `@` for the names they give; a failure is a notice of the page.
|
|
12
13
|
*/
|
|
13
|
-
export function WebComposer({ notices, placeholder, onSend, images, emoji, autoFocus, mentions, mentionLabel, actions, cwd, onPickCwd, commands, working, onStop, voiceSends, onTalkSent, onListening, after, draft, server, listDirectory, serverCwd, remote, }) {
|
|
14
|
+
export function WebComposer({ notices, placeholder, onSend, images, videos, emoji, autoFocus, mentions, mentionLabel, actions, cwd, onPickCwd, commands, working, onStop, voiceSends, onTalkSent, onListening, after, draft, server, listDirectory, serverCwd, remote, }) {
|
|
14
15
|
const t = useT();
|
|
15
16
|
const language = useLanguage();
|
|
16
17
|
const [query, setQuery] = React.useState();
|
|
18
|
+
// It takes what extensions put in the box in front (WebUiAPI.addToComposer), a message quoted in a group chat say.
|
|
19
|
+
const box = React.useRef(null);
|
|
20
|
+
React.useEffect(() => ComposerTarget.set({
|
|
21
|
+
text: () => { var _a; var _b; return (_b = (_a = box.current) === null || _a === void 0 ? void 0 : _a.text()) !== null && _b !== void 0 ? _b : ''; },
|
|
22
|
+
setText: text => { var _a; return (_a = box.current) === null || _a === void 0 ? void 0 : _a.setText(text); },
|
|
23
|
+
addFiles: files => { var _a, _b; return (_b = (_a = box.current) === null || _a === void 0 ? void 0 : _a.addFiles) === null || _b === void 0 ? void 0 : _b.call(_a, files); },
|
|
24
|
+
shown: () => { var _a; var _b; return (_b = (_a = box.current) === null || _a === void 0 ? void 0 : _a.shown()) !== null && _b !== void 0 ? _b : false; },
|
|
25
|
+
}), []);
|
|
17
26
|
const found = useDirectoryCommands(server, commands ? cwd || serverCwd : undefined);
|
|
18
27
|
const listed = React.useMemo(() => found.map(command => ({ name: command.name, description: ComposerUtil.commandDescription(command, language, t) })), [found, language, t]);
|
|
19
|
-
return (React.createElement(ComposerBox, { placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t('ta.composer.label'), onSend: async (text, attached) => {
|
|
28
|
+
return (React.createElement(ComposerBox, { ref: box, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t('ta.composer.label'), onSend: async (text, attached) => {
|
|
20
29
|
const limits = typeof images === 'object' ? images : undefined;
|
|
21
30
|
await onSend(text, limits ? await Promise.all(attached.map(image => ImageShrink.shrink(image, limits))) : attached);
|
|
22
|
-
}, images: !!images, emoji: emoji, autoFocus: autoFocus, commands: listed, onMentionQuery: mentions ? setQuery : undefined, mentions: mentions && query !== undefined
|
|
31
|
+
}, images: !!images, videos: videos, emoji: emoji, autoFocus: autoFocus, commands: listed, onMentionQuery: mentions ? setQuery : undefined, mentions: mentions && query !== undefined
|
|
23
32
|
? {
|
|
24
33
|
items: ComposerUtil.commands(mentions, query).map(mention => ({
|
|
25
34
|
key: mention.name,
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import type { WebPickedVideo } from '../extension/web-api-components.js';
|
|
2
|
+
/** What was picked: the photos, and the videos when asked for. */
|
|
3
|
+
export interface PhotoPick {
|
|
4
|
+
images: File[];
|
|
5
|
+
videos: WebPickedVideo[];
|
|
6
|
+
}
|
|
1
7
|
/**
|
|
2
8
|
* The photos of the device, picked in the library itself as WeChat's Album does: the Ta app on iOS opens it at once
|
|
3
9
|
* (PHPicker, which asks for no permission), where a file field shows a menu first (Photo Library, Take Photo,
|
|
@@ -7,8 +13,10 @@ export declare namespace PhotoPicker {
|
|
|
7
13
|
/** Whether the library opens at once here. */
|
|
8
14
|
function available(): boolean;
|
|
9
15
|
/**
|
|
10
|
-
* Up to `limit` photos, in the order picked; none when the user cancels. Not timed
|
|
11
|
-
* they need, and a pick started again ends the one before with none.
|
|
16
|
+
* Up to `limit` photos (and videos, with `videos`), in the order picked; none when the user cancels. Not timed
|
|
17
|
+
* out: the user takes the time they need, and a pick started again ends the one before with none.
|
|
12
18
|
*/
|
|
13
|
-
function pick(limit: number): Promise<
|
|
19
|
+
function pick(limit: number, videos?: boolean): Promise<PhotoPick>;
|
|
20
|
+
/** Picks, the photos to `images`, the videos to `videos` (asked for only with it). */
|
|
21
|
+
function pickInto(limit: number, images: (files: File[]) => void, videos?: (videos: WebPickedVideo[]) => void): void;
|
|
14
22
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RecentShots } from './recent-shots.js';
|
|
2
|
+
import { VideoPicks } from './video-picks.js';
|
|
2
3
|
/**
|
|
3
4
|
* The photos of the device, picked in the library itself as WeChat's Album does: the Ta app on iOS opens it at once
|
|
4
5
|
* (PHPicker, which asks for no permission), where a file field shows a menu first (Photo Library, Take Photo,
|
|
@@ -17,13 +18,13 @@ export var PhotoPicker;
|
|
|
17
18
|
}
|
|
18
19
|
PhotoPicker.available = available;
|
|
19
20
|
/**
|
|
20
|
-
* Up to `limit` photos, in the order picked; none when the user cancels. Not timed
|
|
21
|
-
* they need, and a pick started again ends the one before with none.
|
|
21
|
+
* Up to `limit` photos (and videos, with `videos`), in the order picked; none when the user cancels. Not timed
|
|
22
|
+
* out: the user takes the time they need, and a pick started again ends the one before with none.
|
|
22
23
|
*/
|
|
23
|
-
function pick(limit) {
|
|
24
|
+
function pick(limit, videos = false) {
|
|
24
25
|
const photos = native();
|
|
25
26
|
if (!photos) {
|
|
26
|
-
return Promise.resolve([]);
|
|
27
|
+
return Promise.resolve({ images: [], videos: [] });
|
|
27
28
|
}
|
|
28
29
|
const id = `p${++next}`;
|
|
29
30
|
return new Promise(resolve => {
|
|
@@ -34,15 +35,31 @@ export var PhotoPicker;
|
|
|
34
35
|
}
|
|
35
36
|
globalThis.removeEventListener(RecentShots.EVENT, onEvent);
|
|
36
37
|
const images = Array.isArray(detail.images) ? detail.images : [];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const kept = Array.isArray(detail.videos) ? detail.videos : [];
|
|
39
|
+
resolve({
|
|
40
|
+
images: images
|
|
41
|
+
.filter((image) => typeof image === 'string')
|
|
42
|
+
.map((image, index) => RecentShots.file(image, `photo-${index + 1}`))
|
|
43
|
+
.filter((file) => file !== undefined),
|
|
44
|
+
videos: kept.filter((video) => typeof (video === null || video === void 0 ? void 0 : video.url) === 'string').map(VideoPicks.ofNative),
|
|
45
|
+
});
|
|
41
46
|
};
|
|
42
47
|
globalThis.addEventListener(RecentShots.EVENT, onEvent);
|
|
43
|
-
photos.postMessage({ id, action: 'pick', limit: Math.max(1, limit) });
|
|
48
|
+
photos.postMessage({ id, action: 'pick', limit: Math.max(1, limit), ...(videos ? { videos: true } : {}) });
|
|
44
49
|
});
|
|
45
50
|
}
|
|
46
51
|
PhotoPicker.pick = pick;
|
|
52
|
+
/** Picks, the photos to `images`, the videos to `videos` (asked for only with it). */
|
|
53
|
+
function pickInto(limit, images, videos) {
|
|
54
|
+
void pick(limit, !!videos).then(picked => {
|
|
55
|
+
if (picked.images.length) {
|
|
56
|
+
images(picked.images);
|
|
57
|
+
}
|
|
58
|
+
if (picked.videos.length) {
|
|
59
|
+
videos === null || videos === void 0 ? void 0 : videos(picked.videos);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
PhotoPicker.pickInto = pickInto;
|
|
47
64
|
})(PhotoPicker || (PhotoPicker = {}));
|
|
48
65
|
//# sourceMappingURL=photo-picker.js.map
|