@celljs/ta-web 4.14.0 → 4.15.1
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-initiative.js +1 -1
- package/esm/browser/components/access-view.js +3 -2
- package/esm/browser/components/account-menu.js +10 -3
- package/esm/browser/components/app-view.js +4 -1
- package/esm/browser/components/auth-view.d.ts +1 -1
- package/esm/browser/components/auth-view.js +38 -10
- package/esm/browser/components/custom-provider-advanced.d.ts +14 -0
- package/esm/browser/components/custom-provider-advanced.js +50 -0
- package/esm/browser/components/custom-provider-util.d.ts +38 -0
- package/esm/browser/components/custom-provider-util.js +103 -0
- package/esm/browser/components/custom-provider-view.d.ts +11 -0
- package/esm/browser/components/custom-provider-view.js +181 -0
- package/esm/browser/components/face.js +7 -2
- package/esm/browser/components/gallery.d.ts +9 -0
- package/esm/browser/components/gallery.js +57 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/lightbox.d.ts +8 -1
- package/esm/browser/components/lightbox.js +4 -1
- package/esm/browser/components/markdown.js +6 -1
- package/esm/browser/components/media.d.ts +12 -2
- package/esm/browser/components/media.js +55 -13
- package/esm/browser/components/message-list.js +3 -2
- package/esm/browser/components/notice-center.js +6 -2
- package/esm/browser/components/serve-restart.d.ts +26 -0
- package/esm/browser/components/serve-restart.js +91 -0
- package/esm/browser/components/session-view.js +19 -11
- package/esm/browser/components/settings-choices.js +2 -3
- package/esm/browser/components/settings-controls.d.ts +7 -1
- package/esm/browser/components/settings-controls.js +8 -0
- package/esm/browser/components/settings-parts.js +25 -10
- package/esm/browser/components/sign-in-setup.js +3 -1
- package/esm/browser/editor/monaco-loader.js +7 -1
- package/esm/browser/extension/icons.js +3 -1
- package/esm/browser/extension/web-api-contributions.d.ts +3 -0
- package/esm/browser/extension/web-extension-api.d.ts +7 -0
- package/esm/browser/extension/web-extension-context.d.ts +2 -0
- package/esm/browser/extension/web-extension-context.js +19 -0
- package/esm/browser/game/game-loader.js +22 -2
- package/esm/browser/game/game3d-protocol.d.ts +13 -4
- package/esm/browser/i18n/locales.d.ts +68 -1
- package/esm/browser/i18n/locales.js +25 -1
- package/esm/browser/i18n/messages-ja.d.ts +2 -0
- package/esm/browser/i18n/messages-ja.js +984 -0
- package/esm/browser/i18n/messages-zh-tw.d.ts +3 -0
- package/esm/browser/i18n/messages-zh-tw.js +985 -0
- package/esm/browser/i18n/messages.d.ts +63 -0
- package/esm/browser/i18n/messages.js +126 -1
- package/esm/browser/i18n/use-t.js +3 -2
- package/esm/browser/settings/settings-protocol.d.ts +3 -2
- package/esm/browser/settings/settings-protocol.js +4 -3
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +18 -0
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +2 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +45 -1
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +2 -0
- package/esm/browser/style/surfaces.d.ts +1 -1
- package/esm/browser/style/surfaces.js +1 -0
- package/esm/browser/util/desktop.d.ts +17 -1
- package/esm/browser/util/desktop.js +24 -0
- package/esm/browser/util/gallery.d.ts +18 -0
- package/esm/browser/util/gallery.js +123 -0
- package/esm/browser/util/link.d.ts +8 -0
- package/esm/browser/util/link.js +14 -0
- package/esm/browser/util/markdown.d.ts +11 -0
- package/esm/browser/util/markdown.js +4 -0
- package/esm/browser/util/thumbnail.d.ts +18 -0
- package/esm/browser/util/thumbnail.js +26 -0
- package/esm/browser/util/voice.d.ts +20 -1
- package/esm/browser/util/voice.js +27 -11
- package/esm/browser/workbench-protocol.d.ts +8 -0
- package/esm/browser/workbench-util.d.ts +2 -0
- package/esm/browser/workbench-util.js +6 -1
- package/esm/browser/workbench.d.ts +16 -0
- package/esm/browser/workbench.js +67 -0
- package/lib/browser/assistant/assistant-initiative.js +1 -1
- package/lib/browser/components/access-view.js +3 -2
- package/lib/browser/components/account-menu.js +9 -2
- package/lib/browser/components/app-view.js +4 -1
- package/lib/browser/components/auth-view.d.ts +1 -1
- package/lib/browser/components/auth-view.js +37 -9
- package/lib/browser/components/custom-provider-advanced.d.ts +15 -0
- package/lib/browser/components/custom-provider-advanced.js +86 -0
- package/lib/browser/components/custom-provider-util.d.ts +39 -0
- package/lib/browser/components/custom-provider-util.js +106 -0
- package/lib/browser/components/custom-provider-view.d.ts +12 -0
- package/lib/browser/components/custom-provider-view.js +217 -0
- package/lib/browser/components/face.js +7 -2
- package/lib/browser/components/gallery.d.ts +10 -0
- package/lib/browser/components/gallery.js +93 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/lightbox.d.ts +8 -1
- package/lib/browser/components/lightbox.js +4 -1
- package/lib/browser/components/markdown.js +6 -1
- package/lib/browser/components/media.d.ts +12 -2
- package/lib/browser/components/media.js +57 -13
- package/lib/browser/components/message-list.js +3 -2
- package/lib/browser/components/notice-center.js +6 -2
- package/lib/browser/components/serve-restart.d.ts +27 -0
- package/lib/browser/components/serve-restart.js +129 -0
- package/lib/browser/components/session-view.js +21 -13
- package/lib/browser/components/settings-choices.js +1 -2
- package/lib/browser/components/settings-controls.d.ts +7 -1
- package/lib/browser/components/settings-controls.js +9 -0
- package/lib/browser/components/settings-parts.js +23 -8
- package/lib/browser/components/sign-in-setup.js +3 -1
- package/lib/browser/editor/monaco-loader.js +7 -1
- package/lib/browser/extension/icons.js +2 -0
- package/lib/browser/extension/web-api-contributions.d.ts +3 -0
- package/lib/browser/extension/web-extension-api.d.ts +7 -0
- package/lib/browser/extension/web-extension-context.d.ts +2 -0
- package/lib/browser/extension/web-extension-context.js +19 -0
- package/lib/browser/game/game-loader.js +22 -2
- package/lib/browser/game/game3d-protocol.d.ts +13 -4
- package/lib/browser/i18n/locales.d.ts +68 -1
- package/lib/browser/i18n/locales.js +25 -1
- package/lib/browser/i18n/messages-ja.d.ts +3 -0
- package/lib/browser/i18n/messages-ja.js +987 -0
- package/lib/browser/i18n/messages-zh-tw.d.ts +4 -0
- package/lib/browser/i18n/messages-zh-tw.js +988 -0
- package/lib/browser/i18n/messages.d.ts +63 -0
- package/lib/browser/i18n/messages.js +129 -2
- package/lib/browser/i18n/use-t.js +2 -1
- package/lib/browser/settings/settings-protocol.d.ts +3 -2
- package/lib/browser/settings/settings-protocol.js +4 -3
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +18 -0
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +2 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +45 -1
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +2 -0
- package/lib/browser/style/surfaces.d.ts +1 -1
- package/lib/browser/style/surfaces.js +1 -0
- package/lib/browser/util/desktop.d.ts +17 -1
- package/lib/browser/util/desktop.js +24 -0
- package/lib/browser/util/gallery.d.ts +19 -0
- package/lib/browser/util/gallery.js +126 -0
- package/lib/browser/util/link.d.ts +8 -0
- package/lib/browser/util/link.js +14 -0
- package/lib/browser/util/markdown.d.ts +11 -0
- package/lib/browser/util/markdown.js +4 -0
- package/lib/browser/util/thumbnail.d.ts +19 -0
- package/lib/browser/util/thumbnail.js +29 -0
- package/lib/browser/util/voice.d.ts +20 -1
- package/lib/browser/util/voice.js +27 -11
- package/lib/browser/workbench-protocol.d.ts +8 -0
- package/lib/browser/workbench-util.d.ts +2 -0
- package/lib/browser/workbench-util.js +6 -1
- package/lib/browser/workbench.d.ts +16 -0
- package/lib/browser/workbench.js +67 -0
- package/package.json +7 -7
|
@@ -3,11 +3,14 @@ import * as React from 'react';
|
|
|
3
3
|
import { useT } from '../i18n/use-t.js';
|
|
4
4
|
import { KeptRecent } from '../markdown/lazy.js';
|
|
5
5
|
import { MarkdownUtil } from '../util/markdown.js';
|
|
6
|
+
import { ThumbnailUtil } from '../util/thumbnail.js';
|
|
6
7
|
import { Icon } from './icon.js';
|
|
7
8
|
import { Lightbox } from './lightbox.js';
|
|
8
9
|
/**
|
|
9
10
|
* Where the page loads a file of the workspace from (TaWorkspaceServer.fileUrl), in the directory of the
|
|
10
|
-
* conversation that shows it; without it, files of the workspace do not show.
|
|
11
|
+
* conversation that shows it, smaller in `box` (ThumbnailUtil); without it, files of the workspace do not show.
|
|
12
|
+
* Through a relay what it gives is a blob: URL of the bytes, to which nothing can be added: the box is asked of
|
|
13
|
+
* the file before.
|
|
11
14
|
*/
|
|
12
15
|
export const FileUrls = React.createContext(undefined);
|
|
13
16
|
/**
|
|
@@ -17,35 +20,75 @@ export const FileUrls = React.createContext(undefined);
|
|
|
17
20
|
const shown = new KeptRecent('ta.media.shown', 300);
|
|
18
21
|
/** The max-height of an image of a reply (style/conversation.ts). */
|
|
19
22
|
const MEDIA_MAX_HEIGHT = 420;
|
|
20
|
-
/**
|
|
21
|
-
|
|
23
|
+
/** As wide as an image of a reply shows at most: the column of the conversation. */
|
|
24
|
+
const MEDIA_MAX_WIDTH = 720;
|
|
25
|
+
/** The box an image of a reply asks for. */
|
|
26
|
+
const IMAGE_BOX = { width: ThumbnailUtil.side(MEDIA_MAX_WIDTH), height: ThumbnailUtil.side(MEDIA_MAX_HEIGHT) };
|
|
27
|
+
/**
|
|
28
|
+
* The URL of a target: as it is, or for a path, the URL of the file, smaller in `box`; null when it cannot show,
|
|
29
|
+
* undefined while it is asked (and for no target).
|
|
30
|
+
*/
|
|
31
|
+
export function useMediaUrl(src, box) {
|
|
22
32
|
const fileUrl = React.useContext(FileUrls);
|
|
23
|
-
const path = MarkdownUtil.localPath(src);
|
|
24
|
-
const
|
|
33
|
+
const path = src === undefined ? undefined : MarkdownUtil.localPath(src);
|
|
34
|
+
const { width, height, cover } = box !== null && box !== void 0 ? box : {};
|
|
35
|
+
// What it asked for with the URL: another target (a gallery enlarged goes through its pictures) is not shown the one before.
|
|
36
|
+
const asked = `${path} ${width}x${height}${cover ? ' cover' : ''}`;
|
|
37
|
+
const [found, setFound] = React.useState();
|
|
25
38
|
React.useEffect(() => {
|
|
26
39
|
if (path === undefined) {
|
|
27
|
-
setUrl(src);
|
|
28
40
|
return;
|
|
29
41
|
}
|
|
30
42
|
if (!fileUrl) {
|
|
31
|
-
|
|
43
|
+
setFound({ asked, url: null });
|
|
32
44
|
return;
|
|
33
45
|
}
|
|
34
46
|
let current = true;
|
|
35
|
-
fileUrl(path).then(url => current &&
|
|
47
|
+
fileUrl(path, width && height ? { width, height, cover } : undefined).then(url => current && setFound({ asked, url }), () => current && setFound({ asked, url: null }));
|
|
36
48
|
return () => {
|
|
37
49
|
current = false;
|
|
38
50
|
};
|
|
39
|
-
}, [fileUrl, path,
|
|
40
|
-
|
|
51
|
+
}, [fileUrl, path, asked, width, height, cover]);
|
|
52
|
+
if (path === undefined) {
|
|
53
|
+
return src;
|
|
54
|
+
}
|
|
55
|
+
return (found === null || found === void 0 ? void 0 : found.asked) === asked ? found.url : undefined;
|
|
56
|
+
}
|
|
57
|
+
/** The URLs of targets, as `useMediaUrl` gives each, all in one `box`: the tiles of a gallery. */
|
|
58
|
+
export function useMediaUrls(sources, box) {
|
|
59
|
+
const fileUrl = React.useContext(FileUrls);
|
|
60
|
+
const key = sources.join('\n');
|
|
61
|
+
const { width, height, cover } = box !== null && box !== void 0 ? box : {};
|
|
62
|
+
const [urls, setUrls] = React.useState({});
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
let current = true;
|
|
65
|
+
for (const src of key.split('\n')) {
|
|
66
|
+
const path = MarkdownUtil.localPath(src);
|
|
67
|
+
if (path === undefined) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (!fileUrl) {
|
|
71
|
+
setUrls(known => ({ ...known, [src]: null }));
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
fileUrl(path, width && height ? { width, height, cover } : undefined).then(url => current && setUrls(known => ({ ...known, [src]: url })), () => current && setUrls(known => ({ ...known, [src]: null })));
|
|
75
|
+
}
|
|
76
|
+
return () => {
|
|
77
|
+
current = false;
|
|
78
|
+
};
|
|
79
|
+
}, [fileUrl, key, width, height, cover]);
|
|
80
|
+
return sources.map(src => (MarkdownUtil.localPath(src) === undefined ? src : urls[src]));
|
|
41
81
|
}
|
|
42
82
|
/** An image, a video or a sound a reply shows: from the web, a data URL, or a file of the workspace. */
|
|
43
83
|
export function MediaView({ src, alt }) {
|
|
44
84
|
var _a;
|
|
45
85
|
const t = useT();
|
|
46
|
-
const
|
|
86
|
+
const kind = (_a = MarkdownUtil.media(src)) !== null && _a !== void 0 ? _a : 'image';
|
|
87
|
+
// A picture of the workspace loads as large as it shows (ThumbnailUtil); enlarged, as it is.
|
|
88
|
+
const url = useMediaUrl(src, kind === 'image' ? IMAGE_BOX : undefined);
|
|
47
89
|
const [failedUrl, setFailedUrl] = React.useState();
|
|
48
90
|
const [open, setOpen] = React.useState(false);
|
|
91
|
+
const full = useMediaUrl(open && kind === 'image' ? src : undefined);
|
|
49
92
|
const [loaded, setLoaded] = React.useState(false);
|
|
50
93
|
const known = shown.get(src);
|
|
51
94
|
const failed = (!!url && url === failedUrl) || known === false;
|
|
@@ -56,7 +99,6 @@ export function MediaView({ src, alt }) {
|
|
|
56
99
|
}
|
|
57
100
|
setFailedUrl(url !== null && url !== void 0 ? url : undefined);
|
|
58
101
|
};
|
|
59
|
-
const kind = (_a = MarkdownUtil.media(src)) !== null && _a !== void 0 ? _a : 'image';
|
|
60
102
|
const size = kind === 'image' && known ? known : undefined;
|
|
61
103
|
// Of the size it had when known: its place does not change as it loads.
|
|
62
104
|
const box = size &&
|
|
@@ -92,7 +134,7 @@ export function MediaView({ src, alt }) {
|
|
|
92
134
|
}
|
|
93
135
|
setLoaded(true);
|
|
94
136
|
}, onError: setFailed })),
|
|
95
|
-
open && React.createElement(Lightbox, { src: url, alt: alt, onClose: () => setOpen(false) })));
|
|
137
|
+
open && React.createElement(Lightbox, { src: full || url, alt: alt, onClose: () => setOpen(false) })));
|
|
96
138
|
}
|
|
97
139
|
}
|
|
98
140
|
//# sourceMappingURL=media.js.map
|
|
@@ -6,6 +6,7 @@ import { WEB_ICONS } from '../extension/icons.js';
|
|
|
6
6
|
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
7
7
|
import { CodeAnswer, CodeRenderers } from '../markdown/code-renderers.js';
|
|
8
8
|
import { Recent } from '../markdown/lazy.js';
|
|
9
|
+
import { GalleryUtil } from '../util/gallery.js';
|
|
9
10
|
import { MessageUtil } from '../util/message.js';
|
|
10
11
|
import { FreshRows, ProcessUtil } from '../util/process.js';
|
|
11
12
|
import { ProgressUtil } from '../util/progress.js';
|
|
@@ -164,9 +165,9 @@ export function UserImages({ blocks, timestamp }) {
|
|
|
164
165
|
}
|
|
165
166
|
const single = images.length === 1 ? UserImageUtil.box(UserImageUtil.size(images[0].block)) : undefined;
|
|
166
167
|
const shown = open !== undefined ? sources[open] : undefined;
|
|
167
|
-
return (React.createElement("div", { className: "ta-user-images", "data-count": Math.min(images.length, 3) },
|
|
168
|
+
return (React.createElement("div", { className: "ta-user-images", "data-count": Math.min(images.length, 3), style: { '--ta-user-image-columns': GalleryUtil.columns(images.length) } },
|
|
168
169
|
images.map(({ index }, at) => (React.createElement("button", { key: index, type: "button", className: "ta-user-image", title: t('ta.markdown.enlarge'), disabled: !sources[at], onClick: () => setOpen(at) }, sources[at] ? (React.createElement("img", { className: "ta-thumb", src: sources[at], alt: "", style: single })) : (React.createElement("span", { className: "ta-thumb ta-thumb-waiting", style: single }))))),
|
|
169
|
-
open !== undefined && shown && (React.createElement(Lightbox, { src: shown, alt: "", onClose: () => setOpen(undefined), onPrevious: open > 0 && sources[open - 1] ? () => setOpen(open - 1) : undefined, onNext: open < images.length - 1 && sources[open + 1] ? () => setOpen(open + 1) : undefined }))));
|
|
170
|
+
open !== undefined && shown && (React.createElement(Lightbox, { src: shown, alt: "", count: { at: open, of: images.length }, onClose: () => setOpen(undefined), onPrevious: open > 0 && sources[open - 1] ? () => setOpen(open - 1) : undefined, onNext: open < images.length - 1 && sources[open + 1] ? () => setOpen(open + 1) : undefined }))));
|
|
170
171
|
}
|
|
171
172
|
/**
|
|
172
173
|
* What the user said, in the bubble of a message of theirs, with the pictures they sent with it in the same
|
|
@@ -74,6 +74,7 @@ function SessionToast({ notice, leaving, leave, hold, }) {
|
|
|
74
74
|
React.createElement(IconButton, { icon: X, label: t('ta.dismiss'), className: "ta-toast-close", onClick: leave })));
|
|
75
75
|
}
|
|
76
76
|
function Toast({ notice, notices }) {
|
|
77
|
+
var _a;
|
|
77
78
|
const t = useT();
|
|
78
79
|
const [leaving, setLeaving] = React.useState(false);
|
|
79
80
|
const leave = React.useCallback(() => {
|
|
@@ -94,11 +95,14 @@ function Toast({ notice, notices }) {
|
|
|
94
95
|
notice.count)),
|
|
95
96
|
notice.detail && React.createElement("div", { className: "ta-toast-detail" }, notice.detail),
|
|
96
97
|
notice.art && React.createElement(TerminalArt, { art: notice.art, className: "ta-toast-art", label: t('ta.notice.picture') }),
|
|
97
|
-
notice.action
|
|
98
|
+
((_a = notice.actions) === null || _a === void 0 ? void 0 : _a.length) ? (React.createElement("div", { className: "ta-toast-actions" }, [...notice.actions, ...(notice.action ? [notice.action] : [])].map(action => (React.createElement("button", { key: action.label, type: "button", className: "ta-toast-action", onClick: () => {
|
|
99
|
+
action.run();
|
|
100
|
+
leave();
|
|
101
|
+
} }, action.label))))) : (notice.action && (React.createElement("button", { type: "button", className: "ta-toast-action", onClick: () => {
|
|
98
102
|
var _a;
|
|
99
103
|
(_a = notice.action) === null || _a === void 0 ? void 0 : _a.run();
|
|
100
104
|
leave();
|
|
101
|
-
} }, notice.action.label))),
|
|
105
|
+
} }, notice.action.label)))),
|
|
102
106
|
React.createElement(IconButton, { icon: X, label: t('ta.dismiss'), className: "ta-toast-close", onClick: leave })));
|
|
103
107
|
}
|
|
104
108
|
function ConfirmDialog({ request, notices }) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TaServerInfo, TaServerUpdate } from '@celljs/ta-protocol';
|
|
2
|
+
export declare namespace ServeRestartUtil {
|
|
3
|
+
/** `v4.16.0`, with the commit of a build of the development channel: `v4.16.0 (695fbe1)`. */
|
|
4
|
+
function label(build: {
|
|
5
|
+
version: string;
|
|
6
|
+
build?: string;
|
|
7
|
+
}): string;
|
|
8
|
+
function key(update: TaServerUpdate): string;
|
|
9
|
+
/** Whether the page may restart Ta: the owner, of a Ta service that can restart itself. */
|
|
10
|
+
function restartable(server: TaServerInfo | undefined): boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface RestartTa {
|
|
13
|
+
/** The page may restart Ta. */
|
|
14
|
+
can: boolean;
|
|
15
|
+
restarting: boolean;
|
|
16
|
+
/** Another build installed, which a restart runs. */
|
|
17
|
+
update?: TaServerUpdate;
|
|
18
|
+
/** Asks the user first, unless they already said so (the button of the notice of an update). */
|
|
19
|
+
restart(ask?: boolean): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function useRestartTa(): RestartTa;
|
|
22
|
+
/**
|
|
23
|
+
* Tells of what restarting Ta is about, in a corner: another build installed (an update of Ta Desktop, `npm i -g`, a
|
|
24
|
+
* build of the repository), with Restart and Later, once for each build; Ta restarting, then back with its version.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ServeRestartNotices(): null;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useNotices, useWorkbench } from '../hooks.js';
|
|
3
|
+
import { useT } from '../i18n/use-t.js';
|
|
4
|
+
import { storage } from '../workbench-util.js';
|
|
5
|
+
/** The build installed that the user put off restarting for (Later): not asked about again on this device. */
|
|
6
|
+
const LATER_KEY = 'ta.update.later';
|
|
7
|
+
export var ServeRestartUtil;
|
|
8
|
+
(function (ServeRestartUtil) {
|
|
9
|
+
/** `v4.16.0`, with the commit of a build of the development channel: `v4.16.0 (695fbe1)`. */
|
|
10
|
+
function label(build) {
|
|
11
|
+
return `v${build.version}${build.build ? ` (${build.build})` : ''}`;
|
|
12
|
+
}
|
|
13
|
+
ServeRestartUtil.label = label;
|
|
14
|
+
function key(update) {
|
|
15
|
+
var _a;
|
|
16
|
+
return `${update.version}+${(_a = update.build) !== null && _a !== void 0 ? _a : ''}`;
|
|
17
|
+
}
|
|
18
|
+
ServeRestartUtil.key = key;
|
|
19
|
+
/** Whether the page may restart Ta: the owner, of a Ta service that can restart itself. */
|
|
20
|
+
function restartable(server) {
|
|
21
|
+
return !!server && !server.member && server.restartable === true;
|
|
22
|
+
}
|
|
23
|
+
ServeRestartUtil.restartable = restartable;
|
|
24
|
+
})(ServeRestartUtil || (ServeRestartUtil = {}));
|
|
25
|
+
export function useRestartTa() {
|
|
26
|
+
const t = useT();
|
|
27
|
+
const [{ server, restarting }, workbench] = useWorkbench();
|
|
28
|
+
const [, notices] = useNotices();
|
|
29
|
+
const restart = React.useCallback(async (ask = true) => {
|
|
30
|
+
if (ask && !(await notices.confirm({ title: t('ta.restart.confirm'), message: t('ta.restart.detail'), confirmLabel: t('ta.restart') }))) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
await workbench.restartServer().catch(error => notices.error(error));
|
|
34
|
+
}, [t, notices, workbench]);
|
|
35
|
+
const can = ServeRestartUtil.restartable(server);
|
|
36
|
+
return { can, restarting: !!restarting, update: can ? server === null || server === void 0 ? void 0 : server.update : undefined, restart };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Tells of what restarting Ta is about, in a corner: another build installed (an update of Ta Desktop, `npm i -g`, a
|
|
40
|
+
* build of the repository), with Restart and Later, once for each build; Ta restarting, then back with its version.
|
|
41
|
+
*/
|
|
42
|
+
export function ServeRestartNotices() {
|
|
43
|
+
const t = useT();
|
|
44
|
+
const [{ server }] = useWorkbench();
|
|
45
|
+
const [, notices] = useNotices();
|
|
46
|
+
const { update, restarting, restart } = useRestartTa();
|
|
47
|
+
const told = React.useRef(undefined);
|
|
48
|
+
const key = update && ServeRestartUtil.key(update);
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
if (!update || !key || restarting || ((_a = told.current) === null || _a === void 0 ? void 0 : _a.key) === key || ((_b = storage()) === null || _b === void 0 ? void 0 : _b.getItem(LATER_KEY)) === key) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
told.current = {
|
|
55
|
+
key,
|
|
56
|
+
id: notices.notify(t('ta.update.ready', { version: ServeRestartUtil.label(update) }), {
|
|
57
|
+
detail: t('ta.update.readyDetail'),
|
|
58
|
+
key: 'ta-serve-update',
|
|
59
|
+
sticky: true,
|
|
60
|
+
actions: [{ label: t('ta.update.later'), run: () => { var _a; return (_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(LATER_KEY, key); } }],
|
|
61
|
+
action: { label: t('ta.restart'), run: () => void restart(false) },
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
}, [update, key, restarting, notices, restart, t]);
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
// Restarted, or put in place some other way: nothing to restart for any more.
|
|
67
|
+
if (!key && told.current) {
|
|
68
|
+
notices.dismiss(told.current.id);
|
|
69
|
+
told.current = undefined;
|
|
70
|
+
}
|
|
71
|
+
}, [key, notices]);
|
|
72
|
+
const restartingId = React.useRef(undefined);
|
|
73
|
+
// Read once the restart ended: a server read again meanwhile says nothing.
|
|
74
|
+
const serverNow = React.useRef(server);
|
|
75
|
+
serverNow.current = server;
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (restarting) {
|
|
78
|
+
restartingId.current = notices.notify(t('ta.restart.restarting'), { key: 'ta-serve-restart', sticky: true });
|
|
79
|
+
}
|
|
80
|
+
else if (restartingId.current !== undefined) {
|
|
81
|
+
notices.dismiss(restartingId.current);
|
|
82
|
+
restartingId.current = undefined;
|
|
83
|
+
const back = serverNow.current;
|
|
84
|
+
if (back) {
|
|
85
|
+
notices.notify(t('ta.restart.done', { version: ServeRestartUtil.label(back) }), { level: 'success', key: 'ta-serve-restart' });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, [restarting, notices, t]);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=serve-restart.js.map
|
|
@@ -7,8 +7,10 @@ import { TaFiles } from '../files/files-protocol.js';
|
|
|
7
7
|
import { useNotices, useOpenLink, usePersisted, useSessionState, useSettings, useSettingsServer } from '../hooks.js';
|
|
8
8
|
import { useT } from '../i18n/use-t.js';
|
|
9
9
|
import { CodeReply } from '../markdown/code-renderers.js';
|
|
10
|
+
import { LinkUtil } from '../util/link.js';
|
|
10
11
|
import { MessageUtil } from '../util/message.js';
|
|
11
12
|
import { TerminalText } from '../util/terminal-text.js';
|
|
13
|
+
import { ThumbnailUtil } from '../util/thumbnail.js';
|
|
12
14
|
import { TaWorkbench } from '../workbench-protocol.js';
|
|
13
15
|
import { ChatAskUtil, LET_GO_ASKS } from './chat-asks.js';
|
|
14
16
|
import { Composer } from './composer.js';
|
|
@@ -29,14 +31,17 @@ import { TerminalArt } from './terminal-art.js';
|
|
|
29
31
|
import { useStopTimes } from './use-stop-times.js';
|
|
30
32
|
/**
|
|
31
33
|
* What the extensions of the session say with `notify` goes to the notices of the page; what was said before it
|
|
32
|
-
* opened stays quiet. A picture in it (a QR code to sign in) is drawn,
|
|
33
|
-
* session, which says how it went or
|
|
34
|
+
* opened stays quiet. A picture in it (a QR code to sign in) is drawn, a web address in it (a page to sign in on)
|
|
35
|
+
* is a button that opens it, and either stays until the next notice of the session, which says how it went or
|
|
36
|
+
* brings a new one.
|
|
34
37
|
*/
|
|
35
38
|
function useSessionNotices(store, notices) {
|
|
39
|
+
const t = useT();
|
|
36
40
|
const [, center] = useNotices();
|
|
41
|
+
const openLink = useOpenLink(undefined);
|
|
37
42
|
// Of the store shown: one that took the place of another (attached for what the device showed) starts quiet too.
|
|
38
43
|
const seen = React.useRef(undefined);
|
|
39
|
-
const
|
|
44
|
+
const lasting = React.useRef(undefined);
|
|
40
45
|
React.useEffect(() => {
|
|
41
46
|
var _a;
|
|
42
47
|
if (((_a = seen.current) === null || _a === void 0 ? void 0 : _a.store) !== store) {
|
|
@@ -46,16 +51,19 @@ function useSessionNotices(store, notices) {
|
|
|
46
51
|
for (const notice of notices) {
|
|
47
52
|
if (!seen.current.ids.has(notice.id)) {
|
|
48
53
|
seen.current.ids.add(notice.id);
|
|
49
|
-
if (
|
|
50
|
-
center.dismiss(
|
|
51
|
-
|
|
54
|
+
if (lasting.current !== undefined) {
|
|
55
|
+
center.dismiss(lasting.current);
|
|
56
|
+
lasting.current = undefined;
|
|
52
57
|
}
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
58
|
+
const art = TerminalText.art(notice.message);
|
|
59
|
+
const { text, url } = LinkUtil.noticeLink(art.text);
|
|
60
|
+
const action = url ? { label: t('ta.notice.openLink'), run: () => openLink({ type: 'url', url }, false) } : undefined;
|
|
61
|
+
const keep = art.art !== undefined || url !== undefined;
|
|
62
|
+
const id = center.notify(text, { level: notice.type, art: art.art, action, sticky: keep });
|
|
63
|
+
lasting.current = keep ? id : undefined;
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
|
-
}, [store, notices, center]);
|
|
66
|
+
}, [store, notices, center, t, openLink]);
|
|
59
67
|
}
|
|
60
68
|
/** What an extension shows above or below the message box (`setWidget`): its lines as a terminal draws them, a picture in them drawn. */
|
|
61
69
|
function WidgetView({ lines }) {
|
|
@@ -123,7 +131,7 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
123
131
|
}
|
|
124
132
|
}, [draftText]);
|
|
125
133
|
const files = useInject(TaFiles);
|
|
126
|
-
const fileUrl = React.useCallback(async (path) => files.loadable(await workspace.fileUrl(path, cwd)), [workspace, cwd, files]);
|
|
134
|
+
const fileUrl = React.useCallback(async (path, box) => files.loadable(ThumbnailUtil.boxed(await workspace.fileUrl(path, cwd), box)), [workspace, cwd, files]);
|
|
127
135
|
const namedPaths = React.useCallback(() => MessageUtil.namedPaths(store.state.messages), [store]);
|
|
128
136
|
const openLink = useOpenLink(cwd, namedPaths);
|
|
129
137
|
// biome-ignore lint/correctness/useExhaustiveDependencies: runs when a run starts or settles
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TaPackageTextUtil } from '@celljs/ta-protocol';
|
|
1
|
+
import { TaLanguageUtil, TaPackageTextUtil } from '@celljs/ta-protocol';
|
|
2
2
|
import { Box, Globe, Layers, MessagesSquare, Monitor, Moon, Puzzle, RefreshCw, Sun, Wrench } from 'lucide-react';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { WEB_ICONS } from '../extension/icons.js';
|
|
@@ -20,8 +20,7 @@ export const FONT_SIZES = [
|
|
|
20
20
|
];
|
|
21
21
|
export const LANGUAGES = [
|
|
22
22
|
{ value: 'system', icon: Globe, label: 'ta.settings.language.system' },
|
|
23
|
-
{ value
|
|
24
|
-
{ value: 'en-US', label: 'English' },
|
|
23
|
+
...TaLanguageUtil.ALL.map(value => ({ value, label: TaLanguageUtil.NAMES[value] })),
|
|
25
24
|
];
|
|
26
25
|
/** The model has the icon of the + menu's model (ModelPicker), the others their own. */
|
|
27
26
|
export const GROUP_ICONS = { model: Box, conversation: MessagesSquare, context: Layers, tools: Wrench };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LucideIcon } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { MessageId } from '../i18n/messages.js';
|
|
4
4
|
import { type Glyph } from './icon.js';
|
|
@@ -42,6 +42,12 @@ export interface RowProps {
|
|
|
42
42
|
}
|
|
43
43
|
/** Label and description on the left, the control on the right; stacked when the control is wide. */
|
|
44
44
|
export declare function Row({ label, icon, description, stacked, modified, children }: RowProps): React.JSX.Element;
|
|
45
|
+
/** 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
|
+
export declare function ChoiceRow({ label, checked, onPick }: {
|
|
47
|
+
label: string;
|
|
48
|
+
checked: boolean;
|
|
49
|
+
onPick(): void;
|
|
50
|
+
}): React.JSX.Element;
|
|
45
51
|
/** A list of the settings with nothing in it yet: a quiet line in the middle of the row. */
|
|
46
52
|
export declare function EmptyRow({ title, hint, picture }: {
|
|
47
53
|
title: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Check } from 'lucide-react';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { useT } from '../i18n/use-t.js';
|
|
3
4
|
import { AgentSettingsUtil, ShortcutUtil } from '../settings/agent-settings.js';
|
|
@@ -34,6 +35,13 @@ export function Row({ label, icon, description, stacked, modified, children }) {
|
|
|
34
35
|
description && React.createElement("span", { className: "ta-setting-description" }, description))),
|
|
35
36
|
children && React.createElement("div", { className: "ta-setting-control" }, children)));
|
|
36
37
|
}
|
|
38
|
+
/** 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. */
|
|
39
|
+
export function ChoiceRow({ label, checked, onPick }) {
|
|
40
|
+
return (React.createElement("button", { type: "button", "aria-pressed": checked, className: "ta-setting-row ta-setting-choice", onClick: onPick },
|
|
41
|
+
React.createElement("span", { className: "ta-setting-text" },
|
|
42
|
+
React.createElement("span", { className: "ta-setting-label" }, label)),
|
|
43
|
+
checked && React.createElement(Icon, { icon: Check, size: 18, className: "ta-setting-check" })));
|
|
44
|
+
}
|
|
37
45
|
/** A list of the settings with nothing in it yet: a quiet line in the middle of the row. */
|
|
38
46
|
export function EmptyRow({ title, hint, picture }) {
|
|
39
47
|
return (React.createElement("div", { className: "ta-setting-row" },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Blocks, Bot, Cloud, Compass, FolderOpen, Info, Keyboard, KeyRound, Languages, Link2, LogOut, MessagesSquare, Palette, Puzzle, RefreshCw, Server, ShieldCheck, Smartphone, Trash2, Volume2, Wrench, } from 'lucide-react';
|
|
1
|
+
import { Blocks, Bot, Cloud, Compass, FolderOpen, Info, Keyboard, KeyRound, Languages, Link2, LogOut, MessagesSquare, Palette, Puzzle, RefreshCw, RotateCw, Server, ShieldCheck, Smartphone, Trash2, Volume2, Wrench, } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useDevice } from '../device/device.js';
|
|
4
4
|
import { ExtensionBoundary } from '../extension/extension-view.js';
|
|
@@ -19,7 +19,8 @@ import { useLaunchRows } from './launch-settings.js';
|
|
|
19
19
|
import { SettingsModelPicker } from './model-picker.js';
|
|
20
20
|
import { RelayServices } from './relay-services.js';
|
|
21
21
|
import { RemoteHosts } from './remote-hosts.js';
|
|
22
|
-
import {
|
|
22
|
+
import { ServeRestartUtil, useRestartTa } from './serve-restart.js';
|
|
23
|
+
import { ChoiceRow, EmptyRow, Keys, Row, row, Segmented, Switch } from './settings-controls.js';
|
|
23
24
|
import { SignInSetupSettings, useSignInConfig } from './sign-in-setup.js';
|
|
24
25
|
import { TrustedDomains } from './trusted-domains.js';
|
|
25
26
|
import { VoicePicker } from './voice-picker.js';
|
|
@@ -41,6 +42,7 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
41
42
|
const access = useAccess();
|
|
42
43
|
const signInConfig = useSignInConfig();
|
|
43
44
|
const gateway = useGateway();
|
|
45
|
+
const restartTa = useRestartTa();
|
|
44
46
|
// As the menu of the account (useAccountEntries): a finger has no keys to learn; a phone is not the computer
|
|
45
47
|
// that pairs phones, and signs out at the foot of Me.
|
|
46
48
|
const touch = useDevice(device => device.touch);
|
|
@@ -90,10 +92,16 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
90
92
|
id: 'language',
|
|
91
93
|
title: t('ta.settings.language'),
|
|
92
94
|
icon: Languages,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
// A phone has no room for five names side by side: a row each, as its own settings have them.
|
|
96
|
+
rows: handheld
|
|
97
|
+
? LANGUAGES.map(choice => {
|
|
98
|
+
const label = choice.label.startsWith('ta.') ? t(choice.label) : choice.label;
|
|
99
|
+
return row(`language:${choice.value}`, [t('ta.settings.displayLanguage'), 'language', label], React.createElement(ChoiceRow, { label: label, checked: settings.language === choice.value, onPick: () => store.update({ language: choice.value }) }));
|
|
100
|
+
})
|
|
101
|
+
: [
|
|
102
|
+
row('language', [t('ta.settings.displayLanguage'), 'language'], React.createElement(Row, { label: t('ta.settings.displayLanguage'), stacked: true },
|
|
103
|
+
React.createElement(Segmented, { label: t('ta.settings.displayLanguage'), value: settings.language, choices: LANGUAGES, onChange: language => store.update({ language }) }))),
|
|
104
|
+
],
|
|
97
105
|
},
|
|
98
106
|
{
|
|
99
107
|
id: 'navigation',
|
|
@@ -311,10 +319,17 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
311
319
|
icon: Info,
|
|
312
320
|
rows: workbench.server
|
|
313
321
|
? [
|
|
314
|
-
row('version', [t('ta.settings.version'), 'version'], React.createElement(Row, { label: t('ta.settings.version') },
|
|
315
|
-
React.createElement("span", { className: "ta-path" },
|
|
316
|
-
|
|
317
|
-
|
|
322
|
+
row('version', [t('ta.settings.version'), 'version'], React.createElement(Row, { label: t('ta.settings.version'), description: restartTa.update && t('ta.update.ready', { version: ServeRestartUtil.label(restartTa.update) }) },
|
|
323
|
+
React.createElement("span", { className: "ta-path" }, ServeRestartUtil.label(workbench.server)))),
|
|
324
|
+
...(restartTa.can
|
|
325
|
+
? [
|
|
326
|
+
row('restart', [t('ta.restart'), t('ta.restart.description'), 'restart', 'update'], React.createElement(Row, { label: t('ta.restart'), description: t('ta.restart.description') },
|
|
327
|
+
React.createElement("button", { type: "button", className: `ta-button${restartTa.update ? ' ta-primary' : ''}`, disabled: restartTa.restarting, onClick: () => void restartTa.restart() },
|
|
328
|
+
restartTa.restarting ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: RotateCw, size: 15 }),
|
|
329
|
+
' ',
|
|
330
|
+
t('ta.restart.button')))),
|
|
331
|
+
]
|
|
332
|
+
: []),
|
|
318
333
|
row('cwd', [t('ta.settings.cwd'), workbench.server.cwd], React.createElement(Row, { label: t('ta.settings.cwd'), description: t('ta.settings.cwdDescription', { path: workbench.server.cwd }) },
|
|
319
334
|
React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('directory') },
|
|
320
335
|
React.createElement(Icon, { icon: FolderOpen, size: 15 }),
|
|
@@ -94,7 +94,9 @@ export function SignInSetupSettings({ config, onChange }) {
|
|
|
94
94
|
? t('ta.signInSetup.on', { id: (_b = (_a = setup.fields.clientId) !== null && _a !== void 0 ? _a : setup.fields.appId) !== null && _b !== void 0 ? _b : '' })
|
|
95
95
|
: setup.source
|
|
96
96
|
? t('ta.signInSetup.incomplete')
|
|
97
|
-
:
|
|
97
|
+
: setup.device
|
|
98
|
+
? t('ta.signInSetup.device')
|
|
99
|
+
: t('ta.signInSetup.off');
|
|
98
100
|
return (React.createElement(Row, { key: setup.id, label: React.createElement("span", { className: "ta-sign-in-name" },
|
|
99
101
|
React.createElement(SignInMark, { provider: setup.id, size: 15 }),
|
|
100
102
|
" ",
|
|
@@ -129,10 +129,16 @@ export var MonacoLoader;
|
|
|
129
129
|
}
|
|
130
130
|
MonacoLoader.load = load;
|
|
131
131
|
async function start(language) {
|
|
132
|
+
// Sets the words Monaco reads as its modules load.
|
|
132
133
|
if (language === 'zh-CN') {
|
|
133
|
-
// Sets the words Monaco reads as its modules load.
|
|
134
134
|
await import('monaco-editor/nls/lang/zh-cn.js');
|
|
135
135
|
}
|
|
136
|
+
else if (language === 'zh-TW') {
|
|
137
|
+
await import('monaco-editor/nls/lang/zh-tw.js');
|
|
138
|
+
}
|
|
139
|
+
else if (language === 'ja-JP') {
|
|
140
|
+
await import('monaco-editor/nls/lang/ja.js');
|
|
141
|
+
}
|
|
136
142
|
return (await import('./monaco.js')).monaco;
|
|
137
143
|
}
|
|
138
144
|
})(MonacoLoader || (MonacoLoader = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlarmClock, Aperture, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, BellOff, BookOpen, Bot, Building2, CaseSensitive, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, CircleHelp, Clipboard, Clock, Cloud, Code, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Crown, Database, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, Heart, House, Image, ImagePlus, Info, KeyRound, Laptop, LayoutDashboard, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MapIcon, Megaphone, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MonitorSmartphone, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, Radar, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Send, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, X, } from 'lucide-react';
|
|
1
|
+
import { AlarmClock, Aperture, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, BellOff, BookOpen, Bot, Box, Building2, CaseSensitive, ChartSpline, Check, ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown, CircleAlert, CircleHelp, Clipboard, Clock, Cloud, Code, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Crown, Database, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, Folder, FolderInput, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, GitBranch, GitCommitHorizontal, Globe, Grip, Hash, Heart, House, Image, ImagePlus, Info, KeyRound, Laptop, LayoutDashboard, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, MapIcon, Megaphone, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minus, MonitorSmartphone, MousePointerClick, PackageOpen, Paperclip, Pencil, Pin, PinOff, Play, Plus, Power, Puzzle, QrCode, Radar, RefreshCw, Regex, Replace, ReplaceAll, RotateCcw, Rows2, Save, ScanLine, ScrollText, Search, Send, Server, Share2, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Text, Trash2, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, X, } from 'lucide-react';
|
|
2
2
|
/** The icons a web extension gets as `pi.ui.icons`; names are lucide's. Only add: removing one breaks extensions. */
|
|
3
3
|
export const WEB_ICONS = Object.freeze({
|
|
4
4
|
AlarmClock,
|
|
@@ -12,8 +12,10 @@ export const WEB_ICONS = Object.freeze({
|
|
|
12
12
|
BellOff,
|
|
13
13
|
BookOpen,
|
|
14
14
|
Bot,
|
|
15
|
+
Box,
|
|
15
16
|
Building2,
|
|
16
17
|
CaseSensitive,
|
|
18
|
+
ChartSpline,
|
|
17
19
|
Check,
|
|
18
20
|
ChevronDown,
|
|
19
21
|
ChevronRight,
|
|
@@ -144,9 +144,12 @@ export type WebInitiativeLevel = 'off' | 'digest' | 'ask' | 'act';
|
|
|
144
144
|
export interface WebInitiativeKind {
|
|
145
145
|
/** `<area>.<verb>`: `double.start-task`. */
|
|
146
146
|
id: string;
|
|
147
|
+
/** Traditional Chinese (`tw`) falls back to `zh`, Japanese (`ja`) to `en`. */
|
|
147
148
|
title: {
|
|
148
149
|
en: string;
|
|
149
150
|
zh: string;
|
|
151
|
+
tw?: string;
|
|
152
|
+
ja?: string;
|
|
150
153
|
};
|
|
151
154
|
/** What it does can be taken back: one that cannot never goes past `ask`. */
|
|
152
155
|
reversible: boolean;
|
|
@@ -44,6 +44,13 @@ export interface WebExtensionAPI {
|
|
|
44
44
|
* ta serve. `byUrl` says which way it is; the bytes come sealed, end to end, when it is not.
|
|
45
45
|
*/
|
|
46
46
|
readonly files: TaFiles;
|
|
47
|
+
/**
|
|
48
|
+
* A URL the page can load for a file of the extension's own package, by its path there (`models/rex.glb`): a model
|
|
49
|
+
* of `ui.Game3D`, a picture, a sound. Where the page cannot load the files of ta serve by their URL (`files.byUrl`)
|
|
50
|
+
* it is a `blob:` of the bytes. Throws for a path outside the package, and in a web extension that comes with the
|
|
51
|
+
* page. Newer than some Ta apps: `pi.fileUrl?.(…)`.
|
|
52
|
+
*/
|
|
53
|
+
fileUrl(path: string): Promise<string>;
|
|
47
54
|
/** The other machines of `ssh://` directories (TaLocation): their ports, for a page served there. */
|
|
48
55
|
readonly remote: TaRemoteServer;
|
|
49
56
|
/** pi's settings of ta (`settings.json`): `getSettings(cwd)` also lists the models with credentials, for a model picker. */
|
|
@@ -50,6 +50,8 @@ export declare class WebExtensionContext {
|
|
|
50
50
|
static marked(server: TaServer, mark: (text: string) => string): TaServer;
|
|
51
51
|
/** A renderer of code whose `send` (a choice tapped in it) says it came from the extension. */
|
|
52
52
|
static replying(Renderer: React.ComponentType<WebCodeRendererProps>, mark: (text: string) => string): React.ComponentType<WebCodeRendererProps>;
|
|
53
|
+
/** A path of a file of a package, relative to it and inside it (`./models/rex.glb`, `models\rex.glb`: `models/rex.glb`). */
|
|
54
|
+
static packagePath(path: string): string;
|
|
53
55
|
/** Monaco and the games in the theme and language of the settings, the same component for every extension. */
|
|
54
56
|
protected readonly codeEditor: (props: CodeEditorProps) => React.FunctionComponentElement<CodeEditorProps & {
|
|
55
57
|
settings: TaSettings;
|
|
@@ -101,6 +101,17 @@ export class WebExtensionContext {
|
|
|
101
101
|
return React.createElement(Renderer, { ...props, send: marked });
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
+
/** A path of a file of a package, relative to it and inside it (`./models/rex.glb`, `models\rex.glb`: `models/rex.glb`). */
|
|
105
|
+
static packagePath(path) {
|
|
106
|
+
const parts = path
|
|
107
|
+
.replace(/\\/g, '/')
|
|
108
|
+
.split('/')
|
|
109
|
+
.filter(part => part !== '' && part !== '.');
|
|
110
|
+
if (/^([a-z]:)?[\\/]/i.test(path) || parts.length === 0 || parts.includes('..')) {
|
|
111
|
+
throw new Error(`Not a file inside the package: ${path}`);
|
|
112
|
+
}
|
|
113
|
+
return parts.join('/');
|
|
114
|
+
}
|
|
104
115
|
create(run) {
|
|
105
116
|
const { host } = this;
|
|
106
117
|
const { workbench, files } = host;
|
|
@@ -137,6 +148,14 @@ export class WebExtensionContext {
|
|
|
137
148
|
get files() {
|
|
138
149
|
return files;
|
|
139
150
|
},
|
|
151
|
+
fileUrl: path => live(async () => {
|
|
152
|
+
var _a;
|
|
153
|
+
const root = (_a = run.loaded.info) === null || _a === void 0 ? void 0 : _a.root;
|
|
154
|
+
if (!root) {
|
|
155
|
+
throw new Error(`The web extension ${run.loaded.name} has no files of its own here.`);
|
|
156
|
+
}
|
|
157
|
+
return files.loadable(await workbench.workspace.fileUrl(WebExtensionContext.packagePath(path), root));
|
|
158
|
+
}),
|
|
140
159
|
get remote() {
|
|
141
160
|
return workbench.remote;
|
|
142
161
|
},
|