@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
@@ -38,26 +38,30 @@ const lucide_react_1 = require("lucide-react");
38
38
  const React = __importStar(require("react"));
39
39
  const device_1 = require("../device/device");
40
40
  const hold_1 = require("../device/hold");
41
- const mini_program_1 = require("../device/mini-program");
42
41
  const photo_picker_1 = require("../device/photo-picker");
43
42
  const recent_shots_1 = require("../device/recent-shots");
44
43
  const video_picks_1 = require("../device/video-picks");
45
44
  const use_composer_draft_1 = require("../drafts/use-composer-draft");
46
45
  const use_t_1 = require("../i18n/use-t");
47
46
  const composer_1 = require("../util/composer");
47
+ const composer_files_1 = require("../util/composer-files");
48
48
  const file_drag_1 = require("../util/file-drag");
49
49
  const voice_1 = require("../util/voice");
50
50
  const composer_attachments_1 = require("./composer-attachments");
51
51
  const composer_box_hooks_1 = require("./composer-box-hooks");
52
+ const composer_drop_hooks_1 = require("./composer-drop-hooks");
52
53
  const composer_emoji_1 = require("./composer-emoji");
54
+ const composer_faces_1 = require("./composer-faces");
53
55
  const composer_media_1 = require("./composer-media");
54
56
  const composer_menu_1 = require("./composer-menu");
57
+ const composer_voice_1 = require("./composer-voice");
55
58
  const emoji_panel_1 = require("./emoji-panel");
56
59
  const held_talk_1 = require("./held-talk");
57
60
  const icon_1 = require("./icon");
58
61
  const plus_menu_1 = require("./plus-menu");
59
62
  const recent_shot_1 = require("./recent-shot");
60
- const voice_button_1 = require("./voice-button");
63
+ const use_composer_attachments_1 = require("./use-composer-attachments");
64
+ const use_composer_files_1 = require("./use-composer-files");
61
65
  const voice_talk_1 = require("./voice-talk");
62
66
  /**
63
67
  * 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;
@@ -68,12 +72,14 @@ const voice_talk_1 = require("./voice-talk");
68
72
  let talkFirst = false;
69
73
  exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
70
74
  var _a;
71
- 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;
75
+ 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;
72
76
  const t = (0, use_t_1.useT)();
73
77
  const drafts = (0, use_composer_draft_1.useTaDrafts)();
74
78
  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 : ''; });
75
79
  const [caret, setCaret] = React.useState(() => text.length);
76
- const [attachments, setAttachments] = React.useState([]);
80
+ const uploaded = (0, use_composer_files_1.useComposerFiles)(takesFiles, cwd, t, onError);
81
+ const images = (0, use_composer_attachments_1.useComposerAttachments)({ images: !!takesImages, videos: props.videos, files: !!takesFiles, addFiles: uploaded.add, t, onError });
82
+ const attachments = images.attachments;
77
83
  (0, use_composer_draft_1.useComposerDraft)(drafts, draft, {
78
84
  text,
79
85
  attachments,
@@ -81,10 +87,7 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
81
87
  setText(next);
82
88
  setCaret(next.length);
83
89
  setDismissed(undefined);
84
- setAttachments(previous => {
85
- composer_1.ComposerUtil.release(previous.filter(attachment => !kept.includes(attachment)));
86
- return kept;
87
- });
90
+ images.set(kept);
88
91
  },
89
92
  });
90
93
  const [selected, setSelected] = React.useState(0);
@@ -100,6 +103,8 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
100
103
  setStopping(false);
101
104
  }
102
105
  }, [busy]);
106
+ // When the box last sent: the button turns to stop under the pointer, and a second click then is not a stop.
107
+ const sentAt = React.useRef(undefined);
103
108
  const stop = () => {
104
109
  if (!onStop || stopping) {
105
110
  return;
@@ -118,6 +123,7 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
118
123
  const [focused, setFocused] = React.useState(false);
119
124
  const input = React.useRef(null);
120
125
  const picker = React.useRef(null);
126
+ const documents = React.useRef(null);
121
127
  const camera = React.useRef(null);
122
128
  const plus = React.useRef(null);
123
129
  const panel = React.useRef(null);
@@ -127,6 +133,7 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
127
133
  setClosing(handheld);
128
134
  }, [handheld]);
129
135
  const emojis = (0, composer_emoji_1.useComposerEmoji)(handheld, input, () => menu && setMenu(false));
136
+ const faces = (0, composer_faces_1.useBoxFaces)(input, text, !!takesEmoji);
130
137
  const found = composer_1.ComposerUtil.trigger(text, caret);
131
138
  const trigger = found && `${found.kind}:${found.start}` !== dismissed ? found : undefined;
132
139
  const query = (trigger === null || trigger === void 0 ? void 0 : trigger.kind) === 'file' ? trigger.query : undefined;
@@ -142,10 +149,10 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
142
149
  : []
143
150
  : [];
144
151
  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;
145
- const sendable = text.trim().length > 0 || attachments.length > 0;
152
+ const sendable = text.trim().length > 0 || attachments.length > 0 || uploaded.files.length > 0;
146
153
  const action = composer_1.ComposerUtil.action(working, sendable, compacting);
147
- // An image still being read holds the message back, rather than leaving without it.
148
- const reading = !composer_1.ComposerUtil.ready(attachments);
154
+ // An image still being read, or a file still uploading, holds the message back, rather than leaving without it.
155
+ const reading = !composer_1.ComposerUtil.ready(attachments) || !uploaded.ready;
149
156
  (0, composer_box_hooks_1.useFieldFit)(input, text, talkMode);
150
157
  (0, composer_box_hooks_1.usePlusMenuDismiss)(menu, closeMenu, plus, panel);
151
158
  const toggleMenu = () => {
@@ -174,7 +181,8 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
174
181
  requestAnimationFrame(() => {
175
182
  var _a, _b;
176
183
  (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
177
- (_b = input.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(position, position);
184
+ const at = faces.shownCaret(next, position);
185
+ (_b = input.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(at, at);
178
186
  });
179
187
  };
180
188
  /** An emoji or a delete of the panel: on a phone the keyboard stays down, the caret where it was. */
@@ -192,12 +200,24 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
192
200
  // What a talk finds as it ends, long after it began.
193
201
  const latestCaret = React.useRef(caret);
194
202
  latestCaret.current = caret;
203
+ // What a drop or a paste brings: the pictures into the box as ever, every other file under `uploads/` of the
204
+ // conversation, named where the caret is (useComposerDrop).
205
+ const drop = (0, composer_drop_hooks_1.useComposerDrop)({
206
+ files: !!takesFiles,
207
+ videos: !!props.videos,
208
+ droppedFiles,
209
+ addImages: images.add,
210
+ text: () => latest.current,
211
+ caret: () => latestCaret.current,
212
+ insert: edit,
213
+ onError,
214
+ });
195
215
  const readingNow = React.useRef(reading);
196
216
  readingNow.current = reading;
197
217
  React.useImperativeHandle(ref, () => ({
198
218
  text: () => latest.current,
199
219
  setText: next => edit(next, next.length),
200
- ...(takesImages ? { addFiles: (files) => addFiles(files) } : {}),
220
+ ...(takesImages || takesFiles ? { addFiles: (files) => images.add(files) } : {}),
201
221
  shown: () => { var _a; return !!((_a = input.current) === null || _a === void 0 ? void 0 : _a.isConnected) && input.current.getClientRects().length > 0; },
202
222
  }));
203
223
  const pick = (item) => {
@@ -212,17 +232,23 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
212
232
  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());
213
233
  /** Sends; the sending, which fails as it does (what was sent back in the box), or nothing when there is nothing to send. */
214
234
  const send = (key, message = text.trim()) => {
215
- if ((!message && !attachments.length) || reading) {
235
+ if ((!message && !attachments.length && !uploaded.files.length) || reading) {
216
236
  return undefined;
217
237
  }
218
238
  const attached = attachments;
239
+ const files = uploaded.files;
240
+ sentAt.current = performance.now();
219
241
  setText('');
220
242
  setCaret(0);
221
- setAttachments([]);
222
- const sent = onSend(message, composer_1.ComposerUtil.images(attached), key);
243
+ images.set([]);
244
+ uploaded.clear();
245
+ // Where the files are, after what was typed: the agent opens them with its tools.
246
+ const said = files.length ? [message, composer_files_1.ComposerFileUtil.references(files)].filter(part => part.trim()).join('\n\n') : message;
247
+ const sent = onSend(said, composer_1.ComposerUtil.images(attached), key);
223
248
  sent.then(() => composer_1.ComposerUtil.release(attached), error => {
224
249
  setText(message);
225
- setAttachments(attached);
250
+ images.set(attached);
251
+ uploaded.restore(files);
226
252
  onError(error);
227
253
  });
228
254
  return sent;
@@ -262,16 +288,6 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
262
288
  }
263
289
  }, onError, hints, onTalkCall ? talkCalls : []);
264
290
  const talking = (0, composer_box_hooks_1.useTalkWiring)(talk, onListening, talkPlace);
265
- // Speech goes where the caret was when listening began, between what was typed.
266
- const spoken = React.useRef({ before: '', after: '' });
267
- const listen = (on) => {
268
- if (on) {
269
- spoken.current = { before: text.slice(0, caret), after: text.slice(caret) };
270
- }
271
- setListening(on);
272
- onListening === null || onListening === void 0 ? void 0 : onListening(on);
273
- };
274
- const speech = (words) => `${spoken.current.before}${words}${spoken.current.after}`;
275
291
  const switchTalk = (on) => {
276
292
  var _a;
277
293
  talkFirst = on;
@@ -284,14 +300,31 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
284
300
  requestAnimationFrame(() => { var _a; return (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus(); });
285
301
  }
286
302
  };
287
- const microphone = mini_program_1.MiniProgram.canDictate() ? (React.createElement(voice_button_1.DictateButton, { onHeard: words => {
288
- const [message, position] = composer_1.ComposerUtil.insert(latest.current, latestCaret.current, words);
289
- edit(message, position);
290
- } })) : !voice_1.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) },
291
- React.createElement(icon_1.Icon, { icon: talkMode ? lucide_react_1.Keyboard : lucide_react_1.Mic, size: 18 }))) : (React.createElement(voice_button_1.VoiceButton, { hints: hints, onListening: listen, onText: words => {
292
- setText(speech(words));
293
- setCaret(spoken.current.before.length + words.length);
294
- }, onHeard: words => (voiceSends ? send('enter', speech(words).trim()) : edit(speech(words), spoken.current.before.length + words.length)), onError: onError }));
303
+ /** Listening began or ended: the box shows it, and the microphone too. */
304
+ const listen = (on) => {
305
+ setListening(on);
306
+ onListening === null || onListening === void 0 ? void 0 : onListening(on);
307
+ };
308
+ const microphone = (0, composer_voice_1.useMicrophone)({
309
+ touch,
310
+ talkMode,
311
+ hints,
312
+ voiceSends: !!voiceSends,
313
+ said: () => ({ text: latest.current, caret: latestCaret.current }),
314
+ onHear: (words, at) => {
315
+ if (voiceSends) {
316
+ send('enter', words.trim());
317
+ }
318
+ else {
319
+ setText(words);
320
+ setCaret(at);
321
+ }
322
+ },
323
+ onInsert: words => edit(...composer_1.ComposerUtil.insert(latest.current, latestCaret.current, words)),
324
+ onListening: listen,
325
+ onTalkKey: switchTalk,
326
+ onError,
327
+ });
295
328
  // A finger held on the box while the keyboard is down talks (the field takes no finger then, .ta-talkable: a tap
296
329
  // on it is the box's, which types in it). With the keyboard up, the field and the box are the system's.
297
330
  const held = (0, hold_1.useHeld)();
@@ -307,43 +340,9 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
307
340
  : undefined);
308
341
  const box = React.useRef(null);
309
342
  (0, composer_box_hooks_1.useTapToType)(box, input, talkable);
310
- const remove = (id) => {
311
- composer_1.ComposerUtil.release(attachments.filter(attachment => attachment.id === id));
312
- setAttachments(previous => previous.filter(attachment => attachment.id !== id));
313
- };
314
- // The previews of a box that goes away go with it.
315
- const shown = React.useRef(attachments);
316
- shown.current = attachments;
317
- React.useEffect(() => () => composer_1.ComposerUtil.release(shown.current), []);
318
- /** Shows each image at once from its file, and reads them all at the same time. */
319
- const addFiles = (list) => {
320
- const added = [];
321
- for (const file of video_picks_1.VideoPicks.take(list, props.videos)) {
322
- const reason = composer_1.ComposerUtil.rejectImage(file, attachments.length + added.length);
323
- if (reason) {
324
- onError(new Error(t(`ta.composer.image.${reason}`, { name: file.name })));
325
- continue;
326
- }
327
- added.push({ attachment: { id: crypto.randomUUID(), preview: URL.createObjectURL(file) }, file });
328
- }
329
- if (!added.length) {
330
- return;
331
- }
332
- setAttachments(previous => [...previous, ...added.map(({ attachment }) => attachment)]);
333
- for (const { attachment, file } of added) {
334
- void (0, composer_attachments_1.readImage)(file).then(image => {
335
- if (!image) {
336
- composer_1.ComposerUtil.release([attachment]);
337
- }
338
- setAttachments(previous => image
339
- ? previous.map(other => (other.id === attachment.id ? { ...other, image } : other))
340
- : previous.filter(other => other.id !== attachment.id));
341
- });
342
- }
343
- };
344
343
  const onPicked = (event) => {
345
344
  if (event.target.files) {
346
- addFiles(event.target.files);
345
+ images.add(event.target.files);
347
346
  }
348
347
  event.target.value = '';
349
348
  };
@@ -372,10 +371,21 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
372
371
  }
373
372
  };
374
373
  const onPaste = (event) => {
375
- const pasted = takesImages ? video_picks_1.VideoPicks.pasted(event.clipboardData.files, !!props.videos) : [];
374
+ const pasted = takesFiles || droppedFiles
375
+ ? Array.from(event.clipboardData.files)
376
+ : takesImages
377
+ ? video_picks_1.VideoPicks.pasted(event.clipboardData.files, !!props.videos)
378
+ : [];
376
379
  if (pasted.length) {
377
380
  event.preventDefault();
378
- addFiles(pasted);
381
+ drop.take(pasted);
382
+ }
383
+ };
384
+ /** A copy of the field with faces: their names in brackets, and what is cut away. */
385
+ const copyFaces = (event, cut) => {
386
+ const left = faces.copied(event, cut);
387
+ if (left !== undefined) {
388
+ edit(left, left.length);
379
389
  }
380
390
  };
381
391
  const onDrop = (event) => {
@@ -386,9 +396,10 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
386
396
  edit(...composer_1.ComposerUtil.insert(text, caret, `${file_drag_1.FileDragUtil.references(files, cwd)} `));
387
397
  return;
388
398
  }
389
- if (takesImages && event.dataTransfer.files.length) {
399
+ const dropped = Array.from(event.dataTransfer.files);
400
+ if (dropped.length) {
390
401
  event.preventDefault();
391
- addFiles(event.dataTransfer.files);
402
+ drop.take(dropped);
392
403
  }
393
404
  };
394
405
  const own = [];
@@ -396,7 +407,7 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
396
407
  var _a, _b, _c;
397
408
  // The Ta app on iOS opens its library at once (and asks for the photos, for the screenshots, once picked).
398
409
  if (photo_picker_1.PhotoPicker.available()) {
399
- photo_picker_1.PhotoPicker.pickInto(composer_1.MAX_IMAGES - attachments.length, addFiles, props.videos);
410
+ photo_picker_1.PhotoPicker.pickInto(composer_1.MAX_IMAGES - attachments.length, images.add, props.videos);
400
411
  return;
401
412
  }
402
413
  if (recentShots) {
@@ -407,6 +418,9 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
407
418
  if (takesImages) {
408
419
  own.push(...(0, composer_media_1.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(); } }));
409
420
  }
421
+ if (takesFiles) {
422
+ own.push((0, composer_media_1.fileTile)(t, () => { var _a; return (_a = documents.current) === null || _a === void 0 ? void 0 : _a.click(); }));
423
+ }
410
424
  if (mentionLabel) {
411
425
  own.push({ key: 'mention', label: mentionLabel, icon: React.createElement(icon_1.Icon, { icon: lucide_react_1.AtSign, size: 16 }), run: () => edit(...composer_1.ComposerUtil.insert(text, caret, '@')) });
412
426
  }
@@ -426,7 +440,7 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
426
440
  above,
427
441
  head && React.createElement("div", { className: "ta-console-head" }, head),
428
442
  React.createElement("div", { ref: box, className: `ta-console-box${dragging ? ' ta-dragging' : ''}${talkable ? ' ta-talkable' : ''}`, ...boxHold, onDragOver: event => {
429
- if (file_drag_1.FileDragUtil.has(event.dataTransfer) || (takesImages && event.dataTransfer.types.includes('Files'))) {
443
+ if (file_drag_1.FileDragUtil.has(event.dataTransfer) || ((takesImages || takesFiles || droppedFiles) && event.dataTransfer.types.includes('Files'))) {
430
444
  event.preventDefault();
431
445
  setDragging(true);
432
446
  }
@@ -438,20 +452,28 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
438
452
  (_a = input.current) === null || _a === void 0 ? void 0 : _a.focus();
439
453
  }
440
454
  } },
441
- attachments.length > 0 && React.createElement(composer_attachments_1.Attachments, { attachments: attachments, onRemove: remove }),
455
+ attachments.length > 0 && React.createElement(composer_attachments_1.Attachments, { attachments: attachments, onRemove: images.remove }),
456
+ uploaded.files.length > 0 && React.createElement(composer_attachments_1.ComposerFiles, { files: uploaded.files, onRemove: uploaded.remove }),
442
457
  React.createElement("div", { className: "ta-console-row ta-conversation" },
443
458
  sections.length > 0 && (React.createElement("div", { className: "ta-plus", ref: plus },
444
459
  React.createElement(icon_1.IconButton, { icon: lucide_react_1.Plus, label: t('ta.composer.more'), className: `ta-attach ta-plus-button ${menu ? 'ta-on' : ''}`, onClick: toggleMenu }),
445
460
  menu && !handheld && React.createElement(plus_menu_1.PlusMenu, { sections: sections, onClose: closeMenu }),
446
- takesImages && recentShots && (React.createElement(recent_shot_1.RecentShotOffer, { box: box, activity: `${text}|${attachments.length}|${menu}|${talkMode}`, onPick: file => addFiles([file]) })))),
461
+ takesImages && recentShots && (React.createElement(recent_shot_1.RecentShotOffer, { box: box, activity: `${text}|${attachments.length}|${menu}|${talkMode}`, onPick: file => images.add([file]) })))),
447
462
  takesImages && React.createElement(composer_media_1.MediaInputs, { picker: picker, camera: handheld && touch ? camera : undefined, videos: !!props.videos, onChange: onPicked }),
463
+ takesFiles && React.createElement(composer_media_1.FileInput, { picker: documents, onChange: onPicked }),
448
464
  talkMode && React.createElement(voice_talk_1.TalkBar, { talk: talk }),
449
- 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 => {
450
- setText(event.target.value);
451
- onTextChange === null || onTextChange === void 0 ? void 0 : onTextChange(event.target.value);
452
- setCaret(event.target.selectionStart);
465
+ 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 => {
466
+ const [next, position] = faces.typed(event.target.value, event.target.selectionStart);
467
+ setText(next);
468
+ onTextChange === null || onTextChange === void 0 ? void 0 : onTextChange(next);
469
+ setCaret(position);
453
470
  setSelected(0);
454
- }, onSelect: event => setCaret(event.currentTarget.selectionStart), onKeyDown: onKeyDown, onPaste: onPaste, onFocus: () => {
471
+ // A face typed out by its name ([微笑]) turns into the face: the caret stays where it was,
472
+ // the browser told so, that it does not put its own back before the face.
473
+ if (faces.shown !== event.target.value) {
474
+ faces.settle(event.target, next, position);
475
+ }
476
+ }, 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: () => {
455
477
  setFocused(true);
456
478
  // The keyboard comes in place of the panel.
457
479
  if (menu && handheld) {
@@ -461,6 +483,7 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
461
483
  emojis.close();
462
484
  }
463
485
  }, onBlur: () => setFocused(false) }),
486
+ faces.mirror && !talkMode && faces.mirror,
464
487
  takesEmoji && (React.createElement(composer_emoji_1.ComposerEmojiButton, { emoji: emojis, handheld: handheld, onPick: emoji => type(...emoji_panel_1.EmojiPanelUtil.insert(text, caret, emoji)) })),
465
488
  after,
466
489
  microphone,
@@ -472,7 +495,7 @@ exports.ComposerBox = React.forwardRef(function ComposerBox(props, ref) {
472
495
  ? sendTitle
473
496
  : 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',
474
497
  // Pressed with the keyboard open, the box keeps the focus and the keyboard stays, as in WeChat.
475
- 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_1.Icon, { icon: action === 'stop' ? lucide_react_1.Square : lucide_react_1.ArrowUp, size: action === 'stop' ? 14 : 18 }))))),
498
+ onPointerDown: event => document.activeElement === input.current && event.preventDefault(), onClick: () => (action === 'stop' ? !composer_1.ComposerUtil.accidentalStop(sentAt.current, performance.now()) && stop() : send('enter')) }, action === 'stop' && stopping ? (React.createElement("span", { className: "ta-spinner" })) : (React.createElement(icon_1.Icon, { icon: action === 'stop' ? lucide_react_1.Square : lucide_react_1.ArrowUp, size: action === 'stop' ? 14 : 18 }))))),
476
499
  takesEmoji && handheld && (emojis.open || emojis.closing) && (React.createElement(emoji_panel_1.EmojiPanel, { ref: emojis.panel, docked: true, closing: !emojis.open, onClosed: emojis.closed, onPick: emoji => type(...emoji_panel_1.EmojiPanelUtil.insert(text, caret, emoji)), onDelete: () => type(...emoji_panel_1.EmojiPanelUtil.deleteBack(text, caret)), sendable: sendable && !reading, onSend: () => void send('enter') })),
477
500
  handheld && (menu || closing) && sections.length > 0 && (React.createElement(plus_menu_1.PlusMenu, { ref: panel, sections: sections, docked: true, closing: !menu, onClosed: () => setClosing(false), onClose: closeMenu }))));
478
501
  });
@@ -0,0 +1,27 @@
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 {};
27
+ //# sourceMappingURL=composer-drop-hooks.d.ts.map
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useComposerDrop = useComposerDrop;
37
+ const React = __importStar(require("react"));
38
+ const composer_1 = require("../util/composer");
39
+ const composer_drop_1 = require("../util/composer-drop");
40
+ /**
41
+ * The files of a drop or a paste into the message box (ComposerBoxProps.droppedFiles): the pictures (and the videos the
42
+ * box takes) into it as ever, and every other file where the box takes none, written by its owner under `uploads/` of
43
+ * the conversation and named as an `@` reference put where the caret is (ComposerDropUtil). A box that takes files of
44
+ * its own (files) keeps them as it did; one with neither hands them to the pictures, which says what it cannot send.
45
+ */
46
+ function useComposerDrop(options) {
47
+ const { files, videos, droppedFiles, addImages, text, caret, insert, onError } = options;
48
+ return {
49
+ take: React.useCallback((coming) => {
50
+ const write = files ? undefined : droppedFiles;
51
+ if (!coming.length) {
52
+ return;
53
+ }
54
+ if (!write) {
55
+ addImages(coming);
56
+ return;
57
+ }
58
+ const { pictures, others } = composer_drop_1.ComposerDropUtil.part(coming, videos);
59
+ if (pictures.length) {
60
+ addImages(pictures);
61
+ }
62
+ if (!others.length) {
63
+ return;
64
+ }
65
+ // As the files come: what was typed a moment before they are written is still there.
66
+ void write(others)
67
+ .then(paths => insert(...composer_1.ComposerUtil.insert(text(), caret(), `${composer_drop_1.ComposerDropUtil.references(paths)} `)))
68
+ .catch(error => onError(error));
69
+ }, [files, videos, droppedFiles, addImages, text, caret, insert, onError]),
70
+ };
71
+ }
72
+ //# sourceMappingURL=composer-drop-hooks.js.map
@@ -78,7 +78,7 @@ function ComposerEmojiButton({ emoji, handheld, onPick }) {
78
78
  const t = (0, use_t_1.useT)();
79
79
  const keyboard = emoji.open && handheld;
80
80
  return (React.createElement("div", { className: "ta-emoji-anchor", ref: emoji.anchor },
81
- 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,
81
+ 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,
82
82
  // On a computer the field keeps the focus while the popover opens.
83
83
  onPointerDown: event => !handheld && event.preventDefault(), onClick: emoji.toggle },
84
84
  React.createElement(icon_1.Icon, { icon: keyboard ? lucide_react_1.Keyboard : lucide_react_1.Smile, size: 20 })),
@@ -0,0 +1,17 @@
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
+ };
17
+ //# sourceMappingURL=composer-faces.d.ts.map
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useBoxFaces = useBoxFaces;
37
+ const React = __importStar(require("react"));
38
+ const chat_emoji_1 = require("./chat-emoji");
39
+ /**
40
+ * The faces of the field of a box (ComposerBoxProps.emoji), as WeChat's box shows them: the text is still said the way
41
+ * it is sent (`[微笑]`), and the field shows each face as one character of its own font, drawn as the face (FaceField),
42
+ * which the caret steps over and Delete takes whole. Everything here is between the two.
43
+ */
44
+ function useBoxFaces(field, text, takes) {
45
+ // What the field holds: each face one character.
46
+ const shown = takes ? chat_emoji_1.ChatEmojiUtil.glyphs(text) : text;
47
+ /** Where a place of the text is in the field, and back. */
48
+ const shownCaret = React.useCallback((said, position) => (takes ? chat_emoji_1.ChatEmojiUtil.shownCaret(said, position) : position), [takes]);
49
+ const saidCaret = React.useCallback((value, position) => (takes ? chat_emoji_1.ChatEmojiUtil.saidCaret(value, position) : position), [takes]);
50
+ /** What the field was given: the text as it is said, and where the caret is in it. */
51
+ const typed = React.useCallback((value, position) => [takes ? chat_emoji_1.ChatEmojiUtil.codes(value) : value, saidCaret(value, position)], [takes, saidCaret]);
52
+ /** A face typed out by its name ([微笑]) turned into the face: the caret put where it was, after it. */
53
+ const settle = (field, said, position) => {
54
+ const at = chat_emoji_1.ChatEmojiUtil.shownCaret(said, position);
55
+ field.setSelectionRange(at, at);
56
+ };
57
+ /** Copied or cut, faces go as their names in brackets, as WeChat pastes them; what comes back is the text left. */
58
+ const copied = (event, cut) => {
59
+ const element = event.currentTarget;
60
+ const from = element.selectionStart;
61
+ const to = element.selectionEnd;
62
+ if (!takes || from === to) {
63
+ return undefined;
64
+ }
65
+ event.preventDefault();
66
+ event.clipboardData.setData('text/plain', chat_emoji_1.ChatEmojiUtil.codes(element.value.slice(from, to)));
67
+ return cut ? chat_emoji_1.ChatEmojiUtil.codes(element.value.slice(0, from) + element.value.slice(to)) : undefined;
68
+ };
69
+ /** The faces of what the field shows, over it. */
70
+ const mirror = shown === text ? undefined : React.createElement(chat_emoji_1.FaceField, { field: field, text: shown });
71
+ return { shown, taken: takes, shownCaret, saidCaret, typed, settle, copied, mirror };
72
+ }
73
+ //# sourceMappingURL=composer-faces.js.map
@@ -24,4 +24,14 @@ 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;
27
37
  //# sourceMappingURL=composer-media.d.ts.map
@@ -35,6 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.mediaTiles = mediaTiles;
37
37
  exports.MediaInputs = MediaInputs;
38
+ exports.fileTile = fileTile;
39
+ exports.FileInput = FileInput;
38
40
  const lucide_react_1 = require("lucide-react");
39
41
  const React = __importStar(require("react"));
40
42
  const video_picks_1 = require("../device/video-picks");
@@ -71,4 +73,15 @@ function MediaInputs({ picker, camera, videos, onChange, }) {
71
73
  React.createElement("input", { ref: picker, type: "file", accept: video_picks_1.VideoPicks.accept(composer_1.IMAGE_TYPES, videos), multiple: true, hidden: true, onChange: onChange }),
72
74
  camera && React.createElement("input", { ref: camera, type: "file", accept: videos ? 'image/*,video/*' : 'image/*', capture: "environment", hidden: true, onChange: onChange })));
73
75
  }
76
+ /**
77
+ * The tile of the + that adds files at all (ComposerBoxProps.files): a PDF, a sheet, a picture a model cannot see.
78
+ * They go to `uploads/` of the conversation, which the message names as `@` references.
79
+ */
80
+ function fileTile(t, pick) {
81
+ return { key: 'file', label: t('ta.composer.addFile'), icon: React.createElement(icon_1.Icon, { icon: lucide_react_1.FilePlus2, size: 16 }), run: pick };
82
+ }
83
+ /** The field of those files, hidden: they are anything, so it takes anything. */
84
+ function FileInput({ picker, onChange }) {
85
+ return React.createElement("input", { ref: picker, type: "file", multiple: true, hidden: true, onChange: onChange });
86
+ }
74
87
  //# 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
  }