@rafaelaugusto/jolt 0.0.0-stage → 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +256 -2
  3. package/dist/animate.d.ts +26 -0
  4. package/dist/animate.d.ts.map +1 -0
  5. package/dist/animate.js +153 -0
  6. package/dist/animate.js.map +1 -0
  7. package/dist/driver/android.d.ts +3 -0
  8. package/dist/driver/android.d.ts.map +1 -0
  9. package/dist/driver/android.js +73 -0
  10. package/dist/driver/android.js.map +1 -0
  11. package/dist/driver/index.d.ts +18 -0
  12. package/dist/driver/index.d.ts.map +1 -0
  13. package/dist/driver/index.js +15 -0
  14. package/dist/driver/index.js.map +1 -0
  15. package/dist/driver/ios.d.ts +3 -0
  16. package/dist/driver/ios.d.ts.map +1 -0
  17. package/dist/driver/ios.js +68 -0
  18. package/dist/driver/ios.js.map +1 -0
  19. package/dist/easing.d.ts +8 -0
  20. package/dist/easing.d.ts.map +1 -0
  21. package/dist/easing.js +71 -0
  22. package/dist/easing.js.map +1 -0
  23. package/dist/engine.d.ts +47 -0
  24. package/dist/engine.d.ts.map +1 -0
  25. package/dist/engine.js +168 -0
  26. package/dist/engine.js.map +1 -0
  27. package/dist/index.d.ts +13 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +7 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/presets.d.ts +295 -0
  32. package/dist/presets.d.ts.map +1 -0
  33. package/dist/presets.js +123 -0
  34. package/dist/presets.js.map +1 -0
  35. package/dist/press.d.ts +13 -0
  36. package/dist/press.d.ts.map +1 -0
  37. package/dist/press.js +32 -0
  38. package/dist/press.js.map +1 -0
  39. package/dist/properties.d.ts +8 -0
  40. package/dist/properties.d.ts.map +1 -0
  41. package/dist/properties.js +42 -0
  42. package/dist/properties.js.map +1 -0
  43. package/dist/sequence.d.ts +25 -0
  44. package/dist/sequence.d.ts.map +1 -0
  45. package/dist/sequence.js +68 -0
  46. package/dist/sequence.js.map +1 -0
  47. package/dist/spring.d.ts +22 -0
  48. package/dist/spring.d.ts.map +1 -0
  49. package/dist/spring.js +54 -0
  50. package/dist/spring.js.map +1 -0
  51. package/dist/track.d.ts +28 -0
  52. package/dist/track.d.ts.map +1 -0
  53. package/dist/track.js +103 -0
  54. package/dist/track.js.map +1 -0
  55. package/dist/transition.d.ts +58 -0
  56. package/dist/transition.d.ts.map +1 -0
  57. package/dist/transition.js +82 -0
  58. package/dist/transition.js.map +1 -0
  59. package/dist/types.d.ts +38 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/dist/types.js +2 -0
  62. package/dist/types.js.map +1 -0
  63. package/package.json +63 -4
  64. package/src/animate.ts +219 -0
  65. package/src/driver/android.ts +101 -0
  66. package/src/driver/index.ts +32 -0
  67. package/src/driver/ios.ts +88 -0
  68. package/src/easing.ts +100 -0
  69. package/src/engine.ts +208 -0
  70. package/src/index.ts +12 -0
  71. package/src/presets.ts +134 -0
  72. package/src/press.ts +43 -0
  73. package/src/properties.ts +51 -0
  74. package/src/sequence.ts +85 -0
  75. package/src/spring.ts +95 -0
  76. package/src/track.ts +163 -0
  77. package/src/transition.ts +160 -0
  78. package/src/types.ts +39 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rafael Augusto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,257 @@
1
- # Temporary Holding Version
1
+ # Jolt
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Native animations for [NativeScript](https://nativescript.org): presets, springs, keyframes and stagger, one call each.
4
+
5
+ ```ts
6
+ import { animate } from '@rafaelaugusto/jolt'
7
+
8
+ animate(card, 'fadeInUp')
9
+ animate(button, { scale: 1.1 }, 'bouncy')
10
+ animate(rows, 'fadeInUp', { stagger: 40 })
11
+ ```
12
+
13
+ NativeScript's `view.animate()` covers the basics and stops there: one curve for every property, a `spring` curve with no settings, no keyframes, and a promise that rejects when the animation is cancelled. Anything richer ends up as platform code.
14
+
15
+ Jolt computes the motion once, in JavaScript, when the animation starts, and hands it to the platform as keyframes: Core Animation on iOS, `ObjectAnimator` on Android. Nothing runs in JavaScript while it plays. Springs follow real physics, and an animation that interrupts another one starts from where the view is, at the speed it was going.
16
+
17
+ ## Install
18
+
19
+ ```sh
20
+ npm install @rafaelaugusto/jolt@next
21
+ ```
22
+
23
+ It's in beta for now, published under the `next` tag. Requires `@nativescript/core` 8.9 or later. It doesn't depend on a framework: it takes a view, or an element that holds one.
24
+
25
+ ## Animating
26
+
27
+ `animate(target, keyframes, transition?)` takes a view and where to take it:
28
+
29
+ ```ts
30
+ animate(card, { opacity: 0.5, y: -20 })
31
+ ```
32
+
33
+ | Property | Unit |
34
+ | -------------------- | ---------------------------------------- |
35
+ | `opacity` | |
36
+ | `x`, `y` | DIPs, same as `translateX`, `translateY` |
37
+ | `scale` | sets `scaleX` and `scaleY` together |
38
+ | `scaleX`, `scaleY` | |
39
+ | `rotate` | degrees |
40
+ | `rotateX`, `rotateY` | degrees, with perspective |
41
+
42
+ A single value animates from wherever the view is. An array is a list of keyframes, and `null` stands for the current value:
43
+
44
+ ```ts
45
+ animate(card, { x: [0, 100] }) // from 0, whatever x is now
46
+ animate(card, { x: [null, 20, -20, null] }) // out and back to where it was
47
+ ```
48
+
49
+ The target can be a view, or anything that holds one: a NativeScript-Vue template ref, an Angular `ElementRef`.
50
+
51
+ ```vue
52
+ <script setup lang="ts">
53
+ const card = ref()
54
+ const open = () => animate(card.value, 'popIn')
55
+ </script>
56
+
57
+ <template>
58
+ <GridLayout ref="card" @tap="open" />
59
+ </template>
60
+ ```
61
+
62
+ A view that isn't loaded yet takes its first keyframe right away and plays once it's on screen. Calling `animate(title, 'fadeInUp')` in `onMounted` doesn't flash the title before it fades in.
63
+
64
+ ## Transitions
65
+
66
+ The third argument says how to get there. Without one, transforms move with a spring and `opacity` eases over 300ms. Keyframes tween.
67
+
68
+ ### Springs
69
+
70
+ ```ts
71
+ animate(card, { scale: 1.2 }, 'bouncy')
72
+ animate(card, { y: 0 }, { bounce: 0.3, duration: 600 })
73
+ animate(card, { y: 0 }, { stiffness: 300, damping: 20, mass: 1 })
74
+ ```
75
+
76
+ | Spring | Feel |
77
+ | -------- | ------------------------------------- |
78
+ | `smooth` | no overshoot |
79
+ | `snappy` | quick, barely overshoots. The default |
80
+ | `bouncy` | overshoots and settles with a bounce |
81
+
82
+ `bounce` goes from -1 to 1: 0 settles without overshooting, higher values bounce more, negative values settle more slowly. `duration` is how long the spring feels, the same model as SwiftUI. Or describe it with `stiffness`, `damping` and `mass`. A spring starts with the velocity of the animation it interrupts, unless you pass `velocity` (units per second).
83
+
84
+ ### Tweens
85
+
86
+ ```ts
87
+ animate(card, { opacity: 0 }, { duration: 200, ease: 'easeIn' })
88
+ animate(
89
+ card,
90
+ { x: [0, 100, 50] },
91
+ { duration: 600, ease: ['easeOut', 'easeIn'], times: [0, 0.3, 1] },
92
+ )
93
+ ```
94
+
95
+ Tweens take 300ms and `easeOut` unless told otherwise. `ease` takes `linear`, `ease`, `easeIn`, `easeOut`, `easeInOut`, `circIn`, `circOut`, `circInOut`, `backIn`, `backOut`, `backInOut`, `anticipate`, a cubic bezier (`[0.2, 0, 0, 1]`) or any function from 0..1 to a value. With keyframes, pass one per segment. `times` places each keyframe between 0 and 1.
96
+
97
+ Custom easing functions run once, when the animation starts, like springs do. They don't cost anything per frame.
98
+
99
+ ### Per property
100
+
101
+ ```ts
102
+ animate(
103
+ card,
104
+ { y: 0, opacity: 1 },
105
+ { type: 'spring', bounce: 0.3, opacity: { duration: 150 } },
106
+ )
107
+ ```
108
+
109
+ A property's transition replaces the curve, and keeps the timing (`delay`, `repeat`) of the main one unless it sets its own.
110
+
111
+ ### Timing
112
+
113
+ ```ts
114
+ animate(
115
+ badge,
116
+ { scale: [1, 1.2] },
117
+ { delay: 300, repeat: Infinity, repeatType: 'reverse' },
118
+ )
119
+ ```
120
+
121
+ `delay` is in milliseconds, and the view takes the first keyframe during it. `repeat` is how many more times to play, `Infinity` until stopped. `repeatType: 'reverse'` plays every other repeat backwards. Repeats play natively too.
122
+
123
+ ## Presets
124
+
125
+ ```ts
126
+ animate(card, 'popIn')
127
+ animate(card, 'shake', { delay: 200 })
128
+ animate(spinner, 'spin', { repeat: Infinity })
129
+ ```
130
+
131
+ | | |
132
+ | --------- | -------------------------------------------------------------------------------------------------------- |
133
+ | Enter | `fadeIn`, `fadeInUp`, `fadeInDown`, `fadeInLeft`, `fadeInRight`, `zoomIn`, `popIn`, `flipInX`, `flipInY` |
134
+ | Exit | `fadeOut`, `fadeOutUp`, `fadeOutDown`, `fadeOutLeft`, `fadeOutRight`, `zoomOut`, `popOut` |
135
+ | Attention | `pulse`, `bounce`, `shake`, `wiggle`, `heartbeat`, `jelly`, `flash`, `tada`, `spin` |
136
+
137
+ Directions follow animate.css: `fadeInUp` comes up from below, `fadeOutUp` leaves upwards. Every preset is plain keyframes and a transition, listed in [`src/presets.ts`](./src/presets.ts) and exported as `presets`.
138
+
139
+ Options with timing only (`delay`, `repeat`, `stagger`) keep the preset's curves. Options with a curve (`duration`, `ease`, a spring) replace them:
140
+
141
+ ```ts
142
+ animate(card, 'fadeInUp', { delay: 100 }) // the preset's spring, 100ms later
143
+ animate(card, 'fadeInUp', { duration: 600 }) // a 600ms tween instead
144
+ animate(card, 'fadeInUp', 'bouncy') // a bouncy spring instead
145
+ ```
146
+
147
+ ## Several views
148
+
149
+ Pass an array to animate them together, and `stagger` to start them one after another:
150
+
151
+ ```ts
152
+ animate(rows, 'fadeInUp', { stagger: 40 })
153
+ animate(tiles, 'popIn', { stagger: { each: 30, from: 'center' } })
154
+ ```
155
+
156
+ `from` is `'first'` (the default), `'last'`, `'center'` or an index.
157
+
158
+ ## Sequences
159
+
160
+ ```ts
161
+ await sequence([
162
+ [logo, 'popIn'],
163
+ [[title, subtitle], 'fadeInUp', { stagger: 80 }],
164
+ () => animate(button, 'fadeIn'),
165
+ ])
166
+ ```
167
+
168
+ Each step takes the same arguments as `animate`, or is a function that starts an animation. A step starts once the previous one looks done: a spring that's close to its target and staying there counts, even if it's still settling, so steps don't wait on the last pixel. The whole sequence finishes once every step has.
169
+
170
+ Views in later steps take their first keyframe when the sequence starts, so the title above stays hidden until its turn instead of showing up and disappearing.
171
+
172
+ ## Press
173
+
174
+ ```ts
175
+ const remove = press(button) // scales to 0.96 while pressed
176
+ press(card, { scale: 0.97, opacity: 0.8 })
177
+ press(tile, { scale: 0.9, rotate: -4 }, 'bouncy')
178
+ ```
179
+
180
+ Animates to the given values while a finger is down, and back to where the view was once it lifts, or once the touch is cancelled by a scroll taking over. Views with `isEnabled` set to `false` don't react. It returns a function that removes the effect.
181
+
182
+ ## Interrupting and stopping
183
+
184
+ Starting an animation on a property that's already animating takes it over: the new one starts from the value on screen, with the same velocity, so a card can change its mind halfway without a jump. Other properties of the previous animation keep going.
185
+
186
+ `animate()` returns an animation you can `await`. It resolves with `true` when it played to the end, and `false` when it was stopped or taken over. It never rejects.
187
+
188
+ ```ts
189
+ const animation = animate(card, { x: 300 })
190
+ animation.stop() // the card stays where it is
191
+
192
+ stop(card) // stops everything running on the card
193
+ ```
194
+
195
+ ## How it works
196
+
197
+ When an animation starts, Jolt resolves where each property starts from (the value on screen, or the keyframes you gave), and computes the whole curve: easing, keyframes, spring physics. It samples the curve 60 times per second of motion, and keeps keyframe times exact. Linear segments aren't sampled at all.
198
+
199
+ The samples go to the platform in one go:
200
+
201
+ - **iOS**: a `CAKeyframeAnimation` per property on the view's layer (`opacity`, `transform.translation.x`, `transform.scale.y`, `transform.rotation.z`...). Core Animation composes them, so `x` and `scale` can belong to different animations, and plays them in the render server.
202
+ - **Android**: an `ObjectAnimator` per property with `Keyframe`s and a linear interpolator, on the view's `alpha`, `translationX`, `scaleY`, `rotation`...
203
+
204
+ Before playing, the final values are set on the NativeScript view, like `view.animate()` does, so `view.translateX` already holds the target while the animation runs. Stopping writes back the values on screen.
205
+
206
+ Each running property remembers its curve and start time, so Jolt knows the value and velocity of any property at any moment without asking the platform. That's what lets an interruption pick up the motion where it was. On Android, where an animator starts on the next frame, it reads the value on screen instead.
207
+
208
+ ## Not there yet
209
+
210
+ - Only transforms and opacity. Colors, size and layout changes aren't animated yet.
211
+ - No gestures: dragging something and letting it fly with its velocity is next.
212
+ - No layout or shared element transitions.
213
+
214
+ ## API
215
+
216
+ **Animating**: `animate(target, keyframes | preset, transition?)`, `stop(target)`, `sequence(steps)`, `press(target, pressed?, transition?)`.
217
+
218
+ **Animations** returned by them: `await`, `finished`, `stop()`.
219
+
220
+ **Helpers**: `presets`, `springs`, `cubicBezier`, plus the types (`Keyframes`, `Transition`, `Spring`, `Tween`, `PresetName`, `SpringName`, `Easing`, `Animation`, `Target`...).
221
+
222
+ ## Demo
223
+
224
+ [`demo/`](./demo) is a NativeScript-Vue app with every preset, the three springs on a ball you can interrupt, stagger, press effects, loops and a sequence on launch.
225
+
226
+ With the [NativeScript CLI](https://docs.nativescript.org/setup/) installed:
227
+
228
+ ```sh
229
+ npm install
230
+ npm run dev # builds Jolt in watch mode
231
+
232
+ cd demo
233
+ npm install
234
+ ns run ios # or: ns run android
235
+ ```
236
+
237
+ ## Development
238
+
239
+ ```sh
240
+ npm test # unit tests
241
+ npm run typecheck # including the iOS and Android drivers, against the platform typings
242
+ npm run build
243
+ ```
244
+
245
+ The tests run the engine against a fake platform driver ([`test/helpers.ts`](./test/helpers.ts)) with its own clock: it records the keyframes it would play and ends them when the clock passes their end.
246
+
247
+ ### Releasing
248
+
249
+ 1. Bump `version` in `package.json` (`npm version <version> --no-git-tag-version`) and move the changes under it in `CHANGELOG.md`.
250
+ 2. Merge that into `main`.
251
+ 3. Publish a GitHub release tagged `v<version>`. The [release workflow](./.github/workflows/release.yml) checks the tag against `package.json`, runs the tests and publishes to npm: under `next` when the release is marked as a pre-release, under `latest` otherwise.
252
+
253
+ Publishing authenticates with the `NPM_TOKEN` secret, or with [trusted publishing](https://docs.npmjs.com/trusted-publishers) once it's set up for the package on npm.
254
+
255
+ ## License
256
+
257
+ [MIT](./LICENSE)
@@ -0,0 +1,26 @@
1
+ import { View } from '@nativescript/core';
2
+ import { type Animation } from './engine.js';
3
+ import { type PresetName } from './presets.js';
4
+ import { type Property } from './properties.js';
5
+ import { type SpringName } from './transition.js';
6
+ import type { AnimateOptions, Keyframes, Target } from './types.js';
7
+ /**
8
+ * Animates one view, or several. Takes keyframes or the name of a preset,
9
+ * and a transition or the name of a spring.
10
+ *
11
+ * ```ts
12
+ * animate(card, 'fadeInUp')
13
+ * animate(card, { scale: 1.1, rotate: [0, 90] }, 'bouncy')
14
+ * animate(rows, 'fadeInUp', { stagger: 40 })
15
+ * ```
16
+ */
17
+ export declare function animate(target: Target | readonly Target[], animation: Keyframes | PresetName, options?: AnimateOptions | SpringName): Animation;
18
+ /** Stops every animation running on the view, leaving it where it is. */
19
+ export declare function stop(target: Target | readonly Target[]): void;
20
+ /** Plays several animations as one: finished once they all are, and stopped together. */
21
+ export declare function group(animations: readonly Animation[]): Animation;
22
+ export declare function toView(target: Target): View;
23
+ export declare function toViews(target: Target | readonly Target[]): View[];
24
+ /** Each property the animation touches, with the value it starts from when it sets one. */
25
+ export declare function startingValues(animation: Keyframes | PresetName): Map<Property, number>;
26
+ //# sourceMappingURL=animate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animate.d.ts","sourceRoot":"","sources":["../src/animate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EAKL,KAAK,SAAS,EAEf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EAGT,MAAM,EACP,MAAM,YAAY,CAAA;AAQnB;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAClC,SAAS,EAAE,SAAS,GAAG,UAAU,EACjC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,GACpC,SAAS,CAiBX;AAED,yEAAyE;AACzE,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,QAEtD;AAED,yFAAyF;AACzF,wBAAgB,KAAK,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAWjE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAO3C;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,EAAE,CAElE;AA+DD,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,yBAO/D"}
@@ -0,0 +1,153 @@
1
+ import { View } from '@nativescript/core';
2
+ import { arrivalOf, setArrival, stopView, ViewAnimation, } from './engine.js';
3
+ import { presets } from './presets.js';
4
+ import { isProperty } from './properties.js';
5
+ import { hasCurve, mergeTransitions, resolveTransition, springs, } from './transition.js';
6
+ /**
7
+ * Animates one view, or several. Takes keyframes or the name of a preset,
8
+ * and a transition or the name of a spring.
9
+ *
10
+ * ```ts
11
+ * animate(card, 'fadeInUp')
12
+ * animate(card, { scale: 1.1, rotate: [0, 90] }, 'bouncy')
13
+ * animate(rows, 'fadeInUp', { stagger: 40 })
14
+ * ```
15
+ */
16
+ export function animate(target, animation, options) {
17
+ const { keyframes, base, overrides, stagger } = prepare(animation, options);
18
+ if (!isList(target)) {
19
+ return new ViewAnimation(toView(target), plan(keyframes, base, overrides, 0));
20
+ }
21
+ const views = target.map(toView);
22
+ return group(views.map((view, index) => new ViewAnimation(view, plan(keyframes, base, overrides, staggerDelay(stagger, index, views.length)))));
23
+ }
24
+ /** Stops every animation running on the view, leaving it where it is. */
25
+ export function stop(target) {
26
+ for (const view of toViews(target))
27
+ stopView(view);
28
+ }
29
+ /** Plays several animations as one: finished once they all are, and stopped together. */
30
+ export function group(animations) {
31
+ const finished = Promise.all(animations.map((animation) => animation.finished)).then((results) => results.every(Boolean));
32
+ const animation = {
33
+ finished,
34
+ stop: () => animations.forEach((animation) => animation.stop()),
35
+ then: (onfulfilled, onrejected) => finished.then(onfulfilled, onrejected),
36
+ };
37
+ setArrival(animation, Promise.all(animations.map(arrivalOf)));
38
+ return animation;
39
+ }
40
+ export function toView(target) {
41
+ if (target instanceof View)
42
+ return target;
43
+ const view = target?.nativeView ??
44
+ target?.nativeElement;
45
+ if (view instanceof View)
46
+ return view;
47
+ throw new TypeError(`Expected a NativeScript view, got ${String(target)}.`);
48
+ }
49
+ export function toViews(target) {
50
+ return isList(target) ? target.map(toView) : [toView(target)];
51
+ }
52
+ function isList(target) {
53
+ return Array.isArray(target);
54
+ }
55
+ function prepare(animation, options) {
56
+ const user = normalize(options);
57
+ if (typeof animation !== 'string')
58
+ return { keyframes: animation, ...user };
59
+ const preset = presets[animation];
60
+ if (!preset)
61
+ throw new Error(`Unknown preset "${animation}".`);
62
+ const own = normalize(preset.transition);
63
+ return {
64
+ keyframes: preset.keyframes,
65
+ base: mergeTransitions(own.base, user.base),
66
+ overrides: hasCurve(user.base)
67
+ ? user.overrides
68
+ : { ...own.overrides, ...user.overrides },
69
+ stagger: user.stagger,
70
+ };
71
+ }
72
+ function normalize(options) {
73
+ if (options === undefined)
74
+ return { base: {}, overrides: {}, stagger: undefined };
75
+ if (typeof options === 'string')
76
+ return { base: spring(options), overrides: {}, stagger: undefined };
77
+ const base = {};
78
+ const overrides = {};
79
+ let stagger;
80
+ for (const [key, value] of Object.entries(options)) {
81
+ if (value === undefined)
82
+ continue;
83
+ if (key === 'stagger')
84
+ stagger = value;
85
+ else if (key === 'scale' || isProperty(key)) {
86
+ overrides[key] = typeof value === 'string' ? spring(value) : value;
87
+ }
88
+ else
89
+ base[key] = value;
90
+ }
91
+ return { base, overrides, stagger };
92
+ }
93
+ function plan(keyframes, base, overrides, offset) {
94
+ return expand(keyframes).map(([property, frames]) => {
95
+ const override = overrides[property] ?? (property.startsWith('scale') ? overrides.scale : undefined);
96
+ const transition = resolveTransition(override ? mergeTransitions(base, override) : base, property, frames.length);
97
+ transition.delay += offset;
98
+ return { property, keyframes: frames, transition };
99
+ });
100
+ }
101
+ /** Each property the animation touches, with the value it starts from when it sets one. */
102
+ export function startingValues(animation) {
103
+ const keyframes = typeof animation === 'string' ? presets[animation]?.keyframes : animation;
104
+ if (!keyframes)
105
+ throw new Error(`Unknown preset "${animation}".`);
106
+ return new Map(expand(keyframes).map(([property, [first]]) => [property, first]));
107
+ }
108
+ function expand(keyframes) {
109
+ const expanded = [];
110
+ for (const [key, value] of Object.entries(keyframes)) {
111
+ if (value === undefined)
112
+ continue;
113
+ if (key !== 'scale' && !isProperty(key))
114
+ throw new Error(`Can't animate "${key}".`);
115
+ const properties = key === 'scale' ? ['scaleX', 'scaleY'] : [key];
116
+ for (const property of properties) {
117
+ if (key === 'scale' && keyframes[property] !== undefined)
118
+ continue;
119
+ expanded.push([property, toKeyframes(property, value)]);
120
+ }
121
+ }
122
+ return expanded;
123
+ }
124
+ function toKeyframes(property, value) {
125
+ const frames = typeof value === 'number' ? [null, value] : [...value];
126
+ if (frames.length === 1)
127
+ frames.unshift(null);
128
+ if (frames.length === 0 ||
129
+ frames.some((frame) => frame !== null && !Number.isFinite(frame))) {
130
+ throw new Error(`Invalid keyframes for "${property}": ${JSON.stringify(value)}.`);
131
+ }
132
+ return frames;
133
+ }
134
+ function staggerDelay(stagger, index, count) {
135
+ if (stagger === undefined)
136
+ return 0;
137
+ const { each, from = 'first' } = typeof stagger === 'number' ? { each: stagger } : stagger;
138
+ const origin = from === 'first'
139
+ ? 0
140
+ : from === 'last'
141
+ ? count - 1
142
+ : from === 'center'
143
+ ? (count - 1) / 2
144
+ : from;
145
+ return each * Math.abs(index - origin);
146
+ }
147
+ function spring(name) {
148
+ const transition = springs[name];
149
+ if (!transition)
150
+ throw new Error(`Unknown spring "${name}".`);
151
+ return transition;
152
+ }
153
+ //# sourceMappingURL=animate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animate.js","sourceRoot":"","sources":["../src/animate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,aAAa,GAGd,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,OAAO,EAAmB,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,UAAU,EAAiB,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,OA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} from './index.js';
2
+ export declare function createAndroidDriver(): Driver;
3
+ //# sourceMappingURL=android.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../../src/driver/android.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,YAAY,CAAA;AAqB/C,wBAAgB,mBAAmB,IAAI,MAAM,CA6E5C"}
@@ -0,0 +1,73 @@
1
+ import { Utils } from '@nativescript/core';
2
+ import { after } from './index.js';
3
+ const accessors = {
4
+ opacity: { get: (v) => v.getAlpha(), set: (v, value) => v.setAlpha(value) },
5
+ x: { get: (v) => v.getTranslationX(), set: (v, value) => v.setTranslationX(value) },
6
+ y: { get: (v) => v.getTranslationY(), set: (v, value) => v.setTranslationY(value) },
7
+ scaleX: { get: (v) => v.getScaleX(), set: (v, value) => v.setScaleX(value) },
8
+ scaleY: { get: (v) => v.getScaleY(), set: (v, value) => v.setScaleY(value) },
9
+ rotate: { get: (v) => v.getRotation(), set: (v, value) => v.setRotation(value) },
10
+ rotateX: { get: (v) => v.getRotationX(), set: (v, value) => v.setRotationX(value) },
11
+ rotateY: { get: (v) => v.getRotationY(), set: (v, value) => v.setRotationY(value) },
12
+ };
13
+ const unit = (property) => property === 'x' || property === 'y' ? Utils.layout.getDisplayDensity() : 1;
14
+ export function createAndroidDriver() {
15
+ const { View } = android.view;
16
+ const nativeProperties = {
17
+ opacity: View.ALPHA,
18
+ x: View.TRANSLATION_X,
19
+ y: View.TRANSLATION_Y,
20
+ scaleX: View.SCALE_X,
21
+ scaleY: View.SCALE_Y,
22
+ rotate: View.ROTATION,
23
+ rotateX: View.ROTATION_X,
24
+ rotateY: View.ROTATION_Y,
25
+ };
26
+ const interpolator = new android.view.animation.LinearInterpolator();
27
+ return {
28
+ now: () => android.os.SystemClock.uptimeMillis(),
29
+ play(view, track, _startedAt, onEnd) {
30
+ const nativeView = view.nativeViewProtected;
31
+ const scale = unit(track.property);
32
+ const keyframes = Array.create(android.animation.Keyframe, track.values.length);
33
+ track.values.forEach((value, i) => {
34
+ keyframes[i] = android.animation.Keyframe.ofFloat(track.times[i], value * scale);
35
+ });
36
+ const holders = Array.create(android.animation.PropertyValuesHolder, 1);
37
+ holders[0] = android.animation.PropertyValuesHolder.ofKeyframe(nativeProperties[track.property], keyframes);
38
+ const animator = android.animation.ObjectAnimator.ofPropertyValuesHolder(nativeView, holders);
39
+ animator.setDuration(Math.max(track.duration, 1));
40
+ animator.setStartDelay(track.delay);
41
+ animator.setInterpolator(interpolator);
42
+ if (track.repeat > 0) {
43
+ animator.setRepeatCount(Number.isFinite(track.repeat)
44
+ ? track.repeat
45
+ : android.animation.ValueAnimator.INFINITE);
46
+ animator.setRepeatMode(track.reverse
47
+ ? android.animation.ValueAnimator.REVERSE
48
+ : android.animation.ValueAnimator.RESTART);
49
+ }
50
+ animator.addListener(new android.animation.Animator.AnimatorListener({
51
+ onAnimationStart() { },
52
+ onAnimationRepeat() { },
53
+ onAnimationCancel() { },
54
+ onAnimationEnd() {
55
+ onEnd();
56
+ },
57
+ }));
58
+ accessors[track.property].set(nativeView, track.values[0] * scale);
59
+ animator.start();
60
+ return animator;
61
+ },
62
+ stop(_view, handle) {
63
+ ;
64
+ handle.cancel();
65
+ },
66
+ presented(view, property) {
67
+ const nativeView = view.nativeViewProtected;
68
+ return nativeView ? accessors[property].get(nativeView) / unit(property) : undefined;
69
+ },
70
+ after,
71
+ };
72
+ }
73
+ //# sourceMappingURL=android.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"android.js","sourceRoot":"","sources":["../../src/driver/android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAa,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,KAAK,EAAe,MAAM,YAAY,CAAA;AAI/C,MAAM,SAAS,GAGX;IACF,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAG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OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO;oBACzC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAC5C,CAAA;YACH,CAAC;YACD,QAAQ,CAAC,WAAW,CAClB,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBAC9C,gBAAgB,KAAI,CAAC;gBACrB,iBAAiB,KAAI,CAAC;gBACtB,iBAAiB,KAAI,CAAC;gBACtB,cAAc;oBACZ,KAAK,EAAE,CAAA;gBACT,CAAC;aACF,CAAC,CACH,CAAA;YAED,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAE,GAAG,KAAK,CAAC,CAAA;YACnE,QAAQ,CAAC,KAAK,EAAE,CAAA;YAChB,OAAO,QAAQ,CAAA;QACjB,CAAC;QAED,IAAI,CAAC,KAAK,EAAE,MAAM;YAChB,CAAC;YAAC,MAA2C,CAAC,MAAM,EAAE,CAAA;QACxD,CAAC;QAED,SAAS,CAAC,IAAI,EAAE,QAAQ;YACtB,MAAM,UAAU,GAAG,IAAI,CAAC,mBAA6C,CAAA;YACrE,OAAO,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACtF,CAAC;QAED,KAAK;KACN,CAAA;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type View } from '@nativescript/core';
2
+ import type { Property } from '../properties.js';
3
+ import type { Track } from '../track.js';
4
+ export interface Driver {
5
+ /** Milliseconds, on the clock the platform's animations run on. */
6
+ now(): number;
7
+ /** Starts the track at `startedAt + track.delay` and calls `onEnd` once, however it ends. */
8
+ play(view: View, track: Track, startedAt: number, onEnd: () => void): unknown;
9
+ stop(view: View, handle: unknown): void;
10
+ /** The value on screen, when the platform knows it better than the track does. */
11
+ presented(view: View, property: Property): number | undefined;
12
+ /** Calls back after `ms` on the same clock, and returns a function that cancels it. */
13
+ after(ms: number, callback: () => void): () => void;
14
+ }
15
+ export declare function after(ms: number, callback: () => void): () => void;
16
+ export declare function getDriver(): Driver;
17
+ export declare function setDriver(next: Driver | undefined): void;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/driver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,MAAM,WAAW,MAAM;IACrB,mEAAmE;IACnE,GAAG,IAAI,MAAM,CAAA;IACb,6FAA6F;IAC7F,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,OAAO,CAAA;IAC7E,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;IACvC,kFAAkF;IAClF,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAA;IAC7D,uFAAuF;IACvF,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;CACpD;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,cAGrD;AAID,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,QAEjD"}
@@ -0,0 +1,15 @@
1
+ import { isAndroid } from '@nativescript/core';
2
+ import { createAndroidDriver } from './android.js';
3
+ import { createIOSDriver } from './ios.js';
4
+ export function after(ms, callback) {
5
+ const timer = setTimeout(callback, ms);
6
+ return () => clearTimeout(timer);
7
+ }
8
+ let driver;
9
+ export function getDriver() {
10
+ return (driver ??= isAndroid ? createAndroidDriver() : createIOSDriver());
11
+ }
12
+ export function setDriver(next) {
13
+ driver = next;
14
+ }
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/driver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAc1C,MAAM,UAAU,KAAK,CAAC,EAAU,EAAE,QAAoB;IACpD,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;IACtC,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;AAClC,CAAC;AAED,IAAI,MAA0B,CAAA;AAE9B,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAA;AAC3E,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAwB;IAChD,MAAM,GAAG,IAAI,CAAA;AACf,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type Driver } from './index.js';
2
+ export declare function createIOSDriver(): Driver;
3
+ //# sourceMappingURL=ios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/driver/ios.ts"],"names":[],"mappings":"AAEA,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,YAAY,CAAA;AA2C/C,wBAAgB,eAAe,IAAI,MAAM,CA0CxC"}