@celljs/ta-web 4.9.0 → 4.9.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 (127) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/assistant/assistant-extension.js +13 -5
  4. package/esm/browser/assistant/assistant-task-source.d.ts +2 -0
  5. package/esm/browser/assistant/assistant-task-source.js +2 -0
  6. package/esm/browser/assistant/assistant-task-util.d.ts +6 -0
  7. package/esm/browser/assistant/assistant-task-util.js +8 -0
  8. package/esm/browser/assistant/assistant-tasks.js +3 -2
  9. package/esm/browser/assistant/assistant.d.ts +20 -0
  10. package/esm/browser/assistant/assistant.js +45 -1
  11. package/esm/browser/assistant/task-views.d.ts +40 -6
  12. package/esm/browser/assistant/task-views.js +73 -21
  13. package/esm/browser/avatar/dino-avatar.d.ts +3 -4
  14. package/esm/browser/avatar/dino-avatar.js +4 -178
  15. package/esm/browser/avatar/dino-face.d.ts +19 -0
  16. package/esm/browser/avatar/dino-face.js +142 -0
  17. package/esm/browser/avatar/dino-geometry.d.ts +11 -0
  18. package/esm/browser/avatar/dino-geometry.js +38 -0
  19. package/esm/browser/avatar/dino-kinds.d.ts +15 -0
  20. package/esm/browser/avatar/dino-kinds.js +544 -0
  21. package/esm/browser/avatar/dino-motion.js +1 -1
  22. package/esm/browser/avatar/dino-shape.d.ts +80 -0
  23. package/esm/browser/avatar/dino-shape.js +113 -0
  24. package/esm/browser/avatar/dino-species.d.ts +1 -61
  25. package/esm/browser/avatar/dino-species.js +2 -653
  26. package/esm/browser/components/access-view.js +1 -1
  27. package/esm/browser/components/account-menu.js +1 -1
  28. package/esm/browser/components/app-shell-hooks.d.ts +47 -0
  29. package/esm/browser/components/app-shell-hooks.js +165 -0
  30. package/esm/browser/components/app-view.js +6 -151
  31. package/esm/browser/components/auth-view.js +1 -1
  32. package/esm/browser/components/composer.js +17 -10
  33. package/esm/browser/components/dino.js +1 -1
  34. package/esm/browser/components/folder-picker.js +4 -1
  35. package/esm/browser/components/host-view.d.ts +1 -1
  36. package/esm/browser/components/host-view.js +1 -1
  37. package/esm/browser/components/select-bar.d.ts +9 -0
  38. package/esm/browser/components/select-bar.js +24 -0
  39. package/esm/browser/components/settings-choices.d.ts +35 -0
  40. package/esm/browser/components/settings-choices.js +117 -0
  41. package/esm/browser/components/settings-parts.d.ts +21 -0
  42. package/esm/browser/components/settings-parts.js +300 -0
  43. package/esm/browser/components/settings-view.d.ts +0 -6
  44. package/esm/browser/components/settings-view.js +4 -406
  45. package/esm/browser/components/workbench-view.js +1 -1
  46. package/esm/browser/extension/icons.js +2 -1
  47. package/esm/browser/extension/web-extension-api.d.ts +38 -1
  48. package/esm/browser/extension/web-extensions.js +6 -1
  49. package/esm/browser/extension/web-tasks.d.ts +9 -1
  50. package/esm/browser/extension/web-tasks.js +24 -0
  51. package/esm/browser/hooks.d.ts +3 -1
  52. package/esm/browser/hooks.js +8 -0
  53. package/esm/browser/i18n/locales.d.ts +6 -1
  54. package/esm/browser/i18n/messages.d.ts +5 -0
  55. package/esm/browser/i18n/messages.js +10 -0
  56. package/esm/browser/style/device.js +16 -0
  57. package/esm/browser/style/shell.d.ts +1 -1
  58. package/esm/browser/style/shell.js +1 -0
  59. package/esm/browser/style/tasks.d.ts +1 -1
  60. package/esm/browser/style/tasks.js +2 -0
  61. package/esm/browser/workbench-util.d.ts +61 -0
  62. package/esm/browser/workbench-util.js +138 -0
  63. package/esm/browser/workbench.d.ts +1 -37
  64. package/esm/browser/workbench.js +2 -136
  65. package/lib/browser/assistant/assistant-extension.js +13 -5
  66. package/lib/browser/assistant/assistant-task-source.d.ts +2 -0
  67. package/lib/browser/assistant/assistant-task-source.js +2 -0
  68. package/lib/browser/assistant/assistant-task-util.d.ts +6 -0
  69. package/lib/browser/assistant/assistant-task-util.js +8 -0
  70. package/lib/browser/assistant/assistant-tasks.js +2 -1
  71. package/lib/browser/assistant/assistant.d.ts +20 -0
  72. package/lib/browser/assistant/assistant.js +45 -1
  73. package/lib/browser/assistant/task-views.d.ts +40 -6
  74. package/lib/browser/assistant/task-views.js +74 -21
  75. package/lib/browser/avatar/dino-avatar.d.ts +3 -4
  76. package/lib/browser/avatar/dino-avatar.js +27 -202
  77. package/lib/browser/avatar/dino-face.d.ts +20 -0
  78. package/lib/browser/avatar/dino-face.js +148 -0
  79. package/lib/browser/avatar/dino-geometry.d.ts +12 -0
  80. package/lib/browser/avatar/dino-geometry.js +47 -0
  81. package/lib/browser/avatar/dino-kinds.d.ts +16 -0
  82. package/lib/browser/avatar/dino-kinds.js +547 -0
  83. package/lib/browser/avatar/dino-motion.js +2 -2
  84. package/lib/browser/avatar/dino-shape.d.ts +81 -0
  85. package/lib/browser/avatar/dino-shape.js +126 -0
  86. package/lib/browser/avatar/dino-species.d.ts +1 -61
  87. package/lib/browser/avatar/dino-species.js +34 -687
  88. package/lib/browser/components/access-view.js +2 -2
  89. package/lib/browser/components/account-menu.js +2 -2
  90. package/lib/browser/components/app-shell-hooks.d.ts +48 -0
  91. package/lib/browser/components/app-shell-hooks.js +207 -0
  92. package/lib/browser/components/app-view.js +16 -161
  93. package/lib/browser/components/auth-view.js +3 -3
  94. package/lib/browser/components/composer.js +17 -10
  95. package/lib/browser/components/dino.js +3 -3
  96. package/lib/browser/components/folder-picker.js +4 -1
  97. package/lib/browser/components/host-view.d.ts +1 -1
  98. package/lib/browser/components/host-view.js +5 -5
  99. package/lib/browser/components/select-bar.d.ts +10 -0
  100. package/lib/browser/components/select-bar.js +61 -0
  101. package/lib/browser/components/settings-choices.d.ts +36 -0
  102. package/lib/browser/components/settings-choices.js +156 -0
  103. package/lib/browser/components/settings-parts.d.ts +22 -0
  104. package/lib/browser/components/settings-parts.js +336 -0
  105. package/lib/browser/components/settings-view.d.ts +0 -6
  106. package/lib/browser/components/settings-view.js +2 -405
  107. package/lib/browser/components/workbench-view.js +3 -3
  108. package/lib/browser/extension/icons.js +1 -0
  109. package/lib/browser/extension/web-extension-api.d.ts +38 -1
  110. package/lib/browser/extension/web-extensions.js +5 -0
  111. package/lib/browser/extension/web-tasks.d.ts +9 -1
  112. package/lib/browser/extension/web-tasks.js +24 -0
  113. package/lib/browser/hooks.d.ts +3 -1
  114. package/lib/browser/hooks.js +9 -0
  115. package/lib/browser/i18n/locales.d.ts +6 -1
  116. package/lib/browser/i18n/messages.d.ts +5 -0
  117. package/lib/browser/i18n/messages.js +10 -0
  118. package/lib/browser/style/device.js +16 -0
  119. package/lib/browser/style/shell.d.ts +1 -1
  120. package/lib/browser/style/shell.js +1 -0
  121. package/lib/browser/style/tasks.d.ts +1 -1
  122. package/lib/browser/style/tasks.js +2 -0
  123. package/lib/browser/workbench-util.d.ts +62 -0
  124. package/lib/browser/workbench-util.js +144 -0
  125. package/lib/browser/workbench.d.ts +1 -37
  126. package/lib/browser/workbench.js +24 -159
  127. package/package.json +7 -7
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkbenchUtil = exports.WorkbenchError = exports.PAGE_BYTES = exports.SWITCH_MS = exports.GRACE_MS = exports.PROBE_MS = void 0;
4
+ exports.storage = storage;
5
+ exports.pageHost = pageHost;
6
+ const ta_relay_1 = require("@celljs/ta-relay");
7
+ const hosts_1 = require("./hosts");
8
+ /** Before the list of hosts (HostUtil.KEY): the one token or pairing, taken into the list once. */
9
+ const TOKEN_KEY = 'ta.token';
10
+ const PAIRING_KEY = 'ta.pairing';
11
+ /** How long a computer added while another is in use has to answer before it counts as unreachable. */
12
+ exports.PROBE_MS = 15000;
13
+ /** Waits between attempts while ta serve is not running: doubling up to the last. */
14
+ const RETRY_DELAYS_MS = [1000, 2000, 4000, 8000];
15
+ /**
16
+ * How long the connection is down, while the page is seen, before the user is told (`offlineShown`):
17
+ * the first tries to connect again are within it, so a short drop shows nothing.
18
+ */
19
+ exports.GRACE_MS = 2500;
20
+ /**
21
+ * The lists of the last time, of the ta serve they were of: the next start shows them at once while it
22
+ * connects, as a phone's app shows its chats before it is online. They are small; the conversations
23
+ * are not kept.
24
+ */
25
+ const LISTS_KEY = 'ta.lists';
26
+ /** How long the page shows which computer it switches to before it loads again for it. */
27
+ exports.SWITCH_MS = 160;
28
+ /** A conversation opens with about this much of its latest messages, its earlier ones loaded as much at a time when scrolled to. */
29
+ exports.PAGE_BYTES = 128 * 1024;
30
+ /** Why a computer added while another is in use was not switched to. */
31
+ class WorkbenchError extends Error {
32
+ constructor(reason) {
33
+ super(reason === 'refused' ? 'The computer refused this device.' : 'The computer did not answer.');
34
+ this.reason = reason;
35
+ }
36
+ }
37
+ exports.WorkbenchError = WorkbenchError;
38
+ var WorkbenchUtil;
39
+ (function (WorkbenchUtil) {
40
+ /** A pairing link (`ta pair`) or else a token. */
41
+ function credential(text) {
42
+ try {
43
+ return { pairing: ta_relay_1.RelayPairingUtil.parse(text) };
44
+ }
45
+ catch (_a) {
46
+ return { token: text };
47
+ }
48
+ }
49
+ WorkbenchUtil.credential = credential;
50
+ /**
51
+ * Whether the ta serve in use runs on another machine than this browser: reached through a relay, from
52
+ * the app, or at an address that is not this machine's. A sign-in there cannot come back to it by itself.
53
+ */
54
+ function elsewhere(hostId, hostname = typeof location === 'undefined' ? '' : location.hostname) {
55
+ return isApp() || Boolean(hostId === null || hostId === void 0 ? void 0 : hostId.startsWith('relay ')) || !['localhost', '127.0.0.1', '[::1]', '::1'].includes(hostname);
56
+ }
57
+ WorkbenchUtil.elsewhere = elsewhere;
58
+ /** In the Ta app on a phone, where no ta serve serves the page: it reaches one through a relay. */
59
+ function isApp() {
60
+ var _a, _b;
61
+ return Boolean((_b = (_a = globalThis.Capacitor) === null || _a === void 0 ? void 0 : _a.isNativePlatform) === null || _b === void 0 ? void 0 : _b.call(_a));
62
+ }
63
+ WorkbenchUtil.isApp = isApp;
64
+ function readPairing(text) {
65
+ try {
66
+ return text ? ta_relay_1.RelayPairingUtil.parse(ta_relay_1.RelayPairingUtil.link(JSON.parse(text))) : undefined;
67
+ }
68
+ catch (_a) {
69
+ return undefined;
70
+ }
71
+ }
72
+ WorkbenchUtil.readPairing = readPairing;
73
+ /**
74
+ * Whether the server of the page answers at all. A WebSocket that does not open cannot say why: a
75
+ * server that answers refused the token; none means ta serve is not running (the installed app opens
76
+ * from its service worker then).
77
+ */
78
+ async function reachable(base, fetcher = fetch) {
79
+ try {
80
+ await fetcher(base, { method: 'HEAD', cache: 'no-store' });
81
+ return true;
82
+ }
83
+ catch (_a) {
84
+ return false;
85
+ }
86
+ }
87
+ WorkbenchUtil.reachable = reachable;
88
+ /** The hosts kept in `storage`; the token or pairing an older version kept becomes the first. */
89
+ function readHosts(storage, now = Date.now()) {
90
+ const text = storage === null || storage === void 0 ? void 0 : storage.getItem(hosts_1.HostUtil.KEY);
91
+ if (text || !storage) {
92
+ return hosts_1.HostUtil.read(text);
93
+ }
94
+ const pairing = readPairing(storage.getItem(PAIRING_KEY));
95
+ const token = storage.getItem(TOKEN_KEY);
96
+ const credential = pairing ? { pairing } : token ? { token } : undefined;
97
+ storage.removeItem(PAIRING_KEY);
98
+ storage.removeItem(TOKEN_KEY);
99
+ return credential ? hosts_1.HostUtil.use({ hosts: [] }, serverOf(credential, pageHost()), credential, now) : { hosts: [] };
100
+ }
101
+ WorkbenchUtil.readHosts = readHosts;
102
+ /** Which ta serve a credential reaches, to know whose lists were kept. */
103
+ function serverOf(credential, host) {
104
+ return 'pairing' in credential ? `relay ${credential.pairing.relay} ${credential.pairing.host}` : `serve ${host}`;
105
+ }
106
+ WorkbenchUtil.serverOf = serverOf;
107
+ /** Where the lists of `of` are kept: each computer has its own, to show at once when switched to. */
108
+ function listsKey(of) {
109
+ return `${LISTS_KEY} ${of}`;
110
+ }
111
+ WorkbenchUtil.listsKey = listsKey;
112
+ /** The lists kept for `of`, none running: whether one runs is known once connected. */
113
+ function readLists(text, of) {
114
+ try {
115
+ const kept = text ? JSON.parse(text) : undefined;
116
+ if ((kept === null || kept === void 0 ? void 0 : kept.of) !== of || !Array.isArray(kept.sessions) || !Array.isArray(kept.saved)) {
117
+ return undefined;
118
+ }
119
+ return { server: kept.server, sessions: kept.sessions.map(session => ({ ...session, isStreaming: false })), saved: kept.saved };
120
+ }
121
+ catch (_a) {
122
+ return undefined;
123
+ }
124
+ }
125
+ WorkbenchUtil.readLists = readLists;
126
+ /** `previous` if `next` is the same, so that what shows it is not drawn again. */
127
+ function same(previous, next) {
128
+ return JSON.stringify(previous) === JSON.stringify(next) ? previous : next;
129
+ }
130
+ WorkbenchUtil.same = same;
131
+ function retryDelay(attempt) {
132
+ return RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];
133
+ }
134
+ WorkbenchUtil.retryDelay = retryDelay;
135
+ })(WorkbenchUtil || (exports.WorkbenchUtil = WorkbenchUtil = {}));
136
+ /** None where the page is not in a browser (tests). */
137
+ function storage() {
138
+ return typeof localStorage === 'undefined' ? undefined : localStorage;
139
+ }
140
+ /** The ta serve that serves the page, whose token a sign-in without a pairing is for. */
141
+ function pageHost() {
142
+ return typeof location === 'undefined' ? '' : location.host;
143
+ }
144
+ //# sourceMappingURL=workbench-util.js.map
@@ -1,43 +1,8 @@
1
1
  import { SessionStore, type SessionStoreOptions, TaConnection } from '@celljs/ta-client';
2
2
  import { type TaAccessServer, type TaAuthEvent, type TaAuthServer, type TaGatewayServer, type TaPackageServer, type TaRelayServer, type TaRemoteEvent, type TaRemoteServer, type TaServer, type TaServerInfo, type TaSettingsServer, type TaTerminalServer, type TaWorkspaceServer } from '@celljs/ta-protocol';
3
- import { type RelayPairing } from '@celljs/ta-relay';
4
3
  import { type HostList } from './hosts';
5
4
  import { type Credential, TaWorkbench, type WorkbenchState } from './workbench-protocol';
6
- type ServiceName = 'server' | 'workspace' | 'terminals' | 'settings' | 'packages' | 'auth' | 'access' | 'gateway' | 'relay' | 'remote';
7
- /** Why a computer added while another is in use was not switched to. */
8
- export declare class WorkbenchError extends Error {
9
- readonly reason: 'refused' | 'unreachable';
10
- constructor(reason: 'refused' | 'unreachable');
11
- }
12
- export declare namespace WorkbenchUtil {
13
- /** A pairing link (`ta pair`) or else a token. */
14
- function credential(text: string): Credential;
15
- /**
16
- * Whether the ta serve in use runs on another machine than this browser: reached through a relay, from
17
- * the app, or at an address that is not this machine's. A sign-in there cannot come back to it by itself.
18
- */
19
- function elsewhere(hostId: string | undefined, hostname?: string): boolean;
20
- /** In the Ta app on a phone, where no ta serve serves the page: it reaches one through a relay. */
21
- function isApp(): boolean;
22
- function readPairing(text: string | null): RelayPairing | undefined;
23
- /**
24
- * Whether the server of the page answers at all. A WebSocket that does not open cannot say why: a
25
- * server that answers refused the token; none means ta serve is not running (the installed app opens
26
- * from its service worker then).
27
- */
28
- function reachable(base: string, fetcher?: typeof fetch): Promise<boolean>;
29
- /** The hosts kept in `storage`; the token or pairing an older version kept becomes the first. */
30
- function readHosts(storage: Storage | undefined, now?: number): HostList;
31
- /** Which ta serve a credential reaches, to know whose lists were kept. */
32
- function serverOf(credential: Credential, host: string): string;
33
- /** Where the lists of `of` are kept: each computer has its own, to show at once when switched to. */
34
- function listsKey(of: string): string;
35
- /** The lists kept for `of`, none running: whether one runs is known once connected. */
36
- function readLists(text: string | null, of: string): Pick<WorkbenchState, 'server' | 'sessions' | 'saved'> | undefined;
37
- /** `previous` if `next` is the same, so that what shows it is not drawn again. */
38
- function same<T>(previous: T, next: T): T;
39
- function retryDelay(attempt: number): number;
40
- }
5
+ import { type ServiceName } from './workbench-util';
41
6
  export declare class TaWorkbenchImpl implements TaWorkbench {
42
7
  protected list: HostList;
43
8
  protected current: WorkbenchState;
@@ -134,5 +99,4 @@ export declare class TaWorkbenchImpl implements TaWorkbench {
134
99
  protected update(change: Partial<WorkbenchState>): void;
135
100
  protected keepLists(of: string): void;
136
101
  }
137
- export {};
138
102
  //# sourceMappingURL=workbench.d.ts.map
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.TaWorkbenchImpl = exports.WorkbenchUtil = exports.WorkbenchError = void 0;
9
+ exports.TaWorkbenchImpl = void 0;
10
10
  const core_1 = require("@celljs/core");
11
11
  const ta_client_1 = require("@celljs/ta-client");
12
12
  const ta_protocol_1 = require("@celljs/ta-protocol");
@@ -14,148 +14,13 @@ const ta_relay_1 = require("@celljs/ta-relay");
14
14
  const hosts_1 = require("./hosts");
15
15
  const state_protocol_1 = require("./state/state-protocol");
16
16
  const workbench_protocol_1 = require("./workbench-protocol");
17
- /** Before the list of hosts (HostUtil.KEY): the one token or pairing, taken into the list once. */
18
- const TOKEN_KEY = 'ta.token';
19
- const PAIRING_KEY = 'ta.pairing';
20
- /** How long a computer added while another is in use has to answer before it counts as unreachable. */
21
- const PROBE_MS = 15000;
22
- /** Waits between attempts while ta serve is not running: doubling up to the last. */
23
- const RETRY_DELAYS_MS = [1000, 2000, 4000, 8000];
24
- /**
25
- * How long the connection is down, while the page is seen, before the user is told (`offlineShown`):
26
- * the first tries to connect again are within it, so a short drop shows nothing.
27
- */
28
- const GRACE_MS = 2500;
29
- /**
30
- * The lists of the last time, of the ta serve they were of: the next start shows them at once while it
31
- * connects, as a phone's app shows its chats before it is online. They are small; the conversations
32
- * are not kept.
33
- */
34
- const LISTS_KEY = 'ta.lists';
35
- /** How long the page shows which computer it switches to before it loads again for it. */
36
- const SWITCH_MS = 160;
37
- /** A conversation opens with about this much of its latest messages, its earlier ones loaded as much at a time when scrolled to. */
38
- const PAGE_BYTES = 128 * 1024;
39
- /** Why a computer added while another is in use was not switched to. */
40
- class WorkbenchError extends Error {
41
- constructor(reason) {
42
- super(reason === 'refused' ? 'The computer refused this device.' : 'The computer did not answer.');
43
- this.reason = reason;
44
- }
45
- }
46
- exports.WorkbenchError = WorkbenchError;
47
- var WorkbenchUtil;
48
- (function (WorkbenchUtil) {
49
- /** A pairing link (`ta pair`) or else a token. */
50
- function credential(text) {
51
- try {
52
- return { pairing: ta_relay_1.RelayPairingUtil.parse(text) };
53
- }
54
- catch (_a) {
55
- return { token: text };
56
- }
57
- }
58
- WorkbenchUtil.credential = credential;
59
- /**
60
- * Whether the ta serve in use runs on another machine than this browser: reached through a relay, from
61
- * the app, or at an address that is not this machine's. A sign-in there cannot come back to it by itself.
62
- */
63
- function elsewhere(hostId, hostname = typeof location === 'undefined' ? '' : location.hostname) {
64
- return isApp() || Boolean(hostId === null || hostId === void 0 ? void 0 : hostId.startsWith('relay ')) || !['localhost', '127.0.0.1', '[::1]', '::1'].includes(hostname);
65
- }
66
- WorkbenchUtil.elsewhere = elsewhere;
67
- /** In the Ta app on a phone, where no ta serve serves the page: it reaches one through a relay. */
68
- function isApp() {
69
- var _a, _b;
70
- return Boolean((_b = (_a = globalThis.Capacitor) === null || _a === void 0 ? void 0 : _a.isNativePlatform) === null || _b === void 0 ? void 0 : _b.call(_a));
71
- }
72
- WorkbenchUtil.isApp = isApp;
73
- function readPairing(text) {
74
- try {
75
- return text ? ta_relay_1.RelayPairingUtil.parse(ta_relay_1.RelayPairingUtil.link(JSON.parse(text))) : undefined;
76
- }
77
- catch (_a) {
78
- return undefined;
79
- }
80
- }
81
- WorkbenchUtil.readPairing = readPairing;
82
- /**
83
- * Whether the server of the page answers at all. A WebSocket that does not open cannot say why: a
84
- * server that answers refused the token; none means ta serve is not running (the installed app opens
85
- * from its service worker then).
86
- */
87
- async function reachable(base, fetcher = fetch) {
88
- try {
89
- await fetcher(base, { method: 'HEAD', cache: 'no-store' });
90
- return true;
91
- }
92
- catch (_a) {
93
- return false;
94
- }
95
- }
96
- WorkbenchUtil.reachable = reachable;
97
- /** The hosts kept in `storage`; the token or pairing an older version kept becomes the first. */
98
- function readHosts(storage, now = Date.now()) {
99
- const text = storage === null || storage === void 0 ? void 0 : storage.getItem(hosts_1.HostUtil.KEY);
100
- if (text || !storage) {
101
- return hosts_1.HostUtil.read(text);
102
- }
103
- const pairing = readPairing(storage.getItem(PAIRING_KEY));
104
- const token = storage.getItem(TOKEN_KEY);
105
- const credential = pairing ? { pairing } : token ? { token } : undefined;
106
- storage.removeItem(PAIRING_KEY);
107
- storage.removeItem(TOKEN_KEY);
108
- return credential ? hosts_1.HostUtil.use({ hosts: [] }, serverOf(credential, pageHost()), credential, now) : { hosts: [] };
109
- }
110
- WorkbenchUtil.readHosts = readHosts;
111
- /** Which ta serve a credential reaches, to know whose lists were kept. */
112
- function serverOf(credential, host) {
113
- return 'pairing' in credential ? `relay ${credential.pairing.relay} ${credential.pairing.host}` : `serve ${host}`;
114
- }
115
- WorkbenchUtil.serverOf = serverOf;
116
- /** Where the lists of `of` are kept: each computer has its own, to show at once when switched to. */
117
- function listsKey(of) {
118
- return `${LISTS_KEY} ${of}`;
119
- }
120
- WorkbenchUtil.listsKey = listsKey;
121
- /** The lists kept for `of`, none running: whether one runs is known once connected. */
122
- function readLists(text, of) {
123
- try {
124
- const kept = text ? JSON.parse(text) : undefined;
125
- if ((kept === null || kept === void 0 ? void 0 : kept.of) !== of || !Array.isArray(kept.sessions) || !Array.isArray(kept.saved)) {
126
- return undefined;
127
- }
128
- return { server: kept.server, sessions: kept.sessions.map(session => ({ ...session, isStreaming: false })), saved: kept.saved };
129
- }
130
- catch (_a) {
131
- return undefined;
132
- }
133
- }
134
- WorkbenchUtil.readLists = readLists;
135
- /** `previous` if `next` is the same, so that what shows it is not drawn again. */
136
- function same(previous, next) {
137
- return JSON.stringify(previous) === JSON.stringify(next) ? previous : next;
138
- }
139
- WorkbenchUtil.same = same;
140
- function retryDelay(attempt) {
141
- return RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];
142
- }
143
- WorkbenchUtil.retryDelay = retryDelay;
144
- })(WorkbenchUtil || (exports.WorkbenchUtil = WorkbenchUtil = {}));
145
- /** None where the page is not in a browser (tests). */
146
- function storage() {
147
- return typeof localStorage === 'undefined' ? undefined : localStorage;
148
- }
149
- /** The ta serve that serves the page, whose token a sign-in without a pairing is for. */
150
- function pageHost() {
151
- return typeof location === 'undefined' ? '' : location.host;
152
- }
17
+ const workbench_util_1 = require("./workbench-util");
153
18
  let TaWorkbenchImpl = class TaWorkbenchImpl {
154
19
  constructor() {
155
- this.list = WorkbenchUtil.readHosts(storage());
20
+ this.list = workbench_util_1.WorkbenchUtil.readHosts((0, workbench_util_1.storage)());
156
21
  this.current = { status: 'connecting', hosts: this.list.hosts, host: this.list.current, sessions: [], saved: [] };
157
22
  this.attempts = 0;
158
- this.graceMs = GRACE_MS;
23
+ this.graceMs = workbench_util_1.GRACE_MS;
159
24
  /** Those waiting for the connection (`connected`): `resolve` once online, `reject` once signed out. */
160
25
  this.beforeConnection = new Map();
161
26
  this.connectedWaiters = new Set();
@@ -265,7 +130,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
265
130
  history.replaceState(null, '', location.pathname + location.search);
266
131
  }
267
132
  if (fromUrl) {
268
- this.keepHosts(hosts_1.HostUtil.use(this.list, WorkbenchUtil.serverOf({ token: fromUrl }, pageHost()), { token: fromUrl }, Date.now()));
133
+ this.keepHosts(hosts_1.HostUtil.use(this.list, workbench_util_1.WorkbenchUtil.serverOf({ token: fromUrl }, (0, workbench_util_1.pageHost)()), { token: fromUrl }, Date.now()));
269
134
  }
270
135
  const host = this.list.hosts.find(one => one.id === this.list.current);
271
136
  if (host) {
@@ -276,8 +141,8 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
276
141
  }
277
142
  }
278
143
  async signIn(text) {
279
- const credential = WorkbenchUtil.credential(text.trim());
280
- const id = WorkbenchUtil.serverOf(credential, pageHost());
144
+ const credential = workbench_util_1.WorkbenchUtil.credential(text.trim());
145
+ const id = workbench_util_1.WorkbenchUtil.serverOf(credential, (0, workbench_util_1.pageHost)());
281
146
  if (this.current.status === 'signed-out' || id === this.current.host) {
282
147
  this.keepHosts(hosts_1.HostUtil.use(this.list, id, credential, Date.now()));
283
148
  await this.connectWith(credential);
@@ -326,13 +191,13 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
326
191
  let timer;
327
192
  try {
328
193
  const late = new Promise((_, reject) => {
329
- timer = setTimeout(() => reject(new WorkbenchError('unreachable')), PROBE_MS);
194
+ timer = setTimeout(() => reject(new workbench_util_1.WorkbenchError('unreachable')), workbench_util_1.PROBE_MS);
330
195
  });
331
196
  await Promise.race([connection.connect(), late]);
332
197
  return await Promise.race([connection.server.getServerInfo(), late]);
333
198
  }
334
199
  catch (error) {
335
- throw error instanceof WorkbenchError ? error : new WorkbenchError((await refused()) ? 'refused' : 'unreachable');
200
+ throw error instanceof workbench_util_1.WorkbenchError ? error : new workbench_util_1.WorkbenchError((await refused()) ? 'refused' : 'unreachable');
336
201
  }
337
202
  finally {
338
203
  clearTimeout(timer);
@@ -345,7 +210,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
345
210
  */
346
211
  load(hostId) {
347
212
  this.update({ switching: hostId });
348
- setTimeout(() => this.reload(), SWITCH_MS);
213
+ setTimeout(() => this.reload(), workbench_util_1.SWITCH_MS);
349
214
  }
350
215
  reload() {
351
216
  location.reload();
@@ -353,8 +218,8 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
353
218
  /** A host off this device, with what the page kept of it. */
354
219
  drop(hostId) {
355
220
  this.keepHosts(hosts_1.HostUtil.remove(this.list, hostId));
356
- const kept = storage();
357
- kept === null || kept === void 0 ? void 0 : kept.removeItem(WorkbenchUtil.listsKey(hostId));
221
+ const kept = (0, workbench_util_1.storage)();
222
+ kept === null || kept === void 0 ? void 0 : kept.removeItem(workbench_util_1.WorkbenchUtil.listsKey(hostId));
358
223
  if (kept) {
359
224
  state_protocol_1.StateUtil.forgetHost(kept, hostId);
360
225
  }
@@ -366,7 +231,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
366
231
  var _a;
367
232
  this.list = list;
368
233
  try {
369
- (_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(hosts_1.HostUtil.KEY, JSON.stringify(list));
234
+ (_a = (0, workbench_util_1.storage)()) === null || _a === void 0 ? void 0 : _a.setItem(hosts_1.HostUtil.KEY, JSON.stringify(list));
370
235
  }
371
236
  catch (_b) {
372
237
  // Full: kept for this page.
@@ -378,11 +243,11 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
378
243
  var _c;
379
244
  this.stopRetrying();
380
245
  (_a = this.connection) === null || _a === void 0 ? void 0 : _a.close();
381
- const of = WorkbenchUtil.serverOf(credential, pageHost());
246
+ const of = workbench_util_1.WorkbenchUtil.serverOf(credential, (0, workbench_util_1.pageHost)());
382
247
  if (of !== this.listsOf) {
383
248
  // Another ta serve: its lists of the last time, or none, rather than those of the one before.
384
249
  this.listsOf = of;
385
- this.update({ server: undefined, sessions: [], saved: [], ...WorkbenchUtil.readLists((_c = (_b = storage()) === null || _b === void 0 ? void 0 : _b.getItem(WorkbenchUtil.listsKey(of))) !== null && _c !== void 0 ? _c : null, of) });
250
+ this.update({ server: undefined, sessions: [], saved: [], ...workbench_util_1.WorkbenchUtil.readLists((_c = (_b = (0, workbench_util_1.storage)()) === null || _b === void 0 ? void 0 : _b.getItem(workbench_util_1.WorkbenchUtil.listsKey(of))) !== null && _c !== void 0 ? _c : null, of) });
386
251
  }
387
252
  this.update({ status: 'connecting', error: undefined });
388
253
  await this.connect(credential);
@@ -402,11 +267,11 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
402
267
  }
403
268
  if (wasRefused) {
404
269
  // Unpaired on the computer, or a token of before: of no use any more.
405
- this.drop(WorkbenchUtil.serverOf(credential, pageHost()));
270
+ this.drop(workbench_util_1.WorkbenchUtil.serverOf(credential, (0, workbench_util_1.pageHost)()));
406
271
  this.update({ status: 'signed-out', error: 'refused', server: undefined, sessions: [], saved: [] });
407
272
  }
408
273
  else {
409
- const delay = WorkbenchUtil.retryDelay(this.attempts++);
274
+ const delay = workbench_util_1.WorkbenchUtil.retryDelay(this.attempts++);
410
275
  this.retry = () => {
411
276
  clearTimeout(this.retryTimer);
412
277
  this.retry = undefined;
@@ -468,7 +333,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
468
333
  if (generation !== this.generation) {
469
334
  return;
470
335
  }
471
- this.keepHosts(hosts_1.HostUtil.use(this.list, WorkbenchUtil.serverOf(credential, pageHost()), credential, Date.now(), { user: server.user, host: server.host }));
336
+ this.keepHosts(hosts_1.HostUtil.use(this.list, workbench_util_1.WorkbenchUtil.serverOf(credential, (0, workbench_util_1.pageHost)()), credential, Date.now(), { user: server.user, host: server.host }));
472
337
  this.update({ status: 'online', error: undefined, retryAt: undefined, server });
473
338
  await this.refresh();
474
339
  }
@@ -489,7 +354,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
489
354
  token: credential.token,
490
355
  });
491
356
  // A server that answers refused the token.
492
- return { connection, refused: () => WorkbenchUtil.reachable(document.baseURI) };
357
+ return { connection, refused: () => workbench_util_1.WorkbenchUtil.reachable(document.baseURI) };
493
358
  }
494
359
  /**
495
360
  * Back to the sign-in, loaded again: what the page holds of the computer (the double's and the open
@@ -536,16 +401,16 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
536
401
  sessions.sort((a, b) => b.createdAt - a.createdAt);
537
402
  // Read every few seconds and mostly the same: what shows them is not drawn again for nothing.
538
403
  this.update({
539
- sessions: WorkbenchUtil.same(this.current.sessions, sessions),
540
- saved: WorkbenchUtil.same(this.current.saved, saved),
541
- server: WorkbenchUtil.same(this.current.server, server),
404
+ sessions: workbench_util_1.WorkbenchUtil.same(this.current.sessions, sessions),
405
+ saved: workbench_util_1.WorkbenchUtil.same(this.current.saved, saved),
406
+ server: workbench_util_1.WorkbenchUtil.same(this.current.server, server),
542
407
  });
543
408
  }
544
409
  createStore(sessionId, options) {
545
410
  if (!this.connection) {
546
411
  throw new Error('Not signed in to ta serve.');
547
412
  }
548
- return new ta_client_1.SessionStore(this.connection, sessionId, { pageBytes: PAGE_BYTES, ...options });
413
+ return new ta_client_1.SessionStore(this.connection, sessionId, { pageBytes: workbench_util_1.PAGE_BYTES, ...options });
549
414
  }
550
415
  /** The prompts of ssh that wait for an answer, from now and those already there. */
551
416
  async watchRemote(connection) {
@@ -641,7 +506,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
641
506
  const { server, sessions, saved } = this.current;
642
507
  const kept = { of, server, sessions, saved };
643
508
  try {
644
- (_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(WorkbenchUtil.listsKey(of), JSON.stringify(kept));
509
+ (_a = (0, workbench_util_1.storage)()) === null || _a === void 0 ? void 0 : _a.setItem(workbench_util_1.WorkbenchUtil.listsKey(of), JSON.stringify(kept));
645
510
  }
646
511
  catch (_b) {
647
512
  // Full: the next start waits for the server, as it would without.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-web",
3
- "version": "4.9.0",
3
+ "version": "4.9.1",
4
4
  "description": "The web client of ta serve: sessions, streaming messages, tool runs with diffs, and dialogs",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -33,12 +33,12 @@
33
33
  "watch": "tsc -b -w --preserveWatchOutput"
34
34
  },
35
35
  "dependencies": {
36
- "@celljs/core": "4.9.0",
37
- "@celljs/react": "4.9.0",
38
- "@celljs/ta-client": "4.9.0",
39
- "@celljs/ta-protocol": "4.9.0",
40
- "@celljs/ta-relay": "4.9.0",
41
- "@celljs/widget": "4.9.0",
36
+ "@celljs/core": "4.9.1",
37
+ "@celljs/react": "4.9.1",
38
+ "@celljs/ta-client": "4.9.1",
39
+ "@celljs/ta-protocol": "4.9.1",
40
+ "@celljs/ta-relay": "4.9.1",
41
+ "@celljs/widget": "4.9.1",
42
42
  "@xterm/addon-fit": "^0.11.0",
43
43
  "@xterm/addon-unicode11": "^0.9.0",
44
44
  "@xterm/addon-webgl": "^0.19.0",