@ssgoi/core 7.0.3 → 7.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.
- package/dist/animation/animation.d.ts +4 -66
- package/dist/animation/animation.d.ts.map +1 -1
- package/dist/animation/integrator/provider.d.ts +1 -1
- package/dist/animation/integrator/provider.d.ts.map +1 -1
- package/dist/animation/web-animation.d.ts.map +1 -1
- package/dist/index.cjs +15 -15
- package/dist/index.js +1191 -1347
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +543 -707
- package/dist/multi-animation-B5hEmEgN.cjs +1 -0
- package/dist/{multi-animation-ZFZBDBGr.js → multi-animation-DyZGEfKy.js} +72 -128
- package/dist/page-motion-gH3WomQO.cjs +1 -0
- package/dist/page-motion-wmW7PW6B.js +204 -0
- package/dist/resolve-transition-rule-BL12rDDu.cjs +1 -0
- package/dist/resolve-transition-rule-DbkMu0rm.js +160 -0
- package/dist/runtime/animation.d.ts +68 -0
- package/dist/runtime/animation.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +12 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/motion-state.d.ts +25 -0
- package/dist/runtime/motion-state.d.ts.map +1 -0
- package/dist/runtime/page-motion.d.ts +27 -0
- package/dist/runtime/page-motion.d.ts.map +1 -0
- package/dist/runtime/physics.d.ts +30 -0
- package/dist/runtime/physics.d.ts.map +1 -0
- package/dist/runtime/presence.d.ts +20 -0
- package/dist/runtime/presence.d.ts.map +1 -0
- package/dist/runtime/resolve-transition-rule.d.ts +21 -0
- package/dist/runtime/resolve-transition-rule.d.ts.map +1 -0
- package/dist/runtime/timeline.d.ts +12 -0
- package/dist/runtime/timeline.d.ts.map +1 -0
- package/dist/runtime/types.d.ts +53 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime.cjs +1 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +51 -0
- package/dist/ssgoi-transition/navigation-direction.d.ts +3 -4
- package/dist/ssgoi-transition/navigation-direction.d.ts.map +1 -1
- package/dist/ssgoi-transition/path-pattern.d.ts +1 -1
- package/dist/ssgoi-transition/path-pattern.d.ts.map +1 -1
- package/dist/ssgoi-transition/resolve-transition-rule.d.ts +2 -20
- package/dist/ssgoi-transition/resolve-transition-rule.d.ts.map +1 -1
- package/dist/timeline-L_vXntmP.js +68 -0
- package/dist/timeline-Zoo1I4XU.cjs +1 -0
- package/dist/transitions/fade/transition.d.ts.map +1 -1
- package/dist/transitions/slide/transition.d.ts.map +1 -1
- package/dist/types/index.d.ts +17 -147
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -1
- package/dist/multi-animation-6124HEke.cjs +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var r = Object.defineProperty;
|
|
2
|
+
var u = (t, i, o) => i in t ? r(t, i, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[i] = o;
|
|
3
|
+
var y = (t, i, o) => u(t, typeof i != "symbol" ? i + "" : i, o);
|
|
4
|
+
let E = class {
|
|
5
|
+
constructor() {
|
|
6
|
+
/** Current playback rate (1 = realtime, 0 = paused, negative = backwards) */
|
|
7
|
+
y(this, "_playbackRate", 1);
|
|
8
|
+
/** Fired every frame with the most recent value. Optional. */
|
|
9
|
+
y(this, "onUpdate");
|
|
10
|
+
/** Fired once when the animation settles. */
|
|
11
|
+
y(this, "onComplete");
|
|
12
|
+
}
|
|
13
|
+
get playbackRate() {
|
|
14
|
+
return this._playbackRate;
|
|
15
|
+
}
|
|
16
|
+
set playbackRate(i) {
|
|
17
|
+
this._playbackRate = i;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const S = 0.01, _ = 0.01, R = 0.05, v = 1e3 / 60;
|
|
21
|
+
function b(t, i, o, c) {
|
|
22
|
+
if (i === o && c === 0) return [];
|
|
23
|
+
const p = 600;
|
|
24
|
+
let e = { position: i, velocity: c }, n = 0;
|
|
25
|
+
const s = [];
|
|
26
|
+
for (let l = 0; l < p; l++) {
|
|
27
|
+
const a = l * v;
|
|
28
|
+
if (s.push({ time: a, position: e.position, velocity: e.velocity }), e = t.step(e, o, v / 1e3), t.isSettled(e, o)) {
|
|
29
|
+
if (n += v / 1e3, n >= R) {
|
|
30
|
+
s.push({
|
|
31
|
+
time: (l + 1) * v,
|
|
32
|
+
position: o,
|
|
33
|
+
velocity: 0
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
} else
|
|
38
|
+
n = 0;
|
|
39
|
+
}
|
|
40
|
+
return s;
|
|
41
|
+
}
|
|
42
|
+
function k(t, i) {
|
|
43
|
+
"worklet";
|
|
44
|
+
if (t.length === 0) return { position: 0, velocity: 0 };
|
|
45
|
+
const o = t[0], c = t[t.length - 1];
|
|
46
|
+
if (i <= 0)
|
|
47
|
+
return { position: o.position, velocity: o.velocity };
|
|
48
|
+
if (i >= c.time)
|
|
49
|
+
return { position: c.position, velocity: c.velocity };
|
|
50
|
+
let p = 0, e = t.length - 1;
|
|
51
|
+
for (; p < e - 1; ) {
|
|
52
|
+
const a = p + e >> 1;
|
|
53
|
+
t[a].time <= i ? p = a : e = a;
|
|
54
|
+
}
|
|
55
|
+
const n = t[p], s = t[e], l = (i - n.time) / (s.time - n.time);
|
|
56
|
+
return {
|
|
57
|
+
position: n.position + (s.position - n.position) * l,
|
|
58
|
+
velocity: n.velocity + (s.velocity - n.velocity) * l
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
E as A,
|
|
63
|
+
S as P,
|
|
64
|
+
R as S,
|
|
65
|
+
_ as V,
|
|
66
|
+
k as i,
|
|
67
|
+
b as s
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var u=(t,i,o)=>i in t?r(t,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[i]=o;var y=(t,i,o)=>u(t,typeof i!="symbol"?i+"":i,o);let v=class{constructor(){y(this,"_playbackRate",1);y(this,"onUpdate");y(this,"onComplete")}get playbackRate(){return this._playbackRate}set playbackRate(i){this._playbackRate=i}};const R=.01,H=.01,E=.05,T=1e3/60;function O(t,i,o,c){if(i===o&&c===0)return[];const p=600;let e={position:i,velocity:c},n=0;const l=[];for(let s=0;s<p;s++){const a=s*T;if(l.push({time:a,position:e.position,velocity:e.velocity}),e=t.step(e,o,T/1e3),t.isSettled(e,o)){if(n+=T/1e3,n>=E){l.push({time:(s+1)*T,position:o,velocity:0});break}}else n=0}return l}function S(t,i){"worklet";if(t.length===0)return{position:0,velocity:0};const o=t[0],c=t[t.length-1];if(i<=0)return{position:o.position,velocity:o.velocity};if(i>=c.time)return{position:c.position,velocity:c.velocity};let p=0,e=t.length-1;for(;p<e-1;){const a=p+e>>1;t[a].time<=i?p=a:e=a}const n=t[p],l=t[e],s=(i-n.time)/(l.time-n.time);return{position:n.position+(l.position-n.position)*s,velocity:n.velocity+(l.velocity-n.velocity)*s}}exports.Animation=v;exports.POSITION_THRESHOLD=R;exports.SETTLE_THRESHOLD=E;exports.VELOCITY_THRESHOLD=H;exports.interpolateFrame=S;exports.simulate=O;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/fade/transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/fade/transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAa/D,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,eAAO,MAAM,IAAI,GAAI,UAAS,WAAgB,KAAG,gBAgDhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/slide/transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAO/D,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/slide/transition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAO/D,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAID,eAAO,MAAM,KAAK,GAAI,UAAS,YAAiB,KAAG,gBAgElD,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,51 +1,12 @@
|
|
|
1
|
-
import { Integrator } from '../animation/integrator';
|
|
2
1
|
import { Animation } from '../animation/animation';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
doubleSpring?: boolean | number | DoubleSpringFollowerConfig;
|
|
12
|
-
restDelta?: number;
|
|
13
|
-
restSpeed?: number;
|
|
14
|
-
};
|
|
15
|
-
export type ResistanceType = "linear" | "quadratic";
|
|
16
|
-
export type InertiaConfig = {
|
|
17
|
-
acceleration: number;
|
|
18
|
-
resistance: number;
|
|
19
|
-
resistanceType?: ResistanceType;
|
|
20
|
-
min?: number;
|
|
21
|
-
max?: number;
|
|
22
|
-
bounceStiffness?: number;
|
|
23
|
-
bounceDamping?: number;
|
|
24
|
-
restDelta?: number;
|
|
25
|
-
};
|
|
26
|
-
export type IntegratorFactory = () => Integrator;
|
|
27
|
-
export type PhysicsOptions = {
|
|
28
|
-
spring?: SpringConfig;
|
|
29
|
-
inertia?: InertiaConfig;
|
|
30
|
-
integrator?: IntegratorFactory;
|
|
31
|
-
};
|
|
32
|
-
export type Pose = {
|
|
33
|
-
/** Identity for motion matching — same DOM node across animations means
|
|
34
|
-
* the same pose. */
|
|
35
|
-
element: HTMLElement;
|
|
36
|
-
value: number;
|
|
37
|
-
velocity: number;
|
|
38
|
-
};
|
|
39
|
-
export type TimelineFrame = {
|
|
40
|
-
time: number;
|
|
41
|
-
value: number;
|
|
42
|
-
velocity: number;
|
|
43
|
-
style?: StyleObject;
|
|
44
|
-
};
|
|
45
|
-
export type Timeline = {
|
|
46
|
-
element: HTMLElement;
|
|
47
|
-
frames: TimelineFrame[];
|
|
48
|
-
};
|
|
2
|
+
import { StyleObject } from '../runtime/motion-state';
|
|
3
|
+
import { NavigationDirection } from '../runtime/types';
|
|
4
|
+
export type { StyleObject } from '../runtime/motion-state';
|
|
5
|
+
export type { DoubleSpringFollowerConfig, SpringConfig, ResistanceType, InertiaConfig, IntegratorFactory, PhysicsOptions, } from '../runtime/physics';
|
|
6
|
+
/** Existing web imports default to DOM targets; the runtime types require an explicit target. */
|
|
7
|
+
export type Pose<TTarget = HTMLElement> = import('../runtime/motion-state').Pose<TTarget>;
|
|
8
|
+
export type TimelineFrame<TStyle = StyleObject> = import('../runtime/motion-state').TimelineFrame<TStyle>;
|
|
9
|
+
export type Timeline<TTarget = HTMLElement, TStyle = StyleObject> = import('../runtime/motion-state').Timeline<TTarget, TStyle>;
|
|
49
10
|
export type ScrollOffset = {
|
|
50
11
|
x: number;
|
|
51
12
|
y: number;
|
|
@@ -54,7 +15,7 @@ export type ScrollPosition = {
|
|
|
54
15
|
x: number;
|
|
55
16
|
y: number;
|
|
56
17
|
};
|
|
57
|
-
export type NavigationDirection
|
|
18
|
+
export type { NavigationDirection } from '../runtime/types';
|
|
58
19
|
/**
|
|
59
20
|
* Context provided by the dispatcher to a transition.
|
|
60
21
|
*
|
|
@@ -132,104 +93,14 @@ export type TransitionConfig<TExtras extends object = object> = {
|
|
|
132
93
|
* extras as opaque here.
|
|
133
94
|
*/
|
|
134
95
|
export type AnyTransitionConfig = TransitionConfig<any>;
|
|
135
|
-
export type PathPatterns
|
|
136
|
-
export type
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
* Restore the forward relationship's destination when it becomes the
|
|
144
|
-
* incoming page again.
|
|
145
|
-
*/
|
|
146
|
-
to: boolean;
|
|
147
|
-
};
|
|
148
|
-
type SsgoiTransitionRuleBase = {
|
|
149
|
-
transition: AnyTransitionConfig;
|
|
150
|
-
/**
|
|
151
|
-
* Override this rule's automatic scroll-restoration policy.
|
|
152
|
-
*
|
|
153
|
-
* `from` and `to` describe the rule's semantic forward relationship, not the
|
|
154
|
-
* current navigation's physical OUT and IN pages. On backward navigation the
|
|
155
|
-
* mapping is reversed automatically.
|
|
156
|
-
*
|
|
157
|
-
* Omitted defaults:
|
|
158
|
-
* - `on`: `{ from: true, to: false }`
|
|
159
|
-
* - `from`/`to`: `{ from: true, to: false }`
|
|
160
|
-
* - `ordered`: `{ from: true, to: true }`
|
|
161
|
-
*/
|
|
162
|
-
preserveScroll?: PreserveScrollConfig;
|
|
163
|
-
/**
|
|
164
|
-
* Higher values win before path specificity. Defaults to 0.
|
|
165
|
-
* Useful for an exceptional effect declared below a broad fallback.
|
|
166
|
-
*/
|
|
167
|
-
priority?: number;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* A route-family rule. Entering the family is forward, leaving it is
|
|
171
|
-
* backward, and navigation within it uses semantic history/pop detection.
|
|
172
|
-
*/
|
|
173
|
-
export type SsgoiOnTransitionRule = SsgoiTransitionRuleBase & {
|
|
174
|
-
on: PathPatterns;
|
|
175
|
-
except?: PathPatterns;
|
|
176
|
-
from?: never;
|
|
177
|
-
to?: never;
|
|
178
|
-
ordered?: never;
|
|
179
|
-
bidirectional?: never;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* A precise relationship between two route families. The normal from → to
|
|
183
|
-
* orientation is forward; the reverse is backward when bidirectional
|
|
184
|
-
* (the default).
|
|
185
|
-
*/
|
|
186
|
-
export type SsgoiPairTransitionRule = SsgoiTransitionRuleBase & {
|
|
187
|
-
from: PathPatterns;
|
|
188
|
-
to: PathPatterns;
|
|
189
|
-
bidirectional?: boolean;
|
|
190
|
-
on?: never;
|
|
191
|
-
except?: never;
|
|
192
|
-
ordered?: never;
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* An ordered set of routes. Both endpoints must match the set; increasing
|
|
196
|
-
* index is forward and decreasing index is backward.
|
|
197
|
-
*/
|
|
198
|
-
export type SsgoiOrderedTransitionRule = SsgoiTransitionRuleBase & {
|
|
199
|
-
ordered: readonly string[];
|
|
200
|
-
on?: never;
|
|
201
|
-
except?: never;
|
|
202
|
-
from?: never;
|
|
203
|
-
to?: never;
|
|
204
|
-
bidirectional?: never;
|
|
205
|
-
};
|
|
206
|
-
export type SsgoiTransitionRule = SsgoiOnTransitionRule | SsgoiPairTransitionRule | SsgoiOrderedTransitionRule;
|
|
207
|
-
/**
|
|
208
|
-
* Argument handed to a functional `transitions` config. Destructured at the
|
|
209
|
-
* call site (`({ isMobile }) => …`) so the boolean's meaning is self-documenting
|
|
210
|
-
* — and so the object can grow more fields later without breaking signatures.
|
|
211
|
-
*/
|
|
212
|
-
export type TransitionsResolverArgs = {
|
|
213
|
-
isMobile: boolean;
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* Functional form of `transitions`: receives device context and returns the
|
|
217
|
-
* path-transition list. Lets a config branch on viewport (e.g. drawer on
|
|
218
|
-
* mobile, fade on desktop) without an outer wrapper.
|
|
219
|
-
*/
|
|
220
|
-
export type SsgoiTransitionsFn = (args: TransitionsResolverArgs) => readonly SsgoiTransitionRule[];
|
|
221
|
-
/**
|
|
222
|
-
* `transitions` accepts either a flat rule list or a function of device
|
|
223
|
-
* context. Both normalize to the functional form internally.
|
|
224
|
-
*/
|
|
225
|
-
export type SsgoiTransitionsOption = readonly SsgoiTransitionRule[] | SsgoiTransitionsFn;
|
|
226
|
-
export type SsgoiConfig = {
|
|
227
|
-
transitions?: SsgoiTransitionsOption;
|
|
228
|
-
middleware?: (from: string, to: string) => {
|
|
229
|
-
from: string;
|
|
230
|
-
to: string;
|
|
231
|
-
};
|
|
232
|
-
};
|
|
96
|
+
export type { PathPatterns, PreserveScrollConfig, TransitionsResolverArgs, } from '../runtime/types';
|
|
97
|
+
export type SsgoiOnTransitionRule = import('../runtime/types').OnRouteRule<AnyTransitionConfig>;
|
|
98
|
+
export type SsgoiPairTransitionRule = import('../runtime/types').PairRouteRule<AnyTransitionConfig>;
|
|
99
|
+
export type SsgoiOrderedTransitionRule = import('../runtime/types').OrderedRouteRule<AnyTransitionConfig>;
|
|
100
|
+
export type SsgoiTransitionRule = import('../runtime/types').RouteRule<AnyTransitionConfig>;
|
|
101
|
+
export type SsgoiTransitionsFn = import('../runtime/types').TransitionsFn<AnyTransitionConfig>;
|
|
102
|
+
export type SsgoiTransitionsOption = import('../runtime/types').TransitionsOption<AnyTransitionConfig>;
|
|
103
|
+
export type SsgoiConfig = import('../runtime/types').RouteConfig<AnyTransitionConfig>;
|
|
233
104
|
/**
|
|
234
105
|
* Adapter-facing API surface exposed by `createSsgoiTransitionContext`.
|
|
235
106
|
*
|
|
@@ -260,5 +131,4 @@ export type SsgoiContext = {
|
|
|
260
131
|
*/
|
|
261
132
|
refFor: (path: string) => (element: HTMLElement | null) => void;
|
|
262
133
|
};
|
|
263
|
-
export {};
|
|
264
134
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMxD,O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AE,WAAW,CAAC,mBAAmB,CAAC,CAAC;AAC9D,MAAM,MAAM,uBAAuB,GACjC,OAAO,kBAAkB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,0BAA0B,GACpC,OAAO,kBAAkB,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;AACnE,MAAM,MAAM,mBAAmB,GAC7B,OAAO,kBAAkB,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAC;AAC5D,MAAM,MAAM,kBAAkB,GAC5B,OAAO,kBAAkB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,sBAAsB,GAChC,OAAO,kBAAkB,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;AACpE,MAAM,MAAM,WAAW,GACrB,OAAO,kBAAkB,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAAC;AAS9D;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;OAKG;IACH,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE;QACR;;;;;;WAMG;QACH,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,KACE,IAAI,CAAC;IAEV;;;;OAIG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;CACjE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/core",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-beta.0",
|
|
4
4
|
"description": "Core animation engine for SSGOI - Native app-like page transitions with spring physics",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
"import": "./dist/internal.js",
|
|
26
26
|
"require": "./dist/internal.cjs",
|
|
27
27
|
"default": "./dist/internal.js"
|
|
28
|
+
},
|
|
29
|
+
"./runtime": {
|
|
30
|
+
"types": "./dist/runtime/index.d.ts",
|
|
31
|
+
"import": "./dist/runtime.js",
|
|
32
|
+
"require": "./dist/runtime.cjs",
|
|
33
|
+
"default": "./dist/runtime.js"
|
|
28
34
|
}
|
|
29
35
|
},
|
|
30
36
|
"files": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var F=Object.defineProperty;var b=(a,i,t)=>i in a?F(a,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[i]=t;var r=(a,i,t)=>b(a,typeof i!="symbol"?i+"":i,t);class d{constructor(){r(this,"_playbackRate",1);r(this,"onUpdate");r(this,"onComplete")}get playbackRate(){return this._playbackRate}set playbackRate(i){this._playbackRate=i}}const R=.01,T=.01,g=.05;function k(a){return new Promise(i=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{i()})})})}const w=1e3/60,y=1e3/30,C=y+1;class A{constructor(){r(this,"drivers",new Set);r(this,"observers",new Set);r(this,"frameRequest",null);r(this,"previousTimestamp",null);r(this,"tick",i=>{this.frameRequest=null;const t=this.previousTimestamp===null?w:Math.max(0,i-this.previousTimestamp);this.previousTimestamp=i;const e={delta:Math.min(t,y),rawDelta:t};this.runPhase(this.drivers,e),this.runPhase(this.observers,e),this.hasCallbacks()?this.requestFrame():this.previousTimestamp=null})}subscribe(i,t="drive"){const e=t==="drive"?this.drivers:this.observers;return e.add(i),this.requestFrame(),()=>{e.delete(i),this.stopIfIdle()}}requestFrame(){this.frameRequest!==null||!this.hasCallbacks()||(this.frameRequest=requestAnimationFrame(this.tick))}runPhase(i,t){for(const e of[...i])i.has(e)&&e(t)}hasCallbacks(){return this.drivers.size>0||this.observers.size>0}stopIfIdle(){this.hasCallbacks()||(this.frameRequest!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameRequest),this.frameRequest=null,this.previousTimestamp=null)}}const S=new A,p=1e3/60,P=2;class O extends d{constructor(t){super();r(this,"element");r(this,"integrator");r(this,"styleFn");r(this,"lowerBound");r(this,"upperBound");r(this,"currentValue");r(this,"currentVelocity",0);r(this,"frames",[]);r(this,"waapi",null);r(this,"runId",0);r(this,"waitingForStart",!1);r(this,"startReady",!1);r(this,"pendingFirstFrame");r(this,"stopStartupClock",null);r(this,"startupStableFrames",0);r(this,"running",!1);r(this,"paused",!1);r(this,"settled",!1);r(this,"reversing",!1);this.element=t.element,this.integrator=t.integrator,this.styleFn=t.style,this.lowerBound=t.lowerBound??0,this.upperBound=t.upperBound??1,this.currentValue=this.lowerBound,this.onUpdate=t.onUpdate,this.onComplete=t.onComplete}play(){if(this.reversing=!1,this.paused&&this.waapi){if(this.paused=!1,this.running=!0,this.waitingForStart){this.startReady&&this.startFramePacedPlayback(this.waapi);return}this.waapi.play();return}this.runToward(this.upperBound)}reverse(){this.reversing=!0,this.runToward(this.lowerBound)}pause(){var t,e;this.running&&(this.captureLiveState(),(t=this.waapi)==null||t.pause(),(e=this.stopStartupClock)==null||e.call(this),this.stopStartupClock=null,this.running=!1,this.paused=!0)}complete(){var t;this.clearWaapi(),this.running=!1,this.paused=!1,this.currentValue=this.upperBound,this.currentVelocity=0,this.applyStyleAt(this.currentValue),this.settled=!0,(t=this.onComplete)==null||t.call(this)}releaseFill(){this.clearWaapi()}get isAnimating(){return this.running}get isPaused(){return this.paused}get isComplete(){return this.settled}get isReversing(){return this.reversing}get progress(){this.running&&this.captureLiveState();const t=this.upperBound-this.lowerBound;if(t===0)return 0;const e=(this.currentValue-this.lowerBound)/t;return e<0?0:e>1?1:e}findTimeForProgress(t){if(this.frames.length<2)return null;const e=this.upperBound-this.lowerBound;if(e===0)return 0;for(const s of this.frames)if((s.position-this.lowerBound)/e>=t)return s.time;return this.frames[this.frames.length-1].time}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.waapi&&(this.waapi.playbackRate=t)}getPose(){return this.running&&this.captureLiveState(),[{element:this.element,value:this.currentValue,velocity:this.currentVelocity}]}getTimeline(){const t=this.frames.map(e=>{const s=e.position,n=this.lowerBound+this.upperBound-s;return{time:e.time,value:e.position,velocity:e.velocity,style:this.styleFn(s,n)}});return[{element:this.element,frames:t}]}matchInto(t){const e=t.find(s=>s.element===this.element);e&&(this.currentValue=e.value,this.currentVelocity=e.velocity)}runToward(t){var o;if(this.running&&this.captureLiveState(),this.clearWaapi(),this.running=!1,this.paused=!1,this.settled=!1,this.frames=B(this.integrator,this.currentValue,t,this.currentVelocity),this.frames.length===0){this.currentValue=t,this.currentVelocity=0,this.applyStyleAt(t),this.settled=!0,(o=this.onComplete)==null||o.call(this);return}const e=this.frames.map(c=>{const m=c.position,v=this.lowerBound+this.upperBound-m;return this.styleFn(m,v)}),s=e[0],n=this.frames[this.frames.length-1],h=n.time,u=++this.runId,l=this.element.animate(e,{duration:h,fill:"both",easing:"linear",composite:"replace"});l.playbackRate=this.playbackRate,l.currentTime=0,l.pause(),this.waapi=l,this.waitingForStart=!0,this.startReady=!1,this.pendingFirstFrame=s,this.running=!0,l.onfinish=()=>{var c;!this.running||this.waapi!==l||(this.running=!1,this.settled=!0,this.currentValue=n.position,this.currentVelocity=0,(c=this.onComplete)==null||c.call(this))},this.startWhenReady(l,u)}clearWaapi(){var t,e;this.runId++,(t=this.waapi)==null||t.cancel(),this.waapi=null,this.waitingForStart=!1,this.startReady=!1,this.pendingFirstFrame=void 0,(e=this.stopStartupClock)==null||e.call(this),this.stopStartupClock=null,this.startupStableFrames=0}captureLiveState(){if(this.frames.length===0)return;const t=f(this.waapi);if(t===null)return;const{position:e,velocity:s}=E(this.frames,t);this.currentValue=e,this.currentVelocity=s}async startWhenReady(t,e){try{await t.ready,typeof requestAnimationFrame<"u"&&await k(this.element)}catch{return}this.runId!==e||this.waapi!==t||(this.startReady=!0,!(!this.running||this.paused)&&this.startFramePacedPlayback(t))}startFramePacedPlayback(t){if(!(this.waapi!==t||!this.waitingForStart||!this.startReady||this.stopStartupClock)){if(this.pendingFirstFrame)for(const e of Object.keys(this.pendingFirstFrame))this.element.style[e]="";if(this.pendingFirstFrame=void 0,typeof requestAnimationFrame>"u"||this.playbackRate<0){this.handOffToWaapi(t);return}this.startupStableFrames=0,this.stopStartupClock=S.subscribe(e=>{this.advanceFramePacedStartup(t,e)})}}advanceFramePacedStartup(t,e){if(this.waapi!==t||!this.running||this.paused||!this.waitingForStart)return;const s=this.frames[this.frames.length-1];if(!s)return;const n=f(t)??0,h=Math.min(s.time,n+e.delta*Math.max(0,this.playbackRate));if(t.currentTime=h,this.captureLiveState(),h>=s.time){this.finishFramePacedRun(t,s);return}e.rawDelta<=C?this.startupStableFrames++:this.startupStableFrames=0,!(this.startupStableFrames<P)&&this.handOffToWaapi(t)}handOffToWaapi(t){var e;this.waapi!==t||!this.running||this.paused||((e=this.stopStartupClock)==null||e.call(this),this.stopStartupClock=null,this.waitingForStart=!1,this.startReady=!1,this.startupStableFrames=0,t.play())}finishFramePacedRun(t,e){var s,n;this.waapi!==t||!this.running||((s=this.stopStartupClock)==null||s.call(this),this.stopStartupClock=null,this.waitingForStart=!1,this.startReady=!1,this.startupStableFrames=0,this.running=!1,this.settled=!0,this.currentValue=e.position,this.currentVelocity=0,(n=this.onComplete)==null||n.call(this))}applyStyleAt(t){const e=this.lowerBound+this.upperBound-t,s=this.styleFn(t,e);for(const[n,h]of Object.entries(s))this.element.style[n]=typeof h=="number"?String(h):h}}function B(a,i,t,e){if(i===t&&e===0)return[];const s=600;let n={position:i,velocity:e},h=0;const u=[];for(let l=0;l<s;l++){const o=l*p;if(u.push({time:o,position:n.position,velocity:n.velocity}),n=a.step(n,t,p/1e3),a.isSettled(n,t)){if(h+=p/1e3,h>=g){u.push({time:(l+1)*p,position:t,velocity:0});break}}else h=0}return u}function E(a,i){if(a.length===0)return{position:0,velocity:0};const t=a[0],e=a[a.length-1];if(i<=0)return{position:t.position,velocity:t.velocity};if(i>=e.time)return{position:e.position,velocity:e.velocity};let s=0,n=a.length-1;for(;s<n-1;){const o=s+n>>1;a[o].time<=i?s=o:n=o}const h=a[s],u=a[n],l=(i-h.time)/(u.time-h.time);return{position:h.position+(u.position-h.position)*l,velocity:h.velocity+(u.velocity-h.velocity)*l}}function f(a){const i=a==null?void 0:a.currentTime;return typeof i=="number"?i:null}class _ extends d{constructor(t,e={}){super();r(this,"children");r(this,"startAt");r(this,"pendingComplete",0);r(this,"running",!1);r(this,"pendingStartObservers",[]);this.children=t,(e.mode??"parallel")==="sequence"?this.startAt=t.map((s,n)=>n===0?0:1):this.startAt=e.startAt??[]}play(){this.startRun("play")}reverse(){this.startRun("reverse")}pause(){this.running=!1,this.clearPendingStartObservers();for(const t of this.children)t.pause()}complete(){var t;this.running=!1,this.clearPendingStartObservers();for(const e of this.children)e.complete();(t=this.onComplete)==null||t.call(this)}get progress(){if(this.children.length===0)return 0;let t=0;for(const e of this.children)t+=e.progress;return t/this.children.length}getPose(){return this.children.flatMap(t=>t.getPose())}getTimeline(){return this.children.flatMap(t=>t.getTimeline())}matchInto(t){}get isAnimating(){return this.children.some(t=>t.isAnimating)}get isPaused(){return this.children.some(t=>t.isPaused)&&this.children.every(t=>t.isPaused||t.isComplete)}get isComplete(){return this.children.every(t=>t.isComplete)}get isReversing(){return this.children.some(t=>t.isReversing)}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t;for(const e of this.children)e.playbackRate=t}startRun(t){if(this.running&&this.pause(),this.running=!0,this.pendingComplete=this.children.length,this.pendingComplete===0){this.handleFinished();return}for(const e of this.children){const s=e.onComplete;e.onComplete=()=>{s==null||s(),this.handleChildComplete()}}this.scheduleStart(0,t)}scheduleStart(t,e){if(!this.running||t>=this.children.length)return;this.children[t][e]();const s=t+1;if(s>=this.children.length)return;const n=this.startAt[s];if(n===void 0||n<=0){this.scheduleStart(s,e);return}const h=this.children[t];if(this.hasReachedThreshold(h,n,e)){this.scheduleStart(s,e);return}const u=S.subscribe(()=>{this.running&&this.hasReachedThreshold(h,n,e)&&(u(),this.pendingStartObservers=this.pendingStartObservers.filter(l=>l!==u),this.scheduleStart(s,e))},"observe");this.pendingStartObservers.push(u)}hasReachedThreshold(t,e,s){return t.isComplete?!0:(s==="play"?t.progress:1-t.progress)>=e}clearPendingStartObservers(){for(const t of this.pendingStartObservers)t();this.pendingStartObservers=[]}handleChildComplete(){this.pendingComplete--,this.pendingComplete<=0&&this.handleFinished()}handleFinished(){var t;this.running=!1,this.clearPendingStartObservers(),(t=this.onComplete)==null||t.call(this)}findTimeForProgress(t){return null}}exports.Animation=d;exports.MultiAnimation=_;exports.POSITION_THRESHOLD=R;exports.SETTLE_THRESHOLD=g;exports.VELOCITY_THRESHOLD=T;exports.WebAnimation=O;
|