@estjs/template 0.0.16 → 0.0.17-beta.2
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/template.cjs +2 -2
- package/dist/template.d.cts +25 -52
- package/dist/template.d.ts +25 -52
- package/dist/template.dev.cjs +211 -257
- package/dist/template.dev.cjs.map +1 -1
- package/dist/template.dev.js +211 -257
- package/dist/template.dev.js.map +1 -1
- package/dist/template.js +2 -2
- package/package.json +4 -4
package/dist/template.dev.js
CHANGED
|
@@ -13,6 +13,14 @@ var SUSPENSE_COMPONENT = /* @__PURE__ */ Symbol("Suspense Component" );
|
|
|
13
13
|
var FOR_COMPONENT = /* @__PURE__ */ Symbol("For Component" );
|
|
14
14
|
var TRANSITION_COMPONENT = /* @__PURE__ */ Symbol("Transition Component" );
|
|
15
15
|
var TRANSITION_GROUP_COMPONENT = /* @__PURE__ */ Symbol("TransitionGroup Component" );
|
|
16
|
+
var DANGEROUS_DATA_MIME_RE = /^data:\s*(?:text\/html|text\/xml|application\/xhtml\+xml|image\/svg\+xml|application\/xml)/;
|
|
17
|
+
function isUnsafeUrl(value) {
|
|
18
|
+
const v = value.replaceAll(/[\u0000-\u0020]+/g, "").toLowerCase();
|
|
19
|
+
if (startsWith(v, "javascript:") || startsWith(v, "vbscript:")) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return DANGEROUS_DATA_MIME_RE.test(v);
|
|
23
|
+
}
|
|
16
24
|
function patchAttr(el, key, prev, next2) {
|
|
17
25
|
if (key === KEY_PROP) {
|
|
18
26
|
if (next2 == null) {
|
|
@@ -94,11 +102,8 @@ function patchAttr(el, key, prev, next2) {
|
|
|
94
102
|
}
|
|
95
103
|
const attrValue = isSymbol(next2) ? String(next2) : next2;
|
|
96
104
|
const isUrlAttr = lowerKey === "href" || lowerKey === "src" || lowerKey === "xlink:href" || lowerKey === "action" || lowerKey === "formaction" || lowerKey === "poster";
|
|
97
|
-
if (isUrlAttr && isString(attrValue)) {
|
|
98
|
-
|
|
99
|
-
if (startsWith(v, "javascript:") || startsWith(v, "data:")) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
105
|
+
if (isUrlAttr && isString(attrValue) && isUnsafeUrl(attrValue)) {
|
|
106
|
+
return;
|
|
102
107
|
}
|
|
103
108
|
if (isXlink) {
|
|
104
109
|
el.setAttributeNS(XLINK_NAMESPACE, key, String(attrValue));
|
|
@@ -1035,7 +1040,13 @@ function createApp(component, target) {
|
|
|
1035
1040
|
const existingContent = container.innerHTML;
|
|
1036
1041
|
if (existingContent) {
|
|
1037
1042
|
{
|
|
1038
|
-
|
|
1043
|
+
if (container.querySelector("[data-hk]")) {
|
|
1044
|
+
warn(
|
|
1045
|
+
`Target element contains server-rendered markup ([data-hk]); createApp() will discard it and render from scratch. Did you mean to call hydrate()?`
|
|
1046
|
+
);
|
|
1047
|
+
} else {
|
|
1048
|
+
warn(`Target element is not empty, it will be cleared: ${target}`);
|
|
1049
|
+
}
|
|
1039
1050
|
}
|
|
1040
1051
|
container.innerHTML = "";
|
|
1041
1052
|
}
|
|
@@ -1540,11 +1551,6 @@ function tryHydratePortal(props) {
|
|
|
1540
1551
|
function isPortal(node) {
|
|
1541
1552
|
return !!node && !!node[PORTAL_COMPONENT];
|
|
1542
1553
|
}
|
|
1543
|
-
function clearContainer(el) {
|
|
1544
|
-
while (el.firstChild) {
|
|
1545
|
-
el.removeChild(el.firstChild);
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
1554
|
function resolveNodeValue(value) {
|
|
1549
1555
|
let current = value;
|
|
1550
1556
|
while (isFunction(current)) {
|
|
@@ -1553,6 +1559,9 @@ function resolveNodeValue(value) {
|
|
|
1553
1559
|
if (isSignal(current) || isComputed(current)) {
|
|
1554
1560
|
return resolveNodeValue(current.value);
|
|
1555
1561
|
}
|
|
1562
|
+
if (Array.isArray(current)) {
|
|
1563
|
+
return current.map((item) => resolveNodeValue(item));
|
|
1564
|
+
}
|
|
1556
1565
|
return current;
|
|
1557
1566
|
}
|
|
1558
1567
|
var SuspenseContext = /* @__PURE__ */ Symbol("SuspenseContext");
|
|
@@ -1561,129 +1570,127 @@ function Suspense(props) {
|
|
|
1561
1570
|
if (!isBrowser()) {
|
|
1562
1571
|
return (_a2 = props.fallback) != null ? _a2 : "";
|
|
1563
1572
|
}
|
|
1564
|
-
const
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
let
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
return nodes;
|
|
1583
|
-
}
|
|
1584
|
-
return normalizeNode(current);
|
|
1573
|
+
const owner = getActiveScope();
|
|
1574
|
+
const start = document.createComment("suspense");
|
|
1575
|
+
const end = document.createComment("/suspense");
|
|
1576
|
+
const frag = document.createDocumentFragment();
|
|
1577
|
+
frag.append(start, end);
|
|
1578
|
+
let mounted = true;
|
|
1579
|
+
let pending = 0;
|
|
1580
|
+
let mounting = false;
|
|
1581
|
+
let contentScope = null;
|
|
1582
|
+
let parked = null;
|
|
1583
|
+
let fallbackScope = null;
|
|
1584
|
+
let resolved = null;
|
|
1585
|
+
const parkContent = () => {
|
|
1586
|
+
const off = document.createDocumentFragment();
|
|
1587
|
+
while (end.previousSibling && end.previousSibling !== start) {
|
|
1588
|
+
off.prepend(end.previousSibling);
|
|
1589
|
+
}
|
|
1590
|
+
parked = off;
|
|
1585
1591
|
};
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1592
|
+
const restoreContent = () => {
|
|
1593
|
+
var _a3;
|
|
1594
|
+
if (!parked) return;
|
|
1595
|
+
const parent = (_a3 = end.parentNode) != null ? _a3 : frag;
|
|
1596
|
+
while (parked.firstChild) {
|
|
1597
|
+
parent.insertBefore(parked.firstChild, end);
|
|
1598
|
+
}
|
|
1599
|
+
parked = null;
|
|
1594
1600
|
};
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1601
|
+
const mountFallback = () => {
|
|
1602
|
+
if (props.fallback == null || fallbackScope) return;
|
|
1603
|
+
fallbackScope = createScope(owner);
|
|
1604
|
+
runWithScope(fallbackScope, () => {
|
|
1605
|
+
var _a3;
|
|
1606
|
+
insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(props.fallback), end);
|
|
1607
|
+
});
|
|
1600
1608
|
};
|
|
1601
|
-
const
|
|
1602
|
-
if (
|
|
1603
|
-
|
|
1604
|
-
|
|
1609
|
+
const disposeFallback = () => {
|
|
1610
|
+
if (!fallbackScope) return;
|
|
1611
|
+
disposeScope(fallbackScope);
|
|
1612
|
+
fallbackScope = null;
|
|
1605
1613
|
};
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
if (
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
renderChildren(props.children);
|
|
1614
|
+
const mountContent = (children2) => {
|
|
1615
|
+
mounting = true;
|
|
1616
|
+
contentScope = createScope(owner);
|
|
1617
|
+
runWithScope(contentScope, () => {
|
|
1618
|
+
var _a3;
|
|
1619
|
+
insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(children2), end);
|
|
1620
|
+
});
|
|
1621
|
+
mounting = false;
|
|
1622
|
+
if (pending && !parked) {
|
|
1623
|
+
parkContent();
|
|
1624
|
+
mountFallback();
|
|
1618
1625
|
}
|
|
1619
1626
|
};
|
|
1620
|
-
const
|
|
1621
|
-
if (
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1627
|
+
const showFallback = () => {
|
|
1628
|
+
if (parked) return;
|
|
1629
|
+
if (mounting) return;
|
|
1630
|
+
parkContent();
|
|
1631
|
+
mountFallback();
|
|
1632
|
+
};
|
|
1633
|
+
const showContent = () => {
|
|
1634
|
+
if (!parked) return;
|
|
1635
|
+
const hasSyncChildren = props.children != null && !isPromise(props.children);
|
|
1636
|
+
if (contentScope == null && resolved == null && !hasSyncChildren) return;
|
|
1637
|
+
disposeFallback();
|
|
1638
|
+
restoreContent();
|
|
1639
|
+
if (!contentScope) {
|
|
1640
|
+
if (resolved) {
|
|
1641
|
+
mountContent(resolved);
|
|
1642
|
+
} else if (hasSyncChildren) {
|
|
1643
|
+
mountContent(props.children);
|
|
1628
1644
|
}
|
|
1629
1645
|
}
|
|
1630
|
-
if (isShowingFallback) {
|
|
1631
|
-
renderFallbackContent();
|
|
1632
|
-
}
|
|
1633
1646
|
};
|
|
1634
|
-
const
|
|
1647
|
+
const settle = () => {
|
|
1648
|
+
if (!mounted) return;
|
|
1649
|
+
if (--pending === 0) showContent();
|
|
1650
|
+
};
|
|
1651
|
+
const ctx = {
|
|
1635
1652
|
register: (promise) => {
|
|
1636
|
-
|
|
1653
|
+
pending++;
|
|
1637
1654
|
showFallback();
|
|
1638
|
-
promise.then(() => {
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
if (pendingCount === 0) {
|
|
1642
|
-
showChildren();
|
|
1643
|
-
}
|
|
1644
|
-
}).catch((error4) => {
|
|
1645
|
-
{
|
|
1646
|
-
warn("[Suspense] Resource failed:", error4);
|
|
1647
|
-
}
|
|
1648
|
-
if (!isMounted) return;
|
|
1649
|
-
pendingCount--;
|
|
1650
|
-
if (pendingCount === 0) {
|
|
1651
|
-
showChildren();
|
|
1652
|
-
}
|
|
1655
|
+
promise.then(settle).catch((error4) => {
|
|
1656
|
+
warn("[Suspense] Resource failed:", error4);
|
|
1657
|
+
settle();
|
|
1653
1658
|
});
|
|
1654
1659
|
},
|
|
1655
1660
|
increment: () => {
|
|
1656
|
-
|
|
1661
|
+
pending++;
|
|
1657
1662
|
showFallback();
|
|
1658
1663
|
},
|
|
1659
1664
|
decrement: () => {
|
|
1660
|
-
|
|
1661
|
-
if (
|
|
1662
|
-
showChildren();
|
|
1663
|
-
}
|
|
1665
|
+
pending = Math.max(0, pending - 1);
|
|
1666
|
+
if (pending === 0) showContent();
|
|
1664
1667
|
}
|
|
1665
1668
|
};
|
|
1666
|
-
provide(SuspenseContext,
|
|
1669
|
+
provide(SuspenseContext, ctx);
|
|
1667
1670
|
const children = props.children;
|
|
1668
1671
|
if (isPromise(children)) {
|
|
1669
|
-
children.then((
|
|
1670
|
-
|
|
1672
|
+
children.then((value) => {
|
|
1673
|
+
resolved = value;
|
|
1671
1674
|
}).catch(() => {
|
|
1672
1675
|
});
|
|
1673
|
-
|
|
1676
|
+
ctx.register(children);
|
|
1674
1677
|
} else if (children != null) {
|
|
1675
|
-
|
|
1676
|
-
} else {
|
|
1678
|
+
mountContent(children);
|
|
1679
|
+
} else if (props.fallback != null) {
|
|
1677
1680
|
showFallback();
|
|
1678
1681
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1682
|
+
onCleanup(() => {
|
|
1683
|
+
mounted = false;
|
|
1684
|
+
pending = 0;
|
|
1685
|
+
resolved = null;
|
|
1686
|
+
if (contentScope) disposeScope(contentScope);
|
|
1687
|
+
if (fallbackScope) disposeScope(fallbackScope);
|
|
1688
|
+
contentScope = fallbackScope = null;
|
|
1689
|
+
parked = null;
|
|
1690
|
+
start.remove();
|
|
1691
|
+
end.remove();
|
|
1685
1692
|
});
|
|
1686
|
-
return
|
|
1693
|
+
return frag;
|
|
1687
1694
|
}
|
|
1688
1695
|
Suspense[SUSPENSE_COMPONENT] = true;
|
|
1689
1696
|
function isSuspense(node) {
|
|
@@ -1757,185 +1764,130 @@ function createResource(fetcher, options) {
|
|
|
1757
1764
|
function resolveModule(mod) {
|
|
1758
1765
|
return isFunction(mod) ? mod : mod.default;
|
|
1759
1766
|
}
|
|
1760
|
-
function
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1767
|
+
function defineServerAsyncComponent(loader, ssr) {
|
|
1768
|
+
if (ssr === "client-only") {
|
|
1769
|
+
const placeholder = () => "";
|
|
1770
|
+
placeholder.__asyncLoader = loader;
|
|
1771
|
+
placeholder.__asyncResolved = () => null;
|
|
1772
|
+
return placeholder;
|
|
1773
|
+
}
|
|
1774
|
+
let resolved = null;
|
|
1775
|
+
let promise = null;
|
|
1776
|
+
const load = () => promise != null ? promise : promise = loader().then((mod) => {
|
|
1777
|
+
resolved = resolveModule(mod);
|
|
1778
|
+
}).catch(() => {
|
|
1779
|
+
});
|
|
1780
|
+
load();
|
|
1781
|
+
const wrapper = (props) => resolved ? resolved(props) : "";
|
|
1782
|
+
wrapper.__asyncLoader = load;
|
|
1783
|
+
wrapper.__asyncResolved = () => resolved;
|
|
1784
|
+
return wrapper;
|
|
1764
1785
|
}
|
|
1765
|
-
function
|
|
1766
|
-
const { delay = 200, timeout,
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
placeholder.__asyncLoader = loader;
|
|
1771
|
-
placeholder.__asyncResolved = () => null;
|
|
1772
|
-
return placeholder;
|
|
1773
|
-
}
|
|
1774
|
-
let ssrResolved = null;
|
|
1775
|
-
let ssrPromise = null;
|
|
1776
|
-
const ssrLoad = () => {
|
|
1777
|
-
if (ssrPromise) return ssrPromise;
|
|
1778
|
-
ssrPromise = loader().then((mod) => {
|
|
1779
|
-
ssrResolved = resolveModule(mod);
|
|
1780
|
-
}).catch(() => {
|
|
1781
|
-
});
|
|
1782
|
-
return ssrPromise;
|
|
1783
|
-
};
|
|
1784
|
-
ssrLoad();
|
|
1785
|
-
const ssrWrapper = (props) => {
|
|
1786
|
-
if (ssrResolved) {
|
|
1787
|
-
return ssrResolved(props);
|
|
1788
|
-
}
|
|
1789
|
-
return "";
|
|
1790
|
-
};
|
|
1791
|
-
ssrWrapper.__asyncLoader = ssrLoad;
|
|
1792
|
-
ssrWrapper.__asyncResolved = () => ssrResolved;
|
|
1793
|
-
return ssrWrapper;
|
|
1794
|
-
}
|
|
1795
|
-
let cachedComponent = null;
|
|
1796
|
-
let cachedError = null;
|
|
1797
|
-
let cachedStatus = "pending";
|
|
1786
|
+
function defineClientAsyncComponent(loader, options) {
|
|
1787
|
+
const { loading, error: errorComp, delay = 200, timeout, onError } = options;
|
|
1788
|
+
let component = null;
|
|
1789
|
+
let error4 = null;
|
|
1790
|
+
let status = "pending";
|
|
1798
1791
|
let loadPromise = null;
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
loadPromise = null;
|
|
1808
|
-
});
|
|
1809
|
-
return loadPromise;
|
|
1810
|
-
}
|
|
1792
|
+
const load = () => loadPromise != null ? loadPromise : loadPromise = loader().then((mod) => {
|
|
1793
|
+
component = resolveModule(mod);
|
|
1794
|
+
status = "resolved";
|
|
1795
|
+
}).catch((error_) => {
|
|
1796
|
+
error4 = error_ instanceof Error ? error_ : new Error(String(error_));
|
|
1797
|
+
status = "errored";
|
|
1798
|
+
loadPromise = null;
|
|
1799
|
+
});
|
|
1811
1800
|
load();
|
|
1812
1801
|
function AsyncWrapper(props) {
|
|
1813
1802
|
var _a2;
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
onCleanup(() => comp.destroy());
|
|
1819
|
-
return el;
|
|
1820
|
-
}
|
|
1821
|
-
if (cachedStatus === "errored" && cachedError) {
|
|
1822
|
-
const el = document.createElement("div");
|
|
1823
|
-
el.style.display = "contents";
|
|
1824
|
-
if (options.error) {
|
|
1825
|
-
let alive2 = true;
|
|
1826
|
-
let currentComp2 = null;
|
|
1827
|
-
const swap2 = (fn, swapProps) => {
|
|
1828
|
-
if (!alive2) return;
|
|
1829
|
-
currentComp2 == null ? void 0 : currentComp2.destroy();
|
|
1830
|
-
currentComp2 = renderInto(el, fn, swapProps);
|
|
1831
|
-
};
|
|
1832
|
-
const retry = () => {
|
|
1833
|
-
loadPromise = null;
|
|
1834
|
-
cachedStatus = "pending";
|
|
1835
|
-
cachedError = null;
|
|
1836
|
-
if (options.loading) swap2(options.loading);
|
|
1837
|
-
load().then(() => {
|
|
1838
|
-
if (!alive2) return;
|
|
1839
|
-
if (cachedStatus === "resolved" && cachedComponent) {
|
|
1840
|
-
swap2(cachedComponent, props);
|
|
1841
|
-
} else if (cachedStatus === "errored" && cachedError) {
|
|
1842
|
-
if (options.error) swap2(options.error, { error: cachedError, retry });
|
|
1843
|
-
}
|
|
1844
|
-
});
|
|
1845
|
-
};
|
|
1846
|
-
swap2(options.error, { error: cachedError, retry });
|
|
1847
|
-
onDestroy(() => {
|
|
1848
|
-
alive2 = false;
|
|
1849
|
-
currentComp2 == null ? void 0 : currentComp2.destroy();
|
|
1850
|
-
currentComp2 = null;
|
|
1851
|
-
});
|
|
1852
|
-
}
|
|
1853
|
-
return el;
|
|
1854
|
-
}
|
|
1855
|
-
const container = document.createElement("div");
|
|
1856
|
-
container.style.display = "contents";
|
|
1803
|
+
const owner = getActiveScope();
|
|
1804
|
+
const end = document.createComment("async");
|
|
1805
|
+
const frag = document.createDocumentFragment();
|
|
1806
|
+
frag.appendChild(end);
|
|
1857
1807
|
let alive = true;
|
|
1858
|
-
let
|
|
1808
|
+
let viewScope = null;
|
|
1859
1809
|
let delayTimer = null;
|
|
1860
1810
|
let timeoutTimer = null;
|
|
1861
|
-
const
|
|
1862
|
-
if (
|
|
1863
|
-
|
|
1864
|
-
|
|
1811
|
+
const clearTimers = () => {
|
|
1812
|
+
if (delayTimer != null) clearTimeout(delayTimer);
|
|
1813
|
+
if (timeoutTimer != null) clearTimeout(timeoutTimer);
|
|
1814
|
+
delayTimer = timeoutTimer = null;
|
|
1865
1815
|
};
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
error: cachedError,
|
|
1878
|
-
retry: retryWith(retryProps)
|
|
1879
|
-
});
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1816
|
+
const render = (fn, fnProps) => {
|
|
1817
|
+
if (!alive) return;
|
|
1818
|
+
if (viewScope) {
|
|
1819
|
+
disposeScope(viewScope);
|
|
1820
|
+
viewScope = null;
|
|
1821
|
+
}
|
|
1822
|
+
if (!fn) return;
|
|
1823
|
+
viewScope = createScope(owner);
|
|
1824
|
+
runWithScope(viewScope, () => {
|
|
1825
|
+
var _a3;
|
|
1826
|
+
insert((_a3 = end.parentNode) != null ? _a3 : frag, () => new Component(fn, fnProps), end);
|
|
1882
1827
|
});
|
|
1883
1828
|
};
|
|
1884
1829
|
onDestroy(() => {
|
|
1885
1830
|
alive = false;
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1831
|
+
clearTimers();
|
|
1832
|
+
if (viewScope) {
|
|
1833
|
+
disposeScope(viewScope);
|
|
1834
|
+
viewScope = null;
|
|
1835
|
+
}
|
|
1836
|
+
end.remove();
|
|
1890
1837
|
});
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
if (options.loading) swap(options.loading);
|
|
1838
|
+
const retryWith = (retryProps) => () => {
|
|
1839
|
+
loadPromise = null;
|
|
1840
|
+
status = "pending";
|
|
1841
|
+
error4 = null;
|
|
1842
|
+
if (loading) render(loading);
|
|
1843
|
+
load().then(() => settle(retryProps));
|
|
1898
1844
|
};
|
|
1899
|
-
const
|
|
1845
|
+
const settle = (renderProps) => {
|
|
1900
1846
|
if (!alive) return;
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
if (
|
|
1847
|
+
clearTimers();
|
|
1848
|
+
if (status === "resolved" && component) {
|
|
1849
|
+
render(component, renderProps);
|
|
1850
|
+
} else if (status === "errored" && error4) {
|
|
1851
|
+
if (errorComp) render(errorComp, { error: error4, retry: retryWith(renderProps) });
|
|
1852
|
+
if (onError) onError(error4, retryWith(renderProps));
|
|
1906
1853
|
}
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1854
|
+
};
|
|
1855
|
+
if (status === "resolved" && component) {
|
|
1856
|
+
render(component, props);
|
|
1857
|
+
return frag;
|
|
1858
|
+
}
|
|
1859
|
+
if (status === "errored" && error4) {
|
|
1860
|
+
if (errorComp) render(errorComp, { error: error4, retry: retryWith(props) });
|
|
1861
|
+
return frag;
|
|
1912
1862
|
}
|
|
1863
|
+
const pending = load().then(() => settle(props));
|
|
1864
|
+
(_a2 = inject(SuspenseContext)) == null ? void 0 : _a2.register(pending);
|
|
1913
1865
|
if (delay > 0) {
|
|
1914
1866
|
delayTimer = setTimeout(() => {
|
|
1915
|
-
if (alive &&
|
|
1916
|
-
showLoading();
|
|
1917
|
-
}
|
|
1867
|
+
if (alive && status === "pending" && loading) render(loading);
|
|
1918
1868
|
}, delay);
|
|
1919
|
-
} else if (
|
|
1920
|
-
|
|
1869
|
+
} else if (loading) {
|
|
1870
|
+
render(loading);
|
|
1921
1871
|
}
|
|
1922
1872
|
if (timeout != null) {
|
|
1923
1873
|
timeoutTimer = setTimeout(() => {
|
|
1924
|
-
if (alive
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
if (onError) onError(err, retryWith(props));
|
|
1930
|
-
}
|
|
1874
|
+
if (!alive || status !== "pending") return;
|
|
1875
|
+
error4 = new Error(`[defineAsyncComponent] Timeout after ${timeout}ms`);
|
|
1876
|
+
status = "errored";
|
|
1877
|
+
if (errorComp) render(errorComp, { error: error4, retry: retryWith(props) });
|
|
1878
|
+
if (onError) onError(error4, retryWith(props));
|
|
1931
1879
|
}, timeout);
|
|
1932
1880
|
}
|
|
1933
|
-
return
|
|
1881
|
+
return frag;
|
|
1934
1882
|
}
|
|
1935
1883
|
AsyncWrapper.__asyncLoader = load;
|
|
1936
|
-
AsyncWrapper.__asyncResolved = () =>
|
|
1884
|
+
AsyncWrapper.__asyncResolved = () => component;
|
|
1937
1885
|
return AsyncWrapper;
|
|
1938
1886
|
}
|
|
1887
|
+
function defineAsyncComponent(loader, options = {}) {
|
|
1888
|
+
var _a2;
|
|
1889
|
+
return typeof window === "undefined" ? defineServerAsyncComponent(loader, (_a2 = options.ssr) != null ? _a2 : "blocking") : defineClientAsyncComponent(loader, options);
|
|
1890
|
+
}
|
|
1939
1891
|
function For(props) {
|
|
1940
1892
|
const fragment = document.createDocumentFragment();
|
|
1941
1893
|
const marker = document.createComment("");
|
|
@@ -1984,8 +1936,10 @@ function For(props) {
|
|
|
1984
1936
|
}
|
|
1985
1937
|
fallbackNodes = [];
|
|
1986
1938
|
};
|
|
1939
|
+
const ownerScope = getActiveScope();
|
|
1987
1940
|
const renderItem = (item, index, parent, before, key = getKey(item, index)) => {
|
|
1988
|
-
|
|
1941
|
+
var _a2;
|
|
1942
|
+
const parentScope = (_a2 = getActiveScope()) != null ? _a2 : ownerScope;
|
|
1989
1943
|
const scope = createScope(parentScope);
|
|
1990
1944
|
let mountedNodes = [];
|
|
1991
1945
|
runWithScope(scope, () => {
|