@celljs/ta-web 4.9.0 → 4.10.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/README.en.md +4 -3
- package/README.md +4 -3
- package/esm/browser/assistant/assistant-chat-list.js +8 -2
- package/esm/browser/assistant/assistant-extension.d.ts +8 -1
- package/esm/browser/assistant/assistant-extension.js +33 -5
- package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
- package/esm/browser/assistant/assistant-task-source.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-source.js +2 -0
- package/esm/browser/assistant/assistant-task-util.d.ts +8 -0
- package/esm/browser/assistant/assistant-task-util.js +13 -3
- package/esm/browser/assistant/assistant-tasks.js +3 -2
- package/esm/browser/assistant/assistant-view.js +81 -56
- package/esm/browser/assistant/assistant.d.ts +30 -1
- package/esm/browser/assistant/assistant.js +89 -6
- package/esm/browser/assistant/task-views.d.ts +40 -6
- package/esm/browser/assistant/task-views.js +73 -21
- package/esm/browser/avatar/dino-avatar.d.ts +3 -4
- package/esm/browser/avatar/dino-avatar.js +4 -178
- package/esm/browser/avatar/dino-face.d.ts +19 -0
- package/esm/browser/avatar/dino-face.js +142 -0
- package/esm/browser/avatar/dino-geometry.d.ts +11 -0
- package/esm/browser/avatar/dino-geometry.js +38 -0
- package/esm/browser/avatar/dino-kinds.d.ts +15 -0
- package/esm/browser/avatar/dino-kinds.js +544 -0
- package/esm/browser/avatar/dino-motion.js +1 -1
- package/esm/browser/avatar/dino-shape.d.ts +80 -0
- package/esm/browser/avatar/dino-shape.js +113 -0
- package/esm/browser/avatar/dino-species.d.ts +1 -61
- package/esm/browser/avatar/dino-species.js +2 -653
- package/esm/browser/chat/chat-packages.d.ts +39 -0
- package/esm/browser/chat/chat-packages.js +70 -0
- package/esm/browser/chat/chat-protocol.d.ts +23 -1
- package/esm/browser/chat/chat-stores.d.ts +59 -0
- package/esm/browser/chat/chat-stores.js +121 -0
- package/esm/browser/chat/chat-util.d.ts +17 -0
- package/esm/browser/chat/chat-util.js +61 -0
- package/esm/browser/chat/chat-view.js +33 -12
- package/esm/browser/chat/chat.d.ts +31 -39
- package/esm/browser/chat/chat.js +226 -175
- package/esm/browser/components/access-view.js +1 -1
- package/esm/browser/components/account-menu.js +1 -1
- package/esm/browser/components/app-nav.d.ts +6 -3
- package/esm/browser/components/app-nav.js +19 -10
- package/esm/browser/components/app-shell-hooks.d.ts +47 -0
- package/esm/browser/components/app-shell-hooks.js +169 -0
- package/esm/browser/components/app-view.js +81 -172
- package/esm/browser/components/auth-view.js +1 -1
- package/esm/browser/components/chat-list.d.ts +20 -2
- package/esm/browser/components/chat-list.js +138 -22
- package/esm/browser/components/composer-box.d.ts +5 -5
- package/esm/browser/components/composer-box.js +111 -4
- package/esm/browser/components/composer.d.ts +7 -0
- package/esm/browser/components/composer.js +22 -14
- package/esm/browser/components/connection-bar.js +50 -17
- package/esm/browser/components/context-menu.d.ts +30 -4
- package/esm/browser/components/context-menu.js +199 -37
- package/esm/browser/components/conversation-scroll.d.ts +129 -6
- package/esm/browser/components/conversation-scroll.js +429 -109
- package/esm/browser/components/dino.js +1 -1
- package/esm/browser/components/earlier-messages.d.ts +2 -1
- package/esm/browser/components/earlier-messages.js +2 -17
- package/esm/browser/components/editor-area.d.ts +3 -1
- package/esm/browser/components/editor-area.js +6 -5
- package/esm/browser/components/empty-pictures.d.ts +0 -2
- package/esm/browser/components/empty-pictures.js +0 -16
- package/esm/browser/components/folder-picker.d.ts +5 -2
- package/esm/browser/components/folder-picker.js +30 -9
- package/esm/browser/components/held-talk.d.ts +28 -0
- package/esm/browser/components/held-talk.js +76 -0
- package/esm/browser/components/host-view.d.ts +1 -1
- package/esm/browser/components/host-view.js +1 -1
- package/esm/browser/components/icon.d.ts +2 -2
- package/esm/browser/components/icon.js +5 -6
- package/esm/browser/components/image-viewer.d.ts +124 -0
- package/esm/browser/components/image-viewer.js +397 -0
- package/esm/browser/components/lightbox.d.ts +11 -0
- package/esm/browser/components/lightbox.js +24 -0
- package/esm/browser/components/markdown.d.ts +6 -2
- package/esm/browser/components/markdown.js +24 -10
- package/esm/browser/components/media.js +1 -10
- package/esm/browser/components/message-footer.d.ts +16 -2
- package/esm/browser/components/message-footer.js +29 -12
- package/esm/browser/components/message-list.d.ts +24 -3
- package/esm/browser/components/message-list.js +149 -20
- package/esm/browser/components/message-menu.d.ts +3 -1
- package/esm/browser/components/message-menu.js +18 -3
- package/esm/browser/components/nav-places.d.ts +16 -1
- package/esm/browser/components/nav-places.js +12 -3
- package/esm/browser/components/phone-shell.d.ts +4 -1
- package/esm/browser/components/phone-shell.js +3 -1
- package/esm/browser/components/run-status.js +3 -3
- package/esm/browser/components/select-bar.d.ts +9 -0
- package/esm/browser/components/select-bar.js +24 -0
- package/esm/browser/components/session-settings.d.ts +6 -0
- package/esm/browser/components/session-settings.js +14 -1
- package/esm/browser/components/session-view.js +8 -4
- package/esm/browser/components/settings-choices.d.ts +35 -0
- package/esm/browser/components/settings-choices.js +117 -0
- package/esm/browser/components/settings-parts.d.ts +21 -0
- package/esm/browser/components/settings-parts.js +323 -0
- package/esm/browser/components/settings-view.d.ts +0 -6
- package/esm/browser/components/settings-view.js +4 -406
- package/esm/browser/components/swipe-row.d.ts +2 -2
- package/esm/browser/components/swipe-row.js +7 -3
- package/esm/browser/components/tool-view.js +14 -12
- package/esm/browser/components/voice-button.d.ts +1 -1
- package/esm/browser/components/voice-button.js +1 -1
- package/esm/browser/components/voice-talk.d.ts +43 -0
- package/esm/browser/components/voice-talk.js +222 -0
- package/esm/browser/components/workbench-view.js +1 -1
- package/esm/browser/device/device.d.ts +3 -0
- package/esm/browser/device/device.js +11 -1
- package/esm/browser/device/hold.d.ts +42 -0
- package/esm/browser/device/hold.js +136 -0
- package/esm/browser/device/launch-screen.d.ts +1 -1
- package/esm/browser/device/launch-screen.js +1 -1
- package/esm/browser/device/long-press.d.ts +2 -0
- package/esm/browser/device/long-press.js +16 -1
- package/esm/browser/device/pull-down.d.ts +4 -2
- package/esm/browser/device/pull-down.js +64 -76
- package/esm/browser/device/row-swipe.d.ts +35 -10
- package/esm/browser/device/row-swipe.js +149 -71
- package/esm/browser/device/shake-undo.d.ts +16 -0
- package/esm/browser/device/shake-undo.js +59 -0
- package/esm/browser/device/sheet-swipe.d.ts +118 -18
- package/esm/browser/device/sheet-swipe.js +406 -107
- package/esm/browser/extension/icons.js +2 -1
- package/esm/browser/extension/web-extension-api.d.ts +135 -2
- package/esm/browser/extension/web-extension-code.d.ts +6 -0
- package/esm/browser/extension/web-extension-code.js +24 -0
- package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
- package/esm/browser/extension/web-extension-protocol.js +8 -0
- package/esm/browser/extension/web-extensions.d.ts +14 -1
- package/esm/browser/extension/web-extensions.js +128 -24
- package/esm/browser/extension/web-tasks.d.ts +9 -1
- package/esm/browser/extension/web-tasks.js +24 -0
- package/esm/browser/files/files-protocol.d.ts +25 -0
- package/esm/browser/files/files-protocol.js +2 -0
- package/esm/browser/files/files.d.ts +35 -0
- package/esm/browser/files/files.js +119 -0
- package/esm/browser/hooks.d.ts +3 -1
- package/esm/browser/hooks.js +8 -0
- package/esm/browser/i18n/locales.d.ts +29 -2
- package/esm/browser/i18n/messages.d.ts +28 -1
- package/esm/browser/i18n/messages.js +58 -4
- package/esm/browser/index.d.ts +6 -0
- package/esm/browser/index.js +6 -0
- package/esm/browser/notices/notices-protocol.d.ts +9 -1
- package/esm/browser/notices/notices.d.ts +2 -0
- package/esm/browser/notices/notices.js +20 -10
- package/esm/browser/offline/device-values.d.ts +55 -0
- package/esm/browser/offline/device-values.js +142 -0
- package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
- package/esm/browser/offline/kept-chats-protocol.js +2 -0
- package/esm/browser/offline/kept-chats.d.ts +47 -0
- package/esm/browser/offline/kept-chats.js +146 -0
- package/esm/browser/offline/offline-reads.d.ts +44 -0
- package/esm/browser/offline/offline-reads.js +107 -0
- package/esm/browser/settings/settings-protocol.d.ts +2 -0
- package/esm/browser/settings/settings-protocol.js +2 -0
- package/esm/browser/style/conversation.d.ts +1 -1
- package/esm/browser/style/conversation.js +57 -17
- package/esm/browser/style/device.js +43 -4
- package/esm/browser/style/layout.d.ts +1 -1
- package/esm/browser/style/layout.js +67 -15
- package/esm/browser/style/pages.d.ts +1 -1
- package/esm/browser/style/pages.js +2 -1
- package/esm/browser/style/shell.d.ts +1 -1
- package/esm/browser/style/shell.js +47 -3
- package/esm/browser/style/tasks.d.ts +1 -1
- package/esm/browser/style/tasks.js +2 -0
- package/esm/browser/util/frame.d.ts +5 -4
- package/esm/browser/util/frame.js +5 -4
- package/esm/browser/util/markdown.d.ts +18 -1
- package/esm/browser/util/markdown.js +119 -5
- package/esm/browser/util/process.d.ts +21 -0
- package/esm/browser/util/process.js +45 -1
- package/esm/browser/util/voice.d.ts +5 -2
- package/esm/browser/util/voice.js +6 -3
- package/esm/browser/util/zoom.d.ts +46 -0
- package/esm/browser/util/zoom.js +96 -0
- package/esm/browser/workbench-calls.d.ts +59 -0
- package/esm/browser/workbench-calls.js +141 -0
- package/esm/browser/workbench-protocol.d.ts +5 -1
- package/esm/browser/workbench-util.d.ts +68 -0
- package/esm/browser/workbench-util.js +145 -0
- package/esm/browser/workbench.d.ts +15 -42
- package/esm/browser/workbench.js +53 -167
- package/lib/browser/assistant/assistant-chat-list.js +8 -2
- package/lib/browser/assistant/assistant-extension.d.ts +8 -1
- package/lib/browser/assistant/assistant-extension.js +33 -5
- package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
- package/lib/browser/assistant/assistant-task-source.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-source.js +2 -0
- package/lib/browser/assistant/assistant-task-util.d.ts +8 -0
- package/lib/browser/assistant/assistant-task-util.js +13 -3
- package/lib/browser/assistant/assistant-tasks.js +2 -1
- package/lib/browser/assistant/assistant-view.js +78 -53
- package/lib/browser/assistant/assistant.d.ts +30 -1
- package/lib/browser/assistant/assistant.js +89 -6
- package/lib/browser/assistant/task-views.d.ts +40 -6
- package/lib/browser/assistant/task-views.js +74 -21
- package/lib/browser/avatar/dino-avatar.d.ts +3 -4
- package/lib/browser/avatar/dino-avatar.js +27 -202
- package/lib/browser/avatar/dino-face.d.ts +20 -0
- package/lib/browser/avatar/dino-face.js +148 -0
- package/lib/browser/avatar/dino-geometry.d.ts +12 -0
- package/lib/browser/avatar/dino-geometry.js +47 -0
- package/lib/browser/avatar/dino-kinds.d.ts +16 -0
- package/lib/browser/avatar/dino-kinds.js +547 -0
- package/lib/browser/avatar/dino-motion.js +2 -2
- package/lib/browser/avatar/dino-shape.d.ts +81 -0
- package/lib/browser/avatar/dino-shape.js +126 -0
- package/lib/browser/avatar/dino-species.d.ts +1 -61
- package/lib/browser/avatar/dino-species.js +34 -687
- package/lib/browser/chat/chat-packages.d.ts +40 -0
- package/lib/browser/chat/chat-packages.js +74 -0
- package/lib/browser/chat/chat-protocol.d.ts +23 -1
- package/lib/browser/chat/chat-stores.d.ts +60 -0
- package/lib/browser/chat/chat-stores.js +125 -0
- package/lib/browser/chat/chat-util.d.ts +18 -0
- package/lib/browser/chat/chat-util.js +64 -0
- package/lib/browser/chat/chat-view.js +33 -12
- package/lib/browser/chat/chat.d.ts +31 -39
- package/lib/browser/chat/chat.js +227 -176
- package/lib/browser/components/access-view.js +2 -2
- package/lib/browser/components/account-menu.js +2 -2
- package/lib/browser/components/app-nav.d.ts +6 -3
- package/lib/browser/components/app-nav.js +17 -8
- package/lib/browser/components/app-shell-hooks.d.ts +48 -0
- package/lib/browser/components/app-shell-hooks.js +211 -0
- package/lib/browser/components/app-view.js +89 -180
- package/lib/browser/components/auth-view.js +3 -3
- package/lib/browser/components/chat-list.d.ts +20 -2
- package/lib/browser/components/chat-list.js +137 -21
- package/lib/browser/components/composer-box.d.ts +5 -5
- package/lib/browser/components/composer-box.js +111 -4
- package/lib/browser/components/composer.d.ts +7 -0
- package/lib/browser/components/composer.js +22 -14
- package/lib/browser/components/connection-bar.js +48 -15
- package/lib/browser/components/context-menu.d.ts +30 -4
- package/lib/browser/components/context-menu.js +198 -36
- package/lib/browser/components/conversation-scroll.d.ts +129 -6
- package/lib/browser/components/conversation-scroll.js +431 -110
- package/lib/browser/components/dino.js +3 -3
- package/lib/browser/components/earlier-messages.d.ts +2 -1
- package/lib/browser/components/earlier-messages.js +2 -17
- package/lib/browser/components/editor-area.d.ts +3 -1
- package/lib/browser/components/editor-area.js +5 -4
- package/lib/browser/components/empty-pictures.d.ts +0 -2
- package/lib/browser/components/empty-pictures.js +0 -17
- package/lib/browser/components/folder-picker.d.ts +5 -2
- package/lib/browser/components/folder-picker.js +30 -9
- package/lib/browser/components/held-talk.d.ts +29 -0
- package/lib/browser/components/held-talk.js +79 -0
- package/lib/browser/components/host-view.d.ts +1 -1
- package/lib/browser/components/host-view.js +5 -5
- package/lib/browser/components/icon.d.ts +2 -2
- package/lib/browser/components/icon.js +7 -6
- package/lib/browser/components/image-viewer.d.ts +125 -0
- package/lib/browser/components/image-viewer.js +435 -0
- package/lib/browser/components/lightbox.d.ts +12 -0
- package/lib/browser/components/lightbox.js +60 -0
- package/lib/browser/components/markdown.d.ts +6 -2
- package/lib/browser/components/markdown.js +24 -10
- package/lib/browser/components/media.js +2 -11
- package/lib/browser/components/message-footer.d.ts +16 -2
- package/lib/browser/components/message-footer.js +31 -12
- package/lib/browser/components/message-list.d.ts +24 -3
- package/lib/browser/components/message-list.js +146 -16
- package/lib/browser/components/message-menu.d.ts +3 -1
- package/lib/browser/components/message-menu.js +17 -2
- package/lib/browser/components/nav-places.d.ts +16 -1
- package/lib/browser/components/nav-places.js +13 -3
- package/lib/browser/components/phone-shell.d.ts +4 -1
- package/lib/browser/components/phone-shell.js +3 -1
- package/lib/browser/components/run-status.js +3 -3
- package/lib/browser/components/select-bar.d.ts +10 -0
- package/lib/browser/components/select-bar.js +61 -0
- package/lib/browser/components/session-settings.d.ts +6 -0
- package/lib/browser/components/session-settings.js +14 -1
- package/lib/browser/components/session-view.js +7 -3
- package/lib/browser/components/settings-choices.d.ts +36 -0
- package/lib/browser/components/settings-choices.js +156 -0
- package/lib/browser/components/settings-parts.d.ts +22 -0
- package/lib/browser/components/settings-parts.js +359 -0
- package/lib/browser/components/settings-view.d.ts +0 -6
- package/lib/browser/components/settings-view.js +2 -405
- package/lib/browser/components/swipe-row.d.ts +2 -2
- package/lib/browser/components/swipe-row.js +7 -3
- package/lib/browser/components/tool-view.js +14 -12
- package/lib/browser/components/voice-button.d.ts +1 -1
- package/lib/browser/components/voice-button.js +1 -1
- package/lib/browser/components/voice-talk.d.ts +44 -0
- package/lib/browser/components/voice-talk.js +260 -0
- package/lib/browser/components/workbench-view.js +3 -3
- package/lib/browser/device/device.d.ts +3 -0
- package/lib/browser/device/device.js +11 -1
- package/lib/browser/device/hold.d.ts +43 -0
- package/lib/browser/device/hold.js +173 -0
- package/lib/browser/device/launch-screen.d.ts +1 -1
- package/lib/browser/device/launch-screen.js +1 -1
- package/lib/browser/device/long-press.d.ts +2 -0
- package/lib/browser/device/long-press.js +16 -1
- package/lib/browser/device/pull-down.d.ts +4 -2
- package/lib/browser/device/pull-down.js +63 -75
- package/lib/browser/device/row-swipe.d.ts +35 -10
- package/lib/browser/device/row-swipe.js +148 -70
- package/lib/browser/device/shake-undo.d.ts +17 -0
- package/lib/browser/device/shake-undo.js +63 -0
- package/lib/browser/device/sheet-swipe.d.ts +118 -18
- package/lib/browser/device/sheet-swipe.js +410 -108
- package/lib/browser/extension/icons.js +1 -0
- package/lib/browser/extension/web-extension-api.d.ts +135 -2
- package/lib/browser/extension/web-extension-code.d.ts +6 -0
- package/lib/browser/extension/web-extension-code.js +24 -0
- package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
- package/lib/browser/extension/web-extension-protocol.js +9 -1
- package/lib/browser/extension/web-extensions.d.ts +14 -1
- package/lib/browser/extension/web-extensions.js +125 -21
- package/lib/browser/extension/web-tasks.d.ts +9 -1
- package/lib/browser/extension/web-tasks.js +24 -0
- package/lib/browser/files/files-protocol.d.ts +26 -0
- package/lib/browser/files/files-protocol.js +5 -0
- package/lib/browser/files/files.d.ts +36 -0
- package/lib/browser/files/files.js +122 -0
- package/lib/browser/hooks.d.ts +3 -1
- package/lib/browser/hooks.js +9 -0
- package/lib/browser/i18n/locales.d.ts +29 -2
- package/lib/browser/i18n/messages.d.ts +28 -1
- package/lib/browser/i18n/messages.js +58 -4
- package/lib/browser/index.d.ts +6 -0
- package/lib/browser/index.js +6 -0
- package/lib/browser/notices/notices-protocol.d.ts +9 -1
- package/lib/browser/notices/notices.d.ts +2 -0
- package/lib/browser/notices/notices.js +20 -10
- package/lib/browser/offline/device-values.d.ts +56 -0
- package/lib/browser/offline/device-values.js +148 -0
- package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
- package/lib/browser/offline/kept-chats-protocol.js +5 -0
- package/lib/browser/offline/kept-chats.d.ts +48 -0
- package/lib/browser/offline/kept-chats.js +149 -0
- package/lib/browser/offline/offline-reads.d.ts +45 -0
- package/lib/browser/offline/offline-reads.js +111 -0
- package/lib/browser/settings/settings-protocol.d.ts +2 -0
- package/lib/browser/settings/settings-protocol.js +2 -0
- package/lib/browser/style/conversation.d.ts +1 -1
- package/lib/browser/style/conversation.js +57 -17
- package/lib/browser/style/device.js +43 -4
- package/lib/browser/style/layout.d.ts +1 -1
- package/lib/browser/style/layout.js +67 -15
- package/lib/browser/style/pages.d.ts +1 -1
- package/lib/browser/style/pages.js +2 -1
- package/lib/browser/style/shell.d.ts +1 -1
- package/lib/browser/style/shell.js +47 -3
- package/lib/browser/style/tasks.d.ts +1 -1
- package/lib/browser/style/tasks.js +2 -0
- package/lib/browser/util/frame.d.ts +5 -4
- package/lib/browser/util/frame.js +5 -4
- package/lib/browser/util/markdown.d.ts +18 -1
- package/lib/browser/util/markdown.js +119 -5
- package/lib/browser/util/process.d.ts +21 -0
- package/lib/browser/util/process.js +46 -2
- package/lib/browser/util/voice.d.ts +5 -2
- package/lib/browser/util/voice.js +6 -3
- package/lib/browser/util/zoom.d.ts +47 -0
- package/lib/browser/util/zoom.js +99 -0
- package/lib/browser/workbench-calls.d.ts +60 -0
- package/lib/browser/workbench-calls.js +145 -0
- package/lib/browser/workbench-protocol.d.ts +5 -1
- package/lib/browser/workbench-util.d.ts +69 -0
- package/lib/browser/workbench-util.js +151 -0
- package/lib/browser/workbench.d.ts +15 -42
- package/lib/browser/workbench.js +74 -189
- package/package.json +10 -10
- package/public/launch.svg +46 -42
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkbenchUtil = exports.WorkbenchError = exports.PAGE_BYTES = exports.SWITCH_MS = exports.STORE_WAIT_MS = exports.KEPT_AFTER_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, and read before the
|
|
23
|
+
* first frame; the conversations and what web extensions read are kept in IndexedDB (offline/).
|
|
24
|
+
*/
|
|
25
|
+
const LISTS_KEY = 'ta.lists';
|
|
26
|
+
/**
|
|
27
|
+
* While the page connects, how long a call that reads waits for the connection before it answers as it did
|
|
28
|
+
* last time (OfflineReads): through a relay the page is mostly online within it, and gets what is new.
|
|
29
|
+
*/
|
|
30
|
+
exports.KEPT_AFTER_MS = 1000;
|
|
31
|
+
/** How long a call of a conversation waits for a connection the page never had, as TaConnection's `waitForOpenMs`. */
|
|
32
|
+
exports.STORE_WAIT_MS = 5000;
|
|
33
|
+
/** How long the page shows which computer it switches to before it loads again for it. */
|
|
34
|
+
exports.SWITCH_MS = 160;
|
|
35
|
+
/** A conversation opens with about this much of its latest messages, its earlier ones loaded as much at a time when scrolled to. */
|
|
36
|
+
exports.PAGE_BYTES = 128 * 1024;
|
|
37
|
+
/** Why a computer added while another is in use was not switched to. */
|
|
38
|
+
class WorkbenchError extends Error {
|
|
39
|
+
constructor(reason) {
|
|
40
|
+
super(reason === 'refused' ? 'The computer refused this device.' : 'The computer did not answer.');
|
|
41
|
+
this.reason = reason;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.WorkbenchError = WorkbenchError;
|
|
45
|
+
var WorkbenchUtil;
|
|
46
|
+
(function (WorkbenchUtil) {
|
|
47
|
+
/** A pairing link (`ta pair`) or else a token. */
|
|
48
|
+
function credential(text) {
|
|
49
|
+
try {
|
|
50
|
+
return { pairing: ta_relay_1.RelayPairingUtil.parse(text) };
|
|
51
|
+
}
|
|
52
|
+
catch (_a) {
|
|
53
|
+
return { token: text };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
WorkbenchUtil.credential = credential;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the ta serve in use runs on another machine than this browser: reached through a relay, from
|
|
59
|
+
* the app, or at an address that is not this machine's. A sign-in there cannot come back to it by itself.
|
|
60
|
+
*/
|
|
61
|
+
function elsewhere(hostId, hostname = typeof location === 'undefined' ? '' : location.hostname) {
|
|
62
|
+
return isApp() || Boolean(hostId === null || hostId === void 0 ? void 0 : hostId.startsWith('relay ')) || !['localhost', '127.0.0.1', '[::1]', '::1'].includes(hostname);
|
|
63
|
+
}
|
|
64
|
+
WorkbenchUtil.elsewhere = elsewhere;
|
|
65
|
+
/** In the Ta app on a phone, where no ta serve serves the page: it reaches one through a relay. */
|
|
66
|
+
function isApp() {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
return Boolean((_b = (_a = globalThis.Capacitor) === null || _a === void 0 ? void 0 : _a.isNativePlatform) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
69
|
+
}
|
|
70
|
+
WorkbenchUtil.isApp = isApp;
|
|
71
|
+
function readPairing(text) {
|
|
72
|
+
try {
|
|
73
|
+
return text ? ta_relay_1.RelayPairingUtil.parse(ta_relay_1.RelayPairingUtil.link(JSON.parse(text))) : undefined;
|
|
74
|
+
}
|
|
75
|
+
catch (_a) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
WorkbenchUtil.readPairing = readPairing;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the server of the page answers at all. A WebSocket that does not open cannot say why: a
|
|
82
|
+
* server that answers refused the token; none means ta serve is not running (the installed app opens
|
|
83
|
+
* from its service worker then).
|
|
84
|
+
*/
|
|
85
|
+
async function reachable(base, fetcher = fetch) {
|
|
86
|
+
try {
|
|
87
|
+
await fetcher(base, { method: 'HEAD', cache: 'no-store' });
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
catch (_a) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
WorkbenchUtil.reachable = reachable;
|
|
95
|
+
/** The hosts kept in `storage`; the token or pairing an older version kept becomes the first. */
|
|
96
|
+
function readHosts(storage, now = Date.now()) {
|
|
97
|
+
const text = storage === null || storage === void 0 ? void 0 : storage.getItem(hosts_1.HostUtil.KEY);
|
|
98
|
+
if (text || !storage) {
|
|
99
|
+
return hosts_1.HostUtil.read(text);
|
|
100
|
+
}
|
|
101
|
+
const pairing = readPairing(storage.getItem(PAIRING_KEY));
|
|
102
|
+
const token = storage.getItem(TOKEN_KEY);
|
|
103
|
+
const credential = pairing ? { pairing } : token ? { token } : undefined;
|
|
104
|
+
storage.removeItem(PAIRING_KEY);
|
|
105
|
+
storage.removeItem(TOKEN_KEY);
|
|
106
|
+
return credential ? hosts_1.HostUtil.use({ hosts: [] }, serverOf(credential, pageHost()), credential, now) : { hosts: [] };
|
|
107
|
+
}
|
|
108
|
+
WorkbenchUtil.readHosts = readHosts;
|
|
109
|
+
/** Which ta serve a credential reaches, to know whose lists were kept. */
|
|
110
|
+
function serverOf(credential, host) {
|
|
111
|
+
return 'pairing' in credential ? `relay ${credential.pairing.relay} ${credential.pairing.host}` : `serve ${host}`;
|
|
112
|
+
}
|
|
113
|
+
WorkbenchUtil.serverOf = serverOf;
|
|
114
|
+
/** Where the lists of `of` are kept: each computer has its own, to show at once when switched to. */
|
|
115
|
+
function listsKey(of) {
|
|
116
|
+
return `${LISTS_KEY} ${of}`;
|
|
117
|
+
}
|
|
118
|
+
WorkbenchUtil.listsKey = listsKey;
|
|
119
|
+
/** The lists kept for `of`, none running: whether one runs is known once connected. */
|
|
120
|
+
function readLists(text, of) {
|
|
121
|
+
try {
|
|
122
|
+
const kept = text ? JSON.parse(text) : undefined;
|
|
123
|
+
if ((kept === null || kept === void 0 ? void 0 : kept.of) !== of || !Array.isArray(kept.sessions) || !Array.isArray(kept.saved)) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
return { server: kept.server, sessions: kept.sessions.map(session => ({ ...session, isStreaming: false })), saved: kept.saved };
|
|
127
|
+
}
|
|
128
|
+
catch (_a) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
WorkbenchUtil.readLists = readLists;
|
|
133
|
+
/** `previous` if `next` is the same, so that what shows it is not drawn again. */
|
|
134
|
+
function same(previous, next) {
|
|
135
|
+
return JSON.stringify(previous) === JSON.stringify(next) ? previous : next;
|
|
136
|
+
}
|
|
137
|
+
WorkbenchUtil.same = same;
|
|
138
|
+
function retryDelay(attempt) {
|
|
139
|
+
return RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];
|
|
140
|
+
}
|
|
141
|
+
WorkbenchUtil.retryDelay = retryDelay;
|
|
142
|
+
})(WorkbenchUtil || (exports.WorkbenchUtil = WorkbenchUtil = {}));
|
|
143
|
+
/** None where the page is not in a browser (tests). */
|
|
144
|
+
function storage() {
|
|
145
|
+
return typeof localStorage === 'undefined' ? undefined : localStorage;
|
|
146
|
+
}
|
|
147
|
+
/** The ta serve that serves the page, whose token a sign-in without a pairing is for. */
|
|
148
|
+
function pageHost() {
|
|
149
|
+
return typeof location === 'undefined' ? '' : location.host;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=workbench-util.js.map
|
|
@@ -1,43 +1,9 @@
|
|
|
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';
|
|
4
|
+
import { WorkbenchCalls } from './workbench-calls';
|
|
5
5
|
import { type Credential, TaWorkbench, type WorkbenchState } from './workbench-protocol';
|
|
6
|
-
type ServiceName
|
|
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
|
-
}
|
|
6
|
+
import { type ServiceName } from './workbench-util';
|
|
41
7
|
export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
42
8
|
protected list: HostList;
|
|
43
9
|
protected current: WorkbenchState;
|
|
@@ -51,13 +17,20 @@ export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
|
51
17
|
protected graceMs: number;
|
|
52
18
|
/** The ta serve of the sign-in of now, whose lists are kept as they change. */
|
|
53
19
|
protected listsOf?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The calls of the services and of the stores, to the connection of the time; answered from the device
|
|
22
|
+
* while offline, for the computer in use from the start (web extensions started from the device read
|
|
23
|
+
* before the page connects).
|
|
24
|
+
*/
|
|
25
|
+
protected readonly calls: WorkbenchCalls;
|
|
54
26
|
/** Those waiting for the connection (`connected`): `resolve` once online, `reject` once signed out. */
|
|
55
|
-
protected readonly beforeConnection: Map<ServiceName, object>;
|
|
56
27
|
protected readonly connectedWaiters: Set<{
|
|
57
28
|
resolve(): void;
|
|
58
29
|
reject(error: Error): void;
|
|
59
30
|
}>;
|
|
60
31
|
protected waking: boolean;
|
|
32
|
+
protected refreshing?: Promise<void>;
|
|
33
|
+
protected refreshAgain?: Promise<void>;
|
|
61
34
|
/** Counts sign-ins and sign-outs: an attempt of an earlier one does nothing when it ends. */
|
|
62
35
|
protected generation: number;
|
|
63
36
|
protected readonly listeners: Set<(state: WorkbenchState) => void>;
|
|
@@ -76,10 +49,6 @@ export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
|
76
49
|
get gateway(): TaGatewayServer;
|
|
77
50
|
get relay(): TaRelayServer;
|
|
78
51
|
get remote(): TaRemoteServer;
|
|
79
|
-
/**
|
|
80
|
-
* A service of the connection; before there is one (the lists of the last time show meanwhile), its
|
|
81
|
-
* calls wait for it, and fail if the page signs out instead.
|
|
82
|
-
*/
|
|
83
52
|
protected service<K extends ServiceName>(name: K): TaConnection[K];
|
|
84
53
|
protected signedIn(): TaConnection;
|
|
85
54
|
onTerminalData(listener: (terminalId: string, data: string, exitCode?: number) => void): () => void;
|
|
@@ -119,7 +88,12 @@ export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
|
119
88
|
signOut(): void;
|
|
120
89
|
connected(): Promise<void>;
|
|
121
90
|
reconnect(): void;
|
|
91
|
+
/**
|
|
92
|
+
* One read of the lists at a time: asked again meanwhile, one more follows it for all who asked, so that
|
|
93
|
+
* reads on a slow network do not pile up.
|
|
94
|
+
*/
|
|
122
95
|
refresh(): Promise<void>;
|
|
96
|
+
protected readLists(): Promise<void>;
|
|
123
97
|
createStore(sessionId: string, options?: SessionStoreOptions): SessionStore;
|
|
124
98
|
/** The prompts of ssh that wait for an answer, from now and those already there. */
|
|
125
99
|
protected watchRemote(connection: TaConnection): Promise<void>;
|
|
@@ -134,5 +108,4 @@ export declare class TaWorkbenchImpl implements TaWorkbench {
|
|
|
134
108
|
protected update(change: Partial<WorkbenchState>): void;
|
|
135
109
|
protected keepLists(of: string): void;
|
|
136
110
|
}
|
|
137
|
-
export {};
|
|
138
111
|
//# sourceMappingURL=workbench.d.ts.map
|
package/lib/browser/workbench.js
CHANGED
|
@@ -6,158 +6,40 @@ 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 =
|
|
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");
|
|
13
13
|
const ta_relay_1 = require("@celljs/ta-relay");
|
|
14
14
|
const hosts_1 = require("./hosts");
|
|
15
|
+
const device_values_1 = require("./offline/device-values");
|
|
15
16
|
const state_protocol_1 = require("./state/state-protocol");
|
|
17
|
+
const workbench_calls_1 = require("./workbench-calls");
|
|
16
18
|
const workbench_protocol_1 = require("./workbench-protocol");
|
|
17
|
-
|
|
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
|
-
}
|
|
19
|
+
const workbench_util_1 = require("./workbench-util");
|
|
153
20
|
let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
154
21
|
constructor() {
|
|
155
|
-
this.list = WorkbenchUtil.readHosts(storage());
|
|
22
|
+
this.list = workbench_util_1.WorkbenchUtil.readHosts((0, workbench_util_1.storage)());
|
|
156
23
|
this.current = { status: 'connecting', hosts: this.list.hosts, host: this.list.current, sessions: [], saved: [] };
|
|
157
24
|
this.attempts = 0;
|
|
158
|
-
this.graceMs = GRACE_MS;
|
|
25
|
+
this.graceMs = workbench_util_1.GRACE_MS;
|
|
26
|
+
/**
|
|
27
|
+
* The calls of the services and of the stores, to the connection of the time; answered from the device
|
|
28
|
+
* while offline, for the computer in use from the start (web extensions started from the device read
|
|
29
|
+
* before the page connects).
|
|
30
|
+
*/
|
|
31
|
+
this.calls = new workbench_calls_1.WorkbenchCalls({
|
|
32
|
+
status: () => this.current.status,
|
|
33
|
+
connection: () => this.connection,
|
|
34
|
+
connected: () => this.connected(),
|
|
35
|
+
subscribe: listener => this.subscribe(listener),
|
|
36
|
+
dataChanged: (name, keys, cwd) => {
|
|
37
|
+
for (const listener of this.extensionDataListeners) {
|
|
38
|
+
listener(name, keys, cwd);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
}, this.list.current);
|
|
159
42
|
/** Those waiting for the connection (`connected`): `resolve` once online, `reject` once signed out. */
|
|
160
|
-
this.beforeConnection = new Map();
|
|
161
43
|
this.connectedWaiters = new Set();
|
|
162
44
|
this.waking = false;
|
|
163
45
|
/** Counts sign-ins and sign-outs: an attempt of an earlier one does nothing when it ends. */
|
|
@@ -201,32 +83,8 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
201
83
|
get remote() {
|
|
202
84
|
return this.service('remote');
|
|
203
85
|
}
|
|
204
|
-
/**
|
|
205
|
-
* A service of the connection; before there is one (the lists of the last time show meanwhile), its
|
|
206
|
-
* calls wait for it, and fail if the page signs out instead.
|
|
207
|
-
*/
|
|
208
86
|
service(name) {
|
|
209
|
-
|
|
210
|
-
return this.connection[name];
|
|
211
|
-
}
|
|
212
|
-
// The same each time, as the connection's are: what is given it is not drawn again for nothing.
|
|
213
|
-
const known = this.beforeConnection.get(name);
|
|
214
|
-
if (known) {
|
|
215
|
-
return known;
|
|
216
|
-
}
|
|
217
|
-
const service = new Proxy({}, {
|
|
218
|
-
get: (_target, method) =>
|
|
219
|
-
// Not a promise itself.
|
|
220
|
-
method === 'then'
|
|
221
|
-
? undefined
|
|
222
|
-
: async (...params) => {
|
|
223
|
-
await this.connected();
|
|
224
|
-
const real = this.signedIn()[name];
|
|
225
|
-
return real[method](...params);
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
this.beforeConnection.set(name, service);
|
|
229
|
-
return service;
|
|
87
|
+
return this.calls.service(name);
|
|
230
88
|
}
|
|
231
89
|
signedIn() {
|
|
232
90
|
if (!this.connection) {
|
|
@@ -265,7 +123,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
265
123
|
history.replaceState(null, '', location.pathname + location.search);
|
|
266
124
|
}
|
|
267
125
|
if (fromUrl) {
|
|
268
|
-
this.keepHosts(hosts_1.HostUtil.use(this.list, WorkbenchUtil.serverOf({ token: fromUrl }, pageHost()), { token: fromUrl }, Date.now()));
|
|
126
|
+
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
127
|
}
|
|
270
128
|
const host = this.list.hosts.find(one => one.id === this.list.current);
|
|
271
129
|
if (host) {
|
|
@@ -276,8 +134,8 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
276
134
|
}
|
|
277
135
|
}
|
|
278
136
|
async signIn(text) {
|
|
279
|
-
const credential = WorkbenchUtil.credential(text.trim());
|
|
280
|
-
const id = WorkbenchUtil.serverOf(credential, pageHost());
|
|
137
|
+
const credential = workbench_util_1.WorkbenchUtil.credential(text.trim());
|
|
138
|
+
const id = workbench_util_1.WorkbenchUtil.serverOf(credential, (0, workbench_util_1.pageHost)());
|
|
281
139
|
if (this.current.status === 'signed-out' || id === this.current.host) {
|
|
282
140
|
this.keepHosts(hosts_1.HostUtil.use(this.list, id, credential, Date.now()));
|
|
283
141
|
await this.connectWith(credential);
|
|
@@ -326,13 +184,13 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
326
184
|
let timer;
|
|
327
185
|
try {
|
|
328
186
|
const late = new Promise((_, reject) => {
|
|
329
|
-
timer = setTimeout(() => reject(new WorkbenchError('unreachable')), PROBE_MS);
|
|
187
|
+
timer = setTimeout(() => reject(new workbench_util_1.WorkbenchError('unreachable')), workbench_util_1.PROBE_MS);
|
|
330
188
|
});
|
|
331
189
|
await Promise.race([connection.connect(), late]);
|
|
332
190
|
return await Promise.race([connection.server.getServerInfo(), late]);
|
|
333
191
|
}
|
|
334
192
|
catch (error) {
|
|
335
|
-
throw error instanceof WorkbenchError ? error : new WorkbenchError((await refused()) ? 'refused' : 'unreachable');
|
|
193
|
+
throw error instanceof workbench_util_1.WorkbenchError ? error : new workbench_util_1.WorkbenchError((await refused()) ? 'refused' : 'unreachable');
|
|
336
194
|
}
|
|
337
195
|
finally {
|
|
338
196
|
clearTimeout(timer);
|
|
@@ -345,7 +203,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
345
203
|
*/
|
|
346
204
|
load(hostId) {
|
|
347
205
|
this.update({ switching: hostId });
|
|
348
|
-
setTimeout(() => this.reload(), SWITCH_MS);
|
|
206
|
+
setTimeout(() => this.reload(), workbench_util_1.SWITCH_MS);
|
|
349
207
|
}
|
|
350
208
|
reload() {
|
|
351
209
|
location.reload();
|
|
@@ -353,11 +211,12 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
353
211
|
/** A host off this device, with what the page kept of it. */
|
|
354
212
|
drop(hostId) {
|
|
355
213
|
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));
|
|
214
|
+
const kept = (0, workbench_util_1.storage)();
|
|
215
|
+
kept === null || kept === void 0 ? void 0 : kept.removeItem(workbench_util_1.WorkbenchUtil.listsKey(hostId));
|
|
358
216
|
if (kept) {
|
|
359
217
|
state_protocol_1.StateUtil.forgetHost(kept, hostId);
|
|
360
218
|
}
|
|
219
|
+
void device_values_1.OfflineKeys.forget((0, device_values_1.deviceValues)(), hostId);
|
|
361
220
|
if (this.listsOf === hostId) {
|
|
362
221
|
this.listsOf = undefined;
|
|
363
222
|
}
|
|
@@ -366,7 +225,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
366
225
|
var _a;
|
|
367
226
|
this.list = list;
|
|
368
227
|
try {
|
|
369
|
-
(_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(hosts_1.HostUtil.KEY, JSON.stringify(list));
|
|
228
|
+
(_a = (0, workbench_util_1.storage)()) === null || _a === void 0 ? void 0 : _a.setItem(hosts_1.HostUtil.KEY, JSON.stringify(list));
|
|
370
229
|
}
|
|
371
230
|
catch (_b) {
|
|
372
231
|
// Full: kept for this page.
|
|
@@ -378,11 +237,12 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
378
237
|
var _c;
|
|
379
238
|
this.stopRetrying();
|
|
380
239
|
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.close();
|
|
381
|
-
const of = WorkbenchUtil.serverOf(credential, pageHost());
|
|
240
|
+
const of = workbench_util_1.WorkbenchUtil.serverOf(credential, (0, workbench_util_1.pageHost)());
|
|
382
241
|
if (of !== this.listsOf) {
|
|
383
242
|
// Another ta serve: its lists of the last time, or none, rather than those of the one before.
|
|
384
243
|
this.listsOf = of;
|
|
385
|
-
this.
|
|
244
|
+
this.calls.reads.use(of);
|
|
245
|
+
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
246
|
}
|
|
387
247
|
this.update({ status: 'connecting', error: undefined });
|
|
388
248
|
await this.connect(credential);
|
|
@@ -402,11 +262,11 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
402
262
|
}
|
|
403
263
|
if (wasRefused) {
|
|
404
264
|
// Unpaired on the computer, or a token of before: of no use any more.
|
|
405
|
-
this.drop(WorkbenchUtil.serverOf(credential, pageHost()));
|
|
265
|
+
this.drop(workbench_util_1.WorkbenchUtil.serverOf(credential, (0, workbench_util_1.pageHost)()));
|
|
406
266
|
this.update({ status: 'signed-out', error: 'refused', server: undefined, sessions: [], saved: [] });
|
|
407
267
|
}
|
|
408
268
|
else {
|
|
409
|
-
const delay = WorkbenchUtil.retryDelay(this.attempts++);
|
|
269
|
+
const delay = workbench_util_1.WorkbenchUtil.retryDelay(this.attempts++);
|
|
410
270
|
this.retry = () => {
|
|
411
271
|
clearTimeout(this.retryTimer);
|
|
412
272
|
this.retry = undefined;
|
|
@@ -453,6 +313,11 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
453
313
|
void this.watchRemote(connection);
|
|
454
314
|
});
|
|
455
315
|
void this.watchRemote(connection);
|
|
316
|
+
if ('pairing' in credential) {
|
|
317
|
+
// Through a relay the computer has let the page in once the socket is open, and no gateway is behind
|
|
318
|
+
// it: the calls of the page go now, with the one that reads who it is, not a round trip after it.
|
|
319
|
+
this.update({ status: 'online', error: undefined, retryAt: undefined });
|
|
320
|
+
}
|
|
456
321
|
let server;
|
|
457
322
|
try {
|
|
458
323
|
server = await connection.server.getServerInfo();
|
|
@@ -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
|
|
@@ -525,7 +390,27 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
525
390
|
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.reconnect();
|
|
526
391
|
}
|
|
527
392
|
}
|
|
528
|
-
|
|
393
|
+
/**
|
|
394
|
+
* One read of the lists at a time: asked again meanwhile, one more follows it for all who asked, so that
|
|
395
|
+
* reads on a slow network do not pile up.
|
|
396
|
+
*/
|
|
397
|
+
refresh() {
|
|
398
|
+
var _a;
|
|
399
|
+
if (!this.refreshing) {
|
|
400
|
+
this.refreshing = this.readLists().finally(() => {
|
|
401
|
+
this.refreshing = undefined;
|
|
402
|
+
});
|
|
403
|
+
return this.refreshing;
|
|
404
|
+
}
|
|
405
|
+
(_a = this.refreshAgain) !== null && _a !== void 0 ? _a : (this.refreshAgain = this.refreshing
|
|
406
|
+
.catch(() => undefined)
|
|
407
|
+
.then(() => {
|
|
408
|
+
this.refreshAgain = undefined;
|
|
409
|
+
return this.refresh();
|
|
410
|
+
}));
|
|
411
|
+
return this.refreshAgain;
|
|
412
|
+
}
|
|
413
|
+
async readLists() {
|
|
529
414
|
// A ta serve of before has no saved sessions to list: its list stays the open ones. The default
|
|
530
415
|
// directory comes along, as another device may have changed it.
|
|
531
416
|
const [sessions, saved, server] = await Promise.all([
|
|
@@ -536,16 +421,13 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
536
421
|
sessions.sort((a, b) => b.createdAt - a.createdAt);
|
|
537
422
|
// Read every few seconds and mostly the same: what shows them is not drawn again for nothing.
|
|
538
423
|
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),
|
|
424
|
+
sessions: workbench_util_1.WorkbenchUtil.same(this.current.sessions, sessions),
|
|
425
|
+
saved: workbench_util_1.WorkbenchUtil.same(this.current.saved, saved),
|
|
426
|
+
server: workbench_util_1.WorkbenchUtil.same(this.current.server, server),
|
|
542
427
|
});
|
|
543
428
|
}
|
|
544
429
|
createStore(sessionId, options) {
|
|
545
|
-
|
|
546
|
-
throw new Error('Not signed in to ta serve.');
|
|
547
|
-
}
|
|
548
|
-
return new ta_client_1.SessionStore(this.connection, sessionId, { pageBytes: PAGE_BYTES, ...options });
|
|
430
|
+
return new ta_client_1.SessionStore(this.calls.link, sessionId, { pageBytes: workbench_util_1.PAGE_BYTES, ...options });
|
|
549
431
|
}
|
|
550
432
|
/** The prompts of ssh that wait for an answer, from now and those already there. */
|
|
551
433
|
async watchRemote(connection) {
|
|
@@ -634,6 +516,9 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
634
516
|
if (this.listsOf && (next.sessions !== before.sessions || next.saved !== before.saved || next.server !== before.server)) {
|
|
635
517
|
this.keepLists(this.listsOf);
|
|
636
518
|
}
|
|
519
|
+
if (before.status !== 'online') {
|
|
520
|
+
this.calls.online();
|
|
521
|
+
}
|
|
637
522
|
}
|
|
638
523
|
}
|
|
639
524
|
keepLists(of) {
|
|
@@ -641,7 +526,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
641
526
|
const { server, sessions, saved } = this.current;
|
|
642
527
|
const kept = { of, server, sessions, saved };
|
|
643
528
|
try {
|
|
644
|
-
(_a = storage()) === null || _a === void 0 ? void 0 : _a.setItem(WorkbenchUtil.listsKey(of), JSON.stringify(kept));
|
|
529
|
+
(_a = (0, workbench_util_1.storage)()) === null || _a === void 0 ? void 0 : _a.setItem(workbench_util_1.WorkbenchUtil.listsKey(of), JSON.stringify(kept));
|
|
645
530
|
}
|
|
646
531
|
catch (_b) {
|
|
647
532
|
// Full: the next start waits for the server, as it would without.
|