@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
@@ -33,9 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.SwipeSettle = exports.SwipeVelocity = exports.SwipeUtil = void 0;
36
+ exports.SwipeFinger = exports.SwipeSettle = exports.SwipeVelocity = exports.SwipeSpring = exports.SwipeUtil = void 0;
37
+ exports.afterLetGo = afterLetGo;
38
+ exports.translated = translated;
37
39
  exports.useSheetSwipe = useSheetSwipe;
38
40
  const React = __importStar(require("react"));
41
+ const frame_1 = require("../util/frame");
39
42
  const device_protocol_1 = require("./device-protocol");
40
43
  /** It follows the finger and, let go, ends where it was flicked to, or the nearer side. Pure, for the tests. */
41
44
  var SwipeUtil;
@@ -92,24 +95,29 @@ var SwipeUtil;
92
95
  return claimed === undefined ? undefined : claimed && !sideways();
93
96
  }
94
97
  SwipeUtil.takes = takes;
95
- /** Where the sheet is, from 0 (out) to `∓width` (away on its side), when the finger moved `dx`. */
96
- function offset(sheet, dx, width, open) {
97
- const away = -outward(sheet) * width;
98
- return Math.min(Math.max(away, 0), Math.max(Math.min(away, 0), (open ? 0 : away) + dx));
99
- }
100
- SwipeUtil.offset = offset;
101
- /** Whether it ends out, let go at `speed` (pixels a millisecond, SwipeVelocity) after moving `dx`. */
102
- function settle(sheet, dx, width, open, speed) {
98
+ /** Where the sheet rests away: `∓width`, on its side; out, it rests at 0. */
99
+ function away(sheet, width) {
100
+ return -outward(sheet) * width;
101
+ }
102
+ SwipeUtil.away = away;
103
+ /** Where the sheet is, between 0 (out) and away, when the finger moved `dx` from where it took it (`from`). */
104
+ function position(sheet, from, dx, width) {
105
+ const rest = away(sheet, width);
106
+ return Math.min(Math.max(rest, 0), Math.max(Math.min(rest, 0), from + dx));
107
+ }
108
+ SwipeUtil.position = position;
109
+ /** Whether it ends out, let go at `x` at `speed` (pixels a millisecond, SwipeVelocity): the way it was flicked, or the nearer side. */
110
+ function settle(sheet, x, width, speed) {
103
111
  if (Math.abs(speed) > SwipeUtil.FLICK) {
104
112
  return speed * outward(sheet) > 0;
105
113
  }
106
- return Math.abs(offset(sheet, dx, width, open)) < width / 2;
114
+ return Math.abs(x) < width / 2;
107
115
  }
108
116
  SwipeUtil.settle = settle;
109
117
  /**
110
- * How long it slides on to where it rests, `distance` away (signed), let go at `speed`: as fast at first as
111
- * the finger was, so that a flick goes on at its speed rather than at that of the style; `longest` (the
112
- * style's) when the finger was slow, or going the other way.
118
+ * How long it slides on to where it rests, `distance` away (signed), let go at `speed`, where the curves of
119
+ * `linear()` are not (SwipeSpring): on CURVE, as fast at first as the finger was; `longest` (the style's)
120
+ * when the finger was slow, or going the other way.
113
121
  */
114
122
  function duration(distance, speed, longest) {
115
123
  const toward = Math.sign(distance) * speed;
@@ -119,12 +127,73 @@ var SwipeUtil;
119
127
  return Math.round(Math.min(longest, Math.max(SwipeUtil.SHORTEST_MS, (CURVE_START * Math.abs(distance)) / toward)));
120
128
  }
121
129
  SwipeUtil.duration = duration;
122
- /** The transitions of an element that slides on from where the finger left it, for `ms`; it hides at its end. */
123
- function transition(ms, property = 'transform') {
124
- return property === 'opacity' ? `opacity ${ms}ms ${SwipeUtil.CURVE}` : `transform ${ms}ms ${SwipeUtil.CURVE}, visibility 0s ${ms}ms`;
130
+ /** Whether the page draws the curves of `linear()` (iOS 17.2, Chrome 113 on): a spring then, else CURVE. */
131
+ SwipeUtil.springs = (() => {
132
+ try {
133
+ return typeof CSS !== 'undefined' && CSS.supports('transition-timing-function', 'linear(0, 1)');
134
+ }
135
+ catch (_a) {
136
+ return false;
137
+ }
138
+ })();
139
+ /**
140
+ * How what the finger let go at `from` at `speed` slides on to `to`, never past `bounds`: a spring that starts at
141
+ * the speed of the finger where the page draws it (SwipeSpring), else CURVE for `duration`. `longest` is how long
142
+ * its style slides it.
143
+ */
144
+ function motion(from, to, speed, longest, bounds = [-Infinity, Infinity]) {
145
+ if (SwipeUtil.springs) {
146
+ return SwipeSpring.motion(from, to, speed, longest, bounds);
147
+ }
148
+ return { ms: Math.abs(to - from) < SwipeSpring.REST_PX ? 0 : duration(to - from, speed, longest), easing: SwipeUtil.CURVE };
125
149
  }
126
- SwipeUtil.transition = transition;
150
+ SwipeUtil.motion = motion;
127
151
  })(SwipeUtil || (exports.SwipeUtil = SwipeUtil = {}));
152
+ /**
153
+ * What a finger lets go slides on as on a spring, as the sheets of iOS: at the speed the finger had, slowing
154
+ * down to where it rests, never past it; going the other way, it goes on a little that way first, as far as it
155
+ * may. A sheet let go near where it rests settles there quickly, one let go far away takes its time. Drawn by
156
+ * the compositor as a CSS transition, its curve a `linear()` of the spring's points. Pure, for the tests.
157
+ */
158
+ var SwipeSpring;
159
+ (function (SwipeSpring) {
160
+ /** How stiff, for what its style slides in `longest` ms: ω = STIFFNESS / longest, 95% of the way in about 0.6 × longest from rest. */
161
+ SwipeSpring.STIFFNESS = 8;
162
+ /** It rests once nearer than this, in pixels. */
163
+ SwipeSpring.REST_PX = 0.5;
164
+ /** A point of its curve this often, in milliseconds. */
165
+ const STEP_MS = 12;
166
+ /** How far it still is from where it rests, of the way, after `t` ms: critically damped, at `speed` (of the way a millisecond) at first. */
167
+ function left(t, omega, speed) {
168
+ return (1 + (omega - speed) * t) * Math.exp(-omega * t);
169
+ }
170
+ SwipeSpring.left = left;
171
+ function motion(from, to, speed, longest, bounds = [-Infinity, Infinity]) {
172
+ const distance = to - from;
173
+ const span = Math.abs(distance);
174
+ if (span < SwipeSpring.REST_PX) {
175
+ return { ms: 0, easing: 'linear' };
176
+ }
177
+ const toward = (Math.sign(distance) * speed) / span;
178
+ // Flicked faster than the spring goes, it is stiffer: it goes on at the finger's speed, and never past where it rests.
179
+ const omega = Math.max(SwipeSpring.STIFFNESS / longest, toward);
180
+ let ms = STEP_MS;
181
+ while (ms < longest * 2 && Math.abs(left(ms, omega, toward)) * span > SwipeSpring.REST_PX) {
182
+ ms += 4;
183
+ }
184
+ // The other way, it goes on only as far as it may.
185
+ const behind = distance > 0 ? from - bounds[0] : bounds[1] - from;
186
+ const lowest = -Math.max(0, behind) / span;
187
+ const count = Math.max(8, Math.ceil(ms / STEP_MS));
188
+ const points = [];
189
+ for (let i = 0; i <= count; i++) {
190
+ const progress = i === count ? 1 : Math.max(lowest, 1 - left((ms * i) / count, omega, toward));
191
+ points.push(String(Math.round(progress * 1000) / 1000));
192
+ }
193
+ return { ms, easing: `linear(${points.join(', ')})` };
194
+ }
195
+ SwipeSpring.motion = motion;
196
+ })(SwipeSpring || (exports.SwipeSpring = SwipeSpring = {}));
128
197
  /**
129
198
  * The speed of a finger along x, in pixels a millisecond, of its last moves (SwipeUtil.VELOCITY_MS): let go
130
199
  * after a slow drag and a flick it is the flick's, held still a moment it is none.
@@ -153,46 +222,258 @@ class SwipeVelocity {
153
222
  }
154
223
  }
155
224
  exports.SwipeVelocity = SwipeVelocity;
225
+ /** The settle that holds an element now: one at a time, so that a finger that takes it stops whatever slid it. */
226
+ const holders = new WeakMap();
156
227
  /**
157
- * What slides on, let go, at the speed of the finger (SwipeUtil.duration) rather than of its style; the
158
- * style's again once it rests, or as soon as a finger takes it again.
228
+ * The elements a finger moves, then lets go (SwipeMotion): while it moves them their styles do not slide
229
+ * them; let go, they slide on to where they rest with transitions of their own, and only once they are there,
230
+ * and the state has them there too (`ready`), they are their styles' again. So the slide starts in the frame
231
+ * the finger lets go, before the page draws what the state changed (which may take a while: a long
232
+ * conversation), and never jumps if it takes longer than the slide. A finger that takes one of them again, or
233
+ * another swipe that moves it, stops it where it is now.
159
234
  */
160
235
  class SwipeSettle {
161
236
  constructor() {
162
- this.elements = [];
237
+ this.elements = new Set();
163
238
  }
164
- run(ms, slides, fades = []) {
165
- this.clear();
166
- for (const element of slides) {
167
- this.set(element, SwipeUtil.transition(ms));
239
+ /** Whether some of its elements are still its own: moved, or sliding on. */
240
+ get busy() {
241
+ return this.elements.size > 0;
242
+ }
243
+ /** A finger moves these: each stops where it is, whatever slid it, and its style no longer slides it. */
244
+ hold(elements) {
245
+ clearTimeout(this.timer);
246
+ this.done = undefined;
247
+ for (const element of elements) {
248
+ if (element) {
249
+ this.take(element);
250
+ element.style.transition = 'none';
251
+ }
168
252
  }
169
- for (const element of fades) {
170
- this.set(element, SwipeUtil.transition(ms, 'opacity'));
253
+ }
254
+ /**
255
+ * Let go, each slides on to its target as `motion` says; once there and `ready()`, they are their styles'
256
+ * again and `done` runs.
257
+ */
258
+ run(motion, targets, ready, done) {
259
+ clearTimeout(this.timer);
260
+ const transition = motion.ms > 0 ? `transform ${motion.ms}ms ${motion.easing}, opacity ${motion.ms}ms ${motion.easing}` : 'none';
261
+ for (const { element, transform, opacity } of targets) {
262
+ if (!element) {
263
+ continue;
264
+ }
265
+ this.take(element);
266
+ element.style.transition = transition;
267
+ if (transform !== undefined) {
268
+ element.style.transform = transform;
269
+ }
270
+ if (opacity !== undefined) {
271
+ element.style.opacity = String(opacity);
272
+ }
171
273
  }
172
- this.timer = setTimeout(() => this.clear(), ms + 50);
274
+ this.done = done;
275
+ const until = Date.now() + motion.ms + SwipeSettle.READY_MS;
276
+ const check = () => {
277
+ if (ready() || Date.now() > until) {
278
+ this.finish();
279
+ }
280
+ else {
281
+ this.timer = setTimeout(check, 32);
282
+ }
283
+ };
284
+ this.timer = setTimeout(check, motion.ms + 16);
173
285
  }
174
- clear() {
286
+ /** They are their styles' again at once, where those say they rest, without sliding there. */
287
+ finish() {
288
+ this.giveBack(false);
289
+ }
290
+ /** They are their styles' again from where they are now: the styles slide them on to where they rest. */
291
+ release() {
292
+ this.giveBack(true);
293
+ }
294
+ giveBack(slide) {
175
295
  clearTimeout(this.timer);
176
- for (const element of this.elements) {
296
+ const elements = [...this.elements];
297
+ this.elements.clear();
298
+ const done = this.done;
299
+ this.done = undefined;
300
+ if (slide) {
301
+ for (const element of elements) {
302
+ this.freeze(element);
303
+ }
304
+ // Where they are now is where the styles slide them from.
305
+ if (elements.length) {
306
+ void getComputedStyle(elements[0]).transform;
307
+ }
308
+ done === null || done === void 0 ? void 0 : done();
309
+ for (const element of elements) {
310
+ SwipeSettle.clean(element, this);
311
+ element.style.removeProperty('transition');
312
+ }
313
+ return;
314
+ }
315
+ for (const element of elements) {
316
+ element.style.transition = 'none';
317
+ SwipeSettle.clean(element, this);
318
+ }
319
+ done === null || done === void 0 ? void 0 : done();
320
+ // Where they rest is drawn with no transition, then theirs are the styles' again.
321
+ if (elements.length) {
322
+ void getComputedStyle(elements[0]).transform;
323
+ }
324
+ for (const element of elements) {
177
325
  element.style.removeProperty('transition');
178
326
  }
179
- this.elements = [];
180
327
  }
181
- /** An element that both slides and fades takes both transitions. */
182
- set(element, transition) {
183
- if (!element) {
328
+ static clean(element, holder) {
329
+ if (holders.get(element) === holder) {
330
+ holders.delete(element);
331
+ }
332
+ element.style.removeProperty('transform');
333
+ element.style.removeProperty('opacity');
334
+ element.style.removeProperty('visibility');
335
+ }
336
+ /** Takes `element` from the settle that has it, stopped where it is. */
337
+ take(element) {
338
+ const holder = holders.get(element);
339
+ if (holder && holder !== this) {
340
+ holder.elements.delete(element);
341
+ }
342
+ if (holder) {
343
+ this.freeze(element);
344
+ }
345
+ holders.set(element, this);
346
+ this.elements.add(element);
347
+ }
348
+ /** What slides stops where it is now. */
349
+ freeze(element) {
350
+ const transition = element.style.transition;
351
+ if (!transition || transition === 'none') {
184
352
  return;
185
353
  }
186
- if (this.elements.includes(element)) {
187
- element.style.transition = `${element.style.transition}, ${transition}`;
354
+ const style = getComputedStyle(element);
355
+ if (element.style.transform) {
356
+ element.style.transform = style.transform;
188
357
  }
189
- else {
190
- element.style.transition = transition;
191
- this.elements.push(element);
358
+ if (element.style.opacity) {
359
+ element.style.opacity = style.opacity;
192
360
  }
361
+ element.style.transition = 'none';
193
362
  }
194
363
  }
195
364
  exports.SwipeSettle = SwipeSettle;
365
+ /** How long it waits for the state, past the slide, before giving the elements back anyway. */
366
+ SwipeSettle.READY_MS = 1000;
367
+ /**
368
+ * What a swipe let go changes in the state of the page, once the frame it was let go in is drawn and its slide
369
+ * set off (FrameUtil.painted), or after a while where frames are not drawn (a page out of sight); only if it
370
+ * changes something: the workbench is put away by the same call that brings it out.
371
+ */
372
+ function afterLetGo(open, current) {
373
+ let called = false;
374
+ const call = () => {
375
+ if (!called) {
376
+ called = true;
377
+ if (current().open !== open) {
378
+ current().setOpen(open);
379
+ }
380
+ }
381
+ };
382
+ void frame_1.FrameUtil.painted().then(call);
383
+ setTimeout(call, 100);
384
+ }
385
+ /** Where `element` is moved along `axis` now, by its transform: wherever a style or a slide has it. */
386
+ function translated(element, axis = 'x') {
387
+ const transform = getComputedStyle(element).transform;
388
+ if (!transform || transform === 'none') {
389
+ return 0;
390
+ }
391
+ const matrix = new DOMMatrixReadOnly(transform);
392
+ return axis === 'x' ? matrix.m41 : matrix.m42;
393
+ }
394
+ /**
395
+ * The one finger a swipe follows, from its touchstart. Its moves and its end are listened to on the element
396
+ * it was put down on, which keeps getting them when it leaves the page (a row or a message drawn again under
397
+ * the finger) while the document no longer does, and on the document too, each event once. Another finger put
398
+ * down or lifted beside it is not its own; its end never seen, the next finger put down ends it.
399
+ */
400
+ class SwipeFinger {
401
+ /** `blocking`: its moves may be held back (preventDefault), so their listener is not passive. */
402
+ constructor(on, blocking = false) {
403
+ this.on = on;
404
+ this.blocking = blocking;
405
+ this.targets = [];
406
+ this.onMove = (event) => {
407
+ if (event === this.last) {
408
+ return;
409
+ }
410
+ this.last = event;
411
+ const touch = this.find(event.touches);
412
+ if (touch) {
413
+ this.on.move(event, touch);
414
+ }
415
+ };
416
+ this.onEnd = (event) => {
417
+ if (event === this.last) {
418
+ return;
419
+ }
420
+ this.last = event;
421
+ const touch = this.find(event.changedTouches);
422
+ if (touch) {
423
+ this.stop();
424
+ this.on.end(event, touch);
425
+ }
426
+ };
427
+ }
428
+ get down() {
429
+ return this.id !== undefined;
430
+ }
431
+ /**
432
+ * Follows the finger `event` (a touchstart in `doc`) put down, alone on the screen; false while it follows
433
+ * another, which is still down, or when several are.
434
+ */
435
+ follow(event, doc) {
436
+ if (this.down) {
437
+ if (this.find(event.touches)) {
438
+ return false;
439
+ }
440
+ const lost = event;
441
+ this.stop();
442
+ this.on.end(lost, undefined);
443
+ }
444
+ const touch = event.changedTouches[0];
445
+ if (event.touches.length !== 1 || !touch) {
446
+ return false;
447
+ }
448
+ this.id = touch.identifier;
449
+ const target = event.target;
450
+ this.targets = target && target !== doc ? [target, doc] : [doc];
451
+ for (const element of this.targets) {
452
+ element.addEventListener('touchmove', this.onMove, { passive: !this.blocking });
453
+ element.addEventListener('touchend', this.onEnd, { passive: true });
454
+ element.addEventListener('touchcancel', this.onEnd, { passive: true });
455
+ }
456
+ return true;
457
+ }
458
+ stop() {
459
+ for (const element of this.targets) {
460
+ element.removeEventListener('touchmove', this.onMove);
461
+ element.removeEventListener('touchend', this.onEnd);
462
+ element.removeEventListener('touchcancel', this.onEnd);
463
+ }
464
+ this.targets = [];
465
+ this.id = undefined;
466
+ }
467
+ find(touches) {
468
+ for (let i = 0; i < touches.length; i++) {
469
+ if (touches[i].identifier === this.id) {
470
+ return touches[i];
471
+ }
472
+ }
473
+ return undefined;
474
+ }
475
+ }
476
+ exports.SwipeFinger = SwipeFinger;
196
477
  /** How far what the sheet covers moves, of the width of the sheet (as the styles of the phone, style/phone.ts). */
197
478
  const UNDER = 0.3;
198
479
  /** How long the styles of the phone slide a sheet (style/phone.ts). */
@@ -268,8 +549,10 @@ class TouchSources {
268
549
  * Lets the finger move a sheet while `enabled`, then `setOpen` says where it ended; its style says where it
269
550
  * rests. Smooth on a long conversation: each move only sets transforms and an opacity, which the compositor
270
551
  * draws, never a style the page inherits; the page keeps scrolling on the compositor too, as the listener that
271
- * may hold a move back is only there while a touch may be the sheet's. A touch in a frame the page may read
272
- * moves it as well (TouchSources).
552
+ * may hold a move back is only there while a touch may be the sheet's. Let go, it slides on at once, as on a
553
+ * spring (SwipeSettle, SwipeSpring), and the state changes in the frames after, so that what the page draws
554
+ * for it never holds the sheet still half way. A sheet still sliding, the finger takes it where it is. A touch
555
+ * in a frame the page may read moves it as well (TouchSources).
273
556
  */
274
557
  function useSheetSwipe(options) {
275
558
  const latest = React.useRef(options);
@@ -281,53 +564,63 @@ function useSheetSwipe(options) {
281
564
  }
282
565
  const root = document.documentElement;
283
566
  let start;
567
+ let last;
284
568
  let claimed;
285
569
  let moved;
286
570
  let source;
287
571
  const velocity = new SwipeVelocity();
288
572
  const settle = new SwipeSettle();
289
- const point = (event, touch = event.touches[0]) => {
573
+ const point = (event, touch) => {
290
574
  var _a;
291
- var _b, _c, _d, _e;
575
+ var _b, _c;
292
576
  const box = (_a = source === null || source === void 0 ? void 0 : source.frame) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
293
- return { x: ((_b = touch === null || touch === void 0 ? void 0 : touch.clientX) !== null && _b !== void 0 ? _b : 0) + ((_c = box === null || box === void 0 ? void 0 : box.left) !== null && _c !== void 0 ? _c : 0), y: ((_d = touch === null || touch === void 0 ? void 0 : touch.clientY) !== null && _d !== void 0 ? _d : 0) + ((_e = box === null || box === void 0 ? void 0 : box.top) !== null && _e !== void 0 ? _e : 0), t: event.timeStamp };
577
+ return { x: touch.clientX + ((_b = box === null || box === void 0 ? void 0 : box.left) !== null && _b !== void 0 ? _b : 0), y: touch.clientY + ((_c = box === null || box === void 0 ? void 0 : box.top) !== null && _c !== void 0 ? _c : 0), t: event.timeStamp };
294
578
  };
295
579
  const find = (selector) => (selector ? document.querySelector(selector) : null);
296
- const release = (elements) => {
297
- var _a, _b, _c, _d;
298
- delete root.dataset.sheetDrag;
299
- (_a = elements === null || elements === void 0 ? void 0 : elements.sheet) === null || _a === void 0 ? void 0 : _a.style.removeProperty('transform');
300
- (_b = elements === null || elements === void 0 ? void 0 : elements.sheet) === null || _b === void 0 ? void 0 : _b.style.removeProperty('visibility');
301
- (_c = elements === null || elements === void 0 ? void 0 : elements.under) === null || _c === void 0 ? void 0 : _c.style.removeProperty('transform');
302
- (_d = elements === null || elements === void 0 ? void 0 : elements.scrim) === null || _d === void 0 ? void 0 : _d.style.removeProperty('opacity');
580
+ /** Where each is with the sheet at `x`. */
581
+ const targets = (elements, x) => {
582
+ const out = 1 - Math.abs(x) / elements.width;
583
+ return [
584
+ { element: elements.sheet, transform: `translate3d(${x}px, 0, 0)` },
585
+ { element: elements.under, transform: `translate3d(${SwipeUtil.outward(latest.current) * UNDER * elements.width * out}px, 0, 0)` },
586
+ { element: elements.scrim, opacity: out },
587
+ ];
303
588
  };
304
- const stop = () => {
305
- source === null || source === void 0 ? void 0 : source.doc.removeEventListener('touchmove', onMove);
589
+ const reset = () => {
306
590
  start = undefined;
591
+ last = undefined;
592
+ claimed = undefined;
593
+ moved = undefined;
307
594
  source = undefined;
308
595
  };
309
- const onMove = (event) => {
596
+ const onMove = (event, touch) => {
310
597
  var _a;
598
+ var _b;
311
599
  const current = latest.current;
312
600
  if (!start || claimed === false) {
313
601
  return;
314
602
  }
315
- const now = point(event);
603
+ const now = point(event, touch);
316
604
  if (claimed === undefined) {
317
605
  claimed = SwipeUtil.takes(current, start, now, current.open, () => scrollsSideways(event.target));
318
606
  if (claimed === undefined) {
319
607
  return;
320
608
  }
321
609
  if (!claimed) {
322
- stop();
610
+ finger.stop();
611
+ reset();
323
612
  return;
324
613
  }
325
- settle.clear();
326
614
  const sheet = find(current.sheet);
327
- moved = { sheet, under: find(current.under), scrim: find(current.scrim), width: (sheet === null || sheet === void 0 ? void 0 : sheet.getBoundingClientRect().width) || window.innerWidth };
328
- root.dataset.sheetDrag = (_a = current.name) !== null && _a !== void 0 ? _a : '';
329
- // Seen while it moves, whatever the styles say of where it rests.
615
+ const width = (sheet === null || sheet === void 0 ? void 0 : sheet.getBoundingClientRect().width) || window.innerWidth;
616
+ // From where it is: at rest, or still sliding.
617
+ const from = sheet ? translated(sheet) : current.open ? 0 : SwipeUtil.away(current, width);
618
+ moved = { sheet, under: find(current.under), scrim: find(current.scrim), width, from };
619
+ settle.hold([moved.sheet, moved.under, moved.scrim]);
620
+ root.dataset.sheetDrag = (_b = current.name) !== null && _b !== void 0 ? _b : '';
621
+ // Seen while it moves, and while it slides on, whatever the styles say of where they rest.
330
622
  sheet === null || sheet === void 0 ? void 0 : sheet.style.setProperty('visibility', 'visible');
623
+ (_a = moved.under) === null || _a === void 0 ? void 0 : _a.style.setProperty('visibility', 'visible');
331
624
  }
332
625
  if (!moved) {
333
626
  return;
@@ -335,71 +628,76 @@ function useSheetSwipe(options) {
335
628
  // The page does not scroll under a sheet being dragged.
336
629
  event.preventDefault();
337
630
  velocity.add(now);
338
- const x = SwipeUtil.offset(current, now.x - start.x, moved.width, current.open);
339
- const out = 1 - Math.abs(x) / moved.width;
340
- if (moved.sheet) {
341
- moved.sheet.style.transform = `translate3d(${x}px, 0, 0)`;
342
- }
343
- if (moved.under) {
344
- moved.under.style.transform = `translate3d(${SwipeUtil.outward(current) * UNDER * moved.width * out}px, 0, 0)`;
631
+ last = now;
632
+ const x = SwipeUtil.position(current, moved.from, now.x - start.x, moved.width);
633
+ for (const { element, transform, opacity } of targets(moved, x)) {
634
+ if (element && transform) {
635
+ element.style.transform = transform;
636
+ }
637
+ if (element && opacity !== undefined) {
638
+ element.style.opacity = String(opacity);
639
+ }
345
640
  }
346
- if (moved.scrim) {
347
- moved.scrim.style.opacity = String(out);
641
+ };
642
+ const onEnd = (event, touch) => {
643
+ var _a;
644
+ if (start && claimed && moved) {
645
+ const current = latest.current;
646
+ const end = touch ? point(event, touch) : (last !== null && last !== void 0 ? last : start);
647
+ if (touch) {
648
+ velocity.add(end);
649
+ }
650
+ const speed = touch ? velocity.speed : 0;
651
+ const x = SwipeUtil.position(current, moved.from, end.x - start.x, moved.width);
652
+ const out = SwipeUtil.settle(current, x, moved.width, speed);
653
+ const away = SwipeUtil.away(current, moved.width);
654
+ const rest = out ? 0 : away;
655
+ const motion = SwipeUtil.motion(x, rest, speed, (_a = current.settleMs) !== null && _a !== void 0 ? _a : SETTLE_MS, [Math.min(0, away), Math.max(0, away)]);
656
+ delete root.dataset.sheetDrag;
657
+ // It slides on now; the state follows once that is drawn, so that what it changes never holds it still.
658
+ settle.run(motion, targets(moved, rest), () => latest.current.open === out);
659
+ afterLetGo(out, () => latest.current);
348
660
  }
661
+ reset();
349
662
  };
663
+ const finger = new SwipeFinger({ move: onMove, end: onEnd }, true);
350
664
  const onStart = (event, from) => {
351
665
  var _a;
352
666
  const current = latest.current;
353
- stop();
354
- claimed = undefined;
667
+ // Another finger beside the one that moves it changes nothing; the end of that one never seen, it ends now.
668
+ if (finger.down) {
669
+ if (!finger.follow(event, from.doc)) {
670
+ // A second finger before the swipe was told from a scroll pinches (a picture): it is not the sheet's.
671
+ if (claimed === undefined && event.touches.length > 1) {
672
+ finger.stop();
673
+ reset();
674
+ }
675
+ return;
676
+ }
677
+ finger.stop();
678
+ }
679
+ reset();
355
680
  source = from;
356
- const at = point(event);
681
+ const touch = event.touches[0];
357
682
  const target = ((_a = event.target) === null || _a === void 0 ? void 0 : _a.nodeType) === Node.ELEMENT_NODE ? event.target : null;
358
683
  const fromEdge = !current.open && !!current.edgeOver && !!(target === null || target === void 0 ? void 0 : target.closest(current.edgeOver));
359
684
  const sheet = fromEdge ? { ...current, opensFrom: 'edge' } : current;
360
- if (event.touches.length === 1 && SwipeUtil.starts(sheet, at, current.open, window.innerWidth)) {
685
+ if (event.touches.length !== 1 || !touch) {
686
+ return;
687
+ }
688
+ const at = point(event, touch);
689
+ if (SwipeUtil.starts(sheet, at, current.open, window.innerWidth) && finger.follow(event, from.doc)) {
361
690
  start = at;
362
691
  velocity.start(at);
363
- from.doc.addEventListener('touchmove', onMove, { passive: false });
364
692
  }
365
693
  else {
366
- stop();
694
+ source = undefined;
367
695
  }
368
696
  };
369
- const onEnd = (event) => {
370
- var _a;
371
- if (start && claimed && moved) {
372
- const current = latest.current;
373
- const end = point(event, event.changedTouches[0]);
374
- const dx = end.x - start.x;
375
- velocity.add(end);
376
- const speed = velocity.speed;
377
- const out = SwipeUtil.settle(current, dx, moved.width, current.open, speed);
378
- const x = SwipeUtil.offset(current, dx, moved.width, current.open);
379
- const rest = out ? 0 : -SwipeUtil.outward(current) * moved.width;
380
- const ms = SwipeUtil.duration(rest - x, speed, (_a = current.settleMs) !== null && _a !== void 0 ? _a : SETTLE_MS);
381
- current.setOpen(out);
382
- // Released in the frame the sheet takes its place, so that it slides on from where the finger left it, at its speed.
383
- const elements = moved;
384
- requestAnimationFrame(() => {
385
- settle.run(ms, [elements.sheet, elements.under], [elements.scrim]);
386
- release(elements);
387
- });
388
- }
389
- moved = undefined;
390
- stop();
391
- claimed = undefined;
392
- };
393
697
  const sources = new TouchSources(from => {
394
698
  const begin = (event) => onStart(event, from);
395
699
  from.doc.addEventListener('touchstart', begin, { passive: true });
396
- from.doc.addEventListener('touchend', onEnd, { passive: true });
397
- from.doc.addEventListener('touchcancel', onEnd, { passive: true });
398
- return () => {
399
- from.doc.removeEventListener('touchstart', begin);
400
- from.doc.removeEventListener('touchend', onEnd);
401
- from.doc.removeEventListener('touchcancel', onEnd);
402
- };
700
+ return () => from.doc.removeEventListener('touchstart', begin);
403
701
  });
404
702
  const edge = !!latest.current.edgeOver;
405
703
  if (edge) {
@@ -410,9 +708,13 @@ function useSheetSwipe(options) {
410
708
  delete root.dataset.edgeSwipe;
411
709
  }
412
710
  sources.dispose();
413
- stop();
414
- release(moved);
415
- settle.clear();
711
+ finger.stop();
712
+ // A sheet still under the finger goes back to where it rests; one sliding on finishes its slide.
713
+ if (moved) {
714
+ delete root.dataset.sheetDrag;
715
+ settle.finish();
716
+ }
717
+ reset();
416
718
  };
417
719
  }, [enabled]);
418
720
  }