@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.
Files changed (302) hide show
  1. package/README.en.md +4 -3
  2. package/README.md +4 -3
  3. package/esm/browser/assistant/assistant-chat-list.js +8 -2
  4. package/esm/browser/assistant/assistant-extension.d.ts +8 -1
  5. package/esm/browser/assistant/assistant-extension.js +20 -0
  6. package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
  7. package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
  8. package/esm/browser/assistant/assistant-task-util.js +5 -3
  9. package/esm/browser/assistant/assistant-view.js +81 -56
  10. package/esm/browser/assistant/assistant.d.ts +10 -1
  11. package/esm/browser/assistant/assistant.js +44 -5
  12. package/esm/browser/chat/chat-packages.d.ts +39 -0
  13. package/esm/browser/chat/chat-packages.js +70 -0
  14. package/esm/browser/chat/chat-protocol.d.ts +23 -1
  15. package/esm/browser/chat/chat-stores.d.ts +59 -0
  16. package/esm/browser/chat/chat-stores.js +121 -0
  17. package/esm/browser/chat/chat-util.d.ts +17 -0
  18. package/esm/browser/chat/chat-util.js +61 -0
  19. package/esm/browser/chat/chat-view.js +33 -12
  20. package/esm/browser/chat/chat.d.ts +31 -39
  21. package/esm/browser/chat/chat.js +226 -175
  22. package/esm/browser/components/app-nav.d.ts +6 -3
  23. package/esm/browser/components/app-nav.js +19 -10
  24. package/esm/browser/components/app-shell-hooks.d.ts +2 -2
  25. package/esm/browser/components/app-shell-hooks.js +7 -3
  26. package/esm/browser/components/app-view.js +75 -21
  27. package/esm/browser/components/chat-list.d.ts +20 -2
  28. package/esm/browser/components/chat-list.js +138 -22
  29. package/esm/browser/components/composer-box.d.ts +5 -5
  30. package/esm/browser/components/composer-box.js +111 -4
  31. package/esm/browser/components/composer.d.ts +7 -0
  32. package/esm/browser/components/composer.js +5 -4
  33. package/esm/browser/components/connection-bar.js +50 -17
  34. package/esm/browser/components/context-menu.d.ts +30 -4
  35. package/esm/browser/components/context-menu.js +199 -37
  36. package/esm/browser/components/conversation-scroll.d.ts +129 -6
  37. package/esm/browser/components/conversation-scroll.js +429 -109
  38. package/esm/browser/components/earlier-messages.d.ts +2 -1
  39. package/esm/browser/components/earlier-messages.js +2 -17
  40. package/esm/browser/components/editor-area.d.ts +3 -1
  41. package/esm/browser/components/editor-area.js +6 -5
  42. package/esm/browser/components/empty-pictures.d.ts +0 -2
  43. package/esm/browser/components/empty-pictures.js +0 -16
  44. package/esm/browser/components/folder-picker.d.ts +5 -2
  45. package/esm/browser/components/folder-picker.js +26 -8
  46. package/esm/browser/components/held-talk.d.ts +28 -0
  47. package/esm/browser/components/held-talk.js +76 -0
  48. package/esm/browser/components/host-view.d.ts +1 -1
  49. package/esm/browser/components/icon.d.ts +2 -2
  50. package/esm/browser/components/icon.js +5 -6
  51. package/esm/browser/components/image-viewer.d.ts +124 -0
  52. package/esm/browser/components/image-viewer.js +397 -0
  53. package/esm/browser/components/lightbox.d.ts +11 -0
  54. package/esm/browser/components/lightbox.js +24 -0
  55. package/esm/browser/components/markdown.d.ts +6 -2
  56. package/esm/browser/components/markdown.js +24 -10
  57. package/esm/browser/components/media.js +1 -10
  58. package/esm/browser/components/message-footer.d.ts +16 -2
  59. package/esm/browser/components/message-footer.js +29 -12
  60. package/esm/browser/components/message-list.d.ts +24 -3
  61. package/esm/browser/components/message-list.js +149 -20
  62. package/esm/browser/components/message-menu.d.ts +3 -1
  63. package/esm/browser/components/message-menu.js +18 -3
  64. package/esm/browser/components/nav-places.d.ts +16 -1
  65. package/esm/browser/components/nav-places.js +12 -3
  66. package/esm/browser/components/phone-shell.d.ts +4 -1
  67. package/esm/browser/components/phone-shell.js +3 -1
  68. package/esm/browser/components/run-status.js +3 -3
  69. package/esm/browser/components/session-settings.d.ts +6 -0
  70. package/esm/browser/components/session-settings.js +14 -1
  71. package/esm/browser/components/session-view.js +8 -4
  72. package/esm/browser/components/settings-parts.d.ts +2 -2
  73. package/esm/browser/components/settings-parts.js +24 -1
  74. package/esm/browser/components/swipe-row.d.ts +2 -2
  75. package/esm/browser/components/swipe-row.js +7 -3
  76. package/esm/browser/components/tool-view.js +14 -12
  77. package/esm/browser/components/voice-button.d.ts +1 -1
  78. package/esm/browser/components/voice-button.js +1 -1
  79. package/esm/browser/components/voice-talk.d.ts +43 -0
  80. package/esm/browser/components/voice-talk.js +222 -0
  81. package/esm/browser/device/device.d.ts +3 -0
  82. package/esm/browser/device/device.js +11 -1
  83. package/esm/browser/device/hold.d.ts +42 -0
  84. package/esm/browser/device/hold.js +136 -0
  85. package/esm/browser/device/launch-screen.d.ts +1 -1
  86. package/esm/browser/device/launch-screen.js +1 -1
  87. package/esm/browser/device/long-press.d.ts +2 -0
  88. package/esm/browser/device/long-press.js +16 -1
  89. package/esm/browser/device/pull-down.d.ts +4 -2
  90. package/esm/browser/device/pull-down.js +64 -76
  91. package/esm/browser/device/row-swipe.d.ts +35 -10
  92. package/esm/browser/device/row-swipe.js +149 -71
  93. package/esm/browser/device/shake-undo.d.ts +16 -0
  94. package/esm/browser/device/shake-undo.js +59 -0
  95. package/esm/browser/device/sheet-swipe.d.ts +118 -18
  96. package/esm/browser/device/sheet-swipe.js +406 -107
  97. package/esm/browser/extension/web-extension-api.d.ts +97 -1
  98. package/esm/browser/extension/web-extension-code.d.ts +6 -0
  99. package/esm/browser/extension/web-extension-code.js +24 -0
  100. package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
  101. package/esm/browser/extension/web-extension-protocol.js +8 -0
  102. package/esm/browser/extension/web-extensions.d.ts +14 -1
  103. package/esm/browser/extension/web-extensions.js +122 -23
  104. package/esm/browser/files/files-protocol.d.ts +25 -0
  105. package/esm/browser/files/files-protocol.js +2 -0
  106. package/esm/browser/files/files.d.ts +35 -0
  107. package/esm/browser/files/files.js +119 -0
  108. package/esm/browser/i18n/locales.d.ts +24 -2
  109. package/esm/browser/i18n/messages.d.ts +23 -1
  110. package/esm/browser/i18n/messages.js +48 -4
  111. package/esm/browser/index.d.ts +6 -0
  112. package/esm/browser/index.js +6 -0
  113. package/esm/browser/notices/notices-protocol.d.ts +9 -1
  114. package/esm/browser/notices/notices.d.ts +2 -0
  115. package/esm/browser/notices/notices.js +20 -10
  116. package/esm/browser/offline/device-values.d.ts +55 -0
  117. package/esm/browser/offline/device-values.js +142 -0
  118. package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
  119. package/esm/browser/offline/kept-chats-protocol.js +2 -0
  120. package/esm/browser/offline/kept-chats.d.ts +47 -0
  121. package/esm/browser/offline/kept-chats.js +146 -0
  122. package/esm/browser/offline/offline-reads.d.ts +44 -0
  123. package/esm/browser/offline/offline-reads.js +107 -0
  124. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  125. package/esm/browser/settings/settings-protocol.js +2 -0
  126. package/esm/browser/style/conversation.d.ts +1 -1
  127. package/esm/browser/style/conversation.js +57 -17
  128. package/esm/browser/style/device.js +27 -4
  129. package/esm/browser/style/layout.d.ts +1 -1
  130. package/esm/browser/style/layout.js +67 -15
  131. package/esm/browser/style/pages.d.ts +1 -1
  132. package/esm/browser/style/pages.js +2 -1
  133. package/esm/browser/style/shell.d.ts +1 -1
  134. package/esm/browser/style/shell.js +46 -3
  135. package/esm/browser/util/frame.d.ts +5 -4
  136. package/esm/browser/util/frame.js +5 -4
  137. package/esm/browser/util/markdown.d.ts +18 -1
  138. package/esm/browser/util/markdown.js +119 -5
  139. package/esm/browser/util/process.d.ts +21 -0
  140. package/esm/browser/util/process.js +45 -1
  141. package/esm/browser/util/voice.d.ts +5 -2
  142. package/esm/browser/util/voice.js +6 -3
  143. package/esm/browser/util/zoom.d.ts +46 -0
  144. package/esm/browser/util/zoom.js +96 -0
  145. package/esm/browser/workbench-calls.d.ts +59 -0
  146. package/esm/browser/workbench-calls.js +141 -0
  147. package/esm/browser/workbench-protocol.d.ts +5 -1
  148. package/esm/browser/workbench-util.d.ts +7 -0
  149. package/esm/browser/workbench-util.js +9 -2
  150. package/esm/browser/workbench.d.ts +14 -5
  151. package/esm/browser/workbench.js +51 -31
  152. package/lib/browser/assistant/assistant-chat-list.js +8 -2
  153. package/lib/browser/assistant/assistant-extension.d.ts +8 -1
  154. package/lib/browser/assistant/assistant-extension.js +20 -0
  155. package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
  156. package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
  157. package/lib/browser/assistant/assistant-task-util.js +5 -3
  158. package/lib/browser/assistant/assistant-view.js +78 -53
  159. package/lib/browser/assistant/assistant.d.ts +10 -1
  160. package/lib/browser/assistant/assistant.js +44 -5
  161. package/lib/browser/chat/chat-packages.d.ts +40 -0
  162. package/lib/browser/chat/chat-packages.js +74 -0
  163. package/lib/browser/chat/chat-protocol.d.ts +23 -1
  164. package/lib/browser/chat/chat-stores.d.ts +60 -0
  165. package/lib/browser/chat/chat-stores.js +125 -0
  166. package/lib/browser/chat/chat-util.d.ts +18 -0
  167. package/lib/browser/chat/chat-util.js +64 -0
  168. package/lib/browser/chat/chat-view.js +33 -12
  169. package/lib/browser/chat/chat.d.ts +31 -39
  170. package/lib/browser/chat/chat.js +227 -176
  171. package/lib/browser/components/app-nav.d.ts +6 -3
  172. package/lib/browser/components/app-nav.js +17 -8
  173. package/lib/browser/components/app-shell-hooks.d.ts +2 -2
  174. package/lib/browser/components/app-shell-hooks.js +7 -3
  175. package/lib/browser/components/app-view.js +74 -20
  176. package/lib/browser/components/chat-list.d.ts +20 -2
  177. package/lib/browser/components/chat-list.js +137 -21
  178. package/lib/browser/components/composer-box.d.ts +5 -5
  179. package/lib/browser/components/composer-box.js +111 -4
  180. package/lib/browser/components/composer.d.ts +7 -0
  181. package/lib/browser/components/composer.js +5 -4
  182. package/lib/browser/components/connection-bar.js +48 -15
  183. package/lib/browser/components/context-menu.d.ts +30 -4
  184. package/lib/browser/components/context-menu.js +198 -36
  185. package/lib/browser/components/conversation-scroll.d.ts +129 -6
  186. package/lib/browser/components/conversation-scroll.js +431 -110
  187. package/lib/browser/components/earlier-messages.d.ts +2 -1
  188. package/lib/browser/components/earlier-messages.js +2 -17
  189. package/lib/browser/components/editor-area.d.ts +3 -1
  190. package/lib/browser/components/editor-area.js +5 -4
  191. package/lib/browser/components/empty-pictures.d.ts +0 -2
  192. package/lib/browser/components/empty-pictures.js +0 -17
  193. package/lib/browser/components/folder-picker.d.ts +5 -2
  194. package/lib/browser/components/folder-picker.js +26 -8
  195. package/lib/browser/components/held-talk.d.ts +29 -0
  196. package/lib/browser/components/held-talk.js +79 -0
  197. package/lib/browser/components/host-view.d.ts +1 -1
  198. package/lib/browser/components/icon.d.ts +2 -2
  199. package/lib/browser/components/icon.js +7 -6
  200. package/lib/browser/components/image-viewer.d.ts +125 -0
  201. package/lib/browser/components/image-viewer.js +435 -0
  202. package/lib/browser/components/lightbox.d.ts +12 -0
  203. package/lib/browser/components/lightbox.js +60 -0
  204. package/lib/browser/components/markdown.d.ts +6 -2
  205. package/lib/browser/components/markdown.js +24 -10
  206. package/lib/browser/components/media.js +2 -11
  207. package/lib/browser/components/message-footer.d.ts +16 -2
  208. package/lib/browser/components/message-footer.js +31 -12
  209. package/lib/browser/components/message-list.d.ts +24 -3
  210. package/lib/browser/components/message-list.js +146 -16
  211. package/lib/browser/components/message-menu.d.ts +3 -1
  212. package/lib/browser/components/message-menu.js +17 -2
  213. package/lib/browser/components/nav-places.d.ts +16 -1
  214. package/lib/browser/components/nav-places.js +13 -3
  215. package/lib/browser/components/phone-shell.d.ts +4 -1
  216. package/lib/browser/components/phone-shell.js +3 -1
  217. package/lib/browser/components/run-status.js +3 -3
  218. package/lib/browser/components/session-settings.d.ts +6 -0
  219. package/lib/browser/components/session-settings.js +14 -1
  220. package/lib/browser/components/session-view.js +7 -3
  221. package/lib/browser/components/settings-parts.d.ts +2 -2
  222. package/lib/browser/components/settings-parts.js +24 -1
  223. package/lib/browser/components/swipe-row.d.ts +2 -2
  224. package/lib/browser/components/swipe-row.js +7 -3
  225. package/lib/browser/components/tool-view.js +14 -12
  226. package/lib/browser/components/voice-button.d.ts +1 -1
  227. package/lib/browser/components/voice-button.js +1 -1
  228. package/lib/browser/components/voice-talk.d.ts +44 -0
  229. package/lib/browser/components/voice-talk.js +260 -0
  230. package/lib/browser/device/device.d.ts +3 -0
  231. package/lib/browser/device/device.js +11 -1
  232. package/lib/browser/device/hold.d.ts +43 -0
  233. package/lib/browser/device/hold.js +173 -0
  234. package/lib/browser/device/launch-screen.d.ts +1 -1
  235. package/lib/browser/device/launch-screen.js +1 -1
  236. package/lib/browser/device/long-press.d.ts +2 -0
  237. package/lib/browser/device/long-press.js +16 -1
  238. package/lib/browser/device/pull-down.d.ts +4 -2
  239. package/lib/browser/device/pull-down.js +63 -75
  240. package/lib/browser/device/row-swipe.d.ts +35 -10
  241. package/lib/browser/device/row-swipe.js +148 -70
  242. package/lib/browser/device/shake-undo.d.ts +17 -0
  243. package/lib/browser/device/shake-undo.js +63 -0
  244. package/lib/browser/device/sheet-swipe.d.ts +118 -18
  245. package/lib/browser/device/sheet-swipe.js +410 -108
  246. package/lib/browser/extension/web-extension-api.d.ts +97 -1
  247. package/lib/browser/extension/web-extension-code.d.ts +6 -0
  248. package/lib/browser/extension/web-extension-code.js +24 -0
  249. package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
  250. package/lib/browser/extension/web-extension-protocol.js +9 -1
  251. package/lib/browser/extension/web-extensions.d.ts +14 -1
  252. package/lib/browser/extension/web-extensions.js +120 -21
  253. package/lib/browser/files/files-protocol.d.ts +26 -0
  254. package/lib/browser/files/files-protocol.js +5 -0
  255. package/lib/browser/files/files.d.ts +36 -0
  256. package/lib/browser/files/files.js +122 -0
  257. package/lib/browser/i18n/locales.d.ts +24 -2
  258. package/lib/browser/i18n/messages.d.ts +23 -1
  259. package/lib/browser/i18n/messages.js +48 -4
  260. package/lib/browser/index.d.ts +6 -0
  261. package/lib/browser/index.js +6 -0
  262. package/lib/browser/notices/notices-protocol.d.ts +9 -1
  263. package/lib/browser/notices/notices.d.ts +2 -0
  264. package/lib/browser/notices/notices.js +20 -10
  265. package/lib/browser/offline/device-values.d.ts +56 -0
  266. package/lib/browser/offline/device-values.js +148 -0
  267. package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
  268. package/lib/browser/offline/kept-chats-protocol.js +5 -0
  269. package/lib/browser/offline/kept-chats.d.ts +48 -0
  270. package/lib/browser/offline/kept-chats.js +149 -0
  271. package/lib/browser/offline/offline-reads.d.ts +45 -0
  272. package/lib/browser/offline/offline-reads.js +111 -0
  273. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  274. package/lib/browser/settings/settings-protocol.js +2 -0
  275. package/lib/browser/style/conversation.d.ts +1 -1
  276. package/lib/browser/style/conversation.js +57 -17
  277. package/lib/browser/style/device.js +27 -4
  278. package/lib/browser/style/layout.d.ts +1 -1
  279. package/lib/browser/style/layout.js +67 -15
  280. package/lib/browser/style/pages.d.ts +1 -1
  281. package/lib/browser/style/pages.js +2 -1
  282. package/lib/browser/style/shell.d.ts +1 -1
  283. package/lib/browser/style/shell.js +46 -3
  284. package/lib/browser/util/frame.d.ts +5 -4
  285. package/lib/browser/util/frame.js +5 -4
  286. package/lib/browser/util/markdown.d.ts +18 -1
  287. package/lib/browser/util/markdown.js +119 -5
  288. package/lib/browser/util/process.d.ts +21 -0
  289. package/lib/browser/util/process.js +46 -2
  290. package/lib/browser/util/voice.d.ts +5 -2
  291. package/lib/browser/util/voice.js +6 -3
  292. package/lib/browser/util/zoom.d.ts +47 -0
  293. package/lib/browser/util/zoom.js +99 -0
  294. package/lib/browser/workbench-calls.d.ts +60 -0
  295. package/lib/browser/workbench-calls.js +145 -0
  296. package/lib/browser/workbench-protocol.d.ts +5 -1
  297. package/lib/browser/workbench-util.d.ts +7 -0
  298. package/lib/browser/workbench-util.js +10 -3
  299. package/lib/browser/workbench.d.ts +14 -5
  300. package/lib/browser/workbench.js +51 -31
  301. package/package.json +10 -10
  302. 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 fileUrl = React.useCallback((path) => workspace.fileUrl(path, cwd), [workspace, cwd]);
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: LucideIcon;
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
- }, enabled && (React.createElement("div", { className: "ta-swipe-actions", inert: !open }, actions === null || actions === void 0 ? void 0 : actions.map(action => (React.createElement("button", { key: action.key, type: "button", className: `ta-swipe-action${action.danger ? ' ta-danger' : ''}`, onClick: () => {
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", style: enabled ? { '--ta-swipe-width': `${ACTION_PX * ((_a = actions === null || actions === void 0 ? void 0 : actions.length) !== null && _a !== void 0 ? _a : 0)}px` } : undefined, onClickCapture: open ? closeInstead : undefined }, children), overlay);
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
- details ? React.createElement(Icon, { icon: ChevronRight, size: 13, className: "ta-tool-chevron" }) : React.createElement("span", { className: "ta-tool-chevron" })));
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
- details ? (React.createElement("button", { type: "button", className: "ta-tool-title", "aria-expanded": open, onClick: () => setOpen(!open) }, line)) : (React.createElement("div", { className: "ta-tool-title" }, line)),
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
- const failedAlone = status === 'error' && !calls.some(call => call.status === 'error');
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
- calls.map((call, index) => (React.createElement(NestedRow, { key: call.key, call: call, trailing: index === 0 ? toggle : undefined }))),
101
- failedAlone && React.createElement(ToolRow, { name: "codemode", args: { code }, status: "error", details: result && React.createElement(Output, { text: result }) }),
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 NestedRow({ call, trailing }) {
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 React.createElement(ToolRow, { name: call.name, args: call.args, status: call.status, trailing: trailing, details: shown || error || undefined });
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: (_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.taEditing,
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
+ }