@astryx-vue/core 0.24.0 → 0.26.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 (352) hide show
  1. package/dist/AlertDialog/index.js +1 -1
  2. package/dist/{AlertDialog-DXOTr1D7.js → AlertDialog-Sku86l_R.js} +194 -8
  3. package/dist/AppShell/index.js +1 -1
  4. package/dist/{AppShell-Cmu6bMY6.js → AppShell-CJWvaqgZ.js} +5 -5
  5. package/dist/Avatar/index.js +1 -1
  6. package/dist/{Avatar-dMcn3j8Z.js → Avatar-C5KaulzE.js} +1 -1
  7. package/dist/AvatarGroup/index.d.ts +1 -1
  8. package/dist/AvatarGroup/index.js +1 -1
  9. package/dist/{AvatarGroup-BUXjzekw.js → AvatarGroup-DT5RbxDa.js} +1 -1
  10. package/dist/Badge/index.d.ts +1 -2
  11. package/dist/Banner/index.d.ts +1 -1
  12. package/dist/Banner/index.js +1 -1
  13. package/dist/{Banner-CTY9qV89.js → Banner-cg2nXT_4.js} +1 -1
  14. package/dist/BottomSheet/index.d.ts +1 -1
  15. package/dist/BottomSheet/index.js +2 -2
  16. package/dist/{BottomSheet-DyJJtZZU.js → BottomSheet-BtuF3uH6.js} +114 -11
  17. package/dist/{BottomSheet-ZOjuZya0.js → BottomSheet-DKrJyrhw.js} +1 -1
  18. package/dist/Breadcrumbs/index.js +2 -2
  19. package/dist/{Breadcrumbs-Nv-089W0.js → Breadcrumbs-Cvzwy6sZ.js} +1 -1
  20. package/dist/Button/index.d.ts +1 -1
  21. package/dist/Button/index.js +1 -1
  22. package/dist/{Button-TiYG0btL.js → Button-D8AGK5oT.js} +3 -3
  23. package/dist/ButtonGroup/index.d.ts +1 -1
  24. package/dist/ButtonGroup/index.js +1 -1
  25. package/dist/{ButtonGroup-DNN4O9_-.js → ButtonGroup-CUN_rC57.js} +2 -2
  26. package/dist/Calendar/index.d.ts +1 -1
  27. package/dist/Carousel/index.d.ts +1 -1
  28. package/dist/Carousel/index.js +1 -1
  29. package/dist/{Carousel-DsXup1mZ.js → Carousel-DrCG9wbP.js} +1 -1
  30. package/dist/Chat/index.d.ts +1 -1
  31. package/dist/Chat/index.js +1 -1
  32. package/dist/{Chat-DqYT_S9M.js → Chat-BIHEfSec.js} +205 -43
  33. package/dist/CheckboxInput/index.d.ts +1 -1
  34. package/dist/CheckboxInput/index.js +1 -1
  35. package/dist/{CheckboxInput-FKfsoLcl.js → CheckboxInput-wmX3Ekj-.js} +7 -7
  36. package/dist/CheckboxList/index.d.ts +1 -1
  37. package/dist/CheckboxList/index.js +1 -1
  38. package/dist/{CheckboxList-DuSVBtMk.js → CheckboxList-JWXHHU-u.js} +6 -6
  39. package/dist/ClickableCard/index.d.ts +1 -1
  40. package/dist/ClickableCard/index.js +1 -1
  41. package/dist/{ClickableCard-dNmSVHBu.js → ClickableCard-CwGxO0GU.js} +1 -1
  42. package/dist/Code/index.js +1 -1
  43. package/dist/{CodeBlock-5KoJDvWd.js → CodeBlock-PMZd9dQ9.js} +1 -1
  44. package/dist/Collapsible/index.js +1 -1
  45. package/dist/{Collapsible-B1qW6OuL.js → Collapsible-BDCJRfFN.js} +3 -3
  46. package/dist/CommandPalette/index.js +1 -1
  47. package/dist/{CommandPalette-B2riNg_7.js → CommandPalette-CJyQd7P-.js} +2 -2
  48. package/dist/ComplexSelector/index.d.ts +1 -1
  49. package/dist/ComplexSelector/index.js +1 -1
  50. package/dist/{ComplexSelector-C4CO8Fd2.js → ComplexSelector-DIb8LjYJ.js} +4 -4
  51. package/dist/ContextMenu/index.d.ts +1 -1
  52. package/dist/ContextMenu/index.js +2 -2
  53. package/dist/{ContextMenu-SzsWZf18.js → ContextMenu-HLvsROcS.js} +13 -26
  54. package/dist/DateInput/index.d.ts +1 -1
  55. package/dist/DateInput/index.js +1 -1
  56. package/dist/{DateInput-D9Jv70H7.js → DateInput-D5YBijbb.js} +14 -33
  57. package/dist/DateRangeInput/index.d.ts +1 -1
  58. package/dist/DateRangeInput/index.js +1 -1
  59. package/dist/{DateRangeInput-BsB2kg_q.js → DateRangeInput-BlcHsqgx.js} +6 -6
  60. package/dist/DateTimeInput/index.d.ts +1 -1
  61. package/dist/DateTimeInput/index.js +1 -1
  62. package/dist/{DateTimeInput-BDyKPKGD.js → DateTimeInput-Bx3LWb9Y.js} +7 -7
  63. package/dist/Dialog/index.js +3 -3
  64. package/dist/{Dialog-DUlWQH8R.js → Dialog-CNLEL4Mf.js} +1 -1
  65. package/dist/{Dialog-JCB5s-T-.js → Dialog-CxeXQTqH.js} +10 -0
  66. package/dist/{DialogHeader-C6hZZxdv.js → DialogHeader-CjXS_wba.js} +2 -2
  67. package/dist/Divider/index.d.ts +1 -1
  68. package/dist/Drawer/index.d.ts +1 -1
  69. package/dist/Drawer/index.js +1 -1
  70. package/dist/{Drawer-BDuiw1-g.js → Drawer-B_4HN6v5.js} +2 -2
  71. package/dist/DropdownMenu/index.js +3 -3
  72. package/dist/{DropdownMenu-Der2x_k_.js → DropdownMenu-CvdeExRQ.js} +5 -5
  73. package/dist/{DropdownMenu-BhxKnh6D.js → DropdownMenu-D_fBzKvf.js} +52 -23
  74. package/dist/EmptyState/index.js +1 -1
  75. package/dist/{EmptyState-CnFkYtcS.js → EmptyState-DUaFClsX.js} +4 -50
  76. package/dist/Field/index.d.ts +3 -3
  77. package/dist/Field/index.js +3 -3
  78. package/dist/{Field-D4UmRHlD.js → Field-Btyrw1hd.js} +2 -2
  79. package/dist/{FieldInfoTip-BSqcEcUx.js → FieldInfoTip-Dwl9HNp1.js} +1 -1
  80. package/dist/{FieldLabel-CZbayYFD.js → FieldLabel-B4l3sS4O.js} +3 -3
  81. package/dist/FieldStatus/index.d.ts +1 -1
  82. package/dist/FileInput/index.d.ts +1 -1
  83. package/dist/FileInput/index.js +1 -1
  84. package/dist/{FileInput-8oYiJsq_.js → FileInput-BUwV9fQa.js} +135 -85
  85. package/dist/FormLayout/index.js +1 -1
  86. package/dist/{FormLayout-CGJVeNsL.js → FormLayout-0_X9o-L4.js} +1 -1
  87. package/dist/Heading/index.d.ts +1 -1
  88. package/dist/Heading/index.js +1 -1
  89. package/dist/{Heading-COtyAhtB.js → Heading-BuZaxfIK.js} +1 -1
  90. package/dist/HoverCard/index.d.ts +1 -1
  91. package/dist/HoverCard/index.js +1 -1
  92. package/dist/{HoverCard-DGlOpk4x.js → HoverCard-CZhfsvP4.js} +2 -2
  93. package/dist/IconButton/index.js +1 -1
  94. package/dist/{IconButton-CwjHTIBg.js → IconButton-D9ZRJ7vD.js} +1 -1
  95. package/dist/Indicator/index.d.ts +2 -2
  96. package/dist/InfoTip/index.d.ts +1 -1
  97. package/dist/InfoTip/index.js +1 -1
  98. package/dist/{InfoTip-CNZateDb.js → InfoTip-BDo2xI8h.js} +2 -2
  99. package/dist/{InputClearButton-CzCP41sx.js → InputClearButton-C-j9Nf1s.js} +1 -1
  100. package/dist/InputGroup/index.d.ts +1 -1
  101. package/dist/InputGroup/index.js +1 -1
  102. package/dist/{InputGroup-CfUGHDNz.js → InputGroup-1Ukiu-dg.js} +6 -6
  103. package/dist/InternationalizationProvider/index.d.ts +1 -1
  104. package/dist/InternationalizationProvider/index.js +1 -1
  105. package/dist/{InternationalizationProvider-DaZS5Dch.js → InternationalizationProvider-B2Gv5yAm.js} +1 -1
  106. package/dist/{Item-DyaYlbyE.js → Item-DUI1Qnnd.js} +1 -1
  107. package/dist/Lightbox/index.js +1 -1
  108. package/dist/{Lightbox-Dzzd2Vqe.js → Lightbox-BOWTHnTb.js} +1 -1
  109. package/dist/Link/index.d.ts +1 -1
  110. package/dist/Link/index.js +1 -1
  111. package/dist/{Link-B7OJQ0zl.js → Link-ruNSnGtC.js} +2 -2
  112. package/dist/List/index.d.ts +1 -1
  113. package/dist/List/index.js +2 -2
  114. package/dist/{ListItem-gj_lOvEt.js → ListItem-C8SqSrU6.js} +1 -1
  115. package/dist/Markdown/index.js +1 -1
  116. package/dist/{Markdown-Cbj-nqhN.js → Markdown-C-KT_riK.js} +3 -3
  117. package/dist/MobileNav/index.js +1 -1
  118. package/dist/{MobileNavToggle-BlcdCg8M.js → MobileNavToggle-BGNYwwfI.js} +12 -0
  119. package/dist/MoreMenu/index.d.ts +1 -1
  120. package/dist/MoreMenu/index.js +1 -1
  121. package/dist/{MoreMenu-Dokwc4Mg.js → MoreMenu-DnwzVBEE.js} +17 -31
  122. package/dist/MultiSelector/index.d.ts +1 -1
  123. package/dist/MultiSelector/index.js +1 -1
  124. package/dist/{MultiSelector-CId8-qAX.js → MultiSelector-Cl_HzKvn.js} +25 -26
  125. package/dist/{NavDisclosure-CqAThYgR.js → NavDisclosure-B66SHKdd.js} +1 -1
  126. package/dist/{NavHeadingSurface-DJ4pWvEi.js → NavHeadingSurface-BZCzkCPJ.js} +1 -1
  127. package/dist/NavItem/index.d.ts +1 -1
  128. package/dist/NavItem/index.js +1 -1
  129. package/dist/{NavItem-_eIEwV41.js → NavItem-c1ScHEJY.js} +1 -1
  130. package/dist/NavMenu/index.js +3 -3
  131. package/dist/{NavMenu-BtA_Xbmr.js → NavMenu-pCZjhMHe.js} +2 -2
  132. package/dist/{NavMenuItem-BxfjAf1T.js → NavMenuItem-BIqpJmH6.js} +3 -3
  133. package/dist/NumberInput/index.d.ts +2 -2
  134. package/dist/NumberInput/index.js +1 -1
  135. package/dist/{NumberInput-Bl5TFhGD.js → NumberInput-Dz0H_XPw.js} +386 -99
  136. package/dist/Outline/index.js +1 -1
  137. package/dist/{Outline-NuPQMjxw.js → Outline-DvQbXc_H.js} +1 -1
  138. package/dist/OverflowList/index.d.ts +1 -1
  139. package/dist/OverflowList/index.js +1 -1
  140. package/dist/{OverflowList-CumJl6X_.js → OverflowList-MCN1PhBB.js} +2 -2
  141. package/dist/Overlay/index.d.ts +1 -1
  142. package/dist/Pagination/index.d.ts +1 -1
  143. package/dist/Pagination/index.js +1 -1
  144. package/dist/{Pagination-C0Bx80Tu.js → Pagination-Cq9BIzPe.js} +59 -48
  145. package/dist/Popover/index.d.ts +3 -3
  146. package/dist/Popover/index.js +1 -1
  147. package/dist/Popover-BJAyg1Qh.js +1247 -0
  148. package/dist/PowerSearch/index.js +1 -1
  149. package/dist/{PowerSearch-Dq6Gi9z1.js → PowerSearch-wXnusKnz.js} +19 -19
  150. package/dist/ProgressBar/index.d.ts +1 -1
  151. package/dist/ProgressBar/index.js +1 -1
  152. package/dist/{ProgressBar-Dp-0xquN.js → ProgressBar-C6x0E-BF.js} +1 -1
  153. package/dist/Radio/index.d.ts +1 -1
  154. package/dist/Radio/index.js +1 -1
  155. package/dist/{RadioGroup-IKBXLzYU.js → RadioGroup-LUDji_LA.js} +7 -7
  156. package/dist/RadioList/index.d.ts +1 -1
  157. package/dist/RadioList/index.js +1 -1
  158. package/dist/{RadioList-NW4fGKgm.js → RadioList-CmeUUgn-.js} +1 -1
  159. package/dist/Resizable/index.d.ts +1 -1
  160. package/dist/ScrollableArea/index.d.ts +1 -1
  161. package/dist/SegmentedControl/index.js +1 -1
  162. package/dist/{SegmentedControl-DRxcUlVP.js → SegmentedControl-BkWz-I2J.js} +2 -2
  163. package/dist/SelectableCard/index.d.ts +1 -1
  164. package/dist/SelectableCard/index.js +1 -1
  165. package/dist/{SelectableCard-Dp-LsEcf.js → SelectableCard-GRWYx3iD.js} +1 -1
  166. package/dist/Selector/index.d.ts +1 -1
  167. package/dist/Selector/index.js +1 -1
  168. package/dist/{Selector-BW_oxWDM.js → Selector-BL_JH51H.js} +30 -25
  169. package/dist/SideNav/index.d.ts +1 -1
  170. package/dist/SideNav/index.js +2 -2
  171. package/dist/{SideNav-B5mMRj98.js → SideNav-DtAQA-o-.js} +9 -9
  172. package/dist/Slider/index.d.ts +1 -1
  173. package/dist/Slider/index.js +1 -1
  174. package/dist/{Slider-oD3AY4jh.js → Slider-DEMdW9An.js} +4 -4
  175. package/dist/StatusDot/index.js +1 -1
  176. package/dist/{StatusDot-B3oOyRF7.js → StatusDot-_rucEf3d.js} +1 -1
  177. package/dist/Stepper/index.d.ts +1 -1
  178. package/dist/Stepper/index.js +1 -1
  179. package/dist/{Stepper-CgOdL36_.js → Stepper-CCuggsov.js} +1 -1
  180. package/dist/Switch/index.d.ts +1 -1
  181. package/dist/Switch/index.js +1 -1
  182. package/dist/{Switch-DG_A9cD0.js → Switch-BxRYZTQV.js} +6 -6
  183. package/dist/TabList/index.d.ts +1 -1
  184. package/dist/TabList/index.js +1 -1
  185. package/dist/{TabList-FkoypUk0.js → TabList-D8KzfcGB.js} +3 -3
  186. package/dist/Table/index.d.ts +1 -1
  187. package/dist/Table/index.js +1 -1
  188. package/dist/{Table-zNW23VwP.js → Table-DYDBgr3y.js} +15 -15
  189. package/dist/Text/index.d.ts +1 -1
  190. package/dist/Text/index.js +1 -1
  191. package/dist/{Text-v1ep26uD.js → Text-CHauN5So.js} +1 -1
  192. package/dist/TextArea/index.d.ts +1 -1
  193. package/dist/TextArea/index.js +1 -1
  194. package/dist/{TextArea-BilHnmSs.js → TextArea-BJl6YH4p.js} +56 -22
  195. package/dist/TextInput/index.d.ts +1 -1
  196. package/dist/TextInput/index.js +1 -1
  197. package/dist/{TextInput-D6tHM2sA.js → TextInput-CGOVY0Zk.js} +78 -34
  198. package/dist/Theme/index.d.ts +2 -2
  199. package/dist/Thumbnail/index.js +1 -1
  200. package/dist/{Thumbnail-llGdnQM8.js → Thumbnail-C3MvJ67s.js} +3 -3
  201. package/dist/{TimeField-C5rcoaVu.js → TimeField-C2of7Ok5.js} +14 -33
  202. package/dist/TimeInput/index.d.ts +1 -1
  203. package/dist/TimeInput/index.js +1 -1
  204. package/dist/{TimeInput-D0N8nwrI.js → TimeInput-B_YY-IHW.js} +3 -3
  205. package/dist/Timer/index.d.ts +1 -1
  206. package/dist/Timer/index.js +1 -1
  207. package/dist/{Timer-65PfuoQ7.js → Timer-OULaFQFf.js} +1 -1
  208. package/dist/Timestamp/index.d.ts +1 -1
  209. package/dist/Timestamp/index.js +1 -1
  210. package/dist/{Timestamp-rYC8mE3r.js → Timestamp-B6J0nfYH.js} +3 -3
  211. package/dist/Toast/index.js +1 -1
  212. package/dist/{Toast-BtQ-4Y6Z.js → Toast-BKPl8iIr.js} +1 -1
  213. package/dist/ToggleButton/index.d.ts +1 -1
  214. package/dist/ToggleButton/index.js +1 -1
  215. package/dist/{ToggleButton-Bnn_MiOn.js → ToggleButton-DfpsuhMa.js} +3 -3
  216. package/dist/Token/index.js +1 -1
  217. package/dist/{Token-B-j3AKxB.js → Token-C7Dt5ygK.js} +1 -1
  218. package/dist/Tokenizer/index.d.ts +1 -1
  219. package/dist/Tokenizer/index.js +1 -1
  220. package/dist/{Tokenizer-Cpdy_L00.js → Tokenizer-CSmIMDc4.js} +6 -6
  221. package/dist/Toolbar/index.d.ts +1 -1
  222. package/dist/Tooltip/index.d.ts +1 -1
  223. package/dist/Tooltip/index.js +2 -2
  224. package/dist/{Tooltip-CByjfHBZ.js → Tooltip-gT9_hIEv.js} +1 -1
  225. package/dist/TopNav/index.d.ts +1 -1
  226. package/dist/TopNav/index.js +1 -1
  227. package/dist/{TopNav-q8xDVlM_.js → TopNav-BsrhSbkn.js} +5 -5
  228. package/dist/TreeList/index.d.ts +1 -1
  229. package/dist/TreeList/index.js +1 -1
  230. package/dist/{TreeList-CEGInQtF.js → TreeList-BEPHdVYu.js} +3 -3
  231. package/dist/Typeahead/index.d.ts +2 -2
  232. package/dist/Typeahead/index.js +2 -2
  233. package/dist/{Typeahead-C-PdRnRQ.js → Typeahead-CdLc7S2v.js} +7 -7
  234. package/dist/{types-fRasDCe4.d.ts → adaptationTypes-Cn_pfrsw.d.ts} +155 -155
  235. package/dist/animator-BooLoGyI.js +3164 -0
  236. package/dist/announceRenderedText-CslZ0cev.js +50 -0
  237. package/dist/{assertOptions-og3t30Fh.js → assertOptions-CFn7Gdcr.js} +22 -2
  238. package/dist/{batch-oTkSbtVz.js → batch-CM-vJhQg.js} +3 -279
  239. package/dist/{handle-CSHfxBie.js → bezier-Cts7gENO.js} +3 -22
  240. package/dist/{clickGuard-ChKuogmR.js → clickGuard-FrlnECMp.js} +1 -2
  241. package/dist/coarsePointer-BfMx3H23.js +86 -0
  242. package/dist/composables/index.d.ts +2 -2
  243. package/dist/composables/index.js +7 -7
  244. package/dist/{composables-COCeg92e.js → composables-D9DVeNnL.js} +10 -3271
  245. package/dist/{context-DsNhYm5O.js → context-CrVCeUUK.js} +1 -1
  246. package/dist/context-DH8E-qjm.js +173 -0
  247. package/dist/{edge-3sC8-cbB.js → edge-BYXwSggM.js} +1 -1
  248. package/dist/{edgeRide-DOxmVxTM.js → edgeRide-B5mlN2Q4.js} +4 -4
  249. package/dist/escape-DzSxSmez.js +10 -0
  250. package/dist/{field-CehUqCe0.js → field-BaUBjqf5.js} +4 -2
  251. package/dist/{fieldParts-CbWvZLhH.js → fieldParts-CuE5V12i.js} +1 -1
  252. package/dist/{sharedRealm-H1OrlP0V.js → flatTree-BB4yPMNL.js} +1 -49
  253. package/dist/handle-BazRxHwq.js +22 -0
  254. package/dist/holdEntranceInput-DMCOeRqu.js +37 -0
  255. package/dist/{index-CuW4AQ7M.d.ts → index--kbwaSXW.d.ts} +1 -1
  256. package/dist/{index-CsYDrQ9R.d.ts → index-668zPVsH.d.ts} +1 -1
  257. package/dist/{index-_FjbcSgD.d.ts → index-7Q-wnbe7.d.ts} +1 -1
  258. package/dist/{index-Q1oG9yIT.d.ts → index-B-3EGjfQ.d.ts} +2 -2
  259. package/dist/{index-HULXozsK.d.ts → index-B3uBbehw.d.ts} +8 -8
  260. package/dist/{index-X4S7_dmq.d.ts → index-BA8exXNP.d.ts} +1 -1
  261. package/dist/{index-CnVjgLP5.d.ts → index-BCW6qCcS.d.ts} +1 -1
  262. package/dist/{index-QnlWyUxN.d.ts → index-BFGtLIp8.d.ts} +2 -2
  263. package/dist/{index-DDAcxZAP.d.ts → index-BZUVNr2c.d.ts} +1 -1
  264. package/dist/{index-BWcZ-L80.d.ts → index-BcRvRqWU.d.ts} +1 -1
  265. package/dist/{index-CEjvYAUZ.d.ts → index-BenG-F5d.d.ts} +1 -1
  266. package/dist/{index-ZKBj_1nu.d.ts → index-BfFpUr1B.d.ts} +1 -1
  267. package/dist/{index-DofC9Rll.d.ts → index-BtqvPjAf.d.ts} +1 -1
  268. package/dist/{index-BDZCJ9ri.d.ts → index-BuubzuE8.d.ts} +2 -2
  269. package/dist/{index-mK1ICsVg.d.ts → index-C3JmGujU.d.ts} +1 -1
  270. package/dist/{index-CKnr0JlT.d.ts → index-C4S65SAW.d.ts} +1 -1
  271. package/dist/{index-waTkqxTz.d.ts → index-C89cIh4E.d.ts} +1 -1
  272. package/dist/{index-D05JGsT3.d.ts → index-C8wfe0Mr.d.ts} +1 -1
  273. package/dist/{index-BfoazhEu.d.ts → index-CTXG-KKT.d.ts} +1 -1
  274. package/dist/{index-COgrQZIL.d.ts → index-CdvmnNMH.d.ts} +1 -1
  275. package/dist/{index-lmd9LZKB.d.ts → index-ClJINYPl.d.ts} +5 -2
  276. package/dist/{index-rdwI-mcm.d.ts → index-CtYlR9Cu.d.ts} +1 -1
  277. package/dist/index-CuFLztiI.d.ts +49 -0
  278. package/dist/{index-BOCb89V9.d.ts → index-DFLPv9io.d.ts} +2 -2
  279. package/dist/index-DHUCHxn2.d.ts +69 -0
  280. package/dist/{index-85RFPeV0.d.ts → index-DHsYyqMP.d.ts} +5 -5
  281. package/dist/{index-GmoeIuhl.d.ts → index-DMZ5SKJJ.d.ts} +35 -3
  282. package/dist/{index-DYabo8TI.d.ts → index-DPhQZXYw.d.ts} +1 -1
  283. package/dist/{index-DRDOArzq.d.ts → index-DSEEgvak.d.ts} +1152 -214
  284. package/dist/{index-DxR6cZBf.d.ts → index-DZCpswvp.d.ts} +1 -1
  285. package/dist/{index-etx25Eq-.d.ts → index-NOxH5oYj.d.ts} +1 -1
  286. package/dist/{index-CH-xSiJz.d.ts → index-XY0rleGM.d.ts} +2 -2
  287. package/dist/{index-0RIgvtdm.d.ts → index-ZXrvTM3A.d.ts} +2 -2
  288. package/dist/{index-DGXCnzOL.d.ts → index-aHC2C89h.d.ts} +1 -1
  289. package/dist/{index-0pBqcQXV.d.ts → index-tpkJfk6X.d.ts} +6 -1
  290. package/dist/index.d.ts +43 -44
  291. package/dist/index.js +101 -101
  292. package/dist/inputHold-BmChuR9x.js +525 -0
  293. package/dist/inputHoldState-pblUT4oh.js +39 -0
  294. package/dist/inputStream-LZdK8luP.js +239 -0
  295. package/dist/{landing-DFC97kl9.js → landing-B9Uvex6x.js} +3 -2
  296. package/dist/lazyBottomSheet-CL_PrTxb.js +16 -0
  297. package/dist/{loadCatalog-C8mRnC0E.d.ts → loadCatalog-2Hu-xisJ.d.ts} +2 -0
  298. package/dist/{loadCatalog-BeQt6Uq-.js → loadCatalog-umh_C97k.js} +2 -1
  299. package/dist/locale/index.d.ts +2 -2
  300. package/dist/locale/index.js +3 -3
  301. package/dist/{locale-B4FpGKpc.js → locale-BDPlcO62.js} +1 -1
  302. package/dist/presentationHold-7IkbR4d8.js +118 -0
  303. package/dist/{pressFeedback-CEUPQWIS.js → pressFeedback-DVR5V1b6.js} +3 -164
  304. package/dist/progress-FQfSgLZC.js +38 -0
  305. package/dist/renderedText-BwJdmps3.js +32 -0
  306. package/dist/{stillPointerGate-1Tgkns0J.js → stillPointerGate-D3loXLh7.js} +1 -1
  307. package/dist/textEntryTraits-cb0LZSNl.js +11 -0
  308. package/dist/themeTiming-CWEvdh31.js +287 -0
  309. package/dist/{tooltipFocusRules-vIH7PZh1.js → tooltipFocusRules-CFNKWzYn.js} +1 -1
  310. package/dist/{tooltipTriggerRules-DoBAbfGc.js → tooltipTriggerRules-DyPyWOdP.js} +1 -1
  311. package/dist/touchHold-CFJlSClt.js +30 -0
  312. package/dist/{context-DQPBIsl5.js → transientCopy-VAsg2a46.js} +1 -172
  313. package/dist/{types-OGMYGejX.d.ts → types-BA1veIoa.d.ts} +25 -2
  314. package/dist/{types-bAQk3F8G.d.ts → types-Cvh2VwQZ.d.ts} +4 -2
  315. package/dist/{types-C1ydeFiu.d.ts → types-DL-hRibg.d.ts} +1 -1
  316. package/dist/{useActionGroupTracking-PVBCtLUE.js → useActionGroupTracking-C6BzQzvp.js} +2 -2
  317. package/dist/{useChatStreamScroll-BIMKffDA.js → useChatStreamScroll-Cv51kRT0.js} +91 -30
  318. package/dist/{useDismiss-CMIsdIOQ.js → useDismiss-C7_S7qUA.js} +87 -5
  319. package/dist/useEntryErrorReport-Wee3N8IA.js +51 -0
  320. package/dist/useHeldPresentation-7MH-RlSF.js +24 -0
  321. package/dist/{useInputStatusIcon-CrgeMzrf.js → useInputStatusIcon-BFw-EXjJ.js} +1 -1
  322. package/dist/{useInputStatusIcon-B6m_t8cK.d.ts → useInputStatusIcon-CFkOmDS4.d.ts} +1 -1
  323. package/dist/{useMenuDrillIn-CQrzwZvx.js → useMenuDrillIn-CP0P49ej.js} +9 -8
  324. package/dist/{useMenuPress-wqRDvUMW.js → useMenuPress-Di_3jhOx.js} +5 -3
  325. package/dist/{usePressFeedback-aufF1sCH.js → usePressFeedback-BhNcuxQv.js} +1 -1
  326. package/dist/{useTooltip-BwqzEtoF.js → useTooltip-BpBMQ815.js} +4 -34
  327. package/dist/{useTouchHitArea-BMDBe36j.js → useTouchHitArea-CNZyA18Y.js} +2 -2
  328. package/dist/{useTruncationTooltip-CRhoPzeu.js → useTruncationTooltip-t5G978XB.js} +3 -3
  329. package/dist/{useTypeaheadMenuConfig-GvdIymRg.js → useTypeaheadMenuConfig-DeDGVR8S.js} +1 -1
  330. package/package.json +1 -1
  331. package/styles/alert-dialog.css +5 -0
  332. package/styles/chat.css +45 -17
  333. package/styles/context-menu.css +17 -73
  334. package/styles/dialog.css +18 -1
  335. package/styles/dropdown-menu.css +47 -38
  336. package/styles/file-input.css +8 -1
  337. package/styles/hover-card.css +13 -72
  338. package/styles/input-group.css +0 -15
  339. package/styles/layer.css +68 -0
  340. package/styles/multi-selector.css +17 -30
  341. package/styles/number-input.css +49 -4
  342. package/styles/pagination.css +0 -22
  343. package/styles/popover.css +26 -72
  344. package/styles/selector.css +17 -30
  345. package/styles/text-area.css +16 -1
  346. package/styles/text-input.css +26 -5
  347. package/styles/tooltip.css +12 -71
  348. package/styles/typeahead.css +17 -30
  349. package/dist/Popover-DpR4rwiW.js +0 -374
  350. package/dist/index-B9WzWqzk.d.ts +0 -18
  351. package/dist/index-CyMStZq4.d.ts +0 -957
  352. package/dist/types-DIYwbkpe.d.ts +0 -33
@@ -1,15 +1,18 @@
1
- import { a as sharedWeakMap, c as deepActiveElement, d as shadowRootsOutward, h as isNode, i as sharedState, l as parentAcrossShadow, m as isHTMLElement, n as sharedKey, p as isElement, s as containsAlongFlatTree, t as realmValue, u as shadowHostOf } from "./sharedRealm-H1OrlP0V.js";
2
- import { d as isInsideScrollView, f as parseTouchAction, l as subscribeInput, m as clockOf, p as rootOverflow, u as SCROLLABLE_OVERFLOW } from "./pressFeedback-CEUPQWIS.js";
3
- import { i as withoutClickGuard, n as disarmClickGuard, t as armClickGuard } from "./clickGuard-ChKuogmR.js";
4
- import { b as isSpring, c as UIKIT_PAN, d as UIKIT_VELOCITY, f as registerScrollTable, h as motionRoleOf, l as UIKIT_PRESS, m as motionRoleIn, p as scroll, s as UIKIT_LONG_PRESS, u as UIKIT_TAP, v as registerMotionTable, y as registerSpringRole } from "./pressGesture-BzIBmKF2.js";
1
+ import { a as shadowRootsOutward, c as isHTMLElement, i as shadowHostOf, l as isNode, n as deepActiveElement, r as parentAcrossShadow, s as isElement, t as containsAlongFlatTree } from "./flatTree-BB4yPMNL.js";
2
+ import { d as parseTouchAction, f as rootOverflow, l as SCROLLABLE_OVERFLOW, p as clockOf, u as isInsideScrollView } from "./pressFeedback-DVR5V1b6.js";
3
+ import { i as withoutClickGuard, n as disarmClickGuard, t as armClickGuard } from "./clickGuard-FrlnECMp.js";
4
+ import { a as realmValue, i as subscribeInput, l as sharedWeakMap, o as sharedKey } from "./inputStream-LZdK8luP.js";
5
+ import { a as solveSpring, i as motionNow, n as resolveMotion, o as toSpring, r as SETTLE_THRESHOLD, t as createMotionEngine } from "./animator-BooLoGyI.js";
6
+ import { c as UIKIT_PAN, d as UIKIT_VELOCITY, f as registerScrollTable, l as UIKIT_PRESS, p as scroll, s as UIKIT_LONG_PRESS, u as UIKIT_TAP, v as registerMotionTable, y as registerSpringRole } from "./pressGesture-BzIBmKF2.js";
5
7
  import { o as pushLayer } from "./layerDepth-D3Rh8T5C.js";
6
8
  import { t as useMediaQuery } from "./useMediaQuery-BzXGT1Aw.js";
7
- import { t as quietFinished } from "./quietFinished-CKZXgsPM.js";
8
- import { a as reducedMotionCrossFade, c as clearPresentedResolve, d as registerPresentedOffset, f as resolvePresented, h as themeReducesMotion, i as cubicBezier, l as presentedElements, m as writePresentedResolve, n as createAnimatedLayout, o as registerReducedMotionCrossFade, p as watchPresentedElements, u as presentedOffsetOf } from "./handle-CSHfxBie.js";
9
- import { n as isDevBuild } from "./devBuild-G249YcdZ.js";
9
+ import { l as resolvePresented, o as presentedElements, s as presentedOffsetOf, u as watchPresentedElements } from "./bezier-Cts7gENO.js";
10
10
  import { t as devWarn } from "./useDevWarning-B2fsk2B-.js";
11
11
  import { t as isApplePlatform } from "./isApplePlatform-B1ju6F5B.js";
12
+ import { a as isIosWebKit, r as watchCoarsePointer, t as isCoarsePointer } from "./coarsePointer-BfMx3H23.js";
12
13
  import { n as isRtlElement } from "./useListFocus-CkHfsZp0.js";
14
+ import { t as holdsTouch } from "./touchHold-CFJlSClt.js";
15
+ import { n as createAnimatedLayout } from "./handle-BazRxHwq.js";
13
16
  import { o as useComponentMessages } from "./context-B8IEFCDR.js";
14
17
  import { t as _sfc_main$1 } from "./Kbd-CbD993ig.js";
15
18
  import { t as keyboardHintMessages } from "./keyboard-hint-KWx0-7kD.js";
@@ -19,3164 +22,6 @@ import { t as useTouchTriggerInternal } from "./useTouchTriggerInternal-Bdm_M4aa
19
22
  import { Fragment, computed, createBlock, createElementBlock, createElementVNode, defineComponent, getCurrentInstance, getCurrentScope, h, normalizeStyle, onBeforeUnmount, onMounted, onScopeDispose, openBlock, ref, renderList, toDisplayString, toValue, unref, vShow, watch, withDirectives } from "vue";
20
23
  import "../styles/indicator-focus-ring.css";
21
24
  import "../styles/keyboard-hint.css";
22
- //#region src/motion/springParameters.ts
23
- /**
24
- * @file springParameters.ts
25
- * @output The `Spring` model and the conversions between Apple's spring
26
- * vocabularies (duration and bounce, response and damping ratio, mass,
27
- * stiffness and damping), and UIKit's relative velocity
28
- * @position Pure math under spring.ts, which re-exports all of it. See
29
- * spring.ts for the sources of each conversion.
30
- */
31
- const TAU = 2 * Math.PI;
32
- function assertPositiveFinite(name, value) {
33
- if (!(Number.isFinite(value) && value > 0)) throw new RangeError(`spring: ${name} must be a positive number, got ${value}`);
34
- }
35
- /**
36
- * SwiftUI's `Spring(duration:bounce:)` and UIKit's
37
- * `UIView.animate(springDuration:bounce:…)`: the WWDC23 equations. Bounce is
38
- * clamped to SwiftUI's documented range (−1, 1].
39
- *
40
- * @example
41
- * ```
42
- * springFromDurationBounce({duration: 0.5, bounce: 0}); // SwiftUI .smooth
43
- * ```
44
- */
45
- function springFromDurationBounce({ duration, bounce }) {
46
- assertPositiveFinite("duration", duration);
47
- if (!Number.isFinite(bounce)) throw new RangeError(`spring: bounce must be finite, got ${bounce}`);
48
- const b = Math.min(1, Math.max(-.999999, bounce));
49
- return {
50
- mass: 1,
51
- stiffness: (TAU / duration) ** 2,
52
- damping: b >= 0 ? (1 - b) * 2 * TAU / duration : 2 * TAU / (duration * (1 + b))
53
- };
54
- }
55
- /**
56
- * SwiftUI's `Spring(response:dampingRatio:)` and
57
- * `Animation.spring(response:dampingFraction:)`. Overdamping (ratio > 1) is
58
- * kept, as SwiftUI keeps it for this initializer.
59
- */
60
- function springFromResponse({ response, dampingRatio }) {
61
- assertPositiveFinite("response", response);
62
- if (!(Number.isFinite(dampingRatio) && dampingRatio >= 0)) throw new RangeError(`spring: dampingRatio must be ≥ 0, got ${dampingRatio}`);
63
- const omega = TAU / response;
64
- return {
65
- mass: 1,
66
- stiffness: omega * omega,
67
- damping: 2 * dampingRatio * omega
68
- };
69
- }
70
- /**
71
- * `CASpringAnimation` / `UISpringTimingParameters(mass:stiffness:damping:)`
72
- * / SwiftUI `Spring(mass:stiffness:damping:allowOverDamping:)`. Like SwiftUI,
73
- * an overdamped spring is treated as critically damped unless
74
- * `allowOverdamping` is set: "a value of false specifies that such cases
75
- * should instead be treated as critically damped".
76
- */
77
- function springFromPhysics({ mass = 1, stiffness, damping, allowOverdamping = false }) {
78
- assertPositiveFinite("mass", mass);
79
- assertPositiveFinite("stiffness", stiffness);
80
- if (!(Number.isFinite(damping) && damping >= 0)) throw new RangeError(`spring: damping must be ≥ 0, got ${damping}`);
81
- const critical = 2 * Math.sqrt(stiffness * mass);
82
- return {
83
- mass,
84
- stiffness,
85
- damping: allowOverdamping ? damping : Math.min(damping, critical)
86
- };
87
- }
88
- /** Undamped angular frequency ω₀ = √(k/m), rad/s. */
89
- function naturalFrequency(spring) {
90
- return Math.sqrt(spring.stiffness / spring.mass);
91
- }
92
- /** Damping ratio ζ = c / (2·√(k·m)). */
93
- function dampingRatioOf(spring) {
94
- return spring.damping / (2 * Math.sqrt(spring.stiffness * spring.mass));
95
- }
96
- /**
97
- * Normalizes a description to the physical `Spring`. A physical description
98
- * gets `springFromPhysics`' treatment: overdamping is clamped to critical, as
99
- * SwiftUI and Core Animation do by default.
100
- */
101
- function toSpring(description) {
102
- if ("stiffness" in description) return springFromPhysics(description);
103
- if ("bounce" in description) return springFromDurationBounce(description);
104
- return springFromResponse(description);
105
- }
106
- //#endregion
107
- //#region src/motion/spring.ts
108
- /**
109
- * Closed-form solution of the spring released at `from` with
110
- * `initialVelocity` (units/s), heading for `to`.
111
- *
112
- * @example
113
- * ```
114
- * const curve = solveSpring(springFromDurationBounce({duration: 0.5, bounce: 0}), {from: 0, to: 300});
115
- * curve.value(0.1); // px after 100 ms
116
- * ```
117
- */
118
- function solveSpring(spring, { from, to, velocity: initialVelocity = 0 }) {
119
- const omega0 = naturalFrequency(spring);
120
- const zeta = dampingRatioOf(spring);
121
- const x0 = from - to;
122
- const v0 = initialVelocity;
123
- let displacement;
124
- let speed;
125
- let envelope;
126
- let envelopePeak = 0;
127
- if (zeta < .999999) {
128
- const decay = zeta * omega0;
129
- const omegaD = omega0 * Math.sqrt(1 - zeta * zeta);
130
- const a = x0;
131
- const b = (v0 + decay * x0) / omegaD;
132
- const bv = (decay * v0 + omega0 * omega0 * x0) / omegaD;
133
- displacement = (t) => Math.exp(-decay * t) * (a * Math.cos(omegaD * t) + b * Math.sin(omegaD * t));
134
- speed = (t) => Math.exp(-decay * t) * (v0 * Math.cos(omegaD * t) - bv * Math.sin(omegaD * t));
135
- const amplitude = Math.abs(a) + Math.abs(b);
136
- envelope = (t) => amplitude * Math.exp(-decay * t);
137
- } else if (zeta <= 1.000001) {
138
- const b = v0 + omega0 * x0;
139
- displacement = (t) => (x0 + b * t) * Math.exp(-omega0 * t);
140
- speed = (t) => (v0 - omega0 * b * t) * Math.exp(-omega0 * t);
141
- const absA = Math.abs(x0);
142
- const absB = Math.abs(b);
143
- envelope = (t) => (absA + absB * t) * Math.exp(-omega0 * t);
144
- envelopePeak = absB > 0 ? Math.max(0, 1 / omega0 - absA / absB) : 0;
145
- } else {
146
- const root = omega0 * Math.sqrt(zeta * zeta - 1);
147
- const r1 = -zeta * omega0 + root;
148
- const r2 = -zeta * omega0 - root;
149
- const c1 = (v0 - r2 * x0) / (r1 - r2);
150
- const c2 = x0 - c1;
151
- displacement = (t) => c1 * Math.exp(r1 * t) + c2 * Math.exp(r2 * t);
152
- speed = (t) => r1 * c1 * Math.exp(r1 * t) + r2 * c2 * Math.exp(r2 * t);
153
- const absC1 = Math.abs(c1);
154
- const absC2 = Math.abs(c2);
155
- envelope = (t) => absC1 * Math.exp(r1 * t) + absC2 * Math.exp(r2 * t);
156
- }
157
- const settleTime = (threshold) => {
158
- if (!(threshold > 0)) return Infinity;
159
- if (zeta === 0) return x0 === 0 && v0 === 0 ? 0 : Infinity;
160
- const start = envelopePeak;
161
- if (envelope(start) <= threshold) return 0;
162
- if (zeta < .999999) {
163
- const amplitude = envelope(0);
164
- return Math.log(amplitude / threshold) / (zeta * omega0);
165
- }
166
- let lo = start;
167
- let hi = Math.max(start, 1 / omega0);
168
- while (envelope(hi) > threshold) {
169
- lo = hi;
170
- hi *= 2;
171
- if (hi > 1e6) return Infinity;
172
- }
173
- for (let i = 0; i < 100 && hi - lo > 1e-12; i++) {
174
- const mid = (lo + hi) / 2;
175
- if (envelope(mid) > threshold) lo = mid;
176
- else hi = mid;
177
- }
178
- return hi;
179
- };
180
- return {
181
- spring,
182
- from,
183
- to,
184
- initialVelocity,
185
- value: (t) => to + displacement(t),
186
- velocity: (t) => speed(t),
187
- settleTime
188
- };
189
- }
190
- //#endregion
191
- //#region src/motion/engine/constants.ts
192
- const PROPERTIES = [
193
- "x",
194
- "y",
195
- "rotate",
196
- "scaleX",
197
- "scaleY",
198
- "opacity"
199
- ];
200
- /** The axes momentum moves: `decay` takes only these (DR2, DEC-2). */
201
- const DECAY_PROPERTIES = ["x", "y"];
202
- const IDENTITY = {
203
- x: 0,
204
- y: 0,
205
- rotate: 0,
206
- scaleX: 1,
207
- scaleY: 1,
208
- opacity: 1
209
- };
210
- /**
211
- * Keyframes are added until linear interpolation is within this: a quarter of
212
- * a device pixel (this quarter of a CSS pixel, divided by the device pixel
213
- * ratio where it is above 1), a twentieth of a degree, a 2000th of the size,
214
- * about one step of an 8-bit alpha. Every one is below what a moving element
215
- * can show.
216
- */
217
- const SAMPLE_TOLERANCE = {
218
- x: .25,
219
- y: .25,
220
- rotate: .05,
221
- scaleX: 5e-4,
222
- scaleY: 5e-4,
223
- opacity: .004
224
- };
225
- /** Keyframes start on this grid (ms) and are split where the curve needs it. */
226
- const SAMPLE_GRID_MS = 1e3 / 30;
227
- /** A curve that has not settled by then (an undamped spring) snaps. */
228
- const MAX_DURATION_MS = 3e4;
229
- /**
230
- * The keyframes hold the end state this long after a curve ends. An engine
231
- * whose compositor ends an animation while the main thread is blocked falls
232
- * back to the value its main thread last committed, the curve's start
233
- * (WebKit on Linux); the hold keeps the end state on screen through any such
234
- * block. It only stretches the last keyframe. The main thread retires the
235
- * animation as soon as it runs after the curve's end.
236
- *
237
- * Why a tail inside the curve's own animation, with a bound (measured Oct 24
238
- * 2026; do not replace it without these proofs):
239
- * - WebKit on Linux (WebKitGTK and WPE) ignores `fill` on its compositor:
240
- * a 400 ms move that ends during a 1 s main-thread block snaps back to the
241
- * block-start position 13 ms after its end, with `fill: forwards` or with
242
- * no fill, and holds with this tail. iOS 26.2 Mobile Safari holds the end
243
- * in all three forms, so there the tail is unneeded but harmless (measured
244
- * Oct 25 2026). The browser proof "a spring that ends inside the block
245
- * keeps showing its end state" catches it.
246
- * - A separate static animation of the end state under the curve would hold
247
- * it without a bound, but two animations on one property push Chromium to
248
- * run the curve on the main thread: the 1 s block proof moved in 0 of 57
249
- * frames, the start-before-a-block proof failed, and seeking the curve
250
- * broke.
251
- */
252
- const END_HOLD_MS = 6e4;
253
- /**
254
- * The soonest a running animation's end is looked for again, ms: a frame at
255
- * 60 Hz. WebKit moves an animation's currentTime once per frame, so a look
256
- * within a frame reads the frame's time, a fraction of a ms short of the end,
257
- * and a timer for that fraction would fire again before anything moved.
258
- */
259
- const END_RECHECK_MS = 1e3 / 60;
260
- const CHANNELS$1 = {
261
- translate: ["x", "y"],
262
- rotate: ["rotate"],
263
- scale: ["scaleX", "scaleY"],
264
- opacity: ["opacity"]
265
- };
266
- const CHANNEL_OF = {
267
- x: "translate",
268
- y: "translate",
269
- rotate: "rotate",
270
- scaleX: "scale",
271
- scaleY: "scale",
272
- opacity: "opacity"
273
- };
274
- /** What `inlineText` writes for each channel at identity. */
275
- const IDENTITY_TEXT = {
276
- translate: "none",
277
- rotate: "none",
278
- scale: "none",
279
- opacity: "1"
280
- };
281
- /**
282
- * The transition `decay` hands a Reduce Motion transition curve to: under
283
- * Reduce Motion `animate` plays no spring (a cross-fade, or at once), so the
284
- * spring itself is never solved.
285
- */
286
- const REDUCED_TRANSITION = { spring: {
287
- duration: .5,
288
- bounce: 0
289
- } };
290
- //#endregion
291
- //#region src/motion/engine/cssValues.ts
292
- function round(value, digits) {
293
- return Number(value.toFixed(digits));
294
- }
295
- function format(channel, value) {
296
- switch (channel) {
297
- case "translate": return `${round(value("x"), 3)}px ${round(value("y"), 3)}px`;
298
- case "rotate": return `${round(value("rotate"), 4)}deg`;
299
- case "scale": return `${round(value("scaleX"), 5)} ${round(value("scaleY"), 5)}`;
300
- case "opacity": return `${round(Math.min(1, Math.max(0, value("opacity"))), 4)}`;
301
- }
302
- }
303
- /**
304
- * Whether a computed value shows `expected` (`format`'s text). An unset or
305
- * `none` value is the channel's identity. One value of a two-value channel
306
- * stands for both (scale), or for x with y at 0 (translate).
307
- */
308
- function sameShown(channel, shown, expected) {
309
- const numbers = (text) => {
310
- const list = ((text === "" || text === "none" ? IDENTITY_TEXT[channel] : text).match(/-?\d*\.?\d+(?:e-?\d+)?/g) ?? []).map(Number);
311
- if (channel === "translate") return [list[0] ?? 0, list[1] ?? 0];
312
- if (channel === "scale") return [list[0] ?? 1, list[1] ?? list[0] ?? 1];
313
- return list.length > 0 ? list : [channel === "opacity" ? 1 : 0];
314
- };
315
- const a = numbers(shown);
316
- const b = numbers(expected);
317
- return a.length === b.length && a.every((value, i) => Math.abs(value - b[i]) < .001);
318
- }
319
- /**
320
- * The inline text for a channel: `format`, except that an identity transform
321
- * is written `none`. Any other value, `translate: 0px 0px` included, makes
322
- * the element the containing block of its `position: fixed` descendants and
323
- * a stacking context, so a motion back to identity would leave a fixed child
324
- * moved with its parent; Mobile Safari also lets no finger scroll a list
325
- * inside an element left at `scale: 1`. At rest the identity leaves the
326
- * element entirely when its stylesheet agrees (`releaseIdentity`).
327
- */
328
- function inlineText(channel, value) {
329
- const at = (property, identity, digits) => round(value(property), digits) === identity;
330
- switch (channel) {
331
- case "translate": return at("x", 0, 3) && at("y", 0, 3) ? "none" : format(channel, value);
332
- case "rotate": return at("rotate", 0, 4) ? "none" : format(channel, value);
333
- case "scale": return at("scaleX", 1, 5) && at("scaleY", 1, 5) ? "none" : format(channel, value);
334
- case "opacity": return format(channel, value);
335
- }
336
- }
337
- /** Whether a computed value (or an unset one) is the channel's identity. */
338
- function isIdentityText(channel, text) {
339
- const value = text.trim();
340
- if (value === "" || value === "none") return true;
341
- const numbers = value.split(/\s+/).map((part) => Number.parseFloat(part));
342
- if (numbers.some((number) => !Number.isFinite(number))) return false;
343
- const identity = channel === "scale" || channel === "opacity" ? 1 : 0;
344
- return numbers.every((number) => Math.abs(number - identity) < 1e-6);
345
- }
346
- function expand(values) {
347
- const out = {};
348
- for (const [key, value] of Object.entries(values)) {
349
- if (value == null || !Number.isFinite(value)) continue;
350
- if (key === "scale") {
351
- out.scaleX ??= value;
352
- out.scaleY ??= value;
353
- } else if (PROPERTIES.includes(key)) out[key] = value;
354
- }
355
- return out;
356
- }
357
- /** The time the motion clock reads (`performance.now()`'s time base). */
358
- function motionNow() {
359
- return typeof performance === "undefined" ? Date.now() : performance.now();
360
- }
361
- /**
362
- * Whether the user asked for reduced motion (`prefers-reduced-motion:
363
- * reduce`), read at the moment of the call: the preference the animator uses
364
- * by default for its Reduce Motion substitution. A component never reads it
365
- * to pick a curve of its own: its motion settings do not override the
366
- * policy (design:reduced-motion DR4); `animator.reducedMotion()` or
367
- * `reducedMotionFade()` gives the policy's answer. False without a window
368
- * (server rendering).
369
- */
370
- function defaultPrefersReducedMotion() {
371
- return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
372
- }
373
- /** Whether the primary pointer is coarse: `(pointer: coarse)`. */
374
- function defaultIsCoarsePointer() {
375
- return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(pointer: coarse)").matches;
376
- }
377
- /**
378
- * Registers `name` as an inherited `<length>` (initially 0px) or `<number>`
379
- * (initially 0) so keyframes interpolate it; an unregistered custom property
380
- * animates in steps. A property the page already registered is left as it
381
- * is.
382
- */
383
- function registerCustomProperty(name, syntax) {
384
- if (typeof CSS === "undefined" || typeof CSS.registerProperty !== "function") return;
385
- try {
386
- CSS.registerProperty({
387
- name,
388
- syntax,
389
- inherits: true,
390
- initialValue: syntax === "<length>" ? "0px" : "0"
391
- });
392
- } catch (error) {
393
- if (!(error instanceof DOMException) || error.name !== "InvalidModificationError") throw error;
394
- }
395
- }
396
- function expandList(properties) {
397
- const out = /* @__PURE__ */ new Set();
398
- for (const property of properties) if (property === "scale") {
399
- out.add("scaleX");
400
- out.add("scaleY");
401
- } else out.add(property);
402
- return [...out];
403
- }
404
- //#endregion
405
- //#region src/motion/engine/taskClock.ts
406
- /** The task the current calls from rest are made in, until it ends. */
407
- let openTask = null;
408
- /** How many of the animators' animation-frame callbacks are running now. */
409
- const frameNesting = { depth: 0 };
410
- /** The mark of the running task, opened by its first call from rest. */
411
- function markTask(time, clock) {
412
- if (openTask == null) {
413
- const task = { first: time };
414
- openTask = task;
415
- queueMicrotask(() => {
416
- task.ended = clock();
417
- openTask = null;
418
- });
419
- }
420
- return openTask;
421
- }
422
- /** The first read of the time an animation frame runs, by its timestamp. */
423
- let frameRead = null;
424
- /** The first motion call on a clock since the last microtask checkpoint. */
425
- let openCall = null;
426
- /**
427
- * The time of a motion call with no explicit clock. It is the time of the
428
- * first such call on the same clock since the last microtask checkpoint. One
429
- * event listener or frame callback thus shares one clock. So calls on
430
- * several animators in one callback, such as a pager's children, line up, as
431
- * calls from rest share one start. A call more than LATE_START_MS after the
432
- * first opens a new clock: the curves that a block passed restart at their
433
- * frame instead.
434
- */
435
- function callTime(clock) {
436
- const time = clock();
437
- if (openCall != null && openCall.clock === clock && time - openCall.time <= 34) return openCall.time;
438
- const call = {
439
- time,
440
- clock
441
- };
442
- openCall = call;
443
- queueMicrotask(() => {
444
- if (openCall === call) openCall = null;
445
- });
446
- return time;
447
- }
448
- /**
449
- * Promotions that wait for their stylesheet's will-change, from every
450
- * animator, until the running callback's microtasks run.
451
- */
452
- const sheetReads = [];
453
- /**
454
- * Queues an element's stylesheet read for a microtask after the callback.
455
- * That microtask lifts every queued promotion, reads every stylesheet, and
456
- * then writes every promotion back. So motions that one callback starts force
457
- * one style pass, not one per element.
458
- */
459
- function queueSheetRead(read) {
460
- if (sheetReads.length === 0) queueMicrotask(flushSheetReads);
461
- sheetReads.push(read);
462
- }
463
- function flushSheetReads() {
464
- const reads = sheetReads.splice(0);
465
- for (const read of reads) read.lift();
466
- for (const read of reads) read.read();
467
- for (const read of reads) read.write();
468
- }
469
- /**
470
- * Per animator, the first of its calls that still wait for the frame that
471
- * commits them. An animator removes its entry once nothing of its waits: a
472
- * rebuild or a hidden page committed its calls, or it was disposed or moved.
473
- * The frame's first read takes every entry.
474
- */
475
- const waitingCalls = /* @__PURE__ */ new Map();
476
- /** The first waiting call, read once by the frame with this timestamp. */
477
- let waitingRead = null;
478
- /**
479
- * The first call that the animation frame with timestamp `frame` commits.
480
- * The frame reads it once, so every animator in it judges a late commit from
481
- * the same call. `own` is the first of the reading animator's calls.
482
- */
483
- function firstCommitted(frame, own) {
484
- if (frame != null && waitingRead?.frame === frame) return Math.min(waitingRead.first, own);
485
- const first = Math.min(own, ...waitingCalls.values());
486
- waitingCalls.clear();
487
- if (frame != null) {
488
- const read = {
489
- frame,
490
- first
491
- };
492
- waitingRead = read;
493
- setTimeout(() => {
494
- if (waitingRead === read) waitingRead = null;
495
- }, 0);
496
- }
497
- return first;
498
- }
499
- /**
500
- * The time the animation frame with timestamp `frame` runs, read once in
501
- * that frame. Every animator's callback in the frame takes that read, so the
502
- * calls from rest that one frame commits start together. A long callback
503
- * before them does not move their start. A call on a moving element keeps
504
- * its own clock. The read ends with the frame's task, so a frame
505
- * source that repeats a timestamp still reads each frame anew. A frame
506
- * source with no timestamp reads the clock.
507
- */
508
- function frameTime(frame, clock) {
509
- if (frame == null) return clock();
510
- if (frameRead?.frame === frame) return frameRead.time;
511
- const read = {
512
- frame,
513
- time: clock()
514
- };
515
- frameRead = read;
516
- setTimeout(() => {
517
- if (frameRead === read) frameRead = null;
518
- }, 0);
519
- return read.time;
520
- }
521
- let taskBakes = null;
522
- function bakesOfTask() {
523
- if (taskBakes == null) {
524
- const bakes = {
525
- times: [],
526
- keyframes: []
527
- };
528
- taskBakes = bakes;
529
- queueMicrotask(() => {
530
- if (taskBakes === bakes) taskBakes = null;
531
- });
532
- }
533
- return taskBakes;
534
- }
535
- function isSameKey(a, b) {
536
- return a.length === b.length && a.every((value, i) => Object.is(value, b[i]));
537
- }
538
- /** Whether the engine can copy an effect with its parsed keyframes. */
539
- function isCopyable(effect) {
540
- return typeof KeyframeEffect === "function" && typeof Animation === "function" && effect instanceof KeyframeEffect;
541
- }
542
- /**
543
- * Plays a copy of `effect` on `element`, as `element.animate` would play the
544
- * same keyframes and timing, without parsing them again.
545
- */
546
- function copyAnimation(effect, element) {
547
- const copy = new KeyframeEffect(effect);
548
- copy.target = element;
549
- const animation = new Animation(copy, element.ownerDocument.timeline);
550
- animation.play();
551
- return quietFinished(animation);
552
- }
553
- //#endregion
554
- //#region src/motion/engine/animate.ts
555
- function installAnimate(engine) {
556
- const { animator, isCoarsePointer, lastSpring, now, resting, segments } = engine;
557
- animator.animate = (to, transition, animateOptions = {}) => {
558
- engine.syncPending();
559
- if (animateOptions.start !== "presented") engine.flushDeferred();
560
- const time = animateOptions.at ?? callTime(now);
561
- const targets = expand(to);
562
- const velocities = expand(transition.velocity ?? {});
563
- const { owner, finished } = engine.newOwner();
564
- lastSpring.set(owner, transition.spring);
565
- const properties = Object.keys(targets);
566
- const next = {};
567
- let plan = null;
568
- if (engine.prefersReducedMotion()) {
569
- plan = engine.reducedMotion(owner, time, targets, properties, isCoarsePointer() || animateOptions.touchRelease === true, animateOptions.crossfadeAs);
570
- Object.assign(next, plan.next);
571
- } else for (const property of properties) {
572
- const running = animateOptions.additive === true && velocities[property] == null ? engine.segmentAt(property, time) : null;
573
- if (running != null && !engine.isHeld(running)) {
574
- next[property] = engine.additiveSegment(owner, property, time, targets[property], transition.spring, running);
575
- continue;
576
- }
577
- const handed = velocities[property];
578
- const current = engine.velocityAt(property, time);
579
- const segment = engine.springSegment(owner, property, time, targets[property], transition.spring, handed ?? current);
580
- const isHanded = handed != null && Math.abs(handed - current) > SAMPLE_TOLERANCE[property] * 60;
581
- next[property] = segment != null && isHanded ? {
582
- ...segment,
583
- handedVelocity: handed
584
- } : segment;
585
- }
586
- const group = engine.beginGroup(time, Object.keys(next), animateOptions.at, animateOptions.start);
587
- if (group != null && animateOptions.at == null && animateOptions.start === "next-frame") group.nextFrame = true;
588
- const waitsForFrame = engine.noteShown(Object.keys(next), time, group, animateOptions.at);
589
- const adopted = plan?.landing != null ? engine.adoptLandings(plan.landing, Object.keys(next)) : null;
590
- const changed = [];
591
- for (const [property, segment] of Object.entries(next)) {
592
- engine.interrupt(property, time);
593
- changed.push(property);
594
- if (segment == null) {
595
- const value = plan?.holds[property] ?? targets[property] ?? engine.valueAt(property, time);
596
- segments.delete(property);
597
- resting[property] = value;
598
- } else segments.set(property, segment);
599
- }
600
- engine.commitCall(group, owner, changed, time, animateOptions.start === "presented" && animateOptions.at == null, waitsForFrame);
601
- if (plan?.borrowed != null) engine.borrowedOpacity = plan.borrowed;
602
- if (plan?.joins === true) engine.joinWaitingDip(owner);
603
- const handle = plan?.joins === true ? engine.makeHandle(owner, ["opacity"], finished, time, group, true) : engine.makeHandle(owner, changed, finished, time, group);
604
- if (plan?.landing != null) engine.scheduleLanding(owner, handle.started, plan.landing, adopted);
605
- return handle;
606
- };
607
- }
608
- //#endregion
609
- //#region src/motion/engine/attach.ts
610
- function installAttach(engine) {
611
- const { animator, heldForFrame, isCoarsePointer, landings, now, pseudoElement, restWaits, resting, retireFrames, retireLooks, retireTimers, running, segments } = engine;
612
- animator.reducedMotion = (reducedOptions = {}) => {
613
- if (!engine.prefersReducedMotion()) return "off";
614
- return isCoarsePointer() || reducedOptions.touchRelease === true ? "crossfade" : "instant";
615
- };
616
- animator.attach = (next) => {
617
- if (next === engine.target) return;
618
- engine.flushDeferred();
619
- engine.present(false);
620
- engine.forgetShown();
621
- heldForFrame.clear();
622
- if (next == null) {
623
- engine.lastDetached = engine.target;
624
- if (!engine.unmountQueued) {
625
- engine.unmountQueued = true;
626
- queueMicrotask(() => {
627
- if (!engine.unmountQueued) return;
628
- engine.unmountQueued = false;
629
- engine.onLastDetached(() => {
630
- engine.landPending(false);
631
- for (const animation of running.values()) animation.cancel();
632
- running.clear();
633
- for (const timer of retireTimers.values()) clearTimeout(timer);
634
- retireTimers.clear();
635
- for (const timer of retireLooks.values()) clearTimeout(timer);
636
- retireLooks.clear();
637
- retireFrames.clear();
638
- engine.demote();
639
- engine.cancelSheetWillChangeRead();
640
- });
641
- engine.lastDetached = null;
642
- const time = now();
643
- for (const property of PROPERTIES) engine.interrupt(property, time);
644
- for (const wait of [...restWaits]) wait.settle();
645
- });
646
- }
647
- } else {
648
- engine.unmountQueued = false;
649
- engine.lastDetached = null;
650
- }
651
- engine.demote();
652
- const isOpacityBorrowed = engine.borrowedOpacity != null || [...landings].some((landing) => landing.restoreIsBorrowed === true);
653
- const pseudoHeld = pseudoElement == null || engine.target == null ? null : new Set(Object.keys(CHANNELS$1).filter((channel) => running.has(channel) && !(channel === "opacity" && isOpacityBorrowed) && CHANNELS$1[channel].every((p) => !segments.has(p) && resting[p] === IDENTITY[p])));
654
- for (const animation of running.values()) animation.cancel();
655
- running.clear();
656
- for (const timer of retireTimers.values()) clearTimeout(timer);
657
- retireTimers.clear();
658
- for (const timer of retireLooks.values()) clearTimeout(timer);
659
- retireLooks.clear();
660
- retireFrames.clear();
661
- if (isOpacityBorrowed) engine.releaseOwnOpacity();
662
- if (engine.target != null) {
663
- const outgoing = engine.target;
664
- engine.heldIdentity = pseudoHeld ?? new Set(Object.keys(CHANNELS$1).filter((channel) => outgoing.style.getPropertyValue(engine.cssName(channel)) === engine.identityOf(channel)));
665
- }
666
- const held = engine.heldIdentity;
667
- engine.target = next;
668
- engine.cancelSheetWillChangeRead();
669
- engine.sheetWillChangeRead = false;
670
- if (engine.target == null) return;
671
- engine.heldIdentity = /* @__PURE__ */ new Set();
672
- const time = now();
673
- const dip = segments.get("opacity");
674
- if (engine.borrowedOpacity != null && (dip == null || time >= dip.start + dip.duration)) {
675
- engine.borrowedOpacity = null;
676
- segments.delete("opacity");
677
- resting.opacity = IDENTITY.opacity;
678
- }
679
- for (const channel of Object.keys(CHANNELS$1)) if (!CHANNELS$1[channel].every((p) => !segments.has(p) && resting[p] === IDENTITY[p])) engine.rebuild(channel, time);
680
- else if (held.has(channel)) {
681
- if (pseudoElement != null) engine.hold(channel, time);
682
- else engine.writeInline(channel, (property) => resting[property]);
683
- }
684
- engine.flushReleases();
685
- engine.readSheetWillChangeLater();
686
- };
687
- }
688
- //#endregion
689
- //#region src/motion/engine/channelText.ts
690
- function installChannelText(engine) {
691
- const { companion, customProperty, customUnit } = engine;
692
- engine.companionText = (x) => companion == null ? "" : companion.syntax === "<number>" ? `${round(companion.map(x), 5)}` : `${round(companion.map(x), 3)}px`;
693
- engine.isCustom = (channel) => customProperty != null && channel === "translate";
694
- engine.cssName = (channel) => customProperty != null && channel === "translate" ? customProperty.name : channel;
695
- engine.textOf = (channel, value) => engine.isCustom(channel) ? `${round(value("x"), customUnit === "" ? 5 : 3)}${customUnit}` : format(channel, value);
696
- /** A keyframe's properties for a channel: the companion rides x's. */
697
- engine.frameOf = (channel, value) => engine.isCustom(channel) && companion != null ? {
698
- [engine.cssName(channel)]: engine.textOf(channel, value),
699
- [companion.name]: engine.companionText(value("x"))
700
- } : { [engine.cssName(channel)]: engine.textOf(channel, value) };
701
- engine.identityOf = (channel) => engine.isCustom(channel) ? `0${customUnit}` : IDENTITY_TEXT[channel];
702
- engine.prefersReducedMotion = () => defaultPrefersReducedMotion() || themeReducesMotion(engine.target);
703
- /** Runs `write` with the pending unmount's node as the target. */
704
- engine.onLastDetached = (write) => {
705
- const current = engine.target;
706
- engine.target = engine.target ?? engine.lastDetached;
707
- try {
708
- write();
709
- } finally {
710
- engine.target = current;
711
- }
712
- };
713
- }
714
- //#endregion
715
- //#region src/motion/engine/curveReads.ts
716
- function installCurveReads(engine) {
717
- const { companion, now, presentedSource, pseudoElement, resting, segments, touched } = engine;
718
- engine.segmentAt = (property, time) => {
719
- const segment = segments.get(property);
720
- if (segment == null) return null;
721
- if (time >= engine.endOf(property, segment)) return null;
722
- return segment;
723
- };
724
- /**
725
- * A curve whose call the browser has not started yet: still at its start
726
- * on screen (valueAt), already moving in the model (velocityAt).
727
- */
728
- engine.isHeld = (segment) => segment.group != null && !segment.group.resolved;
729
- /** The curve itself at `time`: what the keyframes play. */
730
- engine.curveAt = (property, time) => {
731
- const segment = segments.get(property);
732
- if (segment == null) return resting[property];
733
- if (time >= segment.start + segment.duration) return segment.target;
734
- return segment.at(Math.max(0, time - segment.start));
735
- };
736
- /**
737
- * A held curve's start once a frame dated its call, as the browser's start
738
- * moves it: by that frame's lead over the call's own time.
739
- */
740
- engine.datedFromLatest = (segment, latest) => latest == null || segment.group == null ? null : {
741
- latest,
742
- start: segment.start + latest - segment.group.provisional
743
- };
744
- /**
745
- * When a waiting curve's call had its first frame, which put the curve on
746
- * screen. Undefined for a curve that does not wait, or whose call has had
747
- * no first frame.
748
- */
749
- engine.shownSince = (property, segment) => segment.group?.resolved === false ? segment.group.latest?.get(CHANNEL_OF[property]) : void 0;
750
- /** A curve's end, dated from its call's first frame while it waits. */
751
- engine.endOf = (property, segment) => (engine.datedFromLatest(segment, engine.shownSince(property, segment))?.start ?? segment.start) + segment.duration;
752
- /**
753
- * Takes a curve on screen out of the call that still waits for the
754
- * browser's start. The curve keeps its course, dated from the call's first
755
- * frame. A call that has no channel left starts at that frame.
756
- */
757
- engine.leaveWaitingCall = (segment, channel, latest) => {
758
- const group = segment.group;
759
- if (group == null) return;
760
- const index = group.segments.indexOf(segment);
761
- if (index >= 0) group.segments.splice(index, 1);
762
- segment.start += latest - group.provisional;
763
- segment.group = void 0;
764
- if (!CHANNELS$1[channel].some((p) => segments.get(p)?.group === group)) {
765
- group.latest?.delete(channel);
766
- group.channels.delete(channel);
767
- }
768
- if (group.channels.size === 0 && group.segments.length === 0) engine.resolveGroup(group, latest);
769
- };
770
- /**
771
- * The value on screen at `time`. Until the browser reports its start, a
772
- * held curve shows its first value. A frame that ran without that start
773
- * dates the curve. Without that frame, a later time reads from the
774
- * provisional start, so a companion that samples ahead follows the curve's
775
- * shape.
776
- */
777
- engine.valueAt = (property, time) => {
778
- const segment = segments.get(property);
779
- if (segment != null && engine.isHeld(segment)) {
780
- const latest = segment.group?.latest?.get(CHANNEL_OF[property]);
781
- const dated = engine.datedFromLatest(segment, latest);
782
- if (dated != null) {
783
- const elapsed = Math.max(time, dated.latest) - dated.start;
784
- return elapsed >= segment.duration ? segment.target : segment.at(elapsed);
785
- }
786
- if (time <= now()) return segment.at(0);
787
- }
788
- return engine.curveAt(property, time);
789
- };
790
- /**
791
- * Whether a curve's tail already shows as at rest at `time`. Under a
792
- * starved main thread the browser commits a call late. A call that starts
793
- * at its own time then skips that far into its curve. One that starts at
794
- * the commit holds an element that hardly moves.
795
- */
796
- engine.showsAtRest = (property, segment, time) => Math.abs(engine.valueAt(property, time) - segment.target) <= 2 * SAMPLE_TOLERANCE[property] && Math.abs(engine.velocityAt(property, time)) <= SAMPLE_TOLERANCE[property] * 60;
797
- engine.velocityAt = (property, time) => {
798
- const held = segments.get(property);
799
- if (held != null && engine.isHeld(held)) {
800
- const dated = engine.datedFromLatest(held, held.group?.latest?.get(CHANNEL_OF[property]));
801
- return held.speed(Math.max(0, dated != null && time > dated.latest ? time - dated.start : time - held.start));
802
- }
803
- const segment = engine.segmentAt(property, time);
804
- if (segment == null || time < segment.start) return 0;
805
- return segment.speed(time - segment.start);
806
- };
807
- engine.valueBefore = (property, time) => engine.curveAt(property, time - 1e-6);
808
- engine.finalValue = (property) => segments.get(property)?.target ?? resting[property];
809
- /**
810
- * Where translate is drawn relative to where the translate animation
811
- * started, read live when a touch lands. iOS WebKit keeps the transform it
812
- * resolved when the animation went to the compositor (iOS 26.2: the
813
- * element's rect and its hit tests stay at the start for the whole curve,
814
- * while the computed style is live), until the animation is retired. A
815
- * segment whose start still waits for the browser's commit has painted
816
- * nothing of its curve yet.
817
- */
818
- engine.drawnTranslate = (property, time) => {
819
- const segment = segments.get(property);
820
- return segment?.group != null && !segment.group.resolved ? segment.at(0) : engine.valueAt(property, time);
821
- };
822
- /** Reports the element while its translate moves (not a pseudo-element's). */
823
- engine.present = (isMoving) => {
824
- const element = isMoving && pseudoElement == null ? engine.target : null;
825
- if (element === engine.presented) return;
826
- engine.unpresent?.();
827
- engine.unpresent = null;
828
- if (engine.presented instanceof HTMLElement) clearPresentedResolve(engine.presented);
829
- engine.presented = element;
830
- if (element != null) engine.unpresent = registerPresentedOffset(element, presentedSource);
831
- };
832
- engine.writeInline = (channel, value, release = true) => {
833
- if (engine.target == null || pseudoElement != null) return;
834
- touched.add(channel);
835
- const text = engine.isCustom(channel) ? engine.textOf(channel, value) : inlineText(channel, value);
836
- if (engine.target.style.getPropertyValue(engine.cssName(channel)) !== text) engine.target.style.setProperty(engine.cssName(channel), text);
837
- if (engine.isCustom(channel) && companion != null) {
838
- const companionValue = engine.companionText(value("x"));
839
- if (engine.target.style.getPropertyValue(companion.name) !== companionValue) engine.target.style.setProperty(companion.name, companionValue);
840
- }
841
- if (release && text === engine.identityOf(channel)) engine.releaseIdentity(channel);
842
- };
843
- }
844
- //#endregion
845
- //#region src/motion/engine/decayStop.ts
846
- function installDecayStop(engine) {
847
- const { animator, landings, now, resting, segments, shown } = engine;
848
- animator.decay = (curves, decayOptions = {}) => {
849
- engine.syncPending();
850
- engine.flushDeferred();
851
- const time = decayOptions.at ?? callTime(now);
852
- const reduce = engine.prefersReducedMotion();
853
- const transitions = {};
854
- for (const property of DECAY_PROPERTIES) {
855
- const curve = curves[property];
856
- if (reduce && curve?.isTransition === true) transitions[property] = curve.at(curve.duration);
857
- }
858
- const transitioned = Object.keys(transitions).length > 0 ? animator.animate(transitions, REDUCED_TRANSITION, {
859
- at: time,
860
- touchRelease: decayOptions.touchRelease
861
- }) : null;
862
- const { owner, finished } = engine.newOwner();
863
- const properties = DECAY_PROPERTIES.filter((property) => curves[property] != null && transitions[property] === void 0);
864
- if (transitioned != null && properties.length === 0) return transitioned;
865
- const group = engine.beginGroup(time, properties, decayOptions.at);
866
- const waitsForFrame = engine.noteShown(properties, time, group, decayOptions.at);
867
- for (const property of properties) {
868
- const curve = curves[property];
869
- engine.interrupt(property, time);
870
- if (!(curve.duration > 0)) {
871
- segments.delete(property);
872
- resting[property] = curve.at(0);
873
- continue;
874
- }
875
- segments.set(property, {
876
- start: time,
877
- duration: Math.min(MAX_DURATION_MS, curve.duration * 1e3),
878
- target: curve.at(curve.duration),
879
- at: (t) => curve.at(t / 1e3),
880
- speed: (t) => curve.velocity(t / 1e3),
881
- jumps: [],
882
- owner
883
- });
884
- }
885
- engine.commitCall(group, owner, properties, time, false, waitsForFrame);
886
- const handle = engine.makeHandle(owner, properties, finished, time, group);
887
- if (transitioned == null) return handle;
888
- const faded = transitioned;
889
- const owns = (property) => faded.properties.includes(property);
890
- return {
891
- ...handle,
892
- properties: [...handle.properties, ...faded.properties],
893
- started: Promise.all([handle.started, faded.started]).then(([coasting]) => coasting),
894
- finished: Promise.all([handle.finished, faded.finished]).then(([coasted, done]) => coasted && done),
895
- value: (property, at) => owns(property) ? faded.value(property, at) : handle.value(property, at),
896
- velocity: (property, at) => owns(property) ? faded.velocity(property, at) : handle.velocity(property, at),
897
- stop: () => {
898
- handle.stop();
899
- faded.stop();
900
- }
901
- };
902
- };
903
- animator.stop = (properties) => {
904
- engine.syncPending();
905
- engine.flushDeferred();
906
- const time = now();
907
- const list = properties == null ? PROPERTIES : expandList(properties);
908
- const changed = [];
909
- const wasBorrowed = engine.borrowedOpacity != null || [...landings].some((landing) => landing.restoreIsBorrowed === true);
910
- const heading = engine.opacityHeading();
911
- for (const property of list) {
912
- engine.cancelLanding(property);
913
- const segment = segments.get(property);
914
- if (segment == null) continue;
915
- const noted = shown.get(property);
916
- shown.delete(property);
917
- const value = !segment.isFade ? noted != null && time - noted.since > 34 ? engine.shownAt(noted, time).value : engine.valueAt(property, time) : wasBorrowed ? IDENTITY.opacity : heading;
918
- engine.interrupt(property, time);
919
- segments.delete(property);
920
- resting[property] = value;
921
- changed.push(property);
922
- }
923
- engine.commit(changed, time);
924
- if (wasBorrowed && changed.includes("opacity")) engine.releaseOwnOpacity();
925
- };
926
- }
927
- //#endregion
928
- //#region src/motion/engine/groupSync.ts
929
- function installGroupSync(engine) {
930
- const { now, pendingGroups, requestFrame, resting, running, segments } = engine;
931
- /**
932
- * A call whose first animation was cancelled before its first frame: if a
933
- * later call in the same task took over its curves, it starts with that
934
- * call; otherwise it never started.
935
- */
936
- engine.settleCancelled = (group) => {
937
- if (group.resolved) return;
938
- let adopter = group.adoptedBy;
939
- while (adopter?.adoptedBy != null) adopter = adopter.adoptedBy;
940
- if (adopter != null && adopter !== group) {
941
- adopter.started.then((start) => engine.resolveGroup(group, start));
942
- return;
943
- }
944
- if (engine.awaitStart(group)) return;
945
- engine.resolveGroup(group, group.provisional);
946
- };
947
- /**
948
- * Waits for the browser's start of a call through one of its animations
949
- * still playing; false when none is left to wait on.
950
- */
951
- engine.awaitStart = (group) => {
952
- const ready = group.animations.find((animation) => animation.playState !== "idle")?.ready;
953
- if (ready == null || typeof ready.then !== "function") return false;
954
- ready.then(() => engine.syncGroup(group), () => engine.settleCancelled(group));
955
- return true;
956
- };
957
- engine.syncGroup = (group) => {
958
- if (group.resolved) return;
959
- for (const animation of group.animations) if (animation.startTime != null) {
960
- engine.resolveGroup(group, engine.startAfterBlock(group, Number(animation.startTime)));
961
- return;
962
- }
963
- if (group.animations.length > 0 && group.animations.every((animation) => animation.playState === "finished" || animation.playState === "idle") && group.animations.some((animation) => animation.playState === "finished")) {
964
- engine.resolveGroup(group, group.provisional);
965
- return;
966
- }
967
- if (group.animations.some((animation) => animation.startTime == null && animation.playState !== "idle")) requestFrame?.(() => engine.syncGroup(group));
968
- };
969
- /**
970
- * Reads the start of every call whose first frame may have been committed:
971
- * not those created in the running task, whose start the browser cannot
972
- * have set (reading it there can cost a style update per call).
973
- */
974
- engine.syncPending = () => {
975
- for (const group of pendingGroups) if (!group.fresh) engine.syncGroup(group);
976
- engine.syncFinished();
977
- };
978
- /**
979
- * An animation finished from outside (a test utility's or devtools'
980
- * `finish()`) shows its end state while the model still reads its curve:
981
- * the curve ends now in the model too, so the next call starts from what
982
- * is on screen.
983
- */
984
- engine.syncFinished = () => {
985
- for (const [channel, animation] of running) {
986
- if (animation.playState !== "finished") continue;
987
- const time = now();
988
- for (const property of CHANNELS$1[channel]) {
989
- const segment = segments.get(property);
990
- if (segment == null || time >= segment.start + segment.duration) continue;
991
- segments.delete(property);
992
- resting[property] = segment.target;
993
- }
994
- }
995
- };
996
- /**
997
- * The start of a call from rest, on the frame that commits it. Chromium,
998
- * like Core Animation, starts a pending animation when it commits it, so a
999
- * main-thread block later in the call's task delays the motion; WebKit
1000
- * dates it at its last frame time before that task, so the first frame
1001
- * after the block would show it skipped into its curve. When the task ran
1002
- * on more than LATE_START_MS past its first call, a start the browser put
1003
- * by the task's first animations (a presented call's second frame, not the
1004
- * call) and more than LATE_START_MS before the call's first read (its
1005
- * `ready`, once the task has ended, or the first frame after it) moves to
1006
- * that read, with every animation of the call, and every call of the task
1007
- * moves to the same read. A shorter task, or a read other tasks delay,
1008
- * keeps the browser's start.
1009
- */
1010
- engine.startAfterBlock = (group, start) => {
1011
- const timeline = typeof document === "undefined" ? null : document.timeline?.currentTime;
1012
- if (timeline == null || group.framed === true || start > (group.task?.first ?? group.provisional) + 34) return start;
1013
- const { task } = group;
1014
- const ended = task?.nextFrame === true ? now() : task?.ended ?? now();
1015
- if (task == null || ended - task.first <= 34) return start;
1016
- const at = task.at ?? Math.max(now(), timeline);
1017
- if (at - start <= 34) return start;
1018
- task.at = at;
1019
- for (const animation of group.animations) if (animation.playState !== "idle") animation.startTime = at;
1020
- return at;
1021
- };
1022
- /** Moves a call from rest onto the time the browser started it. */
1023
- engine.resolveGroup = (group, start) => {
1024
- if (group.resolved) return;
1025
- group.resolved = true;
1026
- pendingGroups.delete(group);
1027
- for (const animation of group.animations) if (animation.startTime == null && animation.playState !== "idle") animation.startTime = start;
1028
- const delta = start - group.provisional;
1029
- if (delta !== 0) {
1030
- for (const segment of group.segments) segment.start += delta;
1031
- for (const channel of group.channels) {
1032
- const animation = running.get(channel);
1033
- if (animation == null || !group.animations.includes(animation)) continue;
1034
- const ends = CHANNELS$1[channel].flatMap((p) => {
1035
- const segment = segments.get(p);
1036
- return segment == null ? [] : [segment.start + segment.duration];
1037
- });
1038
- if (ends.length > 0) engine.scheduleRetire(channel, animation, Math.max(...ends));
1039
- }
1040
- for (const owner of new Set(group.segments.map((s) => s.owner))) {
1041
- if (owner.settled || owner.timer == null) continue;
1042
- clearTimeout(owner.timer);
1043
- const ends = group.segments.filter((segment) => segment.owner === owner).map((segment) => segment.start + segment.duration);
1044
- owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, Math.max(start, ...ends) - now()));
1045
- }
1046
- }
1047
- group.resolve(start);
1048
- };
1049
- }
1050
- //#endregion
1051
- //#region src/motion/engine/handles.ts
1052
- function installHandles(engine) {
1053
- const { animator, carriedOwners, heldForFrame, landings, lastSpring, now, running, segments } = engine;
1054
- engine.interrupt = (property, time) => {
1055
- engine.cancelLanding(property);
1056
- const segment = segments.get(property);
1057
- if (segment == null) return;
1058
- if (time < segment.start + segment.duration && !carriedOwners.has(segment.owner)) engine.settle(segment.owner, false);
1059
- };
1060
- engine.settle = (owner, finished) => {
1061
- if (owner.settled) return;
1062
- owner.settled = true;
1063
- if (owner.timer != null) {
1064
- clearTimeout(owner.timer);
1065
- owner.timer = null;
1066
- }
1067
- owner.resolve(finished);
1068
- };
1069
- /**
1070
- * A handle whose curves have reached their end on the wall clock finishes,
1071
- * unless a sampler holds one of its animations (paused, or sought back):
1072
- * then it waits on that animation's own time, as retiring does
1073
- * (scheduleRetire), so `finished` never resolves under motion still on
1074
- * screen.
1075
- */
1076
- engine.settleAtEnd = (owner) => {
1077
- owner.timer = null;
1078
- let wait = 0;
1079
- for (const [channel, animation] of running) {
1080
- if (!CHANNELS$1[channel].some((property) => segments.get(property)?.owner === owner)) continue;
1081
- if (heldForFrame.has(channel)) {
1082
- wait = Math.max(wait, END_RECHECK_MS);
1083
- continue;
1084
- }
1085
- const remaining = engine.remainingCurve(animation);
1086
- if (remaining != null && remaining > 0) wait = Math.max(wait, animation.playState === "paused" ? 100 : Math.max(remaining, END_RECHECK_MS));
1087
- }
1088
- if (wait > 0) {
1089
- owner.timer = setTimeout(() => engine.settleAtEnd(owner), wait);
1090
- return;
1091
- }
1092
- engine.settle(owner, true);
1093
- };
1094
- engine.makeHandle = (owner, properties, finished, time, group = null, settlesWithLanding = false) => {
1095
- const ends = properties.map((p) => {
1096
- const segment = segments.get(p);
1097
- return segment != null && segment.owner === owner ? segment.start + segment.duration : time;
1098
- });
1099
- const end = Math.max(time, ...ends);
1100
- if (settlesWithLanding) {} else if (properties.length === 0 || end <= time) engine.settle(owner, true);
1101
- else owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, end - now()));
1102
- const curves = /* @__PURE__ */ new Map();
1103
- for (const property of properties) {
1104
- const segment = segments.get(property);
1105
- if (segment != null && segment.owner === owner) curves.set(property, segment);
1106
- }
1107
- return {
1108
- properties,
1109
- finished,
1110
- started: group?.started ?? Promise.resolve(time),
1111
- curve: (property) => {
1112
- const segment = curves.get(property === "scale" ? "scaleX" : property);
1113
- if (segment == null) return null;
1114
- return {
1115
- duration: segment.duration / 1e3,
1116
- at: (t) => t * 1e3 >= segment.duration ? segment.target : segment.at(Math.max(0, t * 1e3)),
1117
- velocity: (t) => t * 1e3 >= segment.duration ? 0 : segment.speed(t * 1e3)
1118
- };
1119
- },
1120
- value: (property, at = now()) => {
1121
- engine.syncPending();
1122
- return engine.valueAt(property, at);
1123
- },
1124
- velocity: (property, at = now()) => {
1125
- engine.syncPending();
1126
- return engine.velocityAt(property, at);
1127
- },
1128
- retarget: (to, transition, retargetOptions) => {
1129
- const spring = transition?.spring ?? lastSpring.get(owner);
1130
- if (spring == null) throw new Error("animator: retarget needs a spring");
1131
- return animator.animate(to, {
1132
- ...transition,
1133
- spring
1134
- }, retargetOptions);
1135
- },
1136
- stop: () => animator.stop(PROPERTIES.filter((p) => properties.includes(p) && (segments.get(p)?.owner === owner || [...landings].some((landing) => landing.values.has(p) && (landing.owners.get(p) ?? landing.owner) === owner))))
1137
- };
1138
- };
1139
- engine.newOwner = () => {
1140
- let resolve = () => {};
1141
- const finished = new Promise((r) => {
1142
- resolve = r;
1143
- });
1144
- return {
1145
- owner: {
1146
- resolve,
1147
- settled: false,
1148
- timer: null
1149
- },
1150
- finished
1151
- };
1152
- };
1153
- }
1154
- //#endregion
1155
- //#region src/motion/reducedMotionPlan.ts
1156
- /** The properties that move an element rather than fade it. */
1157
- const TRAVEL_PROPERTIES = [
1158
- "x",
1159
- "y",
1160
- "rotate",
1161
- "scaleX",
1162
- "scaleY"
1163
- ];
1164
- /** The opacity no call has changed. */
1165
- const IDENTITY_OPACITY = 1;
1166
- /**
1167
- * Plans one call under Reduce Motion: with `fade`, an opacity-only
1168
- * cross-fade whose travel lands while the element is transparent; without,
1169
- * everything at once. `role` gives a call that names no opacity its
1170
- * direction (`crossfadeAs`).
1171
- */
1172
- function planReducedMotion(view, time, targets, properties, fade, role) {
1173
- const holds = {};
1174
- if (!fade) return {
1175
- atOnce: [...properties],
1176
- opacityFade: null,
1177
- holds,
1178
- landing: null
1179
- };
1180
- const atOnce = properties.filter((property) => TRAVEL_PROPERTIES.includes(property));
1181
- const opacityNow = view.valueAt("opacity", time);
1182
- const opacityTo = targets.opacity ?? view.opacityHeading();
1183
- const travel = properties.filter((property) => TRAVEL_PROPERTIES.includes(property) && Math.abs(targets[property] - view.valueAt(property, time)) > 1e-9);
1184
- const named = targets.opacity != null;
1185
- let entering = named && opacityTo > opacityNow + 1e-6;
1186
- let leaving = named && opacityTo < opacityNow - 1e-6;
1187
- let fadeFrom = opacityNow;
1188
- let fadeTo = opacityTo;
1189
- let restore = null;
1190
- const roleBorrow = role != null && !named && view.borrowedOpacity == null && !view.hasOpacityCurve && view.restingOpacity === IDENTITY_OPACITY && !view.writesOwnOpacity() ? view.ownOpacity() : null;
1191
- if (!entering && !leaving && role === "entrance") {
1192
- entering = true;
1193
- fadeFrom = view.hasOpacityCurve ? opacityNow : 0;
1194
- fadeTo = roleBorrow ?? opacityTo;
1195
- } else if (!entering && !leaving && role === "exit") {
1196
- leaving = true;
1197
- fadeFrom = roleBorrow ?? opacityNow;
1198
- fadeTo = 0;
1199
- restore = roleBorrow ?? opacityTo;
1200
- }
1201
- const pending = view.hasPendingLanding;
1202
- const ms = reducedMotionCrossFade.durationMs;
1203
- const landsLater = (at, fadeIn) => {
1204
- const values = /* @__PURE__ */ new Map();
1205
- for (const property of travel) {
1206
- holds[property] = view.valueAt(property, time);
1207
- values.set(property, targets[property]);
1208
- }
1209
- return {
1210
- at,
1211
- values,
1212
- fadeIn,
1213
- restore,
1214
- ...roleBorrow != null && restore != null ? { restoreIsBorrowed: true } : {}
1215
- };
1216
- };
1217
- if (named && view.hasWaitingDip && !properties.some((property) => TRAVEL_PROPERTIES.includes(property)) && Math.abs(opacityTo - view.opacityHeading()) < 1e-6) return {
1218
- atOnce: [],
1219
- opacityFade: null,
1220
- holds,
1221
- landing: null,
1222
- joins: true
1223
- };
1224
- const carries = travel.length > 0 || pending;
1225
- if (entering && !pending && (!carries || fadeFrom <= 1e-6)) return {
1226
- atOnce,
1227
- opacityFade: [{
1228
- at: 0,
1229
- value: fadeFrom
1230
- }, {
1231
- at: ms,
1232
- value: fadeTo
1233
- }],
1234
- holds,
1235
- landing: null,
1236
- borrowed: roleBorrow
1237
- };
1238
- if (leaving && (!carries || fadeTo <= 1e-6)) return {
1239
- atOnce,
1240
- opacityFade: [{
1241
- at: 0,
1242
- value: fadeFrom
1243
- }, {
1244
- at: ms,
1245
- value: fadeTo
1246
- }],
1247
- holds,
1248
- landing: travel.length > 0 || restore != null || pending ? landsLater(ms, null) : null
1249
- };
1250
- if (carries) {
1251
- const priorBorrow = view.borrowedOpacity;
1252
- const borrowed = named || priorBorrow == null && (view.hasOpacityCurve || view.restingOpacity !== IDENTITY_OPACITY || view.writesOwnOpacity()) ? null : priorBorrow ?? view.ownOpacity();
1253
- if (borrowed != null && borrowed <= 1e-6) return {
1254
- atOnce,
1255
- opacityFade: null,
1256
- holds,
1257
- landing: null
1258
- };
1259
- return {
1260
- atOnce,
1261
- opacityFade: [{
1262
- at: 0,
1263
- value: view.hasOpacityCurve ? opacityNow : borrowed ?? opacityNow
1264
- }, {
1265
- at: ms / 2,
1266
- value: 0
1267
- }],
1268
- holds,
1269
- landing: landsLater(ms / 2, {
1270
- to: borrowed ?? opacityTo,
1271
- ms: ms / 2,
1272
- isBorrowed: borrowed != null
1273
- }),
1274
- borrowed
1275
- };
1276
- }
1277
- return {
1278
- atOnce: "opacity" in targets ? [...atOnce, "opacity"] : atOnce,
1279
- opacityFade: null,
1280
- holds,
1281
- landing: null
1282
- };
1283
- }
1284
- //#endregion
1285
- //#region src/motion/engine/landingRun.ts
1286
- function installLandingRun(engine) {
1287
- const { carriedOwners, landings, namedOpacity, now, resting, segments } = engine;
1288
- /**
1289
- * Writes the travel while the element is transparent: a plain style write,
1290
- * never an animation (DR2: opacity only), so it is never shown in the wrong
1291
- * place. In a dip the fade back in starts from here and takes what is left
1292
- * of the cross-fade, so the dip ends when it was due even when a busy main
1293
- * thread runs this timer late; past the whole fade back in (100 ms late or
1294
- * more) the element appears at once where it landed, with no animation,
1295
- * and the call settles then.
1296
- */
1297
- engine.land = (landing) => {
1298
- landings.delete(landing);
1299
- landing.timer = null;
1300
- const time = now();
1301
- const changed = [];
1302
- for (const [property, value] of landing.values) {
1303
- segments.delete(property);
1304
- resting[property] = value;
1305
- changed.push(property);
1306
- }
1307
- let end = time;
1308
- const late = landing.due == null ? 0 : Math.max(0, time - landing.due);
1309
- const appears = landing.fadeIn != null && late >= landing.fadeIn.ms;
1310
- if (landing.fadeIn != null && !appears) {
1311
- const ms = landing.fadeIn.ms - late;
1312
- segments.set("opacity", engine.fadeSegment(landing.owner, time, [{
1313
- at: 0,
1314
- value: engine.valueAt("opacity", time)
1315
- }, {
1316
- at: ms,
1317
- value: landing.fadeIn.to
1318
- }]));
1319
- changed.push("opacity");
1320
- end = time + ms;
1321
- } else if (landing.fadeIn != null) {
1322
- segments.delete("opacity");
1323
- resting.opacity = landing.fadeIn.isBorrowed === true ? IDENTITY.opacity : landing.fadeIn.to;
1324
- changed.push("opacity");
1325
- } else if (landing.restore != null) {
1326
- segments.delete("opacity");
1327
- resting.opacity = landing.restoreIsBorrowed === true ? IDENTITY.opacity : landing.restore;
1328
- changed.push("opacity");
1329
- }
1330
- engine.commit(changed, time);
1331
- if (landing.restoreIsBorrowed === true || appears && landing.fadeIn?.isBorrowed === true) engine.releaseOwnOpacity();
1332
- else if (landing.fadeIn?.isBorrowed === true) engine.borrowedOpacity = landing.fadeIn.to;
1333
- for (const carried of landing.carried) {
1334
- carriedOwners.delete(carried);
1335
- if (!carried.settled) engine.settle(carried, true);
1336
- }
1337
- const { owner } = landing;
1338
- if (owner.settled) return;
1339
- if (end <= time) engine.settle(owner, true);
1340
- else owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, end - now()));
1341
- };
1342
- /**
1343
- * A call that sets a value still waiting to land takes it over: the earlier
1344
- * move never lands, and its call settles interrupted. Once nothing waiting
1345
- * is left, a call that names its own opacity replaces an earlier fade back
1346
- * in or restore too, so a caught dismissal fades straight back up instead
1347
- * of dipping. Whatever still waits is carried by the new plan.
1348
- */
1349
- engine.takeOverLandings = (properties, namesOpacity) => {
1350
- for (const property of properties) if (property !== "opacity") engine.cancelLanding(property);
1351
- if (!namesOpacity) {
1352
- for (const landing of [...landings]) if (landing.values.size === 0 && landing.fadeIn != null) {
1353
- engine.endLanding(landing);
1354
- engine.land(landing);
1355
- }
1356
- return;
1357
- }
1358
- for (const landing of [...landings]) {
1359
- for (const owner of [landing.owner, ...landing.carried]) if (namedOpacity.has(owner) && !owner.settled) engine.settle(owner, false);
1360
- if (landing.values.size > 0) continue;
1361
- engine.endLanding(landing);
1362
- if (landing.fadeIn?.isBorrowed === true || landing.restoreIsBorrowed === true) engine.borrowedOpacity = null;
1363
- for (const owner of [landing.owner, ...landing.carried]) {
1364
- carriedOwners.delete(owner);
1365
- if (!owner.settled) engine.settle(owner, false);
1366
- }
1367
- }
1368
- };
1369
- /**
1370
- * Reduced Motion (see the file header): the planner's plan
1371
- * (reducedMotionPlan.ts) as this call's segments.
1372
- */
1373
- engine.reducedMotion = (owner, time, targets, properties, fade, role) => {
1374
- const heading = engine.opacityHeading();
1375
- engine.takeOverLandings(properties, targets.opacity != null || role != null);
1376
- if (targets.opacity != null) namedOpacity.add(owner);
1377
- engine.headingBeforeTakeOver = heading;
1378
- let plan;
1379
- try {
1380
- plan = planReducedMotion(engine.planView, time, targets, properties, fade, role);
1381
- } finally {
1382
- engine.headingBeforeTakeOver = null;
1383
- }
1384
- const next = {};
1385
- for (const property of plan.atOnce) next[property] = null;
1386
- if (plan.opacityFade != null) next.opacity = engine.fadeSegment(owner, time, plan.opacityFade);
1387
- return {
1388
- next,
1389
- holds: plan.holds,
1390
- landing: plan.landing,
1391
- borrowed: plan.borrowed,
1392
- joins: plan.joins
1393
- };
1394
- };
1395
- }
1396
- //#endregion
1397
- //#region src/motion/engine/landings.ts
1398
- function installLandings(engine) {
1399
- const { carriedOwners, landings, now, resting, running, segments } = engine;
1400
- /**
1401
- * A later write to `property` takes it from any landing. A write to opacity
1402
- * decides what shows, so a landing still waiting writes its travel at once
1403
- * rather than never, and its calls settle as interrupted.
1404
- */
1405
- engine.cancelLanding = (property) => {
1406
- for (const landing of [...landings]) if (property === "opacity") {
1407
- engine.endLanding(landing);
1408
- engine.landNow(landing);
1409
- } else if (landing.values.delete(property)) {
1410
- const moved = landing.owners.get(property) ?? landing.owner;
1411
- landing.owners.delete(property);
1412
- if (!moved.settled) engine.settle(moved, false);
1413
- }
1414
- };
1415
- engine.landNow = (landing) => {
1416
- const changed = [];
1417
- for (const [property, value] of landing.values) {
1418
- segments.delete(property);
1419
- resting[property] = value;
1420
- changed.push(property);
1421
- }
1422
- if (changed.length > 0) engine.commit(changed, now());
1423
- for (const owner of [landing.owner, ...landing.carried]) {
1424
- carriedOwners.delete(owner);
1425
- if (!owner.settled) engine.settle(owner, false);
1426
- }
1427
- };
1428
- /**
1429
- * A later Reduced Motion call that lands too carries the landings still
1430
- * waiting: their travel lands with its own, which wins where both move a
1431
- * property, and their calls settle when it lands. So two calls in one
1432
- * frame (a drag cancel's position and scale) both land.
1433
- */
1434
- engine.adoptLandings = (plan, properties) => {
1435
- const carried = [];
1436
- const owners = /* @__PURE__ */ new Map();
1437
- for (const landing of [...landings]) {
1438
- for (const [property, value] of landing.values) {
1439
- const moved = landing.owners.get(property) ?? landing.owner;
1440
- if (!properties.includes(property) && !plan.values.has(property)) {
1441
- plan.values.set(property, value);
1442
- owners.set(property, moved);
1443
- } else if (!moved.settled) engine.settle(moved, false);
1444
- }
1445
- carried.push(landing.owner, ...landing.carried);
1446
- engine.endLanding(landing);
1447
- }
1448
- for (const owner of carried) carriedOwners.add(owner);
1449
- return {
1450
- carried,
1451
- owners
1452
- };
1453
- };
1454
- /**
1455
- * A call joins the newest waiting dip: it takes the landing over and
1456
- * settles when the dip ends, and the call it replaces lands with it. Each
1457
- * value keeps the call whose move it is.
1458
- */
1459
- engine.joinWaitingDip = (owner) => {
1460
- const dip = [...landings].reverse().find((landing) => landing.fadeIn != null);
1461
- if (dip == null) {
1462
- engine.settle(owner, true);
1463
- return;
1464
- }
1465
- for (const property of dip.values.keys()) if (!dip.owners.has(property)) dip.owners.set(property, dip.owner);
1466
- dip.carried.push(dip.owner);
1467
- carriedOwners.add(dip.owner);
1468
- dip.owner = owner;
1469
- };
1470
- /** Where opacity is heading: past a waiting landing's fade back in. */
1471
- engine.opacityHeading = () => {
1472
- let to = engine.finalValue("opacity");
1473
- for (const landing of landings) if (landing.fadeIn != null) to = landing.fadeIn.to;
1474
- else if (landing.restore != null) to = landing.restore;
1475
- return to;
1476
- };
1477
- engine.endLanding = (landing) => {
1478
- if (landing.timer != null) clearTimeout(landing.timer);
1479
- landings.delete(landing);
1480
- };
1481
- /**
1482
- * How long `landing` still waits for its fade, in ms. A sampler that pauses
1483
- * the fade holds it, so it checks again later. A resumed fade holds it until
1484
- * the fade starts again. A fade that runs past the landing's due time, as
1485
- * after a pause, holds it for the rest of the fade. Any other fade holds
1486
- * nothing.
1487
- */
1488
- engine.fadeHeldFor = (landing) => {
1489
- const animation = running.get("opacity");
1490
- const owner = segments.get("opacity")?.owner;
1491
- if (animation == null || owner == null || owner !== landing.owner && !landing.carried.includes(owner)) return 0;
1492
- if (animation.playState === "paused") return 100;
1493
- const start = animation.startTime;
1494
- const duration = Number(animation.effect?.getTiming?.().duration);
1495
- if (!Number.isFinite(duration)) return 0;
1496
- if (start == null) return animation.playState === "running" ? END_RECHECK_MS : 0;
1497
- const end = Number(start) + duration - END_HOLD_MS;
1498
- if (landing.due != null && end <= landing.due) return 0;
1499
- const left = end - now();
1500
- return left > 0 ? left : 0;
1501
- };
1502
- /**
1503
- * The landing's timer: it lands once its fade lets it. A call that takes the
1504
- * landing over lands it directly, at once.
1505
- */
1506
- engine.landWhenFaded = (landing) => {
1507
- const held = engine.fadeHeldFor(landing);
1508
- if (held > 0) {
1509
- landing.due = now() + held;
1510
- landing.timer = setTimeout(() => engine.landWhenFaded(landing), held);
1511
- return;
1512
- }
1513
- engine.land(landing);
1514
- };
1515
- /** Arms a landing from the call's start (the browser's, for a call from rest). */
1516
- engine.scheduleLanding = (owner, started, plan, adopted) => {
1517
- const owners = /* @__PURE__ */ new Map();
1518
- for (const property of plan.values.keys()) owners.set(property, adopted?.owners.get(property) ?? owner);
1519
- const landing = {
1520
- ...plan,
1521
- owner,
1522
- carried: adopted?.carried ?? [],
1523
- owners,
1524
- timer: null,
1525
- due: null
1526
- };
1527
- landings.add(landing);
1528
- if (owner.timer != null) {
1529
- clearTimeout(owner.timer);
1530
- owner.timer = null;
1531
- }
1532
- started.then((start) => {
1533
- if (!landings.has(landing)) return;
1534
- landing.due = start + landing.at;
1535
- landing.timer = setTimeout(() => engine.landWhenFaded(landing), Math.max(0, landing.due - now()));
1536
- });
1537
- };
1538
- }
1539
- //#endregion
1540
- //#region src/motion/engine/lookAtShown.ts
1541
- function installLookAtShown(engine) {
1542
- const { heldForFrame, now, resting, segments, shown } = engine;
1543
- /**
1544
- * The frame that commits calls that continue motion. When it comes more
1545
- * than LATE_START_MS after the first call it commits on any animator, the
1546
- * screen has shown the old curve. Each spring that they leave
1547
- * then starts here, from the value on screen, as UIKit's added spring
1548
- * begins at its commit. It keeps a velocity that its call handed it, such
1549
- * as a release's, and otherwise takes the one on screen. A played curve or
1550
- * a coast keeps its call's clock, and an earlier frame keeps every call on
1551
- * its own clock.
1552
- */
1553
- engine.lookAtShown = (frame) => {
1554
- engine.isShownLookQueued = false;
1555
- const entries = [...shown];
1556
- const channels = [...heldForFrame];
1557
- heldForFrame.clear();
1558
- engine.forgetShown();
1559
- if (engine.target == null) return;
1560
- const at = frameTime(frame, now);
1561
- const late = at - firstCommitted(frame, Math.min(...entries.map(([, entry]) => entry.since))) > 34;
1562
- const changed = [];
1563
- const owners = /* @__PURE__ */ new Set();
1564
- for (const [property, entry] of entries) {
1565
- const current = segments.get(property);
1566
- if (!late || current == null || current.spring == null || current.isFade === true || engine.isHeld(current)) continue;
1567
- const screen = engine.shownAt(entry, at);
1568
- const next = current.isAdditive === true && entry.segment != null ? engine.additiveSegment(current.owner, property, at, current.target, current.spring, engine.shifted(entry.segment, entry.offset)) : engine.springFrom(current.owner, property, at, screen.value, current.handedVelocity ?? (entry.segment == null ? current.speed(0) : screen.velocity), current.target, current.spring);
1569
- if (next == null) {
1570
- segments.delete(property);
1571
- resting[property] = current.target;
1572
- } else segments.set(property, current.handedVelocity == null ? next : {
1573
- ...next,
1574
- handedVelocity: current.handedVelocity
1575
- });
1576
- owners.add(current.owner);
1577
- changed.push(property);
1578
- }
1579
- const restarted = new Set(changed.map((property) => CHANNEL_OF[property]));
1580
- if (restarted.size > 0) engine.commit([...restarted].flatMap((channel) => CHANNELS$1[channel]), at);
1581
- engine.rebuildOnCallClocks(channels.filter(([channel]) => !restarted.has(channel)));
1582
- for (const owner of owners) {
1583
- if (owner.settled || owner.timer == null) continue;
1584
- clearTimeout(owner.timer);
1585
- let end = at;
1586
- for (const segment of segments.values()) if (segment.owner === owner) end = Math.max(end, segment.start + segment.duration);
1587
- owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, end - now()));
1588
- }
1589
- };
1590
- engine.commit = (changed, time) => {
1591
- const channels = /* @__PURE__ */ new Set();
1592
- for (const property of changed) channels.add(CHANNEL_OF[property]);
1593
- if (channels.has("opacity")) engine.borrowedOpacity = null;
1594
- for (const channel of channels) engine.rebuild(channel, time);
1595
- engine.flushReleases();
1596
- };
1597
- }
1598
- //#endregion
1599
- //#region src/motion/engine/play.ts
1600
- function installPlay(engine) {
1601
- const { animator, isCoarsePointer, now, resting, segments } = engine;
1602
- animator.play = (curves, playOptions = {}) => {
1603
- engine.syncPending();
1604
- if (playOptions.start !== "presented") engine.flushDeferred();
1605
- const time = playOptions.at ?? callTime(now);
1606
- const { owner, finished } = engine.newOwner();
1607
- const byProperty = {};
1608
- const entries = Object.entries(curves).sort(([a], [b]) => Number(b === "scale") - Number(a === "scale"));
1609
- for (const [key, curve] of entries) {
1610
- if (curve == null) continue;
1611
- if (!Number.isFinite(curve.duration) || curve.duration < 0) throw new RangeError(`animator: a curve needs a finite duration ≥ 0 (got ${curve.duration})`);
1612
- for (const property of expandList([key])) byProperty[property] = curve;
1613
- }
1614
- const properties = Object.keys(byProperty);
1615
- const targets = {};
1616
- for (const property of properties) {
1617
- const curve = byProperty[property];
1618
- targets[property] = curve.at(curve.duration);
1619
- }
1620
- const plan = engine.prefersReducedMotion() ? engine.reducedMotion(owner, time, targets, properties, isCoarsePointer() || playOptions.touchRelease === true, playOptions.crossfadeAs) : null;
1621
- const next = { ...plan?.next };
1622
- for (const property of properties) {
1623
- if (property in next) continue;
1624
- const curve = byProperty[property];
1625
- const running = playOptions.additive === true ? engine.segmentAt(property, time) : null;
1626
- if (running != null && !engine.isHeld(running) && curve.duration > 0 && Math.abs(curve.at(curve.duration) - curve.at(0)) > 1e-9) {
1627
- next[property] = engine.additiveCurveSegment(owner, time, curve, running);
1628
- continue;
1629
- }
1630
- next[property] = curve.duration === 0 ? null : {
1631
- start: time,
1632
- duration: Math.min(MAX_DURATION_MS, curve.duration * 1e3),
1633
- target: targets[property],
1634
- at: (t) => curve.at(t / 1e3),
1635
- speed: (t) => curve.velocity(t / 1e3),
1636
- jumps: [],
1637
- owner,
1638
- source: curve
1639
- };
1640
- }
1641
- const group = engine.beginGroup(time, Object.keys(next), playOptions.at, playOptions.start);
1642
- if (group != null && playOptions.at == null && playOptions.start === "next-frame") group.nextFrame = true;
1643
- const waitsForFrame = engine.noteShown(Object.keys(next), time, group, playOptions.at);
1644
- const adopted = plan?.landing != null ? engine.adoptLandings(plan.landing, Object.keys(next)) : null;
1645
- const changed = [];
1646
- for (const [property, segment] of Object.entries(next)) {
1647
- engine.interrupt(property, time);
1648
- changed.push(property);
1649
- if (segment == null) {
1650
- const value = plan?.holds[property] ?? targets[property] ?? engine.valueAt(property, time);
1651
- segments.delete(property);
1652
- resting[property] = value;
1653
- } else segments.set(property, segment);
1654
- }
1655
- engine.commitCall(group, owner, changed, time, playOptions.start === "presented" && playOptions.at == null, waitsForFrame);
1656
- if (plan?.borrowed != null) engine.borrowedOpacity = plan.borrowed;
1657
- if (plan?.joins === true) engine.joinWaitingDip(owner);
1658
- const handle = plan?.joins === true ? engine.makeHandle(owner, ["opacity"], finished, time, group, true) : engine.makeHandle(owner, changed, finished, time, group);
1659
- if (plan?.landing != null) engine.scheduleLanding(owner, handle.started, plan.landing, adopted);
1660
- return handle;
1661
- };
1662
- }
1663
- //#endregion
1664
- //#region src/motion/engine/promotion.ts
1665
- function installPromotion(engine) {
1666
- const { now, pendingGroups, promoted, promotionProperty, segments } = engine;
1667
- /** Writes the promoted channels as will-change (or the pseudo's property). */
1668
- engine.writePromotion = (element) => {
1669
- const list = [...promoted].join(", ");
1670
- if (promotionProperty != null) {
1671
- if (list === "") element.style.removeProperty(promotionProperty);
1672
- else element.style.setProperty(promotionProperty, list);
1673
- return;
1674
- }
1675
- if (list === "") {
1676
- element.style.willChange = engine.ownWillChange ?? "";
1677
- engine.ownWillChange = null;
1678
- return;
1679
- }
1680
- engine.ownWillChange ??= element.style.willChange;
1681
- if (engine.ownWillChange === "" && !engine.sheetWillChangeRead) {
1682
- element.style.willChange = [...promoted].join(", ");
1683
- engine.queueSheetReadFor(element);
1684
- return;
1685
- }
1686
- const base = engine.ownWillChange !== "" ? engine.ownWillChange : engine.sheetWillChange;
1687
- const reasons = (base === "auto" ? "" : base).split(",").map((reason) => reason.trim()).filter((reason) => reason !== "" && !promoted.has(reason));
1688
- element.style.willChange = [...reasons, ...promoted].join(", ");
1689
- };
1690
- /** Reads the element's own will-change while no promotion of ours is written. */
1691
- engine.readSheetWillChange = (element) => {
1692
- engine.sheetWillChange = element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue("will-change") ?? "";
1693
- engine.sheetWillChangeRead = true;
1694
- };
1695
- /** Joins the stylesheet's reasons to a promotion once the callback ends. */
1696
- engine.queueSheetReadFor = (element) => {
1697
- if (engine.sheetReadQueuedFor === element) return;
1698
- engine.sheetReadQueuedFor = element;
1699
- const waits = () => engine.sheetReadQueuedFor === element && engine.target === element && promoted.size > 0 && engine.ownWillChange === "";
1700
- queueSheetRead({
1701
- lift: () => {
1702
- if (waits()) element.style.willChange = "";
1703
- },
1704
- read: () => {
1705
- if (waits()) engine.readSheetWillChange(element);
1706
- },
1707
- write: () => {
1708
- if (engine.sheetReadQueuedFor !== element) return;
1709
- engine.sheetReadQueuedFor = null;
1710
- if (engine.target === element && promoted.size > 0) engine.writePromotion(element);
1711
- }
1712
- });
1713
- };
1714
- /**
1715
- * Reads sheetWillChange in a task of its own, so a later promotion reads no
1716
- * style in its own task. Skipped while a promotion of ours is written,
1717
- * which the read would see (demote asks again), and for a node out of the
1718
- * document. A pseudo-element's promotion is its own property, with
1719
- * nothing to read.
1720
- */
1721
- engine.readSheetWillChangeLater = () => {
1722
- engine.cancelSheetWillChangeRead();
1723
- engine.sheetWillChangeRead = false;
1724
- if (engine.target == null || promotionProperty != null) return;
1725
- const element = engine.target;
1726
- engine.sheetReadTimer = setTimeout(() => {
1727
- engine.sheetReadTimer = null;
1728
- if (engine.target === element && promoted.size === 0 && element.isConnected) engine.readSheetWillChange(element);
1729
- }, 0);
1730
- };
1731
- engine.cancelSheetWillChangeRead = () => {
1732
- if (engine.sheetReadTimer != null) {
1733
- clearTimeout(engine.sheetReadTimer);
1734
- engine.sheetReadTimer = null;
1735
- }
1736
- };
1737
- /**
1738
- * Gives the element (or its pseudo-element) a compositing layer for
1739
- * `channel` from the task that starts the motion: Mobile Safari runs an
1740
- * animation whose start time is set from script on its compositor at its
1741
- * first commit only if the element already has a layer.
1742
- */
1743
- engine.promote = (channel) => {
1744
- if (engine.target == null) return;
1745
- if (!promoted.has(channel)) {
1746
- promoted.add(channel);
1747
- engine.writePromotion(engine.target);
1748
- }
1749
- engine.scheduleDemote();
1750
- };
1751
- /** Ends promotion PROMOTION_LINGER_MS after the last motion ends. */
1752
- engine.scheduleDemote = () => {
1753
- if (engine.demoteTimer != null) clearTimeout(engine.demoteTimer);
1754
- let end = now();
1755
- for (const segment of segments.values()) end = Math.max(end, segment.start + segment.duration);
1756
- engine.demoteTimer = setTimeout(() => {
1757
- engine.demoteTimer = null;
1758
- const time = now();
1759
- if ([...segments.values()].some((segment) => time < segment.start + segment.duration) || pendingGroups.size > 0) {
1760
- engine.scheduleDemote();
1761
- return;
1762
- }
1763
- engine.demote();
1764
- }, Math.max(0, end - now()) + 500);
1765
- };
1766
- engine.demote = () => {
1767
- if (engine.demoteTimer != null) {
1768
- clearTimeout(engine.demoteTimer);
1769
- engine.demoteTimer = null;
1770
- }
1771
- if (promoted.size === 0) return;
1772
- promoted.clear();
1773
- if (engine.target != null) {
1774
- engine.writePromotion(engine.target);
1775
- engine.readSheetWillChangeLater();
1776
- }
1777
- };
1778
- }
1779
- //#endregion
1780
- //#region src/motion/engine/readSet.ts
1781
- function installReadSet(engine) {
1782
- const { animator, now, resting, segments, shown } = engine;
1783
- animator.get = (property, time = now()) => {
1784
- engine.syncPending();
1785
- return engine.valueAt(property === "scale" ? "scaleX" : property, time);
1786
- };
1787
- animator.getVelocity = (property, time = now()) => {
1788
- engine.syncPending();
1789
- return engine.velocityAt(property === "scale" ? "scaleX" : property, time);
1790
- };
1791
- animator.set = (values, setOptions = {}) => {
1792
- engine.syncPending();
1793
- engine.flushDeferred();
1794
- const time = now();
1795
- const next = expand(values);
1796
- for (const [property, value] of Object.entries(next)) {
1797
- engine.interrupt(property, time);
1798
- segments.delete(property);
1799
- shown.delete(property);
1800
- resting[property] = value;
1801
- }
1802
- if (setOptions.promote !== false) for (const property of Object.keys(next)) engine.promote(CHANNEL_OF[property]);
1803
- engine.commit(Object.keys(next), time);
1804
- };
1805
- }
1806
- //#endregion
1807
- //#region src/motion/types.ts
1808
- /**
1809
- * Within this of its target a curve is over (in the property's own unit). A
1810
- * curve built outside the animator (a progress curve) settles where a call
1811
- * would with this as its epsilon.
1812
- */
1813
- const SETTLE_THRESHOLD = {
1814
- x: .05,
1815
- y: .05,
1816
- rotate: .01,
1817
- scaleX: 1e-4,
1818
- scaleY: 1e-4,
1819
- opacity: .001
1820
- };
1821
- //#endregion
1822
- //#region src/motion/engine/rebase.ts
1823
- function installRebase(engine) {
1824
- const { animator, heldForFrame, landings, now, restWaits, resting, retireFrames, retireLooks, retireTimers, running, segments, shown, stale } = engine;
1825
- animator.rebase = (deltas, rebaseOptions = {}) => {
1826
- engine.syncPending();
1827
- engine.flushDeferred();
1828
- const time = rebaseOptions.at ?? now();
1829
- const towards = expand(rebaseOptions.towards ?? {});
1830
- const changed = [];
1831
- const owners = /* @__PURE__ */ new Set();
1832
- for (const [property, delta] of Object.entries(expand(deltas))) {
1833
- if (delta === 0) continue;
1834
- const noted = shown.get(property);
1835
- if (noted != null) noted.offset += delta;
1836
- const segment = engine.segmentAt(property, time);
1837
- if (segment == null) {
1838
- changed.push(property);
1839
- resting[property] = engine.valueAt(property, time) + delta;
1840
- segments.delete(property);
1841
- continue;
1842
- }
1843
- owners.add(segment.owner);
1844
- const latest = engine.shownSince(property, segment);
1845
- const group = latest == null && segment.group != null && !segment.group.resolved ? segment.group : void 0;
1846
- const replace = (next) => {
1847
- if (group != null) engine.replaceIn(group, segment, next);
1848
- segments.set(property, next);
1849
- };
1850
- const heading = towards[property];
1851
- if (segment.spring != null && heading != null && Math.abs(segment.target + delta - heading) <= 1e-6) {
1852
- const whole = {
1853
- ...segment,
1854
- target: heading,
1855
- at: (t) => segment.at(t) + delta
1856
- };
1857
- if (latest == null) {
1858
- changed.push(property);
1859
- replace(whole);
1860
- continue;
1861
- }
1862
- const waiting = segment.group;
1863
- if (waiting != null && !waiting.resolved) {
1864
- engine.replaceIn(waiting, segment, whole);
1865
- segments.set(property, whole);
1866
- engine.markStale(CHANNEL_OF[property]);
1867
- continue;
1868
- }
1869
- }
1870
- changed.push(property);
1871
- if (segment.spring != null) {
1872
- const from = engine.valueAt(property, time) + delta;
1873
- const velocity = engine.velocityAt(property, time);
1874
- if (latest != null) engine.leaveWaitingCall(segment, CHANNEL_OF[property], latest);
1875
- const curve = solveSpring(toSpring(segment.spring), {
1876
- from,
1877
- to: segment.target,
1878
- velocity
1879
- });
1880
- replace({
1881
- start: group?.provisional ?? time,
1882
- ...group != null ? { group } : {},
1883
- duration: Math.min(MAX_DURATION_MS, curve.settleTime(SETTLE_THRESHOLD[property]) * 1e3),
1884
- target: segment.target,
1885
- at: (t) => curve.value(t / 1e3),
1886
- speed: (t) => curve.velocity(t / 1e3),
1887
- jumps: [],
1888
- owner: segment.owner,
1889
- spring: segment.spring
1890
- });
1891
- } else {
1892
- if (latest != null) engine.leaveWaitingCall(segment, CHANNEL_OF[property], latest);
1893
- replace({
1894
- ...segment,
1895
- source: void 0,
1896
- target: segment.target + delta,
1897
- at: (t) => segment.at(t) + delta
1898
- });
1899
- }
1900
- }
1901
- engine.commit(changed.filter((property) => !heldForFrame.has(CHANNEL_OF[property])), time);
1902
- for (const channel of new Set(changed.map((p) => CHANNEL_OF[p]))) if (heldForFrame.has(channel)) engine.rebuildShown(channel, time);
1903
- for (const owner of owners) {
1904
- if (owner.settled || owner.timer == null) continue;
1905
- clearTimeout(owner.timer);
1906
- let end = time;
1907
- for (const segment of segments.values()) if (segment.owner === owner) end = Math.max(end, segment.start + segment.duration);
1908
- owner.timer = setTimeout(() => engine.settleAtEnd(owner), Math.max(0, end - now()));
1909
- }
1910
- };
1911
- animator.atRest = async (properties) => {
1912
- const list = properties == null ? PROPERTIES : expandList(properties);
1913
- return new Promise((resolve) => {
1914
- const wait = {
1915
- timer: null,
1916
- settle: () => {}
1917
- };
1918
- const done = () => {
1919
- if (wait.timer != null) clearTimeout(wait.timer);
1920
- restWaits.delete(wait);
1921
- resolve();
1922
- };
1923
- wait.settle = done;
1924
- restWaits.add(wait);
1925
- const check = () => {
1926
- wait.timer = null;
1927
- engine.syncPending();
1928
- const time = now();
1929
- let end = time;
1930
- for (const property of list) {
1931
- const segment = segments.get(property);
1932
- if (segment != null) end = Math.max(end, segment.start + segment.duration);
1933
- }
1934
- if (landings.size > 0) wait.timer = setTimeout(check, 16);
1935
- else if (end <= time) done();
1936
- else wait.timer = setTimeout(check, end - time);
1937
- };
1938
- check();
1939
- });
1940
- };
1941
- animator.dispose = () => {
1942
- engine.flushDeferred();
1943
- if (engine.target == null && engine.unmountQueued) engine.target = engine.lastDetached;
1944
- engine.lastDetached = null;
1945
- engine.unmountQueued = false;
1946
- engine.landPending(false);
1947
- for (const wait of [...restWaits]) wait.settle();
1948
- const time = now();
1949
- for (const property of PROPERTIES) engine.interrupt(property, time);
1950
- for (const animation of running.values()) animation.cancel();
1951
- running.clear();
1952
- stale.clear();
1953
- engine.forgetShown();
1954
- heldForFrame.clear();
1955
- for (const timer of retireTimers.values()) clearTimeout(timer);
1956
- retireTimers.clear();
1957
- engine.present(false);
1958
- for (const timer of retireLooks.values()) clearTimeout(timer);
1959
- retireLooks.clear();
1960
- retireFrames.clear();
1961
- engine.handBackBorrow();
1962
- engine.demote();
1963
- engine.cancelSheetWillChangeRead();
1964
- engine.target = null;
1965
- };
1966
- }
1967
- //#endregion
1968
- //#region src/motion/engine/rebuild.ts
1969
- function installRebuild(engine) {
1970
- const { now, pseudoElement, requestFrame, resting, retireLooks, retireTimers, running, segments, stale } = engine;
1971
- engine.rebuild = (channel, time) => {
1972
- engine.commitWaitingNow(channel);
1973
- stale.delete(channel);
1974
- const previous = running.get(channel);
1975
- running.delete(channel);
1976
- clearTimeout(retireTimers.get(channel));
1977
- retireTimers.delete(channel);
1978
- clearTimeout(retireLooks.get(channel));
1979
- retireLooks.delete(channel);
1980
- if (pseudoElement == null) previous?.cancel();
1981
- const properties = CHANNELS$1[channel];
1982
- for (const property of properties) {
1983
- const segment = segments.get(property);
1984
- if (segment != null && time >= engine.endOf(property, segment)) {
1985
- resting[property] = segment.target;
1986
- segments.delete(property);
1987
- }
1988
- }
1989
- const moving = properties.filter((p) => segments.has(p));
1990
- if (engine.callGroup == null) for (const property of moving) {
1991
- const segment = segments.get(property);
1992
- const latest = engine.shownSince(property, segment);
1993
- if (latest != null) engine.leaveWaitingCall(segment, channel, latest);
1994
- }
1995
- const waiting = engine.callGroup ?? moving.map((p) => segments.get(p).group).find((group) => group != null && !group.resolved) ?? null;
1996
- const rebuiltAfterFirstFrame = waiting?.framed === true;
1997
- const restarted = /* @__PURE__ */ new Set();
1998
- if (rebuiltAfterFirstFrame) restarted.add(waiting);
1999
- if (engine.callGroup != null) for (const property of moving) {
2000
- const group = segments.get(property).group;
2001
- if (group != null && group !== engine.callGroup && !group.resolved) restarted.add(group);
2002
- }
2003
- for (const group of restarted) group.latest?.delete(channel);
2004
- if (channel === "translate" && !engine.isCustom(channel)) {
2005
- engine.hitTested = {
2006
- x: engine.valueAt("x", time),
2007
- y: engine.valueAt("y", time)
2008
- };
2009
- engine.present(moving.length > 0 && engine.target != null && typeof engine.target.animate === "function");
2010
- }
2011
- if (moving.length === 0 || engine.target == null || typeof engine.target.animate !== "function") engine.writeInline(channel, engine.finalValue);
2012
- else engine.writeInline(channel, (p) => engine.valueAt(p, time));
2013
- if (engine.target == null || typeof engine.target.animate !== "function") {
2014
- previous?.cancel();
2015
- return;
2016
- }
2017
- if (moving.length === 0) {
2018
- if (pseudoElement != null) engine.hold(channel, time);
2019
- previous?.cancel();
2020
- return;
2021
- }
2022
- const from = waiting?.provisional ?? time;
2023
- const end = Math.min(from + MAX_DURATION_MS, Math.max(...moving.map((p) => segments.get(p).start + segments.get(p).duration)));
2024
- if (end <= from) {
2025
- if (pseudoElement != null) engine.hold(channel, time);
2026
- previous?.cancel();
2027
- return;
2028
- }
2029
- if (engine.callGroup != null) for (const property of moving) {
2030
- const segment = segments.get(property);
2031
- const group = segment.group;
2032
- if (group != null && group !== engine.callGroup && !group.resolved) {
2033
- const index = group.segments.indexOf(segment);
2034
- if (index >= 0) group.segments.splice(index, 1);
2035
- group.adoptedBy = engine.callGroup;
2036
- segment.group = engine.callGroup;
2037
- segment.start += engine.callGroup.provisional - group.provisional;
2038
- engine.callGroup.segments.push(segment);
2039
- }
2040
- }
2041
- const devicePixel = 1 / Math.max(1, globalThis.devicePixelRatio || 1);
2042
- const bakeKey = pseudoElement == null && !engine.isCustom(channel) ? engine.taskBakeKey(channel, moving, from, end, devicePixel) : null;
2043
- const baked = bakeKey == null ? void 0 : bakesOfTask().keyframes.find((bake) => isSameKey(bake.key, bakeKey));
2044
- const collect = (scale) => {
2045
- const times = /* @__PURE__ */ new Set([from, end]);
2046
- for (const property of moving) {
2047
- const tolerance = SAMPLE_TOLERANCE[property] * scale * (property === "x" || property === "y" ? devicePixel : 1);
2048
- for (const t of engine.sharedSampleTimes(property, from, end, tolerance)) times.add(t);
2049
- }
2050
- return times;
2051
- };
2052
- const span = end - from + END_HOLD_MS;
2053
- const bakeKeyframes = () => {
2054
- let scale = 1;
2055
- let all = collect(scale);
2056
- while (all.size > 1200 && scale < 64) {
2057
- scale *= 2;
2058
- all = collect(scale);
2059
- }
2060
- const jumpTimes = /* @__PURE__ */ new Set();
2061
- for (const property of moving) {
2062
- const segment = segments.get(property);
2063
- for (const j of segment.jumps) {
2064
- const t = segment.start + j;
2065
- if (t > from && t <= end) {
2066
- jumpTimes.add(t);
2067
- all.add(t);
2068
- }
2069
- }
2070
- }
2071
- const times = [...all].sort((a, b) => a - b);
2072
- const frames = [];
2073
- for (const t of times) {
2074
- const offset = (t - from) / span;
2075
- if (jumpTimes.has(t)) frames.push({
2076
- offset,
2077
- ...engine.frameOf(channel, (p) => engine.valueBefore(p, t))
2078
- });
2079
- frames.push({
2080
- offset,
2081
- ...engine.frameOf(channel, (p) => t >= end ? engine.finalValue(p) : engine.curveAt(p, t))
2082
- });
2083
- }
2084
- frames.push({
2085
- offset: 1,
2086
- ...engine.frameOf(channel, engine.finalValue)
2087
- });
2088
- return frames;
2089
- };
2090
- const keyframes = baked?.keyframes ?? bakeKeyframes();
2091
- if (!engine.isCustom(channel)) engine.promote(channel);
2092
- const animation = baked != null && isCopyable(baked.effect) ? copyAnimation(baked.effect, engine.target) : quietFinished(engine.target.animate(keyframes, {
2093
- duration: span,
2094
- fill: "both",
2095
- easing: "linear",
2096
- ...pseudoElement != null ? { pseudoElement } : {}
2097
- }));
2098
- if (bakeKey != null && baked == null) bakesOfTask().keyframes.push({
2099
- key: bakeKey,
2100
- keyframes,
2101
- effect: animation.effect
2102
- });
2103
- if (waiting != null) {
2104
- waiting.animations.push(animation);
2105
- waiting.channels.add(channel);
2106
- animation.ready?.catch(() => {});
2107
- if (rebuiltAfterFirstFrame) requestFrame?.((frame) => {
2108
- if (!waiting.resolved && running.get(channel) === animation && animation.startTime == null && animation.playState === "running") (waiting.latest ??= /* @__PURE__ */ new Map()).set(channel, frameTime(frame, now));
2109
- });
2110
- } else animation.startTime = time;
2111
- running.set(channel, animation);
2112
- previous?.cancel();
2113
- engine.scheduleRetire(channel, animation, end);
2114
- };
2115
- }
2116
- //#endregion
2117
- //#region src/motion/engine/retire.ts
2118
- function installRetire(engine) {
2119
- const { carriedOwners, heldForFrame, landings, now, pendingGroups, pseudoElement, releasing, requestFrame, resting, retireFrames, retireLooks, retireTimers, running, segments } = engine;
2120
- /**
2121
- * Once the main thread runs after the curve's end, the animation leaves the
2122
- * running state: an element's end values are written inline in the task
2123
- * that cancels it; a pseudo-element's end value moves to a static holding
2124
- * animation, created before the long one goes.
2125
- *
2126
- * Why a timer at the curve's end: no browser event reports that an
2127
- * animation's time has reached a point inside its effect, and its
2128
- * `finished` comes only after the END_HOLD_MS tail, which would keep the
2129
- * element promoted and the animation alive for a minute. The timer is set
2130
- * on the curve's own clock and re-armed while a sampler pauses or seeks the
2131
- * animation, so it never retires a held one.
2132
- */
2133
- engine.scheduleRetire = (channel, animation, end) => {
2134
- clearTimeout(retireTimers.get(channel));
2135
- retireTimers.delete(channel);
2136
- clearTimeout(retireLooks.get(channel));
2137
- retireLooks.delete(channel);
2138
- const lookAtFrame = () => {
2139
- if (requestFrame == null || retireFrames.has(animation)) return;
2140
- retireFrames.add(animation);
2141
- requestFrame(() => {
2142
- retireFrames.delete(animation);
2143
- retire(true);
2144
- });
2145
- };
2146
- const retire = (atFrame = false) => {
2147
- if (!atFrame) retireTimers.delete(channel);
2148
- if (running.get(channel) !== animation) return;
2149
- if (heldForFrame.has(channel)) {
2150
- if (!retireTimers.has(channel)) retireTimers.set(channel, setTimeout(retire, END_RECHECK_MS));
2151
- return;
2152
- }
2153
- const remaining = engine.remainingCurve(animation);
2154
- if (atFrame && remaining == null) return;
2155
- if (remaining != null && remaining > 0) {
2156
- const paused = animation.playState === "paused";
2157
- if (!paused && remaining <= (atFrame ? 2 : 1) * 16.666666666666668) lookAtFrame();
2158
- if (!retireTimers.has(channel)) retireTimers.set(channel, setTimeout(retire, paused ? 100 : Math.max(remaining, END_RECHECK_MS)));
2159
- return;
2160
- }
2161
- clearTimeout(retireTimers.get(channel));
2162
- retireTimers.delete(channel);
2163
- running.delete(channel);
2164
- if (channel === "translate") engine.present(false);
2165
- const handsBack = channel === "opacity" && engine.borrowedOpacity != null && ![...landings].some((landing) => landing.fadeIn?.isBorrowed === true);
2166
- if (pseudoElement != null && !handsBack) engine.hold(channel, now());
2167
- else engine.writeInline(channel, engine.finalValue, false);
2168
- const waiting = [...pendingGroups].filter((group) => group.animations.includes(animation));
2169
- for (const group of waiting) engine.syncGroup(group);
2170
- animation.cancel();
2171
- for (const group of waiting) engine.resolveGroup(group, group.provisional);
2172
- engine.releaseIdentity(channel);
2173
- engine.flushReleases();
2174
- };
2175
- retireTimers.set(channel, setTimeout(retire, Math.max(0, end - now())));
2176
- if (requestFrame != null) retireLooks.set(channel, setTimeout(() => {
2177
- retireLooks.delete(channel);
2178
- lookAtFrame();
2179
- }, Math.max(0, end - now() - END_RECHECK_MS)));
2180
- };
2181
- /** The element's own (stylesheet) opacity, read once when a dip starts. */
2182
- engine.ownOpacity = () => {
2183
- const view = engine.target?.ownerDocument.defaultView;
2184
- const value = engine.target == null ? NaN : Number.parseFloat(view?.getComputedStyle(engine.target, pseudoElement ?? null).getPropertyValue("opacity") ?? "");
2185
- return Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 1;
2186
- };
2187
- /**
2188
- * Whether the animator holds an opacity of its own on the element: an inline
2189
- * value it wrote, or a pseudo-element's holding animation (a `set` over a
2190
- * stylesheet that hides or dims it). A dip returns to that value.
2191
- */
2192
- engine.writesOwnOpacity = () => pseudoElement == null ? (engine.target?.style.getPropertyValue("opacity") ?? "") !== "" : running.has("opacity");
2193
- /**
2194
- * Gives the element's opacity back to its stylesheet: an element's inline
2195
- * value goes; a pseudo-element, which has no inline style, loses the
2196
- * animation holding its value.
2197
- */
2198
- engine.releaseOwnOpacity = () => {
2199
- if (pseudoElement == null) {
2200
- engine.target?.style.removeProperty("opacity");
2201
- return;
2202
- }
2203
- const held = running.get("opacity");
2204
- running.delete("opacity");
2205
- held?.cancel();
2206
- };
2207
- /**
2208
- * Lands every Reduce Motion move still waiting, at once, on the current
2209
- * element: its travel, and the opacity its fade was heading to (the
2210
- * stylesheet's again for a borrowed one). Its calls settle `finished`.
2211
- */
2212
- engine.landPending = (finished) => {
2213
- if (landings.size === 0) return;
2214
- const changed = /* @__PURE__ */ new Set();
2215
- let handedBack = false;
2216
- for (const landing of [...landings]) {
2217
- engine.endLanding(landing);
2218
- for (const [property, value] of landing.values) {
2219
- segments.delete(property);
2220
- resting[property] = value;
2221
- changed.add(property);
2222
- }
2223
- if (landing.fadeIn != null || landing.restore != null) {
2224
- const borrowed = landing.fadeIn?.isBorrowed === true || landing.restoreIsBorrowed === true;
2225
- segments.delete("opacity");
2226
- resting.opacity = borrowed ? IDENTITY.opacity : landing.fadeIn?.to ?? landing.restore ?? IDENTITY.opacity;
2227
- changed.add("opacity");
2228
- if (borrowed) {
2229
- engine.borrowedOpacity = null;
2230
- handedBack = true;
2231
- }
2232
- }
2233
- for (const owner of [landing.owner, ...landing.carried]) {
2234
- carriedOwners.delete(owner);
2235
- if (!owner.settled) engine.settle(owner, finished);
2236
- }
2237
- }
2238
- engine.commit(changed, now());
2239
- if (handedBack) engine.releaseOwnOpacity();
2240
- };
2241
- /**
2242
- * Ends a borrowed dip on the element it ran on: the stylesheet owns its
2243
- * opacity again (an unmount or a new element never keeps the borrow).
2244
- */
2245
- engine.handBackBorrow = () => {
2246
- if (engine.borrowedOpacity == null) return;
2247
- engine.borrowedOpacity = null;
2248
- segments.delete("opacity");
2249
- resting.opacity = IDENTITY.opacity;
2250
- engine.releaseOwnOpacity();
2251
- };
2252
- /**
2253
- * A channel at identity with no animation of its own leaves the element:
2254
- * its inline value is removed, unless the stylesheet would then move the
2255
- * element, in which case the identity stays inline. Runs when such a value
2256
- * is written and again when a motion ends.
2257
- */
2258
- engine.releaseIdentity = (channel) => {
2259
- if (engine.target == null || running.has(channel)) return;
2260
- if (channel === "opacity" && engine.borrowedOpacity != null) {
2261
- if ([...landings].some((landing) => landing.fadeIn?.isBorrowed === true)) return;
2262
- engine.borrowedOpacity = null;
2263
- segments.delete("opacity");
2264
- resting.opacity = IDENTITY.opacity;
2265
- engine.releaseOwnOpacity();
2266
- return;
2267
- }
2268
- if (pseudoElement != null) return;
2269
- if (engine.target.style.getPropertyValue(engine.cssName(channel)) !== engine.identityOf(channel)) return;
2270
- releasing.add(channel);
2271
- if (!engine.releaseQueued) {
2272
- engine.releaseQueued = true;
2273
- queueMicrotask(engine.flushReleases);
2274
- }
2275
- };
2276
- /**
2277
- * Removes the identity values written since the last flush, reads the
2278
- * stylesheet once for all of them, and puts back the ones it would move:
2279
- * a single forced style read per element and commit, where a read per
2280
- * channel used to force one each.
2281
- */
2282
- engine.flushReleases = () => {
2283
- engine.releaseQueued = false;
2284
- const element = engine.target;
2285
- const channels = [...releasing].filter((channel) => !running.has(channel) && element?.style.getPropertyValue(engine.cssName(channel)) === engine.identityOf(channel));
2286
- releasing.clear();
2287
- if (element == null || channels.length === 0) return;
2288
- for (const channel of channels) element.style.removeProperty(engine.cssName(channel));
2289
- const style = element.ownerDocument.defaultView?.getComputedStyle(element);
2290
- for (const channel of channels) {
2291
- const underneath = style?.getPropertyValue(engine.cssName(channel));
2292
- if (underneath != null && !isIdentityText(channel, underneath)) element.style.setProperty(engine.cssName(channel), engine.identityOf(channel));
2293
- }
2294
- };
2295
- /**
2296
- * Curve time an animation still has to play on its own clock (its keyframes
2297
- * hold the end for END_HOLD_MS after the curve), or null where the engine
2298
- * does not report it; a paused animation always has some left.
2299
- */
2300
- engine.remainingCurve = (animation) => {
2301
- const timing = animation.effect?.getTiming?.();
2302
- const current = animation.currentTime;
2303
- if (timing == null || current == null) return animation.playState === "paused" ? Infinity : null;
2304
- const left = Number(timing.duration) - END_HOLD_MS - Number(current);
2305
- return animation.playState === "paused" ? Math.max(left, 1) : left;
2306
- };
2307
- }
2308
- //#endregion
2309
- //#region src/motion/engine/sampling.ts
2310
- function installSampling(engine) {
2311
- const { base, heldForFrame, now, pseudoElement, resting, running, segments, stale } = engine;
2312
- /**
2313
- * What identifies a channel's keyframes across calls of one task: each
2314
- * moving property's curve object, offset and length, and each other
2315
- * property's rest value. Null when a moving property has no shared curve
2316
- * (a spring, a rebase, a jump).
2317
- */
2318
- engine.taskBakeKey = (channel, moving, from, end, devicePixel) => {
2319
- const key = [
2320
- channel,
2321
- end - from,
2322
- devicePixel
2323
- ];
2324
- for (const property of CHANNELS$1[channel]) {
2325
- const segment = segments.get(property);
2326
- if (!moving.includes(property)) key.push(property, resting[property]);
2327
- else if (segment?.source != null && segment.jumps.length === 0) {
2328
- key.push(property, segment.source, segment.start - from);
2329
- key.push(segment.duration);
2330
- } else return null;
2331
- }
2332
- return key;
2333
- };
2334
- /** `sampleTimes`, shared by the calls of a task that play one curve. */
2335
- engine.sharedSampleTimes = (property, from, end, tolerance) => {
2336
- const segment = segments.get(property);
2337
- if (segment?.source == null || segment.jumps.length > 0) return engine.sampleTimes(property, from, end, tolerance);
2338
- const key = [
2339
- segment.source,
2340
- segment.start - from,
2341
- segment.duration,
2342
- end - from,
2343
- tolerance
2344
- ];
2345
- const { times } = bakesOfTask();
2346
- const known = times.find((entry) => isSameKey(entry.key, key));
2347
- if (known != null) return known.times.map((t) => t + from);
2348
- const sampled = engine.sampleTimes(property, from, end, tolerance);
2349
- times.push({
2350
- key,
2351
- times: sampled.map((t) => t - from)
2352
- });
2353
- return sampled;
2354
- };
2355
- engine.sampleTimes = (property, from, to, tolerance) => {
2356
- const segment = segments.get(property);
2357
- if (segment == null) return [];
2358
- const begin = Math.max(from, segment.start);
2359
- const end = Math.min(to, segment.start + segment.duration);
2360
- if (end <= begin) return [];
2361
- const times = [begin];
2362
- const value = (t) => engine.curveAt(property, t);
2363
- const breaks = segment.jumps.map((j) => segment.start + j).filter((t) => t > begin && t < end);
2364
- const edges = [
2365
- begin,
2366
- ...breaks,
2367
- end
2368
- ];
2369
- for (let e = 0; e + 1 < edges.length; e++) {
2370
- const a = edges[e];
2371
- const b = edges[e + 1];
2372
- const steps = Math.max(1, Math.ceil((b - a) / SAMPLE_GRID_MS));
2373
- const split = (t0, t1, depth) => {
2374
- const v0 = value(t0);
2375
- const v1 = t1 === b && breaks.includes(b) ? engine.valueBefore(property, b) : value(t1);
2376
- let worst = 0;
2377
- for (const f of [
2378
- .25,
2379
- .5,
2380
- .75
2381
- ]) {
2382
- const t = t0 + (t1 - t0) * f;
2383
- worst = Math.max(worst, Math.abs(value(t) - (v0 + (v1 - v0) * f)));
2384
- }
2385
- if (worst > tolerance && depth < 10 && t1 - t0 > .25) {
2386
- const mid = (t0 + t1) / 2;
2387
- split(t0, mid, depth + 1);
2388
- split(mid, t1, depth + 1);
2389
- } else times.push(t1);
2390
- };
2391
- for (let i = 0; i < steps; i++) split(a + (b - a) * i / steps, a + (b - a) * (i + 1) / steps, 0);
2392
- }
2393
- return times;
2394
- };
2395
- /**
2396
- * Whether the pseudo-element's stylesheet shows the channel's resting
2397
- * value: its base, to within the sampling tolerance, which no frame shows.
2398
- * A curve that settles to a threshold ends that close to its target.
2399
- */
2400
- engine.atBase = (channel) => CHANNELS$1[channel].every((property) => {
2401
- const value = base[property];
2402
- return value != null && Math.abs(engine.finalValue(property) - value) <= SAMPLE_TOLERANCE[property];
2403
- });
2404
- /**
2405
- * The first hold dropped at `base` checks, in development, that the
2406
- * stylesheet shows it. It reads after the cancel and off the motion's task,
2407
- * so it adds no style read to a frame that starts a motion.
2408
- */
2409
- engine.checkBase = (channel) => {
2410
- if (!isDevBuild() || engine.baseChecked) return;
2411
- engine.baseChecked = true;
2412
- setTimeout(() => {
2413
- if (engine.target == null) return;
2414
- const shown = getComputedStyle(engine.target, pseudoElement).getPropertyValue(channel);
2415
- const expected = format(channel, (p) => base[p] ?? IDENTITY[p]);
2416
- if (!sameShown(channel, shown, expected)) devWarn("Astryx motion", `the ${pseudoElement} stylesheet shows ${channel} ${shown || "(unset)"}, not its declared base ${expected}, so it shows the wrong value at rest. Make \`base\` match the stylesheet.`);
2417
- }, 0);
2418
- };
2419
- /**
2420
- * A pseudo-element's resting value, held by a static filling animation,
2421
- * unless its stylesheet shows it (`base`).
2422
- */
2423
- engine.hold = (channel, time) => {
2424
- if (engine.target == null) return;
2425
- if (engine.atBase(channel)) {
2426
- engine.checkBase(channel);
2427
- return;
2428
- }
2429
- const value = format(channel, engine.finalValue);
2430
- const animation = quietFinished(engine.target.animate([{ [channel]: value }, { [channel]: value }], {
2431
- duration: 1,
2432
- fill: "both",
2433
- pseudoElement
2434
- }));
2435
- animation.startTime = time;
2436
- running.set(channel, animation);
2437
- };
2438
- engine.replaceIn = (group, segment, next) => {
2439
- const index = group.segments.indexOf(segment);
2440
- if (index >= 0) group.segments[index] = next;
2441
- else group.segments.push(next);
2442
- };
2443
- engine.markStale = (channel) => {
2444
- stale.add(channel);
2445
- if (!engine.healQueued) {
2446
- engine.healQueued = true;
2447
- queueMicrotask(engine.healStale);
2448
- }
2449
- };
2450
- engine.healStale = () => {
2451
- engine.healQueued = false;
2452
- if (stale.size === 0) return;
2453
- const properties = [...stale].filter((channel) => !heldForFrame.has(channel)).flatMap((channel) => CHANNELS$1[channel]);
2454
- stale.clear();
2455
- engine.commit(properties, now());
2456
- };
2457
- }
2458
- //#endregion
2459
- //#region src/motion/themeTempo.ts
2460
- /**
2461
- * @file themeTempo.ts
2462
- * @input An element on the page
2463
- * @output `themeTempo(element)`: the tempo of the theme the element is in
2464
- * @position Motion foundation; resolveMotion.ts scales a motion role by it,
2465
- * and the pager scales its settle by it, which no role names
2466
- *
2467
- * A theme that sets `tempo` writes it, clamped, to the private custom
2468
- * property `--_astryx-motion-tempo` beside its duration tokens. An
2469
- * adaptation rule writes it where its condition holds, and a nested theme
2470
- * that sets no tempo inherits it. A layer whose durations come from a
2471
- * duration scale writes a tempo of 1, so its springs keep its own pace. One
2472
- * read of a custom property forces no layout.
2473
- * Nothing here imports a theme module, runs on import or runs on the server.
2474
- */
2475
- /** The property a theme that sets `tempo` writes (theme/themeMotion.ts). */
2476
- const TEMPO_PROPERTY = "--_astryx-motion-tempo";
2477
- /**
2478
- * The tempo motion on `element` plays at: the one its theme or an adaptation
2479
- * rule sets, else 1. Without an element in a document, or with a value that
2480
- * is not a positive number, it is 1.
2481
- */
2482
- function themeTempo(element) {
2483
- const view = element?.ownerDocument?.defaultView;
2484
- if (element == null || view == null) return 1;
2485
- const text = view.getComputedStyle(element).getPropertyValue(TEMPO_PROPERTY).trim();
2486
- const tempo = text === "" ? NaN : Number(text);
2487
- return Number.isFinite(tempo) && tempo > 0 ? tempo : 1;
2488
- }
2489
- //#endregion
2490
- //#region src/motion/resolveMotion.ts
2491
- /**
2492
- * The roles the tempo leaves as measured: the parts that follow a finger,
2493
- * and ProgressBar's busy loop.
2494
- */
2495
- const FIXED_ROLES = /* @__PURE__ */ new Set([
2496
- "springs.fingerTracking",
2497
- "switchControl.tracking",
2498
- "progress.reducedMotionPulseMs"
2499
- ]);
2500
- /** Each role spring at each tempo, so a role resolves to one object per tempo. */
2501
- const springsAtTempo = /* @__PURE__ */ new WeakMap();
2502
- /**
2503
- * `spring` at `tempo`. In each of its forms, the undamped period grows by the
2504
- * tempo and the damping ratio stays. So the motion keeps its shape and takes
2505
- * `tempo` times as long.
2506
- */
2507
- function springAtTempo(spring, tempo) {
2508
- let byTempo = springsAtTempo.get(spring);
2509
- if (byTempo == null) {
2510
- byTempo = /* @__PURE__ */ new Map();
2511
- springsAtTempo.set(spring, byTempo);
2512
- }
2513
- let scaled = byTempo.get(tempo);
2514
- if (scaled == null) {
2515
- if ("response" in spring) scaled = {
2516
- response: spring.response * tempo,
2517
- dampingRatio: spring.dampingRatio
2518
- };
2519
- else if ("duration" in spring) scaled = {
2520
- duration: spring.duration * tempo,
2521
- bounce: spring.bounce
2522
- };
2523
- else scaled = {
2524
- ...spring.mass == null ? null : { mass: spring.mass },
2525
- stiffness: spring.stiffness / (tempo * tempo),
2526
- damping: spring.damping / tempo
2527
- };
2528
- byTempo.set(tempo, scaled);
2529
- }
2530
- return scaled;
2531
- }
2532
- function resolveMotion(element, leafOrGroup, key) {
2533
- const value = key === void 0 ? leafOrGroup : leafOrGroup[key];
2534
- const role = key === void 0 ? motionRoleOf(leafOrGroup) : motionRoleIn(leafOrGroup, key);
2535
- if (role == null || role.kind === "curve" || FIXED_ROLES.has(role.id)) return value;
2536
- const tempo = themeTempo(element);
2537
- if (tempo === 1) return value;
2538
- if (typeof value === "number") return value * tempo;
2539
- return isSpring(value) ? springAtTempo(value, tempo) : value;
2540
- }
2541
- //#endregion
2542
- //#region src/motion/engine/segments.ts
2543
- function installSegments(engine) {
2544
- engine.springSegment = (owner, property, start, to, spring, velocity) => engine.springFrom(owner, property, start, engine.valueAt(property, start), velocity, to, resolveMotion(engine.target, spring));
2545
- /**
2546
- * `resolved` is already at the theme's tempo. A restart passes a segment's
2547
- * spring as it is.
2548
- */
2549
- engine.springFrom = (owner, property, start, from, velocity, to, resolved) => {
2550
- if (from === to && velocity === 0) return null;
2551
- const curve = solveSpring(toSpring(resolved), {
2552
- from,
2553
- to,
2554
- velocity
2555
- });
2556
- return {
2557
- start,
2558
- duration: Math.min(MAX_DURATION_MS, curve.settleTime(SETTLE_THRESHOLD[property]) * 1e3),
2559
- target: to,
2560
- at: (t) => curve.value(t / 1e3),
2561
- speed: (t) => curve.velocity(t / 1e3),
2562
- jumps: [],
2563
- owner,
2564
- spring: resolved
2565
- };
2566
- };
2567
- /** The retarget of `additive`: the old curve plus a spring of the difference. */
2568
- engine.additiveSegment = (owner, property, start, to, spring, old) => {
2569
- const oldEnd = old.start + old.duration;
2570
- const resolved = resolveMotion(engine.target, spring);
2571
- const delta = solveSpring(toSpring(resolved), {
2572
- from: 0,
2573
- to: to - old.target,
2574
- velocity: 0
2575
- });
2576
- const deltaMs = Math.min(MAX_DURATION_MS, delta.settleTime(SETTLE_THRESHOLD[property]) * 1e3);
2577
- const ownAt = (t) => t >= deltaMs ? to - old.target : delta.value(t / 1e3);
2578
- const oldAt = (time) => time >= oldEnd ? old.target : old.at(Math.max(0, time - old.start));
2579
- return {
2580
- start,
2581
- duration: Math.min(MAX_DURATION_MS, Math.max(oldEnd - start, deltaMs)),
2582
- target: to,
2583
- at: (t) => oldAt(start + t) + ownAt(t),
2584
- speed: (t) => (start + t >= oldEnd ? 0 : old.speed(start + t - old.start)) + (t >= deltaMs ? 0 : delta.velocity(t / 1e3)),
2585
- jumps: old.jumps.map((jump) => old.start + jump - start).filter((jump) => jump > 0),
2586
- owner,
2587
- spring: resolved,
2588
- isAdditive: true
2589
- };
2590
- };
2591
- /**
2592
- * `additive` for a played curve: the old curve plus the new curve's shape,
2593
- * scaled to the difference between the two targets.
2594
- */
2595
- engine.additiveCurveSegment = (owner, start, curve, old) => {
2596
- const from = curve.at(0);
2597
- const to = curve.at(curve.duration);
2598
- const scale = (to - old.target) / (to - from);
2599
- const ms = Math.min(MAX_DURATION_MS, curve.duration * 1e3);
2600
- const oldEnd = old.start + old.duration;
2601
- const oldAt = (time) => time >= oldEnd ? old.target : old.at(Math.max(0, time - old.start));
2602
- return {
2603
- start,
2604
- duration: Math.min(MAX_DURATION_MS, Math.max(oldEnd - start, ms)),
2605
- target: to,
2606
- at: (t) => oldAt(start + t) + (t >= ms ? to - old.target : (curve.at(t / 1e3) - from) * scale),
2607
- speed: (t) => (start + t >= oldEnd ? 0 : old.speed(start + t - old.start)) + (t >= ms ? 0 : curve.velocity(t / 1e3) * scale),
2608
- jumps: old.jumps.map((jump) => old.start + jump - start).filter((jump) => jump > 0),
2609
- owner
2610
- };
2611
- };
2612
- engine.fadeSegment = (owner, start, stops, jumps = []) => {
2613
- registerReducedMotionCrossFade();
2614
- const ease = cubicBezier(resolveMotion(engine.target, reducedMotionCrossFade.curve));
2615
- const duration = stops[stops.length - 1].at;
2616
- const at = (t) => {
2617
- for (let i = 0; i + 1 < stops.length; i++) {
2618
- const a = stops[i];
2619
- const b = stops[i + 1];
2620
- if (t < b.at || i + 2 === stops.length) {
2621
- if (b.at === a.at) return b.value;
2622
- const p = Math.min(1, Math.max(0, (t - a.at) / (b.at - a.at)));
2623
- return a.value + (b.value - a.value) * ease(p);
2624
- }
2625
- }
2626
- return stops[stops.length - 1].value;
2627
- };
2628
- return {
2629
- start,
2630
- duration,
2631
- target: stops[stops.length - 1].value,
2632
- at,
2633
- speed: (t) => (at(t + .5) - at(Math.max(0, t - .5))) / (t >= .5 ? 1 : .5 + t) * 1e3,
2634
- jumps,
2635
- owner,
2636
- isFade: true
2637
- };
2638
- };
2639
- }
2640
- //#endregion
2641
- //#region src/motion/engine/shownWatch.ts
2642
- function installShownWatch(engine) {
2643
- const { framePage, heldForFrame, requestFrame, resting, retireLooks, retireTimers, segments, shown, stale, waitKey } = engine;
2644
- /**
2645
- * Whether no frame comes. A hidden page draws none. The frame source of a
2646
- * hidden page draws none either, while the element shows elsewhere (a
2647
- * Picture-in-Picture window's opener).
2648
- */
2649
- engine.isPageHidden = () => engine.target?.ownerDocument.visibilityState === "hidden" || framePage?.visibilityState === "hidden";
2650
- engine.forgetShown = () => {
2651
- shown.clear();
2652
- engine.syncWaiting();
2653
- engine.stopWatchingHidden?.();
2654
- };
2655
- engine.syncWaiting = () => {
2656
- let first = Infinity;
2657
- for (const entry of shown.values()) first = Math.min(first, entry.since);
2658
- if (first === Infinity) waitingCalls.delete(waitKey);
2659
- else waitingCalls.set(waitKey, first);
2660
- };
2661
- /**
2662
- * Rebuilds channels from their last calls' times, as those calls would
2663
- * have rebuilt them: the same keyframes and start time.
2664
- */
2665
- engine.rebuildOnCallClocks = (channels) => {
2666
- for (const time of new Set(channels.map(([, at]) => at))) engine.commit(channels.filter(([, at]) => at === time).flatMap(([channel]) => CHANNELS$1[channel]), time);
2667
- };
2668
- engine.flushWaiting = () => {
2669
- const channels = [...heldForFrame];
2670
- heldForFrame.clear();
2671
- engine.rebuildOnCallClocks(channels);
2672
- };
2673
- /**
2674
- * A hidden page draws no frames and shows nothing, so its calls keep their
2675
- * own clock, as the timers do (scheduleRetire). A page that goes hidden
2676
- * before the frame forgets what it showed and rebuilds what waits.
2677
- */
2678
- engine.watchHidden = () => {
2679
- const pages = [...new Set([engine.target?.ownerDocument, framePage].filter((page) => page != null))];
2680
- if (engine.stopWatchingHidden != null || pages.length === 0) return;
2681
- const onChange = () => {
2682
- if (engine.isPageHidden()) {
2683
- engine.forgetShown();
2684
- engine.flushWaiting();
2685
- }
2686
- };
2687
- for (const page of pages) page.addEventListener("visibilitychange", onChange);
2688
- engine.stopWatchingHidden = () => {
2689
- for (const page of pages) page.removeEventListener("visibilitychange", onChange);
2690
- engine.stopWatchingHidden = null;
2691
- };
2692
- };
2693
- /**
2694
- * Holds a call's channels for the frame that commits it, which rebuilds
2695
- * them (lookAtShown). Until then the old curve plays on, and no end look
2696
- * retires it.
2697
- */
2698
- engine.deferRebuild = (changed, time) => {
2699
- for (const property of changed) {
2700
- const channel = CHANNEL_OF[property];
2701
- const isNew = !heldForFrame.has(channel);
2702
- heldForFrame.set(channel, time);
2703
- if (!isNew) continue;
2704
- stale.delete(channel);
2705
- clearTimeout(retireTimers.get(channel));
2706
- retireTimers.delete(channel);
2707
- clearTimeout(retireLooks.get(channel));
2708
- retireLooks.delete(channel);
2709
- }
2710
- };
2711
- /** A rebuild before that frame commits the channel's calls at once. */
2712
- engine.commitWaitingNow = (channel) => {
2713
- if (!heldForFrame.delete(channel)) return;
2714
- for (const property of CHANNELS$1[channel]) shown.delete(property);
2715
- engine.syncWaiting();
2716
- };
2717
- /**
2718
- * Rebuilds a waiting channel from what the screen shows, after a rebase
2719
- * moved the element under it. The old curve plays on, shifted with the
2720
- * element, until the frame that commits the call.
2721
- */
2722
- engine.rebuildShown = (channel, time) => {
2723
- const model = /* @__PURE__ */ new Map();
2724
- const rests = /* @__PURE__ */ new Map();
2725
- for (const property of CHANNELS$1[channel]) {
2726
- const entry = shown.get(property);
2727
- if (entry == null) continue;
2728
- model.set(property, segments.get(property));
2729
- rests.set(property, resting[property]);
2730
- if (entry.segment == null) {
2731
- segments.delete(property);
2732
- resting[property] = entry.resting + entry.offset;
2733
- } else segments.set(property, engine.shifted(entry.segment, entry.offset));
2734
- }
2735
- const callTime = heldForFrame.get(channel);
2736
- heldForFrame.delete(channel);
2737
- try {
2738
- engine.rebuild(channel, time);
2739
- } finally {
2740
- for (const [property, segment] of model) if (segment == null) segments.delete(property);
2741
- else segments.set(property, segment);
2742
- for (const [property, rest] of rests) resting[property] = rest;
2743
- if (callTime != null) heldForFrame.set(channel, callTime);
2744
- }
2745
- };
2746
- /**
2747
- * Notes what the screen shows of each property that a call continuing
2748
- * motion changes, before the call replaces its curve. The call's channels
2749
- * then wait for the frame that commits it, which rebuilds them
2750
- * (lookAtShown). That holds for a call in a frame callback of the page's.
2751
- * A call from rest, a call on an explicit clock and a call in an
2752
- * animator's frame callback start on their frame already.
2753
- */
2754
- engine.noteShown = (properties, time, group, at) => {
2755
- if (group != null || at != null || frameNesting.depth > 0 || requestFrame == null || engine.target == null || typeof engine.target.animate !== "function" || engine.isPageHidden()) return false;
2756
- const list = [...properties];
2757
- if (list.some((property) => CHANNELS$1[CHANNEL_OF[property]].some((other) => {
2758
- const segment = segments.get(other);
2759
- return segment != null && engine.isHeld(segment);
2760
- }))) return false;
2761
- for (const property of list) {
2762
- if (shown.has(property)) continue;
2763
- shown.set(property, {
2764
- segment: segments.get(property) ?? null,
2765
- resting: resting[property],
2766
- offset: 0,
2767
- since: time
2768
- });
2769
- }
2770
- engine.syncWaiting();
2771
- engine.watchHidden();
2772
- if (!engine.isShownLookQueued) {
2773
- engine.isShownLookQueued = true;
2774
- requestFrame(engine.lookAtShown);
2775
- }
2776
- return true;
2777
- };
2778
- /** The value and velocity that the screen shows of a property at `time`. */
2779
- engine.shownAt = (entry, time) => {
2780
- const { segment, offset } = entry;
2781
- if (segment == null) return {
2782
- value: entry.resting + offset,
2783
- velocity: 0
2784
- };
2785
- const elapsed = time - segment.start;
2786
- if (elapsed >= segment.duration) return {
2787
- value: segment.target + offset,
2788
- velocity: 0
2789
- };
2790
- const t = Math.max(0, elapsed);
2791
- return {
2792
- value: segment.at(t) + offset,
2793
- velocity: segment.speed(t)
2794
- };
2795
- };
2796
- engine.shifted = (segment, offset) => offset === 0 ? segment : {
2797
- ...segment,
2798
- target: segment.target + offset,
2799
- at: (t) => segment.at(t) + offset
2800
- };
2801
- }
2802
- //#endregion
2803
- //#region src/motion/engine/startGroups.ts
2804
- function installStartGroups(engine) {
2805
- const { deferredCalls, now, pendingGroups, requestFrame, running, segments } = engine;
2806
- /**
2807
- * A call starts from rest when nothing on the channels it drives moves on
2808
- * screen and nothing pins its clock (`at`). A curve still waiting for its
2809
- * first frame counts as rest, as does one whose tail already shows as at
2810
- * rest. Returns its start group, or null for an explicit start.
2811
- */
2812
- engine.beginGroup = (time, properties, at, start) => {
2813
- if (engine.target == null || typeof engine.target.animate !== "function") return null;
2814
- const channels = /* @__PURE__ */ new Set();
2815
- for (const property of properties) channels.add(CHANNEL_OF[property]);
2816
- if (at != null) {
2817
- for (const channel of channels) for (const property of CHANNELS$1[channel]) {
2818
- const group = segments.get(property)?.group;
2819
- if (group != null && !group.resolved && at <= group.provisional) return group;
2820
- }
2821
- return null;
2822
- }
2823
- for (const channel of start === "commit" ? [] : channels) for (const property of CHANNELS$1[channel]) {
2824
- const segment = segments.get(property);
2825
- if (segment != null && time < engine.endOf(property, segment) && (segment.group == null || segment.group.resolved || engine.shownSince(property, segment) != null) && !engine.showsAtRest(property, segment, time)) return null;
2826
- }
2827
- let resolve = () => {};
2828
- const started = new Promise((r) => {
2829
- resolve = r;
2830
- });
2831
- return {
2832
- provisional: time,
2833
- fresh: false,
2834
- segments: [],
2835
- animations: [],
2836
- channels: /* @__PURE__ */ new Set(),
2837
- resolved: false,
2838
- resolve,
2839
- started
2840
- };
2841
- };
2842
- /** Commits a call's changes, from rest when it has a start group. */
2843
- engine.commitCall = (group, owner, changed, time, presented = false, waitsForFrame = false) => {
2844
- if (group != null) for (const property of changed) {
2845
- const segment = segments.get(property);
2846
- if (segment != null && segment.owner === owner) {
2847
- segment.group = group;
2848
- group.segments.push(segment);
2849
- }
2850
- }
2851
- if (presented && group != null && requestFrame != null) {
2852
- const call = {
2853
- group,
2854
- changed
2855
- };
2856
- deferredCalls.push(call);
2857
- requestFrame(() => requestFrame(() => engine.flushDeferredThrough(call)));
2858
- return;
2859
- }
2860
- if (group == null && waitsForFrame) {
2861
- engine.deferRebuild(changed, time);
2862
- return;
2863
- }
2864
- engine.startCall(group, changed, time);
2865
- };
2866
- /** Creates the animations of the given waiting calls, in call order. */
2867
- engine.startDeferred = (calls) => {
2868
- for (const { group, changed } of calls) {
2869
- const own = [];
2870
- let handedTo = null;
2871
- for (const property of changed) {
2872
- const holder = CHANNELS$1[CHANNEL_OF[property]].map((other) => segments.get(other)?.group).find((waiting) => waiting != null && waiting !== group && deferredCalls.some((call) => call.group === waiting));
2873
- if (holder == null) {
2874
- own.push(property);
2875
- continue;
2876
- }
2877
- const segment = segments.get(property);
2878
- if (segment != null && segment.group === group) {
2879
- segment.start += holder.provisional - group.provisional;
2880
- segment.group = holder;
2881
- holder.segments.push(segment);
2882
- group.segments.splice(group.segments.indexOf(segment), 1);
2883
- handedTo = holder;
2884
- }
2885
- }
2886
- if (own.length === 0 && handedTo != null) {
2887
- const adopter = handedTo;
2888
- group.adoptedBy = adopter;
2889
- adopter.started.then((start) => engine.resolveGroup(group, start));
2890
- continue;
2891
- }
2892
- engine.startCall(group, own, group.provisional);
2893
- }
2894
- };
2895
- /** Creates the animations of every waiting call, in call order. */
2896
- engine.flushDeferred = () => {
2897
- engine.startDeferred(deferredCalls.splice(0));
2898
- };
2899
- /**
2900
- * A call's second frame: it starts, with every call queued before it (in
2901
- * call order), unless another change created it already.
2902
- */
2903
- engine.flushDeferredThrough = (call) => {
2904
- const index = deferredCalls.indexOf(call);
2905
- if (index >= 0) engine.startDeferred(deferredCalls.splice(0, index + 1));
2906
- };
2907
- engine.startCall = (group, changed, time) => {
2908
- engine.callGroup = group;
2909
- try {
2910
- engine.commit(changed, time);
2911
- } finally {
2912
- engine.callGroup = null;
2913
- }
2914
- if (group == null) return;
2915
- if (group.animations.length === 0) {
2916
- engine.resolveGroup(group, group.provisional);
2917
- return;
2918
- }
2919
- pendingGroups.add(group);
2920
- group.fresh = true;
2921
- group.task = markTask(now(), now);
2922
- if (group.nextFrame === true) group.task.nextFrame = true;
2923
- group.madeInFrame = frameNesting.depth > 0;
2924
- queueMicrotask(() => {
2925
- group.fresh = false;
2926
- });
2927
- for (const animation of group.animations) animation.ready?.catch(() => {});
2928
- const ready = group.animations[0].ready;
2929
- if (ready == null || typeof ready.then !== "function") {
2930
- engine.resolveGroup(group, group.provisional);
2931
- return;
2932
- }
2933
- requestFrame?.((frame) => {
2934
- engine.syncGroup(group);
2935
- group.framed = true;
2936
- if (group.resolved) return;
2937
- const at = frameTime(frame, now);
2938
- if (group.madeInFrame !== true && (group.task?.nextFrame === true || at - (group.task?.first ?? group.provisional) <= 34) && group.animations.some((animation) => animation.startTime == null && animation.playState === "running")) engine.resolveGroup(group, at);
2939
- if (!group.resolved) for (const channel of group.channels) {
2940
- const animation = running.get(channel);
2941
- if (animation != null && group.animations.includes(animation) && animation.startTime == null && animation.playState === "running") (group.latest ??= /* @__PURE__ */ new Map()).set(channel, at);
2942
- }
2943
- });
2944
- ready.then(() => engine.syncGroup(group), () => engine.settleCancelled(group));
2945
- };
2946
- }
2947
- //#endregion
2948
- //#region src/motion/engine/state.ts
2949
- function initEngineState(engine) {
2950
- const { options } = engine;
2951
- const now = options.now ?? motionNow;
2952
- engine.now = now;
2953
- const frameSource = options.requestFrame ?? (typeof requestAnimationFrame === "function" ? (callback) => {
2954
- requestAnimationFrame((frame) => callback(frame));
2955
- } : null);
2956
- engine.frameSource = frameSource;
2957
- engine.requestFrame = frameSource == null ? null : (callback) => {
2958
- frameSource((frame) => {
2959
- frameNesting.depth += 1;
2960
- try {
2961
- callback(frame);
2962
- } finally {
2963
- frameNesting.depth -= 1;
2964
- }
2965
- });
2966
- };
2967
- const pseudoElement = options.pseudoElement;
2968
- engine.pseudoElement = pseudoElement;
2969
- const customProperty = options.customProperty;
2970
- engine.customProperty = customProperty;
2971
- const companion = customProperty?.companion;
2972
- engine.companion = companion;
2973
- if (customProperty != null) registerCustomProperty(customProperty.name, customProperty.syntax);
2974
- if (companion != null) registerCustomProperty(companion.name, companion.syntax);
2975
- engine.customUnit = customProperty?.syntax === "<number>" ? "" : "px";
2976
- engine.isCoarsePointer = defaultIsCoarsePointer;
2977
- engine.resting = {
2978
- ...IDENTITY,
2979
- ...expand(options.initial ?? {})
2980
- };
2981
- engine.base = expand(options.base ?? {});
2982
- engine.segments = /* @__PURE__ */ new Map();
2983
- engine.running = /* @__PURE__ */ new Map();
2984
- /** Drops a finished, still-filling animation once the main thread runs. */
2985
- engine.retireTimers = /* @__PURE__ */ new Map();
2986
- /**
2987
- * Animations whose retire looks again at the next frame (scheduleRetire):
2988
- * each its own, so one still waiting for a replaced animation does not
2989
- * stand in for the next.
2990
- */
2991
- engine.retireFrames = /* @__PURE__ */ new Set();
2992
- /** The timer that starts those looks a frame before a curve's end. */
2993
- engine.retireLooks = /* @__PURE__ */ new Map();
2994
- engine.touched = /* @__PURE__ */ new Set();
2995
- /**
2996
- * The stylesheet's opacity a Reduce Motion dip borrowed because no call
2997
- * owned opacity; the dip runs from and back to it, then hands it back.
2998
- */
2999
- engine.borrowedOpacity = null;
3000
- engine.target = null;
3001
- /** Calls from rest whose start still waits for the browser's commit. */
3002
- engine.pendingGroups = /* @__PURE__ */ new Set();
3003
- /** atRest() calls still waiting; dispose settles them. */
3004
- engine.restWaits = /* @__PURE__ */ new Set();
3005
- /** A detach that settles as an unmount at the end of the task, unless an attach follows. */
3006
- engine.unmountQueued = false;
3007
- /**
3008
- * The node the latest attach(null) detached, while its unmount is pending:
3009
- * a waiting Reduce Motion move lands there, so that node is left visible
3010
- * where it was going.
3011
- */
3012
- engine.lastDetached = null;
3013
- /** The call being committed, when it starts from rest. */
3014
- engine.callGroup = null;
3015
- /** The element reported to presentation.ts while translate moves. */
3016
- engine.presented = null;
3017
- /**
3018
- * The translate the engine hit-tests the element at while the compositor
3019
- * moves it: where the animation started, or where a `resolve` left it.
3020
- */
3021
- engine.hitTested = {
3022
- x: 0,
3023
- y: 0
3024
- };
3025
- engine.unpresent = null;
3026
- /** Channels promoted to the element's compositing layer (will-change). */
3027
- engine.promoted = /* @__PURE__ */ new Set();
3028
- /** The element's own inline will-change, restored when promotion ends. */
3029
- engine.ownWillChange = null;
3030
- /** The stylesheet's will-change when there is no inline value. */
3031
- engine.sheetWillChange = "";
3032
- /**
3033
- * Whether sheetWillChange holds a read of the element's current style: it
3034
- * is read in the task after the element is attached, and again after each
3035
- * demotion, so a promotion (a drag's first move) reads no style in its
3036
- * own task.
3037
- */
3038
- engine.sheetWillChangeRead = false;
3039
- /** The pending read of sheetWillChange, cancelled with its element. */
3040
- engine.sheetReadTimer = null;
3041
- /** The node whose promotion waits in sheetReads for its stylesheet. */
3042
- engine.sheetReadQueuedFor = null;
3043
- engine.demoteTimer = null;
3044
- /** A pseudo-element is promoted through a custom property on its host. */
3045
- engine.promotionProperty = pseudoElement == null ? null : `--astryx-motion-will-change-${pseudoElement.replace(/^:+/, "")}`;
3046
- /** Channels whose identity the last node held inline (see `attach`). */
3047
- engine.heldIdentity = /* @__PURE__ */ new Set();
3048
- engine.presentedSource = {
3049
- offset: (time = now()) => {
3050
- engine.syncPending();
3051
- return {
3052
- x: engine.drawnTranslate("x", time) - engine.hitTested.x,
3053
- y: engine.drawnTranslate("y", time) - engine.hitTested.y
3054
- };
3055
- },
3056
- resolve: () => {
3057
- if (engine.target == null) return;
3058
- engine.syncPending();
3059
- const time = now();
3060
- writePresentedResolve(engine.target);
3061
- engine.hitTested = {
3062
- x: engine.drawnTranslate("x", time),
3063
- y: engine.drawnTranslate("y", time)
3064
- };
3065
- }
3066
- };
3067
- engine.baseChecked = false;
3068
- /**
3069
- * Channels whose model a rebase moved while their animation still shows
3070
- * the old curve. Any rebuild clears its channel; the end of the task
3071
- * rebuilds the rest, so a frame never shows the old curve at the new rest.
3072
- */
3073
- engine.stale = /* @__PURE__ */ new Set();
3074
- engine.healQueued = false;
3075
- /** Channels left at identity whose stylesheet value is still to be read. */
3076
- engine.releasing = /* @__PURE__ */ new Set();
3077
- engine.releaseQueued = false;
3078
- /** Calls with `start: 'presented'` waiting for their second frame. */
3079
- engine.deferredCalls = [];
3080
- engine.lastSpring = /* @__PURE__ */ new WeakMap();
3081
- engine.shown = /* @__PURE__ */ new Map();
3082
- /**
3083
- * Channels whose rebuild waits for the frame that commits their call, with
3084
- * the time of the last call on each.
3085
- */
3086
- engine.heldForFrame = /* @__PURE__ */ new Map();
3087
- engine.isShownLookQueued = false;
3088
- engine.stopWatchingHidden = null;
3089
- /** The page whose frames the animator's own frame source draws. */
3090
- engine.framePage = options.requestFrame == null && typeof document !== "undefined" ? document : null;
3091
- /** This animator's entry in the waiting calls, from what still waits. */
3092
- engine.waitKey = {};
3093
- /** Reduced Motion landings still waiting for the element to be transparent. */
3094
- engine.landings = /* @__PURE__ */ new Set();
3095
- /** Calls a later call's landing carries: an interrupt does not settle them. */
3096
- engine.carriedOwners = /* @__PURE__ */ new Set();
3097
- /** Reduce Motion calls that named their own opacity. */
3098
- engine.namedOpacity = /* @__PURE__ */ new WeakSet();
3099
- /**
3100
- * Where opacity was heading before a call took the waiting landings over:
3101
- * an entrance by role that catches an exit fades back to what the exit
3102
- * would have restored.
3103
- */
3104
- engine.headingBeforeTakeOver = null;
3105
- engine.animator = { get element() {
3106
- return engine.target;
3107
- } };
3108
- }
3109
- function initLateEngineState(engine) {
3110
- /** What the Reduce Motion planner reads of this animator. */
3111
- engine.planView = {
3112
- valueAt: engine.valueAt,
3113
- opacityHeading: () => engine.headingBeforeTakeOver ?? engine.opacityHeading(),
3114
- ownOpacity: () => engine.ownOpacity(),
3115
- writesOwnOpacity: () => engine.writesOwnOpacity(),
3116
- get borrowedOpacity() {
3117
- return engine.borrowedOpacity;
3118
- },
3119
- get hasOpacityCurve() {
3120
- return engine.segments.has("opacity");
3121
- },
3122
- get restingOpacity() {
3123
- return engine.resting.opacity;
3124
- },
3125
- get hasPendingLanding() {
3126
- return engine.landings.size > 0;
3127
- },
3128
- get hasWaitingDip() {
3129
- return [...engine.landings].some((landing) => landing.fadeIn != null);
3130
- }
3131
- };
3132
- }
3133
- //#endregion
3134
- //#region src/motion/animator.ts
3135
- /**
3136
- * Creates an animator for `element` (or for an element attached later).
3137
- *
3138
- * @example
3139
- * ```
3140
- * const animator = createMotionEngine(sheet);
3141
- * // finger lifts at 1200 px/s heading for the detent at 0 (a component
3142
- * // passes the spring of its motion role):
3143
- * animator.animate({y: 0}, {spring: {response: 0.45, dampingRatio: 0.9}, velocity: {y: 1200}});
3144
- * // the finger lands again: where is it right now?
3145
- * const y = animator.get('y', event.timeStamp);
3146
- * animator.stop(['y']);
3147
- * ```
3148
- */
3149
- function createMotionEngine(element, options = {}) {
3150
- const engine = {
3151
- element,
3152
- options
3153
- };
3154
- initEngineState(engine);
3155
- installChannelText(engine);
3156
- installCurveReads(engine);
3157
- installSampling(engine);
3158
- installRebuild(engine);
3159
- installRetire(engine);
3160
- installPromotion(engine);
3161
- installStartGroups(engine);
3162
- installGroupSync(engine);
3163
- installHandles(engine);
3164
- installSegments(engine);
3165
- installShownWatch(engine);
3166
- installLookAtShown(engine);
3167
- installLandings(engine);
3168
- installLandingRun(engine);
3169
- installAttach(engine);
3170
- installReadSet(engine);
3171
- installAnimate(engine);
3172
- installPlay(engine);
3173
- installDecayStop(engine);
3174
- installRebase(engine);
3175
- initLateEngineState(engine);
3176
- engine.animator.attach(element);
3177
- return engine.animator;
3178
- }
3179
- //#endregion
3180
25
  //#region src/motion/decay.ts
3181
26
  /**
3182
27
  * @file decay.ts
@@ -5315,37 +2160,6 @@ function isPrimaryClick(event) {
5315
2160
  return event.button === 0 && !(event.ctrlKey && isApplePlatform());
5316
2161
  }
5317
2162
  //#endregion
5318
- //#region src/utils/touchQueries.ts
5319
- /**
5320
- * @file touchQueries.ts
5321
- * @input Nothing: plain strings
5322
- * @output TOUCH_QUERY, the media query for a coarse primary pointer; and
5323
- * IOS_SUPPORTS_QUERY with isIosWebKit, the iOS WebKit engine check
5324
- * @position The dependency-free half of touchPresentation.ts, for code that
5325
- * must load without React or the theme: the motion foundation, which
5326
- * Node-side specs and browser proofs load without a StyleX compile.
5327
- * touchPresentation.ts re-exports it beside the hook and the parts that
5328
- * read the theme.
5329
- */
5330
- /** The primary pointer is coarse: touch behaviours. */
5331
- const TOUCH_QUERY = "(pointer: coarse)";
5332
- /**
5333
- * The engine is WebKit on iOS or iPadOS: the only one that implements
5334
- * `-webkit-touch-callout`. For a style iOS WebKit requires, never a
5335
- * behaviour; isIosWebKit reads it for an engine workaround a record names.
5336
- */
5337
- const IOS_SUPPORTS_QUERY = "(-webkit-touch-callout: none)";
5338
- /**
5339
- * Whether `view`'s engine is iOS WebKit, by IOS_SUPPORTS_QUERY. Only for an
5340
- * engine workaround a record names (`spec:AST-013` FR6): the selection
5341
- * lock's inline style, and the gesture host's presented hit testing. The
5342
- * keyboard's rise and its scroll back from the blur read it too. False where
5343
- * `CSS.supports` is missing (jsdom has `CSS.escape` only).
5344
- */
5345
- function isIosWebKit(view = globalThis) {
5346
- return view?.CSS?.supports?.(IOS_SUPPORTS_QUERY) === true;
5347
- }
5348
- //#endregion
5349
2163
  //#region src/utils/selectionLock.ts
5350
2164
  /**
5351
2165
  * @file selectionLock.ts
@@ -5853,60 +2667,6 @@ function lockDragSelection(elements, view, kept, onReleased) {
5853
2667
  return release;
5854
2668
  }
5855
2669
  //#endregion
5856
- //#region src/utils/coarsePointer.ts
5857
- /**
5858
- * @file coarsePointer.ts
5859
- * @input A window
5860
- * @output Exports isCoarsePointer, matchesMediaQuery, watchCoarsePointer and
5861
- * watchMediaQuery: whether the primary pointer is coarse (TOUCH_QUERY) or
5862
- * any media query matches, and when either changes
5863
- * @position The coarse-pointer gate of packages/core/src/gestures and of
5864
- * the press controller (pressFeedback.ts): touch-only work registers only
5865
- * while it holds. useMediaQuery and the presentation resolvers read and
5866
- * watch through matchesMediaQuery and watchMediaQuery
5867
- *
5868
- * Under a coarse primary pointer, a phone's touch work stays registered: the
5869
- * gesture host's page listeners, the page hold and the finger scroll. Under a
5870
- * fine one, recognizers still attach, and the host listens on the page only
5871
- * during a press (AST-094). The answer can change while the page is open (a
5872
- * tablet docking a mouse), so a holder watches it.
5873
- *
5874
- * SYNC: When modified, update coarsePointer.test.ts.
5875
- */
5876
- /** Whether the primary pointer of `view` is coarse now. */
5877
- function isCoarsePointer(view) {
5878
- return matchesMediaQuery(view, TOUCH_QUERY);
5879
- }
5880
- /**
5881
- * Whether `query` matches in `view` now. False where `view` has no
5882
- * `matchMedia`, as in a test DOM.
5883
- */
5884
- function matchesMediaQuery(view, query) {
5885
- return typeof view?.matchMedia === "function" && view.matchMedia(query).matches;
5886
- }
5887
- /**
5888
- * Call `listener` with the new answer each time `query` starts or stops
5889
- * matching in `view`, until the returned function is called.
5890
- */
5891
- function watchMediaQuery(view, query, listener) {
5892
- if (typeof view?.matchMedia !== "function") return () => {};
5893
- const list = view.matchMedia(query);
5894
- const onChange = () => listener(list.matches);
5895
- if (typeof list.addEventListener === "function") {
5896
- list.addEventListener("change", onChange);
5897
- return () => list.removeEventListener("change", onChange);
5898
- }
5899
- list.addListener(onChange);
5900
- return () => list.removeListener(onChange);
5901
- }
5902
- /**
5903
- * Call `listener` with the new answer each time the primary pointer of
5904
- * `view` turns coarse or fine, until the returned function is called.
5905
- */
5906
- function watchCoarsePointer(view, listener) {
5907
- return watchMediaQuery(view, TOUCH_QUERY, listener);
5908
- }
5909
- //#endregion
5910
2670
  //#region src/gestures/wheelSegmenter.ts
5911
2671
  /** Momentum arrives at frame rate: a pause this long ends it. */
5912
2672
  const MOMENTUM_GAP_MS = 50;
@@ -7364,27 +4124,6 @@ function createNativeScrollProbe(target, { readsTouchAction = true } = {}) {
7364
4124
  };
7365
4125
  }
7366
4126
  //#endregion
7367
- //#region src/gestures/touchHold.ts
7368
- /**
7369
- * @file touchHold.ts
7370
- * @input The holds a layer places on input while it animates or shields
7371
- * what is beneath it
7372
- * @output registerTouchHold, which adds a hold's read, and holdsTouch, the
7373
- * gesture host's one question: whether a touch on a target is held
7374
- * @position The seam between the gesture host and a layer's input hold
7375
- * (upstream Layer/inputHold `holdsTouch`): a layer registers its read, and
7376
- * the host asks before it gives a touch to any recognizer
7377
- *
7378
- * A held touch reaches no recognizer: the host drops it as it lands. With
7379
- * no hold registered, every touch passes, at once.
7380
- */
7381
- const holds = sharedState("gestures/touch-hold", 1, () => /* @__PURE__ */ new Set());
7382
- /** Whether any registered hold takes a touch on `target`. */
7383
- function holdsTouch(target) {
7384
- for (const query of holds) if (query(target)) return true;
7385
- return false;
7386
- }
7387
- //#endregion
7388
4127
  //#region src/gestures/hostHitTest.ts
7389
4128
  /** Presented hit testing, click retargeting, and the participants a contact meets; GestureHost is the class to use. */
7390
4129
  var HostHitTest = class extends HostInstall {