@celljs/ta-web 4.48.0 → 4.50.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 (382) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/account/account-side.js +4 -0
  4. package/esm/browser/account/device-account.d.ts +6 -0
  5. package/esm/browser/account/device-account.js +20 -5
  6. package/esm/browser/assistant/assistant-view.js +2 -0
  7. package/esm/browser/assistant/call-announcing.d.ts +25 -0
  8. package/esm/browser/assistant/call-announcing.js +32 -0
  9. package/esm/browser/assistant/call-answering.d.ts +43 -0
  10. package/esm/browser/assistant/call-answering.js +63 -0
  11. package/esm/browser/assistant/call-hearing.d.ts +53 -0
  12. package/esm/browser/assistant/call-hearing.js +98 -0
  13. package/esm/browser/assistant/call-pausing.d.ts +40 -0
  14. package/esm/browser/assistant/call-pausing.js +82 -0
  15. package/esm/browser/assistant/call-reading.d.ts +32 -0
  16. package/esm/browser/assistant/call-reading.js +35 -0
  17. package/esm/browser/assistant/call-revoicing.d.ts +33 -0
  18. package/esm/browser/assistant/call-revoicing.js +68 -0
  19. package/esm/browser/assistant/call-turns.d.ts +29 -0
  20. package/esm/browser/assistant/call-turns.js +33 -0
  21. package/esm/browser/assistant/spoken-answer.d.ts +21 -0
  22. package/esm/browser/assistant/spoken-answer.js +69 -0
  23. package/esm/browser/assistant/spoken-call.d.ts +7 -0
  24. package/esm/browser/assistant/spoken-call.js +16 -0
  25. package/esm/browser/assistant/voice-call-protocol.d.ts +5 -0
  26. package/esm/browser/assistant/voice-call.d.ts +47 -43
  27. package/esm/browser/assistant/voice-call.js +193 -219
  28. package/esm/browser/chat/chat-view.js +2 -1
  29. package/esm/browser/components/account-recovery-view.d.ts +11 -0
  30. package/esm/browser/components/account-recovery-view.js +81 -0
  31. package/esm/browser/components/account-view.d.ts +1 -2
  32. package/esm/browser/components/account-view.js +10 -1
  33. package/esm/browser/components/app-nav.js +19 -8
  34. package/esm/browser/components/app-shell-hooks.d.ts +5 -0
  35. package/esm/browser/components/app-shell-hooks.js +45 -0
  36. package/esm/browser/components/app-shell-state.js +2 -1
  37. package/esm/browser/components/app-view.js +9 -5
  38. package/esm/browser/components/chat-emoji.d.ts +35 -0
  39. package/esm/browser/components/chat-emoji.js +129 -0
  40. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  41. package/esm/browser/components/composer-attachments.d.ts +6 -0
  42. package/esm/browser/components/composer-attachments.js +12 -1
  43. package/esm/browser/components/composer-box-protocol.d.ts +15 -0
  44. package/esm/browser/components/composer-box.js +110 -87
  45. package/esm/browser/components/composer-drop-hooks.d.ts +26 -0
  46. package/esm/browser/components/composer-drop-hooks.js +36 -0
  47. package/esm/browser/components/composer-emoji.js +1 -1
  48. package/esm/browser/components/composer-faces.d.ts +16 -0
  49. package/esm/browser/components/composer-faces.js +37 -0
  50. package/esm/browser/components/composer-media.d.ts +10 -0
  51. package/esm/browser/components/composer-media.js +12 -1
  52. package/esm/browser/components/composer-target.d.ts +4 -0
  53. package/esm/browser/components/composer-target.js +18 -7
  54. package/esm/browser/components/composer-type-focus.d.ts +24 -0
  55. package/esm/browser/components/composer-type-focus.js +17 -0
  56. package/esm/browser/components/composer-voice.d.ts +24 -0
  57. package/esm/browser/components/composer-voice.js +37 -0
  58. package/esm/browser/components/composer.d.ts +2 -2
  59. package/esm/browser/components/composer.js +39 -8
  60. package/esm/browser/components/context-menu.js +2 -1
  61. package/esm/browser/components/emoji-panel.d.ts +11 -7
  62. package/esm/browser/components/emoji-panel.js +40 -22
  63. package/esm/browser/components/extension-settings.js +2 -2
  64. package/esm/browser/components/folder-new.d.ts +18 -0
  65. package/esm/browser/components/folder-new.js +53 -0
  66. package/esm/browser/components/folder-picker.d.ts +5 -2
  67. package/esm/browser/components/folder-picker.js +18 -6
  68. package/esm/browser/components/host-view.d.ts +1 -1
  69. package/esm/browser/components/image-menu.d.ts +8 -3
  70. package/esm/browser/components/image-menu.js +34 -9
  71. package/esm/browser/components/markdown.js +9 -2
  72. package/esm/browser/components/media.js +3 -2
  73. package/esm/browser/components/message-list.js +2 -2
  74. package/esm/browser/components/message-steps.js +20 -11
  75. package/esm/browser/components/message-user.js +2 -2
  76. package/esm/browser/components/moved-notice.js +2 -1
  77. package/esm/browser/components/nav-places.d.ts +2 -0
  78. package/esm/browser/components/nav-places.js +4 -2
  79. package/esm/browser/components/phone-shell.d.ts +2 -0
  80. package/esm/browser/components/phone-shell.js +5 -1
  81. package/esm/browser/components/secret-text.d.ts +1 -1
  82. package/esm/browser/components/secret-text.js +4 -3
  83. package/esm/browser/components/session-view.js +3 -0
  84. package/esm/browser/components/settings-choices.d.ts +2 -1
  85. package/esm/browser/components/settings-choices.js +13 -5
  86. package/esm/browser/components/settings-more.js +3 -3
  87. package/esm/browser/components/settings-parts.js +13 -2
  88. package/esm/browser/components/share-item-sheet.js +7 -1
  89. package/esm/browser/components/tab-title.d.ts +27 -0
  90. package/esm/browser/components/tab-title.js +35 -0
  91. package/esm/browser/components/use-composer-attachments.d.ts +28 -0
  92. package/esm/browser/components/use-composer-attachments.js +65 -0
  93. package/esm/browser/components/use-composer-files.d.ts +25 -0
  94. package/esm/browser/components/use-composer-files.js +52 -0
  95. package/esm/browser/components/web-composer.d.ts +3 -1
  96. package/esm/browser/components/web-composer.js +3 -2
  97. package/esm/browser/components/workbench-view.js +1 -0
  98. package/esm/browser/components/working-directory.js +2 -1
  99. package/esm/browser/device/drag-move.d.ts +21 -0
  100. package/esm/browser/device/drag-move.js +86 -0
  101. package/esm/browser/extension/icons.js +7 -1
  102. package/esm/browser/extension/web-api-desktop.d.ts +19 -0
  103. package/esm/browser/extension/web-api-menus.d.ts +19 -0
  104. package/esm/browser/extension/web-api-spec.js +2 -0
  105. package/esm/browser/extension/web-extension-api.d.ts +24 -23
  106. package/esm/browser/extension/web-extension-context.d.ts +1 -0
  107. package/esm/browser/extension/web-extension-context.js +12 -5
  108. package/esm/browser/extension/web-extension-run.js +1 -0
  109. package/esm/browser/extension/web-share-ui.d.ts +1 -1
  110. package/esm/browser/extension/web-share-ui.js +2 -0
  111. package/esm/browser/extension/web-share.d.ts +13 -0
  112. package/esm/browser/extension/web-share.js +37 -2
  113. package/esm/browser/i18n/en/account.d.ts +18 -0
  114. package/esm/browser/i18n/en/account.js +18 -0
  115. package/esm/browser/i18n/en/call.js +1 -1
  116. package/esm/browser/i18n/en/chat.d.ts +15 -0
  117. package/esm/browser/i18n/en/chat.js +16 -1
  118. package/esm/browser/i18n/en/common.d.ts +2 -0
  119. package/esm/browser/i18n/en/common.js +2 -0
  120. package/esm/browser/i18n/en/discover.d.ts +2 -0
  121. package/esm/browser/i18n/en/discover.js +2 -0
  122. package/esm/browser/i18n/en/settings.d.ts +17 -0
  123. package/esm/browser/i18n/en/settings.js +17 -0
  124. package/esm/browser/i18n/ja/account.js +18 -0
  125. package/esm/browser/i18n/ja/call.js +1 -1
  126. package/esm/browser/i18n/ja/chat.js +16 -1
  127. package/esm/browser/i18n/ja/common.js +2 -0
  128. package/esm/browser/i18n/ja/discover.js +3 -1
  129. package/esm/browser/i18n/ja/settings.js +17 -0
  130. package/esm/browser/i18n/locales.d.ts +55 -1
  131. package/esm/browser/i18n/messages.d.ts +54 -0
  132. package/esm/browser/i18n/zh/account.js +18 -0
  133. package/esm/browser/i18n/zh/call.js +1 -1
  134. package/esm/browser/i18n/zh/chat.js +16 -1
  135. package/esm/browser/i18n/zh/common.js +2 -0
  136. package/esm/browser/i18n/zh/discover.js +3 -1
  137. package/esm/browser/i18n/zh/settings.js +17 -0
  138. package/esm/browser/i18n/zh-tw/account.js +18 -0
  139. package/esm/browser/i18n/zh-tw/call.js +1 -1
  140. package/esm/browser/i18n/zh-tw/chat.js +16 -1
  141. package/esm/browser/i18n/zh-tw/common.js +2 -0
  142. package/esm/browser/i18n/zh-tw/discover.js +3 -1
  143. package/esm/browser/i18n/zh-tw/settings.js +17 -0
  144. package/esm/browser/offline/kept-chats.d.ts +3 -1
  145. package/esm/browser/offline/kept-chats.js +1 -1
  146. package/esm/browser/partners/group-picker.d.ts +3 -2
  147. package/esm/browser/partners/group-picker.js +8 -3
  148. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  149. package/esm/browser/sandbox/work/work-docs.js +5 -2
  150. package/esm/browser/sandbox/work/work-frame.d.ts +3 -0
  151. package/esm/browser/sandbox/work/work-frame.js +9 -3
  152. package/esm/browser/sandbox/work/work-gates.d.ts +77 -0
  153. package/esm/browser/sandbox/work/work-gates.js +182 -0
  154. package/esm/browser/settings/agent-settings.js +1 -1
  155. package/esm/browser/settings/navigation.d.ts +38 -10
  156. package/esm/browser/settings/navigation.js +73 -17
  157. package/esm/browser/settings/settings-protocol.d.ts +16 -1
  158. package/esm/browser/settings/settings-protocol.js +20 -2
  159. package/esm/browser/settings/settings.js +4 -1
  160. package/esm/browser/style/base.d.ts +1 -1
  161. package/esm/browser/style/base.js +15 -2
  162. package/esm/browser/style/chat-list.d.ts +1 -1
  163. package/esm/browser/style/chat-list.js +6 -3
  164. package/esm/browser/style/conversation-column.d.ts +1 -1
  165. package/esm/browser/style/conversation-column.js +28 -8
  166. package/esm/browser/style/conversation.d.ts +1 -1
  167. package/esm/browser/style/conversation.js +5 -0
  168. package/esm/browser/style/device.js +5 -0
  169. package/esm/browser/style/pages.d.ts +1 -1
  170. package/esm/browser/style/pages.js +3 -3
  171. package/esm/browser/style/shell.d.ts +1 -1
  172. package/esm/browser/style/shell.js +13 -6
  173. package/esm/browser/style/tasks.d.ts +1 -1
  174. package/esm/browser/style/tasks.js +4 -2
  175. package/esm/browser/util/chat-emoji.d.ts +44 -0
  176. package/esm/browser/util/chat-emoji.js +269 -0
  177. package/esm/browser/util/composer-drop.d.ts +26 -0
  178. package/esm/browser/util/composer-drop.js +40 -0
  179. package/esm/browser/util/composer-files.d.ts +48 -0
  180. package/esm/browser/util/composer-files.js +99 -0
  181. package/esm/browser/util/composer.d.ts +13 -1
  182. package/esm/browser/util/composer.js +24 -6
  183. package/esm/browser/util/markdown.d.ts +5 -0
  184. package/esm/browser/util/markdown.js +18 -0
  185. package/esm/browser/util/message.d.ts +6 -1
  186. package/esm/browser/util/message.js +13 -2
  187. package/esm/browser/util/process.d.ts +10 -13
  188. package/esm/browser/util/process.js +31 -83
  189. package/esm/browser/util/turn-join.d.ts +38 -0
  190. package/esm/browser/util/turn-join.js +119 -0
  191. package/esm/browser/workbench-services.js +1 -1
  192. package/lib/browser/account/account-side.js +4 -0
  193. package/lib/browser/account/device-account.d.ts +6 -0
  194. package/lib/browser/account/device-account.js +20 -5
  195. package/lib/browser/assistant/assistant-view.js +2 -0
  196. package/lib/browser/assistant/call-announcing.d.ts +26 -0
  197. package/lib/browser/assistant/call-announcing.js +36 -0
  198. package/lib/browser/assistant/call-answering.d.ts +44 -0
  199. package/lib/browser/assistant/call-answering.js +67 -0
  200. package/lib/browser/assistant/call-hearing.d.ts +54 -0
  201. package/lib/browser/assistant/call-hearing.js +102 -0
  202. package/lib/browser/assistant/call-pausing.d.ts +41 -0
  203. package/lib/browser/assistant/call-pausing.js +86 -0
  204. package/lib/browser/assistant/call-reading.d.ts +33 -0
  205. package/lib/browser/assistant/call-reading.js +39 -0
  206. package/lib/browser/assistant/call-revoicing.d.ts +34 -0
  207. package/lib/browser/assistant/call-revoicing.js +72 -0
  208. package/lib/browser/assistant/call-turns.d.ts +30 -0
  209. package/lib/browser/assistant/call-turns.js +37 -0
  210. package/lib/browser/assistant/spoken-answer.d.ts +22 -0
  211. package/lib/browser/assistant/spoken-answer.js +73 -0
  212. package/lib/browser/assistant/spoken-call.d.ts +8 -0
  213. package/lib/browser/assistant/spoken-call.js +19 -0
  214. package/lib/browser/assistant/voice-call-protocol.d.ts +5 -0
  215. package/lib/browser/assistant/voice-call.d.ts +47 -43
  216. package/lib/browser/assistant/voice-call.js +192 -218
  217. package/lib/browser/chat/chat-view.js +2 -1
  218. package/lib/browser/components/account-recovery-view.d.ts +12 -0
  219. package/lib/browser/components/account-recovery-view.js +117 -0
  220. package/lib/browser/components/account-view.d.ts +1 -2
  221. package/lib/browser/components/account-view.js +10 -1
  222. package/lib/browser/components/app-nav.js +19 -8
  223. package/lib/browser/components/app-shell-hooks.d.ts +5 -0
  224. package/lib/browser/components/app-shell-hooks.js +46 -0
  225. package/lib/browser/components/app-shell-state.js +1 -0
  226. package/lib/browser/components/app-view.js +8 -4
  227. package/lib/browser/components/chat-emoji.d.ts +36 -0
  228. package/lib/browser/components/chat-emoji.js +167 -0
  229. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  230. package/lib/browser/components/composer-attachments.d.ts +6 -0
  231. package/lib/browser/components/composer-attachments.js +12 -0
  232. package/lib/browser/components/composer-box-protocol.d.ts +15 -0
  233. package/lib/browser/components/composer-box.js +107 -84
  234. package/lib/browser/components/composer-drop-hooks.d.ts +27 -0
  235. package/lib/browser/components/composer-drop-hooks.js +72 -0
  236. package/lib/browser/components/composer-emoji.js +1 -1
  237. package/lib/browser/components/composer-faces.d.ts +17 -0
  238. package/lib/browser/components/composer-faces.js +73 -0
  239. package/lib/browser/components/composer-media.d.ts +10 -0
  240. package/lib/browser/components/composer-media.js +13 -0
  241. package/lib/browser/components/composer-target.d.ts +4 -0
  242. package/lib/browser/components/composer-target.js +18 -7
  243. package/lib/browser/components/composer-type-focus.d.ts +25 -0
  244. package/lib/browser/components/composer-type-focus.js +20 -0
  245. package/lib/browser/components/composer-voice.d.ts +25 -0
  246. package/lib/browser/components/composer-voice.js +73 -0
  247. package/lib/browser/components/composer.d.ts +2 -2
  248. package/lib/browser/components/composer.js +38 -7
  249. package/lib/browser/components/context-menu.js +2 -1
  250. package/lib/browser/components/emoji-panel.d.ts +11 -7
  251. package/lib/browser/components/emoji-panel.js +40 -22
  252. package/lib/browser/components/extension-settings.js +1 -1
  253. package/lib/browser/components/folder-new.d.ts +19 -0
  254. package/lib/browser/components/folder-new.js +90 -0
  255. package/lib/browser/components/folder-picker.d.ts +5 -2
  256. package/lib/browser/components/folder-picker.js +17 -5
  257. package/lib/browser/components/host-view.d.ts +1 -1
  258. package/lib/browser/components/image-menu.d.ts +8 -3
  259. package/lib/browser/components/image-menu.js +34 -9
  260. package/lib/browser/components/markdown.js +9 -2
  261. package/lib/browser/components/media.js +3 -2
  262. package/lib/browser/components/message-list.js +2 -2
  263. package/lib/browser/components/message-steps.js +20 -11
  264. package/lib/browser/components/message-user.js +1 -1
  265. package/lib/browser/components/moved-notice.js +2 -1
  266. package/lib/browser/components/nav-places.d.ts +2 -0
  267. package/lib/browser/components/nav-places.js +4 -2
  268. package/lib/browser/components/phone-shell.d.ts +2 -0
  269. package/lib/browser/components/phone-shell.js +5 -1
  270. package/lib/browser/components/secret-text.d.ts +1 -1
  271. package/lib/browser/components/secret-text.js +4 -3
  272. package/lib/browser/components/session-view.js +3 -0
  273. package/lib/browser/components/settings-choices.d.ts +2 -1
  274. package/lib/browser/components/settings-choices.js +12 -4
  275. package/lib/browser/components/settings-more.js +2 -2
  276. package/lib/browser/components/settings-parts.js +11 -0
  277. package/lib/browser/components/share-item-sheet.js +7 -1
  278. package/lib/browser/components/tab-title.d.ts +28 -0
  279. package/lib/browser/components/tab-title.js +38 -0
  280. package/lib/browser/components/use-composer-attachments.d.ts +29 -0
  281. package/lib/browser/components/use-composer-attachments.js +101 -0
  282. package/lib/browser/components/use-composer-files.d.ts +26 -0
  283. package/lib/browser/components/use-composer-files.js +88 -0
  284. package/lib/browser/components/web-composer.d.ts +3 -1
  285. package/lib/browser/components/web-composer.js +3 -2
  286. package/lib/browser/components/workbench-view.js +1 -0
  287. package/lib/browser/components/working-directory.js +2 -1
  288. package/lib/browser/device/drag-move.d.ts +22 -0
  289. package/lib/browser/device/drag-move.js +122 -0
  290. package/lib/browser/extension/icons.js +6 -0
  291. package/lib/browser/extension/web-api-desktop.d.ts +19 -0
  292. package/lib/browser/extension/web-api-menus.d.ts +19 -0
  293. package/lib/browser/extension/web-api-spec.js +2 -0
  294. package/lib/browser/extension/web-extension-api.d.ts +24 -23
  295. package/lib/browser/extension/web-extension-context.d.ts +1 -0
  296. package/lib/browser/extension/web-extension-context.js +12 -5
  297. package/lib/browser/extension/web-extension-run.js +1 -0
  298. package/lib/browser/extension/web-share-ui.d.ts +1 -1
  299. package/lib/browser/extension/web-share-ui.js +2 -0
  300. package/lib/browser/extension/web-share.d.ts +13 -0
  301. package/lib/browser/extension/web-share.js +37 -2
  302. package/lib/browser/i18n/en/account.d.ts +18 -0
  303. package/lib/browser/i18n/en/account.js +18 -0
  304. package/lib/browser/i18n/en/call.js +1 -1
  305. package/lib/browser/i18n/en/chat.d.ts +15 -0
  306. package/lib/browser/i18n/en/chat.js +16 -1
  307. package/lib/browser/i18n/en/common.d.ts +2 -0
  308. package/lib/browser/i18n/en/common.js +2 -0
  309. package/lib/browser/i18n/en/discover.d.ts +2 -0
  310. package/lib/browser/i18n/en/discover.js +2 -0
  311. package/lib/browser/i18n/en/settings.d.ts +17 -0
  312. package/lib/browser/i18n/en/settings.js +17 -0
  313. package/lib/browser/i18n/ja/account.js +18 -0
  314. package/lib/browser/i18n/ja/call.js +1 -1
  315. package/lib/browser/i18n/ja/chat.js +16 -1
  316. package/lib/browser/i18n/ja/common.js +2 -0
  317. package/lib/browser/i18n/ja/discover.js +3 -1
  318. package/lib/browser/i18n/ja/settings.js +17 -0
  319. package/lib/browser/i18n/locales.d.ts +55 -1
  320. package/lib/browser/i18n/messages.d.ts +54 -0
  321. package/lib/browser/i18n/zh/account.js +18 -0
  322. package/lib/browser/i18n/zh/call.js +1 -1
  323. package/lib/browser/i18n/zh/chat.js +16 -1
  324. package/lib/browser/i18n/zh/common.js +2 -0
  325. package/lib/browser/i18n/zh/discover.js +3 -1
  326. package/lib/browser/i18n/zh/settings.js +17 -0
  327. package/lib/browser/i18n/zh-tw/account.js +18 -0
  328. package/lib/browser/i18n/zh-tw/call.js +1 -1
  329. package/lib/browser/i18n/zh-tw/chat.js +16 -1
  330. package/lib/browser/i18n/zh-tw/common.js +2 -0
  331. package/lib/browser/i18n/zh-tw/discover.js +3 -1
  332. package/lib/browser/i18n/zh-tw/settings.js +17 -0
  333. package/lib/browser/offline/kept-chats.d.ts +3 -1
  334. package/lib/browser/offline/kept-chats.js +1 -1
  335. package/lib/browser/partners/group-picker.d.ts +3 -2
  336. package/lib/browser/partners/group-picker.js +8 -3
  337. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  338. package/lib/browser/sandbox/work/work-docs.js +5 -2
  339. package/lib/browser/sandbox/work/work-frame.d.ts +3 -0
  340. package/lib/browser/sandbox/work/work-frame.js +9 -3
  341. package/lib/browser/sandbox/work/work-gates.d.ts +78 -0
  342. package/lib/browser/sandbox/work/work-gates.js +185 -0
  343. package/lib/browser/settings/agent-settings.js +1 -1
  344. package/lib/browser/settings/navigation.d.ts +38 -10
  345. package/lib/browser/settings/navigation.js +74 -18
  346. package/lib/browser/settings/settings-protocol.d.ts +16 -1
  347. package/lib/browser/settings/settings-protocol.js +21 -3
  348. package/lib/browser/settings/settings.js +3 -0
  349. package/lib/browser/style/base.d.ts +1 -1
  350. package/lib/browser/style/base.js +15 -2
  351. package/lib/browser/style/chat-list.d.ts +1 -1
  352. package/lib/browser/style/chat-list.js +6 -3
  353. package/lib/browser/style/conversation-column.d.ts +1 -1
  354. package/lib/browser/style/conversation-column.js +28 -8
  355. package/lib/browser/style/conversation.d.ts +1 -1
  356. package/lib/browser/style/conversation.js +5 -0
  357. package/lib/browser/style/device.js +5 -0
  358. package/lib/browser/style/pages.d.ts +1 -1
  359. package/lib/browser/style/pages.js +3 -3
  360. package/lib/browser/style/shell.d.ts +1 -1
  361. package/lib/browser/style/shell.js +13 -6
  362. package/lib/browser/style/tasks.d.ts +1 -1
  363. package/lib/browser/style/tasks.js +4 -2
  364. package/lib/browser/util/chat-emoji.d.ts +45 -0
  365. package/lib/browser/util/chat-emoji.js +272 -0
  366. package/lib/browser/util/composer-drop.d.ts +27 -0
  367. package/lib/browser/util/composer-drop.js +43 -0
  368. package/lib/browser/util/composer-files.d.ts +49 -0
  369. package/lib/browser/util/composer-files.js +102 -0
  370. package/lib/browser/util/composer.d.ts +13 -1
  371. package/lib/browser/util/composer.js +24 -6
  372. package/lib/browser/util/markdown.d.ts +5 -0
  373. package/lib/browser/util/markdown.js +18 -0
  374. package/lib/browser/util/message.d.ts +6 -1
  375. package/lib/browser/util/message.js +13 -2
  376. package/lib/browser/util/process.d.ts +10 -13
  377. package/lib/browser/util/process.js +32 -84
  378. package/lib/browser/util/turn-join.d.ts +39 -0
  379. package/lib/browser/util/turn-join.js +122 -0
  380. package/lib/browser/workbench-services.js +1 -1
  381. package/package.json +7 -7
  382. package/public/emoji/wechat-v1.webp +0 -0
@@ -1,27 +1,31 @@
1
- import { ArrowUp, AtSign, Keyboard, Mic, Plus, Slash, Square } from 'lucide-react';
1
+ import { ArrowUp, AtSign, Plus, Slash, Square } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import { useDevice } from '../device/device.js';
4
4
  import { useHeld } from '../device/hold.js';
5
- import { MiniProgram } from '../device/mini-program.js';
6
5
  import { PhotoPicker } from '../device/photo-picker.js';
7
6
  import { RecentShots } from '../device/recent-shots.js';
8
7
  import { VideoPicks } from '../device/video-picks.js';
9
8
  import { useComposerDraft, useTaDrafts } from '../drafts/use-composer-draft.js';
10
9
  import { useT } from '../i18n/use-t.js';
11
10
  import { ComposerUtil, MAX_IMAGES } from '../util/composer.js';
11
+ import { ComposerFileUtil } from '../util/composer-files.js';
12
12
  import { FileDragUtil } from '../util/file-drag.js';
13
13
  import { Voice } from '../util/voice.js';
14
- import { Attachments, readImage } from './composer-attachments.js';
14
+ import { Attachments, ComposerFiles } from './composer-attachments.js';
15
15
  import { talkTarget, useArgumentQuery, useFieldFit, usePlusMenuDismiss, useTalkWiring, useTapToType } from './composer-box-hooks.js';
16
+ import { useComposerDrop } from './composer-drop-hooks.js';
16
17
  import { ComposerEmojiButton, useComposerEmoji } from './composer-emoji.js';
17
- import { MediaInputs, mediaTiles } from './composer-media.js';
18
+ import { useBoxFaces } from './composer-faces.js';
19
+ import { FileInput, fileTile, MediaInputs, mediaTiles } from './composer-media.js';
18
20
  import { ComposerMenu } from './composer-menu.js';
21
+ import { useMicrophone } from './composer-voice.js';
19
22
  import { EmojiPanel, EmojiPanelUtil } from './emoji-panel.js';
20
23
  import { HeldTalk } from './held-talk.js';
21
24
  import { Icon, IconButton } from './icon.js';
22
25
  import { PlusMenu } from './plus-menu.js';
23
26
  import { RecentShotOffer } from './recent-shot.js';
24
- import { DictateButton, VoiceButton } from './voice-button.js';
27
+ import { useComposerAttachments } from './use-composer-attachments.js';
28
+ import { useComposerFiles } from './use-composer-files.js';
25
29
  import { TalkBar, useVoiceTalk, VoiceTalkOverlay } from './voice-talk.js';
26
30
  /**
27
31
  * The message box of every conversation: Enter sends (the Send key of a phone, as in WeChat), Shift+Enter is a new line, Alt+Enter a follow-up;
@@ -32,12 +36,14 @@ import { TalkBar, useVoiceTalk, VoiceTalkOverlay } from './voice-talk.js';
32
36
  let talkFirst = false;
33
37
  export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
34
38
  var _a;
35
- const { placeholder, working = false, compacting = false, onStop, onSend, sendTitle, commands = [], onArgumentQuery, argumentItems, onMentionQuery, mentions, mentionLabel, images: takesImages, emoji: takesEmoji, recentShots, actions = [], above, head, after, voiceSends, talkPlace, onTalkSent, onTalkCall, talkCalls = ['keep', 'call'], onListening, autoFocus, onTextChange, draft, cwd, onError, } = props;
39
+ const { placeholder, working = false, compacting = false, onStop, onSend, sendTitle, commands = [], onArgumentQuery, argumentItems, onMentionQuery, mentions, mentionLabel, images: takesImages, files: takesFiles, emoji: takesEmoji, recentShots, actions = [], above, head, after, voiceSends, talkPlace, onTalkSent, onTalkCall, talkCalls = ['keep', 'call'], onListening, autoFocus, onTextChange, draft, cwd, droppedFiles, onError, } = props;
36
40
  const t = useT();
37
41
  const drafts = useTaDrafts();
38
42
  const [text, setText] = React.useState(() => { var _a; var _b; return (_b = (draft === undefined ? undefined : (_a = drafts === null || drafts === void 0 ? void 0 : drafts.get(draft)) === null || _a === void 0 ? void 0 : _a.text)) !== null && _b !== void 0 ? _b : ''; });
39
43
  const [caret, setCaret] = React.useState(() => text.length);
40
- const [attachments, setAttachments] = React.useState([]);
44
+ const uploaded = useComposerFiles(takesFiles, cwd, t, onError);
45
+ const images = useComposerAttachments({ images: !!takesImages, videos: props.videos, files: !!takesFiles, addFiles: uploaded.add, t, onError });
46
+ const attachments = images.attachments;
41
47
  useComposerDraft(drafts, draft, {
42
48
  text,
43
49
  attachments,
@@ -45,10 +51,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
45
51
  setText(next);
46
52
  setCaret(next.length);
47
53
  setDismissed(undefined);
48
- setAttachments(previous => {
49
- ComposerUtil.release(previous.filter(attachment => !kept.includes(attachment)));
50
- return kept;
51
- });
54
+ images.set(kept);
52
55
  },
53
56
  });
54
57
  const [selected, setSelected] = React.useState(0);
@@ -64,6 +67,8 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
64
67
  setStopping(false);
65
68
  }
66
69
  }, [busy]);
70
+ // When the box last sent: the button turns to stop under the pointer, and a second click then is not a stop.
71
+ const sentAt = React.useRef(undefined);
67
72
  const stop = () => {
68
73
  if (!onStop || stopping) {
69
74
  return;
@@ -82,6 +87,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
82
87
  const [focused, setFocused] = React.useState(false);
83
88
  const input = React.useRef(null);
84
89
  const picker = React.useRef(null);
90
+ const documents = React.useRef(null);
85
91
  const camera = React.useRef(null);
86
92
  const plus = React.useRef(null);
87
93
  const panel = React.useRef(null);
@@ -91,6 +97,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
91
97
  setClosing(handheld);
92
98
  }, [handheld]);
93
99
  const emojis = useComposerEmoji(handheld, input, () => menu && setMenu(false));
100
+ const faces = useBoxFaces(input, text, !!takesEmoji);
94
101
  const found = ComposerUtil.trigger(text, caret);
95
102
  const trigger = found && `${found.kind}:${found.start}` !== dismissed ? found : undefined;
96
103
  const query = (trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'file' ? trigger.query : undefined;
@@ -106,10 +113,10 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
106
113
  : []
107
114
  : [];
108
115
  const note = (trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'file' && onMentionQuery && !items.length ? mentions === null || mentions === void 0 ? void 0 : mentions.note : undefined;
109
- const sendable = text.trim().length > 0 || attachments.length > 0;
116
+ const sendable = text.trim().length > 0 || attachments.length > 0 || uploaded.files.length > 0;
110
117
  const action = ComposerUtil.action(working, sendable, compacting);
111
- // An image still being read holds the message back, rather than leaving without it.
112
- const reading = !ComposerUtil.ready(attachments);
118
+ // An image still being read, or a file still uploading, holds the message back, rather than leaving without it.
119
+ const reading = !ComposerUtil.ready(attachments) || !uploaded.ready;
113
120
  useFieldFit(input, text, talkMode);
114
121
  usePlusMenuDismiss(menu, closeMenu, plus, panel);
115
122
  const toggleMenu = () => {
@@ -138,7 +145,8 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
138
145
  requestAnimationFrame(() => {
139
146
  var _a, _b;
140
147
  (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
141
- (_b = input.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(position, position);
148
+ const at = faces.shownCaret(next, position);
149
+ (_b = input.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(at, at);
142
150
  });
143
151
  };
144
152
  /** An emoji or a delete of the panel: on a phone the keyboard stays down, the caret where it was. */
@@ -156,12 +164,24 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
156
164
  // What a talk finds as it ends, long after it began.
157
165
  const latestCaret = React.useRef(caret);
158
166
  latestCaret.current = caret;
167
+ // What a drop or a paste brings: the pictures into the box as ever, every other file under `uploads/` of the
168
+ // conversation, named where the caret is (useComposerDrop).
169
+ const drop = useComposerDrop({
170
+ files: !!takesFiles,
171
+ videos: !!props.videos,
172
+ droppedFiles,
173
+ addImages: images.add,
174
+ text: () => latest.current,
175
+ caret: () => latestCaret.current,
176
+ insert: edit,
177
+ onError,
178
+ });
159
179
  const readingNow = React.useRef(reading);
160
180
  readingNow.current = reading;
161
181
  React.useImperativeHandle(ref, () => ({
162
182
  text: () => latest.current,
163
183
  setText: next => edit(next, next.length),
164
- ...(takesImages ? { addFiles: (files) => addFiles(files) } : {}),
184
+ ...(takesImages || takesFiles ? { addFiles: (files) => images.add(files) } : {}),
165
185
  shown: () => { var _a; return !!((_a = input.current) === null || _a === void 0 ? void 0 : _a.isConnected) && input.current.getClientRects().length > 0; },
166
186
  }));
167
187
  const pick = (item) => {
@@ -176,17 +196,23 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
176
196
  const typed = (item) => ((trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'command' && (item === null || item === void 0 ? void 0 : item.label) === text.trim()) || ((trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'argument' && (item === null || item === void 0 ? void 0 : item.key.trim()) === trigger.query.trim());
177
197
  /** Sends; the sending, which fails as it does (what was sent back in the box), or nothing when there is nothing to send. */
178
198
  const send = (key, message = text.trim()) => {
179
- if ((!message && !attachments.length) || reading) {
199
+ if ((!message && !attachments.length && !uploaded.files.length) || reading) {
180
200
  return undefined;
181
201
  }
182
202
  const attached = attachments;
203
+ const files = uploaded.files;
204
+ sentAt.current = performance.now();
183
205
  setText('');
184
206
  setCaret(0);
185
- setAttachments([]);
186
- const sent = onSend(message, ComposerUtil.images(attached), key);
207
+ images.set([]);
208
+ uploaded.clear();
209
+ // Where the files are, after what was typed: the agent opens them with its tools.
210
+ const said = files.length ? [message, ComposerFileUtil.references(files)].filter(part => part.trim()).join('\n\n') : message;
211
+ const sent = onSend(said, ComposerUtil.images(attached), key);
187
212
  sent.then(() => ComposerUtil.release(attached), error => {
188
213
  setText(message);
189
- setAttachments(attached);
214
+ images.set(attached);
215
+ uploaded.restore(files);
190
216
  onError(error);
191
217
  });
192
218
  return sent;
@@ -226,16 +252,6 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
226
252
  }
227
253
  }, onError, hints, onTalkCall ? talkCalls : []);
228
254
  const talking = useTalkWiring(talk, onListening, talkPlace);
229
- // Speech goes where the caret was when listening began, between what was typed.
230
- const spoken = React.useRef({ before: '', after: '' });
231
- const listen = (on) => {
232
- if (on) {
233
- spoken.current = { before: text.slice(0, caret), after: text.slice(caret) };
234
- }
235
- setListening(on);
236
- onListening === null || onListening === void 0 ? void 0 : onListening(on);
237
- };
238
- const speech = (words) => `${spoken.current.before}${words}${spoken.current.after}`;
239
255
  const switchTalk = (on) => {
240
256
  var _a;
241
257
  talkFirst = on;
@@ -248,14 +264,31 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
248
264
  requestAnimationFrame(() => { var _a; return (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus(); });
249
265
  }
250
266
  };
251
- const microphone = MiniProgram.canDictate() ? (React.createElement(DictateButton, { onHeard: words => {
252
- const [message, position] = ComposerUtil.insert(latest.current, latestCaret.current, words);
253
- edit(message, position);
254
- } })) : !Voice.canListen() ? null : touch ? (React.createElement("button", { type: "button", className: "ta-mic", title: t(talkMode ? 'ta.composer.keyboard' : 'ta.composer.voice'), "aria-label": t(talkMode ? 'ta.composer.keyboard' : 'ta.composer.voice'), "aria-pressed": talkMode, onClick: () => switchTalk(!talkMode) },
255
- React.createElement(Icon, { icon: talkMode ? Keyboard : Mic, size: 18 }))) : (React.createElement(VoiceButton, { hints: hints, onListening: listen, onText: words => {
256
- setText(speech(words));
257
- setCaret(spoken.current.before.length + words.length);
258
- }, onHeard: words => (voiceSends ? send('enter', speech(words).trim()) : edit(speech(words), spoken.current.before.length + words.length)), onError: onError }));
267
+ /** Listening began or ended: the box shows it, and the microphone too. */
268
+ const listen = (on) => {
269
+ setListening(on);
270
+ onListening === null || onListening === void 0 ? void 0 : onListening(on);
271
+ };
272
+ const microphone = useMicrophone({
273
+ touch,
274
+ talkMode,
275
+ hints,
276
+ voiceSends: !!voiceSends,
277
+ said: () => ({ text: latest.current, caret: latestCaret.current }),
278
+ onHear: (words, at) => {
279
+ if (voiceSends) {
280
+ send('enter', words.trim());
281
+ }
282
+ else {
283
+ setText(words);
284
+ setCaret(at);
285
+ }
286
+ },
287
+ onInsert: words => edit(...ComposerUtil.insert(latest.current, latestCaret.current, words)),
288
+ onListening: listen,
289
+ onTalkKey: switchTalk,
290
+ onError,
291
+ });
259
292
  // A finger held on the box while the keyboard is down talks (the field takes no finger then, .ta-talkable: a tap
260
293
  // on it is the box's, which types in it). With the keyboard up, the field and the box are the system's.
261
294
  const held = useHeld();
@@ -271,43 +304,9 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
271
304
  : undefined);
272
305
  const box = React.useRef(null);
273
306
  useTapToType(box, input, talkable);
274
- const remove = (id) => {
275
- ComposerUtil.release(attachments.filter(attachment => attachment.id === id));
276
- setAttachments(previous => previous.filter(attachment => attachment.id !== id));
277
- };
278
- // The previews of a box that goes away go with it.
279
- const shown = React.useRef(attachments);
280
- shown.current = attachments;
281
- React.useEffect(() => () => ComposerUtil.release(shown.current), []);
282
- /** Shows each image at once from its file, and reads them all at the same time. */
283
- const addFiles = (list) => {
284
- const added = [];
285
- for (const file of VideoPicks.take(list, props.videos)) {
286
- const reason = ComposerUtil.rejectImage(file, attachments.length + added.length);
287
- if (reason) {
288
- onError(new Error(t(`ta.composer.image.${reason}`, { name: file.name })));
289
- continue;
290
- }
291
- added.push({ attachment: { id: crypto.randomUUID(), preview: URL.createObjectURL(file) }, file });
292
- }
293
- if (!added.length) {
294
- return;
295
- }
296
- setAttachments(previous => [...previous, ...added.map(({ attachment }) => attachment)]);
297
- for (const { attachment, file } of added) {
298
- void readImage(file).then(image => {
299
- if (!image) {
300
- ComposerUtil.release([attachment]);
301
- }
302
- setAttachments(previous => image
303
- ? previous.map(other => (other.id === attachment.id ? { ...other, image } : other))
304
- : previous.filter(other => other.id !== attachment.id));
305
- });
306
- }
307
- };
308
307
  const onPicked = (event) => {
309
308
  if (event.target.files) {
310
- addFiles(event.target.files);
309
+ images.add(event.target.files);
311
310
  }
312
311
  event.target.value = '';
313
312
  };
@@ -336,10 +335,21 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
336
335
  }
337
336
  };
338
337
  const onPaste = (event) => {
339
- const pasted = takesImages ? VideoPicks.pasted(event.clipboardData.files, !!props.videos) : [];
338
+ const pasted = takesFiles || droppedFiles
339
+ ? Array.from(event.clipboardData.files)
340
+ : takesImages
341
+ ? VideoPicks.pasted(event.clipboardData.files, !!props.videos)
342
+ : [];
340
343
  if (pasted.length) {
341
344
  event.preventDefault();
342
- addFiles(pasted);
345
+ drop.take(pasted);
346
+ }
347
+ };
348
+ /** A copy of the field with faces: their names in brackets, and what is cut away. */
349
+ const copyFaces = (event, cut) => {
350
+ const left = faces.copied(event, cut);
351
+ if (left !== undefined) {
352
+ edit(left, left.length);
343
353
  }
344
354
  };
345
355
  const onDrop = (event) => {
@@ -350,9 +360,10 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
350
360
  edit(...ComposerUtil.insert(text, caret, `${FileDragUtil.references(files, cwd)} `));
351
361
  return;
352
362
  }
353
- if (takesImages && event.dataTransfer.files.length) {
363
+ const dropped = Array.from(event.dataTransfer.files);
364
+ if (dropped.length) {
354
365
  event.preventDefault();
355
- addFiles(event.dataTransfer.files);
366
+ drop.take(dropped);
356
367
  }
357
368
  };
358
369
  const own = [];
@@ -360,7 +371,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
360
371
  var _a, _b, _c;
361
372
  // The Ta app on iOS opens its library at once (and asks for the photos, for the screenshots, once picked).
362
373
  if (PhotoPicker.available()) {
363
- PhotoPicker.pickInto(MAX_IMAGES - attachments.length, addFiles, props.videos);
374
+ PhotoPicker.pickInto(MAX_IMAGES - attachments.length, images.add, props.videos);
364
375
  return;
365
376
  }
366
377
  if (recentShots) {
@@ -371,6 +382,9 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
371
382
  if (takesImages) {
372
383
  own.push(...mediaTiles({ phone: handheld && touch, videos: !!props.videos, t, pick: pickImages, shoot: () => { var _a; return (_a = camera.current) === null || _a === void 0 ? void 0 : _a.click(); } }));
373
384
  }
385
+ if (takesFiles) {
386
+ own.push(fileTile(t, () => { var _a; return (_a = documents.current) === null || _a === void 0 ? void 0 : _a.click(); }));
387
+ }
374
388
  if (mentionLabel) {
375
389
  own.push({ key: 'mention', label: mentionLabel, icon: React.createElement(Icon, { icon: AtSign, size: 16 }), run: () => edit(...ComposerUtil.insert(text, caret, '@')) });
376
390
  }
@@ -390,7 +404,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
390
404
  above,
391
405
  head && React.createElement("div", { className: "ta-console-head" }, head),
392
406
  React.createElement("div", { ref: box, className: `ta-console-box${dragging ? ' ta-dragging' : ''}${talkable ? ' ta-talkable' : ''}`, ...boxHold, onDragOver: event => {
393
- if (FileDragUtil.has(event.dataTransfer) || (takesImages && event.dataTransfer.types.includes('Files'))) {
407
+ if (FileDragUtil.has(event.dataTransfer) || ((takesImages || takesFiles || droppedFiles) && event.dataTransfer.types.includes('Files'))) {
394
408
  event.preventDefault();
395
409
  setDragging(true);
396
410
  }
@@ -402,20 +416,28 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
402
416
  (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
403
417
  }
404
418
  } },
405
- attachments.length > 0 && React.createElement(Attachments, { attachments: attachments, onRemove: remove }),
419
+ attachments.length > 0 && React.createElement(Attachments, { attachments: attachments, onRemove: images.remove }),
420
+ uploaded.files.length > 0 && React.createElement(ComposerFiles, { files: uploaded.files, onRemove: uploaded.remove }),
406
421
  React.createElement("div", { className: "ta-console-row ta-conversation" },
407
422
  sections.length > 0 && (React.createElement("div", { className: "ta-plus", ref: plus },
408
423
  React.createElement(IconButton, { icon: Plus, label: t('ta.composer.more'), className: `ta-attach ta-plus-button ${menu ? 'ta-on' : ''}`, onClick: toggleMenu }),
409
424
  menu && !handheld && React.createElement(PlusMenu, { sections: sections, onClose: closeMenu }),
410
- takesImages && recentShots && (React.createElement(RecentShotOffer, { box: box, activity: `${text}|${attachments.length}|${menu}|${talkMode}`, onPick: file => addFiles([file]) })))),
425
+ takesImages && recentShots && (React.createElement(RecentShotOffer, { box: box, activity: `${text}|${attachments.length}|${menu}|${talkMode}`, onPick: file => images.add([file]) })))),
411
426
  takesImages && React.createElement(MediaInputs, { picker: picker, camera: handheld && touch ? camera : undefined, videos: !!props.videos, onChange: onPicked }),
427
+ takesFiles && React.createElement(FileInput, { picker: documents, onChange: onPicked }),
412
428
  talkMode && React.createElement(TalkBar, { talk: talk }),
413
- React.createElement("textarea", { ref: input, hidden: talkMode, rows: 1, value: text, autoFocus: autoFocus, enterKeyHint: "send", "aria-label": t('ta.composer.label'), "aria-controls": items.length ? menuId : undefined, "aria-activedescendant": items.length ? `${menuId}-${selected}` : undefined, placeholder: listening ? t('ta.composer.listening') : placeholder, onChange: event => {
414
- setText(event.target.value);
415
- onTextChange === null || onTextChange === void 0 ? void 0 : onTextChange(event.target.value);
416
- setCaret(event.target.selectionStart);
429
+ React.createElement("textarea", { ref: input, hidden: talkMode, rows: 1, value: faces.shown, className: faces.mirror ? 'ta-faced' : undefined, autoFocus: autoFocus, enterKeyHint: "send", "aria-label": t('ta.composer.label'), "aria-controls": items.length ? menuId : undefined, "aria-activedescendant": items.length ? `${menuId}-${selected}` : undefined, placeholder: listening ? t('ta.composer.listening') : placeholder, onChange: event => {
430
+ const [next, position] = faces.typed(event.target.value, event.target.selectionStart);
431
+ setText(next);
432
+ onTextChange === null || onTextChange === void 0 ? void 0 : onTextChange(next);
433
+ setCaret(position);
417
434
  setSelected(0);
418
- }, onSelect: event => setCaret(event.currentTarget.selectionStart), onKeyDown: onKeyDown, onPaste: onPaste, onFocus: () => {
435
+ // A face typed out by its name ([微笑]) turns into the face: the caret stays where it was,
436
+ // the browser told so, that it does not put its own back before the face.
437
+ if (faces.shown !== event.target.value) {
438
+ faces.settle(event.target, next, position);
439
+ }
440
+ }, onSelect: event => setCaret(faces.saidCaret(event.currentTarget.value, event.currentTarget.selectionStart)), onCopy: faces.mirror ? event => copyFaces(event, false) : undefined, onCut: faces.mirror ? event => copyFaces(event, true) : undefined, onKeyDown: onKeyDown, onPaste: onPaste, onFocus: () => {
419
441
  setFocused(true);
420
442
  // The keyboard comes in place of the panel.
421
443
  if (menu && handheld) {
@@ -425,6 +447,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
425
447
  emojis.close();
426
448
  }
427
449
  }, onBlur: () => setFocused(false) }),
450
+ faces.mirror && !talkMode && faces.mirror,
428
451
  takesEmoji && (React.createElement(ComposerEmojiButton, { emoji: emojis, handheld: handheld, onPick: emoji => type(...EmojiPanelUtil.insert(text, caret, emoji)) })),
429
452
  after,
430
453
  microphone,
@@ -436,7 +459,7 @@ export const ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
436
459
  ? sendTitle
437
460
  : t('ta.send'), "aria-label": action === 'stop' ? t(stopping ? 'ta.composer.stopping' : 'ta.stop') : t('ta.send'), "aria-busy": action === 'stop' && stopping, "data-ta-action": action === 'stop' ? 'stop' : 'send',
438
461
  // Pressed with the keyboard open, the box keeps the focus and the keyboard stays, as in WeChat.
439
- onPointerDown: event => document.activeElement === input.current && event.preventDefault(), onClick: () => (action === 'stop' ? stop() : send('enter')) }, action === 'stop' && stopping ? (React.createElement("span", { className: "ta-spinner" })) : (React.createElement(Icon, { icon: action === 'stop' ? Square : ArrowUp, size: action === 'stop' ? 14 : 18 }))))),
462
+ onPointerDown: event => document.activeElement === input.current && event.preventDefault(), onClick: () => (action === 'stop' ? !ComposerUtil.accidentalStop(sentAt.current, performance.now()) && stop() : send('enter')) }, action === 'stop' && stopping ? (React.createElement("span", { className: "ta-spinner" })) : (React.createElement(Icon, { icon: action === 'stop' ? Square : ArrowUp, size: action === 'stop' ? 14 : 18 }))))),
440
463
  takesEmoji && handheld && (emojis.open || emojis.closing) && (React.createElement(EmojiPanel, { ref: emojis.panel, docked: true, closing: !emojis.open, onClosed: emojis.closed, onPick: emoji => type(...EmojiPanelUtil.insert(text, caret, emoji)), onDelete: () => type(...EmojiPanelUtil.deleteBack(text, caret)), sendable: sendable && !reading, onSend: () => void send('enter') })),
441
464
  handheld && (menu || closing) && sections.length > 0 && (React.createElement(PlusMenu, { ref: panel, sections: sections, docked: true, closing: !menu, onClosed: () => setClosing(false), onClose: closeMenu }))));
442
465
  });
@@ -0,0 +1,26 @@
1
+ /** What a drop or a paste into the box is given: the files, where the box puts the text they name. */
2
+ export interface ComposerDropHook {
3
+ /** Takes what came, as the box takes it: the pictures into it as ever, every other file where it takes none. */
4
+ take(files: File[]): void;
5
+ }
6
+ /**
7
+ * The files of a drop or a paste into the message box (ComposerBoxProps.droppedFiles): the pictures (and the videos the
8
+ * box takes) into it as ever, and every other file where the box takes none, written by its owner under `uploads/` of
9
+ * the conversation and named as an `@` reference put where the caret is (ComposerDropUtil). A box that takes files of
10
+ * its own (files) keeps them as it did; one with neither hands them to the pictures, which says what it cannot send.
11
+ */
12
+ export declare function useComposerDrop(options: {
13
+ /** The box takes files of its own (ComposerBoxProps.files): they go there, pictures and all. */
14
+ files: boolean;
15
+ videos: boolean;
16
+ droppedFiles: ComposerBoxPropsFiles;
17
+ addImages(files: File[]): void;
18
+ /** Where the text typed so far is, as it is now: a file written a moment later still lands where the caret was. */
19
+ text(): string;
20
+ caret(): number;
21
+ insert(text: string, position: number): void;
22
+ onError(error: unknown): void;
23
+ }): ComposerDropHook;
24
+ /** ComposerBoxProps.droppedFiles, as the hook takes it. */
25
+ type ComposerBoxPropsFiles = ((files: File[]) => Promise<string[]>) | undefined;
26
+ export {};
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ import { ComposerUtil } from '../util/composer.js';
3
+ import { ComposerDropUtil } from '../util/composer-drop.js';
4
+ /**
5
+ * The files of a drop or a paste into the message box (ComposerBoxProps.droppedFiles): the pictures (and the videos the
6
+ * box takes) into it as ever, and every other file where the box takes none, written by its owner under `uploads/` of
7
+ * the conversation and named as an `@` reference put where the caret is (ComposerDropUtil). A box that takes files of
8
+ * its own (files) keeps them as it did; one with neither hands them to the pictures, which says what it cannot send.
9
+ */
10
+ export function useComposerDrop(options) {
11
+ const { files, videos, droppedFiles, addImages, text, caret, insert, onError } = options;
12
+ return {
13
+ take: React.useCallback((coming) => {
14
+ const write = files ? undefined : droppedFiles;
15
+ if (!coming.length) {
16
+ return;
17
+ }
18
+ if (!write) {
19
+ addImages(coming);
20
+ return;
21
+ }
22
+ const { pictures, others } = ComposerDropUtil.part(coming, videos);
23
+ if (pictures.length) {
24
+ addImages(pictures);
25
+ }
26
+ if (!others.length) {
27
+ return;
28
+ }
29
+ // As the files come: what was typed a moment before they are written is still there.
30
+ void write(others)
31
+ .then(paths => insert(...ComposerUtil.insert(text(), caret(), `${ComposerDropUtil.references(paths)} `)))
32
+ .catch(error => onError(error));
33
+ }, [files, videos, droppedFiles, addImages, text, caret, insert, onError]),
34
+ };
35
+ }
36
+ //# sourceMappingURL=composer-drop-hooks.js.map
@@ -41,7 +41,7 @@ export function ComposerEmojiButton({ emoji, handheld, onPick }) {
41
41
  const t = useT();
42
42
  const keyboard = emoji.open && handheld;
43
43
  return (React.createElement("div", { className: "ta-emoji-anchor", ref: emoji.anchor },
44
- React.createElement("button", { type: "button", className: `ta-mic ta-emoji-button${emoji.open ? ' ta-on' : ''}`, title: t(keyboard ? 'ta.composer.keyboard' : 'ta.composer.emoji'), "aria-label": t(keyboard ? 'ta.composer.keyboard' : 'ta.composer.emoji'), "aria-expanded": emoji.open,
44
+ React.createElement("button", { type: "button", className: `ta-emoji-button${emoji.open ? ' ta-on' : ''}`, title: t(keyboard ? 'ta.composer.keyboard' : 'ta.composer.emoji'), "aria-label": t(keyboard ? 'ta.composer.keyboard' : 'ta.composer.emoji'), "aria-expanded": emoji.open,
45
45
  // On a computer the field keeps the focus while the popover opens.
46
46
  onPointerDown: event => !handheld && event.preventDefault(), onClick: emoji.toggle },
47
47
  React.createElement(Icon, { icon: keyboard ? Keyboard : Smile, size: 20 })),
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * The faces of the field of a box (ComposerBoxProps.emoji), as WeChat's box shows them: the text is still said the way
4
+ * it is sent (`[微笑]`), and the field shows each face as one character of its own font, drawn as the face (FaceField),
5
+ * which the caret steps over and Delete takes whole. Everything here is between the two.
6
+ */
7
+ export declare function useBoxFaces(field: React.RefObject<HTMLTextAreaElement | null>, text: string, takes: boolean): {
8
+ shown: string;
9
+ taken: boolean;
10
+ shownCaret: (said: string, position: number) => number;
11
+ saidCaret: (value: string, position: number) => number;
12
+ typed: (value: string, position: number) => [string, number];
13
+ settle: (field: HTMLTextAreaElement, said: string, position: number) => void;
14
+ copied: (event: React.ClipboardEvent<HTMLTextAreaElement>, cut: boolean) => string | undefined;
15
+ mirror: React.JSX.Element | undefined;
16
+ };
@@ -0,0 +1,37 @@
1
+ import * as React from 'react';
2
+ import { ChatEmojiUtil, FaceField } from './chat-emoji.js';
3
+ /**
4
+ * The faces of the field of a box (ComposerBoxProps.emoji), as WeChat's box shows them: the text is still said the way
5
+ * it is sent (`[微笑]`), and the field shows each face as one character of its own font, drawn as the face (FaceField),
6
+ * which the caret steps over and Delete takes whole. Everything here is between the two.
7
+ */
8
+ export function useBoxFaces(field, text, takes) {
9
+ // What the field holds: each face one character.
10
+ const shown = takes ? ChatEmojiUtil.glyphs(text) : text;
11
+ /** Where a place of the text is in the field, and back. */
12
+ const shownCaret = React.useCallback((said, position) => (takes ? ChatEmojiUtil.shownCaret(said, position) : position), [takes]);
13
+ const saidCaret = React.useCallback((value, position) => (takes ? ChatEmojiUtil.saidCaret(value, position) : position), [takes]);
14
+ /** What the field was given: the text as it is said, and where the caret is in it. */
15
+ const typed = React.useCallback((value, position) => [takes ? ChatEmojiUtil.codes(value) : value, saidCaret(value, position)], [takes, saidCaret]);
16
+ /** A face typed out by its name ([微笑]) turned into the face: the caret put where it was, after it. */
17
+ const settle = (field, said, position) => {
18
+ const at = ChatEmojiUtil.shownCaret(said, position);
19
+ field.setSelectionRange(at, at);
20
+ };
21
+ /** Copied or cut, faces go as their names in brackets, as WeChat pastes them; what comes back is the text left. */
22
+ const copied = (event, cut) => {
23
+ const element = event.currentTarget;
24
+ const from = element.selectionStart;
25
+ const to = element.selectionEnd;
26
+ if (!takes || from === to) {
27
+ return undefined;
28
+ }
29
+ event.preventDefault();
30
+ event.clipboardData.setData('text/plain', ChatEmojiUtil.codes(element.value.slice(from, to)));
31
+ return cut ? ChatEmojiUtil.codes(element.value.slice(0, from) + element.value.slice(to)) : undefined;
32
+ };
33
+ /** The faces of what the field shows, over it. */
34
+ const mirror = shown === text ? undefined : React.createElement(FaceField, { field: field, text: shown });
35
+ return { shown, taken: takes, shownCaret, saidCaret, typed, settle, copied, mirror };
36
+ }
37
+ //# sourceMappingURL=composer-faces.js.map
@@ -24,3 +24,13 @@ export declare function MediaInputs({ picker, camera, videos, onChange, }: {
24
24
  videos: boolean;
25
25
  onChange(event: React.ChangeEvent<HTMLInputElement>): void;
26
26
  }): React.JSX.Element;
27
+ /**
28
+ * The tile of the + that adds files at all (ComposerBoxProps.files): a PDF, a sheet, a picture a model cannot see.
29
+ * They go to `uploads/` of the conversation, which the message names as `@` references.
30
+ */
31
+ export declare function fileTile(t: ReturnType<typeof useT>, pick: () => void): ComposerAction;
32
+ /** The field of those files, hidden: they are anything, so it takes anything. */
33
+ export declare function FileInput({ picker, onChange }: {
34
+ picker: React.Ref<HTMLInputElement>;
35
+ onChange(event: React.ChangeEvent<HTMLInputElement>): void;
36
+ }): React.JSX.Element;
@@ -1,4 +1,4 @@
1
- import { Camera, ImagePlus, Images } from 'lucide-react';
1
+ import { Camera, FilePlus2, ImagePlus, Images } from 'lucide-react';
2
2
  import * as React from 'react';
3
3
  import { VideoPicks } from '../device/video-picks.js';
4
4
  import { IMAGE_TYPES } from '../util/composer.js';
@@ -34,4 +34,15 @@ export function MediaInputs({ picker, camera, videos, onChange, }) {
34
34
  React.createElement("input", { ref: picker, type: "file", accept: VideoPicks.accept(IMAGE_TYPES, videos), multiple: true, hidden: true, onChange: onChange }),
35
35
  camera && React.createElement("input", { ref: camera, type: "file", accept: videos ? 'image/*,video/*' : 'image/*', capture: "environment", hidden: true, onChange: onChange })));
36
36
  }
37
+ /**
38
+ * The tile of the + that adds files at all (ComposerBoxProps.files): a PDF, a sheet, a picture a model cannot see.
39
+ * They go to `uploads/` of the conversation, which the message names as `@` references.
40
+ */
41
+ export function fileTile(t, pick) {
42
+ return { key: 'file', label: t('ta.composer.addFile'), icon: React.createElement(Icon, { icon: FilePlus2, size: 16 }), run: pick };
43
+ }
44
+ /** The field of those files, hidden: they are anything, so it takes anything. */
45
+ export function FileInput({ picker, onChange }) {
46
+ return React.createElement("input", { ref: picker, type: "file", multiple: true, hidden: true, onChange: onChange });
47
+ }
37
48
  //# sourceMappingURL=composer-media.js.map
@@ -18,6 +18,10 @@ export interface ComposerDraft {
18
18
  export declare namespace ComposerTarget {
19
19
  /** A box shown; returns what forgets it. */
20
20
  function set(handle: ComposerBoxHandle): () => void;
21
+ /** Whether a box is in front to type in. */
22
+ function present(): boolean;
23
+ /** Types a key pressed on the page at the end of what the box in front holds, and focuses it; false when none is shown. */
24
+ function type(key: string): boolean;
21
25
  /** Puts the draft in the box in front, and focuses it; false when no box is shown. */
22
26
  function add(draft: ComposerDraft): boolean;
23
27
  }
@@ -1,3 +1,4 @@
1
+ import { ComposerUtil } from '../util/composer.js';
1
2
  import { QuoteUtil } from '../util/quote.js';
2
3
  /**
3
4
  * The message box in front of the user, which extensions put things in (a conversation's, or one of an extension's
@@ -17,16 +18,26 @@ export var ComposerTarget;
17
18
  };
18
19
  }
19
20
  ComposerTarget.set = set;
20
- function file({ data, mimeType }, index) {
21
- var _a;
22
- const bytes = Uint8Array.from(atob(data), char => char.charCodeAt(0));
23
- const extension = ((_a = mimeType.split('/')[1]) === null || _a === void 0 ? void 0 : _a.replace('jpeg', 'jpg')) || 'png';
24
- return new File([bytes], `picked-${index + 1}.${extension}`, { type: mimeType });
21
+ /** The box in front: the last one shown that is on the screen. */
22
+ function front() {
23
+ return [...shown].reverse().find(each => each.shown());
25
24
  }
25
+ /** Whether a box is in front to type in. */
26
+ function present() {
27
+ return !!front();
28
+ }
29
+ ComposerTarget.present = present;
30
+ /** Types a key pressed on the page at the end of what the box in front holds, and focuses it; false when none is shown. */
31
+ function type(key) {
32
+ const box = front();
33
+ box === null || box === void 0 ? void 0 : box.setText(box.text() + key);
34
+ return !!box;
35
+ }
36
+ ComposerTarget.type = type;
26
37
  /** Puts the draft in the box in front, and focuses it; false when no box is shown. */
27
38
  function add(draft) {
28
39
  var _a, _b;
29
- const box = [...shown].reverse().find(each => each.shown());
40
+ const box = front();
30
41
  if (!box) {
31
42
  return false;
32
43
  }
@@ -38,7 +49,7 @@ export var ComposerTarget;
38
49
  box.setText(`${held}${held && !/\s$/.test(held) ? ' ' : ''}${draft.text}`);
39
50
  }
40
51
  if (((_b = draft.images) === null || _b === void 0 ? void 0 : _b.length) && box.addFiles) {
41
- box.addFiles(draft.images.map(file));
52
+ box.addFiles(draft.images.map(ComposerUtil.imageFile));
42
53
  }
43
54
  return true;
44
55
  }