sibujs 4.13.0 → 4.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser.cjs +15 -2
- package/dist/browser.js +9 -7
- package/dist/build.cjs +880 -281
- package/dist/build.d.cts +68 -3
- package/dist/build.d.ts +68 -3
- package/dist/build.js +88 -30
- package/dist/cdn.dev.global.js +12 -12
- package/dist/cdn.full.dev.global.js +13 -13
- package/dist/cdn.full.global.js +12 -12
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-7K7W4AA5.js → chunk-2TTRW2TE.js} +6 -6
- package/dist/{chunk-J6FW5TV6.js → chunk-3HEX6QJQ.js} +5 -3
- package/dist/chunk-3HZOSMPX.js +90 -0
- package/dist/{chunk-GNSRXK34.js → chunk-4FJSAUKB.js} +11 -3
- package/dist/{chunk-IV74C2YX.js → chunk-4TQDTWWN.js} +6 -5
- package/dist/{chunk-L3QHS4O4.js → chunk-7ILEHTVX.js} +1 -1
- package/dist/{chunk-CK5F2IR5.js → chunk-A454RAEK.js} +4 -4
- package/dist/{chunk-BRRRVLHQ.js → chunk-AE32RGWX.js} +10 -6
- package/dist/{chunk-EXXSN3BW.js → chunk-B3HOT4TK.js} +1 -1
- package/dist/{chunk-F4W7WYXY.js → chunk-BKZ5N6NK.js} +8 -6
- package/dist/{chunk-MNEITZ27.js → chunk-BNXRWZZV.js} +49 -8
- package/dist/chunk-BOYKGGVD.js +2015 -0
- package/dist/{chunk-G6366I2A.js → chunk-CCKUNHVU.js} +2 -2
- package/dist/{chunk-346BYZL2.js → chunk-CJ7KS3DF.js} +16 -10
- package/dist/chunk-CNPT6NKV.js +1859 -0
- package/dist/{chunk-ENFRHCMK.js → chunk-F67F77IA.js} +2 -2
- package/dist/{chunk-TUCPL2HB.js → chunk-GIJ33UJZ.js} +1 -1
- package/dist/chunk-GVAMIU6K.js +195 -0
- package/dist/{chunk-HDKDBC6V.js → chunk-HQIAL7F2.js} +8 -6
- package/dist/{chunk-ZE5LF44R.js → chunk-JTFQ7IL4.js} +8 -8
- package/dist/{chunk-AM6DZLBM.js → chunk-LJMX4SQ7.js} +2 -2
- package/dist/{chunk-HVVRXRGO.js → chunk-MIRKTVH4.js} +7 -14
- package/dist/{chunk-YJ57VR6Y.js → chunk-N7A6FKWW.js} +5 -3
- package/dist/chunk-NT3ZYB5S.js +167 -0
- package/dist/{chunk-Z3EZX6DZ.js → chunk-QS6GMWDD.js} +151 -86
- package/dist/chunk-R5U7XKVJ.js +16 -0
- package/dist/{chunk-3C56VNCK.js → chunk-RVR5NPFL.js} +3 -3
- package/dist/{chunk-F2UWOZ6J.js → chunk-RVWJGWCL.js} +2 -2
- package/dist/{chunk-NYNYSPK7.js → chunk-S37PZD6I.js} +30 -45
- package/dist/{chunk-QV5WEOFD.js → chunk-SVULV7O4.js} +119 -26
- package/dist/{chunk-C2FAO6VQ.js → chunk-TLS4NVIB.js} +5 -5
- package/dist/{chunk-M25RIH6Y.js → chunk-UUIKJJIK.js} +10 -8
- package/dist/chunk-UYTYNCMZ.js +199 -0
- package/dist/chunk-VM2U5LEL.js +2596 -0
- package/dist/{chunk-24L5RDPS.js → chunk-Y4LUM2XS.js} +8 -6
- package/dist/data.cjs +265 -35
- package/dist/data.d.cts +31 -1
- package/dist/data.d.ts +31 -1
- package/dist/data.js +16 -10
- package/dist/devtools.cjs +15 -2
- package/dist/devtools.js +9 -7
- package/dist/{dispose-GEIG2KOF.js → dispose-EIHHHDC7.js} +3 -1
- package/dist/ecosystem.cjs +62 -23
- package/dist/ecosystem.js +14 -12
- package/dist/extras.cjs +3520 -270
- package/dist/extras.d.cts +3 -3
- package/dist/extras.d.ts +3 -3
- package/dist/extras.js +39 -29
- package/dist/index.cjs +442 -253
- package/dist/index.d.cts +93 -283
- package/dist/index.d.ts +93 -283
- package/dist/index.js +26 -16
- package/dist/motion.cjs +12 -1
- package/dist/motion.js +6 -4
- package/dist/patterns.cjs +15 -2
- package/dist/patterns.js +10 -8
- package/dist/performance.cjs +36 -2
- package/dist/performance.d.cts +2 -2
- package/dist/performance.d.ts +2 -2
- package/dist/performance.js +14 -10
- package/dist/plugins.cjs +5225 -1807
- package/dist/plugins.d.cts +8 -834
- package/dist/plugins.d.ts +8 -834
- package/dist/plugins.js +64 -2329
- package/dist/prerenderServer-MXJEVWA3.js +350 -0
- package/dist/renderRoute-DP20XwMS.d.cts +86 -0
- package/dist/renderRoute-fxgsm2Ir.d.ts +86 -0
- package/dist/routeHead-CE9SV-cH.d.cts +995 -0
- package/dist/routeHead-DzVxPviY.d.ts +995 -0
- package/dist/{routeMiddleware-B1sp4P7a.d.ts → routeMiddleware-BySbueoE.d.ts} +0 -25
- package/dist/{routeMiddleware-CedQTsLK.d.cts → routeMiddleware-CijZD5eW.d.cts} +0 -25
- package/dist/ssr-JpGpHnpC.d.cts +841 -0
- package/dist/ssr-JpGpHnpC.d.ts +841 -0
- package/dist/{ssr-VBM6J5SJ.js → ssr-NECEU4X4.js} +15 -6
- package/dist/ssr-dom.cjs +1862 -0
- package/dist/ssr-dom.d.cts +341 -0
- package/dist/ssr-dom.d.ts +341 -0
- package/dist/ssr-dom.js +19 -0
- package/dist/ssr.cjs +7630 -2064
- package/dist/ssr.d.cts +63 -5
- package/dist/ssr.d.ts +63 -5
- package/dist/ssr.js +136 -14
- package/dist/testing.cjs +6543 -87
- package/dist/testing.d.cts +80 -1
- package/dist/testing.d.ts +80 -1
- package/dist/testing.js +117 -4
- package/dist/ui.cjs +36 -2
- package/dist/ui.js +17 -14
- package/dist/widgets.cjs +14 -1
- package/dist/widgets.js +11 -9
- package/package.json +9 -2
- package/dist/chunk-2F4PSJ5Z.js +0 -765
- package/dist/chunk-7XHATCIH.js +0 -121
- package/dist/chunk-B36ADEIR.js +0 -21
- package/dist/ssr-Db0Sgdu3.d.cts +0 -245
- package/dist/ssr-Db0Sgdu3.d.ts +0 -245
|
@@ -135,67 +135,72 @@ import {
|
|
|
135
135
|
use,
|
|
136
136
|
var_,
|
|
137
137
|
video
|
|
138
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-7ILEHTVX.js";
|
|
139
139
|
import {
|
|
140
140
|
trustHTML
|
|
141
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-BOYKGGVD.js";
|
|
142
142
|
import {
|
|
143
143
|
watch
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-RVR5NPFL.js";
|
|
145
145
|
import {
|
|
146
146
|
__resetIdCounter,
|
|
147
147
|
createId,
|
|
148
148
|
domBinding
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-CCKUNHVU.js";
|
|
150
150
|
import {
|
|
151
151
|
SVG_NS,
|
|
152
152
|
bindChildNode,
|
|
153
153
|
captureFocusWithin,
|
|
154
154
|
restoreFocusWithin,
|
|
155
155
|
tagFactory
|
|
156
|
-
} from "./chunk-
|
|
156
|
+
} from "./chunk-CJ7KS3DF.js";
|
|
157
157
|
import {
|
|
158
158
|
bindAttribute,
|
|
159
159
|
bindDynamic,
|
|
160
160
|
requireDocument,
|
|
161
161
|
setSafeAttribute,
|
|
162
162
|
setTrustedAttribute
|
|
163
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-HQIAL7F2.js";
|
|
164
164
|
import {
|
|
165
165
|
isCodeTextElement
|
|
166
|
-
} from "./chunk-
|
|
166
|
+
} from "./chunk-RVWJGWCL.js";
|
|
167
167
|
import {
|
|
168
168
|
derived
|
|
169
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-N7A6FKWW.js";
|
|
170
170
|
import {
|
|
171
171
|
globalSingleton
|
|
172
172
|
} from "./chunk-7ZHH77QA.js";
|
|
173
173
|
import {
|
|
174
174
|
effect,
|
|
175
175
|
on
|
|
176
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-AE32RGWX.js";
|
|
177
177
|
import {
|
|
178
|
+
currentBoundary,
|
|
178
179
|
disableSSR,
|
|
179
180
|
enableSSR,
|
|
180
181
|
getRequestScopedCache,
|
|
181
182
|
getSSRStore,
|
|
183
|
+
isClient,
|
|
182
184
|
isSSR,
|
|
185
|
+
isServer,
|
|
186
|
+
openBoundary,
|
|
183
187
|
runInSSRContext,
|
|
188
|
+
trackPending,
|
|
184
189
|
withSSR
|
|
185
|
-
} from "./chunk-
|
|
190
|
+
} from "./chunk-UYTYNCMZ.js";
|
|
186
191
|
import {
|
|
187
192
|
adoptThenable
|
|
188
193
|
} from "./chunk-5HZXGZ6T.js";
|
|
189
194
|
import {
|
|
190
195
|
batch,
|
|
196
|
+
emitDevtools,
|
|
191
197
|
enqueueBatchedSignal,
|
|
192
198
|
external,
|
|
193
199
|
isBatching,
|
|
194
200
|
signal
|
|
195
|
-
} from "./chunk-
|
|
201
|
+
} from "./chunk-4FJSAUKB.js";
|
|
196
202
|
import {
|
|
197
203
|
bindOwnerScope,
|
|
198
|
-
emitDevtools,
|
|
199
204
|
getOwnerScope,
|
|
200
205
|
notifySubscribers,
|
|
201
206
|
reactiveBinding,
|
|
@@ -208,18 +213,12 @@ import {
|
|
|
208
213
|
suspendTracking,
|
|
209
214
|
track,
|
|
210
215
|
untracked
|
|
211
|
-
} from "./chunk-
|
|
216
|
+
} from "./chunk-MIRKTVH4.js";
|
|
212
217
|
import {
|
|
213
|
-
DEV,
|
|
214
218
|
MAX_DRAIN_TEARDOWNS,
|
|
215
|
-
__export,
|
|
216
219
|
checkLeaks,
|
|
217
|
-
devAssert,
|
|
218
|
-
devWarn,
|
|
219
|
-
devWarnLazy,
|
|
220
220
|
dispose,
|
|
221
221
|
getRuntimeErrorHandler,
|
|
222
|
-
isDev,
|
|
223
222
|
normalizeError,
|
|
224
223
|
registerDisposer,
|
|
225
224
|
replaceChildrenSafely,
|
|
@@ -228,11 +227,29 @@ import {
|
|
|
228
227
|
setRuntimeErrorHandler,
|
|
229
228
|
unregisterDisposer,
|
|
230
229
|
withDisposerRollback
|
|
231
|
-
} from "./chunk-
|
|
230
|
+
} from "./chunk-S37PZD6I.js";
|
|
231
|
+
import {
|
|
232
|
+
DEV,
|
|
233
|
+
afterHydration,
|
|
234
|
+
captureScope,
|
|
235
|
+
createScopedElement,
|
|
236
|
+
devAssert,
|
|
237
|
+
devWarn,
|
|
238
|
+
devWarnLazy,
|
|
239
|
+
inAdoptScope,
|
|
240
|
+
inScope,
|
|
241
|
+
isDev,
|
|
242
|
+
isHydrating,
|
|
243
|
+
keyedScope
|
|
244
|
+
} from "./chunk-NT3ZYB5S.js";
|
|
245
|
+
import {
|
|
246
|
+
__export
|
|
247
|
+
} from "./chunk-R5U7XKVJ.js";
|
|
232
248
|
|
|
233
249
|
// index.ts
|
|
234
250
|
var index_exports = {};
|
|
235
251
|
__export(index_exports, {
|
|
252
|
+
ClientOnly: () => ClientOnly,
|
|
236
253
|
DynamicComponent: () => DynamicComponent,
|
|
237
254
|
ErrorBoundary: () => ErrorBoundary,
|
|
238
255
|
ErrorDisplay: () => ErrorDisplay,
|
|
@@ -338,7 +355,9 @@ __export(index_exports, {
|
|
|
338
355
|
input: () => input,
|
|
339
356
|
ins: () => ins,
|
|
340
357
|
isBatching: () => isBatching,
|
|
358
|
+
isClient: () => isClient,
|
|
341
359
|
isSSR: () => isSSR,
|
|
360
|
+
isServer: () => isServer,
|
|
342
361
|
kbd: () => kbd,
|
|
343
362
|
label: () => label,
|
|
344
363
|
lazy: () => lazy,
|
|
@@ -487,18 +506,28 @@ function takePendingError(node) {
|
|
|
487
506
|
function lazy(importFn) {
|
|
488
507
|
let cached = null;
|
|
489
508
|
return function LazyComponent() {
|
|
490
|
-
if (cached) {
|
|
509
|
+
if (cached && !inAdoptScope()) {
|
|
491
510
|
return cached();
|
|
492
511
|
}
|
|
493
512
|
const container = div({ class: "sibu-lazy" });
|
|
513
|
+
const scope = captureScope();
|
|
514
|
+
const boundary = currentBoundary();
|
|
494
515
|
let disposed = false;
|
|
495
|
-
|
|
516
|
+
const loading = inScope(null, () => span("sibu-lazy-loading", "Loading..."));
|
|
517
|
+
if (cached) {
|
|
518
|
+
const loaded = cached;
|
|
519
|
+
replaceChildrenSafely(container, inScope(scope, () => loaded()));
|
|
520
|
+
return container;
|
|
521
|
+
}
|
|
522
|
+
trackPending(importFn(), "lazy").then(
|
|
496
523
|
// The component renders after the import resolves, in the owner scope
|
|
497
524
|
// of whoever rendered the placeholder.
|
|
498
525
|
bindOwnerScope((mod) => {
|
|
499
526
|
if (disposed) return;
|
|
500
527
|
cached = mod.default;
|
|
501
|
-
const
|
|
528
|
+
const component = cached;
|
|
529
|
+
const build = () => inScope(scope, () => component());
|
|
530
|
+
const rendered = boundary ? boundary.enter(build) : build();
|
|
502
531
|
replaceChildrenSafely(container, rendered);
|
|
503
532
|
})
|
|
504
533
|
).catch((err) => {
|
|
@@ -510,7 +539,7 @@ function lazy(importFn) {
|
|
|
510
539
|
);
|
|
511
540
|
dispatchPropagate(container, errorObj);
|
|
512
541
|
});
|
|
513
|
-
container.appendChild(
|
|
542
|
+
if (!(isHydrating() && container.firstChild)) container.appendChild(loading);
|
|
514
543
|
registerDisposer(container, () => {
|
|
515
544
|
disposed = true;
|
|
516
545
|
});
|
|
@@ -519,8 +548,15 @@ function lazy(importFn) {
|
|
|
519
548
|
}
|
|
520
549
|
function Suspense({ nodes, fallback }) {
|
|
521
550
|
const container = div({ class: "sibu-suspense" });
|
|
522
|
-
const
|
|
523
|
-
container
|
|
551
|
+
const scope = captureScope();
|
|
552
|
+
const boundary = openBoundary(container);
|
|
553
|
+
const commit = (el) => {
|
|
554
|
+
replaceChildrenSafely(container, el);
|
|
555
|
+
boundary?.done();
|
|
556
|
+
};
|
|
557
|
+
const fallbackEl = inScope(null, fallback);
|
|
558
|
+
if (isHydrating() && container.firstChild) dispose(fallbackEl);
|
|
559
|
+
else container.appendChild(fallbackEl);
|
|
524
560
|
let suspenseDisposed = false;
|
|
525
561
|
let observer = null;
|
|
526
562
|
let childEl = null;
|
|
@@ -535,11 +571,11 @@ function Suspense({ nodes, fallback }) {
|
|
|
535
571
|
const renderContent = bindOwnerScope(() => {
|
|
536
572
|
if (suspenseDisposed) return;
|
|
537
573
|
try {
|
|
538
|
-
const el = nodes();
|
|
574
|
+
const el = boundary ? boundary.enter(() => inScope(scope, nodes)) : inScope(scope, nodes);
|
|
539
575
|
childEl = el;
|
|
540
576
|
if (el.classList.contains("sibu-lazy")) {
|
|
541
577
|
if (!el.querySelector(".sibu-lazy-loading")) {
|
|
542
|
-
|
|
578
|
+
commit(el);
|
|
543
579
|
return;
|
|
544
580
|
}
|
|
545
581
|
observer = new MutationObserver(() => {
|
|
@@ -548,12 +584,12 @@ function Suspense({ nodes, fallback }) {
|
|
|
548
584
|
if (!loading) {
|
|
549
585
|
observer?.disconnect();
|
|
550
586
|
observer = null;
|
|
551
|
-
|
|
587
|
+
commit(el);
|
|
552
588
|
}
|
|
553
589
|
});
|
|
554
590
|
observer.observe(el, { childList: true, subtree: true });
|
|
555
591
|
} else {
|
|
556
|
-
|
|
592
|
+
commit(el);
|
|
557
593
|
}
|
|
558
594
|
} catch (err) {
|
|
559
595
|
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
@@ -743,7 +779,7 @@ function registerUnmountWatcher(element, cb) {
|
|
|
743
779
|
};
|
|
744
780
|
}
|
|
745
781
|
function onMount(callback, element) {
|
|
746
|
-
if (typeof document === "undefined") return;
|
|
782
|
+
if (typeof document === "undefined" || isSSR()) return;
|
|
747
783
|
const scope = getOwnerScope();
|
|
748
784
|
callback = pinScope(scope, callback);
|
|
749
785
|
if (element) {
|
|
@@ -778,7 +814,7 @@ function onMount(callback, element) {
|
|
|
778
814
|
}
|
|
779
815
|
}
|
|
780
816
|
function onUnmount(callback, element) {
|
|
781
|
-
if (typeof document === "undefined") return;
|
|
817
|
+
if (typeof document === "undefined" || isSSR()) return;
|
|
782
818
|
watchUnmount(pinScope(getOwnerScope(), callback), element);
|
|
783
819
|
}
|
|
784
820
|
function watchUnmount(callback, element) {
|
|
@@ -1796,52 +1832,6 @@ function setGlobalErrorHandler(handler) {
|
|
|
1796
1832
|
globalErrorHandler = handler;
|
|
1797
1833
|
}
|
|
1798
1834
|
|
|
1799
|
-
// src/core/rendering/context.ts
|
|
1800
|
-
function context(defaultValue) {
|
|
1801
|
-
const [getValue, setValue] = signal(defaultValue);
|
|
1802
|
-
const warnIfSSR = (method) => {
|
|
1803
|
-
if (!DEV || !isSSR()) return;
|
|
1804
|
-
devWarn(
|
|
1805
|
-
`context.${method}() called during SSR. SibuJS context() is application-global \u2014 it is NOT isolated per request, so a concurrent request can observe this value. Do not use context() for request-specific SSR data; pass it explicitly or use request-scoped storage instead.`
|
|
1806
|
-
);
|
|
1807
|
-
};
|
|
1808
|
-
const ctx = {
|
|
1809
|
-
provide(value) {
|
|
1810
|
-
warnIfSSR("provide");
|
|
1811
|
-
const previous = getValue();
|
|
1812
|
-
setValue(value);
|
|
1813
|
-
return () => setValue(previous);
|
|
1814
|
-
},
|
|
1815
|
-
use() {
|
|
1816
|
-
return getValue;
|
|
1817
|
-
},
|
|
1818
|
-
get() {
|
|
1819
|
-
return getValue();
|
|
1820
|
-
},
|
|
1821
|
-
set(value) {
|
|
1822
|
-
warnIfSSR("set");
|
|
1823
|
-
setValue(value);
|
|
1824
|
-
},
|
|
1825
|
-
withContext(value, fn) {
|
|
1826
|
-
warnIfSSR("withContext");
|
|
1827
|
-
const previous = getValue();
|
|
1828
|
-
setValue(value);
|
|
1829
|
-
try {
|
|
1830
|
-
const result = fn();
|
|
1831
|
-
if (DEV && result !== null && typeof result?.then === "function") {
|
|
1832
|
-
devWarn(
|
|
1833
|
-
"context.withContext() received an async callback. Scoping is synchronous only \u2014 the previous value is restored as soon as the callback returns its promise, so anything after an `await` runs outside the scope."
|
|
1834
|
-
);
|
|
1835
|
-
}
|
|
1836
|
-
return result;
|
|
1837
|
-
} finally {
|
|
1838
|
-
setValue(previous);
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
};
|
|
1842
|
-
return ctx;
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
1835
|
// src/core/rendering/directives.ts
|
|
1846
1836
|
function show(condition, element) {
|
|
1847
1837
|
const resolved = typeof element === "function" ? element() : element;
|
|
@@ -1867,7 +1857,7 @@ function attachBranch(parent, anchor, branch, attachedOnce, where) {
|
|
|
1867
1857
|
() => `${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.`
|
|
1868
1858
|
);
|
|
1869
1859
|
}
|
|
1870
|
-
parent.insertBefore(node, anchor.nextSibling);
|
|
1860
|
+
if (anchor.nextSibling !== node) parent.insertBefore(node, anchor.nextSibling);
|
|
1871
1861
|
return { node, owned };
|
|
1872
1862
|
}
|
|
1873
1863
|
function releaseBranchNode(node, owned) {
|
|
@@ -1883,6 +1873,7 @@ function when(condition, thenBranch, elseBranch, options) {
|
|
|
1883
1873
|
const elseNode = elseBranch;
|
|
1884
1874
|
const focusPolicy = options?.focus;
|
|
1885
1875
|
const anchor = document.createComment("when");
|
|
1876
|
+
const scope = captureScope();
|
|
1886
1877
|
let currentNode = null;
|
|
1887
1878
|
let lastCondition;
|
|
1888
1879
|
let initialized = false;
|
|
@@ -1902,7 +1893,7 @@ function when(condition, thenBranch, elseBranch, options) {
|
|
|
1902
1893
|
currentNode = null;
|
|
1903
1894
|
}
|
|
1904
1895
|
const branch = show2 ? thenBranch : elseNode !== void 0 ? elseNode : null;
|
|
1905
|
-
const attached = untracked(() => attachBranch(parent, anchor, branch, attachedOnce, "when"));
|
|
1896
|
+
const attached = untracked(() => inScope(scope, () => attachBranch(parent, anchor, branch, attachedOnce, "when")));
|
|
1906
1897
|
currentNode = attached.node;
|
|
1907
1898
|
currentNodeOwned = attached.owned;
|
|
1908
1899
|
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "when", focusPolicy);
|
|
@@ -1933,6 +1924,7 @@ function match(value, cases, fallback, options) {
|
|
|
1933
1924
|
const fallbackNode = fallback;
|
|
1934
1925
|
const focusPolicy = options?.focus;
|
|
1935
1926
|
const anchor = document.createComment("match");
|
|
1927
|
+
const scope = captureScope();
|
|
1936
1928
|
let currentNode = null;
|
|
1937
1929
|
let lastKey;
|
|
1938
1930
|
let initialized = false;
|
|
@@ -1952,7 +1944,9 @@ function match(value, cases, fallback, options) {
|
|
|
1952
1944
|
currentNode = null;
|
|
1953
1945
|
}
|
|
1954
1946
|
const branch = Object.hasOwn(cases, key) ? cases[key] : fallbackNode;
|
|
1955
|
-
const attached = untracked(
|
|
1947
|
+
const attached = untracked(
|
|
1948
|
+
() => inScope(scope, () => attachBranch(parent, anchor, branch ?? null, attachedOnce, "match"))
|
|
1949
|
+
);
|
|
1956
1950
|
currentNode = attached.node;
|
|
1957
1951
|
currentNodeOwned = attached.owned;
|
|
1958
1952
|
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "match", focusPolicy);
|
|
@@ -1975,6 +1969,60 @@ function match(value, cases, fallback, options) {
|
|
|
1975
1969
|
return anchor;
|
|
1976
1970
|
}
|
|
1977
1971
|
|
|
1972
|
+
// src/core/rendering/clientOnly.ts
|
|
1973
|
+
function ClientOnly(content, options = {}) {
|
|
1974
|
+
const server = isServer();
|
|
1975
|
+
const [ready, setReady] = signal(!server && !isHydrating());
|
|
1976
|
+
if (!server && !ready()) afterHydration(() => setReady(true));
|
|
1977
|
+
return when(ready, content, options.fallback);
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
// src/core/rendering/context.ts
|
|
1981
|
+
function context(defaultValue) {
|
|
1982
|
+
const [getValue, setValue] = signal(defaultValue);
|
|
1983
|
+
const warnIfSSR = (method) => {
|
|
1984
|
+
if (!DEV || !isSSR()) return;
|
|
1985
|
+
devWarn(
|
|
1986
|
+
`context.${method}() called during SSR. SibuJS context() is application-global \u2014 it is NOT isolated per request, so a concurrent request can observe this value. Do not use context() for request-specific SSR data; pass it explicitly or use request-scoped storage instead.`
|
|
1987
|
+
);
|
|
1988
|
+
};
|
|
1989
|
+
const ctx = {
|
|
1990
|
+
provide(value) {
|
|
1991
|
+
warnIfSSR("provide");
|
|
1992
|
+
const previous = getValue();
|
|
1993
|
+
setValue(value);
|
|
1994
|
+
return () => setValue(previous);
|
|
1995
|
+
},
|
|
1996
|
+
use() {
|
|
1997
|
+
return getValue;
|
|
1998
|
+
},
|
|
1999
|
+
get() {
|
|
2000
|
+
return getValue();
|
|
2001
|
+
},
|
|
2002
|
+
set(value) {
|
|
2003
|
+
warnIfSSR("set");
|
|
2004
|
+
setValue(value);
|
|
2005
|
+
},
|
|
2006
|
+
withContext(value, fn) {
|
|
2007
|
+
warnIfSSR("withContext");
|
|
2008
|
+
const previous = getValue();
|
|
2009
|
+
setValue(value);
|
|
2010
|
+
try {
|
|
2011
|
+
const result = fn();
|
|
2012
|
+
if (DEV && result !== null && typeof result?.then === "function") {
|
|
2013
|
+
devWarn(
|
|
2014
|
+
"context.withContext() received an async callback. Scoping is synchronous only \u2014 the previous value is restored as soon as the callback returns its promise, so anything after an `await` runs outside the scope."
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
2017
|
+
return result;
|
|
2018
|
+
} finally {
|
|
2019
|
+
setValue(previous);
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
};
|
|
2023
|
+
return ctx;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
1978
2026
|
// src/core/rendering/dynamic.ts
|
|
1979
2027
|
var componentRegistry = globalSingleton(
|
|
1980
2028
|
/* @__PURE__ */ Symbol.for("sibujs.components.registry.v1"),
|
|
@@ -2070,6 +2118,7 @@ function each(getArray, render, options) {
|
|
|
2070
2118
|
);
|
|
2071
2119
|
requireDocument();
|
|
2072
2120
|
const anchor = document.createComment("each:anchor");
|
|
2121
|
+
const scope = captureScope();
|
|
2073
2122
|
const end = document.createComment("each:end");
|
|
2074
2123
|
const oldKeysBufA = [];
|
|
2075
2124
|
const oldKeysBufB = [];
|
|
@@ -2099,7 +2148,9 @@ function each(getArray, render, options) {
|
|
|
2099
2148
|
const parent = anchor.parentNode;
|
|
2100
2149
|
if (!parent) return;
|
|
2101
2150
|
if (!sentinelInserted) {
|
|
2102
|
-
|
|
2151
|
+
const serverEnd = isHydrating() ? findServerEnd(anchor) : null;
|
|
2152
|
+
if (serverEnd) parent.replaceChild(end, serverEnd);
|
|
2153
|
+
else parent.insertBefore(end, anchor.nextSibling);
|
|
2103
2154
|
sentinelInserted = true;
|
|
2104
2155
|
}
|
|
2105
2156
|
if (newKeysBuf.length < newLen) {
|
|
@@ -2140,7 +2191,7 @@ function each(getArray, render, options) {
|
|
|
2140
2191
|
try {
|
|
2141
2192
|
suspendTracking();
|
|
2142
2193
|
try {
|
|
2143
|
-
node = resolveNodeChild(render(itemGetter, indexGetter));
|
|
2194
|
+
node = resolveNodeChild(inScope(keyedScope(scope, key), () => render(itemGetter, indexGetter)));
|
|
2144
2195
|
} finally {
|
|
2145
2196
|
resumeTracking();
|
|
2146
2197
|
}
|
|
@@ -2274,6 +2325,19 @@ function each(getArray, render, options) {
|
|
|
2274
2325
|
}
|
|
2275
2326
|
return anchor;
|
|
2276
2327
|
}
|
|
2328
|
+
function findServerEnd(anchor) {
|
|
2329
|
+
let depth = 0;
|
|
2330
|
+
for (let n = anchor.nextSibling; n; n = n.nextSibling) {
|
|
2331
|
+
if (n.nodeType !== 8) continue;
|
|
2332
|
+
const data2 = n.data;
|
|
2333
|
+
if (data2 === "each:anchor") depth++;
|
|
2334
|
+
else if (data2 === "each:end") {
|
|
2335
|
+
if (depth === 0) return n;
|
|
2336
|
+
depth--;
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
return null;
|
|
2340
|
+
}
|
|
2277
2341
|
|
|
2278
2342
|
// src/core/rendering/fragment.ts
|
|
2279
2343
|
function Fragment(nodes) {
|
|
@@ -2555,7 +2619,7 @@ function parseTemplate(strings) {
|
|
|
2555
2619
|
return parseChildren();
|
|
2556
2620
|
}
|
|
2557
2621
|
function executeElement(tmpl, values) {
|
|
2558
|
-
const el = tmpl.svg ?
|
|
2622
|
+
const el = createScopedElement(tmpl.tag, tmpl.svg ? SVG_NS : void 0);
|
|
2559
2623
|
for (let i2 = 0; i2 < tmpl.attrs.length; i2++) {
|
|
2560
2624
|
const attr = tmpl.attrs[i2];
|
|
2561
2625
|
switch (attr.t) {
|
|
@@ -2648,7 +2712,7 @@ function renderTemplate(tmpl, values) {
|
|
|
2648
2712
|
if (tmpl.length === 1 && tmpl[0].t === 0) {
|
|
2649
2713
|
return executeElement(tmpl[0].el, values);
|
|
2650
2714
|
}
|
|
2651
|
-
const wrapper =
|
|
2715
|
+
const wrapper = createScopedElement("div");
|
|
2652
2716
|
for (let i2 = 0; i2 < tmpl.length; i2++) {
|
|
2653
2717
|
const child = tmpl[i2];
|
|
2654
2718
|
switch (child.t) {
|
|
@@ -3968,10 +4032,11 @@ export {
|
|
|
3968
4032
|
catchError,
|
|
3969
4033
|
catchErrorAsync,
|
|
3970
4034
|
setGlobalErrorHandler,
|
|
3971
|
-
context,
|
|
3972
4035
|
show,
|
|
3973
4036
|
when,
|
|
3974
4037
|
match,
|
|
4038
|
+
ClientOnly,
|
|
4039
|
+
context,
|
|
3975
4040
|
registerComponent,
|
|
3976
4041
|
unregisterComponent,
|
|
3977
4042
|
resolveComponent,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
__require,
|
|
15
|
+
__export
|
|
16
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSSR
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UYTYNCMZ.js";
|
|
4
4
|
import {
|
|
5
5
|
resumeTracking,
|
|
6
6
|
suspendTracking,
|
|
7
7
|
track
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MIRKTVH4.js";
|
|
9
9
|
import {
|
|
10
10
|
devAssert
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NT3ZYB5S.js";
|
|
12
12
|
|
|
13
13
|
// src/core/signals/watch.ts
|
|
14
14
|
function watch(getter, callback) {
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
isUrlAttribute,
|
|
6
6
|
sanitizeUrl,
|
|
7
7
|
stripControlChars
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-B3HOT4TK.js";
|
|
9
9
|
import {
|
|
10
10
|
DEV
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NT3ZYB5S.js";
|
|
12
12
|
|
|
13
13
|
// src/utils/metaRefresh.ts
|
|
14
14
|
function isAsciiWhitespace(ch) {
|
|
@@ -1,41 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// src/core/dev.ts
|
|
14
|
-
var DEV = typeof __SIBU_DEV__ !== "undefined" ? !!__SIBU_DEV__ : typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
|
|
15
|
-
// safe default: off in browser, on in test/dev Node
|
|
16
|
-
typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
|
|
17
|
-
);
|
|
18
|
-
function isDev() {
|
|
19
|
-
if (typeof globalThis.__SIBU_DEV__ !== "undefined") return !!globalThis.__SIBU_DEV__;
|
|
20
|
-
if (typeof __SIBU_DEV__ !== "undefined") return !!__SIBU_DEV__;
|
|
21
|
-
return typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
22
|
-
}
|
|
23
|
-
function devAssert(condition, message) {
|
|
24
|
-
if ((typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) && !condition) {
|
|
25
|
-
throw new Error(`[SibuJS] ${message}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function devWarnLazy(build) {
|
|
29
|
-
if (typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) {
|
|
30
|
-
const message = build();
|
|
31
|
-
if (message) console.warn(`[SibuJS] ${message}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function devWarn(message) {
|
|
35
|
-
if (typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : DEV) {
|
|
36
|
-
console.warn(`[SibuJS] ${message}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DEV,
|
|
3
|
+
devWarn,
|
|
4
|
+
isHydrating
|
|
5
|
+
} from "./chunk-NT3ZYB5S.js";
|
|
39
6
|
|
|
40
7
|
// src/core/errors.ts
|
|
41
8
|
var ERROR_STATE_KEY = /* @__PURE__ */ Symbol.for("sibujs.runtime-errors.v1");
|
|
@@ -110,10 +77,21 @@ function defaultReport(error, context) {
|
|
|
110
77
|
if (typeof console === "undefined") return;
|
|
111
78
|
console.error(`[SibuJS] Uncaught error during ${describe(context)}: ${error.message}`, error);
|
|
112
79
|
}
|
|
80
|
+
function requestErrorSink() {
|
|
81
|
+
const shared = globalThis[/* @__PURE__ */ Symbol.for("sibujs.ssr.v1")];
|
|
82
|
+
if (!shared) return void 0;
|
|
83
|
+
const store = shared.als ? shared.als.getStore() : shared.fallbackDepth > 0 ? shared.fallbackStore : void 0;
|
|
84
|
+
return store?.errors;
|
|
85
|
+
}
|
|
113
86
|
function reportError(error, context) {
|
|
114
87
|
const err = normalizeError(error);
|
|
115
88
|
untrackedRun(() => {
|
|
116
89
|
if (claimedByBoundary(err, context)) return;
|
|
90
|
+
const sink = requestErrorSink();
|
|
91
|
+
if (sink) {
|
|
92
|
+
sink.push({ error: err, context });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
117
95
|
const s = state();
|
|
118
96
|
const handler = s.handler;
|
|
119
97
|
if (handler && s.handlerDepth === 0) {
|
|
@@ -271,6 +249,20 @@ function disposeNodeOwn(node) {
|
|
|
271
249
|
}
|
|
272
250
|
}
|
|
273
251
|
function replaceChildrenSafely(parent, ...next) {
|
|
252
|
+
if (isHydrating() && next.length > 0 && next[0] === parent.firstChild) {
|
|
253
|
+
let ok = true;
|
|
254
|
+
for (let i = 1; i < next.length && ok; i++) ok = next[i - 1].nextSibling === next[i];
|
|
255
|
+
if (ok) {
|
|
256
|
+
let rest = next[next.length - 1].nextSibling;
|
|
257
|
+
while (rest) {
|
|
258
|
+
const following = rest.nextSibling;
|
|
259
|
+
dispose(rest);
|
|
260
|
+
parent.removeChild(rest);
|
|
261
|
+
rest = following;
|
|
262
|
+
}
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
274
266
|
for (let i = 0; i < next.length; i++) {
|
|
275
267
|
const node = next[i];
|
|
276
268
|
node.parentNode?.removeChild(node);
|
|
@@ -292,13 +284,6 @@ function checkLeaks(warnThreshold = 0) {
|
|
|
292
284
|
}
|
|
293
285
|
|
|
294
286
|
export {
|
|
295
|
-
__require,
|
|
296
|
-
__export,
|
|
297
|
-
DEV,
|
|
298
|
-
isDev,
|
|
299
|
-
devAssert,
|
|
300
|
-
devWarnLazy,
|
|
301
|
-
devWarn,
|
|
302
287
|
setRuntimeErrorHandler,
|
|
303
288
|
getRuntimeErrorHandler,
|
|
304
289
|
normalizeError,
|