@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
@@ -0,0 +1,63 @@
1
+ import type { ShapeFactory } from './native.js'
2
+ const floats = (values: readonly number[]) => {
3
+ const a = Array.create('float', values.length)
4
+ values.forEach((v, i) => (a[i] = v))
5
+ return a
6
+ }
7
+ export const androidShape: ShapeFactory = (view, style, initial) => {
8
+ if (
9
+ typeof org === 'undefined' ||
10
+ typeof org.rafaelaugusto.jolt.ShapeLayer !== 'function'
11
+ )
12
+ throw new Error('Rebuild the Android app to install native shapes.')
13
+ const native = view.nativeViewProtected as android.view.View
14
+ const layer = new org.rafaelaugusto.jolt.ShapeLayer(JSON.stringify(style))
15
+ native.getOverlay().add(layer)
16
+ let path = initial.path
17
+ const paint = (frame: typeof initial) => {
18
+ path = frame.path
19
+ layer.paint(path.commands, floats(path.points), frame.start, frame.end)
20
+ }
21
+ const resize = () => layer.setBounds(0, 0, native.getWidth(), native.getHeight())
22
+ resize()
23
+ paint(initial)
24
+ return {
25
+ paint,
26
+ resize,
27
+ read() {
28
+ const v = layer.values()
29
+ return {
30
+ path: {
31
+ ...path,
32
+ points: Array.from({ length: v.length - 2 }, (_, i) => v[i + 2]!),
33
+ },
34
+ start: v[0]!,
35
+ end: v[1]!,
36
+ }
37
+ },
38
+ play(from, to, track) {
39
+ path = from.path
40
+ layer.play(
41
+ path.commands,
42
+ floats([from.start, from.end, ...from.path.points]),
43
+ floats([to.start, to.end, ...to.path.points]),
44
+ floats(track.times),
45
+ floats(track.values),
46
+ track.duration,
47
+ track.delay,
48
+ track.repeat === Infinity ? -1 : track.repeat,
49
+ track.reverse,
50
+ )
51
+ },
52
+ control: (time, paused) => layer.control(time, paused),
53
+ animations: () => (layer.isPlaying() ? 1 : 0),
54
+ bounds() {
55
+ const b = layer.geometryBounds()
56
+ return Array.from({ length: b.length }, (_, i) => b[i]!)
57
+ },
58
+ dispose() {
59
+ layer.dispose()
60
+ native.getOverlay().remove(layer)
61
+ },
62
+ }
63
+ }
@@ -0,0 +1,267 @@
1
+ import { Application, type View } from '@nativescript/core'
2
+ import { toView } from '../animate.js'
3
+ import { parseColor } from '../color.js'
4
+ import { onReducedMotion, reducedMotion } from '../config.js'
5
+ import { TimedAnimation } from '../timed-animation.js'
6
+ import { createTrack, instantTrack, type Track } from '../track.js'
7
+ import {
8
+ resolveTransition,
9
+ springs,
10
+ type Transition,
11
+ type SpringName,
12
+ } from '../transition.js'
13
+ import type { Target } from '../types.js'
14
+ import { compatible, pathString, shapePath } from './path.js'
15
+ import { createShape, type ShapePainter } from './native.js'
16
+ import {
17
+ mixFrame,
18
+ type Shape,
19
+ type ShapeValues,
20
+ type ShapeOptions,
21
+ type ShapeFrame,
22
+ type ShapeStyle,
23
+ } from './types.js'
24
+ export type { Shape, ShapeValues, ShapeOptions } from './types.js'
25
+ const owners = new WeakMap<View, ShapeOwner>()
26
+ function number(n: number, name: string, min: number, max: number) {
27
+ if (!Number.isFinite(n) || n < min || n > max)
28
+ throw new RangeError(`${name} must be within ${min}..${max}.`)
29
+ return n
30
+ }
31
+ function resolve(base: ShapeFrame, values: ShapeValues): ShapeFrame {
32
+ if (
33
+ !values ||
34
+ typeof values !== 'object' ||
35
+ Object.keys(values).some((k) => !['d', 'strokeStart', 'strokeEnd'].includes(k))
36
+ )
37
+ throw new TypeError('Shape values accept d, strokeStart and strokeEnd.')
38
+ const path = values.d === undefined ? base.path : shapePath(values.d)
39
+ const start = number(values.strokeStart ?? base.start, 'strokeStart', 0, 1),
40
+ end = number(values.strokeEnd ?? base.end, 'strokeEnd', 0, 1)
41
+ if (path.contours > 1 && (start !== 0 || end !== 1))
42
+ throw new RangeError(
43
+ 'Partial stroke drawing requires one continuous subpath. Compound paths can morph or draw their complete stroke.',
44
+ )
45
+ return { path, start, end }
46
+ }
47
+ /** Draw an owned native vector surface over a view. Create after native layout. */
48
+ export function shape(target: Target, options: ShapeOptions): Shape {
49
+ if (!options || typeof options !== 'object')
50
+ throw new TypeError('Shape options are required.')
51
+ const frame = resolve(
52
+ { path: shapePath(options.d), start: 0, end: 1 },
53
+ { strokeStart: options.strokeStart, strokeEnd: options.strokeEnd },
54
+ )
55
+ const box = options.viewBox
56
+ if (!Array.isArray(box) || box.length !== 4)
57
+ throw new TypeError('viewBox needs [minX, minY, width, height].')
58
+ const viewBox: [number, number, number, number] = [
59
+ number(box[0]!, 'viewBox x', -1000000, 1000000),
60
+ number(box[1]!, 'viewBox y', -1000000, 1000000),
61
+ number(box[2]!, 'viewBox width', 0.001, 1000000),
62
+ number(box[3]!, 'viewBox height', 0.001, 1000000),
63
+ ]
64
+ const style: ShapeStyle = {
65
+ viewBox,
66
+ stroke: parseColor(options.stroke ?? '#202630'),
67
+ fill: parseColor(options.fill ?? '#00000000'),
68
+ width: number(options.strokeWidth ?? 2, 'strokeWidth', 0, 1000),
69
+ cap: options.lineCap ?? 'round',
70
+ join: options.lineJoin ?? 'round',
71
+ rule: options.fillRule ?? 'nonzero',
72
+ }
73
+ if (
74
+ !['butt', 'round', 'square'].includes(style.cap) ||
75
+ !['miter', 'round', 'bevel'].includes(style.join) ||
76
+ !['nonzero', 'evenodd'].includes(style.rule)
77
+ )
78
+ throw new TypeError('Invalid shape cap, join or fill rule.')
79
+ const view = toView(target)
80
+ if (!view.isLoaded || !view.nativeViewProtected)
81
+ throw new Error('Create shapes after native layout.')
82
+ if (owners.has(view))
83
+ throw new Error('This view already owns a shape. Dispose it first.')
84
+ return new ShapeOwner(view, style, frame)
85
+ }
86
+ class ShapeOwner implements Shape {
87
+ disposed = false
88
+ private painter?: ShapePainter
89
+ private native?: object
90
+ private active?: {
91
+ animation: TimedAnimation
92
+ track: Track
93
+ from: ShapeFrame
94
+ to: ShapeFrame
95
+ }
96
+ private suspended = false
97
+ private backgrounded = false
98
+ private offReduced: () => void
99
+ constructor(
100
+ private readonly view: View,
101
+ private readonly style: ShapeStyle,
102
+ private frame: ShapeFrame,
103
+ ) {
104
+ this.attach()
105
+ owners.set(view, this)
106
+ view.on('loaded', this.layout)
107
+ view.on('layoutChanged', this.layout)
108
+ view.on('unloaded', this.unload)
109
+ Application.on(Application.suspendEvent, this.background)
110
+ Application.on(Application.resumeEvent, this.foreground)
111
+ this.offReduced = onReducedMotion((value) => {
112
+ if (!value || !this.active) return
113
+ const destination = this.active.to
114
+ this.stop()
115
+ this.frame = destination
116
+ this.painter?.paint(destination)
117
+ })
118
+ }
119
+ private alive() {
120
+ if (this.disposed) throw new Error('Shape has been disposed.')
121
+ }
122
+ private attach() {
123
+ this.native = this.view.nativeViewProtected
124
+ this.painter = createShape(this.view, this.style, this.frame)
125
+ }
126
+ private layout = () => {
127
+ if (this.disposed || !this.view.isLoaded || !this.view.nativeViewProtected) return
128
+ if (this.native && this.native !== this.view.nativeViewProtected) this.unload()
129
+ if (!this.painter) {
130
+ this.attach()
131
+ if (this.active) {
132
+ const { from, to, track, animation } = this.active
133
+ this.painter!.play(from, to, track)
134
+ this.painter!.control(animation.time, true)
135
+ }
136
+ }
137
+ this.painter!.resize()
138
+ if (!this.backgrounded && this.suspended) {
139
+ this.active?.animation.play()
140
+ this.suspended = false
141
+ }
142
+ }
143
+ private unload = () => {
144
+ if (this.backgrounded && this.active) this.frame = this.painter?.read() ?? this.frame
145
+ else this.stop()
146
+ this.painter?.dispose()
147
+ this.painter = undefined
148
+ this.native = undefined
149
+ }
150
+ private background = () => {
151
+ if (this.backgrounded) return
152
+ this.backgrounded = true
153
+ this.suspended = !!this.active && !this.active.animation.paused
154
+ if (this.suspended) this.active!.animation.pause()
155
+ }
156
+ private foreground = () => {
157
+ this.backgrounded = false
158
+ if (this.painter) {
159
+ if (this.suspended) this.active?.animation.play()
160
+ this.suspended = false
161
+ }
162
+ }
163
+ snapshot() {
164
+ this.frame = this.painter?.read() ?? this.frame
165
+ return {
166
+ d: pathString(this.frame.path),
167
+ strokeStart: this.frame.start,
168
+ strokeEnd: this.frame.end,
169
+ attached: !!this.painter,
170
+ nativeAnimations: this.painter?.animations() ?? 0,
171
+ bounds: this.painter?.bounds() ?? null,
172
+ }
173
+ }
174
+ set(values: ShapeValues) {
175
+ this.alive()
176
+ const frame = resolve(this.painter?.read() ?? this.frame, values)
177
+ this.stop()
178
+ this.frame = frame
179
+ this.painter?.paint(frame)
180
+ }
181
+ animate(values: ShapeValues, options: Transition | SpringName = {}) {
182
+ this.alive()
183
+ if (!this.painter || !this.view.isLoaded)
184
+ throw new Error('Load the shape before animating.')
185
+ const from = this.painter.read(),
186
+ to = resolve(from, values)
187
+ compatible(from.path, to.path)
188
+ if (typeof options === 'string' && !Object.hasOwn(springs, options))
189
+ throw new TypeError('Unknown shape spring.')
190
+ const settings = typeof options === 'string' ? springs[options] : options
191
+ if ('layer' in settings)
192
+ throw new TypeError(
193
+ 'Shapes own one geometry/trim animation; named layers are not supported.',
194
+ )
195
+ const transition = resolveTransition(settings, 'opacity', 2)
196
+ const vector = (f: ShapeFrame) => [f.start, f.end, ...f.path.points]
197
+ const a = vector(from),
198
+ b = vector(to),
199
+ delta = b.map((p, i) => p - a[i]!),
200
+ squared = delta.reduce((s, v) => s + v * v, 0)
201
+ let velocity = 0
202
+ if (this.active && !this.active.animation.paused && squared) {
203
+ const old = this.active,
204
+ speed = old.track.velocityAt(old.animation.time),
205
+ x = vector(old.from),
206
+ y = vector(old.to)
207
+ velocity =
208
+ delta.reduce((s, v, i) => s + v * ((y[i] ?? 0) - (x[i] ?? 0)) * speed, 0) /
209
+ squared
210
+ }
211
+ const track = reducedMotion()
212
+ ? instantTrack('opacity', 1)
213
+ : createTrack('opacity', [0, 1], transition, velocity)
214
+ if (track.times.length * (a.length + 1) > 262144)
215
+ throw new RangeError(
216
+ 'Shape animation exceeds the sampled geometry budget. Simplify the path or curve.',
217
+ )
218
+ this.stop()
219
+ let animation: TimedAnimation
220
+ animation = new TimedAnimation(
221
+ track.end,
222
+ track.arrival,
223
+ (time, paused) => this.painter?.control(time, paused),
224
+ (completed) => {
225
+ this.frame = completed
226
+ ? mixFrame(from, to, track.to)
227
+ : (this.painter?.read() ?? this.frame)
228
+ this.painter?.paint(this.frame)
229
+ if (this.active?.animation === animation) this.active = undefined
230
+ },
231
+ )
232
+ this.active = { animation, track, from, to }
233
+ try {
234
+ if (track.end > 0) this.painter.play(from, to, track)
235
+ else {
236
+ this.frame = to
237
+ this.painter.paint(to)
238
+ }
239
+ animation.start()
240
+ if (this.backgrounded && this.active) {
241
+ this.suspended = true
242
+ animation.pause()
243
+ }
244
+ } catch (e) {
245
+ animation.stop()
246
+ throw e
247
+ }
248
+ return animation
249
+ }
250
+ stop() {
251
+ this.active?.animation.stop()
252
+ this.suspended = false
253
+ }
254
+ dispose() {
255
+ if (this.disposed) return
256
+ this.stop()
257
+ this.unload()
258
+ this.disposed = true
259
+ this.offReduced()
260
+ this.view.off('loaded', this.layout)
261
+ this.view.off('layoutChanged', this.layout)
262
+ this.view.off('unloaded', this.unload)
263
+ Application.off(Application.suspendEvent, this.background)
264
+ Application.off(Application.resumeEvent, this.foreground)
265
+ owners.delete(this.view)
266
+ }
267
+ }
@@ -0,0 +1,194 @@
1
+ import { Color, type View } from '@nativescript/core'
2
+ import { getDriver } from '../driver/index.js'
3
+ import type { Track } from '../track.js'
4
+ import type { ShapeFactory } from './native.js'
5
+ import { mixFrame, type ShapeFrame } from './types.js'
6
+
7
+ export const iosShape: ShapeFactory = (view: View, style, initial) => {
8
+ const native = view.nativeViewProtected as UIView
9
+ const root = CALayer.new(),
10
+ layer = CAShapeLayer.new()
11
+ let marker = CALayer.new()
12
+ root.name = 'jolt:shape'
13
+ root.masksToBounds = true
14
+ layer.name = 'jolt:shape:path'
15
+ marker.name = 'jolt:shape:progress'
16
+ layer.fillColor = new Color(style.fill).ios.CGColor
17
+ layer.strokeColor = new Color(style.stroke).ios.CGColor
18
+ layer.lineWidth = style.width
19
+ layer.lineCap = style.cap
20
+ layer.lineJoin = style.join
21
+ layer.fillRule = style.rule === 'evenodd' ? kCAFillRuleEvenOdd : kCAFillRuleNonZero
22
+ layer.contentsScale = UIScreen.mainScreen.scale
23
+ root.addSublayer(layer)
24
+ root.addSublayer(marker)
25
+ native.layer.addSublayer(root)
26
+ let current = initial,
27
+ program:
28
+ | {
29
+ from: ShapeFrame
30
+ to: ShapeFrame
31
+ track: Track
32
+ start: number
33
+ offset: number
34
+ paused: boolean
35
+ }
36
+ | undefined
37
+ const transaction = (fn: () => void) => {
38
+ CATransaction.begin()
39
+ CATransaction.setDisableActions(true)
40
+ try {
41
+ fn()
42
+ } finally {
43
+ CATransaction.commit()
44
+ }
45
+ }
46
+ const path = (frame: ShapeFrame) => {
47
+ const p = UIBezierPath.bezierPath(),
48
+ v = frame.path.points
49
+ let i = 0
50
+ for (const op of frame.path.commands) {
51
+ if (op === 'M') {
52
+ p.moveToPoint(CGPointMake(v[i]!, v[i + 1]!))
53
+ i += 2
54
+ }
55
+ if (op === 'L') {
56
+ p.addLineToPoint(CGPointMake(v[i]!, v[i + 1]!))
57
+ i += 2
58
+ }
59
+ if (op === 'C') {
60
+ p.addCurveToPointControlPoint1ControlPoint2(
61
+ CGPointMake(v[i + 4]!, v[i + 5]!),
62
+ CGPointMake(v[i]!, v[i + 1]!),
63
+ CGPointMake(v[i + 2]!, v[i + 3]!),
64
+ )
65
+ i += 6
66
+ }
67
+ if (op === 'Q') {
68
+ p.addQuadCurveToPointControlPoint(
69
+ CGPointMake(v[i + 2]!, v[i + 3]!),
70
+ CGPointMake(v[i]!, v[i + 1]!),
71
+ )
72
+ i += 4
73
+ }
74
+ if (op === 'Z') p.closePath()
75
+ }
76
+ return p.CGPath
77
+ }
78
+ const resize = () =>
79
+ transaction(() => {
80
+ const { width, height } = view.getActualSize(),
81
+ [x, y, w, h] = style.viewBox
82
+ root.frame = CGRectMake(0, 0, Math.max(0, width), Math.max(0, height))
83
+ layer.bounds = CGRectMake(x, y, w, h)
84
+ layer.position = CGPointMake(width / 2, height / 2)
85
+ const scale = Math.max(0, Math.min(width / w, height / h))
86
+ layer.transform = CATransform3DMakeScale(scale, scale, 1)
87
+ })
88
+ const paint = (frame: ShapeFrame) =>
89
+ transaction(() => {
90
+ program = undefined
91
+ current = frame
92
+ root.speed = 1
93
+ root.beginTime = 0
94
+ root.timeOffset = 0
95
+ layer.removeAllAnimations()
96
+ marker.removeAllAnimations()
97
+ layer.path = path(frame)
98
+ layer.strokeStart = frame.start
99
+ layer.strokeEnd = frame.end
100
+ })
101
+ resize()
102
+ paint(initial)
103
+ return {
104
+ paint,
105
+ resize,
106
+ read() {
107
+ if (!program) return current
108
+ const { from, to, track, paused, offset, start } = program
109
+ const presented = marker.presentationLayer()
110
+ const progress =
111
+ !paused && presented
112
+ ? Number(presented.valueForKeyPath('transform.translation.x'))
113
+ : track.valueAt(offset + (paused ? 0 : getDriver().now() - start))
114
+ const frame = mixFrame(from, to, progress)
115
+ // Trim diagnostics read the actual shape layer, except before a pending pause transaction is drawn.
116
+ const shown = layer.presentationLayer() as CAShapeLayer | null
117
+ if (shown && !paused) {
118
+ frame.start = shown.strokeStart
119
+ frame.end = shown.strokeEnd
120
+ }
121
+ return frame
122
+ },
123
+ play(from, to, track) {
124
+ paint(mixFrame(from, to, track.to))
125
+ // A new marker cannot expose the previous program's cached presentation
126
+ // when several retargets happen before the next render transaction.
127
+ marker.removeFromSuperlayer()
128
+ marker = CALayer.new()
129
+ marker.name = 'jolt:shape:progress'
130
+ root.addSublayer(marker)
131
+ program = { from, to, track, paused: false, offset: 0, start: getDriver().now() }
132
+ transaction(() => {
133
+ root.beginTime = native.layer.convertTimeFromLayer(CACurrentMediaTime(), null)
134
+ const frames = track.values.map((t) => mixFrame(from, to, t))
135
+ const add = (target: CALayer, key: string, values: unknown[]) => {
136
+ const a = CAKeyframeAnimation.animationWithKeyPath(key)
137
+ a.values = NSArray.arrayWithArray(values)
138
+ a.keyTimes = NSArray.arrayWithArray([...track.times])
139
+ a.duration = track.duration / 1000
140
+ a.beginTime = Math.max(0.000001, track.delay / 1000)
141
+ a.fillMode = kCAFillModeBoth
142
+ a.removedOnCompletion = false
143
+ a.autoreverses = track.reverse
144
+ a.repeatCount =
145
+ track.repeat === Infinity
146
+ ? Infinity
147
+ : track.reverse
148
+ ? (track.repeat + 1) / 2
149
+ : track.repeat + 1
150
+ target.addAnimationForKey(a, 'jolt:shape:' + key)
151
+ }
152
+ marker.setValueForKeyPath(track.to, 'transform.translation.x')
153
+ add(layer, 'path', frames.map(path))
154
+ add(
155
+ layer,
156
+ 'strokeStart',
157
+ frames.map((f) => f.start),
158
+ )
159
+ add(
160
+ layer,
161
+ 'strokeEnd',
162
+ frames.map((f) => f.end),
163
+ )
164
+ add(marker, 'transform.translation.x', [...track.values])
165
+ })
166
+ },
167
+ control(time, paused) {
168
+ if (!program) return
169
+ program.offset = time
170
+ program.start = getDriver().now()
171
+ program.paused = paused
172
+ transaction(() => {
173
+ root.speed = paused ? 0 : 1
174
+ root.timeOffset = paused ? time / 1000 : 0
175
+ root.beginTime = paused
176
+ ? 0
177
+ : native.layer.convertTimeFromLayer(CACurrentMediaTime(), null) - time / 1000
178
+ })
179
+ },
180
+ animations: () =>
181
+ (layer.animationKeys()?.count ?? 0) + (marker.animationKeys()?.count ?? 0),
182
+ bounds() {
183
+ const shown = (layer.presentationLayer() as CAShapeLayer | null) ?? layer
184
+ const b = CGPathGetBoundingBox(shown.path)
185
+ return [b.origin.x, b.origin.y, b.size.width, b.size.height]
186
+ },
187
+ dispose() {
188
+ program = undefined
189
+ layer.removeAllAnimations()
190
+ marker.removeAllAnimations()
191
+ root.removeFromSuperlayer()
192
+ },
193
+ }
194
+ }
@@ -0,0 +1,27 @@
1
+ import { isAndroid, type View } from '@nativescript/core'
2
+ import type { Track } from '../track.js'
3
+ import type { ShapeFrame, ShapeStyle } from './types.js'
4
+ import { iosShape } from './ios.js'
5
+ import { androidShape } from './android.js'
6
+ export interface ShapePainter {
7
+ paint(frame: ShapeFrame): void
8
+ read(): ShapeFrame
9
+ play(from: ShapeFrame, to: ShapeFrame, track: Track): void
10
+ control(time: number, paused: boolean): void
11
+ resize(): void
12
+ animations(): number
13
+ bounds(): number[]
14
+ dispose(): void
15
+ }
16
+ export type ShapeFactory = (
17
+ view: View,
18
+ style: ShapeStyle,
19
+ frame: ShapeFrame,
20
+ ) => ShapePainter
21
+ let override: ShapeFactory | undefined
22
+ /** Internal injection for lifecycle tests. */
23
+ export function setShapeFactory(value: ShapeFactory | undefined) {
24
+ override = value
25
+ }
26
+ export const createShape: ShapeFactory = (view, style, frame) =>
27
+ (override ?? (isAndroid ? androidShape : iosShape))(view, style, frame)
@@ -0,0 +1,127 @@
1
+ import { Scanner, arc, type PathPoint } from '../svg-path.js'
2
+
3
+ /** Absolute M/L/C/Q/Z commands, shared by both native renderers. */
4
+ export interface ShapePath {
5
+ commands: string
6
+ points: number[]
7
+ contours: number
8
+ }
9
+ export function shapePath(d: string): ShapePath {
10
+ if (typeof d !== 'string' || !d.trim())
11
+ throw new TypeError('Shape d must be a nonempty SVG path.')
12
+ if (d.length > 20000) throw new RangeError('Shape path exceeds 20000 characters.')
13
+ const scanner = new Scanner(d),
14
+ result: ShapePath = { commands: '', points: [], contours: 0 }
15
+ let current = { x: 0, y: 0 },
16
+ first: PathPoint | undefined,
17
+ control = current
18
+ let command = '',
19
+ previous = ''
20
+ const add = (op: string, ...points: PathPoint[]) => {
21
+ if (result.commands.length >= 256)
22
+ throw new RangeError('Shapes support at most 256 normalized commands.')
23
+ result.commands += op
24
+ for (const p of points) {
25
+ if (![p.x, p.y].every((n) => Number.isFinite(n) && Math.abs(n) <= 1000000))
26
+ throw new RangeError('Shape coordinates must stay within ±1000000.')
27
+ result.points.push(p.x, p.y)
28
+ }
29
+ if (points.length) current = points.at(-1)!
30
+ }
31
+ while (scanner.peek() !== undefined) {
32
+ if (/[a-z]/i.test(scanner.peek()!)) command = scanner.command()
33
+ else if (!command) scanner.error()
34
+ const upper = command.toUpperCase(),
35
+ relative = command !== upper,
36
+ origin = current
37
+ const point = () => ({
38
+ x: scanner.number() + (relative ? origin.x : 0),
39
+ y: scanner.number() + (relative ? origin.y : 0),
40
+ })
41
+ if (!first && upper !== 'M')
42
+ throw new SyntaxError('Shape path must start with M or m.')
43
+ if (upper === 'M') {
44
+ first = point()
45
+ add('M', first)
46
+ result.contours++
47
+ command = relative ? 'l' : 'L'
48
+ } else if (upper === 'L') add('L', point())
49
+ else if (upper === 'H' || upper === 'V') {
50
+ const n = scanner.number()
51
+ add(
52
+ 'L',
53
+ upper === 'H'
54
+ ? { x: n + (relative ? origin.x : 0), y: current.y }
55
+ : { x: current.x, y: n + (relative ? origin.y : 0) },
56
+ )
57
+ } else if (upper === 'C' || upper === 'S') {
58
+ const c1 =
59
+ upper === 'C'
60
+ ? point()
61
+ : /[CS]/.test(previous)
62
+ ? { x: 2 * current.x - control.x, y: 2 * current.y - control.y }
63
+ : current
64
+ const c2 = point(),
65
+ end = point()
66
+ add('C', c1, c2, end)
67
+ control = c2
68
+ } else if (upper === 'Q' || upper === 'T') {
69
+ const c =
70
+ upper === 'Q'
71
+ ? point()
72
+ : /[QT]/.test(previous)
73
+ ? { x: 2 * current.x - control.x, y: 2 * current.y - control.y }
74
+ : current
75
+ add('Q', c, point())
76
+ control = c
77
+ } else if (upper === 'A') {
78
+ const rx = scanner.number(),
79
+ ry = scanner.number(),
80
+ rotation = scanner.number(),
81
+ large = scanner.number(true),
82
+ sweep = scanner.number(true),
83
+ end = point()
84
+ const segment = arc(current, end, rx, ry, rotation, !!large, !!sweep)
85
+ if (!segment.angle) add('L', end)
86
+ else {
87
+ const count = Math.ceil(Math.abs(segment.angle) / (Math.PI / 2)),
88
+ factor = ((4 / 3) * Math.tan(segment.angle / count / 4)) / segment.angle
89
+ for (let i = 0; i < count; i++) {
90
+ const a = segment.point(i / count),
91
+ b = segment.point((i + 1) / count),
92
+ da = segment.tangent(i / count),
93
+ db = segment.tangent((i + 1) / count)
94
+ add(
95
+ 'C',
96
+ { x: a.x + da.x * factor, y: a.y + da.y * factor },
97
+ { x: b.x - db.x * factor, y: b.y - db.y * factor },
98
+ b,
99
+ )
100
+ }
101
+ }
102
+ } else if (upper === 'Z') {
103
+ add('Z')
104
+ current = first!
105
+ command = ''
106
+ } else scanner.error()
107
+ previous = upper
108
+ }
109
+ if (!/[LCQ]/.test(result.commands))
110
+ throw new SyntaxError('Shape needs at least one drawing segment.')
111
+ return result
112
+ }
113
+ export function compatible(a: ShapePath, b: ShapePath) {
114
+ if (a.commands !== b.commands)
115
+ throw new TypeError(
116
+ 'Morph paths need matching normalized commands and subpaths. Use set() for a topology change.',
117
+ )
118
+ }
119
+ export function pathString(path: ShapePath) {
120
+ let i = 0
121
+ return [...path.commands]
122
+ .map((op) => {
123
+ const count = op === 'C' ? 6 : op === 'Q' ? 4 : op === 'Z' ? 0 : 2
124
+ return op + path.points.slice(i, (i += count)).join(' ')
125
+ })
126
+ .join(' ')
127
+ }