@celljs/ta-web 4.9.0 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/README.en.md +4 -3
  2. package/README.md +4 -3
  3. package/esm/browser/assistant/assistant-chat-list.js +8 -2
  4. package/esm/browser/assistant/assistant-extension.d.ts +8 -1
  5. package/esm/browser/assistant/assistant-extension.js +33 -5
  6. package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
  7. package/esm/browser/assistant/assistant-task-source.d.ts +2 -0
  8. package/esm/browser/assistant/assistant-task-source.js +2 -0
  9. package/esm/browser/assistant/assistant-task-util.d.ts +8 -0
  10. package/esm/browser/assistant/assistant-task-util.js +13 -3
  11. package/esm/browser/assistant/assistant-tasks.js +3 -2
  12. package/esm/browser/assistant/assistant-view.js +81 -56
  13. package/esm/browser/assistant/assistant.d.ts +30 -1
  14. package/esm/browser/assistant/assistant.js +89 -6
  15. package/esm/browser/assistant/task-views.d.ts +40 -6
  16. package/esm/browser/assistant/task-views.js +73 -21
  17. package/esm/browser/avatar/dino-avatar.d.ts +3 -4
  18. package/esm/browser/avatar/dino-avatar.js +4 -178
  19. package/esm/browser/avatar/dino-face.d.ts +19 -0
  20. package/esm/browser/avatar/dino-face.js +142 -0
  21. package/esm/browser/avatar/dino-geometry.d.ts +11 -0
  22. package/esm/browser/avatar/dino-geometry.js +38 -0
  23. package/esm/browser/avatar/dino-kinds.d.ts +15 -0
  24. package/esm/browser/avatar/dino-kinds.js +544 -0
  25. package/esm/browser/avatar/dino-motion.js +1 -1
  26. package/esm/browser/avatar/dino-shape.d.ts +80 -0
  27. package/esm/browser/avatar/dino-shape.js +113 -0
  28. package/esm/browser/avatar/dino-species.d.ts +1 -61
  29. package/esm/browser/avatar/dino-species.js +2 -653
  30. package/esm/browser/chat/chat-packages.d.ts +39 -0
  31. package/esm/browser/chat/chat-packages.js +70 -0
  32. package/esm/browser/chat/chat-protocol.d.ts +23 -1
  33. package/esm/browser/chat/chat-stores.d.ts +59 -0
  34. package/esm/browser/chat/chat-stores.js +121 -0
  35. package/esm/browser/chat/chat-util.d.ts +17 -0
  36. package/esm/browser/chat/chat-util.js +61 -0
  37. package/esm/browser/chat/chat-view.js +33 -12
  38. package/esm/browser/chat/chat.d.ts +31 -39
  39. package/esm/browser/chat/chat.js +226 -175
  40. package/esm/browser/components/access-view.js +1 -1
  41. package/esm/browser/components/account-menu.js +1 -1
  42. package/esm/browser/components/app-nav.d.ts +6 -3
  43. package/esm/browser/components/app-nav.js +19 -10
  44. package/esm/browser/components/app-shell-hooks.d.ts +47 -0
  45. package/esm/browser/components/app-shell-hooks.js +169 -0
  46. package/esm/browser/components/app-view.js +81 -172
  47. package/esm/browser/components/auth-view.js +1 -1
  48. package/esm/browser/components/chat-list.d.ts +20 -2
  49. package/esm/browser/components/chat-list.js +138 -22
  50. package/esm/browser/components/composer-box.d.ts +5 -5
  51. package/esm/browser/components/composer-box.js +111 -4
  52. package/esm/browser/components/composer.d.ts +7 -0
  53. package/esm/browser/components/composer.js +22 -14
  54. package/esm/browser/components/connection-bar.js +50 -17
  55. package/esm/browser/components/context-menu.d.ts +30 -4
  56. package/esm/browser/components/context-menu.js +199 -37
  57. package/esm/browser/components/conversation-scroll.d.ts +129 -6
  58. package/esm/browser/components/conversation-scroll.js +429 -109
  59. package/esm/browser/components/dino.js +1 -1
  60. package/esm/browser/components/earlier-messages.d.ts +2 -1
  61. package/esm/browser/components/earlier-messages.js +2 -17
  62. package/esm/browser/components/editor-area.d.ts +3 -1
  63. package/esm/browser/components/editor-area.js +6 -5
  64. package/esm/browser/components/empty-pictures.d.ts +0 -2
  65. package/esm/browser/components/empty-pictures.js +0 -16
  66. package/esm/browser/components/folder-picker.d.ts +5 -2
  67. package/esm/browser/components/folder-picker.js +30 -9
  68. package/esm/browser/components/held-talk.d.ts +28 -0
  69. package/esm/browser/components/held-talk.js +76 -0
  70. package/esm/browser/components/host-view.d.ts +1 -1
  71. package/esm/browser/components/host-view.js +1 -1
  72. package/esm/browser/components/icon.d.ts +2 -2
  73. package/esm/browser/components/icon.js +5 -6
  74. package/esm/browser/components/image-viewer.d.ts +124 -0
  75. package/esm/browser/components/image-viewer.js +397 -0
  76. package/esm/browser/components/lightbox.d.ts +11 -0
  77. package/esm/browser/components/lightbox.js +24 -0
  78. package/esm/browser/components/markdown.d.ts +6 -2
  79. package/esm/browser/components/markdown.js +24 -10
  80. package/esm/browser/components/media.js +1 -10
  81. package/esm/browser/components/message-footer.d.ts +16 -2
  82. package/esm/browser/components/message-footer.js +29 -12
  83. package/esm/browser/components/message-list.d.ts +24 -3
  84. package/esm/browser/components/message-list.js +149 -20
  85. package/esm/browser/components/message-menu.d.ts +3 -1
  86. package/esm/browser/components/message-menu.js +18 -3
  87. package/esm/browser/components/nav-places.d.ts +16 -1
  88. package/esm/browser/components/nav-places.js +12 -3
  89. package/esm/browser/components/phone-shell.d.ts +4 -1
  90. package/esm/browser/components/phone-shell.js +3 -1
  91. package/esm/browser/components/run-status.js +3 -3
  92. package/esm/browser/components/select-bar.d.ts +9 -0
  93. package/esm/browser/components/select-bar.js +24 -0
  94. package/esm/browser/components/session-settings.d.ts +6 -0
  95. package/esm/browser/components/session-settings.js +14 -1
  96. package/esm/browser/components/session-view.js +8 -4
  97. package/esm/browser/components/settings-choices.d.ts +35 -0
  98. package/esm/browser/components/settings-choices.js +117 -0
  99. package/esm/browser/components/settings-parts.d.ts +21 -0
  100. package/esm/browser/components/settings-parts.js +323 -0
  101. package/esm/browser/components/settings-view.d.ts +0 -6
  102. package/esm/browser/components/settings-view.js +4 -406
  103. package/esm/browser/components/swipe-row.d.ts +2 -2
  104. package/esm/browser/components/swipe-row.js +7 -3
  105. package/esm/browser/components/tool-view.js +14 -12
  106. package/esm/browser/components/voice-button.d.ts +1 -1
  107. package/esm/browser/components/voice-button.js +1 -1
  108. package/esm/browser/components/voice-talk.d.ts +43 -0
  109. package/esm/browser/components/voice-talk.js +222 -0
  110. package/esm/browser/components/workbench-view.js +1 -1
  111. package/esm/browser/device/device.d.ts +3 -0
  112. package/esm/browser/device/device.js +11 -1
  113. package/esm/browser/device/hold.d.ts +42 -0
  114. package/esm/browser/device/hold.js +136 -0
  115. package/esm/browser/device/launch-screen.d.ts +1 -1
  116. package/esm/browser/device/launch-screen.js +1 -1
  117. package/esm/browser/device/long-press.d.ts +2 -0
  118. package/esm/browser/device/long-press.js +16 -1
  119. package/esm/browser/device/pull-down.d.ts +4 -2
  120. package/esm/browser/device/pull-down.js +64 -76
  121. package/esm/browser/device/row-swipe.d.ts +35 -10
  122. package/esm/browser/device/row-swipe.js +149 -71
  123. package/esm/browser/device/shake-undo.d.ts +16 -0
  124. package/esm/browser/device/shake-undo.js +59 -0
  125. package/esm/browser/device/sheet-swipe.d.ts +118 -18
  126. package/esm/browser/device/sheet-swipe.js +406 -107
  127. package/esm/browser/extension/icons.js +2 -1
  128. package/esm/browser/extension/web-extension-api.d.ts +135 -2
  129. package/esm/browser/extension/web-extension-code.d.ts +6 -0
  130. package/esm/browser/extension/web-extension-code.js +24 -0
  131. package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
  132. package/esm/browser/extension/web-extension-protocol.js +8 -0
  133. package/esm/browser/extension/web-extensions.d.ts +14 -1
  134. package/esm/browser/extension/web-extensions.js +128 -24
  135. package/esm/browser/extension/web-tasks.d.ts +9 -1
  136. package/esm/browser/extension/web-tasks.js +24 -0
  137. package/esm/browser/files/files-protocol.d.ts +25 -0
  138. package/esm/browser/files/files-protocol.js +2 -0
  139. package/esm/browser/files/files.d.ts +35 -0
  140. package/esm/browser/files/files.js +119 -0
  141. package/esm/browser/hooks.d.ts +3 -1
  142. package/esm/browser/hooks.js +8 -0
  143. package/esm/browser/i18n/locales.d.ts +29 -2
  144. package/esm/browser/i18n/messages.d.ts +28 -1
  145. package/esm/browser/i18n/messages.js +58 -4
  146. package/esm/browser/index.d.ts +6 -0
  147. package/esm/browser/index.js +6 -0
  148. package/esm/browser/notices/notices-protocol.d.ts +9 -1
  149. package/esm/browser/notices/notices.d.ts +2 -0
  150. package/esm/browser/notices/notices.js +20 -10
  151. package/esm/browser/offline/device-values.d.ts +55 -0
  152. package/esm/browser/offline/device-values.js +142 -0
  153. package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
  154. package/esm/browser/offline/kept-chats-protocol.js +2 -0
  155. package/esm/browser/offline/kept-chats.d.ts +47 -0
  156. package/esm/browser/offline/kept-chats.js +146 -0
  157. package/esm/browser/offline/offline-reads.d.ts +44 -0
  158. package/esm/browser/offline/offline-reads.js +107 -0
  159. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  160. package/esm/browser/settings/settings-protocol.js +2 -0
  161. package/esm/browser/style/conversation.d.ts +1 -1
  162. package/esm/browser/style/conversation.js +57 -17
  163. package/esm/browser/style/device.js +43 -4
  164. package/esm/browser/style/layout.d.ts +1 -1
  165. package/esm/browser/style/layout.js +67 -15
  166. package/esm/browser/style/pages.d.ts +1 -1
  167. package/esm/browser/style/pages.js +2 -1
  168. package/esm/browser/style/shell.d.ts +1 -1
  169. package/esm/browser/style/shell.js +47 -3
  170. package/esm/browser/style/tasks.d.ts +1 -1
  171. package/esm/browser/style/tasks.js +2 -0
  172. package/esm/browser/util/frame.d.ts +5 -4
  173. package/esm/browser/util/frame.js +5 -4
  174. package/esm/browser/util/markdown.d.ts +18 -1
  175. package/esm/browser/util/markdown.js +119 -5
  176. package/esm/browser/util/process.d.ts +21 -0
  177. package/esm/browser/util/process.js +45 -1
  178. package/esm/browser/util/voice.d.ts +5 -2
  179. package/esm/browser/util/voice.js +6 -3
  180. package/esm/browser/util/zoom.d.ts +46 -0
  181. package/esm/browser/util/zoom.js +96 -0
  182. package/esm/browser/workbench-calls.d.ts +59 -0
  183. package/esm/browser/workbench-calls.js +141 -0
  184. package/esm/browser/workbench-protocol.d.ts +5 -1
  185. package/esm/browser/workbench-util.d.ts +68 -0
  186. package/esm/browser/workbench-util.js +145 -0
  187. package/esm/browser/workbench.d.ts +15 -42
  188. package/esm/browser/workbench.js +53 -167
  189. package/lib/browser/assistant/assistant-chat-list.js +8 -2
  190. package/lib/browser/assistant/assistant-extension.d.ts +8 -1
  191. package/lib/browser/assistant/assistant-extension.js +33 -5
  192. package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
  193. package/lib/browser/assistant/assistant-task-source.d.ts +2 -0
  194. package/lib/browser/assistant/assistant-task-source.js +2 -0
  195. package/lib/browser/assistant/assistant-task-util.d.ts +8 -0
  196. package/lib/browser/assistant/assistant-task-util.js +13 -3
  197. package/lib/browser/assistant/assistant-tasks.js +2 -1
  198. package/lib/browser/assistant/assistant-view.js +78 -53
  199. package/lib/browser/assistant/assistant.d.ts +30 -1
  200. package/lib/browser/assistant/assistant.js +89 -6
  201. package/lib/browser/assistant/task-views.d.ts +40 -6
  202. package/lib/browser/assistant/task-views.js +74 -21
  203. package/lib/browser/avatar/dino-avatar.d.ts +3 -4
  204. package/lib/browser/avatar/dino-avatar.js +27 -202
  205. package/lib/browser/avatar/dino-face.d.ts +20 -0
  206. package/lib/browser/avatar/dino-face.js +148 -0
  207. package/lib/browser/avatar/dino-geometry.d.ts +12 -0
  208. package/lib/browser/avatar/dino-geometry.js +47 -0
  209. package/lib/browser/avatar/dino-kinds.d.ts +16 -0
  210. package/lib/browser/avatar/dino-kinds.js +547 -0
  211. package/lib/browser/avatar/dino-motion.js +2 -2
  212. package/lib/browser/avatar/dino-shape.d.ts +81 -0
  213. package/lib/browser/avatar/dino-shape.js +126 -0
  214. package/lib/browser/avatar/dino-species.d.ts +1 -61
  215. package/lib/browser/avatar/dino-species.js +34 -687
  216. package/lib/browser/chat/chat-packages.d.ts +40 -0
  217. package/lib/browser/chat/chat-packages.js +74 -0
  218. package/lib/browser/chat/chat-protocol.d.ts +23 -1
  219. package/lib/browser/chat/chat-stores.d.ts +60 -0
  220. package/lib/browser/chat/chat-stores.js +125 -0
  221. package/lib/browser/chat/chat-util.d.ts +18 -0
  222. package/lib/browser/chat/chat-util.js +64 -0
  223. package/lib/browser/chat/chat-view.js +33 -12
  224. package/lib/browser/chat/chat.d.ts +31 -39
  225. package/lib/browser/chat/chat.js +227 -176
  226. package/lib/browser/components/access-view.js +2 -2
  227. package/lib/browser/components/account-menu.js +2 -2
  228. package/lib/browser/components/app-nav.d.ts +6 -3
  229. package/lib/browser/components/app-nav.js +17 -8
  230. package/lib/browser/components/app-shell-hooks.d.ts +48 -0
  231. package/lib/browser/components/app-shell-hooks.js +211 -0
  232. package/lib/browser/components/app-view.js +89 -180
  233. package/lib/browser/components/auth-view.js +3 -3
  234. package/lib/browser/components/chat-list.d.ts +20 -2
  235. package/lib/browser/components/chat-list.js +137 -21
  236. package/lib/browser/components/composer-box.d.ts +5 -5
  237. package/lib/browser/components/composer-box.js +111 -4
  238. package/lib/browser/components/composer.d.ts +7 -0
  239. package/lib/browser/components/composer.js +22 -14
  240. package/lib/browser/components/connection-bar.js +48 -15
  241. package/lib/browser/components/context-menu.d.ts +30 -4
  242. package/lib/browser/components/context-menu.js +198 -36
  243. package/lib/browser/components/conversation-scroll.d.ts +129 -6
  244. package/lib/browser/components/conversation-scroll.js +431 -110
  245. package/lib/browser/components/dino.js +3 -3
  246. package/lib/browser/components/earlier-messages.d.ts +2 -1
  247. package/lib/browser/components/earlier-messages.js +2 -17
  248. package/lib/browser/components/editor-area.d.ts +3 -1
  249. package/lib/browser/components/editor-area.js +5 -4
  250. package/lib/browser/components/empty-pictures.d.ts +0 -2
  251. package/lib/browser/components/empty-pictures.js +0 -17
  252. package/lib/browser/components/folder-picker.d.ts +5 -2
  253. package/lib/browser/components/folder-picker.js +30 -9
  254. package/lib/browser/components/held-talk.d.ts +29 -0
  255. package/lib/browser/components/held-talk.js +79 -0
  256. package/lib/browser/components/host-view.d.ts +1 -1
  257. package/lib/browser/components/host-view.js +5 -5
  258. package/lib/browser/components/icon.d.ts +2 -2
  259. package/lib/browser/components/icon.js +7 -6
  260. package/lib/browser/components/image-viewer.d.ts +125 -0
  261. package/lib/browser/components/image-viewer.js +435 -0
  262. package/lib/browser/components/lightbox.d.ts +12 -0
  263. package/lib/browser/components/lightbox.js +60 -0
  264. package/lib/browser/components/markdown.d.ts +6 -2
  265. package/lib/browser/components/markdown.js +24 -10
  266. package/lib/browser/components/media.js +2 -11
  267. package/lib/browser/components/message-footer.d.ts +16 -2
  268. package/lib/browser/components/message-footer.js +31 -12
  269. package/lib/browser/components/message-list.d.ts +24 -3
  270. package/lib/browser/components/message-list.js +146 -16
  271. package/lib/browser/components/message-menu.d.ts +3 -1
  272. package/lib/browser/components/message-menu.js +17 -2
  273. package/lib/browser/components/nav-places.d.ts +16 -1
  274. package/lib/browser/components/nav-places.js +13 -3
  275. package/lib/browser/components/phone-shell.d.ts +4 -1
  276. package/lib/browser/components/phone-shell.js +3 -1
  277. package/lib/browser/components/run-status.js +3 -3
  278. package/lib/browser/components/select-bar.d.ts +10 -0
  279. package/lib/browser/components/select-bar.js +61 -0
  280. package/lib/browser/components/session-settings.d.ts +6 -0
  281. package/lib/browser/components/session-settings.js +14 -1
  282. package/lib/browser/components/session-view.js +7 -3
  283. package/lib/browser/components/settings-choices.d.ts +36 -0
  284. package/lib/browser/components/settings-choices.js +156 -0
  285. package/lib/browser/components/settings-parts.d.ts +22 -0
  286. package/lib/browser/components/settings-parts.js +359 -0
  287. package/lib/browser/components/settings-view.d.ts +0 -6
  288. package/lib/browser/components/settings-view.js +2 -405
  289. package/lib/browser/components/swipe-row.d.ts +2 -2
  290. package/lib/browser/components/swipe-row.js +7 -3
  291. package/lib/browser/components/tool-view.js +14 -12
  292. package/lib/browser/components/voice-button.d.ts +1 -1
  293. package/lib/browser/components/voice-button.js +1 -1
  294. package/lib/browser/components/voice-talk.d.ts +44 -0
  295. package/lib/browser/components/voice-talk.js +260 -0
  296. package/lib/browser/components/workbench-view.js +3 -3
  297. package/lib/browser/device/device.d.ts +3 -0
  298. package/lib/browser/device/device.js +11 -1
  299. package/lib/browser/device/hold.d.ts +43 -0
  300. package/lib/browser/device/hold.js +173 -0
  301. package/lib/browser/device/launch-screen.d.ts +1 -1
  302. package/lib/browser/device/launch-screen.js +1 -1
  303. package/lib/browser/device/long-press.d.ts +2 -0
  304. package/lib/browser/device/long-press.js +16 -1
  305. package/lib/browser/device/pull-down.d.ts +4 -2
  306. package/lib/browser/device/pull-down.js +63 -75
  307. package/lib/browser/device/row-swipe.d.ts +35 -10
  308. package/lib/browser/device/row-swipe.js +148 -70
  309. package/lib/browser/device/shake-undo.d.ts +17 -0
  310. package/lib/browser/device/shake-undo.js +63 -0
  311. package/lib/browser/device/sheet-swipe.d.ts +118 -18
  312. package/lib/browser/device/sheet-swipe.js +410 -108
  313. package/lib/browser/extension/icons.js +1 -0
  314. package/lib/browser/extension/web-extension-api.d.ts +135 -2
  315. package/lib/browser/extension/web-extension-code.d.ts +6 -0
  316. package/lib/browser/extension/web-extension-code.js +24 -0
  317. package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
  318. package/lib/browser/extension/web-extension-protocol.js +9 -1
  319. package/lib/browser/extension/web-extensions.d.ts +14 -1
  320. package/lib/browser/extension/web-extensions.js +125 -21
  321. package/lib/browser/extension/web-tasks.d.ts +9 -1
  322. package/lib/browser/extension/web-tasks.js +24 -0
  323. package/lib/browser/files/files-protocol.d.ts +26 -0
  324. package/lib/browser/files/files-protocol.js +5 -0
  325. package/lib/browser/files/files.d.ts +36 -0
  326. package/lib/browser/files/files.js +122 -0
  327. package/lib/browser/hooks.d.ts +3 -1
  328. package/lib/browser/hooks.js +9 -0
  329. package/lib/browser/i18n/locales.d.ts +29 -2
  330. package/lib/browser/i18n/messages.d.ts +28 -1
  331. package/lib/browser/i18n/messages.js +58 -4
  332. package/lib/browser/index.d.ts +6 -0
  333. package/lib/browser/index.js +6 -0
  334. package/lib/browser/notices/notices-protocol.d.ts +9 -1
  335. package/lib/browser/notices/notices.d.ts +2 -0
  336. package/lib/browser/notices/notices.js +20 -10
  337. package/lib/browser/offline/device-values.d.ts +56 -0
  338. package/lib/browser/offline/device-values.js +148 -0
  339. package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
  340. package/lib/browser/offline/kept-chats-protocol.js +5 -0
  341. package/lib/browser/offline/kept-chats.d.ts +48 -0
  342. package/lib/browser/offline/kept-chats.js +149 -0
  343. package/lib/browser/offline/offline-reads.d.ts +45 -0
  344. package/lib/browser/offline/offline-reads.js +111 -0
  345. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  346. package/lib/browser/settings/settings-protocol.js +2 -0
  347. package/lib/browser/style/conversation.d.ts +1 -1
  348. package/lib/browser/style/conversation.js +57 -17
  349. package/lib/browser/style/device.js +43 -4
  350. package/lib/browser/style/layout.d.ts +1 -1
  351. package/lib/browser/style/layout.js +67 -15
  352. package/lib/browser/style/pages.d.ts +1 -1
  353. package/lib/browser/style/pages.js +2 -1
  354. package/lib/browser/style/shell.d.ts +1 -1
  355. package/lib/browser/style/shell.js +47 -3
  356. package/lib/browser/style/tasks.d.ts +1 -1
  357. package/lib/browser/style/tasks.js +2 -0
  358. package/lib/browser/util/frame.d.ts +5 -4
  359. package/lib/browser/util/frame.js +5 -4
  360. package/lib/browser/util/markdown.d.ts +18 -1
  361. package/lib/browser/util/markdown.js +119 -5
  362. package/lib/browser/util/process.d.ts +21 -0
  363. package/lib/browser/util/process.js +46 -2
  364. package/lib/browser/util/voice.d.ts +5 -2
  365. package/lib/browser/util/voice.js +6 -3
  366. package/lib/browser/util/zoom.d.ts +47 -0
  367. package/lib/browser/util/zoom.js +99 -0
  368. package/lib/browser/workbench-calls.d.ts +60 -0
  369. package/lib/browser/workbench-calls.js +145 -0
  370. package/lib/browser/workbench-protocol.d.ts +5 -1
  371. package/lib/browser/workbench-util.d.ts +69 -0
  372. package/lib/browser/workbench-util.js +151 -0
  373. package/lib/browser/workbench.d.ts +15 -42
  374. package/lib/browser/workbench.js +74 -189
  375. package/package.json +10 -10
  376. package/public/launch.svg +46 -42
@@ -33,143 +33,458 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ASK_CLASS = void 0;
36
+ exports.ConversationScroller = exports.SCROLL_SKIP = exports.ASK_CLASS = void 0;
37
37
  exports.useConversationScroll = useConversationScroll;
38
38
  exports.useAwayFromBottom = useAwayFromBottom;
39
39
  const React = __importStar(require("react"));
40
40
  const frame_1 = require("../util/frame");
41
41
  /** A message of the user in the thread: where the view goes when one is sent. */
42
42
  exports.ASK_CLASS = 'ta-thread-ask';
43
+ /** How long a part of a message opened or closed by a click keeps its place (a motion of its height). */
44
+ const TOGGLE_MS = 400;
45
+ /** A finger moving by more than this scrolls; less is a tap. */
46
+ const TOUCH_PX = 2;
47
+ /** Keys that move the view, and those of them that move it up. */
48
+ const UP_KEYS = new Set(['ArrowUp', 'PageUp', 'Home']);
49
+ const MOVE_KEYS = new Set([...UP_KEYS, 'ArrowDown', 'PageDown', 'End', ' ']);
50
+ /** What opens or closes a part of a message. */
51
+ const TOGGLE = '[aria-expanded], summary';
52
+ /** A row of the thread under which earlier rows come in (what says they load): the row read is the one after it. */
53
+ exports.SCROLL_SKIP = { 'data-scroll-skip': '' };
43
54
  function calm() {
44
55
  return typeof document !== 'undefined' && document.documentElement.hasAttribute('data-reduce-motion');
45
56
  }
57
+ function isElement(value) {
58
+ return typeof Element !== 'undefined' && value instanceof Element;
59
+ }
60
+ /** Whether something inside the view scrolls at `target` in that direction: a wheel or a finger there is its, not the view's. */
61
+ function scrollsInside(target, view, up) {
62
+ for (let node = isElement(target) ? target : null; node && node !== view; node = node.parentElement) {
63
+ if (node.scrollHeight > node.clientHeight + 1) {
64
+ const overflow = getComputedStyle(node).overflowY;
65
+ if ((overflow === 'auto' || overflow === 'scroll') && (up ? node.scrollTop > 0 : node.scrollTop + node.clientHeight < node.scrollHeight - 1)) {
66
+ return true;
67
+ }
68
+ }
69
+ }
70
+ return false;
71
+ }
46
72
  /**
47
- * The scrolling of a conversation, whose thread is the first child of the element of the returned ref.
48
- * A message the user sends goes to the top of the view, and the answer comes in under it: the thread
49
- * keeps the room for that until the answer fills it. Past that, the view follows what comes in while it
50
- * is at the bottom, after layout, on a change of the size of the thread or of the view rather than of the state.
51
- * Opened, and when messages of the user go (a rewind), the view goes to the bottom.
73
+ * The scrolling of a conversation: its view scrolls, its thread (the first child of the view, positioned)
74
+ * holds a row for each message.
52
75
  *
53
- * `asked`: how many messages of the user there are; the thread marks them with ASK_CLASS.
76
+ * - At the bottom, the view follows what comes in, after layout, on a change of the size of the thread or of
77
+ * the view. The user scrolling up, by however little, leaves it where they took it: a wheel, a finger, a key,
78
+ * the scroll bar, whatever else moved the view up. Back down near the bottom, it follows again.
79
+ * - Away from the bottom, what the user reads stays where it is: the row at the top of the view keeps its place
80
+ * as rows above it change their height (earlier messages coming in, pictures, rows laid out as they come into
81
+ * view), and the bottom of the view keeps to the message box as it grows and shrinks (lines typed, the
82
+ * keyboard of a phone), as in a chat app.
83
+ * - A part of a message opened or closed by a click (what has `aria-expanded`, a `summary`) stays where it was
84
+ * clicked; opened past the bottom, the view stops following, for the user to read it.
85
+ * - While the user holds the view (a finger on it, the mouse on its scroll bar), nothing moves it under them.
86
+ * - A message the user sends goes to the top of the view, and the answer comes in under it: the thread keeps
87
+ * the room for that until the answer fills it (`send`), and the message keeps to the top as rows above it
88
+ * change their height (the turn it was sent into folding its steps).
54
89
  */
55
- function useConversationScroll(asked) {
56
- const ref = React.useRef(null);
57
- const stuck = React.useRef(true);
58
- // Where a smooth scroll to a message goes: the view need not follow a bottom it is on its way to.
59
- const heading = React.useRef(undefined);
60
- // The message sent last, kept at the top until the user scrolls: rows above it may still change their height.
61
- const anchored = React.useRef(undefined);
62
- const before = React.useRef(undefined);
63
- // The user scrolled since the view went to the bottom: until then, a scroll is the page moving under it.
64
- const touched = React.useRef(false);
65
- React.useEffect(() => {
66
- const element = ref.current;
67
- if (!element) {
68
- return;
69
- }
70
- let height = element.clientHeight;
71
- const onScroll = () => {
72
- // The view shrank or grew (the keyboard of a phone, a turn of it): where it is follows from the resize, not the user.
73
- if (element.clientHeight !== height) {
74
- height = element.clientHeight;
75
- return;
76
- }
77
- if (heading.current === undefined) {
78
- // Rows above that take their height as they come into view (content-visibility) move the view, not the user.
79
- stuck.current = frame_1.FrameUtil.atBottom(element) || (stuck.current && !touched.current);
80
- }
81
- else if (Math.abs(element.scrollTop - heading.current) < 1) {
82
- // There: from now on the view follows the answer as it grows past the bottom.
83
- heading.current = undefined;
84
- stuck.current = true;
90
+ class ConversationScroller {
91
+ /** The scroller of a view, while it has one. */
92
+ static of(view) {
93
+ return ConversationScroller.views.get(view);
94
+ }
95
+ constructor(view, thread, now = () => performance.now()) {
96
+ this.view = view;
97
+ this.thread = thread;
98
+ this.now = now;
99
+ this.following = true;
100
+ /** On a smooth way to the bottom (`toBottom`): what comes in meanwhile moves the end of the way. */
101
+ this.chasing = false;
102
+ this.held = false;
103
+ /**
104
+ * The room under the thread for the answer to the message sent, added to the padding of its bottom: a least
105
+ * height would hide from the observer rows above the message that change their height.
106
+ */
107
+ this.room = 0;
108
+ this.padding = 0;
109
+ this.top = view.scrollTop;
110
+ this.height = view.clientHeight;
111
+ }
112
+ /** Whether the view follows what comes in. */
113
+ get atLatest() {
114
+ return this.following;
115
+ }
116
+ /** Listens to `view` (the view of this scroller) and its thread; returns what stops it. */
117
+ attach(view, thread) {
118
+ ConversationScroller.views.set(view, this);
119
+ thread.style.paddingBottom = '';
120
+ this.padding = Number.parseFloat(getComputedStyle(thread).paddingBottom) || 0;
121
+ const onScroll = () => this.scrolled();
122
+ const onScrollEnd = () => this.scrollEnded();
123
+ const onWheel = (event) => this.wheel(event.deltaY, event.target);
124
+ const onKey = (event) => {
125
+ var _a;
126
+ const target = event.target;
127
+ if (!((_a = target === null || target === void 0 ? void 0 : target.closest) === null || _a === void 0 ? void 0 : _a.call(target, 'input, textarea, button, [contenteditable="true"]'))) {
128
+ this.key(event.key, event.shiftKey);
85
129
  }
86
130
  };
87
- // The user scrolls: a smooth scroll on its way stops, and where the view is says whether it follows.
88
- const onInput = (event) => {
89
- // A tap is not a scroll: only a wheel, a drag or a key moves the view away from the bottom.
90
- if (event.type !== 'touchstart' && event.type !== 'pointerdown') {
91
- touched.current = true;
131
+ const onTouchStart = (event) => { var _a; return this.touchStart((_a = event.touches[0]) === null || _a === void 0 ? void 0 : _a.clientY); };
132
+ const onTouchMove = (event) => { var _a; return this.touchMove((_a = event.touches[0]) === null || _a === void 0 ? void 0 : _a.clientY, event.target); };
133
+ const onTouchEnd = (event) => {
134
+ if (event.touches.length === 0) {
135
+ this.release();
92
136
  }
93
- heading.current = undefined;
94
- anchored.current = undefined;
95
137
  };
96
- // A smooth scroll that ended short of where it went (the page moved under it) counts as there.
97
- const onScrollEnd = () => {
98
- if (heading.current !== undefined) {
99
- heading.current = undefined;
100
- stuck.current = true;
138
+ // The mouse on the scroll bar (or beside the thread): the view itself is the target.
139
+ const onPointerDown = (event) => {
140
+ if (event.pointerType === 'mouse' && event.button === 0 && event.target === view) {
141
+ this.hold();
101
142
  }
102
143
  };
103
- const inputs = ['wheel', 'touchstart', 'touchmove', 'pointerdown', 'keydown'];
104
- element.addEventListener('scroll', onScroll, { passive: true });
105
- element.addEventListener('scrollend', onScrollEnd);
106
- for (const input of inputs) {
107
- element.addEventListener(input, onInput, { passive: true });
108
- }
109
- const content = element.firstElementChild;
110
- const observer = content && typeof ResizeObserver !== 'undefined'
111
- ? new ResizeObserver(() => {
112
- const message = anchored.current;
113
- if (message && content instanceof HTMLElement) {
114
- const { top, minHeight } = frame_1.FrameUtil.anchor(message.offsetTop, element.clientHeight);
115
- content.style.minHeight = `${minHeight}px`;
116
- if (heading.current !== undefined && Math.abs(top - heading.current) >= 1) {
117
- heading.current = top;
118
- element.scrollTo({ top, behavior: calm() ? 'auto' : 'smooth' });
119
- return;
120
- }
121
- }
122
- const bottom = element.scrollHeight - element.clientHeight;
123
- if (stuck.current && heading.current === undefined && bottom - element.scrollTop >= 1) {
124
- element.scrollTo({ top: bottom });
125
- }
126
- })
127
- : undefined;
128
- if (content) {
129
- observer === null || observer === void 0 ? void 0 : observer.observe(content);
130
- // The view itself shrinks under what comes above the message box (the files changed, the keyboard of a phone).
131
- observer === null || observer === void 0 ? void 0 : observer.observe(element);
132
- }
144
+ const onPointerUp = () => this.release();
145
+ // Captured: before the click opens or closes what it is on (React handles it after, on the root).
146
+ const onClick = (event) => this.clicked(event.target);
147
+ const passive = { passive: true };
148
+ view.addEventListener('scroll', onScroll, passive);
149
+ view.addEventListener('scrollend', onScrollEnd);
150
+ view.addEventListener('wheel', onWheel, passive);
151
+ view.addEventListener('keydown', onKey);
152
+ view.addEventListener('touchstart', onTouchStart, passive);
153
+ view.addEventListener('touchmove', onTouchMove, passive);
154
+ view.addEventListener('touchend', onTouchEnd, passive);
155
+ view.addEventListener('touchcancel', onTouchEnd, passive);
156
+ view.addEventListener('pointerdown', onPointerDown, passive);
157
+ view.addEventListener('click', onClick, true);
158
+ window.addEventListener('pointerup', onPointerUp, passive);
159
+ window.addEventListener('pointercancel', onPointerUp, passive);
160
+ const observer = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(() => this.resized()) : undefined;
161
+ observer === null || observer === void 0 ? void 0 : observer.observe(thread);
162
+ // The view itself changes its height under what is around it (the message box, the keyboard of a phone).
163
+ observer === null || observer === void 0 ? void 0 : observer.observe(view);
133
164
  return () => {
134
- element.removeEventListener('scroll', onScroll);
135
- element.removeEventListener('scrollend', onScrollEnd);
136
- for (const input of inputs) {
137
- element.removeEventListener(input, onInput);
138
- }
165
+ ConversationScroller.views.delete(view);
166
+ view.removeEventListener('scroll', onScroll);
167
+ view.removeEventListener('scrollend', onScrollEnd);
168
+ view.removeEventListener('wheel', onWheel);
169
+ view.removeEventListener('keydown', onKey);
170
+ view.removeEventListener('touchstart', onTouchStart);
171
+ view.removeEventListener('touchmove', onTouchMove);
172
+ view.removeEventListener('touchend', onTouchEnd);
173
+ view.removeEventListener('touchcancel', onTouchEnd);
174
+ view.removeEventListener('pointerdown', onPointerDown);
175
+ view.removeEventListener('click', onClick, true);
176
+ window.removeEventListener('pointerup', onPointerUp);
177
+ window.removeEventListener('pointercancel', onPointerUp);
139
178
  observer === null || observer === void 0 ? void 0 : observer.disconnect();
140
179
  };
180
+ }
181
+ /** To the bottom at once, following from there: a conversation opened, loaded again or rewound. */
182
+ reset() {
183
+ this.makeRoom(0);
184
+ this.sent = undefined;
185
+ this.heading = undefined;
186
+ this.chasing = false;
187
+ this.toggled = undefined;
188
+ this.following = true;
189
+ this.toBottomNow();
190
+ }
191
+ /** A message sent (its row): to the top of the view, smoothly, with the room under it that its answer will fill. */
192
+ send(message) {
193
+ this.sent = message;
194
+ this.toggled = undefined;
195
+ this.chasing = false;
196
+ const top = this.place(message);
197
+ if (Math.abs(this.view.scrollTop - top) < 1) {
198
+ this.arrive();
199
+ return;
200
+ }
201
+ this.following = false;
202
+ this.heading = top;
203
+ this.view.scrollTo({ top, behavior: calm() ? 'auto' : 'smooth' });
204
+ }
205
+ /** Back to the latest (the button that shows away from it): following again at once, the view on its way. */
206
+ toBottom() {
207
+ this.sent = undefined;
208
+ this.heading = undefined;
209
+ this.toggled = undefined;
210
+ this.following = true;
211
+ this.anchor = undefined;
212
+ if (calm()) {
213
+ this.toBottomNow();
214
+ }
215
+ else {
216
+ this.chasing = true;
217
+ this.view.scrollTo({ top: this.view.scrollHeight - this.view.clientHeight, behavior: 'smooth' });
218
+ }
219
+ }
220
+ scrolled() {
221
+ const { view } = this;
222
+ const top = view.scrollTop;
223
+ const moved = top - this.top;
224
+ this.top = top;
225
+ if (this.heading !== undefined) {
226
+ // There: from now on the view follows the answer as it grows past the bottom.
227
+ if (Math.abs(top - this.heading) < 1) {
228
+ this.arrive();
229
+ }
230
+ return;
231
+ }
232
+ const distance = view.scrollHeight - top - view.clientHeight;
233
+ if (distance < 1) {
234
+ this.following = true;
235
+ }
236
+ else if (moved <= -1) {
237
+ // Up, by the user or for them (a search in the page): the view stays where it was taken.
238
+ this.following = false;
239
+ this.chasing = false;
240
+ }
241
+ else if (moved >= 1 && distance < frame_1.FrameUtil.STICK_PX) {
242
+ this.following = true;
243
+ }
244
+ this.remember();
245
+ }
246
+ /** A smooth scroll that ended short of where it went (the page moved under it) counts as there. */
247
+ scrollEnded() {
248
+ if (this.heading !== undefined) {
249
+ this.arrive();
250
+ }
251
+ else if (this.chasing) {
252
+ this.chasing = false;
253
+ if (this.following) {
254
+ this.toBottomNow();
255
+ }
256
+ }
257
+ }
258
+ wheel(deltaY, target) {
259
+ this.byUser();
260
+ if (deltaY < 0 && this.following && !scrollsInside(target, this.view, true)) {
261
+ this.leave();
262
+ }
263
+ }
264
+ key(key, shift) {
265
+ if (MOVE_KEYS.has(key)) {
266
+ this.byUser();
267
+ if (UP_KEYS.has(key) || (key === ' ' && shift)) {
268
+ this.leave();
269
+ }
270
+ }
271
+ }
272
+ touchStart(y) {
273
+ this.touchY = y;
274
+ this.held = true;
275
+ }
276
+ touchMove(y, target) {
277
+ if (y === undefined || this.touchY === undefined || Math.abs(y - this.touchY) <= TOUCH_PX) {
278
+ return;
279
+ }
280
+ this.byUser();
281
+ // The finger moving down scrolls the thread up.
282
+ if (y > this.touchY && this.following && !scrollsInside(target, this.view, true)) {
283
+ this.leave();
284
+ }
285
+ this.touchY = y;
286
+ }
287
+ hold() {
288
+ this.held = true;
289
+ this.byUser();
290
+ }
291
+ /** Let go: what came in meanwhile shows, if the view follows. */
292
+ release() {
293
+ if (!this.held) {
294
+ return;
295
+ }
296
+ this.held = false;
297
+ this.touchY = undefined;
298
+ if (this.following && this.heading === undefined && !this.chasing) {
299
+ this.toBottomNow();
300
+ }
301
+ }
302
+ clicked(target) {
303
+ const element = isElement(target) ? target.closest(TOGGLE) : null;
304
+ if (element) {
305
+ this.toggled = { element, offset: this.offsetOf(element), until: this.now() + TOGGLE_MS };
306
+ }
307
+ }
308
+ /** The thread or the view changed its size. */
309
+ resized() {
310
+ const { view } = this;
311
+ const height = view.clientHeight;
312
+ const shrunk = this.height - height;
313
+ this.height = height;
314
+ const sent = this.sent;
315
+ if (sent === null || sent === void 0 ? void 0 : sent.isConnected) {
316
+ const top = this.place(sent);
317
+ if (this.heading !== undefined && Math.abs(top - this.heading) >= 1) {
318
+ this.heading = top;
319
+ view.scrollTo({ top, behavior: calm() ? 'auto' : 'smooth' });
320
+ }
321
+ }
322
+ if (this.heading !== undefined) {
323
+ return;
324
+ }
325
+ const toggled = this.toggled;
326
+ if (toggled && toggled.until > this.now() && toggled.element.isConnected) {
327
+ this.moveTo(view.scrollTop + this.offsetOf(toggled.element) - toggled.offset);
328
+ // Opened past the bottom: the user reads it, the view no longer follows.
329
+ this.following = view.scrollHeight - view.scrollTop - view.clientHeight < 1 || (this.following && !this.past(toggled.element));
330
+ this.remember();
331
+ return;
332
+ }
333
+ this.toggled = undefined;
334
+ if (this.following) {
335
+ if (this.chasing) {
336
+ view.scrollTo({ top: view.scrollHeight - view.clientHeight, behavior: 'smooth' });
337
+ }
338
+ else if (!this.held) {
339
+ this.toBottomNow();
340
+ }
341
+ return;
342
+ }
343
+ // The row read where it was, the bottom of the view kept to the message box. From the row rather than the
344
+ // view: the browser may have pulled the view up meanwhile, the thread shorter than where it was.
345
+ const anchor = this.anchor;
346
+ this.moveTo(((anchor === null || anchor === void 0 ? void 0 : anchor.row.isConnected) ? anchor.row.offsetTop - anchor.offset : this.top) + shrunk);
347
+ this.remember();
348
+ }
349
+ /** Where the view goes for the message sent to be at its top, with the room under the thread for that. */
350
+ place(message) {
351
+ // offsetTop: from the thread; the transform of the message coming in does not count.
352
+ const { top, room } = frame_1.FrameUtil.anchor(message.offsetTop, this.view.clientHeight, this.thread.offsetHeight - this.room);
353
+ this.makeRoom(room);
354
+ return top;
355
+ }
356
+ makeRoom(room) {
357
+ if (room !== this.room) {
358
+ this.room = room;
359
+ this.thread.style.paddingBottom = room > 0 ? `${this.padding + room}px` : '';
360
+ }
361
+ }
362
+ arrive() {
363
+ this.heading = undefined;
364
+ this.following = true;
365
+ this.top = this.view.scrollTop;
366
+ }
367
+ /** The user moves the view: a smooth scroll on its way is theirs now, the message sent no longer holds the top. */
368
+ byUser() {
369
+ if (this.heading !== undefined) {
370
+ this.heading = undefined;
371
+ this.following = false;
372
+ }
373
+ this.chasing = false;
374
+ this.sent = undefined;
375
+ this.toggled = undefined;
376
+ }
377
+ /** The user moves the view up: it stops following before the scroll comes, which a follow would undo. */
378
+ leave() {
379
+ if (this.following) {
380
+ this.following = false;
381
+ this.remember();
382
+ }
383
+ }
384
+ toBottomNow() {
385
+ const { view } = this;
386
+ const bottom = view.scrollHeight - view.clientHeight;
387
+ if (bottom - view.scrollTop >= 1) {
388
+ view.scrollTop = bottom;
389
+ }
390
+ this.top = view.scrollTop;
391
+ this.anchor = undefined;
392
+ }
393
+ moveTo(top) {
394
+ const { view } = this;
395
+ const target = Math.max(0, Math.min(top, view.scrollHeight - view.clientHeight));
396
+ if (Math.abs(target - view.scrollTop) >= 1) {
397
+ view.scrollTop = target;
398
+ }
399
+ this.top = view.scrollTop;
400
+ }
401
+ /** The first row in the view, while it does not follow. */
402
+ remember() {
403
+ var _a, _b;
404
+ if (this.following) {
405
+ this.anchor = undefined;
406
+ return;
407
+ }
408
+ const rows = this.thread.children;
409
+ const top = this.view.scrollTop;
410
+ let low = 0;
411
+ let high = rows.length - 1;
412
+ while (low < high) {
413
+ const middle = (low + high) >> 1;
414
+ const row = rows[middle];
415
+ if (row.offsetTop + row.offsetHeight > top) {
416
+ high = middle;
417
+ }
418
+ else {
419
+ low = middle + 1;
420
+ }
421
+ }
422
+ const row = ((_b = (_a = rows[low]) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.scrollSkip) !== undefined && low + 1 < rows.length ? rows[low + 1] : rows[low];
423
+ this.anchor = row ? { row, offset: row.offsetTop - top } : undefined;
424
+ }
425
+ offsetOf(element) {
426
+ return element.getBoundingClientRect().top - this.view.getBoundingClientRect().top;
427
+ }
428
+ /** Whether what `element` opened goes on past the bottom of the view. */
429
+ past(element) {
430
+ var _a, _b;
431
+ const part = (_b = (_a = element.closest('details')) !== null && _a !== void 0 ? _a : element.parentElement) !== null && _b !== void 0 ? _b : element;
432
+ return part.getBoundingClientRect().bottom > this.view.getBoundingClientRect().top + this.view.clientHeight + 1;
433
+ }
434
+ }
435
+ exports.ConversationScroller = ConversationScroller;
436
+ ConversationScroller.views = new WeakMap();
437
+ /**
438
+ * The scrolling of a conversation (ConversationScroller), whose thread is the first child of the element of the
439
+ * returned ref. Opened, and when messages of the user go (a rewind), the view goes to the bottom.
440
+ *
441
+ * `asked`: how many messages of the user there are; the thread marks them with ASK_CLASS.
442
+ */
443
+ function useConversationScroll(asked, options = {}) {
444
+ const { sentTo = 'top', key } = options;
445
+ const ref = React.useRef(null);
446
+ const attached = React.useRef(undefined);
447
+ const before = React.useRef(undefined);
448
+ // After each render, the view may only now be there (a page that shows it once its data came).
449
+ React.useLayoutEffect(() => {
450
+ var _a, _b;
451
+ const view = ref.current;
452
+ const thread = view === null || view === void 0 ? void 0 : view.firstElementChild;
453
+ if (((_a = attached.current) === null || _a === void 0 ? void 0 : _a.view) === view) {
454
+ return;
455
+ }
456
+ (_b = attached.current) === null || _b === void 0 ? void 0 : _b.detach();
457
+ attached.current = undefined;
458
+ if (view && thread instanceof HTMLElement) {
459
+ const scroller = new ConversationScroller(view, thread);
460
+ attached.current = { view, scroller, detach: scroller.attach(view, thread) };
461
+ }
462
+ });
463
+ React.useLayoutEffect(() => () => {
464
+ var _a;
465
+ (_a = attached.current) === null || _a === void 0 ? void 0 : _a.detach();
466
+ attached.current = undefined;
141
467
  }, []);
142
468
  React.useLayoutEffect(() => {
143
- const element = ref.current;
144
- const content = element === null || element === void 0 ? void 0 : element.firstElementChild;
145
- // One more: sent now. More at once is the conversation loaded again, which opens at its bottom.
146
- const sent = before.current !== undefined && asked === before.current + 1;
147
- before.current = asked;
148
- if (!element || !content) {
469
+ var _a, _b;
470
+ const previous = before.current;
471
+ before.current = { asked, key };
472
+ const current = (_a = attached.current) === null || _a === void 0 ? void 0 : _a.scroller;
473
+ const thread = (_b = ref.current) === null || _b === void 0 ? void 0 : _b.firstElementChild;
474
+ if (!current || !thread) {
149
475
  return;
150
476
  }
151
- const asks = sent ? content.getElementsByClassName(exports.ASK_CLASS) : undefined;
477
+ // One more: sent now. More at once is the conversation loaded again, which opens at its bottom.
478
+ const sent = previous !== undefined && previous.key === key && asked === previous.asked + 1;
479
+ const asks = sent && sentTo === 'top' ? thread.getElementsByClassName(exports.ASK_CLASS) : undefined;
152
480
  const message = asks === null || asks === void 0 ? void 0 : asks[asks.length - 1];
153
- anchored.current = message;
154
- touched.current = false;
155
- if (!message) {
156
- content.style.minHeight = '';
157
- heading.current = undefined;
158
- stuck.current = true;
159
- element.scrollTo({ top: element.scrollHeight });
160
- return;
481
+ if (message) {
482
+ current.send(message);
161
483
  }
162
- // offsetTop: from the thread, which is positioned; the transform of the message coming in does not count.
163
- const { top, minHeight } = frame_1.FrameUtil.anchor(message.offsetTop, element.clientHeight);
164
- content.style.minHeight = `${minHeight}px`;
165
- stuck.current = false;
166
- if (Math.abs(element.scrollTop - top) < 1) {
167
- stuck.current = true;
168
- return;
484
+ else {
485
+ current.reset();
169
486
  }
170
- heading.current = top;
171
- element.scrollTo({ top, behavior: calm() ? 'auto' : 'smooth' });
172
- }, [asked]);
487
+ }, [asked, key, sentTo]);
173
488
  return ref;
174
489
  }
175
490
  /** Away from the bottom by more than half of the view: the button back to the latest shows. */
@@ -204,7 +519,13 @@ function useAwayFromBottom(ref) {
204
519
  }, [ref]);
205
520
  const back = React.useCallback(() => {
206
521
  const element = ref.current;
207
- element === null || element === void 0 ? void 0 : element.scrollTo({ top: element.scrollHeight, behavior: calm() ? 'auto' : 'smooth' });
522
+ const scroller = element ? ConversationScroller.of(element) : undefined;
523
+ if (scroller) {
524
+ scroller.toBottom();
525
+ }
526
+ else {
527
+ element === null || element === void 0 ? void 0 : element.scrollTo({ top: element.scrollHeight, behavior: calm() ? 'auto' : 'smooth' });
528
+ }
208
529
  }, [ref]);
209
530
  return [away, back];
210
531
  }
@@ -37,16 +37,16 @@ exports.DINO_GREEN = void 0;
37
37
  exports.Dino = Dino;
38
38
  exports.dinoFavicon = dinoFavicon;
39
39
  const React = __importStar(require("react"));
40
- const dino_species_1 = require("../avatar/dino-species");
40
+ const dino_shape_1 = require("../avatar/dino-shape");
41
41
  exports.DINO_GREEN = '#10B981';
42
42
  /** Cell's dinosaur as assets/logo.svg draws it: the mark of ta. */
43
43
  function Dino({ size = 32 }) {
44
44
  return (React.createElement("svg", { width: size, height: size, viewBox: "0 0 256 256", "aria-label": "ta", role: "img" },
45
- React.createElement("path", { d: dino_species_1.LOGO_PATH, fill: exports.DINO_GREEN, fillRule: "evenodd" })));
45
+ React.createElement("path", { d: dino_shape_1.LOGO_PATH, fill: exports.DINO_GREEN, fillRule: "evenodd" })));
46
46
  }
47
47
  /** The same picture as the icon of the tab. */
48
48
  function dinoFavicon() {
49
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path d="${dino_species_1.LOGO_PATH}" fill="${exports.DINO_GREEN}" fill-rule="evenodd"/></svg>`;
49
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><path d="${dino_shape_1.LOGO_PATH}" fill="${exports.DINO_GREEN}" fill-rule="evenodd"/></svg>`;
50
50
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
51
51
  }
52
52
  //# sourceMappingURL=dino.js.map
@@ -25,7 +25,8 @@ export declare namespace EarlierUtil {
25
25
  export declare function useAsked(state: SessionState, isAsk?: (message: SessionMessage) => boolean): number;
26
26
  /**
27
27
  * The earlier messages of a long conversation, loaded as the view of `ref` nears the top of its thread
28
- * (only its latest came when it opened): what the view shows stays where it is as they come in front.
28
+ * (only its latest came when it opened). What the view shows stays where it is as they come in front: the
29
+ * scrolling of the conversation (ConversationScroller) keeps the row read in its place.
29
30
  */
30
31
  export declare function useEarlierMessages(store: SessionStore, state: SessionState, ref: React.RefObject<HTMLDivElement | null>): void;
31
32
  //# sourceMappingURL=earlier-messages.d.ts.map
@@ -77,25 +77,10 @@ function useAsked(state, isAsk = isUser) {
77
77
  }
78
78
  /**
79
79
  * The earlier messages of a long conversation, loaded as the view of `ref` nears the top of its thread
80
- * (only its latest came when it opened): what the view shows stays where it is as they come in front.
80
+ * (only its latest came when it opened). What the view shows stays where it is as they come in front: the
81
+ * scrolling of the conversation (ConversationScroller) keeps the row read in its place.
81
82
  */
82
83
  function useEarlierMessages(store, state, ref) {
83
- const shown = React.useRef({ start: state.start, first: state.messages[0] });
84
- const before = React.useRef(undefined);
85
- // Read before the commit: the messages in front are not in the page yet.
86
- const element = ref.current;
87
- if (element && !before.current && EarlierUtil.prepended(state.messages, state.start, shown.current) !== undefined) {
88
- before.current = { height: element.scrollHeight, top: element.scrollTop };
89
- }
90
- React.useLayoutEffect(() => {
91
- const element = ref.current;
92
- const at = before.current;
93
- before.current = undefined;
94
- if (element && at && EarlierUtil.prepended(state.messages, state.start, shown.current) !== undefined) {
95
- element.scrollTop = at.top + element.scrollHeight - at.height;
96
- }
97
- shown.current = { start: state.start, first: state.messages[0] };
98
- }, [state.messages, state.start, ref]);
99
84
  const more = state.start > 0;
100
85
  // biome-ignore lint/correctness/useExhaustiveDependencies: checks again once earlier messages came
101
86
  React.useEffect(() => {