sibujs 3.4.0 → 4.0.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/LICENSE +21 -21
- package/README.md +118 -15
- package/dist/browser.cjs +410 -101
- package/dist/browser.d.cts +50 -5
- package/dist/browser.d.ts +50 -5
- package/dist/browser.js +8 -6
- package/dist/build.cjs +777 -385
- package/dist/build.js +15 -15
- package/dist/cdn.global.js +11 -7
- package/dist/{chunk-JCO7AHNU.js → chunk-3EKJK5FZ.js} +73 -34
- package/dist/chunk-4MFZMLUU.js +147 -0
- package/dist/chunk-52XFPGSN.js +123 -0
- package/dist/chunk-5INI7D2L.js +194 -0
- package/dist/{chunk-OAVXAFAY.js → chunk-6LG2T7LO.js} +5 -5
- package/dist/{chunk-OOUQUCNN.js → chunk-ACBT6UZS.js} +57 -22
- package/dist/{chunk-F7HW2NI5.js → chunk-AW6HPJ3L.js} +1 -1
- package/dist/chunk-DHDZ7IVN.js +109 -0
- package/dist/{chunk-JNGGM2XE.js → chunk-DQVUBVNX.js} +16 -25
- package/dist/{chunk-AXFWGY32.js → chunk-DR7H6UGM.js} +232 -67
- package/dist/{chunk-WSGLJYFI.js → chunk-E62UADKL.js} +9 -3
- package/dist/{chunk-3Z2NGWQI.js → chunk-ES2GERY2.js} +1 -1
- package/dist/{chunk-S3V6ZXPI.js → chunk-EWEE7NBF.js} +115 -41
- package/dist/{chunk-3DVGCW7O.js → chunk-F64ZPCFE.js} +8 -8
- package/dist/{chunk-APFRCIRI.js → chunk-GCSGGA3Q.js} +295 -198
- package/dist/{chunk-EX77FXTT.js → chunk-HYCCIYNS.js} +228 -51
- package/dist/{chunk-ELXMRSVN.js → chunk-NF3LYCQH.js} +259 -124
- package/dist/chunk-O3QQ3XOL.js +61 -0
- package/dist/{chunk-BUKYCWHX.js → chunk-PBQEW5VW.js} +14 -10
- package/dist/{chunk-H5FI5WDP.js → chunk-RRIDJQ5C.js} +3 -3
- package/dist/{chunk-S3NFJO6L.js → chunk-TIRZCERI.js} +36 -5
- package/dist/{chunk-ODXVQ3CS.js → chunk-VFHIVEPF.js} +309 -188
- package/dist/chunk-VPP2FONR.js +142 -0
- package/dist/{chunk-KZBEVFXZ.js → chunk-W55YHPEP.js} +5 -3
- package/dist/{chunk-FKQG7FTY.js → chunk-WN6WDFCB.js} +4 -4
- package/dist/{chunk-CEBWDD63.js → chunk-WOOMUJFT.js} +228 -86
- package/dist/{chunk-ITWCTZYH.js → chunk-Z2CE42DB.js} +19 -25
- package/dist/{contracts-ey_Qh8ef.d.cts → contracts-Hg6ITAEF.d.cts} +6 -6
- package/dist/{contracts-ey_Qh8ef.d.ts → contracts-Hg6ITAEF.d.ts} +6 -6
- package/dist/{customElement-CPfIrbvg.d.ts → customElement-CKLoO63w.d.cts} +73 -11
- package/dist/{customElement-CPfIrbvg.d.cts → customElement-CKLoO63w.d.ts} +73 -11
- package/dist/data.cjs +483 -205
- package/dist/data.d.cts +139 -7
- package/dist/data.d.ts +139 -7
- package/dist/data.js +9 -9
- package/dist/devtools.cjs +222 -87
- package/dist/devtools.js +8 -8
- package/dist/dispose-4FZ6OFXR.js +19 -0
- package/dist/ecosystem.cjs +419 -175
- package/dist/ecosystem.js +11 -11
- package/dist/extras.cjs +1981 -765
- package/dist/extras.d.cts +7 -7
- package/dist/extras.d.ts +7 -7
- package/dist/extras.js +29 -26
- package/dist/index.cjs +784 -385
- package/dist/index.d.cts +299 -28
- package/dist/index.d.ts +299 -28
- package/dist/index.js +33 -18
- package/dist/motion.cjs +180 -50
- package/dist/motion.d.cts +26 -0
- package/dist/motion.d.ts +26 -0
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +437 -170
- package/dist/patterns.d.cts +60 -13
- package/dist/patterns.d.ts +60 -13
- package/dist/patterns.js +7 -7
- package/dist/performance.cjs +333 -148
- package/dist/performance.d.cts +55 -7
- package/dist/performance.d.ts +55 -7
- package/dist/performance.js +9 -9
- package/dist/plugins.cjs +1374 -576
- package/dist/plugins.d.cts +227 -9
- package/dist/plugins.d.ts +227 -9
- package/dist/plugins.js +613 -321
- package/dist/{ssr-D62yFwuw.d.cts → ssr-BiPRdZ6n.d.cts} +44 -15
- package/dist/{ssr-D62yFwuw.d.ts → ssr-BiPRdZ6n.d.ts} +44 -15
- package/dist/{ssr-2PPULEK2.js → ssr-JFP5535P.js} +5 -4
- package/dist/ssr.cjs +1104 -443
- package/dist/ssr.d.cts +230 -20
- package/dist/ssr.d.ts +230 -20
- package/dist/ssr.js +15 -12
- package/dist/{startup-0Qv6aosO.d.cts → startup-BMpaiMhP.d.cts} +1 -1
- package/dist/{startup-0Qv6aosO.d.ts → startup-BMpaiMhP.d.ts} +1 -1
- package/dist/testing.cjs +205 -63
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +8 -10
- package/dist/ui.cjs +640 -199
- package/dist/ui.d.cts +2 -2
- package/dist/ui.d.ts +2 -2
- package/dist/ui.js +10 -10
- package/dist/widgets.cjs +207 -82
- package/dist/widgets.js +9 -9
- package/package.json +12 -7
- package/dist/chunk-5VGSK6D2.js +0 -80
- package/dist/chunk-COY6PUD2.js +0 -34
- package/dist/chunk-K35BAR4P.js +0 -96
- package/dist/chunk-L3GAGWCC.js +0 -111
- package/dist/chunk-RT3IYFN2.js +0 -38
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isSSR
|
|
3
|
+
} from "./chunk-TIRZCERI.js";
|
|
4
|
+
import {
|
|
5
|
+
signal
|
|
6
|
+
} from "./chunk-W55YHPEP.js";
|
|
7
|
+
import {
|
|
8
|
+
devWarn,
|
|
9
|
+
isDev
|
|
10
|
+
} from "./chunk-VPP2FONR.js";
|
|
11
|
+
|
|
12
|
+
// src/core/rendering/context.ts
|
|
13
|
+
var _isDev = isDev();
|
|
14
|
+
function context(defaultValue) {
|
|
15
|
+
const [getValue, setValue] = signal(defaultValue);
|
|
16
|
+
const warnIfSSR = (method) => {
|
|
17
|
+
if (!_isDev || !isSSR()) return;
|
|
18
|
+
devWarn(
|
|
19
|
+
`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.`
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
const ctx = {
|
|
23
|
+
provide(value) {
|
|
24
|
+
warnIfSSR("provide");
|
|
25
|
+
const previous = getValue();
|
|
26
|
+
setValue(value);
|
|
27
|
+
return () => setValue(previous);
|
|
28
|
+
},
|
|
29
|
+
use() {
|
|
30
|
+
return getValue;
|
|
31
|
+
},
|
|
32
|
+
get() {
|
|
33
|
+
return getValue();
|
|
34
|
+
},
|
|
35
|
+
set(value) {
|
|
36
|
+
warnIfSSR("set");
|
|
37
|
+
setValue(value);
|
|
38
|
+
},
|
|
39
|
+
withContext(value, fn) {
|
|
40
|
+
warnIfSSR("withContext");
|
|
41
|
+
const previous = getValue();
|
|
42
|
+
setValue(value);
|
|
43
|
+
try {
|
|
44
|
+
const result = fn();
|
|
45
|
+
if (_isDev && result !== null && typeof result?.then === "function") {
|
|
46
|
+
devWarn(
|
|
47
|
+
"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."
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
} finally {
|
|
52
|
+
setValue(previous);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return ctx;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
context
|
|
61
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSSR
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TIRZCERI.js";
|
|
4
4
|
import {
|
|
5
5
|
cleanup,
|
|
6
6
|
retrack,
|
|
7
7
|
untracked
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ACBT6UZS.js";
|
|
9
9
|
import {
|
|
10
|
-
devAssert
|
|
11
|
-
|
|
10
|
+
devAssert,
|
|
11
|
+
reportError
|
|
12
|
+
} from "./chunk-VPP2FONR.js";
|
|
12
13
|
|
|
13
14
|
// src/core/signals/effect.ts
|
|
14
15
|
var _g = globalThis;
|
|
@@ -37,7 +38,7 @@ function flushUserCleanups(ctx) {
|
|
|
37
38
|
try {
|
|
38
39
|
list[i]();
|
|
39
40
|
} catch (err) {
|
|
40
|
-
|
|
41
|
+
reportError(err, { phase: "cleanup" });
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -50,11 +51,12 @@ function drainReruns(ctx) {
|
|
|
50
51
|
} while (ctx.rerunPending && ++reruns <= MAX_RERUNS);
|
|
51
52
|
if (ctx.rerunPending) {
|
|
52
53
|
ctx.rerunPending = false;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
`
|
|
56
|
-
)
|
|
57
|
-
|
|
54
|
+
reportError(
|
|
55
|
+
new Error(
|
|
56
|
+
`effect re-requested itself ${MAX_RERUNS}+ times \u2014 likely a write-reads-self cycle. Breaking to prevent infinite loop.`
|
|
57
|
+
),
|
|
58
|
+
{ phase: "effect" }
|
|
59
|
+
);
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
function disposeEffect(ctx) {
|
|
@@ -131,6 +133,8 @@ function effect(effectFn, options) {
|
|
|
131
133
|
sub.depsTail = null;
|
|
132
134
|
sub._epoch = 0;
|
|
133
135
|
sub._structDirty = false;
|
|
136
|
+
sub._hasComputedDep = false;
|
|
137
|
+
sub._errorPhase = "effect";
|
|
134
138
|
sub._runEpoch = 0;
|
|
135
139
|
sub._runs = 0;
|
|
136
140
|
ctx.subscriber = sub;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSSR
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TIRZCERI.js";
|
|
4
4
|
import {
|
|
5
5
|
resumeTracking,
|
|
6
6
|
suspendTracking,
|
|
7
7
|
track
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ACBT6UZS.js";
|
|
9
9
|
import {
|
|
10
10
|
devAssert
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-VPP2FONR.js";
|
|
12
12
|
|
|
13
13
|
// src/core/signals/watch.ts
|
|
14
14
|
function watch(getter, callback) {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require,
|
|
3
|
+
devWarn
|
|
4
|
+
} from "./chunk-VPP2FONR.js";
|
|
5
|
+
|
|
1
6
|
// src/core/ssr-context.ts
|
|
2
7
|
var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
|
|
3
8
|
function detectSSRShared() {
|
|
@@ -8,20 +13,35 @@ function detectSSRShared() {
|
|
|
8
13
|
const getBuiltin = process.getBuiltinModule;
|
|
9
14
|
if (typeof getBuiltin === "function") {
|
|
10
15
|
mod = getBuiltin("node:async_hooks");
|
|
11
|
-
} else {
|
|
12
|
-
|
|
13
|
-
if (req) mod = req("node:async_hooks");
|
|
16
|
+
} else if (typeof __require === "function") {
|
|
17
|
+
mod = __require("async_hooks");
|
|
14
18
|
}
|
|
15
19
|
if (mod) detected = new mod.AsyncLocalStorage();
|
|
16
20
|
}
|
|
17
21
|
} catch {
|
|
18
22
|
detected = null;
|
|
19
23
|
}
|
|
20
|
-
return {
|
|
24
|
+
return {
|
|
25
|
+
als: detected,
|
|
26
|
+
fallbackStore: { ssr: false, suspenseIdCounter: 0, locale: void 0 },
|
|
27
|
+
fallbackDepth: 0
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
|
|
23
31
|
var als = _shared.als;
|
|
24
32
|
var fallbackStore = _shared.fallbackStore;
|
|
33
|
+
_shared.fallbackDepth ?? (_shared.fallbackDepth = 0);
|
|
34
|
+
var _alsWarned = false;
|
|
35
|
+
function warnMissingAsyncLocalStorage() {
|
|
36
|
+
if (_alsWarned || als) return;
|
|
37
|
+
const isNode = typeof process !== "undefined" && !!process.versions?.node;
|
|
38
|
+
if (!isNode) return;
|
|
39
|
+
_alsWarned = true;
|
|
40
|
+
const version = process.versions.node;
|
|
41
|
+
devWarn(
|
|
42
|
+
`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.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
25
45
|
function getSSRStore() {
|
|
26
46
|
if (als) {
|
|
27
47
|
const s = als.getStore();
|
|
@@ -29,6 +49,10 @@ function getSSRStore() {
|
|
|
29
49
|
}
|
|
30
50
|
return fallbackStore;
|
|
31
51
|
}
|
|
52
|
+
function getRequestStore() {
|
|
53
|
+
if (als) return als.getStore() ?? null;
|
|
54
|
+
return _shared.fallbackDepth > 0 ? fallbackStore : null;
|
|
55
|
+
}
|
|
32
56
|
function isSSR() {
|
|
33
57
|
return getSSRStore().ssr;
|
|
34
58
|
}
|
|
@@ -50,19 +74,25 @@ function disableSSR() {
|
|
|
50
74
|
getSSRStore().ssr = false;
|
|
51
75
|
}
|
|
52
76
|
function runInSSRContext(fn) {
|
|
53
|
-
const store = { ssr: true, suspenseIdCounter: 0 };
|
|
77
|
+
const store = { ssr: true, suspenseIdCounter: 0, locale: void 0 };
|
|
54
78
|
if (als) {
|
|
55
79
|
return als.run(store, fn);
|
|
56
80
|
}
|
|
81
|
+
warnMissingAsyncLocalStorage();
|
|
57
82
|
const prevSSR = fallbackStore.ssr;
|
|
58
83
|
const prevCounter = fallbackStore.suspenseIdCounter;
|
|
84
|
+
const prevLocale = fallbackStore.locale;
|
|
59
85
|
fallbackStore.ssr = true;
|
|
60
86
|
fallbackStore.suspenseIdCounter = 0;
|
|
87
|
+
fallbackStore.locale = void 0;
|
|
88
|
+
_shared.fallbackDepth++;
|
|
61
89
|
try {
|
|
62
90
|
return fn();
|
|
63
91
|
} finally {
|
|
92
|
+
_shared.fallbackDepth--;
|
|
64
93
|
fallbackStore.ssr = prevSSR;
|
|
65
94
|
fallbackStore.suspenseIdCounter = prevCounter;
|
|
95
|
+
fallbackStore.locale = prevLocale;
|
|
66
96
|
}
|
|
67
97
|
}
|
|
68
98
|
function withSSR(fn) {
|
|
@@ -78,6 +108,7 @@ function withSSR(fn) {
|
|
|
78
108
|
|
|
79
109
|
export {
|
|
80
110
|
getSSRStore,
|
|
111
|
+
getRequestStore,
|
|
81
112
|
isSSR,
|
|
82
113
|
getRequestScopedCache,
|
|
83
114
|
enableSSR,
|