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/build.cjs
CHANGED
|
@@ -1419,6 +1419,23 @@ function reportDrainRunaway(label2, executed, remaining) {
|
|
|
1419
1419
|
);
|
|
1420
1420
|
}
|
|
1421
1421
|
var activeBindingCount = 0;
|
|
1422
|
+
function resolveCapture(capture) {
|
|
1423
|
+
let frame = capture;
|
|
1424
|
+
while (frame?.closed) frame = frame.forwardTo;
|
|
1425
|
+
return frame ?? null;
|
|
1426
|
+
}
|
|
1427
|
+
var registrationCaptures = [];
|
|
1428
|
+
function currentDisposerCapture() {
|
|
1429
|
+
return resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
|
|
1430
|
+
}
|
|
1431
|
+
function beginDisposerCapture(capture) {
|
|
1432
|
+
if (capture === null && registrationCaptures.length === 0) return false;
|
|
1433
|
+
registrationCaptures.push(resolveCapture(capture));
|
|
1434
|
+
return true;
|
|
1435
|
+
}
|
|
1436
|
+
function endDisposerCapture() {
|
|
1437
|
+
registrationCaptures.pop();
|
|
1438
|
+
}
|
|
1422
1439
|
function registerDisposer(node, teardown) {
|
|
1423
1440
|
let disposers = elementDisposers.get(node);
|
|
1424
1441
|
if (!disposers) {
|
|
@@ -1427,15 +1444,18 @@ function registerDisposer(node, teardown) {
|
|
|
1427
1444
|
}
|
|
1428
1445
|
disposers.push(teardown);
|
|
1429
1446
|
if (DEV) activeBindingCount++;
|
|
1447
|
+
const capture = resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
|
|
1448
|
+
if (capture) capture.entries.push([node, teardown]);
|
|
1430
1449
|
}
|
|
1431
1450
|
function unregisterDisposer(node, teardown) {
|
|
1432
1451
|
const disposers = elementDisposers.get(node);
|
|
1433
|
-
if (!disposers) return;
|
|
1452
|
+
if (!disposers) return false;
|
|
1434
1453
|
const index = disposers.indexOf(teardown);
|
|
1435
|
-
if (index === -1) return;
|
|
1454
|
+
if (index === -1) return false;
|
|
1436
1455
|
disposers.splice(index, 1);
|
|
1437
1456
|
if (DEV) activeBindingCount--;
|
|
1438
1457
|
if (disposers.length === 0) elementDisposers.delete(node);
|
|
1458
|
+
return true;
|
|
1439
1459
|
}
|
|
1440
1460
|
function dispose(node) {
|
|
1441
1461
|
const stack = [node];
|
|
@@ -1449,33 +1469,34 @@ function dispose(node) {
|
|
|
1449
1469
|
}
|
|
1450
1470
|
}
|
|
1451
1471
|
for (let i2 = order.length - 1; i2 >= 0; i2--) {
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1472
|
+
disposeNodeOwn(order[i2]);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
function disposeNodeOwn(node) {
|
|
1476
|
+
if (!elementDisposers.has(node)) return;
|
|
1477
|
+
let executed = 0;
|
|
1478
|
+
let runaway = false;
|
|
1479
|
+
while (!runaway) {
|
|
1480
|
+
const pending = elementDisposers.get(node);
|
|
1481
|
+
if (!pending || pending.length === 0) break;
|
|
1482
|
+
const snapshot = pending.slice();
|
|
1483
|
+
elementDisposers.delete(node);
|
|
1484
|
+
if (DEV) activeBindingCount -= snapshot.length;
|
|
1485
|
+
for (let i2 = 0; i2 < snapshot.length; i2++) {
|
|
1486
|
+
if (executed >= MAX_DRAIN_TEARDOWNS) {
|
|
1487
|
+
const rest = snapshot.slice(i2);
|
|
1488
|
+
const added = elementDisposers.get(node);
|
|
1489
|
+
elementDisposers.set(node, added ? rest.concat(added) : rest);
|
|
1490
|
+
if (DEV) activeBindingCount += rest.length;
|
|
1491
|
+
reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
|
|
1492
|
+
runaway = true;
|
|
1493
|
+
break;
|
|
1494
|
+
}
|
|
1495
|
+
executed++;
|
|
1496
|
+
try {
|
|
1497
|
+
snapshot[i2]();
|
|
1498
|
+
} catch (err) {
|
|
1499
|
+
reportError(err, { phase: "cleanup", name: "disposer" });
|
|
1479
1500
|
}
|
|
1480
1501
|
}
|
|
1481
1502
|
}
|
|
@@ -1765,6 +1786,14 @@ function setSafeAttribute(el, name, value, options = {}) {
|
|
|
1765
1786
|
const html3 = isHtmlElement(el);
|
|
1766
1787
|
const idlName = html3 ? name.toLowerCase() : name;
|
|
1767
1788
|
if (typeof value === "boolean") {
|
|
1789
|
+
if (name.length > 5 && name.slice(0, 5).toLowerCase() === "aria-") {
|
|
1790
|
+
const token = value ? "true" : "false";
|
|
1791
|
+
if ((ns ? el.getAttributeNS(ns, localName) : el.getAttribute(name)) !== token) {
|
|
1792
|
+
if (ns) el.setAttributeNS(ns, name, token);
|
|
1793
|
+
else el.setAttribute(name, token);
|
|
1794
|
+
}
|
|
1795
|
+
return true;
|
|
1796
|
+
}
|
|
1768
1797
|
if (html3 && BOOLEAN_IDL_ATTRS.has(idlName) && idlName in el) {
|
|
1769
1798
|
setProp(el, idlName, value);
|
|
1770
1799
|
} else if (value) {
|
|
@@ -1937,8 +1966,18 @@ function untracked(fn) {
|
|
|
1937
1966
|
var subscriberEpochCounter = 0;
|
|
1938
1967
|
function retrack(effectFn, subscriber) {
|
|
1939
1968
|
const prev = currentSubscriber;
|
|
1969
|
+
let savedDepth = 0;
|
|
1970
|
+
let savedSuspendSub = null;
|
|
1971
|
+
if (trackingSuspended) {
|
|
1972
|
+
savedDepth = suspendDepth;
|
|
1973
|
+
savedSuspendSub = suspendSavedSub;
|
|
1974
|
+
suspendDepth = 0;
|
|
1975
|
+
suspendSavedSub = null;
|
|
1976
|
+
trackingSuspended = false;
|
|
1977
|
+
}
|
|
1940
1978
|
currentSubscriber = subscriber;
|
|
1941
1979
|
const sub2 = subscriber;
|
|
1980
|
+
if (sub2._cap === void 0) sub2._cap = currentDisposerCapture();
|
|
1942
1981
|
const epoch = ++subscriberEpochCounter;
|
|
1943
1982
|
sub2._epoch = epoch;
|
|
1944
1983
|
sub2._structDirty = false;
|
|
@@ -1951,6 +1990,11 @@ function retrack(effectFn, subscriber) {
|
|
|
1951
1990
|
effectFn();
|
|
1952
1991
|
} finally {
|
|
1953
1992
|
currentSubscriber = prev;
|
|
1993
|
+
if (savedDepth !== 0) {
|
|
1994
|
+
suspendDepth = savedDepth;
|
|
1995
|
+
suspendSavedSub = savedSuspendSub;
|
|
1996
|
+
trackingSuspended = true;
|
|
1997
|
+
}
|
|
1954
1998
|
let node = sub2.depsHead ?? null;
|
|
1955
1999
|
while (node !== null) {
|
|
1956
2000
|
const next = node.subNext;
|
|
@@ -1970,11 +2014,25 @@ function track(effectFn, subscriber) {
|
|
|
1970
2014
|
if (!subscriber) return reactiveBinding(effectFn);
|
|
1971
2015
|
cleanup(subscriber);
|
|
1972
2016
|
const prev = currentSubscriber;
|
|
2017
|
+
let savedDepth = 0;
|
|
2018
|
+
let savedSuspendSub = null;
|
|
2019
|
+
if (trackingSuspended) {
|
|
2020
|
+
savedDepth = suspendDepth;
|
|
2021
|
+
savedSuspendSub = suspendSavedSub;
|
|
2022
|
+
suspendDepth = 0;
|
|
2023
|
+
suspendSavedSub = null;
|
|
2024
|
+
trackingSuspended = false;
|
|
2025
|
+
}
|
|
1973
2026
|
currentSubscriber = subscriber;
|
|
1974
2027
|
try {
|
|
1975
2028
|
effectFn();
|
|
1976
2029
|
} finally {
|
|
1977
2030
|
currentSubscriber = prev;
|
|
2031
|
+
if (savedDepth !== 0) {
|
|
2032
|
+
suspendDepth = savedDepth;
|
|
2033
|
+
suspendSavedSub = savedSuspendSub;
|
|
2034
|
+
trackingSuspended = true;
|
|
2035
|
+
}
|
|
1978
2036
|
const sub3 = subscriber;
|
|
1979
2037
|
for (let n = sub3.depsHead ?? null; n !== null; n = n.subNext) {
|
|
1980
2038
|
const sig = n.sig;
|
|
@@ -2111,7 +2169,12 @@ function drainQueue() {
|
|
|
2111
2169
|
quarantined.add(sub2);
|
|
2112
2170
|
continue;
|
|
2113
2171
|
}
|
|
2114
|
-
|
|
2172
|
+
const pushed = beginDisposerCapture(sub2._cap ?? null);
|
|
2173
|
+
try {
|
|
2174
|
+
safeInvoke(sub2);
|
|
2175
|
+
} finally {
|
|
2176
|
+
if (pushed) endDisposerCapture();
|
|
2177
|
+
}
|
|
2115
2178
|
}
|
|
2116
2179
|
}
|
|
2117
2180
|
function drainNotificationQueue() {
|
|
@@ -2145,8 +2208,9 @@ function propagateDirty(sub2) {
|
|
|
2145
2208
|
if (s2._c) {
|
|
2146
2209
|
const nSig = s2._sig;
|
|
2147
2210
|
if (nSig) {
|
|
2148
|
-
if (!nSig._d) {
|
|
2211
|
+
if (!nSig._d || nSig._f === true) {
|
|
2149
2212
|
nSig._d = true;
|
|
2213
|
+
nSig._f = false;
|
|
2150
2214
|
stack.push(nSig);
|
|
2151
2215
|
}
|
|
2152
2216
|
} else {
|
|
@@ -2246,7 +2310,7 @@ function forEachSubscriber(signal2, visit) {
|
|
|
2246
2310
|
}
|
|
2247
2311
|
|
|
2248
2312
|
// src/reactivity/track.ts
|
|
2249
|
-
var _runtimeVersion = true ? "4.
|
|
2313
|
+
var _runtimeVersion = true ? "4.6.0" : "dev";
|
|
2250
2314
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
2251
2315
|
function resolveReactiveApi() {
|
|
2252
2316
|
const g2 = globalThis;
|
|
@@ -3287,6 +3351,10 @@ function getSSRStore() {
|
|
|
3287
3351
|
}
|
|
3288
3352
|
return fallbackStore;
|
|
3289
3353
|
}
|
|
3354
|
+
function getRequestStore() {
|
|
3355
|
+
if (als) return als.getStore() ?? null;
|
|
3356
|
+
return _shared.fallbackDepth > 0 ? fallbackStore : null;
|
|
3357
|
+
}
|
|
3290
3358
|
function isSSR() {
|
|
3291
3359
|
return getSSRStore().ssr;
|
|
3292
3360
|
}
|
|
@@ -3308,16 +3376,18 @@ function disableSSR() {
|
|
|
3308
3376
|
getSSRStore().ssr = false;
|
|
3309
3377
|
}
|
|
3310
3378
|
function runInSSRContext(fn) {
|
|
3311
|
-
const store2 = { ssr: true, suspenseIdCounter: 0, locale: void 0 };
|
|
3379
|
+
const store2 = { ssr: true, suspenseIdCounter: 0, idCounter: 0, locale: void 0 };
|
|
3312
3380
|
if (als) {
|
|
3313
3381
|
return als.run(store2, fn);
|
|
3314
3382
|
}
|
|
3315
3383
|
warnMissingAsyncLocalStorage();
|
|
3316
3384
|
const prevSSR = fallbackStore.ssr;
|
|
3317
3385
|
const prevCounter = fallbackStore.suspenseIdCounter;
|
|
3386
|
+
const prevIdCounter = fallbackStore.idCounter;
|
|
3318
3387
|
const prevLocale = fallbackStore.locale;
|
|
3319
3388
|
fallbackStore.ssr = true;
|
|
3320
3389
|
fallbackStore.suspenseIdCounter = 0;
|
|
3390
|
+
fallbackStore.idCounter = 0;
|
|
3321
3391
|
fallbackStore.locale = void 0;
|
|
3322
3392
|
_shared.fallbackDepth++;
|
|
3323
3393
|
try {
|
|
@@ -3326,6 +3396,7 @@ function runInSSRContext(fn) {
|
|
|
3326
3396
|
_shared.fallbackDepth--;
|
|
3327
3397
|
fallbackStore.ssr = prevSSR;
|
|
3328
3398
|
fallbackStore.suspenseIdCounter = prevCounter;
|
|
3399
|
+
fallbackStore.idCounter = prevIdCounter;
|
|
3329
3400
|
fallbackStore.locale = prevLocale;
|
|
3330
3401
|
}
|
|
3331
3402
|
}
|
|
@@ -4497,9 +4568,14 @@ var longPress = (element, options) => {
|
|
|
4497
4568
|
};
|
|
4498
4569
|
};
|
|
4499
4570
|
var copyOnClick = (element, getText) => {
|
|
4571
|
+
const report = (error) => reportError(error, { phase: "async", name: "copyOnClick", node: element });
|
|
4500
4572
|
const handler = () => {
|
|
4501
|
-
|
|
4502
|
-
|
|
4573
|
+
try {
|
|
4574
|
+
const text2 = typeof getText === "function" ? getText() : element.textContent ?? "";
|
|
4575
|
+
Promise.resolve(navigator.clipboard.writeText(text2)).catch(report);
|
|
4576
|
+
} catch (error) {
|
|
4577
|
+
report(error);
|
|
4578
|
+
}
|
|
4503
4579
|
};
|
|
4504
4580
|
element.addEventListener("click", handler);
|
|
4505
4581
|
return () => element.removeEventListener("click", handler);
|
|
@@ -4635,6 +4711,11 @@ function context(defaultValue) {
|
|
|
4635
4711
|
var COUNTER_KEY = /* @__PURE__ */ Symbol.for("sibujs.createId.v1");
|
|
4636
4712
|
var _counter = globalThis[COUNTER_KEY] ?? (globalThis[COUNTER_KEY] = { n: 0 });
|
|
4637
4713
|
function createId(prefix = "sibu") {
|
|
4714
|
+
const request = getRequestStore();
|
|
4715
|
+
if (request) {
|
|
4716
|
+
request.idCounter = (request.idCounter ?? 0) + 1;
|
|
4717
|
+
return `${prefix}-${request.idCounter}`;
|
|
4718
|
+
}
|
|
4638
4719
|
_counter.n++;
|
|
4639
4720
|
return `${prefix}-${_counter.n}`;
|
|
4640
4721
|
}
|
|
@@ -4648,7 +4729,7 @@ function show(condition, element) {
|
|
|
4648
4729
|
const update = () => {
|
|
4649
4730
|
resolved.style.display = condition() ? "" : "none";
|
|
4650
4731
|
};
|
|
4651
|
-
registerDisposer(resolved,
|
|
4732
|
+
registerDisposer(resolved, reactiveBinding2(update, resolved));
|
|
4652
4733
|
return resolved;
|
|
4653
4734
|
}
|
|
4654
4735
|
function attachBranch(parent, anchor, branch, attachedOnce, where) {
|
|
@@ -4672,9 +4753,11 @@ function when(condition, thenBranch, elseBranch) {
|
|
|
4672
4753
|
let currentNode = null;
|
|
4673
4754
|
let lastCondition;
|
|
4674
4755
|
let initialized = false;
|
|
4756
|
+
let disposed = false;
|
|
4675
4757
|
const attachedOnce = /* @__PURE__ */ new WeakSet();
|
|
4676
4758
|
let currentNodeOwned = false;
|
|
4677
4759
|
const update = () => {
|
|
4760
|
+
if (disposed) return;
|
|
4678
4761
|
const show2 = condition();
|
|
4679
4762
|
const parent = anchor.parentNode;
|
|
4680
4763
|
if (!parent) return;
|
|
@@ -4693,10 +4776,14 @@ function when(condition, thenBranch, elseBranch) {
|
|
|
4693
4776
|
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "when");
|
|
4694
4777
|
initialized = true;
|
|
4695
4778
|
};
|
|
4696
|
-
|
|
4779
|
+
const stopBinding = reactiveBinding2(update, anchor);
|
|
4780
|
+
registerDisposer(anchor, () => {
|
|
4781
|
+
disposed = true;
|
|
4782
|
+
stopBinding();
|
|
4783
|
+
});
|
|
4697
4784
|
if (!initialized) {
|
|
4698
4785
|
queueMicrotask(() => {
|
|
4699
|
-
if (!initialized && anchor.parentNode) update();
|
|
4786
|
+
if (!disposed && !initialized && anchor.parentNode) update();
|
|
4700
4787
|
});
|
|
4701
4788
|
}
|
|
4702
4789
|
return anchor;
|
|
@@ -4706,9 +4793,11 @@ function match(value, cases, fallback) {
|
|
|
4706
4793
|
let currentNode = null;
|
|
4707
4794
|
let lastKey;
|
|
4708
4795
|
let initialized = false;
|
|
4796
|
+
let disposed = false;
|
|
4709
4797
|
const attachedOnce = /* @__PURE__ */ new WeakSet();
|
|
4710
4798
|
let currentNodeOwned = false;
|
|
4711
4799
|
const update = () => {
|
|
4800
|
+
if (disposed) return;
|
|
4712
4801
|
const key = String(value());
|
|
4713
4802
|
const parent = anchor.parentNode;
|
|
4714
4803
|
if (!parent) return;
|
|
@@ -4727,17 +4816,30 @@ function match(value, cases, fallback) {
|
|
|
4727
4816
|
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "match");
|
|
4728
4817
|
initialized = true;
|
|
4729
4818
|
};
|
|
4730
|
-
|
|
4819
|
+
const stopBinding = reactiveBinding2(update, anchor);
|
|
4820
|
+
registerDisposer(anchor, () => {
|
|
4821
|
+
disposed = true;
|
|
4822
|
+
stopBinding();
|
|
4823
|
+
});
|
|
4731
4824
|
if (!initialized) {
|
|
4732
4825
|
queueMicrotask(() => {
|
|
4733
|
-
if (!initialized && anchor.parentNode) update();
|
|
4826
|
+
if (!disposed && !initialized && anchor.parentNode) update();
|
|
4734
4827
|
});
|
|
4735
4828
|
}
|
|
4736
4829
|
return anchor;
|
|
4737
4830
|
}
|
|
4738
4831
|
|
|
4832
|
+
// src/utils/globalSingleton.ts
|
|
4833
|
+
function globalSingleton(key, create) {
|
|
4834
|
+
const g2 = globalThis;
|
|
4835
|
+
return g2[key] ?? (g2[key] = create());
|
|
4836
|
+
}
|
|
4837
|
+
|
|
4739
4838
|
// src/core/rendering/dynamic.ts
|
|
4740
|
-
var componentRegistry =
|
|
4839
|
+
var componentRegistry = globalSingleton(
|
|
4840
|
+
/* @__PURE__ */ Symbol.for("sibujs.components.registry.v1"),
|
|
4841
|
+
() => /* @__PURE__ */ new Map()
|
|
4842
|
+
);
|
|
4741
4843
|
function registerComponent(name, component) {
|
|
4742
4844
|
componentRegistry.set(name, component);
|
|
4743
4845
|
}
|
|
@@ -4749,7 +4851,7 @@ function resolveComponent(name) {
|
|
|
4749
4851
|
if (component) {
|
|
4750
4852
|
return component();
|
|
4751
4853
|
}
|
|
4752
|
-
return div(
|
|
4854
|
+
return div(`[Component "${name}" not found]`);
|
|
4753
4855
|
}
|
|
4754
4856
|
function DynamicComponent(is) {
|
|
4755
4857
|
const container = div({ class: "sibu-dynamic" });
|
|
@@ -4882,7 +4984,12 @@ function each(getArray, render, options) {
|
|
|
4882
4984
|
const [indexGetter, setIndex] = signal(i2);
|
|
4883
4985
|
let node;
|
|
4884
4986
|
try {
|
|
4885
|
-
|
|
4987
|
+
suspendTracking2();
|
|
4988
|
+
try {
|
|
4989
|
+
node = resolveNodeChild(render(itemGetter, indexGetter));
|
|
4990
|
+
} finally {
|
|
4991
|
+
resumeTracking2();
|
|
4992
|
+
}
|
|
4886
4993
|
} catch (err) {
|
|
4887
4994
|
const key2 = newKeys[i2];
|
|
4888
4995
|
node = document.createComment(`each:error:${i2}`);
|
|
@@ -5563,10 +5670,15 @@ function Portal(nodes, target) {
|
|
|
5563
5670
|
|
|
5564
5671
|
// src/core/rendering/slots.ts
|
|
5565
5672
|
function getSlot(slots, name = "default") {
|
|
5566
|
-
|
|
5673
|
+
if (slots == null || !Object.hasOwn(slots, name)) return void 0;
|
|
5674
|
+
const slot2 = slots[name];
|
|
5675
|
+
return typeof slot2 === "function" ? slot2 : void 0;
|
|
5567
5676
|
}
|
|
5568
5677
|
|
|
5569
5678
|
// src/core/signals/array.ts
|
|
5679
|
+
function nativeSplice(target, start, rest) {
|
|
5680
|
+
return rest.length === 0 ? target.splice(start) : target.splice(start, ...rest);
|
|
5681
|
+
}
|
|
5570
5682
|
function array(initial = []) {
|
|
5571
5683
|
const [arr, setArr] = signal([...initial]);
|
|
5572
5684
|
const actions = {
|
|
@@ -5594,12 +5706,12 @@ function array(initial = []) {
|
|
|
5594
5706
|
unshift(...items) {
|
|
5595
5707
|
setArr((prev) => [...items, ...prev]);
|
|
5596
5708
|
},
|
|
5597
|
-
splice(start,
|
|
5709
|
+
splice(start, ...rest) {
|
|
5598
5710
|
let removed = [];
|
|
5599
5711
|
setArr((prev) => {
|
|
5600
5712
|
const copy = [...prev];
|
|
5601
|
-
removed = copy
|
|
5602
|
-
return copy;
|
|
5713
|
+
removed = nativeSplice(copy, start, rest);
|
|
5714
|
+
return removed.length === 0 && rest.length <= 1 ? prev : copy;
|
|
5603
5715
|
});
|
|
5604
5716
|
return removed;
|
|
5605
5717
|
},
|
|
@@ -5682,9 +5794,9 @@ function reactiveArray(initial = []) {
|
|
|
5682
5794
|
data2.unshift(...items);
|
|
5683
5795
|
notify();
|
|
5684
5796
|
},
|
|
5685
|
-
splice(start,
|
|
5686
|
-
const removed = data2
|
|
5687
|
-
if (removed.length > 0 ||
|
|
5797
|
+
splice(start, ...rest) {
|
|
5798
|
+
const removed = nativeSplice(data2, start, rest);
|
|
5799
|
+
if (removed.length > 0 || rest.length > 1) {
|
|
5688
5800
|
notify();
|
|
5689
5801
|
}
|
|
5690
5802
|
return removed;
|
|
@@ -5906,6 +6018,21 @@ function deepEqual(a2, b2, seen) {
|
|
|
5906
6018
|
if (a2.length !== b2.length) return false;
|
|
5907
6019
|
return a2.every((val, i2) => deepEqual(val, b2[i2], seen));
|
|
5908
6020
|
}
|
|
6021
|
+
if (a2 instanceof Number || a2 instanceof String || a2 instanceof Boolean) {
|
|
6022
|
+
return Object.is(a2.valueOf(), b2.valueOf());
|
|
6023
|
+
}
|
|
6024
|
+
if (typeof URL !== "undefined" && a2 instanceof URL) {
|
|
6025
|
+
return a2.href === b2.href;
|
|
6026
|
+
}
|
|
6027
|
+
if (a2 instanceof Error) {
|
|
6028
|
+
const eb = b2;
|
|
6029
|
+
return a2.name === eb.name && a2.message === eb.message && deepEqual(a2.cause, eb.cause, seen) && plainKeysEqual(objA, objB, seen);
|
|
6030
|
+
}
|
|
6031
|
+
const proto = Object.getPrototypeOf(objA);
|
|
6032
|
+
if (proto !== Object.prototype && proto !== null) return false;
|
|
6033
|
+
return plainKeysEqual(objA, objB, seen);
|
|
6034
|
+
}
|
|
6035
|
+
function plainKeysEqual(objA, objB, seen) {
|
|
5909
6036
|
const keysA = Object.keys(objA);
|
|
5910
6037
|
const keysB = Object.keys(objB);
|
|
5911
6038
|
if (keysA.length !== keysB.length) return false;
|
|
@@ -5925,10 +6052,14 @@ function derived(getter, options) {
|
|
|
5925
6052
|
const cs = {};
|
|
5926
6053
|
cs._d = false;
|
|
5927
6054
|
cs._init = false;
|
|
6055
|
+
cs._f = false;
|
|
5928
6056
|
cs._g = getter;
|
|
5929
6057
|
cs.__v = 0;
|
|
6058
|
+
let evaluating = false;
|
|
6059
|
+
let disposed = false;
|
|
6060
|
+
let pendingError;
|
|
5930
6061
|
const markDirty = () => {
|
|
5931
|
-
if (cs._d) return;
|
|
6062
|
+
if (cs._d || disposed) return;
|
|
5932
6063
|
cs._d = true;
|
|
5933
6064
|
};
|
|
5934
6065
|
markDirty._c = 1;
|
|
@@ -5951,33 +6082,53 @@ function derived(getter, options) {
|
|
|
5951
6082
|
}
|
|
5952
6083
|
}, markDirty);
|
|
5953
6084
|
const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
5954
|
-
let evaluating = false;
|
|
5955
6085
|
const validate = () => {
|
|
5956
|
-
if (!cs._d) return;
|
|
6086
|
+
if (!cs._d || disposed || pendingError !== void 0) return;
|
|
5957
6087
|
const oldValue = cs._v;
|
|
5958
6088
|
evaluating = true;
|
|
5959
6089
|
try {
|
|
5960
6090
|
retrack2(recompute, markDirty);
|
|
5961
6091
|
if (!Object.is(oldValue, cs._v)) cs.__v++;
|
|
6092
|
+
} catch (err) {
|
|
6093
|
+
pendingError = { error: err };
|
|
6094
|
+
cs.__v++;
|
|
6095
|
+
if (disposed) cs._d = true;
|
|
6096
|
+
else cs._f = true;
|
|
5962
6097
|
} finally {
|
|
5963
6098
|
evaluating = false;
|
|
6099
|
+
if (disposed) cleanup2(markDirty);
|
|
5964
6100
|
}
|
|
5965
|
-
if (hook && !Object.is(oldValue, cs._v)) {
|
|
6101
|
+
if (hook && !disposed && !Object.is(oldValue, cs._v)) {
|
|
5966
6102
|
hook.emit("computed:update", { signal: cs, oldValue, newValue: cs._v });
|
|
5967
6103
|
}
|
|
5968
6104
|
};
|
|
5969
6105
|
cs._validate = validate;
|
|
6106
|
+
const throwPending = () => {
|
|
6107
|
+
const { error } = pendingError;
|
|
6108
|
+
pendingError = void 0;
|
|
6109
|
+
if (disposed) cs._d = false;
|
|
6110
|
+
throw error;
|
|
6111
|
+
};
|
|
5970
6112
|
function computedGetter() {
|
|
5971
6113
|
if (evaluating) {
|
|
5972
6114
|
throw new Error(
|
|
5973
6115
|
`[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
|
|
5974
6116
|
);
|
|
5975
6117
|
}
|
|
5976
|
-
if (isTrackingSuspended2()) {
|
|
5977
|
-
if (cs._d)
|
|
6118
|
+
if (isTrackingSuspended2() || disposed) {
|
|
6119
|
+
if (cs._d) {
|
|
6120
|
+
validate();
|
|
6121
|
+
if (pendingError !== void 0) throwPending();
|
|
6122
|
+
}
|
|
5978
6123
|
return cs._v;
|
|
5979
6124
|
}
|
|
5980
|
-
if (cs._d)
|
|
6125
|
+
if (cs._d) {
|
|
6126
|
+
validate();
|
|
6127
|
+
if (pendingError !== void 0) {
|
|
6128
|
+
recordDependency2(cs);
|
|
6129
|
+
throwPending();
|
|
6130
|
+
}
|
|
6131
|
+
}
|
|
5981
6132
|
recordDependency2(cs);
|
|
5982
6133
|
return cs._v;
|
|
5983
6134
|
}
|
|
@@ -5986,6 +6137,19 @@ function derived(getter, options) {
|
|
|
5986
6137
|
cs.__name = debugName;
|
|
5987
6138
|
}
|
|
5988
6139
|
computedGetter.__signal = cs;
|
|
6140
|
+
computedGetter.dispose = () => {
|
|
6141
|
+
if (disposed) return;
|
|
6142
|
+
disposed = true;
|
|
6143
|
+
cs._d = pendingError !== void 0;
|
|
6144
|
+
cleanup2(markDirty);
|
|
6145
|
+
const h = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
6146
|
+
if (h) {
|
|
6147
|
+
try {
|
|
6148
|
+
h.emit("computed:destroy", { signal: cs, getter: computedGetter });
|
|
6149
|
+
} catch {
|
|
6150
|
+
}
|
|
6151
|
+
}
|
|
6152
|
+
};
|
|
5989
6153
|
if (hook) hook.emit("computed:create", { signal: cs, name: debugName, getter: computedGetter });
|
|
5990
6154
|
return computedGetter;
|
|
5991
6155
|
}
|
|
@@ -6004,15 +6168,18 @@ function ref(initial) {
|
|
|
6004
6168
|
}
|
|
6005
6169
|
|
|
6006
6170
|
// src/core/signals/store.ts
|
|
6171
|
+
function defineOwn(obj, key, value) {
|
|
6172
|
+
Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });
|
|
6173
|
+
}
|
|
6007
6174
|
function store(initialState) {
|
|
6008
6175
|
devAssert(
|
|
6009
6176
|
initialState !== null && typeof initialState === "object" && !Array.isArray(initialState),
|
|
6010
6177
|
"store: argument must be a plain object. For arrays, use array() instead."
|
|
6011
6178
|
);
|
|
6012
|
-
const signals =
|
|
6179
|
+
const signals = /* @__PURE__ */ Object.create(null);
|
|
6013
6180
|
Object.keys(initialState).forEach((key) => {
|
|
6014
6181
|
const [getter, setter] = signal(initialState[key]);
|
|
6015
|
-
signals
|
|
6182
|
+
defineOwn(signals, key, [getter, setter]);
|
|
6016
6183
|
});
|
|
6017
6184
|
const store2 = new Proxy({}, {
|
|
6018
6185
|
get(target, prop) {
|
|
@@ -6031,7 +6198,7 @@ function store(initialState) {
|
|
|
6031
6198
|
const getSnapshot = () => {
|
|
6032
6199
|
const snapshot = {};
|
|
6033
6200
|
Object.keys(signals).forEach((key) => {
|
|
6034
|
-
snapshot
|
|
6201
|
+
defineOwn(snapshot, key, signals[key][0]());
|
|
6035
6202
|
});
|
|
6036
6203
|
return snapshot;
|
|
6037
6204
|
};
|
|
@@ -6167,6 +6334,13 @@ function strictEffect(fn) {
|
|
|
6167
6334
|
};
|
|
6168
6335
|
}
|
|
6169
6336
|
|
|
6337
|
+
// src/reactivity/domBinding.ts
|
|
6338
|
+
function domBinding(commit, ownerNode) {
|
|
6339
|
+
if (isSSR()) return () => {
|
|
6340
|
+
};
|
|
6341
|
+
return reactiveBinding2(commit, ownerNode);
|
|
6342
|
+
}
|
|
6343
|
+
|
|
6170
6344
|
// src/platform/enhance.ts
|
|
6171
6345
|
var ENHANCED_ATTR = "data-sibu-enhanced";
|
|
6172
6346
|
var enhancementOwner = /* @__PURE__ */ new WeakMap();
|
|
@@ -6202,9 +6376,7 @@ function resolveTarget(root, target) {
|
|
|
6202
6376
|
}
|
|
6203
6377
|
}
|
|
6204
6378
|
function bindNode(el, commit) {
|
|
6205
|
-
|
|
6206
|
-
};
|
|
6207
|
-
return reactiveBinding2(commit, el);
|
|
6379
|
+
return domBinding(commit, el);
|
|
6208
6380
|
}
|
|
6209
6381
|
function readControlValue(el) {
|
|
6210
6382
|
if (el instanceof HTMLInputElement) {
|
|
@@ -6462,12 +6634,6 @@ function enhanceAll(selector, setup) {
|
|
|
6462
6634
|
};
|
|
6463
6635
|
}
|
|
6464
6636
|
|
|
6465
|
-
// src/utils/globalSingleton.ts
|
|
6466
|
-
function globalSingleton(key, create) {
|
|
6467
|
-
const g2 = globalThis;
|
|
6468
|
-
return g2[key] ?? (g2[key] = create());
|
|
6469
|
-
}
|
|
6470
|
-
|
|
6471
6637
|
// src/platform/islands.ts
|
|
6472
6638
|
var SAFE_NAME = /^[A-Za-z0-9_-]+$/;
|
|
6473
6639
|
var LAZY = /* @__PURE__ */ Symbol.for("sibujs.islands.lazy");
|
|
@@ -6624,6 +6790,27 @@ function trustHTML(html3) {
|
|
|
6624
6790
|
}
|
|
6625
6791
|
var DEFAULT_MAX_SSR_BYTES = 1024 * 1024;
|
|
6626
6792
|
|
|
6793
|
+
// src/utils/adoptThenable.ts
|
|
6794
|
+
function adoptThenable(value) {
|
|
6795
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return null;
|
|
6796
|
+
let then;
|
|
6797
|
+
try {
|
|
6798
|
+
then = value.then;
|
|
6799
|
+
} catch (error) {
|
|
6800
|
+
return Promise.reject(error);
|
|
6801
|
+
}
|
|
6802
|
+
if (typeof then !== "function") return null;
|
|
6803
|
+
return new Promise((resolve, reject) => {
|
|
6804
|
+
queueMicrotask(() => {
|
|
6805
|
+
try {
|
|
6806
|
+
Reflect.apply(then, value, [resolve, reject]);
|
|
6807
|
+
} catch (error) {
|
|
6808
|
+
reject(error);
|
|
6809
|
+
}
|
|
6810
|
+
});
|
|
6811
|
+
});
|
|
6812
|
+
}
|
|
6813
|
+
|
|
6627
6814
|
// src/reactivity/concurrent.ts
|
|
6628
6815
|
function defer(getter) {
|
|
6629
6816
|
const [value, setValue] = signal(getter());
|
|
@@ -6673,23 +6860,27 @@ function scheduleIdle(fn) {
|
|
|
6673
6860
|
}
|
|
6674
6861
|
function transition() {
|
|
6675
6862
|
const [pending, setPending] = signal(false);
|
|
6863
|
+
let outstanding = 0;
|
|
6676
6864
|
function start(fn) {
|
|
6865
|
+
outstanding++;
|
|
6677
6866
|
setPending(true);
|
|
6867
|
+
let settled = false;
|
|
6868
|
+
const finish = () => {
|
|
6869
|
+
if (settled) return;
|
|
6870
|
+
settled = true;
|
|
6871
|
+
outstanding--;
|
|
6872
|
+
if (outstanding === 0) setPending(false);
|
|
6873
|
+
};
|
|
6874
|
+
const fail = (error) => {
|
|
6875
|
+
finish();
|
|
6876
|
+
reportError(error, { phase: "async", name: "transition" });
|
|
6877
|
+
};
|
|
6678
6878
|
scheduleIdle(() => {
|
|
6679
|
-
let result;
|
|
6680
6879
|
try {
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
}
|
|
6686
|
-
if (result && typeof result.then === "function") {
|
|
6687
|
-
result.then(
|
|
6688
|
-
() => setPending(false),
|
|
6689
|
-
() => setPending(false)
|
|
6690
|
-
);
|
|
6691
|
-
} else {
|
|
6692
|
-
setPending(false);
|
|
6880
|
+
const adopted = adoptThenable(fn());
|
|
6881
|
+
adopted ? adopted.then(finish, fail) : finish();
|
|
6882
|
+
} catch (error) {
|
|
6883
|
+
fail(error);
|
|
6693
6884
|
}
|
|
6694
6885
|
});
|
|
6695
6886
|
}
|