@rafaelaugusto/jolt 0.1.0-beta.9 → 0.1.0-rc.2

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 (576) hide show
  1. package/README.md +167 -21
  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 +27 -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 +4 -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-scroll-delegate.d.ts +4 -0
  67. package/dist/driver/ios-scroll-delegate.d.ts.map +1 -0
  68. package/dist/driver/ios-scroll-delegate.js +26 -0
  69. package/dist/driver/ios-scroll-delegate.js.map +1 -0
  70. package/dist/driver/ios.d.ts.map +1 -1
  71. package/dist/driver/ios.js +9 -0
  72. package/dist/driver/ios.js.map +1 -1
  73. package/dist/easing.d.ts +3 -1
  74. package/dist/easing.d.ts.map +1 -1
  75. package/dist/easing.js +18 -1
  76. package/dist/easing.js.map +1 -1
  77. package/dist/engine.d.ts +31 -2
  78. package/dist/engine.d.ts.map +1 -1
  79. package/dist/engine.js +194 -42
  80. package/dist/engine.js.map +1 -1
  81. package/dist/gesture-native.d.ts +28 -0
  82. package/dist/gesture-native.d.ts.map +1 -0
  83. package/dist/gesture-native.js +61 -0
  84. package/dist/gesture-native.js.map +1 -0
  85. package/dist/gestures/index.d.ts +69 -0
  86. package/dist/gestures/index.d.ts.map +1 -0
  87. package/dist/gestures/index.js +262 -0
  88. package/dist/gestures/index.js.map +1 -0
  89. package/dist/glass/index.d.ts +55 -0
  90. package/dist/glass/index.d.ts.map +1 -0
  91. package/dist/glass/index.js +205 -0
  92. package/dist/glass/index.js.map +1 -0
  93. package/dist/gradient-binding.d.ts +38 -0
  94. package/dist/gradient-binding.d.ts.map +1 -0
  95. package/dist/gradient-binding.js +128 -0
  96. package/dist/gradient-binding.js.map +1 -0
  97. package/dist/gradient.d.ts +105 -0
  98. package/dist/gradient.d.ts.map +1 -0
  99. package/dist/gradient.js +514 -0
  100. package/dist/gradient.js.map +1 -0
  101. package/dist/gravity.d.ts +13 -0
  102. package/dist/gravity.d.ts.map +1 -0
  103. package/dist/gravity.js +84 -0
  104. package/dist/gravity.js.map +1 -0
  105. package/dist/haptics.d.ts.map +1 -1
  106. package/dist/haptics.js +101 -28
  107. package/dist/haptics.js.map +1 -1
  108. package/dist/image-effect.d.ts +1 -0
  109. package/dist/image-effect.d.ts.map +1 -1
  110. package/dist/image-effect.js +10 -2
  111. package/dist/image-effect.js.map +1 -1
  112. package/dist/index.d.ts +19 -7
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +10 -4
  115. package/dist/index.js.map +1 -1
  116. package/dist/inspector/index.d.ts +86 -0
  117. package/dist/inspector/index.d.ts.map +1 -0
  118. package/dist/inspector/index.js +419 -0
  119. package/dist/inspector/index.js.map +1 -0
  120. package/dist/inspector/plot.d.ts +4 -0
  121. package/dist/inspector/plot.d.ts.map +1 -0
  122. package/dist/inspector/plot.js +23 -0
  123. package/dist/inspector/plot.js.map +1 -0
  124. package/dist/inspector/probe.d.ts +19 -0
  125. package/dist/inspector/probe.d.ts.map +1 -0
  126. package/dist/inspector/probe.js +37 -0
  127. package/dist/inspector/probe.js.map +1 -0
  128. package/dist/inspector/tuning.d.ts +19 -0
  129. package/dist/inspector/tuning.d.ts.map +1 -0
  130. package/dist/inspector/tuning.js +37 -0
  131. package/dist/inspector/tuning.js.map +1 -0
  132. package/dist/interactive-navigation/index.d.ts +44 -0
  133. package/dist/interactive-navigation/index.d.ts.map +1 -0
  134. package/dist/interactive-navigation/index.js +350 -0
  135. package/dist/interactive-navigation/index.js.map +1 -0
  136. package/dist/keyboard.d.ts +24 -0
  137. package/dist/keyboard.d.ts.map +1 -1
  138. package/dist/keyboard.js +199 -6
  139. package/dist/keyboard.js.map +1 -1
  140. package/dist/live-spring-driver.d.ts +52 -0
  141. package/dist/live-spring-driver.d.ts.map +1 -0
  142. package/dist/live-spring-driver.js +104 -0
  143. package/dist/live-spring-driver.js.map +1 -0
  144. package/dist/mixer.d.ts +55 -0
  145. package/dist/mixer.d.ts.map +1 -0
  146. package/dist/mixer.js +286 -0
  147. package/dist/mixer.js.map +1 -0
  148. package/dist/motion-scope.d.ts +8 -2
  149. package/dist/motion-scope.d.ts.map +1 -1
  150. package/dist/motion-scope.js +24 -3
  151. package/dist/motion-scope.js.map +1 -1
  152. package/dist/motion-states.d.ts +19 -7
  153. package/dist/motion-states.d.ts.map +1 -1
  154. package/dist/motion-states.js +116 -26
  155. package/dist/motion-states.js.map +1 -1
  156. package/dist/motion-value.d.ts +227 -0
  157. package/dist/motion-value.d.ts.map +1 -0
  158. package/dist/motion-value.js +1074 -0
  159. package/dist/motion-value.js.map +1 -0
  160. package/dist/native/index.d.ts +10 -0
  161. package/dist/native/index.d.ts.map +1 -0
  162. package/dist/native/index.js +6 -0
  163. package/dist/native/index.js.map +1 -0
  164. package/dist/native-properties.d.ts +28 -0
  165. package/dist/native-properties.d.ts.map +1 -0
  166. package/dist/native-properties.js +154 -0
  167. package/dist/native-properties.js.map +1 -0
  168. package/dist/native-property-driver.d.ts +19 -0
  169. package/dist/native-property-driver.d.ts.map +1 -0
  170. package/dist/native-property-driver.js +69 -0
  171. package/dist/native-property-driver.js.map +1 -0
  172. package/dist/native-property.d.ts +37 -0
  173. package/dist/native-property.d.ts.map +1 -0
  174. package/dist/native-property.js +285 -0
  175. package/dist/native-property.js.map +1 -0
  176. package/dist/particles.d.ts +5 -2
  177. package/dist/particles.d.ts.map +1 -1
  178. package/dist/particles.js +16 -10
  179. package/dist/particles.js.map +1 -1
  180. package/dist/path.d.ts.map +1 -1
  181. package/dist/path.js +2 -2
  182. package/dist/path.js.map +1 -1
  183. package/dist/physics/index.d.ts +139 -0
  184. package/dist/physics/index.d.ts.map +1 -0
  185. package/dist/physics/index.js +316 -0
  186. package/dist/physics/index.js.map +1 -0
  187. package/dist/physics/native.d.ts +54 -0
  188. package/dist/physics/native.d.ts.map +1 -0
  189. package/dist/physics/native.js +64 -0
  190. package/dist/physics/native.js.map +1 -0
  191. package/dist/playback-group.d.ts.map +1 -1
  192. package/dist/playback-group.js +17 -1
  193. package/dist/playback-group.js.map +1 -1
  194. package/dist/playback.d.ts +15 -0
  195. package/dist/playback.d.ts.map +1 -1
  196. package/dist/playback.js +23 -0
  197. package/dist/playback.js.map +1 -1
  198. package/dist/predictive-back/index.d.ts +45 -0
  199. package/dist/predictive-back/index.d.ts.map +1 -0
  200. package/dist/predictive-back/index.js +220 -0
  201. package/dist/predictive-back/index.js.map +1 -0
  202. package/dist/predictive-back/presentation.d.ts +4 -0
  203. package/dist/predictive-back/presentation.d.ts.map +1 -0
  204. package/dist/predictive-back/presentation.js +3 -0
  205. package/dist/predictive-back/presentation.js.map +1 -0
  206. package/dist/press.d.ts.map +1 -1
  207. package/dist/press.js +11 -2
  208. package/dist/press.js.map +1 -1
  209. package/dist/reorder/handle.d.ts +6 -0
  210. package/dist/reorder/handle.d.ts.map +1 -0
  211. package/dist/reorder/handle.js +10 -0
  212. package/dist/reorder/handle.js.map +1 -0
  213. package/dist/reorder/index.d.ts +10 -0
  214. package/dist/reorder/index.d.ts.map +1 -0
  215. package/dist/reorder/index.js +233 -0
  216. package/dist/reorder/index.js.map +1 -0
  217. package/dist/reorder/list-view.d.ts +5 -0
  218. package/dist/reorder/list-view.d.ts.map +1 -0
  219. package/dist/reorder/list-view.js +238 -0
  220. package/dist/reorder/list-view.js.map +1 -0
  221. package/dist/reorder/model.d.ts +6 -0
  222. package/dist/reorder/model.d.ts.map +1 -0
  223. package/dist/reorder/model.js +30 -0
  224. package/dist/reorder/model.js.map +1 -0
  225. package/dist/reorder/surface.d.ts +6 -0
  226. package/dist/reorder/surface.d.ts.map +1 -0
  227. package/dist/reorder/surface.js +10 -0
  228. package/dist/reorder/surface.js.map +1 -0
  229. package/dist/reorder/types.d.ts +92 -0
  230. package/dist/reorder/types.d.ts.map +1 -0
  231. package/dist/reorder/types.js +2 -0
  232. package/dist/reorder/types.js.map +1 -0
  233. package/dist/sampling.d.ts +35 -0
  234. package/dist/sampling.d.ts.map +1 -0
  235. package/dist/sampling.js +123 -0
  236. package/dist/sampling.js.map +1 -0
  237. package/dist/scene-appearance.d.ts +14 -0
  238. package/dist/scene-appearance.d.ts.map +1 -0
  239. package/dist/scene-appearance.js +68 -0
  240. package/dist/scene-appearance.js.map +1 -0
  241. package/dist/scene-camera.d.ts +5 -0
  242. package/dist/scene-camera.d.ts.map +1 -0
  243. package/dist/scene-camera.js +23 -0
  244. package/dist/scene-camera.js.map +1 -0
  245. package/dist/scene-shader.d.ts +18 -0
  246. package/dist/scene-shader.d.ts.map +1 -0
  247. package/dist/scene-shader.js +76 -0
  248. package/dist/scene-shader.js.map +1 -0
  249. package/dist/scroll-header/geometry.d.ts +18 -0
  250. package/dist/scroll-header/geometry.d.ts.map +1 -0
  251. package/dist/scroll-header/geometry.js +46 -0
  252. package/dist/scroll-header/geometry.js.map +1 -0
  253. package/dist/scroll-header/index.d.ts +48 -0
  254. package/dist/scroll-header/index.d.ts.map +1 -0
  255. package/dist/scroll-header/index.js +399 -0
  256. package/dist/scroll-header/index.js.map +1 -0
  257. package/dist/scroll-header/native.d.ts +28 -0
  258. package/dist/scroll-header/native.d.ts.map +1 -0
  259. package/dist/scroll-header/native.js +43 -0
  260. package/dist/scroll-header/native.js.map +1 -0
  261. package/dist/sensors/index.d.ts +69 -0
  262. package/dist/sensors/index.d.ts.map +1 -0
  263. package/dist/sensors/index.js +149 -0
  264. package/dist/sensors/index.js.map +1 -0
  265. package/dist/sensors/native.d.ts +20 -0
  266. package/dist/sensors/native.d.ts.map +1 -0
  267. package/dist/sensors/native.js +48 -0
  268. package/dist/sensors/native.js.map +1 -0
  269. package/dist/sequence.d.ts +24 -0
  270. package/dist/sequence.d.ts.map +1 -1
  271. package/dist/sequence.js +181 -19
  272. package/dist/sequence.js.map +1 -1
  273. package/dist/shapes/android.d.ts +3 -0
  274. package/dist/shapes/android.d.ts.map +1 -0
  275. package/dist/shapes/android.js +51 -0
  276. package/dist/shapes/android.js.map +1 -0
  277. package/dist/shapes/index.d.ts +6 -0
  278. package/dist/shapes/index.d.ts.map +1 -0
  279. package/dist/shapes/index.js +238 -0
  280. package/dist/shapes/index.js.map +1 -0
  281. package/dist/shapes/ios.d.ts +3 -0
  282. package/dist/shapes/ios.d.ts.map +1 -0
  283. package/dist/shapes/ios.js +164 -0
  284. package/dist/shapes/ios.js.map +1 -0
  285. package/dist/shapes/native.d.ts +18 -0
  286. package/dist/shapes/native.d.ts.map +1 -0
  287. package/dist/shapes/native.js +10 -0
  288. package/dist/shapes/native.js.map +1 -0
  289. package/dist/shapes/path.d.ts +10 -0
  290. package/dist/shapes/path.d.ts.map +1 -0
  291. package/dist/shapes/path.js +106 -0
  292. package/dist/shapes/path.js.map +1 -0
  293. package/dist/shapes/types.d.ts +55 -0
  294. package/dist/shapes/types.d.ts.map +1 -0
  295. package/dist/shapes/types.js +11 -0
  296. package/dist/shapes/types.js.map +1 -0
  297. package/dist/shared-layout/index.d.ts +40 -0
  298. package/dist/shared-layout/index.d.ts.map +1 -0
  299. package/dist/shared-layout/index.js +267 -0
  300. package/dist/shared-layout/index.js.map +1 -0
  301. package/dist/shared-layout/native.d.ts +15 -0
  302. package/dist/shared-layout/native.d.ts.map +1 -0
  303. package/dist/shared-layout/native.js +79 -0
  304. package/dist/shared-layout/native.js.map +1 -0
  305. package/dist/shared-layout/timing.d.ts +9 -0
  306. package/dist/shared-layout/timing.d.ts.map +1 -0
  307. package/dist/shared-layout/timing.js +68 -0
  308. package/dist/shared-layout/timing.js.map +1 -0
  309. package/dist/shared-navigation/entry.d.ts +51 -0
  310. package/dist/shared-navigation/entry.d.ts.map +1 -0
  311. package/dist/shared-navigation/entry.js +619 -0
  312. package/dist/shared-navigation/entry.js.map +1 -0
  313. package/dist/shared-navigation/index.d.ts +58 -0
  314. package/dist/shared-navigation/index.d.ts.map +1 -0
  315. package/dist/shared-navigation/index.js +318 -0
  316. package/dist/shared-navigation/index.js.map +1 -0
  317. package/dist/shared-navigation/return-signal.d.ts +16 -0
  318. package/dist/shared-navigation/return-signal.d.ts.map +1 -0
  319. package/dist/shared-navigation/return-signal.js +35 -0
  320. package/dist/shared-navigation/return-signal.js.map +1 -0
  321. package/dist/shared-navigation/return-target.d.ts +32 -0
  322. package/dist/shared-navigation/return-target.d.ts.map +1 -0
  323. package/dist/shared-navigation/return-target.js +168 -0
  324. package/dist/shared-navigation/return-target.js.map +1 -0
  325. package/dist/shared-navigation/scope.d.ts +4 -0
  326. package/dist/shared-navigation/scope.d.ts.map +1 -0
  327. package/dist/shared-navigation/scope.js +2 -0
  328. package/dist/shared-navigation/scope.js.map +1 -0
  329. package/dist/shared-navigation/targets.d.ts +6 -0
  330. package/dist/shared-navigation/targets.d.ts.map +1 -0
  331. package/dist/shared-navigation/targets.js +36 -0
  332. package/dist/shared-navigation/targets.js.map +1 -0
  333. package/dist/size-layout.d.ts +19 -0
  334. package/dist/size-layout.d.ts.map +1 -0
  335. package/dist/size-layout.js +216 -0
  336. package/dist/size-layout.js.map +1 -0
  337. package/dist/size.d.ts +19 -0
  338. package/dist/size.d.ts.map +1 -0
  339. package/dist/size.js +251 -0
  340. package/dist/size.js.map +1 -0
  341. package/dist/spring.d.ts +2 -0
  342. package/dist/spring.d.ts.map +1 -1
  343. package/dist/spring.js +11 -0
  344. package/dist/spring.js.map +1 -1
  345. package/dist/svg-path.d.ts +18 -0
  346. package/dist/svg-path.d.ts.map +1 -1
  347. package/dist/svg-path.js +3 -2
  348. package/dist/svg-path.js.map +1 -1
  349. package/dist/testing/clock.d.ts +40 -0
  350. package/dist/testing/clock.d.ts.map +1 -0
  351. package/dist/testing/clock.js +116 -0
  352. package/dist/testing/clock.js.map +1 -0
  353. package/dist/testing/handoff-recorder.d.ts +8 -0
  354. package/dist/testing/handoff-recorder.d.ts.map +1 -0
  355. package/dist/testing/handoff-recorder.js +77 -0
  356. package/dist/testing/handoff-recorder.js.map +1 -0
  357. package/dist/testing/index.d.ts +5 -0
  358. package/dist/testing/index.d.ts.map +1 -0
  359. package/dist/testing/index.js +5 -0
  360. package/dist/testing/index.js.map +1 -0
  361. package/dist/testing/native.d.ts +46 -0
  362. package/dist/testing/native.d.ts.map +1 -0
  363. package/dist/testing/native.js +313 -0
  364. package/dist/testing/native.js.map +1 -0
  365. package/dist/testing/presentation.d.ts +11 -0
  366. package/dist/testing/presentation.d.ts.map +1 -0
  367. package/dist/testing/presentation.js +45 -0
  368. package/dist/testing/presentation.js.map +1 -0
  369. package/dist/testing/replay.d.ts +39 -0
  370. package/dist/testing/replay.d.ts.map +1 -0
  371. package/dist/testing/replay.js +99 -0
  372. package/dist/testing/replay.js.map +1 -0
  373. package/dist/testing/scroll-handoff-native.d.ts +10 -0
  374. package/dist/testing/scroll-handoff-native.d.ts.map +1 -0
  375. package/dist/testing/scroll-handoff-native.js +151 -0
  376. package/dist/testing/scroll-handoff-native.js.map +1 -0
  377. package/dist/testing/scroll-handoff.d.ts +25 -0
  378. package/dist/testing/scroll-handoff.d.ts.map +1 -0
  379. package/dist/testing/scroll-handoff.js +127 -0
  380. package/dist/testing/scroll-handoff.js.map +1 -0
  381. package/dist/testing/sensors.d.ts +13 -0
  382. package/dist/testing/sensors.d.ts.map +1 -0
  383. package/dist/testing/sensors.js +26 -0
  384. package/dist/testing/sensors.js.map +1 -0
  385. package/dist/testing/trace.d.ts +101 -0
  386. package/dist/testing/trace.d.ts.map +1 -0
  387. package/dist/testing/trace.js +263 -0
  388. package/dist/testing/trace.js.map +1 -0
  389. package/dist/timed-animation.d.ts +38 -0
  390. package/dist/timed-animation.d.ts.map +1 -0
  391. package/dist/timed-animation.js +177 -0
  392. package/dist/timed-animation.js.map +1 -0
  393. package/dist/track.d.ts +3 -0
  394. package/dist/track.d.ts.map +1 -1
  395. package/dist/track.js +281 -40
  396. package/dist/track.js.map +1 -1
  397. package/dist/transition.d.ts +54 -2
  398. package/dist/transition.d.ts.map +1 -1
  399. package/dist/transition.js +128 -8
  400. package/dist/transition.js.map +1 -1
  401. package/dist/types.d.ts +10 -1
  402. package/dist/types.d.ts.map +1 -1
  403. package/dist/value-observers.d.ts +22 -0
  404. package/dist/value-observers.d.ts.map +1 -0
  405. package/dist/value-observers.js +122 -0
  406. package/dist/value-observers.js.map +1 -0
  407. package/dist/value-track.d.ts +13 -0
  408. package/dist/value-track.d.ts.map +1 -0
  409. package/dist/value-track.js +59 -0
  410. package/dist/value-track.js.map +1 -0
  411. package/dist/vue/index.d.ts +33 -3
  412. package/dist/vue/index.d.ts.map +1 -1
  413. package/dist/vue/index.js +118 -3
  414. package/dist/vue/index.js.map +1 -1
  415. package/dist/zoomable.d.ts +1 -1
  416. package/dist/zoomable.d.ts.map +1 -1
  417. package/package.json +68 -3
  418. package/platforms/android/include.gradle +10 -0
  419. package/platforms/android/java/org/rafaelaugusto/jolt/BlurEffect.java +89 -0
  420. package/platforms/android/java/org/rafaelaugusto/jolt/CircleMath.java +158 -0
  421. package/platforms/android/java/org/rafaelaugusto/jolt/CircleWorld.java +221 -0
  422. package/platforms/android/java/org/rafaelaugusto/jolt/GestureSession.java +227 -0
  423. package/platforms/android/java/org/rafaelaugusto/jolt/GestureSurface.java +54 -0
  424. package/platforms/android/java/org/rafaelaugusto/jolt/GradientLayer.java +224 -0
  425. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrame.java +53 -0
  426. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrameFollower.java +57 -0
  427. package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardObserver.java +97 -0
  428. package/platforms/android/java/org/rafaelaugusto/jolt/LiveSpring.java +277 -0
  429. package/platforms/android/java/org/rafaelaugusto/jolt/MotionProbe.java +70 -0
  430. package/platforms/android/java/org/rafaelaugusto/jolt/ParticleEmitter.java +192 -0
  431. package/platforms/android/java/org/rafaelaugusto/jolt/ParticleSimulation.java +114 -0
  432. package/platforms/android/java/org/rafaelaugusto/jolt/PredictiveBackSession.java +212 -0
  433. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderHandle.java +25 -0
  434. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSession.java +213 -0
  435. package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSurface.java +27 -0
  436. package/platforms/android/java/org/rafaelaugusto/jolt/ScrollHeader.java +84 -0
  437. package/platforms/android/java/org/rafaelaugusto/jolt/SensorMath.java +28 -0
  438. package/platforms/android/java/org/rafaelaugusto/jolt/SensorSource.java +217 -0
  439. package/platforms/android/java/org/rafaelaugusto/jolt/ShapeLayer.java +120 -0
  440. package/platforms/android/java/org/rafaelaugusto/jolt/SharedLayoutFlight.java +287 -0
  441. package/platforms/android/java/org/rafaelaugusto/jolt/SharedNavigationScene.java +115 -0
  442. package/platforms/android/java/org/rafaelaugusto/jolt/SpringState.java +39 -0
  443. package/platforms/android/proguard-rules.pro +20 -0
  444. package/platforms/ios/build.xcconfig +1 -1
  445. package/platforms/ios/src/JoltBlur.h +14 -0
  446. package/platforms/ios/src/JoltBlur.m +86 -0
  447. package/platforms/ios/src/JoltCircleMath.h +191 -0
  448. package/platforms/ios/src/JoltCircleWorld.h +18 -0
  449. package/platforms/ios/src/JoltCircleWorld.m +218 -0
  450. package/platforms/ios/src/JoltGestureSession.h +23 -0
  451. package/platforms/ios/src/JoltGestureSession.m +251 -0
  452. package/platforms/ios/src/JoltInteractiveNavigation.h +23 -0
  453. package/platforms/ios/src/JoltInteractiveNavigation.m +255 -0
  454. package/platforms/ios/src/JoltLiveSpring.h +29 -0
  455. package/platforms/ios/src/JoltLiveSpring.m +243 -0
  456. package/platforms/ios/src/JoltMotionProbe.h +9 -0
  457. package/platforms/ios/src/JoltMotionProbe.m +72 -0
  458. package/platforms/ios/src/JoltReorderSession.h +15 -0
  459. package/platforms/ios/src/JoltReorderSession.m +205 -0
  460. package/platforms/ios/src/JoltScrollHeader.h +13 -0
  461. package/platforms/ios/src/JoltScrollHeader.m +101 -0
  462. package/platforms/ios/src/JoltSensorMath.h +39 -0
  463. package/platforms/ios/src/JoltSensorSource.h +13 -0
  464. package/platforms/ios/src/JoltSensorSource.m +201 -0
  465. package/platforms/ios/src/JoltSharedLayoutFlight.h +19 -0
  466. package/platforms/ios/src/JoltSharedLayoutFlight.m +250 -0
  467. package/platforms/ios/src/JoltSpringState.h +35 -0
  468. package/platforms/ios/src/module.modulemap +10 -0
  469. package/src/android-plugin.d.ts +464 -0
  470. package/src/animate.ts +129 -15
  471. package/src/blur/index.ts +195 -0
  472. package/src/blur/native.ts +70 -0
  473. package/src/blur/types.ts +32 -0
  474. package/src/bottom-sheet/geometry.ts +84 -0
  475. package/src/bottom-sheet/index.ts +536 -0
  476. package/src/bottom-sheet/native.ts +214 -0
  477. package/src/config.ts +39 -1
  478. package/src/decay.ts +9 -0
  479. package/src/drag.ts +67 -21
  480. package/src/driver/android-gradient.ts +116 -0
  481. package/src/driver/android-particles.ts +118 -0
  482. package/src/driver/android.ts +31 -1
  483. package/src/driver/frame.ts +10 -0
  484. package/src/driver/index.ts +4 -0
  485. package/src/driver/ios-gradient.ts +136 -0
  486. package/src/driver/ios-scroll-delegate.ts +23 -0
  487. package/src/driver/ios.ts +10 -0
  488. package/src/easing.ts +21 -1
  489. package/src/engine.ts +209 -60
  490. package/src/gesture-native.ts +139 -0
  491. package/src/gestures/index.ts +365 -0
  492. package/src/glass/index.ts +218 -0
  493. package/src/gradient-binding.ts +158 -0
  494. package/src/gradient.ts +663 -0
  495. package/src/gravity.ts +107 -0
  496. package/src/haptics.ts +106 -28
  497. package/src/image-effect.ts +10 -2
  498. package/src/index.ts +56 -7
  499. package/src/inspector/index.ts +523 -0
  500. package/src/inspector/plot.ts +27 -0
  501. package/src/inspector/probe.ts +50 -0
  502. package/src/inspector/tuning.ts +51 -0
  503. package/src/interactive-navigation/index.ts +427 -0
  504. package/src/ios-plugin.d.ts +280 -0
  505. package/src/keyboard.ts +231 -7
  506. package/src/live-spring-driver.ts +181 -0
  507. package/src/mixer.ts +312 -0
  508. package/src/motion-scope.ts +39 -6
  509. package/src/motion-states.ts +149 -42
  510. package/src/motion-value.ts +1289 -0
  511. package/src/native/index.ts +30 -0
  512. package/src/native-properties.ts +188 -0
  513. package/src/native-property-driver.ts +123 -0
  514. package/src/native-property.ts +366 -0
  515. package/src/particles.ts +18 -17
  516. package/src/path.ts +2 -1
  517. package/src/physics/index.ts +476 -0
  518. package/src/physics/native.ts +121 -0
  519. package/src/playback-group.ts +17 -1
  520. package/src/playback.ts +41 -0
  521. package/src/predictive-back/index.ts +280 -0
  522. package/src/predictive-back/presentation.ts +6 -0
  523. package/src/press.ts +10 -2
  524. package/src/reorder/handle.ts +9 -0
  525. package/src/reorder/index.ts +243 -0
  526. package/src/reorder/list-view.ts +262 -0
  527. package/src/reorder/model.ts +47 -0
  528. package/src/reorder/surface.ts +10 -0
  529. package/src/reorder/types.ts +87 -0
  530. package/src/sampling.ts +173 -0
  531. package/src/scene-appearance.ts +92 -0
  532. package/src/scene-camera.ts +30 -0
  533. package/src/scene-shader.ts +139 -0
  534. package/src/scroll-header/geometry.ts +88 -0
  535. package/src/scroll-header/index.ts +530 -0
  536. package/src/scroll-header/native.ts +89 -0
  537. package/src/sensors/index.ts +246 -0
  538. package/src/sensors/native.ts +72 -0
  539. package/src/sequence.ts +209 -20
  540. package/src/shapes/android.ts +63 -0
  541. package/src/shapes/index.ts +267 -0
  542. package/src/shapes/ios.ts +194 -0
  543. package/src/shapes/native.ts +27 -0
  544. package/src/shapes/path.ts +127 -0
  545. package/src/shapes/types.ts +63 -0
  546. package/src/shared-layout/index.ts +343 -0
  547. package/src/shared-layout/native.ts +138 -0
  548. package/src/shared-layout/timing.ts +87 -0
  549. package/src/shared-navigation/entry.ts +695 -0
  550. package/src/shared-navigation/index.ts +414 -0
  551. package/src/shared-navigation/return-signal.ts +41 -0
  552. package/src/shared-navigation/return-target.ts +197 -0
  553. package/src/shared-navigation/scope.ts +3 -0
  554. package/src/shared-navigation/targets.ts +38 -0
  555. package/src/size-layout.ts +237 -0
  556. package/src/size.ts +302 -0
  557. package/src/spring.ts +18 -0
  558. package/src/svg-path.ts +8 -3
  559. package/src/testing/clock.ts +128 -0
  560. package/src/testing/handoff-recorder.ts +98 -0
  561. package/src/testing/index.ts +4 -0
  562. package/src/testing/native.ts +386 -0
  563. package/src/testing/presentation.ts +46 -0
  564. package/src/testing/replay.ts +149 -0
  565. package/src/testing/scroll-handoff-native.ts +201 -0
  566. package/src/testing/scroll-handoff.ts +140 -0
  567. package/src/testing/sensors.ts +41 -0
  568. package/src/testing/trace.ts +340 -0
  569. package/src/timed-animation.ts +192 -0
  570. package/src/track.ts +334 -38
  571. package/src/transition.ts +197 -9
  572. package/src/types.ts +11 -1
  573. package/src/value-observers.ts +147 -0
  574. package/src/value-track.ts +71 -0
  575. package/src/vue/index.ts +147 -1
  576. package/src/zoomable.ts +1 -1
package/src/animate.ts CHANGED
@@ -17,16 +17,26 @@ import { DEFAULT_FRICTION, solveDecay } from './decay.js'
17
17
  import {
18
18
  arrivalOf,
19
19
  setArrival,
20
+ stopLayer,
20
21
  stopView,
21
22
  ViewAnimation,
22
23
  type Animation,
23
24
  type Plan,
24
25
  } from './engine.js'
25
26
  import { getPreset, type PresetName } from './presets.js'
27
+ import {
28
+ asRoot,
29
+ detachBindings,
30
+ isMotionValue,
31
+ type MotionValue,
32
+ type ValueAnimationOptions,
33
+ } from './motion-value.js'
26
34
  import { resolveHaptic, type Haptic } from './haptics.js'
35
+ import { layerable } from './mixer.js'
27
36
  import { isProperty, precision, type Property } from './properties.js'
28
37
  import {
29
38
  hasCurve,
39
+ fitTransition,
30
40
  mergeTransitions,
31
41
  resolveTransition,
32
42
  springs,
@@ -42,6 +52,7 @@ import type {
42
52
  KeyframeProperty,
43
53
  Stagger,
44
54
  Target,
55
+ Values,
45
56
  } from './types.js'
46
57
 
47
58
  interface Options {
@@ -50,24 +61,45 @@ interface Options {
50
61
  stagger: number | Stagger | undefined
51
62
  relative: boolean | undefined
52
63
  haptic: Haptic | undefined
64
+ layer?: string
53
65
  }
54
66
 
55
67
  /**
56
68
  * Animates one view, or several. Takes keyframes or the name of a preset,
57
- * and a transition or the name of a spring.
69
+ * and a transition or the name of a spring. A motion value animates to a number.
58
70
  *
59
71
  * ```ts
60
72
  * animate(card, 'fadeInUp')
61
73
  * animate(card, { scale: 1.1, rotate: [0, 90] }, 'bouncy')
62
74
  * animate(rows, 'fadeInUp', { stagger: 40 })
75
+ * animate(progress, 1, 'snappy')
63
76
  * ```
64
77
  */
78
+ export function animate(
79
+ value: MotionValue,
80
+ to: number | readonly (number | null)[],
81
+ transition?: ValueAnimationOptions | SpringName,
82
+ ): PlaybackAnimation
65
83
  export function animate(
66
84
  target: Target | readonly Target[],
67
85
  animation: Keyframes | PresetName,
68
86
  options?: AnimateOptions | SpringName,
69
- ): PlaybackAnimation {
70
- return prepareAnimation(target, animation, options)()
87
+ ): PlaybackAnimation
88
+ export function animate(
89
+ target: Target | readonly Target[] | MotionValue,
90
+ animation: Keyframes | PresetName | number | readonly (number | null)[],
91
+ options?: AnimateOptions | SpringName,
92
+ ): PlaybackAnimation | Animation {
93
+ if (isMotionValue(target))
94
+ return asRoot(target).animate(
95
+ animation as number | readonly (number | null)[],
96
+ options as ValueAnimationOptions | SpringName | undefined,
97
+ )
98
+ return prepareAnimation(
99
+ target as Target | readonly Target[],
100
+ animation as Keyframes | PresetName,
101
+ options,
102
+ )()
71
103
  }
72
104
 
73
105
  /** Validate and snapshot a complete animation before changing any view ownership. */
@@ -76,7 +108,7 @@ export function prepareAnimation(
76
108
  animation: Keyframes | PresetName,
77
109
  options?: AnimateOptions | SpringName,
78
110
  ): () => PlaybackAnimation {
79
- const { keyframes, base, overrides, stagger, relative, haptic, path } = prepare(
111
+ const { keyframes, base, overrides, stagger, relative, haptic, path, layer } = prepare(
80
112
  animation,
81
113
  options,
82
114
  )
@@ -87,8 +119,15 @@ export function prepareAnimation(
87
119
  for (const property of Object.keys(keyframes))
88
120
  if (isColorProperty(property)) validateColorTarget(view, property)
89
121
  else if (isDecorationProperty(property)) validateDecorationTarget(view, property)
90
- const plans = plan(keyframes, base, overrides, 0, relative, path)
91
- return () => new ViewAnimation(view, plans, feedback)
122
+ const plans = plan(keyframes, base, overrides, 0, relative, path, layer)
123
+ return () => {
124
+ if (layer === undefined)
125
+ detachBindings(
126
+ view,
127
+ plans.map(({ property }) => property),
128
+ )
129
+ return new ViewAnimation(view, plans, feedback)
130
+ }
92
131
  }
93
132
 
94
133
  const views = target.map(toView)
@@ -96,6 +135,7 @@ export function prepareAnimation(
96
135
  for (const property of Object.keys(keyframes))
97
136
  if (isColorProperty(property)) validateColorTarget(view, property)
98
137
  else if (isDecorationProperty(property)) validateDecorationTarget(view, property)
138
+ const seed = Math.random()
99
139
  const plans = views.map((_, index) =>
100
140
  plan(
101
141
  keyframes,
@@ -104,11 +144,20 @@ export function prepareAnimation(
104
144
  staggerDelay(stagger, index, views.length),
105
145
  relative,
106
146
  path,
147
+ layer,
148
+ seed,
107
149
  ),
108
150
  )
109
151
  return () =>
110
152
  playbackGroup(
111
- views.map((view, index) => new ViewAnimation(view, plans[index]!, feedback, true)),
153
+ views.map((view, index) => {
154
+ if (layer === undefined)
155
+ detachBindings(
156
+ view,
157
+ plans[index]!.map(({ property }) => property),
158
+ )
159
+ return new ViewAnimation(view, plans[index]!, feedback, true)
160
+ }),
112
161
  )
113
162
  }
114
163
 
@@ -185,15 +234,63 @@ export function decay(
185
234
  )
186
235
  }
187
236
 
188
- /** Stops all or selected properties at their current values. `scale` stops both axes. */
237
+ /**
238
+ * Stops all or selected properties at their current values. `scale` stops both axes.
239
+ * A motion value stops where it is, and so do the views bound to it.
240
+ */
241
+ export function stop(value: MotionValue, options?: { layer?: string }): void
189
242
  export function stop(
190
243
  target: Target | readonly Target[],
191
244
  properties?: readonly KeyframeProperty[],
245
+ options?: { layer?: string },
246
+ ): void
247
+ export function stop(
248
+ target: Target | readonly Target[] | MotionValue,
249
+ properties?: readonly KeyframeProperty[] | { layer?: string },
250
+ options?: { layer?: string },
192
251
  ) {
193
- const expanded = properties?.flatMap<Property>((property) =>
252
+ if (isMotionValue(target))
253
+ return asRoot(target).stop((properties as { layer?: string } | undefined)?.layer)
254
+ if (properties && !Array.isArray(properties))
255
+ throw new TypeError('View properties must be an array.')
256
+ const expanded = (
257
+ properties as readonly KeyframeProperty[] | undefined
258
+ )?.flatMap<Property>((property) =>
194
259
  property === 'scale' ? ['scaleX', 'scaleY'] : [property],
195
260
  )
196
- for (const view of toViews(target)) stopView(view, expanded)
261
+ for (const view of toViews(target as Target | readonly Target[]))
262
+ if (options?.layer !== undefined) stopLayer(view, options.layer, expanded)
263
+ else stopView(view, expanded)
264
+ }
265
+
266
+ /**
267
+ * Applies values at once, stopping whatever animates those properties.
268
+ * `scale` sets both axes. A view that isn't loaded yet gets them right away.
269
+ *
270
+ * ```ts
271
+ * set(logo, { opacity: 1, scale: 1, y: 0 })
272
+ * ```
273
+ */
274
+ export function set(value: MotionValue, to: number): void
275
+ export function set(target: Target | readonly Target[], values: Values): void
276
+ export function set(
277
+ target: Target | readonly Target[] | MotionValue,
278
+ values: Values | number,
279
+ ) {
280
+ if (isMotionValue(target)) return asRoot(target).set(values as number)
281
+ if (values === null || typeof values !== 'object' || Array.isArray(values))
282
+ throw new TypeError('set() takes an object of values.')
283
+ const keyframes: Record<string, unknown> = {}
284
+ for (const [key, value] of Object.entries(values)) {
285
+ if (value === undefined) continue
286
+ if (key !== 'scale' && !isProperty(key)) throw new Error(`Can't set "${key}".`)
287
+ if (value === null || Array.isArray(value))
288
+ throw new TypeError(
289
+ `set() takes one value per property, got ${String(value)} for "${key}".`,
290
+ )
291
+ keyframes[key] = [value, value]
292
+ }
293
+ animate(target as Target | readonly Target[], keyframes as Keyframes, { duration: 0 })
197
294
  }
198
295
 
199
296
  /** Plays several animations as one: finished once they all are, and stopped together. */
@@ -256,6 +353,7 @@ function resolveAnimation(
256
353
  stagger: user.stagger ?? own.stagger,
257
354
  relative: user.relative ?? own.relative,
258
355
  haptic: user.haptic ?? own.haptic,
356
+ layer: user.layer,
259
357
  }
260
358
  }
261
359
 
@@ -282,16 +380,21 @@ function normalize(options: AnimateOptions | SpringName | undefined): Options {
282
380
  let stagger: Options['stagger']
283
381
  let relative: Options['relative']
284
382
  let haptic: Options['haptic']
383
+ let layer: Options['layer']
285
384
  for (const [key, value] of Object.entries(options)) {
286
385
  if (value === undefined) continue
287
- if (key === 'stagger') stagger = value as Options['stagger']
386
+ if (key === 'layer') {
387
+ if (typeof value !== 'string' || !value)
388
+ throw new TypeError('A layer is named by a nonempty string.')
389
+ layer = value
390
+ } else if (key === 'stagger') stagger = value as Options['stagger']
288
391
  else if (key === 'relative') relative = value as Options['relative']
289
392
  else if (key === 'haptic') haptic = value as Options['haptic']
290
393
  else if (key === 'path' || key === 'scale' || isProperty(key)) {
291
394
  overrides[key] = typeof value === 'string' ? spring(value as SpringName) : value
292
395
  } else base[key] = value
293
396
  }
294
- return { base, overrides, stagger, relative, haptic }
397
+ return { base, overrides, stagger, relative, haptic, layer }
295
398
  }
296
399
 
297
400
  function plan(
@@ -301,8 +404,16 @@ function plan(
301
404
  offset: number,
302
405
  relative = false,
303
406
  path?: PreparedPath,
407
+ layer?: string,
408
+ seed = Math.random(),
304
409
  ): Plan[] {
410
+ if (layer !== undefined && path)
411
+ throw new Error("A path owns x and y; it can't play on a layer.")
305
412
  return expand(keyframes, path).map(([property, frames]) => {
413
+ if (layer !== undefined && !layerable(property))
414
+ throw new Error(
415
+ `Layers apply to x, y, scale, rotation and opacity; "${property}" has a single owner.`,
416
+ )
306
417
  if (path?.properties.includes(property as 'x' | 'y' | 'rotate')) {
307
418
  if (
308
419
  !Number.isFinite(path.transition.delay + offset) ||
@@ -322,12 +433,13 @@ function plan(
322
433
  const override =
323
434
  overrides[property] ?? (property.startsWith('scale') ? overrides.scale : undefined)
324
435
  const transition = resolveTransition(
325
- override ? mergeTransitions(base, override) : base,
436
+ fitTransition(override ? mergeTransitions(base, override) : base, frames.length),
326
437
  property,
327
438
  frames.length,
328
439
  )
329
440
  transition.delay += offset
330
- return { property, keyframes: frames, transition, relative }
441
+ if (transition.seed !== undefined) transition.seed = seed
442
+ return { property, keyframes: frames, transition, relative, layer }
331
443
  })
332
444
  }
333
445
 
@@ -336,8 +448,10 @@ export function startingValues(
336
448
  animation: Keyframes | PresetName,
337
449
  options?: AnimateOptions | SpringName,
338
450
  ) {
339
- const { keyframes, relative, path } = prepare(animation, options)
451
+ const { keyframes, relative, path, layer } = prepare(animation, options)
340
452
  if (!keyframes) throw new Error(`Unknown preset "${animation}".`)
453
+ if (layer !== undefined)
454
+ return new Map(expand(keyframes, path).map(([property]) => [property, null]))
341
455
  return new Map(
342
456
  expand(keyframes, path).map(([property, [first]]) => [
343
457
  property,
@@ -0,0 +1,195 @@
1
+ import { Application, type View } from '@nativescript/core'
2
+ import { toView } from '../animate.js'
3
+ import { onReducedMotion, reducedMotion } from '../config.js'
4
+ import { TimedAnimation } from '../timed-animation.js'
5
+ import { createTrack, instantTrack, type Track } from '../track.js'
6
+ import {
7
+ resolveTransition,
8
+ springs,
9
+ type Transition,
10
+ type SpringName,
11
+ } from '../transition.js'
12
+ import type { Target } from '../types.js'
13
+ import { createBlur, type BlurPainter } from './native.js'
14
+ import type { Blur, BlurOptions, BlurSnapshot } from './types.js'
15
+ export type { Blur, BlurOptions, BlurSnapshot } from './types.js'
16
+
17
+ const owners = new WeakMap<View, BlurOwner>()
18
+ function amount(value: number) {
19
+ if (!Number.isFinite(value) || value < 0 || value > 1)
20
+ throw new RangeError('Blur amount must be within 0..1.')
21
+ return value
22
+ }
23
+ /** Blur a dedicated content view after native layout. Keep sharp controls in a sibling. */
24
+ export function blur(target: Target, options: BlurOptions = {}): Blur {
25
+ if (!options || typeof options !== 'object')
26
+ throw new TypeError('Invalid blur options.')
27
+ const settings: Required<BlurOptions> = {
28
+ amount: amount(options.amount ?? 0),
29
+ radius: options.radius ?? 24,
30
+ style: options.style ?? 'system',
31
+ }
32
+ if (!Number.isFinite(settings.radius) || settings.radius < 1 || settings.radius > 64)
33
+ throw new RangeError('Blur radius must be within 1..64 DIPs.')
34
+ if (!['system', 'light', 'dark'].includes(settings.style))
35
+ throw new TypeError('Invalid blur style.')
36
+ const view = toView(target)
37
+ if (!view.isLoaded || !view.nativeViewProtected)
38
+ throw new Error('Create blur after native layout.')
39
+ if (owners.has(view)) throw new Error('This view already owns blur. Dispose it first.')
40
+ return new BlurOwner(view, settings)
41
+ }
42
+ class BlurOwner implements Blur {
43
+ disposed = false
44
+ private painter?: BlurPainter
45
+ private native?: object
46
+ private state: BlurSnapshot
47
+ private active?: { animation: TimedAnimation; track: Track; destination: number }
48
+ private suspended = false
49
+ private backgrounded = false
50
+ private offReduced: () => void
51
+ constructor(
52
+ private readonly view: View,
53
+ private readonly options: Required<BlurOptions>,
54
+ ) {
55
+ this.attach(options.amount)
56
+ this.state = this.painter!.snapshot()
57
+ owners.set(view, this)
58
+ view.on('loaded', this.layout)
59
+ view.on('layoutChanged', this.layout)
60
+ view.on('unloaded', this.unload)
61
+ Application.on(Application.suspendEvent, this.background)
62
+ Application.on(Application.resumeEvent, this.foreground)
63
+ this.offReduced = onReducedMotion((value) => {
64
+ if (!value || !this.active) return
65
+ const destination = this.active.destination
66
+ this.set(destination)
67
+ })
68
+ }
69
+ private alive() {
70
+ if (this.disposed) throw new Error('Blur has been disposed.')
71
+ }
72
+ private attach(value: number) {
73
+ this.painter = createBlur(this.view, { ...this.options, amount: value })
74
+ this.native = this.view.nativeViewProtected
75
+ }
76
+ private layout = () => {
77
+ if (this.disposed || !this.view.isLoaded || !this.view.nativeViewProtected) return
78
+ if (this.native && this.native !== this.view.nativeViewProtected) this.unload()
79
+ if (!this.painter) {
80
+ this.attach(this.state.amount)
81
+ if (this.active) {
82
+ this.painter!.play(this.active.track)
83
+ this.painter!.control(this.active.animation.time, true)
84
+ }
85
+ }
86
+ this.painter!.resize()
87
+ if (!this.backgrounded && this.suspended) {
88
+ this.active?.animation.play()
89
+ this.suspended = false
90
+ }
91
+ }
92
+ private unload = () => {
93
+ if (!this.backgrounded || !this.active) this.stop()
94
+ this.state = this.snapshot()
95
+ this.painter?.dispose()
96
+ this.painter = undefined
97
+ this.native = undefined
98
+ }
99
+ private background = () => {
100
+ if (this.backgrounded) return
101
+ this.backgrounded = true
102
+ this.suspended = !!this.active && !this.active.animation.paused
103
+ if (this.suspended) this.active!.animation.pause()
104
+ }
105
+ private foreground = () => {
106
+ this.backgrounded = false
107
+ if (this.painter) {
108
+ if (this.suspended) this.active?.animation.play()
109
+ this.suspended = false
110
+ }
111
+ }
112
+ snapshot(): BlurSnapshot {
113
+ if (this.painter) this.state = this.painter.snapshot()
114
+ return {
115
+ ...this.state,
116
+ attached: !!this.painter,
117
+ appliedAmount: this.painter ? this.state.appliedAmount : 0,
118
+ nativeAnimations: this.painter ? this.state.nativeAnimations : 0,
119
+ }
120
+ }
121
+ set(value: number) {
122
+ this.alive()
123
+ amount(value)
124
+ this.stop()
125
+ this.state.amount = value
126
+ this.painter?.paint(value)
127
+ }
128
+ animate(value: number, options: Transition | SpringName = {}) {
129
+ this.alive()
130
+ amount(value)
131
+ if (!this.painter || !this.view.isLoaded)
132
+ throw new Error('Load blur before animating.')
133
+ if (typeof options === 'string' && !Object.hasOwn(springs, options))
134
+ throw new TypeError('Unknown blur spring.')
135
+ const settings = typeof options === 'string' ? springs[options] : options
136
+ if ('layer' in settings)
137
+ throw new TypeError('Blur owns one animation; named layers are not supported.')
138
+ const transition = resolveTransition(settings, 'opacity', 2)
139
+ const from = this.snapshot().amount
140
+ const velocity =
141
+ this.active && !this.active.animation.paused
142
+ ? this.active.track.velocityAt(this.active.animation.time)
143
+ : 0
144
+ const track =
145
+ reducedMotion() || this.state.backend === 'none'
146
+ ? instantTrack('opacity', value)
147
+ : createTrack('opacity', [from, value], transition, velocity)
148
+ this.stop()
149
+ let animation: TimedAnimation
150
+ animation = new TimedAnimation(
151
+ track.end,
152
+ track.arrival,
153
+ (time, paused) => this.painter?.control(time, paused),
154
+ (completed) => {
155
+ const current = completed
156
+ ? Math.max(0, Math.min(1, track.to))
157
+ : this.snapshot().amount
158
+ this.state.amount = current
159
+ this.painter?.paint(current)
160
+ if (this.active?.animation === animation) this.active = undefined
161
+ },
162
+ )
163
+ this.active = { animation, track, destination: value }
164
+ try {
165
+ if (track.end > 0) this.painter.play(track)
166
+ else this.painter.paint(value)
167
+ animation.start()
168
+ if (this.backgrounded && this.active) {
169
+ this.suspended = true
170
+ animation.pause()
171
+ }
172
+ } catch (e) {
173
+ animation.stop()
174
+ throw e
175
+ }
176
+ return animation
177
+ }
178
+ stop() {
179
+ this.active?.animation.stop()
180
+ this.suspended = false
181
+ }
182
+ dispose() {
183
+ if (this.disposed) return
184
+ this.stop()
185
+ this.unload()
186
+ this.disposed = true
187
+ this.offReduced()
188
+ this.view.off('loaded', this.layout)
189
+ this.view.off('layoutChanged', this.layout)
190
+ this.view.off('unloaded', this.unload)
191
+ Application.off(Application.suspendEvent, this.background)
192
+ Application.off(Application.resumeEvent, this.foreground)
193
+ owners.delete(this.view)
194
+ }
195
+ }
@@ -0,0 +1,70 @@
1
+ import { isIOS, type View } from '@nativescript/core'
2
+ import type { Track } from '../track.js'
3
+ import type { BlurOptions, BlurSnapshot } from './types.js'
4
+
5
+ export interface BlurPainter {
6
+ paint(amount: number): void
7
+ play(track: Track): void
8
+ control(time: number, paused: boolean): void
9
+ resize(): void
10
+ snapshot(): BlurSnapshot
11
+ dispose(): void
12
+ }
13
+ type Factory = (view: View, options: Required<BlurOptions>) => BlurPainter
14
+ let override: Factory | undefined
15
+ /** Internal seam for lifecycle tests. */
16
+ export function setBlurFactory(value: Factory | undefined) {
17
+ override = value
18
+ }
19
+ export const createBlur: Factory = (view, options) => {
20
+ if (override) return override(view, options)
21
+ let native: {
22
+ paint(value: number): void
23
+ play(program: string): void
24
+ resize(): void
25
+ snapshot(): string
26
+ dispose(): void
27
+ }
28
+ let control: (time: number, paused: boolean) => void
29
+ if (isIOS) {
30
+ if (typeof JoltBlur === 'undefined')
31
+ throw new Error('Rebuild the native app to install animated blur.')
32
+ const effect = JoltBlur.attachOptions(
33
+ view.nativeViewProtected,
34
+ JSON.stringify(options),
35
+ )
36
+ native = effect
37
+ control = (time, paused) => effect.controlPaused(time, paused)
38
+ } else {
39
+ if (
40
+ typeof org === 'undefined' ||
41
+ typeof org.rafaelaugusto.jolt.BlurEffect !== 'function'
42
+ )
43
+ throw new Error('Rebuild the native app to install animated blur.')
44
+ const effect = new org.rafaelaugusto.jolt.BlurEffect(
45
+ view.nativeViewProtected,
46
+ options.radius,
47
+ )
48
+ native = effect
49
+ control = (time, paused) => effect.control(time, paused)
50
+ }
51
+ native.paint(options.amount)
52
+ return {
53
+ paint: (amount) => native.paint(amount),
54
+ play: (track) =>
55
+ native.play(
56
+ JSON.stringify({
57
+ times: track.times,
58
+ values: track.values,
59
+ duration: track.duration,
60
+ delay: track.delay,
61
+ repeat: track.repeat === Infinity ? -1 : track.repeat,
62
+ reverse: track.reverse,
63
+ }),
64
+ ),
65
+ control,
66
+ resize: () => native.resize(),
67
+ snapshot: () => JSON.parse(native.snapshot()),
68
+ dispose: () => native.dispose(),
69
+ }
70
+ }
@@ -0,0 +1,32 @@
1
+ import type { PlaybackAnimation } from '../playback.js'
2
+ import type { SpringName, Transition } from '../transition.js'
3
+
4
+ export interface BlurOptions {
5
+ /** Initial intensity, 0..1. Defaults to 0 (clear). */
6
+ amount?: number
7
+ /** Android maximum radius in DIPs, 1..64. Defaults to 24. iOS uses a system material. */
8
+ radius?: number
9
+ /** iOS material. Defaults to system. Android ignores this option. */
10
+ style?: 'system' | 'light' | 'dark'
11
+ }
12
+ export interface BlurSnapshot {
13
+ amount: number
14
+ /** iOS animator fraction or Android radius/maxRadius; 0 for the unsupported fallback. */
15
+ appliedAmount: number
16
+ backend: 'ios-material' | 'android-render-effect' | 'none'
17
+ attached: boolean
18
+ nativeAnimations: number
19
+ frames: number
20
+ width: number
21
+ height: number
22
+ }
23
+ export interface Blur {
24
+ readonly disposed: boolean
25
+ /** Retarget from the displayed amount. One owner per view. */
26
+ animate(amount: number, transition?: Transition | SpringName): PlaybackAnimation
27
+ set(amount: number): void
28
+ stop(): void
29
+ snapshot(): BlurSnapshot
30
+ /** Remove the owned effect and lifecycle listeners. */
31
+ dispose(): void
32
+ }
@@ -0,0 +1,84 @@
1
+ export type SheetSnap = number | `${number}%` | 'content'
2
+
3
+ export interface SheetStop {
4
+ point: SheetSnap
5
+ height: number
6
+ y: number
7
+ }
8
+
9
+ export interface SheetGeometry {
10
+ height: number
11
+ closedY: number
12
+ top: number
13
+ stops: SheetStop[]
14
+ }
15
+
16
+ export function validateSnaps(points: readonly SheetSnap[]): void {
17
+ if (!Array.isArray(points) || !points.length)
18
+ throw new TypeError('bottomSheet() needs at least one snap point.')
19
+ for (const point of points) {
20
+ if (point === 'content') continue
21
+ if (typeof point === 'number' && Number.isFinite(point) && point > 0) continue
22
+ if (typeof point === 'string' && /^(?:\d+(?:\.\d+)?|\.\d+)%$/.test(point)) {
23
+ const percent = Number.parseFloat(point)
24
+ if (percent > 0 && percent <= 100) continue
25
+ }
26
+ throw new RangeError(
27
+ 'Sheet snaps must be positive DIPs, 0–100% (exclusive of 0), or content.',
28
+ )
29
+ }
30
+ if (new Set(points).size !== points.length)
31
+ throw new RangeError('Sheet snap points must not repeat.')
32
+ }
33
+
34
+ /** Keyboard overlap is relative to the host, so adjustResize is not subtracted twice. */
35
+ export function sheetGeometry(
36
+ points: readonly SheetSnap[],
37
+ hostHeight: number,
38
+ hostBottom: number,
39
+ windowHeight: number,
40
+ keyboardHeight: number,
41
+ safeTop: number,
42
+ safeBottom: number,
43
+ contentHeight: number,
44
+ ): SheetGeometry {
45
+ const top = Math.max(0, safeTop)
46
+ const overlap = Math.max(
47
+ 0,
48
+ Math.min(hostHeight, hostBottom - (windowHeight - keyboardHeight)),
49
+ )
50
+ const bottom = Math.max(Math.max(0, safeBottom), overlap)
51
+ const height = Math.max(1, hostHeight - top - bottom)
52
+ const closedY = Math.max(height, hostHeight - top)
53
+ const stops = points.map((point) => {
54
+ const desired =
55
+ point === 'content'
56
+ ? contentHeight
57
+ : typeof point === 'number'
58
+ ? point
59
+ : (Number.parseFloat(point) / 100) * height
60
+ const visible = Math.max(1, Math.min(height, desired))
61
+ return { point, height: visible, y: height - visible }
62
+ })
63
+ return { height, closedY, top, stops }
64
+ }
65
+
66
+ /** Projection selects a stop; the native spring retains the actual release velocity. */
67
+ export function releaseStop(
68
+ geometry: SheetGeometry,
69
+ y: number,
70
+ velocity: number,
71
+ dismissible: boolean,
72
+ ): SheetStop | undefined {
73
+ const projected = y + Math.max(-4000, Math.min(4000, velocity)) * 0.2
74
+ let distance = dismissible ? Math.abs(projected - geometry.closedY) : Infinity
75
+ let result: SheetStop | undefined
76
+ for (const stop of geometry.stops) {
77
+ const next = Math.abs(projected - stop.y)
78
+ if (next <= distance) {
79
+ distance = next
80
+ result = stop
81
+ }
82
+ }
83
+ return result
84
+ }