sibujs 3.3.2 → 3.4.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/browser.cjs +21 -4
- package/dist/browser.js +4 -4
- package/dist/build.cjs +3343 -3009
- package/dist/build.js +12 -11
- package/dist/cdn.global.js +7 -7
- package/dist/{chunk-AEOLHSSQ.js → chunk-3DVGCW7O.js} +72 -25
- package/dist/{chunk-6TCOWMGY.js → chunk-3Z2NGWQI.js} +1 -1
- package/dist/chunk-7ZHH77QA.js +9 -0
- package/dist/{chunk-2ARSB7NG.js → chunk-APFRCIRI.js} +2906 -2569
- package/dist/{chunk-62V653X2.js → chunk-AXFWGY32.js} +79 -44
- package/dist/{chunk-N5TQVEKE.js → chunk-BUKYCWHX.js} +1 -1
- package/dist/{chunk-655B7MMR.js → chunk-CEBWDD63.js} +15 -8
- package/dist/{chunk-YUBEOWII.js → chunk-ELXMRSVN.js} +16 -5
- package/dist/{chunk-FJIRS3FM.js → chunk-F7HW2NI5.js} +1 -3
- package/dist/{chunk-P7C7SEJV.js → chunk-FKQG7FTY.js} +5 -5
- package/dist/{chunk-RLTFJYDN.js → chunk-H5FI5WDP.js} +1 -1
- package/dist/{chunk-G6N3LMO2.js → chunk-ITWCTZYH.js} +1 -1
- package/dist/{chunk-YUR5SX7F.js → chunk-JCO7AHNU.js} +70 -59
- package/dist/{chunk-ZEUP4TUD.js → chunk-JNGGM2XE.js} +6 -6
- package/dist/{chunk-QCFBIVIQ.js → chunk-K35BAR4P.js} +1 -1
- package/dist/{chunk-JCQG2I2G.js → chunk-KZBEVFXZ.js} +1 -1
- package/dist/{chunk-FJO2ZL4Q.js → chunk-OAVXAFAY.js} +73 -16
- package/dist/{chunk-A7CZH3GN.js → chunk-ODXVQ3CS.js} +41 -20
- package/dist/{chunk-4NJEAPLI.js → chunk-OOUQUCNN.js} +1 -1
- package/dist/{chunk-5VH3GIDX.js → chunk-RT3IYFN2.js} +1 -1
- package/dist/{chunk-Q46YIQYW.js → chunk-S3V6ZXPI.js} +22 -5
- package/dist/{chunk-IQJ36UTJ.js → chunk-WSGLJYFI.js} +31 -24
- package/dist/{chunk-3JHCYHWN.js → chunk-WWV3SJ3L.js} +19 -13
- package/dist/data.cjs +16 -2
- package/dist/data.js +7 -6
- package/dist/devtools.cjs +71 -21
- package/dist/devtools.d.cts +12 -5
- package/dist/devtools.d.ts +12 -5
- package/dist/devtools.js +6 -5
- package/dist/ecosystem.cjs +11 -2
- package/dist/ecosystem.d.cts +1 -1
- package/dist/ecosystem.d.ts +1 -1
- package/dist/ecosystem.js +10 -9
- package/dist/extras.cjs +454 -250
- package/dist/extras.d.cts +2 -2
- package/dist/extras.d.ts +2 -2
- package/dist/extras.js +26 -22
- package/dist/index.cjs +3385 -3045
- package/dist/index.d.cts +1179 -1057
- package/dist/index.d.ts +1179 -1057
- package/dist/index.js +32 -19
- package/dist/motion.cjs +223 -204
- package/dist/motion.d.cts +8 -1
- package/dist/motion.d.ts +8 -1
- package/dist/motion.js +6 -3
- package/dist/patterns.cjs +13 -6
- package/dist/patterns.d.cts +4 -1
- package/dist/patterns.d.ts +4 -1
- package/dist/patterns.js +5 -5
- package/dist/performance.cjs +70 -56
- package/dist/performance.js +6 -5
- package/dist/plugins.cjs +98 -42
- package/dist/plugins.d.cts +2 -1
- package/dist/plugins.d.ts +2 -1
- package/dist/plugins.js +89 -36
- package/dist/ssr.cjs +112 -91
- package/dist/ssr.d.cts +8 -1
- package/dist/ssr.d.ts +8 -1
- package/dist/ssr.js +9 -8
- package/dist/{tagFactory-S17H2qxu.d.ts → tagFactory-Bzupt4Pj.d.cts} +1 -1
- package/dist/{tagFactory-S17H2qxu.d.cts → tagFactory-Bzupt4Pj.d.ts} +1 -1
- package/dist/testing.cjs +18 -4
- package/dist/testing.js +18 -7
- package/dist/ui.cjs +322 -281
- package/dist/ui.d.cts +0 -20
- package/dist/ui.d.ts +0 -20
- package/dist/ui.js +27 -21
- package/dist/widgets.cjs +75 -13
- package/dist/widgets.d.cts +6 -1
- package/dist/widgets.d.ts +6 -1
- package/dist/widgets.js +7 -6
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -19,13 +19,17 @@ import {
|
|
|
19
19
|
deepSignal,
|
|
20
20
|
defer,
|
|
21
21
|
each,
|
|
22
|
+
enhance,
|
|
23
|
+
enhanceAll,
|
|
22
24
|
getAction,
|
|
23
25
|
getSlot,
|
|
24
26
|
html,
|
|
25
27
|
lazy,
|
|
28
|
+
lazyIsland,
|
|
26
29
|
longPress,
|
|
27
30
|
match,
|
|
28
31
|
mount,
|
|
32
|
+
mountIslands,
|
|
29
33
|
nextTick,
|
|
30
34
|
onCleanup,
|
|
31
35
|
onMount,
|
|
@@ -34,6 +38,7 @@ import {
|
|
|
34
38
|
ref,
|
|
35
39
|
registerAction,
|
|
36
40
|
registerComponent,
|
|
41
|
+
registerIsland,
|
|
37
42
|
resolveComponent,
|
|
38
43
|
setGlobalErrorHandler,
|
|
39
44
|
show,
|
|
@@ -44,13 +49,10 @@ import {
|
|
|
44
49
|
transition,
|
|
45
50
|
trapFocus,
|
|
46
51
|
unregisterComponent,
|
|
52
|
+
unregisterIsland,
|
|
47
53
|
when,
|
|
48
54
|
writable
|
|
49
|
-
} from "./chunk-
|
|
50
|
-
import {
|
|
51
|
-
__resetIdCounter,
|
|
52
|
-
createId
|
|
53
|
-
} from "./chunk-CCSJMTRN.js";
|
|
55
|
+
} from "./chunk-APFRCIRI.js";
|
|
54
56
|
import {
|
|
55
57
|
a,
|
|
56
58
|
abbr,
|
|
@@ -188,36 +190,36 @@ import {
|
|
|
188
190
|
use,
|
|
189
191
|
var_,
|
|
190
192
|
video
|
|
191
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-3Z2NGWQI.js";
|
|
192
194
|
import {
|
|
193
195
|
watch
|
|
194
|
-
} from "./chunk-
|
|
196
|
+
} from "./chunk-H5FI5WDP.js";
|
|
197
|
+
import {
|
|
198
|
+
__resetIdCounter,
|
|
199
|
+
createId
|
|
200
|
+
} from "./chunk-CCSJMTRN.js";
|
|
195
201
|
import {
|
|
196
202
|
trustHTML
|
|
197
203
|
} from "./chunk-EX77FXTT.js";
|
|
198
204
|
import {
|
|
199
205
|
context
|
|
200
|
-
} from "./chunk-
|
|
206
|
+
} from "./chunk-RT3IYFN2.js";
|
|
201
207
|
import {
|
|
202
208
|
SVG_NS,
|
|
203
209
|
tagFactory
|
|
204
|
-
} from "./chunk-
|
|
210
|
+
} from "./chunk-JNGGM2XE.js";
|
|
205
211
|
import {
|
|
206
212
|
bindDynamic
|
|
207
|
-
} from "./chunk-
|
|
213
|
+
} from "./chunk-K35BAR4P.js";
|
|
208
214
|
import {
|
|
209
215
|
derived
|
|
210
|
-
} from "./chunk-
|
|
211
|
-
import
|
|
212
|
-
checkLeaks,
|
|
213
|
-
dispose,
|
|
214
|
-
registerDisposer
|
|
215
|
-
} from "./chunk-5VGSK6D2.js";
|
|
216
|
+
} from "./chunk-ITWCTZYH.js";
|
|
217
|
+
import "./chunk-7ZHH77QA.js";
|
|
216
218
|
import "./chunk-L3GAGWCC.js";
|
|
217
219
|
import {
|
|
218
220
|
effect,
|
|
219
221
|
on
|
|
220
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-BUKYCWHX.js";
|
|
221
223
|
import {
|
|
222
224
|
disableSSR,
|
|
223
225
|
enableSSR,
|
|
@@ -227,17 +229,22 @@ import {
|
|
|
227
229
|
runInSSRContext,
|
|
228
230
|
withSSR
|
|
229
231
|
} from "./chunk-S3NFJO6L.js";
|
|
232
|
+
import {
|
|
233
|
+
checkLeaks,
|
|
234
|
+
dispose,
|
|
235
|
+
registerDisposer
|
|
236
|
+
} from "./chunk-5VGSK6D2.js";
|
|
230
237
|
import {
|
|
231
238
|
batch,
|
|
232
239
|
enqueueBatchedSignal,
|
|
233
240
|
isBatching,
|
|
234
241
|
signal
|
|
235
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-KZBEVFXZ.js";
|
|
236
243
|
import {
|
|
237
244
|
retrack,
|
|
238
245
|
setMaxDrainIterations,
|
|
239
246
|
untracked
|
|
240
|
-
} from "./chunk-
|
|
247
|
+
} from "./chunk-OOUQUCNN.js";
|
|
241
248
|
import "./chunk-COY6PUD2.js";
|
|
242
249
|
export {
|
|
243
250
|
DynamicComponent,
|
|
@@ -311,6 +318,8 @@ export {
|
|
|
311
318
|
em,
|
|
312
319
|
embed,
|
|
313
320
|
enableSSR,
|
|
321
|
+
enhance,
|
|
322
|
+
enhanceAll,
|
|
314
323
|
enqueueBatchedSignal,
|
|
315
324
|
fieldset,
|
|
316
325
|
figcaption,
|
|
@@ -343,6 +352,7 @@ export {
|
|
|
343
352
|
kbd,
|
|
344
353
|
label,
|
|
345
354
|
lazy,
|
|
355
|
+
lazyIsland,
|
|
346
356
|
legend,
|
|
347
357
|
li,
|
|
348
358
|
line,
|
|
@@ -361,6 +371,7 @@ export {
|
|
|
361
371
|
meta,
|
|
362
372
|
meter,
|
|
363
373
|
mount,
|
|
374
|
+
mountIslands,
|
|
364
375
|
nav,
|
|
365
376
|
nextTick,
|
|
366
377
|
noscript,
|
|
@@ -391,6 +402,7 @@ export {
|
|
|
391
402
|
registerAction,
|
|
392
403
|
registerComponent,
|
|
393
404
|
registerDisposer,
|
|
405
|
+
registerIsland,
|
|
394
406
|
resolveComponent,
|
|
395
407
|
retrack,
|
|
396
408
|
rp,
|
|
@@ -443,6 +455,7 @@ export {
|
|
|
443
455
|
u,
|
|
444
456
|
ul,
|
|
445
457
|
unregisterComponent,
|
|
458
|
+
unregisterIsland,
|
|
446
459
|
untracked,
|
|
447
460
|
use,
|
|
448
461
|
var_,
|
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
|
|
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 (
|
|
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
|
|
722
|
-
var _runtimeVersion = true ? "3.
|
|
581
|
+
var _isDev4 = isDev();
|
|
582
|
+
var _runtimeVersion = true ? "3.4.0" : "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 (
|
|
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
|
|
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 =
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 (
|
|
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 };
|