@celljs/ta-web 4.39.0 → 4.40.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.
Files changed (43) hide show
  1. package/esm/browser/chat/chat-shown.js +2 -2
  2. package/esm/browser/components/busy.d.ts +5 -0
  3. package/esm/browser/components/busy.js +17 -0
  4. package/esm/browser/extension/icons.js +15 -1
  5. package/esm/browser/extension/web-api-hosts.d.ts +22 -0
  6. package/esm/browser/extension/web-api-hosts.js +2 -0
  7. package/esm/browser/extension/web-api-spec.js +2 -0
  8. package/esm/browser/extension/web-extension-api.d.ts +7 -0
  9. package/esm/browser/extension/web-extension-context.js +4 -3
  10. package/esm/browser/extension/web-file-drag.d.ts +3 -0
  11. package/esm/browser/extension/web-file-drag.js +4 -0
  12. package/esm/browser/extension/web-hosts.d.ts +7 -0
  13. package/esm/browser/extension/web-hosts.js +29 -0
  14. package/esm/browser/hosts.d.ts +2 -0
  15. package/esm/browser/hosts.js +9 -0
  16. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  17. package/esm/browser/style/conversation.d.ts +1 -1
  18. package/esm/browser/style/conversation.js +2 -2
  19. package/esm/browser/workbench-hosts.d.ts +1 -0
  20. package/esm/browser/workbench-hosts.js +9 -0
  21. package/esm/browser/workbench-protocol.d.ts +5 -0
  22. package/lib/browser/chat/chat-shown.js +2 -2
  23. package/lib/browser/components/busy.d.ts +5 -0
  24. package/lib/browser/components/busy.js +17 -0
  25. package/lib/browser/extension/icons.js +14 -0
  26. package/lib/browser/extension/web-api-hosts.d.ts +23 -0
  27. package/lib/browser/extension/web-api-hosts.js +3 -0
  28. package/lib/browser/extension/web-api-spec.js +2 -0
  29. package/lib/browser/extension/web-extension-api.d.ts +7 -0
  30. package/lib/browser/extension/web-extension-context.js +4 -3
  31. package/lib/browser/extension/web-file-drag.d.ts +4 -0
  32. package/lib/browser/extension/web-file-drag.js +7 -0
  33. package/lib/browser/extension/web-hosts.d.ts +8 -0
  34. package/lib/browser/extension/web-hosts.js +32 -0
  35. package/lib/browser/hosts.d.ts +2 -0
  36. package/lib/browser/hosts.js +9 -0
  37. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  38. package/lib/browser/style/conversation.d.ts +1 -1
  39. package/lib/browser/style/conversation.js +2 -2
  40. package/lib/browser/workbench-hosts.d.ts +1 -0
  41. package/lib/browser/workbench-hosts.js +9 -0
  42. package/lib/browser/workbench-protocol.d.ts +5 -0
  43. package/package.json +7 -7
@@ -202,8 +202,8 @@ export class ChatShown {
202
202
  this.unfollow = [
203
203
  store.subscribe(state => {
204
204
  if (state.closed) {
205
- // Closed by another client.
206
- void this.enqueue(() => (this.current.store === store ? this.replace() : Promise.resolve()));
205
+ // Closed by another client; or it goes on elsewhere (to the cloud and back): followed there, opened again from its file.
206
+ void this.enqueue(() => (this.current.store === store ? (state.reopen ? this.recover() : this.replace()) : Promise.resolve()));
207
207
  }
208
208
  else if (working && !state.working) {
209
209
  void this.packages.settled(store);
@@ -3,6 +3,11 @@ import * as React from 'react';
3
3
  export type BusyRun = <T>(action: () => T | PromiseLike<T>) => Promise<T | undefined>;
4
4
  export declare namespace BusyUtil {
5
5
  function thenable(value: unknown): value is PromiseLike<unknown>;
6
+ /**
7
+ * The button of Ta's look (`ta-button`) the click that is being handled was on, unless it is marked busy already:
8
+ * a button handing its click to `run` that only goes disabled would show nothing else for as long as it waits.
9
+ */
10
+ function clicked(): Element | undefined;
6
11
  }
7
12
  /**
8
13
  * What waits on something slow (ta serve, code to load): `run` marks it busy until what it returns settles, and
@@ -5,6 +5,19 @@ export var BusyUtil;
5
5
  return !!value && typeof value.then === 'function';
6
6
  }
7
7
  BusyUtil.thenable = thenable;
8
+ /**
9
+ * The button of Ta's look (`ta-button`) the click that is being handled was on, unless it is marked busy already:
10
+ * a button handing its click to `run` that only goes disabled would show nothing else for as long as it waits.
11
+ */
12
+ function clicked() {
13
+ const event = globalThis.event;
14
+ if ((event === null || event === void 0 ? void 0 : event.type) !== 'click' || typeof Element === 'undefined' || !(event.target instanceof Element)) {
15
+ return undefined;
16
+ }
17
+ const button = event.target.closest('.ta-button');
18
+ return button && !button.classList.contains('ta-busy') ? button : undefined;
19
+ }
20
+ BusyUtil.clicked = clicked;
8
21
  })(BusyUtil || (BusyUtil = {}));
9
22
  /**
10
23
  * What waits on something slow (ta serve, code to load): `run` marks it busy until what it returns settles, and
@@ -38,8 +51,12 @@ export class BusyGate {
38
51
  return Promise.resolve(result);
39
52
  }
40
53
  this.running = true;
54
+ // Marked here, so that a button busy by `run` alone says it waits as one marked `ta-busy` by its view does.
55
+ const clicked = BusyUtil.clicked();
56
+ clicked === null || clicked === void 0 ? void 0 : clicked.classList.add('ta-busy');
41
57
  this.changed(true);
42
58
  return Promise.resolve(result).finally(() => {
59
+ clicked === null || clicked === void 0 ? void 0 : clicked.classList.remove('ta-busy');
43
60
  this.running = false;
44
61
  this.changed(false);
45
62
  });
@@ -1,6 +1,20 @@
1
- import { AlarmClock, Aperture, AppWindow, Archive, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, BellOff, BookOpen, Bot, Box, Bug, Building2, Calendar, Camera, CaseSensitive, ChartColumn, ChartSpline, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsDownUp, ChevronsUpDown, ChevronUp, Circle, CircleAlert, CircleArrowRight, CircleHelp, Clipboard, ClipboardPaste, Clock, Cloud, CloudUpload, Code, Coins, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Cpu, Crown, Database, Download, Ellipsis, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, FlaskConical, Folder, FolderInput, FolderLock, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, Gauge, GitBranch, GitCommitHorizontal, Globe, Grip, HardDrive, Hash, Headphones, Heart, House, Image, ImagePlus, Info, Keyboard, KeyRound, Laptop, LayoutDashboard, Lightbulb, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, Lock, MapIcon, Maximize, Maximize2, Megaphone, MemoryStick, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minimize2, Minus, Monitor, MonitorSmartphone, MousePointer2, MousePointerClick, Navigation, Package, PackageOpen, Paperclip, Pencil, Phone, Pin, PinOff, Play, Plus, Pointer, Power, Presentation, Puzzle, QrCode, Quote, Radar, RefreshCw, Regex, Replace, ReplaceAll, Rocket, RotateCcw, Rows2, Save, Scan, ScanLine, ScrollText, Search, Send, Server, Share2, Sheet, Shield, ShieldAlert, ShieldCheck, Shuffle, SlidersHorizontal, Smartphone, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, Target, Text, ThumbsDown, ThumbsUp, Timer, Trash2, TrendingDown, TrendingUp, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, Wrench, X, Zap, } from 'lucide-react';
1
+ import { AlarmClock, AlignCenter, AlignLeft, AlignRight, Aperture, AppWindow, Archive, ArrowDown, ArrowDownToLine, ArrowDownWideNarrow, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, ArrowUpNarrowWide, Bell, BellOff, BetweenHorizontalStart, BetweenVerticalStart, Bold, BookOpen, Bot, Box, Bug, Building2, Calendar, Camera, CaseSensitive, ChartColumn, ChartSpline, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsDownUp, ChevronsUpDown, ChevronUp, Circle, CircleAlert, CircleArrowRight, CircleHelp, Clipboard, ClipboardPaste, Clock, Cloud, CloudUpload, Code, Coins, Columns2, Contact, Copy, CopyMinus, CornerDownRight, CornerUpLeft, Cpu, Crown, Database, Download, Ellipsis, Eraser, ExternalLink, Eye, File, FileArchive, FileDiff, FilePlus, Files, FileText, Film, FlaskConical, Folder, FolderInput, FolderLock, FolderOpen, FolderPlus, FolderSearch, FolderTree, Forward, Gamepad2, Gauge, GitBranch, GitCommitHorizontal, Globe, Grip, HardDrive, Hash, Headphones, Heart, House, Image, ImagePlus, Info, Keyboard, KeyRound, Laptop, LayoutDashboard, Lightbulb, Link, List, ListChecks, ListTodo, ListTree, ListX, LoaderCircle, LocateFixed, Lock, MapIcon, Maximize, Maximize2, Megaphone, MemoryStick, MessageCircle, MessageSquareDot, MessageSquareText, MessagesSquare, Mic, Minimize2, Minus, Monitor, MonitorSmartphone, MousePointer2, MousePointerClick, Navigation, Package, PackageOpen, PaintBucket, Paperclip, Pencil, Phone, Pin, PinOff, Play, Plus, Pointer, Power, Presentation, Puzzle, QrCode, Quote, Radar, RefreshCw, Regex, Replace, ReplaceAll, Rocket, RotateCcw, Rows2, Save, Scan, ScanLine, ScrollText, Search, Send, Server, Share2, Sheet, Shield, ShieldAlert, ShieldCheck, Shuffle, Sigma, SlidersHorizontal, Smartphone, Snowflake, Sparkles, Square, SquareMinus, SquarePlus, SquareTerminal, Star, StarOff, Store, TableCellsMerge, Target, Text, ThumbsDown, ThumbsUp, Timer, Trash2, TrendingDown, TrendingUp, Trophy, Undo2, Unplug, Upload, User, UserPlus, Users, Volume2, WholeWord, Wrench, X, Zap, } 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
+ AlignCenter,
5
+ AlignLeft,
6
+ AlignRight,
7
+ ArrowDownToLine,
8
+ ArrowDownWideNarrow,
9
+ ArrowUpNarrowWide,
10
+ BetweenHorizontalStart,
11
+ BetweenVerticalStart,
12
+ Bold,
13
+ Eraser,
14
+ PaintBucket,
15
+ Sigma,
16
+ Snowflake,
17
+ TableCellsMerge,
4
18
  AlarmClock,
5
19
  Aperture,
6
20
  AppWindow,
@@ -0,0 +1,22 @@
1
+ /** A computer this device reaches, as the page keeps it (WebHosts). */
2
+ export interface WebHost {
3
+ /** Its id on this device. */
4
+ id: string;
5
+ /** As the device shows it: the name given it, else its machine's. */
6
+ name: string;
7
+ /** The host name of its machine, as it said the last time. */
8
+ machine?: string;
9
+ /** Reached through a relay (a pairing), as a phone reaches a computer; not at an address of its own. */
10
+ relay: boolean;
11
+ }
12
+ /** The computers this device reaches (WebExtensionAPI.hosts). Everything the page shows is of one: it loads again for another. */
13
+ export interface WebHosts {
14
+ /** The computer the page shows. */
15
+ current(): WebHost | undefined;
16
+ /** Those kept on this device. */
17
+ list(): WebHost[];
18
+ /** Keeps the computer of a pairing link (a link of Ta) on this device, named `name`, without asking or moving to it: its id. */
19
+ keep(link: string, name?: string): string;
20
+ /** The page loads again for another computer kept on this device, after a moment that says which. */
21
+ switchTo(id: string): void;
22
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=web-api-hosts.js.map
@@ -155,6 +155,8 @@ export const WEB_API_SPEC = {
155
155
  storage: group(B, STORAGE),
156
156
  fileUrl: { form: 'call', access: B, returns: 'url' },
157
157
  openLink: call(B),
158
+ // The computers of the device, and moving to another: what the page itself is.
159
+ hosts: page,
158
160
  registerView: fire(B, [null, VIEW]),
159
161
  registerMessageRenderer: fire(B, [null, 'C']),
160
162
  registerCodeRenderer: fire(A, [null, 'C', { fields: { spoken: 'X' } }]),
@@ -10,6 +10,7 @@ import type { WebAsk, WebCallsAPI, WebChatIconSource, WebChatTagsAPI, WebCompose
10
10
  import type { WebDesktop, WebDeviceUI, WebFileDrag } from './web-api-desktop.js';
11
11
  import type { WebEditorsUI } from './web-api-editors.js';
12
12
  import type { WebHomeUI, WebPartnersAPI, WebPartnersUI } from './web-api-home.js';
13
+ import type { WebHosts } from './web-api-hosts.js';
13
14
  import type { WebFileRef, WebMenus } from './web-api-menus.js';
14
15
  import type { WebPlayUI } from './web-api-play.js';
15
16
  import type { WebServices } from './web-api-services.js';
@@ -29,6 +30,7 @@ export type * from './web-api-contributions.js';
29
30
  export type * from './web-api-desktop.js';
30
31
  export type * from './web-api-editors.js';
31
32
  export type * from './web-api-home.js';
33
+ export type * from './web-api-hosts.js';
32
34
  export type * from './web-api-menus.js';
33
35
  export type * from './web-api-play.js';
34
36
  export type * from './web-api-services.js';
@@ -155,6 +157,11 @@ export interface WebExtensionAPI extends WebServices, WebPartnersAPI, WebMenus,
155
157
  * whole of this API. `from` says where it came from.
156
158
  */
157
159
  openTemporary(source: string, from: 'market' | 'link' | 'agent'): Promise<string>;
160
+ /**
161
+ * The computers this device reaches (docs/design/ta-cloud-handoff.md 15.3): the one the page shows, keeping another
162
+ * one's way in, and moving to it. Newer than some Ta apps: `pi.hosts?.…`.
163
+ */
164
+ readonly hosts?: WebHosts;
158
165
  /** Small JSON values the package keeps on the server, so they stay across browsers. */
159
166
  readonly storage: WebPackageStorage;
160
167
  /**
@@ -48,15 +48,15 @@ import { ScreenUtil } from '../screen/screen-protocol.js';
48
48
  import { TargetsUtil } from '../targets/targets-protocol.js';
49
49
  import { DefaultWebTerminal } from '../terminal/web-terminal.js';
50
50
  import { DesktopUtil } from '../util/desktop.js';
51
- import { FileDragUtil } from '../util/file-drag.js';
52
51
  import { WEB_ICONS } from './icons.js';
53
52
  import { WebAccessUtil } from './web-access.js';
54
53
  import { WebCwdUtil, WebLabelUtil } from './web-extension-protocol.js';
55
54
  import { WebExtensionRunUtil } from './web-extension-run.js';
55
+ import { WEB_FILE_DRAG } from './web-file-drag.js';
56
56
  import { WebHomeUtil } from './web-home.js';
57
+ import { WebHostsUtil } from './web-hosts.js';
57
58
  import { WebPagesUtil } from './web-pages.js';
58
59
  import { WebTaskUtil } from './web-tasks.js';
59
- const FILE_DRAG = Object.freeze({ set: FileDragUtil.set, has: FileDragUtil.has, get: FileDragUtil.get, paths: FileDragUtil.paths });
60
60
  /**
61
61
  * The API each web extension gets: what it registers is its own and goes when it stops, and once it stopped (turned off, removed,
62
62
  * a timer of it left behind) it neither shows nor does anything more: its dialogs answer no, and what would act for the user fails.
@@ -249,6 +249,7 @@ export class WebExtensionContext {
249
249
  openChat: sessionFile => live(() => host.links.openConversation(sessionFile)),
250
250
  openLink: (url, options) => live(() => host.links.open({ type: 'url', url }, { onlyTa: options === null || options === void 0 ? void 0 : options.onlyTa })),
251
251
  openTemporary: (source, from) => live(() => host.extensions.openTemporary(source, from)),
252
+ hosts: WebHostsUtil.of(() => host.workbench),
252
253
  callHost: (method, ...params) => live(() => workbench.packages.callPackageHost(run.loaded.name, method, params)),
253
254
  reloadExtensions: () => live(() => host.extensions.reloadPackages()),
254
255
  };
@@ -297,7 +298,7 @@ export class WebExtensionContext {
297
298
  supportsWebview: DesktopUtil.has('webview'),
298
299
  composerVideos: true,
299
300
  desktop: DesktopUtil.fileManager(),
300
- fileDrag: FILE_DRAG,
301
+ fileDrag: WEB_FILE_DRAG,
301
302
  debugWebview: DesktopUtil.debugWebview(),
302
303
  addToComposer: draft => !run.stopped && ComposerTarget.add(draft),
303
304
  // An extension opens, closes and marks only tabs of its own.
@@ -0,0 +1,3 @@
1
+ import type { WebFileDrag } from './web-extension-api.js';
2
+ /** The files dragged in the page, as extensions read and set them (WebExtensionUI.fileDrag): one for all of them. */
3
+ export declare const WEB_FILE_DRAG: WebFileDrag;
@@ -0,0 +1,4 @@
1
+ import { FileDragUtil } from '../util/file-drag.js';
2
+ /** The files dragged in the page, as extensions read and set them (WebExtensionUI.fileDrag): one for all of them. */
3
+ export const WEB_FILE_DRAG = Object.freeze({ set: FileDragUtil.set, has: FileDragUtil.has, get: FileDragUtil.get, paths: FileDragUtil.paths });
4
+ //# sourceMappingURL=web-file-drag.js.map
@@ -0,0 +1,7 @@
1
+ import type { SavedHost, TaWorkbench } from '../workbench-protocol.js';
2
+ import type { WebHost, WebHosts } from './web-api-hosts.js';
3
+ /** The computers of the device as extensions see them (WebExtensionAPI.hosts): never their ways in. */
4
+ export declare namespace WebHostsUtil {
5
+ function of(workbench: () => TaWorkbench): WebHosts;
6
+ function hostOf(saved: SavedHost): WebHost;
7
+ }
@@ -0,0 +1,29 @@
1
+ import { HostUtil } from '../hosts.js';
2
+ /** The computers of the device as extensions see them (WebExtensionAPI.hosts): never their ways in. */
3
+ export var WebHostsUtil;
4
+ (function (WebHostsUtil) {
5
+ function of(workbench) {
6
+ return {
7
+ current: () => {
8
+ const { hosts, host } = workbench().state;
9
+ const saved = hosts.find(one => one.id === host);
10
+ return saved && hostOf(saved);
11
+ },
12
+ list: () => workbench().state.hosts.map(hostOf),
13
+ keep: (link, name) => workbench().keepHost(link, name),
14
+ switchTo: id => workbench().switchTo(id),
15
+ };
16
+ }
17
+ WebHostsUtil.of = of;
18
+ function hostOf(saved) {
19
+ var _a;
20
+ return {
21
+ id: saved.id,
22
+ name: HostUtil.label(saved),
23
+ ...(((_a = saved.server) === null || _a === void 0 ? void 0 : _a.host) ? { machine: saved.server.host } : {}),
24
+ relay: 'pairing' in saved.credential,
25
+ };
26
+ }
27
+ WebHostsUtil.hostOf = hostOf;
28
+ })(WebHostsUtil || (WebHostsUtil = {}));
29
+ //# sourceMappingURL=web-hosts.js.map
@@ -21,6 +21,8 @@ export declare namespace HostUtil {
21
21
  * keeps its place, name and use.
22
22
  */
23
23
  function keep(list: HostList, id: string, credential: Credential, account: string, now: number): HostList;
24
+ /** A computer kept, not used yet: its way in the one given, its name kept when it has one. */
25
+ function add(list: HostList, id: string, credential: Credential, name: string | undefined, now: number): HostList;
24
26
  function select(list: HostList, id: string, now: number): HostList;
25
27
  /** None in use, all kept: the sign-in shows them to pick from. */
26
28
  function leave(list: HostList): HostList;
@@ -91,6 +91,15 @@ export var HostUtil;
91
91
  return { ...list, hosts: known ? list.hosts.map(one => (one === known ? next : one)) : [...list.hosts, next] };
92
92
  }
93
93
  HostUtil.keep = keep;
94
+ /** A computer kept, not used yet: its way in the one given, its name kept when it has one. */
95
+ function add(list, id, credential, name, now) {
96
+ const known = list.hosts.find(one => one.id === id);
97
+ const next = known
98
+ ? { ...known, credential, ...(known.name || !name ? {} : { name }) }
99
+ : { id, credential, ...(name ? { name } : {}), addedAt: now, usedAt: 0 };
100
+ return { ...list, hosts: known ? list.hosts.map(one => (one === known ? next : one)) : [...list.hosts, next] };
101
+ }
102
+ HostUtil.add = add;
94
103
  function select(list, id, now) {
95
104
  return list.hosts.some(one => one.id === id) ? { current: id, hosts: list.hosts.map(one => (one.id === id ? { ...one, usedAt: now } : one)) } : list;
96
105
  }