sibujs 4.4.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/browser.cjs +339 -130
- package/dist/browser.d.cts +61 -16
- package/dist/browser.d.ts +61 -16
- package/dist/browser.js +8 -6
- package/dist/build.cjs +273 -82
- package/dist/build.js +15 -16
- package/dist/cdn.dev.global.js +12 -12
- package/dist/cdn.full.dev.global.js +11 -11
- package/dist/cdn.full.global.js +10 -10
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
- package/dist/chunk-3ISI6ACU.js +44 -0
- package/dist/{chunk-VCTAEPSB.js → chunk-47M47FOM.js} +11 -3
- package/dist/chunk-5HZXGZ6T.js +24 -0
- package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
- package/dist/{chunk-3BTTCZ5J.js → chunk-5Q4R7HCL.js} +42 -4
- package/dist/{chunk-ADM46X22.js → chunk-7GQCWFOE.js} +157 -61
- package/dist/{chunk-4Z3SPQ67.js → chunk-7NCARGJW.js} +16 -8
- package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
- package/dist/{chunk-LQFGQNMV.js → chunk-AIF3Z2T7.js} +302 -39
- package/dist/{chunk-UCALUKB5.js → chunk-BAAG6ZTI.js} +98 -29
- package/dist/{chunk-NVNJH22U.js → chunk-D33YTSX5.js} +2 -2
- package/dist/{chunk-M2F7TZHH.js → chunk-DKGBBKOF.js} +136 -80
- package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
- package/dist/{chunk-HFCOH2GN.js → chunk-HYXDKS4N.js} +153 -110
- package/dist/chunk-J6FW5TV6.js +233 -0
- package/dist/{chunk-36S2YPP4.js → chunk-JSXPZCET.js} +1 -1
- package/dist/chunk-NYNYSPK7.js +318 -0
- package/dist/{chunk-HQSEH5F6.js → chunk-ORMZXBKQ.js} +108 -45
- package/dist/{chunk-LYVUX7NT.js → chunk-OXUY2A6L.js} +287 -130
- package/dist/{chunk-6GSIXTWX.js → chunk-PK6FK2G2.js} +187 -66
- package/dist/{chunk-W2EQ7X2L.js → chunk-QE4TTDU3.js} +47 -9
- package/dist/{chunk-XLO7SLIX.js → chunk-SXXVZMKZ.js} +262 -70
- package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
- package/dist/{chunk-RR7M3FHM.js → chunk-UZQ6ALFS.js} +3 -3
- package/dist/{chunk-PNIRUQ4C.js → chunk-VVWPJ543.js} +6 -8
- package/dist/{chunk-7GIHSAWB.js → chunk-XC4MEKGA.js} +3 -3
- package/dist/{chunk-SKPTERHP.js → chunk-XRRZKZYX.js} +55 -31
- package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
- package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
- package/dist/{customElement-CNZxEB9G.d.ts → customElement-MmInOW1U.d.cts} +59 -10
- package/dist/{customElement-CNZxEB9G.d.cts → customElement-MmInOW1U.d.ts} +59 -10
- package/dist/data.cjs +293 -125
- package/dist/data.d.cts +47 -9
- package/dist/data.d.ts +47 -9
- package/dist/data.js +12 -9
- package/dist/devtools.cjs +121 -58
- package/dist/devtools.js +7 -8
- package/dist/dispose-GEIG2KOF.js +28 -0
- package/dist/ecosystem.cjs +391 -112
- package/dist/ecosystem.d.cts +31 -7
- package/dist/ecosystem.d.ts +31 -7
- package/dist/ecosystem.js +12 -12
- package/dist/extras.cjs +2250 -879
- package/dist/extras.d.cts +10 -9
- package/dist/extras.d.ts +10 -9
- package/dist/extras.js +39 -28
- package/dist/index.cjs +273 -82
- package/dist/index.d.cts +44 -154
- package/dist/index.d.ts +44 -154
- package/dist/index.js +24 -27
- package/dist/motion.cjs +137 -42
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +397 -48
- package/dist/patterns.d.cts +32 -9
- package/dist/patterns.d.ts +32 -9
- package/dist/patterns.js +8 -8
- package/dist/performance.cjs +338 -217
- package/dist/performance.d.cts +2 -2
- package/dist/performance.d.ts +2 -2
- package/dist/performance.js +8 -9
- package/dist/plugin-DVgSnTfK.d.cts +112 -0
- package/dist/plugin-DVgSnTfK.d.ts +112 -0
- package/dist/plugins.cjs +587 -203
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +35 -23
- package/dist/signal-EotCj4hS.d.cts +110 -0
- package/dist/signal-EotCj4hS.d.ts +110 -0
- package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
- package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
- package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
- package/dist/ssr.cjs +214 -73
- package/dist/ssr.d.cts +9 -3
- package/dist/ssr.d.ts +9 -3
- package/dist/ssr.js +11 -12
- package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
- package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
- package/dist/tagFactory-DFstCLQV.d.cts +117 -0
- package/dist/tagFactory-DkaNVUNV.d.ts +117 -0
- package/dist/testing.cjs +2481 -2153
- package/dist/testing.d.cts +56 -5
- package/dist/testing.d.ts +56 -5
- package/dist/testing.js +580 -307
- package/dist/ui.cjs +798 -328
- package/dist/ui.d.cts +40 -7
- package/dist/ui.d.ts +40 -7
- package/dist/ui.js +151 -56
- package/dist/widgets.cjs +319 -285
- package/dist/widgets.js +9 -10
- package/package.json +2 -2
- package/dist/chunk-2WLZ6757.js +0 -149
- package/dist/chunk-7NBDXVHS.js +0 -60
- package/dist/chunk-CCSJMTRN.js +0 -15
- package/dist/chunk-QKRPLZ2V.js +0 -108
- package/dist/chunk-WWV3SJ3L.js +0 -131
- package/dist/dispose-46BOMMQJ.js +0 -19
- package/dist/plugin-D30wlGW5.d.cts +0 -71
- package/dist/plugin-D30wlGW5.d.ts +0 -71
- package/dist/tagFactory-Bzupt4Pj.d.cts +0 -55
- package/dist/tagFactory-Bzupt4Pj.d.ts +0 -55
package/dist/widgets.js
CHANGED
|
@@ -8,16 +8,15 @@ import {
|
|
|
8
8
|
select,
|
|
9
9
|
tabs,
|
|
10
10
|
tooltip
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-2WLZ6757.js";
|
|
11
|
+
} from "./chunk-HYXDKS4N.js";
|
|
12
|
+
import "./chunk-UZQ6ALFS.js";
|
|
13
|
+
import "./chunk-3ISI6ACU.js";
|
|
14
|
+
import "./chunk-QE4TTDU3.js";
|
|
15
|
+
import "./chunk-2INLLLMZ.js";
|
|
16
|
+
import "./chunk-7XHATCIH.js";
|
|
17
|
+
import "./chunk-D33YTSX5.js";
|
|
18
|
+
import "./chunk-5Q4R7HCL.js";
|
|
19
|
+
import "./chunk-NYNYSPK7.js";
|
|
21
20
|
export {
|
|
22
21
|
accordion,
|
|
23
22
|
combobox,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sibujs",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "4.6.0",
|
|
4
|
+
"description": "A function-based frontend framework with fine-grained reactivity and no virtual DOM. Tag factories return live DOM nodes you can hold and mutate, signals update only what changed, and nothing needs a compiler — it runs from a script tag or a bundler.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"frontend",
|
|
7
7
|
"framework",
|
package/dist/chunk-2WLZ6757.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
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
|
-
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
|
-
}
|
|
39
|
-
|
|
40
|
-
// src/core/errors.ts
|
|
41
|
-
var ERROR_STATE_KEY = /* @__PURE__ */ Symbol.for("sibujs.runtime-errors.v1");
|
|
42
|
-
function state() {
|
|
43
|
-
const g = globalThis;
|
|
44
|
-
const existing = g[ERROR_STATE_KEY];
|
|
45
|
-
if (existing) return existing;
|
|
46
|
-
const created = { handler: null, handlerDepth: 0 };
|
|
47
|
-
g[ERROR_STATE_KEY] = created;
|
|
48
|
-
return created;
|
|
49
|
-
}
|
|
50
|
-
function setRuntimeErrorHandler(handler) {
|
|
51
|
-
const s = state();
|
|
52
|
-
const prev = s.handler;
|
|
53
|
-
s.handler = handler;
|
|
54
|
-
return prev;
|
|
55
|
-
}
|
|
56
|
-
function getRuntimeErrorHandler() {
|
|
57
|
-
return state().handler;
|
|
58
|
-
}
|
|
59
|
-
function normalizeError(value) {
|
|
60
|
-
if (value instanceof Error) return value;
|
|
61
|
-
const message = typeof value === "string" ? value : `Non-Error value thrown: ${safeStringify(value)}`;
|
|
62
|
-
return new Error(message, { cause: value });
|
|
63
|
-
}
|
|
64
|
-
function safeStringify(value) {
|
|
65
|
-
if (typeof value === "symbol") return value.toString();
|
|
66
|
-
try {
|
|
67
|
-
return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
68
|
-
} catch {
|
|
69
|
-
return Object.prototype.toString.call(value);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function describe(context) {
|
|
73
|
-
return context.name ? `${context.phase} "${context.name}"` : context.phase;
|
|
74
|
-
}
|
|
75
|
-
var REACTIVE_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
76
|
-
function untrackedRun(fn) {
|
|
77
|
-
const api = globalThis[REACTIVE_REGISTRY_KEY];
|
|
78
|
-
return api?.untracked ? api.untracked(fn) : fn();
|
|
79
|
-
}
|
|
80
|
-
var PROPAGATE_EVENT = "sibu:error-propagate";
|
|
81
|
-
function claimedByBoundary(error, context) {
|
|
82
|
-
const raw = context.node;
|
|
83
|
-
if (!raw || typeof CustomEvent === "undefined") return false;
|
|
84
|
-
const target = resolveEventTarget(raw);
|
|
85
|
-
if (!target) return false;
|
|
86
|
-
try {
|
|
87
|
-
const event = new CustomEvent(PROPAGATE_EVENT, {
|
|
88
|
-
bubbles: true,
|
|
89
|
-
cancelable: true,
|
|
90
|
-
detail: { error, context }
|
|
91
|
-
});
|
|
92
|
-
return target.dispatchEvent(event) === false;
|
|
93
|
-
} catch {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function resolveEventTarget(node) {
|
|
98
|
-
const ELEMENT_NODE = 1;
|
|
99
|
-
let current = node;
|
|
100
|
-
while (current) {
|
|
101
|
-
if (current.nodeType === ELEMENT_NODE && typeof current.dispatchEvent === "function") {
|
|
102
|
-
return current;
|
|
103
|
-
}
|
|
104
|
-
current = current.parentNode;
|
|
105
|
-
}
|
|
106
|
-
const self = node;
|
|
107
|
-
return typeof self.dispatchEvent === "function" ? self : null;
|
|
108
|
-
}
|
|
109
|
-
function defaultReport(error, context) {
|
|
110
|
-
if (typeof console === "undefined") return;
|
|
111
|
-
console.error(`[SibuJS] Uncaught error during ${describe(context)}: ${error.message}`, error);
|
|
112
|
-
}
|
|
113
|
-
function reportError(error, context) {
|
|
114
|
-
const err = normalizeError(error);
|
|
115
|
-
untrackedRun(() => {
|
|
116
|
-
if (claimedByBoundary(err, context)) return;
|
|
117
|
-
const s = state();
|
|
118
|
-
const handler = s.handler;
|
|
119
|
-
if (handler && s.handlerDepth === 0) {
|
|
120
|
-
s.handlerDepth++;
|
|
121
|
-
try {
|
|
122
|
-
handler(error instanceof Error ? error : err, context);
|
|
123
|
-
return;
|
|
124
|
-
} catch (handlerError) {
|
|
125
|
-
if (typeof console !== "undefined") {
|
|
126
|
-
const detail = handlerError instanceof Error ? handlerError.message : String(handlerError);
|
|
127
|
-
console.error(`[SibuJS] runtime error handler itself threw: ${detail}`, handlerError);
|
|
128
|
-
}
|
|
129
|
-
} finally {
|
|
130
|
-
s.handlerDepth--;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
defaultReport(err, context);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export {
|
|
138
|
-
__require,
|
|
139
|
-
__export,
|
|
140
|
-
DEV,
|
|
141
|
-
isDev,
|
|
142
|
-
devAssert,
|
|
143
|
-
devWarnLazy,
|
|
144
|
-
devWarn,
|
|
145
|
-
setRuntimeErrorHandler,
|
|
146
|
-
getRuntimeErrorHandler,
|
|
147
|
-
normalizeError,
|
|
148
|
-
reportError
|
|
149
|
-
};
|
package/dist/chunk-7NBDXVHS.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isSSR
|
|
3
|
-
} from "./chunk-5DXA2J44.js";
|
|
4
|
-
import {
|
|
5
|
-
signal
|
|
6
|
-
} from "./chunk-NVNJH22U.js";
|
|
7
|
-
import {
|
|
8
|
-
DEV,
|
|
9
|
-
devWarn
|
|
10
|
-
} from "./chunk-2WLZ6757.js";
|
|
11
|
-
|
|
12
|
-
// src/core/rendering/context.ts
|
|
13
|
-
function context(defaultValue) {
|
|
14
|
-
const [getValue, setValue] = signal(defaultValue);
|
|
15
|
-
const warnIfSSR = (method) => {
|
|
16
|
-
if (!DEV || !isSSR()) return;
|
|
17
|
-
devWarn(
|
|
18
|
-
`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.`
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
const ctx = {
|
|
22
|
-
provide(value) {
|
|
23
|
-
warnIfSSR("provide");
|
|
24
|
-
const previous = getValue();
|
|
25
|
-
setValue(value);
|
|
26
|
-
return () => setValue(previous);
|
|
27
|
-
},
|
|
28
|
-
use() {
|
|
29
|
-
return getValue;
|
|
30
|
-
},
|
|
31
|
-
get() {
|
|
32
|
-
return getValue();
|
|
33
|
-
},
|
|
34
|
-
set(value) {
|
|
35
|
-
warnIfSSR("set");
|
|
36
|
-
setValue(value);
|
|
37
|
-
},
|
|
38
|
-
withContext(value, fn) {
|
|
39
|
-
warnIfSSR("withContext");
|
|
40
|
-
const previous = getValue();
|
|
41
|
-
setValue(value);
|
|
42
|
-
try {
|
|
43
|
-
const result = fn();
|
|
44
|
-
if (DEV && result !== null && typeof result?.then === "function") {
|
|
45
|
-
devWarn(
|
|
46
|
-
"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."
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
} finally {
|
|
51
|
-
setValue(previous);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return ctx;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export {
|
|
59
|
-
context
|
|
60
|
-
};
|
package/dist/chunk-CCSJMTRN.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/core/rendering/createId.ts
|
|
2
|
-
var COUNTER_KEY = /* @__PURE__ */ Symbol.for("sibujs.createId.v1");
|
|
3
|
-
var _counter = globalThis[COUNTER_KEY] ?? (globalThis[COUNTER_KEY] = { n: 0 });
|
|
4
|
-
function createId(prefix = "sibu") {
|
|
5
|
-
_counter.n++;
|
|
6
|
-
return `${prefix}-${_counter.n}`;
|
|
7
|
-
}
|
|
8
|
-
function __resetIdCounter() {
|
|
9
|
-
_counter.n = 0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
createId,
|
|
14
|
-
__resetIdCounter
|
|
15
|
-
};
|
package/dist/chunk-QKRPLZ2V.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEV,
|
|
3
|
-
devWarn,
|
|
4
|
-
reportError
|
|
5
|
-
} from "./chunk-2WLZ6757.js";
|
|
6
|
-
|
|
7
|
-
// src/core/rendering/dispose.ts
|
|
8
|
-
var elementDisposers = /* @__PURE__ */ new WeakMap();
|
|
9
|
-
var MAX_DRAIN_TEARDOWNS = 1e4;
|
|
10
|
-
function reportDrainRunaway(label, executed, remaining) {
|
|
11
|
-
if (typeof console === "undefined") return;
|
|
12
|
-
console.error(
|
|
13
|
-
`[SibuJS ${label}] runaway cleanup: stopped after running ${executed} teardowns with ${remaining} still queued. Cleanup production did not stabilize before the teardown safety ceiling was reached \u2014 the remaining work was NOT run.`,
|
|
14
|
-
{ executed, remaining }
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
var activeBindingCount = 0;
|
|
18
|
-
function registerDisposer(node, teardown) {
|
|
19
|
-
let disposers = elementDisposers.get(node);
|
|
20
|
-
if (!disposers) {
|
|
21
|
-
disposers = [];
|
|
22
|
-
elementDisposers.set(node, disposers);
|
|
23
|
-
}
|
|
24
|
-
disposers.push(teardown);
|
|
25
|
-
if (DEV) activeBindingCount++;
|
|
26
|
-
}
|
|
27
|
-
function unregisterDisposer(node, teardown) {
|
|
28
|
-
const disposers = elementDisposers.get(node);
|
|
29
|
-
if (!disposers) return;
|
|
30
|
-
const index = disposers.indexOf(teardown);
|
|
31
|
-
if (index === -1) return;
|
|
32
|
-
disposers.splice(index, 1);
|
|
33
|
-
if (DEV) activeBindingCount--;
|
|
34
|
-
if (disposers.length === 0) elementDisposers.delete(node);
|
|
35
|
-
}
|
|
36
|
-
function dispose(node) {
|
|
37
|
-
const stack = [node];
|
|
38
|
-
const order = [];
|
|
39
|
-
while (stack.length > 0) {
|
|
40
|
-
const current = stack.pop();
|
|
41
|
-
order.push(current);
|
|
42
|
-
const children = Array.from(current.childNodes);
|
|
43
|
-
for (let i = 0; i < children.length; i++) {
|
|
44
|
-
stack.push(children[i]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
for (let i = order.length - 1; i >= 0; i--) {
|
|
48
|
-
const current = order[i];
|
|
49
|
-
if (elementDisposers.has(current)) {
|
|
50
|
-
let executed = 0;
|
|
51
|
-
let runaway = false;
|
|
52
|
-
while (!runaway) {
|
|
53
|
-
const pending = elementDisposers.get(current);
|
|
54
|
-
if (!pending || pending.length === 0) break;
|
|
55
|
-
const snapshot = pending.slice();
|
|
56
|
-
elementDisposers.delete(current);
|
|
57
|
-
if (DEV) activeBindingCount -= snapshot.length;
|
|
58
|
-
for (let i2 = 0; i2 < snapshot.length; i2++) {
|
|
59
|
-
if (executed >= MAX_DRAIN_TEARDOWNS) {
|
|
60
|
-
const rest = snapshot.slice(i2);
|
|
61
|
-
const added = elementDisposers.get(current);
|
|
62
|
-
elementDisposers.set(current, added ? rest.concat(added) : rest);
|
|
63
|
-
if (DEV) activeBindingCount += rest.length;
|
|
64
|
-
reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
|
|
65
|
-
runaway = true;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
executed++;
|
|
69
|
-
try {
|
|
70
|
-
snapshot[i2]();
|
|
71
|
-
} catch (err) {
|
|
72
|
-
reportError(err, { phase: "cleanup", name: "disposer" });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function replaceChildrenSafely(parent, ...next) {
|
|
80
|
-
for (let i = 0; i < next.length; i++) {
|
|
81
|
-
const node = next[i];
|
|
82
|
-
node.parentNode?.removeChild(node);
|
|
83
|
-
}
|
|
84
|
-
const current = Array.from(parent.childNodes);
|
|
85
|
-
for (let i = 0; i < current.length; i++) {
|
|
86
|
-
dispose(current[i]);
|
|
87
|
-
}
|
|
88
|
-
parent.replaceChildren(...next);
|
|
89
|
-
}
|
|
90
|
-
function checkLeaks(warnThreshold = 0) {
|
|
91
|
-
if (!DEV) return 0;
|
|
92
|
-
if (warnThreshold > 0 && activeBindingCount > warnThreshold) {
|
|
93
|
-
devWarn(
|
|
94
|
-
`checkLeaks: ${activeBindingCount} active DOM bindings detected. Expected \u2264${warnThreshold}. This may indicate a component was removed from the DOM without calling dispose().`
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
return activeBindingCount;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export {
|
|
101
|
-
MAX_DRAIN_TEARDOWNS,
|
|
102
|
-
reportDrainRunaway,
|
|
103
|
-
registerDisposer,
|
|
104
|
-
unregisterDisposer,
|
|
105
|
-
dispose,
|
|
106
|
-
replaceChildrenSafely,
|
|
107
|
-
checkLeaks
|
|
108
|
-
};
|
package/dist/chunk-WWV3SJ3L.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
globalSingleton
|
|
3
|
-
} from "./chunk-7ZHH77QA.js";
|
|
4
|
-
|
|
5
|
-
// src/plugins/plugin.ts
|
|
6
|
-
function createPluginRegistry() {
|
|
7
|
-
const installedPlugins = /* @__PURE__ */ new Set();
|
|
8
|
-
const hooks = { init: [], mount: [], unmount: [], error: [] };
|
|
9
|
-
const provided = /* @__PURE__ */ new Map();
|
|
10
|
-
const registry = {
|
|
11
|
-
installedPlugins,
|
|
12
|
-
hooks,
|
|
13
|
-
provided,
|
|
14
|
-
plugin(p, options) {
|
|
15
|
-
if (installedPlugins.has(p.name)) {
|
|
16
|
-
console.warn(`[Plugin] "${p.name}" is already installed.`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const ctx = {
|
|
20
|
-
onInit: (cb) => hooks.init.push(cb),
|
|
21
|
-
onMount: (cb) => hooks.mount.push(cb),
|
|
22
|
-
onUnmount: (cb) => hooks.unmount.push(cb),
|
|
23
|
-
onError: (cb) => hooks.error.push(cb),
|
|
24
|
-
provide: (key, value) => provided.set(key, value)
|
|
25
|
-
};
|
|
26
|
-
const initHooksBefore = hooks.init.length;
|
|
27
|
-
p.install(ctx, options);
|
|
28
|
-
installedPlugins.add(p.name);
|
|
29
|
-
const justAdded = hooks.init.slice(initHooksBefore);
|
|
30
|
-
for (const cb of justAdded) {
|
|
31
|
-
try {
|
|
32
|
-
cb();
|
|
33
|
-
} catch (e) {
|
|
34
|
-
console.error(`[Plugin] "${p.name}" init error:`, e);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
inject(key, defaultValue) {
|
|
39
|
-
if (provided.has(key)) return provided.get(key);
|
|
40
|
-
if (defaultValue !== void 0) return defaultValue;
|
|
41
|
-
throw new Error(`[Plugin] No provider found for key "${key}"`);
|
|
42
|
-
},
|
|
43
|
-
triggerMount(element) {
|
|
44
|
-
const snapshot = hooks.mount.slice();
|
|
45
|
-
for (const hook of snapshot) {
|
|
46
|
-
try {
|
|
47
|
-
hook(element);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
console.error("[Plugin] Mount hook error:", e);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
triggerUnmount(element) {
|
|
54
|
-
const snapshot = hooks.unmount.slice();
|
|
55
|
-
for (const hook of snapshot) {
|
|
56
|
-
try {
|
|
57
|
-
hook(element);
|
|
58
|
-
} catch (e) {
|
|
59
|
-
console.error("[Plugin] Unmount hook error:", e);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
triggerError(error) {
|
|
64
|
-
const snapshot = hooks.error.slice();
|
|
65
|
-
for (const hook of snapshot) {
|
|
66
|
-
try {
|
|
67
|
-
hook(error);
|
|
68
|
-
} catch (e) {
|
|
69
|
-
console.error("[Plugin] Error hook error:", e);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
reset() {
|
|
74
|
-
installedPlugins.clear();
|
|
75
|
-
hooks.init.length = 0;
|
|
76
|
-
hooks.mount.length = 0;
|
|
77
|
-
hooks.unmount.length = 0;
|
|
78
|
-
hooks.error.length = 0;
|
|
79
|
-
provided.clear();
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
return registry;
|
|
83
|
-
}
|
|
84
|
-
var _defaults = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.plugins.defaultRegistry.v1"), () => ({
|
|
85
|
-
registry: createPluginRegistry(),
|
|
86
|
-
touched: false
|
|
87
|
-
}));
|
|
88
|
-
function createPlugin(name, install) {
|
|
89
|
-
return { name, install };
|
|
90
|
-
}
|
|
91
|
-
function plugin(plugin2, options) {
|
|
92
|
-
_defaults.touched = true;
|
|
93
|
-
_defaults.registry.plugin(plugin2, options);
|
|
94
|
-
}
|
|
95
|
-
function inject(key, defaultValue) {
|
|
96
|
-
return _defaults.registry.inject(key, defaultValue);
|
|
97
|
-
}
|
|
98
|
-
function triggerPluginMount(element) {
|
|
99
|
-
_defaults.registry.triggerMount(element);
|
|
100
|
-
}
|
|
101
|
-
function triggerPluginUnmount(element) {
|
|
102
|
-
_defaults.registry.triggerUnmount(element);
|
|
103
|
-
}
|
|
104
|
-
function triggerPluginError(error) {
|
|
105
|
-
_defaults.registry.triggerError(error);
|
|
106
|
-
}
|
|
107
|
-
function resetPlugins() {
|
|
108
|
-
_defaults.registry.reset();
|
|
109
|
-
_defaults.touched = false;
|
|
110
|
-
}
|
|
111
|
-
function setDefaultPluginRegistry(registry) {
|
|
112
|
-
if (_defaults.touched && _defaults.registry.installedPlugins.size > 0) {
|
|
113
|
-
console.warn(
|
|
114
|
-
"[Plugin] Replacing default plugin registry while plugins are already installed on the singleton. This may indicate mixed singleton/registry usage."
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
_defaults.registry = registry;
|
|
118
|
-
_defaults.touched = true;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export {
|
|
122
|
-
createPluginRegistry,
|
|
123
|
-
createPlugin,
|
|
124
|
-
plugin,
|
|
125
|
-
inject,
|
|
126
|
-
triggerPluginMount,
|
|
127
|
-
triggerPluginUnmount,
|
|
128
|
-
triggerPluginError,
|
|
129
|
-
resetPlugins,
|
|
130
|
-
setDefaultPluginRegistry
|
|
131
|
-
};
|
package/dist/dispose-46BOMMQJ.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MAX_DRAIN_TEARDOWNS,
|
|
3
|
-
checkLeaks,
|
|
4
|
-
dispose,
|
|
5
|
-
registerDisposer,
|
|
6
|
-
replaceChildrenSafely,
|
|
7
|
-
reportDrainRunaway,
|
|
8
|
-
unregisterDisposer
|
|
9
|
-
} from "./chunk-QKRPLZ2V.js";
|
|
10
|
-
import "./chunk-2WLZ6757.js";
|
|
11
|
-
export {
|
|
12
|
-
MAX_DRAIN_TEARDOWNS,
|
|
13
|
-
checkLeaks,
|
|
14
|
-
dispose,
|
|
15
|
-
registerDisposer,
|
|
16
|
-
replaceChildrenSafely,
|
|
17
|
-
reportDrainRunaway,
|
|
18
|
-
unregisterDisposer
|
|
19
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
interface PluginContext {
|
|
2
|
-
/** Register a global hook */
|
|
3
|
-
onInit: (callback: () => void) => void;
|
|
4
|
-
onMount: (callback: (element: HTMLElement) => void) => void;
|
|
5
|
-
onUnmount: (callback: (element: HTMLElement) => void) => void;
|
|
6
|
-
onError: (callback: (error: Error) => void) => void;
|
|
7
|
-
/** Provide a value globally */
|
|
8
|
-
provide: (key: string, value: unknown) => void;
|
|
9
|
-
}
|
|
10
|
-
interface SibuPlugin {
|
|
11
|
-
name: string;
|
|
12
|
-
install: (ctx: PluginContext, options?: unknown) => void;
|
|
13
|
-
}
|
|
14
|
-
interface PluginHooks {
|
|
15
|
-
init: Array<() => void>;
|
|
16
|
-
mount: Array<(element: HTMLElement) => void>;
|
|
17
|
-
unmount: Array<(element: HTMLElement) => void>;
|
|
18
|
-
error: Array<(error: Error) => void>;
|
|
19
|
-
}
|
|
20
|
-
interface PluginRegistry {
|
|
21
|
-
readonly installedPlugins: Set<string>;
|
|
22
|
-
readonly hooks: PluginHooks;
|
|
23
|
-
readonly provided: Map<string, unknown>;
|
|
24
|
-
plugin: (p: SibuPlugin, options?: unknown) => void;
|
|
25
|
-
inject: <T = unknown>(key: string, defaultValue?: T) => T;
|
|
26
|
-
triggerMount: (element: HTMLElement) => void;
|
|
27
|
-
triggerUnmount: (element: HTMLElement) => void;
|
|
28
|
-
triggerError: (error: Error) => void;
|
|
29
|
-
reset: () => void;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Create an isolated plugin registry. Useful for tests, SSR per-request
|
|
33
|
-
* isolation, or embedding multiple independent SibuJS apps on one page.
|
|
34
|
-
*/
|
|
35
|
-
declare function createPluginRegistry(): PluginRegistry;
|
|
36
|
-
/**
|
|
37
|
-
* Creates a plugin definition.
|
|
38
|
-
*/
|
|
39
|
-
declare function createPlugin(name: string, install: (ctx: PluginContext, options?: unknown) => void): SibuPlugin;
|
|
40
|
-
/**
|
|
41
|
-
* Installs a plugin into the default (singleton) registry.
|
|
42
|
-
*/
|
|
43
|
-
declare function plugin(plugin: SibuPlugin, options?: unknown): void;
|
|
44
|
-
/**
|
|
45
|
-
* Retrieve a value provided by a plugin (from the default registry).
|
|
46
|
-
*/
|
|
47
|
-
declare function inject<T = unknown>(key: string, defaultValue?: T): T;
|
|
48
|
-
/**
|
|
49
|
-
* Trigger mount hooks for an element (default registry).
|
|
50
|
-
*/
|
|
51
|
-
declare function triggerPluginMount(element: HTMLElement): void;
|
|
52
|
-
/**
|
|
53
|
-
* Trigger unmount hooks for an element (default registry).
|
|
54
|
-
*/
|
|
55
|
-
declare function triggerPluginUnmount(element: HTMLElement): void;
|
|
56
|
-
/**
|
|
57
|
-
* Trigger error hooks (default registry).
|
|
58
|
-
*/
|
|
59
|
-
declare function triggerPluginError(error: Error): void;
|
|
60
|
-
/**
|
|
61
|
-
* Reset the default plugin registry (useful for testing).
|
|
62
|
-
*/
|
|
63
|
-
declare function resetPlugins(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Replace the default registry with an isolated one. Emits a dev warning
|
|
66
|
-
* if the default singleton already had plugins installed (to surface
|
|
67
|
-
* accidental interleaving of singleton + registry use).
|
|
68
|
-
*/
|
|
69
|
-
declare function setDefaultPluginRegistry(registry: PluginRegistry): void;
|
|
70
|
-
|
|
71
|
-
export { type PluginContext as P, type SibuPlugin as S, type PluginRegistry as a, createPluginRegistry as b, createPlugin as c, triggerPluginMount as d, triggerPluginUnmount as e, inject as i, plugin as p, resetPlugins as r, setDefaultPluginRegistry as s, triggerPluginError as t };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
interface PluginContext {
|
|
2
|
-
/** Register a global hook */
|
|
3
|
-
onInit: (callback: () => void) => void;
|
|
4
|
-
onMount: (callback: (element: HTMLElement) => void) => void;
|
|
5
|
-
onUnmount: (callback: (element: HTMLElement) => void) => void;
|
|
6
|
-
onError: (callback: (error: Error) => void) => void;
|
|
7
|
-
/** Provide a value globally */
|
|
8
|
-
provide: (key: string, value: unknown) => void;
|
|
9
|
-
}
|
|
10
|
-
interface SibuPlugin {
|
|
11
|
-
name: string;
|
|
12
|
-
install: (ctx: PluginContext, options?: unknown) => void;
|
|
13
|
-
}
|
|
14
|
-
interface PluginHooks {
|
|
15
|
-
init: Array<() => void>;
|
|
16
|
-
mount: Array<(element: HTMLElement) => void>;
|
|
17
|
-
unmount: Array<(element: HTMLElement) => void>;
|
|
18
|
-
error: Array<(error: Error) => void>;
|
|
19
|
-
}
|
|
20
|
-
interface PluginRegistry {
|
|
21
|
-
readonly installedPlugins: Set<string>;
|
|
22
|
-
readonly hooks: PluginHooks;
|
|
23
|
-
readonly provided: Map<string, unknown>;
|
|
24
|
-
plugin: (p: SibuPlugin, options?: unknown) => void;
|
|
25
|
-
inject: <T = unknown>(key: string, defaultValue?: T) => T;
|
|
26
|
-
triggerMount: (element: HTMLElement) => void;
|
|
27
|
-
triggerUnmount: (element: HTMLElement) => void;
|
|
28
|
-
triggerError: (error: Error) => void;
|
|
29
|
-
reset: () => void;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Create an isolated plugin registry. Useful for tests, SSR per-request
|
|
33
|
-
* isolation, or embedding multiple independent SibuJS apps on one page.
|
|
34
|
-
*/
|
|
35
|
-
declare function createPluginRegistry(): PluginRegistry;
|
|
36
|
-
/**
|
|
37
|
-
* Creates a plugin definition.
|
|
38
|
-
*/
|
|
39
|
-
declare function createPlugin(name: string, install: (ctx: PluginContext, options?: unknown) => void): SibuPlugin;
|
|
40
|
-
/**
|
|
41
|
-
* Installs a plugin into the default (singleton) registry.
|
|
42
|
-
*/
|
|
43
|
-
declare function plugin(plugin: SibuPlugin, options?: unknown): void;
|
|
44
|
-
/**
|
|
45
|
-
* Retrieve a value provided by a plugin (from the default registry).
|
|
46
|
-
*/
|
|
47
|
-
declare function inject<T = unknown>(key: string, defaultValue?: T): T;
|
|
48
|
-
/**
|
|
49
|
-
* Trigger mount hooks for an element (default registry).
|
|
50
|
-
*/
|
|
51
|
-
declare function triggerPluginMount(element: HTMLElement): void;
|
|
52
|
-
/**
|
|
53
|
-
* Trigger unmount hooks for an element (default registry).
|
|
54
|
-
*/
|
|
55
|
-
declare function triggerPluginUnmount(element: HTMLElement): void;
|
|
56
|
-
/**
|
|
57
|
-
* Trigger error hooks (default registry).
|
|
58
|
-
*/
|
|
59
|
-
declare function triggerPluginError(error: Error): void;
|
|
60
|
-
/**
|
|
61
|
-
* Reset the default plugin registry (useful for testing).
|
|
62
|
-
*/
|
|
63
|
-
declare function resetPlugins(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Replace the default registry with an isolated one. Emits a dev warning
|
|
66
|
-
* if the default singleton already had plugins installed (to surface
|
|
67
|
-
* accidental interleaving of singleton + registry use).
|
|
68
|
-
*/
|
|
69
|
-
declare function setDefaultPluginRegistry(registry: PluginRegistry): void;
|
|
70
|
-
|
|
71
|
-
export { type PluginContext as P, type SibuPlugin as S, type PluginRegistry as a, createPluginRegistry as b, createPlugin as c, triggerPluginMount as d, triggerPluginUnmount as e, inject as i, plugin as p, resetPlugins as r, setDefaultPluginRegistry as s, triggerPluginError as t };
|