@estjs/template 0.0.17-beta.1 → 0.0.17-beta.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-3SR36LGP.js → chunk-CBFQJ3PB.js} +1 -1
- package/dist/{chunk-R6JICOKI.dev.js → chunk-PYFF2HI3.dev.js} +6 -6
- package/dist/chunk-PYFF2HI3.dev.js.map +1 -0
- package/dist/internal.cjs +1 -1
- package/dist/internal.dev.cjs +4 -4
- package/dist/internal.dev.cjs.map +1 -1
- package/dist/internal.dev.js +1 -1
- package/dist/internal.js +1 -1
- 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 +220 -266
- package/dist/template.dev.cjs.map +1 -1
- package/dist/template.dev.js +217 -263
- package/dist/template.dev.js.map +1 -1
- package/dist/template.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-R6JICOKI.dev.js.map +0 -1
package/dist/template.dev.cjs
CHANGED
|
@@ -102,6 +102,10 @@ function disposeScope(scope) {
|
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
scope.isDestroyed = true;
|
|
105
|
+
if ((_a2 = scope.parent) == null ? void 0 : _a2.children) {
|
|
106
|
+
scope.parent.children.delete(scope);
|
|
107
|
+
}
|
|
108
|
+
scope.parent = null;
|
|
105
109
|
if (scope.children && scope.children.size > 0) {
|
|
106
110
|
for (const child2 of scope.children) {
|
|
107
111
|
if (child2) {
|
|
@@ -135,9 +139,6 @@ function disposeScope(scope) {
|
|
|
135
139
|
}
|
|
136
140
|
setActiveScope(prevScope);
|
|
137
141
|
scope.effectScope.stop();
|
|
138
|
-
if ((_a2 = scope.parent) == null ? void 0 : _a2.children) {
|
|
139
|
-
scope.parent.children.delete(scope);
|
|
140
|
-
}
|
|
141
142
|
if (scope.provides) {
|
|
142
143
|
scope.provides.clear();
|
|
143
144
|
scope.provides = null;
|
|
@@ -145,7 +146,6 @@ function disposeScope(scope) {
|
|
|
145
146
|
scope.onMount = null;
|
|
146
147
|
scope.onUpdate = null;
|
|
147
148
|
scope.children = null;
|
|
148
|
-
scope.parent = null;
|
|
149
149
|
}
|
|
150
150
|
function onCleanup(fn) {
|
|
151
151
|
const scope = activeScope;
|
|
@@ -160,6 +160,14 @@ function onCleanup(fn) {
|
|
|
160
160
|
}
|
|
161
161
|
scope.cleanup.push(fn);
|
|
162
162
|
}
|
|
163
|
+
var DANGEROUS_DATA_MIME_RE = /^data:\s*(?:text\/html|text\/xml|application\/xhtml\+xml|image\/svg\+xml|application\/xml)/;
|
|
164
|
+
function isUnsafeUrl(value) {
|
|
165
|
+
const v = value.replaceAll(/[\u0000-\u0020]+/g, "").toLowerCase();
|
|
166
|
+
if (shared.startsWith(v, "javascript:") || shared.startsWith(v, "vbscript:")) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return DANGEROUS_DATA_MIME_RE.test(v);
|
|
170
|
+
}
|
|
163
171
|
function patchAttr(el, key, prev, next2) {
|
|
164
172
|
if (key === KEY_PROP) {
|
|
165
173
|
if (next2 == null) {
|
|
@@ -241,11 +249,8 @@ function patchAttr(el, key, prev, next2) {
|
|
|
241
249
|
}
|
|
242
250
|
const attrValue = shared.isSymbol(next2) ? String(next2) : next2;
|
|
243
251
|
const isUrlAttr = lowerKey === "href" || lowerKey === "src" || lowerKey === "xlink:href" || lowerKey === "action" || lowerKey === "formaction" || lowerKey === "poster";
|
|
244
|
-
if (isUrlAttr && shared.isString(attrValue)) {
|
|
245
|
-
|
|
246
|
-
if (shared.startsWith(v, "javascript:") || shared.startsWith(v, "data:")) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
252
|
+
if (isUrlAttr && shared.isString(attrValue) && isUnsafeUrl(attrValue)) {
|
|
253
|
+
return;
|
|
249
254
|
}
|
|
250
255
|
if (isXlink) {
|
|
251
256
|
el.setAttributeNS(XLINK_NAMESPACE, key, String(attrValue));
|
|
@@ -1072,6 +1077,7 @@ var Component = class {
|
|
|
1072
1077
|
for (const key of Object.getOwnPropertyNames(this.reactiveProps)) {
|
|
1073
1078
|
delete this.reactiveProps[key];
|
|
1074
1079
|
}
|
|
1080
|
+
this.state = 0 /* INITIAL */;
|
|
1075
1081
|
}
|
|
1076
1082
|
/**
|
|
1077
1083
|
* Apply props that bind to the root DOM element rather than flowing into
|
|
@@ -1182,7 +1188,13 @@ function createApp(component, target) {
|
|
|
1182
1188
|
const existingContent = container.innerHTML;
|
|
1183
1189
|
if (existingContent) {
|
|
1184
1190
|
{
|
|
1185
|
-
|
|
1191
|
+
if (container.querySelector("[data-hk]")) {
|
|
1192
|
+
shared.warn(
|
|
1193
|
+
`Target element contains server-rendered markup ([data-hk]); createApp() will discard it and render from scratch. Did you mean to call hydrate()?`
|
|
1194
|
+
);
|
|
1195
|
+
} else {
|
|
1196
|
+
shared.warn(`Target element is not empty, it will be cleared: ${target}`);
|
|
1197
|
+
}
|
|
1186
1198
|
}
|
|
1187
1199
|
container.innerHTML = "";
|
|
1188
1200
|
}
|
|
@@ -1203,8 +1215,8 @@ function createApp(component, target) {
|
|
|
1203
1215
|
return {
|
|
1204
1216
|
root: rootNode,
|
|
1205
1217
|
unmount: () => {
|
|
1206
|
-
disposeScope(scope);
|
|
1207
1218
|
rootNode == null ? void 0 : rootNode.destroy();
|
|
1219
|
+
disposeScope(scope);
|
|
1208
1220
|
}
|
|
1209
1221
|
};
|
|
1210
1222
|
}
|
|
@@ -1236,8 +1248,8 @@ function hydrate(component, target) {
|
|
|
1236
1248
|
return {
|
|
1237
1249
|
root: rootNode,
|
|
1238
1250
|
unmount: () => {
|
|
1239
|
-
disposeScope(scope);
|
|
1240
1251
|
rootNode == null ? void 0 : rootNode.destroy();
|
|
1252
|
+
disposeScope(scope);
|
|
1241
1253
|
}
|
|
1242
1254
|
};
|
|
1243
1255
|
}
|
|
@@ -1687,11 +1699,6 @@ function tryHydratePortal(props) {
|
|
|
1687
1699
|
function isPortal(node) {
|
|
1688
1700
|
return !!node && !!node[PORTAL_COMPONENT];
|
|
1689
1701
|
}
|
|
1690
|
-
function clearContainer(el) {
|
|
1691
|
-
while (el.firstChild) {
|
|
1692
|
-
el.removeChild(el.firstChild);
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
1702
|
function resolveNodeValue(value) {
|
|
1696
1703
|
let current = value;
|
|
1697
1704
|
while (shared.isFunction(current)) {
|
|
@@ -1700,6 +1707,9 @@ function resolveNodeValue(value) {
|
|
|
1700
1707
|
if (signals.isSignal(current) || signals.isComputed(current)) {
|
|
1701
1708
|
return resolveNodeValue(current.value);
|
|
1702
1709
|
}
|
|
1710
|
+
if (Array.isArray(current)) {
|
|
1711
|
+
return current.map((item) => resolveNodeValue(item));
|
|
1712
|
+
}
|
|
1703
1713
|
return current;
|
|
1704
1714
|
}
|
|
1705
1715
|
var SuspenseContext = /* @__PURE__ */ Symbol("SuspenseContext");
|
|
@@ -1708,129 +1718,127 @@ function Suspense(props) {
|
|
|
1708
1718
|
if (!shared.isBrowser()) {
|
|
1709
1719
|
return (_a2 = props.fallback) != null ? _a2 : "";
|
|
1710
1720
|
}
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
let
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
return nodes;
|
|
1730
|
-
}
|
|
1731
|
-
return normalizeNode(current);
|
|
1721
|
+
const owner = getActiveScope();
|
|
1722
|
+
const start = document.createComment("suspense");
|
|
1723
|
+
const end = document.createComment("/suspense");
|
|
1724
|
+
const frag = document.createDocumentFragment();
|
|
1725
|
+
frag.append(start, end);
|
|
1726
|
+
let mounted = true;
|
|
1727
|
+
let pending = 0;
|
|
1728
|
+
let mounting = false;
|
|
1729
|
+
let contentScope = null;
|
|
1730
|
+
let parked = null;
|
|
1731
|
+
let fallbackScope = null;
|
|
1732
|
+
let resolved = null;
|
|
1733
|
+
const parkContent = () => {
|
|
1734
|
+
const off = document.createDocumentFragment();
|
|
1735
|
+
while (end.previousSibling && end.previousSibling !== start) {
|
|
1736
|
+
off.prepend(end.previousSibling);
|
|
1737
|
+
}
|
|
1738
|
+
parked = off;
|
|
1732
1739
|
};
|
|
1733
|
-
const
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1740
|
+
const restoreContent = () => {
|
|
1741
|
+
var _a3;
|
|
1742
|
+
if (!parked) return;
|
|
1743
|
+
const parent = (_a3 = end.parentNode) != null ? _a3 : frag;
|
|
1744
|
+
while (parked.firstChild) {
|
|
1745
|
+
parent.insertBefore(parked.firstChild, end);
|
|
1746
|
+
}
|
|
1747
|
+
parked = null;
|
|
1741
1748
|
};
|
|
1742
|
-
const
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1749
|
+
const mountFallback = () => {
|
|
1750
|
+
if (props.fallback == null || fallbackScope) return;
|
|
1751
|
+
fallbackScope = createScope(owner);
|
|
1752
|
+
runWithScope(fallbackScope, () => {
|
|
1753
|
+
var _a3;
|
|
1754
|
+
insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(props.fallback), end);
|
|
1755
|
+
});
|
|
1747
1756
|
};
|
|
1748
|
-
const
|
|
1749
|
-
if (
|
|
1750
|
-
|
|
1751
|
-
|
|
1757
|
+
const disposeFallback = () => {
|
|
1758
|
+
if (!fallbackScope) return;
|
|
1759
|
+
disposeScope(fallbackScope);
|
|
1760
|
+
fallbackScope = null;
|
|
1752
1761
|
};
|
|
1753
|
-
const
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
if (
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
renderChildren(props.children);
|
|
1762
|
+
const mountContent = (children2) => {
|
|
1763
|
+
mounting = true;
|
|
1764
|
+
contentScope = createScope(owner);
|
|
1765
|
+
runWithScope(contentScope, () => {
|
|
1766
|
+
var _a3;
|
|
1767
|
+
insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(children2), end);
|
|
1768
|
+
});
|
|
1769
|
+
mounting = false;
|
|
1770
|
+
if (pending && !parked) {
|
|
1771
|
+
parkContent();
|
|
1772
|
+
mountFallback();
|
|
1765
1773
|
}
|
|
1766
1774
|
};
|
|
1767
|
-
const
|
|
1768
|
-
if (
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
+
const showFallback = () => {
|
|
1776
|
+
if (parked) return;
|
|
1777
|
+
if (mounting) return;
|
|
1778
|
+
parkContent();
|
|
1779
|
+
mountFallback();
|
|
1780
|
+
};
|
|
1781
|
+
const showContent = () => {
|
|
1782
|
+
if (!parked) return;
|
|
1783
|
+
const hasSyncChildren = props.children != null && !shared.isPromise(props.children);
|
|
1784
|
+
if (contentScope == null && resolved == null && !hasSyncChildren) return;
|
|
1785
|
+
disposeFallback();
|
|
1786
|
+
restoreContent();
|
|
1787
|
+
if (!contentScope) {
|
|
1788
|
+
if (resolved) {
|
|
1789
|
+
mountContent(resolved);
|
|
1790
|
+
} else if (hasSyncChildren) {
|
|
1791
|
+
mountContent(props.children);
|
|
1775
1792
|
}
|
|
1776
1793
|
}
|
|
1777
|
-
if (isShowingFallback) {
|
|
1778
|
-
renderFallbackContent();
|
|
1779
|
-
}
|
|
1780
1794
|
};
|
|
1781
|
-
const
|
|
1795
|
+
const settle = () => {
|
|
1796
|
+
if (!mounted) return;
|
|
1797
|
+
if (--pending === 0) showContent();
|
|
1798
|
+
};
|
|
1799
|
+
const ctx = {
|
|
1782
1800
|
register: (promise) => {
|
|
1783
|
-
|
|
1801
|
+
pending++;
|
|
1784
1802
|
showFallback();
|
|
1785
|
-
promise.then(() => {
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
if (pendingCount === 0) {
|
|
1789
|
-
showChildren();
|
|
1790
|
-
}
|
|
1791
|
-
}).catch((error5) => {
|
|
1792
|
-
{
|
|
1793
|
-
shared.warn("[Suspense] Resource failed:", error5);
|
|
1794
|
-
}
|
|
1795
|
-
if (!isMounted) return;
|
|
1796
|
-
pendingCount--;
|
|
1797
|
-
if (pendingCount === 0) {
|
|
1798
|
-
showChildren();
|
|
1799
|
-
}
|
|
1803
|
+
promise.then(settle).catch((error5) => {
|
|
1804
|
+
shared.warn("[Suspense] Resource failed:", error5);
|
|
1805
|
+
settle();
|
|
1800
1806
|
});
|
|
1801
1807
|
},
|
|
1802
1808
|
increment: () => {
|
|
1803
|
-
|
|
1809
|
+
pending++;
|
|
1804
1810
|
showFallback();
|
|
1805
1811
|
},
|
|
1806
1812
|
decrement: () => {
|
|
1807
|
-
|
|
1808
|
-
if (
|
|
1809
|
-
showChildren();
|
|
1810
|
-
}
|
|
1813
|
+
pending = Math.max(0, pending - 1);
|
|
1814
|
+
if (pending === 0) showContent();
|
|
1811
1815
|
}
|
|
1812
1816
|
};
|
|
1813
|
-
provide(SuspenseContext,
|
|
1817
|
+
provide(SuspenseContext, ctx);
|
|
1814
1818
|
const children = props.children;
|
|
1815
1819
|
if (shared.isPromise(children)) {
|
|
1816
|
-
children.then((
|
|
1817
|
-
|
|
1820
|
+
children.then((value) => {
|
|
1821
|
+
resolved = value;
|
|
1818
1822
|
}).catch(() => {
|
|
1819
1823
|
});
|
|
1820
|
-
|
|
1824
|
+
ctx.register(children);
|
|
1821
1825
|
} else if (children != null) {
|
|
1822
|
-
|
|
1823
|
-
} else {
|
|
1826
|
+
mountContent(children);
|
|
1827
|
+
} else if (props.fallback != null) {
|
|
1824
1828
|
showFallback();
|
|
1825
1829
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1830
|
+
onCleanup(() => {
|
|
1831
|
+
mounted = false;
|
|
1832
|
+
pending = 0;
|
|
1833
|
+
resolved = null;
|
|
1834
|
+
if (contentScope) disposeScope(contentScope);
|
|
1835
|
+
if (fallbackScope) disposeScope(fallbackScope);
|
|
1836
|
+
contentScope = fallbackScope = null;
|
|
1837
|
+
parked = null;
|
|
1838
|
+
start.remove();
|
|
1839
|
+
end.remove();
|
|
1832
1840
|
});
|
|
1833
|
-
return
|
|
1841
|
+
return frag;
|
|
1834
1842
|
}
|
|
1835
1843
|
Suspense[SUSPENSE_COMPONENT] = true;
|
|
1836
1844
|
function isSuspense(node) {
|
|
@@ -1904,185 +1912,131 @@ function createResource(fetcher, options) {
|
|
|
1904
1912
|
function resolveModule(mod) {
|
|
1905
1913
|
return shared.isFunction(mod) ? mod : mod.default;
|
|
1906
1914
|
}
|
|
1907
|
-
function
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1915
|
+
function defineServerAsyncComponent(loader, ssr) {
|
|
1916
|
+
if (ssr === "client-only") {
|
|
1917
|
+
const placeholder = () => "";
|
|
1918
|
+
placeholder.__asyncLoader = loader;
|
|
1919
|
+
placeholder.__asyncResolved = () => null;
|
|
1920
|
+
return placeholder;
|
|
1921
|
+
}
|
|
1922
|
+
let resolved = null;
|
|
1923
|
+
let promise = null;
|
|
1924
|
+
const load = () => promise != null ? promise : promise = loader().then((mod) => {
|
|
1925
|
+
resolved = resolveModule(mod);
|
|
1926
|
+
}).catch(() => {
|
|
1927
|
+
});
|
|
1928
|
+
load();
|
|
1929
|
+
const wrapper = (props) => resolved ? resolved(props) : "";
|
|
1930
|
+
wrapper.__asyncLoader = load;
|
|
1931
|
+
wrapper.__asyncResolved = () => resolved;
|
|
1932
|
+
return wrapper;
|
|
1911
1933
|
}
|
|
1912
|
-
function
|
|
1913
|
-
const { delay = 200, timeout,
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
placeholder.__asyncLoader = loader;
|
|
1918
|
-
placeholder.__asyncResolved = () => null;
|
|
1919
|
-
return placeholder;
|
|
1920
|
-
}
|
|
1921
|
-
let ssrResolved = null;
|
|
1922
|
-
let ssrPromise = null;
|
|
1923
|
-
const ssrLoad = () => {
|
|
1924
|
-
if (ssrPromise) return ssrPromise;
|
|
1925
|
-
ssrPromise = loader().then((mod) => {
|
|
1926
|
-
ssrResolved = resolveModule(mod);
|
|
1927
|
-
}).catch(() => {
|
|
1928
|
-
});
|
|
1929
|
-
return ssrPromise;
|
|
1930
|
-
};
|
|
1931
|
-
ssrLoad();
|
|
1932
|
-
const ssrWrapper = (props) => {
|
|
1933
|
-
if (ssrResolved) {
|
|
1934
|
-
return ssrResolved(props);
|
|
1935
|
-
}
|
|
1936
|
-
return "";
|
|
1937
|
-
};
|
|
1938
|
-
ssrWrapper.__asyncLoader = ssrLoad;
|
|
1939
|
-
ssrWrapper.__asyncResolved = () => ssrResolved;
|
|
1940
|
-
return ssrWrapper;
|
|
1941
|
-
}
|
|
1942
|
-
let cachedComponent = null;
|
|
1943
|
-
let cachedError = null;
|
|
1944
|
-
let cachedStatus = "pending";
|
|
1934
|
+
function defineClientAsyncComponent(loader, options) {
|
|
1935
|
+
const { loading, error: errorComp, delay = 200, timeout, onError } = options;
|
|
1936
|
+
let component = null;
|
|
1937
|
+
let error5 = null;
|
|
1938
|
+
let status = "pending";
|
|
1945
1939
|
let loadPromise = null;
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
loadPromise = null;
|
|
1955
|
-
});
|
|
1956
|
-
return loadPromise;
|
|
1957
|
-
}
|
|
1940
|
+
const load = () => loadPromise != null ? loadPromise : loadPromise = loader().then((mod) => {
|
|
1941
|
+
component = resolveModule(mod);
|
|
1942
|
+
status = "resolved";
|
|
1943
|
+
}).catch((error_) => {
|
|
1944
|
+
error5 = error_ instanceof Error ? error_ : new Error(String(error_));
|
|
1945
|
+
status = "errored";
|
|
1946
|
+
loadPromise = null;
|
|
1947
|
+
});
|
|
1958
1948
|
load();
|
|
1959
1949
|
function AsyncWrapper(props) {
|
|
1960
1950
|
var _a2;
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
onCleanup(() => comp.destroy());
|
|
1966
|
-
return el;
|
|
1967
|
-
}
|
|
1968
|
-
if (cachedStatus === "errored" && cachedError) {
|
|
1969
|
-
const el = document.createElement("div");
|
|
1970
|
-
el.style.display = "contents";
|
|
1971
|
-
if (options.error) {
|
|
1972
|
-
let alive2 = true;
|
|
1973
|
-
let currentComp2 = null;
|
|
1974
|
-
const swap2 = (fn, swapProps) => {
|
|
1975
|
-
if (!alive2) return;
|
|
1976
|
-
currentComp2 == null ? void 0 : currentComp2.destroy();
|
|
1977
|
-
currentComp2 = renderInto(el, fn, swapProps);
|
|
1978
|
-
};
|
|
1979
|
-
const retry = () => {
|
|
1980
|
-
loadPromise = null;
|
|
1981
|
-
cachedStatus = "pending";
|
|
1982
|
-
cachedError = null;
|
|
1983
|
-
if (options.loading) swap2(options.loading);
|
|
1984
|
-
load().then(() => {
|
|
1985
|
-
if (!alive2) return;
|
|
1986
|
-
if (cachedStatus === "resolved" && cachedComponent) {
|
|
1987
|
-
swap2(cachedComponent, props);
|
|
1988
|
-
} else if (cachedStatus === "errored" && cachedError) {
|
|
1989
|
-
if (options.error) swap2(options.error, { error: cachedError, retry });
|
|
1990
|
-
}
|
|
1991
|
-
});
|
|
1992
|
-
};
|
|
1993
|
-
swap2(options.error, { error: cachedError, retry });
|
|
1994
|
-
onDestroy(() => {
|
|
1995
|
-
alive2 = false;
|
|
1996
|
-
currentComp2 == null ? void 0 : currentComp2.destroy();
|
|
1997
|
-
currentComp2 = null;
|
|
1998
|
-
});
|
|
1999
|
-
}
|
|
2000
|
-
return el;
|
|
2001
|
-
}
|
|
2002
|
-
const container = document.createElement("div");
|
|
2003
|
-
container.style.display = "contents";
|
|
1951
|
+
const owner = getActiveScope();
|
|
1952
|
+
const end = document.createComment("async");
|
|
1953
|
+
const frag = document.createDocumentFragment();
|
|
1954
|
+
frag.appendChild(end);
|
|
2004
1955
|
let alive = true;
|
|
2005
|
-
let
|
|
1956
|
+
let viewScope = null;
|
|
2006
1957
|
let delayTimer = null;
|
|
2007
1958
|
let timeoutTimer = null;
|
|
2008
|
-
const
|
|
2009
|
-
if (
|
|
2010
|
-
|
|
2011
|
-
|
|
1959
|
+
const clearTimers = () => {
|
|
1960
|
+
if (delayTimer != null) clearTimeout(delayTimer);
|
|
1961
|
+
if (timeoutTimer != null) clearTimeout(timeoutTimer);
|
|
1962
|
+
delayTimer = timeoutTimer = null;
|
|
2012
1963
|
};
|
|
2013
|
-
const
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
retry: retryWith(retryProps)
|
|
2026
|
-
});
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
1964
|
+
const render = (fn, fnProps) => {
|
|
1965
|
+
if (!alive) return;
|
|
1966
|
+
if (owner && owner.isDestroyed) return;
|
|
1967
|
+
if (viewScope) {
|
|
1968
|
+
disposeScope(viewScope);
|
|
1969
|
+
viewScope = null;
|
|
1970
|
+
}
|
|
1971
|
+
if (!fn) return;
|
|
1972
|
+
viewScope = createScope(owner);
|
|
1973
|
+
runWithScope(viewScope, () => {
|
|
1974
|
+
var _a3;
|
|
1975
|
+
insert((_a3 = end.parentNode) != null ? _a3 : frag, () => new Component(fn, fnProps), end);
|
|
2029
1976
|
});
|
|
2030
1977
|
};
|
|
2031
1978
|
onDestroy(() => {
|
|
2032
1979
|
alive = false;
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
1980
|
+
clearTimers();
|
|
1981
|
+
if (viewScope) {
|
|
1982
|
+
disposeScope(viewScope);
|
|
1983
|
+
viewScope = null;
|
|
1984
|
+
}
|
|
1985
|
+
end.remove();
|
|
2037
1986
|
});
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
if (options.loading) swap(options.loading);
|
|
1987
|
+
const retryWith = (retryProps) => () => {
|
|
1988
|
+
loadPromise = null;
|
|
1989
|
+
status = "pending";
|
|
1990
|
+
error5 = null;
|
|
1991
|
+
if (loading) render(loading);
|
|
1992
|
+
load().then(() => settle(retryProps));
|
|
2045
1993
|
};
|
|
2046
|
-
const
|
|
1994
|
+
const settle = (renderProps) => {
|
|
2047
1995
|
if (!alive) return;
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
if (
|
|
1996
|
+
clearTimers();
|
|
1997
|
+
if (status === "resolved" && component) {
|
|
1998
|
+
render(component, renderProps);
|
|
1999
|
+
} else if (status === "errored" && error5) {
|
|
2000
|
+
if (errorComp) render(errorComp, { error: error5, retry: retryWith(renderProps) });
|
|
2001
|
+
if (onError) onError(error5, retryWith(renderProps));
|
|
2053
2002
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2003
|
+
};
|
|
2004
|
+
if (status === "resolved" && component) {
|
|
2005
|
+
render(component, props);
|
|
2006
|
+
return frag;
|
|
2007
|
+
}
|
|
2008
|
+
if (status === "errored" && error5) {
|
|
2009
|
+
if (errorComp) render(errorComp, { error: error5, retry: retryWith(props) });
|
|
2010
|
+
return frag;
|
|
2059
2011
|
}
|
|
2012
|
+
const pending = load().then(() => settle(props));
|
|
2013
|
+
(_a2 = inject(SuspenseContext)) == null ? void 0 : _a2.register(pending);
|
|
2060
2014
|
if (delay > 0) {
|
|
2061
2015
|
delayTimer = setTimeout(() => {
|
|
2062
|
-
if (alive &&
|
|
2063
|
-
showLoading();
|
|
2064
|
-
}
|
|
2016
|
+
if (alive && status === "pending" && loading) render(loading);
|
|
2065
2017
|
}, delay);
|
|
2066
|
-
} else if (
|
|
2067
|
-
|
|
2018
|
+
} else if (loading) {
|
|
2019
|
+
render(loading);
|
|
2068
2020
|
}
|
|
2069
2021
|
if (timeout != null) {
|
|
2070
2022
|
timeoutTimer = setTimeout(() => {
|
|
2071
|
-
if (alive
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
if (onError) onError(err, retryWith(props));
|
|
2077
|
-
}
|
|
2023
|
+
if (!alive || status !== "pending") return;
|
|
2024
|
+
error5 = new Error(`[defineAsyncComponent] Timeout after ${timeout}ms`);
|
|
2025
|
+
status = "errored";
|
|
2026
|
+
if (errorComp) render(errorComp, { error: error5, retry: retryWith(props) });
|
|
2027
|
+
if (onError) onError(error5, retryWith(props));
|
|
2078
2028
|
}, timeout);
|
|
2079
2029
|
}
|
|
2080
|
-
return
|
|
2030
|
+
return frag;
|
|
2081
2031
|
}
|
|
2082
2032
|
AsyncWrapper.__asyncLoader = load;
|
|
2083
|
-
AsyncWrapper.__asyncResolved = () =>
|
|
2033
|
+
AsyncWrapper.__asyncResolved = () => component;
|
|
2084
2034
|
return AsyncWrapper;
|
|
2085
2035
|
}
|
|
2036
|
+
function defineAsyncComponent(loader, options = {}) {
|
|
2037
|
+
var _a2;
|
|
2038
|
+
return typeof window === "undefined" ? defineServerAsyncComponent(loader, (_a2 = options.ssr) != null ? _a2 : "blocking") : defineClientAsyncComponent(loader, options);
|
|
2039
|
+
}
|
|
2086
2040
|
function For(props) {
|
|
2087
2041
|
const fragment = document.createDocumentFragment();
|
|
2088
2042
|
const marker = document.createComment("");
|
|
@@ -2125,14 +2079,14 @@ function For(props) {
|
|
|
2125
2079
|
};
|
|
2126
2080
|
const clearFallback = () => {
|
|
2127
2081
|
for (const node of fallbackNodes) {
|
|
2128
|
-
|
|
2129
|
-
node.parentNode.removeChild(node);
|
|
2130
|
-
}
|
|
2082
|
+
removeNode(node);
|
|
2131
2083
|
}
|
|
2132
2084
|
fallbackNodes = [];
|
|
2133
2085
|
};
|
|
2086
|
+
const ownerScope = getActiveScope();
|
|
2134
2087
|
const renderItem = (item, index, parent, before, key = getKey(item, index)) => {
|
|
2135
|
-
|
|
2088
|
+
var _a2;
|
|
2089
|
+
const parentScope = (_a2 = getActiveScope()) != null ? _a2 : ownerScope;
|
|
2136
2090
|
const scope = createScope(parentScope);
|
|
2137
2091
|
let mountedNodes = [];
|
|
2138
2092
|
runWithScope(scope, () => {
|