sibujs 4.14.0 → 4.15.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 +297 -45
- package/dist/browser.js +6 -7
- package/dist/build.cjs +2189 -573
- package/dist/build.js +16 -15
- package/dist/cdn.dev.global.js +13 -12
- package/dist/cdn.full.dev.global.js +14 -13
- package/dist/cdn.full.global.js +12 -12
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-RVR5NPFL.js → chunk-2VKTFA7C.js} +1 -1
- package/dist/{chunk-7ILEHTVX.js → chunk-4AEFGRYW.js} +1 -1
- package/dist/{chunk-4TQDTWWN.js → chunk-6IV5ZRG6.js} +5 -7
- package/dist/{chunk-GVAMIU6K.js → chunk-75EAQH3U.js} +2 -2
- package/dist/{chunk-TLS4NVIB.js → chunk-7JO7DPSS.js} +4 -4
- package/dist/{chunk-SVULV7O4.js → chunk-AQH7WDSE.js} +6 -8
- package/dist/{chunk-S37PZD6I.js → chunk-BF3WBJJQ.js} +60 -10
- package/dist/{chunk-LJMX4SQ7.js → chunk-BG4BP44S.js} +3 -3
- package/dist/{chunk-N7A6FKWW.js → chunk-D44TAGCT.js} +2 -2
- package/dist/{chunk-CCKUNHVU.js → chunk-DAEXQJQA.js} +1 -1
- package/dist/chunk-DNCQDFJJ.js +22 -0
- package/dist/{chunk-BKZ5N6NK.js → chunk-DNCT2UXB.js} +4 -4
- package/dist/{chunk-BOYKGGVD.js → chunk-DRWOD7RZ.js} +4 -4
- package/dist/chunk-DS5V2PRE.js +64 -0
- package/dist/{chunk-VM2U5LEL.js → chunk-EHSJESRN.js} +595 -123
- package/dist/{chunk-MIRKTVH4.js → chunk-GFM5WWPU.js} +252 -5
- package/dist/{chunk-52XFPGSN.js → chunk-HTPOIAAL.js} +1 -1
- package/dist/{chunk-3HEX6QJQ.js → chunk-I2R5QALY.js} +2 -4
- package/dist/{chunk-4FJSAUKB.js → chunk-IUBV5WO5.js} +1 -1
- package/dist/{chunk-A454RAEK.js → chunk-KIDETDMU.js} +5 -7
- package/dist/{chunk-JTFQ7IL4.js → chunk-KPAXG5IR.js} +7 -9
- package/dist/{chunk-AE32RGWX.js → chunk-LGUXYHTZ.js} +3 -3
- package/dist/{chunk-Y4LUM2XS.js → chunk-LQWLPQOK.js} +6 -8
- package/dist/{chunk-CNPT6NKV.js → chunk-MINLMJUY.js} +48 -9
- package/dist/{chunk-BNXRWZZV.js → chunk-OURTGOJT.js} +8 -10
- package/dist/{chunk-F67F77IA.js → chunk-TQ24Y3IV.js} +2 -2
- package/dist/{chunk-2TTRW2TE.js → chunk-UM3M5PXS.js} +8 -8
- package/dist/{chunk-CJ7KS3DF.js → chunk-VSTX3XSX.js} +205 -15
- package/dist/{chunk-HQIAL7F2.js → chunk-XPDZ2LDR.js} +2 -2
- package/dist/{chunk-UUIKJJIK.js → chunk-Y7JM7GY2.js} +5 -7
- package/dist/{chunk-QS6GMWDD.js → chunk-YAFITBOK.js} +1269 -162
- package/dist/data.cjs +285 -33
- package/dist/data.js +6 -7
- package/dist/devtools.cjs +289 -39
- package/dist/devtools.js +5 -6
- package/dist/{dispose-EIHHHDC7.js → dispose-3WDBYJMH.js} +3 -1
- package/dist/ecosystem.cjs +345 -61
- package/dist/ecosystem.d.cts +1 -1
- package/dist/ecosystem.d.ts +1 -1
- package/dist/ecosystem.js +10 -10
- package/dist/extras.cjs +568 -248
- package/dist/extras.d.cts +1 -1
- package/dist/extras.d.ts +1 -1
- package/dist/extras.js +27 -27
- package/dist/index.cjs +2134 -515
- package/dist/index.d.cts +628 -211
- package/dist/index.d.ts +628 -211
- package/dist/index.js +22 -15
- package/dist/motion.cjs +286 -30
- package/dist/motion.js +4 -4
- package/dist/patterns.cjs +301 -43
- package/dist/patterns.js +6 -6
- package/dist/performance.cjs +286 -36
- package/dist/performance.js +9 -9
- package/dist/plugins.cjs +1237 -291
- package/dist/plugins.d.cts +3 -1
- package/dist/plugins.d.ts +3 -1
- package/dist/plugins.js +20 -19
- package/dist/{renderRoute-fxgsm2Ir.d.ts → renderRoute-B84MONaO.d.cts} +2 -2
- package/dist/{renderRoute-DP20XwMS.d.cts → renderRoute-_yxPuEQY.d.ts} +2 -2
- package/dist/{routeHead-CE9SV-cH.d.cts → routeHead-DLxlq15W.d.cts} +94 -0
- package/dist/{routeHead-DzVxPviY.d.ts → routeHead-w8nANZ3M.d.ts} +94 -0
- package/dist/{ssr-NECEU4X4.js → ssr-EF3IUHTE.js} +6 -6
- package/dist/ssr-dom.cjs +64 -9
- package/dist/ssr-dom.d.cts +2 -0
- package/dist/ssr-dom.d.ts +2 -0
- package/dist/ssr-dom.js +2 -1
- package/dist/ssr.cjs +850 -170
- package/dist/ssr.d.cts +5 -3
- package/dist/ssr.d.ts +5 -3
- package/dist/ssr.js +16 -15
- package/dist/{tagFactory-DkytnJws.d.cts → tagFactory-BfEh69VF.d.cts} +7 -0
- package/dist/{tagFactory-Bnd_Nph9.d.ts → tagFactory-pSYiLYyh.d.ts} +7 -0
- package/dist/testing.cjs +817 -132
- package/dist/testing.d.cts +4 -2
- package/dist/testing.d.ts +4 -2
- package/dist/testing.js +18 -17
- package/dist/track-core-0edROAF5.d.ts +187 -0
- package/dist/track-core-DN5fYLWi.d.cts +187 -0
- package/dist/ui.cjs +293 -43
- package/dist/ui.js +10 -12
- package/dist/widgets.cjs +285 -27
- package/dist/widgets.js +7 -7
- package/package.json +1 -1
- package/dist/chunk-7ZHH77QA.js +0 -9
package/dist/build.cjs
CHANGED
|
@@ -141,14 +141,14 @@ function assertPrerendered(url, result, failures, timeout) {
|
|
|
141
141
|
`[sibu prerender] ${url}: ${failures[0]}. The page needs data from an API that is not reachable at build time \u2014 start it and point \`prerender.fetch\` at it, or skip the request with isPrerendering().`
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const pending2 = result.diagnostics.pending.join(", ");
|
|
145
145
|
if (result.failure === "timeout") {
|
|
146
146
|
throw new Error(
|
|
147
|
-
`[sibu prerender] ${url}: the route did not render within ${timeout} ms (pending: ${
|
|
147
|
+
`[sibu prerender] ${url}: the route did not render within ${timeout} ms (pending: ${pending2}). A lazy import, a guard or a route load did not finish in time; fix it or raise \`prerender.timeout\`.`
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
if (result.diagnostics.timedOut) {
|
|
151
|
-
throw new Error(`[sibu prerender] ${url}: did not settle within ${timeout} ms (pending: ${
|
|
151
|
+
throw new Error(`[sibu prerender] ${url}: did not settle within ${timeout} ms (pending: ${pending2})`);
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
function buildSitemap(origin, paths) {
|
|
@@ -326,8 +326,8 @@ export { renderRoute, entry };
|
|
|
326
326
|
);
|
|
327
327
|
}
|
|
328
328
|
const body2 = result.render === "client" || result.render === "ssr" ? "" : result.html;
|
|
329
|
-
const
|
|
330
|
-
await write(file, injectIntoShell(shell, { body: body2, head: result.head, state:
|
|
329
|
+
const state4 = body2 ? result.state : "";
|
|
330
|
+
await write(file, injectIntoShell(shell, { body: body2, head: result.head, state: state4 }, options.container));
|
|
331
331
|
if (!result.noindex && result.render !== "client") {
|
|
332
332
|
const pathname = route.path.split(/[?#]/)[0];
|
|
333
333
|
indexable.push(
|
|
@@ -711,6 +711,7 @@ __export(index_exports, {
|
|
|
711
711
|
lazyIsland: () => lazyIsland,
|
|
712
712
|
legend: () => legend,
|
|
713
713
|
li: () => li,
|
|
714
|
+
lifecycleScope: () => lifecycleScope,
|
|
714
715
|
line: () => line,
|
|
715
716
|
linearGradient: () => linearGradient,
|
|
716
717
|
link: () => link,
|
|
@@ -744,6 +745,7 @@ __export(index_exports, {
|
|
|
744
745
|
param: () => param,
|
|
745
746
|
path: () => path,
|
|
746
747
|
pattern: () => pattern,
|
|
748
|
+
pendingContent: () => pendingContent,
|
|
747
749
|
picture: () => picture,
|
|
748
750
|
polygon: () => polygon,
|
|
749
751
|
polyline: () => polyline,
|
|
@@ -770,6 +772,7 @@ __export(index_exports, {
|
|
|
770
772
|
runInSSRContext: () => runInSSRContext,
|
|
771
773
|
s: () => s,
|
|
772
774
|
samp: () => samp,
|
|
775
|
+
scopeOwner: () => scopeOwner,
|
|
773
776
|
script: () => script,
|
|
774
777
|
section: () => section,
|
|
775
778
|
select: () => select,
|
|
@@ -778,7 +781,7 @@ __export(index_exports, {
|
|
|
778
781
|
setRuntimeErrorHandler: () => setRuntimeErrorHandler,
|
|
779
782
|
show: () => show,
|
|
780
783
|
signal: () => signal,
|
|
781
|
-
slot: () =>
|
|
784
|
+
slot: () => slot3,
|
|
782
785
|
small: () => small,
|
|
783
786
|
source: () => source,
|
|
784
787
|
span: () => span,
|
|
@@ -935,6 +938,12 @@ function reportError(error, context2) {
|
|
|
935
938
|
});
|
|
936
939
|
}
|
|
937
940
|
|
|
941
|
+
// src/utils/globalSingleton.ts
|
|
942
|
+
function globalSingleton(key, create) {
|
|
943
|
+
const g2 = globalThis;
|
|
944
|
+
return g2[key] ?? (g2[key] = create());
|
|
945
|
+
}
|
|
946
|
+
|
|
938
947
|
// src/core/dev.ts
|
|
939
948
|
var DEV = typeof __SIBU_DEV__ !== "undefined" ? !!__SIBU_DEV__ : typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
|
|
940
949
|
// safe default: off in browser, on in test/dev Node
|
|
@@ -1035,7 +1044,12 @@ function holdHydration(sessions, entry) {
|
|
|
1035
1044
|
}
|
|
1036
1045
|
|
|
1037
1046
|
// src/core/rendering/dispose.ts
|
|
1038
|
-
var
|
|
1047
|
+
var state2 = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.disposers.v1"), () => ({
|
|
1048
|
+
disposers: /* @__PURE__ */ new WeakMap(),
|
|
1049
|
+
captures: [],
|
|
1050
|
+
bindings: { count: 0 }
|
|
1051
|
+
}));
|
|
1052
|
+
var elementDisposers = state2.disposers;
|
|
1039
1053
|
var MAX_DRAIN_TEARDOWNS = 1e4;
|
|
1040
1054
|
function reportDrainRunaway(label2, executed, remaining) {
|
|
1041
1055
|
if (typeof console === "undefined") return;
|
|
@@ -1044,13 +1058,13 @@ function reportDrainRunaway(label2, executed, remaining) {
|
|
|
1044
1058
|
{ executed, remaining }
|
|
1045
1059
|
);
|
|
1046
1060
|
}
|
|
1047
|
-
var
|
|
1061
|
+
var bindings = state2.bindings;
|
|
1048
1062
|
function resolveCapture(capture) {
|
|
1049
1063
|
let frame = capture;
|
|
1050
1064
|
while (frame?.closed) frame = frame.forwardTo;
|
|
1051
1065
|
return frame ?? null;
|
|
1052
1066
|
}
|
|
1053
|
-
var registrationCaptures =
|
|
1067
|
+
var registrationCaptures = state2.captures;
|
|
1054
1068
|
function currentDisposerCapture() {
|
|
1055
1069
|
return resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
|
|
1056
1070
|
}
|
|
@@ -1069,7 +1083,7 @@ function registerDisposer(node, teardown) {
|
|
|
1069
1083
|
elementDisposers.set(node, disposers);
|
|
1070
1084
|
}
|
|
1071
1085
|
disposers.push(teardown);
|
|
1072
|
-
if (DEV)
|
|
1086
|
+
if (DEV) bindings.count++;
|
|
1073
1087
|
const capture = resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
|
|
1074
1088
|
if (capture) capture.entries.push([node, teardown]);
|
|
1075
1089
|
}
|
|
@@ -1122,7 +1136,7 @@ function unregisterDisposer(node, teardown) {
|
|
|
1122
1136
|
const index = disposers.indexOf(teardown);
|
|
1123
1137
|
if (index === -1) return false;
|
|
1124
1138
|
disposers.splice(index, 1);
|
|
1125
|
-
if (DEV)
|
|
1139
|
+
if (DEV) bindings.count--;
|
|
1126
1140
|
if (disposers.length === 0) elementDisposers.delete(node);
|
|
1127
1141
|
return true;
|
|
1128
1142
|
}
|
|
@@ -1146,17 +1160,17 @@ function disposeNodeOwn(node) {
|
|
|
1146
1160
|
let executed = 0;
|
|
1147
1161
|
let runaway = false;
|
|
1148
1162
|
while (!runaway) {
|
|
1149
|
-
const
|
|
1150
|
-
if (!
|
|
1151
|
-
const snapshot =
|
|
1163
|
+
const pending2 = elementDisposers.get(node);
|
|
1164
|
+
if (!pending2 || pending2.length === 0) break;
|
|
1165
|
+
const snapshot = pending2.slice();
|
|
1152
1166
|
elementDisposers.delete(node);
|
|
1153
|
-
if (DEV)
|
|
1167
|
+
if (DEV) bindings.count -= snapshot.length;
|
|
1154
1168
|
for (let i2 = 0; i2 < snapshot.length; i2++) {
|
|
1155
1169
|
if (executed >= MAX_DRAIN_TEARDOWNS) {
|
|
1156
1170
|
const rest = snapshot.slice(i2);
|
|
1157
1171
|
const added = elementDisposers.get(node);
|
|
1158
1172
|
elementDisposers.set(node, added ? rest.concat(added) : rest);
|
|
1159
|
-
if (DEV)
|
|
1173
|
+
if (DEV) bindings.count += rest.length;
|
|
1160
1174
|
reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
|
|
1161
1175
|
runaway = true;
|
|
1162
1176
|
break;
|
|
@@ -1195,14 +1209,51 @@ function replaceChildrenSafely(parent, ...next) {
|
|
|
1195
1209
|
}
|
|
1196
1210
|
parent.replaceChildren(...next);
|
|
1197
1211
|
}
|
|
1212
|
+
function stageReplaceChildren(parent, next) {
|
|
1213
|
+
const done = /* @__PURE__ */ new Set();
|
|
1214
|
+
const adopted = () => {
|
|
1215
|
+
if (!isHydrating() || next.length === 0 || next[0] !== parent.firstChild) return false;
|
|
1216
|
+
for (let i2 = 1; i2 < next.length; i2++) if (next[i2 - 1].nextSibling !== next[i2]) return false;
|
|
1217
|
+
return true;
|
|
1218
|
+
};
|
|
1219
|
+
const outgoing = () => {
|
|
1220
|
+
if (adopted()) {
|
|
1221
|
+
const out = [];
|
|
1222
|
+
for (let n = next[next.length - 1].nextSibling; n !== null; n = n.nextSibling) out.push(n);
|
|
1223
|
+
return out;
|
|
1224
|
+
}
|
|
1225
|
+
for (let i2 = 0; i2 < next.length; i2++) next[i2].parentNode?.removeChild(next[i2]);
|
|
1226
|
+
return Array.from(parent.childNodes);
|
|
1227
|
+
};
|
|
1228
|
+
return {
|
|
1229
|
+
teardown: () => {
|
|
1230
|
+
let ran = false;
|
|
1231
|
+
for (const node of outgoing()) {
|
|
1232
|
+
if (done.has(node)) continue;
|
|
1233
|
+
done.add(node);
|
|
1234
|
+
ran = true;
|
|
1235
|
+
dispose(node);
|
|
1236
|
+
}
|
|
1237
|
+
return ran;
|
|
1238
|
+
},
|
|
1239
|
+
insert: () => {
|
|
1240
|
+
if (!adopted()) {
|
|
1241
|
+
parent.replaceChildren(...next);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
const last = next[next.length - 1];
|
|
1245
|
+
while (last.nextSibling) parent.removeChild(last.nextSibling);
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1198
1249
|
function checkLeaks(warnThreshold = 0) {
|
|
1199
1250
|
if (!DEV) return 0;
|
|
1200
|
-
if (warnThreshold > 0 &&
|
|
1251
|
+
if (warnThreshold > 0 && bindings.count > warnThreshold) {
|
|
1201
1252
|
devWarn(
|
|
1202
|
-
`checkLeaks: ${
|
|
1253
|
+
`checkLeaks: ${bindings.count} active DOM bindings detected. Expected \u2264${warnThreshold}. This may indicate a component was removed from the DOM without calling dispose().`
|
|
1203
1254
|
);
|
|
1204
1255
|
}
|
|
1205
|
-
return
|
|
1256
|
+
return bindings.count;
|
|
1206
1257
|
}
|
|
1207
1258
|
|
|
1208
1259
|
// src/utils/sanitize.ts
|
|
@@ -1803,8 +1854,8 @@ function commitSafeAttribute(el, name, value, options) {
|
|
|
1803
1854
|
else el.removeAttribute(name);
|
|
1804
1855
|
return false;
|
|
1805
1856
|
}
|
|
1806
|
-
const
|
|
1807
|
-
const refusal = contextualAttributeRefusal(el, name,
|
|
1857
|
+
const pending2 = value == null || value === false ? null : value === true ? "" : String(value);
|
|
1858
|
+
const refusal = contextualAttributeRefusal(el, name, pending2, options.reactive ? "reactive" : "runtime");
|
|
1808
1859
|
if (refusal !== ContextualRefusal.None) {
|
|
1809
1860
|
warnContextualRefusal(options.label ?? "setSafeAttribute", name, refusal);
|
|
1810
1861
|
if (ns) el.removeAttributeNS(ns, localName);
|
|
@@ -2044,6 +2095,201 @@ function bindOwnerScope(fn) {
|
|
|
2044
2095
|
return (...args) => runWithOwnerScope(scope, () => fn(...args));
|
|
2045
2096
|
}
|
|
2046
2097
|
var currentStructOwner = null;
|
|
2098
|
+
var frozenOwners = 0;
|
|
2099
|
+
var ACTIVE = 0;
|
|
2100
|
+
var PAUSED = 1;
|
|
2101
|
+
var ENDED = 2;
|
|
2102
|
+
var NOOP = () => {
|
|
2103
|
+
};
|
|
2104
|
+
var skippedWhileHeld = /* @__PURE__ */ new Set();
|
|
2105
|
+
var waiters = /* @__PURE__ */ new Set();
|
|
2106
|
+
var heldRoots = /* @__PURE__ */ new Set();
|
|
2107
|
+
function ownerState(tok) {
|
|
2108
|
+
let state4 = ACTIVE;
|
|
2109
|
+
for (let t = tok; t !== null; ) {
|
|
2110
|
+
const o = t.sub;
|
|
2111
|
+
if (o === null) return ENDED;
|
|
2112
|
+
if (o._frozen === true) state4 = PAUSED;
|
|
2113
|
+
t = o._owner ?? null;
|
|
2114
|
+
}
|
|
2115
|
+
return state4;
|
|
2116
|
+
}
|
|
2117
|
+
var endWatchers = /* @__PURE__ */ new Set();
|
|
2118
|
+
var stateWatchers = /* @__PURE__ */ new Set();
|
|
2119
|
+
var stateCheckQueued = false;
|
|
2120
|
+
function queueStateCheck() {
|
|
2121
|
+
if (stateCheckQueued || stateWatchers.size === 0) return;
|
|
2122
|
+
stateCheckQueued = true;
|
|
2123
|
+
queueMicrotask(() => {
|
|
2124
|
+
stateCheckQueued = false;
|
|
2125
|
+
for (const watcher of [...stateWatchers]) {
|
|
2126
|
+
if (!stateWatchers.has(watcher)) continue;
|
|
2127
|
+
const state4 = watcher.check.state();
|
|
2128
|
+
if (state4 === ENDED) stateWatchers.delete(watcher);
|
|
2129
|
+
if (state4 === ENDED || state4 === watcher.last) continue;
|
|
2130
|
+
watcher.last = state4;
|
|
2131
|
+
try {
|
|
2132
|
+
watcher.listener(state4);
|
|
2133
|
+
} catch (err) {
|
|
2134
|
+
reportError(err, { phase: "effect" });
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
var ALWAYS_ACTIVE = Object.assign(() => false, {
|
|
2140
|
+
state: () => ACTIVE,
|
|
2141
|
+
wait: (onActive) => {
|
|
2142
|
+
onActive();
|
|
2143
|
+
return NOOP;
|
|
2144
|
+
},
|
|
2145
|
+
onEnd: () => NOOP,
|
|
2146
|
+
run: (fn) => fn(),
|
|
2147
|
+
onChange: () => NOOP,
|
|
2148
|
+
within: () => false
|
|
2149
|
+
});
|
|
2150
|
+
function captureFrozen() {
|
|
2151
|
+
const tok = currentStructOwner;
|
|
2152
|
+
if (tok === null) return ALWAYS_ACTIVE;
|
|
2153
|
+
const state4 = () => ownerState(tok);
|
|
2154
|
+
const check = Object.assign(() => state4() !== ACTIVE, {
|
|
2155
|
+
state: state4,
|
|
2156
|
+
wait: (onActive, onEnd) => {
|
|
2157
|
+
const now2 = state4();
|
|
2158
|
+
if (now2 !== PAUSED) {
|
|
2159
|
+
(now2 === ACTIVE ? onActive : onEnd)();
|
|
2160
|
+
return NOOP;
|
|
2161
|
+
}
|
|
2162
|
+
const waiter = { check, onActive, onEnd };
|
|
2163
|
+
waiters.add(waiter);
|
|
2164
|
+
return () => {
|
|
2165
|
+
waiters.delete(waiter);
|
|
2166
|
+
};
|
|
2167
|
+
},
|
|
2168
|
+
onEnd: (onEnd) => {
|
|
2169
|
+
if (state4() === ENDED) {
|
|
2170
|
+
onEnd();
|
|
2171
|
+
return NOOP;
|
|
2172
|
+
}
|
|
2173
|
+
const watcher = { check, onActive: NOOP, onEnd };
|
|
2174
|
+
endWatchers.add(watcher);
|
|
2175
|
+
return () => {
|
|
2176
|
+
endWatchers.delete(watcher);
|
|
2177
|
+
};
|
|
2178
|
+
},
|
|
2179
|
+
run: (fn) => {
|
|
2180
|
+
const prev = currentStructOwner;
|
|
2181
|
+
currentStructOwner = tok.sub === null ? null : tok;
|
|
2182
|
+
try {
|
|
2183
|
+
return fn();
|
|
2184
|
+
} finally {
|
|
2185
|
+
currentStructOwner = prev;
|
|
2186
|
+
}
|
|
2187
|
+
},
|
|
2188
|
+
onChange: (listener) => {
|
|
2189
|
+
const last = state4();
|
|
2190
|
+
if (last === ENDED) return NOOP;
|
|
2191
|
+
const watcher = { check, last, listener };
|
|
2192
|
+
stateWatchers.add(watcher);
|
|
2193
|
+
return () => {
|
|
2194
|
+
stateWatchers.delete(watcher);
|
|
2195
|
+
};
|
|
2196
|
+
},
|
|
2197
|
+
within: (owner) => {
|
|
2198
|
+
const target = owner.run(() => currentStructOwner);
|
|
2199
|
+
if (target === null) return false;
|
|
2200
|
+
for (let t = tok; t !== null; ) {
|
|
2201
|
+
if (t === target) return true;
|
|
2202
|
+
const o = t.sub;
|
|
2203
|
+
if (o === null) return false;
|
|
2204
|
+
t = o._owner ?? null;
|
|
2205
|
+
}
|
|
2206
|
+
return false;
|
|
2207
|
+
}
|
|
2208
|
+
});
|
|
2209
|
+
return check;
|
|
2210
|
+
}
|
|
2211
|
+
function holdSubtree(root) {
|
|
2212
|
+
heldRoots.add(root);
|
|
2213
|
+
return () => {
|
|
2214
|
+
if (heldRoots.delete(root)) settleHeld();
|
|
2215
|
+
};
|
|
2216
|
+
}
|
|
2217
|
+
function isHeld(sub2) {
|
|
2218
|
+
if (frozenOwners !== 0 && hasFrozenOwner(sub2)) return true;
|
|
2219
|
+
if (heldRoots.size !== 0) {
|
|
2220
|
+
const node = sub2._errorNode;
|
|
2221
|
+
if (node != null) {
|
|
2222
|
+
for (const root of heldRoots) if (root.contains(node)) return true;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
return false;
|
|
2226
|
+
}
|
|
2227
|
+
function notifyEnded() {
|
|
2228
|
+
for (const watcher of stateWatchers) if (watcher.check.state() === ENDED) stateWatchers.delete(watcher);
|
|
2229
|
+
let ended = null;
|
|
2230
|
+
for (const watcher of endWatchers) {
|
|
2231
|
+
if (watcher.check.state() !== ENDED) continue;
|
|
2232
|
+
endWatchers.delete(watcher);
|
|
2233
|
+
(ended ?? (ended = [])).push(watcher);
|
|
2234
|
+
}
|
|
2235
|
+
if (ended === null) return;
|
|
2236
|
+
for (const watcher of ended) {
|
|
2237
|
+
try {
|
|
2238
|
+
watcher.onEnd();
|
|
2239
|
+
} catch (err) {
|
|
2240
|
+
reportError(err, { phase: "cleanup" });
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
function dropReleasedSkipped() {
|
|
2245
|
+
for (const sub2 of skippedWhileHeld) {
|
|
2246
|
+
if (sub2._disposed === true || sub2.depsHead == null) skippedWhileHeld.delete(sub2);
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
function settleHeld() {
|
|
2250
|
+
for (const sub2 of skippedWhileHeld) {
|
|
2251
|
+
if (sub2._disposed === true) skippedWhileHeld.delete(sub2);
|
|
2252
|
+
else if (!isHeld(sub2)) {
|
|
2253
|
+
skippedWhileHeld.delete(sub2);
|
|
2254
|
+
if (!pendingSet.has(sub2)) {
|
|
2255
|
+
pendingSet.add(sub2);
|
|
2256
|
+
pendingQueue.push(sub2);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
if (frozenOwners === 0 && heldRoots.size === 0) skippedWhileHeld.clear();
|
|
2261
|
+
let ready = null;
|
|
2262
|
+
for (const waiter of waiters) {
|
|
2263
|
+
if (waiter.check.state() === PAUSED) continue;
|
|
2264
|
+
waiters.delete(waiter);
|
|
2265
|
+
(ready ?? (ready = [])).push(waiter);
|
|
2266
|
+
}
|
|
2267
|
+
if (ready !== null) {
|
|
2268
|
+
const settle = ready;
|
|
2269
|
+
queueMicrotask(() => {
|
|
2270
|
+
for (const waiter of settle) {
|
|
2271
|
+
const state4 = waiter.check.state();
|
|
2272
|
+
if (state4 === PAUSED) waiters.add(waiter);
|
|
2273
|
+
else
|
|
2274
|
+
try {
|
|
2275
|
+
(state4 === ACTIVE ? waiter.onActive : waiter.onEnd)();
|
|
2276
|
+
} catch (err) {
|
|
2277
|
+
reportError(err, { phase: "effect" });
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
if (pendingQueue.length > 0) drainNotificationQueue();
|
|
2283
|
+
}
|
|
2284
|
+
function hasFrozenOwner(sub2) {
|
|
2285
|
+
for (let t = sub2._owner ?? null; t !== null; ) {
|
|
2286
|
+
const o = t.sub;
|
|
2287
|
+
if (o === null) return false;
|
|
2288
|
+
if (o._frozen === true) return true;
|
|
2289
|
+
t = o._owner ?? null;
|
|
2290
|
+
}
|
|
2291
|
+
return false;
|
|
2292
|
+
}
|
|
2047
2293
|
var subscriberEpochCounter = 0;
|
|
2048
2294
|
function retrack(effectFn, subscriber) {
|
|
2049
2295
|
const prev = currentSubscriber;
|
|
@@ -2151,6 +2397,20 @@ function structuralBinding(commit, ownerNode) {
|
|
|
2151
2397
|
} finally {
|
|
2152
2398
|
currentStructOwner = prev;
|
|
2153
2399
|
}
|
|
2400
|
+
},
|
|
2401
|
+
freeze: () => {
|
|
2402
|
+
const s2 = sub2;
|
|
2403
|
+
if (s2._disposed || s2._frozen) return;
|
|
2404
|
+
s2._frozen = true;
|
|
2405
|
+
frozenOwners++;
|
|
2406
|
+
queueStateCheck();
|
|
2407
|
+
},
|
|
2408
|
+
thaw: () => {
|
|
2409
|
+
if (!sub2._frozen) return;
|
|
2410
|
+
sub2._frozen = false;
|
|
2411
|
+
frozenOwners--;
|
|
2412
|
+
queueStateCheck();
|
|
2413
|
+
settleHeld();
|
|
2154
2414
|
}
|
|
2155
2415
|
};
|
|
2156
2416
|
}
|
|
@@ -2179,20 +2439,34 @@ function createBinding(commit, ownerNode, structural) {
|
|
|
2179
2439
|
subscriber._errorNode = ownerNode;
|
|
2180
2440
|
subscriber._tok = null;
|
|
2181
2441
|
subscriber._owner = null;
|
|
2442
|
+
subscriber._frozen = false;
|
|
2182
2443
|
if (structural) subscriber._tok = { sub: subscriber };
|
|
2183
2444
|
try {
|
|
2184
2445
|
run();
|
|
2185
2446
|
} catch (err) {
|
|
2186
2447
|
subscriber._disposed = true;
|
|
2187
2448
|
subscriber._errorNode = void 0;
|
|
2188
|
-
if (subscriber._tok != null)
|
|
2449
|
+
if (subscriber._tok != null) {
|
|
2450
|
+
subscriber._tok.sub = null;
|
|
2451
|
+
if (endWatchers.size !== 0 || stateWatchers.size !== 0) notifyEnded();
|
|
2452
|
+
}
|
|
2189
2453
|
cleanup(subscriber);
|
|
2190
2454
|
throw err;
|
|
2191
2455
|
}
|
|
2192
2456
|
subscriber._dispose = () => {
|
|
2193
2457
|
subscriber._disposed = true;
|
|
2458
|
+
const wasFrozen = subscriber._frozen === true;
|
|
2459
|
+
if (wasFrozen) {
|
|
2460
|
+
subscriber._frozen = false;
|
|
2461
|
+
frozenOwners--;
|
|
2462
|
+
}
|
|
2194
2463
|
subscriber._errorNode = void 0;
|
|
2195
|
-
if (subscriber._tok != null)
|
|
2464
|
+
if (subscriber._tok != null) {
|
|
2465
|
+
subscriber._tok.sub = null;
|
|
2466
|
+
if (endWatchers.size !== 0 || stateWatchers.size !== 0) notifyEnded();
|
|
2467
|
+
if (skippedWhileHeld.size !== 0) dropReleasedSkipped();
|
|
2468
|
+
if (wasFrozen || waiters.size !== 0) settleHeld();
|
|
2469
|
+
}
|
|
2196
2470
|
cleanup(subscriber);
|
|
2197
2471
|
};
|
|
2198
2472
|
return subscriber;
|
|
@@ -2302,6 +2576,10 @@ function runPendingOwners(sub2) {
|
|
|
2302
2576
|
}
|
|
2303
2577
|
}
|
|
2304
2578
|
function runQueued(sub2) {
|
|
2579
|
+
if ((frozenOwners !== 0 || heldRoots.size !== 0) && isHeld(sub2)) {
|
|
2580
|
+
skippedWhileHeld.add(sub2);
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2305
2583
|
if (quarantined.size > 0 && quarantined.has(sub2)) return;
|
|
2306
2584
|
if (sub2._hasComputedDep === true && !depsChanged(sub2)) return;
|
|
2307
2585
|
if (tickRepeat(sub2)) {
|
|
@@ -2449,7 +2727,7 @@ function forEachSubscriber(signal2, visit) {
|
|
|
2449
2727
|
}
|
|
2450
2728
|
|
|
2451
2729
|
// src/reactivity/track.ts
|
|
2452
|
-
var _runtimeVersion = true ? "4.
|
|
2730
|
+
var _runtimeVersion = true ? "4.15.0" : "dev";
|
|
2453
2731
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
2454
2732
|
function resolveReactiveApi() {
|
|
2455
2733
|
const g2 = globalThis;
|
|
@@ -2485,6 +2763,8 @@ function resolveReactiveApi() {
|
|
|
2485
2763
|
runWithOwnerScope,
|
|
2486
2764
|
bindOwnerScope,
|
|
2487
2765
|
structuralBinding,
|
|
2766
|
+
captureFrozen,
|
|
2767
|
+
holdSubtree,
|
|
2488
2768
|
version: _runtimeVersion
|
|
2489
2769
|
};
|
|
2490
2770
|
g2[REGISTRY_KEY] = local;
|
|
@@ -2512,6 +2792,22 @@ var getOwnerScope2 = API.getOwnerScope ?? getOwnerScope;
|
|
|
2512
2792
|
var runWithOwnerScope2 = API.runWithOwnerScope ?? runWithOwnerScope;
|
|
2513
2793
|
var bindOwnerScope2 = API.bindOwnerScope ?? bindOwnerScope;
|
|
2514
2794
|
var structuralBinding2 = API.structuralBinding ?? ((commit, ownerNode) => ({ stop: API.reactiveBinding(commit, ownerNode), run: (fn) => fn() }));
|
|
2795
|
+
var captureFrozen2 = API.captureFrozen ?? (() => Object.assign(() => false, {
|
|
2796
|
+
state: () => 0,
|
|
2797
|
+
wait: (onActive) => {
|
|
2798
|
+
onActive();
|
|
2799
|
+
return () => {
|
|
2800
|
+
};
|
|
2801
|
+
},
|
|
2802
|
+
onEnd: () => () => {
|
|
2803
|
+
},
|
|
2804
|
+
run: (fn) => fn(),
|
|
2805
|
+
onChange: () => () => {
|
|
2806
|
+
},
|
|
2807
|
+
within: () => false
|
|
2808
|
+
}));
|
|
2809
|
+
var holdSubtree2 = API.holdSubtree ?? (() => () => {
|
|
2810
|
+
});
|
|
2515
2811
|
|
|
2516
2812
|
// src/reactivity/bindAttribute.ts
|
|
2517
2813
|
function bindAttribute(el, attr, getter) {
|
|
@@ -2640,7 +2936,7 @@ function restoreFocusWithin(snapshot, nodes, where, policy) {
|
|
|
2640
2936
|
const active = document.activeElement;
|
|
2641
2937
|
if (active === snapshot.el) return;
|
|
2642
2938
|
if (active && active !== document.body && active !== document.documentElement) return;
|
|
2643
|
-
if (snapshot.el.isConnected) {
|
|
2939
|
+
if (snapshot.el.isConnected && !snapshot.el.closest("[inert]")) {
|
|
2644
2940
|
refocus(snapshot.el, snapshot);
|
|
2645
2941
|
return;
|
|
2646
2942
|
}
|
|
@@ -2667,141 +2963,475 @@ function restoreFocusWithin(snapshot, nodes, where, policy) {
|
|
|
2667
2963
|
});
|
|
2668
2964
|
}
|
|
2669
2965
|
|
|
2670
|
-
// src/
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
}
|
|
2693
|
-
const parent = placeholder.parentNode;
|
|
2694
|
-
if (!parent) {
|
|
2695
|
-
lastNodes.length = 0;
|
|
2696
|
-
return;
|
|
2697
|
-
}
|
|
2698
|
-
let newNodes;
|
|
2699
|
-
if (Array.isArray(result)) {
|
|
2700
|
-
newNodes = [];
|
|
2701
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2702
|
-
for (let i2 = 0; i2 < result.length; i2++) {
|
|
2703
|
-
const item = result[i2];
|
|
2704
|
-
if (item == null || typeof item === "boolean") continue;
|
|
2705
|
-
const node = item instanceof Node ? item : document.createTextNode(String(item));
|
|
2706
|
-
if (seen.has(node)) {
|
|
2707
|
-
if (DEV) devWarn("bindChildNode: duplicate node reference in array \u2014 only the first occurrence is rendered.");
|
|
2708
|
-
continue;
|
|
2709
|
-
}
|
|
2710
|
-
seen.add(node);
|
|
2711
|
-
newNodes.push(node);
|
|
2712
|
-
}
|
|
2713
|
-
} else {
|
|
2714
|
-
const node = result instanceof Node ? result : document.createTextNode(String(result));
|
|
2715
|
-
newNodes = [node];
|
|
2716
|
-
}
|
|
2717
|
-
let reused;
|
|
2718
|
-
if (lastNodes.length > 0 && newNodes.length > 0) {
|
|
2719
|
-
const lastSet = new Set(lastNodes);
|
|
2720
|
-
reused = /* @__PURE__ */ new Set();
|
|
2721
|
-
for (let i2 = 0; i2 < newNodes.length; i2++) {
|
|
2722
|
-
if (lastSet.has(newNodes[i2])) reused.add(newNodes[i2]);
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
for (let i2 = 0; i2 < lastNodes.length; i2++) {
|
|
2726
|
-
const node = lastNodes[i2];
|
|
2727
|
-
if (reused?.has(node)) continue;
|
|
2728
|
-
dispose(node);
|
|
2729
|
-
if (node.parentNode) node.parentNode.removeChild(node);
|
|
2730
|
-
}
|
|
2731
|
-
let prev = placeholder;
|
|
2732
|
-
for (let i2 = 0; i2 < newNodes.length; i2++) {
|
|
2733
|
-
const node = newNodes[i2];
|
|
2734
|
-
if (prev.nextSibling !== node) {
|
|
2735
|
-
parent.insertBefore(node, prev.nextSibling);
|
|
2966
|
+
// src/core/rendering/streamBoundary.ts
|
|
2967
|
+
var _a2;
|
|
2968
|
+
var slot2 = globalThis[_a2 = /* @__PURE__ */ Symbol.for("sibujs.streamBoundary.v1")] ?? (globalThis[_a2] = { hook: null, current: null });
|
|
2969
|
+
function openBoundary(container) {
|
|
2970
|
+
return slot2.hook ? slot2.hook(container) : null;
|
|
2971
|
+
}
|
|
2972
|
+
function currentBoundary() {
|
|
2973
|
+
return slot2.current;
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
// src/core/ssr-context.ts
|
|
2977
|
+
var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
|
|
2978
|
+
function detectSSRShared() {
|
|
2979
|
+
let detected = null;
|
|
2980
|
+
try {
|
|
2981
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
2982
|
+
let mod = null;
|
|
2983
|
+
const getBuiltin = process.getBuiltinModule;
|
|
2984
|
+
if (typeof getBuiltin === "function") {
|
|
2985
|
+
mod = getBuiltin("node:async_hooks");
|
|
2986
|
+
} else if (typeof require === "function") {
|
|
2987
|
+
mod = require("async_hooks");
|
|
2736
2988
|
}
|
|
2737
|
-
|
|
2989
|
+
if (mod) detected = new mod.AsyncLocalStorage();
|
|
2738
2990
|
}
|
|
2739
|
-
|
|
2740
|
-
|
|
2991
|
+
const globalAls = globalThis.AsyncLocalStorage;
|
|
2992
|
+
if (!detected && typeof globalAls === "function") detected = new globalAls();
|
|
2993
|
+
} catch {
|
|
2994
|
+
detected = null;
|
|
2741
2995
|
}
|
|
2742
|
-
return
|
|
2996
|
+
return {
|
|
2997
|
+
als: detected,
|
|
2998
|
+
fallbackStore: { ssr: false, suspenseIdCounter: 0, locale: void 0 },
|
|
2999
|
+
fallbackDepth: 0
|
|
3000
|
+
};
|
|
2743
3001
|
}
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
3002
|
+
var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
|
|
3003
|
+
var als = _shared.als;
|
|
3004
|
+
var fallbackStore = _shared.fallbackStore;
|
|
3005
|
+
_shared.fallbackDepth ?? (_shared.fallbackDepth = 0);
|
|
3006
|
+
var _alsWarned = false;
|
|
3007
|
+
function warnMissingAsyncLocalStorage() {
|
|
3008
|
+
if (_alsWarned || als) return;
|
|
3009
|
+
const isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
3010
|
+
if (!isNode) return;
|
|
3011
|
+
_alsWarned = true;
|
|
3012
|
+
const version = process.versions.node;
|
|
3013
|
+
devWarn(
|
|
3014
|
+
`SSR request isolation is UNAVAILABLE on this runtime (Node ${version}). AsyncLocalStorage could not be loaded, so concurrent requests share one SSR store: request state and the query cache can bleed between them. Node >= 22.3 is required for isolated SSR under ESM; the CommonJS build works on older versions. A fully synchronous render is unaffected.`
|
|
2749
3015
|
);
|
|
2750
3016
|
}
|
|
2751
|
-
function
|
|
2752
|
-
if (
|
|
3017
|
+
function getSSRStore() {
|
|
3018
|
+
if (als) {
|
|
3019
|
+
const s2 = als.getStore();
|
|
3020
|
+
if (s2) return s2;
|
|
3021
|
+
}
|
|
3022
|
+
return fallbackStore;
|
|
2753
3023
|
}
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
var CLOBBER_RISKY_IDS = /* @__PURE__ */ new Set([
|
|
2758
|
-
"config",
|
|
2759
|
-
"location",
|
|
2760
|
-
"history",
|
|
2761
|
-
"document",
|
|
2762
|
-
"window",
|
|
2763
|
-
"navigator",
|
|
2764
|
-
"name",
|
|
2765
|
-
"top",
|
|
2766
|
-
"parent",
|
|
2767
|
-
"self",
|
|
2768
|
-
"frames"
|
|
2769
|
-
]);
|
|
2770
|
-
var warnedLoneStrings = /* @__PURE__ */ new Set();
|
|
2771
|
-
var MAX_WARNED_LONE_STRINGS = 100;
|
|
2772
|
-
var loneStringCapAnnounced = false;
|
|
2773
|
-
var kebabCache = /* @__PURE__ */ new Map();
|
|
2774
|
-
function toKebab(prop) {
|
|
2775
|
-
let cached = kebabCache.get(prop);
|
|
2776
|
-
if (cached !== void 0) return cached;
|
|
2777
|
-
cached = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
2778
|
-
kebabCache.set(prop, cached);
|
|
2779
|
-
return cached;
|
|
3024
|
+
function getRequestStore() {
|
|
3025
|
+
if (als) return als.getStore() ?? null;
|
|
3026
|
+
return _shared.fallbackDepth > 0 ? fallbackStore : null;
|
|
2780
3027
|
}
|
|
2781
|
-
function
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
3028
|
+
function isSSR() {
|
|
3029
|
+
return getSSRStore().ssr;
|
|
3030
|
+
}
|
|
3031
|
+
function getRequestScopedCache(name) {
|
|
3032
|
+
if (!isSSR()) return null;
|
|
3033
|
+
const store2 = getSSRStore();
|
|
3034
|
+
const caches = store2.caches ?? (store2.caches = /* @__PURE__ */ new Map());
|
|
3035
|
+
let c = caches.get(name);
|
|
3036
|
+
if (!c) {
|
|
3037
|
+
c = /* @__PURE__ */ new Map();
|
|
3038
|
+
caches.set(name, c);
|
|
3039
|
+
}
|
|
3040
|
+
return c;
|
|
3041
|
+
}
|
|
3042
|
+
var PRERENDER_HOST = /* @__PURE__ */ Symbol.for("sibujs.prerender.v1");
|
|
3043
|
+
function isServer() {
|
|
3044
|
+
return getSSRStore().ssr || globalThis[PRERENDER_HOST] !== void 0;
|
|
3045
|
+
}
|
|
3046
|
+
function isClient() {
|
|
3047
|
+
return !isServer();
|
|
3048
|
+
}
|
|
3049
|
+
function enableSSR() {
|
|
3050
|
+
getSSRStore().ssr = true;
|
|
3051
|
+
}
|
|
3052
|
+
function disableSSR() {
|
|
3053
|
+
getSSRStore().ssr = false;
|
|
3054
|
+
}
|
|
3055
|
+
function runInSSRContext(fn) {
|
|
3056
|
+
const store2 = {
|
|
3057
|
+
ssr: true,
|
|
3058
|
+
suspenseIdCounter: 0,
|
|
3059
|
+
idCounter: 0,
|
|
3060
|
+
locale: void 0,
|
|
3061
|
+
pending: /* @__PURE__ */ new Set(),
|
|
3062
|
+
wake: null
|
|
3063
|
+
};
|
|
3064
|
+
if (als) {
|
|
3065
|
+
return als.run(store2, fn);
|
|
3066
|
+
}
|
|
3067
|
+
warnMissingAsyncLocalStorage();
|
|
3068
|
+
const prev = { ...fallbackStore };
|
|
3069
|
+
Object.assign(fallbackStore, store2);
|
|
3070
|
+
_shared.fallbackDepth++;
|
|
3071
|
+
try {
|
|
3072
|
+
return fn();
|
|
3073
|
+
} finally {
|
|
3074
|
+
_shared.fallbackDepth--;
|
|
3075
|
+
for (const key of Object.keys(fallbackStore)) {
|
|
3076
|
+
if (!(key in prev)) delete fallbackStore[key];
|
|
3077
|
+
}
|
|
3078
|
+
Object.assign(fallbackStore, prev);
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
function trackPending(promise, label2, hydration = true) {
|
|
3082
|
+
const store2 = getRequestStore();
|
|
3083
|
+
const pending2 = store2?.pending;
|
|
3084
|
+
const sessions = pending2 || !hydration ? [] : hydrationOwners();
|
|
3085
|
+
if (!pending2 && sessions.length === 0) return promise;
|
|
3086
|
+
const entry = { label: label2, since: Date.now(), boundary: currentBoundary() ?? void 0 };
|
|
3087
|
+
pending2?.add(entry);
|
|
3088
|
+
const release = holdHydration(sessions, entry);
|
|
3089
|
+
const done = () => {
|
|
3090
|
+
pending2?.delete(entry);
|
|
3091
|
+
store2?.wake?.();
|
|
3092
|
+
release();
|
|
3093
|
+
};
|
|
3094
|
+
try {
|
|
3095
|
+
Promise.resolve(promise).then(done, done);
|
|
3096
|
+
} catch {
|
|
3097
|
+
done();
|
|
3098
|
+
}
|
|
3099
|
+
return promise;
|
|
3100
|
+
}
|
|
3101
|
+
function withSSR(fn) {
|
|
3102
|
+
const store2 = getSSRStore();
|
|
3103
|
+
const wasSSR = store2.ssr;
|
|
3104
|
+
store2.ssr = true;
|
|
3105
|
+
try {
|
|
3106
|
+
return fn();
|
|
3107
|
+
} finally {
|
|
3108
|
+
if (!wasSSR) store2.ssr = false;
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
// src/core/rendering/range.ts
|
|
3113
|
+
var state3 = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.ranges.v1"), () => ({
|
|
3114
|
+
ends: /* @__PURE__ */ new WeakMap(),
|
|
3115
|
+
pending: /* @__PURE__ */ new WeakMap(),
|
|
3116
|
+
registrations: /* @__PURE__ */ new Set(),
|
|
3117
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
3118
|
+
notice: { queued: false, batch: [] }
|
|
3119
|
+
}));
|
|
3120
|
+
var ends = state3.ends;
|
|
3121
|
+
function registerRange(start, last) {
|
|
3122
|
+
ends.set(start, last);
|
|
3123
|
+
}
|
|
3124
|
+
var pending = state3.pending;
|
|
3125
|
+
var NOTHING = () => {
|
|
3126
|
+
};
|
|
3127
|
+
function queueFirstRender(anchor, render, held) {
|
|
3128
|
+
if (held) {
|
|
3129
|
+
const unguarded = render;
|
|
3130
|
+
render = () => {
|
|
3131
|
+
held.wait(unguarded, NOTHING);
|
|
3132
|
+
};
|
|
3133
|
+
}
|
|
3134
|
+
pending.set(anchor, true);
|
|
3135
|
+
queueMicrotask(() => {
|
|
3136
|
+
if (pending.get(anchor) !== true) return;
|
|
3137
|
+
if (anchor.parentNode === null) {
|
|
3138
|
+
pending.set(anchor, render);
|
|
3139
|
+
return;
|
|
3140
|
+
}
|
|
3141
|
+
pending.delete(anchor);
|
|
3142
|
+
render();
|
|
3143
|
+
});
|
|
3144
|
+
}
|
|
3145
|
+
function resumePending(nodes) {
|
|
3146
|
+
for (const node of nodes) {
|
|
3147
|
+
const render = pending.get(node);
|
|
3148
|
+
if (typeof render !== "function") continue;
|
|
3149
|
+
pending.delete(node);
|
|
3150
|
+
render();
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
function anyPending(nodes) {
|
|
3154
|
+
for (const node of nodes) if (pending.has(node)) return true;
|
|
3155
|
+
return false;
|
|
3156
|
+
}
|
|
3157
|
+
var registrations = state3.registrations;
|
|
3158
|
+
var loadListeners = state3.listeners;
|
|
3159
|
+
var notice = state3.notice;
|
|
3160
|
+
function notifyLoad(settled) {
|
|
3161
|
+
if (loadListeners.size === 0) return;
|
|
3162
|
+
if (settled !== null) notice.batch.push(settled);
|
|
3163
|
+
if (notice.queued) return;
|
|
3164
|
+
notice.queued = true;
|
|
3165
|
+
queueMicrotask(() => {
|
|
3166
|
+
notice.queued = false;
|
|
3167
|
+
const batch2 = notice.batch;
|
|
3168
|
+
notice.batch = [];
|
|
3169
|
+
for (const listener of [...loadListeners]) listener(batch2);
|
|
3170
|
+
});
|
|
3171
|
+
}
|
|
3172
|
+
function beginPending(at, held) {
|
|
3173
|
+
const entry = { at, held, settled: false, cancelled: false, committed: null };
|
|
3174
|
+
registrations.add(entry);
|
|
3175
|
+
notifyLoad(null);
|
|
3176
|
+
const settle = (cancelled, committed) => {
|
|
3177
|
+
if (entry.settled) return;
|
|
3178
|
+
entry.settled = true;
|
|
3179
|
+
entry.cancelled = cancelled;
|
|
3180
|
+
entry.committed = committed;
|
|
3181
|
+
registrations.delete(entry);
|
|
3182
|
+
notifyLoad(entry);
|
|
3183
|
+
};
|
|
3184
|
+
return {
|
|
3185
|
+
entry,
|
|
3186
|
+
done: (committed) => settle(false, committed ?? null),
|
|
3187
|
+
cancel: () => settle(true, null)
|
|
3188
|
+
};
|
|
3189
|
+
}
|
|
3190
|
+
var INERT = { done: NOTHING, cancel: NOTHING };
|
|
3191
|
+
function beginLoading(anchor) {
|
|
3192
|
+
if (isServer()) return INERT;
|
|
3193
|
+
const { done, cancel } = beginPending(anchor, null);
|
|
3194
|
+
return { done: () => done(), cancel };
|
|
3195
|
+
}
|
|
3196
|
+
function pendingWithin(entry, nodes, owner) {
|
|
3197
|
+
const at = entry.at;
|
|
3198
|
+
if (at !== null) {
|
|
3199
|
+
for (let i2 = 0; i2 < nodes.length; i2++) if (nodes[i2] === at || nodes[i2].contains(at)) return true;
|
|
3200
|
+
return false;
|
|
3201
|
+
}
|
|
3202
|
+
return owner !== null && entry.held?.within(owner) === true;
|
|
3203
|
+
}
|
|
3204
|
+
function loadingWithin(nodes, owner) {
|
|
3205
|
+
const found = [];
|
|
3206
|
+
if (registrations.size === 0) return found;
|
|
3207
|
+
for (const entry of registrations) if (pendingWithin(entry, nodes, owner)) found.push(entry);
|
|
3208
|
+
return found;
|
|
3209
|
+
}
|
|
3210
|
+
function settledContent(entry) {
|
|
3211
|
+
if (!entry.settled || entry.cancelled) return [];
|
|
3212
|
+
let nodes;
|
|
3213
|
+
if (entry.committed !== null) nodes = entry.committed;
|
|
3214
|
+
else if (entry.at === null) return [];
|
|
3215
|
+
else if (entry.at.nodeType === 1) nodes = Array.from(entry.at.childNodes);
|
|
3216
|
+
else nodes = collectRange([entry.at]);
|
|
3217
|
+
const out = [];
|
|
3218
|
+
for (let i2 = 0; i2 < nodes.length; i2++) if (nodes[i2].nodeType === 1) out.push(nodes[i2]);
|
|
3219
|
+
return out;
|
|
3220
|
+
}
|
|
3221
|
+
function onLoaded(listener) {
|
|
3222
|
+
loadListeners.add(listener);
|
|
3223
|
+
return () => {
|
|
3224
|
+
loadListeners.delete(listener);
|
|
3225
|
+
};
|
|
3226
|
+
}
|
|
3227
|
+
function settledSinceNotify() {
|
|
3228
|
+
return notice.batch;
|
|
3229
|
+
}
|
|
3230
|
+
function hasRange(node) {
|
|
3231
|
+
return ends.has(node);
|
|
3232
|
+
}
|
|
3233
|
+
function registerNodesRange(anchor, nodes) {
|
|
3234
|
+
registerRange(anchor, () => {
|
|
3235
|
+
const parent = anchor.parentNode;
|
|
3236
|
+
const wanted = nodes().filter((n) => n !== null && n.parentNode === parent);
|
|
3237
|
+
let last = null;
|
|
3238
|
+
let left = wanted.length;
|
|
3239
|
+
for (let n = anchor.nextSibling; n !== null && left > 0; n = n.nextSibling) {
|
|
3240
|
+
if (wanted.includes(n)) {
|
|
3241
|
+
last = n;
|
|
3242
|
+
left--;
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
return last;
|
|
3246
|
+
});
|
|
3247
|
+
}
|
|
3248
|
+
function rangeEnd(node) {
|
|
3249
|
+
let cur = node;
|
|
3250
|
+
for (let get = ends.get(cur); get !== void 0; get = ends.get(cur)) {
|
|
3251
|
+
const next = get();
|
|
3252
|
+
if (next === null || next === cur || next.parentNode !== node.parentNode) break;
|
|
3253
|
+
cur = next;
|
|
3254
|
+
}
|
|
3255
|
+
return cur;
|
|
3256
|
+
}
|
|
3257
|
+
function collectRange(starts) {
|
|
3258
|
+
const out = [];
|
|
3259
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3260
|
+
for (const start of starts) {
|
|
3261
|
+
if (start.parentNode === null) continue;
|
|
3262
|
+
const end = rangeEnd(start);
|
|
3263
|
+
let node = start;
|
|
3264
|
+
let span2 = [start];
|
|
3265
|
+
while (node !== end) {
|
|
3266
|
+
node = node.nextSibling;
|
|
3267
|
+
if (node === null) {
|
|
3268
|
+
span2 = [start];
|
|
3269
|
+
break;
|
|
3270
|
+
}
|
|
3271
|
+
span2.push(node);
|
|
3272
|
+
}
|
|
3273
|
+
for (const n of span2) {
|
|
3274
|
+
if (!seen.has(n)) {
|
|
3275
|
+
seen.add(n);
|
|
3276
|
+
out.push(n);
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
return out;
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
// src/reactivity/bindChildNode.ts
|
|
3284
|
+
function bindChildNode(placeholder, getter, exposeNodes) {
|
|
3285
|
+
let lastNodes = [];
|
|
3286
|
+
const scope = captureScope();
|
|
3287
|
+
function commit() {
|
|
3288
|
+
let result;
|
|
3289
|
+
try {
|
|
3290
|
+
result = inScope(scope, getter);
|
|
3291
|
+
} catch (err) {
|
|
3292
|
+
reportError(err, { phase: "binding", name: "bindChildNode", node: placeholder });
|
|
3293
|
+
return;
|
|
3294
|
+
}
|
|
3295
|
+
const focused = captureFocusWithin(lastNodes);
|
|
3296
|
+
if (result == null || typeof result === "boolean") {
|
|
3297
|
+
for (let i2 = 0; i2 < lastNodes.length; i2++) {
|
|
3298
|
+
const node = lastNodes[i2];
|
|
3299
|
+
dispose(node);
|
|
3300
|
+
if (node.parentNode) node.parentNode.removeChild(node);
|
|
3301
|
+
}
|
|
3302
|
+
lastNodes.length = 0;
|
|
3303
|
+
restoreFocusWithin(focused, lastNodes, "bindChildNode");
|
|
3304
|
+
return;
|
|
3305
|
+
}
|
|
3306
|
+
const parent = placeholder.parentNode;
|
|
3307
|
+
if (!parent) {
|
|
3308
|
+
lastNodes.length = 0;
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
let newNodes;
|
|
3312
|
+
if (Array.isArray(result)) {
|
|
3313
|
+
newNodes = [];
|
|
3314
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3315
|
+
for (let i2 = 0; i2 < result.length; i2++) {
|
|
3316
|
+
const item = result[i2];
|
|
3317
|
+
if (item == null || typeof item === "boolean") continue;
|
|
3318
|
+
const node = item instanceof Node ? item : document.createTextNode(String(item));
|
|
3319
|
+
if (seen.has(node)) {
|
|
3320
|
+
if (DEV) devWarn("bindChildNode: duplicate node reference in array \u2014 only the first occurrence is rendered.");
|
|
3321
|
+
continue;
|
|
3322
|
+
}
|
|
3323
|
+
seen.add(node);
|
|
3324
|
+
newNodes.push(node);
|
|
3325
|
+
}
|
|
3326
|
+
} else {
|
|
3327
|
+
const node = result instanceof Node ? result : document.createTextNode(String(result));
|
|
3328
|
+
newNodes = [node];
|
|
3329
|
+
}
|
|
3330
|
+
let reused;
|
|
3331
|
+
if (lastNodes.length > 0 && newNodes.length > 0) {
|
|
3332
|
+
const lastSet = new Set(lastNodes);
|
|
3333
|
+
reused = /* @__PURE__ */ new Set();
|
|
3334
|
+
for (let i2 = 0; i2 < newNodes.length; i2++) {
|
|
3335
|
+
if (lastSet.has(newNodes[i2])) reused.add(newNodes[i2]);
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
for (let i2 = 0; i2 < lastNodes.length; i2++) {
|
|
3339
|
+
const node = lastNodes[i2];
|
|
3340
|
+
if (reused?.has(node)) continue;
|
|
3341
|
+
dispose(node);
|
|
3342
|
+
if (node.parentNode) node.parentNode.removeChild(node);
|
|
3343
|
+
}
|
|
3344
|
+
let prev = placeholder;
|
|
3345
|
+
for (let i2 = 0; i2 < newNodes.length; i2++) {
|
|
3346
|
+
const node = newNodes[i2];
|
|
3347
|
+
if (prev.nextSibling !== node) {
|
|
3348
|
+
parent.insertBefore(node, prev.nextSibling);
|
|
3349
|
+
}
|
|
3350
|
+
prev = node;
|
|
3351
|
+
}
|
|
3352
|
+
lastNodes = newNodes;
|
|
3353
|
+
restoreFocusWithin(focused, newNodes, "bindChildNode");
|
|
3354
|
+
}
|
|
3355
|
+
if (exposeNodes) {
|
|
3356
|
+
registerRange(placeholder, () => {
|
|
3357
|
+
for (let i2 = lastNodes.length - 1; i2 >= 0; i2--) if (lastNodes[i2].parentNode !== null) return lastNodes[i2];
|
|
3358
|
+
return null;
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
return reactiveBinding2(commit, placeholder, true);
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3364
|
+
// src/utils/styleKey.ts
|
|
3365
|
+
var EXCEPTIONS = { cssFloat: "float" };
|
|
3366
|
+
var VENDOR_PREFIX = /^(webkit|moz|ms|o)-/;
|
|
3367
|
+
var cache = /* @__PURE__ */ new Map();
|
|
3368
|
+
var CACHE_MAX = 1e3;
|
|
3369
|
+
function styleKeyToProperty(key) {
|
|
3370
|
+
let name = cache.get(key);
|
|
3371
|
+
if (name !== void 0) return name;
|
|
3372
|
+
if (key.startsWith("--")) name = key;
|
|
3373
|
+
else if (Object.hasOwn(EXCEPTIONS, key)) name = EXCEPTIONS[key];
|
|
3374
|
+
else {
|
|
3375
|
+
name = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
3376
|
+
if (VENDOR_PREFIX.test(name)) name = `-${name}`;
|
|
3377
|
+
}
|
|
3378
|
+
if (cache.size >= CACHE_MAX) cache.clear();
|
|
3379
|
+
cache.set(key, name);
|
|
3380
|
+
return name;
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3383
|
+
// src/core/rendering/requireDocument.ts
|
|
3384
|
+
function noDocument() {
|
|
3385
|
+
throw new Error(
|
|
3386
|
+
"[SibuJS] renderToString needs a DOM: register happy-dom or jsdom globals first." + (DEV ? ' There is no global `document`, and SibuJS builds live DOM nodes, on the server too. For example: import { GlobalRegistrator } from "@happy-dom/global-registrator"; GlobalRegistrator.register(); See SSR in AGENTS.md \xA710.' : "")
|
|
3387
|
+
);
|
|
3388
|
+
}
|
|
3389
|
+
function requireDocument() {
|
|
3390
|
+
if (typeof document === "undefined") noDocument();
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
// src/core/rendering/tagFactory.ts
|
|
3394
|
+
var SVG_NS3 = "http://www.w3.org/2000/svg";
|
|
3395
|
+
var CLOBBER_RISKY_IDS = /* @__PURE__ */ new Set([
|
|
3396
|
+
"config",
|
|
3397
|
+
"location",
|
|
3398
|
+
"history",
|
|
3399
|
+
"document",
|
|
3400
|
+
"window",
|
|
3401
|
+
"navigator",
|
|
3402
|
+
"name",
|
|
3403
|
+
"top",
|
|
3404
|
+
"parent",
|
|
3405
|
+
"self",
|
|
3406
|
+
"frames"
|
|
3407
|
+
]);
|
|
3408
|
+
var warnedLoneStrings = /* @__PURE__ */ new Set();
|
|
3409
|
+
var MAX_WARNED_LONE_STRINGS = 100;
|
|
3410
|
+
var loneStringCapAnnounced = false;
|
|
3411
|
+
function applyStyle(el, style2) {
|
|
3412
|
+
if (typeof style2 === "function") {
|
|
3413
|
+
const getter = style2;
|
|
3414
|
+
let written = [];
|
|
3415
|
+
let wroteString = false;
|
|
3416
|
+
const teardown = reactiveBinding2(() => {
|
|
3417
|
+
const value = getter();
|
|
3418
|
+
if (value === null || typeof value !== "object") {
|
|
3419
|
+
written = [];
|
|
3420
|
+
wroteString = true;
|
|
3421
|
+
el.setAttribute("style", sanitizeStyleAttribute(String(value), { element: el }));
|
|
3422
|
+
return;
|
|
3423
|
+
}
|
|
3424
|
+
const decl = el.style;
|
|
3425
|
+
if (wroteString) {
|
|
3426
|
+
el.removeAttribute("style");
|
|
3427
|
+
wroteString = false;
|
|
2798
3428
|
}
|
|
2799
3429
|
const next = [];
|
|
2800
3430
|
for (const prop in value) {
|
|
2801
3431
|
if (!Object.hasOwn(value, prop)) continue;
|
|
2802
3432
|
const val = value[prop];
|
|
2803
3433
|
if (val == null) continue;
|
|
2804
|
-
const name =
|
|
3434
|
+
const name = styleKeyToProperty(prop);
|
|
2805
3435
|
next.push(name);
|
|
2806
3436
|
decl.setProperty(name, sanitizeCSSDeclaration(name, String(val), { element: el }));
|
|
2807
3437
|
}
|
|
@@ -2821,7 +3451,7 @@ function applyStyle(el, style2) {
|
|
|
2821
3451
|
for (const prop in style2) {
|
|
2822
3452
|
if (!Object.hasOwn(style2, prop)) continue;
|
|
2823
3453
|
const val = style2[prop];
|
|
2824
|
-
const name =
|
|
3454
|
+
const name = styleKeyToProperty(prop);
|
|
2825
3455
|
if (typeof val === "function") {
|
|
2826
3456
|
const getter = val;
|
|
2827
3457
|
const teardown = reactiveBinding2(() => {
|
|
@@ -3128,196 +3758,107 @@ var tr = tagFactory("tr");
|
|
|
3128
3758
|
var button = tagFactory("button");
|
|
3129
3759
|
var datalist = tagFactory("datalist");
|
|
3130
3760
|
var fieldset = tagFactory("fieldset");
|
|
3131
|
-
var form = tagFactory("form");
|
|
3132
|
-
var input = tagFactory("input");
|
|
3133
|
-
var label = tagFactory("label");
|
|
3134
|
-
var legend = tagFactory("legend");
|
|
3135
|
-
var meter = tagFactory("meter");
|
|
3136
|
-
var optgroup = tagFactory("optgroup");
|
|
3137
|
-
var option = tagFactory("option");
|
|
3138
|
-
var output = tagFactory("output");
|
|
3139
|
-
var progress = tagFactory("progress");
|
|
3140
|
-
var select = tagFactory("select");
|
|
3141
|
-
var textarea = tagFactory("textarea");
|
|
3142
|
-
var details = tagFactory("details");
|
|
3143
|
-
var dialog = tagFactory("dialog");
|
|
3144
|
-
var menu = tagFactory("menu");
|
|
3145
|
-
var summary = tagFactory("summary");
|
|
3146
|
-
var
|
|
3147
|
-
var template = tagFactory("template");
|
|
3148
|
-
var base = tagFactory("base");
|
|
3149
|
-
var link = tagFactory("link");
|
|
3150
|
-
var meta = tagFactory("meta");
|
|
3151
|
-
var style = tagFactory("style");
|
|
3152
|
-
var circle = tagFactory("circle", SVG_NS3);
|
|
3153
|
-
var ellipse = tagFactory("ellipse", SVG_NS3);
|
|
3154
|
-
var g = tagFactory("g", SVG_NS3);
|
|
3155
|
-
var line = tagFactory("line", SVG_NS3);
|
|
3156
|
-
var path = tagFactory("path", SVG_NS3);
|
|
3157
|
-
var polygon = tagFactory("polygon", SVG_NS3);
|
|
3158
|
-
var polyline = tagFactory("polyline", SVG_NS3);
|
|
3159
|
-
var rect = tagFactory("rect", SVG_NS3);
|
|
3160
|
-
var text = tagFactory("text", SVG_NS3);
|
|
3161
|
-
var tspan = tagFactory("tspan", SVG_NS3);
|
|
3162
|
-
var defs = tagFactory("defs", SVG_NS3);
|
|
3163
|
-
var clipPath = tagFactory("clipPath", SVG_NS3);
|
|
3164
|
-
var mask = tagFactory("mask", SVG_NS3);
|
|
3165
|
-
var pattern = tagFactory("pattern", SVG_NS3);
|
|
3166
|
-
var linearGradient = tagFactory("linearGradient", SVG_NS3);
|
|
3167
|
-
var radialGradient = tagFactory("radialGradient", SVG_NS3);
|
|
3168
|
-
var stop = tagFactory("stop", SVG_NS3);
|
|
3169
|
-
var use = tagFactory("use", SVG_NS3);
|
|
3170
|
-
var symbol = tagFactory("symbol", SVG_NS3);
|
|
3171
|
-
var marker = tagFactory("marker", SVG_NS3);
|
|
3172
|
-
var center = tagFactory("center");
|
|
3173
|
-
var font = tagFactory("font");
|
|
3174
|
-
var marquee = tagFactory("marquee");
|
|
3175
|
-
var customElement = (tagName) => tagFactory(tagName);
|
|
3176
|
-
|
|
3177
|
-
// src/core/rendering/
|
|
3178
|
-
var
|
|
3179
|
-
|
|
3180
|
-
function
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
function detectSSRShared() {
|
|
3190
|
-
let detected = null;
|
|
3191
|
-
try {
|
|
3192
|
-
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
3193
|
-
let mod = null;
|
|
3194
|
-
const getBuiltin = process.getBuiltinModule;
|
|
3195
|
-
if (typeof getBuiltin === "function") {
|
|
3196
|
-
mod = getBuiltin("node:async_hooks");
|
|
3197
|
-
} else if (typeof require === "function") {
|
|
3198
|
-
mod = require("async_hooks");
|
|
3199
|
-
}
|
|
3200
|
-
if (mod) detected = new mod.AsyncLocalStorage();
|
|
3201
|
-
}
|
|
3202
|
-
const globalAls = globalThis.AsyncLocalStorage;
|
|
3203
|
-
if (!detected && typeof globalAls === "function") detected = new globalAls();
|
|
3204
|
-
} catch {
|
|
3205
|
-
detected = null;
|
|
3206
|
-
}
|
|
3207
|
-
return {
|
|
3208
|
-
als: detected,
|
|
3209
|
-
fallbackStore: { ssr: false, suspenseIdCounter: 0, locale: void 0 },
|
|
3210
|
-
fallbackDepth: 0
|
|
3211
|
-
};
|
|
3212
|
-
}
|
|
3213
|
-
var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
|
|
3214
|
-
var als = _shared.als;
|
|
3215
|
-
var fallbackStore = _shared.fallbackStore;
|
|
3216
|
-
_shared.fallbackDepth ?? (_shared.fallbackDepth = 0);
|
|
3217
|
-
var _alsWarned = false;
|
|
3218
|
-
function warnMissingAsyncLocalStorage() {
|
|
3219
|
-
if (_alsWarned || als) return;
|
|
3220
|
-
const isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
3221
|
-
if (!isNode) return;
|
|
3222
|
-
_alsWarned = true;
|
|
3223
|
-
const version = process.versions.node;
|
|
3224
|
-
devWarn(
|
|
3225
|
-
`SSR request isolation is UNAVAILABLE on this runtime (Node ${version}). AsyncLocalStorage could not be loaded, so concurrent requests share one SSR store: request state and the query cache can bleed between them. Node >= 22.3 is required for isolated SSR under ESM; the CommonJS build works on older versions. A fully synchronous render is unaffected.`
|
|
3226
|
-
);
|
|
3227
|
-
}
|
|
3228
|
-
function getSSRStore() {
|
|
3229
|
-
if (als) {
|
|
3230
|
-
const s2 = als.getStore();
|
|
3231
|
-
if (s2) return s2;
|
|
3232
|
-
}
|
|
3233
|
-
return fallbackStore;
|
|
3234
|
-
}
|
|
3235
|
-
function getRequestStore() {
|
|
3236
|
-
if (als) return als.getStore() ?? null;
|
|
3237
|
-
return _shared.fallbackDepth > 0 ? fallbackStore : null;
|
|
3238
|
-
}
|
|
3239
|
-
function isSSR() {
|
|
3240
|
-
return getSSRStore().ssr;
|
|
3241
|
-
}
|
|
3242
|
-
function getRequestScopedCache(name) {
|
|
3243
|
-
if (!isSSR()) return null;
|
|
3244
|
-
const store2 = getSSRStore();
|
|
3245
|
-
const caches = store2.caches ?? (store2.caches = /* @__PURE__ */ new Map());
|
|
3246
|
-
let c = caches.get(name);
|
|
3247
|
-
if (!c) {
|
|
3248
|
-
c = /* @__PURE__ */ new Map();
|
|
3249
|
-
caches.set(name, c);
|
|
3250
|
-
}
|
|
3251
|
-
return c;
|
|
3252
|
-
}
|
|
3253
|
-
var PRERENDER_HOST = /* @__PURE__ */ Symbol.for("sibujs.prerender.v1");
|
|
3254
|
-
function isServer() {
|
|
3255
|
-
return getSSRStore().ssr || globalThis[PRERENDER_HOST] !== void 0;
|
|
3256
|
-
}
|
|
3257
|
-
function isClient() {
|
|
3258
|
-
return !isServer();
|
|
3259
|
-
}
|
|
3260
|
-
function enableSSR() {
|
|
3261
|
-
getSSRStore().ssr = true;
|
|
3262
|
-
}
|
|
3263
|
-
function disableSSR() {
|
|
3264
|
-
getSSRStore().ssr = false;
|
|
3265
|
-
}
|
|
3266
|
-
function runInSSRContext(fn) {
|
|
3267
|
-
const store2 = {
|
|
3268
|
-
ssr: true,
|
|
3269
|
-
suspenseIdCounter: 0,
|
|
3270
|
-
idCounter: 0,
|
|
3271
|
-
locale: void 0,
|
|
3272
|
-
pending: /* @__PURE__ */ new Set(),
|
|
3273
|
-
wake: null
|
|
3761
|
+
var form = tagFactory("form");
|
|
3762
|
+
var input = tagFactory("input");
|
|
3763
|
+
var label = tagFactory("label");
|
|
3764
|
+
var legend = tagFactory("legend");
|
|
3765
|
+
var meter = tagFactory("meter");
|
|
3766
|
+
var optgroup = tagFactory("optgroup");
|
|
3767
|
+
var option = tagFactory("option");
|
|
3768
|
+
var output = tagFactory("output");
|
|
3769
|
+
var progress = tagFactory("progress");
|
|
3770
|
+
var select = tagFactory("select");
|
|
3771
|
+
var textarea = tagFactory("textarea");
|
|
3772
|
+
var details = tagFactory("details");
|
|
3773
|
+
var dialog = tagFactory("dialog");
|
|
3774
|
+
var menu = tagFactory("menu");
|
|
3775
|
+
var summary = tagFactory("summary");
|
|
3776
|
+
var slot3 = tagFactory("slot");
|
|
3777
|
+
var template = tagFactory("template");
|
|
3778
|
+
var base = tagFactory("base");
|
|
3779
|
+
var link = tagFactory("link");
|
|
3780
|
+
var meta = tagFactory("meta");
|
|
3781
|
+
var style = tagFactory("style");
|
|
3782
|
+
var circle = tagFactory("circle", SVG_NS3);
|
|
3783
|
+
var ellipse = tagFactory("ellipse", SVG_NS3);
|
|
3784
|
+
var g = tagFactory("g", SVG_NS3);
|
|
3785
|
+
var line = tagFactory("line", SVG_NS3);
|
|
3786
|
+
var path = tagFactory("path", SVG_NS3);
|
|
3787
|
+
var polygon = tagFactory("polygon", SVG_NS3);
|
|
3788
|
+
var polyline = tagFactory("polyline", SVG_NS3);
|
|
3789
|
+
var rect = tagFactory("rect", SVG_NS3);
|
|
3790
|
+
var text = tagFactory("text", SVG_NS3);
|
|
3791
|
+
var tspan = tagFactory("tspan", SVG_NS3);
|
|
3792
|
+
var defs = tagFactory("defs", SVG_NS3);
|
|
3793
|
+
var clipPath = tagFactory("clipPath", SVG_NS3);
|
|
3794
|
+
var mask = tagFactory("mask", SVG_NS3);
|
|
3795
|
+
var pattern = tagFactory("pattern", SVG_NS3);
|
|
3796
|
+
var linearGradient = tagFactory("linearGradient", SVG_NS3);
|
|
3797
|
+
var radialGradient = tagFactory("radialGradient", SVG_NS3);
|
|
3798
|
+
var stop = tagFactory("stop", SVG_NS3);
|
|
3799
|
+
var use = tagFactory("use", SVG_NS3);
|
|
3800
|
+
var symbol = tagFactory("symbol", SVG_NS3);
|
|
3801
|
+
var marker = tagFactory("marker", SVG_NS3);
|
|
3802
|
+
var center = tagFactory("center");
|
|
3803
|
+
var font = tagFactory("font");
|
|
3804
|
+
var marquee = tagFactory("marquee");
|
|
3805
|
+
var customElement = (tagName) => tagFactory(tagName);
|
|
3806
|
+
|
|
3807
|
+
// src/core/rendering/heldCommit.ts
|
|
3808
|
+
var NOOP2 = () => {
|
|
3809
|
+
};
|
|
3810
|
+
function commitWhenActive(slot4, c) {
|
|
3811
|
+
let over = false;
|
|
3812
|
+
let unhold = null;
|
|
3813
|
+
let drop = NOOP2;
|
|
3814
|
+
const finish = () => {
|
|
3815
|
+
over = true;
|
|
3816
|
+
if (slot4.cancel === cancel) slot4.cancel = NOOP2;
|
|
3817
|
+
drop();
|
|
3818
|
+
drop = NOOP2;
|
|
3274
3819
|
};
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
} finally {
|
|
3285
|
-
_shared.fallbackDepth--;
|
|
3286
|
-
for (const key of Object.keys(fallbackStore)) {
|
|
3287
|
-
if (!(key in prev)) delete fallbackStore[key];
|
|
3820
|
+
const cancel = () => {
|
|
3821
|
+
if (over) return;
|
|
3822
|
+
finish();
|
|
3823
|
+
const release = unhold;
|
|
3824
|
+
unhold = null;
|
|
3825
|
+
try {
|
|
3826
|
+
c.discard();
|
|
3827
|
+
} finally {
|
|
3828
|
+
release?.();
|
|
3288
3829
|
}
|
|
3289
|
-
Object.assign(fallbackStore, prev);
|
|
3290
|
-
}
|
|
3291
|
-
}
|
|
3292
|
-
function trackPending(promise, label2, hydration = true) {
|
|
3293
|
-
const store2 = getRequestStore();
|
|
3294
|
-
const pending = store2?.pending;
|
|
3295
|
-
const sessions = pending || !hydration ? [] : hydrationOwners();
|
|
3296
|
-
if (!pending && sessions.length === 0) return promise;
|
|
3297
|
-
const entry = { label: label2, since: Date.now(), boundary: currentBoundary() ?? void 0 };
|
|
3298
|
-
pending?.add(entry);
|
|
3299
|
-
const release = holdHydration(sessions, entry);
|
|
3300
|
-
const done = () => {
|
|
3301
|
-
pending?.delete(entry);
|
|
3302
|
-
store2?.wake?.();
|
|
3303
|
-
release();
|
|
3304
3830
|
};
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3831
|
+
const attempt = () => {
|
|
3832
|
+
drop = NOOP2;
|
|
3833
|
+
let clean = false;
|
|
3834
|
+
while (!over) {
|
|
3835
|
+
const state4 = c.held.state();
|
|
3836
|
+
if (state4 === 2 || c.owned !== void 0 && !c.owned()) {
|
|
3837
|
+
cancel();
|
|
3838
|
+
return;
|
|
3839
|
+
}
|
|
3840
|
+
if (state4 === 1) {
|
|
3841
|
+
if (c.node !== null && unhold === null) unhold = holdSubtree2(c.node);
|
|
3842
|
+
drop = c.held.wait(attempt, attempt);
|
|
3843
|
+
return;
|
|
3844
|
+
}
|
|
3845
|
+
if (unhold !== null) {
|
|
3846
|
+
const release = unhold;
|
|
3847
|
+
unhold = null;
|
|
3848
|
+
release();
|
|
3849
|
+
continue;
|
|
3850
|
+
}
|
|
3851
|
+
if (!clean) {
|
|
3852
|
+
clean = c.teardown?.() !== true;
|
|
3853
|
+
continue;
|
|
3854
|
+
}
|
|
3855
|
+
finish();
|
|
3856
|
+
c.insert();
|
|
3857
|
+
return;
|
|
3858
|
+
}
|
|
3859
|
+
};
|
|
3860
|
+
slot4.cancel = cancel;
|
|
3861
|
+
attempt();
|
|
3321
3862
|
}
|
|
3322
3863
|
|
|
3323
3864
|
// src/core/rendering/lazy.ts
|
|
@@ -3343,100 +3884,296 @@ function takePendingError(node) {
|
|
|
3343
3884
|
}
|
|
3344
3885
|
return void 0;
|
|
3345
3886
|
}
|
|
3887
|
+
var NOOP3 = () => {
|
|
3888
|
+
};
|
|
3346
3889
|
function lazy(importFn) {
|
|
3347
3890
|
let cached = null;
|
|
3891
|
+
const instance = (component) => {
|
|
3892
|
+
const own = structuralBinding2(NOOP3);
|
|
3893
|
+
try {
|
|
3894
|
+
return [withDisposerRollback(() => own.run(component)), own];
|
|
3895
|
+
} catch (err) {
|
|
3896
|
+
own.stop();
|
|
3897
|
+
throw err;
|
|
3898
|
+
}
|
|
3899
|
+
};
|
|
3900
|
+
const ending = (root, own) => root.nodeType === 11 ? () => {
|
|
3901
|
+
disposeNodeOwn(root);
|
|
3902
|
+
own.stop();
|
|
3903
|
+
} : own.stop;
|
|
3348
3904
|
return function LazyComponent() {
|
|
3349
3905
|
if (cached && !inAdoptScope()) {
|
|
3350
|
-
|
|
3906
|
+
const [root, own] = instance(cached);
|
|
3907
|
+
const type = root?.nodeType;
|
|
3908
|
+
if (type === 11) {
|
|
3909
|
+
const box = div({ class: "sibu-lazy" });
|
|
3910
|
+
registerDisposer(box, ending(root, own));
|
|
3911
|
+
box.appendChild(root);
|
|
3912
|
+
return box;
|
|
3913
|
+
}
|
|
3914
|
+
if (typeof type === "number") registerDisposer(root, own.stop);
|
|
3915
|
+
return root;
|
|
3351
3916
|
}
|
|
3352
3917
|
const container = div({ class: "sibu-lazy" });
|
|
3353
3918
|
const scope = captureScope();
|
|
3354
3919
|
const boundary = currentBoundary();
|
|
3355
|
-
let disposed = false;
|
|
3356
3920
|
const loading = inScope(null, () => span("sibu-lazy-loading", "Loading..."));
|
|
3357
3921
|
if (cached) {
|
|
3358
3922
|
const loaded = cached;
|
|
3359
|
-
|
|
3923
|
+
let rendered;
|
|
3924
|
+
try {
|
|
3925
|
+
const [root, own] = instance(() => inScope(scope, () => loaded()));
|
|
3926
|
+
registerDisposer(container, ending(root, own));
|
|
3927
|
+
rendered = root;
|
|
3928
|
+
} catch (err) {
|
|
3929
|
+
dispose(container);
|
|
3930
|
+
throw err;
|
|
3931
|
+
}
|
|
3932
|
+
replaceChildrenSafely(container, rendered);
|
|
3360
3933
|
return container;
|
|
3361
3934
|
}
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
const build = () => inScope(scope, () => component());
|
|
3370
|
-
const rendered = boundary ? boundary.enter(build) : build();
|
|
3371
|
-
replaceChildrenSafely(container, rendered);
|
|
3372
|
-
})
|
|
3373
|
-
).catch((err) => {
|
|
3374
|
-
if (disposed) return;
|
|
3375
|
-
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
3376
|
-
replaceChildrenSafely(
|
|
3377
|
-
container,
|
|
3378
|
-
div({ class: "sibu-lazy-error" }, `Failed to load component: ${errorObj.message}`)
|
|
3379
|
-
);
|
|
3380
|
-
dispatchPropagate(container, errorObj);
|
|
3381
|
-
});
|
|
3382
|
-
if (!(isHydrating() && container.firstChild)) container.appendChild(loading);
|
|
3935
|
+
const held = captureFrozen2();
|
|
3936
|
+
const inOwner = bindOwnerScope2((fn) => fn());
|
|
3937
|
+
const ready = beginLoading(container);
|
|
3938
|
+
let disposed = false;
|
|
3939
|
+
const live = () => !disposed;
|
|
3940
|
+
let owner = null;
|
|
3941
|
+
const waiting = { cancel: NOOP3 };
|
|
3383
3942
|
registerDisposer(container, () => {
|
|
3384
3943
|
disposed = true;
|
|
3944
|
+
waiting.cancel();
|
|
3945
|
+
ready.cancel();
|
|
3946
|
+
const end = owner;
|
|
3947
|
+
owner = null;
|
|
3948
|
+
end?.();
|
|
3385
3949
|
});
|
|
3950
|
+
if (!(isHydrating() && container.firstChild)) container.appendChild(loading);
|
|
3951
|
+
const show2 = (view, release, claim, shown, failed) => {
|
|
3952
|
+
const swap = stageReplaceChildren(container, [view]);
|
|
3953
|
+
commitWhenActive(waiting, {
|
|
3954
|
+
held,
|
|
3955
|
+
node: view,
|
|
3956
|
+
owned: live,
|
|
3957
|
+
teardown: swap.teardown,
|
|
3958
|
+
insert: () => {
|
|
3959
|
+
claim();
|
|
3960
|
+
try {
|
|
3961
|
+
swap.insert();
|
|
3962
|
+
} catch (err) {
|
|
3963
|
+
release();
|
|
3964
|
+
failed(err);
|
|
3965
|
+
return;
|
|
3966
|
+
}
|
|
3967
|
+
if (!disposed) shown();
|
|
3968
|
+
},
|
|
3969
|
+
discard: () => {
|
|
3970
|
+
release();
|
|
3971
|
+
ready.cancel();
|
|
3972
|
+
}
|
|
3973
|
+
});
|
|
3974
|
+
};
|
|
3975
|
+
const later = (fn) => commitWhenActive(waiting, { held, node: null, owned: live, insert: () => inOwner(fn), discard: ready.cancel });
|
|
3976
|
+
const fail = (err) => {
|
|
3977
|
+
if (disposed) return;
|
|
3978
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
3979
|
+
const view = div({ class: "sibu-lazy-error" }, `Failed to load component: ${error.message}`);
|
|
3980
|
+
show2(
|
|
3981
|
+
view,
|
|
3982
|
+
() => dispose(view),
|
|
3983
|
+
NOOP3,
|
|
3984
|
+
() => {
|
|
3985
|
+
ready.done();
|
|
3986
|
+
dispatchPropagate(container, error);
|
|
3987
|
+
},
|
|
3988
|
+
(insertError) => {
|
|
3989
|
+
ready.cancel();
|
|
3990
|
+
reportError(insertError, { phase: "render", name: "lazy" });
|
|
3991
|
+
}
|
|
3992
|
+
);
|
|
3993
|
+
};
|
|
3994
|
+
const build = (component) => {
|
|
3995
|
+
if (disposed) return;
|
|
3996
|
+
let rendered;
|
|
3997
|
+
let own;
|
|
3998
|
+
try {
|
|
3999
|
+
const render = () => held.run(() => instance(() => inScope(scope, () => component())));
|
|
4000
|
+
[rendered, own] = boundary ? boundary.enter(render) : render();
|
|
4001
|
+
} catch (err) {
|
|
4002
|
+
fail(err);
|
|
4003
|
+
return;
|
|
4004
|
+
}
|
|
4005
|
+
const end = ending(rendered, own);
|
|
4006
|
+
show2(
|
|
4007
|
+
rendered,
|
|
4008
|
+
() => {
|
|
4009
|
+
if (owner === end) owner = null;
|
|
4010
|
+
own.stop();
|
|
4011
|
+
dispose(rendered);
|
|
4012
|
+
},
|
|
4013
|
+
() => {
|
|
4014
|
+
owner = end;
|
|
4015
|
+
},
|
|
4016
|
+
() => ready.done(),
|
|
4017
|
+
fail
|
|
4018
|
+
);
|
|
4019
|
+
};
|
|
4020
|
+
let imported;
|
|
4021
|
+
try {
|
|
4022
|
+
imported = importFn();
|
|
4023
|
+
} catch (err) {
|
|
4024
|
+
dispose(container);
|
|
4025
|
+
throw err;
|
|
4026
|
+
}
|
|
4027
|
+
trackPending(imported, "lazy").then(
|
|
4028
|
+
(mod) => {
|
|
4029
|
+
if (disposed) return;
|
|
4030
|
+
cached = mod.default;
|
|
4031
|
+
const component = cached;
|
|
4032
|
+
later(() => build(component));
|
|
4033
|
+
},
|
|
4034
|
+
(err) => {
|
|
4035
|
+
if (!disposed) later(() => fail(err));
|
|
4036
|
+
}
|
|
4037
|
+
);
|
|
3386
4038
|
return container;
|
|
3387
4039
|
};
|
|
3388
4040
|
}
|
|
3389
4041
|
function Suspense({ nodes, fallback }) {
|
|
3390
4042
|
const container = div({ class: "sibu-suspense" });
|
|
3391
4043
|
const scope = captureScope();
|
|
4044
|
+
const held = captureFrozen2();
|
|
4045
|
+
const inOwner = bindOwnerScope2((fn) => fn());
|
|
3392
4046
|
const boundary = openBoundary(container);
|
|
3393
|
-
const
|
|
3394
|
-
replaceChildrenSafely(container, el);
|
|
3395
|
-
boundary?.done();
|
|
3396
|
-
};
|
|
3397
|
-
const fallbackEl = inScope(null, fallback);
|
|
3398
|
-
if (isHydrating() && container.firstChild) dispose(fallbackEl);
|
|
3399
|
-
else container.appendChild(fallbackEl);
|
|
4047
|
+
const ready = beginLoading(container);
|
|
3400
4048
|
let suspenseDisposed = false;
|
|
4049
|
+
const live = () => !suspenseDisposed;
|
|
3401
4050
|
let observer = null;
|
|
3402
4051
|
let childEl = null;
|
|
4052
|
+
let contentOwner = null;
|
|
4053
|
+
const endContent = () => {
|
|
4054
|
+
const own = contentOwner;
|
|
4055
|
+
contentOwner = null;
|
|
4056
|
+
own?.stop();
|
|
4057
|
+
};
|
|
4058
|
+
const fallbackOwn = structuralBinding2(NOOP3);
|
|
4059
|
+
let fallbackOwner = fallbackOwn;
|
|
4060
|
+
const endFallback = () => {
|
|
4061
|
+
const own = fallbackOwner;
|
|
4062
|
+
fallbackOwner = null;
|
|
4063
|
+
own?.stop();
|
|
4064
|
+
};
|
|
4065
|
+
const waiting = { cancel: NOOP3 };
|
|
3403
4066
|
registerDisposer(container, () => {
|
|
3404
4067
|
suspenseDisposed = true;
|
|
4068
|
+
waiting.cancel();
|
|
4069
|
+
ready.cancel();
|
|
3405
4070
|
if (observer) {
|
|
3406
4071
|
observer.disconnect();
|
|
3407
4072
|
observer = null;
|
|
3408
4073
|
}
|
|
3409
4074
|
if (childEl && !container.contains(childEl)) dispose(childEl);
|
|
4075
|
+
endFallback();
|
|
4076
|
+
endContent();
|
|
3410
4077
|
});
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
4078
|
+
let fallbackEl;
|
|
4079
|
+
try {
|
|
4080
|
+
fallbackEl = inScope(null, () => withDisposerRollback(() => fallbackOwn.run(fallback)));
|
|
4081
|
+
} catch (err) {
|
|
4082
|
+
boundary?.done();
|
|
4083
|
+
dispose(container);
|
|
4084
|
+
throw err;
|
|
4085
|
+
}
|
|
4086
|
+
if (isHydrating() && container.firstChild) {
|
|
4087
|
+
dispose(fallbackEl);
|
|
4088
|
+
endFallback();
|
|
4089
|
+
} else container.appendChild(fallbackEl);
|
|
4090
|
+
const commit = (el) => {
|
|
4091
|
+
const swap = stageReplaceChildren(container, [el]);
|
|
4092
|
+
commitWhenActive(waiting, {
|
|
4093
|
+
held,
|
|
4094
|
+
node: el,
|
|
4095
|
+
owned: live,
|
|
4096
|
+
teardown: () => {
|
|
4097
|
+
if (swap.teardown()) return true;
|
|
4098
|
+
if (fallbackOwner === null) return false;
|
|
4099
|
+
endFallback();
|
|
4100
|
+
return true;
|
|
4101
|
+
},
|
|
4102
|
+
// `el` is the container's content already (`childEl`): disposing the
|
|
4103
|
+
// container from its `connectedCallback`, during the insertion,
|
|
4104
|
+
// disposes it — in the container, or as the orphan `childEl` is.
|
|
4105
|
+
insert: () => {
|
|
4106
|
+
try {
|
|
4107
|
+
swap.insert();
|
|
4108
|
+
} catch (err) {
|
|
4109
|
+
if (childEl === el) childEl = null;
|
|
4110
|
+
dispose(el);
|
|
4111
|
+
endContent();
|
|
4112
|
+
ready.cancel();
|
|
4113
|
+
boundary?.done();
|
|
4114
|
+
dispatchPropagate(container, err instanceof Error ? err : new Error(String(err)));
|
|
3419
4115
|
return;
|
|
3420
4116
|
}
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
});
|
|
3430
|
-
observer.observe(el, { childList: true, subtree: true });
|
|
3431
|
-
} else {
|
|
3432
|
-
commit(el);
|
|
4117
|
+
boundary?.done();
|
|
4118
|
+
ready.done();
|
|
4119
|
+
},
|
|
4120
|
+
discard: () => {
|
|
4121
|
+
if (childEl === el) childEl = null;
|
|
4122
|
+
dispose(el);
|
|
4123
|
+
endContent();
|
|
4124
|
+
ready.cancel();
|
|
3433
4125
|
}
|
|
4126
|
+
});
|
|
4127
|
+
};
|
|
4128
|
+
const renderContent = () => {
|
|
4129
|
+
if (suspenseDisposed) return;
|
|
4130
|
+
const own = held.run(() => structuralBinding2(NOOP3));
|
|
4131
|
+
contentOwner = own;
|
|
4132
|
+
let el;
|
|
4133
|
+
try {
|
|
4134
|
+
const build = () => withDisposerRollback(() => own.run(() => inScope(scope, nodes)));
|
|
4135
|
+
el = boundary ? boundary.enter(build) : build();
|
|
3434
4136
|
} catch (err) {
|
|
4137
|
+
endContent();
|
|
3435
4138
|
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
4139
|
+
ready.cancel();
|
|
3436
4140
|
dispatchPropagate(container, errorObj);
|
|
4141
|
+
return;
|
|
4142
|
+
}
|
|
4143
|
+
childEl = el;
|
|
4144
|
+
if (suspenseDisposed) {
|
|
4145
|
+
childEl = null;
|
|
4146
|
+
dispose(el);
|
|
4147
|
+
return;
|
|
4148
|
+
}
|
|
4149
|
+
if (el.classList.contains("sibu-lazy")) {
|
|
4150
|
+
if (!el.querySelector(".sibu-lazy-loading")) {
|
|
4151
|
+
commit(el);
|
|
4152
|
+
return;
|
|
4153
|
+
}
|
|
4154
|
+
observer = new MutationObserver(() => {
|
|
4155
|
+
if (suspenseDisposed) return;
|
|
4156
|
+
const loading = el.querySelector(".sibu-lazy-loading");
|
|
4157
|
+
if (!loading) {
|
|
4158
|
+
observer?.disconnect();
|
|
4159
|
+
observer = null;
|
|
4160
|
+
commit(el);
|
|
4161
|
+
}
|
|
4162
|
+
});
|
|
4163
|
+
observer.observe(el, { childList: true, subtree: true });
|
|
4164
|
+
} else {
|
|
4165
|
+
commit(el);
|
|
3437
4166
|
}
|
|
4167
|
+
};
|
|
4168
|
+
queueMicrotask(() => {
|
|
4169
|
+
commitWhenActive(waiting, {
|
|
4170
|
+
held,
|
|
4171
|
+
node: null,
|
|
4172
|
+
owned: live,
|
|
4173
|
+
insert: () => inOwner(renderContent),
|
|
4174
|
+
discard: ready.cancel
|
|
4175
|
+
});
|
|
3438
4176
|
});
|
|
3439
|
-
queueMicrotask(renderContent);
|
|
3440
4177
|
return container;
|
|
3441
4178
|
}
|
|
3442
4179
|
|
|
@@ -3894,7 +4631,7 @@ var isBatching = API2.isBatching;
|
|
|
3894
4631
|
// src/core/signals/signal.ts
|
|
3895
4632
|
var _g2 = globalThis;
|
|
3896
4633
|
function signal(initial, options) {
|
|
3897
|
-
const
|
|
4634
|
+
const state4 = {
|
|
3898
4635
|
value: initial,
|
|
3899
4636
|
__v: 0,
|
|
3900
4637
|
__sc: 0,
|
|
@@ -3907,57 +4644,57 @@ function signal(initial, options) {
|
|
|
3907
4644
|
};
|
|
3908
4645
|
const debugName = DEV ? options?.name : void 0;
|
|
3909
4646
|
const equalsFn = options?.equals;
|
|
3910
|
-
if (debugName)
|
|
4647
|
+
if (debugName) state4.__name = debugName;
|
|
3911
4648
|
function get() {
|
|
3912
|
-
recordDependency2(
|
|
3913
|
-
return
|
|
4649
|
+
recordDependency2(state4);
|
|
4650
|
+
return state4.value;
|
|
3914
4651
|
}
|
|
3915
|
-
get.__signal =
|
|
4652
|
+
get.__signal = state4;
|
|
3916
4653
|
if (debugName) get.__name = debugName;
|
|
3917
4654
|
let set;
|
|
3918
4655
|
if (equalsFn) {
|
|
3919
4656
|
set = (next) => {
|
|
3920
|
-
const prev =
|
|
4657
|
+
const prev = state4.value;
|
|
3921
4658
|
const newValue = typeof next === "function" ? next(prev) : next;
|
|
3922
4659
|
if (equalsFn(prev, newValue)) return;
|
|
3923
|
-
|
|
3924
|
-
|
|
4660
|
+
state4.value = newValue;
|
|
4661
|
+
state4.__v++;
|
|
3925
4662
|
if (DEV) {
|
|
3926
4663
|
const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
3927
|
-
if (hook) emitDevtools(hook, "signal:update", { signal:
|
|
4664
|
+
if (hook) emitDevtools(hook, "signal:update", { signal: state4, name: debugName, oldValue: prev, newValue });
|
|
3928
4665
|
}
|
|
3929
|
-
if (!enqueueBatchedSignal(
|
|
3930
|
-
notifySubscribers2(
|
|
4666
|
+
if (!enqueueBatchedSignal(state4)) {
|
|
4667
|
+
notifySubscribers2(state4);
|
|
3931
4668
|
}
|
|
3932
4669
|
};
|
|
3933
4670
|
} else if (DEV) {
|
|
3934
4671
|
set = (next) => {
|
|
3935
|
-
const prev =
|
|
4672
|
+
const prev = state4.value;
|
|
3936
4673
|
const newValue = typeof next === "function" ? next(prev) : next;
|
|
3937
4674
|
if (Object.is(newValue, prev)) return;
|
|
3938
|
-
|
|
3939
|
-
|
|
4675
|
+
state4.value = newValue;
|
|
4676
|
+
state4.__v++;
|
|
3940
4677
|
const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
3941
|
-
if (hook) emitDevtools(hook, "signal:update", { signal:
|
|
3942
|
-
if (!enqueueBatchedSignal(
|
|
3943
|
-
notifySubscribers2(
|
|
4678
|
+
if (hook) emitDevtools(hook, "signal:update", { signal: state4, name: debugName, oldValue: prev, newValue });
|
|
4679
|
+
if (!enqueueBatchedSignal(state4)) {
|
|
4680
|
+
notifySubscribers2(state4);
|
|
3944
4681
|
}
|
|
3945
4682
|
};
|
|
3946
4683
|
} else {
|
|
3947
4684
|
set = (next) => {
|
|
3948
|
-
const prev =
|
|
4685
|
+
const prev = state4.value;
|
|
3949
4686
|
const newValue = typeof next === "function" ? next(prev) : next;
|
|
3950
4687
|
if (Object.is(newValue, prev)) return;
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
if (!enqueueBatchedSignal(
|
|
3954
|
-
notifySubscribers2(
|
|
4688
|
+
state4.value = newValue;
|
|
4689
|
+
state4.__v++;
|
|
4690
|
+
if (!enqueueBatchedSignal(state4)) {
|
|
4691
|
+
notifySubscribers2(state4);
|
|
3955
4692
|
}
|
|
3956
4693
|
};
|
|
3957
4694
|
}
|
|
3958
4695
|
if (DEV) {
|
|
3959
4696
|
const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
3960
|
-
if (hook) emitDevtools(hook, "signal:create", { signal:
|
|
4697
|
+
if (hook) emitDevtools(hook, "signal:create", { signal: state4, name: debugName, getter: get, initial });
|
|
3961
4698
|
}
|
|
3962
4699
|
return [get, set];
|
|
3963
4700
|
}
|
|
@@ -4681,8 +5418,8 @@ function ErrorBoundary(optionsOrChildren, maybeChildren) {
|
|
|
4681
5418
|
const collected = [];
|
|
4682
5419
|
let node = walker.currentNode;
|
|
4683
5420
|
while (node) {
|
|
4684
|
-
const
|
|
4685
|
-
if (
|
|
5421
|
+
const pending2 = takePendingError(node);
|
|
5422
|
+
if (pending2) collected.push(pending2);
|
|
4686
5423
|
node = walker.nextNode();
|
|
4687
5424
|
}
|
|
4688
5425
|
if (collected.length === 1) {
|
|
@@ -4983,6 +5720,202 @@ function setGlobalErrorHandler(handler) {
|
|
|
4983
5720
|
globalErrorHandler = handler;
|
|
4984
5721
|
}
|
|
4985
5722
|
|
|
5723
|
+
// src/core/rendering/branchTransition.ts
|
|
5724
|
+
var HARD_CAP_MS = 5e3;
|
|
5725
|
+
function now() {
|
|
5726
|
+
return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
5727
|
+
}
|
|
5728
|
+
var SLACK_MS = 50;
|
|
5729
|
+
var INSTANT_MS = 1;
|
|
5730
|
+
var FALLBACK_EVENTS = ["transitionend", "transitioncancel", "animationend", "animationcancel"];
|
|
5731
|
+
function parseList(list, fallback) {
|
|
5732
|
+
return (list?.trim() ? list : fallback).split(",").map((part) => part.trim());
|
|
5733
|
+
}
|
|
5734
|
+
function parseTimes(list) {
|
|
5735
|
+
return parseList(list, "0s").map((v) => (Number.parseFloat(v) || 0) * (v.endsWith("ms") ? 1 : 1e3));
|
|
5736
|
+
}
|
|
5737
|
+
function measure(el) {
|
|
5738
|
+
if (typeof getComputedStyle !== "function") return null;
|
|
5739
|
+
const cs = getComputedStyle(el);
|
|
5740
|
+
if (cs.display === "none") return null;
|
|
5741
|
+
const timing = { total: 0, transitions: /* @__PURE__ */ new Map(), animations: /* @__PURE__ */ new Map(), pending: 0 };
|
|
5742
|
+
const expect = (map2, names, durations, delays, iterations) => {
|
|
5743
|
+
for (let i2 = 0; i2 < names.length; i2++) {
|
|
5744
|
+
const duration = durations[i2 % durations.length];
|
|
5745
|
+
if (names[i2] === "none" || duration <= 0) continue;
|
|
5746
|
+
const count = iterations[i2 % iterations.length];
|
|
5747
|
+
const runs = count === "infinite" ? Number.POSITIVE_INFINITY : Number.parseFloat(count) || 1;
|
|
5748
|
+
timing.total = Math.max(timing.total, delays[i2 % delays.length] + duration * runs);
|
|
5749
|
+
map2.set(names[i2], (map2.get(names[i2]) ?? 0) + 1);
|
|
5750
|
+
timing.pending++;
|
|
5751
|
+
}
|
|
5752
|
+
};
|
|
5753
|
+
expect(
|
|
5754
|
+
timing.transitions,
|
|
5755
|
+
parseList(cs.transitionProperty, "all"),
|
|
5756
|
+
parseTimes(cs.transitionDuration),
|
|
5757
|
+
parseTimes(cs.transitionDelay),
|
|
5758
|
+
["1"]
|
|
5759
|
+
);
|
|
5760
|
+
expect(
|
|
5761
|
+
timing.animations,
|
|
5762
|
+
parseList(cs.animationName, "none"),
|
|
5763
|
+
parseTimes(cs.animationDuration),
|
|
5764
|
+
parseTimes(cs.animationDelay),
|
|
5765
|
+
parseList(cs.animationIterationCount, "1")
|
|
5766
|
+
);
|
|
5767
|
+
return timing.total <= INSTANT_MS ? null : timing;
|
|
5768
|
+
}
|
|
5769
|
+
function matchEntry(map2, name) {
|
|
5770
|
+
if (typeof name !== "string" || name === "") return map2.keys().next().value;
|
|
5771
|
+
if (map2.has(name)) return name;
|
|
5772
|
+
for (const key of map2.keys()) if (name.startsWith(`${key}-`)) return key;
|
|
5773
|
+
return map2.has("all") ? "all" : void 0;
|
|
5774
|
+
}
|
|
5775
|
+
function insideAnimating(animating, el) {
|
|
5776
|
+
for (const a2 of animating) if (a2 !== el && a2.contains(el)) return true;
|
|
5777
|
+
return false;
|
|
5778
|
+
}
|
|
5779
|
+
function runPhase(nodes, cls, custom, maxDuration, onDone, name, open = 0) {
|
|
5780
|
+
const cap = Math.min(typeof maxDuration === "number" && maxDuration >= 0 ? maxDuration : HARD_CAP_MS, HARD_CAP_MS);
|
|
5781
|
+
const elements = [];
|
|
5782
|
+
for (let i2 = 0; i2 < nodes.length; i2++) if (nodes[i2].nodeType === 1) elements.push(nodes[i2]);
|
|
5783
|
+
let finished = false;
|
|
5784
|
+
let timer = null;
|
|
5785
|
+
const cleanups = [];
|
|
5786
|
+
const finish = (complete) => {
|
|
5787
|
+
if (finished) return;
|
|
5788
|
+
finished = true;
|
|
5789
|
+
if (timer !== null) clearTimeout(timer);
|
|
5790
|
+
for (let i2 = 0; i2 < cleanups.length; i2++) cleanups[i2]();
|
|
5791
|
+
if (complete) onDone();
|
|
5792
|
+
};
|
|
5793
|
+
const report = (error) => reportError(error, { phase: "async", name, node: elements[0] });
|
|
5794
|
+
if (custom) {
|
|
5795
|
+
let result;
|
|
5796
|
+
try {
|
|
5797
|
+
result = custom(nodes);
|
|
5798
|
+
} catch (error) {
|
|
5799
|
+
report(error);
|
|
5800
|
+
}
|
|
5801
|
+
const pending2 = adoptThenable(result);
|
|
5802
|
+
if (pending2 === null) {
|
|
5803
|
+
onDone();
|
|
5804
|
+
return null;
|
|
5805
|
+
}
|
|
5806
|
+
pending2.then(
|
|
5807
|
+
() => finish(true),
|
|
5808
|
+
(error) => {
|
|
5809
|
+
report(error);
|
|
5810
|
+
finish(true);
|
|
5811
|
+
}
|
|
5812
|
+
);
|
|
5813
|
+
timer = setTimeout(() => finish(true), cap);
|
|
5814
|
+
return { cancel: () => finish(false) };
|
|
5815
|
+
}
|
|
5816
|
+
let holding = open > 0;
|
|
5817
|
+
if (!cls || elements.length === 0 && !holding) {
|
|
5818
|
+
onDone();
|
|
5819
|
+
return null;
|
|
5820
|
+
}
|
|
5821
|
+
for (let i2 = 0; i2 < elements.length; i2++) elements[i2].classList.add(cls);
|
|
5822
|
+
cleanups.push(() => {
|
|
5823
|
+
for (let i2 = 0; i2 < elements.length; i2++) elements[i2].classList.remove(cls);
|
|
5824
|
+
});
|
|
5825
|
+
const capAt = now() + cap;
|
|
5826
|
+
let deadline = 0;
|
|
5827
|
+
const arm = (until) => {
|
|
5828
|
+
const at = Math.min(until, capAt);
|
|
5829
|
+
if (timer !== null && at <= deadline) return;
|
|
5830
|
+
if (timer !== null) clearTimeout(timer);
|
|
5831
|
+
deadline = at;
|
|
5832
|
+
timer = setTimeout(() => finish(true), Math.max(0, at - now()));
|
|
5833
|
+
};
|
|
5834
|
+
let waiting = 0;
|
|
5835
|
+
const animating = /* @__PURE__ */ new Set();
|
|
5836
|
+
const enroll = (el) => {
|
|
5837
|
+
const timing = measure(el);
|
|
5838
|
+
if (timing === null) return -1;
|
|
5839
|
+
const running = typeof el.getAnimations === "function" ? el.getAnimations() : null;
|
|
5840
|
+
if (running !== null) {
|
|
5841
|
+
if (running.length === 0) return -1;
|
|
5842
|
+
waiting++;
|
|
5843
|
+
animating.add(el);
|
|
5844
|
+
let left = running.length;
|
|
5845
|
+
const settle2 = () => {
|
|
5846
|
+
if (left === 0 || --left !== 0) return;
|
|
5847
|
+
animating.delete(el);
|
|
5848
|
+
if (!finished && --waiting === 0 && !holding) finish(true);
|
|
5849
|
+
};
|
|
5850
|
+
for (const animation of running) animation.finished.then(settle2, settle2);
|
|
5851
|
+
return timing.total;
|
|
5852
|
+
}
|
|
5853
|
+
waiting++;
|
|
5854
|
+
animating.add(el);
|
|
5855
|
+
let done = false;
|
|
5856
|
+
let estimate = null;
|
|
5857
|
+
const settle = () => {
|
|
5858
|
+
if (done) return;
|
|
5859
|
+
done = true;
|
|
5860
|
+
if (estimate !== null) clearTimeout(estimate);
|
|
5861
|
+
animating.delete(el);
|
|
5862
|
+
if (!finished && --waiting === 0 && !holding) finish(true);
|
|
5863
|
+
};
|
|
5864
|
+
const onEnd = (event) => {
|
|
5865
|
+
if (event.target !== el || done || timing.pending === 0) return;
|
|
5866
|
+
const transition2 = event.type === "transitionend" || event.type === "transitioncancel";
|
|
5867
|
+
const map2 = transition2 ? timing.transitions : timing.animations;
|
|
5868
|
+
const key = matchEntry(
|
|
5869
|
+
map2,
|
|
5870
|
+
event[transition2 ? "propertyName" : "animationName"]
|
|
5871
|
+
);
|
|
5872
|
+
if (key === void 0) return;
|
|
5873
|
+
const left = map2.get(key) - 1;
|
|
5874
|
+
if (left > 0) map2.set(key, left);
|
|
5875
|
+
else map2.delete(key);
|
|
5876
|
+
if (--timing.pending === 0) settle();
|
|
5877
|
+
};
|
|
5878
|
+
for (const type of FALLBACK_EVENTS) el.addEventListener(type, onEnd);
|
|
5879
|
+
if (Number.isFinite(timing.total)) estimate = setTimeout(settle, timing.total + SLACK_MS);
|
|
5880
|
+
cleanups.push(() => {
|
|
5881
|
+
if (estimate !== null) clearTimeout(estimate);
|
|
5882
|
+
for (const type of FALLBACK_EVENTS) el.removeEventListener(type, onEnd);
|
|
5883
|
+
});
|
|
5884
|
+
return timing.total;
|
|
5885
|
+
};
|
|
5886
|
+
let longest = -1;
|
|
5887
|
+
for (let i2 = 0; i2 < elements.length; i2++) longest = Math.max(longest, enroll(elements[i2]));
|
|
5888
|
+
if (waiting === 0 && !holding) {
|
|
5889
|
+
finish(true);
|
|
5890
|
+
return null;
|
|
5891
|
+
}
|
|
5892
|
+
if (waiting > 0) arm(now() + longest + SLACK_MS);
|
|
5893
|
+
const close = () => {
|
|
5894
|
+
holding = false;
|
|
5895
|
+
if (!finished && waiting === 0) finish(true);
|
|
5896
|
+
};
|
|
5897
|
+
if (holding) {
|
|
5898
|
+
arm(now() + open);
|
|
5899
|
+
const openTimer = setTimeout(close, Math.max(0, Math.min(now() + open, capAt) - now()));
|
|
5900
|
+
cleanups.push(() => clearTimeout(openTimer));
|
|
5901
|
+
}
|
|
5902
|
+
return {
|
|
5903
|
+
cancel: () => finish(false),
|
|
5904
|
+
close,
|
|
5905
|
+
add: (late) => {
|
|
5906
|
+
if (finished) return;
|
|
5907
|
+
for (let i2 = 0; i2 < late.length; i2++) {
|
|
5908
|
+
const el = late[i2];
|
|
5909
|
+
if (elements.includes(el) || insideAnimating(animating, el)) continue;
|
|
5910
|
+
el.classList.add(cls);
|
|
5911
|
+
elements.push(el);
|
|
5912
|
+
const total = enroll(el);
|
|
5913
|
+
if (total >= 0) arm(now() + total + SLACK_MS);
|
|
5914
|
+
}
|
|
5915
|
+
}
|
|
5916
|
+
};
|
|
5917
|
+
}
|
|
5918
|
+
|
|
4986
5919
|
// src/core/rendering/directives.ts
|
|
4987
5920
|
function show(condition, element) {
|
|
4988
5921
|
const resolved = typeof element === "function" ? element() : element;
|
|
@@ -4995,9 +5928,15 @@ function show(condition, element) {
|
|
|
4995
5928
|
function isDirectiveOptions(value) {
|
|
4996
5929
|
return typeof value === "object" && value !== null && !(value instanceof Node);
|
|
4997
5930
|
}
|
|
4998
|
-
|
|
5931
|
+
var fragmentStarts = /* @__PURE__ */ new WeakMap();
|
|
5932
|
+
var detachedRanges = /* @__PURE__ */ new WeakMap();
|
|
5933
|
+
var parked = /* @__PURE__ */ new WeakMap();
|
|
5934
|
+
var ENTER_WAIT_TURNS = 8;
|
|
5935
|
+
var NOOP4 = () => {
|
|
5936
|
+
};
|
|
5937
|
+
function resolveBranch(branch, attachedOnce, where) {
|
|
4999
5938
|
const result = typeof branch === "function" ? branch() : branch;
|
|
5000
|
-
if (result == null || typeof result === "boolean") return
|
|
5939
|
+
if (result == null || typeof result === "boolean") return null;
|
|
5001
5940
|
const node = result instanceof Node ? result : document.createTextNode(String(result));
|
|
5002
5941
|
const handedIn = node === branch;
|
|
5003
5942
|
const seenBefore = attachedOnce.has(node);
|
|
@@ -5008,64 +5947,603 @@ function attachBranch(parent, anchor, branch, attachedOnce, where) {
|
|
|
5008
5947
|
() => `${where}: ${handedIn ? "a branch was given as an element rather than a function" : "a branch factory returned a node it had already returned"}, so the SAME node is being re-attached \u2014 any state it accumulated while detached (input value, scroll position, classes set imperatively) comes back with it. Its reactive bindings are left intact rather than disposed, because the node is not this directive's to tear down. Return a FRESH node per call (\`() => div(\u2026)\`) for rebuild semantics, or keep this form deliberately when the reuse is what you want.`
|
|
5009
5948
|
);
|
|
5010
5949
|
}
|
|
5011
|
-
|
|
5012
|
-
|
|
5950
|
+
let starts;
|
|
5951
|
+
if (node.nodeType === 11) {
|
|
5952
|
+
if (node.firstChild) {
|
|
5953
|
+
starts = Array.from(node.childNodes);
|
|
5954
|
+
fragmentStarts.set(node, starts);
|
|
5955
|
+
} else {
|
|
5956
|
+
starts = fragmentStarts.get(node) ?? [];
|
|
5957
|
+
}
|
|
5958
|
+
} else {
|
|
5959
|
+
starts = [node];
|
|
5960
|
+
}
|
|
5961
|
+
const park = owned ? void 0 : parked.get(node);
|
|
5962
|
+
const nodes = park?.firstChild ? Array.from(park.childNodes) : !owned && starts.every((start) => start.parentNode === null) && detachedRanges.get(node) || attachedRanges(starts);
|
|
5963
|
+
if (nodes.length === 0 && !owned) return null;
|
|
5964
|
+
return {
|
|
5965
|
+
source: node,
|
|
5966
|
+
starts,
|
|
5967
|
+
nodes,
|
|
5968
|
+
owned,
|
|
5969
|
+
owner: null,
|
|
5970
|
+
phase: null,
|
|
5971
|
+
restore: null,
|
|
5972
|
+
unhold: null,
|
|
5973
|
+
waiting: false,
|
|
5974
|
+
released: false,
|
|
5975
|
+
inserting: false
|
|
5976
|
+
};
|
|
5977
|
+
}
|
|
5978
|
+
function attachedRanges(starts) {
|
|
5979
|
+
if (!starts.some(hasRange)) return starts;
|
|
5980
|
+
return [...new Set(starts.flatMap((start) => start.parentNode === null ? [start] : collectRange([start])))];
|
|
5981
|
+
}
|
|
5982
|
+
function refreshNodes(branch) {
|
|
5983
|
+
const starts = branch.starts;
|
|
5984
|
+
if (starts.length === 1 && (!hasRange(starts[0]) || starts[0].parentNode === null)) return;
|
|
5985
|
+
const live = collectRange(starts);
|
|
5986
|
+
branch.nodes = branch.owned && branch.inserting ? [.../* @__PURE__ */ new Set([...branch.nodes, ...live])] : live;
|
|
5987
|
+
if (!branch.owned) detachedRanges.set(branch.source, branch.nodes);
|
|
5988
|
+
}
|
|
5989
|
+
function insertBranch(anchor, nodes, live) {
|
|
5990
|
+
let prev = anchor;
|
|
5991
|
+
for (let i2 = 0; i2 < nodes.length; i2++) {
|
|
5992
|
+
if (!live()) return false;
|
|
5993
|
+
const parent = anchor.parentNode;
|
|
5994
|
+
if (parent === null) return false;
|
|
5995
|
+
const node = nodes[i2];
|
|
5996
|
+
if (prev.parentNode !== parent) prev = anchor;
|
|
5997
|
+
if (prev.nextSibling !== node) parent.insertBefore(node, prev.nextSibling);
|
|
5998
|
+
prev = node;
|
|
5999
|
+
}
|
|
6000
|
+
return live();
|
|
6001
|
+
}
|
|
6002
|
+
function releaseBranch(branch) {
|
|
6003
|
+
if (branch.released) return;
|
|
6004
|
+
branch.released = true;
|
|
6005
|
+
refreshNodes(branch);
|
|
6006
|
+
if (branch.phase !== null) {
|
|
6007
|
+
branch.phase.cancel();
|
|
6008
|
+
branch.phase = null;
|
|
6009
|
+
}
|
|
6010
|
+
if (branch.restore !== null) {
|
|
6011
|
+
branch.restore();
|
|
6012
|
+
branch.restore = null;
|
|
6013
|
+
}
|
|
6014
|
+
const nodes = branch.nodes;
|
|
6015
|
+
let park;
|
|
6016
|
+
if (!branch.owned && (branch.source.nodeType === 11 || branch.starts.some(hasRange))) {
|
|
6017
|
+
park = parked.get(branch.source);
|
|
6018
|
+
if (park === void 0) parked.set(branch.source, park = document.createDocumentFragment());
|
|
6019
|
+
}
|
|
6020
|
+
for (let i2 = 0; i2 < nodes.length; i2++) {
|
|
6021
|
+
const node = nodes[i2];
|
|
6022
|
+
if (branch.owned) dispose(node);
|
|
6023
|
+
if (park !== void 0) park.appendChild(node);
|
|
6024
|
+
else node.parentNode?.removeChild(node);
|
|
6025
|
+
}
|
|
6026
|
+
if (branch.owned && branch.source.nodeType === 11) dispose(branch.source);
|
|
6027
|
+
if (branch.owner !== null) {
|
|
6028
|
+
if (branch.owned) branch.owner.stop();
|
|
6029
|
+
else branch.owner.thaw?.();
|
|
6030
|
+
branch.owner = null;
|
|
6031
|
+
}
|
|
6032
|
+
if (branch.unhold !== null) {
|
|
6033
|
+
branch.unhold();
|
|
6034
|
+
branch.unhold = null;
|
|
6035
|
+
}
|
|
6036
|
+
}
|
|
6037
|
+
function makeInert(branch, onLate) {
|
|
6038
|
+
const saved = [];
|
|
6039
|
+
const marked = /* @__PURE__ */ new Set();
|
|
6040
|
+
const mark2 = (nodes) => {
|
|
6041
|
+
for (let i2 = 0; i2 < nodes.length; i2++) {
|
|
6042
|
+
if (nodes[i2].nodeType !== 1 || marked.has(nodes[i2])) continue;
|
|
6043
|
+
const el = nodes[i2];
|
|
6044
|
+
marked.add(el);
|
|
6045
|
+
saved.push([el, el.getAttribute("inert"), el.getAttribute("aria-hidden")]);
|
|
6046
|
+
el.setAttribute("inert", "");
|
|
6047
|
+
el.setAttribute("aria-hidden", "true");
|
|
6048
|
+
}
|
|
6049
|
+
};
|
|
6050
|
+
const active = typeof document !== "undefined" ? document.activeElement : null;
|
|
6051
|
+
mark2(branch.nodes);
|
|
6052
|
+
const initial = saved.length;
|
|
6053
|
+
for (let i2 = 0; i2 < initial; i2++) {
|
|
6054
|
+
const el = saved[i2][0];
|
|
6055
|
+
if (active && (el === active || el.contains(active))) {
|
|
6056
|
+
active.blur?.();
|
|
6057
|
+
break;
|
|
6058
|
+
}
|
|
6059
|
+
}
|
|
6060
|
+
const unwatch = watchRange(branch, (late) => {
|
|
6061
|
+
const before = saved.length;
|
|
6062
|
+
mark2(late);
|
|
6063
|
+
if (saved.length > before) onLate(saved.slice(before).map((entry) => entry[0]));
|
|
6064
|
+
});
|
|
6065
|
+
return () => {
|
|
6066
|
+
unwatch();
|
|
6067
|
+
for (let i2 = 0; i2 < saved.length; i2++) {
|
|
6068
|
+
const [el, inert, hidden] = saved[i2];
|
|
6069
|
+
if (inert === null) el.removeAttribute("inert");
|
|
6070
|
+
else el.setAttribute("inert", inert);
|
|
6071
|
+
if (hidden === null) el.removeAttribute("aria-hidden");
|
|
6072
|
+
else el.setAttribute("aria-hidden", hidden);
|
|
6073
|
+
}
|
|
6074
|
+
};
|
|
5013
6075
|
}
|
|
5014
|
-
function
|
|
5015
|
-
|
|
5016
|
-
|
|
6076
|
+
function watchRange(branch, onLate) {
|
|
6077
|
+
const parent = branch.nodes[0]?.parentNode;
|
|
6078
|
+
if (!parent || typeof MutationObserver !== "function" || !branch.starts.some(hasRange)) return NOOP4;
|
|
6079
|
+
const seen = new Set(branch.nodes);
|
|
6080
|
+
const observer = new MutationObserver(() => {
|
|
6081
|
+
refreshNodes(branch);
|
|
6082
|
+
const late = [];
|
|
6083
|
+
for (const node of branch.nodes) {
|
|
6084
|
+
if (seen.has(node)) continue;
|
|
6085
|
+
seen.add(node);
|
|
6086
|
+
if (node.nodeType === 1) late.push(node);
|
|
6087
|
+
}
|
|
6088
|
+
if (late.length > 0) onLate(late);
|
|
6089
|
+
});
|
|
6090
|
+
observer.observe(parent, { childList: true });
|
|
6091
|
+
return () => observer.disconnect();
|
|
6092
|
+
}
|
|
6093
|
+
function readyWindow(ms) {
|
|
6094
|
+
const endAt = now() + ms;
|
|
6095
|
+
const win = {
|
|
6096
|
+
expired: false,
|
|
6097
|
+
remaining: () => win.expired ? 0 : Math.max(0, Math.min(ms, endAt - now())),
|
|
6098
|
+
onExpire: null,
|
|
6099
|
+
stop: () => {
|
|
6100
|
+
clearTimeout(timer);
|
|
6101
|
+
win.onExpire = null;
|
|
6102
|
+
}
|
|
6103
|
+
};
|
|
6104
|
+
const timer = setTimeout(() => {
|
|
6105
|
+
win.expired = true;
|
|
6106
|
+
const expire = win.onExpire;
|
|
6107
|
+
win.onExpire = null;
|
|
6108
|
+
expire?.();
|
|
6109
|
+
}, ms);
|
|
6110
|
+
return win;
|
|
6111
|
+
}
|
|
6112
|
+
function watchMembership(branch, onChange) {
|
|
6113
|
+
if (typeof MutationObserver !== "function") return null;
|
|
6114
|
+
const observer = new MutationObserver(onChange);
|
|
6115
|
+
const watched = /* @__PURE__ */ new Set();
|
|
6116
|
+
const refresh = () => {
|
|
6117
|
+
const parent = branch.nodes[0]?.parentNode;
|
|
6118
|
+
if (parent && !watched.has(parent)) {
|
|
6119
|
+
watched.add(parent);
|
|
6120
|
+
observer.observe(parent, { childList: true });
|
|
6121
|
+
}
|
|
6122
|
+
for (const node of branch.nodes) {
|
|
6123
|
+
if (node.nodeType !== 1 || watched.has(node)) continue;
|
|
6124
|
+
watched.add(node);
|
|
6125
|
+
observer.observe(node, { childList: true, subtree: true });
|
|
6126
|
+
}
|
|
6127
|
+
};
|
|
6128
|
+
refresh();
|
|
6129
|
+
return {
|
|
6130
|
+
refresh,
|
|
6131
|
+
stop: () => {
|
|
6132
|
+
observer.disconnect();
|
|
6133
|
+
watched.clear();
|
|
6134
|
+
}
|
|
6135
|
+
};
|
|
5017
6136
|
}
|
|
5018
|
-
function
|
|
5019
|
-
requireDocument();
|
|
5020
|
-
if (isDirectiveOptions(elseBranch)) {
|
|
5021
|
-
options = elseBranch;
|
|
5022
|
-
elseBranch = void 0;
|
|
5023
|
-
}
|
|
5024
|
-
const elseNode = elseBranch;
|
|
6137
|
+
function directive(name, read, pick, options) {
|
|
5025
6138
|
const focusPolicy = options?.focus;
|
|
5026
|
-
const
|
|
6139
|
+
const tr2 = options?.transition !== void 0 && !isServer() ? options.transition : void 0;
|
|
6140
|
+
const anchor = document.createComment(name);
|
|
5027
6141
|
const scope = captureScope();
|
|
5028
|
-
|
|
5029
|
-
let
|
|
6142
|
+
const frozen = captureFrozen2();
|
|
6143
|
+
let current2 = null;
|
|
6144
|
+
let last;
|
|
5030
6145
|
let initialized = false;
|
|
5031
6146
|
let disposed = false;
|
|
5032
6147
|
const attachedOnce = /* @__PURE__ */ new WeakSet();
|
|
5033
|
-
|
|
6148
|
+
const leaving = [];
|
|
6149
|
+
let deferred = false;
|
|
6150
|
+
let deferredFocus = null;
|
|
6151
|
+
let dropDeferredWait = NOOP4;
|
|
6152
|
+
const build = (branch, owns) => {
|
|
6153
|
+
const owner = structuralBinding2(NOOP4, anchor);
|
|
6154
|
+
const inBranch = (fn) => owner.run(() => untracked2(() => inScope(scope, fn)));
|
|
6155
|
+
let built;
|
|
6156
|
+
try {
|
|
6157
|
+
built = inBranch(() => resolveBranch(branch, attachedOnce, name));
|
|
6158
|
+
} catch (err) {
|
|
6159
|
+
owner.stop();
|
|
6160
|
+
throw err;
|
|
6161
|
+
}
|
|
6162
|
+
if (built === null) {
|
|
6163
|
+
owner.stop();
|
|
6164
|
+
return null;
|
|
6165
|
+
}
|
|
6166
|
+
const ownsOwner = built.owned;
|
|
6167
|
+
if (ownsOwner) built.owner = owner;
|
|
6168
|
+
if (disposed || !owns() || current2 !== null) {
|
|
6169
|
+
releaseBranch(built);
|
|
6170
|
+
if (!ownsOwner) owner.stop();
|
|
6171
|
+
return null;
|
|
6172
|
+
}
|
|
6173
|
+
let reclaimed = null;
|
|
6174
|
+
if (tr2) {
|
|
6175
|
+
for (let i2 = 0; i2 < leaving.length; i2++) {
|
|
6176
|
+
if (leaving[i2].source !== built.source) continue;
|
|
6177
|
+
reclaimed = leaving.splice(i2, 1)[0];
|
|
6178
|
+
built.owner = reclaimed.owner;
|
|
6179
|
+
reclaimed.owner = null;
|
|
6180
|
+
break;
|
|
6181
|
+
}
|
|
6182
|
+
}
|
|
6183
|
+
current2 = built;
|
|
6184
|
+
built.inserting = true;
|
|
6185
|
+
let complete = false;
|
|
6186
|
+
try {
|
|
6187
|
+
if (reclaimed !== null) {
|
|
6188
|
+
const prev = reclaimed;
|
|
6189
|
+
if (prev.phase !== null) prev.phase.cancel();
|
|
6190
|
+
prev.phase = null;
|
|
6191
|
+
if (prev.restore !== null) prev.restore();
|
|
6192
|
+
prev.restore = null;
|
|
6193
|
+
const unhold = prev.unhold;
|
|
6194
|
+
prev.unhold = null;
|
|
6195
|
+
built.owner?.thaw?.();
|
|
6196
|
+
unhold?.();
|
|
6197
|
+
if (!built.released) refreshNodes(built);
|
|
6198
|
+
}
|
|
6199
|
+
const live = () => !disposed && owns() && current2 === built && !built.released;
|
|
6200
|
+
complete = live() && inBranch(() => insertBranch(anchor, built.nodes, live));
|
|
6201
|
+
} catch (err) {
|
|
6202
|
+
built.inserting = false;
|
|
6203
|
+
if (current2 === built) current2 = null;
|
|
6204
|
+
releaseBranch(built);
|
|
6205
|
+
if (!ownsOwner) owner.stop();
|
|
6206
|
+
throw err;
|
|
6207
|
+
}
|
|
6208
|
+
built.inserting = false;
|
|
6209
|
+
if (complete) inBranch(() => resumePending(built.nodes));
|
|
6210
|
+
if (!ownsOwner) owner.stop();
|
|
6211
|
+
return current2 === built && !built.released && owns() ? built : null;
|
|
6212
|
+
};
|
|
6213
|
+
const playPhase = (branch, start, onEnd, onCancel = NOOP4) => {
|
|
6214
|
+
let valid = true;
|
|
6215
|
+
let run = null;
|
|
6216
|
+
const invalidate = () => {
|
|
6217
|
+
if (!valid) return;
|
|
6218
|
+
valid = false;
|
|
6219
|
+
onCancel();
|
|
6220
|
+
};
|
|
6221
|
+
const handle = {
|
|
6222
|
+
cancel: () => {
|
|
6223
|
+
invalidate();
|
|
6224
|
+
run?.cancel();
|
|
6225
|
+
}
|
|
6226
|
+
};
|
|
6227
|
+
branch.phase = handle;
|
|
6228
|
+
run = start(() => {
|
|
6229
|
+
if (!valid || branch.phase !== handle) return;
|
|
6230
|
+
valid = false;
|
|
6231
|
+
branch.phase = null;
|
|
6232
|
+
onEnd();
|
|
6233
|
+
});
|
|
6234
|
+
if (valid && branch.phase === handle && !branch.released && !disposed && run !== null) {
|
|
6235
|
+
handle.add = run.add;
|
|
6236
|
+
handle.close = run.close;
|
|
6237
|
+
return handle;
|
|
6238
|
+
}
|
|
6239
|
+
invalidate();
|
|
6240
|
+
if (branch.phase === handle) branch.phase = null;
|
|
6241
|
+
run?.cancel();
|
|
6242
|
+
return null;
|
|
6243
|
+
};
|
|
6244
|
+
const startLeave = (branch) => {
|
|
6245
|
+
branch.waiting = false;
|
|
6246
|
+
if (branch.released || disposed) return;
|
|
6247
|
+
const t = tr2;
|
|
6248
|
+
playPhase(
|
|
6249
|
+
branch,
|
|
6250
|
+
(done) => runPhase(branch.nodes, t.leaveClass, t.leave, t.maxDuration, done, `${name}(leave)`),
|
|
6251
|
+
() => finishLeave(branch)
|
|
6252
|
+
);
|
|
6253
|
+
};
|
|
6254
|
+
const startWaitingLeaves = () => {
|
|
6255
|
+
for (const branch of [...leaving]) {
|
|
6256
|
+
if (disposed) return;
|
|
6257
|
+
if (branch.waiting) startLeave(branch);
|
|
6258
|
+
}
|
|
6259
|
+
};
|
|
6260
|
+
const beginLeave = (branch) => {
|
|
6261
|
+
if (branch.released) return;
|
|
6262
|
+
const t = tr2;
|
|
6263
|
+
if (branch.phase !== null) {
|
|
6264
|
+
branch.phase.cancel();
|
|
6265
|
+
branch.phase = null;
|
|
6266
|
+
}
|
|
6267
|
+
refreshNodes(branch);
|
|
6268
|
+
if (branch.owner !== null) {
|
|
6269
|
+
branch.owner.freeze?.();
|
|
6270
|
+
branch.unhold = holdSubtree2({
|
|
6271
|
+
contains: (node) => branch.nodes.some((n) => n === node || n.contains(node))
|
|
6272
|
+
});
|
|
6273
|
+
}
|
|
6274
|
+
const restore = makeInert(branch, (late) => branch.phase?.add?.(late));
|
|
6275
|
+
if (branch.released) {
|
|
6276
|
+
restore();
|
|
6277
|
+
return;
|
|
6278
|
+
}
|
|
6279
|
+
branch.restore = restore;
|
|
6280
|
+
if (t.mode === "in-out") {
|
|
6281
|
+
startWaitingLeaves();
|
|
6282
|
+
branch.waiting = true;
|
|
6283
|
+
leaving.push(branch);
|
|
6284
|
+
return;
|
|
6285
|
+
}
|
|
6286
|
+
leaving.push(branch);
|
|
6287
|
+
startLeave(branch);
|
|
6288
|
+
};
|
|
6289
|
+
const finishLeave = (branch) => {
|
|
6290
|
+
const index = leaving.indexOf(branch);
|
|
6291
|
+
if (index !== -1) leaving.splice(index, 1);
|
|
6292
|
+
releaseBranch(branch);
|
|
6293
|
+
if (deferred && leaving.length === 0 && !disposed) buildDeferred();
|
|
6294
|
+
};
|
|
6295
|
+
const afterInsert = (first, superseded) => {
|
|
6296
|
+
if (superseded()) return;
|
|
6297
|
+
const t = tr2;
|
|
6298
|
+
const entering = current2;
|
|
6299
|
+
if (entering !== null && (!first || t.appear === true)) {
|
|
6300
|
+
enterWhenReady(entering);
|
|
6301
|
+
if (superseded()) return;
|
|
6302
|
+
if (entering.phase !== null) return;
|
|
6303
|
+
}
|
|
6304
|
+
if (t.mode === "in-out") startWaitingLeaves();
|
|
6305
|
+
};
|
|
6306
|
+
const enterWhenReady = (entering) => {
|
|
6307
|
+
const t = tr2;
|
|
6308
|
+
const budget = typeof t.waitForContent === "number" && t.waitForContent > 0 ? t.waitForContent : 0;
|
|
6309
|
+
const ready = budget > 0 ? readyWindow(Math.min(budget, HARD_CAP_MS)) : null;
|
|
6310
|
+
const contentReady = () => t.enter === void 0 || ready === null || ready.expired || loadingWithin(entering.nodes, entering.owner).length === 0;
|
|
6311
|
+
if (!frozen() && !anyPending(entering.nodes) && contentReady()) {
|
|
6312
|
+
startEnter(entering, ready);
|
|
6313
|
+
return;
|
|
6314
|
+
}
|
|
6315
|
+
let cancelled = false;
|
|
6316
|
+
let waiting = false;
|
|
6317
|
+
let dropWait = NOOP4;
|
|
6318
|
+
let dropLoaded = NOOP4;
|
|
6319
|
+
let membership = null;
|
|
6320
|
+
let turns = 0;
|
|
6321
|
+
const stopWaiting = () => {
|
|
6322
|
+
dropWait();
|
|
6323
|
+
dropWait = NOOP4;
|
|
6324
|
+
dropLoaded();
|
|
6325
|
+
dropLoaded = NOOP4;
|
|
6326
|
+
membership?.stop();
|
|
6327
|
+
membership = null;
|
|
6328
|
+
if (ready !== null) ready.onExpire = null;
|
|
6329
|
+
};
|
|
6330
|
+
const placeholder = {
|
|
6331
|
+
cancel: () => {
|
|
6332
|
+
cancelled = true;
|
|
6333
|
+
stopWaiting();
|
|
6334
|
+
ready?.stop();
|
|
6335
|
+
}
|
|
6336
|
+
};
|
|
6337
|
+
entering.phase = placeholder;
|
|
6338
|
+
const step = () => {
|
|
6339
|
+
if (cancelled || disposed || current2 !== entering || entering.phase !== placeholder) return;
|
|
6340
|
+
if (frozen()) {
|
|
6341
|
+
dropWait();
|
|
6342
|
+
dropWait = frozen.wait(step, NOOP4);
|
|
6343
|
+
return;
|
|
6344
|
+
}
|
|
6345
|
+
refreshNodes(entering);
|
|
6346
|
+
if (anyPending(entering.nodes) && ++turns < ENTER_WAIT_TURNS) {
|
|
6347
|
+
queueMicrotask(step);
|
|
6348
|
+
return;
|
|
6349
|
+
}
|
|
6350
|
+
if (!contentReady()) {
|
|
6351
|
+
if (!waiting) {
|
|
6352
|
+
waiting = true;
|
|
6353
|
+
dropLoaded = onLoaded(() => {
|
|
6354
|
+
turns = 0;
|
|
6355
|
+
step();
|
|
6356
|
+
});
|
|
6357
|
+
membership = watchMembership(entering, step);
|
|
6358
|
+
ready.onExpire = step;
|
|
6359
|
+
} else membership?.refresh();
|
|
6360
|
+
return;
|
|
6361
|
+
}
|
|
6362
|
+
stopWaiting();
|
|
6363
|
+
entering.phase = null;
|
|
6364
|
+
startEnter(entering, ready);
|
|
6365
|
+
};
|
|
6366
|
+
if (frozen()) step();
|
|
6367
|
+
else queueMicrotask(step);
|
|
6368
|
+
};
|
|
6369
|
+
const startEnter = (entering, ready) => {
|
|
6370
|
+
const t = tr2;
|
|
6371
|
+
const open = t.enter === void 0 && ready !== null && !ready.expired ? ready.remaining() : 0;
|
|
6372
|
+
const waitingFor = open > 0 ? loadingWithin(entering.nodes, entering.owner) : [];
|
|
6373
|
+
if (waitingFor.length === 0) ready?.stop();
|
|
6374
|
+
let stopWatching = NOOP4;
|
|
6375
|
+
const run = playPhase(
|
|
6376
|
+
entering,
|
|
6377
|
+
(done) => runPhase(
|
|
6378
|
+
entering.nodes,
|
|
6379
|
+
t.enterClass,
|
|
6380
|
+
t.enter,
|
|
6381
|
+
t.maxDuration,
|
|
6382
|
+
done,
|
|
6383
|
+
`${name}(enter)`,
|
|
6384
|
+
waitingFor.length > 0 ? open : 0
|
|
6385
|
+
),
|
|
6386
|
+
() => {
|
|
6387
|
+
stopWatching();
|
|
6388
|
+
if (t.mode === "in-out" && !disposed) startWaitingLeaves();
|
|
6389
|
+
},
|
|
6390
|
+
() => stopWatching()
|
|
6391
|
+
);
|
|
6392
|
+
const add = run?.add;
|
|
6393
|
+
if (run === null || add === void 0) {
|
|
6394
|
+
ready?.stop();
|
|
6395
|
+
return;
|
|
6396
|
+
}
|
|
6397
|
+
const unwatch = watchRange(entering, add);
|
|
6398
|
+
let dropLoaded = NOOP4;
|
|
6399
|
+
let membership = null;
|
|
6400
|
+
const stopLoading = () => {
|
|
6401
|
+
dropLoaded();
|
|
6402
|
+
dropLoaded = NOOP4;
|
|
6403
|
+
membership?.stop();
|
|
6404
|
+
membership = null;
|
|
6405
|
+
ready?.stop();
|
|
6406
|
+
};
|
|
6407
|
+
if (waitingFor.length > 0) {
|
|
6408
|
+
const win = ready;
|
|
6409
|
+
const reconcile = (settled) => {
|
|
6410
|
+
if (win.expired || dropLoaded === NOOP4) {
|
|
6411
|
+
stopLoading();
|
|
6412
|
+
return;
|
|
6413
|
+
}
|
|
6414
|
+
refreshNodes(entering);
|
|
6415
|
+
const inBranch = (el) => entering.nodes.some((n) => n === el || n.contains(el));
|
|
6416
|
+
for (const entry of settled) {
|
|
6417
|
+
if (entry.cancelled || !pendingWithin(entry, entering.nodes, entering.owner)) continue;
|
|
6418
|
+
const content = settledContent(entry).filter(inBranch);
|
|
6419
|
+
if (content.length > 0) add(content);
|
|
6420
|
+
}
|
|
6421
|
+
if (loadingWithin(entering.nodes, entering.owner).length === 0) {
|
|
6422
|
+
stopLoading();
|
|
6423
|
+
run.close?.();
|
|
6424
|
+
} else membership?.refresh();
|
|
6425
|
+
};
|
|
6426
|
+
dropLoaded = onLoaded(reconcile);
|
|
6427
|
+
membership = watchMembership(entering, () => reconcile(settledSinceNotify()));
|
|
6428
|
+
win.onExpire = stopLoading;
|
|
6429
|
+
}
|
|
6430
|
+
stopWatching = () => {
|
|
6431
|
+
unwatch();
|
|
6432
|
+
stopLoading();
|
|
6433
|
+
};
|
|
6434
|
+
};
|
|
6435
|
+
const buildDeferred = bindOwnerScope2(() => {
|
|
6436
|
+
if (disposed || !deferred) return;
|
|
6437
|
+
if (frozen()) {
|
|
6438
|
+
dropDeferredWait();
|
|
6439
|
+
dropDeferredWait = frozen.wait(() => {
|
|
6440
|
+
dropDeferredWait = NOOP4;
|
|
6441
|
+
if (deferred && !disposed) buildDeferred();
|
|
6442
|
+
}, NOOP4);
|
|
6443
|
+
return;
|
|
6444
|
+
}
|
|
6445
|
+
deferred = false;
|
|
6446
|
+
const focused = deferredFocus;
|
|
6447
|
+
deferredFocus = null;
|
|
6448
|
+
const gen = deferredGen;
|
|
6449
|
+
const superseded = () => disposed || gen !== generation;
|
|
6450
|
+
if (superseded() || !anchor.parentNode || current2 !== null) return;
|
|
6451
|
+
let built;
|
|
6452
|
+
try {
|
|
6453
|
+
built = binding.run(() => build(pick(last), () => !superseded()));
|
|
6454
|
+
} catch (err) {
|
|
6455
|
+
reportError(err, { phase: "render", name, node: anchor });
|
|
6456
|
+
return;
|
|
6457
|
+
}
|
|
6458
|
+
if (superseded()) return;
|
|
6459
|
+
restoreFocusWithin(focused, built !== null ? built.nodes : [], name, focusPolicy);
|
|
6460
|
+
afterInsert(false, superseded);
|
|
6461
|
+
});
|
|
6462
|
+
let generation = 0;
|
|
6463
|
+
let deferredGen = 0;
|
|
5034
6464
|
const update = () => {
|
|
5035
6465
|
if (disposed) return;
|
|
5036
|
-
const
|
|
5037
|
-
|
|
5038
|
-
if (
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
const focused = currentNode ? captureFocusWithin([currentNode]) : null;
|
|
5042
|
-
if (currentNode?.parentNode) {
|
|
5043
|
-
releaseBranchNode(currentNode, currentNodeOwned);
|
|
5044
|
-
currentNode = null;
|
|
5045
|
-
}
|
|
5046
|
-
const branch = show2 ? thenBranch : elseNode !== void 0 ? elseNode : null;
|
|
5047
|
-
const attached = untracked2(() => inScope(scope, () => attachBranch(parent, anchor, branch, attachedOnce, "when")));
|
|
5048
|
-
currentNode = attached.node;
|
|
5049
|
-
currentNodeOwned = attached.owned;
|
|
5050
|
-
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "when", focusPolicy);
|
|
6466
|
+
const value = read();
|
|
6467
|
+
if (!anchor.parentNode) return;
|
|
6468
|
+
if (initialized && Object.is(value, last)) return;
|
|
6469
|
+
last = value;
|
|
6470
|
+
const first = !initialized;
|
|
5051
6471
|
initialized = true;
|
|
6472
|
+
const gen = ++generation;
|
|
6473
|
+
const superseded = () => disposed || gen !== generation;
|
|
6474
|
+
if (current2 !== null) refreshNodes(current2);
|
|
6475
|
+
const focused = current2 !== null ? captureFocusWithin(current2.nodes) : null;
|
|
6476
|
+
if (current2 !== null) {
|
|
6477
|
+
const outgoing = current2;
|
|
6478
|
+
if (tr2) beginLeave(outgoing);
|
|
6479
|
+
else releaseBranch(outgoing);
|
|
6480
|
+
if (current2 === outgoing) current2 = null;
|
|
6481
|
+
if (superseded()) return;
|
|
6482
|
+
}
|
|
6483
|
+
const branch = pick(value);
|
|
6484
|
+
if (tr2?.mode === "out-in" && leaving.length > 0) {
|
|
6485
|
+
let reclaim = false;
|
|
6486
|
+
for (let i2 = 0; i2 < leaving.length && !reclaim; i2++) reclaim = leaving[i2].source === branch;
|
|
6487
|
+
if (!reclaim) {
|
|
6488
|
+
deferred = true;
|
|
6489
|
+
deferredGen = gen;
|
|
6490
|
+
deferredFocus ?? (deferredFocus = focused);
|
|
6491
|
+
return;
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6494
|
+
deferred = false;
|
|
6495
|
+
build(branch, () => !superseded());
|
|
6496
|
+
if (superseded()) return;
|
|
6497
|
+
restoreFocusWithin(focused, current2 !== null ? current2.nodes : [], name, focusPolicy);
|
|
6498
|
+
if (tr2) afterInsert(first, superseded);
|
|
5052
6499
|
};
|
|
5053
6500
|
const binding = structuralBinding2(update, anchor);
|
|
6501
|
+
registerRange(anchor, () => {
|
|
6502
|
+
for (let i2 = 0; i2 <= leaving.length; i2++) {
|
|
6503
|
+
const branch = i2 < leaving.length ? leaving[i2] : current2;
|
|
6504
|
+
if (branch === null) break;
|
|
6505
|
+
const nodes = collectRange(branch.starts);
|
|
6506
|
+
if (nodes.length > 0) return nodes[nodes.length - 1];
|
|
6507
|
+
}
|
|
6508
|
+
return null;
|
|
6509
|
+
});
|
|
5054
6510
|
registerDisposer(anchor, () => {
|
|
5055
6511
|
disposed = true;
|
|
6512
|
+
deferred = false;
|
|
6513
|
+
deferredFocus = null;
|
|
6514
|
+
dropDeferredWait();
|
|
6515
|
+
dropDeferredWait = NOOP4;
|
|
5056
6516
|
binding.stop();
|
|
5057
|
-
if (
|
|
5058
|
-
|
|
6517
|
+
if (current2 !== null) releaseBranch(current2);
|
|
6518
|
+
current2 = null;
|
|
6519
|
+
const rest = leaving.splice(0);
|
|
6520
|
+
for (let i2 = 0; i2 < rest.length; i2++) releaseBranch(rest[i2]);
|
|
5059
6521
|
});
|
|
5060
6522
|
if (!initialized) {
|
|
5061
|
-
|
|
6523
|
+
queueFirstRender(
|
|
6524
|
+
anchor,
|
|
5062
6525
|
bindOwnerScope2(() => {
|
|
5063
6526
|
if (!disposed && !initialized && anchor.parentNode) binding.run(update);
|
|
5064
|
-
})
|
|
6527
|
+
}),
|
|
6528
|
+
frozen
|
|
5065
6529
|
);
|
|
5066
6530
|
}
|
|
5067
6531
|
return anchor;
|
|
5068
6532
|
}
|
|
6533
|
+
function when(condition, thenBranch, elseBranch, options) {
|
|
6534
|
+
requireDocument();
|
|
6535
|
+
if (isDirectiveOptions(elseBranch)) {
|
|
6536
|
+
options = elseBranch;
|
|
6537
|
+
elseBranch = void 0;
|
|
6538
|
+
}
|
|
6539
|
+
const elseNode = elseBranch;
|
|
6540
|
+
return directive(
|
|
6541
|
+
"when",
|
|
6542
|
+
condition,
|
|
6543
|
+
(show2) => show2 ? thenBranch : elseNode !== void 0 ? elseNode : null,
|
|
6544
|
+
options
|
|
6545
|
+
);
|
|
6546
|
+
}
|
|
5069
6547
|
function match(value, cases, fallback, options) {
|
|
5070
6548
|
requireDocument();
|
|
5071
6549
|
if (isDirectiveOptions(fallback)) {
|
|
@@ -5073,51 +6551,14 @@ function match(value, cases, fallback, options) {
|
|
|
5073
6551
|
fallback = void 0;
|
|
5074
6552
|
}
|
|
5075
6553
|
const fallbackNode = fallback;
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
let currentNodeOwned = false;
|
|
5085
|
-
const update = () => {
|
|
5086
|
-
if (disposed) return;
|
|
5087
|
-
const key = String(value());
|
|
5088
|
-
const parent = anchor.parentNode;
|
|
5089
|
-
if (!parent) return;
|
|
5090
|
-
if (initialized && key === lastKey) return;
|
|
5091
|
-
lastKey = key;
|
|
5092
|
-
const focused = currentNode ? captureFocusWithin([currentNode]) : null;
|
|
5093
|
-
if (currentNode?.parentNode) {
|
|
5094
|
-
releaseBranchNode(currentNode, currentNodeOwned);
|
|
5095
|
-
currentNode = null;
|
|
5096
|
-
}
|
|
5097
|
-
const branch = Object.hasOwn(cases, key) ? cases[key] : fallbackNode;
|
|
5098
|
-
const attached = untracked2(
|
|
5099
|
-
() => inScope(scope, () => attachBranch(parent, anchor, branch ?? null, attachedOnce, "match"))
|
|
5100
|
-
);
|
|
5101
|
-
currentNode = attached.node;
|
|
5102
|
-
currentNodeOwned = attached.owned;
|
|
5103
|
-
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "match", focusPolicy);
|
|
5104
|
-
initialized = true;
|
|
5105
|
-
};
|
|
5106
|
-
const binding = structuralBinding2(update, anchor);
|
|
5107
|
-
registerDisposer(anchor, () => {
|
|
5108
|
-
disposed = true;
|
|
5109
|
-
binding.stop();
|
|
5110
|
-
if (currentNode) releaseBranchNode(currentNode, currentNodeOwned);
|
|
5111
|
-
currentNode = null;
|
|
5112
|
-
});
|
|
5113
|
-
if (!initialized) {
|
|
5114
|
-
queueMicrotask(
|
|
5115
|
-
bindOwnerScope2(() => {
|
|
5116
|
-
if (!disposed && !initialized && anchor.parentNode) binding.run(update);
|
|
5117
|
-
})
|
|
5118
|
-
);
|
|
5119
|
-
}
|
|
5120
|
-
return anchor;
|
|
6554
|
+
return directive(
|
|
6555
|
+
"match",
|
|
6556
|
+
() => String(value()),
|
|
6557
|
+
// `Object.hasOwn` rather than `||` so a case whose value is legitimately
|
|
6558
|
+
// falsy (an empty string, 0) still wins over the fallback.
|
|
6559
|
+
(key) => Object.hasOwn(cases, key) ? cases[key] : fallbackNode ?? null,
|
|
6560
|
+
options
|
|
6561
|
+
);
|
|
5121
6562
|
}
|
|
5122
6563
|
|
|
5123
6564
|
// src/core/rendering/clientOnly.ts
|
|
@@ -5190,12 +6631,6 @@ function __resetIdCounter() {
|
|
|
5190
6631
|
_counter.n = 0;
|
|
5191
6632
|
}
|
|
5192
6633
|
|
|
5193
|
-
// src/utils/globalSingleton.ts
|
|
5194
|
-
function globalSingleton(key, create) {
|
|
5195
|
-
const g2 = globalThis;
|
|
5196
|
-
return g2[key] ?? (g2[key] = create());
|
|
5197
|
-
}
|
|
5198
|
-
|
|
5199
6634
|
// src/core/rendering/dynamic.ts
|
|
5200
6635
|
var componentRegistry = globalSingleton(
|
|
5201
6636
|
/* @__PURE__ */ Symbol.for("sibujs.components.registry.v1"),
|
|
@@ -5282,6 +6717,14 @@ function longestIncreasingSubsequence(arr, len) {
|
|
|
5282
6717
|
}
|
|
5283
6718
|
return result;
|
|
5284
6719
|
}
|
|
6720
|
+
var renderingRow = null;
|
|
6721
|
+
var warnedReadSites = /* @__PURE__ */ new Set();
|
|
6722
|
+
function withPeek(get) {
|
|
6723
|
+
const state4 = get.__signal;
|
|
6724
|
+
const cell = get;
|
|
6725
|
+
cell.peek = () => state4.value;
|
|
6726
|
+
return cell;
|
|
6727
|
+
}
|
|
5285
6728
|
function each(getArray, render, options) {
|
|
5286
6729
|
devAssert(typeof getArray === "function", "each: first argument must be a function that returns an array.");
|
|
5287
6730
|
devAssert(typeof render === "function", "each: second argument must be a render function.");
|
|
@@ -5360,13 +6803,40 @@ function each(getArray, render, options) {
|
|
|
5360
6803
|
} else {
|
|
5361
6804
|
const [itemGetter, setItem] = signal(arr[i2]);
|
|
5362
6805
|
const [indexGetter, setIndex] = signal(i2);
|
|
6806
|
+
const item = withPeek(itemGetter);
|
|
6807
|
+
const index = withPeek(indexGetter);
|
|
6808
|
+
let reads = null;
|
|
6809
|
+
let renderItem = item;
|
|
6810
|
+
let renderIndex = index;
|
|
6811
|
+
let outerRow = null;
|
|
6812
|
+
devWarnLazy(() => {
|
|
6813
|
+
const rowReads = { item: null, index: null };
|
|
6814
|
+
const recording = (get, slot4) => {
|
|
6815
|
+
const read = (() => {
|
|
6816
|
+
if (renderingRow === rowReads && rowReads[slot4] === null && isTrackingSuspended2()) {
|
|
6817
|
+
rowReads[slot4] = new Error();
|
|
6818
|
+
}
|
|
6819
|
+
return get();
|
|
6820
|
+
});
|
|
6821
|
+
read.peek = get.peek;
|
|
6822
|
+
read.__signal = get.__signal;
|
|
6823
|
+
return read;
|
|
6824
|
+
};
|
|
6825
|
+
reads = rowReads;
|
|
6826
|
+
renderItem = recording(item, "item");
|
|
6827
|
+
renderIndex = recording(index, "index");
|
|
6828
|
+
return "";
|
|
6829
|
+
});
|
|
5363
6830
|
let node;
|
|
5364
6831
|
try {
|
|
5365
6832
|
suspendTracking2();
|
|
6833
|
+
outerRow = renderingRow;
|
|
6834
|
+
renderingRow = reads;
|
|
5366
6835
|
try {
|
|
5367
|
-
node = resolveNodeChild(inScope(keyedScope(scope, key), () => render(
|
|
6836
|
+
node = resolveNodeChild(inScope(keyedScope(scope, key), () => render(renderItem, renderIndex)));
|
|
5368
6837
|
} finally {
|
|
5369
6838
|
resumeTracking2();
|
|
6839
|
+
renderingRow = outerRow;
|
|
5370
6840
|
}
|
|
5371
6841
|
} catch (err) {
|
|
5372
6842
|
const key2 = newKeys[i2];
|
|
@@ -5379,7 +6849,7 @@ function each(getArray, render, options) {
|
|
|
5379
6849
|
});
|
|
5380
6850
|
});
|
|
5381
6851
|
}
|
|
5382
|
-
row = { node, item
|
|
6852
|
+
row = { node, item, setItem, index, setIndex, reads };
|
|
5383
6853
|
}
|
|
5384
6854
|
workMap.set(key, row);
|
|
5385
6855
|
newNodes[i2] = row.node;
|
|
@@ -5457,6 +6927,7 @@ function each(getArray, render, options) {
|
|
|
5457
6927
|
batch(() => {
|
|
5458
6928
|
for (let i2 = 0; i2 < count; i2++) {
|
|
5459
6929
|
const row = pendingRows[i2];
|
|
6930
|
+
if (row.reads !== null) warnStaleRead(row, pendingItems[i2], pendingIndices[i2]);
|
|
5460
6931
|
row.setItem(pendingItems[i2]);
|
|
5461
6932
|
row.setIndex(pendingIndices[i2]);
|
|
5462
6933
|
pendingRows[i2] = void 0;
|
|
@@ -5464,7 +6935,29 @@ function each(getArray, render, options) {
|
|
|
5464
6935
|
}
|
|
5465
6936
|
});
|
|
5466
6937
|
}
|
|
5467
|
-
|
|
6938
|
+
function warnStaleRead(row, nextItem, nextIndex) {
|
|
6939
|
+
devWarnLazy(() => {
|
|
6940
|
+
const reads = row.reads;
|
|
6941
|
+
let site = null;
|
|
6942
|
+
let which = "";
|
|
6943
|
+
if (reads.item !== null && !Object.is(row.item.peek(), nextItem)) {
|
|
6944
|
+
site = reads.item;
|
|
6945
|
+
which = "item";
|
|
6946
|
+
reads.item = null;
|
|
6947
|
+
} else if (reads.index !== null && row.index.peek() !== nextIndex) {
|
|
6948
|
+
site = reads.index;
|
|
6949
|
+
which = "index";
|
|
6950
|
+
reads.index = null;
|
|
6951
|
+
}
|
|
6952
|
+
if (site === null) return "";
|
|
6953
|
+
const frames = (site.stack ?? "").split("\n").filter((line2) => /^\s*at\s|@/.test(line2));
|
|
6954
|
+
const at = (frames[1] ?? frames[0] ?? "").trim().replace(/^at\s+/, "") || "unknown location";
|
|
6955
|
+
if (warnedReadSites.has(at)) return "";
|
|
6956
|
+
if (warnedReadSites.size < 100) warnedReadSites.add(at);
|
|
6957
|
+
return `each(): the row for key "${String(keyFn(nextItem))}" read ${which}() directly while rendering, so it will not show the new value. Read it inside a binding (\`() => ${which}().x\`) or an effect, or include the changing field in the key. For an intentional one-time read, use ${which}.peek(). (render at ${at})`;
|
|
6958
|
+
});
|
|
6959
|
+
}
|
|
6960
|
+
const binding = structuralBinding2(update, anchor);
|
|
5468
6961
|
const untrack = binding.stop;
|
|
5469
6962
|
const disposeRange = () => {
|
|
5470
6963
|
if (rangeDisposed) return;
|
|
@@ -5487,13 +6980,15 @@ function each(getArray, render, options) {
|
|
|
5487
6980
|
pendingCount = 0;
|
|
5488
6981
|
};
|
|
5489
6982
|
registerDisposer(anchor, disposeRange);
|
|
6983
|
+
registerRange(anchor, () => sentinelInserted ? end : null);
|
|
5490
6984
|
if (!initialized) {
|
|
5491
|
-
|
|
6985
|
+
const frozen = captureFrozen2();
|
|
6986
|
+
queueFirstRender(
|
|
6987
|
+
anchor,
|
|
5492
6988
|
bindOwnerScope2(() => {
|
|
5493
|
-
if (!initialized && !rangeDisposed && anchor.parentNode)
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
})
|
|
6989
|
+
if (!initialized && !rangeDisposed && anchor.parentNode) binding.run(update);
|
|
6990
|
+
}),
|
|
6991
|
+
frozen
|
|
5497
6992
|
);
|
|
5498
6993
|
}
|
|
5499
6994
|
return anchor;
|
|
@@ -5537,7 +7032,7 @@ function appendChild(frag, child) {
|
|
|
5537
7032
|
if (typeof child === "function") {
|
|
5538
7033
|
const placeholder = document.createComment("");
|
|
5539
7034
|
frag.appendChild(placeholder);
|
|
5540
|
-
registerDisposer(placeholder, bindChildNode(placeholder, child));
|
|
7035
|
+
registerDisposer(placeholder, bindChildNode(placeholder, child, true));
|
|
5541
7036
|
return;
|
|
5542
7037
|
}
|
|
5543
7038
|
frag.appendChild(document.createTextNode(String(child)));
|
|
@@ -5583,7 +7078,7 @@ var SVG_TAGS = /* @__PURE__ */ new Set([
|
|
|
5583
7078
|
"symbol",
|
|
5584
7079
|
"marker"
|
|
5585
7080
|
]);
|
|
5586
|
-
var
|
|
7081
|
+
var cache2 = /* @__PURE__ */ new WeakMap();
|
|
5587
7082
|
function parseTemplate(strings) {
|
|
5588
7083
|
const exprCount = strings.length - 1;
|
|
5589
7084
|
let template2 = strings[0];
|
|
@@ -5870,10 +7365,10 @@ function executeElement(tmpl, values) {
|
|
|
5870
7365
|
return el;
|
|
5871
7366
|
}
|
|
5872
7367
|
function html2(strings, ...values) {
|
|
5873
|
-
let tmpl =
|
|
7368
|
+
let tmpl = cache2.get(strings);
|
|
5874
7369
|
if (!tmpl) {
|
|
5875
7370
|
tmpl = parseTemplate(strings);
|
|
5876
|
-
|
|
7371
|
+
cache2.set(strings, tmpl);
|
|
5877
7372
|
}
|
|
5878
7373
|
return renderTemplate(tmpl, values);
|
|
5879
7374
|
}
|
|
@@ -5929,7 +7424,7 @@ function renderTemplate(tmpl, values) {
|
|
|
5929
7424
|
function KeepAlive(activeKey, cases, options) {
|
|
5930
7425
|
requireDocument();
|
|
5931
7426
|
const anchor = document.createComment("keep-alive");
|
|
5932
|
-
const
|
|
7427
|
+
const cache3 = /* @__PURE__ */ new Map();
|
|
5933
7428
|
const lruOrder = [];
|
|
5934
7429
|
const max = options?.max ?? 10;
|
|
5935
7430
|
if (max === 0 && isDev()) {
|
|
@@ -5949,7 +7444,7 @@ function KeepAlive(activeKey, cases, options) {
|
|
|
5949
7444
|
parent.removeChild(currentNode);
|
|
5950
7445
|
}
|
|
5951
7446
|
currentKey = key;
|
|
5952
|
-
let node =
|
|
7447
|
+
let node = cache3.get(key);
|
|
5953
7448
|
if (!node) {
|
|
5954
7449
|
const factory = cases[key];
|
|
5955
7450
|
if (!factory) {
|
|
@@ -5964,15 +7459,15 @@ function KeepAlive(activeKey, cases, options) {
|
|
|
5964
7459
|
wrapper.appendChild(node);
|
|
5965
7460
|
node = wrapper;
|
|
5966
7461
|
}
|
|
5967
|
-
|
|
7462
|
+
cache3.set(key, node);
|
|
5968
7463
|
lruOrder.push(key);
|
|
5969
7464
|
if (max > 0 && lruOrder.length > max) {
|
|
5970
7465
|
const evictKey = lruOrder.shift();
|
|
5971
|
-
const evictNode =
|
|
7466
|
+
const evictNode = cache3.get(evictKey);
|
|
5972
7467
|
if (evictNode) {
|
|
5973
7468
|
dispose(evictNode);
|
|
5974
7469
|
if (evictNode.parentNode) evictNode.parentNode.removeChild(evictNode);
|
|
5975
|
-
|
|
7470
|
+
cache3.delete(evictKey);
|
|
5976
7471
|
}
|
|
5977
7472
|
}
|
|
5978
7473
|
} else {
|
|
@@ -5986,23 +7481,27 @@ function KeepAlive(activeKey, cases, options) {
|
|
|
5986
7481
|
currentNode = node;
|
|
5987
7482
|
initialized = true;
|
|
5988
7483
|
};
|
|
5989
|
-
const binding = structuralBinding2(update);
|
|
7484
|
+
const binding = structuralBinding2(update, anchor);
|
|
7485
|
+
registerNodesRange(anchor, () => [currentNode]);
|
|
5990
7486
|
const untrack = binding.stop;
|
|
5991
7487
|
if (!initialized) {
|
|
5992
|
-
|
|
7488
|
+
const frozen = captureFrozen2();
|
|
7489
|
+
queueFirstRender(
|
|
7490
|
+
anchor,
|
|
5993
7491
|
bindOwnerScope2(() => {
|
|
5994
7492
|
if (!initialized && anchor.parentNode) binding.run(update);
|
|
5995
|
-
})
|
|
7493
|
+
}),
|
|
7494
|
+
frozen
|
|
5996
7495
|
);
|
|
5997
7496
|
}
|
|
5998
7497
|
registerDisposer(anchor, () => {
|
|
5999
7498
|
disposed = true;
|
|
6000
7499
|
untrack();
|
|
6001
|
-
for (const node of
|
|
7500
|
+
for (const node of cache3.values()) {
|
|
6002
7501
|
dispose(node);
|
|
6003
7502
|
if (node.parentNode) node.parentNode.removeChild(node);
|
|
6004
7503
|
}
|
|
6005
|
-
|
|
7504
|
+
cache3.clear();
|
|
6006
7505
|
lruOrder.length = 0;
|
|
6007
7506
|
currentNode = null;
|
|
6008
7507
|
});
|
|
@@ -6020,8 +7519,8 @@ function mount(component, container) {
|
|
|
6020
7519
|
typeof component === "function" || component instanceof Node,
|
|
6021
7520
|
"mount: first argument must be a component function or a DOM Node."
|
|
6022
7521
|
);
|
|
6023
|
-
const
|
|
6024
|
-
const startTime =
|
|
7522
|
+
const now2 = () => typeof performance !== "undefined" ? performance.now() : 0;
|
|
7523
|
+
const startTime = now2();
|
|
6025
7524
|
let range = null;
|
|
6026
7525
|
const attach = (built) => {
|
|
6027
7526
|
if (built instanceof DocumentFragment) {
|
|
@@ -6044,7 +7543,7 @@ function mount(component, container) {
|
|
|
6044
7543
|
node = component;
|
|
6045
7544
|
attach(node);
|
|
6046
7545
|
}
|
|
6047
|
-
const duration =
|
|
7546
|
+
const duration = now2() - startTime;
|
|
6048
7547
|
const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
6049
7548
|
if (hook) emitDevtools(hook, "app:init", { rootElement: node, container, duration });
|
|
6050
7549
|
const mounted = range;
|
|
@@ -6092,6 +7591,153 @@ function unmountRange(start, end) {
|
|
|
6092
7591
|
end.parentNode?.removeChild(end);
|
|
6093
7592
|
}
|
|
6094
7593
|
|
|
7594
|
+
// src/core/signals/watch.ts
|
|
7595
|
+
function watch(getter, callback) {
|
|
7596
|
+
devAssert(typeof getter === "function", "watch: first argument must be a getter function.");
|
|
7597
|
+
devAssert(typeof callback === "function", "watch: second argument must be a callback function.");
|
|
7598
|
+
if (isSSR()) return () => {
|
|
7599
|
+
};
|
|
7600
|
+
let oldValue;
|
|
7601
|
+
let first = true;
|
|
7602
|
+
const subscriber = () => {
|
|
7603
|
+
const newValue = getter();
|
|
7604
|
+
if (first) {
|
|
7605
|
+
oldValue = newValue;
|
|
7606
|
+
first = false;
|
|
7607
|
+
return;
|
|
7608
|
+
}
|
|
7609
|
+
if (!Object.is(newValue, oldValue)) {
|
|
7610
|
+
const prev = oldValue;
|
|
7611
|
+
oldValue = newValue;
|
|
7612
|
+
suspendTracking2();
|
|
7613
|
+
try {
|
|
7614
|
+
callback(newValue, prev);
|
|
7615
|
+
} finally {
|
|
7616
|
+
resumeTracking2();
|
|
7617
|
+
}
|
|
7618
|
+
}
|
|
7619
|
+
};
|
|
7620
|
+
const teardown = track2(subscriber);
|
|
7621
|
+
return teardown;
|
|
7622
|
+
}
|
|
7623
|
+
|
|
7624
|
+
// src/core/signals/lifecycleScope.ts
|
|
7625
|
+
var STATES = ["active", "paused", "ended"];
|
|
7626
|
+
var ENDED2 = 2;
|
|
7627
|
+
var NOOP5 = () => {
|
|
7628
|
+
};
|
|
7629
|
+
var scopeOwners = globalSingleton(
|
|
7630
|
+
/* @__PURE__ */ Symbol.for("sibujs.lifecycleScope.owners.v1"),
|
|
7631
|
+
() => /* @__PURE__ */ new WeakMap()
|
|
7632
|
+
);
|
|
7633
|
+
function scopeOwner(scope) {
|
|
7634
|
+
return scopeOwners.get(scope);
|
|
7635
|
+
}
|
|
7636
|
+
function lifecycleScope() {
|
|
7637
|
+
const held = captureFrozen2();
|
|
7638
|
+
const inOwnerScope = bindOwnerScope2((fn) => fn());
|
|
7639
|
+
const ended = () => held.state() === ENDED2;
|
|
7640
|
+
const own = (register) => {
|
|
7641
|
+
let disposed = false;
|
|
7642
|
+
let stop2 = null;
|
|
7643
|
+
let dropWait = NOOP5;
|
|
7644
|
+
let dropEnd = NOOP5;
|
|
7645
|
+
const dispose2 = () => {
|
|
7646
|
+
if (disposed) return;
|
|
7647
|
+
disposed = true;
|
|
7648
|
+
dropWait();
|
|
7649
|
+
dropEnd();
|
|
7650
|
+
const running = stop2;
|
|
7651
|
+
stop2 = null;
|
|
7652
|
+
running?.();
|
|
7653
|
+
};
|
|
7654
|
+
const start = () => {
|
|
7655
|
+
dropWait = NOOP5;
|
|
7656
|
+
if (disposed) return;
|
|
7657
|
+
dropEnd = held.onEnd(dispose2);
|
|
7658
|
+
if (disposed) return;
|
|
7659
|
+
let created;
|
|
7660
|
+
try {
|
|
7661
|
+
created = held.run(() => inOwnerScope(register));
|
|
7662
|
+
} catch (err) {
|
|
7663
|
+
disposed = true;
|
|
7664
|
+
dropEnd();
|
|
7665
|
+
dropEnd = NOOP5;
|
|
7666
|
+
throw err;
|
|
7667
|
+
}
|
|
7668
|
+
if (disposed) created();
|
|
7669
|
+
else stop2 = created;
|
|
7670
|
+
};
|
|
7671
|
+
const state4 = held.state();
|
|
7672
|
+
if (state4 === ENDED2) disposed = true;
|
|
7673
|
+
else if (state4 === 1) dropWait = held.wait(start, dispose2);
|
|
7674
|
+
else start();
|
|
7675
|
+
return dispose2;
|
|
7676
|
+
};
|
|
7677
|
+
const onState = (want, callback) => held.onChange((state4) => {
|
|
7678
|
+
if (state4 === want) held.run(() => inOwnerScope(callback));
|
|
7679
|
+
});
|
|
7680
|
+
const scope = {
|
|
7681
|
+
state: () => STATES[held.state()],
|
|
7682
|
+
own,
|
|
7683
|
+
onPause: (callback) => onState(1, callback),
|
|
7684
|
+
onResume: (callback) => onState(0, callback),
|
|
7685
|
+
// The guards are the liveness check of a registration whose owner ended
|
|
7686
|
+
// while its own run was in progress (a body that ends its branch and
|
|
7687
|
+
// re-runs itself); `own` disposes it as soon as that run returns.
|
|
7688
|
+
effect: (fn, options) => own(
|
|
7689
|
+
() => effect((onCleanup2) => {
|
|
7690
|
+
if (!ended()) fn(onCleanup2);
|
|
7691
|
+
}, options)
|
|
7692
|
+
),
|
|
7693
|
+
watch: (getter, callback) => own(
|
|
7694
|
+
() => watch(getter, (value, prev) => {
|
|
7695
|
+
if (!ended()) callback(value, prev);
|
|
7696
|
+
})
|
|
7697
|
+
)
|
|
7698
|
+
};
|
|
7699
|
+
scopeOwners.set(scope, held);
|
|
7700
|
+
return scope;
|
|
7701
|
+
}
|
|
7702
|
+
|
|
7703
|
+
// src/core/rendering/pendingContent.ts
|
|
7704
|
+
var INERT2 = { done: () => {
|
|
7705
|
+
}, cancel: () => {
|
|
7706
|
+
}, settled: true };
|
|
7707
|
+
function pendingContent(at) {
|
|
7708
|
+
if (isServer()) return INERT2;
|
|
7709
|
+
const isNode = typeof at.nodeType === "number";
|
|
7710
|
+
const held = isNode ? null : scopeOwner(at) ?? null;
|
|
7711
|
+
if (!isNode && (held === null || held.state() === 2)) return INERT2;
|
|
7712
|
+
const { entry, done, cancel: cancelEntry } = beginPending(isNode ? at : null, held);
|
|
7713
|
+
let drop = () => {
|
|
7714
|
+
};
|
|
7715
|
+
const cancel = () => {
|
|
7716
|
+
if (entry.settled) return;
|
|
7717
|
+
drop();
|
|
7718
|
+
cancelEntry();
|
|
7719
|
+
};
|
|
7720
|
+
if (isNode) {
|
|
7721
|
+
registerDisposer(at, cancel);
|
|
7722
|
+
drop = () => {
|
|
7723
|
+
unregisterDisposer(at, cancel);
|
|
7724
|
+
};
|
|
7725
|
+
} else drop = held.onEnd(cancel);
|
|
7726
|
+
return {
|
|
7727
|
+
done: (committed) => {
|
|
7728
|
+
if (entry.settled) return;
|
|
7729
|
+
drop();
|
|
7730
|
+
done(
|
|
7731
|
+
committed === void 0 ? null : typeof committed.nodeType === "number" ? [committed] : [...committed]
|
|
7732
|
+
);
|
|
7733
|
+
},
|
|
7734
|
+
cancel,
|
|
7735
|
+
get settled() {
|
|
7736
|
+
return entry.settled;
|
|
7737
|
+
}
|
|
7738
|
+
};
|
|
7739
|
+
}
|
|
7740
|
+
|
|
6095
7741
|
// src/core/rendering/portal.ts
|
|
6096
7742
|
function Portal(nodes, target) {
|
|
6097
7743
|
requireDocument();
|
|
@@ -6720,36 +8366,6 @@ function store(initialState) {
|
|
|
6720
8366
|
return [store2, { setState, reset, subscribe, subscribeKey, getSnapshot }];
|
|
6721
8367
|
}
|
|
6722
8368
|
|
|
6723
|
-
// src/core/signals/watch.ts
|
|
6724
|
-
function watch(getter, callback) {
|
|
6725
|
-
devAssert(typeof getter === "function", "watch: first argument must be a getter function.");
|
|
6726
|
-
devAssert(typeof callback === "function", "watch: second argument must be a callback function.");
|
|
6727
|
-
if (isSSR()) return () => {
|
|
6728
|
-
};
|
|
6729
|
-
let oldValue;
|
|
6730
|
-
let first = true;
|
|
6731
|
-
const subscriber = () => {
|
|
6732
|
-
const newValue = getter();
|
|
6733
|
-
if (first) {
|
|
6734
|
-
oldValue = newValue;
|
|
6735
|
-
first = false;
|
|
6736
|
-
return;
|
|
6737
|
-
}
|
|
6738
|
-
if (!Object.is(newValue, oldValue)) {
|
|
6739
|
-
const prev = oldValue;
|
|
6740
|
-
oldValue = newValue;
|
|
6741
|
-
suspendTracking2();
|
|
6742
|
-
try {
|
|
6743
|
-
callback(newValue, prev);
|
|
6744
|
-
} finally {
|
|
6745
|
-
resumeTracking2();
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
};
|
|
6749
|
-
const teardown = track2(subscriber);
|
|
6750
|
-
return teardown;
|
|
6751
|
-
}
|
|
6752
|
-
|
|
6753
8369
|
// src/core/signals/writable.ts
|
|
6754
8370
|
function writable(get, set, options) {
|
|
6755
8371
|
const getter = derived(get, options);
|
|
@@ -7003,10 +8619,10 @@ function enhance(target, setup) {
|
|
|
7003
8619
|
});
|
|
7004
8620
|
});
|
|
7005
8621
|
},
|
|
7006
|
-
model: (t,
|
|
8622
|
+
model: (t, state4, options) => {
|
|
7007
8623
|
bind("model", t, (el) => {
|
|
7008
8624
|
const control = el;
|
|
7009
|
-
const [get, set] =
|
|
8625
|
+
const [get, set] = state4;
|
|
7010
8626
|
const evt = options?.event ?? (control instanceof HTMLSelectElement || control instanceof HTMLInputElement && (control.type === "checkbox" || control.type === "radio") ? "change" : "input");
|
|
7011
8627
|
teardowns.push(
|
|
7012
8628
|
bindNode(el, () => {
|
|
@@ -7251,17 +8867,17 @@ var DEFAULT_MAX_SSR_BYTES = 1024 * 1024;
|
|
|
7251
8867
|
// src/reactivity/concurrent.ts
|
|
7252
8868
|
function defer(getter) {
|
|
7253
8869
|
const [value, setValue] = signal(getter());
|
|
7254
|
-
let
|
|
8870
|
+
let pending2 = false;
|
|
7255
8871
|
let disposed = false;
|
|
7256
8872
|
let latest = value();
|
|
7257
8873
|
const flush = () => {
|
|
7258
|
-
|
|
8874
|
+
pending2 = false;
|
|
7259
8875
|
if (disposed) return;
|
|
7260
8876
|
setValue(latest);
|
|
7261
8877
|
};
|
|
7262
8878
|
const schedule2 = () => {
|
|
7263
|
-
if (
|
|
7264
|
-
|
|
8879
|
+
if (pending2) return;
|
|
8880
|
+
pending2 = true;
|
|
7265
8881
|
queueMicrotask(() => {
|
|
7266
8882
|
if (typeof requestAnimationFrame === "function") {
|
|
7267
8883
|
requestAnimationFrame(flush);
|
|
@@ -7296,7 +8912,7 @@ function scheduleIdle(fn) {
|
|
|
7296
8912
|
setTimeout(fn, IDLE_FALLBACK_MS);
|
|
7297
8913
|
}
|
|
7298
8914
|
function transition() {
|
|
7299
|
-
const [
|
|
8915
|
+
const [pending2, setPending] = signal(false);
|
|
7300
8916
|
let outstanding = 0;
|
|
7301
8917
|
function start(fn) {
|
|
7302
8918
|
outstanding++;
|
|
@@ -7321,7 +8937,7 @@ function transition() {
|
|
|
7321
8937
|
}
|
|
7322
8938
|
});
|
|
7323
8939
|
}
|
|
7324
|
-
return { pending, start };
|
|
8940
|
+
return { pending: pending2, start };
|
|
7325
8941
|
}
|
|
7326
8942
|
|
|
7327
8943
|
// src/reactivity/nextTick.ts
|
|
@@ -7534,22 +9150,22 @@ function editsSourceMap(code2, edits, append, source2) {
|
|
|
7534
9150
|
};
|
|
7535
9151
|
const emitReplacement = (edit) => {
|
|
7536
9152
|
let origOffset = edit.start;
|
|
7537
|
-
let
|
|
9153
|
+
let pending2 = true;
|
|
7538
9154
|
for (let i2 = 0; i2 < edit.text.length; i2++) {
|
|
7539
9155
|
if (edit.text.charCodeAt(i2) === 10) {
|
|
7540
9156
|
newline();
|
|
7541
9157
|
const nl = code2.indexOf("\n", origOffset);
|
|
7542
9158
|
if (nl !== -1 && nl < edit.end) {
|
|
7543
9159
|
origOffset = nl + 1;
|
|
7544
|
-
|
|
9160
|
+
pending2 = true;
|
|
7545
9161
|
} else {
|
|
7546
|
-
|
|
9162
|
+
pending2 = false;
|
|
7547
9163
|
}
|
|
7548
9164
|
continue;
|
|
7549
9165
|
}
|
|
7550
|
-
if (
|
|
9166
|
+
if (pending2) {
|
|
7551
9167
|
mark2(origOffset);
|
|
7552
|
-
|
|
9168
|
+
pending2 = false;
|
|
7553
9169
|
}
|
|
7554
9170
|
col2++;
|
|
7555
9171
|
}
|
|
@@ -7892,7 +9508,7 @@ function collectImports(code2, tokens) {
|
|
|
7892
9508
|
if (!next) return null;
|
|
7893
9509
|
if (next.type === "punct" && (next.value === "(" || next.value === ".")) continue;
|
|
7894
9510
|
let j = i2 + 1;
|
|
7895
|
-
const
|
|
9511
|
+
const bindings2 = [];
|
|
7896
9512
|
let typeOnly = false;
|
|
7897
9513
|
if (next.type === "string") {
|
|
7898
9514
|
const source3 = stringTokenValue(code2, next);
|
|
@@ -7900,7 +9516,7 @@ function collectImports(code2, tokens) {
|
|
|
7900
9516
|
let end2 = next.end;
|
|
7901
9517
|
const semi = tokens[j + 1];
|
|
7902
9518
|
if (semi && semi.type === "punct" && semi.value === ";") end2 = semi.end;
|
|
7903
|
-
decls.push({ source: source3, bindings, start: tok.start, end: end2 });
|
|
9519
|
+
decls.push({ source: source3, bindings: bindings2, start: tok.start, end: end2 });
|
|
7904
9520
|
continue;
|
|
7905
9521
|
}
|
|
7906
9522
|
const at = (k) => tokens[k];
|
|
@@ -7917,13 +9533,13 @@ function collectImports(code2, tokens) {
|
|
|
7917
9533
|
j++;
|
|
7918
9534
|
}
|
|
7919
9535
|
if (isIdent(j) && !isIdent(j, "from")) {
|
|
7920
|
-
|
|
9536
|
+
bindings2.push({ imported: "default", local: at(j).value });
|
|
7921
9537
|
j++;
|
|
7922
9538
|
if (isPunct(j, ",")) j++;
|
|
7923
9539
|
}
|
|
7924
9540
|
if (isPunct(j, "*")) {
|
|
7925
9541
|
if (!isIdent(j + 1, "as") || !isIdent(j + 2)) return null;
|
|
7926
|
-
|
|
9542
|
+
bindings2.push({ imported: "*", local: at(j + 2).value });
|
|
7927
9543
|
j += 3;
|
|
7928
9544
|
} else if (isPunct(j, "{")) {
|
|
7929
9545
|
j++;
|
|
@@ -7947,7 +9563,7 @@ function collectImports(code2, tokens) {
|
|
|
7947
9563
|
local = at(j + 1).value;
|
|
7948
9564
|
j += 2;
|
|
7949
9565
|
}
|
|
7950
|
-
if (!specTypeOnly)
|
|
9566
|
+
if (!specTypeOnly) bindings2.push({ imported, local });
|
|
7951
9567
|
if (isPunct(j, ",")) j++;
|
|
7952
9568
|
else if (!isPunct(j, "}")) return null;
|
|
7953
9569
|
}
|
|
@@ -7969,7 +9585,7 @@ function collectImports(code2, tokens) {
|
|
|
7969
9585
|
j = k + 1;
|
|
7970
9586
|
}
|
|
7971
9587
|
if (isPunct(j, ";")) end = at(j).end;
|
|
7972
|
-
decls.push({ source: source2, bindings: typeOnly ? [] :
|
|
9588
|
+
decls.push({ source: source2, bindings: typeOnly ? [] : bindings2, start: tok.start, end });
|
|
7973
9589
|
i2 = j;
|
|
7974
9590
|
}
|
|
7975
9591
|
return decls;
|