@celljs/ta-web 4.9.1 → 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 +20 -0
- package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
- package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
- package/esm/browser/assistant/assistant-task-util.js +5 -3
- package/esm/browser/assistant/assistant-view.js +81 -56
- package/esm/browser/assistant/assistant.d.ts +10 -1
- package/esm/browser/assistant/assistant.js +44 -5
- 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/app-nav.d.ts +6 -3
- package/esm/browser/components/app-nav.js +19 -10
- package/esm/browser/components/app-shell-hooks.d.ts +2 -2
- package/esm/browser/components/app-shell-hooks.js +7 -3
- package/esm/browser/components/app-view.js +75 -21
- 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 +5 -4
- 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/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 +26 -8
- 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/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/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-parts.d.ts +2 -2
- package/esm/browser/components/settings-parts.js +24 -1
- 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/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/web-extension-api.d.ts +97 -1
- 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 +122 -23
- 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/i18n/locales.d.ts +24 -2
- package/esm/browser/i18n/messages.d.ts +23 -1
- package/esm/browser/i18n/messages.js +48 -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 +27 -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 +46 -3
- 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 +7 -0
- package/esm/browser/workbench-util.js +9 -2
- package/esm/browser/workbench.d.ts +14 -5
- package/esm/browser/workbench.js +51 -31
- 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 +20 -0
- package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
- package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
- package/lib/browser/assistant/assistant-task-util.js +5 -3
- package/lib/browser/assistant/assistant-view.js +78 -53
- package/lib/browser/assistant/assistant.d.ts +10 -1
- package/lib/browser/assistant/assistant.js +44 -5
- 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/app-nav.d.ts +6 -3
- package/lib/browser/components/app-nav.js +17 -8
- package/lib/browser/components/app-shell-hooks.d.ts +2 -2
- package/lib/browser/components/app-shell-hooks.js +7 -3
- package/lib/browser/components/app-view.js +74 -20
- 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 +5 -4
- 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/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 +26 -8
- 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/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/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-parts.d.ts +2 -2
- package/lib/browser/components/settings-parts.js +24 -1
- 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/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/web-extension-api.d.ts +97 -1
- 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 +120 -21
- 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/i18n/locales.d.ts +24 -2
- package/lib/browser/i18n/messages.d.ts +23 -1
- package/lib/browser/i18n/messages.js +48 -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 +27 -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 +46 -3
- 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 +7 -0
- package/lib/browser/workbench-util.js +10 -3
- package/lib/browser/workbench.d.ts +14 -5
- package/lib/browser/workbench.js +51 -31
- package/package.json +10 -10
- package/public/launch.svg +46 -42
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { useInject } from '@celljs/react';
|
|
1
2
|
import { ArrowDown } from 'lucide-react';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { useKeyboardDismiss } from '../device/device.js';
|
|
5
|
+
import { TaFiles } from '../files/files-protocol.js';
|
|
4
6
|
import { useNotices, useOpenLink, useSessionState, useSettingsServer } from '../hooks.js';
|
|
5
7
|
import { useT } from '../i18n/use-t.js';
|
|
6
8
|
import { MessageUtil } from '../util/message.js';
|
|
7
9
|
import { TerminalText } from '../util/terminal-text.js';
|
|
8
10
|
import { Composer } from './composer.js';
|
|
9
11
|
import { useComposerAddons } from './composer-addons.js';
|
|
10
|
-
import { useAwayFromBottom, useConversationScroll } from './conversation-scroll.js';
|
|
12
|
+
import { SCROLL_SKIP, useAwayFromBottom, useConversationScroll } from './conversation-scroll.js';
|
|
11
13
|
import { DialogView } from './dialog-view.js';
|
|
12
14
|
import { useAsked, useEarlierMessages } from './earlier-messages.js';
|
|
13
15
|
import { OpenLink } from './link.js';
|
|
@@ -94,7 +96,8 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
94
96
|
(_a = composer.current) === null || _a === void 0 ? void 0 : _a.setText(draftText);
|
|
95
97
|
}
|
|
96
98
|
}, [draftText]);
|
|
97
|
-
const
|
|
99
|
+
const files = useInject(TaFiles);
|
|
100
|
+
const fileUrl = React.useCallback(async (path) => files.loadable(await workspace.fileUrl(path, cwd)), [workspace, cwd, files]);
|
|
98
101
|
const openLink = useOpenLink(cwd);
|
|
99
102
|
// biome-ignore lint/correctness/useExhaustiveDependencies: runs when a run starts or settles
|
|
100
103
|
React.useEffect(() => onActivity(), [state.working, onActivity]);
|
|
@@ -110,6 +113,7 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
110
113
|
const title = (info === null || info === void 0 ? void 0 : info.sessionName) || (info ? MessageUtil.basename(info.cwd) : t('ta.session.title'));
|
|
111
114
|
const conversation = React.useMemo(() => ({ sessionId: store.sessionId, sessionFile: info === null || info === void 0 ? void 0 : info.sessionFile, cwd: info === null || info === void 0 ? void 0 : info.cwd, kind: 'chat', group: info === null || info === void 0 ? void 0 : info.group, title }), [store.sessionId, info === null || info === void 0 ? void 0 : info.sessionFile, info === null || info === void 0 ? void 0 : info.cwd, info === null || info === void 0 ? void 0 : info.group, title]);
|
|
112
115
|
const addons = useComposerAddons(conversation);
|
|
116
|
+
const outbox = React.useMemo(() => ({ resend: id => void store.resend(id), discard: id => store.discard(id) }), [store]);
|
|
113
117
|
return (React.createElement("section", { className: `ta-session ${compact ? 'ta-session-compact' : ''}` },
|
|
114
118
|
!compact && (React.createElement("header", { className: "ta-session-header" },
|
|
115
119
|
leading,
|
|
@@ -119,14 +123,14 @@ export function SessionView({ store, server, workspace, info, onClosed, onActivi
|
|
|
119
123
|
trailing)),
|
|
120
124
|
React.createElement("div", { className: "ta-scroll ta-conversation", ref: scroller },
|
|
121
125
|
React.createElement("div", { className: "ta-thread" },
|
|
122
|
-
state.start > 0 && (React.createElement("div", { className: "ta-earlier", role: "status", "aria-label": t('ta.session.earlier') },
|
|
126
|
+
state.start > 0 && (React.createElement("div", { className: "ta-earlier", role: "status", "aria-label": t('ta.session.earlier'), ...SCROLL_SKIP },
|
|
123
127
|
React.createElement("span", { className: "ta-spinner" }))),
|
|
124
128
|
state.messages.length === 0 && (empty !== null && empty !== void 0 ? empty : React.createElement("div", { className: "ta-empty" }, t('ta.session.empty', { cwd: (_a = info === null || info === void 0 ? void 0 : info.cwd) !== null && _a !== void 0 ? _a : '.' }))),
|
|
125
129
|
React.createElement(ConversationSession.Provider, { value: info },
|
|
126
130
|
React.createElement(MessageActions.Provider, { value: messageActions },
|
|
127
131
|
React.createElement(FileUrls.Provider, { value: fileUrl },
|
|
128
132
|
React.createElement(OpenLink.Provider, { value: openLink },
|
|
129
|
-
React.createElement(MessageList, { state: state }))))))),
|
|
133
|
+
React.createElement(MessageList, { state: state, outbox: outbox }))))))),
|
|
130
134
|
React.createElement("div", { className: "ta-bottom" },
|
|
131
135
|
away && (React.createElement("button", { type: "button", className: "ta-to-bottom", "aria-label": t('ta.session.toBottom'), title: t('ta.session.toBottom'), onClick: toBottom },
|
|
132
136
|
React.createElement(ArrowDown, { size: 18 }))),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TaSettingsScope } from '@celljs/ta-protocol';
|
|
2
|
-
import { type LucideIcon } from 'lucide-react';
|
|
3
2
|
import * as React from 'react';
|
|
3
|
+
import { type Glyph } from './icon.js';
|
|
4
4
|
import { type RowEntry } from './settings-controls.js';
|
|
5
5
|
export interface SectionEntry {
|
|
6
6
|
id: string;
|
|
7
7
|
title: string;
|
|
8
|
-
icon:
|
|
8
|
+
icon: Glyph;
|
|
9
9
|
rows: RowEntry[];
|
|
10
10
|
}
|
|
11
11
|
export interface Part {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Blocks, Bot, Cloud, Compass, FolderOpen, Info, Keyboard, KeyRound, Languages, Link2, LogOut, Palette, Puzzle, RefreshCw, Server, ShieldCheck, Smartphone, Trash2, Volume2, Wrench, } from 'lucide-react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useDevice } from '../device/device.js';
|
|
4
|
+
import { ExtensionBoundary } from '../extension/extension-view.js';
|
|
5
|
+
import { WebLabelUtil } from '../extension/web-extension-protocol.js';
|
|
4
6
|
import { useNotices, useSettings, useSettingsServer, useWebExtensions, useWorkbench } from '../hooks.js';
|
|
5
7
|
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
6
8
|
import { AGENT_SETTINGS_GROUPS, AgentSettingsUtil } from '../settings/agent-settings.js';
|
|
@@ -25,7 +27,7 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
25
27
|
const [{ settings }, store] = useSettings();
|
|
26
28
|
const settingsServer = useSettingsServer();
|
|
27
29
|
const [workbench, bench] = useWorkbench();
|
|
28
|
-
const [{ extensions, cwd, views }, host] = useWebExtensions();
|
|
30
|
+
const [{ extensions, cwd, views, settingsSections }, host] = useWebExtensions();
|
|
29
31
|
const navigation = useNavigation(views);
|
|
30
32
|
const packageList = usePackages();
|
|
31
33
|
const builtinPackages = packageList.packages.filter(pkg => pkg.origin === 'builtin');
|
|
@@ -124,6 +126,8 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
124
126
|
rows: [
|
|
125
127
|
row('speak', [t('ta.settings.speak'), t('ta.settings.speakHint')], React.createElement(Row, { label: t('ta.settings.speak'), description: t('ta.settings.speakHint') },
|
|
126
128
|
React.createElement(Switch, { label: t('ta.settings.speak'), checked: settings.speak, onChange: speak => store.update({ speak }) }))),
|
|
129
|
+
row('speakTalk', [t('ta.settings.speakTalk'), t('ta.settings.speakTalkHint')], React.createElement(Row, { label: t('ta.settings.speakTalk'), description: t('ta.settings.speakTalkHint') },
|
|
130
|
+
React.createElement(Switch, { label: t('ta.settings.speakTalk'), checked: settings.speakTalk, onChange: speakTalk => store.update({ speakTalk }) }))),
|
|
127
131
|
],
|
|
128
132
|
},
|
|
129
133
|
];
|
|
@@ -203,6 +207,7 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
203
207
|
}),
|
|
204
208
|
],
|
|
205
209
|
},
|
|
210
|
+
...settingsSections.map(extensionSection),
|
|
206
211
|
// Behind a gateway only: where the Ta of this account runs.
|
|
207
212
|
...(gateway.info
|
|
208
213
|
? [
|
|
@@ -297,4 +302,22 @@ export function useParts(scope, onScope, onClose, onDialog) {
|
|
|
297
302
|
{ id: 'more', title: t('ta.settings.more'), sections: more },
|
|
298
303
|
];
|
|
299
304
|
}
|
|
305
|
+
/** A section an extension added (WebExtensionAPI.registerSettings): its rows as Ta's, each control in a boundary of its own. */
|
|
306
|
+
function extensionSection({ id, section }) {
|
|
307
|
+
var _a;
|
|
308
|
+
const title = WebLabelUtil.text(section.title);
|
|
309
|
+
return {
|
|
310
|
+
id: `extension-${id.replace(/[^\w-]+/g, '-')}`,
|
|
311
|
+
title,
|
|
312
|
+
icon: (_a = section.icon) !== null && _a !== void 0 ? _a : Puzzle,
|
|
313
|
+
rows: section.rows.map(item => {
|
|
314
|
+
const label = WebLabelUtil.text(item.label);
|
|
315
|
+
const description = item.description === undefined ? undefined : WebLabelUtil.text(item.description);
|
|
316
|
+
const Control = item.render;
|
|
317
|
+
return row(`${id}/${item.key}`, [label, description, title], React.createElement(Row, { label: label, description: description, stacked: item.stacked },
|
|
318
|
+
React.createElement(ExtensionBoundary, { name: title, resetKey: Control },
|
|
319
|
+
React.createElement(Control, null))));
|
|
320
|
+
}),
|
|
321
|
+
};
|
|
322
|
+
}
|
|
300
323
|
//# sourceMappingURL=settings-parts.js.map
|
|
@@ -11,7 +11,7 @@ export interface SwipeRowProps extends WebSwipeRowProps, Omit<React.HTMLAttribut
|
|
|
11
11
|
* list of the page and of web extensions (`ui.SwipeRow`) takes it, so that they swipe as one. Open, a tap on
|
|
12
12
|
* it closes it rather than opening what it is.
|
|
13
13
|
*/
|
|
14
|
-
export declare function SwipeRow({ as, actions, className, overlay, children, ...rest }: SwipeRowProps): React.DetailedReactHTMLElement<{
|
|
14
|
+
export declare function SwipeRow({ as, actions, className, overlay, children, style, ...rest }: SwipeRowProps): React.DetailedReactHTMLElement<{
|
|
15
15
|
dangerouslySetInnerHTML?: {
|
|
16
16
|
__html: string | TrustedHTML;
|
|
17
17
|
} | undefined;
|
|
@@ -254,7 +254,6 @@ export declare function SwipeRow({ as, actions, className, overlay, children, ..
|
|
|
254
254
|
nonce?: string | undefined;
|
|
255
255
|
slot?: string | undefined;
|
|
256
256
|
spellCheck?: ("false" | "true" | boolean) | undefined;
|
|
257
|
-
style?: React.CSSProperties | undefined;
|
|
258
257
|
tabIndex?: number | undefined;
|
|
259
258
|
title?: string | undefined;
|
|
260
259
|
translate?: "yes" | "no" | undefined;
|
|
@@ -294,4 +293,5 @@ export declare function SwipeRow({ as, actions, className, overlay, children, ..
|
|
|
294
293
|
className: string;
|
|
295
294
|
'data-swipeable': string | undefined;
|
|
296
295
|
'data-swiped': string | undefined;
|
|
296
|
+
style: React.CSSProperties | undefined;
|
|
297
297
|
}, HTMLElement>;
|
|
@@ -8,7 +8,7 @@ const ACTION_PX = 84;
|
|
|
8
8
|
* list of the page and of web extensions (`ui.SwipeRow`) takes it, so that they swipe as one. Open, a tap on
|
|
9
9
|
* it closes it rather than opening what it is.
|
|
10
10
|
*/
|
|
11
|
-
export function SwipeRow({ as = 'div', actions, className, overlay, children, ...rest }) {
|
|
11
|
+
export function SwipeRow({ as = 'div', actions, className, overlay, children, style, ...rest }) {
|
|
12
12
|
var _a;
|
|
13
13
|
const row = React.useRef(null);
|
|
14
14
|
const handheld = useDevice(device => device.handheld);
|
|
@@ -26,9 +26,13 @@ export function SwipeRow({ as = 'div', actions, className, overlay, children, ..
|
|
|
26
26
|
className: className ? `ta-swipe-row ${className}` : 'ta-swipe-row',
|
|
27
27
|
'data-swipeable': enabled ? '' : undefined,
|
|
28
28
|
'data-swiped': open ? '' : undefined,
|
|
29
|
-
|
|
29
|
+
// How far the content slides open, and its actions come out from: theirs together.
|
|
30
|
+
style: enabled ? { ...style, '--ta-swipe-width': `${ACTION_PX * ((_a = actions === null || actions === void 0 ? void 0 : actions.length) !== null && _a !== void 0 ? _a : 0)}px` } : style,
|
|
31
|
+
}, enabled && (React.createElement("div", { className: "ta-swipe-actions", inert: !open }, actions === null || actions === void 0 ? void 0 : actions.map((action, index) => (React.createElement("button", { key: action.key, type: "button", className: `ta-swipe-action${action.danger ? ' ta-danger' : ''}`,
|
|
32
|
+
// Of the way the row is shown, how far it is pushed out while closed (RowSwipeUtil.shift).
|
|
33
|
+
style: { '--ta-swipe-share': 1 - index / actions.length }, onClick: () => {
|
|
30
34
|
unswipe();
|
|
31
35
|
action.run();
|
|
32
|
-
} }, action.label))))), React.createElement("div", { className: "ta-swipe-content",
|
|
36
|
+
} }, action.label))))), React.createElement("div", { className: "ta-swipe-content", onClickCapture: open ? closeInstead : undefined }, children), overlay);
|
|
33
37
|
}
|
|
34
38
|
//# sourceMappingURL=swipe-row.js.map
|
|
@@ -33,10 +33,10 @@ function ToolRow({ name, args, status, trailing, details }) {
|
|
|
33
33
|
React.createElement(StatusDot, { status: status }),
|
|
34
34
|
React.createElement("span", { className: "ta-tool-verb" }, summary.verb ? t(summary.verb) : summary.name),
|
|
35
35
|
summary.target && React.createElement("span", { className: `ta-tool-target ${summary.code ? 'ta-mono' : ''}` }, summary.target),
|
|
36
|
-
|
|
36
|
+
React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-tool-chevron" })));
|
|
37
37
|
return (React.createElement("div", { className: `ta-tool ta-tool-${status}` },
|
|
38
38
|
React.createElement("div", { className: "ta-tool-line" },
|
|
39
|
-
|
|
39
|
+
React.createElement("button", { type: "button", className: "ta-tool-title", disabled: !details, "aria-expanded": details ? open : undefined, onClick: () => setOpen(!open) }, line),
|
|
40
40
|
React.createElement("span", { className: "ta-tool-trailing" }, trailing)),
|
|
41
41
|
details && open && React.createElement("div", { className: "ta-tool-body" }, details)));
|
|
42
42
|
}
|
|
@@ -88,23 +88,25 @@ function CodemodeView({ id, args, output, status, runs }) {
|
|
|
88
88
|
const script = (React.createElement(React.Fragment, null,
|
|
89
89
|
React.createElement(CodeBlock, { code: code, language: "js" }),
|
|
90
90
|
result && React.createElement(Output, { text: result })));
|
|
91
|
-
if (!calls.length) {
|
|
92
|
-
return React.createElement(ToolRow, { name: "codemode", args: args, status: status, details: script });
|
|
93
|
-
}
|
|
94
91
|
const label = t(showScript ? 'ta.tool.hideScript' : 'ta.tool.showScript');
|
|
95
|
-
const toggle = (React.createElement("button", { type: "button", className: `ta-tool-script ${showScript ? 'ta-on' : ''}`, title: label, "aria-label": label, "aria-pressed": showScript, onClick: () => setShowScript(!showScript) },
|
|
92
|
+
const toggle = calls.length > 0 && (React.createElement("button", { type: "button", className: `ta-tool-script ${showScript ? 'ta-on' : ''}`, title: label, "aria-label": label, "aria-pressed": showScript, onClick: () => setShowScript(!showScript) },
|
|
96
93
|
React.createElement(Icon, { icon: FileCode2, size: 13 })));
|
|
94
|
+
// Before its first call the script is the one step; its calls then take its place, the first in the same
|
|
95
|
+
// element, so that the line changes rather than comes again. By place: the calls are in order, live or
|
|
96
|
+
// kept, and their ids are not the same in both.
|
|
97
|
+
const rows = calls.length ? calls.map(nestedRow) : [{ name: 'codemode', args, status, details: script }];
|
|
97
98
|
// A script that failed after its calls went well: one more step, the script, whose output says what went wrong.
|
|
98
|
-
|
|
99
|
+
if (calls.length && status === 'error' && !calls.some(call => call.status === 'error')) {
|
|
100
|
+
rows.push({ name: 'codemode', args: { code }, status: 'error', details: result ? React.createElement(Output, { text: result }) : undefined });
|
|
101
|
+
}
|
|
99
102
|
return (React.createElement("div", { className: "ta-tool-group" },
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
showScript && React.createElement("div", { className: "ta-tool-body" }, script)));
|
|
103
|
+
rows.map((row, index) => (React.createElement(ToolRow, { key: index, ...row, trailing: index === 0 ? toggle || undefined : undefined }))),
|
|
104
|
+
showScript && calls.length > 0 && React.createElement("div", { className: "ta-tool-body" }, script)));
|
|
103
105
|
}
|
|
104
|
-
function
|
|
106
|
+
function nestedRow(call) {
|
|
105
107
|
var _a;
|
|
106
108
|
const shown = details(call.name, call.args, (_a = call.run) === null || _a === void 0 ? void 0 : _a.result, call.status);
|
|
107
109
|
const error = call.status === 'error' && call.error ? React.createElement(Output, { text: call.error }) : undefined;
|
|
108
|
-
return
|
|
110
|
+
return { name: call.name, args: call.args, status: call.status, details: shown || error || undefined };
|
|
109
111
|
}
|
|
110
112
|
//# sourceMappingURL=tool-view.js.map
|
|
@@ -7,5 +7,5 @@ export interface VoiceButtonProps {
|
|
|
7
7
|
onListening?(listening: boolean): void;
|
|
8
8
|
onError(error: unknown): void;
|
|
9
9
|
}
|
|
10
|
-
/** The microphone of a message box, where the browser can recognize speech: a click listens, a wave shows it, a click stops it. */
|
|
10
|
+
/** The microphone of a message box, where the browser can recognize speech: a click listens, a wave shows it, a click stops it (a finger held on it talks, which is the box's: voice-talk.ts). */
|
|
11
11
|
export declare function VoiceButton(props: VoiceButtonProps): React.JSX.Element;
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
4
4
|
import { Voice } from '../util/voice.js';
|
|
5
5
|
import { Icon } from './icon.js';
|
|
6
|
-
/** The microphone of a message box, where the browser can recognize speech: a click listens, a wave shows it, a click stops it. */
|
|
6
|
+
/** The microphone of a message box, where the browser can recognize speech: a click listens, a wave shows it, a click stops it (a finger held on it talks, which is the box's: voice-talk.ts). */
|
|
7
7
|
export function VoiceButton(props) {
|
|
8
8
|
const t = useT();
|
|
9
9
|
const language = useLanguage();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TalkTarget } from './held-talk.js';
|
|
3
|
+
/** Where the finger is let go: on the bottom, the words go; over 取消 they are dropped; over 编辑 they stay in the box. */
|
|
4
|
+
export type TalkZone = 'send' | 'cancel' | 'edit';
|
|
5
|
+
export declare namespace VoiceTalkUtil {
|
|
6
|
+
/** How long a talk lasts for the words to count: shorter, a finger slipped on the box and nothing is given. */
|
|
7
|
+
const SHORT_MS = 600;
|
|
8
|
+
/** How long the end of a talk waits for recognition to say it ended before it ends anyway. */
|
|
9
|
+
const SETTLE_MS = 1500;
|
|
10
|
+
/** How long "too short" stays before the page comes back. */
|
|
11
|
+
const SHORT_NOTICE_MS = 700;
|
|
12
|
+
/** How long the overlay takes to fade out. */
|
|
13
|
+
const LEAVE_MS = 160;
|
|
14
|
+
/** What a talk gives; none when it was too short to be meant, or when nothing was heard. */
|
|
15
|
+
function given(words: string, heldMs: number): string | undefined;
|
|
16
|
+
/** The zone of the overlay under a point (`data-talk-zone`): the bottom, where the finger starts, sends. */
|
|
17
|
+
function zone(element: Element | null): TalkZone;
|
|
18
|
+
}
|
|
19
|
+
/** Where a talk is: listening, the finger let go and the last words coming, said too short, the page coming back. */
|
|
20
|
+
export type TalkPhase = 'idle' | 'listening' | 'released' | 'short' | 'leaving';
|
|
21
|
+
export interface VoiceTalk extends TalkTarget {
|
|
22
|
+
phase: TalkPhase;
|
|
23
|
+
/** Listening, or the finger let go and the last words still coming. */
|
|
24
|
+
active: boolean;
|
|
25
|
+
/** What has been heard so far. */
|
|
26
|
+
words: string;
|
|
27
|
+
/** Where the finger is. */
|
|
28
|
+
zone: TalkZone;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A conversation by voice as WeChat's: a finger held on the message box (or on an entry of the navigation) dims the
|
|
32
|
+
* page and a green bubble listens, the words coming as they are said. Let go on the bottom, they are sent; slid
|
|
33
|
+
* over 取消 they are dropped, over 编辑 they stay in the box to be read over. A talk too short to be meant, which a
|
|
34
|
+
* wrong touch is, says so and gives nothing, as one where nothing was heard does.
|
|
35
|
+
*/
|
|
36
|
+
export declare function useVoiceTalk(onGive: (text: string, zone: 'send' | 'edit') => void, onError: (error: unknown) => void): VoiceTalk;
|
|
37
|
+
/**
|
|
38
|
+
* What a talk shows, over the whole page (above the keyboard): the page dimmed, a green bubble with the words as
|
|
39
|
+
* they come, 取消 and 编辑 to slide the finger onto, and the bottom it starts on, which says what letting go does.
|
|
40
|
+
*/
|
|
41
|
+
export declare function VoiceTalkOverlay({ talk }: {
|
|
42
|
+
talk: VoiceTalk;
|
|
43
|
+
}): React.ReactPortal | null;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { PenLine, X } from 'lucide-react';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { HeldUtil } from '../device/hold.js';
|
|
5
|
+
import { useLanguage, useT } from '../i18n/use-t.js';
|
|
6
|
+
import { Voice } from '../util/voice.js';
|
|
7
|
+
import { Icon } from './icon.js';
|
|
8
|
+
export var VoiceTalkUtil;
|
|
9
|
+
(function (VoiceTalkUtil) {
|
|
10
|
+
/** How long a talk lasts for the words to count: shorter, a finger slipped on the box and nothing is given. */
|
|
11
|
+
VoiceTalkUtil.SHORT_MS = 600;
|
|
12
|
+
/** How long the end of a talk waits for recognition to say it ended before it ends anyway. */
|
|
13
|
+
VoiceTalkUtil.SETTLE_MS = 1500;
|
|
14
|
+
/** How long "too short" stays before the page comes back. */
|
|
15
|
+
VoiceTalkUtil.SHORT_NOTICE_MS = 700;
|
|
16
|
+
/** How long the overlay takes to fade out. */
|
|
17
|
+
VoiceTalkUtil.LEAVE_MS = 160;
|
|
18
|
+
/** What a talk gives; none when it was too short to be meant, or when nothing was heard. */
|
|
19
|
+
function given(words, heldMs) {
|
|
20
|
+
const text = words.trim();
|
|
21
|
+
return text && heldMs >= VoiceTalkUtil.SHORT_MS ? text : undefined;
|
|
22
|
+
}
|
|
23
|
+
VoiceTalkUtil.given = given;
|
|
24
|
+
/** The zone of the overlay under a point (`data-talk-zone`): the bottom, where the finger starts, sends. */
|
|
25
|
+
function zone(element) {
|
|
26
|
+
var _a;
|
|
27
|
+
const zone = (_a = element === null || element === void 0 ? void 0 : element.closest('[data-talk-zone]')) === null || _a === void 0 ? void 0 : _a.getAttribute('data-talk-zone');
|
|
28
|
+
return zone === 'cancel' || zone === 'edit' ? zone : 'send';
|
|
29
|
+
}
|
|
30
|
+
VoiceTalkUtil.zone = zone;
|
|
31
|
+
})(VoiceTalkUtil || (VoiceTalkUtil = {}));
|
|
32
|
+
const IDLE = { phase: 'idle', words: '', zone: 'send' };
|
|
33
|
+
/**
|
|
34
|
+
* A conversation by voice as WeChat's: a finger held on the message box (or on an entry of the navigation) dims the
|
|
35
|
+
* page and a green bubble listens, the words coming as they are said. Let go on the bottom, they are sent; slid
|
|
36
|
+
* over 取消 they are dropped, over 编辑 they stay in the box to be read over. A talk too short to be meant, which a
|
|
37
|
+
* wrong touch is, says so and gives nothing, as one where nothing was heard does.
|
|
38
|
+
*/
|
|
39
|
+
export function useVoiceTalk(onGive, onError) {
|
|
40
|
+
const t = useT();
|
|
41
|
+
const language = useLanguage();
|
|
42
|
+
const [state, setState] = React.useState(IDLE);
|
|
43
|
+
// The phase as the finger and recognition find it, between renders.
|
|
44
|
+
const phase = React.useRef('idle');
|
|
45
|
+
const listening = React.useRef(undefined);
|
|
46
|
+
const heard = React.useRef('');
|
|
47
|
+
const since = React.useRef(0);
|
|
48
|
+
const held = React.useRef(0);
|
|
49
|
+
const zone = React.useRef('send');
|
|
50
|
+
/** Recognition ended while the finger was still down (a long silence): what it heard waits for the finger. */
|
|
51
|
+
const ended = React.useRef(false);
|
|
52
|
+
const timer = React.useRef(undefined);
|
|
53
|
+
// Recognition and the finger outlive a render: always to what the box is now.
|
|
54
|
+
const give = React.useRef(onGive);
|
|
55
|
+
give.current = onGive;
|
|
56
|
+
const fail = React.useRef(onError);
|
|
57
|
+
fail.current = onError;
|
|
58
|
+
// The box goes as it listens (another conversation, another page): what was said is not given to it.
|
|
59
|
+
React.useEffect(() => () => {
|
|
60
|
+
clearTimeout(timer.current);
|
|
61
|
+
const session = listening.current;
|
|
62
|
+
listening.current = undefined;
|
|
63
|
+
session === null || session === void 0 ? void 0 : session.stop();
|
|
64
|
+
}, []);
|
|
65
|
+
const go = (next, more) => {
|
|
66
|
+
phase.current = next;
|
|
67
|
+
setState(current => ({ ...current, ...more, phase: next }));
|
|
68
|
+
};
|
|
69
|
+
const later = (ms, then) => {
|
|
70
|
+
clearTimeout(timer.current);
|
|
71
|
+
timer.current = setTimeout(then, ms);
|
|
72
|
+
};
|
|
73
|
+
/** Stops listening, whatever it heard after. */
|
|
74
|
+
const quiet = () => {
|
|
75
|
+
const session = listening.current;
|
|
76
|
+
listening.current = undefined;
|
|
77
|
+
session === null || session === void 0 ? void 0 : session.stop();
|
|
78
|
+
};
|
|
79
|
+
/** The page comes back, the overlay fading out. */
|
|
80
|
+
const leave = () => {
|
|
81
|
+
quiet();
|
|
82
|
+
go('leaving');
|
|
83
|
+
later(VoiceTalkUtil.LEAVE_MS, () => {
|
|
84
|
+
phase.current = 'idle';
|
|
85
|
+
setState(IDLE);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/** The finger let go off 取消 and recognition said its last: the words go as the place it let go says. */
|
|
89
|
+
const deliver = () => {
|
|
90
|
+
const text = VoiceTalkUtil.given(heard.current, held.current);
|
|
91
|
+
const where = zone.current;
|
|
92
|
+
leave();
|
|
93
|
+
if (text && where !== 'cancel') {
|
|
94
|
+
give.current(text, where);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const start = () => {
|
|
98
|
+
if (phase.current === 'listening' || phase.current === 'released') {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
clearTimeout(timer.current);
|
|
102
|
+
since.current = Date.now();
|
|
103
|
+
held.current = 0;
|
|
104
|
+
heard.current = '';
|
|
105
|
+
zone.current = 'send';
|
|
106
|
+
ended.current = false;
|
|
107
|
+
// What a talk ended or dropped before still says it ended (onerror, then onend): not to the next one.
|
|
108
|
+
let session;
|
|
109
|
+
session = Voice.listen(language, words => {
|
|
110
|
+
if (listening.current === session) {
|
|
111
|
+
heard.current = words;
|
|
112
|
+
setState(current => ({ ...current, words }));
|
|
113
|
+
}
|
|
114
|
+
}, failure => {
|
|
115
|
+
if (listening.current !== session) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (failure) {
|
|
119
|
+
fail.current(new Error(t(Voice.denied(failure) ? 'ta.composer.voiceDenied' : 'ta.composer.voiceFailed', { error: failure })));
|
|
120
|
+
leave();
|
|
121
|
+
}
|
|
122
|
+
else if (phase.current === 'released') {
|
|
123
|
+
listening.current = undefined;
|
|
124
|
+
deliver();
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
ended.current = true;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
// A finger held goes on past a pause: it stops when it lets go.
|
|
131
|
+
true);
|
|
132
|
+
if (session) {
|
|
133
|
+
listening.current = session;
|
|
134
|
+
go('listening', { words: '', zone: 'send' });
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const point = (x, y) => {
|
|
138
|
+
if (phase.current !== 'listening') {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const next = VoiceTalkUtil.zone(document.elementFromPoint(x, y));
|
|
142
|
+
if (next !== zone.current) {
|
|
143
|
+
zone.current = next;
|
|
144
|
+
setState(current => ({ ...current, zone: next }));
|
|
145
|
+
if (next !== 'send') {
|
|
146
|
+
HeldUtil.tick();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const release = () => {
|
|
151
|
+
var _a;
|
|
152
|
+
if (phase.current !== 'listening') {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
held.current = Date.now() - since.current;
|
|
156
|
+
if (zone.current === 'cancel') {
|
|
157
|
+
leave();
|
|
158
|
+
}
|
|
159
|
+
else if (held.current < VoiceTalkUtil.SHORT_MS) {
|
|
160
|
+
// Too short to be meant: said so for a moment, and nothing is given.
|
|
161
|
+
quiet();
|
|
162
|
+
go('short');
|
|
163
|
+
later(VoiceTalkUtil.SHORT_NOTICE_MS, leave);
|
|
164
|
+
}
|
|
165
|
+
else if (ended.current) {
|
|
166
|
+
listening.current = undefined;
|
|
167
|
+
deliver();
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
go('released');
|
|
171
|
+
(_a = listening.current) === null || _a === void 0 ? void 0 : _a.stop();
|
|
172
|
+
// Recognition that does not say it ended would leave the page dimmed: the talk ends with what was heard.
|
|
173
|
+
later(VoiceTalkUtil.SETTLE_MS, () => phase.current === 'released' && deliver());
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const cancel = () => {
|
|
177
|
+
if (phase.current !== 'idle' && phase.current !== 'leaving') {
|
|
178
|
+
leave();
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
return { ...state, active: state.phase === 'listening' || state.phase === 'released', start, point, release, cancel };
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* What a talk shows, over the whole page (above the keyboard): the page dimmed, a green bubble with the words as
|
|
185
|
+
* they come, 取消 and 编辑 to slide the finger onto, and the bottom it starts on, which says what letting go does.
|
|
186
|
+
*/
|
|
187
|
+
export function VoiceTalkOverlay({ talk }) {
|
|
188
|
+
const t = useT();
|
|
189
|
+
const { phase, cancel } = talk;
|
|
190
|
+
const listening = phase === 'listening';
|
|
191
|
+
React.useEffect(() => {
|
|
192
|
+
if (!listening) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const onKey = (event) => event.key === 'Escape' && cancel();
|
|
196
|
+
document.addEventListener('keydown', onKey);
|
|
197
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
198
|
+
}, [listening, cancel]);
|
|
199
|
+
if (phase === 'idle') {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
const short = phase === 'short';
|
|
203
|
+
const hint = listening ? t(talk.zone === 'cancel' ? 'ta.talk.releaseCancel' : talk.zone === 'edit' ? 'ta.talk.releaseEdit' : 'ta.talk.releaseSend') : '';
|
|
204
|
+
return createPortal(React.createElement("div", { className: `ta-talk ta-talk-${talk.zone} ta-talk-${phase}`, role: "dialog", "aria-modal": "true", "aria-label": t('ta.talk.listening') },
|
|
205
|
+
React.createElement("div", { className: "ta-talk-bubble", "aria-live": "polite" }, short ? (React.createElement("p", { className: "ta-talk-words" }, t('ta.talk.tooShort'))) : talk.words ? (React.createElement("p", { className: "ta-talk-words" }, talk.words)) : (React.createElement("span", { className: "ta-wave", "aria-hidden": "true" },
|
|
206
|
+
React.createElement("i", null),
|
|
207
|
+
React.createElement("i", null),
|
|
208
|
+
React.createElement("i", null),
|
|
209
|
+
React.createElement("i", null)))),
|
|
210
|
+
React.createElement("div", { className: "ta-talk-zones", "aria-hidden": !listening },
|
|
211
|
+
React.createElement("div", { className: `ta-talk-zone${talk.zone === 'cancel' ? ' ta-on' : ''}`, "data-talk-zone": "cancel" },
|
|
212
|
+
React.createElement("span", { className: "ta-talk-zone-label" }, t('ta.cancel')),
|
|
213
|
+
React.createElement("span", { className: "ta-talk-zone-circle" },
|
|
214
|
+
React.createElement(Icon, { icon: X, size: 26 }))),
|
|
215
|
+
React.createElement("div", { className: `ta-talk-zone${talk.zone === 'edit' ? ' ta-on' : ''}`, "data-talk-zone": "edit" },
|
|
216
|
+
React.createElement("span", { className: "ta-talk-zone-label" }, t('ta.talk.edit')),
|
|
217
|
+
React.createElement("span", { className: "ta-talk-zone-circle" },
|
|
218
|
+
React.createElement(Icon, { icon: PenLine, size: 24 })))),
|
|
219
|
+
React.createElement("div", { className: "ta-talk-base" },
|
|
220
|
+
React.createElement("span", { className: "ta-talk-hint" }, hint))), document.body);
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=voice-talk.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type DeviceLayout, type DeviceState } from './device-protocol.js';
|
|
3
3
|
import { type NewLineBridge } from './new-line.js';
|
|
4
|
+
import { type ShakeUndoBridge } from './shake-undo.js';
|
|
4
5
|
/** What the observer reads of the browser; tests give their own. */
|
|
5
6
|
export interface DeviceEnvironment {
|
|
6
7
|
matchMedia(query: string): {
|
|
@@ -33,6 +34,8 @@ export interface DeviceEnvironment {
|
|
|
33
34
|
readonly keyboard?: (listener: (height: number) => void) => void;
|
|
34
35
|
/** The edit menu of the app on iOS, which offers New Line in the message box (new-line.ts); none elsewhere. */
|
|
35
36
|
readonly newLine?: NewLineBridge;
|
|
37
|
+
/** Shake to Undo of the app on iOS, offered only while a field has text (shake-undo.ts); none elsewhere. */
|
|
38
|
+
readonly shakeUndo?: ShakeUndoBridge;
|
|
36
39
|
}
|
|
37
40
|
export declare namespace DeviceUtil {
|
|
38
41
|
/** Where the page is not in a browser (tests, the server). */
|
|
@@ -3,6 +3,7 @@ import { DeviceMedia, DeviceMotion } from './device-protocol.js';
|
|
|
3
3
|
import { startFieldDismiss } from './field-dismiss.js';
|
|
4
4
|
import { startLongPress } from './long-press.js';
|
|
5
5
|
import { startNewLine } from './new-line.js';
|
|
6
|
+
import { startShakeUndo } from './shake-undo.js';
|
|
6
7
|
/** How much of the height the keyboard has to take before it counts as open: more than the bars of a browser. */
|
|
7
8
|
const KEYBOARD_PX = 80;
|
|
8
9
|
export var DeviceUtil;
|
|
@@ -95,6 +96,9 @@ export class DeviceObserver {
|
|
|
95
96
|
if (env.newLine) {
|
|
96
97
|
startNewLine(env.document, env.newLine);
|
|
97
98
|
}
|
|
99
|
+
if (env.shakeUndo) {
|
|
100
|
+
startShakeUndo(env.document, env.shakeUndo);
|
|
101
|
+
}
|
|
98
102
|
}
|
|
99
103
|
if (env.keyboard) {
|
|
100
104
|
env.keyboard(height => this.moveKeyboard(height));
|
|
@@ -194,9 +198,15 @@ function browser() {
|
|
|
194
198
|
root: document.documentElement,
|
|
195
199
|
native: nativeBridge(),
|
|
196
200
|
keyboard: nativeKeyboard(),
|
|
197
|
-
newLine: (
|
|
201
|
+
newLine: (_a = messageHandlers()) === null || _a === void 0 ? void 0 : _a.taEditing,
|
|
202
|
+
shakeUndo: (_b = messageHandlers()) === null || _b === void 0 ? void 0 : _b.taUndo,
|
|
198
203
|
};
|
|
199
204
|
}
|
|
205
|
+
/** What the Ta app on iOS listens to from the page (TaBridgeViewController of apps/ta-mobile); none elsewhere. */
|
|
206
|
+
function messageHandlers() {
|
|
207
|
+
var _a;
|
|
208
|
+
return (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers;
|
|
209
|
+
}
|
|
200
210
|
/** One plugin of the Ta app (Capacitor), when the app has it; none in a browser, or in an app built before it. */
|
|
201
211
|
export function nativePlugin(name) {
|
|
202
212
|
var _a;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* What a held finger does, as the talk button of a phone's chat: it starts once the finger has been kept still
|
|
4
|
+
* for PRESS_MS, follows the finger while it stays, and ends when it lets go.
|
|
5
|
+
*/
|
|
6
|
+
export interface Hold {
|
|
7
|
+
/** Whether a press is the hold's (a field, a button of its own are not); every press is, without it. */
|
|
8
|
+
accepts?(event: React.PointerEvent): boolean;
|
|
9
|
+
start(): void;
|
|
10
|
+
/** Where the finger is while it is held, in the coordinates of the page. */
|
|
11
|
+
move?(x: number, y: number): void;
|
|
12
|
+
/** The finger let go. */
|
|
13
|
+
end(): void;
|
|
14
|
+
/** The system took the finger (a gesture of its own, a call): nothing is given. */
|
|
15
|
+
cancel(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What an element takes of the pointer, for the hold it has. `data-held` takes the panning of a finger from the
|
|
19
|
+
* browser (style/device.ts): it decides that as the finger lands, too early for a hold, and a pan it began takes
|
|
20
|
+
* the finger from the page (pointercancel) as soon as it slides toward 取消.
|
|
21
|
+
*/
|
|
22
|
+
export interface HeldProps {
|
|
23
|
+
onPointerDown?(event: React.PointerEvent): void;
|
|
24
|
+
onContextMenu?(event: React.MouseEvent): void;
|
|
25
|
+
'data-held'?: '';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Something done while an element is held. A press that moves first scrolls, and one let go before PRESS_MS
|
|
29
|
+
* starts nothing, so that a tap stays a tap. Once held, the finger is the hold's until it lets go: the page does
|
|
30
|
+
* not scroll under it, the system's menu and selection do not come, the click of the finger let go is not a tap
|
|
31
|
+
* of what was under it, and the hold outlives the element (a tab bar that a page slides over).
|
|
32
|
+
*/
|
|
33
|
+
export declare function useHeld(): (hold: Hold | undefined) => HeldProps;
|
|
34
|
+
export declare namespace HeldUtil {
|
|
35
|
+
/** A light tap of the haptic engine as a held finger comes onto something (取消, 编辑): the app's, or a phone's. */
|
|
36
|
+
function tick(): void;
|
|
37
|
+
/**
|
|
38
|
+
* The click that follows a finger let go after a hold: not a tap of what was under it. A browser that sends
|
|
39
|
+
* none (a long press is no tap to it) leaves the next press its own.
|
|
40
|
+
*/
|
|
41
|
+
function swallowClick(): void;
|
|
42
|
+
}
|