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.cjs
CHANGED
|
@@ -383,6 +383,23 @@ function reportDrainRunaway(label2, executed, remaining) {
|
|
|
383
383
|
);
|
|
384
384
|
}
|
|
385
385
|
var activeBindingCount = 0;
|
|
386
|
+
function resolveCapture(capture) {
|
|
387
|
+
let frame = capture;
|
|
388
|
+
while (frame?.closed) frame = frame.forwardTo;
|
|
389
|
+
return frame ?? null;
|
|
390
|
+
}
|
|
391
|
+
var registrationCaptures = [];
|
|
392
|
+
function currentDisposerCapture() {
|
|
393
|
+
return resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
|
|
394
|
+
}
|
|
395
|
+
function beginDisposerCapture(capture) {
|
|
396
|
+
if (capture === null && registrationCaptures.length === 0) return false;
|
|
397
|
+
registrationCaptures.push(resolveCapture(capture));
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
function endDisposerCapture() {
|
|
401
|
+
registrationCaptures.pop();
|
|
402
|
+
}
|
|
386
403
|
function registerDisposer(node, teardown) {
|
|
387
404
|
let disposers = elementDisposers.get(node);
|
|
388
405
|
if (!disposers) {
|
|
@@ -391,15 +408,18 @@ function registerDisposer(node, teardown) {
|
|
|
391
408
|
}
|
|
392
409
|
disposers.push(teardown);
|
|
393
410
|
if (DEV) activeBindingCount++;
|
|
411
|
+
const capture = resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
|
|
412
|
+
if (capture) capture.entries.push([node, teardown]);
|
|
394
413
|
}
|
|
395
414
|
function unregisterDisposer(node, teardown) {
|
|
396
415
|
const disposers = elementDisposers.get(node);
|
|
397
|
-
if (!disposers) return;
|
|
416
|
+
if (!disposers) return false;
|
|
398
417
|
const index = disposers.indexOf(teardown);
|
|
399
|
-
if (index === -1) return;
|
|
418
|
+
if (index === -1) return false;
|
|
400
419
|
disposers.splice(index, 1);
|
|
401
420
|
if (DEV) activeBindingCount--;
|
|
402
421
|
if (disposers.length === 0) elementDisposers.delete(node);
|
|
422
|
+
return true;
|
|
403
423
|
}
|
|
404
424
|
function dispose(node) {
|
|
405
425
|
const stack = [node];
|
|
@@ -413,33 +433,34 @@ function dispose(node) {
|
|
|
413
433
|
}
|
|
414
434
|
}
|
|
415
435
|
for (let i2 = order.length - 1; i2 >= 0; i2--) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
436
|
+
disposeNodeOwn(order[i2]);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function disposeNodeOwn(node) {
|
|
440
|
+
if (!elementDisposers.has(node)) return;
|
|
441
|
+
let executed = 0;
|
|
442
|
+
let runaway = false;
|
|
443
|
+
while (!runaway) {
|
|
444
|
+
const pending = elementDisposers.get(node);
|
|
445
|
+
if (!pending || pending.length === 0) break;
|
|
446
|
+
const snapshot = pending.slice();
|
|
447
|
+
elementDisposers.delete(node);
|
|
448
|
+
if (DEV) activeBindingCount -= snapshot.length;
|
|
449
|
+
for (let i2 = 0; i2 < snapshot.length; i2++) {
|
|
450
|
+
if (executed >= MAX_DRAIN_TEARDOWNS) {
|
|
451
|
+
const rest = snapshot.slice(i2);
|
|
452
|
+
const added = elementDisposers.get(node);
|
|
453
|
+
elementDisposers.set(node, added ? rest.concat(added) : rest);
|
|
454
|
+
if (DEV) activeBindingCount += rest.length;
|
|
455
|
+
reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
|
|
456
|
+
runaway = true;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
executed++;
|
|
460
|
+
try {
|
|
461
|
+
snapshot[i2]();
|
|
462
|
+
} catch (err) {
|
|
463
|
+
reportError(err, { phase: "cleanup", name: "disposer" });
|
|
443
464
|
}
|
|
444
465
|
}
|
|
445
466
|
}
|
|
@@ -729,6 +750,14 @@ function setSafeAttribute(el, name, value, options = {}) {
|
|
|
729
750
|
const html3 = isHtmlElement(el);
|
|
730
751
|
const idlName = html3 ? name.toLowerCase() : name;
|
|
731
752
|
if (typeof value === "boolean") {
|
|
753
|
+
if (name.length > 5 && name.slice(0, 5).toLowerCase() === "aria-") {
|
|
754
|
+
const token = value ? "true" : "false";
|
|
755
|
+
if ((ns ? el.getAttributeNS(ns, localName) : el.getAttribute(name)) !== token) {
|
|
756
|
+
if (ns) el.setAttributeNS(ns, name, token);
|
|
757
|
+
else el.setAttribute(name, token);
|
|
758
|
+
}
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
732
761
|
if (html3 && BOOLEAN_IDL_ATTRS.has(idlName) && idlName in el) {
|
|
733
762
|
setProp(el, idlName, value);
|
|
734
763
|
} else if (value) {
|
|
@@ -901,8 +930,18 @@ function untracked(fn) {
|
|
|
901
930
|
var subscriberEpochCounter = 0;
|
|
902
931
|
function retrack(effectFn, subscriber) {
|
|
903
932
|
const prev = currentSubscriber;
|
|
933
|
+
let savedDepth = 0;
|
|
934
|
+
let savedSuspendSub = null;
|
|
935
|
+
if (trackingSuspended) {
|
|
936
|
+
savedDepth = suspendDepth;
|
|
937
|
+
savedSuspendSub = suspendSavedSub;
|
|
938
|
+
suspendDepth = 0;
|
|
939
|
+
suspendSavedSub = null;
|
|
940
|
+
trackingSuspended = false;
|
|
941
|
+
}
|
|
904
942
|
currentSubscriber = subscriber;
|
|
905
943
|
const sub2 = subscriber;
|
|
944
|
+
if (sub2._cap === void 0) sub2._cap = currentDisposerCapture();
|
|
906
945
|
const epoch = ++subscriberEpochCounter;
|
|
907
946
|
sub2._epoch = epoch;
|
|
908
947
|
sub2._structDirty = false;
|
|
@@ -915,6 +954,11 @@ function retrack(effectFn, subscriber) {
|
|
|
915
954
|
effectFn();
|
|
916
955
|
} finally {
|
|
917
956
|
currentSubscriber = prev;
|
|
957
|
+
if (savedDepth !== 0) {
|
|
958
|
+
suspendDepth = savedDepth;
|
|
959
|
+
suspendSavedSub = savedSuspendSub;
|
|
960
|
+
trackingSuspended = true;
|
|
961
|
+
}
|
|
918
962
|
let node = sub2.depsHead ?? null;
|
|
919
963
|
while (node !== null) {
|
|
920
964
|
const next = node.subNext;
|
|
@@ -934,11 +978,25 @@ function track(effectFn, subscriber) {
|
|
|
934
978
|
if (!subscriber) return reactiveBinding(effectFn);
|
|
935
979
|
cleanup(subscriber);
|
|
936
980
|
const prev = currentSubscriber;
|
|
981
|
+
let savedDepth = 0;
|
|
982
|
+
let savedSuspendSub = null;
|
|
983
|
+
if (trackingSuspended) {
|
|
984
|
+
savedDepth = suspendDepth;
|
|
985
|
+
savedSuspendSub = suspendSavedSub;
|
|
986
|
+
suspendDepth = 0;
|
|
987
|
+
suspendSavedSub = null;
|
|
988
|
+
trackingSuspended = false;
|
|
989
|
+
}
|
|
937
990
|
currentSubscriber = subscriber;
|
|
938
991
|
try {
|
|
939
992
|
effectFn();
|
|
940
993
|
} finally {
|
|
941
994
|
currentSubscriber = prev;
|
|
995
|
+
if (savedDepth !== 0) {
|
|
996
|
+
suspendDepth = savedDepth;
|
|
997
|
+
suspendSavedSub = savedSuspendSub;
|
|
998
|
+
trackingSuspended = true;
|
|
999
|
+
}
|
|
942
1000
|
const sub3 = subscriber;
|
|
943
1001
|
for (let n = sub3.depsHead ?? null; n !== null; n = n.subNext) {
|
|
944
1002
|
const sig = n.sig;
|
|
@@ -1075,7 +1133,12 @@ function drainQueue() {
|
|
|
1075
1133
|
quarantined.add(sub2);
|
|
1076
1134
|
continue;
|
|
1077
1135
|
}
|
|
1078
|
-
|
|
1136
|
+
const pushed = beginDisposerCapture(sub2._cap ?? null);
|
|
1137
|
+
try {
|
|
1138
|
+
safeInvoke(sub2);
|
|
1139
|
+
} finally {
|
|
1140
|
+
if (pushed) endDisposerCapture();
|
|
1141
|
+
}
|
|
1079
1142
|
}
|
|
1080
1143
|
}
|
|
1081
1144
|
function drainNotificationQueue() {
|
|
@@ -1109,8 +1172,9 @@ function propagateDirty(sub2) {
|
|
|
1109
1172
|
if (s2._c) {
|
|
1110
1173
|
const nSig = s2._sig;
|
|
1111
1174
|
if (nSig) {
|
|
1112
|
-
if (!nSig._d) {
|
|
1175
|
+
if (!nSig._d || nSig._f === true) {
|
|
1113
1176
|
nSig._d = true;
|
|
1177
|
+
nSig._f = false;
|
|
1114
1178
|
stack.push(nSig);
|
|
1115
1179
|
}
|
|
1116
1180
|
} else {
|
|
@@ -1210,7 +1274,7 @@ function forEachSubscriber(signal2, visit) {
|
|
|
1210
1274
|
}
|
|
1211
1275
|
|
|
1212
1276
|
// src/reactivity/track.ts
|
|
1213
|
-
var _runtimeVersion = true ? "4.
|
|
1277
|
+
var _runtimeVersion = true ? "4.6.0" : "dev";
|
|
1214
1278
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
1215
1279
|
function resolveReactiveApi() {
|
|
1216
1280
|
const g2 = globalThis;
|
|
@@ -2251,6 +2315,10 @@ function getSSRStore() {
|
|
|
2251
2315
|
}
|
|
2252
2316
|
return fallbackStore;
|
|
2253
2317
|
}
|
|
2318
|
+
function getRequestStore() {
|
|
2319
|
+
if (als) return als.getStore() ?? null;
|
|
2320
|
+
return _shared.fallbackDepth > 0 ? fallbackStore : null;
|
|
2321
|
+
}
|
|
2254
2322
|
function isSSR() {
|
|
2255
2323
|
return getSSRStore().ssr;
|
|
2256
2324
|
}
|
|
@@ -2272,16 +2340,18 @@ function disableSSR() {
|
|
|
2272
2340
|
getSSRStore().ssr = false;
|
|
2273
2341
|
}
|
|
2274
2342
|
function runInSSRContext(fn) {
|
|
2275
|
-
const store2 = { ssr: true, suspenseIdCounter: 0, locale: void 0 };
|
|
2343
|
+
const store2 = { ssr: true, suspenseIdCounter: 0, idCounter: 0, locale: void 0 };
|
|
2276
2344
|
if (als) {
|
|
2277
2345
|
return als.run(store2, fn);
|
|
2278
2346
|
}
|
|
2279
2347
|
warnMissingAsyncLocalStorage();
|
|
2280
2348
|
const prevSSR = fallbackStore.ssr;
|
|
2281
2349
|
const prevCounter = fallbackStore.suspenseIdCounter;
|
|
2350
|
+
const prevIdCounter = fallbackStore.idCounter;
|
|
2282
2351
|
const prevLocale = fallbackStore.locale;
|
|
2283
2352
|
fallbackStore.ssr = true;
|
|
2284
2353
|
fallbackStore.suspenseIdCounter = 0;
|
|
2354
|
+
fallbackStore.idCounter = 0;
|
|
2285
2355
|
fallbackStore.locale = void 0;
|
|
2286
2356
|
_shared.fallbackDepth++;
|
|
2287
2357
|
try {
|
|
@@ -2290,6 +2360,7 @@ function runInSSRContext(fn) {
|
|
|
2290
2360
|
_shared.fallbackDepth--;
|
|
2291
2361
|
fallbackStore.ssr = prevSSR;
|
|
2292
2362
|
fallbackStore.suspenseIdCounter = prevCounter;
|
|
2363
|
+
fallbackStore.idCounter = prevIdCounter;
|
|
2293
2364
|
fallbackStore.locale = prevLocale;
|
|
2294
2365
|
}
|
|
2295
2366
|
}
|
|
@@ -3461,9 +3532,14 @@ var longPress = (element, options) => {
|
|
|
3461
3532
|
};
|
|
3462
3533
|
};
|
|
3463
3534
|
var copyOnClick = (element, getText) => {
|
|
3535
|
+
const report = (error) => reportError(error, { phase: "async", name: "copyOnClick", node: element });
|
|
3464
3536
|
const handler = () => {
|
|
3465
|
-
|
|
3466
|
-
|
|
3537
|
+
try {
|
|
3538
|
+
const text2 = typeof getText === "function" ? getText() : element.textContent ?? "";
|
|
3539
|
+
Promise.resolve(navigator.clipboard.writeText(text2)).catch(report);
|
|
3540
|
+
} catch (error) {
|
|
3541
|
+
report(error);
|
|
3542
|
+
}
|
|
3467
3543
|
};
|
|
3468
3544
|
element.addEventListener("click", handler);
|
|
3469
3545
|
return () => element.removeEventListener("click", handler);
|
|
@@ -3599,6 +3675,11 @@ function context(defaultValue) {
|
|
|
3599
3675
|
var COUNTER_KEY = /* @__PURE__ */ Symbol.for("sibujs.createId.v1");
|
|
3600
3676
|
var _counter = globalThis[COUNTER_KEY] ?? (globalThis[COUNTER_KEY] = { n: 0 });
|
|
3601
3677
|
function createId(prefix = "sibu") {
|
|
3678
|
+
const request = getRequestStore();
|
|
3679
|
+
if (request) {
|
|
3680
|
+
request.idCounter = (request.idCounter ?? 0) + 1;
|
|
3681
|
+
return `${prefix}-${request.idCounter}`;
|
|
3682
|
+
}
|
|
3602
3683
|
_counter.n++;
|
|
3603
3684
|
return `${prefix}-${_counter.n}`;
|
|
3604
3685
|
}
|
|
@@ -3612,7 +3693,7 @@ function show(condition, element) {
|
|
|
3612
3693
|
const update = () => {
|
|
3613
3694
|
resolved.style.display = condition() ? "" : "none";
|
|
3614
3695
|
};
|
|
3615
|
-
registerDisposer(resolved,
|
|
3696
|
+
registerDisposer(resolved, reactiveBinding2(update, resolved));
|
|
3616
3697
|
return resolved;
|
|
3617
3698
|
}
|
|
3618
3699
|
function attachBranch(parent, anchor, branch, attachedOnce, where) {
|
|
@@ -3636,9 +3717,11 @@ function when(condition, thenBranch, elseBranch) {
|
|
|
3636
3717
|
let currentNode = null;
|
|
3637
3718
|
let lastCondition;
|
|
3638
3719
|
let initialized = false;
|
|
3720
|
+
let disposed = false;
|
|
3639
3721
|
const attachedOnce = /* @__PURE__ */ new WeakSet();
|
|
3640
3722
|
let currentNodeOwned = false;
|
|
3641
3723
|
const update = () => {
|
|
3724
|
+
if (disposed) return;
|
|
3642
3725
|
const show2 = condition();
|
|
3643
3726
|
const parent = anchor.parentNode;
|
|
3644
3727
|
if (!parent) return;
|
|
@@ -3657,10 +3740,14 @@ function when(condition, thenBranch, elseBranch) {
|
|
|
3657
3740
|
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "when");
|
|
3658
3741
|
initialized = true;
|
|
3659
3742
|
};
|
|
3660
|
-
|
|
3743
|
+
const stopBinding = reactiveBinding2(update, anchor);
|
|
3744
|
+
registerDisposer(anchor, () => {
|
|
3745
|
+
disposed = true;
|
|
3746
|
+
stopBinding();
|
|
3747
|
+
});
|
|
3661
3748
|
if (!initialized) {
|
|
3662
3749
|
queueMicrotask(() => {
|
|
3663
|
-
if (!initialized && anchor.parentNode) update();
|
|
3750
|
+
if (!disposed && !initialized && anchor.parentNode) update();
|
|
3664
3751
|
});
|
|
3665
3752
|
}
|
|
3666
3753
|
return anchor;
|
|
@@ -3670,9 +3757,11 @@ function match(value, cases, fallback) {
|
|
|
3670
3757
|
let currentNode = null;
|
|
3671
3758
|
let lastKey;
|
|
3672
3759
|
let initialized = false;
|
|
3760
|
+
let disposed = false;
|
|
3673
3761
|
const attachedOnce = /* @__PURE__ */ new WeakSet();
|
|
3674
3762
|
let currentNodeOwned = false;
|
|
3675
3763
|
const update = () => {
|
|
3764
|
+
if (disposed) return;
|
|
3676
3765
|
const key = String(value());
|
|
3677
3766
|
const parent = anchor.parentNode;
|
|
3678
3767
|
if (!parent) return;
|
|
@@ -3691,17 +3780,30 @@ function match(value, cases, fallback) {
|
|
|
3691
3780
|
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "match");
|
|
3692
3781
|
initialized = true;
|
|
3693
3782
|
};
|
|
3694
|
-
|
|
3783
|
+
const stopBinding = reactiveBinding2(update, anchor);
|
|
3784
|
+
registerDisposer(anchor, () => {
|
|
3785
|
+
disposed = true;
|
|
3786
|
+
stopBinding();
|
|
3787
|
+
});
|
|
3695
3788
|
if (!initialized) {
|
|
3696
3789
|
queueMicrotask(() => {
|
|
3697
|
-
if (!initialized && anchor.parentNode) update();
|
|
3790
|
+
if (!disposed && !initialized && anchor.parentNode) update();
|
|
3698
3791
|
});
|
|
3699
3792
|
}
|
|
3700
3793
|
return anchor;
|
|
3701
3794
|
}
|
|
3702
3795
|
|
|
3796
|
+
// src/utils/globalSingleton.ts
|
|
3797
|
+
function globalSingleton(key, create) {
|
|
3798
|
+
const g2 = globalThis;
|
|
3799
|
+
return g2[key] ?? (g2[key] = create());
|
|
3800
|
+
}
|
|
3801
|
+
|
|
3703
3802
|
// src/core/rendering/dynamic.ts
|
|
3704
|
-
var componentRegistry =
|
|
3803
|
+
var componentRegistry = globalSingleton(
|
|
3804
|
+
/* @__PURE__ */ Symbol.for("sibujs.components.registry.v1"),
|
|
3805
|
+
() => /* @__PURE__ */ new Map()
|
|
3806
|
+
);
|
|
3705
3807
|
function registerComponent(name, component) {
|
|
3706
3808
|
componentRegistry.set(name, component);
|
|
3707
3809
|
}
|
|
@@ -3713,7 +3815,7 @@ function resolveComponent(name) {
|
|
|
3713
3815
|
if (component) {
|
|
3714
3816
|
return component();
|
|
3715
3817
|
}
|
|
3716
|
-
return div(
|
|
3818
|
+
return div(`[Component "${name}" not found]`);
|
|
3717
3819
|
}
|
|
3718
3820
|
function DynamicComponent(is) {
|
|
3719
3821
|
const container = div({ class: "sibu-dynamic" });
|
|
@@ -3846,7 +3948,12 @@ function each(getArray, render, options) {
|
|
|
3846
3948
|
const [indexGetter, setIndex] = signal(i2);
|
|
3847
3949
|
let node;
|
|
3848
3950
|
try {
|
|
3849
|
-
|
|
3951
|
+
suspendTracking2();
|
|
3952
|
+
try {
|
|
3953
|
+
node = resolveNodeChild(render(itemGetter, indexGetter));
|
|
3954
|
+
} finally {
|
|
3955
|
+
resumeTracking2();
|
|
3956
|
+
}
|
|
3850
3957
|
} catch (err) {
|
|
3851
3958
|
const key2 = newKeys[i2];
|
|
3852
3959
|
node = document.createComment(`each:error:${i2}`);
|
|
@@ -4527,10 +4634,15 @@ function Portal(nodes, target) {
|
|
|
4527
4634
|
|
|
4528
4635
|
// src/core/rendering/slots.ts
|
|
4529
4636
|
function getSlot(slots, name = "default") {
|
|
4530
|
-
|
|
4637
|
+
if (slots == null || !Object.hasOwn(slots, name)) return void 0;
|
|
4638
|
+
const slot2 = slots[name];
|
|
4639
|
+
return typeof slot2 === "function" ? slot2 : void 0;
|
|
4531
4640
|
}
|
|
4532
4641
|
|
|
4533
4642
|
// src/core/signals/array.ts
|
|
4643
|
+
function nativeSplice(target, start, rest) {
|
|
4644
|
+
return rest.length === 0 ? target.splice(start) : target.splice(start, ...rest);
|
|
4645
|
+
}
|
|
4534
4646
|
function array(initial = []) {
|
|
4535
4647
|
const [arr, setArr] = signal([...initial]);
|
|
4536
4648
|
const actions = {
|
|
@@ -4558,12 +4670,12 @@ function array(initial = []) {
|
|
|
4558
4670
|
unshift(...items) {
|
|
4559
4671
|
setArr((prev) => [...items, ...prev]);
|
|
4560
4672
|
},
|
|
4561
|
-
splice(start,
|
|
4673
|
+
splice(start, ...rest) {
|
|
4562
4674
|
let removed = [];
|
|
4563
4675
|
setArr((prev) => {
|
|
4564
4676
|
const copy = [...prev];
|
|
4565
|
-
removed = copy
|
|
4566
|
-
return copy;
|
|
4677
|
+
removed = nativeSplice(copy, start, rest);
|
|
4678
|
+
return removed.length === 0 && rest.length <= 1 ? prev : copy;
|
|
4567
4679
|
});
|
|
4568
4680
|
return removed;
|
|
4569
4681
|
},
|
|
@@ -4646,9 +4758,9 @@ function reactiveArray(initial = []) {
|
|
|
4646
4758
|
data2.unshift(...items);
|
|
4647
4759
|
notify();
|
|
4648
4760
|
},
|
|
4649
|
-
splice(start,
|
|
4650
|
-
const removed = data2
|
|
4651
|
-
if (removed.length > 0 ||
|
|
4761
|
+
splice(start, ...rest) {
|
|
4762
|
+
const removed = nativeSplice(data2, start, rest);
|
|
4763
|
+
if (removed.length > 0 || rest.length > 1) {
|
|
4652
4764
|
notify();
|
|
4653
4765
|
}
|
|
4654
4766
|
return removed;
|
|
@@ -4870,6 +4982,21 @@ function deepEqual(a2, b2, seen) {
|
|
|
4870
4982
|
if (a2.length !== b2.length) return false;
|
|
4871
4983
|
return a2.every((val, i2) => deepEqual(val, b2[i2], seen));
|
|
4872
4984
|
}
|
|
4985
|
+
if (a2 instanceof Number || a2 instanceof String || a2 instanceof Boolean) {
|
|
4986
|
+
return Object.is(a2.valueOf(), b2.valueOf());
|
|
4987
|
+
}
|
|
4988
|
+
if (typeof URL !== "undefined" && a2 instanceof URL) {
|
|
4989
|
+
return a2.href === b2.href;
|
|
4990
|
+
}
|
|
4991
|
+
if (a2 instanceof Error) {
|
|
4992
|
+
const eb = b2;
|
|
4993
|
+
return a2.name === eb.name && a2.message === eb.message && deepEqual(a2.cause, eb.cause, seen) && plainKeysEqual(objA, objB, seen);
|
|
4994
|
+
}
|
|
4995
|
+
const proto = Object.getPrototypeOf(objA);
|
|
4996
|
+
if (proto !== Object.prototype && proto !== null) return false;
|
|
4997
|
+
return plainKeysEqual(objA, objB, seen);
|
|
4998
|
+
}
|
|
4999
|
+
function plainKeysEqual(objA, objB, seen) {
|
|
4873
5000
|
const keysA = Object.keys(objA);
|
|
4874
5001
|
const keysB = Object.keys(objB);
|
|
4875
5002
|
if (keysA.length !== keysB.length) return false;
|
|
@@ -4889,10 +5016,14 @@ function derived(getter, options) {
|
|
|
4889
5016
|
const cs = {};
|
|
4890
5017
|
cs._d = false;
|
|
4891
5018
|
cs._init = false;
|
|
5019
|
+
cs._f = false;
|
|
4892
5020
|
cs._g = getter;
|
|
4893
5021
|
cs.__v = 0;
|
|
5022
|
+
let evaluating = false;
|
|
5023
|
+
let disposed = false;
|
|
5024
|
+
let pendingError;
|
|
4894
5025
|
const markDirty = () => {
|
|
4895
|
-
if (cs._d) return;
|
|
5026
|
+
if (cs._d || disposed) return;
|
|
4896
5027
|
cs._d = true;
|
|
4897
5028
|
};
|
|
4898
5029
|
markDirty._c = 1;
|
|
@@ -4915,33 +5046,53 @@ function derived(getter, options) {
|
|
|
4915
5046
|
}
|
|
4916
5047
|
}, markDirty);
|
|
4917
5048
|
const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
4918
|
-
let evaluating = false;
|
|
4919
5049
|
const validate = () => {
|
|
4920
|
-
if (!cs._d) return;
|
|
5050
|
+
if (!cs._d || disposed || pendingError !== void 0) return;
|
|
4921
5051
|
const oldValue = cs._v;
|
|
4922
5052
|
evaluating = true;
|
|
4923
5053
|
try {
|
|
4924
5054
|
retrack2(recompute, markDirty);
|
|
4925
5055
|
if (!Object.is(oldValue, cs._v)) cs.__v++;
|
|
5056
|
+
} catch (err) {
|
|
5057
|
+
pendingError = { error: err };
|
|
5058
|
+
cs.__v++;
|
|
5059
|
+
if (disposed) cs._d = true;
|
|
5060
|
+
else cs._f = true;
|
|
4926
5061
|
} finally {
|
|
4927
5062
|
evaluating = false;
|
|
5063
|
+
if (disposed) cleanup2(markDirty);
|
|
4928
5064
|
}
|
|
4929
|
-
if (hook && !Object.is(oldValue, cs._v)) {
|
|
5065
|
+
if (hook && !disposed && !Object.is(oldValue, cs._v)) {
|
|
4930
5066
|
hook.emit("computed:update", { signal: cs, oldValue, newValue: cs._v });
|
|
4931
5067
|
}
|
|
4932
5068
|
};
|
|
4933
5069
|
cs._validate = validate;
|
|
5070
|
+
const throwPending = () => {
|
|
5071
|
+
const { error } = pendingError;
|
|
5072
|
+
pendingError = void 0;
|
|
5073
|
+
if (disposed) cs._d = false;
|
|
5074
|
+
throw error;
|
|
5075
|
+
};
|
|
4934
5076
|
function computedGetter() {
|
|
4935
5077
|
if (evaluating) {
|
|
4936
5078
|
throw new Error(
|
|
4937
5079
|
`[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
|
|
4938
5080
|
);
|
|
4939
5081
|
}
|
|
4940
|
-
if (isTrackingSuspended2()) {
|
|
4941
|
-
if (cs._d)
|
|
5082
|
+
if (isTrackingSuspended2() || disposed) {
|
|
5083
|
+
if (cs._d) {
|
|
5084
|
+
validate();
|
|
5085
|
+
if (pendingError !== void 0) throwPending();
|
|
5086
|
+
}
|
|
4942
5087
|
return cs._v;
|
|
4943
5088
|
}
|
|
4944
|
-
if (cs._d)
|
|
5089
|
+
if (cs._d) {
|
|
5090
|
+
validate();
|
|
5091
|
+
if (pendingError !== void 0) {
|
|
5092
|
+
recordDependency2(cs);
|
|
5093
|
+
throwPending();
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
4945
5096
|
recordDependency2(cs);
|
|
4946
5097
|
return cs._v;
|
|
4947
5098
|
}
|
|
@@ -4950,6 +5101,19 @@ function derived(getter, options) {
|
|
|
4950
5101
|
cs.__name = debugName;
|
|
4951
5102
|
}
|
|
4952
5103
|
computedGetter.__signal = cs;
|
|
5104
|
+
computedGetter.dispose = () => {
|
|
5105
|
+
if (disposed) return;
|
|
5106
|
+
disposed = true;
|
|
5107
|
+
cs._d = pendingError !== void 0;
|
|
5108
|
+
cleanup2(markDirty);
|
|
5109
|
+
const h = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
5110
|
+
if (h) {
|
|
5111
|
+
try {
|
|
5112
|
+
h.emit("computed:destroy", { signal: cs, getter: computedGetter });
|
|
5113
|
+
} catch {
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
};
|
|
4953
5117
|
if (hook) hook.emit("computed:create", { signal: cs, name: debugName, getter: computedGetter });
|
|
4954
5118
|
return computedGetter;
|
|
4955
5119
|
}
|
|
@@ -4968,15 +5132,18 @@ function ref(initial) {
|
|
|
4968
5132
|
}
|
|
4969
5133
|
|
|
4970
5134
|
// src/core/signals/store.ts
|
|
5135
|
+
function defineOwn(obj, key, value) {
|
|
5136
|
+
Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });
|
|
5137
|
+
}
|
|
4971
5138
|
function store(initialState) {
|
|
4972
5139
|
devAssert(
|
|
4973
5140
|
initialState !== null && typeof initialState === "object" && !Array.isArray(initialState),
|
|
4974
5141
|
"store: argument must be a plain object. For arrays, use array() instead."
|
|
4975
5142
|
);
|
|
4976
|
-
const signals =
|
|
5143
|
+
const signals = /* @__PURE__ */ Object.create(null);
|
|
4977
5144
|
Object.keys(initialState).forEach((key) => {
|
|
4978
5145
|
const [getter, setter] = signal(initialState[key]);
|
|
4979
|
-
signals
|
|
5146
|
+
defineOwn(signals, key, [getter, setter]);
|
|
4980
5147
|
});
|
|
4981
5148
|
const store2 = new Proxy({}, {
|
|
4982
5149
|
get(target, prop) {
|
|
@@ -4995,7 +5162,7 @@ function store(initialState) {
|
|
|
4995
5162
|
const getSnapshot = () => {
|
|
4996
5163
|
const snapshot = {};
|
|
4997
5164
|
Object.keys(signals).forEach((key) => {
|
|
4998
|
-
snapshot
|
|
5165
|
+
defineOwn(snapshot, key, signals[key][0]());
|
|
4999
5166
|
});
|
|
5000
5167
|
return snapshot;
|
|
5001
5168
|
};
|
|
@@ -5131,6 +5298,13 @@ function strictEffect(fn) {
|
|
|
5131
5298
|
};
|
|
5132
5299
|
}
|
|
5133
5300
|
|
|
5301
|
+
// src/reactivity/domBinding.ts
|
|
5302
|
+
function domBinding(commit, ownerNode) {
|
|
5303
|
+
if (isSSR()) return () => {
|
|
5304
|
+
};
|
|
5305
|
+
return reactiveBinding2(commit, ownerNode);
|
|
5306
|
+
}
|
|
5307
|
+
|
|
5134
5308
|
// src/platform/enhance.ts
|
|
5135
5309
|
var ENHANCED_ATTR = "data-sibu-enhanced";
|
|
5136
5310
|
var enhancementOwner = /* @__PURE__ */ new WeakMap();
|
|
@@ -5166,9 +5340,7 @@ function resolveTarget(root, target) {
|
|
|
5166
5340
|
}
|
|
5167
5341
|
}
|
|
5168
5342
|
function bindNode(el, commit) {
|
|
5169
|
-
|
|
5170
|
-
};
|
|
5171
|
-
return reactiveBinding2(commit, el);
|
|
5343
|
+
return domBinding(commit, el);
|
|
5172
5344
|
}
|
|
5173
5345
|
function readControlValue(el) {
|
|
5174
5346
|
if (el instanceof HTMLInputElement) {
|
|
@@ -5426,12 +5598,6 @@ function enhanceAll(selector, setup) {
|
|
|
5426
5598
|
};
|
|
5427
5599
|
}
|
|
5428
5600
|
|
|
5429
|
-
// src/utils/globalSingleton.ts
|
|
5430
|
-
function globalSingleton(key, create) {
|
|
5431
|
-
const g2 = globalThis;
|
|
5432
|
-
return g2[key] ?? (g2[key] = create());
|
|
5433
|
-
}
|
|
5434
|
-
|
|
5435
5601
|
// src/platform/islands.ts
|
|
5436
5602
|
var SAFE_NAME = /^[A-Za-z0-9_-]+$/;
|
|
5437
5603
|
var LAZY = /* @__PURE__ */ Symbol.for("sibujs.islands.lazy");
|
|
@@ -5588,6 +5754,27 @@ function trustHTML(html3) {
|
|
|
5588
5754
|
}
|
|
5589
5755
|
var DEFAULT_MAX_SSR_BYTES = 1024 * 1024;
|
|
5590
5756
|
|
|
5757
|
+
// src/utils/adoptThenable.ts
|
|
5758
|
+
function adoptThenable(value) {
|
|
5759
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return null;
|
|
5760
|
+
let then;
|
|
5761
|
+
try {
|
|
5762
|
+
then = value.then;
|
|
5763
|
+
} catch (error) {
|
|
5764
|
+
return Promise.reject(error);
|
|
5765
|
+
}
|
|
5766
|
+
if (typeof then !== "function") return null;
|
|
5767
|
+
return new Promise((resolve, reject) => {
|
|
5768
|
+
queueMicrotask(() => {
|
|
5769
|
+
try {
|
|
5770
|
+
Reflect.apply(then, value, [resolve, reject]);
|
|
5771
|
+
} catch (error) {
|
|
5772
|
+
reject(error);
|
|
5773
|
+
}
|
|
5774
|
+
});
|
|
5775
|
+
});
|
|
5776
|
+
}
|
|
5777
|
+
|
|
5591
5778
|
// src/reactivity/concurrent.ts
|
|
5592
5779
|
function defer(getter) {
|
|
5593
5780
|
const [value, setValue] = signal(getter());
|
|
@@ -5637,23 +5824,27 @@ function scheduleIdle(fn) {
|
|
|
5637
5824
|
}
|
|
5638
5825
|
function transition() {
|
|
5639
5826
|
const [pending, setPending] = signal(false);
|
|
5827
|
+
let outstanding = 0;
|
|
5640
5828
|
function start(fn) {
|
|
5829
|
+
outstanding++;
|
|
5641
5830
|
setPending(true);
|
|
5831
|
+
let settled = false;
|
|
5832
|
+
const finish = () => {
|
|
5833
|
+
if (settled) return;
|
|
5834
|
+
settled = true;
|
|
5835
|
+
outstanding--;
|
|
5836
|
+
if (outstanding === 0) setPending(false);
|
|
5837
|
+
};
|
|
5838
|
+
const fail = (error) => {
|
|
5839
|
+
finish();
|
|
5840
|
+
reportError(error, { phase: "async", name: "transition" });
|
|
5841
|
+
};
|
|
5642
5842
|
scheduleIdle(() => {
|
|
5643
|
-
let result;
|
|
5644
5843
|
try {
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
}
|
|
5650
|
-
if (result && typeof result.then === "function") {
|
|
5651
|
-
result.then(
|
|
5652
|
-
() => setPending(false),
|
|
5653
|
-
() => setPending(false)
|
|
5654
|
-
);
|
|
5655
|
-
} else {
|
|
5656
|
-
setPending(false);
|
|
5844
|
+
const adopted = adoptThenable(fn());
|
|
5845
|
+
adopted ? adopted.then(finish, fail) : finish();
|
|
5846
|
+
} catch (error) {
|
|
5847
|
+
fail(error);
|
|
5657
5848
|
}
|
|
5658
5849
|
});
|
|
5659
5850
|
}
|