sibujs 3.3.1 → 3.3.3

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/dist/browser.cjs +41 -18
  2. package/dist/browser.js +5 -5
  3. package/dist/build.cjs +57 -22
  4. package/dist/build.js +14 -14
  5. package/dist/cdn.global.js +7 -7
  6. package/dist/{chunk-MHBCEJQO.js → chunk-23VT3KZB.js} +2 -2
  7. package/dist/{chunk-WL7BIR6O.js → chunk-25LY5SRH.js} +31 -24
  8. package/dist/{chunk-37BUKSLH.js → chunk-5K6RVA2S.js} +1 -1
  9. package/dist/{chunk-AMIKDMLP.js → chunk-5Y34FWED.js} +17 -6
  10. package/dist/chunk-7ZHH77QA.js +9 -0
  11. package/dist/chunk-CCSJMTRN.js +15 -0
  12. package/dist/{chunk-R3QEDXFS.js → chunk-EX77FXTT.js} +1 -1
  13. package/dist/{chunk-WW6DAGGR.js → chunk-F3HO2MP7.js} +1 -1
  14. package/dist/{chunk-ZUVLC7TM.js → chunk-F7HW2NI5.js} +2 -4
  15. package/dist/{chunk-ULLTNDRA.js → chunk-IEYFHN5V.js} +72 -25
  16. package/dist/{chunk-Z37APKBV.js → chunk-IQN5W7GE.js} +73 -16
  17. package/dist/{chunk-WZG2SZOT.js → chunk-IWFE4AHO.js} +1 -1
  18. package/dist/{chunk-IKLYI3RF.js → chunk-MYXEBADX.js} +53 -23
  19. package/dist/{chunk-6LTFHJQG.js → chunk-QCQQ2N5H.js} +41 -20
  20. package/dist/{chunk-VOVVTOEA.js → chunk-QTOOBABV.js} +22 -5
  21. package/dist/{chunk-LU2MQXQQ.js → chunk-RZKGMHH4.js} +6 -6
  22. package/dist/{chunk-GOJMFRBL.js → chunk-S3NFJO6L.js} +20 -14
  23. package/dist/{chunk-NHKQKKZU.js → chunk-SBPUXWCE.js} +1 -1
  24. package/dist/{chunk-SLMFA3ZZ.js → chunk-TBDTU7UO.js} +2 -2
  25. package/dist/{chunk-4UUMSLSL.js → chunk-TVCCXPU2.js} +5 -5
  26. package/dist/{chunk-TEFZT5PJ.js → chunk-UOMYIAG6.js} +1 -1
  27. package/dist/{chunk-XH2RTYEQ.js → chunk-WFUUT6TG.js} +15 -8
  28. package/dist/{chunk-M5KBNOSJ.js → chunk-WTFMV2RU.js} +70 -59
  29. package/dist/{chunk-3JHCYHWN.js → chunk-WWV3SJ3L.js} +19 -13
  30. package/dist/{chunk-RYMOSG5B.js → chunk-Y35NQNLG.js} +90 -60
  31. package/dist/{chunk-F7FXQ3QS.js → chunk-ZXCZWMZT.js} +1 -1
  32. package/dist/data.cjs +36 -16
  33. package/dist/data.js +8 -7
  34. package/dist/devtools.cjs +91 -35
  35. package/dist/devtools.d.cts +12 -5
  36. package/dist/devtools.d.ts +12 -5
  37. package/dist/devtools.js +7 -6
  38. package/dist/ecosystem.cjs +31 -16
  39. package/dist/ecosystem.js +11 -10
  40. package/dist/extras.cjs +485 -280
  41. package/dist/extras.d.cts +1 -1
  42. package/dist/extras.d.ts +1 -1
  43. package/dist/extras.js +28 -24
  44. package/dist/index.cjs +59 -22
  45. package/dist/index.d.cts +24 -8
  46. package/dist/index.d.ts +24 -8
  47. package/dist/index.js +25 -21
  48. package/dist/motion.cjs +223 -204
  49. package/dist/motion.d.cts +8 -1
  50. package/dist/motion.d.ts +8 -1
  51. package/dist/motion.js +6 -3
  52. package/dist/patterns.cjs +33 -20
  53. package/dist/patterns.d.cts +4 -1
  54. package/dist/patterns.d.ts +4 -1
  55. package/dist/patterns.js +6 -6
  56. package/dist/performance.cjs +90 -70
  57. package/dist/performance.js +8 -7
  58. package/dist/plugins.cjs +207 -144
  59. package/dist/plugins.d.cts +2 -1
  60. package/dist/plugins.d.ts +2 -1
  61. package/dist/plugins.js +178 -124
  62. package/dist/{ssr-6D67RAVB.js → ssr-2PPULEK2.js} +2 -2
  63. package/dist/ssr.cjs +132 -105
  64. package/dist/ssr.d.cts +8 -1
  65. package/dist/ssr.d.ts +8 -1
  66. package/dist/ssr.js +11 -10
  67. package/dist/testing.cjs +38 -18
  68. package/dist/testing.js +19 -8
  69. package/dist/ui.cjs +337 -294
  70. package/dist/ui.d.cts +0 -20
  71. package/dist/ui.d.ts +0 -20
  72. package/dist/ui.js +30 -24
  73. package/dist/widgets.cjs +95 -27
  74. package/dist/widgets.d.cts +6 -1
  75. package/dist/widgets.d.ts +6 -1
  76. package/dist/widgets.js +8 -7
  77. package/package.json +1 -1
  78. package/dist/chunk-YT6HQ6AM.js +0 -14
package/dist/motion.cjs CHANGED
@@ -27,6 +27,7 @@ __export(motion_exports, {
27
27
  fadeIn: () => fadeIn,
28
28
  fadeOut: () => fadeOut,
29
29
  flipIn: () => flipIn,
30
+ prefersReducedMotion: () => prefersReducedMotion,
30
31
  pulse: () => pulse,
31
32
  reducedMotion: () => reducedMotion,
32
33
  scaleDown: () => scaleDown,
@@ -43,6 +44,37 @@ __export(motion_exports, {
43
44
  });
44
45
  module.exports = __toCommonJS(motion_exports);
45
46
 
47
+ // src/core/dev.ts
48
+ function isDev() {
49
+ return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
50
+ // The bare `__SIBU_DEV__` is a bundler define that only exists in
51
+ // production builds; under the test runner it is always undefined, so
52
+ // this branch is unreachable here.
53
+ /* v8 ignore next 2 */
54
+ typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
55
+ );
56
+ }
57
+ var _isDev = isDev();
58
+ function devWarn(message) {
59
+ if (_isDev) {
60
+ console.warn(`[SibuJS] ${message}`);
61
+ }
62
+ }
63
+
64
+ // src/core/rendering/dispose.ts
65
+ var elementDisposers = /* @__PURE__ */ new WeakMap();
66
+ var _isDev2 = isDev();
67
+ var activeBindingCount = 0;
68
+ function registerDisposer(node, teardown) {
69
+ let disposers = elementDisposers.get(node);
70
+ if (!disposers) {
71
+ disposers = [];
72
+ elementDisposers.set(node, disposers);
73
+ }
74
+ disposers.push(teardown);
75
+ if (_isDev2) activeBindingCount++;
76
+ }
77
+
46
78
  // src/ui/transition.ts
47
79
  function transition(element, options = {}) {
48
80
  const {
@@ -115,6 +147,7 @@ function transition(element, options = {}) {
115
147
  }
116
148
  });
117
149
  }
150
+ registerDisposer(element, cancelPending);
118
151
  return { enter, leave };
119
152
  }
120
153
  function spring(element, keyframes, options = {}) {
@@ -130,181 +163,8 @@ function spring(element, keyframes, options = {}) {
130
163
  });
131
164
  }
132
165
 
133
- // src/ui/animationPresets.ts
134
- var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
135
- function createPreset(keyframes, defaults, overrides) {
136
- const opts = {
137
- ...defaults,
138
- ...overrides,
139
- fill: overrides?.fill ?? defaults.fill ?? "forwards"
140
- };
141
- if (prefersReducedMotion()) {
142
- return {
143
- keyframes: [keyframes[keyframes.length - 1]],
144
- options: { ...opts, duration: 0, delay: 0 }
145
- };
146
- }
147
- return { keyframes, options: opts };
148
- }
149
- function applyPreset(el, preset) {
150
- return new Promise((resolve) => {
151
- const anim = el.animate(preset.keyframes, preset.options);
152
- anim.onfinish = () => resolve();
153
- anim.oncancel = () => resolve();
154
- });
155
- }
156
- function fadeIn(opts) {
157
- return createPreset([{ opacity: 0 }, { opacity: 1 }], { duration: 300, easing: "ease-out" }, opts);
158
- }
159
- function fadeOut(opts) {
160
- return createPreset([{ opacity: 1 }, { opacity: 0 }], { duration: 300, easing: "ease-in" }, opts);
161
- }
162
- var slideOffsets = {
163
- up: "translateY(20px)",
164
- down: "translateY(-20px)",
165
- left: "translateX(20px)",
166
- right: "translateX(-20px)"
167
- };
168
- function slideIn(direction = "up", opts) {
169
- return createPreset(
170
- [
171
- { transform: slideOffsets[direction], opacity: 0 },
172
- { transform: "translate(0, 0)", opacity: 1 }
173
- ],
174
- { duration: 400, easing: "cubic-bezier(0.16, 1, 0.3, 1)" },
175
- opts
176
- );
177
- }
178
- function slideOut(direction = "down", opts) {
179
- return createPreset(
180
- [
181
- { transform: "translate(0, 0)", opacity: 1 },
182
- { transform: slideOffsets[direction], opacity: 0 }
183
- ],
184
- { duration: 300, easing: "cubic-bezier(0.4, 0, 1, 1)" },
185
- opts
186
- );
187
- }
188
- function scaleUp(opts) {
189
- return createPreset(
190
- [
191
- { transform: "scale(0.85)", opacity: 0 },
192
- { transform: "scale(1)", opacity: 1 }
193
- ],
194
- { duration: 350, easing: "cubic-bezier(0.34, 1.56, 0.64, 1)" },
195
- opts
196
- );
197
- }
198
- function scaleDown(opts) {
199
- return createPreset(
200
- [
201
- { transform: "scale(1)", opacity: 1 },
202
- { transform: "scale(0.85)", opacity: 0 }
203
- ],
204
- { duration: 250, easing: "ease-in" },
205
- opts
206
- );
207
- }
208
- function bounceIn(opts) {
209
- return createPreset(
210
- [
211
- { transform: "scale(0.3)", opacity: 0 },
212
- { transform: "scale(1.05)", opacity: 0.8, offset: 0.5 },
213
- { transform: "scale(0.95)", opacity: 0.9, offset: 0.7 },
214
- { transform: "scale(1)", opacity: 1 }
215
- ],
216
- { duration: 500, easing: "cubic-bezier(0.34, 1.56, 0.64, 1)" },
217
- opts
218
- );
219
- }
220
- function bounceOut(opts) {
221
- return createPreset(
222
- [
223
- { transform: "scale(1)", opacity: 1 },
224
- { transform: "scale(1.05)", opacity: 0.9, offset: 0.3 },
225
- { transform: "scale(0.3)", opacity: 0 }
226
- ],
227
- { duration: 400, easing: "ease-in" },
228
- opts
229
- );
230
- }
231
- function flipIn(axis = "x", opts) {
232
- const prop = axis === "x" ? "rotateX" : "rotateY";
233
- return createPreset(
234
- [
235
- { transform: `perspective(400px) ${prop}(90deg)`, opacity: 0 },
236
- { transform: `perspective(400px) ${prop}(-10deg)`, opacity: 1, offset: 0.6 },
237
- { transform: `perspective(400px) ${prop}(0deg)`, opacity: 1 }
238
- ],
239
- { duration: 500, easing: "ease-out" },
240
- opts
241
- );
242
- }
243
- function shake(opts) {
244
- return createPreset(
245
- [
246
- { transform: "translateX(0)" },
247
- { transform: "translateX(-8px)", offset: 0.1 },
248
- { transform: "translateX(8px)", offset: 0.2 },
249
- { transform: "translateX(-6px)", offset: 0.3 },
250
- { transform: "translateX(6px)", offset: 0.4 },
251
- { transform: "translateX(-4px)", offset: 0.5 },
252
- { transform: "translateX(4px)", offset: 0.6 },
253
- { transform: "translateX(-2px)", offset: 0.7 },
254
- { transform: "translateX(0)" }
255
- ],
256
- { duration: 500, easing: "ease-out", fill: "none" },
257
- opts
258
- );
259
- }
260
- function pulse(opts) {
261
- return createPreset(
262
- [{ transform: "scale(1)" }, { transform: "scale(1.08)", offset: 0.5 }, { transform: "scale(1)" }],
263
- { duration: 400, easing: "ease-in-out", fill: "none" },
264
- opts
265
- );
266
- }
267
- function animate(el, preset) {
268
- return applyPreset(el, preset);
269
- }
270
- function stagger(elements, preset, delayBetween = 50) {
271
- const promises = elements.map(
272
- (el, i) => applyPreset(el, {
273
- keyframes: preset.keyframes,
274
- options: {
275
- ...preset.options,
276
- delay: (preset.options.delay || 0) + i * delayBetween
277
- }
278
- })
279
- );
280
- return Promise.all(promises).then(() => {
281
- });
282
- }
283
- async function sequence(steps) {
284
- for (const step of steps) {
285
- await applyPreset(step.el, step.preset);
286
- }
287
- }
288
-
289
- // src/core/dev.ts
290
- function isDev() {
291
- return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
292
- // The bare `__SIBU_DEV__` is a bundler define that only exists in
293
- // production builds; under the test runner it is always undefined, so
294
- // this branch is unreachable here.
295
- /* v8 ignore next 2 */
296
- typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
297
- );
298
- }
299
- var _isDev = isDev();
300
- function devWarn(message) {
301
- if (_isDev) {
302
- console.warn(`[SibuJS] ${message}`);
303
- }
304
- }
305
-
306
166
  // src/reactivity/track-core.ts
307
- var _isDev2 = isDev();
167
+ var _isDev3 = isDev();
308
168
  var POOL_MAX = 4096;
309
169
  var nodePool = [];
310
170
  function createNode() {
@@ -396,7 +256,7 @@ function safeInvoke(sub) {
396
256
  try {
397
257
  sub();
398
258
  } catch (err) {
399
- if (_isDev2) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
259
+ if (_isDev3) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
400
260
  }
401
261
  }
402
262
  var suspendDepth = 0;
@@ -718,14 +578,14 @@ function forEachSubscriber(signal2, visit) {
718
578
  }
719
579
 
720
580
  // src/reactivity/track.ts
721
- var _isDev3 = isDev();
722
- var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
581
+ var _isDev4 = isDev();
582
+ var _runtimeVersion = true ? "3.3.3" : "dev";
723
583
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
724
584
  function resolveReactiveApi() {
725
585
  const g = globalThis;
726
586
  const existing = g[REGISTRY_KEY];
727
587
  if (existing) {
728
- if (_isDev3 && !existing.__dupWarned) {
588
+ if (_isDev4 && !existing.__dupWarned) {
729
589
  existing.__dupWarned = true;
730
590
  devWarn(
731
591
  `Multiple instances of the reactive runtime detected on this page (active: ${existing.version}, duplicate: ${_runtimeVersion}). Reactivity still works \u2014 all copies share the first one \u2014 but de-duplicate sibujs in your bundler (e.g. Vite optimizeDeps.exclude: ['sibujs'] or resolve.dedupe: ['sibujs']).`
@@ -827,7 +687,7 @@ var isBatching = API2.isBatching;
827
687
 
828
688
  // src/core/signals/signal.ts
829
689
  var _g = globalThis;
830
- var _isDev4 = isDev();
690
+ var _isDev5 = isDev();
831
691
  function signal(initial, options) {
832
692
  const state = {
833
693
  value: initial,
@@ -838,7 +698,7 @@ function signal(initial, options) {
838
698
  __activeNode: null,
839
699
  __name: void 0
840
700
  };
841
- const debugName = _isDev4 ? options?.name : void 0;
701
+ const debugName = _isDev5 ? options?.name : void 0;
842
702
  const equalsFn = options?.equals;
843
703
  if (debugName) state.__name = debugName;
844
704
  function get() {
@@ -855,7 +715,7 @@ function signal(initial, options) {
855
715
  if (equalsFn(prev, newValue)) return;
856
716
  state.value = newValue;
857
717
  state.__v++;
858
- if (_isDev4) {
718
+ if (_isDev5) {
859
719
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
860
720
  if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
861
721
  }
@@ -863,7 +723,7 @@ function signal(initial, options) {
863
723
  notifySubscribers2(state);
864
724
  }
865
725
  };
866
- } else if (_isDev4) {
726
+ } else if (_isDev5) {
867
727
  set = (next) => {
868
728
  const prev = state.value;
869
729
  const newValue = typeof next === "function" ? next(prev) : next;
@@ -888,13 +748,190 @@ function signal(initial, options) {
888
748
  }
889
749
  };
890
750
  }
891
- if (_isDev4) {
751
+ if (_isDev5) {
892
752
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
893
753
  if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
894
754
  }
895
755
  return [get, set];
896
756
  }
897
757
 
758
+ // src/ui/reducedMotion.ts
759
+ function prefersReducedMotion() {
760
+ return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
761
+ }
762
+ function reducedMotion() {
763
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
764
+ const [reduced2] = signal(false);
765
+ return { reduced: reduced2, dispose: () => {
766
+ } };
767
+ }
768
+ const mql = window.matchMedia("(prefers-reduced-motion: reduce)");
769
+ const [reduced, setReduced] = signal(mql.matches);
770
+ const handler = (event) => {
771
+ setReduced(event.matches);
772
+ };
773
+ mql.addEventListener("change", handler);
774
+ function dispose() {
775
+ mql.removeEventListener("change", handler);
776
+ }
777
+ return { reduced, dispose };
778
+ }
779
+
780
+ // src/ui/animationPresets.ts
781
+ function createPreset(keyframes, defaults, overrides) {
782
+ const opts = {
783
+ ...defaults,
784
+ ...overrides,
785
+ fill: overrides?.fill ?? defaults.fill ?? "forwards"
786
+ };
787
+ if (prefersReducedMotion()) {
788
+ return {
789
+ keyframes: [keyframes[keyframes.length - 1]],
790
+ options: { ...opts, duration: 0, delay: 0 }
791
+ };
792
+ }
793
+ return { keyframes, options: opts };
794
+ }
795
+ function applyPreset(el, preset) {
796
+ return new Promise((resolve) => {
797
+ const anim = el.animate(preset.keyframes, preset.options);
798
+ anim.onfinish = () => resolve();
799
+ anim.oncancel = () => resolve();
800
+ });
801
+ }
802
+ function fadeIn(opts) {
803
+ return createPreset([{ opacity: 0 }, { opacity: 1 }], { duration: 300, easing: "ease-out" }, opts);
804
+ }
805
+ function fadeOut(opts) {
806
+ return createPreset([{ opacity: 1 }, { opacity: 0 }], { duration: 300, easing: "ease-in" }, opts);
807
+ }
808
+ var slideOffsets = {
809
+ up: "translateY(20px)",
810
+ down: "translateY(-20px)",
811
+ left: "translateX(20px)",
812
+ right: "translateX(-20px)"
813
+ };
814
+ function slideIn(direction = "up", opts) {
815
+ return createPreset(
816
+ [
817
+ { transform: slideOffsets[direction], opacity: 0 },
818
+ { transform: "translate(0, 0)", opacity: 1 }
819
+ ],
820
+ { duration: 400, easing: "cubic-bezier(0.16, 1, 0.3, 1)" },
821
+ opts
822
+ );
823
+ }
824
+ function slideOut(direction = "down", opts) {
825
+ return createPreset(
826
+ [
827
+ { transform: "translate(0, 0)", opacity: 1 },
828
+ { transform: slideOffsets[direction], opacity: 0 }
829
+ ],
830
+ { duration: 300, easing: "cubic-bezier(0.4, 0, 1, 1)" },
831
+ opts
832
+ );
833
+ }
834
+ function scaleUp(opts) {
835
+ return createPreset(
836
+ [
837
+ { transform: "scale(0.85)", opacity: 0 },
838
+ { transform: "scale(1)", opacity: 1 }
839
+ ],
840
+ { duration: 350, easing: "cubic-bezier(0.34, 1.56, 0.64, 1)" },
841
+ opts
842
+ );
843
+ }
844
+ function scaleDown(opts) {
845
+ return createPreset(
846
+ [
847
+ { transform: "scale(1)", opacity: 1 },
848
+ { transform: "scale(0.85)", opacity: 0 }
849
+ ],
850
+ { duration: 250, easing: "ease-in" },
851
+ opts
852
+ );
853
+ }
854
+ function bounceIn(opts) {
855
+ return createPreset(
856
+ [
857
+ { transform: "scale(0.3)", opacity: 0 },
858
+ { transform: "scale(1.05)", opacity: 0.8, offset: 0.5 },
859
+ { transform: "scale(0.95)", opacity: 0.9, offset: 0.7 },
860
+ { transform: "scale(1)", opacity: 1 }
861
+ ],
862
+ { duration: 500, easing: "cubic-bezier(0.34, 1.56, 0.64, 1)" },
863
+ opts
864
+ );
865
+ }
866
+ function bounceOut(opts) {
867
+ return createPreset(
868
+ [
869
+ { transform: "scale(1)", opacity: 1 },
870
+ { transform: "scale(1.05)", opacity: 0.9, offset: 0.3 },
871
+ { transform: "scale(0.3)", opacity: 0 }
872
+ ],
873
+ { duration: 400, easing: "ease-in" },
874
+ opts
875
+ );
876
+ }
877
+ function flipIn(axis = "x", opts) {
878
+ const prop = axis === "x" ? "rotateX" : "rotateY";
879
+ return createPreset(
880
+ [
881
+ { transform: `perspective(400px) ${prop}(90deg)`, opacity: 0 },
882
+ { transform: `perspective(400px) ${prop}(-10deg)`, opacity: 1, offset: 0.6 },
883
+ { transform: `perspective(400px) ${prop}(0deg)`, opacity: 1 }
884
+ ],
885
+ { duration: 500, easing: "ease-out" },
886
+ opts
887
+ );
888
+ }
889
+ function shake(opts) {
890
+ return createPreset(
891
+ [
892
+ { transform: "translateX(0)" },
893
+ { transform: "translateX(-8px)", offset: 0.1 },
894
+ { transform: "translateX(8px)", offset: 0.2 },
895
+ { transform: "translateX(-6px)", offset: 0.3 },
896
+ { transform: "translateX(6px)", offset: 0.4 },
897
+ { transform: "translateX(-4px)", offset: 0.5 },
898
+ { transform: "translateX(4px)", offset: 0.6 },
899
+ { transform: "translateX(-2px)", offset: 0.7 },
900
+ { transform: "translateX(0)" }
901
+ ],
902
+ { duration: 500, easing: "ease-out", fill: "none" },
903
+ opts
904
+ );
905
+ }
906
+ function pulse(opts) {
907
+ return createPreset(
908
+ [{ transform: "scale(1)" }, { transform: "scale(1.08)", offset: 0.5 }, { transform: "scale(1)" }],
909
+ { duration: 400, easing: "ease-in-out", fill: "none" },
910
+ opts
911
+ );
912
+ }
913
+ function animate(el, preset) {
914
+ return applyPreset(el, preset);
915
+ }
916
+ function stagger(elements, preset, delayBetween = 50) {
917
+ const promises = elements.map(
918
+ (el, i) => applyPreset(el, {
919
+ keyframes: preset.keyframes,
920
+ options: {
921
+ ...preset.options,
922
+ delay: (preset.options.delay || 0) + i * delayBetween
923
+ }
924
+ })
925
+ );
926
+ return Promise.all(promises).then(() => {
927
+ });
928
+ }
929
+ async function sequence(steps) {
930
+ for (const step of steps) {
931
+ await applyPreset(step.el, step.preset);
932
+ }
933
+ }
934
+
898
935
  // src/ui/TransitionGroup.ts
899
936
  function TransitionGroup(options) {
900
937
  const [elements, setElements] = signal([]);
@@ -909,6 +946,7 @@ function TransitionGroup(options) {
909
946
  if (options.leave) {
910
947
  await options.leave(el);
911
948
  }
949
+ positions.delete(el);
912
950
  setElements((prev) => prev.filter((e) => e !== el));
913
951
  }
914
952
  function track3(newElements) {
@@ -975,27 +1013,7 @@ function viewTransition(callback) {
975
1013
  return { start, isTransitioning };
976
1014
  }
977
1015
 
978
- // src/ui/reducedMotion.ts
979
- function reducedMotion() {
980
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
981
- const [reduced2] = signal(false);
982
- return { reduced: reduced2, dispose: () => {
983
- } };
984
- }
985
- const mql = window.matchMedia("(prefers-reduced-motion: reduce)");
986
- const [reduced, setReduced] = signal(mql.matches);
987
- const handler = (event) => {
988
- setReduced(event.matches);
989
- };
990
- mql.addEventListener("change", handler);
991
- function dispose() {
992
- mql.removeEventListener("change", handler);
993
- }
994
- return { reduced, dispose };
995
- }
996
-
997
1016
  // src/ui/springSignal.ts
998
- var prefersReducedMotion2 = () => typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
999
1017
  function springSignal(initial, options) {
1000
1018
  const stiffness = options?.stiffness ?? 0.15;
1001
1019
  const damping = options?.damping ?? 0.8;
@@ -1031,7 +1049,7 @@ function springSignal(initial, options) {
1031
1049
  }
1032
1050
  function set(newTarget) {
1033
1051
  target = newTarget;
1034
- if (prefersReducedMotion2()) {
1052
+ if (prefersReducedMotion()) {
1035
1053
  current = newTarget;
1036
1054
  velocity = 0;
1037
1055
  if (rafId !== null) {
@@ -1065,6 +1083,7 @@ function springSignal(initial, options) {
1065
1083
  fadeIn,
1066
1084
  fadeOut,
1067
1085
  flipIn,
1086
+ prefersReducedMotion,
1068
1087
  pulse,
1069
1088
  reducedMotion,
1070
1089
  scaleDown,
package/dist/motion.d.cts CHANGED
@@ -134,6 +134,13 @@ declare function viewTransition(callback: () => void | Promise<void>): {
134
134
  isTransitioning: () => boolean;
135
135
  };
136
136
 
137
+ /**
138
+ * One-shot check of the `prefers-reduced-motion: reduce` media query. Returns
139
+ * false under SSR / where `matchMedia` is unavailable. Use this for imperative
140
+ * "should I animate right now?" decisions; use {@link reducedMotion} when you
141
+ * need a value that reacts to the user changing the setting.
142
+ */
143
+ declare function prefersReducedMotion(): boolean;
137
144
  /**
138
145
  * reducedMotion returns a reactive boolean tracking whether the user
139
146
  * prefers reduced motion via the `prefers-reduced-motion` media query.
@@ -185,4 +192,4 @@ interface SpringOptions {
185
192
  */
186
193
  declare function springSignal(initial: number, options?: SpringOptions): [get: () => number, set: (target: number) => void, dispose: () => void];
187
194
 
188
- export { type AnimationPreset, type PresetOptions, type SlideDirection, type SpringOptions, TransitionGroup, type TransitionGroupOptions, type TransitionOptions, animate, bounceIn, bounceOut, fadeIn, fadeOut, flipIn, pulse, reducedMotion, scaleDown, scaleUp, sequence, shake, slideIn, slideOut, spring, springSignal, stagger, transition, viewTransition };
195
+ export { type AnimationPreset, type PresetOptions, type SlideDirection, type SpringOptions, TransitionGroup, type TransitionGroupOptions, type TransitionOptions, animate, bounceIn, bounceOut, fadeIn, fadeOut, flipIn, prefersReducedMotion, pulse, reducedMotion, scaleDown, scaleUp, sequence, shake, slideIn, slideOut, spring, springSignal, stagger, transition, viewTransition };
package/dist/motion.d.ts CHANGED
@@ -134,6 +134,13 @@ declare function viewTransition(callback: () => void | Promise<void>): {
134
134
  isTransitioning: () => boolean;
135
135
  };
136
136
 
137
+ /**
138
+ * One-shot check of the `prefers-reduced-motion: reduce` media query. Returns
139
+ * false under SSR / where `matchMedia` is unavailable. Use this for imperative
140
+ * "should I animate right now?" decisions; use {@link reducedMotion} when you
141
+ * need a value that reacts to the user changing the setting.
142
+ */
143
+ declare function prefersReducedMotion(): boolean;
137
144
  /**
138
145
  * reducedMotion returns a reactive boolean tracking whether the user
139
146
  * prefers reduced motion via the `prefers-reduced-motion` media query.
@@ -185,4 +192,4 @@ interface SpringOptions {
185
192
  */
186
193
  declare function springSignal(initial: number, options?: SpringOptions): [get: () => number, set: (target: number) => void, dispose: () => void];
187
194
 
188
- export { type AnimationPreset, type PresetOptions, type SlideDirection, type SpringOptions, TransitionGroup, type TransitionGroupOptions, type TransitionOptions, animate, bounceIn, bounceOut, fadeIn, fadeOut, flipIn, pulse, reducedMotion, scaleDown, scaleUp, sequence, shake, slideIn, slideOut, spring, springSignal, stagger, transition, viewTransition };
195
+ export { type AnimationPreset, type PresetOptions, type SlideDirection, type SpringOptions, TransitionGroup, type TransitionGroupOptions, type TransitionOptions, animate, bounceIn, bounceOut, fadeIn, fadeOut, flipIn, prefersReducedMotion, pulse, reducedMotion, scaleDown, scaleUp, sequence, shake, slideIn, slideOut, spring, springSignal, stagger, transition, viewTransition };
package/dist/motion.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  fadeIn,
7
7
  fadeOut,
8
8
  flipIn,
9
+ prefersReducedMotion,
9
10
  pulse,
10
11
  reducedMotion,
11
12
  scaleDown,
@@ -19,9 +20,10 @@ import {
19
20
  stagger,
20
21
  transition,
21
22
  viewTransition
22
- } from "./chunk-WL7BIR6O.js";
23
- import "./chunk-WZG2SZOT.js";
24
- import "./chunk-TEFZT5PJ.js";
23
+ } from "./chunk-25LY5SRH.js";
24
+ import "./chunk-5VGSK6D2.js";
25
+ import "./chunk-IWFE4AHO.js";
26
+ import "./chunk-UOMYIAG6.js";
25
27
  import "./chunk-COY6PUD2.js";
26
28
  export {
27
29
  TransitionGroup,
@@ -31,6 +33,7 @@ export {
31
33
  fadeIn,
32
34
  fadeOut,
33
35
  flipIn,
36
+ prefersReducedMotion,
34
37
  pulse,
35
38
  reducedMotion,
36
39
  scaleDown,