sibujs 4.4.0 → 4.6.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/README.md +11 -0
- package/dist/browser.cjs +339 -130
- package/dist/browser.d.cts +61 -16
- package/dist/browser.d.ts +61 -16
- package/dist/browser.js +8 -6
- package/dist/build.cjs +273 -82
- package/dist/build.js +15 -16
- package/dist/cdn.dev.global.js +12 -12
- package/dist/cdn.full.dev.global.js +11 -11
- package/dist/cdn.full.global.js +10 -10
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
- package/dist/chunk-3ISI6ACU.js +44 -0
- package/dist/{chunk-VCTAEPSB.js → chunk-47M47FOM.js} +11 -3
- package/dist/chunk-5HZXGZ6T.js +24 -0
- package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
- package/dist/{chunk-3BTTCZ5J.js → chunk-5Q4R7HCL.js} +42 -4
- package/dist/{chunk-ADM46X22.js → chunk-7GQCWFOE.js} +157 -61
- package/dist/{chunk-4Z3SPQ67.js → chunk-7NCARGJW.js} +16 -8
- package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
- package/dist/{chunk-LQFGQNMV.js → chunk-AIF3Z2T7.js} +302 -39
- package/dist/{chunk-UCALUKB5.js → chunk-BAAG6ZTI.js} +98 -29
- package/dist/{chunk-NVNJH22U.js → chunk-D33YTSX5.js} +2 -2
- package/dist/{chunk-M2F7TZHH.js → chunk-DKGBBKOF.js} +136 -80
- package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
- package/dist/{chunk-HFCOH2GN.js → chunk-HYXDKS4N.js} +153 -110
- package/dist/chunk-J6FW5TV6.js +233 -0
- package/dist/{chunk-36S2YPP4.js → chunk-JSXPZCET.js} +1 -1
- package/dist/chunk-NYNYSPK7.js +318 -0
- package/dist/{chunk-HQSEH5F6.js → chunk-ORMZXBKQ.js} +108 -45
- package/dist/{chunk-LYVUX7NT.js → chunk-OXUY2A6L.js} +287 -130
- package/dist/{chunk-6GSIXTWX.js → chunk-PK6FK2G2.js} +187 -66
- package/dist/{chunk-W2EQ7X2L.js → chunk-QE4TTDU3.js} +47 -9
- package/dist/{chunk-XLO7SLIX.js → chunk-SXXVZMKZ.js} +262 -70
- package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
- package/dist/{chunk-RR7M3FHM.js → chunk-UZQ6ALFS.js} +3 -3
- package/dist/{chunk-PNIRUQ4C.js → chunk-VVWPJ543.js} +6 -8
- package/dist/{chunk-7GIHSAWB.js → chunk-XC4MEKGA.js} +3 -3
- package/dist/{chunk-SKPTERHP.js → chunk-XRRZKZYX.js} +55 -31
- package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
- package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
- package/dist/{customElement-CNZxEB9G.d.ts → customElement-MmInOW1U.d.cts} +59 -10
- package/dist/{customElement-CNZxEB9G.d.cts → customElement-MmInOW1U.d.ts} +59 -10
- package/dist/data.cjs +293 -125
- package/dist/data.d.cts +47 -9
- package/dist/data.d.ts +47 -9
- package/dist/data.js +12 -9
- package/dist/devtools.cjs +121 -58
- package/dist/devtools.js +7 -8
- package/dist/dispose-GEIG2KOF.js +28 -0
- package/dist/ecosystem.cjs +391 -112
- package/dist/ecosystem.d.cts +31 -7
- package/dist/ecosystem.d.ts +31 -7
- package/dist/ecosystem.js +12 -12
- package/dist/extras.cjs +2250 -879
- package/dist/extras.d.cts +10 -9
- package/dist/extras.d.ts +10 -9
- package/dist/extras.js +39 -28
- package/dist/index.cjs +273 -82
- package/dist/index.d.cts +44 -154
- package/dist/index.d.ts +44 -154
- package/dist/index.js +24 -27
- package/dist/motion.cjs +137 -42
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +397 -48
- package/dist/patterns.d.cts +32 -9
- package/dist/patterns.d.ts +32 -9
- package/dist/patterns.js +8 -8
- package/dist/performance.cjs +338 -217
- package/dist/performance.d.cts +2 -2
- package/dist/performance.d.ts +2 -2
- package/dist/performance.js +8 -9
- package/dist/plugin-DVgSnTfK.d.cts +112 -0
- package/dist/plugin-DVgSnTfK.d.ts +112 -0
- package/dist/plugins.cjs +587 -203
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +35 -23
- package/dist/signal-EotCj4hS.d.cts +110 -0
- package/dist/signal-EotCj4hS.d.ts +110 -0
- package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
- package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
- package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
- package/dist/ssr.cjs +214 -73
- package/dist/ssr.d.cts +9 -3
- package/dist/ssr.d.ts +9 -3
- package/dist/ssr.js +11 -12
- package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
- package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
- package/dist/tagFactory-DFstCLQV.d.cts +117 -0
- package/dist/tagFactory-DkaNVUNV.d.ts +117 -0
- package/dist/testing.cjs +2481 -2153
- package/dist/testing.d.cts +56 -5
- package/dist/testing.d.ts +56 -5
- package/dist/testing.js +580 -307
- package/dist/ui.cjs +798 -328
- package/dist/ui.d.cts +40 -7
- package/dist/ui.d.ts +40 -7
- package/dist/ui.js +151 -56
- package/dist/widgets.cjs +319 -285
- package/dist/widgets.js +9 -10
- package/package.json +2 -2
- package/dist/chunk-2WLZ6757.js +0 -149
- package/dist/chunk-7NBDXVHS.js +0 -60
- package/dist/chunk-CCSJMTRN.js +0 -15
- package/dist/chunk-QKRPLZ2V.js +0 -108
- package/dist/chunk-WWV3SJ3L.js +0 -131
- package/dist/dispose-46BOMMQJ.js +0 -19
- package/dist/plugin-D30wlGW5.d.cts +0 -71
- package/dist/plugin-D30wlGW5.d.ts +0 -71
- package/dist/tagFactory-Bzupt4Pj.d.cts +0 -55
- package/dist/tagFactory-Bzupt4Pj.d.ts +0 -55
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
catchError,
|
|
15
15
|
catchErrorAsync,
|
|
16
16
|
clickOutside,
|
|
17
|
+
context,
|
|
17
18
|
copyOnClick,
|
|
18
19
|
deepEqual,
|
|
19
20
|
deepSignal,
|
|
@@ -52,7 +53,7 @@ import {
|
|
|
52
53
|
unregisterIsland,
|
|
53
54
|
when,
|
|
54
55
|
writable
|
|
55
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-7GQCWFOE.js";
|
|
56
57
|
import {
|
|
57
58
|
a,
|
|
58
59
|
abbr,
|
|
@@ -190,36 +191,33 @@ import {
|
|
|
190
191
|
use,
|
|
191
192
|
var_,
|
|
192
193
|
video
|
|
193
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-JSXPZCET.js";
|
|
194
195
|
import {
|
|
195
196
|
trustHTML
|
|
196
|
-
} from "./chunk-
|
|
197
|
+
} from "./chunk-HURREPU2.js";
|
|
197
198
|
import {
|
|
198
199
|
watch
|
|
199
|
-
} from "./chunk-
|
|
200
|
+
} from "./chunk-UZQ6ALFS.js";
|
|
200
201
|
import {
|
|
201
202
|
__resetIdCounter,
|
|
202
203
|
createId
|
|
203
|
-
} from "./chunk-
|
|
204
|
-
import {
|
|
205
|
-
context
|
|
206
|
-
} from "./chunk-7NBDXVHS.js";
|
|
204
|
+
} from "./chunk-3ISI6ACU.js";
|
|
207
205
|
import {
|
|
208
206
|
SVG_NS,
|
|
209
207
|
tagFactory
|
|
210
|
-
} from "./chunk-
|
|
208
|
+
} from "./chunk-VVWPJ543.js";
|
|
211
209
|
import {
|
|
212
210
|
bindDynamic
|
|
213
|
-
} from "./chunk-
|
|
211
|
+
} from "./chunk-47M47FOM.js";
|
|
214
212
|
import {
|
|
215
213
|
derived
|
|
216
|
-
} from "./chunk-
|
|
217
|
-
import "./chunk-
|
|
214
|
+
} from "./chunk-QE4TTDU3.js";
|
|
215
|
+
import "./chunk-2INLLLMZ.js";
|
|
218
216
|
import "./chunk-7ZHH77QA.js";
|
|
219
217
|
import {
|
|
220
218
|
effect,
|
|
221
219
|
on
|
|
222
|
-
} from "./chunk-
|
|
220
|
+
} from "./chunk-XC4MEKGA.js";
|
|
223
221
|
import {
|
|
224
222
|
disableSSR,
|
|
225
223
|
enableSSR,
|
|
@@ -228,33 +226,32 @@ import {
|
|
|
228
226
|
isSSR,
|
|
229
227
|
runInSSRContext,
|
|
230
228
|
withSSR
|
|
231
|
-
} from "./chunk-
|
|
232
|
-
import
|
|
233
|
-
MAX_DRAIN_TEARDOWNS,
|
|
234
|
-
checkLeaks,
|
|
235
|
-
dispose,
|
|
236
|
-
registerDisposer,
|
|
237
|
-
replaceChildrenSafely,
|
|
238
|
-
reportDrainRunaway,
|
|
239
|
-
unregisterDisposer
|
|
240
|
-
} from "./chunk-QKRPLZ2V.js";
|
|
229
|
+
} from "./chunk-7XHATCIH.js";
|
|
230
|
+
import "./chunk-5HZXGZ6T.js";
|
|
241
231
|
import {
|
|
242
232
|
batch,
|
|
243
233
|
enqueueBatchedSignal,
|
|
244
234
|
external,
|
|
245
235
|
isBatching,
|
|
246
236
|
signal
|
|
247
|
-
} from "./chunk-
|
|
237
|
+
} from "./chunk-D33YTSX5.js";
|
|
248
238
|
import {
|
|
249
239
|
retrack,
|
|
250
240
|
setMaxDrainIterations,
|
|
251
241
|
untracked
|
|
252
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-5Q4R7HCL.js";
|
|
253
243
|
import {
|
|
244
|
+
MAX_DRAIN_TEARDOWNS,
|
|
245
|
+
checkLeaks,
|
|
246
|
+
dispose,
|
|
254
247
|
getRuntimeErrorHandler,
|
|
248
|
+
registerDisposer,
|
|
249
|
+
replaceChildrenSafely,
|
|
250
|
+
reportDrainRunaway,
|
|
255
251
|
reportError,
|
|
256
|
-
setRuntimeErrorHandler
|
|
257
|
-
|
|
252
|
+
setRuntimeErrorHandler,
|
|
253
|
+
unregisterDisposer
|
|
254
|
+
} from "./chunk-NYNYSPK7.js";
|
|
258
255
|
export {
|
|
259
256
|
DynamicComponent,
|
|
260
257
|
ErrorBoundary,
|
package/dist/motion.cjs
CHANGED
|
@@ -44,17 +44,6 @@ __export(motion_exports, {
|
|
|
44
44
|
});
|
|
45
45
|
module.exports = __toCommonJS(motion_exports);
|
|
46
46
|
|
|
47
|
-
// src/core/dev.ts
|
|
48
|
-
var DEV = typeof __SIBU_DEV__ !== "undefined" ? !!__SIBU_DEV__ : typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
|
|
49
|
-
// safe default: off in browser, on in test/dev Node
|
|
50
|
-
typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
|
|
51
|
-
);
|
|
52
|
-
function devWarn(message) {
|
|
53
|
-
if (typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) {
|
|
54
|
-
console.warn(`[SibuJS] ${message}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
47
|
// src/core/errors.ts
|
|
59
48
|
var ERROR_STATE_KEY = /* @__PURE__ */ Symbol.for("sibujs.runtime-errors.v1");
|
|
60
49
|
function state() {
|
|
@@ -143,9 +132,37 @@ function reportError(error, context) {
|
|
|
143
132
|
});
|
|
144
133
|
}
|
|
145
134
|
|
|
135
|
+
// src/core/dev.ts
|
|
136
|
+
var DEV = typeof __SIBU_DEV__ !== "undefined" ? !!__SIBU_DEV__ : typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
|
|
137
|
+
// safe default: off in browser, on in test/dev Node
|
|
138
|
+
typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
|
|
139
|
+
);
|
|
140
|
+
function devWarn(message) {
|
|
141
|
+
if (typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) {
|
|
142
|
+
console.warn(`[SibuJS] ${message}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
146
|
// src/core/rendering/dispose.ts
|
|
147
147
|
var elementDisposers = /* @__PURE__ */ new WeakMap();
|
|
148
148
|
var activeBindingCount = 0;
|
|
149
|
+
function resolveCapture(capture) {
|
|
150
|
+
let frame = capture;
|
|
151
|
+
while (frame?.closed) frame = frame.forwardTo;
|
|
152
|
+
return frame ?? null;
|
|
153
|
+
}
|
|
154
|
+
var registrationCaptures = [];
|
|
155
|
+
function currentDisposerCapture() {
|
|
156
|
+
return resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
|
|
157
|
+
}
|
|
158
|
+
function beginDisposerCapture(capture) {
|
|
159
|
+
if (capture === null && registrationCaptures.length === 0) return false;
|
|
160
|
+
registrationCaptures.push(resolveCapture(capture));
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
function endDisposerCapture() {
|
|
164
|
+
registrationCaptures.pop();
|
|
165
|
+
}
|
|
149
166
|
function registerDisposer(node, teardown) {
|
|
150
167
|
let disposers = elementDisposers.get(node);
|
|
151
168
|
if (!disposers) {
|
|
@@ -154,6 +171,8 @@ function registerDisposer(node, teardown) {
|
|
|
154
171
|
}
|
|
155
172
|
disposers.push(teardown);
|
|
156
173
|
if (DEV) activeBindingCount++;
|
|
174
|
+
const capture = resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
|
|
175
|
+
if (capture) capture.entries.push([node, teardown]);
|
|
157
176
|
}
|
|
158
177
|
|
|
159
178
|
// src/ui/transition.ts
|
|
@@ -183,6 +202,15 @@ function transition(element, options = {}) {
|
|
|
183
202
|
resolvePrev();
|
|
184
203
|
}
|
|
185
204
|
}
|
|
205
|
+
function complete(callback, name, resolve) {
|
|
206
|
+
try {
|
|
207
|
+
callback?.();
|
|
208
|
+
} catch (error) {
|
|
209
|
+
reportError(error, { phase: "async", name, node: element });
|
|
210
|
+
} finally {
|
|
211
|
+
resolve();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
186
214
|
function enter() {
|
|
187
215
|
return new Promise((resolve) => {
|
|
188
216
|
cancelPending();
|
|
@@ -195,8 +223,7 @@ function transition(element, options = {}) {
|
|
|
195
223
|
activeTimer = null;
|
|
196
224
|
pendingResolve = null;
|
|
197
225
|
if (enterClass) element.classList.remove(enterClass);
|
|
198
|
-
onEnterDone
|
|
199
|
-
resolve();
|
|
226
|
+
complete(onEnterDone, "transition(onEnterDone)", resolve);
|
|
200
227
|
};
|
|
201
228
|
if (duration > 0) {
|
|
202
229
|
pendingResolve = resolve;
|
|
@@ -217,8 +244,7 @@ function transition(element, options = {}) {
|
|
|
217
244
|
activeTimer = null;
|
|
218
245
|
pendingResolve = null;
|
|
219
246
|
if (leaveClass) element.classList.remove(leaveClass);
|
|
220
|
-
onLeaveDone
|
|
221
|
-
resolve();
|
|
247
|
+
complete(onLeaveDone, "transition(onLeaveDone)", resolve);
|
|
222
248
|
};
|
|
223
249
|
if (duration > 0) {
|
|
224
250
|
pendingResolve = resolve;
|
|
@@ -391,8 +417,18 @@ function untracked(fn) {
|
|
|
391
417
|
var subscriberEpochCounter = 0;
|
|
392
418
|
function retrack(effectFn, subscriber) {
|
|
393
419
|
const prev = currentSubscriber;
|
|
420
|
+
let savedDepth = 0;
|
|
421
|
+
let savedSuspendSub = null;
|
|
422
|
+
if (trackingSuspended) {
|
|
423
|
+
savedDepth = suspendDepth;
|
|
424
|
+
savedSuspendSub = suspendSavedSub;
|
|
425
|
+
suspendDepth = 0;
|
|
426
|
+
suspendSavedSub = null;
|
|
427
|
+
trackingSuspended = false;
|
|
428
|
+
}
|
|
394
429
|
currentSubscriber = subscriber;
|
|
395
430
|
const sub = subscriber;
|
|
431
|
+
if (sub._cap === void 0) sub._cap = currentDisposerCapture();
|
|
396
432
|
const epoch = ++subscriberEpochCounter;
|
|
397
433
|
sub._epoch = epoch;
|
|
398
434
|
sub._structDirty = false;
|
|
@@ -405,6 +441,11 @@ function retrack(effectFn, subscriber) {
|
|
|
405
441
|
effectFn();
|
|
406
442
|
} finally {
|
|
407
443
|
currentSubscriber = prev;
|
|
444
|
+
if (savedDepth !== 0) {
|
|
445
|
+
suspendDepth = savedDepth;
|
|
446
|
+
suspendSavedSub = savedSuspendSub;
|
|
447
|
+
trackingSuspended = true;
|
|
448
|
+
}
|
|
408
449
|
let node = sub.depsHead ?? null;
|
|
409
450
|
while (node !== null) {
|
|
410
451
|
const next = node.subNext;
|
|
@@ -424,11 +465,25 @@ function track(effectFn, subscriber) {
|
|
|
424
465
|
if (!subscriber) return reactiveBinding(effectFn);
|
|
425
466
|
cleanup(subscriber);
|
|
426
467
|
const prev = currentSubscriber;
|
|
468
|
+
let savedDepth = 0;
|
|
469
|
+
let savedSuspendSub = null;
|
|
470
|
+
if (trackingSuspended) {
|
|
471
|
+
savedDepth = suspendDepth;
|
|
472
|
+
savedSuspendSub = suspendSavedSub;
|
|
473
|
+
suspendDepth = 0;
|
|
474
|
+
suspendSavedSub = null;
|
|
475
|
+
trackingSuspended = false;
|
|
476
|
+
}
|
|
427
477
|
currentSubscriber = subscriber;
|
|
428
478
|
try {
|
|
429
479
|
effectFn();
|
|
430
480
|
} finally {
|
|
431
481
|
currentSubscriber = prev;
|
|
482
|
+
if (savedDepth !== 0) {
|
|
483
|
+
suspendDepth = savedDepth;
|
|
484
|
+
suspendSavedSub = savedSuspendSub;
|
|
485
|
+
trackingSuspended = true;
|
|
486
|
+
}
|
|
432
487
|
const sub2 = subscriber;
|
|
433
488
|
for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
|
|
434
489
|
const sig = n.sig;
|
|
@@ -565,7 +620,12 @@ function drainQueue() {
|
|
|
565
620
|
quarantined.add(sub);
|
|
566
621
|
continue;
|
|
567
622
|
}
|
|
568
|
-
|
|
623
|
+
const pushed = beginDisposerCapture(sub._cap ?? null);
|
|
624
|
+
try {
|
|
625
|
+
safeInvoke(sub);
|
|
626
|
+
} finally {
|
|
627
|
+
if (pushed) endDisposerCapture();
|
|
628
|
+
}
|
|
569
629
|
}
|
|
570
630
|
}
|
|
571
631
|
function drainNotificationQueue() {
|
|
@@ -599,8 +659,9 @@ function propagateDirty(sub) {
|
|
|
599
659
|
if (s._c) {
|
|
600
660
|
const nSig = s._sig;
|
|
601
661
|
if (nSig) {
|
|
602
|
-
if (!nSig._d) {
|
|
662
|
+
if (!nSig._d || nSig._f === true) {
|
|
603
663
|
nSig._d = true;
|
|
664
|
+
nSig._f = false;
|
|
604
665
|
stack.push(nSig);
|
|
605
666
|
}
|
|
606
667
|
} else {
|
|
@@ -700,7 +761,7 @@ function forEachSubscriber(signal2, visit) {
|
|
|
700
761
|
}
|
|
701
762
|
|
|
702
763
|
// src/reactivity/track.ts
|
|
703
|
-
var _runtimeVersion = true ? "4.
|
|
764
|
+
var _runtimeVersion = true ? "4.6.0" : "dev";
|
|
704
765
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
705
766
|
function resolveReactiveApi() {
|
|
706
767
|
const g = globalThis;
|
|
@@ -1054,22 +1115,54 @@ async function sequence(steps) {
|
|
|
1054
1115
|
}
|
|
1055
1116
|
}
|
|
1056
1117
|
|
|
1118
|
+
// src/utils/adoptThenable.ts
|
|
1119
|
+
function adoptThenable(value) {
|
|
1120
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return null;
|
|
1121
|
+
let then;
|
|
1122
|
+
try {
|
|
1123
|
+
then = value.then;
|
|
1124
|
+
} catch (error) {
|
|
1125
|
+
return Promise.reject(error);
|
|
1126
|
+
}
|
|
1127
|
+
if (typeof then !== "function") return null;
|
|
1128
|
+
return new Promise((resolve, reject) => {
|
|
1129
|
+
queueMicrotask(() => {
|
|
1130
|
+
try {
|
|
1131
|
+
Reflect.apply(then, value, [resolve, reject]);
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
reject(error);
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1057
1139
|
// src/ui/TransitionGroup.ts
|
|
1058
1140
|
function TransitionGroup(options) {
|
|
1059
1141
|
const [elements, setElements] = signal([]);
|
|
1060
1142
|
const positions = /* @__PURE__ */ new Map();
|
|
1143
|
+
function runCallback(name, callback, el) {
|
|
1144
|
+
const report = (error) => reportError(error, { phase: "async", name: `TransitionGroup.${name}`, node: el });
|
|
1145
|
+
try {
|
|
1146
|
+
adoptThenable(callback(el))?.then(void 0, report);
|
|
1147
|
+
} catch (error) {
|
|
1148
|
+
report(error);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1061
1151
|
function add(el) {
|
|
1062
1152
|
setElements((prev) => [...prev, el]);
|
|
1063
|
-
if (options.enter)
|
|
1064
|
-
options.enter(el);
|
|
1065
|
-
}
|
|
1153
|
+
if (options.enter) runCallback("enter", options.enter, el);
|
|
1066
1154
|
}
|
|
1067
1155
|
async function remove(el) {
|
|
1068
|
-
|
|
1069
|
-
|
|
1156
|
+
try {
|
|
1157
|
+
if (options.leave) {
|
|
1158
|
+
await adoptThenable(options.leave(el));
|
|
1159
|
+
}
|
|
1160
|
+
} catch (error) {
|
|
1161
|
+
reportError(error, { phase: "async", name: "TransitionGroup.leave", node: el });
|
|
1162
|
+
} finally {
|
|
1163
|
+
positions.delete(el);
|
|
1164
|
+
setElements((prev) => prev.filter((e) => e !== el));
|
|
1070
1165
|
}
|
|
1071
|
-
positions.delete(el);
|
|
1072
|
-
setElements((prev) => prev.filter((e) => e !== el));
|
|
1073
1166
|
}
|
|
1074
1167
|
function track3(newElements) {
|
|
1075
1168
|
const oldPositions = /* @__PURE__ */ new Map();
|
|
@@ -1081,17 +1174,13 @@ function TransitionGroup(options) {
|
|
|
1081
1174
|
const currentSet = new Set(elements());
|
|
1082
1175
|
for (const el of newElements) {
|
|
1083
1176
|
if (!currentSet.has(el)) {
|
|
1084
|
-
if (options.enter)
|
|
1085
|
-
options.enter(el);
|
|
1086
|
-
}
|
|
1177
|
+
if (options.enter) runCallback("enter", options.enter, el);
|
|
1087
1178
|
}
|
|
1088
1179
|
}
|
|
1089
1180
|
const newSet = new Set(newElements);
|
|
1090
1181
|
for (const el of elements()) {
|
|
1091
1182
|
if (!newSet.has(el)) {
|
|
1092
|
-
if (options.leave)
|
|
1093
|
-
options.leave(el);
|
|
1094
|
-
}
|
|
1183
|
+
if (options.leave) runCallback("leave", options.leave, el);
|
|
1095
1184
|
}
|
|
1096
1185
|
}
|
|
1097
1186
|
setElements(newElements);
|
|
@@ -1101,7 +1190,7 @@ function TransitionGroup(options) {
|
|
|
1101
1190
|
if (oldRect && typeof el.getBoundingClientRect === "function") {
|
|
1102
1191
|
const newRect = el.getBoundingClientRect();
|
|
1103
1192
|
if (oldRect.left !== newRect.left || oldRect.top !== newRect.top) {
|
|
1104
|
-
options.move
|
|
1193
|
+
runCallback("move", options.move, el);
|
|
1105
1194
|
}
|
|
1106
1195
|
}
|
|
1107
1196
|
}
|
|
@@ -1152,9 +1241,13 @@ function springSignal(initial, options) {
|
|
|
1152
1241
|
let target = initial;
|
|
1153
1242
|
let rafId = null;
|
|
1154
1243
|
let lastTime = 0;
|
|
1244
|
+
let disposed = false;
|
|
1245
|
+
const canAnimate = () => typeof requestAnimationFrame === "function";
|
|
1155
1246
|
const REF_DT_MS = 1e3 / 60;
|
|
1156
1247
|
const MAX_STEP_RATIO = 4;
|
|
1157
1248
|
function tick(now) {
|
|
1249
|
+
rafId = null;
|
|
1250
|
+
if (disposed) return;
|
|
1158
1251
|
if (lastTime === 0) lastTime = now;
|
|
1159
1252
|
const rawDt = now - lastTime;
|
|
1160
1253
|
lastTime = now;
|
|
@@ -1167,23 +1260,27 @@ function springSignal(initial, options) {
|
|
|
1167
1260
|
if (Math.abs(current - target) < precision && Math.abs(velocity) < precision) {
|
|
1168
1261
|
current = target;
|
|
1169
1262
|
velocity = 0;
|
|
1170
|
-
rafId = null;
|
|
1171
1263
|
lastTime = 0;
|
|
1172
1264
|
setValue(current);
|
|
1173
1265
|
return;
|
|
1174
1266
|
}
|
|
1175
1267
|
setValue(current);
|
|
1268
|
+
if (disposed || rafId !== null) return;
|
|
1176
1269
|
rafId = requestAnimationFrame(tick);
|
|
1177
1270
|
}
|
|
1271
|
+
function cancelFrame() {
|
|
1272
|
+
if (rafId !== null) {
|
|
1273
|
+
if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(rafId);
|
|
1274
|
+
rafId = null;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1178
1277
|
function set(newTarget) {
|
|
1278
|
+
if (disposed) return;
|
|
1179
1279
|
target = newTarget;
|
|
1180
|
-
if (prefersReducedMotion()) {
|
|
1280
|
+
if (!canAnimate() || prefersReducedMotion()) {
|
|
1181
1281
|
current = newTarget;
|
|
1182
1282
|
velocity = 0;
|
|
1183
|
-
|
|
1184
|
-
cancelAnimationFrame(rafId);
|
|
1185
|
-
rafId = null;
|
|
1186
|
-
}
|
|
1283
|
+
cancelFrame();
|
|
1187
1284
|
lastTime = 0;
|
|
1188
1285
|
setValue(current);
|
|
1189
1286
|
return;
|
|
@@ -1194,10 +1291,8 @@ function springSignal(initial, options) {
|
|
|
1194
1291
|
}
|
|
1195
1292
|
}
|
|
1196
1293
|
function dispose() {
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
rafId = null;
|
|
1200
|
-
}
|
|
1294
|
+
disposed = true;
|
|
1295
|
+
cancelFrame();
|
|
1201
1296
|
lastTime = 0;
|
|
1202
1297
|
}
|
|
1203
1298
|
return [value, set, dispose];
|
package/dist/motion.js
CHANGED
|
@@ -20,11 +20,11 @@ import {
|
|
|
20
20
|
stagger,
|
|
21
21
|
transition,
|
|
22
22
|
viewTransition
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-XRRZKZYX.js";
|
|
24
|
+
import "./chunk-5HZXGZ6T.js";
|
|
25
|
+
import "./chunk-D33YTSX5.js";
|
|
26
|
+
import "./chunk-5Q4R7HCL.js";
|
|
27
|
+
import "./chunk-NYNYSPK7.js";
|
|
28
28
|
export {
|
|
29
29
|
TransitionGroup,
|
|
30
30
|
animate,
|