sibujs 4.6.0 → 4.7.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 +18 -5
- package/dist/browser.js +4 -4
- package/dist/build.cjs +1956 -1007
- package/dist/build.d.cts +133 -44
- package/dist/build.d.ts +133 -44
- package/dist/build.js +1368 -569
- 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-SXXVZMKZ.js → chunk-2BPG2XDA.js} +5 -5
- package/dist/{chunk-BAAG6ZTI.js → chunk-3QWBSL5R.js} +4 -4
- package/dist/{chunk-5MT6SJ3P.js → chunk-4AWA2PVD.js} +2 -2
- package/dist/{chunk-JSXPZCET.js → chunk-7LUJQAOJ.js} +1 -1
- package/dist/{chunk-3ISI6ACU.js → chunk-BC2SECJD.js} +1 -1
- package/dist/{chunk-DKGBBKOF.js → chunk-BSY63EM6.js} +2 -2
- package/dist/{chunk-7NCARGJW.js → chunk-DKXRACVN.js} +3 -3
- package/dist/{chunk-47M47FOM.js → chunk-FNJXNGYZ.js} +1 -1
- package/dist/{chunk-D33YTSX5.js → chunk-FQRUXCEE.js} +5 -4
- package/dist/{chunk-5Q4R7HCL.js → chunk-JWKYU5GV.js} +11 -2
- package/dist/{chunk-QE4TTDU3.js → chunk-RUSSKG6G.js} +12 -11
- package/dist/{chunk-UZQ6ALFS.js → chunk-SLM3IA34.js} +1 -1
- package/dist/{chunk-XRRZKZYX.js → chunk-UNWRJRKC.js} +1 -1
- package/dist/{chunk-VVWPJ543.js → chunk-UOL2ECCS.js} +40 -11
- package/dist/{chunk-ORMZXBKQ.js → chunk-VZSG24LS.js} +3 -3
- package/dist/{chunk-XC4MEKGA.js → chunk-WEQ3DMVL.js} +8 -2
- package/dist/{chunk-PK6FK2G2.js → chunk-WOLJZUFQ.js} +176 -27
- package/dist/{chunk-7GQCWFOE.js → chunk-XYV3EDB7.js} +143 -74
- package/dist/{chunk-AIF3Z2T7.js → chunk-XZR4PXRE.js} +3 -3
- package/dist/{chunk-HYXDKS4N.js → chunk-Z3OHK6QT.js} +4 -4
- package/dist/{chunk-OXUY2A6L.js → chunk-ZVL7TY4K.js} +2 -2
- package/dist/{contracts-DRIuclVT.d.ts → contracts-CLqzJnOV.d.ts} +28 -17
- package/dist/{contracts-DRIuclVT.d.cts → contracts-CTOJXu-x.d.cts} +28 -17
- package/dist/data.cjs +198 -39
- package/dist/data.d.cts +119 -3
- package/dist/data.d.ts +119 -3
- package/dist/data.js +5 -5
- package/dist/devtools.cjs +18 -5
- package/dist/devtools.js +4 -4
- package/dist/ecosystem.cjs +64 -23
- package/dist/ecosystem.d.cts +2 -1
- package/dist/ecosystem.d.ts +2 -1
- package/dist/ecosystem.js +7 -7
- package/dist/extras.cjs +236 -49
- package/dist/extras.d.cts +3 -2
- package/dist/extras.d.ts +3 -2
- package/dist/extras.js +20 -20
- package/dist/index.cjs +259 -108
- package/dist/index.d.cts +193 -168
- package/dist/index.d.ts +193 -168
- package/dist/index.js +10 -10
- package/dist/motion.cjs +12 -4
- package/dist/motion.js +3 -3
- package/dist/patterns.cjs +28 -15
- package/dist/patterns.d.cts +2 -1
- package/dist/patterns.d.ts +2 -1
- package/dist/patterns.js +5 -5
- package/dist/performance.cjs +18 -5
- package/dist/performance.js +4 -4
- package/dist/plugins.cjs +118 -34
- package/dist/plugins.d.cts +124 -11
- package/dist/plugins.d.ts +124 -11
- package/dist/plugins.js +68 -26
- package/dist/ssr.cjs +54 -13
- package/dist/ssr.js +7 -7
- package/dist/{tagFactory-DFstCLQV.d.cts → tagFactory-8qL9LCIx.d.cts} +58 -19
- package/dist/{tagFactory-DkaNVUNV.d.ts → tagFactory-BL2fymez.d.ts} +58 -19
- package/dist/testing.cjs +15 -2
- package/dist/testing.js +2 -2
- package/dist/types-CJFViL6Q.d.cts +26 -0
- package/dist/types-CJFViL6Q.d.ts +26 -0
- package/dist/ui.cjs +28 -15
- package/dist/ui.d.cts +2 -1
- package/dist/ui.d.ts +2 -1
- package/dist/ui.js +7 -7
- package/dist/widgets.cjs +22 -14
- package/dist/widgets.js +6 -6
- package/package.json +4 -2
|
@@ -135,40 +135,40 @@ import {
|
|
|
135
135
|
use,
|
|
136
136
|
var_,
|
|
137
137
|
video
|
|
138
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-7LUJQAOJ.js";
|
|
139
139
|
import {
|
|
140
140
|
trustHTML
|
|
141
141
|
} from "./chunk-HURREPU2.js";
|
|
142
142
|
import {
|
|
143
143
|
watch
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-SLM3IA34.js";
|
|
145
145
|
import {
|
|
146
146
|
__resetIdCounter,
|
|
147
147
|
createId,
|
|
148
148
|
domBinding
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-BC2SECJD.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-UOL2ECCS.js";
|
|
157
157
|
import {
|
|
158
158
|
bindAttribute,
|
|
159
159
|
bindDynamic,
|
|
160
160
|
setSafeAttribute
|
|
161
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-FNJXNGYZ.js";
|
|
162
162
|
import {
|
|
163
163
|
derived
|
|
164
|
-
} from "./chunk-
|
|
164
|
+
} from "./chunk-RUSSKG6G.js";
|
|
165
165
|
import {
|
|
166
166
|
globalSingleton
|
|
167
167
|
} from "./chunk-7ZHH77QA.js";
|
|
168
168
|
import {
|
|
169
169
|
effect,
|
|
170
170
|
on
|
|
171
|
-
} from "./chunk-
|
|
171
|
+
} from "./chunk-WEQ3DMVL.js";
|
|
172
172
|
import {
|
|
173
173
|
disableSSR,
|
|
174
174
|
enableSSR,
|
|
@@ -187,8 +187,9 @@ import {
|
|
|
187
187
|
external,
|
|
188
188
|
isBatching,
|
|
189
189
|
signal
|
|
190
|
-
} from "./chunk-
|
|
190
|
+
} from "./chunk-FQRUXCEE.js";
|
|
191
191
|
import {
|
|
192
|
+
emitDevtools,
|
|
192
193
|
notifySubscribers,
|
|
193
194
|
reactiveBinding,
|
|
194
195
|
recordDependency,
|
|
@@ -198,7 +199,7 @@ import {
|
|
|
198
199
|
suspendTracking,
|
|
199
200
|
track,
|
|
200
201
|
untracked
|
|
201
|
-
} from "./chunk-
|
|
202
|
+
} from "./chunk-JWKYU5GV.js";
|
|
202
203
|
import {
|
|
203
204
|
DEV,
|
|
204
205
|
MAX_DRAIN_TEARDOWNS,
|
|
@@ -216,7 +217,8 @@ import {
|
|
|
216
217
|
reportDrainRunaway,
|
|
217
218
|
reportError,
|
|
218
219
|
setRuntimeErrorHandler,
|
|
219
|
-
unregisterDisposer
|
|
220
|
+
unregisterDisposer,
|
|
221
|
+
withDisposerRollback
|
|
220
222
|
} from "./chunk-NYNYSPK7.js";
|
|
221
223
|
|
|
222
224
|
// index.ts
|
|
@@ -557,10 +559,13 @@ function safeCall(cb, hookName) {
|
|
|
557
559
|
return void 0;
|
|
558
560
|
}
|
|
559
561
|
}
|
|
560
|
-
function runMountCallback(callback, hookName, element) {
|
|
562
|
+
function runMountCallback(callback, hookName, element, isDisposed) {
|
|
561
563
|
const cleanup = safeCall(callback, hookName);
|
|
562
|
-
if (typeof cleanup
|
|
563
|
-
|
|
564
|
+
if (typeof cleanup !== "function") return;
|
|
565
|
+
if (isDisposed() || !element.isConnected) {
|
|
566
|
+
safeCall(cleanup, "onUnmount");
|
|
567
|
+
} else {
|
|
568
|
+
onUnmount(cleanup, element);
|
|
564
569
|
}
|
|
565
570
|
}
|
|
566
571
|
var mountWatchers = /* @__PURE__ */ new WeakMap();
|
|
@@ -722,25 +727,26 @@ function onMount(callback, element) {
|
|
|
722
727
|
if (typeof document === "undefined") return;
|
|
723
728
|
if (element) {
|
|
724
729
|
let disposed = false;
|
|
730
|
+
const isDisposed = () => disposed;
|
|
725
731
|
registerDisposer(element, () => {
|
|
726
732
|
disposed = true;
|
|
727
733
|
});
|
|
728
734
|
if (element.isConnected) {
|
|
729
735
|
queueMicrotask(() => {
|
|
730
736
|
if (disposed) return;
|
|
731
|
-
runMountCallback(callback, "onMount", element);
|
|
737
|
+
runMountCallback(callback, "onMount", element, isDisposed);
|
|
732
738
|
});
|
|
733
739
|
return;
|
|
734
740
|
}
|
|
735
741
|
queueMicrotask(() => {
|
|
736
742
|
if (disposed) return;
|
|
737
743
|
if (element.isConnected) {
|
|
738
|
-
runMountCallback(callback, "onMount", element);
|
|
744
|
+
runMountCallback(callback, "onMount", element, isDisposed);
|
|
739
745
|
return;
|
|
740
746
|
}
|
|
741
747
|
const unregister = registerMountWatcher(element, () => {
|
|
742
748
|
if (disposed) return;
|
|
743
|
-
runMountCallback(callback, "onMount", element);
|
|
749
|
+
runMountCallback(callback, "onMount", element, isDisposed);
|
|
744
750
|
});
|
|
745
751
|
registerDisposer(element, unregister);
|
|
746
752
|
});
|
|
@@ -1574,36 +1580,34 @@ function Loading(props = {}) {
|
|
|
1574
1580
|
const { text: text2, variant = "spinner", size = "md" } = props;
|
|
1575
1581
|
const sizeClass = size !== "md" ? ` sibu-loading-${size}` : "";
|
|
1576
1582
|
if (variant === "dots") {
|
|
1577
|
-
return div(
|
|
1583
|
+
return div(
|
|
1584
|
+
{
|
|
1585
|
+
class: `sibu-loading${sizeClass}`,
|
|
1586
|
+
role: "status",
|
|
1587
|
+
"aria-live": "polite",
|
|
1588
|
+
// When there's no visible text, give the live region an accessible name
|
|
1589
|
+
// so it isn't announced as an empty status.
|
|
1590
|
+
"aria-label": text2 ? void 0 : "Loading"
|
|
1591
|
+
},
|
|
1592
|
+
[
|
|
1593
|
+
div({ class: "sibu-loading-dots" }, [
|
|
1594
|
+
span({ class: "sibu-loading-dot" }),
|
|
1595
|
+
span({ class: "sibu-loading-dot" }),
|
|
1596
|
+
span({ class: "sibu-loading-dot" })
|
|
1597
|
+
]),
|
|
1598
|
+
text2 ? span({ class: "sibu-loading-text" }, text2) : null
|
|
1599
|
+
]
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
return div(
|
|
1603
|
+
{
|
|
1578
1604
|
class: `sibu-loading${sizeClass}`,
|
|
1579
1605
|
role: "status",
|
|
1580
1606
|
"aria-live": "polite",
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
div({
|
|
1586
|
-
class: "sibu-loading-dots",
|
|
1587
|
-
nodes: [
|
|
1588
|
-
span({ class: "sibu-loading-dot" }),
|
|
1589
|
-
span({ class: "sibu-loading-dot" }),
|
|
1590
|
-
span({ class: "sibu-loading-dot" })
|
|
1591
|
-
]
|
|
1592
|
-
}),
|
|
1593
|
-
text2 ? span({ class: "sibu-loading-text", nodes: text2 }) : null
|
|
1594
|
-
].filter(Boolean)
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
return div({
|
|
1598
|
-
class: `sibu-loading${sizeClass}`,
|
|
1599
|
-
role: "status",
|
|
1600
|
-
"aria-live": "polite",
|
|
1601
|
-
"aria-label": text2 ? void 0 : "Loading",
|
|
1602
|
-
nodes: [
|
|
1603
|
-
div({ class: "sibu-loading-spinner" }),
|
|
1604
|
-
text2 ? span({ class: "sibu-loading-text", nodes: text2 }) : null
|
|
1605
|
-
].filter(Boolean)
|
|
1606
|
-
});
|
|
1607
|
+
"aria-label": text2 ? void 0 : "Loading"
|
|
1608
|
+
},
|
|
1609
|
+
[div({ class: "sibu-loading-spinner" }), text2 ? span({ class: "sibu-loading-text" }, text2) : null]
|
|
1610
|
+
);
|
|
1607
1611
|
}
|
|
1608
1612
|
|
|
1609
1613
|
// src/core/rendering/action.ts
|
|
@@ -1714,8 +1718,9 @@ var globalErrorHandler = null;
|
|
|
1714
1718
|
function catchError(fn, onError) {
|
|
1715
1719
|
try {
|
|
1716
1720
|
const result = fn();
|
|
1717
|
-
|
|
1718
|
-
|
|
1721
|
+
const adopted = adoptThenable(result);
|
|
1722
|
+
if (adopted) {
|
|
1723
|
+
adopted.then(void 0, (err) => {
|
|
1719
1724
|
if (onError) {
|
|
1720
1725
|
onError(err, "async");
|
|
1721
1726
|
} else if (globalErrorHandler) {
|
|
@@ -1839,7 +1844,7 @@ function when(condition, thenBranch, elseBranch) {
|
|
|
1839
1844
|
const show2 = condition();
|
|
1840
1845
|
const parent = anchor.parentNode;
|
|
1841
1846
|
if (!parent) return;
|
|
1842
|
-
if (initialized && show2
|
|
1847
|
+
if (initialized && Object.is(show2, lastCondition)) return;
|
|
1843
1848
|
lastCondition = show2;
|
|
1844
1849
|
const focused = currentNode ? captureFocusWithin([currentNode]) : null;
|
|
1845
1850
|
if (currentNode?.parentNode) {
|
|
@@ -1848,7 +1853,7 @@ function when(condition, thenBranch, elseBranch) {
|
|
|
1848
1853
|
currentNode = null;
|
|
1849
1854
|
}
|
|
1850
1855
|
const branch = show2 ? thenBranch : elseBranch !== void 0 ? elseBranch : null;
|
|
1851
|
-
const attached = attachBranch(parent, anchor, branch, attachedOnce, "when");
|
|
1856
|
+
const attached = untracked(() => attachBranch(parent, anchor, branch, attachedOnce, "when"));
|
|
1852
1857
|
currentNode = attached.node;
|
|
1853
1858
|
currentNodeOwned = attached.owned;
|
|
1854
1859
|
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "when");
|
|
@@ -1888,7 +1893,7 @@ function match(value, cases, fallback) {
|
|
|
1888
1893
|
currentNode = null;
|
|
1889
1894
|
}
|
|
1890
1895
|
const branch = Object.hasOwn(cases, key) ? cases[key] : fallback;
|
|
1891
|
-
const attached = attachBranch(parent, anchor, branch ?? null, attachedOnce, "match");
|
|
1896
|
+
const attached = untracked(() => attachBranch(parent, anchor, branch ?? null, attachedOnce, "match"));
|
|
1892
1897
|
currentNode = attached.node;
|
|
1893
1898
|
currentNodeOwned = attached.owned;
|
|
1894
1899
|
restoreFocusWithin(focused, currentNode ? [currentNode] : [], "match");
|
|
@@ -1912,11 +1917,17 @@ var componentRegistry = globalSingleton(
|
|
|
1912
1917
|
/* @__PURE__ */ Symbol.for("sibujs.components.registry.v1"),
|
|
1913
1918
|
() => /* @__PURE__ */ new Map()
|
|
1914
1919
|
);
|
|
1920
|
+
var registryVersion = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.components.registryVersion.v1"), () => signal(0));
|
|
1921
|
+
function bumpRegistry() {
|
|
1922
|
+
const [read, write] = registryVersion;
|
|
1923
|
+
write(untracked(read) + 1);
|
|
1924
|
+
}
|
|
1915
1925
|
function registerComponent(name, component) {
|
|
1916
1926
|
componentRegistry.set(name, component);
|
|
1927
|
+
bumpRegistry();
|
|
1917
1928
|
}
|
|
1918
1929
|
function unregisterComponent(name) {
|
|
1919
|
-
componentRegistry.delete(name);
|
|
1930
|
+
if (componentRegistry.delete(name)) bumpRegistry();
|
|
1920
1931
|
}
|
|
1921
1932
|
function resolveComponent(name) {
|
|
1922
1933
|
const component = componentRegistry.get(name);
|
|
@@ -1927,14 +1938,21 @@ function resolveComponent(name) {
|
|
|
1927
1938
|
}
|
|
1928
1939
|
function DynamicComponent(is) {
|
|
1929
1940
|
const container = div({ class: "sibu-dynamic" });
|
|
1941
|
+
const NONE = {};
|
|
1942
|
+
let shown = NONE;
|
|
1930
1943
|
function render() {
|
|
1931
1944
|
const target = is();
|
|
1932
|
-
let
|
|
1945
|
+
let component;
|
|
1933
1946
|
if (typeof target === "function") {
|
|
1934
|
-
|
|
1947
|
+
component = target;
|
|
1935
1948
|
} else {
|
|
1936
|
-
|
|
1949
|
+
registryVersion[0]();
|
|
1950
|
+
component = componentRegistry.get(target);
|
|
1937
1951
|
}
|
|
1952
|
+
const next = component ?? `missing:${target}`;
|
|
1953
|
+
if (next === shown) return;
|
|
1954
|
+
const el = untracked(() => component ? component() : div(`[Component "${target}" not found]`));
|
|
1955
|
+
shown = next;
|
|
1938
1956
|
replaceChildrenSafely(container, el);
|
|
1939
1957
|
}
|
|
1940
1958
|
const untrack = track(render);
|
|
@@ -2198,27 +2216,26 @@ function Fragment(nodes) {
|
|
|
2198
2216
|
if (Array.isArray(child)) {
|
|
2199
2217
|
for (const nested of child) {
|
|
2200
2218
|
if (nested == null || typeof nested === "boolean") continue;
|
|
2201
|
-
|
|
2219
|
+
appendChild(frag, nested);
|
|
2202
2220
|
}
|
|
2203
2221
|
} else {
|
|
2204
|
-
|
|
2222
|
+
appendChild(frag, child);
|
|
2205
2223
|
}
|
|
2206
2224
|
}
|
|
2207
2225
|
return frag;
|
|
2208
2226
|
}
|
|
2209
|
-
function
|
|
2210
|
-
if (child == null) {
|
|
2211
|
-
return document.createTextNode("");
|
|
2212
|
-
}
|
|
2227
|
+
function appendChild(frag, child) {
|
|
2213
2228
|
if (child instanceof Node) {
|
|
2214
|
-
|
|
2229
|
+
frag.appendChild(child);
|
|
2230
|
+
return;
|
|
2215
2231
|
}
|
|
2216
2232
|
if (typeof child === "function") {
|
|
2217
|
-
const
|
|
2218
|
-
|
|
2219
|
-
|
|
2233
|
+
const placeholder = document.createComment("");
|
|
2234
|
+
frag.appendChild(placeholder);
|
|
2235
|
+
registerDisposer(placeholder, bindChildNode(placeholder, child));
|
|
2236
|
+
return;
|
|
2220
2237
|
}
|
|
2221
|
-
|
|
2238
|
+
frag.appendChild(document.createTextNode(String(child)));
|
|
2222
2239
|
}
|
|
2223
2240
|
|
|
2224
2241
|
// src/core/rendering/htm.ts
|
|
@@ -2688,25 +2705,77 @@ function mount(component, container) {
|
|
|
2688
2705
|
typeof component === "function" || component instanceof Node,
|
|
2689
2706
|
"mount: first argument must be a component function or a DOM Node."
|
|
2690
2707
|
);
|
|
2691
|
-
const
|
|
2692
|
-
const
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2708
|
+
const now = () => typeof performance !== "undefined" ? performance.now() : 0;
|
|
2709
|
+
const startTime = now();
|
|
2710
|
+
let range = null;
|
|
2711
|
+
const attach = (built) => {
|
|
2712
|
+
if (built instanceof DocumentFragment) {
|
|
2713
|
+
const start = document.createComment("");
|
|
2714
|
+
const end = document.createComment("");
|
|
2715
|
+
built.insertBefore(start, built.firstChild);
|
|
2716
|
+
built.appendChild(end);
|
|
2717
|
+
range = { start, end };
|
|
2718
|
+
}
|
|
2719
|
+
container.appendChild(built);
|
|
2720
|
+
};
|
|
2721
|
+
let node;
|
|
2722
|
+
if (typeof component === "function") {
|
|
2723
|
+
node = withDisposerRollback(() => {
|
|
2724
|
+
const built = component();
|
|
2725
|
+
attach(built);
|
|
2726
|
+
return built;
|
|
2727
|
+
});
|
|
2728
|
+
} else {
|
|
2729
|
+
node = component;
|
|
2730
|
+
attach(node);
|
|
2698
2731
|
}
|
|
2732
|
+
const duration = now() - startTime;
|
|
2733
|
+
const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
2734
|
+
if (hook) emitDevtools(hook, "app:init", { rootElement: node, container, duration });
|
|
2735
|
+
const mounted = range;
|
|
2699
2736
|
return {
|
|
2700
2737
|
node,
|
|
2701
2738
|
unmount() {
|
|
2702
|
-
if (hook) hook
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2739
|
+
if (hook) emitDevtools(hook, "app:unmount", { rootElement: node });
|
|
2740
|
+
if (mounted) {
|
|
2741
|
+
unmountRange(mounted.start, mounted.end);
|
|
2742
|
+
return;
|
|
2706
2743
|
}
|
|
2744
|
+
dispose(node);
|
|
2745
|
+
node.parentNode?.removeChild(node);
|
|
2707
2746
|
}
|
|
2708
2747
|
};
|
|
2709
2748
|
}
|
|
2749
|
+
function unmountRange(start, end) {
|
|
2750
|
+
const parent = start.parentNode;
|
|
2751
|
+
if (!parent && !end.parentNode) return;
|
|
2752
|
+
let budget = MAX_DRAIN_TEARDOWNS;
|
|
2753
|
+
for (let n = start.nextSibling; n && n !== end; n = n.nextSibling) budget++;
|
|
2754
|
+
let before = start;
|
|
2755
|
+
let after = null;
|
|
2756
|
+
let intact = true;
|
|
2757
|
+
for (; ; ) {
|
|
2758
|
+
if (start.parentNode !== parent || end.parentNode !== parent) intact = false;
|
|
2759
|
+
else if (start.previousSibling !== before || end.nextSibling !== after) {
|
|
2760
|
+
before = start.previousSibling;
|
|
2761
|
+
after = end.nextSibling;
|
|
2762
|
+
intact = !!(start.compareDocumentPosition(end) & 4);
|
|
2763
|
+
}
|
|
2764
|
+
const n = start.nextSibling;
|
|
2765
|
+
if (!intact || n === end) break;
|
|
2766
|
+
if (budget-- <= 0) {
|
|
2767
|
+
reportDrainRunaway("mount", MAX_DRAIN_TEARDOWNS, 1);
|
|
2768
|
+
return;
|
|
2769
|
+
}
|
|
2770
|
+
dispose(n);
|
|
2771
|
+
if (n.parentNode === parent) parent.removeChild(n);
|
|
2772
|
+
}
|
|
2773
|
+
if (!intact) {
|
|
2774
|
+
reportError(new Error("[SibuJS mount] fragment markers lost"), { phase: "cleanup", name: "mount" });
|
|
2775
|
+
}
|
|
2776
|
+
start.parentNode?.removeChild(start);
|
|
2777
|
+
end.parentNode?.removeChild(end);
|
|
2778
|
+
}
|
|
2710
2779
|
|
|
2711
2780
|
// src/core/rendering/portal.ts
|
|
2712
2781
|
function Portal(nodes, target) {
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
} from "./chunk-H3SRKIYX.js";
|
|
5
5
|
import {
|
|
6
6
|
derived
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RUSSKG6G.js";
|
|
8
8
|
import {
|
|
9
9
|
effect
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WEQ3DMVL.js";
|
|
11
11
|
import {
|
|
12
12
|
batch,
|
|
13
13
|
signal
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FQRUXCEE.js";
|
|
15
15
|
import {
|
|
16
16
|
DEV,
|
|
17
17
|
devWarn,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
watch
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SLM3IA34.js";
|
|
4
4
|
import {
|
|
5
5
|
createId,
|
|
6
6
|
domBinding,
|
|
7
7
|
idSegment
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-BC2SECJD.js";
|
|
9
9
|
import {
|
|
10
10
|
derived
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RUSSKG6G.js";
|
|
12
12
|
import {
|
|
13
13
|
stripHtml
|
|
14
14
|
} from "./chunk-2INLLLMZ.js";
|
|
15
15
|
import {
|
|
16
16
|
batch,
|
|
17
17
|
signal
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-FQRUXCEE.js";
|
|
19
19
|
|
|
20
20
|
// src/widgets/Combobox.ts
|
|
21
21
|
var boundComboboxes = /* @__PURE__ */ new WeakMap();
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
} from "./chunk-7ZHH77QA.js";
|
|
10
10
|
import {
|
|
11
11
|
effect
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WEQ3DMVL.js";
|
|
13
13
|
import {
|
|
14
14
|
batch,
|
|
15
15
|
signal
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FQRUXCEE.js";
|
|
17
17
|
import {
|
|
18
18
|
reportError
|
|
19
19
|
} from "./chunk-NYNYSPK7.js";
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { C as Component } from './types-CJFViL6Q.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Higher-order component utilities for SibuJS.
|
|
3
5
|
* These functions wrap or compose components to add behavior.
|
|
6
|
+
*
|
|
7
|
+
* Each helper is generic over the wrapped component's root type `R`, so a
|
|
8
|
+
* component returning `div()` keeps its `HTMLDivElement` root and an SVG
|
|
9
|
+
* component works as well. `R` defaults to `HTMLElement`, the type these
|
|
10
|
+
* helpers used before, for callers that pass the type arguments explicitly.
|
|
4
11
|
*/
|
|
5
|
-
|
|
12
|
+
|
|
6
13
|
/**
|
|
7
14
|
* Wraps a component with additional behavior that runs before/after rendering.
|
|
8
15
|
*
|
|
@@ -18,7 +25,7 @@ type Component<P = unknown> = (props: P) => HTMLElement;
|
|
|
18
25
|
* });
|
|
19
26
|
* ```
|
|
20
27
|
*/
|
|
21
|
-
declare function withWrapper<P>(WrappedComponent: Component<P>, wrapper: (component: Component<P>, props: P) =>
|
|
28
|
+
declare function withWrapper<P, R extends Node = HTMLElement, W extends Node = R>(WrappedComponent: Component<P, R>, wrapper: (component: Component<P, R>, props: P) => W): Component<P, W>;
|
|
22
29
|
/**
|
|
23
30
|
* Adds default props to a component. Missing props are filled from defaults.
|
|
24
31
|
*
|
|
@@ -38,9 +45,9 @@ declare function withWrapper<P>(WrappedComponent: Component<P>, wrapper: (compon
|
|
|
38
45
|
* optional status.
|
|
39
46
|
*/
|
|
40
47
|
type WithDefaultsProps<P, D> = Omit<P, keyof D> & Partial<Pick<P, Extract<keyof P, keyof D>>>;
|
|
41
|
-
declare function withDefaults<P extends object, const D extends Partial<P> = Partial<P
|
|
48
|
+
declare function withDefaults<P extends object, const D extends Partial<P> = Partial<P>, R extends Node = HTMLElement>(component: Component<P, R>, defaults: D & {
|
|
42
49
|
[K in Exclude<keyof D, keyof P>]: never;
|
|
43
|
-
}): Component<WithDefaultsProps<P, D
|
|
50
|
+
}): Component<WithDefaultsProps<P, D>, R>;
|
|
44
51
|
/**
|
|
45
52
|
* Composes multiple HOC wrappers into a single wrapper.
|
|
46
53
|
* Applied from right to left (like function composition).
|
|
@@ -54,7 +61,7 @@ declare function withDefaults<P extends object, const D extends Partial<P> = Par
|
|
|
54
61
|
* const EnhancedPage = enhance(Page);
|
|
55
62
|
* ```
|
|
56
63
|
*/
|
|
57
|
-
declare function compose(...wrappers: Array<(component:
|
|
64
|
+
declare function compose<C extends Component<never, Node> = Component<unknown, HTMLElement>>(...wrappers: Array<(component: C) => C>): (component: C) => C;
|
|
58
65
|
|
|
59
66
|
/**
|
|
60
67
|
* RenderProp implements the render-prop pattern.
|
|
@@ -83,6 +90,7 @@ declare function createSlots(slots: Record<string, () => HTMLElement | HTMLEleme
|
|
|
83
90
|
* Provides utilities to define typed components with prop defaults,
|
|
84
91
|
* nodes slots, and prop mapping — all with full TypeScript inference.
|
|
85
92
|
*/
|
|
93
|
+
|
|
86
94
|
/**
|
|
87
95
|
* Extract the props type from a component defined with defineComponent.
|
|
88
96
|
*
|
|
@@ -94,7 +102,7 @@ declare function createSlots(slots: Record<string, () => HTMLElement | HTMLEleme
|
|
|
94
102
|
* type ButtonProps = ComponentProps<typeof Button>; // { label: string }
|
|
95
103
|
* ```
|
|
96
104
|
*/
|
|
97
|
-
type ComponentProps<T> = T extends (props: infer P) =>
|
|
105
|
+
type ComponentProps<T> = T extends (props: infer P) => Node ? P : never;
|
|
98
106
|
/**
|
|
99
107
|
* Props that include an optional nodes slot.
|
|
100
108
|
*/
|
|
@@ -104,11 +112,14 @@ type WithNodes<Props> = Props & {
|
|
|
104
112
|
/**
|
|
105
113
|
* Define a typed component with props inference, defaults, and a setup function.
|
|
106
114
|
*
|
|
107
|
-
* The `setup` function receives merged props (defaults + provided) and
|
|
108
|
-
*
|
|
115
|
+
* The `setup` function receives merged props (defaults + provided) and
|
|
116
|
+
* returns the component's root. TypeScript infers the full props type from the
|
|
117
|
+
* generic. `R` is the root type; it defaults to `HTMLElement` (every HTML tag
|
|
118
|
+
* factory's result fits) — pass it explicitly for an SVG root
|
|
119
|
+
* (`defineComponent<Props, SVGSVGElement>`).
|
|
109
120
|
*
|
|
110
121
|
* @param config Component configuration with optional defaults and a setup function
|
|
111
|
-
* @returns A component function that accepts props and returns
|
|
122
|
+
* @returns A component function that accepts props and returns the root
|
|
112
123
|
*
|
|
113
124
|
* @example
|
|
114
125
|
* ```ts
|
|
@@ -125,10 +136,10 @@ type WithNodes<Props> = Props & {
|
|
|
125
136
|
* // Usage: Button({ label: 'Click me' }) — TypeScript infers props
|
|
126
137
|
* ```
|
|
127
138
|
*/
|
|
128
|
-
declare function defineComponent<Props extends object>(config: {
|
|
139
|
+
declare function defineComponent<Props extends object, R extends Node = HTMLElement>(config: {
|
|
129
140
|
defaults?: Partial<Props>;
|
|
130
|
-
setup: (props: Props) =>
|
|
131
|
-
}):
|
|
141
|
+
setup: (props: Props) => R;
|
|
142
|
+
}): Component<Props, R>;
|
|
132
143
|
/**
|
|
133
144
|
* Create a component with nodes slot support.
|
|
134
145
|
*
|
|
@@ -137,7 +148,7 @@ declare function defineComponent<Props extends object>(config: {
|
|
|
137
148
|
* wraps arbitrary child content.
|
|
138
149
|
*
|
|
139
150
|
* @param config Component configuration with optional defaults and a setup function
|
|
140
|
-
* @returns A component function that accepts props (including nodes) and returns
|
|
151
|
+
* @returns A component function that accepts props (including nodes) and returns the root
|
|
141
152
|
*
|
|
142
153
|
* @example
|
|
143
154
|
* ```ts
|
|
@@ -156,10 +167,10 @@ declare function defineComponent<Props extends object>(config: {
|
|
|
156
167
|
* // Usage: Card({ title: 'Hello', nodes: p('World') })
|
|
157
168
|
* ```
|
|
158
169
|
*/
|
|
159
|
-
declare function defineSlottedComponent<Props extends object>(config: {
|
|
170
|
+
declare function defineSlottedComponent<Props extends object, R extends Node = HTMLElement>(config: {
|
|
160
171
|
defaults?: Partial<Props>;
|
|
161
|
-
setup: (props: WithNodes<Props>) =>
|
|
162
|
-
}):
|
|
172
|
+
setup: (props: WithNodes<Props>) => R;
|
|
173
|
+
}): Component<WithNodes<Props>, R>;
|
|
163
174
|
/**
|
|
164
175
|
* Higher-order helper to create a component that maps outer props to inner props.
|
|
165
176
|
*
|
|
@@ -185,7 +196,7 @@ declare function defineSlottedComponent<Props extends object>(config: {
|
|
|
185
196
|
* // Usage: SmallIconButton({ icon: 'star', label: 'Favorite' })
|
|
186
197
|
* ```
|
|
187
198
|
*/
|
|
188
|
-
declare function withProps<OuterProps extends object, InnerProps extends object>(component:
|
|
199
|
+
declare function withProps<OuterProps extends object, InnerProps extends object, R extends Node = HTMLElement>(component: Component<InnerProps, R>, mapProps: (outer: OuterProps) => InnerProps): Component<OuterProps, R>;
|
|
189
200
|
|
|
190
201
|
/**
|
|
191
202
|
* Runtime prop validation and strict typing contracts for SibuJS.
|