@weasel-js/core 1.7.3 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/dist/animation/colorHelpers.js +58 -58
- package/dist/animation/colorHelpers.js.map +1 -1
- package/dist/animation/engine/axes.js +36 -0
- package/dist/animation/engine/axes.js.map +1 -0
- package/dist/animation/engine/codec.js +170 -0
- package/dist/animation/engine/codec.js.map +1 -0
- package/dist/animation/engine/integrator.js +12 -0
- package/dist/animation/engine/integrator.js.map +1 -0
- package/dist/animation/useAnimator.js +209 -160
- package/dist/animation/useAnimator.js.map +1 -1
- package/dist/{builtins-C-gRyVRx.d.ts → builtins-CMEh6-Oc.d.ts} +81 -8
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +12 -12
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
- package/dist/canvas/pickWalk.js +2 -2
- package/dist/canvas/pickWalk.js.map +1 -1
- package/dist/canvas/sceneSlotWiring.js +1 -1
- package/dist/canvas/sceneSlotWiring.js.map +1 -1
- package/dist/canvas/sceneViewRender.js +1 -1
- package/dist/canvas/sceneViewRender.js.map +1 -1
- package/dist/core/scene/effectivePose.js +1 -1
- package/dist/core/scene/effectivePose.js.map +1 -1
- package/dist/core/scene/poseOverrides.js +42 -22
- package/dist/core/scene/poseOverrides.js.map +1 -1
- package/dist/core/scene/scene.js +9 -0
- package/dist/core/scene/scene.js.map +1 -1
- package/dist/core/scene/types.js.map +1 -1
- package/dist/core/selection/useSelection.js +27 -33
- package/dist/core/selection/useSelection.js.map +1 -1
- package/dist/core/stableStringify.js +8 -0
- package/dist/core/stableStringify.js.map +1 -0
- package/dist/index.d.ts +35 -25
- package/dist/index.js +269 -268
- package/dist/renderer/WeaselRenderer.js +4 -1
- package/dist/renderer/WeaselRenderer.js.map +1 -1
- package/dist/renderer/batchClip.js +46 -0
- package/dist/renderer/batchClip.js.map +1 -0
- package/dist/renderer/draw.js +367 -294
- package/dist/renderer/draw.js.map +1 -1
- package/dist/renderer/drawBatch.js +75 -45
- package/dist/renderer/drawBatch.js.map +1 -1
- package/dist/renderer/shaders/batchFill.js +3 -2
- package/dist/renderer/shaders/batchFill.js.map +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/tools/builtin/text/useTextTool.js +8 -8
- package/dist/tools/builtin/text/useTextTool.js.map +1 -1
- package/dist/tools/prefs.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +17 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrator.js","names":["stepSpring","ref","target","value","displacement","ops","springForce","k","dampingForce","velocity","damping","accel","mass","v","dt"],"sources":["../../../src/animation/engine/integrator.ts"],"sourcesContent":["export interface VectorOps<T> {\n add(a: T, b: T): T;\n subtract(a: T, b: T): T;\n scale(v: T, k: number): T;\n}\n\n/** One semi-implicit Euler step of a damped spring toward `target`, or of pure damping when\n * `target` is null. Returns the new value and velocity. */\nexport function stepSpring<T>(\n ops: VectorOps<T>,\n value: T, velocity: T, target: T | null,\n k: number, damping: number, mass: number, dt: number,\n): { value: T; velocity: T } {\n const ref = target ?? value;\n const displacement = ops.subtract(value, ref);\n const springForce = ops.scale(displacement, target == null ? 0 : -k);\n const dampingForce = ops.scale(velocity, -damping);\n const accel = ops.scale(ops.add(springForce, dampingForce), 1 / mass);\n const v = ops.add(velocity, ops.scale(accel, dt));\n return { value: ops.add(value, ops.scale(v, dt)), velocity: v };\n}\n"],"mappings":";AAQA,SAAgBA,EACd,GACA,GAAU,GAAa,GACvB,GAAW,GAAiB,GAAc,GACf;CAC3B,IAAMC,IAAMC,KAAUC,GAChBC,IAAeC,EAAI,SAASF,GAAOF,CAAG,GACtCK,IAAcD,EAAI,MAAMD,GAAcF,KAAU,OAAO,IAAI,CAACK,CAAC,GAC7DC,IAAeH,EAAI,MAAMI,GAAU,CAACC,CAAO,GAC3CC,IAAQN,EAAI,MAAMA,EAAI,IAAIC,GAAaE,CAAY,GAAG,IAAII,CAAI,GAC9DC,IAAIR,EAAI,IAAII,GAAUJ,EAAI,MAAMM,GAAOG,CAAE,CAAC;CAChD,OAAO;EAAE,OAAOT,EAAI,IAAIF,GAAOE,EAAI,MAAMQ,GAAGC,CAAE,CAAC;EAAG,UAAUD;CAAE;AAChE"}
|
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
import { useVisibleRaf as e } from "../scheduling/useVisibleRaf.js";
|
|
2
2
|
import { createLoop as t, createTweenLoop as n } from "./loop.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { stepSpring as r } from "./engine/integrator.js";
|
|
4
|
+
import { createCodec as i } from "./engine/codec.js";
|
|
5
|
+
import { axesOf as a } from "./engine/axes.js";
|
|
6
|
+
import { createStagger as o } from "./stagger.js";
|
|
7
|
+
import { createTimeline as s } from "./timeline/createTimeline.js";
|
|
8
|
+
import { ColorOverrideRegistry as c } from "./colorRegistry.js";
|
|
9
|
+
import { AnimatorEventHub as l } from "./observe.js";
|
|
10
|
+
import { SPRING_PRESETS as u, easeOut as d, resolveEasing as f } from "@weasel-js/geom";
|
|
11
|
+
import { useCallback as p, useEffect as m, useInsertionEffect as h, useMemo as g, useRef as _ } from "react";
|
|
12
|
+
import { useLatest as v } from "@weasel-js/react";
|
|
10
13
|
//#region src/animation/useAnimator.ts
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let t = e.preset ? s[e.preset] : null;
|
|
14
|
+
function y(e) {
|
|
15
|
+
let t = e.preset ? u[e.preset] : null;
|
|
14
16
|
return {
|
|
15
17
|
stiffness: e.stiffness ?? t?.stiffness ?? 170,
|
|
16
18
|
damping: e.damping ?? t?.damping ?? 26,
|
|
17
19
|
mass: e.mass ?? t?.mass ?? 1
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
|
-
function
|
|
21
|
-
let
|
|
22
|
-
|
|
22
|
+
function b(u = {}) {
|
|
23
|
+
let b = v(u), x = _(/* @__PURE__ */ new Map()), S = _(1), C = _(0), w = _(null), T = _(1), E = _(!1), D = _(new c()), O = _(/* @__PURE__ */ new Set()), k = _(null), A = e(p((e) => {
|
|
24
|
+
k.current?.(e);
|
|
23
25
|
}, []), {
|
|
24
|
-
requestFrame:
|
|
25
|
-
cancelFrame:
|
|
26
|
+
requestFrame: u.requestFrame,
|
|
27
|
+
cancelFrame: u.cancelFrame,
|
|
26
28
|
onResume: () => {
|
|
27
|
-
for (let e of
|
|
29
|
+
for (let e of x.current.values()) e.lastRealNow = null;
|
|
30
|
+
w.current = null;
|
|
28
31
|
}
|
|
29
|
-
}),
|
|
30
|
-
let e = () => (
|
|
31
|
-
setTimer: (e, t) => (
|
|
32
|
-
clearTimer: (e) => (
|
|
32
|
+
}), j = v(A), M = _(!0), N = _(!1), P = () => !M.current && (N.current || (N.current = !0, (typeof process > "u" || process.env.NODE_ENV !== "production") && console.error("weasel useAnimator: animation tick fired after the host component unmounted. This usually means cleanup logic was bypassed — check for refactors that removed the unmount effect or replaced cancelAll with a custom path.")), !0), { api: F, tickAll: I } = g(() => {
|
|
33
|
+
let e = () => (b.current.now ?? (typeof performance < "u" ? performance.now.bind(performance) : Date.now))(), c = {
|
|
34
|
+
setTimer: (e, t) => (b.current.setTimer ?? ((e, t) => setTimeout(e, t)))(e, t),
|
|
35
|
+
clearTimer: (e) => (b.current.clearTimer ?? ((e) => clearTimeout(e)))(e),
|
|
33
36
|
now: e
|
|
34
|
-
},
|
|
35
|
-
let t =
|
|
37
|
+
}, u = /* @__PURE__ */ new Map(), p = (e) => {
|
|
38
|
+
let t = u.get(e);
|
|
36
39
|
if (t) {
|
|
37
|
-
|
|
40
|
+
u.delete(e);
|
|
38
41
|
for (let e of t) e();
|
|
39
42
|
}
|
|
40
|
-
},
|
|
41
|
-
let n =
|
|
42
|
-
return n.push(t),
|
|
43
|
-
let n =
|
|
43
|
+
}, m = (e, t) => {
|
|
44
|
+
let n = u.get(e) ?? [];
|
|
45
|
+
return n.push(t), u.set(e, n), () => {
|
|
46
|
+
let n = u.get(e);
|
|
44
47
|
if (!n) return;
|
|
45
48
|
let r = n.indexOf(t);
|
|
46
|
-
r >= 0 && n.splice(r, 1), n.length === 0 &&
|
|
49
|
+
r >= 0 && n.splice(r, 1), n.length === 0 && u.delete(e);
|
|
47
50
|
};
|
|
48
|
-
},
|
|
51
|
+
}, h = new l(), g = i(), _ = (e) => {
|
|
49
52
|
if (!e.info) {
|
|
50
53
|
let t = {
|
|
51
54
|
id: e.id,
|
|
@@ -54,73 +57,83 @@ function v(s = {}) {
|
|
|
54
57
|
e.cancelKey != null && (t.key = e.cancelKey), e.label != null && (t.label = e.label), e.info = t;
|
|
55
58
|
}
|
|
56
59
|
return e.info;
|
|
57
|
-
},
|
|
58
|
-
let t =
|
|
59
|
-
t && !t.ended && (t.ended = !0,
|
|
60
|
+
}, v = (e) => {
|
|
61
|
+
let t = x.current.get(e);
|
|
62
|
+
t && !t.ended && (t.ended = !0, h.watched && h.emit({
|
|
60
63
|
type: "end",
|
|
61
|
-
animation:
|
|
64
|
+
animation: _(t)
|
|
62
65
|
}));
|
|
63
|
-
},
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
+
}, k = (e, t, n) => {
|
|
67
|
+
let r = x.current.get(e);
|
|
68
|
+
r && (r.onCancel?.(), g.stop(e), x.current.delete(e), p(e), !(!h.watched || r.ended || n) && h.emit(t ? {
|
|
66
69
|
type: "interrupt",
|
|
67
|
-
animation:
|
|
68
|
-
by:
|
|
70
|
+
animation: _(r),
|
|
71
|
+
by: _(t)
|
|
69
72
|
} : {
|
|
70
73
|
type: "cancel",
|
|
71
|
-
animation:
|
|
74
|
+
animation: _(r)
|
|
72
75
|
}));
|
|
73
|
-
},
|
|
74
|
-
let t = [];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
}, A = (e) => {
|
|
77
|
+
let t = [], n = [], r = w.current == null ? 0 : Math.max(0, e - w.current);
|
|
78
|
+
w.current = e, g.frame(r * (E.current ? 0 : T.current));
|
|
79
|
+
for (let r of x.current.values()) {
|
|
80
|
+
let i = r.lastRealNow == null ? 0 : Math.max(0, e - r.lastRealNow);
|
|
81
|
+
r.lastRealNow = e;
|
|
82
|
+
let a = E.current ? 0 : T.current * (r.paused ? 0 : r.timeScale);
|
|
83
|
+
r.virtualNow += i * a, C.current += 1;
|
|
80
84
|
try {
|
|
81
|
-
|
|
85
|
+
r.tick(r.virtualNow, a) && t.push(r);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
n.push([r, e]);
|
|
82
88
|
} finally {
|
|
83
|
-
--
|
|
89
|
+
--C.current;
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
|
-
for (let e of t)
|
|
87
|
-
|
|
92
|
+
for (let [e, t] of n) console.error("useAnimator: animation tick threw; retiring it", t), x.current.get(e.id) === e && (e.ended ? (x.current.delete(e.id), p(e.id)) : k(e.id, void 0, !0), h.watched && h.emit({
|
|
93
|
+
type: "error",
|
|
94
|
+
animation: _(e),
|
|
95
|
+
error: t
|
|
96
|
+
}));
|
|
97
|
+
for (let e of t) x.current.get(e.id) === e && (v(e.id), x.current.delete(e.id), p(e.id));
|
|
98
|
+
for (let e of O.current) try {
|
|
88
99
|
e();
|
|
89
100
|
} catch (e) {
|
|
90
101
|
console.error("useAnimator: onTick subscriber threw", e);
|
|
91
102
|
}
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
},
|
|
103
|
+
x.current.size > 0 ? j.current.request() : w.current = null;
|
|
104
|
+
}, M = () => {
|
|
105
|
+
x.current.size !== 0 && j.current.request();
|
|
106
|
+
}, N = (e, t) => {
|
|
96
107
|
let n = [];
|
|
97
|
-
for (let t of
|
|
98
|
-
for (let e of n)
|
|
99
|
-
},
|
|
108
|
+
for (let t of x.current.values()) t.cancelKey === e && n.push(t.id);
|
|
109
|
+
for (let e of n) k(e, t);
|
|
110
|
+
}, F = (e) => {
|
|
111
|
+
g.has(e.id) && g.rate(e.id, e.paused ? 0 : e.timeScale);
|
|
112
|
+
}, I = (t) => {
|
|
100
113
|
let n = t;
|
|
101
|
-
return t.cancelKey != null && !t.keepExisting &&
|
|
114
|
+
return t.cancelKey != null && !t.keepExisting && N(t.cancelKey, n), n.paused = !1, n.timeScale = 1, n.virtualNow = 0, n.lastRealNow = e(), x.current.set(n.id, n), h.watched && h.emit({
|
|
102
115
|
type: "start",
|
|
103
|
-
animation:
|
|
104
|
-
}),
|
|
116
|
+
animation: _(n)
|
|
117
|
+
}), M(), {
|
|
105
118
|
id: n.id,
|
|
106
|
-
cancel: () =>
|
|
119
|
+
cancel: () => k(n.id),
|
|
107
120
|
pause: () => {
|
|
108
|
-
let e =
|
|
109
|
-
e && (e.paused = !0);
|
|
121
|
+
let e = x.current.get(n.id);
|
|
122
|
+
e && (e.paused = !0, F(e));
|
|
110
123
|
},
|
|
111
124
|
resume: () => {
|
|
112
|
-
let e =
|
|
113
|
-
e && (e.paused = !1);
|
|
125
|
+
let e = x.current.get(n.id);
|
|
126
|
+
e && (e.paused = !1, F(e));
|
|
114
127
|
},
|
|
115
128
|
setTimeScale: (e) => {
|
|
116
|
-
let t =
|
|
117
|
-
t && (t.timeScale = e);
|
|
129
|
+
let t = x.current.get(n.id);
|
|
130
|
+
t && (t.timeScale = e, F(t));
|
|
118
131
|
},
|
|
119
|
-
timeScale: () =>
|
|
120
|
-
isPaused: () =>
|
|
132
|
+
timeScale: () => x.current.get(n.id)?.timeScale ?? 1,
|
|
133
|
+
isPaused: () => x.current.get(n.id)?.paused ?? !1
|
|
121
134
|
};
|
|
122
|
-
},
|
|
123
|
-
let r =
|
|
135
|
+
}, L = ({ kind: e, cancelKey: t, label: n }) => {
|
|
136
|
+
let r = S.current++, i, a = I({
|
|
124
137
|
id: r,
|
|
125
138
|
kind: e,
|
|
126
139
|
cancelKey: t,
|
|
@@ -140,61 +153,97 @@ function v(s = {}) {
|
|
|
140
153
|
i = e;
|
|
141
154
|
},
|
|
142
155
|
finish: () => {
|
|
143
|
-
|
|
156
|
+
x.current.has(r) && (v(r), x.current.delete(r), p(r));
|
|
144
157
|
},
|
|
145
158
|
cancelKey: t
|
|
146
159
|
};
|
|
147
|
-
},
|
|
148
|
-
let
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
id:
|
|
160
|
+
}, R = (t) => {
|
|
161
|
+
let n = t.interpolate || t.interpolator ? null : a(t.from), r = n && a(t.to), i = n && r && r.shape === n.shape ? n : null;
|
|
162
|
+
if (!i && !t.interpolate && !t.interpolator) throw Error("tween: interpolate or interpolator is required for non-numeric T");
|
|
163
|
+
let o = S.current++, s = f(t.easing ?? d), c = t.interpolator ? t.interpolator(t.from, t.to) : null, l = !1;
|
|
164
|
+
w.current ??= e();
|
|
165
|
+
let u = g.tween({
|
|
166
|
+
id: o,
|
|
167
|
+
ms: Math.max(t.ms, 1),
|
|
168
|
+
ease: s,
|
|
169
|
+
from: i ? i.to(t.from) : [0],
|
|
170
|
+
to: i ? i.to(t.to) : [1]
|
|
171
|
+
});
|
|
172
|
+
return I({
|
|
173
|
+
id: o,
|
|
154
174
|
kind: "tween",
|
|
155
|
-
cancelKey:
|
|
156
|
-
label:
|
|
157
|
-
progress: (
|
|
158
|
-
tick(
|
|
159
|
-
if (
|
|
160
|
-
let
|
|
161
|
-
|
|
175
|
+
cancelKey: t.cancelKey,
|
|
176
|
+
label: t.label,
|
|
177
|
+
progress: (e) => t.ms <= 0 ? 1 : Math.min(1, e / t.ms),
|
|
178
|
+
tick(e) {
|
|
179
|
+
if (P()) return g.stop(o), !0;
|
|
180
|
+
let n = t.ms <= 0 ? 1 : Math.min(1, e / t.ms), r;
|
|
181
|
+
if (i) r = n >= 1 ? t.to : i.from(u.cols, u.at);
|
|
182
|
+
else {
|
|
183
|
+
let e = n >= 1 ? s(1) : u.cols[u.at];
|
|
184
|
+
r = c ? c(e) : t.interpolate(t.from, t.to, e);
|
|
185
|
+
}
|
|
186
|
+
return t.onTick(r), n >= 1 && !l && (l = !0, g.stop(o), x.current.has(o) && (v(o), t.onDone?.()), !0);
|
|
162
187
|
}
|
|
163
188
|
});
|
|
164
|
-
},
|
|
165
|
-
let
|
|
166
|
-
if (typeof
|
|
167
|
-
let
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
189
|
+
}, z = (t, n = "physics") => {
|
|
190
|
+
let i = S.current++;
|
|
191
|
+
if (typeof t.from != "number" && (!t.add || !t.subtract || !t.scale || !t.magnitude)) throw Error("physics: add/subtract/scale/magnitude are required for non-numeric T");
|
|
192
|
+
let o = t.add ?? ((e, t) => e + t), s = t.subtract ?? ((e, t) => e - t), c = t.scale ?? ((e, t) => e * t), l = t.magnitude ?? ((e) => Math.abs(e)), { stiffness: u, damping: d, mass: f } = y(t), p = t.restThreshold ?? .01, m = t.to ?? null, h = t.from, _ = t.velocity ?? c(t.from, 0), b = null, x = d > 0 && f > 0 && (u > 0 || n === "decay") ? a(t.from) : null, C = (e) => e == null || a(e)?.shape === x.shape, T = x && C(t.to) && C(t.velocity) ? x : null, E = null;
|
|
193
|
+
T && (w.current ??= e(), E = g.spring({
|
|
194
|
+
id: i,
|
|
195
|
+
axes: T.count,
|
|
196
|
+
from: T.to(t.from),
|
|
197
|
+
to: t.to == null ? null : T.to(t.to),
|
|
198
|
+
velocity: t.velocity == null ? Array(T.count).fill(0) : T.to(t.velocity),
|
|
199
|
+
stiffness: u,
|
|
200
|
+
damping: d,
|
|
201
|
+
mass: f
|
|
202
|
+
}));
|
|
203
|
+
let D = I({
|
|
204
|
+
id: i,
|
|
205
|
+
kind: n,
|
|
206
|
+
cancelKey: t.cancelKey,
|
|
207
|
+
label: t.label,
|
|
208
|
+
tick(e) {
|
|
209
|
+
if (P()) return g.stop(i), !0;
|
|
210
|
+
if (b == null) {
|
|
211
|
+
if (b = e, m == null && l(_) < p) return g.stop(i), v(i), t.onDone?.(), !0;
|
|
212
|
+
if (!T) return t.onTick(h), !1;
|
|
213
|
+
}
|
|
214
|
+
if (T) {
|
|
215
|
+
let e = E.motion();
|
|
216
|
+
h = T.from(e.value), _ = T.from(e.velocity);
|
|
217
|
+
} else {
|
|
218
|
+
let t = Math.min(.064, (e - b) / 1e3), n = r({
|
|
219
|
+
add: o,
|
|
220
|
+
subtract: s,
|
|
221
|
+
scale: c
|
|
222
|
+
}, h, _, m, u, d, f, t);
|
|
223
|
+
h = n.value, _ = n.velocity;
|
|
183
224
|
}
|
|
184
|
-
|
|
225
|
+
b = e, t.onTick(h);
|
|
226
|
+
let n = l(_) < p, a = m == null || l(s(h, m)) < p;
|
|
227
|
+
return n && a ? (m != null && t.onTick(m), g.stop(i), v(i), t.onDone?.(), !0) : !1;
|
|
228
|
+
}
|
|
229
|
+
}), O = (e, t) => {
|
|
230
|
+
if (!C(e)) throw Error(`physics: ${t} is not the same shape as \`from\``);
|
|
231
|
+
};
|
|
232
|
+
return {
|
|
233
|
+
...D,
|
|
185
234
|
setTarget: (e) => {
|
|
186
|
-
|
|
235
|
+
T && e != null && O(e, "setTarget"), m = e, T && g.has(i) && g.retarget(i, e == null ? null : T.to(e));
|
|
187
236
|
},
|
|
188
237
|
setVelocity: (e) => {
|
|
189
|
-
|
|
238
|
+
T && O(e, "setVelocity"), _ = e, T && g.has(i) && g.push(i, T.to(e));
|
|
190
239
|
}
|
|
191
240
|
};
|
|
192
|
-
},
|
|
193
|
-
tween:
|
|
194
|
-
spring: (e) =>
|
|
241
|
+
}, B = {
|
|
242
|
+
tween: R,
|
|
243
|
+
spring: (e) => z(e, "spring"),
|
|
195
244
|
decay: (e) => {
|
|
196
245
|
let t = e.friction ?? .95, n = -Math.log(t);
|
|
197
|
-
return
|
|
246
|
+
return z({
|
|
198
247
|
from: e.from,
|
|
199
248
|
to: null,
|
|
200
249
|
velocity: e.velocity,
|
|
@@ -212,61 +261,61 @@ function v(s = {}) {
|
|
|
212
261
|
label: e.label
|
|
213
262
|
}, "decay");
|
|
214
263
|
},
|
|
215
|
-
physics:
|
|
216
|
-
cancel: (e) =>
|
|
217
|
-
cancelKey: (e) =>
|
|
264
|
+
physics: z,
|
|
265
|
+
cancel: (e) => k(e.id),
|
|
266
|
+
cancelKey: (e) => N(e),
|
|
218
267
|
cancelAll: () => {
|
|
219
268
|
let e = [];
|
|
220
|
-
for (let t of
|
|
221
|
-
|
|
222
|
-
for (let t of e)
|
|
223
|
-
if (
|
|
269
|
+
for (let t of x.current.values()) t.onCancel?.(), g.stop(t.id), e.push(t);
|
|
270
|
+
x.current.clear(), w.current = null;
|
|
271
|
+
for (let t of e) p(t.id);
|
|
272
|
+
if (h.watched) for (let t of e) h.emit({
|
|
224
273
|
type: "cancel",
|
|
225
|
-
animation:
|
|
274
|
+
animation: _(t)
|
|
226
275
|
});
|
|
227
|
-
|
|
276
|
+
j.current.cancel();
|
|
228
277
|
},
|
|
229
278
|
isActive: (e) => {
|
|
230
|
-
if (e == null) return
|
|
231
|
-
for (let t of
|
|
279
|
+
if (e == null) return x.current.size > 0;
|
|
280
|
+
for (let t of x.current.values()) if (t.cancelKey === e) return !0;
|
|
232
281
|
return !1;
|
|
233
282
|
},
|
|
234
|
-
isTicking: () =>
|
|
283
|
+
isTicking: () => C.current > 0,
|
|
235
284
|
pause: () => {
|
|
236
|
-
|
|
285
|
+
E.current = !0;
|
|
237
286
|
},
|
|
238
287
|
resume: () => {
|
|
239
|
-
|
|
288
|
+
E.current = !1;
|
|
240
289
|
},
|
|
241
|
-
isPaused: () =>
|
|
290
|
+
isPaused: () => E.current,
|
|
242
291
|
setTimeScale: (e) => {
|
|
243
|
-
|
|
292
|
+
T.current = e;
|
|
244
293
|
},
|
|
245
|
-
timeScale: () =>
|
|
294
|
+
timeScale: () => T.current,
|
|
246
295
|
pauseKey: (e) => {
|
|
247
|
-
for (let t of
|
|
296
|
+
for (let t of x.current.values()) t.cancelKey === e && (t.paused = !0, F(t));
|
|
248
297
|
},
|
|
249
298
|
resumeKey: (e) => {
|
|
250
|
-
for (let t of
|
|
299
|
+
for (let t of x.current.values()) t.cancelKey === e && (t.paused = !1, F(t));
|
|
251
300
|
},
|
|
252
301
|
setTimeScaleByKey: (e, t) => {
|
|
253
|
-
for (let n of
|
|
302
|
+
for (let n of x.current.values()) n.cancelKey === e && (n.timeScale = t, F(n));
|
|
254
303
|
},
|
|
255
|
-
loop: (e, n) => t(
|
|
256
|
-
tweenLoop: (e) => n(
|
|
257
|
-
stagger: ((e, t, n,
|
|
304
|
+
loop: (e, n) => t(L, e, n),
|
|
305
|
+
tweenLoop: (e) => n(B, L, e),
|
|
306
|
+
stagger: ((e, t, n, r) => o(B, c, L, m, e, t, n, r)),
|
|
258
307
|
timeline: (e) => {
|
|
259
|
-
let t =
|
|
260
|
-
let e =
|
|
261
|
-
return e &&
|
|
308
|
+
let t = S.current++, n = () => {
|
|
309
|
+
let e = x.current.get(t);
|
|
310
|
+
return e && _(e);
|
|
262
311
|
};
|
|
263
|
-
return
|
|
312
|
+
return s(I, t, e, {
|
|
264
313
|
get watched() {
|
|
265
|
-
return
|
|
314
|
+
return h.watched;
|
|
266
315
|
},
|
|
267
316
|
fire: (e, t, r, i) => {
|
|
268
317
|
let a = n();
|
|
269
|
-
a &&
|
|
318
|
+
a && h.emit({
|
|
270
319
|
type: "fire",
|
|
271
320
|
animation: a,
|
|
272
321
|
track: e,
|
|
@@ -277,7 +326,7 @@ function v(s = {}) {
|
|
|
277
326
|
},
|
|
278
327
|
lap: (e) => {
|
|
279
328
|
let t = n();
|
|
280
|
-
t &&
|
|
329
|
+
t && h.emit({
|
|
281
330
|
type: "lap",
|
|
282
331
|
animation: t,
|
|
283
332
|
lap: e
|
|
@@ -285,20 +334,20 @@ function v(s = {}) {
|
|
|
285
334
|
}
|
|
286
335
|
});
|
|
287
336
|
},
|
|
288
|
-
colorOverrides:
|
|
289
|
-
onTick: (e) => (
|
|
290
|
-
|
|
337
|
+
colorOverrides: D.current,
|
|
338
|
+
onTick: (e) => (O.current.add(e), () => {
|
|
339
|
+
O.current.delete(e);
|
|
291
340
|
}),
|
|
292
341
|
keepAlive: () => {
|
|
293
|
-
let e =
|
|
342
|
+
let e = L({ kind: "keepAlive" });
|
|
294
343
|
return () => e.cancel();
|
|
295
344
|
},
|
|
296
|
-
watch: (e) =>
|
|
345
|
+
watch: (e) => h.add(e),
|
|
297
346
|
live: () => {
|
|
298
347
|
let e = [];
|
|
299
|
-
for (let t of
|
|
348
|
+
for (let t of x.current.values()) {
|
|
300
349
|
let n = {
|
|
301
|
-
...
|
|
350
|
+
..._(t),
|
|
302
351
|
paused: t.paused,
|
|
303
352
|
timeScale: t.timeScale,
|
|
304
353
|
elapsed: t.virtualNow,
|
|
@@ -310,20 +359,20 @@ function v(s = {}) {
|
|
|
310
359
|
}
|
|
311
360
|
};
|
|
312
361
|
return {
|
|
313
|
-
api:
|
|
314
|
-
tickAll:
|
|
362
|
+
api: B,
|
|
363
|
+
tickAll: A
|
|
315
364
|
};
|
|
316
|
-
}, [
|
|
317
|
-
return
|
|
318
|
-
|
|
319
|
-
}, [
|
|
320
|
-
let e =
|
|
321
|
-
return
|
|
322
|
-
|
|
365
|
+
}, [j, b]);
|
|
366
|
+
return h(() => {
|
|
367
|
+
k.current = I;
|
|
368
|
+
}, [I]), m(() => {
|
|
369
|
+
let e = D.current;
|
|
370
|
+
return M.current = !0, () => {
|
|
371
|
+
M.current = !1, F.cancelAll(), e.clearAll();
|
|
323
372
|
};
|
|
324
|
-
}, [
|
|
373
|
+
}, [F]), F;
|
|
325
374
|
}
|
|
326
375
|
//#endregion
|
|
327
|
-
export {
|
|
376
|
+
export { b as useAnimator };
|
|
328
377
|
|
|
329
378
|
//# sourceMappingURL=useAnimator.js.map
|