what-core 0.12.2 → 0.12.3
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/dist/chunk-JVEPLFIB.min.js +11 -0
- package/dist/{chunk-NCPX66TV.min.js → chunk-VTPLA4AS.min.js} +1 -1
- package/dist/index.min.js +5 -5
- package/dist/render.min.js +1 -1
- package/dist/testing.min.js +1 -1
- package/package.json +1 -1
- package/src/agent-context.js +1 -1
- package/src/data.js +89 -23
- package/src/dom.js +52 -0
- package/src/index.js +6 -0
- package/src/render.js +394 -41
- package/dist/chunk-RXISSKLI.min.js +0 -11
package/src/render.js
CHANGED
|
@@ -196,7 +196,20 @@ export function insert(parent, child, marker) {
|
|
|
196
196
|
let current = null;
|
|
197
197
|
let textNode = null; // non-null while on the text fast path
|
|
198
198
|
let mounted = false;
|
|
199
|
-
|
|
199
|
+
// Capture the owning component at CREATION time. See the identical capture
|
|
200
|
+
// in createDOM's reactive branch (dom.js): this effect re-runs long after
|
|
201
|
+
// the synchronous render that created it, when the component stack is
|
|
202
|
+
// empty, so everything it builds on a re-run got parentCtx = null and the
|
|
203
|
+
// owner chain was severed. useContext then fell through to the context
|
|
204
|
+
// DEFAULT, and an ErrorBoundary stopped catching throws from components
|
|
205
|
+
// created by an inner region. Both work on first paint and only break once
|
|
206
|
+
// the app is interactive, which is why nothing caught it.
|
|
207
|
+
//
|
|
208
|
+
// dom.js was given this fix; this path, the one the COMPILER emits for
|
|
209
|
+
// every `{() => ...}`, was not. So it was broken for exactly the users on
|
|
210
|
+
// the recommended build setup.
|
|
211
|
+
const owner = captureOwner();
|
|
212
|
+
effect(() => withOwner(owner, () => {
|
|
200
213
|
const val = child();
|
|
201
214
|
const vt = typeof val;
|
|
202
215
|
if (!mounted) {
|
|
@@ -223,7 +236,7 @@ export function insert(parent, child, marker) {
|
|
|
223
236
|
// Type changed (or never was text) — full reconcile
|
|
224
237
|
textNode = null;
|
|
225
238
|
current = reconcileInsert(parent, val, current, m);
|
|
226
|
-
});
|
|
239
|
+
}));
|
|
227
240
|
return current;
|
|
228
241
|
}
|
|
229
242
|
|
|
@@ -263,6 +276,32 @@ function isSvgParent(parent) {
|
|
|
263
276
|
&& parent.tagName !== 'foreignObject';
|
|
264
277
|
}
|
|
265
278
|
|
|
279
|
+
// --- Owner capture for effects that outlive their render ---
|
|
280
|
+
//
|
|
281
|
+
// A reactive region's effect re-runs long after the synchronous render that
|
|
282
|
+
// created it, when the component stack has unwound. Anything it builds then has
|
|
283
|
+
// no owning component, which severs the chain that useContext and the
|
|
284
|
+
// ErrorBoundary / Suspense lookups both walk. Capturing the owner at creation
|
|
285
|
+
// and re-pushing it for the duration of each re-run restores it.
|
|
286
|
+
|
|
287
|
+
function captureOwner() {
|
|
288
|
+
const stack = getComponentStack();
|
|
289
|
+
return stack[stack.length - 1] || null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function withOwner(owner, fn) {
|
|
293
|
+
const stack = getComponentStack();
|
|
294
|
+
// Already on top during the initial synchronous run; only re-push when the
|
|
295
|
+
// stack has since unwound.
|
|
296
|
+
const restore = owner !== null && stack[stack.length - 1] !== owner;
|
|
297
|
+
if (restore) stack.push(owner);
|
|
298
|
+
try {
|
|
299
|
+
return fn();
|
|
300
|
+
} finally {
|
|
301
|
+
if (restore) stack.pop();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
266
305
|
function asNodeArray(value) {
|
|
267
306
|
if (value == null) return [];
|
|
268
307
|
return Array.isArray(value) ? value : [value];
|
|
@@ -504,9 +543,36 @@ export function mapArray(source, mapFn, options) {
|
|
|
504
543
|
return endMarker;
|
|
505
544
|
};
|
|
506
545
|
inserter._mapArray = true;
|
|
546
|
+
// The server has no DOM to insert into, so it cannot call the inserter at all.
|
|
547
|
+
// Without these it fell through to the generic reactive-child branch, which
|
|
548
|
+
// calls the value with no arguments: `parent` was undefined, the insertBefore
|
|
549
|
+
// threw, SSR swallowed it, and every compiled keyed list rendered as an EMPTY
|
|
550
|
+
// container. Exposing the inputs lets the server produce the same rows the
|
|
551
|
+
// client will, in the same order, without touching a DOM.
|
|
552
|
+
inserter._mapArraySource = source;
|
|
553
|
+
inserter._mapArrayFn = mapFn;
|
|
554
|
+
inserter._mapArrayKeyed = !!keyFn && !raw;
|
|
507
555
|
return inserter;
|
|
508
556
|
}
|
|
509
557
|
|
|
558
|
+
/**
|
|
559
|
+
* Render a mapArray inserter's rows without a DOM. Server-side only.
|
|
560
|
+
*
|
|
561
|
+
* Mirrors the item protocol reconcileKeyed/reconcileList use, because a row
|
|
562
|
+
* built here is hydrated by one built there: keyed non-raw mode hands the mapFn
|
|
563
|
+
* a signal ACCESSOR (so `item()` works), every other mode hands it the raw item.
|
|
564
|
+
* Getting this wrong produces server HTML that differs from the client's on
|
|
565
|
+
* every row.
|
|
566
|
+
*/
|
|
567
|
+
export function _mapArrayToArray(inserter) {
|
|
568
|
+
const items = inserter._mapArraySource() || [];
|
|
569
|
+
const mapFn = inserter._mapArrayFn;
|
|
570
|
+
const keyed = inserter._mapArrayKeyed;
|
|
571
|
+
return items.map((item, index) => (
|
|
572
|
+
keyed ? mapFn(() => item, index) : mapFn(item, index)
|
|
573
|
+
));
|
|
574
|
+
}
|
|
575
|
+
|
|
510
576
|
function reconcileList(parent, endMarker, oldItems, newItems, mappedNodes, disposeFns, mapFn) {
|
|
511
577
|
const newLen = newItems.length;
|
|
512
578
|
const oldLen = oldItems.length;
|
|
@@ -1608,6 +1674,15 @@ export function hydrate(vnode, container) {
|
|
|
1608
1674
|
|
|
1609
1675
|
try {
|
|
1610
1676
|
const result = hydrateNode(vnode, container);
|
|
1677
|
+
// Same trim as every nested element, with one exclusion. A dedicated root
|
|
1678
|
+
// element holds nothing but the app, so anything the walk did not claim is
|
|
1679
|
+
// stranded server markup. <body> and <html> are different: they also hold
|
|
1680
|
+
// the script tags, the hydration payload and whatever the host page put
|
|
1681
|
+
// there, none of which the walk claims and none of which may be removed.
|
|
1682
|
+
// An app that hydrates into <body> keeps the old behavior.
|
|
1683
|
+
if (container !== document.body && container !== document.documentElement) {
|
|
1684
|
+
trimUnclaimed(container);
|
|
1685
|
+
}
|
|
1611
1686
|
return result;
|
|
1612
1687
|
} finally {
|
|
1613
1688
|
_isHydrating = false;
|
|
@@ -1615,6 +1690,34 @@ export function hydrate(vnode, container) {
|
|
|
1615
1690
|
}
|
|
1616
1691
|
}
|
|
1617
1692
|
|
|
1693
|
+
/**
|
|
1694
|
+
* Drop server-rendered nodes that the client's walk never claimed.
|
|
1695
|
+
*
|
|
1696
|
+
* Everything from the cursor to the end of `parent` is content the server
|
|
1697
|
+
* produced and the client tree has no child for. Nothing references it, no
|
|
1698
|
+
* effect owns it, and no later update can ever reach it: it is stranded markup
|
|
1699
|
+
* that simply stays on screen.
|
|
1700
|
+
*
|
|
1701
|
+
* The case that makes this necessary is a reactive region that is empty on the
|
|
1702
|
+
* client and was NOT empty on the server. An empty region deliberately claims
|
|
1703
|
+
* nothing (claiming took the following sibling and destroyed it, cascading a
|
|
1704
|
+
* warn-and-recreate through the rest of the parent), so the element the server
|
|
1705
|
+
* rendered in its place has nothing to remove it. A cart badge the server drew
|
|
1706
|
+
* for a signed-in visitor stayed visible to a signed-out one, underneath the
|
|
1707
|
+
* region that was supposed to have replaced it.
|
|
1708
|
+
*
|
|
1709
|
+
* The two halves are what make each other safe: the walk never destroys a node
|
|
1710
|
+
* it is unsure about, and this removes what the finished walk proves is unused.
|
|
1711
|
+
*/
|
|
1712
|
+
function trimUnclaimed(parent) {
|
|
1713
|
+
if (!_hydrationCursor || _hydrationCursor.parent !== parent) return;
|
|
1714
|
+
while (parent.childNodes.length > _hydrationCursor.index) {
|
|
1715
|
+
const node = parent.lastChild;
|
|
1716
|
+
disposeTree(node);
|
|
1717
|
+
parent.removeChild(node);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1618
1721
|
/**
|
|
1619
1722
|
* Claim the next DOM node from the hydration cursor.
|
|
1620
1723
|
* Returns the existing DOM node or null if none available.
|
|
@@ -1623,10 +1726,14 @@ function claimNode(parent) {
|
|
|
1623
1726
|
const children = parent.childNodes;
|
|
1624
1727
|
while (_hydrationCursor.index < children.length) {
|
|
1625
1728
|
const node = children[_hydrationCursor.index];
|
|
1626
|
-
// Skip hydration comment markers
|
|
1729
|
+
// Skip hydration comment markers. 'fn' / '/fn' are the reactive-region
|
|
1730
|
+
// markers hydration itself inserts as it walks (see the function branch of
|
|
1731
|
+
// hydrateNode); the cursor is adjusted when they go in, and skipping them
|
|
1732
|
+
// here keeps a later sibling from ever claiming one as its node.
|
|
1627
1733
|
if (node.nodeType === 8) { // Comment node
|
|
1628
1734
|
const text = node.textContent;
|
|
1629
|
-
if (text === '$' || text === '/$' || text === '[]' || text === '/[]'
|
|
1735
|
+
if (text === '$' || text === '/$' || text === '[]' || text === '/[]'
|
|
1736
|
+
|| text === 'fn' || text === '/fn') {
|
|
1630
1737
|
_hydrationCursor.index++;
|
|
1631
1738
|
continue;
|
|
1632
1739
|
}
|
|
@@ -1637,8 +1744,60 @@ function claimNode(parent) {
|
|
|
1637
1744
|
return null;
|
|
1638
1745
|
}
|
|
1639
1746
|
|
|
1747
|
+
/**
|
|
1748
|
+
* What claimNode would return next, without consuming it.
|
|
1749
|
+
*
|
|
1750
|
+
* Used by the branches that must decide whether the server left something
|
|
1751
|
+
* REUSABLE here before they commit to taking it. Claiming first and putting it
|
|
1752
|
+
* back is not possible: claiming is what advances the walk.
|
|
1753
|
+
*/
|
|
1754
|
+
function peekNode(parent) {
|
|
1755
|
+
if (!_hydrationCursor || _hydrationCursor.parent !== parent) return null;
|
|
1756
|
+
const children = parent.childNodes;
|
|
1757
|
+
for (let i = _hydrationCursor.index; i < children.length; i++) {
|
|
1758
|
+
const node = children[i];
|
|
1759
|
+
if (node.nodeType === 8) {
|
|
1760
|
+
const text = node.textContent;
|
|
1761
|
+
if (text === '$' || text === '/$' || text === '[]' || text === '/[]'
|
|
1762
|
+
|| text === 'fn' || text === '/fn') {
|
|
1763
|
+
continue;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
return node;
|
|
1767
|
+
}
|
|
1768
|
+
return null;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* Put a client-created node in at the cursor and advance past it.
|
|
1773
|
+
*
|
|
1774
|
+
* The mismatch fallbacks used to appendChild here, which puts the node at the
|
|
1775
|
+
* END of the parent rather than at the position being hydrated, and left the
|
|
1776
|
+
* cursor pointing AT it. Inside a reactive region that was fatal: the region's
|
|
1777
|
+
* end marker is placed at the cursor, so it landed BEFORE the content, the
|
|
1778
|
+
* region owned nothing, and it could never remove or replace what it had just
|
|
1779
|
+
* rendered. A `<Show>` whose server arm produced nothing showed its client arm
|
|
1780
|
+
* once and then ignored the signal forever.
|
|
1781
|
+
*/
|
|
1782
|
+
function insertAtCursor(parent, node) {
|
|
1783
|
+
if (_hydrationCursor && _hydrationCursor.parent === parent) {
|
|
1784
|
+
parent.insertBefore(node, parent.childNodes[_hydrationCursor.index] || null);
|
|
1785
|
+
_hydrationCursor.index++;
|
|
1786
|
+
} else {
|
|
1787
|
+
parent.appendChild(node);
|
|
1788
|
+
}
|
|
1789
|
+
return node;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
// Warnings only. Never gate a DOM CORRECTION on this: see the text branch below.
|
|
1793
|
+
//
|
|
1794
|
+
// This used to test `process.env.NODE_ENV` directly, which is unreachable in a
|
|
1795
|
+
// browser (there is no `process`), so hydration warnings could not fire in the
|
|
1796
|
+
// one environment where hydration actually runs. __DEV__ resolves the same
|
|
1797
|
+
// question across every environment, including a buildless browser app that
|
|
1798
|
+
// opts in with globalThis.__WHAT_DEV__.
|
|
1640
1799
|
function isDevMode() {
|
|
1641
|
-
return
|
|
1800
|
+
return __DEV__;
|
|
1642
1801
|
}
|
|
1643
1802
|
|
|
1644
1803
|
function hydrateNode(vnode, parent) {
|
|
@@ -1648,21 +1807,63 @@ function hydrateNode(vnode, parent) {
|
|
|
1648
1807
|
|
|
1649
1808
|
// Text node
|
|
1650
1809
|
if (typeof vnode === 'string' || typeof vnode === 'number') {
|
|
1651
|
-
const existing = claimNode(parent);
|
|
1652
1810
|
const text = String(vnode);
|
|
1653
1811
|
|
|
1812
|
+
// An empty string never DESTROYS anything to claim it.
|
|
1813
|
+
//
|
|
1814
|
+
// HTML cannot serialize an empty text node, so a reactive child that was
|
|
1815
|
+
// empty on the server emitted nothing at all. Claiming unconditionally took
|
|
1816
|
+
// the next sibling, saw an element where it wanted text, and replaced that
|
|
1817
|
+
// element with an empty text node: the server's real markup was destroyed,
|
|
1818
|
+
// every following sibling shifted, and a warn-and-recreate cascaded through
|
|
1819
|
+
// the rest of the parent. `{() => error()}` next to anything hit it.
|
|
1820
|
+
//
|
|
1821
|
+
// But refusing to claim ANYTHING was the opposite error. When the server
|
|
1822
|
+
// rendered real text here and the client now evaluates to '', the server's
|
|
1823
|
+
// text is exactly what has to be cleared. Skipping it left the stale value
|
|
1824
|
+
// on screen and then rendered the next value ALONGSIDE it ("9 items3
|
|
1825
|
+
// items"), because the region had adopted an empty node of its own while
|
|
1826
|
+
// the server's text sat outside it.
|
|
1827
|
+
//
|
|
1828
|
+
// So: claim a text node if one is there (the client value wins, same as
|
|
1829
|
+
// below), and claim nothing otherwise. The empty and non-empty cases now
|
|
1830
|
+
// differ only in refusing to consume a NON-text node.
|
|
1831
|
+
if (text === '') {
|
|
1832
|
+
const reusable = peekNode(parent);
|
|
1833
|
+
if (reusable && reusable.nodeType === 3) {
|
|
1834
|
+
claimNode(parent);
|
|
1835
|
+
reusable.textContent = '';
|
|
1836
|
+
return reusable;
|
|
1837
|
+
}
|
|
1838
|
+
return insertAtCursor(parent, document.createTextNode(''));
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
const existing = claimNode(parent);
|
|
1842
|
+
|
|
1654
1843
|
if (existing && existing.nodeType === 3) {
|
|
1655
|
-
// Reuse text node
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1844
|
+
// Reuse the text node, but the CLIENT value wins.
|
|
1845
|
+
//
|
|
1846
|
+
// Correcting the DOM used to sit inside the dev-only branch, and dev mode
|
|
1847
|
+
// was decided by `process.env.NODE_ENV`, which no browser has. The result
|
|
1848
|
+
// was that in every real browser a differing value was silently discarded
|
|
1849
|
+
// and the server's text stayed on screen until some later write happened
|
|
1850
|
+
// to touch that node. Any state the server cannot know (a cart restored
|
|
1851
|
+
// from localStorage, a saved theme, a relative timestamp) rendered stale
|
|
1852
|
+
// and looked like a broken store rather than a hydration bug.
|
|
1853
|
+
//
|
|
1854
|
+
// The correction is unconditional now. Only the warning is dev-gated.
|
|
1855
|
+
if (existing.textContent !== text) {
|
|
1856
|
+
if (isDevMode()) {
|
|
1857
|
+
console.warn(
|
|
1858
|
+
`[what] Hydration mismatch: expected text "${text}", got "${existing.textContent}"`
|
|
1859
|
+
);
|
|
1860
|
+
}
|
|
1660
1861
|
existing.textContent = text;
|
|
1661
1862
|
}
|
|
1662
1863
|
return existing;
|
|
1663
1864
|
}
|
|
1664
1865
|
|
|
1665
|
-
// Mismatch: expected text node, got element or nothing
|
|
1866
|
+
// Mismatch: expected text node, got element or nothing.
|
|
1666
1867
|
if (isDevMode()) {
|
|
1667
1868
|
console.warn(
|
|
1668
1869
|
`[what] Hydration mismatch: expected text node "${text}", got ${existing ? existing.nodeName : 'nothing'}. Falling back to client render.`
|
|
@@ -1672,7 +1873,7 @@ function hydrateNode(vnode, parent) {
|
|
|
1672
1873
|
if (existing) {
|
|
1673
1874
|
parent.replaceChild(textNode, existing);
|
|
1674
1875
|
} else {
|
|
1675
|
-
parent
|
|
1876
|
+
insertAtCursor(parent, textNode);
|
|
1676
1877
|
}
|
|
1677
1878
|
return textNode;
|
|
1678
1879
|
}
|
|
@@ -1682,21 +1883,140 @@ function hydrateNode(vnode, parent) {
|
|
|
1682
1883
|
return hydrateNode(vnode(), parent);
|
|
1683
1884
|
}
|
|
1684
1885
|
|
|
1685
|
-
//
|
|
1886
|
+
// Compiled keyed list. `.map()` with a key prop, and `<For>`, lower to a
|
|
1887
|
+
// mapArray INSERTER, which is a function taking (parent, marker) rather than a
|
|
1888
|
+
// thunk returning a value. The generic reactive branch below called it with no
|
|
1889
|
+
// arguments, so it threw on `parent.insertBefore` and the exception escaped
|
|
1890
|
+
// hydrate(): the whole page stopped hydrating and stayed inert. That is the
|
|
1891
|
+
// ordinary shape for a compiled app whose server HTML came from an uncompiled
|
|
1892
|
+
// render, which is exactly what the fullstack template produces.
|
|
1893
|
+
//
|
|
1894
|
+
// The list builds its own rows rather than claiming the server's. That is a
|
|
1895
|
+
// missed reuse, not a correctness problem: the inserter owns its end marker
|
|
1896
|
+
// and its effect from here on, and the server's rows are left unclaimed, so
|
|
1897
|
+
// trimUnclaimed removes them once the walk finishes. Claiming them properly
|
|
1898
|
+
// needs the list's own boundary markers in the server HTML, which is the same
|
|
1899
|
+
// thing reactive regions need and is tracked for 0.13.0.
|
|
1900
|
+
if (typeof vnode === 'function' && vnode._mapArray) {
|
|
1901
|
+
const cursorInParent = !!(_hydrationCursor && _hydrationCursor.parent === parent);
|
|
1902
|
+
const anchor = cursorInParent ? (parent.childNodes[_hydrationCursor.index] || null) : null;
|
|
1903
|
+
const endMarker = vnode(parent, anchor);
|
|
1904
|
+
if (cursorInParent) {
|
|
1905
|
+
const index = Array.prototype.indexOf.call(parent.childNodes, endMarker);
|
|
1906
|
+
if (index >= 0) _hydrationCursor.index = index + 1;
|
|
1907
|
+
}
|
|
1908
|
+
return endMarker;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
// Reactive function child: attach an effect to the existing nodes
|
|
1686
1912
|
if (typeof vnode === 'function') {
|
|
1687
|
-
//
|
|
1688
|
-
|
|
1689
|
-
|
|
1913
|
+
// Bound the region with the same comment markers the client render path
|
|
1914
|
+
// uses (see the reactive-function branch of createDOM in dom.js). Hydration
|
|
1915
|
+
// used to create none, and paid for it twice on the first update:
|
|
1916
|
+
//
|
|
1917
|
+
// - reconcileInsert was handed a null marker, so it had no insertion
|
|
1918
|
+
// point and appended to the END of the parent. A hydrated <Show> that
|
|
1919
|
+
// flipped arms jumped to the bottom of its container, because a
|
|
1920
|
+
// component realizes to a DocumentFragment and fragments deliberately
|
|
1921
|
+
// skip the replace-in-place fast path.
|
|
1922
|
+
// - the effect's disposer was attached to the CONTENT node, so removing
|
|
1923
|
+
// that content disposed the effect. The region then stopped reacting
|
|
1924
|
+
// entirely: a <Show> broke position on its first flip and went dead on
|
|
1925
|
+
// its second.
|
|
1926
|
+
//
|
|
1927
|
+
// Markers are stable nodes that outlive every value the region ever holds,
|
|
1928
|
+
// which is exactly why the client path has them. Client-only rendering was
|
|
1929
|
+
// always correct here; only the SSR path was missing them.
|
|
1930
|
+
//
|
|
1931
|
+
// The start marker goes in BEFORE the value is hydrated, at the slot the
|
|
1932
|
+
// cursor is pointing at. Anchoring afterwards to the first content node was
|
|
1933
|
+
// wrong in two ways that both showed up as content in the wrong place:
|
|
1934
|
+
//
|
|
1935
|
+
// - a value of null/false/undefined claims no node, so there was no anchor
|
|
1936
|
+
// and both markers were appended to the END of the parent. `<Show>` with
|
|
1937
|
+
// no fallback, or `{cond && <X/>}`, permanently lost its position: the
|
|
1938
|
+
// content appeared below every following sibling once it filled in.
|
|
1939
|
+
// - a NESTED region hydrates while we are still inside this one and
|
|
1940
|
+
// inserts its own markers around the content first. Anchoring to the
|
|
1941
|
+
// content then put the outer start marker INSIDE the inner pair, so the
|
|
1942
|
+
// regions interleaved instead of nesting. Switching the outer arm
|
|
1943
|
+
// removed the content but neither the inner markers nor the inner
|
|
1944
|
+
// effect, which kept rendering into a region that was switched off and
|
|
1945
|
+
// duplicated it when the outer arm came back. `<Show>` wrapping
|
|
1946
|
+
// `<Show>` or `<For>` is the canonical shape, not an exotic one.
|
|
1947
|
+
//
|
|
1948
|
+
// Opening the region first makes both cases fall out: everything the value
|
|
1949
|
+
// hydrates lands after the start marker, and the end marker closes at
|
|
1950
|
+
// wherever the cursor ends up.
|
|
1951
|
+
const cursorInParent = !!(_hydrationCursor && _hydrationCursor.parent === parent);
|
|
1952
|
+
const startMarker = document.createComment('fn');
|
|
1953
|
+
const endMarker = document.createComment('/fn');
|
|
1954
|
+
|
|
1955
|
+
if (cursorInParent) {
|
|
1956
|
+
parent.insertBefore(startMarker, parent.childNodes[_hydrationCursor.index] || null);
|
|
1957
|
+
_hydrationCursor.index++;
|
|
1958
|
+
} else {
|
|
1959
|
+
parent.appendChild(startMarker);
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
// Hydrate the value for its side effects: it claims the server's nodes and,
|
|
1963
|
+
// if it contains a nested region, inserts that region's markers. What it
|
|
1964
|
+
// RETURNS is deliberately ignored, because it is not the region's contents:
|
|
1965
|
+
// a nested region's markers are not in it. The tracked set is read back from
|
|
1966
|
+
// the DOM below, between the markers, which is the actual boundary.
|
|
1967
|
+
hydrateNode(vnode(), parent);
|
|
1968
|
+
|
|
1969
|
+
if (cursorInParent) {
|
|
1970
|
+
parent.insertBefore(endMarker, parent.childNodes[_hydrationCursor.index] || null);
|
|
1971
|
+
_hydrationCursor.index++;
|
|
1972
|
+
} else {
|
|
1973
|
+
parent.appendChild(endMarker);
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
// The region owns EVERYTHING between its markers, not just the nodes its own
|
|
1977
|
+
// value produced. A nested region leaves its markers in here too, and those
|
|
1978
|
+
// markers carry the disposer for the nested effect.
|
|
1979
|
+
//
|
|
1980
|
+
// Tracking only the value's own nodes meant that switching this region off
|
|
1981
|
+
// removed the visible content and left the inner markers and the inner
|
|
1982
|
+
// effect behind. The orphaned effect kept rendering into a region that was
|
|
1983
|
+
// switched off, and its output reappeared, doubled, when this region came
|
|
1984
|
+
// back. Collecting from the DOM is also more honest than reasoning about
|
|
1985
|
+
// what hydrateNode returned: the markers are the boundary, so whatever sits
|
|
1986
|
+
// between them is the content.
|
|
1987
|
+
const owned = [];
|
|
1988
|
+
for (let node = startMarker.nextSibling; node && node !== endMarker; node = node.nextSibling) {
|
|
1989
|
+
owned.push(node);
|
|
1990
|
+
}
|
|
1991
|
+
let current = owned.length === 0 ? null : (owned.length === 1 ? owned[0] : owned);
|
|
1690
1992
|
|
|
1691
|
-
// Set up reactive effect for future updates (normal rendering path)
|
|
1692
|
-
|
|
1993
|
+
// Set up reactive effect for future updates (normal rendering path).
|
|
1994
|
+
// The owner is captured for the same reason as in insert() and createDOM:
|
|
1995
|
+
// every re-run happens with the component stack unwound.
|
|
1996
|
+
const owner = captureOwner();
|
|
1997
|
+
const dispose = effect(() => withOwner(owner, () => {
|
|
1693
1998
|
const value = vnode();
|
|
1694
1999
|
// After hydration, this runs as normal insert
|
|
1695
2000
|
if (!_isHydrating) {
|
|
1696
|
-
current = reconcileInsert(parent, value, current,
|
|
2001
|
+
current = reconcileInsert(endMarker.parentNode || parent, value, current, endMarker);
|
|
1697
2002
|
}
|
|
1698
|
-
});
|
|
1699
|
-
|
|
2003
|
+
}));
|
|
2004
|
+
|
|
2005
|
+
// The disposer is now reachable from three places (either marker via
|
|
2006
|
+
// disposeTree, and the hydration disposer registry), which is deliberate:
|
|
2007
|
+
// whichever one the teardown happens to walk, the effect dies. It must
|
|
2008
|
+
// therefore be idempotent, or a tree disposed through more than one route
|
|
2009
|
+
// decrements the live-effect count once per route.
|
|
2010
|
+
let disposed = false;
|
|
2011
|
+
const disposeOnce = () => {
|
|
2012
|
+
if (disposed) return;
|
|
2013
|
+
disposed = true;
|
|
2014
|
+
dispose();
|
|
2015
|
+
};
|
|
2016
|
+
|
|
2017
|
+
startMarker._dispose = disposeOnce;
|
|
2018
|
+
endMarker._dispose = disposeOnce;
|
|
2019
|
+
addHydrationDisposer(startMarker, disposeOnce);
|
|
1700
2020
|
return current;
|
|
1701
2021
|
}
|
|
1702
2022
|
|
|
@@ -1776,11 +2096,26 @@ function hydrateNode(vnode, parent) {
|
|
|
1776
2096
|
// createComponent in dom.js.
|
|
1777
2097
|
try {
|
|
1778
2098
|
const node = hydrateNode(result, parent);
|
|
1779
|
-
// No comment markers exist on this path, so
|
|
1780
|
-
//
|
|
1781
|
-
//
|
|
2099
|
+
// No comment markers exist for a COMPONENT on this path, so the ctx has
|
|
2100
|
+
// to hang off some node that disposeTree will reach, or it leaks.
|
|
2101
|
+
//
|
|
2102
|
+
// Anchoring it to the first node the component produced is only valid
|
|
2103
|
+
// when that node is stable. If the component's root is a reactive
|
|
2104
|
+
// region, that node is the region's current CONTENT, and the region
|
|
2105
|
+
// replaces it on the very first update: disposeTree then ran over it and
|
|
2106
|
+
// took the whole component context with it. Every effect, cleanup and
|
|
2107
|
+
// onCleanup the component owns died the first time its own root
|
|
2108
|
+
// re-rendered, which is the same create-outside/dispose-inside-an-effect
|
|
2109
|
+
// shape the region markers exist to prevent.
|
|
2110
|
+
//
|
|
2111
|
+
// A region root falls back to the parent element instead. That disposes
|
|
2112
|
+
// later than ideal (when the parent goes, not when the component does),
|
|
2113
|
+
// and disposing late is strictly better than disposing while mounted.
|
|
2114
|
+
const rootIsRegion = typeof result === 'function'
|
|
2115
|
+
|| (Array.isArray(result) && result.some((child) => typeof child === 'function'));
|
|
1782
2116
|
const first = Array.isArray(node) ? node[0] : node;
|
|
1783
|
-
|
|
2117
|
+
const anchor = (!rootIsRegion && first && first.nodeType) ? first : parent;
|
|
2118
|
+
addHydratedComponent(anchor, ctx);
|
|
1784
2119
|
return node;
|
|
1785
2120
|
} finally {
|
|
1786
2121
|
componentStack.pop();
|
|
@@ -1788,10 +2123,18 @@ function hydrateNode(vnode, parent) {
|
|
|
1788
2123
|
}
|
|
1789
2124
|
|
|
1790
2125
|
// Element — claim existing DOM element
|
|
2126
|
+
//
|
|
2127
|
+
// The comparison is case-INSENSITIVE. `nodeName` is uppercased for HTML
|
|
2128
|
+
// elements but case-preserved for everything else, so an SVG element's
|
|
2129
|
+
// nodeName is 'svg' and could never equal `tag.toUpperCase()`. Every inline
|
|
2130
|
+
// SVG on a server-rendered page therefore failed to match, warned
|
|
2131
|
+
// "expected <svg>, got svg", and was destroyed and rebuilt: with
|
|
2132
|
+
// document.createElement, in the HTML namespace, which does not render as
|
|
2133
|
+
// SVG at all. Icons, logos and charts went blank on hydration.
|
|
1791
2134
|
const existing = claimNode(parent);
|
|
1792
|
-
const expectedTag = vnode.tag.
|
|
2135
|
+
const expectedTag = vnode.tag.toLowerCase();
|
|
1793
2136
|
|
|
1794
|
-
if (existing && existing.nodeType === 1 && existing.nodeName === expectedTag) {
|
|
2137
|
+
if (existing && existing.nodeType === 1 && existing.nodeName.toLowerCase() === expectedTag) {
|
|
1795
2138
|
// Match! Reuse this element. Apply props/bindings.
|
|
1796
2139
|
hydrateElementProps(existing, vnode.props || {});
|
|
1797
2140
|
|
|
@@ -1804,6 +2147,20 @@ function hydrateNode(vnode, parent) {
|
|
|
1804
2147
|
for (const child of vnode.children) {
|
|
1805
2148
|
hydrateNode(child, existing);
|
|
1806
2149
|
}
|
|
2150
|
+
// Only when the client tree actually declares children here.
|
|
2151
|
+
//
|
|
2152
|
+
// An element the client says is EMPTY is not the same claim as "the
|
|
2153
|
+
// server's content is stale". An island is the counter-example that
|
|
2154
|
+
// matters: it renders a bare host element and fills it in later, when
|
|
2155
|
+
// its trigger fires, from the server HTML still sitting inside it.
|
|
2156
|
+
// Trimming on an empty child list threw that content away and the
|
|
2157
|
+
// island rebuilt it from scratch, which is the exact opposite of what
|
|
2158
|
+
// an island is for (a `mode: 'static'` island, which never hydrates at
|
|
2159
|
+
// all, simply lost its content).
|
|
2160
|
+
//
|
|
2161
|
+
// dangerouslySetInnerHTML is excluded above for the same reason: the
|
|
2162
|
+
// cursor never walks that subtree, so nothing in it is ever claimed.
|
|
2163
|
+
if (vnode.children.length > 0) trimUnclaimed(existing);
|
|
1807
2164
|
}
|
|
1808
2165
|
|
|
1809
2166
|
_hydrationCursor = savedCursor;
|
|
@@ -1817,19 +2174,17 @@ function hydrateNode(vnode, parent) {
|
|
|
1817
2174
|
);
|
|
1818
2175
|
}
|
|
1819
2176
|
|
|
1820
|
-
// Create the element from scratch
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
reconcileInsert(newEl, child, null, null);
|
|
1828
|
-
}
|
|
2177
|
+
// Create the element from scratch, through the same path a client-only
|
|
2178
|
+
// render uses. The hand-rolled version here called document.createElement
|
|
2179
|
+
// and setProp with no SVG context, so a rebuilt <svg> landed in the XHTML
|
|
2180
|
+
// namespace and rendered as nothing at all, and its attributes were set as
|
|
2181
|
+
// properties rather than attributes. Falling back to a client render has to
|
|
2182
|
+
// mean the client render, not an approximation of it.
|
|
2183
|
+
const newEl = createDOM(vnode, parent, isSvgParent(parent));
|
|
1829
2184
|
if (existing) {
|
|
1830
2185
|
parent.replaceChild(newEl, existing);
|
|
1831
2186
|
} else {
|
|
1832
|
-
parent
|
|
2187
|
+
insertAtCursor(parent, newEl);
|
|
1833
2188
|
}
|
|
1834
2189
|
return newEl;
|
|
1835
2190
|
}
|
|
@@ -1840,9 +2195,7 @@ function hydrateNode(vnode, parent) {
|
|
|
1840
2195
|
}
|
|
1841
2196
|
|
|
1842
2197
|
// Fallback — create text node
|
|
1843
|
-
|
|
1844
|
-
parent.appendChild(textNode);
|
|
1845
|
-
return textNode;
|
|
2198
|
+
return insertAtCursor(parent, document.createTextNode(String(vnode)));
|
|
1846
2199
|
}
|
|
1847
2200
|
|
|
1848
2201
|
/**
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{B as bt,N as q,O as xt,Q as mt,R as _t,S as z,U as Q,V as Ct,W as wt,X as At,Y as Et,Z as lt,a as U,c as R,e as j,m as J,q as yt}from"./chunk-NCPX66TV.min.js";import{a as X}from"./chunk-O3SKPRTY.min.js";var Lt=R(null);typeof document<"u"&&document.addEventListener("focusin",t=>{Lt.set(t.target)});function ae(){return{current:()=>Lt(),focus:t=>t?.focus(),blur:()=>document.activeElement?.blur()}}function de(){let t={current:null};function e(o){typeof document>"u"||(t.current=o||document.activeElement||null)}function n(o){let r=t.current||o;r&&typeof r.focus=="function"&&r.focus()}return{capture:e,restore:n,previous:()=>t.current}}function Gt(t){let e=null;function n(){if(typeof document>"u")return;e=document.activeElement;let r=t.current||t;if(!r||typeof r.querySelectorAll!="function")return;let i=Tt(r);if(i.length===0)return;i[0].focus();function g(c){if(c.key!=="Tab")return;let l=Tt(r),s=l[0],p=l[l.length-1];c.shiftKey?document.activeElement===s&&(c.preventDefault(),p.focus()):document.activeElement===p&&(c.preventDefault(),s.focus())}return r.addEventListener("keydown",g),()=>{r.removeEventListener("keydown",g)}}function o(){e&&typeof e.focus=="function"&&e.focus()}return{activate:n,deactivate:o}}function Tt(t){let e=["button:not([disabled])","a[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");return Array.from(t.querySelectorAll(e)).filter(n=>n.offsetParent!==null)}function he({children:t,active:e=!0}){let n={current:null},o=R(0),r=Gt(n),i=null,g=s=>{n.current=s,o.set(p=>p+1)},c=j(()=>{if(o(),i&&(i(),i=null,r.deactivate()),e&&n.current)return i=r.activate(),()=>{i?.(),i=null,r.deactivate()}}),l=Ct?.();return l&&(l._cleanupCallbacks=l._cleanupCallbacks||[],l._cleanupCallbacks.push(()=>{c(),i?.(),i=null,r.deactivate()})),X("div",{ref:g},t)}var O=null,ut=0;function Ut(){return typeof document>"u"?null:(O||(O=document.createElement("div"),O.id="what-announcer",O.setAttribute("aria-live","polite"),O.setAttribute("aria-atomic","true"),O.style.cssText=`
|
|
2
|
-
position: absolute;
|
|
3
|
-
width: 1px;
|
|
4
|
-
height: 1px;
|
|
5
|
-
padding: 0;
|
|
6
|
-
margin: -1px;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
clip: rect(0, 0, 0, 0);
|
|
9
|
-
white-space: nowrap;
|
|
10
|
-
border: 0;
|
|
11
|
-
`,document.body.appendChild(O)),O)}function qt(t,e={}){let{priority:n="polite",timeout:o=1e3}=e,r=Ut();if(!r)return;r.setAttribute("aria-live",n);let i=++ut;r.textContent="",requestAnimationFrame(()=>{ut===i&&(r.textContent=t)}),setTimeout(()=>{ut===i&&(r.textContent="")},o)}function pe(t){return qt(t,{priority:"assertive"})}function ge({href:t="#main",children:e="Skip to content"}){return X("a",{href:t,class:"what-skip-link",onClick:n=>{n.preventDefault();let o=document.querySelector(t);o&&(o.focus(),o.scrollIntoView())},style:{position:"absolute",top:"-40px",left:"0",padding:"8px",background:"#000",color:"#fff",textDecoration:"none",zIndex:"10000"},onFocus:n=>{n.target.style.top="0"},onBlur:n=>{n.target.style.top="-40px"}},e)}function ye(t=!1){let e=R(t);return{expanded:()=>e(),toggle:()=>e.set(!e.peek()),open:()=>e.set(!0),close:()=>e.set(!1),buttonProps:()=>({"aria-expanded":e(),onClick:()=>e.set(!e.peek())}),panelProps:()=>({hidden:!e()})}}function be(t=null){let e=R(t);return{selected:()=>e(),select:n=>e.set(n),isSelected:n=>e()===n,itemProps:n=>({"aria-selected":e()===n,onClick:()=>e.set(n)})}}function xe(t=!1){let e=R(t);return{checked:()=>e(),toggle:()=>e.set(!e.peek()),set:n=>e.set(n),checkboxProps:()=>({role:"checkbox","aria-checked":e(),tabIndex:0,onClick:()=>e.set(!e.peek()),onKeyDown:n=>{(n.key===" "||n.key==="Enter")&&(n.preventDefault(),e.set(!e.peek()))}})}}function me(t){let e=typeof t=="function"?t:()=>t,n=R(0);function o(r){let i=e();if(!(i<=0))switch(r.key){case"ArrowDown":case"ArrowRight":r.preventDefault(),n.set((n.peek()+1)%i);break;case"ArrowUp":case"ArrowLeft":r.preventDefault(),n.set((n.peek()-1+i)%i);break;case"Home":r.preventDefault(),n.set(0);break;case"End":r.preventDefault(),n.set(i-1);break}}return{focusIndex:()=>n(),setFocusIndex:r=>n.set(r),getItemProps:r=>({tabIndex:n()===r?0:-1,onKeyDown:o,onFocus:()=>n.set(r)}),containerProps:()=>({role:"listbox"})}}function _e({children:t,as:e="span"}){return X(e,{style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}},t)}function Ce({children:t,priority:e="polite",atomic:n=!0}){return X("div",{"aria-live":e,"aria-atomic":n},t)}var St=0;function Dt(){let t=yt();return t?(t.idCounter=(t.idCounter||0)+1,t.idCounter):++St}function Mt(){St=0}function Ht(t="what"){let e=`${t}-${Dt()}`;return()=>e}function we(t,e="what"){let n=[];for(let o=0;o<t;o++)n.push(`${e}-${Dt()}`);return n}function Ae(t){let e=Ht("desc");return{descriptionId:e,descriptionProps:()=>({id:e(),style:{display:"none"}}),describedByProps:()=>({"aria-describedby":e()}),Description:()=>X("div",{id:e(),style:{display:"none"}},t)}}function Ee(t){let e=Ht("label");return{labelId:e,labelProps:()=>({id:e()}),labelledByProps:()=>({"aria-labelledby":e()})}}var Te={Enter:"Enter",Space:" ",Escape:"Escape",ArrowUp:"ArrowUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",Home:"Home",End:"End",Tab:"Tab"};function Le(t,e){return n=>{n.key===t&&e(n)}}function Se(t,e){return n=>{t.includes(n.key)&&e(n)}}var v=null;function Re(t){v=typeof t=="function"?t:null}function Ve(t,e,n){if(typeof n=="function"){let o=()=>{let r=n();return r.length===1?r[0]:r};return o._lazyChildren=!0,e||(e={}),Object.defineProperty(e,"_$lazyChildren",{value:o,configurable:!0}),Q({tag:t,props:e,children:[],key:null,_vnode:!0})}if(n&&n.length>0){let o=n.length===1?n[0]:n;e?e.children=o:e={children:o}}return Q({tag:t,props:e||{},children:n||[],key:null,_vnode:!0})}var Wt={tr:{depth:2,wrap:"<table><tbody>",unwrap:"</tbody></table>"},td:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},th:{depth:3,wrap:"<table><tbody><tr>",unwrap:"</tr></tbody></table>"},thead:{depth:1,wrap:"<table>",unwrap:"</table>"},tbody:{depth:1,wrap:"<table>",unwrap:"</table>"},tfoot:{depth:1,wrap:"<table>",unwrap:"</table>"},colgroup:{depth:1,wrap:"<table>",unwrap:"</table>"},col:{depth:1,wrap:"<table>",unwrap:"</table>"},caption:{depth:1,wrap:"<table>",unwrap:"</table>"}},It=new Set(["svg","path","circle","rect","line","polyline","polygon","ellipse","g","defs","use","text","tspan","foreignObject","clipPath","mask","pattern","linearGradient","radialGradient","stop","marker","symbol","image","animate","animateTransform","animateMotion","set","filter","feGaussianBlur","feOffset","feMerge","feMergeNode","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feImage","feMorphology","feSpecularLighting","feTile","feTurbulence","feDistantLight","fePointLight","feSpotLight"]);function Nt(t){let e=t.match(/^<([a-zA-Z][a-zA-Z0-9]*)/);return e?e[1]:""}function Xt(t){let e=t.trim(),n=Nt(e);if(It.has(n))return Zt(e);let o=Wt[n];if(o){let i=document.createElement("template");i.innerHTML=o.wrap+e+o.unwrap;let g=i.content.firstChild;for(let c=0;c<o.depth;c++)g=g.firstChild;return()=>g.cloneNode(!0)}let r=document.createElement("template");return r.innerHTML=e,()=>r.content.firstChild.cloneNode(!0)}var Bt=!1;function ze(t){return U&&!Bt&&(Bt=!0,console.warn("[what] template() is a compiler internal. Use JSX instead. Direct calls with user input can lead to XSS vulnerabilities.")),Xt(t)}function Zt(t){let e=t.trim();if(Nt(e)==="svg"){let r=document.createElement("template");return r.innerHTML=e,()=>r.content.firstChild.cloneNode(!0)}let o=document.createElement("template");return o.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg">${e}</svg>`,()=>o.content.firstChild.firstChild.cloneNode(!0)}function Rt(t,e,n){if(typeof e=="function"&&e._mapArray)return e(t,n||null);if(typeof e=="function"&&e._lazyChildren)return Rt(t,e(),n);if(typeof e=="function"){let o=n||null,r=null,i=null,g=!1;return j(()=>{let c=e(),l=typeof c;if(!g){g=!0,l==="string"||l==="number"?(i=document.createTextNode(String(c)),o?t.insertBefore(i,o):t.appendChild(i),v&&v(t,String(c)),r=i):r=F(t,c,null,o);return}if(i!==null&&(l==="string"||l==="number")){let s=String(c);i.data!==s&&(i.data=s),v&&v(t,s);return}i=null,r=F(t,c,r,o)}),r}if(typeof e=="string"||typeof e=="number"){let o=document.createTextNode(String(e));return n?t.insertBefore(o,n):t.appendChild(o),o}return e!=null&&typeof e=="object"&&e.nodeType>0?(n?t.insertBefore(e,n):t.appendChild(e),e):F(t,e,null,n||null)}function Vt(t){return!t||typeof t!="object"?!1:typeof Node<"u"&&t instanceof Node?!0:typeof t.nodeType=="number"&&typeof t.nodeName=="string"}function Jt(t){return!!t&&typeof t=="object"&&(t._vnode===!0||"tag"in t)}var ft=typeof SVGElement<"u";function jt(t){return ft&&t instanceof SVGElement&&t.tagName!=="foreignObject"}function Pt(t){return t==null?[]:Array.isArray(t)?t:[t]}function zt(t,e,n){if(t==null||typeof t=="boolean")return n;if(Array.isArray(t)){for(let o=0;o<t.length;o++)zt(t[o],e,n);return n}if(typeof t=="function"){let o=Q(t,e,jt(e));if(o&&o.nodeType===11){let r=Array.from(o.childNodes);for(let i=0;i<r.length;i++)n.push(r[i])}else o&&n.push(o);return n}if(typeof t=="string"||typeof t=="number")return n.push(document.createTextNode(String(t))),n;if(Vt(t)){if(t.nodeType===11&&t.childNodes.length>0){let o=Array.from(t.childNodes);for(let r=0;r<o.length;r++)n.push(o[r])}else n.push(t);return n}if(Jt(t)){let o=Q(t,e,jt(e));if(o&&o.nodeType===11)if(o.childNodes.length===0)n.push(o);else{let r=Array.from(o.childNodes);for(let i=0;i<r.length;i++)n.push(r[i])}else o&&n.push(o);return n}return n.push(document.createTextNode(String(t))),n}function Qt(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function F(t,e,n,o){if(!t||typeof t.insertBefore!="function")return U&&console.warn("[what] reconcileInsert called with invalid parent:",t),n;let r=o||null;if(e==null||typeof e=="boolean"){let s=Pt(n);for(let p=0;p<s.length;p++){let u=s[p];u.parentNode===t&&(z(u),t.removeChild(u))}return null}if((typeof e=="string"||typeof e=="number")&&n&&!Array.isArray(n)&&n.nodeType===3){let s=String(e);return n.data!==s&&(n.data=s),n}if(typeof e=="object"&&e!==null&&e.nodeType>0&&e.nodeType!==11&&!Array.isArray(e)){if(e===n)return n;if(n&&!Array.isArray(n)&&n.nodeType>0&&n.nodeType!==11)return n.parentNode===t?(z(n),t.replaceChild(e,n)):r?t.insertBefore(e,r):t.appendChild(e),e}let i=zt(e,t,[]),g=Pt(n);if(Qt(g,i))return n;let c=i.length;for(let s=0;s<g.length;s++){let p=g[s];if(p.parentNode!==t)continue;let u=!1;for(let C=0;C<c;C++)if(i[C]===p){u=!0;break}u||(z(p),t.removeChild(p))}let l=r;for(let s=i.length-1;s>=0;s--){let p=i[s];(p.parentNode!==t||p.nextSibling!==l)&&(l&&l.parentNode!==t&&(l=null),l?t.insertBefore(p,l):t.appendChild(p)),l=p}return i.length===0?null:i.length===1?i[0]:i}function Oe(t,e,n){let o=n?.key,r=n?.raw||!1,i=(g,c)=>{let l=[],s=[],p=[],u=o&&!r?new Map:null,C=document.createComment("/list");return g.insertBefore(C,c||null),j(()=>{let y=t()||[],b=C.parentNode||g;o?te(b,C,l,y,s,p,e,o,u):Yt(b,C,l,y,s,p,e),l=y.length>0?y.slice():y}),C};return i._mapArray=!0,i}function Yt(t,e,n,o,r,i,g){let c=o.length,l=n.length;if(c===0){if(l>0){for(let a=0;a<l;a++)i[a]&&i[a]();for(let a=l-1;a>=0;a--){let d=r[a];d&&(z(d),d.parentNode===t&&t.removeChild(d))}r.length=0,i.length=0}return}if(l===0){let a=document.createDocumentFragment();for(let d=0;d<c;d++){let E=o[d],L=J(N=>(i[d]=N,g(E,d)));r[d]=L,a.appendChild(L)}t.insertBefore(a,e);return}let s=0,p=Math.min(l,c);for(;s<p&&n[s]===o[s];)s++;if(s===l&&s===c)return;let u=l-1,C=c-1;for(;u>=s&&C>=s&&n[u]===o[C];)u--,C--;let y=new Array(c),b=new Array(c);for(let a=0;a<s;a++)y[a]=r[a],b[a]=i[a];for(let a=C+1;a<c;a++){let d=u+1+(a-C-1);y[a]=r[d],b[a]=i[d]}let m=C-s+1,A=u-s+1;if(m===0)for(let a=s;a<=u;a++)i[a]?.(),r[a]&&z(r[a]),r[a]?.parentNode&&r[a].parentNode.removeChild(r[a]);else if(A===0){let a=s<c&&y[C+1]?y[C+1]:e,d=document.createDocumentFragment();for(let E=s;E<=C;E++){let L=o[E],N=E;y[E]=J(S=>(b[N]=S,g(L,N))),d.appendChild(y[E])}t.insertBefore(d,a)}else kt(t,e,n,o,r,i,g,s,u,C,y,b);r.length=c,i.length=c;for(let a=0;a<c;a++)r[a]=y[a],i[a]=b[a]}function kt(t,e,n,o,r,i,g,c,l,s,p,u){let C=new Map;for(let d=c;d<=l;d++)C.set(n[d],d);let y=s-c+1,b=new Int32Array(y);b.fill(-1);for(let d=c;d<=s;d++){let E=C.get(o[d]);E!==void 0&&(C.delete(o[d]),p[d]=r[E],u[d]=i[E],b[d-c]=E)}for(let[,d]of C)i[d]?.(),r[d]&&z(r[d]),r[d]?.parentNode&&r[d].parentNode.removeChild(r[d]);let m=y-vt(b,y),A=new Uint8Array(y);if(m>1){let d=new Int32Array(m),E=new Int32Array(m),L=0;for(let S=0;S<y;S++)b[S]!==-1&&(d[L]=b[S],E[L]=S,L++);let N=Ot(d,m);for(let S=0;S<N.length;S++)A[E[N[S]]]=1}else if(m===1){for(let d=0;d<y;d++)if(b[d]!==-1){A[d]=1;break}}for(let d=c;d<=s;d++)if(!p[d]){let E=o[d],L=d;p[d]=J(N=>(u[L]=N,g(E,L)))}let a=s+1<p.length&&p[s+1]?p[s+1]:e;for(let d=s;d>=c;d--){let E=d-c;(b[E]===-1||!A[E])&&(a&&a.parentNode!==t&&(a=e),t.insertBefore(p[d],a)),a=p[d]}}function vt(t,e){let n=0;for(let o=0;o<e;o++)t[o]===-1&&n++;return n}function Ot(t,e){if(e===0)return[];if(e===1)return[0];let n=new Int32Array(e),o=new Int32Array(e),r=1;n[0]=0,o[0]=-1;for(let c=1;c<e;c++)if(t[c]>t[n[r-1]])o[c]=n[r-1],n[r++]=c;else{let l=0,s=r-1;for(;l<s;){let p=l+s>>1;t[n[p]]<t[c]?l=p+1:s=p}n[l]=c,o[c]=l>0?n[l-1]:-1}let i=new Array(r),g=n[r-1];for(let c=r-1;c>=0;c--)i[c]=g,g=o[g];return i}function Ft(){return document.createComment("i")}function Y(t,e,n,o){let r=e;for(;r&&r!==n;){let i=r.nextSibling;t.insertBefore(r,o),r=i}}function at(t,e,n){let o=e;for(;o&&o!==n;){let r=o.nextSibling;z(o),t.removeChild(o),o=r}}function dt(t,e,n,o,r,i,g,c,l){let s;if(r){let C=o(e),y=l(e);s=y,r.set(C,{itemSig:y})}else s=e;let p=Ft();t.appendChild(p);let u=J(C=>(c[n]=C,i(s,n)));t.appendChild(u),g[n]=p}function te(t,e,n,o,r,i,g,c,l){let s=o.length,p=n.length;if(s===0){if(p>0){for(let f=0;f<p;f++)i[f]&&i[f]();r[0]&&at(t,r[0],e),r.length=0,i.length=0,l&&l.clear()}return}if(p===0){let f=document.createDocumentFragment();for(let _=0;_<s;_++)dt(f,o[_],_,c,l,g,r,i,R);t.insertBefore(f,e);return}let u=0,C=Math.min(p,s);for(;u<C;){if(n[u]===o[u]){u++;continue}let f=c(n[u]),_=c(o[u]);if(f!==_)break;l&&l.get(f).itemSig.set(o[u]),u++}let y=p-1,b=s-1;for(;y>=u&&b>=u;){if(n[y]===o[b]){y--,b--;continue}let f=c(n[y]),_=c(o[b]);if(f!==_)break;l&&l.get(f).itemSig.set(o[b]),y--,b--}if(u>y&&u>b)return;let m=new Array(s),A=new Array(s);for(let f=0;f<u;f++)m[f]=r[f],A[f]=i[f];for(let f=b+1;f<s;f++){let _=y+1+(f-b-1);m[f]=r[_],A[f]=i[_]}let a=b-u+1,d=y-u+1;if(d===0){let f=b+1<s&&m[b+1]?m[b+1]:e,_=document.createDocumentFragment();for(let T=u;T<=b;T++)dt(_,o[T],T,c,l,g,m,A,R);t.insertBefore(_,f),k(r,i,m,A,s);return}if(a===0){for(let f=u;f<=y;f++){i[f]?.();let _=W(t,r[f],r,f,e);at(t,r[f],_),l&&l.delete(c(n[f]))}k(r,i,m,A,s);return}if(a===d&&a>=2&&a<=Math.max(d,200)){let f=0,_=-1,T=-1;for(let x=0;x<a&&f<=4;x++){let w=c(n[u+x]),K=c(o[u+x]);w!==K&&(f===0?_=x:f===1&&(T=x),f++)}if(f===2){let x=u+_,w=u+T,K=c(n[x]),$=c(n[w]),I=c(o[x]),ot=c(o[w]);if(K===ot&&$===I){for(let h=0;h<u;h++)m[h]=r[h],A[h]=i[h];for(let h=u;h<=b;h++)m[h]=r[h],A[h]=i[h];for(let h=b+1;h<s;h++){let P=y+1+(h-b-1);m[h]=r[P],A[h]=i[P]}let G=m[x];m[x]=m[w],m[w]=G;let H=A[x];if(A[x]=A[w],A[w]=H,l){if(o[x]!==n[x]){let h=c(o[x]),P=l.get(h);P&&P.itemSig.set(o[x])}if(o[w]!==n[w]){let h=c(o[w]),P=l.get(h);P&&P.itemSig.set(o[w])}}let M=w===x+1||x===w+1,B=Math.min(x,w),D=Math.max(x,w);if(M){let h=W(t,r[D],r,D,e);Y(t,r[D],h,r[B])}else{let h=W(t,r[w],r,w,e),P=document.createComment("tmp");t.insertBefore(P,r[w]),Y(t,r[w],h,r[x]);let rt=W(t,r[x],r,x,e);Y(t,r[x],rt,P),t.removeChild(P)}k(r,i,m,A,s);return}}if(f>=2&&f<=a){let x=_,w=null,K=-1,$=-1,I=!1,ot=c(n[u+x]),G=-1;for(let H=x;H<a;H++)if(c(o[u+H])===ot){G=H;break}if(G>x){let H=!0;for(let M=x;M<G;M++)if(c(n[u+M+1])!==c(o[u+M])){H=!1;break}if(H){let M=!0;for(let B=G+1;B<a;B++)if(c(n[u+B])!==c(o[u+B])){M=!1;break}M&&(I=!0,K=u+x,$=u+G,w=ot)}}if(!I){let H=c(o[u+x]),M=-1;for(let B=x;B<d;B++)if(c(n[u+B])===H){M=B;break}if(M>x){let B=!0;for(let D=x;D<M;D++)if(c(n[u+D])!==c(o[u+D+1])){B=!1;break}if(B){let D=!0;for(let h=M+1;h<a;h++)if(c(n[u+h])!==c(o[u+h])){D=!1;break}D&&(I=!0,K=u+M,$=u+x,w=H)}}}if(I){for(let h=u;h<=y;h++)m[h]=r[h],A[h]=i[h];let H=m[K],M=A[K];if(K<$)for(let h=K;h<$;h++)m[h]=m[h+1],A[h]=A[h+1];else for(let h=K;h>$;h--)m[h]=m[h-1],A[h]=A[h-1];if(m[$]=H,A[$]=M,l)for(let h=u;h<=b;h++){let P=c(o[h]);if(o[h]!==n[h]){let rt=l.get(P);rt&&rt.itemSig.set(o[h])}}let B=W(t,H,r,K,e),D;$+1<s?D=m[$+1]:D=e,($>=b+1||D&&D.parentNode!==t)&&(D=e),Y(t,H,B,D),k(r,i,m,A,s);return}}}let E=new Map;for(let f=u;f<=y;f++)E.set(c(n[f]),f);let L=new Int32Array(a);L.fill(-1);for(let f=u;f<=b;f++){let _=c(o[f]),T=E.get(_);T!==void 0&&(E.delete(_),m[f]=r[T],A[f]=i[T],L[f-u]=T,l&&o[f]!==n[T]&&l.get(_).itemSig.set(o[f]))}let N=[...E.values()].sort((f,_)=>_-f);for(let f of N){i[f]?.();let _=W(t,r[f],r,f,e);at(t,r[f],_),l&&l.delete(c(n[f]))}for(let f=u;f<=b;f++)if(!m[f]){let _=document.createDocumentFragment();dt(_,o[f],f,c,l,g,m,A,R),m[f]._frag=_}let S=0,pt=!0,gt=-1;for(let f=0;f<a;f++)L[f]!==-1&&(S++,L[f]<=gt&&(pt=!1),gt=L[f]);let nt=new Uint8Array(a);if(pt)for(let f=0;f<a;f++)L[f]!==-1&&(nt[f]=1);else if(S>1){let f=new Int32Array(S),_=new Int32Array(S),T=0;for(let w=0;w<a;w++)L[w]!==-1&&(f[T]=L[w],_[T]=w,T++);let x=Ot(f,S);for(let w=0;w<x.length;w++)nt[_[x[w]]]=1}else if(S===1){for(let f=0;f<a;f++)if(L[f]!==-1){nt[f]=1;break}}k(r,i,m,A,s);let st=b+1<s&&r[b+1]?r[b+1]:e;for(let f=b;f>=u;f--){let _=f-u,T=r[f];if(L[_]===-1)T._frag&&(t.insertBefore(T._frag,st),delete T._frag);else if(!nt[_]){let x=W(t,T,r,f,e);Y(t,T,x,st)}st=T}}function W(t,e,n,o,r){let i=e.nextSibling;for(;i&&i!==r;){if(i.nodeType===8&&i.data==="i")return i;i=i.nextSibling}return r}function k(t,e,n,o,r){t.length=r,e.length=r;for(let i=0;i<r;i++)t[i]=n[i],e[i]=o[i]}function Ge(t,e){for(let n in e){let o=e[n];if(q(n)){if(typeof o!="function")continue;let r=n.slice(2).toLowerCase();t.addEventListener(r,o);continue}if(typeof o=="function"&&!q(n)){if(t._propEffects||(t._propEffects={}),t._propEffects[n])try{t._propEffects[n]()}catch{}n==="class"||n==="className"?t._propEffects[n]=j(()=>{let r=o()||"";ft&&t instanceof SVGElement?t.setAttribute("class",r):t.className=r}):n==="style"&&typeof o()=="object"?t._propEffects[n]=j(()=>{ct(t,o())}):t._propEffects[n]=j(()=>{tt(t,n,o())})}else tt(t,n,o)}}function tt(t,e,n){if(e==="ref"){typeof n=="function"?n(t):n&&typeof n=="object"&&(n.current=t);return}if(e==="key")return;if(typeof n=="function"&&!q(e)){if(t._propEffects||(t._propEffects={}),t._propEffects[e])try{t._propEffects[e]()}catch{}t._propEffects[e]=j(()=>tt(t,e,n()));return}if(q(e))return;if(xt(e,n)){typeof console<"u"&&console.warn(`[what] Blocked unsafe URL in "${e}" attribute:`,n);return}let o=ft&&t instanceof SVGElement;if(e==="class"||e==="className")o?t.setAttribute("class",n||""):t.className=n||"";else if(e==="dangerouslySetInnerHTML"){let r=n?.__html??"";typeof U<"u"&&U&&typeof r=="string"&&/(<script|onerror\s*=|onload\s*=|javascript:)/i.test(r)&&console.warn("[what] dangerouslySetInnerHTML contains potential XSS vectors. Ensure content is sanitized."),t.innerHTML=r}else if(e==="innerHTML")if(n&&typeof n=="object"&&"__html"in n){let r=n.__html??"";typeof U<"u"&&U&&typeof r=="string"&&/(<script|onerror\s*=|onload\s*=|javascript:)/i.test(r)&&console.warn("[what] dangerouslySetInnerHTML contains potential XSS vectors. Ensure content is sanitized."),t.innerHTML=r}else typeof console<"u"&&n!=null&&n!==""&&console.warn('[what] Plain string innerHTML is not allowed. Use { __html: "..." } or dangerouslySetInnerHTML={{ __html: "..." }} instead.');else if(e==="style")ct(t,n);else if(n==null){if(e in t)try{t[e]=""}catch{}t.removeAttribute(e)}else e.startsWith("data-")||e.startsWith("aria-")?t.setAttribute(e,n):typeof n=="boolean"?n?t.setAttribute(e,""):t.removeAttribute(e):o?t.setAttribute(e,n):e==="value"&&t.tagName==="SELECT"?lt(t,n):e in t?t[e]=n:t.setAttribute(e,n)}function et(t,e,n,o){if(t._propEffects||(t._propEffects={}),t._propEffects[e])try{t._propEffects[e]()}catch{}t._propEffects[e]=j(()=>o(t,n()))}function ee(t,e){if(typeof e=="function")return et(t,"class",e,ee);ft&&t instanceof SVGElement?t.setAttribute("class",e||""):t.className=e||""}function ct(t,e){if(typeof e=="function")return et(t,"style",e,ct);if(typeof e=="string")t.style.cssText=e,t._lastStyleObj=null;else if(e&&typeof e=="object"){let n=t.style,o=t._lastStyleObj;if(o)for(let r in o)r in e||(n[r]="");for(let r in e)n[r]=e[r]??"";t._lastStyleObj=e}else e==null&&(t.style.cssText="",t._lastStyleObj=null)}function ne(t,e,n){if(typeof n=="function")return et(t,e,n,(o,r)=>ne(o,e,r));n==null?t.removeAttribute(e):t.setAttribute(e,n)}function oe(t,e){if(typeof e=="function")return et(t,"value",e,oe);if(t.tagName==="SELECT"){lt(t,e);return}let n=e==null?"":String(e);t.value!==n&&(t.value=n)}function re(t,e){if(typeof e=="function")return et(t,"checked",e,re);t.checked=!!e}var Kt=new Set;function Ue(t){for(let e of t)Kt.has(e)||(Kt.add(e),document.addEventListener(e,n=>{let o=n.target,r="$$"+e;for(Object.defineProperty(n,"currentTarget",{configurable:!0,get(){return o||document}});o;){let i=o[r];if(i&&(i(n),n.cancelBubble))return;o=o.parentNode}}))}function qe(t,e,n){return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}function We(t,e){j(()=>{for(let n in e){let o=typeof e[n]=="function"?e[n]():e[n];t.classList.toggle(n,!!o)}})}var it=!1,V=null;function Ie(){return it}function ie(t,e){it=!0,Mt(),V={parent:e,index:0};try{return Z(t,e)}finally{it=!1,V=null}}function $t(t){let e=t.childNodes;for(;V.index<e.length;){let n=e[V.index];if(n.nodeType===8){let o=n.textContent;if(o==="$"||o==="/$"||o==="[]"||o==="/[]"){V.index++;continue}}return V.index++,n}return null}function ht(){return typeof process<"u"&&!1}function Z(t,e){if(t==null||typeof t=="boolean")return null;if(typeof t=="string"||typeof t=="number"){let o=$t(e),r=String(t);if(o&&o.nodeType===3)return ht()&&o.textContent!==r&&(console.warn(`[what] Hydration mismatch: expected text "${r}", got "${o.textContent}"`),o.textContent=r),o;ht()&&console.warn(`[what] Hydration mismatch: expected text node "${r}", got ${o?o.nodeName:"nothing"}. Falling back to client render.`);let i=document.createTextNode(r);return o?e.replaceChild(i,o):e.appendChild(i),i}if(typeof t=="function"&&t._lazyChildren)return Z(t(),e);if(typeof t=="function"){let o=t(),r=Z(o,e),i=j(()=>{let g=t();it||(r=F(e,g,r,null))});return mt(r&&r.nodeType?r:e,i),r}if(Array.isArray(t)){let o=[];for(let r of t){let i=Z(r,e);i&&o.push(i)}return o.length===1?o[0]:o}if(typeof t=="object"&&t._vnode){if(typeof t.tag=="function"){let g=wt(),c=t.tag,l=t.props||{},s=t.children||[],p={hooks:[],hookIndex:0,effects:[],cleanups:[],mounted:!1,disposed:!1,Component:c,_parentCtx:g[g.length-1]||null,_errorBoundary:null};g.push(p);let u,C=null;try{let y={...l};l._$lazyChildren?C=At(c,y,l._$lazyChildren):y.children=s.length===0?l.children:s.length===1?s[0]:s,u=c(y),C&&C()}catch(y){return g.pop(),Et(y)||console.error("[what] Error in component during hydration:",c.name||"Anonymous",y),null}p.mounted=!0,p._mountCallbacks&&queueMicrotask(()=>{if(!p.disposed)for(let y of p._mountCallbacks)try{y()}catch(b){console.error("[what] onMount error:",b)}});try{let y=Z(u,e),b=Array.isArray(y)?y[0]:y;return _t(b&&b.nodeType?b:e,p),y}finally{g.pop()}}let o=$t(e),r=t.tag.toUpperCase();if(o&&o.nodeType===1&&o.nodeName===r){fe(o,t.props||{});let g=V;if(V={parent:o,index:0},t.props?.dangerouslySetInnerHTML?.__html==null)for(let l of t.children)Z(l,o);return V=g,o}ht()&&console.warn(`[what] Hydration mismatch: expected <${t.tag}>, got ${o?o.nodeName:"nothing"}. Falling back to client render.`);let i=document.createElement(t.tag);for(let g in t.props||{})g==="children"||g==="key"||tt(i,g,t.props[g]);for(let g of t.children)F(i,g,null,null);return o?e.replaceChild(i,o):e.appendChild(i),i}if(Vt(t))return t;let n=document.createTextNode(String(t));return e.appendChild(n),n}function fe(t,e){for(let n in e){if(n==="children"||n==="key"||n==="dangerouslySetInnerHTML"||n==="innerHTML")continue;if(n==="ref"){let r=e.ref;typeof r=="function"?r(t):r&&typeof r=="object"&&(r.current=t);continue}let o=e[n];if(q(n)){if(typeof o!="function")continue;let r=n.slice(2).toLowerCase();t.addEventListener(r,o);continue}if(n.startsWith("$$")){t[n]=o;continue}if(typeof o=="function"&&!q(n)){n==="class"||n==="className"?j(()=>{t.className=o()||""}):n==="style"&&typeof o()=="object"?j(()=>{ct(t,o())}):j(()=>{tt(t,n,o())});continue}}}bt({hydrate:ie,insert:Rt});export{ae as a,de as b,Gt as c,he as d,qt as e,pe as f,ge as g,ye as h,be as i,xe as j,me as k,_e as l,Ce as m,Ht as n,we as o,Ae as p,Ee as q,Te as r,Le as s,Se as t,Re as u,Ve as v,Xt as w,ze as x,Zt as y,Rt as z,Oe as A,Ge as B,tt as C,ee as D,ct as E,ne as F,oe as G,re as H,Ue as I,qe as J,We as K,Ie as L,ie as M};
|