@celljs/ta-web 4.46.2 → 4.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/browser/account/account-side.d.ts +3 -3
- package/esm/browser/account/account-side.js +11 -21
- package/esm/browser/account/device-account.d.ts +8 -0
- package/esm/browser/account/device-account.js +20 -0
- package/esm/browser/chat/chat-protocol.d.ts +7 -0
- package/esm/browser/chat/chat-view.js +1 -1
- package/esm/browser/chat/chat.d.ts +1 -0
- package/esm/browser/chat/chat.js +15 -3
- package/esm/browser/chat/draft-model.d.ts +1 -1
- package/esm/browser/chat/draft-model.js +2 -2
- package/esm/browser/components/access-view.js +12 -10
- package/esm/browser/components/account-menu.d.ts +2 -0
- package/esm/browser/components/account-menu.js +11 -2
- package/esm/browser/components/account-view.js +9 -5
- package/esm/browser/components/app-nav.js +4 -1
- package/esm/browser/components/app-shell-state.d.ts +2 -0
- package/esm/browser/components/app-update-view.d.ts +2 -0
- package/esm/browser/components/app-update-view.js +37 -0
- package/esm/browser/components/app-view.js +33 -108
- package/esm/browser/components/auth-guide.d.ts +25 -0
- package/esm/browser/components/auth-guide.js +44 -0
- package/esm/browser/components/auth-view.d.ts +2 -0
- package/esm/browser/components/auth-view.js +30 -9
- package/esm/browser/components/chat-list-controls.d.ts +38 -0
- package/esm/browser/components/chat-list-controls.js +46 -0
- package/esm/browser/components/chat-list-hooks.d.ts +19 -0
- package/esm/browser/components/chat-list-hooks.js +52 -0
- package/esm/browser/components/chat-list-rows.d.ts +51 -0
- package/esm/browser/components/chat-list-rows.js +110 -0
- package/esm/browser/components/chat-list-sections.d.ts +36 -0
- package/esm/browser/components/chat-list-sections.js +72 -0
- package/esm/browser/components/chat-list.js +48 -221
- package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/esm/browser/components/cloud-sign-in-view.js +4 -1
- package/esm/browser/components/custom-provider-util.d.ts +2 -0
- package/esm/browser/components/custom-provider-util.js +5 -0
- package/esm/browser/components/custom-provider-view.js +33 -12
- package/esm/browser/components/device-sign-in-page.js +4 -5
- package/esm/browser/components/discover-view.d.ts +8 -1
- package/esm/browser/components/discover-view.js +28 -3
- package/esm/browser/components/environment-view.js +60 -62
- package/esm/browser/components/extension-settings.js +1 -0
- package/esm/browser/components/first-steps-util.d.ts +29 -0
- package/esm/browser/components/first-steps-util.js +41 -0
- package/esm/browser/components/first-steps.d.ts +3 -0
- package/esm/browser/components/first-steps.js +36 -0
- package/esm/browser/components/host-view.d.ts +3 -3
- package/esm/browser/components/host-view.js +11 -11
- package/esm/browser/components/me-rows.d.ts +8 -1
- package/esm/browser/components/me-rows.js +3 -3
- package/esm/browser/components/me-view.js +1 -1
- package/esm/browser/components/message-user.js +6 -3
- package/esm/browser/components/model-picker.d.ts +5 -0
- package/esm/browser/components/model-picker.js +10 -1
- package/esm/browser/components/nav-places.d.ts +14 -0
- package/esm/browser/components/nav-places.js +11 -0
- package/esm/browser/components/phone-shell.d.ts +14 -0
- package/esm/browser/components/phone-shell.js +22 -0
- package/esm/browser/components/picture-dialog.js +4 -7
- package/esm/browser/components/profile-view.js +1 -1
- package/esm/browser/components/relay-services.js +4 -7
- package/esm/browser/components/relay-view-util.d.ts +5 -0
- package/esm/browser/components/relay-view-util.js +14 -0
- package/esm/browser/components/relay-view.js +40 -37
- package/esm/browser/components/scan-screen.js +5 -8
- package/esm/browser/components/screen-navigator.d.ts +9 -0
- package/esm/browser/components/screen-navigator.js +84 -0
- package/esm/browser/components/search-page.js +9 -2
- package/esm/browser/components/serve-value.d.ts +27 -0
- package/esm/browser/components/serve-value.js +61 -0
- package/esm/browser/components/serve-watch.d.ts +23 -0
- package/esm/browser/components/serve-watch.js +36 -0
- package/esm/browser/components/settings-choices.js +2 -0
- package/esm/browser/components/settings-controls.d.ts +15 -0
- package/esm/browser/components/settings-controls.js +13 -0
- package/esm/browser/components/settings-more.js +6 -4
- package/esm/browser/components/settings-parts.d.ts +3 -1
- package/esm/browser/components/settings-parts.js +3 -0
- package/esm/browser/components/settings-view.js +37 -11
- package/esm/browser/components/share-friends.js +3 -4
- package/esm/browser/components/share-sheet.js +3 -4
- package/esm/browser/components/tool-view.js +17 -3
- package/esm/browser/device/app-update.d.ts +62 -0
- package/esm/browser/device/app-update.js +144 -0
- package/esm/browser/extension/icons.js +2 -1
- package/esm/browser/extension/web-api-contributions.d.ts +6 -1
- package/esm/browser/extension/web-api-partners.d.ts +6 -0
- package/esm/browser/extension/web-api-spec.js +1 -0
- package/esm/browser/extension/web-home.js +9 -0
- package/esm/browser/extension/web-metrics.d.ts +3 -0
- package/esm/browser/extension/web-metrics.js +33 -22
- package/esm/browser/extension/web-pages.d.ts +3 -1
- package/esm/browser/extension/web-pages.js +1 -0
- package/esm/browser/gateway/console-agents.js +11 -15
- package/esm/browser/gateway/console-parts.d.ts +7 -4
- package/esm/browser/gateway/console-parts.js +11 -20
- package/esm/browser/gateway/console-trend.js +2 -2
- package/esm/browser/gateway/console-updates.js +6 -4
- package/esm/browser/gateway/console-view.js +6 -6
- package/esm/browser/i18n/en/account.d.ts +7 -0
- package/esm/browser/i18n/en/account.js +13 -6
- package/esm/browser/i18n/en/chat.d.ts +2 -0
- package/esm/browser/i18n/en/chat.js +2 -0
- package/esm/browser/i18n/en/discover.d.ts +3 -0
- package/esm/browser/i18n/en/discover.js +3 -0
- package/esm/browser/i18n/en/service.d.ts +6 -0
- package/esm/browser/i18n/en/service.js +6 -0
- package/esm/browser/i18n/en/settings.d.ts +3 -0
- package/esm/browser/i18n/en/settings.js +3 -0
- package/esm/browser/i18n/ja/account.js +13 -6
- package/esm/browser/i18n/ja/chat.js +2 -0
- package/esm/browser/i18n/ja/discover.js +3 -0
- package/esm/browser/i18n/ja/service.js +6 -0
- package/esm/browser/i18n/ja/settings.js +3 -0
- package/esm/browser/i18n/locales.d.ts +22 -1
- package/esm/browser/i18n/messages.d.ts +21 -0
- package/esm/browser/i18n/zh/account.js +13 -6
- package/esm/browser/i18n/zh/chat.js +2 -0
- package/esm/browser/i18n/zh/discover.js +3 -0
- package/esm/browser/i18n/zh/service.js +6 -0
- package/esm/browser/i18n/zh/settings.js +3 -0
- package/esm/browser/i18n/zh-tw/account.js +13 -6
- package/esm/browser/i18n/zh-tw/chat.js +2 -0
- package/esm/browser/i18n/zh-tw/discover.js +3 -0
- package/esm/browser/i18n/zh-tw/service.js +6 -0
- package/esm/browser/i18n/zh-tw/settings.js +3 -0
- package/esm/browser/notices/notices.d.ts +2 -0
- package/esm/browser/notices/notices.js +2 -0
- package/esm/browser/partners/group-picker.js +3 -4
- package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
- package/esm/browser/settings/settings-protocol.d.ts +5 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/chat-list.d.ts +1 -1
- package/esm/browser/style/chat-list.js +4 -3
- package/esm/browser/style/dialogs.d.ts +1 -1
- package/esm/browser/style/dialogs.js +7 -0
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +5 -3
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +1 -1
- package/esm/browser/util/tool.d.ts +5 -0
- package/esm/browser/util/tool.js +21 -3
- package/lib/browser/account/account-side.d.ts +3 -3
- package/lib/browser/account/account-side.js +11 -21
- package/lib/browser/account/device-account.d.ts +8 -0
- package/lib/browser/account/device-account.js +20 -0
- package/lib/browser/chat/chat-protocol.d.ts +7 -0
- package/lib/browser/chat/chat-view.js +1 -1
- package/lib/browser/chat/chat.d.ts +1 -0
- package/lib/browser/chat/chat.js +14 -2
- package/lib/browser/chat/draft-model.d.ts +1 -1
- package/lib/browser/chat/draft-model.js +2 -2
- package/lib/browser/components/access-view.js +12 -10
- package/lib/browser/components/account-menu.d.ts +2 -0
- package/lib/browser/components/account-menu.js +11 -2
- package/lib/browser/components/account-view.js +9 -5
- package/lib/browser/components/app-nav.js +3 -0
- package/lib/browser/components/app-shell-state.d.ts +2 -0
- package/lib/browser/components/app-update-view.d.ts +3 -0
- package/lib/browser/components/app-update-view.js +73 -0
- package/lib/browser/components/app-view.js +30 -105
- package/lib/browser/components/auth-guide.d.ts +26 -0
- package/lib/browser/components/auth-guide.js +47 -0
- package/lib/browser/components/auth-view.d.ts +2 -0
- package/lib/browser/components/auth-view.js +29 -8
- package/lib/browser/components/chat-list-controls.d.ts +39 -0
- package/lib/browser/components/chat-list-controls.js +86 -0
- package/lib/browser/components/chat-list-hooks.d.ts +19 -0
- package/lib/browser/components/chat-list-hooks.js +53 -0
- package/lib/browser/components/chat-list-rows.d.ts +52 -0
- package/lib/browser/components/chat-list-rows.js +147 -0
- package/lib/browser/components/chat-list-sections.d.ts +37 -0
- package/lib/browser/components/chat-list-sections.js +108 -0
- package/lib/browser/components/chat-list.js +44 -217
- package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
- package/lib/browser/components/cloud-sign-in-view.js +4 -1
- package/lib/browser/components/custom-provider-util.d.ts +2 -0
- package/lib/browser/components/custom-provider-util.js +5 -0
- package/lib/browser/components/custom-provider-view.js +32 -11
- package/lib/browser/components/device-sign-in-page.js +4 -5
- package/lib/browser/components/discover-view.d.ts +8 -1
- package/lib/browser/components/discover-view.js +27 -2
- package/lib/browser/components/environment-view.js +60 -62
- package/lib/browser/components/extension-settings.js +1 -0
- package/lib/browser/components/first-steps-util.d.ts +30 -0
- package/lib/browser/components/first-steps-util.js +44 -0
- package/lib/browser/components/first-steps.d.ts +4 -0
- package/lib/browser/components/first-steps.js +72 -0
- package/lib/browser/components/host-view.d.ts +3 -3
- package/lib/browser/components/host-view.js +11 -11
- package/lib/browser/components/me-rows.d.ts +8 -1
- package/lib/browser/components/me-rows.js +3 -3
- package/lib/browser/components/me-view.js +1 -1
- package/lib/browser/components/message-user.js +5 -2
- package/lib/browser/components/model-picker.d.ts +5 -0
- package/lib/browser/components/model-picker.js +10 -1
- package/lib/browser/components/nav-places.d.ts +14 -0
- package/lib/browser/components/nav-places.js +13 -1
- package/lib/browser/components/phone-shell.d.ts +14 -0
- package/lib/browser/components/phone-shell.js +23 -0
- package/lib/browser/components/picture-dialog.js +4 -7
- package/lib/browser/components/profile-view.js +1 -1
- package/lib/browser/components/relay-services.js +4 -7
- package/lib/browser/components/relay-view-util.d.ts +6 -0
- package/lib/browser/components/relay-view-util.js +17 -0
- package/lib/browser/components/relay-view.js +38 -35
- package/lib/browser/components/scan-screen.js +5 -8
- package/lib/browser/components/screen-navigator.d.ts +9 -0
- package/lib/browser/components/screen-navigator.js +85 -0
- package/lib/browser/components/search-page.js +8 -1
- package/lib/browser/components/serve-value.d.ts +28 -0
- package/lib/browser/components/serve-value.js +97 -0
- package/lib/browser/components/serve-watch.d.ts +24 -0
- package/lib/browser/components/serve-watch.js +39 -0
- package/lib/browser/components/settings-choices.js +2 -0
- package/lib/browser/components/settings-controls.d.ts +15 -0
- package/lib/browser/components/settings-controls.js +13 -0
- package/lib/browser/components/settings-more.js +6 -4
- package/lib/browser/components/settings-parts.d.ts +3 -1
- package/lib/browser/components/settings-parts.js +3 -0
- package/lib/browser/components/settings-view.js +36 -10
- package/lib/browser/components/share-friends.js +3 -4
- package/lib/browser/components/share-sheet.js +3 -4
- package/lib/browser/components/tool-view.js +17 -3
- package/lib/browser/device/app-update.d.ts +63 -0
- package/lib/browser/device/app-update.js +182 -0
- package/lib/browser/extension/icons.js +1 -0
- package/lib/browser/extension/web-api-contributions.d.ts +6 -1
- package/lib/browser/extension/web-api-partners.d.ts +6 -0
- package/lib/browser/extension/web-api-spec.js +1 -0
- package/lib/browser/extension/web-home.js +9 -0
- package/lib/browser/extension/web-metrics.d.ts +3 -0
- package/lib/browser/extension/web-metrics.js +32 -21
- package/lib/browser/extension/web-pages.d.ts +3 -1
- package/lib/browser/extension/web-pages.js +1 -0
- package/lib/browser/gateway/console-agents.js +10 -14
- package/lib/browser/gateway/console-parts.d.ts +7 -4
- package/lib/browser/gateway/console-parts.js +12 -21
- package/lib/browser/gateway/console-trend.js +1 -1
- package/lib/browser/gateway/console-updates.js +5 -3
- package/lib/browser/gateway/console-view.js +5 -5
- package/lib/browser/i18n/en/account.d.ts +7 -0
- package/lib/browser/i18n/en/account.js +13 -6
- package/lib/browser/i18n/en/chat.d.ts +2 -0
- package/lib/browser/i18n/en/chat.js +2 -0
- package/lib/browser/i18n/en/discover.d.ts +3 -0
- package/lib/browser/i18n/en/discover.js +3 -0
- package/lib/browser/i18n/en/service.d.ts +6 -0
- package/lib/browser/i18n/en/service.js +6 -0
- package/lib/browser/i18n/en/settings.d.ts +3 -0
- package/lib/browser/i18n/en/settings.js +3 -0
- package/lib/browser/i18n/ja/account.js +13 -6
- package/lib/browser/i18n/ja/chat.js +2 -0
- package/lib/browser/i18n/ja/discover.js +3 -0
- package/lib/browser/i18n/ja/service.js +6 -0
- package/lib/browser/i18n/ja/settings.js +3 -0
- package/lib/browser/i18n/locales.d.ts +22 -1
- package/lib/browser/i18n/messages.d.ts +21 -0
- package/lib/browser/i18n/zh/account.js +13 -6
- package/lib/browser/i18n/zh/chat.js +2 -0
- package/lib/browser/i18n/zh/discover.js +3 -0
- package/lib/browser/i18n/zh/service.js +6 -0
- package/lib/browser/i18n/zh/settings.js +3 -0
- package/lib/browser/i18n/zh-tw/account.js +13 -6
- package/lib/browser/i18n/zh-tw/chat.js +2 -0
- package/lib/browser/i18n/zh-tw/discover.js +3 -0
- package/lib/browser/i18n/zh-tw/service.js +6 -0
- package/lib/browser/i18n/zh-tw/settings.js +3 -0
- package/lib/browser/notices/notices.d.ts +2 -0
- package/lib/browser/notices/notices.js +3 -1
- package/lib/browser/partners/group-picker.js +3 -4
- package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
- package/lib/browser/settings/settings-protocol.d.ts +5 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/chat-list.d.ts +1 -1
- package/lib/browser/style/chat-list.js +4 -3
- package/lib/browser/style/dialogs.d.ts +1 -1
- package/lib/browser/style/dialogs.js +7 -0
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +5 -3
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +1 -1
- package/lib/browser/util/tool.d.ts +5 -0
- package/lib/browser/util/tool.js +21 -3
- package/package.json +7 -7
|
@@ -37,6 +37,7 @@ exports.PhoneUtil = exports.PageStackContext = void 0;
|
|
|
37
37
|
exports.useScreenArriving = useScreenArriving;
|
|
38
38
|
exports.PhoneShell = PhoneShell;
|
|
39
39
|
exports.PhoneStack = PhoneStack;
|
|
40
|
+
exports.PhoneHome = PhoneHome;
|
|
40
41
|
const React = __importStar(require("react"));
|
|
41
42
|
const back_stack_1 = require("../device/back-stack");
|
|
42
43
|
const device_1 = require("../device/device");
|
|
@@ -239,6 +240,28 @@ function PhoneStack({ base, top, open, onClose }) {
|
|
|
239
240
|
React.createElement("div", { className: "ta-phone-stack-top", inert: !open },
|
|
240
241
|
React.createElement(back_stack_1.BackLayerContext.Provider, { value: back.layer }, top))));
|
|
241
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* What a tab of a phone shows, and the conversations going on (ui.showChats with `busy`) pushed over it while
|
|
245
|
+
* `busy`, as the folder of the chats is pushed over their list: back with its button, a swipe from the left edge or the
|
|
246
|
+
* back of the system (PhoneStack, a layer of BackLayers), to the tab as it was; a conversation picked in it comes over
|
|
247
|
+
* it, and goes back to it. Drawn while open and while it slides away. Not over a page of an extension's own in the
|
|
248
|
+
* tabs (`pushable`, SideListUtil.pushesOver): the page is drawn as it is, the shell shows those going on over the chats.
|
|
249
|
+
*/
|
|
250
|
+
function PhoneHome({ pushable, busy, onBusy, busyList, children, }) {
|
|
251
|
+
const [drawn, setDrawn] = React.useState(busy);
|
|
252
|
+
React.useEffect(() => {
|
|
253
|
+
if (busy) {
|
|
254
|
+
setDrawn(true);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const timer = setTimeout(() => setDrawn(false), device_protocol_1.DeviceMotion.SHEET_MS);
|
|
258
|
+
return () => clearTimeout(timer);
|
|
259
|
+
}, [busy]);
|
|
260
|
+
if (!pushable) {
|
|
261
|
+
return children;
|
|
262
|
+
}
|
|
263
|
+
return React.createElement(PhoneStack, { base: children, top: (busy || drawn) && busyList(), open: busy, onClose: () => onBusy(false) });
|
|
264
|
+
}
|
|
242
265
|
function TabBar({ tabs, tab, onTab }) {
|
|
243
266
|
const t = (0, use_t_1.useT)();
|
|
244
267
|
const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
|
|
@@ -40,6 +40,7 @@ const React = __importStar(require("react"));
|
|
|
40
40
|
const hooks_1 = require("../hooks");
|
|
41
41
|
const use_t_1 = require("../i18n/use-t");
|
|
42
42
|
const picture_1 = require("../util/picture");
|
|
43
|
+
const busy_1 = require("./busy");
|
|
43
44
|
const face_1 = require("./face");
|
|
44
45
|
const face_pictures_1 = require("./face-pictures");
|
|
45
46
|
const icon_1 = require("./icon");
|
|
@@ -89,19 +90,15 @@ function PictureDialog({ onClose }) {
|
|
|
89
90
|
const pictures = React.useContext(face_pictures_1.FacePictures);
|
|
90
91
|
const mine = !!pictures.pictures[pictures.self];
|
|
91
92
|
const input = React.useRef(null);
|
|
92
|
-
const [busy,
|
|
93
|
+
const [busy, run] = (0, busy_1.useBusy)();
|
|
93
94
|
const [drawing, setDrawing] = React.useState();
|
|
94
95
|
const set = async (picture) => {
|
|
95
|
-
setBusy(true);
|
|
96
96
|
try {
|
|
97
97
|
await workbench.rooms.setPicture(picture);
|
|
98
98
|
}
|
|
99
99
|
catch (error) {
|
|
100
100
|
notices.error(error);
|
|
101
101
|
}
|
|
102
|
-
finally {
|
|
103
|
-
setBusy(false);
|
|
104
|
-
}
|
|
105
102
|
};
|
|
106
103
|
const picked = async (file) => {
|
|
107
104
|
const picture = await picture_1.PictureUtil.square(file).catch(() => undefined);
|
|
@@ -133,7 +130,7 @@ function PictureDialog({ onClose }) {
|
|
|
133
130
|
React.createElement("button", { type: "button", className: "ta-button ta-wide", disabled: busy, onClick: () => setDrawing('') },
|
|
134
131
|
React.createElement(icon_1.Icon, { icon: lucide_react_1.Sparkles, size: 16 }),
|
|
135
132
|
t('ta.picture.draw')),
|
|
136
|
-
mine && (React.createElement("button", { type: "button", className: "ta-button ta-wide", disabled: busy, onClick: () => void set(null) },
|
|
133
|
+
mine && (React.createElement("button", { type: "button", className: "ta-button ta-wide", disabled: busy, onClick: () => void run(() => set(null)) },
|
|
137
134
|
React.createElement(icon_1.Icon, { icon: lucide_react_1.RotateCcw, size: 16 }),
|
|
138
135
|
t('ta.picture.reset'))))) : (React.createElement("form", { className: "ta-picture-actions", onSubmit: event => {
|
|
139
136
|
event.preventDefault();
|
|
@@ -146,7 +143,7 @@ function PictureDialog({ onClose }) {
|
|
|
146
143
|
const file = (_a = event.currentTarget.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
147
144
|
event.currentTarget.value = '';
|
|
148
145
|
if (file) {
|
|
149
|
-
void picked(file);
|
|
146
|
+
void run(() => picked(file));
|
|
150
147
|
}
|
|
151
148
|
} }))));
|
|
152
149
|
}
|
|
@@ -82,7 +82,7 @@ function useIdentity() {
|
|
|
82
82
|
/** The account in use as a line: "Company account · su"; null while signed out, undefined until read. */
|
|
83
83
|
function useAccountLine() {
|
|
84
84
|
const side = (0, account_side_1.useAccountSide)();
|
|
85
|
-
const { info, failed } = (0, account_side_1.useAccountInfo)(side
|
|
85
|
+
const { info, failed } = (0, account_side_1.useAccountInfo)(side);
|
|
86
86
|
const way = (0, account_view_1.useAccountWay)();
|
|
87
87
|
if ((info === null || info === void 0 ? void 0 : info.account) && !info.waiting) {
|
|
88
88
|
return `${way(info.account.id)} · ${(0, account_view_1.accountName)(info.account)}`;
|
|
@@ -39,6 +39,7 @@ const lucide_react_1 = require("lucide-react");
|
|
|
39
39
|
const React = __importStar(require("react"));
|
|
40
40
|
const hooks_1 = require("../hooks");
|
|
41
41
|
const use_t_1 = require("../i18n/use-t");
|
|
42
|
+
const busy_1 = require("./busy");
|
|
42
43
|
const icon_1 = require("./icon");
|
|
43
44
|
const remote_hosts_1 = require("./remote-hosts");
|
|
44
45
|
const settings_controls_1 = require("./settings-controls");
|
|
@@ -275,7 +276,7 @@ function Deployment({ relays, changed }) {
|
|
|
275
276
|
const [, bench] = (0, hooks_1.useWorkbench)();
|
|
276
277
|
const [, notices] = (0, hooks_1.useNotices)();
|
|
277
278
|
const [url, setUrl] = React.useState('');
|
|
278
|
-
const [busy,
|
|
279
|
+
const [busy, run] = (0, busy_1.useBusy)();
|
|
279
280
|
const [clouds, setClouds] = React.useState();
|
|
280
281
|
const joined = relays.deployment;
|
|
281
282
|
const gateway = joined === null || joined === void 0 ? void 0 : joined.gateway;
|
|
@@ -289,7 +290,6 @@ function Deployment({ relays, changed }) {
|
|
|
289
290
|
}
|
|
290
291
|
}, [gateway, readClouds]);
|
|
291
292
|
const act = async (action) => {
|
|
292
|
-
setBusy(true);
|
|
293
293
|
try {
|
|
294
294
|
const listed = await action();
|
|
295
295
|
changed(listed);
|
|
@@ -299,15 +299,12 @@ function Deployment({ relays, changed }) {
|
|
|
299
299
|
notices.error(error);
|
|
300
300
|
return undefined;
|
|
301
301
|
}
|
|
302
|
-
finally {
|
|
303
|
-
setBusy(false);
|
|
304
|
-
}
|
|
305
302
|
};
|
|
306
303
|
if (!joined) {
|
|
307
304
|
return (React.createElement(settings_controls_1.Row, { label: t('ta.deploy.join'), description: t('ta.deploy.joinHint'), stacked: true },
|
|
308
305
|
React.createElement("form", { className: "ta-trusted-add", onSubmit: event => {
|
|
309
306
|
event.preventDefault();
|
|
310
|
-
void act(() => bench.relay.joinDeployment(url.trim())).then(listed => {
|
|
307
|
+
void run(() => act(() => bench.relay.joinDeployment(url.trim()))).then(listed => {
|
|
311
308
|
if (listed === null || listed === void 0 ? void 0 : listed.deployment) {
|
|
312
309
|
setUrl('');
|
|
313
310
|
notices.notify(t('ta.deploy.joined', { name: RelayServicesUtil.deploymentName(listed.deployment) }), { level: 'success' });
|
|
@@ -327,7 +324,7 @@ function Deployment({ relays, changed }) {
|
|
|
327
324
|
const added = gateway && (clouds === null || clouds === void 0 ? void 0 : clouds.some(each => RelayServicesUtil.host(each) === RelayServicesUtil.host(gateway)));
|
|
328
325
|
return (React.createElement(React.Fragment, null,
|
|
329
326
|
React.createElement(settings_controls_1.Row, { icon: lucide_react_1.Building2, label: RelayServicesUtil.deploymentName(joined), description: [t('ta.deploy.joinedLine'), ...parts].join(' · ') },
|
|
330
|
-
React.createElement("button", { type: "button", className: `ta-button${busy ? ' ta-busy' : ''}`, disabled: busy, onClick: () => void act(() => bench.relay.leaveDeployment()) },
|
|
327
|
+
React.createElement("button", { type: "button", className: `ta-button${busy ? ' ta-busy' : ''}`, disabled: busy, onClick: () => void run(() => act(() => bench.relay.leaveDeployment())) },
|
|
331
328
|
busy && React.createElement("span", { className: "ta-spinner ta-busy-mark" }),
|
|
332
329
|
React.createElement("span", null, t('ta.deploy.leave')))),
|
|
333
330
|
gateway && (React.createElement(settings_controls_1.Row, { label: t('ta.deploy.cloud'), description: added ? t('ta.deploy.cloudAdded') : t('ta.deploy.cloudHint'), stacked: true },
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TaRelayDevice } from '@celljs/ta-protocol';
|
|
2
|
+
export declare namespace RelayViewUtil {
|
|
3
|
+
/** The name of the next device paired: `base`, numbered when one paired already has it (`Phone 2`). */
|
|
4
|
+
function nextName(base: string, devices: readonly Pick<TaRelayDevice, 'name'>[]): string;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=relay-view-util.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelayViewUtil = void 0;
|
|
4
|
+
var RelayViewUtil;
|
|
5
|
+
(function (RelayViewUtil) {
|
|
6
|
+
/** The name of the next device paired: `base`, numbered when one paired already has it (`Phone 2`). */
|
|
7
|
+
function nextName(base, devices) {
|
|
8
|
+
const taken = new Set(devices.map(device => device.name));
|
|
9
|
+
let name = base;
|
|
10
|
+
for (let n = 2; taken.has(name); n++) {
|
|
11
|
+
name = `${base} ${n}`;
|
|
12
|
+
}
|
|
13
|
+
return name;
|
|
14
|
+
}
|
|
15
|
+
RelayViewUtil.nextName = nextName;
|
|
16
|
+
})(RelayViewUtil || (exports.RelayViewUtil = RelayViewUtil = {}));
|
|
17
|
+
//# sourceMappingURL=relay-view-util.js.map
|
|
@@ -34,6 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.RelayDialog = RelayDialog;
|
|
37
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
38
|
+
const relay_protocol_1 = require("@celljs/ta-relay/lib/common/relay-protocol");
|
|
37
39
|
const lucide_react_1 = require("lucide-react");
|
|
38
40
|
const React = __importStar(require("react"));
|
|
39
41
|
const react_dom_1 = require("react-dom");
|
|
@@ -45,7 +47,10 @@ const busy_1 = require("./busy");
|
|
|
45
47
|
const icon_1 = require("./icon");
|
|
46
48
|
const picture_1 = require("./picture");
|
|
47
49
|
const qr_view_1 = require("./qr-view");
|
|
50
|
+
const relay_view_util_1 = require("./relay-view-util");
|
|
51
|
+
const serve_value_1 = require("./serve-value");
|
|
48
52
|
const settings_controls_1 = require("./settings-controls");
|
|
53
|
+
const RELAY_TOPICS = [ta_protocol_1.TaServeChanges.RELAY];
|
|
49
54
|
/** A phone and this computer, a relay between them, and a lock on what goes through. */
|
|
50
55
|
function RelayPicture() {
|
|
51
56
|
return (React.createElement(picture_1.Picture, { width: 240, height: 72, frame: false, className: "ta-relay-pic" },
|
|
@@ -62,19 +67,32 @@ function RelayPicture() {
|
|
|
62
67
|
React.createElement("circle", { className: "ta-pic-mark ta-pic-go", cx: "74", cy: "36", r: "3" }),
|
|
63
68
|
React.createElement("circle", { className: "ta-pic-mark ta-pic-go ta-pic-go-back", cx: "153", cy: "36", r: "3" })));
|
|
64
69
|
}
|
|
70
|
+
/** A device paired: its button turns until the relay forgot it. */
|
|
71
|
+
function RelayDeviceRow({ device, onUnpair }) {
|
|
72
|
+
const t = (0, use_t_1.useT)();
|
|
73
|
+
const [busy, run] = (0, busy_1.useBusy)();
|
|
74
|
+
return (React.createElement("div", { className: "ta-auth-row ta-relay-device" },
|
|
75
|
+
React.createElement(icon_1.Icon, { icon: lucide_react_1.Smartphone, size: 16 }),
|
|
76
|
+
React.createElement("span", { className: "ta-auth-name" }, device.name),
|
|
77
|
+
React.createElement("span", { className: "ta-auth-note" }, new Date(device.createdAt).toLocaleDateString()),
|
|
78
|
+
React.createElement(icon_1.IconButton, { icon: lucide_react_1.Trash2, label: t('ta.relay.unpair'), busy: busy, onClick: () => void run(onUnpair) })));
|
|
79
|
+
}
|
|
65
80
|
/** Using Ta from a phone: pair it through a relay, see and remove the devices paired. */
|
|
66
81
|
function RelayDialog({ onClose }) {
|
|
67
82
|
var _a, _b;
|
|
68
83
|
const t = (0, use_t_1.useT)();
|
|
69
84
|
const [, bench] = (0, hooks_1.useWorkbench)();
|
|
70
85
|
const [, notices] = (0, hooks_1.useNotices)();
|
|
71
|
-
const [info, setInfo] = React.useState();
|
|
72
86
|
const [link, setLink] = React.useState();
|
|
73
|
-
const [
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
const [busy, run] = (0, busy_1.useBusy)();
|
|
88
|
+
// Whether ta serve reached the relay shows as it does (TaServeChanges.RELAY), a moment after pairing.
|
|
89
|
+
const getRelay = React.useCallback(() => bench.relay.getRelay(), [bench]);
|
|
90
|
+
const { value: info, failed, read: load, set: setInfo } = (0, serve_value_1.useServeValue)(getRelay, { topics: RELAY_TOPICS });
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (failed) {
|
|
93
|
+
notices.error(failed);
|
|
94
|
+
}
|
|
95
|
+
}, [failed, notices]);
|
|
78
96
|
// The account of this computer: the phones that scan its code sign in to it, unless turned off.
|
|
79
97
|
const [account, setAccount] = React.useState();
|
|
80
98
|
React.useEffect(() => {
|
|
@@ -89,12 +107,6 @@ function RelayDialog({ onClose }) {
|
|
|
89
107
|
throw error;
|
|
90
108
|
}
|
|
91
109
|
};
|
|
92
|
-
React.useEffect(() => {
|
|
93
|
-
load();
|
|
94
|
-
// Whether ta serve reached the relay shows a moment after pairing.
|
|
95
|
-
const timer = setInterval(load, 3000);
|
|
96
|
-
return () => clearInterval(timer);
|
|
97
|
-
}, [load]);
|
|
98
110
|
(0, back_stack_1.useBackLayer)(true, onClose);
|
|
99
111
|
React.useEffect(() => {
|
|
100
112
|
const onKey = (event) => event.key === 'Escape' && onClose();
|
|
@@ -103,31 +115,23 @@ function RelayDialog({ onClose }) {
|
|
|
103
115
|
}, [onClose]);
|
|
104
116
|
const pair = async () => {
|
|
105
117
|
var _a;
|
|
106
|
-
if (!info
|
|
118
|
+
if (!info) {
|
|
107
119
|
return;
|
|
108
120
|
}
|
|
109
|
-
setBusy(true);
|
|
110
121
|
try {
|
|
111
|
-
|
|
122
|
+
// Named for the user, rather than asked: a name of the phone's, numbered (RelayViewUtil.nextName).
|
|
123
|
+
const paired = await bench.relay.pair((_a = info.relay) !== null && _a !== void 0 ? _a : info.defaultRelay, relay_view_util_1.RelayViewUtil.nextName(t('ta.relay.phone'), info.devices));
|
|
112
124
|
setLink(paired.link);
|
|
113
|
-
|
|
114
|
-
load();
|
|
125
|
+
void load();
|
|
115
126
|
}
|
|
116
127
|
catch (error) {
|
|
117
128
|
notices.error(error);
|
|
118
129
|
}
|
|
119
|
-
finally {
|
|
120
|
-
setBusy(false);
|
|
121
|
-
}
|
|
122
130
|
};
|
|
123
|
-
// The device being unpaired: its button turns until the relay forgot it.
|
|
124
|
-
const [unpairing, setUnpairing] = React.useState();
|
|
125
131
|
const unpair = async (device) => {
|
|
126
132
|
if (await notices.confirm({ title: t('ta.relay.unpairConfirm', { name: device.name }), confirmLabel: t('ta.relay.unpair'), danger: true })) {
|
|
127
|
-
setUnpairing(device.id);
|
|
128
133
|
await bench.relay.unpair(device.id).catch((error) => notices.error(error));
|
|
129
|
-
|
|
130
|
-
load();
|
|
134
|
+
void load();
|
|
131
135
|
}
|
|
132
136
|
};
|
|
133
137
|
const keepAwake = async (on) => {
|
|
@@ -150,8 +154,14 @@ function RelayDialog({ onClose }) {
|
|
|
150
154
|
link ? (React.createElement("div", { className: "ta-relay-pairing" },
|
|
151
155
|
React.createElement(qr_view_1.QrView, { text: link }),
|
|
152
156
|
React.createElement("p", null, t('ta.relay.scan')),
|
|
157
|
+
React.createElement("p", { className: "ta-relay-download" },
|
|
158
|
+
React.createElement(icon_1.Icon, { icon: lucide_react_1.Download, size: 14 }),
|
|
159
|
+
React.createElement("span", null,
|
|
160
|
+
t('ta.relay.noApp'),
|
|
161
|
+
' ',
|
|
162
|
+
React.createElement("a", { href: relay_protocol_1.RELAY_DOWNLOAD_PAGE, target: "_blank", rel: "noreferrer" }, t('ta.relay.download')))),
|
|
153
163
|
React.createElement("div", { className: "ta-auth-actions" },
|
|
154
|
-
React.createElement("button", { type: "button", className: "ta-button", onClick: () => { var _a; return
|
|
164
|
+
React.createElement("button", { type: "button", className: "ta-button", onClick: () => void run(() => { var _a; return (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(link).catch(() => undefined); }) },
|
|
155
165
|
React.createElement(icon_1.Icon, { icon: lucide_react_1.Copy, size: 15 }),
|
|
156
166
|
" ",
|
|
157
167
|
t('ta.auth.copyLink')),
|
|
@@ -159,21 +169,14 @@ function RelayDialog({ onClose }) {
|
|
|
159
169
|
React.createElement(RelayPicture, null),
|
|
160
170
|
React.createElement("p", null, t('ta.relay.hint')),
|
|
161
171
|
React.createElement("div", { className: "ta-relay-form" },
|
|
162
|
-
React.createElement("
|
|
163
|
-
React.createElement(lucide_react_1.Smartphone, { size: 15, strokeWidth: 1.75, "aria-hidden": "true" }),
|
|
164
|
-
React.createElement("input", { placeholder: t('ta.relay.phone'), value: name, onChange: event => setName(event.target.value) })),
|
|
165
|
-
React.createElement("button", { type: "button", className: busy ? 'ta-button ta-primary ta-busy' : 'ta-button ta-primary', "aria-busy": busy || undefined, disabled: !info, onClick: () => void pair() },
|
|
172
|
+
React.createElement("button", { type: "button", className: busy ? 'ta-button ta-primary ta-busy' : 'ta-button ta-primary', "aria-busy": busy || undefined, disabled: !info, onClick: () => void run(pair) },
|
|
166
173
|
t('ta.relay.pair'),
|
|
167
174
|
React.createElement(busy_1.BusyMark, { busy: busy }))))),
|
|
168
175
|
info && info.devices.length > 0 && (React.createElement("section", { className: "ta-auth-group" },
|
|
169
176
|
React.createElement("h3", null,
|
|
170
177
|
t('ta.relay.devices'),
|
|
171
178
|
React.createElement("span", { className: `ta-relay-state${info.online ? ' ta-on' : ''}` }, info.online ? t('ta.relay.online', { relay: relayHost }) : t('ta.relay.offline', { relay: relayHost }))),
|
|
172
|
-
info.devices.map(device => (React.createElement(
|
|
173
|
-
React.createElement(icon_1.Icon, { icon: lucide_react_1.Smartphone, size: 16 }),
|
|
174
|
-
React.createElement("span", { className: "ta-auth-name" }, device.name),
|
|
175
|
-
React.createElement("span", { className: "ta-auth-note" }, new Date(device.createdAt).toLocaleDateString()),
|
|
176
|
-
React.createElement(icon_1.IconButton, { icon: lucide_react_1.Trash2, label: t('ta.relay.unpair'), busy: unpairing === device.id, onClick: () => void unpair(device) })))))),
|
|
179
|
+
info.devices.map(device => (React.createElement(RelayDeviceRow, { key: device.id, device: device, onUnpair: () => unpair(device) }))))),
|
|
177
180
|
(account === null || account === void 0 ? void 0 : account.account) && !account.waiting && account.onScan !== undefined && (React.createElement("div", { className: "ta-relay-awake" },
|
|
178
181
|
React.createElement("span", { className: "ta-relay-awake-text" },
|
|
179
182
|
React.createElement("span", null, t('ta.relay.accountOnScan')),
|
|
@@ -45,6 +45,7 @@ const device_1 = require("../device/device");
|
|
|
45
45
|
const mini_program_1 = require("../device/mini-program");
|
|
46
46
|
const hooks_1 = require("../hooks");
|
|
47
47
|
const use_t_1 = require("../i18n/use-t");
|
|
48
|
+
const busy_1 = require("./busy");
|
|
48
49
|
const icon_1 = require("./icon");
|
|
49
50
|
const relay_view_1 = require("./relay-view");
|
|
50
51
|
const ta_avatar_1 = require("./ta-avatar");
|
|
@@ -142,7 +143,7 @@ function ScanView({ instructions, onCode, onClose, onAsk }) {
|
|
|
142
143
|
const [phase, setPhase] = React.useState({ kind: 'live' });
|
|
143
144
|
const [myCode, setMyCode] = React.useState(false);
|
|
144
145
|
const [text, setText] = React.useState('');
|
|
145
|
-
const [sending,
|
|
146
|
+
const [sending, run] = (0, busy_1.useBusy)();
|
|
146
147
|
const [missed, setMissed] = React.useState(false);
|
|
147
148
|
const camera = useCamera(video, facing);
|
|
148
149
|
React.useEffect(() => {
|
|
@@ -251,10 +252,9 @@ function ScanView({ instructions, onCode, onClose, onAsk }) {
|
|
|
251
252
|
}
|
|
252
253
|
};
|
|
253
254
|
const ask = async (prompt) => {
|
|
254
|
-
if (phase.kind !== 'photo' ||
|
|
255
|
+
if (phase.kind !== 'photo' || !onAsk) {
|
|
255
256
|
return;
|
|
256
257
|
}
|
|
257
|
-
setSending(true);
|
|
258
258
|
try {
|
|
259
259
|
await onAsk(prompt, code_vision_1.CodeVision.image(phase.url));
|
|
260
260
|
close();
|
|
@@ -262,9 +262,6 @@ function ScanView({ instructions, onCode, onClose, onAsk }) {
|
|
|
262
262
|
catch (_a) {
|
|
263
263
|
// Said by onAsk; the photo stays to send again.
|
|
264
264
|
}
|
|
265
|
-
finally {
|
|
266
|
-
setSending(false);
|
|
267
|
-
}
|
|
268
265
|
};
|
|
269
266
|
const problem = camera.error === 'denied' ? 'ta.hosts.cameraDenied' : camera.error === 'failed' ? 'ta.scan.cameraFailed' : undefined;
|
|
270
267
|
const said = missed ? 'ta.scan.noCodeFound' : problem;
|
|
@@ -298,10 +295,10 @@ function ScanView({ instructions, onCode, onClose, onAsk }) {
|
|
|
298
295
|
event.target.value = '';
|
|
299
296
|
} }))) : (React.createElement("form", { className: "ta-scan-sheet", onSubmit: event => {
|
|
300
297
|
event.preventDefault();
|
|
301
|
-
void ask(text.trim() || t('ta.scan.identifyPrompt'));
|
|
298
|
+
void run(() => ask(text.trim() || t('ta.scan.identifyPrompt')));
|
|
302
299
|
} },
|
|
303
300
|
React.createElement("div", { className: "ta-scan-sheet-title" }, t(phase.noCode ? 'ta.scan.noCode' : 'ta.scan.askTitle')),
|
|
304
|
-
React.createElement("div", { className: "ta-scan-chips" }, ASKS.map(each => (React.createElement("button", { key: each.label, type: "button", className: "ta-scan-chip", disabled: sending, onClick: () => void ask(t(each.prompt)) }, t(each.label))))),
|
|
301
|
+
React.createElement("div", { className: "ta-scan-chips" }, ASKS.map(each => (React.createElement("button", { key: each.label, type: "button", className: "ta-scan-chip", disabled: sending, onClick: () => void run(() => ask(t(each.prompt))) }, t(each.label))))),
|
|
305
302
|
React.createElement("div", { className: "ta-scan-field" },
|
|
306
303
|
React.createElement("input", { value: text, placeholder: t('ta.scan.askPlaceholder'), "aria-label": t('ta.scan.askPlaceholder'), enterKeyHint: "send", onChange: event => setText(event.target.value) }),
|
|
307
304
|
React.createElement("button", { type: "submit", className: "ta-scan-send", "aria-label": t('ta.send'), disabled: sending }, sending ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(icon_1.Icon, { icon: lucide_react_1.ArrowUp, size: 18 }))))),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ScreenPlace } from '../screen/screen-protocol';
|
|
3
|
+
import type { AppShellState } from './app-shell-state';
|
|
3
4
|
/** What the shell knows of where it is, as AppShell renders: the navigator reads the latest. */
|
|
4
5
|
export interface ShellPlaces {
|
|
5
6
|
phone: boolean;
|
|
@@ -28,4 +29,12 @@ export interface ShellPlaces {
|
|
|
28
29
|
* what the agent reads and where it goes. Called before AppShell returns anything else, as hooks are.
|
|
29
30
|
*/
|
|
30
31
|
export declare function useScreenNavigator(): React.RefObject<ShellPlaces | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Where the shell is and where it goes, as AppShell renders (docs/design/ta-app-use.md 3): what it sets on the ref of
|
|
34
|
+
* useScreenNavigator. `go` is how the shell closes the screen of a phone and picks a tab.
|
|
35
|
+
*/
|
|
36
|
+
export declare function shellPlaces(shell: AppShellState, go: {
|
|
37
|
+
closeScreen(): void;
|
|
38
|
+
pickTab(id: string): void;
|
|
39
|
+
}): ShellPlaces;
|
|
31
40
|
//# sourceMappingURL=screen-navigator.d.ts.map
|
|
@@ -34,9 +34,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.useScreenNavigator = useScreenNavigator;
|
|
37
|
+
exports.shellPlaces = shellPlaces;
|
|
37
38
|
const react_1 = require("@celljs/react");
|
|
38
39
|
const React = __importStar(require("react"));
|
|
40
|
+
const web_extension_protocol_1 = require("../extension/web-extension-protocol");
|
|
39
41
|
const screen_protocol_1 = require("../screen/screen-protocol");
|
|
42
|
+
const nav_places_1 = require("./nav-places");
|
|
40
43
|
const screen_navigator_util_1 = require("./screen-navigator-util");
|
|
41
44
|
/**
|
|
42
45
|
* The shell as TaScreen's navigator (docs/design/ta-app-use.md 3): what AppShell sets on the ref as it renders is
|
|
@@ -80,4 +83,86 @@ function useScreenNavigator() {
|
|
|
80
83
|
}, [screen]);
|
|
81
84
|
return shell;
|
|
82
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Where the shell is and where it goes, as AppShell renders (docs/design/ta-app-use.md 3): what it sets on the ref of
|
|
88
|
+
* useScreenNavigator. `go` is how the shell closes the screen of a phone and picks a tab.
|
|
89
|
+
*/
|
|
90
|
+
function shellPlaces(shell, go) {
|
|
91
|
+
var _a;
|
|
92
|
+
const { t, phone, settingsShown, settings, setSettings, screenOpen, screenPage, tabView, tabPage, setTabPage, view, sideShown, lists, side, setSideId, navigation, openSettings, host, setNavOpen, sidebar, workbench, store, } = shell;
|
|
93
|
+
const { closeScreen, pickTab } = go;
|
|
94
|
+
const chatName = (entry) => entry.sessionName || entry.firstMessage || t('ta.chat.new');
|
|
95
|
+
const shownChat = store ? workbench.sessions.find(session => session.sessionId === store.sessionId) : undefined;
|
|
96
|
+
return {
|
|
97
|
+
phone,
|
|
98
|
+
where: screen_navigator_util_1.ScreenNavigatorUtil.where({
|
|
99
|
+
settings: settingsShown ? (settings !== null && settings !== void 0 ? settings : '') : undefined,
|
|
100
|
+
page: phone ? (screenOpen ? screenPage : tabView) : tabPage === 'discover' ? undefined : view,
|
|
101
|
+
discover: tabPage === 'discover',
|
|
102
|
+
me: phone && !screenOpen && tabPage === 'me',
|
|
103
|
+
list: (phone ? !screenOpen && !tabView && !tabPage : sideShown) ? (_a = lists.find(entry => entry.id === side)) === null || _a === void 0 ? void 0 : _a.label : undefined,
|
|
104
|
+
chat: (phone ? screenOpen && !screenPage && settings === undefined : settings === undefined && tabPage !== 'discover' && !view)
|
|
105
|
+
? shownChat
|
|
106
|
+
? chatName(shownChat)
|
|
107
|
+
: t('ta.chat.new')
|
|
108
|
+
: undefined,
|
|
109
|
+
words: { settings: t('ta.settings'), discover: t('ta.discover'), me: t('ta.me') },
|
|
110
|
+
}),
|
|
111
|
+
places: [
|
|
112
|
+
...lists.map(entry => ({ id: `list:${entry.id}`, title: entry.label })),
|
|
113
|
+
...navigation.pages.map(page => ({
|
|
114
|
+
id: `page:${page.id}`,
|
|
115
|
+
title: web_extension_protocol_1.WebLabelUtil.text(page.title),
|
|
116
|
+
})),
|
|
117
|
+
...navigation.onOpen.map(page => ({ id: `page:${page.id}`, title: page.title })),
|
|
118
|
+
{ id: 'discover', title: t('ta.discover') },
|
|
119
|
+
...(phone ? [{ id: 'me', title: t('ta.me') }] : []),
|
|
120
|
+
{ id: 'settings', title: t('ta.settings') },
|
|
121
|
+
],
|
|
122
|
+
goPlace: place => {
|
|
123
|
+
const [kind, id = ''] = place.id.split(/:(.*)/s);
|
|
124
|
+
if (kind === 'settings') {
|
|
125
|
+
return openSettings();
|
|
126
|
+
}
|
|
127
|
+
if (kind === 'page') {
|
|
128
|
+
return host.showView(id);
|
|
129
|
+
}
|
|
130
|
+
if (phone) {
|
|
131
|
+
// The tabs are under the screen of a phone: what is over them slides away, as the back does.
|
|
132
|
+
if (screenOpen) {
|
|
133
|
+
closeScreen();
|
|
134
|
+
}
|
|
135
|
+
return pickTab(kind === 'list' ? id : kind === 'me' ? nav_places_1.ME_TAB : nav_places_1.DISCOVER);
|
|
136
|
+
}
|
|
137
|
+
setSettings(undefined);
|
|
138
|
+
setNavOpen(false);
|
|
139
|
+
if (kind === 'discover') {
|
|
140
|
+
setTabPage('discover');
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
setTabPage(undefined);
|
|
144
|
+
setSideId(id);
|
|
145
|
+
if (view) {
|
|
146
|
+
host.showPage('');
|
|
147
|
+
}
|
|
148
|
+
sidebar.reveal();
|
|
149
|
+
},
|
|
150
|
+
showChat: async (target) => {
|
|
151
|
+
const switcher = host.sessionSwitcher();
|
|
152
|
+
if (!switcher) {
|
|
153
|
+
throw new Error('The page cannot show a conversation yet.');
|
|
154
|
+
}
|
|
155
|
+
const shown = switcher('sessionId' in target ? target.sessionId : { sessionFile: target.sessionFile });
|
|
156
|
+
host.showPage('');
|
|
157
|
+
await shown;
|
|
158
|
+
},
|
|
159
|
+
chats: [
|
|
160
|
+
...workbench.sessions
|
|
161
|
+
.filter(session => !session.group)
|
|
162
|
+
.map(session => ({ name: chatName(session), sessionId: session.sessionId, sessionFile: session.sessionFile })),
|
|
163
|
+
...workbench.saved.filter(saved => !saved.group).map(saved => ({ name: chatName(saved), sessionFile: saved.sessionFile })),
|
|
164
|
+
],
|
|
165
|
+
openSettings,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
83
168
|
//# sourceMappingURL=screen-navigator.js.map
|
|
@@ -102,8 +102,15 @@ const Row = React.memo(function Row({ item, query, onMenu, }) {
|
|
|
102
102
|
React.createElement("span", { className: "ta-launcher-result-text" },
|
|
103
103
|
React.createElement("span", { className: "ta-launcher-result-title" }, launcher_search_util_1.LauncherSearchUtil.marks(item.title, query).map((part, index) => part.match ? React.createElement("mark", { key: index }, part.text) : React.createElement(React.Fragment, { key: index }, part.text))),
|
|
104
104
|
item.detail && React.createElement("span", { className: "ta-launcher-result-detail" }, item.detail))),
|
|
105
|
-
item.action &&
|
|
105
|
+
item.action && React.createElement(ResultAction, { action: item.action })));
|
|
106
106
|
});
|
|
107
|
+
/** The button beside a result (WebSearchItem.action): it turns until what it does is done, a second tap doing nothing. */
|
|
108
|
+
function ResultAction({ action }) {
|
|
109
|
+
const [busy, run] = (0, busy_1.useBusy)();
|
|
110
|
+
return (React.createElement("button", { type: "button", className: busy ? 'ta-launcher-result-action ta-busy' : 'ta-launcher-result-action', onClick: () => void run(() => action.run()).catch(() => undefined) },
|
|
111
|
+
React.createElement(busy_1.BusyMark, { busy: busy }),
|
|
112
|
+
action.label));
|
|
113
|
+
}
|
|
107
114
|
/** Asks for the next page when the end of a section comes into view. */
|
|
108
115
|
function MoreSentinel({ onMore }) {
|
|
109
116
|
const ref = React.useRef(null);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface ServeValueOptions<T> {
|
|
3
|
+
/** What it is of: read anew (and shown empty meanwhile) when it changes. */
|
|
4
|
+
key?: unknown;
|
|
5
|
+
/** The topics of TaServeChanges (ta serve's, or its gateway's) that tell it changed. */
|
|
6
|
+
topics?: readonly string[];
|
|
7
|
+
/** Another that tells it changed: what the page keeps itself (the account of the app's own device). */
|
|
8
|
+
changes?: (listener: () => void) => () => void;
|
|
9
|
+
/** Read again every so many ms while shown: only for what the server cannot know (a service elsewhere). */
|
|
10
|
+
every?: number;
|
|
11
|
+
/** What to show of the next read, given what shows: the one before when the same, not drawn again for nothing. */
|
|
12
|
+
same?: (previous: T | undefined, next: T) => T | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What a page shows of ta serve itself (docs: AGENTS.md "What a page shows of a host is told, not polled"), as
|
|
16
|
+
* `ui.useHost` is for a package's host: read now, again as soon as ta serve tells one of `topics` changed
|
|
17
|
+
* (TaClient.onHostChanged of TaServeChanges.NAME), as the connection comes back and as a hidden page shows; never while
|
|
18
|
+
* hidden. A ta serve of before tells nothing: what it shows is read again as the page shows and after what the user did.
|
|
19
|
+
* Without `load`, nothing is read.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useServeValue<T>(load: (() => Promise<T>) | undefined, options?: ServeValueOptions<T>): {
|
|
22
|
+
value: T | undefined;
|
|
23
|
+
failed: unknown;
|
|
24
|
+
read: () => Promise<void>;
|
|
25
|
+
readAt: number | undefined;
|
|
26
|
+
set: React.Dispatch<React.SetStateAction<T | undefined>>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=serve-value.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.useServeValue = useServeValue;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
const hooks_1 = require("../hooks");
|
|
39
|
+
const serve_watch_1 = require("./serve-watch");
|
|
40
|
+
/**
|
|
41
|
+
* What a page shows of ta serve itself (docs: AGENTS.md "What a page shows of a host is told, not polled"), as
|
|
42
|
+
* `ui.useHost` is for a package's host: read now, again as soon as ta serve tells one of `topics` changed
|
|
43
|
+
* (TaClient.onHostChanged of TaServeChanges.NAME), as the connection comes back and as a hidden page shows; never while
|
|
44
|
+
* hidden. A ta serve of before tells nothing: what it shows is read again as the page shows and after what the user did.
|
|
45
|
+
* Without `load`, nothing is read.
|
|
46
|
+
*/
|
|
47
|
+
function useServeValue(load, options = {}) {
|
|
48
|
+
var _a;
|
|
49
|
+
const [, bench] = (0, hooks_1.useWorkbench)();
|
|
50
|
+
const [value, setValue] = React.useState();
|
|
51
|
+
const [failed, setFailed] = React.useState();
|
|
52
|
+
const [readAt, setReadAt] = React.useState();
|
|
53
|
+
const current = React.useRef({ load, options });
|
|
54
|
+
current.current = { load, options };
|
|
55
|
+
/** Of which `key`, while shown: a read of one before, or after the page went, is not shown. */
|
|
56
|
+
const generation = React.useRef(0);
|
|
57
|
+
const read = React.useCallback(async () => {
|
|
58
|
+
const reading = current.current.load;
|
|
59
|
+
if (!reading) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const at = generation.current;
|
|
63
|
+
try {
|
|
64
|
+
const next = await reading();
|
|
65
|
+
if (at === generation.current) {
|
|
66
|
+
const same = current.current.options.same;
|
|
67
|
+
setValue(previous => (same ? same(previous, next) : next));
|
|
68
|
+
setFailed(undefined);
|
|
69
|
+
setReadAt(Date.now());
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (at === generation.current) {
|
|
74
|
+
setFailed(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}, []);
|
|
78
|
+
const enabled = !!load;
|
|
79
|
+
const { key, topics, changes, every } = options;
|
|
80
|
+
const topicsKey = (_a = topics === null || topics === void 0 ? void 0 : topics.join('\n')) !== null && _a !== void 0 ? _a : '';
|
|
81
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: read anew whenever what is read changes
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
generation.current++;
|
|
84
|
+
if (!enabled) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
setValue(undefined);
|
|
88
|
+
void read();
|
|
89
|
+
const stop = serve_watch_1.ServeWatch.start({ server: bench, topics: topicsKey ? topicsKey.split('\n') : [], changes, every, read: () => void read() });
|
|
90
|
+
return () => {
|
|
91
|
+
generation.current++;
|
|
92
|
+
stop();
|
|
93
|
+
};
|
|
94
|
+
}, [enabled, key, topicsKey, changes, every, bench, read]);
|
|
95
|
+
return { value, failed, read, readAt, set: setValue };
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=serve-value.js.map
|