sibujs 3.4.1 → 4.0.1
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 +784 -392
- package/dist/build.js +15 -15
- package/dist/cdn.global.js +11 -7
- package/dist/{chunk-PBZWJQNY.js → chunk-52ERIVFD.js} +8 -8
- package/dist/chunk-52XFPGSN.js +123 -0
- package/dist/{chunk-Y22QAKJX.js → chunk-5BVKQX2F.js} +4 -4
- package/dist/chunk-5INI7D2L.js +194 -0
- package/dist/{chunk-4I3M326N.js → chunk-AD5YSZAN.js} +19 -25
- package/dist/{chunk-F7HW2NI5.js → chunk-AW6HPJ3L.js} +1 -1
- package/dist/chunk-DHDZ7IVN.js +109 -0
- package/dist/{chunk-VQZDHAEK.js → chunk-E72G5JSK.js} +1 -1
- package/dist/{chunk-MPE75KOA.js → chunk-HPXTUPJD.js} +259 -124
- package/dist/{chunk-EX77FXTT.js → chunk-HYCCIYNS.js} +228 -51
- package/dist/{chunk-FWFEBYQ6.js → chunk-IKVUUE7D.js} +115 -41
- package/dist/{chunk-5MFF5EPT.js → chunk-J4WZMCIW.js} +5 -5
- package/dist/{chunk-BQLVTAUZ.js → chunk-JYXQCELN.js} +57 -22
- package/dist/{chunk-WEZ5SP7L.js → chunk-PHB3MCK4.js} +73 -34
- package/dist/chunk-PHRH66Y7.js +147 -0
- package/dist/{chunk-S2VW4NBA.js → chunk-PJDSI2K7.js} +295 -198
- package/dist/{chunk-QHPUFNHZ.js → chunk-PTLJ7NQX.js} +3 -3
- package/dist/{chunk-NXR2YFZB.js → chunk-QD4I7ZGZ.js} +24 -34
- package/dist/{chunk-S3NFJO6L.js → chunk-TIRZCERI.js} +36 -5
- package/dist/{chunk-7PNKW3FJ.js → chunk-TNEHT3NG.js} +232 -67
- package/dist/{chunk-335KJEN2.js → chunk-TVURNWDK.js} +5 -3
- package/dist/{chunk-CV7FAQ2R.js → chunk-UNAYBND2.js} +9 -3
- package/dist/chunk-VPP2FONR.js +142 -0
- package/dist/{chunk-X4JS367G.js → chunk-XDOMTQHM.js} +14 -10
- package/dist/chunk-XET2RUJF.js +61 -0
- package/dist/{chunk-3FFCUIGV.js → chunk-XZMCVZW6.js} +309 -188
- package/dist/{chunk-YDWP3ZOU.js → chunk-YLV26GAJ.js} +228 -86
- package/dist/{contracts-ey_Qh8ef.d.ts → contracts-Hg6ITAEF.d.cts} +6 -6
- package/dist/{contracts-ey_Qh8ef.d.cts → contracts-Hg6ITAEF.d.ts} +6 -6
- package/dist/{customElement-CPfIrbvg.d.cts → customElement-CKLoO63w.d.cts} +73 -11
- package/dist/{customElement-CPfIrbvg.d.ts → 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 +426 -182
- package/dist/ecosystem.js +11 -11
- package/dist/extras.cjs +1988 -772
- package/dist/extras.d.cts +7 -7
- package/dist/extras.d.ts +7 -7
- package/dist/extras.js +29 -26
- package/dist/index.cjs +791 -392
- 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 +1378 -583
- package/dist/plugins.d.cts +227 -9
- package/dist/plugins.d.ts +227 -9
- package/dist/plugins.js +610 -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 +1111 -450
- 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-6CAJU5TP.js +0 -38
- package/dist/chunk-COY6PUD2.js +0 -34
- package/dist/chunk-DLBFEAIS.js +0 -96
- package/dist/chunk-L3GAGWCC.js +0 -111
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerDisposer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DHDZ7IVN.js";
|
|
4
4
|
import {
|
|
5
5
|
signal
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TVURNWDK.js";
|
|
7
7
|
|
|
8
8
|
// src/ui/transition.ts
|
|
9
9
|
function transition(element, options = {}) {
|
|
@@ -335,7 +335,9 @@ function TransitionGroup(options) {
|
|
|
335
335
|
// src/ui/viewTransition.ts
|
|
336
336
|
function viewTransition(callback) {
|
|
337
337
|
const [isTransitioning, setIsTransitioning] = signal(false);
|
|
338
|
+
let inflight = 0;
|
|
338
339
|
async function start() {
|
|
340
|
+
inflight++;
|
|
339
341
|
setIsTransitioning(true);
|
|
340
342
|
try {
|
|
341
343
|
if (typeof document !== "undefined" && "startViewTransition" in document && typeof document.startViewTransition === "function") {
|
|
@@ -345,7 +347,11 @@ function viewTransition(callback) {
|
|
|
345
347
|
await callback();
|
|
346
348
|
}
|
|
347
349
|
} finally {
|
|
348
|
-
|
|
350
|
+
inflight--;
|
|
351
|
+
if (inflight <= 0) {
|
|
352
|
+
inflight = 0;
|
|
353
|
+
setIsTransitioning(false);
|
|
354
|
+
}
|
|
349
355
|
}
|
|
350
356
|
}
|
|
351
357
|
return { start, isTransitioning };
|
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
// src/core/dev.ts
|
|
14
|
+
function isDev() {
|
|
15
|
+
return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : (
|
|
16
|
+
// The bare `__SIBU_DEV__` is a bundler define that only exists in
|
|
17
|
+
// production builds; under the test runner it is always undefined, so
|
|
18
|
+
// this branch is unreachable here.
|
|
19
|
+
/* v8 ignore next 2 */
|
|
20
|
+
typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : typeof process !== "undefined" && process.env?.NODE_ENV !== "production"
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
var _isDev = isDev();
|
|
24
|
+
function devAssert(condition, message) {
|
|
25
|
+
if (_isDev && !condition) {
|
|
26
|
+
throw new Error(`[SibuJS] ${message}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function devWarn(message) {
|
|
30
|
+
if (_isDev) {
|
|
31
|
+
console.warn(`[SibuJS] ${message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/core/errors.ts
|
|
36
|
+
var ERROR_STATE_KEY = /* @__PURE__ */ Symbol.for("sibujs.runtime-errors.v1");
|
|
37
|
+
function state() {
|
|
38
|
+
const g = globalThis;
|
|
39
|
+
const existing = g[ERROR_STATE_KEY];
|
|
40
|
+
if (existing) return existing;
|
|
41
|
+
const created = { handler: null, handlerDepth: 0 };
|
|
42
|
+
g[ERROR_STATE_KEY] = created;
|
|
43
|
+
return created;
|
|
44
|
+
}
|
|
45
|
+
function setRuntimeErrorHandler(handler) {
|
|
46
|
+
const s = state();
|
|
47
|
+
const prev = s.handler;
|
|
48
|
+
s.handler = handler;
|
|
49
|
+
return prev;
|
|
50
|
+
}
|
|
51
|
+
function getRuntimeErrorHandler() {
|
|
52
|
+
return state().handler;
|
|
53
|
+
}
|
|
54
|
+
function normalizeError(value) {
|
|
55
|
+
if (value instanceof Error) return value;
|
|
56
|
+
const message = typeof value === "string" ? value : `Non-Error value thrown: ${safeStringify(value)}`;
|
|
57
|
+
return new Error(message, { cause: value });
|
|
58
|
+
}
|
|
59
|
+
function safeStringify(value) {
|
|
60
|
+
if (typeof value === "symbol") return value.toString();
|
|
61
|
+
try {
|
|
62
|
+
return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
63
|
+
} catch {
|
|
64
|
+
return Object.prototype.toString.call(value);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function describe(context) {
|
|
68
|
+
return context.name ? `${context.phase} "${context.name}"` : context.phase;
|
|
69
|
+
}
|
|
70
|
+
var REACTIVE_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
71
|
+
function untrackedRun(fn) {
|
|
72
|
+
const api = globalThis[REACTIVE_REGISTRY_KEY];
|
|
73
|
+
return api?.untracked ? api.untracked(fn) : fn();
|
|
74
|
+
}
|
|
75
|
+
var PROPAGATE_EVENT = "sibu:error-propagate";
|
|
76
|
+
function claimedByBoundary(error, context) {
|
|
77
|
+
const raw = context.node;
|
|
78
|
+
if (!raw || typeof CustomEvent === "undefined") return false;
|
|
79
|
+
const target = resolveEventTarget(raw);
|
|
80
|
+
if (!target) return false;
|
|
81
|
+
try {
|
|
82
|
+
const event = new CustomEvent(PROPAGATE_EVENT, {
|
|
83
|
+
bubbles: true,
|
|
84
|
+
cancelable: true,
|
|
85
|
+
detail: { error, context }
|
|
86
|
+
});
|
|
87
|
+
return target.dispatchEvent(event) === false;
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function resolveEventTarget(node) {
|
|
93
|
+
const ELEMENT_NODE = 1;
|
|
94
|
+
let current = node;
|
|
95
|
+
while (current) {
|
|
96
|
+
if (current.nodeType === ELEMENT_NODE && typeof current.dispatchEvent === "function") {
|
|
97
|
+
return current;
|
|
98
|
+
}
|
|
99
|
+
current = current.parentNode;
|
|
100
|
+
}
|
|
101
|
+
const self = node;
|
|
102
|
+
return typeof self.dispatchEvent === "function" ? self : null;
|
|
103
|
+
}
|
|
104
|
+
function defaultReport(error, context) {
|
|
105
|
+
if (typeof console === "undefined") return;
|
|
106
|
+
console.error(`[SibuJS] Uncaught error during ${describe(context)}: ${error.message}`, error);
|
|
107
|
+
}
|
|
108
|
+
function reportError(error, context) {
|
|
109
|
+
const err = normalizeError(error);
|
|
110
|
+
untrackedRun(() => {
|
|
111
|
+
if (claimedByBoundary(err, context)) return;
|
|
112
|
+
const s = state();
|
|
113
|
+
const handler = s.handler;
|
|
114
|
+
if (handler && s.handlerDepth === 0) {
|
|
115
|
+
s.handlerDepth++;
|
|
116
|
+
try {
|
|
117
|
+
handler(error instanceof Error ? error : err, context);
|
|
118
|
+
return;
|
|
119
|
+
} catch (handlerError) {
|
|
120
|
+
if (typeof console !== "undefined") {
|
|
121
|
+
const detail = handlerError instanceof Error ? handlerError.message : String(handlerError);
|
|
122
|
+
console.error(`[SibuJS] runtime error handler itself threw: ${detail}`, handlerError);
|
|
123
|
+
}
|
|
124
|
+
} finally {
|
|
125
|
+
s.handlerDepth--;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
defaultReport(err, context);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
__require,
|
|
134
|
+
__export,
|
|
135
|
+
isDev,
|
|
136
|
+
devAssert,
|
|
137
|
+
devWarn,
|
|
138
|
+
setRuntimeErrorHandler,
|
|
139
|
+
getRuntimeErrorHandler,
|
|
140
|
+
normalizeError,
|
|
141
|
+
reportError
|
|
142
|
+
};
|
|
@@ -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-JYXQCELN.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;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isSSR
|
|
3
|
+
} from "./chunk-TIRZCERI.js";
|
|
4
|
+
import {
|
|
5
|
+
signal
|
|
6
|
+
} from "./chunk-TVURNWDK.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
|
+
};
|