@celljs/ta-web 4.15.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.
Files changed (89) hide show
  1. package/esm/browser/components/account-menu.js +8 -1
  2. package/esm/browser/components/app-view.js +4 -1
  3. package/esm/browser/components/face.js +7 -2
  4. package/esm/browser/components/gallery.d.ts +9 -0
  5. package/esm/browser/components/gallery.js +57 -0
  6. package/esm/browser/components/host-view.d.ts +1 -1
  7. package/esm/browser/components/lightbox.d.ts +8 -1
  8. package/esm/browser/components/lightbox.js +4 -1
  9. package/esm/browser/components/markdown.js +6 -1
  10. package/esm/browser/components/media.d.ts +12 -2
  11. package/esm/browser/components/media.js +55 -13
  12. package/esm/browser/components/message-list.js +3 -2
  13. package/esm/browser/components/notice-center.js +6 -2
  14. package/esm/browser/components/serve-restart.d.ts +26 -0
  15. package/esm/browser/components/serve-restart.js +91 -0
  16. package/esm/browser/components/session-view.js +19 -11
  17. package/esm/browser/components/settings-parts.js +14 -5
  18. package/esm/browser/extension/icons.js +3 -1
  19. package/esm/browser/i18n/locales.d.ts +15 -3
  20. package/esm/browser/i18n/messages-ja.js +12 -0
  21. package/esm/browser/i18n/messages-zh-tw.js +12 -0
  22. package/esm/browser/i18n/messages.d.ts +12 -0
  23. package/esm/browser/i18n/messages.js +24 -0
  24. package/esm/browser/style/conversation.d.ts +1 -1
  25. package/esm/browser/style/conversation.js +18 -0
  26. package/esm/browser/style/layout.d.ts +1 -1
  27. package/esm/browser/style/layout.js +2 -0
  28. package/esm/browser/style/shell.d.ts +1 -1
  29. package/esm/browser/style/shell.js +2 -0
  30. package/esm/browser/style/surfaces.d.ts +1 -1
  31. package/esm/browser/style/surfaces.js +1 -0
  32. package/esm/browser/util/desktop.d.ts +6 -1
  33. package/esm/browser/util/desktop.js +10 -0
  34. package/esm/browser/util/gallery.d.ts +18 -0
  35. package/esm/browser/util/gallery.js +123 -0
  36. package/esm/browser/util/link.d.ts +8 -0
  37. package/esm/browser/util/link.js +14 -0
  38. package/esm/browser/util/markdown.d.ts +11 -0
  39. package/esm/browser/util/markdown.js +4 -0
  40. package/esm/browser/util/thumbnail.d.ts +18 -0
  41. package/esm/browser/util/thumbnail.js +26 -0
  42. package/esm/browser/workbench-protocol.d.ts +8 -0
  43. package/esm/browser/workbench.d.ts +16 -0
  44. package/esm/browser/workbench.js +67 -0
  45. package/lib/browser/components/account-menu.js +7 -0
  46. package/lib/browser/components/app-view.js +4 -1
  47. package/lib/browser/components/face.js +7 -2
  48. package/lib/browser/components/gallery.d.ts +10 -0
  49. package/lib/browser/components/gallery.js +93 -0
  50. package/lib/browser/components/host-view.d.ts +1 -1
  51. package/lib/browser/components/lightbox.d.ts +8 -1
  52. package/lib/browser/components/lightbox.js +4 -1
  53. package/lib/browser/components/markdown.js +6 -1
  54. package/lib/browser/components/media.d.ts +12 -2
  55. package/lib/browser/components/media.js +57 -13
  56. package/lib/browser/components/message-list.js +3 -2
  57. package/lib/browser/components/notice-center.js +6 -2
  58. package/lib/browser/components/serve-restart.d.ts +27 -0
  59. package/lib/browser/components/serve-restart.js +129 -0
  60. package/lib/browser/components/session-view.js +21 -13
  61. package/lib/browser/components/settings-parts.js +13 -4
  62. package/lib/browser/extension/icons.js +2 -0
  63. package/lib/browser/i18n/locales.d.ts +15 -3
  64. package/lib/browser/i18n/messages-ja.js +12 -0
  65. package/lib/browser/i18n/messages-zh-tw.js +12 -0
  66. package/lib/browser/i18n/messages.d.ts +12 -0
  67. package/lib/browser/i18n/messages.js +24 -0
  68. package/lib/browser/style/conversation.d.ts +1 -1
  69. package/lib/browser/style/conversation.js +18 -0
  70. package/lib/browser/style/layout.d.ts +1 -1
  71. package/lib/browser/style/layout.js +2 -0
  72. package/lib/browser/style/shell.d.ts +1 -1
  73. package/lib/browser/style/shell.js +2 -0
  74. package/lib/browser/style/surfaces.d.ts +1 -1
  75. package/lib/browser/style/surfaces.js +1 -0
  76. package/lib/browser/util/desktop.d.ts +6 -1
  77. package/lib/browser/util/desktop.js +10 -0
  78. package/lib/browser/util/gallery.d.ts +19 -0
  79. package/lib/browser/util/gallery.js +126 -0
  80. package/lib/browser/util/link.d.ts +8 -0
  81. package/lib/browser/util/link.js +14 -0
  82. package/lib/browser/util/markdown.d.ts +11 -0
  83. package/lib/browser/util/markdown.js +4 -0
  84. package/lib/browser/util/thumbnail.d.ts +19 -0
  85. package/lib/browser/util/thumbnail.js +29 -0
  86. package/lib/browser/workbench-protocol.d.ts +8 -0
  87. package/lib/browser/workbench.d.ts +16 -0
  88. package/lib/browser/workbench.js +67 -0
  89. package/package.json +7 -7
@@ -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, and stays until the next notice of the
33
- * session, which says how it went or brings a new code.
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 picture = React.useRef(undefined);
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 (picture.current !== undefined) {
50
- center.dismiss(picture.current);
51
- picture.current = undefined;
54
+ if (lasting.current !== undefined) {
55
+ center.dismiss(lasting.current);
56
+ lasting.current = undefined;
52
57
  }
53
- const { text, art } = TerminalText.art(notice.message);
54
- const id = center.notify(text, { level: notice.type, art, sticky: art !== undefined });
55
- picture.current = art ? id : undefined;
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 { 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,6 +19,7 @@ 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 { ServeRestartUtil, useRestartTa } from './serve-restart.js';
22
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';
@@ -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);
@@ -317,10 +319,17 @@ export function useParts(scope, onScope, onClose, onDialog) {
317
319
  icon: Info,
318
320
  rows: workbench.server
319
321
  ? [
320
- row('version', [t('ta.settings.version'), 'version'], React.createElement(Row, { label: t('ta.settings.version') },
321
- React.createElement("span", { className: "ta-path" },
322
- "v",
323
- workbench.server.version))),
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
+ : []),
324
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 }) },
325
334
  React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('directory') },
326
335
  React.createElement(Icon, { icon: FolderOpen, size: 15 }),
@@ -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,