@rafaelaugusto/jolt 0.1.0-beta.8 → 0.1.0-rc.1

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 (582) hide show
  1. package/README.md +136 -15
  2. package/dist/animate.d.ts +25 -4
  3. package/dist/animate.d.ts.map +1 -1
  4. package/dist/animate.js +67 -26
  5. package/dist/animate.js.map +1 -1
  6. package/dist/blur/index.d.ts +6 -0
  7. package/dist/blur/index.d.ts.map +1 -0
  8. package/dist/blur/index.js +196 -0
  9. package/dist/blur/index.js.map +1 -0
  10. package/dist/blur/native.d.ts +17 -0
  11. package/dist/blur/native.d.ts.map +1 -0
  12. package/dist/blur/native.js +44 -0
  13. package/dist/blur/native.js.map +1 -0
  14. package/dist/blur/types.d.ts +32 -0
  15. package/dist/blur/types.d.ts.map +1 -0
  16. package/dist/blur/types.js +2 -0
  17. package/dist/blur/types.js.map +1 -0
  18. package/dist/bottom-sheet/geometry.d.ts +18 -0
  19. package/dist/bottom-sheet/geometry.d.ts.map +1 -0
  20. package/dist/bottom-sheet/geometry.js +51 -0
  21. package/dist/bottom-sheet/geometry.js.map +1 -0
  22. package/dist/bottom-sheet/index.d.ts +56 -0
  23. package/dist/bottom-sheet/index.d.ts.map +1 -0
  24. package/dist/bottom-sheet/index.js +462 -0
  25. package/dist/bottom-sheet/index.js.map +1 -0
  26. package/dist/bottom-sheet/native.d.ts +11 -0
  27. package/dist/bottom-sheet/native.d.ts.map +1 -0
  28. package/dist/bottom-sheet/native.js +173 -0
  29. package/dist/bottom-sheet/native.js.map +1 -0
  30. package/dist/config.d.ts +9 -0
  31. package/dist/config.d.ts.map +1 -1
  32. package/dist/config.js +40 -1
  33. package/dist/config.js.map +1 -1
  34. package/dist/decay.d.ts +1 -0
  35. package/dist/decay.d.ts.map +1 -1
  36. package/dist/decay.js +7 -0
  37. package/dist/decay.js.map +1 -1
  38. package/dist/drag-physics.d.ts +6 -1
  39. package/dist/drag-physics.d.ts.map +1 -1
  40. package/dist/drag.d.ts +17 -3
  41. package/dist/drag.d.ts.map +1 -1
  42. package/dist/drag.js +34 -11
  43. package/dist/drag.js.map +1 -1
  44. package/dist/driver/android-gradient.d.ts +5 -0
  45. package/dist/driver/android-gradient.d.ts.map +1 -0
  46. package/dist/driver/android-gradient.js +99 -0
  47. package/dist/driver/android-gradient.js.map +1 -0
  48. package/dist/driver/android-particles.d.ts +6 -0
  49. package/dist/driver/android-particles.d.ts.map +1 -0
  50. package/dist/driver/android-particles.js +93 -0
  51. package/dist/driver/android-particles.js.map +1 -0
  52. package/dist/driver/android.d.ts.map +1 -1
  53. package/dist/driver/android.js +67 -1
  54. package/dist/driver/android.js.map +1 -1
  55. package/dist/driver/frame.d.ts +3 -0
  56. package/dist/driver/frame.d.ts.map +1 -0
  57. package/dist/driver/frame.js +7 -0
  58. package/dist/driver/frame.js.map +1 -0
  59. package/dist/driver/index.d.ts +14 -0
  60. package/dist/driver/index.d.ts.map +1 -1
  61. package/dist/driver/index.js.map +1 -1
  62. package/dist/driver/ios-gradient.d.ts +5 -0
  63. package/dist/driver/ios-gradient.d.ts.map +1 -0
  64. package/dist/driver/ios-gradient.js +131 -0
  65. package/dist/driver/ios-gradient.js.map +1 -0
  66. package/dist/driver/ios-layout.d.ts +9 -0
  67. package/dist/driver/ios-layout.d.ts.map +1 -0
  68. package/dist/driver/ios-layout.js +52 -0
  69. package/dist/driver/ios-layout.js.map +1 -0
  70. package/dist/driver/ios-scroll-delegate.d.ts +4 -0
  71. package/dist/driver/ios-scroll-delegate.d.ts.map +1 -0
  72. package/dist/driver/ios-scroll-delegate.js +26 -0
  73. package/dist/driver/ios-scroll-delegate.js.map +1 -0
  74. package/dist/driver/ios.d.ts.map +1 -1
  75. package/dist/driver/ios.js +57 -1
  76. package/dist/driver/ios.js.map +1 -1
  77. package/dist/easing.d.ts +3 -1
  78. package/dist/easing.d.ts.map +1 -1
  79. package/dist/easing.js +18 -1
  80. package/dist/easing.js.map +1 -1
  81. package/dist/engine.d.ts +35 -2
  82. package/dist/engine.d.ts.map +1 -1
  83. package/dist/engine.js +211 -42
  84. package/dist/engine.js.map +1 -1
  85. package/dist/gesture-native.d.ts +28 -0
  86. package/dist/gesture-native.d.ts.map +1 -0
  87. package/dist/gesture-native.js +61 -0
  88. package/dist/gesture-native.js.map +1 -0
  89. package/dist/gestures/index.d.ts +69 -0
  90. package/dist/gestures/index.d.ts.map +1 -0
  91. package/dist/gestures/index.js +262 -0
  92. package/dist/gestures/index.js.map +1 -0
  93. package/dist/glass/index.d.ts +55 -0
  94. package/dist/glass/index.d.ts.map +1 -0
  95. package/dist/glass/index.js +205 -0
  96. package/dist/glass/index.js.map +1 -0
  97. package/dist/gradient-binding.d.ts +38 -0
  98. package/dist/gradient-binding.d.ts.map +1 -0
  99. package/dist/gradient-binding.js +128 -0
  100. package/dist/gradient-binding.js.map +1 -0
  101. package/dist/gradient.d.ts +105 -0
  102. package/dist/gradient.d.ts.map +1 -0
  103. package/dist/gradient.js +514 -0
  104. package/dist/gradient.js.map +1 -0
  105. package/dist/gravity.d.ts +13 -0
  106. package/dist/gravity.d.ts.map +1 -0
  107. package/dist/gravity.js +84 -0
  108. package/dist/gravity.js.map +1 -0
  109. package/dist/haptics.d.ts.map +1 -1
  110. package/dist/haptics.js +101 -28
  111. package/dist/haptics.js.map +1 -1
  112. package/dist/image-effect.d.ts +1 -0
  113. package/dist/image-effect.d.ts.map +1 -1
  114. package/dist/image-effect.js +10 -2
  115. package/dist/image-effect.js.map +1 -1
  116. package/dist/index.d.ts +21 -7
  117. package/dist/index.d.ts.map +1 -1
  118. package/dist/index.js +11 -4
  119. package/dist/index.js.map +1 -1
  120. package/dist/inspector/index.d.ts +86 -0
  121. package/dist/inspector/index.d.ts.map +1 -0
  122. package/dist/inspector/index.js +419 -0
  123. package/dist/inspector/index.js.map +1 -0
  124. package/dist/inspector/plot.d.ts +4 -0
  125. package/dist/inspector/plot.d.ts.map +1 -0
  126. package/dist/inspector/plot.js +23 -0
  127. package/dist/inspector/plot.js.map +1 -0
  128. package/dist/inspector/probe.d.ts +19 -0
  129. package/dist/inspector/probe.d.ts.map +1 -0
  130. package/dist/inspector/probe.js +37 -0
  131. package/dist/inspector/probe.js.map +1 -0
  132. package/dist/inspector/tuning.d.ts +19 -0
  133. package/dist/inspector/tuning.d.ts.map +1 -0
  134. package/dist/inspector/tuning.js +37 -0
  135. package/dist/inspector/tuning.js.map +1 -0
  136. package/dist/interactive-navigation/index.d.ts +44 -0
  137. package/dist/interactive-navigation/index.d.ts.map +1 -0
  138. package/dist/interactive-navigation/index.js +314 -0
  139. package/dist/interactive-navigation/index.js.map +1 -0
  140. package/dist/keyboard.d.ts +24 -0
  141. package/dist/keyboard.d.ts.map +1 -1
  142. package/dist/keyboard.js +199 -6
  143. package/dist/keyboard.js.map +1 -1
  144. package/dist/layout.d.ts +13 -0
  145. package/dist/layout.d.ts.map +1 -0
  146. package/dist/layout.js +348 -0
  147. package/dist/layout.js.map +1 -0
  148. package/dist/live-spring-driver.d.ts +52 -0
  149. package/dist/live-spring-driver.d.ts.map +1 -0
  150. package/dist/live-spring-driver.js +104 -0
  151. package/dist/live-spring-driver.js.map +1 -0
  152. package/dist/mixer.d.ts +55 -0
  153. package/dist/mixer.d.ts.map +1 -0
  154. package/dist/mixer.js +278 -0
  155. package/dist/mixer.js.map +1 -0
  156. package/dist/motion-scope.d.ts +10 -2
  157. package/dist/motion-scope.d.ts.map +1 -1
  158. package/dist/motion-scope.js +30 -3
  159. package/dist/motion-scope.js.map +1 -1
  160. package/dist/motion-states.d.ts +19 -7
  161. package/dist/motion-states.d.ts.map +1 -1
  162. package/dist/motion-states.js +116 -26
  163. package/dist/motion-states.js.map +1 -1
  164. package/dist/motion-value.d.ts +227 -0
  165. package/dist/motion-value.d.ts.map +1 -0
  166. package/dist/motion-value.js +1074 -0
  167. package/dist/motion-value.js.map +1 -0
  168. package/dist/native/index.d.ts +10 -0
  169. package/dist/native/index.d.ts.map +1 -0
  170. package/dist/native/index.js +6 -0
  171. package/dist/native/index.js.map +1 -0
  172. package/dist/native-properties.d.ts +28 -0
  173. package/dist/native-properties.d.ts.map +1 -0
  174. package/dist/native-properties.js +154 -0
  175. package/dist/native-properties.js.map +1 -0
  176. package/dist/native-property-driver.d.ts +19 -0
  177. package/dist/native-property-driver.d.ts.map +1 -0
  178. package/dist/native-property-driver.js +69 -0
  179. package/dist/native-property-driver.js.map +1 -0
  180. package/dist/native-property.d.ts +37 -0
  181. package/dist/native-property.d.ts.map +1 -0
  182. package/dist/native-property.js +285 -0
  183. package/dist/native-property.js.map +1 -0
  184. package/dist/particles.d.ts +5 -2
  185. package/dist/particles.d.ts.map +1 -1
  186. package/dist/particles.js +16 -10
  187. package/dist/particles.js.map +1 -1
  188. package/dist/path.d.ts.map +1 -1
  189. package/dist/path.js +2 -2
  190. package/dist/path.js.map +1 -1
  191. package/dist/physics/index.d.ts +116 -0
  192. package/dist/physics/index.d.ts.map +1 -0
  193. package/dist/physics/index.js +306 -0
  194. package/dist/physics/index.js.map +1 -0
  195. package/dist/physics/native.d.ts +53 -0
  196. package/dist/physics/native.d.ts.map +1 -0
  197. package/dist/physics/native.js +58 -0
  198. package/dist/physics/native.js.map +1 -0
  199. package/dist/playback-group.d.ts.map +1 -1
  200. package/dist/playback-group.js +17 -1
  201. package/dist/playback-group.js.map +1 -1
  202. package/dist/playback.d.ts +15 -0
  203. package/dist/playback.d.ts.map +1 -1
  204. package/dist/playback.js +23 -0
  205. package/dist/playback.js.map +1 -1
  206. package/dist/predictive-back/index.d.ts +45 -0
  207. package/dist/predictive-back/index.d.ts.map +1 -0
  208. package/dist/predictive-back/index.js +220 -0
  209. package/dist/predictive-back/index.js.map +1 -0
  210. package/dist/predictive-back/presentation.d.ts +4 -0
  211. package/dist/predictive-back/presentation.d.ts.map +1 -0
  212. package/dist/predictive-back/presentation.js +3 -0
  213. package/dist/predictive-back/presentation.js.map +1 -0
  214. package/dist/reorder/handle.d.ts +6 -0
  215. package/dist/reorder/handle.d.ts.map +1 -0
  216. package/dist/reorder/handle.js +10 -0
  217. package/dist/reorder/handle.js.map +1 -0
  218. package/dist/reorder/index.d.ts +10 -0
  219. package/dist/reorder/index.d.ts.map +1 -0
  220. package/dist/reorder/index.js +233 -0
  221. package/dist/reorder/index.js.map +1 -0
  222. package/dist/reorder/list-view.d.ts +5 -0
  223. package/dist/reorder/list-view.d.ts.map +1 -0
  224. package/dist/reorder/list-view.js +238 -0
  225. package/dist/reorder/list-view.js.map +1 -0
  226. package/dist/reorder/model.d.ts +6 -0
  227. package/dist/reorder/model.d.ts.map +1 -0
  228. package/dist/reorder/model.js +30 -0
  229. package/dist/reorder/model.js.map +1 -0
  230. package/dist/reorder/surface.d.ts +6 -0
  231. package/dist/reorder/surface.d.ts.map +1 -0
  232. package/dist/reorder/surface.js +10 -0
  233. package/dist/reorder/surface.js.map +1 -0
  234. package/dist/reorder/types.d.ts +92 -0
  235. package/dist/reorder/types.d.ts.map +1 -0
  236. package/dist/reorder/types.js +2 -0
  237. package/dist/reorder/types.js.map +1 -0
  238. package/dist/sampling.d.ts +35 -0
  239. package/dist/sampling.d.ts.map +1 -0
  240. package/dist/sampling.js +123 -0
  241. package/dist/sampling.js.map +1 -0
  242. package/dist/scene-appearance.d.ts +14 -0
  243. package/dist/scene-appearance.d.ts.map +1 -0
  244. package/dist/scene-appearance.js +68 -0
  245. package/dist/scene-appearance.js.map +1 -0
  246. package/dist/scene-camera.d.ts +5 -0
  247. package/dist/scene-camera.d.ts.map +1 -0
  248. package/dist/scene-camera.js +23 -0
  249. package/dist/scene-camera.js.map +1 -0
  250. package/dist/scene-shader.d.ts +18 -0
  251. package/dist/scene-shader.d.ts.map +1 -0
  252. package/dist/scene-shader.js +76 -0
  253. package/dist/scene-shader.js.map +1 -0
  254. package/dist/scroll-header/geometry.d.ts +18 -0
  255. package/dist/scroll-header/geometry.d.ts.map +1 -0
  256. package/dist/scroll-header/geometry.js +46 -0
  257. package/dist/scroll-header/geometry.js.map +1 -0
  258. package/dist/scroll-header/index.d.ts +48 -0
  259. package/dist/scroll-header/index.d.ts.map +1 -0
  260. package/dist/scroll-header/index.js +373 -0
  261. package/dist/scroll-header/index.js.map +1 -0
  262. package/dist/scroll-header/native.d.ts +28 -0
  263. package/dist/scroll-header/native.d.ts.map +1 -0
  264. package/dist/scroll-header/native.js +43 -0
  265. package/dist/scroll-header/native.js.map +1 -0
  266. package/dist/sensors/index.d.ts +69 -0
  267. package/dist/sensors/index.d.ts.map +1 -0
  268. package/dist/sensors/index.js +149 -0
  269. package/dist/sensors/index.js.map +1 -0
  270. package/dist/sensors/native.d.ts +20 -0
  271. package/dist/sensors/native.d.ts.map +1 -0
  272. package/dist/sensors/native.js +48 -0
  273. package/dist/sensors/native.js.map +1 -0
  274. package/dist/sequence.d.ts +24 -0
  275. package/dist/sequence.d.ts.map +1 -1
  276. package/dist/sequence.js +181 -19
  277. package/dist/sequence.js.map +1 -1
  278. package/dist/shapes/android.d.ts +3 -0
  279. package/dist/shapes/android.d.ts.map +1 -0
  280. package/dist/shapes/android.js +51 -0
  281. package/dist/shapes/android.js.map +1 -0
  282. package/dist/shapes/index.d.ts +6 -0
  283. package/dist/shapes/index.d.ts.map +1 -0
  284. package/dist/shapes/index.js +238 -0
  285. package/dist/shapes/index.js.map +1 -0
  286. package/dist/shapes/ios.d.ts +3 -0
  287. package/dist/shapes/ios.d.ts.map +1 -0
  288. package/dist/shapes/ios.js +164 -0
  289. package/dist/shapes/ios.js.map +1 -0
  290. package/dist/shapes/native.d.ts +18 -0
  291. package/dist/shapes/native.d.ts.map +1 -0
  292. package/dist/shapes/native.js +10 -0
  293. package/dist/shapes/native.js.map +1 -0
  294. package/dist/shapes/path.d.ts +10 -0
  295. package/dist/shapes/path.d.ts.map +1 -0
  296. package/dist/shapes/path.js +106 -0
  297. package/dist/shapes/path.js.map +1 -0
  298. package/dist/shapes/types.d.ts +55 -0
  299. package/dist/shapes/types.d.ts.map +1 -0
  300. package/dist/shapes/types.js +11 -0
  301. package/dist/shapes/types.js.map +1 -0
  302. package/dist/shared-layout/index.d.ts +40 -0
  303. package/dist/shared-layout/index.d.ts.map +1 -0
  304. package/dist/shared-layout/index.js +267 -0
  305. package/dist/shared-layout/index.js.map +1 -0
  306. package/dist/shared-layout/native.d.ts +15 -0
  307. package/dist/shared-layout/native.d.ts.map +1 -0
  308. package/dist/shared-layout/native.js +79 -0
  309. package/dist/shared-layout/native.js.map +1 -0
  310. package/dist/shared-layout/timing.d.ts +9 -0
  311. package/dist/shared-layout/timing.d.ts.map +1 -0
  312. package/dist/shared-layout/timing.js +68 -0
  313. package/dist/shared-layout/timing.js.map +1 -0
  314. package/dist/shared-navigation/entry.d.ts +51 -0
  315. package/dist/shared-navigation/entry.d.ts.map +1 -0
  316. package/dist/shared-navigation/entry.js +619 -0
  317. package/dist/shared-navigation/entry.js.map +1 -0
  318. package/dist/shared-navigation/index.d.ts +58 -0
  319. package/dist/shared-navigation/index.d.ts.map +1 -0
  320. package/dist/shared-navigation/index.js +318 -0
  321. package/dist/shared-navigation/index.js.map +1 -0
  322. package/dist/shared-navigation/return-signal.d.ts +16 -0
  323. package/dist/shared-navigation/return-signal.d.ts.map +1 -0
  324. package/dist/shared-navigation/return-signal.js +35 -0
  325. package/dist/shared-navigation/return-signal.js.map +1 -0
  326. package/dist/shared-navigation/return-target.d.ts +32 -0
  327. package/dist/shared-navigation/return-target.d.ts.map +1 -0
  328. package/dist/shared-navigation/return-target.js +168 -0
  329. package/dist/shared-navigation/return-target.js.map +1 -0
  330. package/dist/shared-navigation/scope.d.ts +4 -0
  331. package/dist/shared-navigation/scope.d.ts.map +1 -0
  332. package/dist/shared-navigation/scope.js +2 -0
  333. package/dist/shared-navigation/scope.js.map +1 -0
  334. package/dist/shared-navigation/targets.d.ts +6 -0
  335. package/dist/shared-navigation/targets.d.ts.map +1 -0
  336. package/dist/shared-navigation/targets.js +36 -0
  337. package/dist/shared-navigation/targets.js.map +1 -0
  338. package/dist/size-layout.d.ts +19 -0
  339. package/dist/size-layout.d.ts.map +1 -0
  340. package/dist/size-layout.js +216 -0
  341. package/dist/size-layout.js.map +1 -0
  342. package/dist/size.d.ts +19 -0
  343. package/dist/size.d.ts.map +1 -0
  344. package/dist/size.js +251 -0
  345. package/dist/size.js.map +1 -0
  346. package/dist/spring.d.ts +2 -0
  347. package/dist/spring.d.ts.map +1 -1
  348. package/dist/spring.js +11 -0
  349. package/dist/spring.js.map +1 -1
  350. package/dist/svg-path.d.ts +18 -0
  351. package/dist/svg-path.d.ts.map +1 -1
  352. package/dist/svg-path.js +3 -2
  353. package/dist/svg-path.js.map +1 -1
  354. package/dist/testing/clock.d.ts +40 -0
  355. package/dist/testing/clock.d.ts.map +1 -0
  356. package/dist/testing/clock.js +116 -0
  357. package/dist/testing/clock.js.map +1 -0
  358. package/dist/testing/handoff-recorder.d.ts +8 -0
  359. package/dist/testing/handoff-recorder.d.ts.map +1 -0
  360. package/dist/testing/handoff-recorder.js +77 -0
  361. package/dist/testing/handoff-recorder.js.map +1 -0
  362. package/dist/testing/index.d.ts +5 -0
  363. package/dist/testing/index.d.ts.map +1 -0
  364. package/dist/testing/index.js +5 -0
  365. package/dist/testing/index.js.map +1 -0
  366. package/dist/testing/native.d.ts +46 -0
  367. package/dist/testing/native.d.ts.map +1 -0
  368. package/dist/testing/native.js +313 -0
  369. package/dist/testing/native.js.map +1 -0
  370. package/dist/testing/presentation.d.ts +11 -0
  371. package/dist/testing/presentation.d.ts.map +1 -0
  372. package/dist/testing/presentation.js +45 -0
  373. package/dist/testing/presentation.js.map +1 -0
  374. package/dist/testing/replay.d.ts +39 -0
  375. package/dist/testing/replay.d.ts.map +1 -0
  376. package/dist/testing/replay.js +99 -0
  377. package/dist/testing/replay.js.map +1 -0
  378. package/dist/testing/scroll-handoff-native.d.ts +10 -0
  379. package/dist/testing/scroll-handoff-native.d.ts.map +1 -0
  380. package/dist/testing/scroll-handoff-native.js +151 -0
  381. package/dist/testing/scroll-handoff-native.js.map +1 -0
  382. package/dist/testing/scroll-handoff.d.ts +25 -0
  383. package/dist/testing/scroll-handoff.d.ts.map +1 -0
  384. package/dist/testing/scroll-handoff.js +127 -0
  385. package/dist/testing/scroll-handoff.js.map +1 -0
  386. package/dist/testing/sensors.d.ts +13 -0
  387. package/dist/testing/sensors.d.ts.map +1 -0
  388. package/dist/testing/sensors.js +26 -0
  389. package/dist/testing/sensors.js.map +1 -0
  390. package/dist/testing/trace.d.ts +101 -0
  391. package/dist/testing/trace.d.ts.map +1 -0
  392. package/dist/testing/trace.js +263 -0
  393. package/dist/testing/trace.js.map +1 -0
  394. package/dist/timed-animation.d.ts +38 -0
  395. package/dist/timed-animation.d.ts.map +1 -0
  396. package/dist/timed-animation.js +177 -0
  397. package/dist/timed-animation.js.map +1 -0
  398. package/dist/track.d.ts +3 -0
  399. package/dist/track.d.ts.map +1 -1
  400. package/dist/track.js +281 -40
  401. package/dist/track.js.map +1 -1
  402. package/dist/transition.d.ts +54 -2
  403. package/dist/transition.d.ts.map +1 -1
  404. package/dist/transition.js +128 -8
  405. package/dist/transition.js.map +1 -1
  406. package/dist/types.d.ts +10 -1
  407. package/dist/types.d.ts.map +1 -1
  408. package/dist/value-observers.d.ts +22 -0
  409. package/dist/value-observers.d.ts.map +1 -0
  410. package/dist/value-observers.js +122 -0
  411. package/dist/value-observers.js.map +1 -0
  412. package/dist/value-track.d.ts +13 -0
  413. package/dist/value-track.d.ts.map +1 -0
  414. package/dist/value-track.js +59 -0
  415. package/dist/value-track.js.map +1 -0
  416. package/dist/vue/index.d.ts +33 -3
  417. package/dist/vue/index.d.ts.map +1 -1
  418. package/dist/vue/index.js +118 -3
  419. package/dist/vue/index.js.map +1 -1
  420. package/dist/zoomable.d.ts +1 -1
  421. package/dist/zoomable.d.ts.map +1 -1
  422. package/package.json +68 -3
  423. package/platforms/android/include.gradle +10 -0
  424. package/platforms/android/java/org/rafaelaugusto/jolt/BlurEffect.java +89 -0
  425. package/platforms/android/java/org/rafaelaugusto/jolt/CircleMath.java +151 -0
  426. package/platforms/android/java/org/rafaelaugusto/jolt/CircleWorld.java +210 -0
  427. package/platforms/android/java/org/rafaelaugusto/jolt/GestureSession.java +227 -0
  428. package/platforms/android/java/org/rafaelaugusto/jolt/GestureSurface.java +54 -0
  429. package/platforms/android/java/org/rafaelaugusto/jolt/GradientLayer.java +224 -0
  430. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrame.java +53 -0
  431. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrameFollower.java +57 -0
  432. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardObserver.java +97 -0
  433. package/platforms/android/java/org/rafaelaugusto/jolt/LiveSpring.java +277 -0
  434. package/platforms/android/java/org/rafaelaugusto/jolt/MotionProbe.java +70 -0
  435. package/platforms/android/java/org/rafaelaugusto/jolt/ParticleEmitter.java +192 -0
  436. package/platforms/android/java/org/rafaelaugusto/jolt/ParticleSimulation.java +114 -0
  437. package/platforms/android/java/org/rafaelaugusto/jolt/PredictiveBackSession.java +212 -0
  438. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderHandle.java +25 -0
  439. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSession.java +213 -0
  440. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSurface.java +27 -0
  441. package/platforms/android/java/org/rafaelaugusto/jolt/ScrollHeader.java +84 -0
  442. package/platforms/android/java/org/rafaelaugusto/jolt/SensorMath.java +28 -0
  443. package/platforms/android/java/org/rafaelaugusto/jolt/SensorSource.java +217 -0
  444. package/platforms/android/java/org/rafaelaugusto/jolt/ShapeLayer.java +120 -0
  445. package/platforms/android/java/org/rafaelaugusto/jolt/SharedLayoutFlight.java +287 -0
  446. package/platforms/android/java/org/rafaelaugusto/jolt/SharedNavigationScene.java +115 -0
  447. package/platforms/android/java/org/rafaelaugusto/jolt/SpringState.java +39 -0
  448. package/platforms/android/proguard-rules.pro +20 -0
  449. package/platforms/ios/build.xcconfig +1 -1
  450. package/platforms/ios/src/JoltBlur.h +14 -0
  451. package/platforms/ios/src/JoltBlur.m +86 -0
  452. package/platforms/ios/src/JoltCircleMath.h +183 -0
  453. package/platforms/ios/src/JoltCircleWorld.h +17 -0
  454. package/platforms/ios/src/JoltCircleWorld.m +203 -0
  455. package/platforms/ios/src/JoltGestureSession.h +23 -0
  456. package/platforms/ios/src/JoltGestureSession.m +251 -0
  457. package/platforms/ios/src/JoltInteractiveNavigation.h +23 -0
  458. package/platforms/ios/src/JoltInteractiveNavigation.m +255 -0
  459. package/platforms/ios/src/JoltLiveSpring.h +29 -0
  460. package/platforms/ios/src/JoltLiveSpring.m +243 -0
  461. package/platforms/ios/src/JoltMotionProbe.h +9 -0
  462. package/platforms/ios/src/JoltMotionProbe.m +72 -0
  463. package/platforms/ios/src/JoltReorderSession.h +15 -0
  464. package/platforms/ios/src/JoltReorderSession.m +205 -0
  465. package/platforms/ios/src/JoltScrollHeader.h +13 -0
  466. package/platforms/ios/src/JoltScrollHeader.m +93 -0
  467. package/platforms/ios/src/JoltSensorMath.h +39 -0
  468. package/platforms/ios/src/JoltSensorSource.h +13 -0
  469. package/platforms/ios/src/JoltSensorSource.m +201 -0
  470. package/platforms/ios/src/JoltSharedLayoutFlight.h +19 -0
  471. package/platforms/ios/src/JoltSharedLayoutFlight.m +250 -0
  472. package/platforms/ios/src/JoltSpringState.h +35 -0
  473. package/platforms/ios/src/module.modulemap +10 -0
  474. package/src/android-plugin.d.ts +463 -0
  475. package/src/animate.ts +129 -15
  476. package/src/blur/index.ts +195 -0
  477. package/src/blur/native.ts +70 -0
  478. package/src/blur/types.ts +32 -0
  479. package/src/bottom-sheet/geometry.ts +84 -0
  480. package/src/bottom-sheet/index.ts +536 -0
  481. package/src/bottom-sheet/native.ts +214 -0
  482. package/src/config.ts +39 -1
  483. package/src/decay.ts +9 -0
  484. package/src/drag.ts +67 -21
  485. package/src/driver/android-gradient.ts +116 -0
  486. package/src/driver/android-particles.ts +118 -0
  487. package/src/driver/android.ts +69 -1
  488. package/src/driver/frame.ts +10 -0
  489. package/src/driver/index.ts +15 -0
  490. package/src/driver/ios-gradient.ts +136 -0
  491. package/src/driver/ios-layout.ts +63 -0
  492. package/src/driver/ios-scroll-delegate.ts +23 -0
  493. package/src/driver/ios.ts +70 -17
  494. package/src/easing.ts +21 -1
  495. package/src/engine.ts +226 -59
  496. package/src/gesture-native.ts +139 -0
  497. package/src/gestures/index.ts +365 -0
  498. package/src/glass/index.ts +218 -0
  499. package/src/gradient-binding.ts +158 -0
  500. package/src/gradient.ts +663 -0
  501. package/src/gravity.ts +107 -0
  502. package/src/haptics.ts +106 -28
  503. package/src/image-effect.ts +10 -2
  504. package/src/index.ts +59 -7
  505. package/src/inspector/index.ts +523 -0
  506. package/src/inspector/plot.ts +27 -0
  507. package/src/inspector/probe.ts +50 -0
  508. package/src/inspector/tuning.ts +51 -0
  509. package/src/interactive-navigation/index.ts +398 -0
  510. package/src/ios-plugin.d.ts +279 -0
  511. package/src/keyboard.ts +231 -7
  512. package/src/layout.ts +408 -0
  513. package/src/live-spring-driver.ts +181 -0
  514. package/src/mixer.ts +306 -0
  515. package/src/motion-scope.ts +53 -6
  516. package/src/motion-states.ts +149 -42
  517. package/src/motion-value.ts +1289 -0
  518. package/src/native/index.ts +30 -0
  519. package/src/native-properties.ts +188 -0
  520. package/src/native-property-driver.ts +123 -0
  521. package/src/native-property.ts +366 -0
  522. package/src/particles.ts +18 -17
  523. package/src/path.ts +2 -1
  524. package/src/physics/index.ts +443 -0
  525. package/src/physics/native.ts +110 -0
  526. package/src/playback-group.ts +17 -1
  527. package/src/playback.ts +41 -0
  528. package/src/predictive-back/index.ts +280 -0
  529. package/src/predictive-back/presentation.ts +6 -0
  530. package/src/reorder/handle.ts +9 -0
  531. package/src/reorder/index.ts +243 -0
  532. package/src/reorder/list-view.ts +262 -0
  533. package/src/reorder/model.ts +47 -0
  534. package/src/reorder/surface.ts +10 -0
  535. package/src/reorder/types.ts +87 -0
  536. package/src/sampling.ts +173 -0
  537. package/src/scene-appearance.ts +92 -0
  538. package/src/scene-camera.ts +30 -0
  539. package/src/scene-shader.ts +139 -0
  540. package/src/scroll-header/geometry.ts +88 -0
  541. package/src/scroll-header/index.ts +504 -0
  542. package/src/scroll-header/native.ts +89 -0
  543. package/src/sensors/index.ts +246 -0
  544. package/src/sensors/native.ts +72 -0
  545. package/src/sequence.ts +209 -20
  546. package/src/shapes/android.ts +63 -0
  547. package/src/shapes/index.ts +267 -0
  548. package/src/shapes/ios.ts +194 -0
  549. package/src/shapes/native.ts +27 -0
  550. package/src/shapes/path.ts +127 -0
  551. package/src/shapes/types.ts +63 -0
  552. package/src/shared-layout/index.ts +343 -0
  553. package/src/shared-layout/native.ts +138 -0
  554. package/src/shared-layout/timing.ts +87 -0
  555. package/src/shared-navigation/entry.ts +695 -0
  556. package/src/shared-navigation/index.ts +414 -0
  557. package/src/shared-navigation/return-signal.ts +41 -0
  558. package/src/shared-navigation/return-target.ts +197 -0
  559. package/src/shared-navigation/scope.ts +3 -0
  560. package/src/shared-navigation/targets.ts +38 -0
  561. package/src/size-layout.ts +237 -0
  562. package/src/size.ts +302 -0
  563. package/src/spring.ts +18 -0
  564. package/src/svg-path.ts +8 -3
  565. package/src/testing/clock.ts +128 -0
  566. package/src/testing/handoff-recorder.ts +98 -0
  567. package/src/testing/index.ts +4 -0
  568. package/src/testing/native.ts +386 -0
  569. package/src/testing/presentation.ts +46 -0
  570. package/src/testing/replay.ts +149 -0
  571. package/src/testing/scroll-handoff-native.ts +201 -0
  572. package/src/testing/scroll-handoff.ts +140 -0
  573. package/src/testing/sensors.ts +41 -0
  574. package/src/testing/trace.ts +340 -0
  575. package/src/timed-animation.ts +192 -0
  576. package/src/track.ts +334 -38
  577. package/src/transition.ts +197 -9
  578. package/src/types.ts +11 -1
  579. package/src/value-observers.ts +147 -0
  580. package/src/value-track.ts +71 -0
  581. package/src/vue/index.ts +147 -1
  582. package/src/zoomable.ts +1 -1
package/src/keyboard.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Application, Utils, isAndroid, isIOS, type View } from '@nativescript/core'
2
- import { stop, toView } from './animate.js'
2
+ import { animate, stop, toView } from './animate.js'
3
+ import type { EasingFunction, EasingName } from './easing.js'
4
+ import type { Spring, Transition, Tween } from './transition.js'
3
5
  import type { Target } from './types.js'
4
6
 
5
7
  export interface KeyboardOptions {
@@ -7,7 +9,180 @@ export interface KeyboardOptions {
7
9
  offset?: number
8
10
  }
9
11
 
12
+ export interface KeyboardState {
13
+ /** Whether a docked software keyboard covers part of the window. */
14
+ readonly visible: boolean
15
+ /** DIPs of the window the keyboard covers, from its bottom edge. Zero when hidden or floating. */
16
+ readonly height: number
17
+ /** Milliseconds the keyboard takes to get there. Zero when it changes at once. */
18
+ readonly duration: number
19
+ /** The keyboard's own timing, to pass to `animate()` and move in step with it. */
20
+ readonly transition: Transition
21
+ }
22
+
10
23
  const BEGIN_FROM_CURRENT_STATE = 4
24
+ const IOS_KEYBOARD_CURVE = 7
25
+ // Measured: Core Animation plays the keyboard's spring (stiffness 1000, mass 3) critically damped in 500 ms.
26
+ const iosKeyboard: Spring = {
27
+ type: 'spring',
28
+ stiffness: 1000,
29
+ mass: 3,
30
+ damping: 2 * Math.sqrt(3000),
31
+ }
32
+ const iosCurves: readonly EasingName[] = ['easeInOut', 'easeIn', 'easeOut', 'linear']
33
+ // Before Android 11 nothing reports the keyboard's timing. Measured on an Android 9 emulator,
34
+ // its window fades and slides into place in about 150 ms, decelerating, and leaves as quickly.
35
+ const LEGACY_DURATION = 150
36
+ const legacyShow: Tween = { duration: LEGACY_DURATION, ease: 'quadOut' }
37
+ const legacyHide: Tween = { duration: LEGACY_DURATION, ease: 'quadIn' }
38
+ const legacy = () => isAndroid && android.os.Build.VERSION.SDK_INT < 30
39
+ const hidden: KeyboardState = Object.freeze({
40
+ visible: false,
41
+ height: 0,
42
+ duration: 0,
43
+ transition: { duration: 0 },
44
+ })
45
+
46
+ const listeners = new Set<(keyboard: KeyboardState) => void>()
47
+ let state = hidden
48
+ let unwatch: (() => void) | undefined
49
+
50
+ /**
51
+ * Calls back whenever the keyboard shows, hides or changes height, with how much
52
+ * of the window it covers and its timing. Returns a cleanup function.
53
+ *
54
+ * ```ts
55
+ * const off = onKeyboard(({ visible, transition }) => {
56
+ * animate(header, { scale: visible ? 0.8 : 1 }, transition)
57
+ * })
58
+ * ```
59
+ */
60
+ export function onKeyboard(callback: (keyboard: KeyboardState) => void): () => void {
61
+ if (typeof callback !== 'function')
62
+ throw new TypeError('onKeyboard() takes a callback.')
63
+ const listener = (keyboard: KeyboardState) => callback(keyboard)
64
+ if (listeners.size === 0) {
65
+ state = hidden
66
+ unwatch = isIOS ? watchIOS() : isAndroid ? watchAndroid() : undefined
67
+ }
68
+ listeners.add(listener)
69
+ return () => {
70
+ if (!listeners.delete(listener) || listeners.size > 0) return
71
+ unwatch?.()
72
+ unwatch = undefined
73
+ }
74
+ }
75
+
76
+ /** The last state reported while someone listens. */
77
+ export function currentKeyboard(): KeyboardState {
78
+ return state
79
+ }
80
+
81
+ function update(height: number, duration: number, transition: Transition) {
82
+ if (height === state.height) return
83
+ state = Object.freeze({ visible: height > 0, height, duration, transition })
84
+ for (const listener of [...listeners]) listener(state)
85
+ }
86
+
87
+ function watchIOS() {
88
+ const name = UIKeyboardWillChangeFrameNotification
89
+ const observer = Application.ios.addNotificationObserver(
90
+ name,
91
+ (notification: NSNotification) => {
92
+ const info = notification.userInfo
93
+ const window = Application.ios.window
94
+ const end = info?.objectForKey(UIKeyboardFrameEndUserInfoKey)?.CGRectValue as
95
+ CGRect | undefined
96
+ if (!info || !window || !end) return
97
+ const frame = window.convertRectFromWindow(end, null)
98
+ const bottom = window.bounds.size.height
99
+ const docked =
100
+ frame.size.height > 0 &&
101
+ frame.origin.y < bottom &&
102
+ frame.origin.y + frame.size.height >= bottom - 0.5
103
+ const reported = numberIn(info, UIKeyboardAnimationDurationUserInfoKey) * 1000
104
+ const curve = numberIn(info, UIKeyboardAnimationCurveUserInfoKey)
105
+ const height = docked ? bottom - frame.origin.y : 0
106
+ if (!reported) return update(height, 0, { duration: 0 })
107
+ if (curve === IOS_KEYBOARD_CURVE) return update(height, 500, iosKeyboard)
108
+ update(height, reported, {
109
+ duration: reported,
110
+ ease: iosCurves[curve] ?? 'easeInOut',
111
+ })
112
+ },
113
+ )
114
+ return () => Application.ios.removeNotificationObserver(observer, name)
115
+ }
116
+
117
+ function watchAndroid() {
118
+ const density = Utils.layout.getDisplayDensity()
119
+ let observer:
120
+ | org.rafaelaugusto.jolt.KeyboardObserver
121
+ | org.rafaelaugusto.jolt.KeyboardFrame
122
+ | undefined
123
+ let stopped = false
124
+ const attach = () => {
125
+ Application.off(Application.launchEvent, attach)
126
+ if (stopped || observer) return
127
+ const activity =
128
+ Application.android.foregroundActivity ?? Application.android.startActivity
129
+ const root = activity?.getWindow()?.getDecorView()
130
+ if (!root) return
131
+ try {
132
+ observer = legacy()
133
+ ? new org.rafaelaugusto.jolt.KeyboardFrame(
134
+ root,
135
+ new org.rafaelaugusto.jolt.KeyboardFrame.Listener({
136
+ onChange: (height) =>
137
+ update(
138
+ height / density,
139
+ LEGACY_DURATION,
140
+ height ? legacyShow : legacyHide,
141
+ ),
142
+ }),
143
+ )
144
+ : new org.rafaelaugusto.jolt.KeyboardObserver(
145
+ root,
146
+ new org.rafaelaugusto.jolt.KeyboardObserver.Listener({
147
+ onChange: (height, duration, curve) =>
148
+ update(
149
+ height / density,
150
+ duration,
151
+ duration
152
+ ? { duration, ease: curve ? sampled(curve) : 'linear' }
153
+ : { duration: 0 },
154
+ ),
155
+ }),
156
+ )
157
+ } catch {
158
+ // A JS-only update cannot install the native plugin.
159
+ return
160
+ }
161
+ observer.attach()
162
+ const height = observer.height() / density
163
+ if (height > 0) state = Object.freeze({ ...hidden, visible: true, height })
164
+ }
165
+ if (Application.android.foregroundActivity ?? Application.android.startActivity)
166
+ attach()
167
+ else Application.on(Application.launchEvent, attach)
168
+ return () => {
169
+ stopped = true
170
+ Application.off(Application.launchEvent, attach)
171
+ observer?.detach()
172
+ observer = undefined
173
+ }
174
+ }
175
+
176
+ function sampled(curve: ArrayLike<number>): EasingFunction {
177
+ const values = Array.from({ length: curve.length }, (_, i) => curve[i]!)
178
+ const last = values.length - 1
179
+ if (last < 1) return (progress) => progress
180
+ return (progress) => {
181
+ const position = Math.min(Math.max(progress, 0), 1) * last
182
+ const index = Math.min(Math.floor(position), last - 1)
183
+ return values[index]! + (values[index + 1]! - values[index]!) * (position - index)
184
+ }
185
+ }
11
186
 
12
187
  /**
13
188
  * Lifts the view by its overlap with the software keyboard, at the keyboard's
@@ -55,12 +230,9 @@ function followIOS(view: View, offset: number) {
55
230
  const apply = () => {
56
231
  view.translateY = overlap ? -overlap : 0
57
232
  }
58
- const duration = info.objectForKey(UIKeyboardAnimationDurationUserInfoKey)
59
- ?.doubleValue as number | undefined
233
+ const duration = numberIn(info, UIKeyboardAnimationDurationUserInfoKey)
60
234
  if (!duration) return apply()
61
- const curve =
62
- (info.objectForKey(UIKeyboardAnimationCurveUserInfoKey)?.integerValue as
63
- number | undefined) ?? 0
235
+ const curve = numberIn(info, UIKeyboardAnimationCurveUserInfoKey)
64
236
  // The keyboard's curve is private; shifted into the options it still applies.
65
237
  UIView.animateWithDurationDelayOptionsAnimationsCompletion(
66
238
  duration,
@@ -89,7 +261,7 @@ function followIOS(view: View, offset: number) {
89
261
  }
90
262
 
91
263
  function followAndroid(view: View, offset: number) {
92
- if (android.os.Build.VERSION.SDK_INT < 30) return () => {}
264
+ if (legacy()) return followLegacy(view, offset)
93
265
  const density = Utils.layout.getDisplayDensity()
94
266
  let disposed = false
95
267
  let follower: org.rafaelaugusto.jolt.KeyboardFollower | undefined
@@ -130,3 +302,55 @@ function followAndroid(view: View, offset: number) {
130
302
  if (view.isLoaded) attach()
131
303
  return cleanup
132
304
  }
305
+
306
+ /** Android 7 to 10: no frame-by-frame progress, so the view animates with the keyboard's usual timing. */
307
+ function followLegacy(view: View, offset: number) {
308
+ const density = Utils.layout.getDisplayDensity()
309
+ let disposed = false
310
+ let follower: org.rafaelaugusto.jolt.KeyboardFrameFollower | undefined
311
+ const attach = () => {
312
+ if (disposed || follower) return
313
+ const native = view.nativeViewProtected as android.view.View | undefined
314
+ if (!native) return
315
+ try {
316
+ follower = new org.rafaelaugusto.jolt.KeyboardFrameFollower(
317
+ native,
318
+ offset * density,
319
+ new org.rafaelaugusto.jolt.KeyboardFrameFollower.Listener({
320
+ onMove: (from, to, keyboard) => {
321
+ stop(view, ['y'])
322
+ view.translateY = from / density
323
+ animate(view, { y: to / density }, keyboard ? legacyShow : legacyHide)
324
+ },
325
+ }),
326
+ )
327
+ } catch {
328
+ // A JS-only update cannot install the native plugin. Leave the platform's resize in place.
329
+ return
330
+ }
331
+ follower.attach()
332
+ }
333
+ const cleanup = () => {
334
+ if (disposed) return
335
+ disposed = true
336
+ view.off('loaded', attach)
337
+ view.off('unloaded', cleanup)
338
+ if (follower) {
339
+ follower.detach()
340
+ follower = undefined
341
+ stop(view, ['y'])
342
+ view.translateY = 0
343
+ }
344
+ }
345
+ view.on('loaded', attach)
346
+ view.on('unloaded', cleanup)
347
+ if (view.isLoaded) attach()
348
+ return cleanup
349
+ }
350
+
351
+ /** The runtime hands NSNumber values over as plain numbers. */
352
+ function numberIn(info: NSDictionary<unknown, unknown>, key: string): number {
353
+ const value = info.objectForKey(key) as number | NSNumber | null | undefined
354
+ if (typeof value === 'number') return value
355
+ return value?.doubleValue ?? 0
356
+ }
package/src/layout.ts ADDED
@@ -0,0 +1,408 @@
1
+ import { Application, type View } from '@nativescript/core'
2
+ import { prepareAnimation, toView } from './animate.js'
3
+ import { getDriver, type LayoutFrame } from './driver/index.js'
4
+ import {
5
+ captureValue,
6
+ propertyRevision,
7
+ arrivalOf,
8
+ setArrival,
9
+ type Animation,
10
+ } from './engine.js'
11
+ import { interactionSurface } from './interaction-surface.js'
12
+ import { readValue, writeValue, type NumericProperty } from './properties.js'
13
+ import { springs, type Spring, type Tween, type SpringName } from './transition.js'
14
+ import type { Keyframes, Target } from './types.js'
15
+
16
+ export type LayoutOptions = (
17
+ Omit<Spring, 'repeat' | 'repeatType'> | Omit<Tween, 'repeat' | 'repeatType'>
18
+ ) & {
19
+ /** Scale from the previous size (including content); false snaps size and only moves. Default: 'scale'. */
20
+ size?: 'scale' | false
21
+ /** Fade new children from zero to their configured opacity. Default: true. */
22
+ enter?: boolean
23
+ }
24
+
25
+ type Geometry = 'x' | 'y' | 'scaleX' | 'scaleY'
26
+ interface Snapshot {
27
+ frame: LayoutFrame
28
+ originX: number
29
+ originY: number
30
+ rotate: number
31
+ rotateX: number
32
+ rotateY: number
33
+ values: Record<Geometry, () => number | undefined>
34
+ }
35
+ interface Owned {
36
+ view: View
37
+ handle: Animation
38
+ detach(): void
39
+ targets: { property: NumericProperty; value: number; token: symbol | undefined }[]
40
+ }
41
+ const pending = new WeakMap<View, Animation>()
42
+ const playing = new WeakMap<View, Set<Animation>>()
43
+ const properties = ['x', 'y', 'scaleX', 'scaleY'] as const
44
+
45
+ /** Animate the next layout of a container's direct children. Call before a synchronous mutation. */
46
+ export function animateLayout(
47
+ container: Target,
48
+ options?: LayoutOptions | SpringName,
49
+ ): Animation
50
+ export function animateLayout(
51
+ container: Target,
52
+ change: () => void,
53
+ options?: LayoutOptions | SpringName,
54
+ ): Animation
55
+ export function animateLayout(
56
+ container: Target,
57
+ changeOrOptions?: (() => void) | LayoutOptions | SpringName,
58
+ options?: LayoutOptions | SpringName,
59
+ ): Animation {
60
+ const host = toView(container)
61
+ const change = typeof changeOrOptions === 'function' ? changeOrOptions : undefined
62
+ const input = change ? options : changeOrOptions
63
+ const {
64
+ size = 'scale',
65
+ enter = true,
66
+ ...transition
67
+ } = normalize(input as LayoutOptions | SpringName | undefined)
68
+ // Validate the complete transition before changing children or cancelling an earlier request.
69
+ prepareAnimation(
70
+ host,
71
+ { x: [0, 1], y: [0, 1], scaleX: [1, 2], scaleY: [1, 2], opacity: [0, 1] },
72
+ transition,
73
+ )
74
+ const driver = getDriver()
75
+ const before = new Map<View, Snapshot>()
76
+ const ready = laidOut(host)
77
+ if (ready)
78
+ for (const child of childrenOf(host)) {
79
+ const frame = frameOf(child)
80
+ if (frame)
81
+ before.set(child, {
82
+ frame,
83
+ originX: child.originX,
84
+ originY: child.originY,
85
+ rotate: child.rotate,
86
+ rotateX: child.rotateX,
87
+ rotateY: child.rotateY,
88
+ values: {
89
+ x: captureValue(child, 'x'),
90
+ y: captureValue(child, 'y'),
91
+ scaleX: captureValue(child, 'scaleX'),
92
+ scaleY: captureValue(child, 'scaleY'),
93
+ },
94
+ })
95
+ }
96
+
97
+ let resolve!: (finished: boolean) => void
98
+ let reject!: (error: unknown) => void
99
+ const finished = new Promise<boolean>((done, fail) => {
100
+ resolve = done
101
+ reject = fail
102
+ })
103
+ let arrive!: () => void
104
+ const arrival = new Promise<void>((done) => (arrive = done))
105
+ const owned: Owned[] = []
106
+ let settled = false
107
+ let detach: (() => void) | undefined
108
+ const cleanup = () => {
109
+ detach?.()
110
+ detach = undefined
111
+ host.off('unloaded', stop)
112
+ Application.off(Application.suspendEvent, stop)
113
+ if (pending.get(host) === handle) pending.delete(host)
114
+ const active = playing.get(host)
115
+ active?.delete(handle)
116
+ if (!active?.size) playing.delete(host)
117
+ before.clear()
118
+ owned.forEach((child) => child.detach())
119
+ arrive()
120
+ }
121
+ const complete = (result: boolean, error?: unknown) => {
122
+ if (settled) return
123
+ settled = true
124
+ cleanup()
125
+ if (error !== undefined) reject(error)
126
+ else resolve(result)
127
+ }
128
+ // A cancelled FLIP settles into the real layout rather than leaving a temporary inverse offset.
129
+ // The engine marker protects any animation that took ownership after this operation.
130
+ const restoreOne = ({ view, handle: child, targets }: Owned) => {
131
+ const current = targets.filter(
132
+ (target) => propertyRevision(view, target.property) === target.token,
133
+ )
134
+ child.stop()
135
+ for (const target of current)
136
+ if (propertyRevision(view, target.property) === target.token)
137
+ writeValue(view, target.property, target.value)
138
+ if (current.length) driver.sync?.(view)
139
+ }
140
+ const restore = () => {
141
+ owned.forEach(restoreOne)
142
+ }
143
+ function stop() {
144
+ if (settled) return
145
+ restore()
146
+ complete(false)
147
+ }
148
+ const handle: Animation = {
149
+ finished,
150
+ stop,
151
+ then: (onfulfilled, onrejected) => finished.then(onfulfilled, onrejected),
152
+ }
153
+ setArrival(handle, arrival)
154
+ const run = () => {
155
+ if (settled) return
156
+ detach?.()
157
+ detach = undefined
158
+ if (!laidOut(host)) {
159
+ stop()
160
+ return
161
+ }
162
+ if (pending.get(host) === handle) pending.delete(host)
163
+ const previous = [...(playing.get(host) ?? [])]
164
+ try {
165
+ const prepared: { view: View; frames: Keyframes; start: () => Animation }[] = []
166
+ for (const child of childrenOf(host)) {
167
+ const now = frameOf(child)
168
+ if (!now) continue
169
+ const was = before.get(child)
170
+ const frames = was
171
+ ? inverse(child, was, now, size)
172
+ : enter
173
+ ? { opacity: [0, child.opacity] }
174
+ : undefined
175
+ if (frames && Object.keys(frames).length)
176
+ prepared.push({
177
+ view: child,
178
+ frames,
179
+ start: prepareAnimation(child, frames, transition),
180
+ })
181
+ }
182
+ before.clear()
183
+ // Selection lasts only for starting these tracks; their native geometry driver stays until completion.
184
+ for (const { view, frames, start } of prepared) {
185
+ const surface = interactionSurface(view)
186
+ try {
187
+ const child = start()
188
+ const targets = Object.entries(frames).map(([property, frames]) => ({
189
+ property: property as NumericProperty,
190
+ value: (frames as number[]).at(-1)!,
191
+ token: propertyRevision(view, property as NumericProperty),
192
+ }))
193
+ const item: Owned = {
194
+ view,
195
+ handle: child,
196
+ targets,
197
+ detach: () => view.off('unloaded', unloaded),
198
+ }
199
+ const unloaded = () => {
200
+ item.detach()
201
+ if (!settled) restoreOne(item)
202
+ }
203
+ // Keyed reorder may unload/reinsert the same native view. Do not persist its FLIP offset.
204
+ view.on('unloaded', unloaded)
205
+ owned.push(item)
206
+ } finally {
207
+ surface.dispose()
208
+ }
209
+ }
210
+ const active = playing.get(host) ?? new Set<Animation>()
211
+ active.add(handle)
212
+ playing.set(host, active)
213
+ // Replacements start before old handles stop so the engine can transfer velocity.
214
+ for (const old of previous) old.stop()
215
+ void Promise.all(owned.map(({ handle }) => arrivalOf(handle))).then(arrive)
216
+ void Promise.all(owned.map(({ handle }) => handle.finished)).then(
217
+ (results) => complete(results.every(Boolean)),
218
+ (error) => {
219
+ restore()
220
+ complete(false, error)
221
+ },
222
+ )
223
+ } catch (error) {
224
+ restore()
225
+ complete(false, error)
226
+ }
227
+ }
228
+
229
+ pending.get(host)?.stop()
230
+ pending.set(host, handle)
231
+ host.on('unloaded', stop)
232
+ Application.on(Application.suspendEvent, stop)
233
+ try {
234
+ const result = change?.() as unknown
235
+ if (result && typeof (result as PromiseLike<unknown>).then === 'function') {
236
+ void Promise.resolve(result).catch(() => {})
237
+ throw new TypeError(
238
+ 'Layout mutations must be synchronous. Call animateLayout after awaited work.',
239
+ )
240
+ }
241
+ if (!settled) {
242
+ if (!ready || !laidOut(host)) complete(true)
243
+ else {
244
+ if (!driver.afterLayout || !driver.layoutFrame)
245
+ throw new Error('The animation driver does not support layout changes.')
246
+ detach = driver.afterLayout(host, run)
247
+ // Always request a pass, including a no-op mutation: no arbitrary timer or hanging wait.
248
+ host.requestLayout()
249
+ }
250
+ }
251
+ } catch (error) {
252
+ stop()
253
+ throw error
254
+ }
255
+ return handle
256
+ }
257
+
258
+ function normalize(input: LayoutOptions | SpringName | undefined): LayoutOptions {
259
+ if (typeof input === 'string') {
260
+ if (!Object.hasOwn(springs, input))
261
+ throw new TypeError(`Unknown layout spring "${input}".`)
262
+ return normalize({ ...springs[input] })
263
+ }
264
+ if (input === undefined) return {}
265
+ if (!input || typeof input !== 'object' || Array.isArray(input))
266
+ throw new TypeError('Invalid layout options.')
267
+ const allowed = new Set([
268
+ 'type',
269
+ 'duration',
270
+ 'ease',
271
+ 'times',
272
+ 'stiffness',
273
+ 'damping',
274
+ 'mass',
275
+ 'bounce',
276
+ 'velocity',
277
+ 'delay',
278
+ 'size',
279
+ 'enter',
280
+ ])
281
+ for (const key of Object.keys(input))
282
+ if (!allowed.has(key)) throw new TypeError(`Unsupported layout option "${key}".`)
283
+ if (input.size !== undefined && input.size !== false && input.size !== 'scale')
284
+ throw new TypeError('Layout size must be "scale" or false.')
285
+ if (input.enter !== undefined && typeof input.enter !== 'boolean')
286
+ throw new TypeError('Layout enter must be boolean.')
287
+ if (input.type !== undefined && input.type !== 'spring' && input.type !== 'tween')
288
+ throw new TypeError('Layout type must be "spring" or "tween".')
289
+ const numbers = input as Record<string, unknown>
290
+ for (const key of [
291
+ 'duration',
292
+ 'delay',
293
+ 'stiffness',
294
+ 'damping',
295
+ 'mass',
296
+ 'bounce',
297
+ 'velocity',
298
+ ]) {
299
+ const value = numbers[key]
300
+ if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value)))
301
+ throw new RangeError(`Layout ${key} must be finite.`)
302
+ if (typeof value === 'number') {
303
+ if (['duration', 'delay', 'damping'].includes(key) && value < 0)
304
+ throw new RangeError(`Layout ${key} must be nonnegative.`)
305
+ if (['stiffness', 'mass'].includes(key) && value <= 0)
306
+ throw new RangeError(`Layout ${key} must be positive.`)
307
+ if (key === 'bounce' && (value < -1 || value > 1))
308
+ throw new RangeError('Layout bounce must be between -1 and 1.')
309
+ }
310
+ }
311
+ const physical = ['stiffness', 'damping', 'mass'].some(
312
+ (key) => numbers[key] !== undefined,
313
+ )
314
+ const spring =
315
+ input.type === 'spring' ||
316
+ (input.type !== 'tween' &&
317
+ ['bounce', 'velocity', 'stiffness', 'damping', 'mass'].some(
318
+ (key) => numbers[key] !== undefined,
319
+ ))
320
+ if (spring && !physical && input.duration === 0)
321
+ throw new RangeError(
322
+ 'A duration-based layout spring must have positive duration; use a zero-duration tween to settle immediately.',
323
+ )
324
+ const result = { ...input }
325
+ if ('ease' in result && Array.isArray(result.ease)) result.ease = [...result.ease]
326
+ if ('times' in result && result.times) result.times = [...result.times]
327
+ return result
328
+ }
329
+
330
+ function inverse(
331
+ view: View,
332
+ was: Snapshot,
333
+ now: LayoutFrame,
334
+ size: LayoutOptions['size'],
335
+ ): Keyframes | undefined {
336
+ // Origin/rotation changes require a different affine transform, not a translation/scale FLIP.
337
+ if (
338
+ view.originX !== was.originX ||
339
+ view.originY !== was.originY ||
340
+ view.rotate !== was.rotate ||
341
+ was.rotateX ||
342
+ was.rotateY ||
343
+ view.rotateX ||
344
+ view.rotateY
345
+ )
346
+ return undefined
347
+ const frames: Keyframes = {}
348
+ const width = was.frame.width - now.width,
349
+ height = was.frame.height - now.height
350
+ const resized = Math.abs(width) > 0.25 || Math.abs(height) > 0.25
351
+ for (const property of properties) {
352
+ const current = was.values[property]()
353
+ if (current === undefined) continue // A newer explicit animation owns this property.
354
+ let start: number
355
+ if (property === 'x')
356
+ start =
357
+ was.frame.x -
358
+ now.x +
359
+ current +
360
+ (size === 'scale' && resized ? width * was.originX : 0)
361
+ else if (property === 'y')
362
+ start =
363
+ was.frame.y -
364
+ now.y +
365
+ current +
366
+ (size === 'scale' && resized ? height * was.originY : 0)
367
+ else {
368
+ if (size !== 'scale') continue
369
+ start =
370
+ current *
371
+ (property === 'scaleX'
372
+ ? was.frame.width / now.width
373
+ : was.frame.height / now.height)
374
+ }
375
+ const end = readValue(view, property)
376
+ if (Math.abs(start - end) > (property.startsWith('scale') ? 0.0001 : 0.25))
377
+ frames[property] = [start, end]
378
+ }
379
+ return frames
380
+ }
381
+ function laidOut(view: View): boolean {
382
+ if (!view.isLoaded || !view.nativeViewProtected) return false
383
+ for (
384
+ let current: View | undefined = view;
385
+ current;
386
+ current = current.parent as View | undefined
387
+ )
388
+ if (current.isCollapsed) return false
389
+ return true
390
+ }
391
+ function frameOf(view: View): LayoutFrame | undefined {
392
+ if (!laidOut(view)) return undefined
393
+ const frame = getDriver().layoutFrame?.(view)
394
+ return frame &&
395
+ Object.values(frame).every(Number.isFinite) &&
396
+ frame.width > 0 &&
397
+ frame.height > 0
398
+ ? frame
399
+ : undefined
400
+ }
401
+ function childrenOf(host: View): View[] {
402
+ const children: View[] = []
403
+ host.eachChildView((child) => {
404
+ children.push(child)
405
+ return true
406
+ })
407
+ return children
408
+ }