@celljs/ta-web 4.9.1 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/README.en.md +4 -3
  2. package/README.md +4 -3
  3. package/esm/browser/assistant/assistant-chat-list.js +8 -2
  4. package/esm/browser/assistant/assistant-extension.d.ts +8 -1
  5. package/esm/browser/assistant/assistant-extension.js +20 -0
  6. package/esm/browser/assistant/assistant-protocol.d.ts +3 -1
  7. package/esm/browser/assistant/assistant-task-util.d.ts +2 -0
  8. package/esm/browser/assistant/assistant-task-util.js +5 -3
  9. package/esm/browser/assistant/assistant-view.js +81 -56
  10. package/esm/browser/assistant/assistant.d.ts +10 -1
  11. package/esm/browser/assistant/assistant.js +44 -5
  12. package/esm/browser/chat/chat-packages.d.ts +39 -0
  13. package/esm/browser/chat/chat-packages.js +70 -0
  14. package/esm/browser/chat/chat-protocol.d.ts +23 -1
  15. package/esm/browser/chat/chat-stores.d.ts +59 -0
  16. package/esm/browser/chat/chat-stores.js +121 -0
  17. package/esm/browser/chat/chat-util.d.ts +17 -0
  18. package/esm/browser/chat/chat-util.js +61 -0
  19. package/esm/browser/chat/chat-view.js +33 -12
  20. package/esm/browser/chat/chat.d.ts +31 -39
  21. package/esm/browser/chat/chat.js +226 -175
  22. package/esm/browser/components/app-nav.d.ts +6 -3
  23. package/esm/browser/components/app-nav.js +19 -10
  24. package/esm/browser/components/app-shell-hooks.d.ts +2 -2
  25. package/esm/browser/components/app-shell-hooks.js +7 -3
  26. package/esm/browser/components/app-view.js +75 -21
  27. package/esm/browser/components/chat-list.d.ts +20 -2
  28. package/esm/browser/components/chat-list.js +138 -22
  29. package/esm/browser/components/composer-box.d.ts +5 -5
  30. package/esm/browser/components/composer-box.js +111 -4
  31. package/esm/browser/components/composer.d.ts +7 -0
  32. package/esm/browser/components/composer.js +5 -4
  33. package/esm/browser/components/connection-bar.js +50 -17
  34. package/esm/browser/components/context-menu.d.ts +30 -4
  35. package/esm/browser/components/context-menu.js +199 -37
  36. package/esm/browser/components/conversation-scroll.d.ts +129 -6
  37. package/esm/browser/components/conversation-scroll.js +429 -109
  38. package/esm/browser/components/earlier-messages.d.ts +2 -1
  39. package/esm/browser/components/earlier-messages.js +2 -17
  40. package/esm/browser/components/editor-area.d.ts +3 -1
  41. package/esm/browser/components/editor-area.js +6 -5
  42. package/esm/browser/components/empty-pictures.d.ts +0 -2
  43. package/esm/browser/components/empty-pictures.js +0 -16
  44. package/esm/browser/components/folder-picker.d.ts +5 -2
  45. package/esm/browser/components/folder-picker.js +26 -8
  46. package/esm/browser/components/held-talk.d.ts +28 -0
  47. package/esm/browser/components/held-talk.js +76 -0
  48. package/esm/browser/components/host-view.d.ts +1 -1
  49. package/esm/browser/components/icon.d.ts +2 -2
  50. package/esm/browser/components/icon.js +5 -6
  51. package/esm/browser/components/image-viewer.d.ts +124 -0
  52. package/esm/browser/components/image-viewer.js +397 -0
  53. package/esm/browser/components/lightbox.d.ts +11 -0
  54. package/esm/browser/components/lightbox.js +24 -0
  55. package/esm/browser/components/markdown.d.ts +6 -2
  56. package/esm/browser/components/markdown.js +24 -10
  57. package/esm/browser/components/media.js +1 -10
  58. package/esm/browser/components/message-footer.d.ts +16 -2
  59. package/esm/browser/components/message-footer.js +29 -12
  60. package/esm/browser/components/message-list.d.ts +24 -3
  61. package/esm/browser/components/message-list.js +149 -20
  62. package/esm/browser/components/message-menu.d.ts +3 -1
  63. package/esm/browser/components/message-menu.js +18 -3
  64. package/esm/browser/components/nav-places.d.ts +16 -1
  65. package/esm/browser/components/nav-places.js +12 -3
  66. package/esm/browser/components/phone-shell.d.ts +4 -1
  67. package/esm/browser/components/phone-shell.js +3 -1
  68. package/esm/browser/components/run-status.js +3 -3
  69. package/esm/browser/components/session-settings.d.ts +6 -0
  70. package/esm/browser/components/session-settings.js +14 -1
  71. package/esm/browser/components/session-view.js +8 -4
  72. package/esm/browser/components/settings-parts.d.ts +2 -2
  73. package/esm/browser/components/settings-parts.js +24 -1
  74. package/esm/browser/components/swipe-row.d.ts +2 -2
  75. package/esm/browser/components/swipe-row.js +7 -3
  76. package/esm/browser/components/tool-view.js +14 -12
  77. package/esm/browser/components/voice-button.d.ts +1 -1
  78. package/esm/browser/components/voice-button.js +1 -1
  79. package/esm/browser/components/voice-talk.d.ts +43 -0
  80. package/esm/browser/components/voice-talk.js +222 -0
  81. package/esm/browser/device/device.d.ts +3 -0
  82. package/esm/browser/device/device.js +11 -1
  83. package/esm/browser/device/hold.d.ts +42 -0
  84. package/esm/browser/device/hold.js +136 -0
  85. package/esm/browser/device/launch-screen.d.ts +1 -1
  86. package/esm/browser/device/launch-screen.js +1 -1
  87. package/esm/browser/device/long-press.d.ts +2 -0
  88. package/esm/browser/device/long-press.js +16 -1
  89. package/esm/browser/device/pull-down.d.ts +4 -2
  90. package/esm/browser/device/pull-down.js +64 -76
  91. package/esm/browser/device/row-swipe.d.ts +35 -10
  92. package/esm/browser/device/row-swipe.js +149 -71
  93. package/esm/browser/device/shake-undo.d.ts +16 -0
  94. package/esm/browser/device/shake-undo.js +59 -0
  95. package/esm/browser/device/sheet-swipe.d.ts +118 -18
  96. package/esm/browser/device/sheet-swipe.js +406 -107
  97. package/esm/browser/extension/web-extension-api.d.ts +97 -1
  98. package/esm/browser/extension/web-extension-code.d.ts +6 -0
  99. package/esm/browser/extension/web-extension-code.js +24 -0
  100. package/esm/browser/extension/web-extension-protocol.d.ts +23 -1
  101. package/esm/browser/extension/web-extension-protocol.js +8 -0
  102. package/esm/browser/extension/web-extensions.d.ts +14 -1
  103. package/esm/browser/extension/web-extensions.js +122 -23
  104. package/esm/browser/files/files-protocol.d.ts +25 -0
  105. package/esm/browser/files/files-protocol.js +2 -0
  106. package/esm/browser/files/files.d.ts +35 -0
  107. package/esm/browser/files/files.js +119 -0
  108. package/esm/browser/i18n/locales.d.ts +24 -2
  109. package/esm/browser/i18n/messages.d.ts +23 -1
  110. package/esm/browser/i18n/messages.js +48 -4
  111. package/esm/browser/index.d.ts +6 -0
  112. package/esm/browser/index.js +6 -0
  113. package/esm/browser/notices/notices-protocol.d.ts +9 -1
  114. package/esm/browser/notices/notices.d.ts +2 -0
  115. package/esm/browser/notices/notices.js +20 -10
  116. package/esm/browser/offline/device-values.d.ts +55 -0
  117. package/esm/browser/offline/device-values.js +142 -0
  118. package/esm/browser/offline/kept-chats-protocol.d.ts +17 -0
  119. package/esm/browser/offline/kept-chats-protocol.js +2 -0
  120. package/esm/browser/offline/kept-chats.d.ts +47 -0
  121. package/esm/browser/offline/kept-chats.js +146 -0
  122. package/esm/browser/offline/offline-reads.d.ts +44 -0
  123. package/esm/browser/offline/offline-reads.js +107 -0
  124. package/esm/browser/settings/settings-protocol.d.ts +2 -0
  125. package/esm/browser/settings/settings-protocol.js +2 -0
  126. package/esm/browser/style/conversation.d.ts +1 -1
  127. package/esm/browser/style/conversation.js +57 -17
  128. package/esm/browser/style/device.js +27 -4
  129. package/esm/browser/style/layout.d.ts +1 -1
  130. package/esm/browser/style/layout.js +67 -15
  131. package/esm/browser/style/pages.d.ts +1 -1
  132. package/esm/browser/style/pages.js +2 -1
  133. package/esm/browser/style/shell.d.ts +1 -1
  134. package/esm/browser/style/shell.js +46 -3
  135. package/esm/browser/util/frame.d.ts +5 -4
  136. package/esm/browser/util/frame.js +5 -4
  137. package/esm/browser/util/markdown.d.ts +18 -1
  138. package/esm/browser/util/markdown.js +119 -5
  139. package/esm/browser/util/process.d.ts +21 -0
  140. package/esm/browser/util/process.js +45 -1
  141. package/esm/browser/util/voice.d.ts +5 -2
  142. package/esm/browser/util/voice.js +6 -3
  143. package/esm/browser/util/zoom.d.ts +46 -0
  144. package/esm/browser/util/zoom.js +96 -0
  145. package/esm/browser/workbench-calls.d.ts +59 -0
  146. package/esm/browser/workbench-calls.js +141 -0
  147. package/esm/browser/workbench-protocol.d.ts +5 -1
  148. package/esm/browser/workbench-util.d.ts +7 -0
  149. package/esm/browser/workbench-util.js +9 -2
  150. package/esm/browser/workbench.d.ts +14 -5
  151. package/esm/browser/workbench.js +51 -31
  152. package/lib/browser/assistant/assistant-chat-list.js +8 -2
  153. package/lib/browser/assistant/assistant-extension.d.ts +8 -1
  154. package/lib/browser/assistant/assistant-extension.js +20 -0
  155. package/lib/browser/assistant/assistant-protocol.d.ts +3 -1
  156. package/lib/browser/assistant/assistant-task-util.d.ts +2 -0
  157. package/lib/browser/assistant/assistant-task-util.js +5 -3
  158. package/lib/browser/assistant/assistant-view.js +78 -53
  159. package/lib/browser/assistant/assistant.d.ts +10 -1
  160. package/lib/browser/assistant/assistant.js +44 -5
  161. package/lib/browser/chat/chat-packages.d.ts +40 -0
  162. package/lib/browser/chat/chat-packages.js +74 -0
  163. package/lib/browser/chat/chat-protocol.d.ts +23 -1
  164. package/lib/browser/chat/chat-stores.d.ts +60 -0
  165. package/lib/browser/chat/chat-stores.js +125 -0
  166. package/lib/browser/chat/chat-util.d.ts +18 -0
  167. package/lib/browser/chat/chat-util.js +64 -0
  168. package/lib/browser/chat/chat-view.js +33 -12
  169. package/lib/browser/chat/chat.d.ts +31 -39
  170. package/lib/browser/chat/chat.js +227 -176
  171. package/lib/browser/components/app-nav.d.ts +6 -3
  172. package/lib/browser/components/app-nav.js +17 -8
  173. package/lib/browser/components/app-shell-hooks.d.ts +2 -2
  174. package/lib/browser/components/app-shell-hooks.js +7 -3
  175. package/lib/browser/components/app-view.js +74 -20
  176. package/lib/browser/components/chat-list.d.ts +20 -2
  177. package/lib/browser/components/chat-list.js +137 -21
  178. package/lib/browser/components/composer-box.d.ts +5 -5
  179. package/lib/browser/components/composer-box.js +111 -4
  180. package/lib/browser/components/composer.d.ts +7 -0
  181. package/lib/browser/components/composer.js +5 -4
  182. package/lib/browser/components/connection-bar.js +48 -15
  183. package/lib/browser/components/context-menu.d.ts +30 -4
  184. package/lib/browser/components/context-menu.js +198 -36
  185. package/lib/browser/components/conversation-scroll.d.ts +129 -6
  186. package/lib/browser/components/conversation-scroll.js +431 -110
  187. package/lib/browser/components/earlier-messages.d.ts +2 -1
  188. package/lib/browser/components/earlier-messages.js +2 -17
  189. package/lib/browser/components/editor-area.d.ts +3 -1
  190. package/lib/browser/components/editor-area.js +5 -4
  191. package/lib/browser/components/empty-pictures.d.ts +0 -2
  192. package/lib/browser/components/empty-pictures.js +0 -17
  193. package/lib/browser/components/folder-picker.d.ts +5 -2
  194. package/lib/browser/components/folder-picker.js +26 -8
  195. package/lib/browser/components/held-talk.d.ts +29 -0
  196. package/lib/browser/components/held-talk.js +79 -0
  197. package/lib/browser/components/host-view.d.ts +1 -1
  198. package/lib/browser/components/icon.d.ts +2 -2
  199. package/lib/browser/components/icon.js +7 -6
  200. package/lib/browser/components/image-viewer.d.ts +125 -0
  201. package/lib/browser/components/image-viewer.js +435 -0
  202. package/lib/browser/components/lightbox.d.ts +12 -0
  203. package/lib/browser/components/lightbox.js +60 -0
  204. package/lib/browser/components/markdown.d.ts +6 -2
  205. package/lib/browser/components/markdown.js +24 -10
  206. package/lib/browser/components/media.js +2 -11
  207. package/lib/browser/components/message-footer.d.ts +16 -2
  208. package/lib/browser/components/message-footer.js +31 -12
  209. package/lib/browser/components/message-list.d.ts +24 -3
  210. package/lib/browser/components/message-list.js +146 -16
  211. package/lib/browser/components/message-menu.d.ts +3 -1
  212. package/lib/browser/components/message-menu.js +17 -2
  213. package/lib/browser/components/nav-places.d.ts +16 -1
  214. package/lib/browser/components/nav-places.js +13 -3
  215. package/lib/browser/components/phone-shell.d.ts +4 -1
  216. package/lib/browser/components/phone-shell.js +3 -1
  217. package/lib/browser/components/run-status.js +3 -3
  218. package/lib/browser/components/session-settings.d.ts +6 -0
  219. package/lib/browser/components/session-settings.js +14 -1
  220. package/lib/browser/components/session-view.js +7 -3
  221. package/lib/browser/components/settings-parts.d.ts +2 -2
  222. package/lib/browser/components/settings-parts.js +24 -1
  223. package/lib/browser/components/swipe-row.d.ts +2 -2
  224. package/lib/browser/components/swipe-row.js +7 -3
  225. package/lib/browser/components/tool-view.js +14 -12
  226. package/lib/browser/components/voice-button.d.ts +1 -1
  227. package/lib/browser/components/voice-button.js +1 -1
  228. package/lib/browser/components/voice-talk.d.ts +44 -0
  229. package/lib/browser/components/voice-talk.js +260 -0
  230. package/lib/browser/device/device.d.ts +3 -0
  231. package/lib/browser/device/device.js +11 -1
  232. package/lib/browser/device/hold.d.ts +43 -0
  233. package/lib/browser/device/hold.js +173 -0
  234. package/lib/browser/device/launch-screen.d.ts +1 -1
  235. package/lib/browser/device/launch-screen.js +1 -1
  236. package/lib/browser/device/long-press.d.ts +2 -0
  237. package/lib/browser/device/long-press.js +16 -1
  238. package/lib/browser/device/pull-down.d.ts +4 -2
  239. package/lib/browser/device/pull-down.js +63 -75
  240. package/lib/browser/device/row-swipe.d.ts +35 -10
  241. package/lib/browser/device/row-swipe.js +148 -70
  242. package/lib/browser/device/shake-undo.d.ts +17 -0
  243. package/lib/browser/device/shake-undo.js +63 -0
  244. package/lib/browser/device/sheet-swipe.d.ts +118 -18
  245. package/lib/browser/device/sheet-swipe.js +410 -108
  246. package/lib/browser/extension/web-extension-api.d.ts +97 -1
  247. package/lib/browser/extension/web-extension-code.d.ts +6 -0
  248. package/lib/browser/extension/web-extension-code.js +24 -0
  249. package/lib/browser/extension/web-extension-protocol.d.ts +23 -1
  250. package/lib/browser/extension/web-extension-protocol.js +9 -1
  251. package/lib/browser/extension/web-extensions.d.ts +14 -1
  252. package/lib/browser/extension/web-extensions.js +120 -21
  253. package/lib/browser/files/files-protocol.d.ts +26 -0
  254. package/lib/browser/files/files-protocol.js +5 -0
  255. package/lib/browser/files/files.d.ts +36 -0
  256. package/lib/browser/files/files.js +122 -0
  257. package/lib/browser/i18n/locales.d.ts +24 -2
  258. package/lib/browser/i18n/messages.d.ts +23 -1
  259. package/lib/browser/i18n/messages.js +48 -4
  260. package/lib/browser/index.d.ts +6 -0
  261. package/lib/browser/index.js +6 -0
  262. package/lib/browser/notices/notices-protocol.d.ts +9 -1
  263. package/lib/browser/notices/notices.d.ts +2 -0
  264. package/lib/browser/notices/notices.js +20 -10
  265. package/lib/browser/offline/device-values.d.ts +56 -0
  266. package/lib/browser/offline/device-values.js +148 -0
  267. package/lib/browser/offline/kept-chats-protocol.d.ts +18 -0
  268. package/lib/browser/offline/kept-chats-protocol.js +5 -0
  269. package/lib/browser/offline/kept-chats.d.ts +48 -0
  270. package/lib/browser/offline/kept-chats.js +149 -0
  271. package/lib/browser/offline/offline-reads.d.ts +45 -0
  272. package/lib/browser/offline/offline-reads.js +111 -0
  273. package/lib/browser/settings/settings-protocol.d.ts +2 -0
  274. package/lib/browser/settings/settings-protocol.js +2 -0
  275. package/lib/browser/style/conversation.d.ts +1 -1
  276. package/lib/browser/style/conversation.js +57 -17
  277. package/lib/browser/style/device.js +27 -4
  278. package/lib/browser/style/layout.d.ts +1 -1
  279. package/lib/browser/style/layout.js +67 -15
  280. package/lib/browser/style/pages.d.ts +1 -1
  281. package/lib/browser/style/pages.js +2 -1
  282. package/lib/browser/style/shell.d.ts +1 -1
  283. package/lib/browser/style/shell.js +46 -3
  284. package/lib/browser/util/frame.d.ts +5 -4
  285. package/lib/browser/util/frame.js +5 -4
  286. package/lib/browser/util/markdown.d.ts +18 -1
  287. package/lib/browser/util/markdown.js +119 -5
  288. package/lib/browser/util/process.d.ts +21 -0
  289. package/lib/browser/util/process.js +46 -2
  290. package/lib/browser/util/voice.d.ts +5 -2
  291. package/lib/browser/util/voice.js +6 -3
  292. package/lib/browser/util/zoom.d.ts +47 -0
  293. package/lib/browser/util/zoom.js +99 -0
  294. package/lib/browser/workbench-calls.d.ts +60 -0
  295. package/lib/browser/workbench-calls.js +145 -0
  296. package/lib/browser/workbench-protocol.d.ts +5 -1
  297. package/lib/browser/workbench-util.d.ts +7 -0
  298. package/lib/browser/workbench-util.js +10 -3
  299. package/lib/browser/workbench.d.ts +14 -5
  300. package/lib/browser/workbench.js +51 -31
  301. package/package.json +10 -10
  302. package/public/launch.svg +46 -42
@@ -0,0 +1,136 @@
1
+ import * as React from 'react';
2
+ import { nativePlugin } from './device.js';
3
+ import { LongPressUtil } from './long-press.js';
4
+ /**
5
+ * Something done while an element is held. A press that moves first scrolls, and one let go before PRESS_MS
6
+ * starts nothing, so that a tap stays a tap. Once held, the finger is the hold's until it lets go: the page does
7
+ * not scroll under it, the system's menu and selection do not come, the click of the finger let go is not a tap
8
+ * of what was under it, and the hold outlives the element (a tab bar that a page slides over).
9
+ */
10
+ export function useHeld() {
11
+ const current = React.useRef(undefined);
12
+ // Gone before it held, the press is nothing; once held, it ends when the finger lets go.
13
+ React.useEffect(() => () => {
14
+ const press = current.current;
15
+ if (press && !press.held) {
16
+ clearTimeout(press.timer);
17
+ press.off();
18
+ current.current = undefined;
19
+ }
20
+ }, []);
21
+ return React.useCallback((hold) => {
22
+ if (!hold) {
23
+ return {};
24
+ }
25
+ return {
26
+ 'data-held': '',
27
+ onPointerDown: event => {
28
+ if (current.current || !event.isPrimary || event.button !== 0 || (hold.accepts && !hold.accepts(event))) {
29
+ return;
30
+ }
31
+ const from = { x: event.clientX, y: event.clientY };
32
+ const finish = (how) => {
33
+ if (current.current !== press) {
34
+ return;
35
+ }
36
+ current.current = undefined;
37
+ clearTimeout(press.timer);
38
+ press.off();
39
+ if (!press.held || how === 'none') {
40
+ return;
41
+ }
42
+ HeldUtil.swallowClick();
43
+ if (how === 'end') {
44
+ hold.end();
45
+ }
46
+ else {
47
+ hold.cancel();
48
+ }
49
+ };
50
+ const onUp = () => finish('end');
51
+ const onCancel = () => finish('cancel');
52
+ const onMove = (moved) => {
53
+ var _a;
54
+ if (press.held) {
55
+ (_a = hold.move) === null || _a === void 0 ? void 0 : _a.call(hold, moved.clientX, moved.clientY);
56
+ }
57
+ else if (LongPressUtil.moved(from, moved)) {
58
+ finish('none');
59
+ }
60
+ };
61
+ // Held, the finger drags nothing: no scroll, which would take it from the hold (pointercancel).
62
+ const onTouchMove = (touch) => press.held && touch.cancelable && touch.preventDefault();
63
+ const onSelect = (select) => press.held && select.preventDefault();
64
+ const press = {
65
+ hold,
66
+ held: false,
67
+ timer: setTimeout(() => {
68
+ var _a, _b;
69
+ press.held = true;
70
+ (_a = document.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
71
+ hold.start();
72
+ (_b = hold.move) === null || _b === void 0 ? void 0 : _b.call(hold, from.x, from.y);
73
+ }, LongPressUtil.PRESS_MS),
74
+ off: () => {
75
+ document.removeEventListener('pointerup', onUp);
76
+ document.removeEventListener('pointercancel', onCancel);
77
+ document.removeEventListener('pointermove', onMove);
78
+ document.removeEventListener('touchmove', onTouchMove);
79
+ document.removeEventListener('selectstart', onSelect, true);
80
+ },
81
+ };
82
+ current.current = press;
83
+ document.addEventListener('pointerup', onUp);
84
+ document.addEventListener('pointercancel', onCancel);
85
+ document.addEventListener('pointermove', onMove);
86
+ document.addEventListener('touchmove', onTouchMove, { passive: false });
87
+ document.addEventListener('selectstart', onSelect, true);
88
+ },
89
+ // The long press of a finger (the system's, or startLongPress's) is the hold's: no menu. Taken, it is
90
+ // also what gives the light tap of the haptic engine in the app. A right click is the browser's.
91
+ onContextMenu: event => {
92
+ if (current.current) {
93
+ event.preventDefault();
94
+ }
95
+ },
96
+ };
97
+ }, []);
98
+ }
99
+ export var HeldUtil;
100
+ (function (HeldUtil) {
101
+ /** A light tap of the haptic engine as a held finger comes onto something (取消, 编辑): the app's, or a phone's. */
102
+ function tick() {
103
+ var _a, _b;
104
+ const haptics = nativePlugin('Haptics');
105
+ if (haptics) {
106
+ haptics('impact', { style: 'LIGHT' }).catch(() => undefined);
107
+ }
108
+ else {
109
+ (_b = (_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.vibrate) === null || _b === void 0 ? void 0 : _b.call(_a, 8);
110
+ }
111
+ }
112
+ HeldUtil.tick = tick;
113
+ /**
114
+ * The click that follows a finger let go after a hold: not a tap of what was under it. A browser that sends
115
+ * none (a long press is no tap to it) leaves the next press its own.
116
+ */
117
+ function swallowClick() {
118
+ const until = Date.now() + LongPressUtil.CLICK_GUARD_MS;
119
+ const off = () => {
120
+ document.removeEventListener('click', swallow, true);
121
+ document.removeEventListener('pointerdown', off, true);
122
+ };
123
+ const swallow = (event) => {
124
+ off();
125
+ if (Date.now() < until) {
126
+ event.preventDefault();
127
+ event.stopPropagation();
128
+ }
129
+ };
130
+ document.addEventListener('click', swallow, true);
131
+ document.addEventListener('pointerdown', off, true);
132
+ setTimeout(off, LongPressUtil.CLICK_GUARD_MS);
133
+ }
134
+ HeldUtil.swallowClick = swallowClick;
135
+ })(HeldUtil || (HeldUtil = {}));
136
+ //# sourceMappingURL=hold.js.map
@@ -17,7 +17,7 @@ export interface LaunchEnvironment {
17
17
  */
18
18
  export declare class LaunchScreen {
19
19
  protected readonly env: LaunchEnvironment;
20
- static readonly MAX = 3000;
20
+ static readonly MAX = 2000;
21
21
  static readonly FADE = 320;
22
22
  protected done: boolean;
23
23
  protected stops: (() => void)[];
@@ -43,7 +43,7 @@ export class LaunchScreen {
43
43
  this.env.later(() => element.remove(), LaunchScreen.FADE);
44
44
  }
45
45
  }
46
- LaunchScreen.MAX = 3000;
46
+ LaunchScreen.MAX = 2000;
47
47
  LaunchScreen.FADE = 320;
48
48
  export var LaunchScreenUtil;
49
49
  (function (LaunchScreenUtil) {
@@ -11,6 +11,8 @@ export declare namespace LongPressUtil {
11
11
  const MOVE_PX = 10;
12
12
  /** After a menu opened, the click of the finger let go is not a tap of what was under it. */
13
13
  const CLICK_GUARD_MS = 800;
14
+ /** What the finger of a long press that opened a menu pressed, while it is still down. */
15
+ function held(): Element | undefined;
14
16
  function moved(from: {
15
17
  x: number;
16
18
  y: number;
@@ -1,3 +1,5 @@
1
+ /** What a long press that opened a menu pressed, while the finger is still down: it may slide onto an entry (ContextMenuUtil.attach). */
2
+ let holding;
1
3
  /**
2
4
  * A long press as the right click of a finger: what a right click opens (the menus of tabs, files, chats,
3
5
  * messages) opens under a held finger too, as in the apps of a phone. iOS fires no `contextmenu` on a long
@@ -11,6 +13,11 @@ export var LongPressUtil;
11
13
  LongPressUtil.MOVE_PX = 10;
12
14
  /** After a menu opened, the click of the finger let go is not a tap of what was under it. */
13
15
  LongPressUtil.CLICK_GUARD_MS = 800;
16
+ /** What the finger of a long press that opened a menu pressed, while it is still down. */
17
+ function held() {
18
+ return holding;
19
+ }
20
+ LongPressUtil.held = held;
14
21
  function moved(from, to) {
15
22
  return Math.hypot(to.x - from.x, to.y - from.y) > LongPressUtil.MOVE_PX;
16
23
  }
@@ -37,6 +44,7 @@ export function startLongPress(doc, native) {
37
44
  const end = () => {
38
45
  var _a;
39
46
  cancel();
47
+ holding = undefined;
40
48
  if (taken) {
41
49
  taken = false;
42
50
  (_a = doc.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
@@ -61,6 +69,8 @@ export function startLongPress(doc, native) {
61
69
  return;
62
70
  }
63
71
  sent = true;
72
+ // Before the menu renders, which may be before dispatchEvent returns.
73
+ holding = current.target;
64
74
  const event = new MouseEvent('contextmenu', { bubbles: true, cancelable: true, composed: true, clientX: current.x, clientY: current.y, button: 2 });
65
75
  current.target.dispatchEvent(event);
66
76
  if (event.defaultPrevented) {
@@ -70,11 +80,15 @@ export function startLongPress(doc, native) {
70
80
  (_a = doc.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
71
81
  native === null || native === void 0 ? void 0 : native('Haptics', 'impact', { style: 'LIGHT' }).catch(() => undefined);
72
82
  }
83
+ else {
84
+ holding = undefined;
85
+ }
73
86
  };
74
87
  const onStart = (event) => {
75
88
  cancel();
76
89
  sent = false;
77
90
  taken = false;
91
+ holding = undefined;
78
92
  const touch = event.touches[0];
79
93
  const target = event.target instanceof Element ? event.target : null;
80
94
  if (event.touches.length !== 1 || !touch || !target || LongPressUtil.native(target)) {
@@ -103,7 +117,8 @@ export function startLongPress(doc, native) {
103
117
  }
104
118
  };
105
119
  const onClick = (event) => {
106
- if (Date.now() < guardUntil) {
120
+ // The click of the finger let go; not an entry the finger slid onto, which the menu clicks.
121
+ if (event.isTrusted && Date.now() < guardUntil) {
107
122
  guardUntil = 0;
108
123
  event.preventDefault();
109
124
  event.stopImmediatePropagation();
@@ -40,7 +40,9 @@ export interface PullDownOptions {
40
40
  }
41
41
  /**
42
42
  * Lets a finger pull the launcher down over the first tab while `enabled`. As useSheetSwipe: transforms and
43
- * opacities only, and the listener that may hold a move back is there only for a touch that may be a pull. A
44
- * pull down is decided on the first move (iOS lets a scroll that started go on), only at the top of the list.
43
+ * opacities only, the listener that may hold a move back there only for a touch that may be a pull, the finger
44
+ * followed on what it touched (SwipeFinger), and let go it slides on at once as on a spring (SwipeSettle), the
45
+ * state following. A pull down is decided on the first move (iOS lets a scroll that started go on), only at
46
+ * the top of the list.
45
47
  */
46
48
  export declare function usePullDown(options: PullDownOptions): void;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { nativePlugin } from './device.js';
3
- import { SwipeSettle, SwipeUtil, SwipeVelocity } from './sheet-swipe.js';
3
+ import { afterLetGo, SwipeFinger, SwipeSettle, SwipeUtil, SwipeVelocity } from './sheet-swipe.js';
4
4
  /**
5
5
  * What a finger pulls down from the top of a list, as the launcher of WeChat over its chats (ta-launcher.md):
6
6
  * the list follows the finger, the launcher shows behind it, and let go far or fast enough the list goes down
@@ -84,8 +84,10 @@ function tick() {
84
84
  }
85
85
  /**
86
86
  * Lets a finger pull the launcher down over the first tab while `enabled`. As useSheetSwipe: transforms and
87
- * opacities only, and the listener that may hold a move back is there only for a touch that may be a pull. A
88
- * pull down is decided on the first move (iOS lets a scroll that started go on), only at the top of the list.
87
+ * opacities only, the listener that may hold a move back there only for a touch that may be a pull, the finger
88
+ * followed on what it touched (SwipeFinger), and let go it slides on at once as on a spring (SwipeSettle), the
89
+ * state following. A pull down is decided on the first move (iOS lets a scroll that started go on), only at
90
+ * the top of the list.
89
91
  */
90
92
  export function usePullDown(options) {
91
93
  const latest = React.useRef(options);
@@ -103,51 +105,18 @@ export function usePullDown(options) {
103
105
  const settle = new SwipeSettle();
104
106
  // The strip that shows while open, with the safe area under it, as the style sizes it.
105
107
  const peekOf = () => { var _a; return ((_a = document.querySelector(latest.current.peek)) === null || _a === void 0 ? void 0 : _a.offsetHeight) || PullUtil.PEEK_PX; };
106
- const paint = (offset) => {
107
- if (!moved) {
108
- return;
109
- }
110
- const p = PullUtil.progress(offset, moved.height, moved.peek);
111
- moved.sheet.style.transform = `translate3d(0, ${offset}px, 0)`;
112
- if (moved.reveal) {
113
- moved.reveal.style.opacity = String(p);
114
- moved.reveal.style.transform = `translate3d(0, ${(p - 1) * 36}px, 0) scale(${0.94 + 0.06 * p})`;
115
- }
116
- };
117
- const release = (elements) => {
118
- var _a, _b;
119
- delete root.dataset.pull;
120
- elements === null || elements === void 0 ? void 0 : elements.sheet.style.removeProperty('transform');
121
- (_a = elements === null || elements === void 0 ? void 0 : elements.reveal) === null || _a === void 0 ? void 0 : _a.style.removeProperty('transform');
122
- (_b = elements === null || elements === void 0 ? void 0 : elements.reveal) === null || _b === void 0 ? void 0 : _b.style.removeProperty('opacity');
108
+ const reveal = (offset, height, peek) => {
109
+ const p = PullUtil.progress(offset, height, peek);
110
+ return { opacity: p, transform: `translate3d(0, ${(p - 1) * 36}px, 0) scale(${0.94 + 0.06 * p})` };
123
111
  };
124
- const stop = () => {
125
- document.removeEventListener('touchmove', onMove);
112
+ const reset = () => {
126
113
  start = undefined;
127
- };
128
- const onStart = (event) => {
129
- const current = latest.current;
130
114
  claimed = undefined;
131
- const touch = event.touches[0];
132
- const target = event.target instanceof Node ? event.target : null;
133
- const area = target
134
- ? [...document.querySelectorAll(current.open ? current.closeArea : current.area)].find(element => element.contains(target))
135
- : undefined;
136
- const inside = !!area;
137
- const free = inside && !editable(event.target) && (current.open ? atEnd(event.target, area) : atTop(event.target, area));
138
- if (event.touches.length === 1 && touch && free) {
139
- start = { x: touch.clientX, y: touch.clientY, t: event.timeStamp };
140
- velocity.start(start);
141
- document.addEventListener('touchmove', onMove, { passive: false });
142
- }
143
- else {
144
- stop();
145
- }
115
+ moved = undefined;
146
116
  };
147
- const onMove = (event) => {
117
+ const onMove = (event, touch) => {
148
118
  const current = latest.current;
149
- const touch = event.touches[0];
150
- if (!start || !touch || claimed === false) {
119
+ if (!start || claimed === false) {
151
120
  return;
152
121
  }
153
122
  const dy = touch.clientY - start.y;
@@ -160,17 +129,12 @@ export function usePullDown(options) {
160
129
  }
161
130
  return;
162
131
  }
163
- if (!claimed) {
164
- stop();
165
- return;
166
- }
167
- const sheet = document.querySelector(current.sheet);
132
+ const sheet = claimed ? document.querySelector(current.sheet) : null;
168
133
  if (!sheet) {
169
134
  claimed = false;
170
- stop();
135
+ finger.stop();
171
136
  return;
172
137
  }
173
- settle.clear();
174
138
  moved = {
175
139
  sheet,
176
140
  reveal: document.querySelector(current.reveal),
@@ -179,6 +143,7 @@ export function usePullDown(options) {
179
143
  passed: current.open,
180
144
  offset: 0,
181
145
  };
146
+ settle.hold([moved.sheet, moved.reveal]);
182
147
  // Not data-sheet-drag: the sheets off the screen (the screen, the board) stay hidden.
183
148
  root.dataset.pull = '';
184
149
  }
@@ -193,39 +158,62 @@ export function usePullDown(options) {
193
158
  tick();
194
159
  }
195
160
  moved.passed = passed || current.open;
196
- paint(moved.offset);
161
+ moved.sheet.style.transform = `translate3d(0, ${moved.offset}px, 0)`;
162
+ if (moved.reveal) {
163
+ const { opacity, transform } = reveal(moved.offset, moved.height, moved.peek);
164
+ moved.reveal.style.opacity = String(opacity);
165
+ moved.reveal.style.transform = transform;
166
+ }
197
167
  };
198
- const onEnd = (event) => {
199
- var _a, _b;
200
- const current = latest.current;
168
+ const onEnd = (event, touch) => {
201
169
  if (start && claimed && moved) {
202
- const end = event.changedTouches[0];
203
- velocity.add({ x: (_a = end === null || end === void 0 ? void 0 : end.clientX) !== null && _a !== void 0 ? _a : start.x, y: (_b = end === null || end === void 0 ? void 0 : end.clientY) !== null && _b !== void 0 ? _b : start.y, t: event.timeStamp });
204
- const speed = velocity.speed;
205
- const open = PullUtil.settle(moved.offset, moved.height, current.open, speed, moved.peek);
206
- const rest = open ? moved.height - moved.peek : 0;
207
- const ms = SwipeUtil.duration(rest - moved.offset, speed, PullUtil.SETTLE_MS);
208
- current.setOpen(open);
209
- const elements = moved;
210
- requestAnimationFrame(() => {
211
- settle.run(ms, [elements.sheet, elements.reveal], [elements.reveal]);
212
- release(elements);
213
- });
170
+ const current = latest.current;
171
+ if (touch) {
172
+ velocity.add({ x: touch.clientX, y: touch.clientY, t: event.timeStamp });
173
+ }
174
+ const speed = touch ? velocity.speed : 0;
175
+ const { sheet, height, peek, offset } = moved;
176
+ const open = PullUtil.settle(offset, height, current.open, speed, peek);
177
+ const rest = open ? height - peek : 0;
178
+ const motion = SwipeUtil.motion(offset, rest, speed, PullUtil.SETTLE_MS, [0, height - peek]);
179
+ settle.run(motion, [
180
+ { element: sheet, transform: `translate3d(0, ${rest}px, 0)` },
181
+ { element: moved.reveal, ...reveal(rest, height, peek) },
182
+ ], () => latest.current.open === open, () => delete root.dataset.pull);
183
+ afterLetGo(open, () => latest.current);
184
+ }
185
+ reset();
186
+ };
187
+ const finger = new SwipeFinger({ move: onMove, end: onEnd }, true);
188
+ const onStart = (event) => {
189
+ const current = latest.current;
190
+ // Another finger beside the one that pulls changes nothing.
191
+ if (finger.down && !finger.follow(event, document)) {
192
+ return;
193
+ }
194
+ finger.stop();
195
+ reset();
196
+ const touch = event.touches[0];
197
+ const target = event.target instanceof Node ? event.target : null;
198
+ const area = target
199
+ ? [...document.querySelectorAll(current.open ? current.closeArea : current.area)].find(element => element.contains(target))
200
+ : undefined;
201
+ const free = !!area && !editable(event.target) && (current.open ? atEnd(event.target, area) : atTop(event.target, area));
202
+ if (touch && free && finger.follow(event, document)) {
203
+ start = { x: touch.clientX, y: touch.clientY, t: event.timeStamp };
204
+ velocity.start(start);
214
205
  }
215
- moved = undefined;
216
- claimed = undefined;
217
- stop();
218
206
  };
219
207
  document.addEventListener('touchstart', onStart, { passive: true });
220
- document.addEventListener('touchend', onEnd, { passive: true });
221
- document.addEventListener('touchcancel', onEnd, { passive: true });
222
208
  return () => {
223
209
  document.removeEventListener('touchstart', onStart);
224
- document.removeEventListener('touchend', onEnd);
225
- document.removeEventListener('touchcancel', onEnd);
226
- stop();
227
- release(moved);
228
- settle.clear();
210
+ finger.stop();
211
+ // A list still under the finger goes back to where it rests; one sliding on finishes its slide.
212
+ if (moved) {
213
+ delete root.dataset.pull;
214
+ settle.finish();
215
+ }
216
+ reset();
229
217
  };
230
218
  }, [enabled]);
231
219
  }
@@ -5,22 +5,47 @@ import * as React from 'react';
5
5
  * anywhere else, or another row opened. Pure, for the tests.
6
6
  */
7
7
  export declare namespace RowSwipeUtil {
8
- /** Past the actions, the row follows the finger this much, as a list pulled past its end. */
9
- const STRETCH = 0.3;
8
+ /** Past the actions, the row follows the finger this much at first, then less and less, as a list of iOS pulled past its end. */
9
+ const RUBBER = 0.55;
10
10
  /** How long its style slides the row (style/device.ts). */
11
11
  const SETTLE_MS = 300;
12
- /** Where the row is, from 0 (closed) to `-width` (its actions shown), when the finger moved `dx`. */
13
- function offset(dx: number, width: number, open: boolean): number;
14
- /** Whether it stays open, let go at `speed` (pixels a millisecond, SwipeVelocity) after moving `dx`. */
15
- function settle(dx: number, width: number, open: boolean, speed: number): boolean;
12
+ /** How far past its actions it ever goes, however far the finger: less than what the actions fill past their edge (style/device.ts). */
13
+ const BEYOND_PX = 100;
14
+ /** Told a swipe, the row catches up with the finger over this much of its way, not at once. */
15
+ const CATCH_PX = 40;
16
+ /** Let go, where it is headed is where it would be this much later at the finger's speed: a short quick swipe opens it too. */
17
+ const PROJECT_MS = 150;
18
+ /** Where the row is, from 0 (closed) to `-width` (its actions shown) and a little past, the finger at `x` (where it took the row, and how far it moved since). */
19
+ function offset(x: number, width: number): number;
20
+ /** Where the finger would be for the row at `offset`: the other way from `offset`, so that a row taken past its actions does not jump. */
21
+ function finger(offset: number, width: number): number;
22
+ /** Whether it stays open, let go at `offset` at `speed` (pixels a millisecond, SwipeVelocity): flicked, the way it was; else where it is headed. */
23
+ function settle(offset: number, width: number, speed: number): boolean;
24
+ /**
25
+ * How far the finger has moved the row, `dx` since the move was told a swipe, `lag` before (the few pixels
26
+ * that told it): from where it was, without a jump, a little faster than the finger until it is where the
27
+ * finger says (CATCH_PX), as if it had followed it from the start.
28
+ */
29
+ function follow(dx: number, lag: number): number;
30
+ /**
31
+ * How far each action is pushed to the right of where it rests, the row at `offset`: they come out with the
32
+ * row's edge, as iOS's, the first one at it, the others spread over what is shown (`share`, 1 - its index
33
+ * of how many there are: 1 for the first, less for those after).
34
+ */
35
+ function shift(offset: number, width: number, share: number): number;
16
36
  /** Whether the move so far is the row's (more sideways than down, to the left unless open); undefined until it is told. */
17
37
  function claims(dx: number, dy: number, open: boolean): boolean | undefined;
18
38
  }
19
39
  /**
20
40
  * Lets a finger swipe the row of `ref` (a SwipeRow) while `enabled`: its content moves over its actions, whose
21
- * width is the way to go, and slides on at the speed the finger left it. Its listeners are passive (the row has
22
- * `touch-action: pan-y`), so the list scrolls on the compositor; each move only sets a transform. The style says
23
- * where an open row rests (`data-swiped`); the row clips what slides out of it only while it is moved, open or
24
- * on its way back (`data-swipe-clip`), so that a menu of the row is not cut at its edges.
41
+ * width is the way to go, and they come out with its edge (RowSwipeUtil.shift); let go, all slide on as on a
42
+ * spring from the speed the finger left them (SwipeSettle). The row sets off from where the move is told a swipe
43
+ * and catches up with the finger (RowSwipeUtil.follow), so it never jumps under it; past its actions it stretches less and
44
+ * less. Open, it closes when the finger scrolls the list from it, or holds it for its menu. Its
45
+ * listeners are passive (the row has `touch-action: pan-y`), so the list scrolls on the compositor; each move
46
+ * only sets a transform. The finger is followed on what it touched (SwipeFinger), so that a row drawn again
47
+ * under it does not stop half way. The style says where an open row rests (`data-swiped`); the row clips
48
+ * what slides out of it only while it is moved, open or on its way back (`data-swipe-clip`), so that a menu
49
+ * of the row is not cut at its edges.
25
50
  */
26
51
  export declare function useRowSwipe(ref: React.RefObject<HTMLElement | null>, enabled: boolean): [boolean, () => void];