@askrjs/askr 0.0.76 → 0.0.78
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/actions/index.d.ts +1 -1
- package/dist/actions/index.js +3 -3
- package/dist/{activity-DaqZEUPh.d.ts → activity-CXEaU-Al.d.ts} +1 -1
- package/dist/{activity-386uXmPJ.js → activity-DfrtblJA.js} +3 -3
- package/dist/{authoring-ycOVkX1-.js → authoring-DE-LH_s-.js} +2 -2
- package/dist/benchmark.js +6 -6
- package/dist/boot/index.d.ts +4 -4
- package/dist/boot/index.js +1 -1
- package/dist/{boot-eaBrci4W.js → boot-C5bZY3Uc.js} +14 -14
- package/dist/{cleanup-e4Rn287s.js → cleanup-CyY1ROBI.js} +1 -1
- package/dist/{component-internal-iJ7HAcpc.js → component-internal-BuTG89T8.js} +13 -9
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/control/index.d.ts +1 -1
- package/dist/control/index.js +1 -1
- package/dist/control-C-ApnFs1.js +20 -0
- package/dist/{control-Uvq1GU4K.d.ts → control-Cix3yjVf.d.ts} +7 -1
- package/dist/{control-ByyOdVdr.js → control-DQIsWvhr.js} +4 -4
- package/dist/{csp-nonce-BLkoekFX.js → csp-nonce-BUsz0Em7.js} +1 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.js +3 -3
- package/dist/{data-E7oXei9c.js → data-eBdygZ1f.js} +3 -3
- package/dist/{data-runtime-rpV6-3XW.js → data-runtime-D68YOo9L.js} +1 -1
- package/dist/{deferred-iBBHEN5Z.js → deferred-t79wHqe1.js} +6 -6
- package/dist/{fastlane-BbexfvHo.js → fastlane-CkBXZ_3K.js} +2 -2
- package/dist/{for-internal-tNicxJY3.js → for-internal-BnXrQbgo.js} +1 -1
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +2 -2
- package/dist/foundations/state/index.d.ts +1 -1
- package/dist/foundations/state/index.js +1 -1
- package/dist/foundations/structures/index.d.ts +1 -1
- package/dist/foundations/structures/index.js +2 -2
- package/dist/{index-Bki2rqcr.d.ts → index-5S-fi2xy.d.ts} +17 -17
- package/dist/{router-Dd-LoJmM.d.ts → index-TlEvex-C.d.ts} +162 -4
- package/dist/{index-CbRdEUPB.d.ts → index-Vs1EeWEr.d.ts} +2 -2
- package/dist/{index-acX2RLxD.d.ts → index-ho0Htetw.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +10 -9
- package/dist/jsx-C3IECePB.js +12 -0
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/{lifecycle-operations-D2wzCYYh.js → lifecycle-operations-CN0PiLE_.js} +1 -1
- package/dist/{navigate-DlaVqF4n.d.ts → navigate-DfY1BUYc.d.ts} +1 -1
- package/dist/{navigate-BwCpLrSM.js → navigate-ype2B_M8.js} +8 -8
- package/dist/{portal-EKmTCMKp.js → portal-BZ_rN17v.js} +15 -14
- package/dist/portal-w3oQ6oQU.js +29 -0
- package/dist/{query-registry-Bu_cuMch.js → query-registry-BL6rjGsO.js} +1 -1
- package/dist/{render-context-Clw3rFiO.js → render-context-D-DFk2WN.js} +13 -1
- package/dist/{renderer-GFETYwZ6.js → renderer-_l_U-AbR.js} +292 -67
- package/dist/resources/index.d.ts +2 -2
- package/dist/resources/index.js +4 -4
- package/dist/{route-matching-Dmb_MKUb.js → route-matching-jqwlQJ5g.js} +3 -3
- package/dist/router/index.d.ts +4 -4
- package/dist/router/index.js +5 -5
- package/dist/ssg/index.d.ts +2 -2
- package/dist/ssg/index.js +7 -5
- package/dist/ssr/index.d.ts +8 -25
- package/dist/ssr/index.js +2 -2
- package/dist/{ssr-CtumC_es.js → ssr-Dcmi1bZi.js} +57 -28
- package/dist/{state-rjmMPExl.js → state-BCl9DeiN.js} +1 -1
- package/dist/{structures-DUB3HchX.js → structures-D3vO-WMN.js} +1 -1
- package/dist/testing/index.d.ts +3 -3
- package/dist/testing/index.js +3 -3
- package/dist/{verify-hydration-GMsdoOUX.js → verify-hydration-Dfx-ZhbX.js} +1 -1
- package/package.json +1 -1
- package/dist/control-DhFRTIoE.js +0 -12
- package/dist/index-CDACZEF2.d.ts +0 -102
- package/dist/index-vo_FDR-B.d.ts +0 -40
- package/dist/jsx-CUpRxrLH.js +0 -6
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { t as __CONTROL_BOUNDARY__ } from "./control-
|
|
1
|
+
import { n as hasTransparentComponentResult, t as __CONTROL_BOUNDARY__ } from "./control-C-ApnFs1.js";
|
|
2
2
|
import { n as _isDOMElement, t as __ERROR_BOUNDARY__ } from "./vnode-D24p6IW2.js";
|
|
3
3
|
import { b as isDevelopmentEnvironment, c as runRuntimeHandlerScope, f as configureRuntimeRenderer, i as getDefaultRuntimeInstance, n as enqueueRuntimeTask, v as logger, y as getRuntimeEnv } from "./access-ePqdQqkV.js";
|
|
4
|
-
import { n as markFastPathApplied, t as isBulkCommitActive } from "./fastlane-
|
|
5
|
-
import {
|
|
6
|
-
import { d as getCurrentContextFrame, h as markVNodeTreeWithContextFrame, i as mountInstanceInline, n as createComponentInstance, o as renderComponentInline, p as getVNodeContextFrame, t as captureInlineRenderSnapshot, y as withContext } from "./component-internal-
|
|
4
|
+
import { n as markFastPathApplied, t as isBulkCommitActive } from "./fastlane-CkBXZ_3K.js";
|
|
5
|
+
import { i as isFragmentType, r as STATIC_CHILDREN } from "./jsx-C3IECePB.js";
|
|
6
|
+
import { d as getCurrentContextFrame, h as markVNodeTreeWithContextFrame, i as mountInstanceInline, n as createComponentInstance, o as renderComponentInline, p as getVNodeContextFrame, t as captureInlineRenderSnapshot, y as withContext } from "./component-internal-BuTG89T8.js";
|
|
7
7
|
import { b as restoreDomCommitScope, c as enterDomCommitScope, p as getCurrentInstance } from "./component-scope-DzJEbYGE.js";
|
|
8
8
|
import { t as cleanupComponent } from "./component-cleanup-oWN45rfa.js";
|
|
9
9
|
import { c as getCurrentLifecycleCommitBatch, l as registerLifecycleRollback, p as isPromiseLike, r as discardLifecycleCommitBatch, s as flushLifecycleCommitBatch, t as beginLifecycleCommitBatch, u as registerLifecycleTransaction } from "./lifecycle-batch-CwHCDseR.js";
|
|
10
|
-
import { _ as setControlBoundaryContextFrame, a as registerForStateTransaction, b as rerenderChildScope, c as captureForFallbackTransactionSnapshot, d as clearCaseDomUpdateState, f as clearShowDomUpdateState, g as evaluateShowState, h as evaluateCaseState, i as evaluateForState, l as captureForItemTransactionSnapshot, n as clearForDomUpdateState, o as rollbackForStateTransaction, t as beginForStateTransaction, v as createChildScope, y as disposeChildScope } from "./for-internal-
|
|
10
|
+
import { _ as setControlBoundaryContextFrame, a as registerForStateTransaction, b as rerenderChildScope, c as captureForFallbackTransactionSnapshot, d as clearCaseDomUpdateState, f as clearShowDomUpdateState, g as evaluateShowState, h as evaluateCaseState, i as evaluateForState, l as captureForItemTransactionSnapshot, n as clearForDomUpdateState, o as rollbackForStateTransaction, t as beginForStateTransaction, v as createChildScope, y as disposeChildScope } from "./for-internal-BnXrQbgo.js";
|
|
11
11
|
import { n as createOwnedFineGrainedEffect, r as markFineGrainedEffectsDirtySource, t as createFineGrainedEffect } from "./effect-2IIWvUjG.js";
|
|
12
|
-
import { C as getDelegatedHandlersForElement, D as updateDelegatedListener, E as removeDelegatedListener, S as getDelegatedHandlerForElement, T as isEventDelegationEnabled, _ as teardownNodeSubtree, a as elementReactivePropsCleanup, b as addFreshDelegatedListener, c as forEachElementReactivePropCleanup, d as removeAllListeners, f as removeElementReactiveProps, g as setFreshElementReactivePropCleanup, h as setDirectElementReactivePropCleanup, i as elementListeners, l as getElementReactivePropCleanupSize, m as replaceElementRefBookkeeping, n as cleanupInstanceIfPresent, o as elementRefs, p as removeElementRef, r as cleanupInstancesUnder, s as forEachDescendantNode, t as REACTIVE_CHILDREN_KEY, u as getElementReactivePropsCleanupMap, v as updateElementRef, w as isDelegatedEvent, x as clearDelegatedHandlersForElement, y as addDelegatedListener } from "./cleanup-
|
|
12
|
+
import { C as getDelegatedHandlersForElement, D as updateDelegatedListener, E as removeDelegatedListener, S as getDelegatedHandlerForElement, T as isEventDelegationEnabled, _ as teardownNodeSubtree, a as elementReactivePropsCleanup, b as addFreshDelegatedListener, c as forEachElementReactivePropCleanup, d as removeAllListeners, f as removeElementReactiveProps, g as setFreshElementReactivePropCleanup, h as setDirectElementReactivePropCleanup, i as elementListeners, l as getElementReactivePropCleanupSize, m as replaceElementRefBookkeeping, n as cleanupInstanceIfPresent, o as elementRefs, p as removeElementRef, r as cleanupInstancesUnder, s as forEachDescendantNode, t as REACTIVE_CHILDREN_KEY, u as getElementReactivePropsCleanupMap, v as updateElementRef, w as isDelegatedEvent, x as clearDelegatedHandlersForElement, y as addDelegatedListener } from "./cleanup-CyY1ROBI.js";
|
|
13
|
+
import { a as isSSRPortalHydrationAnchor } from "./portal-w3oQ6oQU.js";
|
|
13
14
|
import { n as getPublicAttributeName, t as sanitizeCssValue } from "./css-BuPaTOfe.js";
|
|
14
|
-
import { a as isSafeHref, i as ROUTE_ROOT_COMPONENT } from "./csp-nonce-
|
|
15
|
+
import { a as isSafeHref, i as ROUTE_ROOT_COMPONENT } from "./csp-nonce-BUsz0Em7.js";
|
|
15
16
|
//#region src/runtime/error-boundary.ts
|
|
16
17
|
function createBoundaryReset(instance) {
|
|
17
18
|
return () => {
|
|
@@ -1817,8 +1818,14 @@ function performFullReconciliation(parent, newChildren, oldKeyMap) {
|
|
|
1817
1818
|
}
|
|
1818
1819
|
//#endregion
|
|
1819
1820
|
//#region src/renderer/child-shape.ts
|
|
1820
|
-
function isFragmentVNode
|
|
1821
|
-
return _isDOMElement(node) &&
|
|
1821
|
+
function isFragmentVNode(node) {
|
|
1822
|
+
return _isDOMElement(node) && isFragmentType(node.type);
|
|
1823
|
+
}
|
|
1824
|
+
function isTransparentComponentResult(result) {
|
|
1825
|
+
return Array.isArray(result) || _isDOMElement(result) && (result.type === __CONTROL_BOUNDARY__ || hasTransparentComponentResult(result.type) || isFragmentVNode(result));
|
|
1826
|
+
}
|
|
1827
|
+
function isTransparentComponentRangeResult(result) {
|
|
1828
|
+
return Array.isArray(result) || isFragmentVNode(result);
|
|
1822
1829
|
}
|
|
1823
1830
|
function normalizeComponentChildren(result) {
|
|
1824
1831
|
if (result === null || result === void 0 || result === false) return [];
|
|
@@ -1827,7 +1834,7 @@ function normalizeComponentChildren(result) {
|
|
|
1827
1834
|
for (const child of result) children.push(...normalizeComponentChildren(child));
|
|
1828
1835
|
return children;
|
|
1829
1836
|
}
|
|
1830
|
-
if (isFragmentVNode
|
|
1837
|
+
if (isFragmentVNode(result)) return normalizeComponentChildren(result.props?.children ?? result.children ?? []);
|
|
1831
1838
|
return [result];
|
|
1832
1839
|
}
|
|
1833
1840
|
function warnMissingKeys(children) {
|
|
@@ -1890,7 +1897,7 @@ function tryGetStaticCreateFastPathShape(props, children) {
|
|
|
1890
1897
|
//#endregion
|
|
1891
1898
|
//#region src/renderer/reactive-child-sources.ts
|
|
1892
1899
|
function collectReactiveScalarSequenceValue(value, normalized) {
|
|
1893
|
-
if (isFragmentVNode
|
|
1900
|
+
if (isFragmentVNode(value)) return collectReactiveScalarSequenceValue(value.props?.children ?? value.children, normalized);
|
|
1894
1901
|
if (Array.isArray(value)) {
|
|
1895
1902
|
for (const child of value) if (!collectReactiveScalarSequenceValue(child, normalized)) return false;
|
|
1896
1903
|
return true;
|
|
@@ -1903,7 +1910,7 @@ function collectReactiveScalarSequenceValue(value, normalized) {
|
|
|
1903
1910
|
return false;
|
|
1904
1911
|
}
|
|
1905
1912
|
function collectReactiveScalarChildSource(children, slots, state) {
|
|
1906
|
-
if (isFragmentVNode
|
|
1913
|
+
if (isFragmentVNode(children)) return collectReactiveScalarChildSource(children.props?.children ?? children.children, slots, state);
|
|
1907
1914
|
if (Array.isArray(children)) {
|
|
1908
1915
|
for (const child of children) if (!collectReactiveScalarChildSource(child, slots, state)) return false;
|
|
1909
1916
|
return true;
|
|
@@ -1933,7 +1940,7 @@ function getReactiveScalarChildSource(children) {
|
|
|
1933
1940
|
return state.hasDynamic ? slots : null;
|
|
1934
1941
|
}
|
|
1935
1942
|
function getSingleReactiveChildBoundarySource(children) {
|
|
1936
|
-
if (isFragmentVNode
|
|
1943
|
+
if (isFragmentVNode(children)) return getSingleReactiveChildBoundarySource(children.props?.children ?? children.children);
|
|
1937
1944
|
if (Array.isArray(children)) {
|
|
1938
1945
|
if (children.length !== 1) return null;
|
|
1939
1946
|
return getSingleReactiveChildBoundarySource(children[0]);
|
|
@@ -1942,7 +1949,7 @@ function getSingleReactiveChildBoundarySource(children) {
|
|
|
1942
1949
|
return null;
|
|
1943
1950
|
}
|
|
1944
1951
|
function collectReactiveChildBoundarySequenceSource(children, slots, state) {
|
|
1945
|
-
if (isFragmentVNode
|
|
1952
|
+
if (isFragmentVNode(children)) return collectReactiveChildBoundarySequenceSource(children.props?.children ?? children.children, slots, state);
|
|
1946
1953
|
if (Array.isArray(children)) {
|
|
1947
1954
|
for (const child of children) if (!collectReactiveChildBoundarySequenceSource(child, slots, state)) return false;
|
|
1948
1955
|
return true;
|
|
@@ -2039,7 +2046,7 @@ function collectReactiveChildValuesAsVNodes(values, children) {
|
|
|
2039
2046
|
for (const value of values) collectReactiveChildBoundaryVNodes(value, children);
|
|
2040
2047
|
}
|
|
2041
2048
|
function normalizeReactiveChildBoundaryVNode(value) {
|
|
2042
|
-
if (!isFragmentVNode
|
|
2049
|
+
if (!isFragmentVNode(value)) return value;
|
|
2043
2050
|
const children = normalizeComponentChildren(value);
|
|
2044
2051
|
if (children.length !== 1) return value;
|
|
2045
2052
|
return normalizeReactiveChildBoundaryVNode(children[0]);
|
|
@@ -2047,7 +2054,7 @@ function normalizeReactiveChildBoundaryVNode(value) {
|
|
|
2047
2054
|
function isSingleRootReactiveChildBoundaryValue(value) {
|
|
2048
2055
|
if (value === null || value === void 0 || value === false) return true;
|
|
2049
2056
|
if (Array.isArray(value)) return value.length === 1 && isSingleRootReactiveChildBoundaryValue(value[0]);
|
|
2050
|
-
if (isFragmentVNode
|
|
2057
|
+
if (isFragmentVNode(value)) {
|
|
2051
2058
|
const children = normalizeComponentChildren(value);
|
|
2052
2059
|
return children.length === 1 && isSingleRootReactiveChildBoundaryValue(children[0]);
|
|
2053
2060
|
}
|
|
@@ -2059,7 +2066,7 @@ function collectReactiveChildBoundaryVNodes(value, children) {
|
|
|
2059
2066
|
for (const child of value) collectReactiveChildBoundaryVNodes(child, children);
|
|
2060
2067
|
return;
|
|
2061
2068
|
}
|
|
2062
|
-
if (isFragmentVNode
|
|
2069
|
+
if (isFragmentVNode(value)) {
|
|
2063
2070
|
collectReactiveChildBoundaryVNodes(value.props?.children ?? value.children, children);
|
|
2064
2071
|
return;
|
|
2065
2072
|
}
|
|
@@ -2489,9 +2496,6 @@ function syncReactiveScalarChild(el, children, host) {
|
|
|
2489
2496
|
/**
|
|
2490
2497
|
* Static subtree reuse checks for intrinsic DOM children.
|
|
2491
2498
|
*/
|
|
2492
|
-
function isFragmentVNode(node) {
|
|
2493
|
-
return _isDOMElement(node) && typeof node.type === "symbol" && (node.type === Fragment || String(node.type) === "Symbol(askr.fragment)");
|
|
2494
|
-
}
|
|
2495
2499
|
function upperCommonTagName(tag) {
|
|
2496
2500
|
switch (tag) {
|
|
2497
2501
|
case "div": return "DIV";
|
|
@@ -2596,7 +2600,7 @@ function updateElementChildren$1(el, children, forceUpdate = false) {
|
|
|
2596
2600
|
el.textContent = "";
|
|
2597
2601
|
return;
|
|
2598
2602
|
}
|
|
2599
|
-
if (!Array.isArray(children) && isFragmentVNode
|
|
2603
|
+
if (!Array.isArray(children) && isFragmentVNode(children)) {
|
|
2600
2604
|
updateUnkeyedChildren(el, normalizeComponentChildren(children), forceUpdate);
|
|
2601
2605
|
return;
|
|
2602
2606
|
}
|
|
@@ -2705,7 +2709,11 @@ function updateMixedControlChildren(parent, children, forceUpdate) {
|
|
|
2705
2709
|
else if (cursorWasReplaced && isRangeStart(cursor)) cursor = findRangeEnd(cursor)?.nextSibling ?? last.end.nextSibling;
|
|
2706
2710
|
else if (isRangeStart(cursor)) cursor = findRangeEnd(cursor)?.nextSibling ?? last.end.nextSibling;
|
|
2707
2711
|
else cursor = last.end.nextSibling;
|
|
2708
|
-
} else
|
|
2712
|
+
} else {
|
|
2713
|
+
const inactiveBoundaryCursor = cursor?.parentNode === parent ? cursor : cursorAfterBoundary?.parentNode === parent ? cursorAfterBoundary : null;
|
|
2714
|
+
const inactiveBoundaryEnd = inactiveBoundaryCursor && isRangeStart(inactiveBoundaryCursor) ? findRangeEnd(inactiveBoundaryCursor) : null;
|
|
2715
|
+
cursor = inactiveBoundaryEnd?.previousSibling === inactiveBoundaryCursor ? inactiveBoundaryEnd.nextSibling : inactiveBoundaryCursor;
|
|
2716
|
+
}
|
|
2709
2717
|
continue;
|
|
2710
2718
|
}
|
|
2711
2719
|
if (cursor) cursor = removeRangeAtCursor(parent, cursor);
|
|
@@ -2720,7 +2728,7 @@ function updateMixedControlChildren(parent, children, forceUpdate) {
|
|
|
2720
2728
|
continue;
|
|
2721
2729
|
}
|
|
2722
2730
|
if (cursor && _isDOMElement(child) && typeof child.type === "function") {
|
|
2723
|
-
const synced = domHost.syncComponentElement(cursor, child, child.type, (child.props ?? {}) || {}, parentNamespace, forceUpdate);
|
|
2731
|
+
const synced = domHost.syncComponentElement(cursor, child, child.type, (child.props ?? {}) || {}, parentNamespace, forceUpdate, void 0, void 0, true);
|
|
2724
2732
|
if (synced) {
|
|
2725
2733
|
cursor = synced.nextSibling;
|
|
2726
2734
|
continue;
|
|
@@ -2763,9 +2771,9 @@ function getOrBuildDomKeyMap(parent) {
|
|
|
2763
2771
|
function updateUnkeyedChildren(parent, newChildren, forceUpdate = false) {
|
|
2764
2772
|
const parentNamespace = getParentNamespace(parent);
|
|
2765
2773
|
const domHost = getRendererDOMHost();
|
|
2766
|
-
const trySyncComponentChild = (currentDom, next) => {
|
|
2774
|
+
const trySyncComponentChild = (currentDom, next, hydrationRangeEnd) => {
|
|
2767
2775
|
if (typeof next.type !== "function") return null;
|
|
2768
|
-
return domHost.syncComponentElement(currentDom, next, next.type, (next.props ?? {}) || {}, parentNamespace, forceUpdate);
|
|
2776
|
+
return domHost.syncComponentElement(currentDom, next, next.type, (next.props ?? {}) || {}, parentNamespace, forceUpdate, void 0, hydrationRangeEnd, true);
|
|
2769
2777
|
};
|
|
2770
2778
|
const hasText = newChildren.some((c) => typeof c === "string" || typeof c === "number");
|
|
2771
2779
|
const hasElements = newChildren.some((c) => _isDOMElement(c));
|
|
@@ -2809,14 +2817,13 @@ function updateUnkeyedChildren(parent, newChildren, forceUpdate = false) {
|
|
|
2809
2817
|
const existing = Array.from(parent.children);
|
|
2810
2818
|
if (hasText || hasComponentChildren || hasEmptyChildren || hasNonElementDomChildren) {
|
|
2811
2819
|
const allNodes = Array.from(parent.childNodes);
|
|
2812
|
-
|
|
2813
|
-
for (let i = 0; i < max; i++) {
|
|
2820
|
+
for (let i = 0; i < Math.max(allNodes.length, newChildren.length); i += 1) {
|
|
2814
2821
|
const currentNode = allNodes[i];
|
|
2815
2822
|
const next = newChildren[i];
|
|
2816
2823
|
const nextIsEmpty = isEmptyChild(next);
|
|
2817
2824
|
if (nextIsEmpty && currentNode) {
|
|
2818
2825
|
teardownNodeSubtree(currentNode);
|
|
2819
|
-
currentNode.
|
|
2826
|
+
currentNode.parentNode?.removeChild(currentNode);
|
|
2820
2827
|
continue;
|
|
2821
2828
|
}
|
|
2822
2829
|
if (!currentNode && !nextIsEmpty) {
|
|
@@ -2844,7 +2851,18 @@ function updateUnkeyedChildren(parent, newChildren, forceUpdate = false) {
|
|
|
2844
2851
|
}
|
|
2845
2852
|
else {
|
|
2846
2853
|
if (trySyncControlBoundaryChild(parent, currentNode, next)) continue;
|
|
2847
|
-
|
|
2854
|
+
const remainingExpected = newChildren.length - i - 1;
|
|
2855
|
+
const hydrationRangeEndIndex = allNodes.length - remainingExpected;
|
|
2856
|
+
const synced = trySyncComponentChild(currentEl, next, hydrationRangeEndIndex > i ? allNodes[hydrationRangeEndIndex] ?? null : void 0);
|
|
2857
|
+
if (synced && isRangeStart(synced)) {
|
|
2858
|
+
allNodes.splice(i, Math.max(1, hydrationRangeEndIndex - i), synced);
|
|
2859
|
+
continue;
|
|
2860
|
+
}
|
|
2861
|
+
if (synced && synced !== currentNode && synced.nextSibling === currentNode) {
|
|
2862
|
+
allNodes.splice(i, 0, synced);
|
|
2863
|
+
continue;
|
|
2864
|
+
}
|
|
2865
|
+
if (!synced) {
|
|
2848
2866
|
const dom = domHost.createDOMNode(next, parentNamespace);
|
|
2849
2867
|
if (dom) {
|
|
2850
2868
|
teardownNodeSubtree(currentEl);
|
|
@@ -2853,7 +2871,20 @@ function updateUnkeyedChildren(parent, newChildren, forceUpdate = false) {
|
|
|
2853
2871
|
}
|
|
2854
2872
|
}
|
|
2855
2873
|
} else {
|
|
2856
|
-
if (typeof next.type === "function"
|
|
2874
|
+
if (typeof next.type === "function") {
|
|
2875
|
+
const remainingExpected = newChildren.length - i - 1;
|
|
2876
|
+
const hydrationRangeEndIndex = allNodes.length - remainingExpected;
|
|
2877
|
+
const synced = trySyncComponentChild(currentNode, next, hydrationRangeEndIndex > i ? allNodes[hydrationRangeEndIndex] ?? null : void 0);
|
|
2878
|
+
if (synced && isRangeStart(synced)) {
|
|
2879
|
+
allNodes.splice(i, Math.max(1, hydrationRangeEndIndex - i), synced);
|
|
2880
|
+
continue;
|
|
2881
|
+
}
|
|
2882
|
+
if (synced && synced !== currentNode && synced.nextSibling === currentNode) {
|
|
2883
|
+
allNodes.splice(i, 0, synced);
|
|
2884
|
+
continue;
|
|
2885
|
+
}
|
|
2886
|
+
if (synced) continue;
|
|
2887
|
+
}
|
|
2857
2888
|
const dom = domHost.createDOMNode(next, parentNamespace);
|
|
2858
2889
|
if (dom) {
|
|
2859
2890
|
teardownNodeSubtree(currentNode);
|
|
@@ -3890,7 +3921,7 @@ function tryFirstRenderKeyedChildren(target, vnode) {
|
|
|
3890
3921
|
return true;
|
|
3891
3922
|
}
|
|
3892
3923
|
function isFragment(vnode) {
|
|
3893
|
-
return _isDOMElement(vnode) &&
|
|
3924
|
+
return _isDOMElement(vnode) && isFragmentType(vnode.type);
|
|
3894
3925
|
}
|
|
3895
3926
|
function getFragmentChildren(vnode) {
|
|
3896
3927
|
const fragmentChildren = vnode.props?.children ?? vnode.children ?? [];
|
|
@@ -4353,6 +4384,11 @@ function checkVNodeShapeChanged(dom, vnode) {
|
|
|
4353
4384
|
if (typeof vnode.type !== "string") return true;
|
|
4354
4385
|
return dom.tagName.toLowerCase() !== vnode.type.toLowerCase();
|
|
4355
4386
|
}
|
|
4387
|
+
function canAdoptHydratedElement(dom, vnode) {
|
|
4388
|
+
if (!_isDOMElement(vnode)) return false;
|
|
4389
|
+
if (typeof vnode.type === "function") return true;
|
|
4390
|
+
return !checkVNodeShapeChanged(dom, vnode);
|
|
4391
|
+
}
|
|
4356
4392
|
function adoptHydratedRange(parent, scope, before, vnode) {
|
|
4357
4393
|
if (!scope.hydrationPending || !before || !isRangeStart(before)) return null;
|
|
4358
4394
|
const end = findRangeEnd(before);
|
|
@@ -4363,7 +4399,7 @@ function adoptHydratedRange(parent, scope, before, vnode) {
|
|
|
4363
4399
|
single: false
|
|
4364
4400
|
};
|
|
4365
4401
|
const contentNodes = getRangeNodes(range);
|
|
4366
|
-
const expectedChildren = _isDOMElement(vnode) && vnode.type
|
|
4402
|
+
const expectedChildren = _isDOMElement(vnode) && isFragmentType(vnode.type) ? vnode.props?.children ?? [] : [vnode];
|
|
4367
4403
|
if (contentNodes.length !== expectedChildren.length) return null;
|
|
4368
4404
|
for (let index = 0; index < expectedChildren.length; index += 1) {
|
|
4369
4405
|
const expected = expectedChildren[index];
|
|
@@ -4521,7 +4557,7 @@ function syncControlBoundaryInMixedParent(parent, controlState, childrenVNodes,
|
|
|
4521
4557
|
const item = controlState.orderedItems[index];
|
|
4522
4558
|
const vnode = childrenVNodes[index];
|
|
4523
4559
|
if (!item || vnode === void 0) continue;
|
|
4524
|
-
if (item.scope.hydrationPending && !item.scope.range && syncBefore instanceof Element && getMaterializedKey(syncBefore) === controlState.orderedKeys[index] &&
|
|
4560
|
+
if (item.scope.hydrationPending && !item.scope.range && syncBefore instanceof Element && getMaterializedKey(syncBefore) === controlState.orderedKeys[index] && canAdoptHydratedElement(syncBefore, vnode)) {
|
|
4525
4561
|
assignScopeRange(item.scope, {
|
|
4526
4562
|
start: syncBefore,
|
|
4527
4563
|
end: syncBefore,
|
|
@@ -4551,6 +4587,14 @@ function syncControlBoundaryInMixedParent(parent, controlState, childrenVNodes,
|
|
|
4551
4587
|
}
|
|
4552
4588
|
const activeScope = controlState.activeScope;
|
|
4553
4589
|
const activeVNode = childrenVNodes[0];
|
|
4590
|
+
if (activeScope?.hydrationPending && activeVNode !== void 0 && !activeScope.range && controlState.lastRemovedRanges.length === 0 && before instanceof Element && canAdoptHydratedElement(before, activeVNode)) {
|
|
4591
|
+
assignScopeRange(activeScope, {
|
|
4592
|
+
start: before,
|
|
4593
|
+
end: before,
|
|
4594
|
+
single: true
|
|
4595
|
+
});
|
|
4596
|
+
activeScope.hydrationPending = false;
|
|
4597
|
+
}
|
|
4554
4598
|
const nextRange = activeScope && activeVNode !== void 0 ? syncControlBoundaryScopeDom(parent, activeScope, activeVNode, before, controlState.lastRemovedRanges.length === 0) : null;
|
|
4555
4599
|
for (const range of controlState.lastRemovedRanges) if (range !== nextRange) removeRange(range, teardownBoundaryRangeNode);
|
|
4556
4600
|
for (const node of controlState.lastRemovedNodes) if (node.parentNode === parent) teardownBoundaryRangeNode(node);
|
|
@@ -4772,6 +4816,120 @@ function trySyncControlBoundaryChild(parent, currentNode, next) {
|
|
|
4772
4816
|
return true;
|
|
4773
4817
|
}
|
|
4774
4818
|
//#endregion
|
|
4819
|
+
//#region src/renderer/component-fragment-range.ts
|
|
4820
|
+
function captureRangeFocus(range, parent) {
|
|
4821
|
+
const active = parent.ownerDocument.activeElement;
|
|
4822
|
+
if (typeof HTMLElement === "undefined" || !(active instanceof HTMLElement) || !parent.contains(active)) return () => {};
|
|
4823
|
+
let rangeChild = active;
|
|
4824
|
+
while (rangeChild.parentNode && rangeChild.parentNode !== parent) rangeChild = rangeChild.parentNode;
|
|
4825
|
+
if (rangeChild.parentNode !== parent || !rangeContains(range, rangeChild)) return () => {};
|
|
4826
|
+
const selection = active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement ? {
|
|
4827
|
+
start: active.selectionStart,
|
|
4828
|
+
end: active.selectionEnd,
|
|
4829
|
+
direction: active.selectionDirection
|
|
4830
|
+
} : null;
|
|
4831
|
+
return () => {
|
|
4832
|
+
if (!active.isConnected || active.ownerDocument.activeElement === active) return;
|
|
4833
|
+
try {
|
|
4834
|
+
active.focus({ preventScroll: true });
|
|
4835
|
+
} catch {
|
|
4836
|
+
active.focus();
|
|
4837
|
+
}
|
|
4838
|
+
if (selection && (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement) && selection.start !== null && selection.end !== null) active.setSelectionRange(selection.start, selection.end, selection.direction ?? void 0);
|
|
4839
|
+
};
|
|
4840
|
+
}
|
|
4841
|
+
function unwrapStagingHost(staging, parent, restoreFocus) {
|
|
4842
|
+
if (staging.parentNode !== parent) return;
|
|
4843
|
+
while (staging.firstChild) parent.insertBefore(staging.firstChild, staging);
|
|
4844
|
+
staging.remove();
|
|
4845
|
+
restoreFocus();
|
|
4846
|
+
}
|
|
4847
|
+
function createAttributeFreeStagingHost(parent) {
|
|
4848
|
+
return parent.ownerDocument.createElementNS(parent.namespaceURI, parent.localName);
|
|
4849
|
+
}
|
|
4850
|
+
function isAutomaticPortalHost(node) {
|
|
4851
|
+
const host = node;
|
|
4852
|
+
const instances = new Set(host.__ASKR_INSTANCES ?? []);
|
|
4853
|
+
if (host.__ASKR_INSTANCE) instances.add(host.__ASKR_INSTANCE);
|
|
4854
|
+
return instances.size > 0 && Array.from(instances).some((candidate) => candidate.props.__askrAutoDefaultPortal === true);
|
|
4855
|
+
}
|
|
4856
|
+
function adoptHydratedComponentRange(existingHost, instance, result, endExclusive, forceChildrenUpdate, retainedInstances) {
|
|
4857
|
+
const parent = existingHost.parentNode;
|
|
4858
|
+
if (!(parent instanceof Element) || endExclusive !== null && endExclusive.parentNode !== parent) return null;
|
|
4859
|
+
if (endExclusive !== null) {
|
|
4860
|
+
let current = existingHost;
|
|
4861
|
+
while (current && current !== endExclusive) current = current.nextSibling;
|
|
4862
|
+
if (current !== endExclusive) return null;
|
|
4863
|
+
}
|
|
4864
|
+
const start = existingHost.ownerDocument.createComment(RANGE_START_MARKER);
|
|
4865
|
+
const end = existingHost.ownerDocument.createComment(RANGE_END_MARKER);
|
|
4866
|
+
parent.insertBefore(start, existingHost);
|
|
4867
|
+
parent.insertBefore(end, endExclusive);
|
|
4868
|
+
registerRange({
|
|
4869
|
+
start,
|
|
4870
|
+
end,
|
|
4871
|
+
single: false
|
|
4872
|
+
}, instance);
|
|
4873
|
+
const host = start;
|
|
4874
|
+
const owners = new Set(retainedInstances);
|
|
4875
|
+
owners.add(instance);
|
|
4876
|
+
host.__ASKR_INSTANCE = instance;
|
|
4877
|
+
host.__ASKR_INSTANCES = Array.from(owners);
|
|
4878
|
+
instance.target = null;
|
|
4879
|
+
instance._placeholder = start;
|
|
4880
|
+
mountInstanceInline(instance, null);
|
|
4881
|
+
const registered = registerLifecycleTransaction({}, () => {}, () => {
|
|
4882
|
+
start.parentNode?.removeChild(start);
|
|
4883
|
+
end.parentNode?.removeChild(end);
|
|
4884
|
+
});
|
|
4885
|
+
try {
|
|
4886
|
+
if (!syncComponentFragmentRange(host, instance, result, forceChildrenUpdate)) throw new Error("[askr] Failed to adopt hydrated component range.");
|
|
4887
|
+
} catch (error) {
|
|
4888
|
+
if (!registered) {
|
|
4889
|
+
start.remove();
|
|
4890
|
+
end.remove();
|
|
4891
|
+
}
|
|
4892
|
+
throw error;
|
|
4893
|
+
}
|
|
4894
|
+
return start;
|
|
4895
|
+
}
|
|
4896
|
+
function syncComponentFragmentRange(host, instance, result, forceUpdate) {
|
|
4897
|
+
if (!isTransparentComponentRangeResult(result)) return false;
|
|
4898
|
+
const range = getOwnedRange(instance);
|
|
4899
|
+
const parent = range?.start.parentNode;
|
|
4900
|
+
if (!range || range.single || range.start !== host || !(parent instanceof Element)) return false;
|
|
4901
|
+
const restoreFocus = captureRangeFocus(range, parent);
|
|
4902
|
+
const normalizedChildren = normalizeComponentChildren(result);
|
|
4903
|
+
const preserveForeignHosts = Array.isArray(result);
|
|
4904
|
+
const staging = createAttributeFreeStagingHost(parent);
|
|
4905
|
+
try {
|
|
4906
|
+
parent.insertBefore(staging, range.end);
|
|
4907
|
+
} catch {
|
|
4908
|
+
staging.remove();
|
|
4909
|
+
return false;
|
|
4910
|
+
}
|
|
4911
|
+
if (staging.parentNode !== parent || staging.nextSibling !== range.end) {
|
|
4912
|
+
staging.remove();
|
|
4913
|
+
restoreFocus();
|
|
4914
|
+
return false;
|
|
4915
|
+
}
|
|
4916
|
+
let current = range.start.nextSibling;
|
|
4917
|
+
while (current && current !== staging) {
|
|
4918
|
+
const next = current.nextSibling;
|
|
4919
|
+
if (!preserveForeignHosts || !isAutomaticPortalHost(current)) staging.appendChild(current);
|
|
4920
|
+
current = next;
|
|
4921
|
+
}
|
|
4922
|
+
const rollbackStaging = registerLifecycleTransaction({}, () => {}, () => unwrapStagingHost(staging, parent, restoreFocus));
|
|
4923
|
+
try {
|
|
4924
|
+
getRendererDOMHost().updateElementChildren(staging, normalizedChildren, forceUpdate);
|
|
4925
|
+
} catch (error) {
|
|
4926
|
+
if (!rollbackStaging) unwrapStagingHost(staging, parent, restoreFocus);
|
|
4927
|
+
throw error;
|
|
4928
|
+
}
|
|
4929
|
+
if (!registerLifecycleTransaction({}, () => unwrapStagingHost(staging, parent, restoreFocus), () => {})) unwrapStagingHost(staging, parent, restoreFocus);
|
|
4930
|
+
return true;
|
|
4931
|
+
}
|
|
4932
|
+
//#endregion
|
|
4775
4933
|
//#region src/renderer/component-host-cleanup.ts
|
|
4776
4934
|
function cleanupDetachedComponentHost(host, retainedInstance) {
|
|
4777
4935
|
const retainedInstances = retainedInstance instanceof Object && typeof retainedInstance[Symbol.iterator] === "function" ? new Set(retainedInstance) : /* @__PURE__ */ new Set([retainedInstance]);
|
|
@@ -4971,11 +5129,19 @@ function inheritComponentKey(target, source) {
|
|
|
4971
5129
|
}
|
|
4972
5130
|
return target;
|
|
4973
5131
|
}
|
|
5132
|
+
function extractComponentIdentityKey(node) {
|
|
5133
|
+
const publicKey = extractKey(node);
|
|
5134
|
+
if (publicKey !== void 0) return publicKey;
|
|
5135
|
+
if (typeof node !== "object" || node === null) return;
|
|
5136
|
+
const internalKey = node.props?.["__askrIdentityKey"];
|
|
5137
|
+
if (internalKey === void 0 || internalKey === null) return;
|
|
5138
|
+
return typeof internalKey === "symbol" ? String(internalKey) : internalKey;
|
|
5139
|
+
}
|
|
4974
5140
|
function setComponentOwnershipIdentity(instance, node, parent, wrapperDepth = 0, position) {
|
|
4975
5141
|
instance._vnodeOwner = typeof node === "object" && node !== null ? node : void 0;
|
|
4976
5142
|
instance._vnodeParent = parent;
|
|
4977
5143
|
instance._vnodeParentGeneration = parent?._ownershipGeneration;
|
|
4978
|
-
const key =
|
|
5144
|
+
const key = extractComponentIdentityKey(node);
|
|
4979
5145
|
if (key === void 0) delete instance._vnodeKey;
|
|
4980
5146
|
else instance._vnodeKey = key;
|
|
4981
5147
|
instance._vnodePosition = position;
|
|
@@ -4986,7 +5152,7 @@ function findHostInstanceByType(host, type, node, parent, wrapperDepth) {
|
|
|
4986
5152
|
if (instances && instances.length > 0) {
|
|
4987
5153
|
const vnodeOwner = getVNodeComponentInstance(node);
|
|
4988
5154
|
if (vnodeOwner && vnodeOwner.fn === type && instances.includes(vnodeOwner)) return vnodeOwner;
|
|
4989
|
-
const key =
|
|
5155
|
+
const key = extractComponentIdentityKey(node);
|
|
4990
5156
|
const identityMatches = instances.filter((instance) => {
|
|
4991
5157
|
if (instance.fn !== type) return false;
|
|
4992
5158
|
if (parent !== void 0 && instance._vnodeParent !== parent) return false;
|
|
@@ -5002,7 +5168,7 @@ function findHostInstanceByType(host, type, node, parent, wrapperDepth) {
|
|
|
5002
5168
|
}
|
|
5003
5169
|
if (host.__ASKR_INSTANCE?.fn === type) {
|
|
5004
5170
|
const instance = host.__ASKR_INSTANCE;
|
|
5005
|
-
const key =
|
|
5171
|
+
const key = extractComponentIdentityKey(node);
|
|
5006
5172
|
if ((parent === void 0 || instance._vnodeParent === parent) && (key === void 0 || instance._vnodeKey === key) && (wrapperDepth === void 0 || instance._wrapperDepth === wrapperDepth)) return instance;
|
|
5007
5173
|
if (node === void 0 && parent === void 0 && wrapperDepth === void 0) return instance;
|
|
5008
5174
|
}
|
|
@@ -5010,8 +5176,9 @@ function findHostInstanceByType(host, type, node, parent, wrapperDepth) {
|
|
|
5010
5176
|
}
|
|
5011
5177
|
/**
|
|
5012
5178
|
* Resolve an instance on a comment host only when the vnode carries durable
|
|
5013
|
-
* identity.
|
|
5014
|
-
*
|
|
5179
|
+
* identity. An unkeyed multi-node range can also move through transparent
|
|
5180
|
+
* wrapper owners while its recorded owner generation remains live. Fresh
|
|
5181
|
+
* unkeyed null components still supersede the old generation.
|
|
5015
5182
|
*/
|
|
5016
5183
|
function findStableHostInstanceByType(host, type, node, parent, wrapperDepth) {
|
|
5017
5184
|
const instances = new Set(host.__ASKR_INSTANCES ?? []);
|
|
@@ -5019,10 +5186,21 @@ function findStableHostInstanceByType(host, type, node, parent, wrapperDepth) {
|
|
|
5019
5186
|
const parentGeneration = parent?._ownershipGeneration;
|
|
5020
5187
|
const vnodeOwner = getVNodeComponentInstance(node);
|
|
5021
5188
|
if (vnodeOwner?.fn === type && instances.has(vnodeOwner) && vnodeOwner._vnodeParent === parent && vnodeOwner._vnodeParentGeneration === parentGeneration) return vnodeOwner;
|
|
5022
|
-
const key =
|
|
5023
|
-
if (key === void 0)
|
|
5189
|
+
const key = extractComponentIdentityKey(node);
|
|
5190
|
+
if (key === void 0) {
|
|
5191
|
+
const rangeMatches = Array.from(instances).filter((instance) => {
|
|
5192
|
+
const range = getOwnedRange(instance);
|
|
5193
|
+
return instance.fn === type && instance._vnodeParent !== parent && instance._vnodeParent != null && instance._vnodeParentGeneration === instance._vnodeParent._ownershipGeneration && instance._vnodeKey === void 0 && instance._wrapperDepth === wrapperDepth && (range?.single === false && range.start === host || host instanceof Comment && host.data === "askr-range-start" && instance._placeholder === host);
|
|
5194
|
+
});
|
|
5195
|
+
return rangeMatches.length === 1 ? rangeMatches[0] : null;
|
|
5196
|
+
}
|
|
5024
5197
|
const matches = Array.from(instances).filter((instance) => instance.fn === type && instance._vnodeParent === parent && instance._vnodeParentGeneration === parentGeneration && instance._vnodeKey === key && instance._wrapperDepth === wrapperDepth);
|
|
5025
|
-
|
|
5198
|
+
if (matches.length > 0) return matches[matches.length - 1];
|
|
5199
|
+
const rangeMatches = Array.from(instances).filter((instance) => {
|
|
5200
|
+
const range = getOwnedRange(instance);
|
|
5201
|
+
return instance.fn === type && instance._vnodeParent !== parent && instance._vnodeParent != null && instance._vnodeParentGeneration === instance._vnodeParent._ownershipGeneration && instance._vnodeKey === key && instance._wrapperDepth === wrapperDepth && (range?.single === false && range.start === host || host instanceof Comment && host.data === "askr-range-start" && instance._placeholder === host);
|
|
5202
|
+
});
|
|
5203
|
+
return rangeMatches.length === 1 ? rangeMatches[0] : null;
|
|
5026
5204
|
}
|
|
5027
5205
|
//#endregion
|
|
5028
5206
|
//#region src/renderer/component-host-replacement.ts
|
|
@@ -5165,6 +5343,39 @@ function registerVNodeComponentInstanceRollback(node, previousInstance, provisio
|
|
|
5165
5343
|
}
|
|
5166
5344
|
//#endregion
|
|
5167
5345
|
//#region src/renderer/component-host-results.ts
|
|
5346
|
+
function retainReplacementOwnerChain(host, owner, retainedInstances) {
|
|
5347
|
+
const componentHost = host;
|
|
5348
|
+
const next = [...componentHost.__ASKR_INSTANCES ?? []];
|
|
5349
|
+
for (const instance of retainedInstances) if (!next.includes(instance)) next.push(instance);
|
|
5350
|
+
componentHost.__ASKR_INSTANCES = next;
|
|
5351
|
+
componentHost.__ASKR_INSTANCE = owner;
|
|
5352
|
+
}
|
|
5353
|
+
function adoptEmptySSRPortalHydrationHost(host, instance, retainedInstances, result) {
|
|
5354
|
+
if (!isSSRPortalHydrationAnchor(host) || result !== null && result !== void 0 && result !== false) return false;
|
|
5355
|
+
const instanceHost = host;
|
|
5356
|
+
instanceHost.__ASKR_INSTANCE = instance;
|
|
5357
|
+
instanceHost.__ASKR_INSTANCES = Array.from(/* @__PURE__ */ new Set([instance, ...retainedInstances]));
|
|
5358
|
+
instance._placeholder = instanceHost;
|
|
5359
|
+
mountInstanceInline(instance, null);
|
|
5360
|
+
retainReplacementOwnerChain(instanceHost, instance, retainedInstances);
|
|
5361
|
+
return true;
|
|
5362
|
+
}
|
|
5363
|
+
function materializeEmptyHydrationPlaceholder(existingHost, instance, retainedInstances, result, preserveHydrationCursor) {
|
|
5364
|
+
if (!preserveHydrationCursor && !isSSRPortalHydrationAnchor(existingHost) || result !== null && result !== void 0 && result !== false) return null;
|
|
5365
|
+
const placeholder = isSSRPortalHydrationAnchor(existingHost) ? existingHost : (existingHost.ownerDocument ?? document).createComment("");
|
|
5366
|
+
if (placeholder !== existingHost) existingHost.parentNode?.insertBefore(placeholder, existingHost);
|
|
5367
|
+
const host = placeholder;
|
|
5368
|
+
host.__ASKR_INSTANCE = instance;
|
|
5369
|
+
host.__ASKR_INSTANCES = [instance];
|
|
5370
|
+
instance._placeholder = placeholder;
|
|
5371
|
+
mountInstanceInline(instance, null);
|
|
5372
|
+
retainReplacementOwnerChain(placeholder, instance, retainedInstances);
|
|
5373
|
+
return placeholder;
|
|
5374
|
+
}
|
|
5375
|
+
function itemInstanceHydrationComplete(host) {
|
|
5376
|
+
const scope = host.__ASKR_INSTANCE?.scope;
|
|
5377
|
+
if (scope) scope.hydrationPending = false;
|
|
5378
|
+
}
|
|
5168
5379
|
function materializeComponentResultNode(childInstance, result, parentNamespace) {
|
|
5169
5380
|
const dom = getRendererDOMHost().createComponentResultNode(childInstance.fn, result, parentNamespace);
|
|
5170
5381
|
if (dom instanceof Element) {
|
|
@@ -5182,7 +5393,17 @@ function materializeComponentResultNode(childInstance, result, parentNamespace)
|
|
|
5182
5393
|
mountInstanceInline(childInstance, null);
|
|
5183
5394
|
return placeholder;
|
|
5184
5395
|
}
|
|
5185
|
-
if (
|
|
5396
|
+
if (dom instanceof Comment) {
|
|
5397
|
+
const host = dom;
|
|
5398
|
+
const instances = host.__ASKR_INSTANCES ?? [];
|
|
5399
|
+
if (!instances.includes(childInstance)) instances.push(childInstance);
|
|
5400
|
+
host.__ASKR_INSTANCES = instances;
|
|
5401
|
+
host.__ASKR_INSTANCE = instances[0] ?? childInstance;
|
|
5402
|
+
childInstance._placeholder = dom;
|
|
5403
|
+
mountInstanceInline(childInstance, null);
|
|
5404
|
+
return dom;
|
|
5405
|
+
}
|
|
5406
|
+
if (!isTransparentComponentResult(result)) {
|
|
5186
5407
|
const host = document.createElement("div");
|
|
5187
5408
|
host.appendChild(dom);
|
|
5188
5409
|
host.__ASKR_WRAPPER_HOST = true;
|
|
@@ -5306,15 +5527,15 @@ function resolveWrapperHostResult(host, result, snapshot, retainedInstances) {
|
|
|
5306
5527
|
}
|
|
5307
5528
|
//#endregion
|
|
5308
5529
|
//#region src/renderer/component-host.ts
|
|
5309
|
-
function syncComponentElement(currentDom, node, type, props, parentNamespace, forceChildrenUpdate = false, retainedHostInstances) {
|
|
5530
|
+
function syncComponentElement(currentDom, node, type, props, parentNamespace, forceChildrenUpdate = false, retainedHostInstances, hydrationRangeEnd, preserveHydrationCursorOnEmpty = false) {
|
|
5310
5531
|
const existingHost = currentDom instanceof Element || currentDom instanceof Comment ? currentDom : null;
|
|
5311
5532
|
const existingInstance = existingHost ? existingHost instanceof Comment ? findStableHostInstanceByType(existingHost, type, node, getCurrentInstance(), 0) : findHostInstanceByType(existingHost, type, node, getCurrentInstance(), 0) : null;
|
|
5312
5533
|
if (!existingHost) return null;
|
|
5313
5534
|
const domHost = getRendererDOMHost();
|
|
5314
5535
|
if (!existingInstance || existingInstance.fn !== type) {
|
|
5315
|
-
if (!(existingHost instanceof Element)) return null;
|
|
5536
|
+
if (!(existingHost instanceof Element) && !isSSRPortalHydrationAnchor(existingHost)) return null;
|
|
5316
5537
|
const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame() || null;
|
|
5317
|
-
const hydrationInstance = createComponentInstance(nextComponentInstanceId(), type, props || {}, existingHost);
|
|
5538
|
+
const hydrationInstance = createComponentInstance(nextComponentInstanceId(), type, props || {}, existingHost instanceof Element ? existingHost : null);
|
|
5318
5539
|
setComponentOwnershipIdentity(hydrationInstance, node, getCurrentInstance(), 0);
|
|
5319
5540
|
hydrationInstance.isRoot = isRouteRootComponentVNode(node);
|
|
5320
5541
|
hydrationInstance.portalScope = getCurrentInstance()?.portalScope ?? hydrationInstance.portalScope;
|
|
@@ -5330,7 +5551,13 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
|
|
|
5330
5551
|
const result = withContext(snapshot, () => renderComponentInline(hydrationInstance));
|
|
5331
5552
|
if (isPromiseLike(result)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
5332
5553
|
const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);
|
|
5333
|
-
|
|
5554
|
+
const emptyPlaceholder = materializeEmptyHydrationPlaceholder(existingHost, hydrationInstance, liveRetainedInstances, scopedResult, preserveHydrationCursorOnEmpty);
|
|
5555
|
+
if (emptyPlaceholder) return emptyPlaceholder;
|
|
5556
|
+
if (hydrationRangeEnd !== void 0 && isTransparentComponentRangeResult(scopedResult)) {
|
|
5557
|
+
const adoptedHost = adoptHydratedComponentRange(existingHost, hydrationInstance, scopedResult, hydrationRangeEnd, forceChildrenUpdate || hydrationInstance.mounted === false, liveRetainedInstances);
|
|
5558
|
+
if (adoptedHost) return adoptedHost;
|
|
5559
|
+
}
|
|
5560
|
+
if (existingHost instanceof Element && scopedResult && typeof scopedResult === "object" && "type" in scopedResult && typeof scopedResult.type === "string" && tagNamesEqualIgnoreCase$1(existingHost.tagName, scopedResult.type)) {
|
|
5334
5561
|
withContext(snapshot, () => {
|
|
5335
5562
|
domHost.updateElementFromVnode(existingHost, inheritComponentKey(scopedResult, node), true, forceChildrenUpdate || hydrationInstance.mounted === false);
|
|
5336
5563
|
materializeKey(existingHost, node, props);
|
|
@@ -5340,7 +5567,12 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
|
|
|
5340
5567
|
return existingHost;
|
|
5341
5568
|
}
|
|
5342
5569
|
const resolvedResult = resolveHostNestedComponentResult(existingHost, hydrationInstance, scopedResult, snapshot ?? null, liveRetainedInstances);
|
|
5343
|
-
if (
|
|
5570
|
+
if (adoptEmptySSRPortalHydrationHost(existingHost, hydrationInstance, liveRetainedInstances, resolvedResult)) return existingHost;
|
|
5571
|
+
if (hydrationRangeEnd !== void 0 && isTransparentComponentRangeResult(resolvedResult)) {
|
|
5572
|
+
const adoptedHost = adoptHydratedComponentRange(existingHost, hydrationInstance, resolvedResult, hydrationRangeEnd, forceChildrenUpdate || hydrationInstance.mounted === false, liveRetainedInstances);
|
|
5573
|
+
if (adoptedHost) return adoptedHost;
|
|
5574
|
+
}
|
|
5575
|
+
if (existingHost instanceof Element && _isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase$1(existingHost.tagName, resolvedResult.type)) {
|
|
5344
5576
|
withContext(snapshot, () => {
|
|
5345
5577
|
domHost.updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || hydrationInstance.mounted === false);
|
|
5346
5578
|
materializeKey(existingHost, node, props);
|
|
@@ -5378,6 +5610,7 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
|
|
|
5378
5610
|
domHost.updateElementChildren(existingHost, normalizeComponentChildren(wrapperResult));
|
|
5379
5611
|
return existingHost;
|
|
5380
5612
|
}
|
|
5613
|
+
if (existingHost instanceof Comment && syncComponentFragmentRange(existingHost, existingInstance, scopedResult, forceChildrenUpdate || existingInstance.mounted === false)) return existingHost;
|
|
5381
5614
|
if (existingHost instanceof Element && scopedResult && typeof scopedResult === "object" && "type" in scopedResult && typeof scopedResult.type === "string" && tagNamesEqualIgnoreCase$1(existingHost.tagName, scopedResult.type)) {
|
|
5382
5615
|
withContext(snapshot, () => {
|
|
5383
5616
|
domHost.updateElementFromVnode(existingHost, inheritComponentKey(scopedResult, node), true, forceChildrenUpdate || existingInstance.mounted === false);
|
|
@@ -5386,6 +5619,7 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
|
|
|
5386
5619
|
return existingHost;
|
|
5387
5620
|
}
|
|
5388
5621
|
const resolvedResult = resolveHostNestedComponentResult(existingHost, existingInstance, scopedResult, snapshot ?? null, liveRetainedInstances);
|
|
5622
|
+
if (existingHost instanceof Comment && syncComponentFragmentRange(existingHost, existingInstance, resolvedResult, forceChildrenUpdate || existingInstance.mounted === false)) return existingHost;
|
|
5389
5623
|
if (existingHost instanceof Comment && (resolvedResult === null || resolvedResult === void 0 || resolvedResult === false)) {
|
|
5390
5624
|
retainReplacementOwnerChain(existingHost, existingInstance, liveRetainedInstances);
|
|
5391
5625
|
for (const instance of liveRetainedInstances) if (instance.target === null || instance._placeholder === existingHost) {
|
|
@@ -5406,20 +5640,6 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
|
|
|
5406
5640
|
retainReplacementOwnerChain(replacement, existingInstance, liveRetainedInstances);
|
|
5407
5641
|
});
|
|
5408
5642
|
}
|
|
5409
|
-
function retainReplacementOwnerChain(host, owner, retainedInstances) {
|
|
5410
|
-
const componentHost = host;
|
|
5411
|
-
const next = [...componentHost.__ASKR_INSTANCES ?? []];
|
|
5412
|
-
for (const instance of retainedInstances) if (!next.includes(instance)) next.push(instance);
|
|
5413
|
-
componentHost.__ASKR_INSTANCES = next;
|
|
5414
|
-
componentHost.__ASKR_INSTANCE = owner;
|
|
5415
|
-
}
|
|
5416
|
-
function itemInstanceHydrationComplete(host) {
|
|
5417
|
-
const instance = host.__ASKR_INSTANCE;
|
|
5418
|
-
if (instance) {
|
|
5419
|
-
const scope = instance.scope;
|
|
5420
|
-
if (scope) scope.hydrationPending = false;
|
|
5421
|
-
}
|
|
5422
|
-
}
|
|
5423
5643
|
function createComponentElement(node, type, props, parentNamespace) {
|
|
5424
5644
|
const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame();
|
|
5425
5645
|
const componentFn = type;
|
|
@@ -5660,7 +5880,7 @@ function getVNodeChildren(vnode) {
|
|
|
5660
5880
|
function getDirectReactiveCompute(value) {
|
|
5661
5881
|
if (typeof value === "function") return value;
|
|
5662
5882
|
if (Array.isArray(value)) return value.length === 1 ? getDirectReactiveCompute(value[0]) : null;
|
|
5663
|
-
if (typeof value === "object" && value !== null && isFragmentVNode
|
|
5883
|
+
if (typeof value === "object" && value !== null && isFragmentVNode(value)) return getDirectReactiveCompute(getVNodeChildren(value));
|
|
5664
5884
|
return null;
|
|
5665
5885
|
}
|
|
5666
5886
|
const ownerBlueprints = /* @__PURE__ */ new WeakMap();
|
|
@@ -5715,7 +5935,7 @@ function collectReactiveSlotShapes(value, slots) {
|
|
|
5715
5935
|
});
|
|
5716
5936
|
return true;
|
|
5717
5937
|
}
|
|
5718
|
-
if (typeof value === "object" && value !== null && isFragmentVNode
|
|
5938
|
+
if (typeof value === "object" && value !== null && isFragmentVNode(value)) return collectReactiveSlotShapes(getVNodeChildren(value), slots);
|
|
5719
5939
|
return false;
|
|
5720
5940
|
}
|
|
5721
5941
|
function collectStaticVNodeChildren(value, children) {
|
|
@@ -5733,7 +5953,7 @@ function collectStaticVNodeChildren(value, children) {
|
|
|
5733
5953
|
children.push(value);
|
|
5734
5954
|
return true;
|
|
5735
5955
|
}
|
|
5736
|
-
if (typeof value.type === "symbol" && isFragmentVNode
|
|
5956
|
+
if (typeof value.type === "symbol" && isFragmentVNode(value)) return collectStaticVNodeChildren(getVNodeChildren(value), children);
|
|
5737
5957
|
}
|
|
5738
5958
|
return false;
|
|
5739
5959
|
}
|
|
@@ -5845,7 +6065,7 @@ function matchReactiveSlots(value, slots, startIndex) {
|
|
|
5845
6065
|
if (!slot) return -1;
|
|
5846
6066
|
if (typeof value === "function") return slot.kind === "dynamic" ? startIndex + 1 : -1;
|
|
5847
6067
|
if (typeof value === "string" || typeof value === "number") return slot.kind === "static" && slot.value === String(value) ? startIndex + 1 : -1;
|
|
5848
|
-
if (typeof value === "object" && value !== null && isFragmentVNode
|
|
6068
|
+
if (typeof value === "object" && value !== null && isFragmentVNode(value)) return matchReactiveSlots(getVNodeChildren(value), slots, startIndex);
|
|
5849
6069
|
return -1;
|
|
5850
6070
|
}
|
|
5851
6071
|
//#endregion
|
|
@@ -6044,7 +6264,7 @@ function prepareStaticSlots(element, value, slots, startIndex, bindings, deferre
|
|
|
6044
6264
|
const childNode = element.childNodes[startIndex];
|
|
6045
6265
|
if (typeof value === "string" || typeof value === "number") return slot?.kind === "text" && slot.value === String(value) ? startIndex + 1 : -1;
|
|
6046
6266
|
if (!_isDOMElement(value)) return -1;
|
|
6047
|
-
if (typeof value.type === "symbol") return isFragmentVNode
|
|
6267
|
+
if (typeof value.type === "symbol") return isFragmentVNode(value) ? prepareStaticSlots(element, getVNodeChildren(value), slots, startIndex, bindings, deferred) : -1;
|
|
6048
6268
|
if (slot?.kind === "element" && childNode !== void 0) return prepareElementBlueprint(childNode, value, slot.shape, bindings, deferred) ? startIndex + 1 : -1;
|
|
6049
6269
|
return -1;
|
|
6050
6270
|
}
|
|
@@ -6152,7 +6372,7 @@ function createDOMNode(node, parentNamespace) {
|
|
|
6152
6372
|
if (typeof type === "function") return createComponentElement(node, type, props, parentNamespace);
|
|
6153
6373
|
if (type === __CONTROL_BOUNDARY__) return createForBoundary(node, props, parentNamespace);
|
|
6154
6374
|
if (type === __ERROR_BOUNDARY__) return createErrorBoundaryElement(node, props, parentNamespace);
|
|
6155
|
-
if (
|
|
6375
|
+
if (isFragmentType(type)) return createFragmentElement(node, props, parentNamespace);
|
|
6156
6376
|
}
|
|
6157
6377
|
return null;
|
|
6158
6378
|
}
|
|
@@ -6469,6 +6689,11 @@ function replaceComponentRange(instance, result, placeholder) {
|
|
|
6469
6689
|
const previousRange = getOwnedRange(instance);
|
|
6470
6690
|
const parent = placeholder.parentNode;
|
|
6471
6691
|
if (!previousRange || previousRange.single || previousRange.start !== placeholder || !(parent instanceof Element)) return null;
|
|
6692
|
+
if (syncComponentFragmentRange(placeholder, instance, result, false)) return placeholder;
|
|
6693
|
+
if (_isDOMElement(result) && hasTransparentComponentResult(result.type)) {
|
|
6694
|
+
const retainedInstances = createRetainedHostInstanceSet(instance);
|
|
6695
|
+
if (syncComponentFragmentRange(placeholder, instance, resolveHostNestedComponentResult(placeholder, instance, result, getVNodeContextFrame(result) ?? instance.ownerFrame ?? null, retainedInstances), false)) return placeholder;
|
|
6696
|
+
}
|
|
6472
6697
|
const next = createDetachedRange(materializeComponentResultNode(instance, result, getParentNamespace(parent)), instance);
|
|
6473
6698
|
const nextHost = next.range.start;
|
|
6474
6699
|
nextHost.__ASKR_INSTANCE = instance;
|