@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.
Files changed (49) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/dist/animation/colorHelpers.js +58 -58
  3. package/dist/animation/colorHelpers.js.map +1 -1
  4. package/dist/animation/engine/axes.js +36 -0
  5. package/dist/animation/engine/axes.js.map +1 -0
  6. package/dist/animation/engine/codec.js +170 -0
  7. package/dist/animation/engine/codec.js.map +1 -0
  8. package/dist/animation/engine/integrator.js +12 -0
  9. package/dist/animation/engine/integrator.js.map +1 -0
  10. package/dist/animation/useAnimator.js +209 -160
  11. package/dist/animation/useAnimator.js.map +1 -1
  12. package/dist/{builtins-C-gRyVRx.d.ts → builtins-CMEh6-Oc.d.ts} +81 -8
  13. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +12 -12
  14. package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -1
  15. package/dist/canvas/pickWalk.js +2 -2
  16. package/dist/canvas/pickWalk.js.map +1 -1
  17. package/dist/canvas/sceneSlotWiring.js +1 -1
  18. package/dist/canvas/sceneSlotWiring.js.map +1 -1
  19. package/dist/canvas/sceneViewRender.js +1 -1
  20. package/dist/canvas/sceneViewRender.js.map +1 -1
  21. package/dist/core/scene/effectivePose.js +1 -1
  22. package/dist/core/scene/effectivePose.js.map +1 -1
  23. package/dist/core/scene/poseOverrides.js +42 -22
  24. package/dist/core/scene/poseOverrides.js.map +1 -1
  25. package/dist/core/scene/scene.js +9 -0
  26. package/dist/core/scene/scene.js.map +1 -1
  27. package/dist/core/scene/types.js.map +1 -1
  28. package/dist/core/selection/useSelection.js +27 -33
  29. package/dist/core/selection/useSelection.js.map +1 -1
  30. package/dist/core/stableStringify.js +8 -0
  31. package/dist/core/stableStringify.js.map +1 -0
  32. package/dist/index.d.ts +35 -25
  33. package/dist/index.js +269 -268
  34. package/dist/renderer/WeaselRenderer.js +4 -1
  35. package/dist/renderer/WeaselRenderer.js.map +1 -1
  36. package/dist/renderer/batchClip.js +46 -0
  37. package/dist/renderer/batchClip.js.map +1 -0
  38. package/dist/renderer/draw.js +367 -294
  39. package/dist/renderer/draw.js.map +1 -1
  40. package/dist/renderer/drawBatch.js +75 -45
  41. package/dist/renderer/drawBatch.js.map +1 -1
  42. package/dist/renderer/shaders/batchFill.js +3 -2
  43. package/dist/renderer/shaders/batchFill.js.map +1 -1
  44. package/dist/renderer.d.ts +1 -1
  45. package/dist/tools/builtin/text/useTextTool.js +8 -8
  46. package/dist/tools/builtin/text/useTextTool.js.map +1 -1
  47. package/dist/tools/prefs.js.map +1 -1
  48. package/dist/version.js +1 -1
  49. 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 { createStagger as r } from "./stagger.js";
4
- import { createTimeline as i } from "./timeline/createTimeline.js";
5
- import { ColorOverrideRegistry as a } from "./colorRegistry.js";
6
- import { AnimatorEventHub as o } from "./observe.js";
7
- import { SPRING_PRESETS as s, easeOut as c, resolveEasing as l } from "@weasel-js/geom";
8
- import { useCallback as u, useEffect as d, useInsertionEffect as f, useMemo as p, useRef as m } from "react";
9
- import { useLatest as h } from "@weasel-js/react";
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
- var g = (e, t, n) => e + (t - e) * n;
12
- function _(e) {
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 v(s = {}) {
21
- let v = h(s), y = m(/* @__PURE__ */ new Map()), b = m(1), x = m(0), S = m(1), C = m(!1), w = m(new a()), T = m(/* @__PURE__ */ new Set()), E = m(null), D = e(u((e) => {
22
- E.current?.(e);
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: s.requestFrame,
25
- cancelFrame: s.cancelFrame,
26
+ requestFrame: u.requestFrame,
27
+ cancelFrame: u.cancelFrame,
26
28
  onResume: () => {
27
- for (let e of y.current.values()) e.lastRealNow = null;
29
+ for (let e of x.current.values()) e.lastRealNow = null;
30
+ w.current = null;
28
31
  }
29
- }), O = h(D), k = m(!0), A = m(!1), j = () => !k.current && (A.current || (A.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: M, tickAll: N } = p(() => {
30
- let e = () => (v.current.now ?? (typeof performance < "u" ? performance.now.bind(performance) : Date.now))(), a = {
31
- setTimer: (e, t) => (v.current.setTimer ?? ((e, t) => setTimeout(e, t)))(e, t),
32
- clearTimer: (e) => (v.current.clearTimer ?? ((e) => clearTimeout(e)))(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
- }, s = /* @__PURE__ */ new Map(), u = (e) => {
35
- let t = s.get(e);
37
+ }, u = /* @__PURE__ */ new Map(), p = (e) => {
38
+ let t = u.get(e);
36
39
  if (t) {
37
- s.delete(e);
40
+ u.delete(e);
38
41
  for (let e of t) e();
39
42
  }
40
- }, d = (e, t) => {
41
- let n = s.get(e) ?? [];
42
- return n.push(t), s.set(e, n), () => {
43
- let n = s.get(e);
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 && s.delete(e);
49
+ r >= 0 && n.splice(r, 1), n.length === 0 && u.delete(e);
47
50
  };
48
- }, f = new o(), p = (e) => {
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
- }, m = (e) => {
58
- let t = y.current.get(e);
59
- t && !t.ended && (t.ended = !0, f.watched && f.emit({
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: p(t)
64
+ animation: _(t)
62
65
  }));
63
- }, h = (e, t) => {
64
- let n = y.current.get(e);
65
- n && (n.onCancel?.(), y.current.delete(e), u(e), f.watched && !n.ended && f.emit(t ? {
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: p(n),
68
- by: p(t)
70
+ animation: _(r),
71
+ by: _(t)
69
72
  } : {
70
73
  type: "cancel",
71
- animation: p(n)
74
+ animation: _(r)
72
75
  }));
73
- }, E = (e) => {
74
- let t = [];
75
- for (let n of y.current.values()) {
76
- let r = n.lastRealNow == null ? 0 : Math.max(0, e - n.lastRealNow);
77
- n.lastRealNow = e;
78
- let i = C.current ? 0 : S.current * (n.paused ? 0 : n.timeScale);
79
- n.virtualNow += r * i, x.current += 1;
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
- n.tick(n.virtualNow, i) && t.push(n);
85
+ r.tick(r.virtualNow, a) && t.push(r);
86
+ } catch (e) {
87
+ n.push([r, e]);
82
88
  } finally {
83
- --x.current;
89
+ --C.current;
84
90
  }
85
91
  }
86
- for (let e of t) y.current.get(e.id) === e && (m(e.id), y.current.delete(e.id), u(e.id));
87
- for (let e of T.current) try {
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
- y.current.size > 0 && O.current.request();
93
- }, D = () => {
94
- y.current.size !== 0 && O.current.request();
95
- }, k = (e, t) => {
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 y.current.values()) t.cancelKey === e && n.push(t.id);
98
- for (let e of n) h(e, t);
99
- }, A = (t) => {
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 && k(t.cancelKey, n), n.paused = !1, n.timeScale = 1, n.virtualNow = 0, n.lastRealNow = e(), y.current.set(n.id, n), f.watched && f.emit({
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: p(n)
104
- }), D(), {
116
+ animation: _(n)
117
+ }), M(), {
105
118
  id: n.id,
106
- cancel: () => h(n.id),
119
+ cancel: () => k(n.id),
107
120
  pause: () => {
108
- let e = y.current.get(n.id);
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 = y.current.get(n.id);
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 = y.current.get(n.id);
117
- t && (t.timeScale = e);
129
+ let t = x.current.get(n.id);
130
+ t && (t.timeScale = e, F(t));
118
131
  },
119
- timeScale: () => y.current.get(n.id)?.timeScale ?? 1,
120
- isPaused: () => y.current.get(n.id)?.paused ?? !1
132
+ timeScale: () => x.current.get(n.id)?.timeScale ?? 1,
133
+ isPaused: () => x.current.get(n.id)?.paused ?? !1
121
134
  };
122
- }, M = ({ kind: e, cancelKey: t, label: n }) => {
123
- let r = b.current++, i, a = A({
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
- y.current.has(r) && (m(r), y.current.delete(r), u(r));
156
+ x.current.has(r) && (v(r), x.current.delete(r), p(r));
144
157
  },
145
158
  cancelKey: t
146
159
  };
147
- }, N = (e) => {
148
- let t = b.current++, n = l(e.easing ?? c), r = e.interpolator ? e.interpolator(e.from, e.to) : null, i = r ? null : e.interpolate ?? ((e, t, n) => {
149
- if (typeof e == "number" && typeof t == "number") return g(e, t, n);
150
- throw Error("tween: interpolate or interpolator is required for non-numeric T");
151
- }), a = !1;
152
- return A({
153
- id: t,
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: e.cancelKey,
156
- label: e.label,
157
- progress: (t) => e.ms <= 0 ? 1 : Math.min(1, t / e.ms),
158
- tick(o) {
159
- if (j()) return !0;
160
- let s = o - 0, c = e.ms <= 0 ? 1 : Math.min(1, Math.max(0, s / e.ms)), l = n(c), u = r ? r(l) : i(e.from, e.to, l);
161
- return e.onTick(u), c >= 1 && !a && (a = !0, y.current.has(t) && (m(t), e.onDone?.()), !0);
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
- }, P = (e, t = "physics") => {
165
- let n = b.current++;
166
- if (typeof e.from != "number" && (!e.add || !e.subtract || !e.scale || !e.magnitude)) throw Error("physics: add/subtract/scale/magnitude are required for non-numeric T");
167
- let r = e.add ?? ((e, t) => e + t), i = e.subtract ?? ((e, t) => e - t), a = e.scale ?? ((e, t) => e * t), o = e.magnitude ?? ((e) => Math.abs(e)), { stiffness: s, damping: c, mass: l } = _(e), u = e.restThreshold ?? .01, d = e.to ?? null, f = e.from, p = e.velocity ?? a(e.from, 0), h = null;
168
- return {
169
- ...A({
170
- id: n,
171
- kind: t,
172
- cancelKey: e.cancelKey,
173
- label: e.label,
174
- tick(t) {
175
- if (j()) return !0;
176
- if (h == null) return h = t, d == null && o(p) < u ? (m(n), e.onDone?.(), !0) : (e.onTick(f), !1);
177
- let g = Math.min(.064, (t - h) / 1e3);
178
- h = t;
179
- let _ = i(f, d ?? f), v = a(_, d == null ? 0 : -s), y = a(p, -c), b = a(r(v, y), 1 / l);
180
- p = r(p, a(b, g)), f = r(f, a(p, g)), e.onTick(f);
181
- let x = o(p) < u, S = d == null || o(i(f, d)) < u;
182
- return x && S ? (d != null && e.onTick(d), m(n), e.onDone?.(), !0) : !1;
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
- d = e;
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
- p = e;
238
+ T && O(e, "setVelocity"), _ = e, T && g.has(i) && g.push(i, T.to(e));
190
239
  }
191
240
  };
192
- }, F = {
193
- tween: N,
194
- spring: (e) => P(e, "spring"),
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 P({
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: P,
216
- cancel: (e) => h(e.id),
217
- cancelKey: (e) => k(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 y.current.values()) t.onCancel?.(), e.push(t);
221
- y.current.clear();
222
- for (let t of e) u(t.id);
223
- if (f.watched) for (let t of e) f.emit({
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: p(t)
274
+ animation: _(t)
226
275
  });
227
- O.current.cancel();
276
+ j.current.cancel();
228
277
  },
229
278
  isActive: (e) => {
230
- if (e == null) return y.current.size > 0;
231
- for (let t of y.current.values()) if (t.cancelKey === e) return !0;
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: () => x.current > 0,
283
+ isTicking: () => C.current > 0,
235
284
  pause: () => {
236
- C.current = !0;
285
+ E.current = !0;
237
286
  },
238
287
  resume: () => {
239
- C.current = !1;
288
+ E.current = !1;
240
289
  },
241
- isPaused: () => C.current,
290
+ isPaused: () => E.current,
242
291
  setTimeScale: (e) => {
243
- S.current = e;
292
+ T.current = e;
244
293
  },
245
- timeScale: () => S.current,
294
+ timeScale: () => T.current,
246
295
  pauseKey: (e) => {
247
- for (let t of y.current.values()) t.cancelKey === e && (t.paused = !0);
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 y.current.values()) t.cancelKey === e && (t.paused = !1);
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 y.current.values()) n.cancelKey === e && (n.timeScale = t);
302
+ for (let n of x.current.values()) n.cancelKey === e && (n.timeScale = t, F(n));
254
303
  },
255
- loop: (e, n) => t(M, e, n),
256
- tweenLoop: (e) => n(F, M, e),
257
- stagger: ((e, t, n, i) => r(F, a, M, d, e, t, n, i)),
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 = b.current++, n = () => {
260
- let e = y.current.get(t);
261
- return e && p(e);
308
+ let t = S.current++, n = () => {
309
+ let e = x.current.get(t);
310
+ return e && _(e);
262
311
  };
263
- return i(A, t, e, {
312
+ return s(I, t, e, {
264
313
  get watched() {
265
- return f.watched;
314
+ return h.watched;
266
315
  },
267
316
  fire: (e, t, r, i) => {
268
317
  let a = n();
269
- a && f.emit({
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 && f.emit({
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: w.current,
289
- onTick: (e) => (T.current.add(e), () => {
290
- T.current.delete(e);
337
+ colorOverrides: D.current,
338
+ onTick: (e) => (O.current.add(e), () => {
339
+ O.current.delete(e);
291
340
  }),
292
341
  keepAlive: () => {
293
- let e = M({ kind: "keepAlive" });
342
+ let e = L({ kind: "keepAlive" });
294
343
  return () => e.cancel();
295
344
  },
296
- watch: (e) => f.add(e),
345
+ watch: (e) => h.add(e),
297
346
  live: () => {
298
347
  let e = [];
299
- for (let t of y.current.values()) {
348
+ for (let t of x.current.values()) {
300
349
  let n = {
301
- ...p(t),
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: F,
314
- tickAll: E
362
+ api: B,
363
+ tickAll: A
315
364
  };
316
- }, [O, v]);
317
- return f(() => {
318
- E.current = N;
319
- }, [N]), d(() => {
320
- let e = w.current;
321
- return k.current = !0, () => {
322
- k.current = !1, M.cancelAll(), e.clearAll();
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
- }, [M]), M;
373
+ }, [F]), F;
325
374
  }
326
375
  //#endregion
327
- export { v as useAnimator };
376
+ export { b as useAnimator };
328
377
 
329
378
  //# sourceMappingURL=useAnimator.js.map