@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,145 @@
|
|
|
1
|
+
import { RelayPairingUtil } from '@celljs/ta-relay';
|
|
2
|
+
import { HostUtil } from './hosts.js';
|
|
3
|
+
/** Before the list of hosts (HostUtil.KEY): the one token or pairing, taken into the list once. */
|
|
4
|
+
const TOKEN_KEY = 'ta.token';
|
|
5
|
+
const PAIRING_KEY = 'ta.pairing';
|
|
6
|
+
/** How long a computer added while another is in use has to answer before it counts as unreachable. */
|
|
7
|
+
export const PROBE_MS = 15000;
|
|
8
|
+
/** Waits between attempts while ta serve is not running: doubling up to the last. */
|
|
9
|
+
const RETRY_DELAYS_MS = [1000, 2000, 4000, 8000];
|
|
10
|
+
/**
|
|
11
|
+
* How long the connection is down, while the page is seen, before the user is told (`offlineShown`):
|
|
12
|
+
* the first tries to connect again are within it, so a short drop shows nothing.
|
|
13
|
+
*/
|
|
14
|
+
export const GRACE_MS = 2500;
|
|
15
|
+
/**
|
|
16
|
+
* The lists of the last time, of the ta serve they were of: the next start shows them at once while it
|
|
17
|
+
* connects, as a phone's app shows its chats before it is online. They are small, and read before the
|
|
18
|
+
* first frame; the conversations and what web extensions read are kept in IndexedDB (offline/).
|
|
19
|
+
*/
|
|
20
|
+
const LISTS_KEY = 'ta.lists';
|
|
21
|
+
/**
|
|
22
|
+
* While the page connects, how long a call that reads waits for the connection before it answers as it did
|
|
23
|
+
* last time (OfflineReads): through a relay the page is mostly online within it, and gets what is new.
|
|
24
|
+
*/
|
|
25
|
+
export const KEPT_AFTER_MS = 1000;
|
|
26
|
+
/** How long a call of a conversation waits for a connection the page never had, as TaConnection's `waitForOpenMs`. */
|
|
27
|
+
export const STORE_WAIT_MS = 5000;
|
|
28
|
+
/** How long the page shows which computer it switches to before it loads again for it. */
|
|
29
|
+
export const SWITCH_MS = 160;
|
|
30
|
+
/** A conversation opens with about this much of its latest messages, its earlier ones loaded as much at a time when scrolled to. */
|
|
31
|
+
export const PAGE_BYTES = 128 * 1024;
|
|
32
|
+
/** Why a computer added while another is in use was not switched to. */
|
|
33
|
+
export class WorkbenchError extends Error {
|
|
34
|
+
constructor(reason) {
|
|
35
|
+
super(reason === 'refused' ? 'The computer refused this device.' : 'The computer did not answer.');
|
|
36
|
+
this.reason = reason;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export var WorkbenchUtil;
|
|
40
|
+
(function (WorkbenchUtil) {
|
|
41
|
+
/** A pairing link (`ta pair`) or else a token. */
|
|
42
|
+
function credential(text) {
|
|
43
|
+
try {
|
|
44
|
+
return { pairing: RelayPairingUtil.parse(text) };
|
|
45
|
+
}
|
|
46
|
+
catch (_a) {
|
|
47
|
+
return { token: text };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
WorkbenchUtil.credential = credential;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the ta serve in use runs on another machine than this browser: reached through a relay, from
|
|
53
|
+
* the app, or at an address that is not this machine's. A sign-in there cannot come back to it by itself.
|
|
54
|
+
*/
|
|
55
|
+
function elsewhere(hostId, hostname = typeof location === 'undefined' ? '' : location.hostname) {
|
|
56
|
+
return isApp() || Boolean(hostId === null || hostId === void 0 ? void 0 : hostId.startsWith('relay ')) || !['localhost', '127.0.0.1', '[::1]', '::1'].includes(hostname);
|
|
57
|
+
}
|
|
58
|
+
WorkbenchUtil.elsewhere = elsewhere;
|
|
59
|
+
/** In the Ta app on a phone, where no ta serve serves the page: it reaches one through a relay. */
|
|
60
|
+
function isApp() {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
return Boolean((_b = (_a = globalThis.Capacitor) === null || _a === void 0 ? void 0 : _a.isNativePlatform) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
63
|
+
}
|
|
64
|
+
WorkbenchUtil.isApp = isApp;
|
|
65
|
+
function readPairing(text) {
|
|
66
|
+
try {
|
|
67
|
+
return text ? RelayPairingUtil.parse(RelayPairingUtil.link(JSON.parse(text))) : undefined;
|
|
68
|
+
}
|
|
69
|
+
catch (_a) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
WorkbenchUtil.readPairing = readPairing;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the server of the page answers at all. A WebSocket that does not open cannot say why: a
|
|
76
|
+
* server that answers refused the token; none means ta serve is not running (the installed app opens
|
|
77
|
+
* from its service worker then).
|
|
78
|
+
*/
|
|
79
|
+
async function reachable(base, fetcher = fetch) {
|
|
80
|
+
try {
|
|
81
|
+
await fetcher(base, { method: 'HEAD', cache: 'no-store' });
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
catch (_a) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
WorkbenchUtil.reachable = reachable;
|
|
89
|
+
/** The hosts kept in `storage`; the token or pairing an older version kept becomes the first. */
|
|
90
|
+
function readHosts(storage, now = Date.now()) {
|
|
91
|
+
const text = storage === null || storage === void 0 ? void 0 : storage.getItem(HostUtil.KEY);
|
|
92
|
+
if (text || !storage) {
|
|
93
|
+
return HostUtil.read(text);
|
|
94
|
+
}
|
|
95
|
+
const pairing = readPairing(storage.getItem(PAIRING_KEY));
|
|
96
|
+
const token = storage.getItem(TOKEN_KEY);
|
|
97
|
+
const credential = pairing ? { pairing } : token ? { token } : undefined;
|
|
98
|
+
storage.removeItem(PAIRING_KEY);
|
|
99
|
+
storage.removeItem(TOKEN_KEY);
|
|
100
|
+
return credential ? HostUtil.use({ hosts: [] }, serverOf(credential, pageHost()), credential, now) : { hosts: [] };
|
|
101
|
+
}
|
|
102
|
+
WorkbenchUtil.readHosts = readHosts;
|
|
103
|
+
/** Which ta serve a credential reaches, to know whose lists were kept. */
|
|
104
|
+
function serverOf(credential, host) {
|
|
105
|
+
return 'pairing' in credential ? `relay ${credential.pairing.relay} ${credential.pairing.host}` : `serve ${host}`;
|
|
106
|
+
}
|
|
107
|
+
WorkbenchUtil.serverOf = serverOf;
|
|
108
|
+
/** Where the lists of `of` are kept: each computer has its own, to show at once when switched to. */
|
|
109
|
+
function listsKey(of) {
|
|
110
|
+
return `${LISTS_KEY} ${of}`;
|
|
111
|
+
}
|
|
112
|
+
WorkbenchUtil.listsKey = listsKey;
|
|
113
|
+
/** The lists kept for `of`, none running: whether one runs is known once connected. */
|
|
114
|
+
function readLists(text, of) {
|
|
115
|
+
try {
|
|
116
|
+
const kept = text ? JSON.parse(text) : undefined;
|
|
117
|
+
if ((kept === null || kept === void 0 ? void 0 : kept.of) !== of || !Array.isArray(kept.sessions) || !Array.isArray(kept.saved)) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
return { server: kept.server, sessions: kept.sessions.map(session => ({ ...session, isStreaming: false })), saved: kept.saved };
|
|
121
|
+
}
|
|
122
|
+
catch (_a) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
WorkbenchUtil.readLists = readLists;
|
|
127
|
+
/** `previous` if `next` is the same, so that what shows it is not drawn again. */
|
|
128
|
+
function same(previous, next) {
|
|
129
|
+
return JSON.stringify(previous) === JSON.stringify(next) ? previous : next;
|
|
130
|
+
}
|
|
131
|
+
WorkbenchUtil.same = same;
|
|
132
|
+
function retryDelay(attempt) {
|
|
133
|
+
return RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];
|
|
134
|
+
}
|
|
135
|
+
WorkbenchUtil.retryDelay = retryDelay;
|
|
136
|
+
})(WorkbenchUtil || (WorkbenchUtil = {}));
|
|
137
|
+
/** None where the page is not in a browser (tests). */
|
|
138
|
+
export function storage() {
|
|
139
|
+
return typeof localStorage === 'undefined' ? undefined : localStorage;
|
|
140
|
+
}
|
|
141
|
+
/** The ta serve that serves the page, whose token a sign-in without a pairing is for. */
|
|
142
|
+
export function pageHost() {
|
|
143
|
+
return typeof location === 'undefined' ? '' : location.host;
|
|
144
|
+
}
|
|
145
|
+
//# 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.js';
|
|
4
|
+
import { WorkbenchCalls } from './workbench-calls.js';
|
|
5
5
|
import { type Credential, TaWorkbench, type WorkbenchState } from './workbench-protocol.js';
|
|
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.js';
|
|
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,4 +108,3 @@ 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 {};
|
package/esm/browser/workbench.js
CHANGED
|
@@ -7,153 +7,36 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Component } from '@celljs/core';
|
|
8
8
|
import { SessionStore, TaConnection } from '@celljs/ta-client';
|
|
9
9
|
import { TA_WEBSOCKET_PATH, TaErrorCode, } from '@celljs/ta-protocol';
|
|
10
|
-
import {
|
|
10
|
+
import { RelaySocket } from '@celljs/ta-relay';
|
|
11
11
|
import { HostUtil } from './hosts.js';
|
|
12
|
+
import { deviceValues, OfflineKeys } from './offline/device-values.js';
|
|
12
13
|
import { StateUtil } from './state/state-protocol.js';
|
|
14
|
+
import { WorkbenchCalls } from './workbench-calls.js';
|
|
13
15
|
import { TaWorkbench } from './workbench-protocol.js';
|
|
14
|
-
|
|
15
|
-
const TOKEN_KEY = 'ta.token';
|
|
16
|
-
const PAIRING_KEY = 'ta.pairing';
|
|
17
|
-
/** How long a computer added while another is in use has to answer before it counts as unreachable. */
|
|
18
|
-
const PROBE_MS = 15000;
|
|
19
|
-
/** Waits between attempts while ta serve is not running: doubling up to the last. */
|
|
20
|
-
const RETRY_DELAYS_MS = [1000, 2000, 4000, 8000];
|
|
21
|
-
/**
|
|
22
|
-
* How long the connection is down, while the page is seen, before the user is told (`offlineShown`):
|
|
23
|
-
* the first tries to connect again are within it, so a short drop shows nothing.
|
|
24
|
-
*/
|
|
25
|
-
const GRACE_MS = 2500;
|
|
26
|
-
/**
|
|
27
|
-
* The lists of the last time, of the ta serve they were of: the next start shows them at once while it
|
|
28
|
-
* connects, as a phone's app shows its chats before it is online. They are small; the conversations
|
|
29
|
-
* are not kept.
|
|
30
|
-
*/
|
|
31
|
-
const LISTS_KEY = 'ta.lists';
|
|
32
|
-
/** How long the page shows which computer it switches to before it loads again for it. */
|
|
33
|
-
const SWITCH_MS = 160;
|
|
34
|
-
/** A conversation opens with about this much of its latest messages, its earlier ones loaded as much at a time when scrolled to. */
|
|
35
|
-
const PAGE_BYTES = 128 * 1024;
|
|
36
|
-
/** Why a computer added while another is in use was not switched to. */
|
|
37
|
-
export class WorkbenchError extends Error {
|
|
38
|
-
constructor(reason) {
|
|
39
|
-
super(reason === 'refused' ? 'The computer refused this device.' : 'The computer did not answer.');
|
|
40
|
-
this.reason = reason;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export var WorkbenchUtil;
|
|
44
|
-
(function (WorkbenchUtil) {
|
|
45
|
-
/** A pairing link (`ta pair`) or else a token. */
|
|
46
|
-
function credential(text) {
|
|
47
|
-
try {
|
|
48
|
-
return { pairing: RelayPairingUtil.parse(text) };
|
|
49
|
-
}
|
|
50
|
-
catch (_a) {
|
|
51
|
-
return { token: text };
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
WorkbenchUtil.credential = credential;
|
|
55
|
-
/**
|
|
56
|
-
* Whether the ta serve in use runs on another machine than this browser: reached through a relay, from
|
|
57
|
-
* the app, or at an address that is not this machine's. A sign-in there cannot come back to it by itself.
|
|
58
|
-
*/
|
|
59
|
-
function elsewhere(hostId, hostname = typeof location === 'undefined' ? '' : location.hostname) {
|
|
60
|
-
return isApp() || Boolean(hostId === null || hostId === void 0 ? void 0 : hostId.startsWith('relay ')) || !['localhost', '127.0.0.1', '[::1]', '::1'].includes(hostname);
|
|
61
|
-
}
|
|
62
|
-
WorkbenchUtil.elsewhere = elsewhere;
|
|
63
|
-
/** In the Ta app on a phone, where no ta serve serves the page: it reaches one through a relay. */
|
|
64
|
-
function isApp() {
|
|
65
|
-
var _a, _b;
|
|
66
|
-
return Boolean((_b = (_a = globalThis.Capacitor) === null || _a === void 0 ? void 0 : _a.isNativePlatform) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
67
|
-
}
|
|
68
|
-
WorkbenchUtil.isApp = isApp;
|
|
69
|
-
function readPairing(text) {
|
|
70
|
-
try {
|
|
71
|
-
return text ? RelayPairingUtil.parse(RelayPairingUtil.link(JSON.parse(text))) : undefined;
|
|
72
|
-
}
|
|
73
|
-
catch (_a) {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
WorkbenchUtil.readPairing = readPairing;
|
|
78
|
-
/**
|
|
79
|
-
* Whether the server of the page answers at all. A WebSocket that does not open cannot say why: a
|
|
80
|
-
* server that answers refused the token; none means ta serve is not running (the installed app opens
|
|
81
|
-
* from its service worker then).
|
|
82
|
-
*/
|
|
83
|
-
async function reachable(base, fetcher = fetch) {
|
|
84
|
-
try {
|
|
85
|
-
await fetcher(base, { method: 'HEAD', cache: 'no-store' });
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
catch (_a) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
WorkbenchUtil.reachable = reachable;
|
|
93
|
-
/** The hosts kept in `storage`; the token or pairing an older version kept becomes the first. */
|
|
94
|
-
function readHosts(storage, now = Date.now()) {
|
|
95
|
-
const text = storage === null || storage === void 0 ? void 0 : storage.getItem(HostUtil.KEY);
|
|
96
|
-
if (text || !storage) {
|
|
97
|
-
return HostUtil.read(text);
|
|
98
|
-
}
|
|
99
|
-
const pairing = readPairing(storage.getItem(PAIRING_KEY));
|
|
100
|
-
const token = storage.getItem(TOKEN_KEY);
|
|
101
|
-
const credential = pairing ? { pairing } : token ? { token } : undefined;
|
|
102
|
-
storage.removeItem(PAIRING_KEY);
|
|
103
|
-
storage.removeItem(TOKEN_KEY);
|
|
104
|
-
return credential ? HostUtil.use({ hosts: [] }, serverOf(credential, pageHost()), credential, now) : { hosts: [] };
|
|
105
|
-
}
|
|
106
|
-
WorkbenchUtil.readHosts = readHosts;
|
|
107
|
-
/** Which ta serve a credential reaches, to know whose lists were kept. */
|
|
108
|
-
function serverOf(credential, host) {
|
|
109
|
-
return 'pairing' in credential ? `relay ${credential.pairing.relay} ${credential.pairing.host}` : `serve ${host}`;
|
|
110
|
-
}
|
|
111
|
-
WorkbenchUtil.serverOf = serverOf;
|
|
112
|
-
/** Where the lists of `of` are kept: each computer has its own, to show at once when switched to. */
|
|
113
|
-
function listsKey(of) {
|
|
114
|
-
return `${LISTS_KEY} ${of}`;
|
|
115
|
-
}
|
|
116
|
-
WorkbenchUtil.listsKey = listsKey;
|
|
117
|
-
/** The lists kept for `of`, none running: whether one runs is known once connected. */
|
|
118
|
-
function readLists(text, of) {
|
|
119
|
-
try {
|
|
120
|
-
const kept = text ? JSON.parse(text) : undefined;
|
|
121
|
-
if ((kept === null || kept === void 0 ? void 0 : kept.of) !== of || !Array.isArray(kept.sessions) || !Array.isArray(kept.saved)) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
return { server: kept.server, sessions: kept.sessions.map(session => ({ ...session, isStreaming: false })), saved: kept.saved };
|
|
125
|
-
}
|
|
126
|
-
catch (_a) {
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
WorkbenchUtil.readLists = readLists;
|
|
131
|
-
/** `previous` if `next` is the same, so that what shows it is not drawn again. */
|
|
132
|
-
function same(previous, next) {
|
|
133
|
-
return JSON.stringify(previous) === JSON.stringify(next) ? previous : next;
|
|
134
|
-
}
|
|
135
|
-
WorkbenchUtil.same = same;
|
|
136
|
-
function retryDelay(attempt) {
|
|
137
|
-
return RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];
|
|
138
|
-
}
|
|
139
|
-
WorkbenchUtil.retryDelay = retryDelay;
|
|
140
|
-
})(WorkbenchUtil || (WorkbenchUtil = {}));
|
|
141
|
-
/** None where the page is not in a browser (tests). */
|
|
142
|
-
function storage() {
|
|
143
|
-
return typeof localStorage === 'undefined' ? undefined : localStorage;
|
|
144
|
-
}
|
|
145
|
-
/** The ta serve that serves the page, whose token a sign-in without a pairing is for. */
|
|
146
|
-
function pageHost() {
|
|
147
|
-
return typeof location === 'undefined' ? '' : location.host;
|
|
148
|
-
}
|
|
16
|
+
import { GRACE_MS, PAGE_BYTES, PROBE_MS, pageHost, SWITCH_MS, storage, WorkbenchError, WorkbenchUtil, } from './workbench-util.js';
|
|
149
17
|
let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
150
18
|
constructor() {
|
|
151
19
|
this.list = WorkbenchUtil.readHosts(storage());
|
|
152
20
|
this.current = { status: 'connecting', hosts: this.list.hosts, host: this.list.current, sessions: [], saved: [] };
|
|
153
21
|
this.attempts = 0;
|
|
154
22
|
this.graceMs = GRACE_MS;
|
|
23
|
+
/**
|
|
24
|
+
* The calls of the services and of the stores, to the connection of the time; answered from the device
|
|
25
|
+
* while offline, for the computer in use from the start (web extensions started from the device read
|
|
26
|
+
* before the page connects).
|
|
27
|
+
*/
|
|
28
|
+
this.calls = new WorkbenchCalls({
|
|
29
|
+
status: () => this.current.status,
|
|
30
|
+
connection: () => this.connection,
|
|
31
|
+
connected: () => this.connected(),
|
|
32
|
+
subscribe: listener => this.subscribe(listener),
|
|
33
|
+
dataChanged: (name, keys, cwd) => {
|
|
34
|
+
for (const listener of this.extensionDataListeners) {
|
|
35
|
+
listener(name, keys, cwd);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
}, this.list.current);
|
|
155
39
|
/** Those waiting for the connection (`connected`): `resolve` once online, `reject` once signed out. */
|
|
156
|
-
this.beforeConnection = new Map();
|
|
157
40
|
this.connectedWaiters = new Set();
|
|
158
41
|
this.waking = false;
|
|
159
42
|
/** Counts sign-ins and sign-outs: an attempt of an earlier one does nothing when it ends. */
|
|
@@ -197,32 +80,8 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
197
80
|
get remote() {
|
|
198
81
|
return this.service('remote');
|
|
199
82
|
}
|
|
200
|
-
/**
|
|
201
|
-
* A service of the connection; before there is one (the lists of the last time show meanwhile), its
|
|
202
|
-
* calls wait for it, and fail if the page signs out instead.
|
|
203
|
-
*/
|
|
204
83
|
service(name) {
|
|
205
|
-
|
|
206
|
-
return this.connection[name];
|
|
207
|
-
}
|
|
208
|
-
// The same each time, as the connection's are: what is given it is not drawn again for nothing.
|
|
209
|
-
const known = this.beforeConnection.get(name);
|
|
210
|
-
if (known) {
|
|
211
|
-
return known;
|
|
212
|
-
}
|
|
213
|
-
const service = new Proxy({}, {
|
|
214
|
-
get: (_target, method) =>
|
|
215
|
-
// Not a promise itself.
|
|
216
|
-
method === 'then'
|
|
217
|
-
? undefined
|
|
218
|
-
: async (...params) => {
|
|
219
|
-
await this.connected();
|
|
220
|
-
const real = this.signedIn()[name];
|
|
221
|
-
return real[method](...params);
|
|
222
|
-
},
|
|
223
|
-
});
|
|
224
|
-
this.beforeConnection.set(name, service);
|
|
225
|
-
return service;
|
|
84
|
+
return this.calls.service(name);
|
|
226
85
|
}
|
|
227
86
|
signedIn() {
|
|
228
87
|
if (!this.connection) {
|
|
@@ -354,6 +213,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
354
213
|
if (kept) {
|
|
355
214
|
StateUtil.forgetHost(kept, hostId);
|
|
356
215
|
}
|
|
216
|
+
void OfflineKeys.forget(deviceValues(), hostId);
|
|
357
217
|
if (this.listsOf === hostId) {
|
|
358
218
|
this.listsOf = undefined;
|
|
359
219
|
}
|
|
@@ -378,6 +238,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
378
238
|
if (of !== this.listsOf) {
|
|
379
239
|
// Another ta serve: its lists of the last time, or none, rather than those of the one before.
|
|
380
240
|
this.listsOf = of;
|
|
241
|
+
this.calls.reads.use(of);
|
|
381
242
|
this.update({ server: undefined, sessions: [], saved: [], ...WorkbenchUtil.readLists((_c = (_b = storage()) === null || _b === void 0 ? void 0 : _b.getItem(WorkbenchUtil.listsKey(of))) !== null && _c !== void 0 ? _c : null, of) });
|
|
382
243
|
}
|
|
383
244
|
this.update({ status: 'connecting', error: undefined });
|
|
@@ -449,6 +310,11 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
449
310
|
void this.watchRemote(connection);
|
|
450
311
|
});
|
|
451
312
|
void this.watchRemote(connection);
|
|
313
|
+
if ('pairing' in credential) {
|
|
314
|
+
// Through a relay the computer has let the page in once the socket is open, and no gateway is behind
|
|
315
|
+
// it: the calls of the page go now, with the one that reads who it is, not a round trip after it.
|
|
316
|
+
this.update({ status: 'online', error: undefined, retryAt: undefined });
|
|
317
|
+
}
|
|
452
318
|
let server;
|
|
453
319
|
try {
|
|
454
320
|
server = await connection.server.getServerInfo();
|
|
@@ -521,7 +387,27 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
521
387
|
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.reconnect();
|
|
522
388
|
}
|
|
523
389
|
}
|
|
524
|
-
|
|
390
|
+
/**
|
|
391
|
+
* One read of the lists at a time: asked again meanwhile, one more follows it for all who asked, so that
|
|
392
|
+
* reads on a slow network do not pile up.
|
|
393
|
+
*/
|
|
394
|
+
refresh() {
|
|
395
|
+
var _a;
|
|
396
|
+
if (!this.refreshing) {
|
|
397
|
+
this.refreshing = this.readLists().finally(() => {
|
|
398
|
+
this.refreshing = undefined;
|
|
399
|
+
});
|
|
400
|
+
return this.refreshing;
|
|
401
|
+
}
|
|
402
|
+
(_a = this.refreshAgain) !== null && _a !== void 0 ? _a : (this.refreshAgain = this.refreshing
|
|
403
|
+
.catch(() => undefined)
|
|
404
|
+
.then(() => {
|
|
405
|
+
this.refreshAgain = undefined;
|
|
406
|
+
return this.refresh();
|
|
407
|
+
}));
|
|
408
|
+
return this.refreshAgain;
|
|
409
|
+
}
|
|
410
|
+
async readLists() {
|
|
525
411
|
// A ta serve of before has no saved sessions to list: its list stays the open ones. The default
|
|
526
412
|
// directory comes along, as another device may have changed it.
|
|
527
413
|
const [sessions, saved, server] = await Promise.all([
|
|
@@ -538,10 +424,7 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
538
424
|
});
|
|
539
425
|
}
|
|
540
426
|
createStore(sessionId, options) {
|
|
541
|
-
|
|
542
|
-
throw new Error('Not signed in to ta serve.');
|
|
543
|
-
}
|
|
544
|
-
return new SessionStore(this.connection, sessionId, { pageBytes: PAGE_BYTES, ...options });
|
|
427
|
+
return new SessionStore(this.calls.link, sessionId, { pageBytes: PAGE_BYTES, ...options });
|
|
545
428
|
}
|
|
546
429
|
/** The prompts of ssh that wait for an answer, from now and those already there. */
|
|
547
430
|
async watchRemote(connection) {
|
|
@@ -630,6 +513,9 @@ let TaWorkbenchImpl = class TaWorkbenchImpl {
|
|
|
630
513
|
if (this.listsOf && (next.sessions !== before.sessions || next.saved !== before.saved || next.server !== before.server)) {
|
|
631
514
|
this.keepLists(this.listsOf);
|
|
632
515
|
}
|
|
516
|
+
if (before.status !== 'online') {
|
|
517
|
+
this.calls.online();
|
|
518
|
+
}
|
|
633
519
|
}
|
|
634
520
|
}
|
|
635
521
|
keepLists(of) {
|
|
@@ -38,18 +38,24 @@ const React = __importStar(require("react"));
|
|
|
38
38
|
const chat_list_1 = require("../components/chat-list");
|
|
39
39
|
const connection_bar_1 = require("../components/connection-bar");
|
|
40
40
|
const hooks_1 = require("../hooks");
|
|
41
|
+
const use_t_1 = require("../i18n/use-t");
|
|
41
42
|
const assistant_hooks_1 = require("./assistant-hooks");
|
|
42
43
|
/** The list of chats with what the double knows of them: its tasks marked, a conversation to hand it. */
|
|
43
44
|
function AssistantChatList(props) {
|
|
44
45
|
var _a;
|
|
45
46
|
const [{ tasks, ready }, assistant] = (0, assistant_hooks_1.useAssistant)();
|
|
46
47
|
const [, notices] = (0, hooks_1.useNotices)();
|
|
48
|
+
const t = (0, use_t_1.useT)();
|
|
49
|
+
const name = assistant.name || t('ta.builtin.assistant');
|
|
47
50
|
const session = ready ? (_a = assistant.store()) === null || _a === void 0 ? void 0 : _a.sessionId : undefined;
|
|
51
|
+
const { sessionFile } = assistant;
|
|
48
52
|
const double = React.useMemo(() => ({
|
|
49
|
-
tasks: new
|
|
53
|
+
tasks: new Map(tasks.filter(task => !task.takenOver).map(task => [task.sessionId, task.status])),
|
|
50
54
|
session,
|
|
55
|
+
sessionFile,
|
|
56
|
+
name,
|
|
51
57
|
hand: (info, title) => void assistant.adopt({ sessionId: info.sessionId, title, cwd: info.cwd }).catch(error => notices.error(error)),
|
|
52
|
-
}), [tasks, session, assistant, notices]);
|
|
58
|
+
}), [tasks, session, sessionFile, name, assistant, notices]);
|
|
53
59
|
return React.createElement(chat_list_1.ChatList, { ...props, double: double, notice: React.createElement(connection_bar_1.ConnectionBanner, null) });
|
|
54
60
|
}
|
|
55
61
|
//# sourceMappingURL=assistant-chat-list.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WebExtensionAPI, WebExtensionFactory, WebMenuItem } from '../extension/web-extension-api';
|
|
1
|
+
import type { WebExtensionAPI, WebExtensionFactory, WebMenuItem, WebViewPreview } from '../extension/web-extension-api';
|
|
2
2
|
import { BuiltinWebExtension } from '../extension/web-extension-protocol';
|
|
3
3
|
import { TaSettings } from '../settings/settings-protocol';
|
|
4
4
|
import { TaState } from '../state/state-protocol';
|
|
@@ -17,6 +17,13 @@ export declare class AssistantWebExtension implements BuiltinWebExtension {
|
|
|
17
17
|
protected readonly persisted: TaState;
|
|
18
18
|
protected readonly workbench: TaWorkbench;
|
|
19
19
|
protected readonly settings: TaSettings;
|
|
20
|
+
/**
|
|
21
|
+
* What the double said last, as the list of chats shows a conversation: from the open sessions, else the
|
|
22
|
+
* saved ones. A note of a task the double reads is not something said to the user: none then.
|
|
23
|
+
*/
|
|
24
|
+
protected preview(): WebViewPreview | undefined;
|
|
25
|
+
/** The double answers in its own conversation now. */
|
|
26
|
+
protected busy(): boolean;
|
|
20
27
|
readonly activate: WebExtensionFactory;
|
|
21
28
|
/** The … of the page: stop, start over; its name, its look, its system prompt, the default directory its tasks open in; the conversation as a file. */
|
|
22
29
|
protected menu(pi: WebExtensionAPI): WebMenuItem[][];
|
|
@@ -90,11 +90,10 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
90
90
|
})
|
|
91
91
|
.catch(fail);
|
|
92
92
|
};
|
|
93
|
+
/** Deletes it without asking: the lists ask (ui.removeTasks), for one or for many. */
|
|
93
94
|
const remove = async (task) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
pi.ui.closeEditor(editorId(task));
|
|
97
|
-
}
|
|
95
|
+
await this.assistant.removeTask(task.id);
|
|
96
|
+
pi.ui.closeEditor(editorId(task));
|
|
98
97
|
};
|
|
99
98
|
/** What can be done with a task, in its … wherever it shows: stop or take over, then remove (a running one is stopped first). */
|
|
100
99
|
const taskMenu = (task) => {
|
|
@@ -106,7 +105,15 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
106
105
|
: []),
|
|
107
106
|
...(task.takenOver ? [] : [{ key: 'takeOver', label: t('ta.task.takeOver'), icon: lucide_react_1.Hand, run: () => takeOver(task) }]),
|
|
108
107
|
],
|
|
109
|
-
[
|
|
108
|
+
[
|
|
109
|
+
{
|
|
110
|
+
key: 'remove',
|
|
111
|
+
label: t('ta.task.remove'),
|
|
112
|
+
icon: lucide_react_1.Trash2,
|
|
113
|
+
danger: true,
|
|
114
|
+
run: () => void pi.ui.removeTasks([{ title: task.title, removeHint: t('ta.task.removeHint'), remove: () => remove(task) }]),
|
|
115
|
+
},
|
|
116
|
+
],
|
|
110
117
|
].filter(section => section.length > 0);
|
|
111
118
|
};
|
|
112
119
|
const showTasks = () => pi.ui.showView(`${assistant_view_1.ASSISTANT_NAME}/${assistant_view_1.ASSISTANT_TASKS_VIEW}`);
|
|
@@ -124,6 +131,7 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
124
131
|
open: openTask,
|
|
125
132
|
openDouble: () => pi.ui.showView(`${assistant_view_1.ASSISTANT_NAME}/assistant`),
|
|
126
133
|
menu: taskMenu,
|
|
134
|
+
remove,
|
|
127
135
|
});
|
|
128
136
|
pi.registerTasks(tasks);
|
|
129
137
|
const registerPage = () => pi.registerView('assistant', {
|
|
@@ -131,6 +139,9 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
131
139
|
icon: lucide_react_1.Bot,
|
|
132
140
|
render: () => React.createElement(assistant_view_1.AssistantPanel, { onTask: openTask }),
|
|
133
141
|
menu: () => this.menu(pi),
|
|
142
|
+
preview: () => this.preview(),
|
|
143
|
+
busy: () => this.busy(),
|
|
144
|
+
subscribe: listener => this.workbench.subscribe(() => listener()),
|
|
134
145
|
});
|
|
135
146
|
registerPage();
|
|
136
147
|
pi.registerView('tasks-card', {
|
|
@@ -178,6 +189,23 @@ let AssistantWebExtension = class AssistantWebExtension {
|
|
|
178
189
|
};
|
|
179
190
|
};
|
|
180
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* What the double said last, as the list of chats shows a conversation: from the open sessions, else the
|
|
194
|
+
* saved ones. A note of a task the double reads is not something said to the user: none then.
|
|
195
|
+
*/
|
|
196
|
+
preview() {
|
|
197
|
+
var _a;
|
|
198
|
+
const file = this.assistant.sessionFile;
|
|
199
|
+
const { sessions, saved } = this.workbench.state;
|
|
200
|
+
const session = file ? ((_a = sessions.find(each => each.sessionFile === file)) !== null && _a !== void 0 ? _a : saved.find(each => each.sessionFile === file)) : undefined;
|
|
201
|
+
const text = session === null || session === void 0 ? void 0 : session.lastMessage;
|
|
202
|
+
return text && !text.startsWith('<task_') ? { text, at: session.updatedAt } : undefined;
|
|
203
|
+
}
|
|
204
|
+
/** The double answers in its own conversation now. */
|
|
205
|
+
busy() {
|
|
206
|
+
const file = this.assistant.sessionFile;
|
|
207
|
+
return !!file && this.workbench.state.sessions.some(each => each.sessionFile === file && each.isStreaming);
|
|
208
|
+
}
|
|
181
209
|
/** The … of the page: stop, start over; its name, its look, its system prompt, the default directory its tasks open in; the conversation as a file. */
|
|
182
210
|
menu(pi) {
|
|
183
211
|
var _a;
|
|
@@ -58,8 +58,10 @@ export interface TaAssistant {
|
|
|
58
58
|
warm(): Promise<void>;
|
|
59
59
|
/** Reads the tasks kept, for the lists, without opening the conversation. */
|
|
60
60
|
loadTasks(): Promise<void>;
|
|
61
|
-
/** The conversation with ta. */
|
|
61
|
+
/** The conversation with ta; before it opens, it as this device kept it (`showKept`), if it did. */
|
|
62
62
|
store(): SessionStore | undefined;
|
|
63
|
+
/** Before the conversation opens, and without the computer: shows it as this device last saw it. */
|
|
64
|
+
showKept(): Promise<void>;
|
|
63
65
|
taskStore(taskId: string): SessionStore | undefined;
|
|
64
66
|
/**
|
|
65
67
|
* The session of a task to show: the one followed, else its conversation opened again from its file (a
|