@estjs/template 0.0.17-beta.7 → 0.0.17

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.
@@ -161,6 +161,24 @@ function onCleanup(fn) {
161
161
  scope.cleanup.push(fn);
162
162
  }
163
163
  var DANGEROUS_DATA_MIME_RE = /^data:\s*(?:text\/html|text\/xml|application\/xhtml\+xml|image\/svg\+xml|application\/xml)/;
164
+ var BOOLEAN_PROPERTY_ALIASES = {
165
+ allowfullscreen: "allowFullscreen",
166
+ formnovalidate: "formNoValidate",
167
+ ismap: "isMap",
168
+ nomodule: "noModule",
169
+ novalidate: "noValidate",
170
+ readonly: "readOnly"
171
+ };
172
+ function syncBooleanProperty(el, key, value) {
173
+ var _a2;
174
+ if (el.namespaceURI === SVG_NAMESPACE) return;
175
+ const prop = (_a2 = BOOLEAN_PROPERTY_ALIASES[key.toLowerCase()]) != null ? _a2 : key;
176
+ if (!(prop in el) || typeof el[prop] !== "boolean") return;
177
+ try {
178
+ el[prop] = value;
179
+ } catch (e) {
180
+ }
181
+ }
164
182
  function isUnsafeUrl(value) {
165
183
  const v = value.replaceAll(/[\u0000-\u0020]+/g, "").toLowerCase();
166
184
  if (shared.startsWith(v, "javascript:") || shared.startsWith(v, "vbscript:")) {
@@ -237,14 +255,19 @@ function patchAttr(el, key, prev, next2) {
237
255
  } else {
238
256
  el.removeAttribute(key);
239
257
  }
258
+ if (isBoolean || lowerKey === "indeterminate") {
259
+ syncBooleanProperty(el, key, false);
260
+ }
240
261
  return;
241
262
  }
242
263
  if (isBoolean) {
243
- if (shared.includeBooleanAttr(next2)) {
264
+ const included = shared.includeBooleanAttr(next2);
265
+ if (included) {
244
266
  el.setAttribute(key, "");
245
267
  } else {
246
268
  el.removeAttribute(key);
247
269
  }
270
+ syncBooleanProperty(el, key, included);
248
271
  return;
249
272
  }
250
273
  const attrValue = shared.isSymbol(next2) ? String(next2) : next2;
@@ -473,19 +496,31 @@ function endHydration() {
473
496
  _teleportTargetStarts.clear();
474
497
  }
475
498
  function claimHydratedNodes(parent, expected, before) {
476
- var _a2, _b;
499
+ var _a2, _b, _c;
477
500
  if (!_isHydrating || before && before.parentNode !== parent) return null;
478
501
  if (expected.length === 0) return [];
479
502
  const claimed = new Array(expected.length);
480
503
  let cursor = before ? before.previousSibling : parent.lastChild;
481
504
  for (let i = expected.length - 1; i >= 0; i--) {
482
- if (!cursor) return null;
483
505
  const expectedNode = expected[i];
484
506
  const expectedType = expectedNode.nodeType;
485
507
  if (expectedType === Node.TEXT_NODE) {
486
508
  const expectedText = (_a2 = expectedNode.textContent) != null ? _a2 : "";
487
- if (!expectedText || cursor.nodeType !== Node.TEXT_NODE) return null;
488
- const existingText = (_b = cursor.textContent) != null ? _b : "";
509
+ if (expectedText === "") {
510
+ if ((cursor == null ? void 0 : cursor.nodeType) === Node.TEXT_NODE && ((_b = cursor.textContent) != null ? _b : "") === "") {
511
+ claimed[i] = cursor;
512
+ cursor = cursor.previousSibling;
513
+ } else {
514
+ const emptyNode = document.createTextNode("");
515
+ const anchor = i + 1 < expected.length ? claimed[i + 1] : before != null ? before : null;
516
+ parent.insertBefore(emptyNode, anchor);
517
+ claimed[i] = emptyNode;
518
+ }
519
+ continue;
520
+ }
521
+ if (!cursor) return null;
522
+ if (cursor.nodeType !== Node.TEXT_NODE) return null;
523
+ const existingText = (_c = cursor.textContent) != null ? _c : "";
489
524
  if (existingText === expectedText) {
490
525
  claimed[i] = cursor;
491
526
  cursor = cursor.previousSibling;
@@ -501,6 +536,7 @@ function claimHydratedNodes(parent, expected, before) {
501
536
  cursor = prefixNode;
502
537
  continue;
503
538
  }
539
+ if (!cursor) return null;
504
540
  if (cursor.nodeType !== expectedType) return null;
505
541
  if (expectedType === Node.ELEMENT_NODE) {
506
542
  if (cursor.tagName !== expectedNode.tagName) return null;
@@ -808,6 +844,8 @@ function insert(parent, nodeFactory, before) {
808
844
  const effectRunner = signals.effect(() => {
809
845
  const executeUpdate = () => {
810
846
  const rawNodes = shared.isFunction(nodeFactory) ? nodeFactory() : nodeFactory;
847
+ const rawType = typeof rawNodes;
848
+ const canPatchText = rawNodes == null || rawType === "string" || rawType === "number" || rawType === "boolean" || rawType === "symbol";
811
849
  const nodes = resolveNodes(rawNodes);
812
850
  if (isFirstRun && isHydrating() && nodes.every((node) => node instanceof Node && node.parentNode === parent)) {
813
851
  renderedNodes = nodes;
@@ -822,6 +860,13 @@ function insert(parent, nodeFactory, before) {
822
860
  return;
823
861
  }
824
862
  }
863
+ if (canPatchText && renderedNodes.length === 1 && nodes.length === 1 && renderedNodes[0].nodeType === Node.TEXT_NODE && nodes[0].nodeType === Node.TEXT_NODE) {
864
+ const current = renderedNodes[0];
865
+ const nextText = nodes[0].textContent;
866
+ if (current.textContent !== nextText) current.textContent = nextText;
867
+ isFirstRun = false;
868
+ return;
869
+ }
825
870
  renderedNodes = reconcileArrays(parent, renderedNodes, nodes, before);
826
871
  isFirstRun = false;
827
872
  };
@@ -868,7 +913,7 @@ function addEvent(el, event, handler, options) {
868
913
  const selector = options.delegate;
869
914
  const wrappedHandler = (e) => {
870
915
  const target = e.target;
871
- if (target.matches(selector) || target.closest(selector)) {
916
+ if (target.closest(selector)) {
872
917
  handler.call(el, e);
873
918
  }
874
919
  };
@@ -1101,28 +1146,34 @@ var Component = class {
1101
1146
  */
1102
1147
  syncSpecialProps(props) {
1103
1148
  if (!props) return;
1104
- const root = this.firstChild;
1105
- if (!root || !(root instanceof Element)) return;
1149
+ const roots = this.getRootElements();
1150
+ if (roots.length === 0) return;
1151
+ const refRoot = roots[0];
1106
1152
  this.releaseSpecialProps();
1107
1153
  for (const key of Reflect.ownKeys(props)) {
1108
1154
  if (!shared.isString(key)) continue;
1109
1155
  if (key === REF_KEY) {
1110
1156
  const value = readDescriptorValue(props, key);
1111
- this.rootRefCleanup = this.bindRootRef(value, root);
1157
+ this.rootRefCleanup = this.bindRootRef(value, refRoot);
1112
1158
  continue;
1113
1159
  }
1114
1160
  if (shared.isOn(key)) {
1115
1161
  const value = readDescriptorValue(props, key);
1116
1162
  if (!shared.isFunction(value)) continue;
1117
1163
  const eventName = key.slice(2).toLowerCase();
1118
- this.bindRootEvent(
1119
- root,
1120
- eventName,
1121
- value
1122
- );
1164
+ for (const root of roots) {
1165
+ this.bindRootEvent(root, eventName, value);
1166
+ }
1123
1167
  }
1124
1168
  }
1125
1169
  }
1170
+ getRootElements() {
1171
+ const roots = [];
1172
+ for (const node of this.renderedNodes) {
1173
+ if (node instanceof Element) roots.push(node);
1174
+ }
1175
+ return roots;
1176
+ }
1126
1177
  bindRootEvent(target, eventName, handler) {
1127
1178
  const slot = `_$${eventName}`;
1128
1179
  const prev = target[slot];
@@ -1330,7 +1381,9 @@ function eventHandler(e) {
1330
1381
  return true;
1331
1382
  };
1332
1383
  const walkUpTree = () => {
1333
- while (handleNode() && (node = node._$host || node.parentNode || node.host)) ;
1384
+ while (handleNode() && (node = node._$host || node.parentNode || node.host)) {
1385
+ if (node === oriCurrentTarget) break;
1386
+ }
1334
1387
  };
1335
1388
  Object.defineProperty(e, "currentTarget", {
1336
1389
  configurable: true,
@@ -1341,23 +1394,26 @@ function eventHandler(e) {
1341
1394
  return node || document;
1342
1395
  }
1343
1396
  });
1344
- if (e.composedPath) {
1345
- const path = e.composedPath();
1346
- reTargetEvent(e, path[0]);
1347
- for (let i = 0; i < path.length - 2; i++) {
1348
- node = path[i];
1349
- if (!handleNode()) break;
1350
- if (node._$host) {
1351
- node = node._$host;
1352
- walkUpTree();
1353
- break;
1354
- }
1355
- if (node.parentNode === oriCurrentTarget) {
1356
- break;
1397
+ try {
1398
+ if (e.composedPath) {
1399
+ const path = e.composedPath();
1400
+ reTargetEvent(e, path[0]);
1401
+ for (let i = 0; i < path.length - 2; i++) {
1402
+ node = path[i];
1403
+ if (!handleNode()) break;
1404
+ if (node._$host) {
1405
+ node = node._$host;
1406
+ walkUpTree();
1407
+ break;
1408
+ }
1409
+ if (node.parentNode === oriCurrentTarget) {
1410
+ break;
1411
+ }
1357
1412
  }
1358
- }
1359
- } else walkUpTree();
1360
- reTargetEvent(e, oriTarget);
1413
+ } else walkUpTree();
1414
+ } finally {
1415
+ reTargetEvent(e, oriTarget);
1416
+ }
1361
1417
  }
1362
1418
  var $EVENTS = /* @__PURE__ */ Symbol("_$EVENTS");
1363
1419
  function delegateEvents(eventNames, document2 = globalThis.document) {
@@ -1395,6 +1451,7 @@ var EMPTY_FILES = (() => {
1395
1451
  if (typeof DataTransfer !== "undefined") return new DataTransfer().files;
1396
1452
  return [];
1397
1453
  })();
1454
+ var checkboxArraySnapshots = /* @__PURE__ */ new WeakMap();
1398
1455
  function writeValue(el, v) {
1399
1456
  const target = el;
1400
1457
  const next2 = v == null ? "" : String(v);
@@ -1511,11 +1568,16 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1511
1568
  const getModel = shared.isFunction(getter) ? getter : () => getter;
1512
1569
  const cast = shouldCast ? (v) => applyModifiers(v, trim, toNum) : IDENTITY;
1513
1570
  const computeNext = checkboxArray ? (raw) => {
1571
+ var _a2;
1514
1572
  const current = getModel();
1515
- if (!shared.isArray(current)) return cast(raw);
1573
+ if (!shared.isArray(current)) {
1574
+ return cast(raw);
1575
+ }
1516
1576
  const own = node.value;
1517
- const next2 = current.filter((item) => String(item) !== own);
1577
+ const source = (_a2 = checkboxArraySnapshots.get(current)) != null ? _a2 : current;
1578
+ const next2 = source.filter((item) => String(item) !== own);
1518
1579
  if (raw) next2.push(own);
1580
+ checkboxArraySnapshots.set(current, next2);
1519
1581
  return next2;
1520
1582
  } : cast;
1521
1583
  let composing = false;
@@ -1542,6 +1604,9 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1542
1604
  }
1543
1605
  const runner = signals.effect(() => {
1544
1606
  const value = getModel();
1607
+ if (checkboxArray) {
1608
+ if (shared.isArray(value)) checkboxArraySnapshots.set(value, [...value]);
1609
+ }
1545
1610
  if (ime && composing) return;
1546
1611
  if (ime && !lazy && isFocused(node) && Object.is(cast(read(node)), value)) return;
1547
1612
  write(node, value);
@@ -1552,7 +1617,7 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1552
1617
  }
1553
1618
  function unwrapSlotValue(raw) {
1554
1619
  let v = raw;
1555
- if (Array.isArray(v) && v.length === 1) v = v[0];
1620
+ if (shared.isArray(v) && v.length === 1) v = v[0];
1556
1621
  return shared.isFunction(v) ? v() : v;
1557
1622
  }
1558
1623
  function useChildren(props) {
@@ -1633,7 +1698,9 @@ function Portal(props) {
1633
1698
  if (children == null) return placeholder;
1634
1699
  const parentScope = getActiveScope();
1635
1700
  let innerScope = null;
1701
+ let disposed = false;
1636
1702
  const mountAt = (parent, before) => {
1703
+ if (disposed || (parentScope == null ? void 0 : parentScope.isDestroyed)) return;
1637
1704
  innerScope = createScope(parentScope);
1638
1705
  runWithScope(innerScope, () => {
1639
1706
  insert(parent, () => children, before);
@@ -1646,6 +1713,7 @@ function Portal(props) {
1646
1713
  }
1647
1714
  };
1648
1715
  const apply = (disabled, target) => {
1716
+ if (disposed) return;
1649
1717
  teardown();
1650
1718
  if (disabled) {
1651
1719
  const parent = placeholder.parentNode;
@@ -1678,11 +1746,13 @@ function Portal(props) {
1678
1746
  return;
1679
1747
  }
1680
1748
  queueMicrotask(() => {
1749
+ if (disposed) return;
1681
1750
  if (!placeholder.parentNode) return;
1682
1751
  apply(evalDisabled(props), resolveTarget(props));
1683
1752
  });
1684
1753
  });
1685
1754
  onCleanup(() => {
1755
+ disposed = true;
1686
1756
  effectRunner.stop();
1687
1757
  teardown();
1688
1758
  });
@@ -1728,12 +1798,15 @@ function resolveNodeValue(value) {
1728
1798
  if (signals.isSignal(current) || signals.isComputed(current)) {
1729
1799
  return resolveNodeValue(current.value);
1730
1800
  }
1731
- if (Array.isArray(current)) {
1801
+ if (shared.isArray(current)) {
1732
1802
  return current.map((item) => resolveNodeValue(item));
1733
1803
  }
1734
1804
  return current;
1735
1805
  }
1736
1806
  var SuspenseContext = /* @__PURE__ */ Symbol("SuspenseContext");
1807
+ function isAbortError(error5) {
1808
+ return !!error5 && typeof error5 === "object" && error5.name === "AbortError";
1809
+ }
1737
1810
  function Suspense(props) {
1738
1811
  var _a2;
1739
1812
  if (!shared.isBrowser()) {
@@ -1747,10 +1820,14 @@ function Suspense(props) {
1747
1820
  let mounted = true;
1748
1821
  let pending = 0;
1749
1822
  let mounting = false;
1823
+ let boundaryVersion = 0;
1824
+ let currentChildren = null;
1750
1825
  let contentScope = null;
1751
1826
  let parked = null;
1752
1827
  let fallbackScope = null;
1753
1828
  let resolved = null;
1829
+ let hasResolved = false;
1830
+ let manualReleases = [];
1754
1831
  const parkContent = () => {
1755
1832
  const off = document.createDocumentFragment();
1756
1833
  while (end.previousSibling && end.previousSibling !== start) {
@@ -1780,14 +1857,35 @@ function Suspense(props) {
1780
1857
  disposeScope(fallbackScope);
1781
1858
  fallbackScope = null;
1782
1859
  };
1783
- const mountContent = (children2) => {
1860
+ const disposeContent = () => {
1861
+ if (contentScope) {
1862
+ disposeScope(contentScope);
1863
+ contentScope = null;
1864
+ }
1865
+ if (parked) {
1866
+ while (parked.firstChild) parked.firstChild.remove();
1867
+ parked = null;
1868
+ }
1869
+ };
1870
+ const mountContent = (children) => {
1871
+ const scope = createScope(owner);
1784
1872
  mounting = true;
1785
- contentScope = createScope(owner);
1786
- runWithScope(contentScope, () => {
1787
- var _a3;
1788
- insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(children2), end);
1789
- });
1790
- mounting = false;
1873
+ contentScope = scope;
1874
+ try {
1875
+ runWithScope(scope, () => {
1876
+ var _a3;
1877
+ insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(children), end);
1878
+ });
1879
+ } catch (error5) {
1880
+ if (contentScope === scope) contentScope = null;
1881
+ disposeScope(scope);
1882
+ pending = 0;
1883
+ manualReleases = [];
1884
+ boundaryVersion++;
1885
+ throw error5;
1886
+ } finally {
1887
+ mounting = false;
1888
+ }
1791
1889
  if (pending && !parked) {
1792
1890
  parkContent();
1793
1891
  mountFallback();
@@ -1801,53 +1899,89 @@ function Suspense(props) {
1801
1899
  };
1802
1900
  const showContent = () => {
1803
1901
  if (!parked) return;
1804
- const hasSyncChildren = props.children != null && !shared.isPromise(props.children);
1805
- if (contentScope == null && resolved == null && !hasSyncChildren) return;
1902
+ const hasSyncChildren = currentChildren != null && !shared.isPromise(currentChildren);
1903
+ if (contentScope == null && !hasResolved && !hasSyncChildren) return;
1806
1904
  disposeFallback();
1807
1905
  restoreContent();
1808
1906
  if (!contentScope) {
1809
- if (resolved) {
1907
+ if (hasResolved) {
1810
1908
  mountContent(resolved);
1811
1909
  } else if (hasSyncChildren) {
1812
- mountContent(props.children);
1910
+ mountContent(currentChildren);
1813
1911
  }
1814
1912
  }
1815
1913
  };
1816
- const settle = () => {
1914
+ const addPending = (version = boundaryVersion) => {
1915
+ pending++;
1916
+ showFallback();
1917
+ const release = (() => {
1918
+ if (!release.active) return;
1919
+ release.active = false;
1920
+ if (!mounted || version !== boundaryVersion) return;
1921
+ if (--pending === 0) showContent();
1922
+ });
1923
+ release.active = true;
1924
+ return release;
1925
+ };
1926
+ const settle = (release) => {
1817
1927
  if (!mounted) return;
1818
- if (--pending === 0) showContent();
1928
+ release();
1929
+ };
1930
+ const dequeueManualRelease = () => {
1931
+ while (manualReleases.length > 0) {
1932
+ const release = manualReleases.shift();
1933
+ if (release.active) return release;
1934
+ }
1935
+ return void 0;
1819
1936
  };
1820
1937
  const ctx = {
1821
1938
  register: (promise) => {
1822
- pending++;
1823
- showFallback();
1824
- promise.then(settle).catch((error5) => {
1825
- shared.warn("[Suspense] Resource failed:", error5);
1826
- settle();
1827
- });
1939
+ const release = addPending();
1940
+ promise.then(
1941
+ () => settle(release),
1942
+ (error5) => {
1943
+ if (!isAbortError(error5)) shared.warn("[Suspense] Resource failed:", error5);
1944
+ settle(release);
1945
+ }
1946
+ );
1947
+ return release;
1828
1948
  },
1829
1949
  increment: () => {
1830
- pending++;
1831
- showFallback();
1950
+ const release = addPending();
1951
+ manualReleases.push(release);
1952
+ return release;
1832
1953
  },
1833
1954
  decrement: () => {
1834
- pending = Math.max(0, pending - 1);
1835
- if (pending === 0) showContent();
1955
+ const release = dequeueManualRelease();
1956
+ if (release) settle(release);
1836
1957
  }
1837
1958
  };
1838
1959
  provide(SuspenseContext, ctx);
1839
- const children = props.children;
1840
- if (shared.isPromise(children)) {
1841
- children.then((value) => {
1842
- resolved = value;
1843
- }).catch(() => {
1844
- });
1845
- ctx.register(children);
1846
- } else if (children != null) {
1847
- mountContent(children);
1848
- } else if (props.fallback != null) {
1849
- showFallback();
1850
- }
1960
+ const renderChildren = (children) => {
1961
+ const version = ++boundaryVersion;
1962
+ currentChildren = children != null ? children : null;
1963
+ pending = 0;
1964
+ resolved = null;
1965
+ hasResolved = false;
1966
+ manualReleases = [];
1967
+ disposeContent();
1968
+ disposeFallback();
1969
+ if (shared.isPromise(children)) {
1970
+ children.then((value) => {
1971
+ if (!mounted || version !== boundaryVersion) return;
1972
+ resolved = value;
1973
+ hasResolved = true;
1974
+ }).catch(() => {
1975
+ });
1976
+ ctx.register(children);
1977
+ } else if (children != null) {
1978
+ mountContent(children);
1979
+ } else if (props.fallback != null) {
1980
+ showFallback();
1981
+ }
1982
+ };
1983
+ renderChildren(props.children);
1984
+ onUpdate(() => renderChildren(props.children));
1851
1985
  onCleanup(() => {
1852
1986
  mounted = false;
1853
1987
  pending = 0;
@@ -1865,6 +1999,9 @@ Suspense[SUSPENSE_COMPONENT] = true;
1865
1999
  function isSuspense(node) {
1866
2000
  return !!node && !!node[SUSPENSE_COMPONENT];
1867
2001
  }
2002
+ function isAbortError2(error5) {
2003
+ return !!error5 && typeof error5 === "object" && error5.name === "AbortError";
2004
+ }
1868
2005
  function createResource(fetcher, options) {
1869
2006
  const value = signals.signal(options == null ? void 0 : options.initialValue);
1870
2007
  const loading = signals.signal(true);
@@ -1899,7 +2036,7 @@ function createResource(fetcher, options) {
1899
2036
  }
1900
2037
  } catch (error_) {
1901
2038
  if (id !== fetchId) return;
1902
- if (error_ instanceof DOMException && error_.name === "AbortError") {
2039
+ if (isAbortError2(error_)) {
1903
2040
  loading.value = false;
1904
2041
  return;
1905
2042
  }
@@ -1954,17 +2091,26 @@ function defineServerAsyncComponent(loader, ssr) {
1954
2091
  function defineClientAsyncComponent(loader, options) {
1955
2092
  const { loading, error: errorComp, delay = 200, timeout, onError } = options;
1956
2093
  let component = null;
1957
- let error5 = null;
2094
+ let loadError = null;
1958
2095
  let status = "pending";
1959
2096
  let loadPromise = null;
1960
- const load = () => loadPromise != null ? loadPromise : loadPromise = loader().then((mod) => {
1961
- component = resolveModule(mod);
1962
- status = "resolved";
1963
- }).catch((error_) => {
1964
- error5 = error_ instanceof Error ? error_ : new Error(String(error_));
1965
- status = "errored";
1966
- loadPromise = null;
1967
- });
2097
+ let loadId = 0;
2098
+ const currentLoad = (id) => id !== loadId ? loadPromise != null ? loadPromise : void 0 : void 0;
2099
+ const load = (forceId) => {
2100
+ if (loadPromise && forceId === void 0) return loadPromise;
2101
+ const id = forceId != null ? forceId : ++loadId;
2102
+ loadPromise = loader().then((mod) => {
2103
+ if (id !== loadId) return currentLoad(id);
2104
+ component = resolveModule(mod);
2105
+ status = "resolved";
2106
+ }).catch((error_) => {
2107
+ if (id !== loadId) return currentLoad(id);
2108
+ loadError = error_ instanceof Error ? error_ : new Error(String(error_));
2109
+ status = "errored";
2110
+ loadPromise = null;
2111
+ });
2112
+ return loadPromise;
2113
+ };
1968
2114
  load();
1969
2115
  function AsyncWrapper(props) {
1970
2116
  var _a2;
@@ -1976,6 +2122,7 @@ function defineClientAsyncComponent(loader, options) {
1976
2122
  let viewScope = null;
1977
2123
  let delayTimer = null;
1978
2124
  let timeoutTimer = null;
2125
+ let instanceRetryId = 0;
1979
2126
  const clearTimers = () => {
1980
2127
  if (delayTimer != null) clearTimeout(delayTimer);
1981
2128
  if (timeoutTimer != null) clearTimeout(timeoutTimer);
@@ -2005,28 +2152,34 @@ function defineClientAsyncComponent(loader, options) {
2005
2152
  end.remove();
2006
2153
  });
2007
2154
  const retryWith = (retryProps) => () => {
2155
+ if (!alive) return;
2156
+ const retryLoadId = ++loadId;
2008
2157
  loadPromise = null;
2009
2158
  status = "pending";
2010
- error5 = null;
2159
+ loadError = null;
2160
+ instanceRetryId++;
2161
+ const capturedRetry = instanceRetryId;
2011
2162
  if (loading) render(loading);
2012
- load().then(() => settle(retryProps));
2163
+ load(retryLoadId).then(() => {
2164
+ if (alive && capturedRetry === instanceRetryId) settle(retryProps);
2165
+ });
2013
2166
  };
2014
2167
  const settle = (renderProps) => {
2015
2168
  if (!alive) return;
2016
2169
  clearTimers();
2017
2170
  if (status === "resolved" && component) {
2018
2171
  render(component, renderProps);
2019
- } else if (status === "errored" && error5) {
2020
- if (errorComp) render(errorComp, { error: error5, retry: retryWith(renderProps) });
2021
- if (onError) onError(error5, retryWith(renderProps));
2172
+ } else if (status === "errored" && loadError) {
2173
+ if (errorComp) render(errorComp, { error: loadError, retry: retryWith(renderProps) });
2174
+ if (onError) onError(loadError, retryWith(renderProps));
2022
2175
  }
2023
2176
  };
2024
2177
  if (status === "resolved" && component) {
2025
2178
  render(component, props);
2026
2179
  return frag;
2027
2180
  }
2028
- if (status === "errored" && error5) {
2029
- if (errorComp) render(errorComp, { error: error5, retry: retryWith(props) });
2181
+ if (status === "errored" && loadError) {
2182
+ if (errorComp) render(errorComp, { error: loadError, retry: retryWith(props) });
2030
2183
  return frag;
2031
2184
  }
2032
2185
  const pending = load().then(() => settle(props));
@@ -2041,10 +2194,9 @@ function defineClientAsyncComponent(loader, options) {
2041
2194
  if (timeout != null) {
2042
2195
  timeoutTimer = setTimeout(() => {
2043
2196
  if (!alive || status !== "pending") return;
2044
- error5 = new Error(`[defineAsyncComponent] Timeout after ${timeout}ms`);
2045
- status = "errored";
2046
- if (errorComp) render(errorComp, { error: error5, retry: retryWith(props) });
2047
- if (onError) onError(error5, retryWith(props));
2197
+ const err = new Error(`[defineAsyncComponent] Timeout after ${timeout}ms`);
2198
+ if (errorComp) render(errorComp, { error: err, retry: retryWith(props) });
2199
+ if (onError) onError(err, retryWith(props));
2048
2200
  }, timeout);
2049
2201
  }
2050
2202
  return frag;
@@ -2063,9 +2215,11 @@ function For(props) {
2063
2215
  fragment.appendChild(marker);
2064
2216
  let entries = [];
2065
2217
  let fallbackNodes = [];
2218
+ let fallbackScope = null;
2219
+ const ownerScope = getActiveScope();
2066
2220
  const keyFn = props.key;
2067
2221
  const raw = props.children;
2068
- const renderFn = Array.isArray(raw) && raw.length === 1 && shared.isFunction(raw[0]) ? raw[0] : props.children;
2222
+ const renderFn = shared.isArray(raw) && raw.length === 1 && shared.isFunction(raw[0]) ? raw[0] : props.children;
2069
2223
  if (!shared.isFunction(renderFn)) {
2070
2224
  throw new TypeError("<For> requires `children` to be a function (item, index) => Node");
2071
2225
  }
@@ -2077,9 +2231,31 @@ function For(props) {
2077
2231
  return input != null ? input : [];
2078
2232
  };
2079
2233
  const getKey = (item, index) => keyFn ? keyFn(item, index) : item;
2234
+ const formatKeyForWarning = (key) => {
2235
+ if (typeof key === "string") return JSON.stringify(key);
2236
+ return String(key);
2237
+ };
2238
+ const getKeys = (items) => {
2239
+ const keys = new Array(items.length);
2240
+ {
2241
+ const seen = /* @__PURE__ */ new Set();
2242
+ for (const [i, item] of items.entries()) {
2243
+ const key = getKey(item, i);
2244
+ keys[i] = key;
2245
+ if (seen.has(key)) {
2246
+ shared.warn(
2247
+ `[For] duplicate key ${formatKeyForWarning(key)} detected. Duplicate keys may cause rows to remount or lose state.`
2248
+ );
2249
+ } else {
2250
+ seen.add(key);
2251
+ }
2252
+ }
2253
+ return keys;
2254
+ }
2255
+ };
2080
2256
  const mountValue = (value, parent, before) => {
2081
2257
  if (value == null || value === false) return [];
2082
- if (Array.isArray(value)) {
2258
+ if (shared.isArray(value)) {
2083
2259
  const nodes = [];
2084
2260
  for (const child2 of value) nodes.push(...mountValue(child2, parent, before));
2085
2261
  return nodes;
@@ -2093,17 +2269,30 @@ function For(props) {
2093
2269
  return [node];
2094
2270
  };
2095
2271
  const mountFallback = (parent, before) => {
2272
+ var _a2;
2096
2273
  if (!props.fallback) return;
2097
- const nodes = mountValue(props.fallback(), parent, before);
2098
- fallbackNodes = nodes;
2274
+ fallbackScope = createScope((_a2 = getActiveScope()) != null ? _a2 : ownerScope);
2275
+ try {
2276
+ runWithScope(fallbackScope, () => {
2277
+ fallbackNodes = mountValue(props.fallback(), parent, before);
2278
+ });
2279
+ } catch (error5) {
2280
+ disposeScope(fallbackScope);
2281
+ fallbackScope = null;
2282
+ fallbackNodes = [];
2283
+ throw error5;
2284
+ }
2099
2285
  };
2100
2286
  const clearFallback = () => {
2287
+ if (fallbackScope) {
2288
+ disposeScope(fallbackScope);
2289
+ fallbackScope = null;
2290
+ }
2101
2291
  for (const node of fallbackNodes) {
2102
2292
  removeNode(node);
2103
2293
  }
2104
2294
  fallbackNodes = [];
2105
2295
  };
2106
- const ownerScope = getActiveScope();
2107
2296
  const renderItem = (item, index, parent, before, key = getKey(item, index)) => {
2108
2297
  var _a2;
2109
2298
  const parentScope = (_a2 = getActiveScope()) != null ? _a2 : ownerScope;
@@ -2135,10 +2324,9 @@ function For(props) {
2135
2324
  mountFallback(fragment, marker);
2136
2325
  } else {
2137
2326
  entries = new Array(newItems.length);
2138
- let idx = 0;
2139
- for (const newItem of newItems) {
2140
- entries[idx] = renderItem(newItem, idx, fragment, marker);
2141
- idx++;
2327
+ const newKeys = getKeys(newItems);
2328
+ for (const [i, newItem] of newItems.entries()) {
2329
+ entries[i] = renderItem(newItem, i, fragment, marker, newKeys[i]);
2142
2330
  }
2143
2331
  }
2144
2332
  return;
@@ -2164,10 +2352,13 @@ function For(props) {
2164
2352
  }
2165
2353
  entries = new Array(newLen);
2166
2354
  const batchFragment2 = document.createDocumentFragment();
2355
+ const newKeys2 = getKeys(newItems);
2167
2356
  for (let i = 0; i < newLen; i++) {
2168
- entries[i] = renderItem(newItems[i], i, batchFragment2, null);
2357
+ entries[i] = renderItem(newItems[i], i, batchFragment2, null, newKeys2[i]);
2169
2358
  }
2170
- parent.insertBefore(batchFragment2, marker);
2359
+ signals.untrack(() => {
2360
+ parent.insertBefore(batchFragment2, marker);
2361
+ });
2171
2362
  return;
2172
2363
  }
2173
2364
  const oldKeyMap = /* @__PURE__ */ new Map();
@@ -2184,10 +2375,7 @@ function For(props) {
2184
2375
  const newIndexToOldIndex = new Int32Array(newLen);
2185
2376
  let moved = false;
2186
2377
  let maxOldSeen = 0;
2187
- const newKeys = new Array(newLen);
2188
- for (let i = 0; i < newLen; i++) {
2189
- newKeys[i] = getKey(newItems[i], i);
2190
- }
2378
+ const newKeys = getKeys(newItems);
2191
2379
  for (let i = 0; i < newLen; i++) {
2192
2380
  const item = newItems[i];
2193
2381
  const key = newKeys[i];
@@ -2202,7 +2390,7 @@ function For(props) {
2202
2390
  else maxOldSeen = oldIndex;
2203
2391
  } else {
2204
2392
  if (!batchFragment) batchFragment = document.createDocumentFragment();
2205
- disposeItem(reused);
2393
+ signals.untrack(() => disposeItem(reused));
2206
2394
  newEntries[i] = renderItem(item, i, batchFragment, null, key);
2207
2395
  }
2208
2396
  } else {
@@ -2213,28 +2401,30 @@ function For(props) {
2213
2401
  for (const list of oldKeyMap.values()) {
2214
2402
  for (const [entry] of list) toRemove.push(entry);
2215
2403
  }
2216
- for (const entry of toRemove) disposeItem(entry);
2217
- const lis = moved ? getSequence(newIndexToOldIndex) : [];
2218
- let lisCursor = lis.length - 1;
2219
- let nextNode = marker;
2220
- for (let i = newLen - 1; i >= 0; i--) {
2221
- const entry = newEntries[i];
2222
- const nodes = entry.nodes;
2223
- const isFresh = newIndexToOldIndex[i] === 0;
2224
- const inLis = !isFresh && moved && lisCursor >= 0 && i === lis[lisCursor];
2225
- if (inLis) {
2226
- lisCursor--;
2227
- for (let j = nodes.length - 1; j >= 0; j--) nextNode = nodes[j];
2228
- continue;
2229
- }
2230
- for (let j = nodes.length - 1; j >= 0; j--) {
2231
- const node = nodes[j];
2232
- if (node.nextSibling !== nextNode) {
2233
- parent.insertBefore(node, nextNode);
2404
+ for (const entry of toRemove) signals.untrack(() => disposeItem(entry));
2405
+ signals.untrack(() => {
2406
+ const lis = moved ? getSequence(newIndexToOldIndex) : [];
2407
+ let lisCursor = lis.length - 1;
2408
+ let nextNode = marker;
2409
+ for (let i = newLen - 1; i >= 0; i--) {
2410
+ const entry = newEntries[i];
2411
+ const nodes = entry.nodes;
2412
+ const isFresh = newIndexToOldIndex[i] === 0;
2413
+ const inLis = !isFresh && moved && lisCursor >= 0 && i === lis[lisCursor];
2414
+ if (inLis) {
2415
+ lisCursor--;
2416
+ for (let j = nodes.length - 1; j >= 0; j--) nextNode = nodes[j];
2417
+ continue;
2418
+ }
2419
+ for (let j = nodes.length - 1; j >= 0; j--) {
2420
+ const node = nodes[j];
2421
+ if (node.nextSibling !== nextNode) {
2422
+ parent.insertBefore(node, nextNode);
2423
+ }
2424
+ nextNode = node;
2234
2425
  }
2235
- nextNode = node;
2236
2426
  }
2237
- }
2427
+ });
2238
2428
  entries = newEntries;
2239
2429
  }
2240
2430
  onCleanup(() => {
@@ -2297,21 +2487,40 @@ function addClass(el, cls) {
2297
2487
  function removeClass(el, cls) {
2298
2488
  for (const c of cls.split(/\s+/)) if (c) el.classList.remove(c);
2299
2489
  }
2300
- function nextFrame(cb) {
2301
- requestAnimationFrame(() => requestAnimationFrame(cb));
2490
+ function nextFrameCancellable(cb) {
2491
+ let cancelled = false;
2492
+ let innerId = null;
2493
+ const outerId = requestAnimationFrame(() => {
2494
+ if (cancelled) return;
2495
+ innerId = requestAnimationFrame(cb);
2496
+ });
2497
+ return () => {
2498
+ cancelled = true;
2499
+ cancelAnimationFrame(outerId);
2500
+ if (innerId != null) cancelAnimationFrame(innerId);
2501
+ };
2302
2502
  }
2303
2503
  function forceReflow(el) {
2304
2504
  void el.offsetHeight;
2305
2505
  }
2306
2506
  function whenTransitionEnds(el, type, explicit, resolve2) {
2307
2507
  if (explicit != null) {
2308
- setTimeout(resolve2, explicit);
2309
- return;
2508
+ let done2 = false;
2509
+ const timer2 = setTimeout(() => {
2510
+ if (done2) return;
2511
+ done2 = true;
2512
+ resolve2();
2513
+ }, explicit);
2514
+ return () => {
2515
+ done2 = true;
2516
+ clearTimeout(timer2);
2517
+ };
2310
2518
  }
2311
2519
  const info = getTransitionInfo(el, type);
2312
2520
  if (!info) {
2313
2521
  resolve2();
2314
- return;
2522
+ return () => {
2523
+ };
2315
2524
  }
2316
2525
  let done = false;
2317
2526
  const finish = () => {
@@ -2321,9 +2530,18 @@ function whenTransitionEnds(el, type, explicit, resolve2) {
2321
2530
  el.removeEventListener(info.event, onEnd);
2322
2531
  resolve2();
2323
2532
  };
2324
- const onEnd = () => finish();
2533
+ const onEnd = (event) => {
2534
+ if (event.target !== el) return;
2535
+ finish();
2536
+ };
2325
2537
  el.addEventListener(info.event, onEnd);
2326
2538
  const timer = setTimeout(finish, info.timeout + 1);
2539
+ return () => {
2540
+ if (done) return;
2541
+ done = true;
2542
+ clearTimeout(timer);
2543
+ el.removeEventListener(info.event, onEnd);
2544
+ };
2327
2545
  }
2328
2546
  function resolveDuration(d, dir) {
2329
2547
  if (d == null) return null;
@@ -2332,7 +2550,7 @@ function resolveDuration(d, dir) {
2332
2550
  }
2333
2551
  function validateSlot(value) {
2334
2552
  if (value == null || value === false) return null;
2335
- if (Array.isArray(value)) {
2553
+ if (shared.isArray(value)) {
2336
2554
  {
2337
2555
  throw new Error(
2338
2556
  "[essor] <Transition> expects a single root child. Use <TransitionGroup> for multiple children."
@@ -2378,8 +2596,26 @@ function Transition(props) {
2378
2596
  let hasPending = false;
2379
2597
  let scheduled = false;
2380
2598
  let disposed = false;
2599
+ let cancelEnterWait = null;
2600
+ let cancelLeaveWait = null;
2601
+ const stopEnterWait = () => {
2602
+ cancelEnterWait == null ? void 0 : cancelEnterWait();
2603
+ cancelEnterWait = null;
2604
+ };
2605
+ const stopLeaveWait = () => {
2606
+ cancelLeaveWait == null ? void 0 : cancelLeaveWait();
2607
+ cancelLeaveWait = null;
2608
+ };
2381
2609
  const enter = (el, phase) => {
2382
2610
  var _a2;
2611
+ stopEnterWait();
2612
+ let cancelWait = null;
2613
+ const stopWait = () => {
2614
+ cancelWait == null ? void 0 : cancelWait();
2615
+ cancelWait = null;
2616
+ if (cancelEnterWait === stopWait) cancelEnterWait = null;
2617
+ };
2618
+ cancelEnterWait = stopWait;
2383
2619
  const prevLeave = el[LEAVE_CB];
2384
2620
  if (prevLeave) prevLeave(true);
2385
2621
  state = "entering";
@@ -2396,6 +2632,7 @@ function Transition(props) {
2396
2632
  var _a3, _b;
2397
2633
  if (called) return;
2398
2634
  called = true;
2635
+ stopWait();
2399
2636
  el[ENTER_CB] = void 0;
2400
2637
  if (useCss) {
2401
2638
  removeClass(el, fromCls);
@@ -2410,7 +2647,8 @@ function Transition(props) {
2410
2647
  }
2411
2648
  };
2412
2649
  el[ENTER_CB] = done;
2413
- nextFrame(() => {
2650
+ cancelWait = nextFrameCancellable(() => {
2651
+ cancelWait = null;
2414
2652
  if (called) return;
2415
2653
  if (useCss) {
2416
2654
  removeClass(el, fromCls);
@@ -2420,7 +2658,10 @@ function Transition(props) {
2420
2658
  props.onEnter(el, () => done(false));
2421
2659
  } else if (useCss) {
2422
2660
  const explicit = resolveDuration(props.duration, "enter");
2423
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2661
+ cancelWait = whenTransitionEnds(el, props.type, explicit, () => {
2662
+ cancelWait = null;
2663
+ done(false);
2664
+ });
2424
2665
  } else {
2425
2666
  done(false);
2426
2667
  }
@@ -2428,6 +2669,14 @@ function Transition(props) {
2428
2669
  };
2429
2670
  const leave = (el, after) => {
2430
2671
  var _a2;
2672
+ stopLeaveWait();
2673
+ let cancelWait = null;
2674
+ const stopWait = () => {
2675
+ cancelWait == null ? void 0 : cancelWait();
2676
+ cancelWait = null;
2677
+ if (cancelLeaveWait === stopWait) cancelLeaveWait = null;
2678
+ };
2679
+ cancelLeaveWait = stopWait;
2431
2680
  const prevEnter = el[ENTER_CB];
2432
2681
  if (prevEnter) {
2433
2682
  prevEnter(true);
@@ -2444,6 +2693,7 @@ function Transition(props) {
2444
2693
  var _a3, _b;
2445
2694
  if (called) return;
2446
2695
  called = true;
2696
+ stopWait();
2447
2697
  el[LEAVE_CB] = void 0;
2448
2698
  if (useCss) {
2449
2699
  removeClass(el, classes.leaveFrom);
@@ -2465,7 +2715,8 @@ function Transition(props) {
2465
2715
  done(false);
2466
2716
  return;
2467
2717
  }
2468
- nextFrame(() => {
2718
+ cancelWait = nextFrameCancellable(() => {
2719
+ cancelWait = null;
2469
2720
  if (called) return;
2470
2721
  if (useCss) {
2471
2722
  removeClass(el, classes.leaveFrom);
@@ -2474,7 +2725,10 @@ function Transition(props) {
2474
2725
  if (props.onLeave) {
2475
2726
  props.onLeave(el, () => done(false));
2476
2727
  } else if (useCss) {
2477
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2728
+ cancelWait = whenTransitionEnds(el, props.type, explicit, () => {
2729
+ cancelWait = null;
2730
+ done(false);
2731
+ });
2478
2732
  } else {
2479
2733
  done(false);
2480
2734
  }
@@ -2549,6 +2803,8 @@ function Transition(props) {
2549
2803
  });
2550
2804
  onCleanup(() => {
2551
2805
  disposed = true;
2806
+ stopEnterWait();
2807
+ stopLeaveWait();
2552
2808
  effectRunner.stop();
2553
2809
  for (const el of [currentEl, leavingEl]) {
2554
2810
  if (!el) continue;
@@ -2570,7 +2826,7 @@ function isTransition(node) {
2570
2826
  }
2571
2827
  function resolveItemElement(raw, parent) {
2572
2828
  if (raw == null || raw === false) return { el: null, comp: null };
2573
- if (Array.isArray(raw) && raw.length === 1) {
2829
+ if (shared.isArray(raw) && raw.length === 1) {
2574
2830
  return resolveItemElement(raw[0], parent);
2575
2831
  }
2576
2832
  if (shared.isFunction(raw)) {
@@ -2625,7 +2881,7 @@ function TransitionGroup(props) {
2625
2881
  const moveClass = (_c = props.moveClass) != null ? _c : `${(_b = props.name) != null ? _b : "v"}-move`;
2626
2882
  const keyFn = props.key;
2627
2883
  const rawChildren = props.children;
2628
- const childrenFn = Array.isArray(rawChildren) && rawChildren.length === 1 && shared.isFunction(rawChildren[0]) ? rawChildren[0] : props.children;
2884
+ const childrenFn = shared.isArray(rawChildren) && rawChildren.length === 1 && shared.isFunction(rawChildren[0]) ? rawChildren[0] : props.children;
2629
2885
  if (!shared.isFunction(childrenFn) || !shared.isFunction(keyFn)) {
2630
2886
  throw new TypeError(
2631
2887
  "<TransitionGroup> requires `children: (item, index) => Node` and `key: (item, index) => unknown`"
@@ -2676,9 +2932,12 @@ function TransitionGroup(props) {
2676
2932
  if (entry.el.parentNode === wrapper) wrapper.removeChild(entry.el);
2677
2933
  };
2678
2934
  const disposeEntry = (entry) => {
2679
- var _a3, _b2;
2935
+ var _a3, _b2, _c2, _d, _e;
2680
2936
  (_a3 = entry.cancelEnter) == null ? void 0 : _a3.call(entry, true);
2681
2937
  (_b2 = entry.cancelLeave) == null ? void 0 : _b2.call(entry, true);
2938
+ (_c2 = entry.cancelEnterWait) == null ? void 0 : _c2.call(entry);
2939
+ (_d = entry.cancelLeaveWait) == null ? void 0 : _d.call(entry);
2940
+ (_e = entry.cancelMoveWait) == null ? void 0 : _e.call(entry);
2682
2941
  if (entry.comp) entry.comp.destroy();
2683
2942
  detachEntryDom(entry);
2684
2943
  disposeScope(entry.scope);
@@ -2697,23 +2956,26 @@ function TransitionGroup(props) {
2697
2956
  addClass(el, classes.enterActive);
2698
2957
  let called = false;
2699
2958
  const done = (cancelled) => {
2700
- var _a4, _b3;
2959
+ var _a4, _b3, _c3;
2701
2960
  if (called) return;
2702
2961
  called = true;
2703
2962
  entry.cancelEnter = void 0;
2963
+ (_a4 = entry.cancelEnterWait) == null ? void 0 : _a4.call(entry);
2964
+ entry.cancelEnterWait = void 0;
2704
2965
  removeClass(el, classes.enterFrom);
2705
2966
  removeClass(el, classes.enterActive);
2706
2967
  removeClass(el, classes.enterTo);
2707
2968
  if (cancelled) {
2708
- (_a4 = props.onEnterCancelled) == null ? void 0 : _a4.call(props, el);
2969
+ (_b3 = props.onEnterCancelled) == null ? void 0 : _b3.call(props, el);
2709
2970
  } else {
2710
2971
  entry.state = "present";
2711
- (_b3 = props.onAfterEnter) == null ? void 0 : _b3.call(props, el);
2972
+ (_c3 = props.onAfterEnter) == null ? void 0 : _c3.call(props, el);
2712
2973
  }
2713
2974
  };
2714
2975
  entry.cancelEnter = done;
2715
2976
  entry.state = "entering";
2716
- nextFrame(() => {
2977
+ entry.cancelEnterWait = nextFrameCancellable(() => {
2978
+ entry.cancelEnterWait = void 0;
2717
2979
  if (called) return;
2718
2980
  removeClass(el, classes.enterFrom);
2719
2981
  addClass(el, classes.enterTo);
@@ -2721,7 +2983,10 @@ function TransitionGroup(props) {
2721
2983
  props.onEnter(el, () => done(false));
2722
2984
  } else {
2723
2985
  const explicit = resolveDuration(props.duration, "enter");
2724
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2986
+ entry.cancelEnterWait = whenTransitionEnds(el, props.type, explicit, () => {
2987
+ entry.cancelEnterWait = void 0;
2988
+ done(false);
2989
+ });
2725
2990
  }
2726
2991
  });
2727
2992
  };
@@ -2753,17 +3018,19 @@ function TransitionGroup(props) {
2753
3018
  addClass(el, classes.leaveActive);
2754
3019
  let called = false;
2755
3020
  const done = (cancelled) => {
2756
- var _a4, _b3;
3021
+ var _a4, _b3, _c2;
2757
3022
  if (called) return;
2758
3023
  called = true;
2759
3024
  entry.cancelLeave = void 0;
3025
+ (_a4 = entry.cancelLeaveWait) == null ? void 0 : _a4.call(entry);
3026
+ entry.cancelLeaveWait = void 0;
2760
3027
  removeClass(el, classes.leaveFrom);
2761
3028
  removeClass(el, classes.leaveActive);
2762
3029
  removeClass(el, classes.leaveTo);
2763
3030
  if (cancelled) {
2764
3031
  if (entry.savedStyles) restoreStyles(el, entry.savedStyles);
2765
3032
  entry.savedStyles = void 0;
2766
- (_a4 = props.onLeaveCancelled) == null ? void 0 : _a4.call(props, el);
3033
+ (_b3 = props.onLeaveCancelled) == null ? void 0 : _b3.call(props, el);
2767
3034
  return;
2768
3035
  }
2769
3036
  if (entry.savedStyles) restoreStyles(el, entry.savedStyles);
@@ -2771,10 +3038,11 @@ function TransitionGroup(props) {
2771
3038
  detachEntryDom(entry);
2772
3039
  disposeScope(entry.scope);
2773
3040
  if (entry.comp) entry.comp.destroy();
2774
- (_b3 = props.onAfterLeave) == null ? void 0 : _b3.call(props, el);
3041
+ (_c2 = props.onAfterLeave) == null ? void 0 : _c2.call(props, el);
2775
3042
  };
2776
3043
  entry.cancelLeave = done;
2777
- nextFrame(() => {
3044
+ entry.cancelLeaveWait = nextFrameCancellable(() => {
3045
+ entry.cancelLeaveWait = void 0;
2778
3046
  if (called) return;
2779
3047
  removeClass(el, classes.leaveFrom);
2780
3048
  addClass(el, classes.leaveTo);
@@ -2782,11 +3050,15 @@ function TransitionGroup(props) {
2782
3050
  props.onLeave(el, () => done(false));
2783
3051
  } else {
2784
3052
  const explicit = resolveDuration(props.duration, "leave");
2785
- whenTransitionEnds(el, props.type, explicit, () => done(false));
3053
+ entry.cancelLeaveWait = whenTransitionEnds(el, props.type, explicit, () => {
3054
+ entry.cancelLeaveWait = void 0;
3055
+ done(false);
3056
+ });
2786
3057
  }
2787
3058
  });
2788
3059
  };
2789
3060
  const runMove = (entry, prevRect) => {
3061
+ var _a3;
2790
3062
  if (!useCss || entry.state !== "present") return;
2791
3063
  const el = entry.el;
2792
3064
  const newRect = el.getBoundingClientRect();
@@ -2802,7 +3074,9 @@ function TransitionGroup(props) {
2802
3074
  el.style.transform = savedTransform;
2803
3075
  el.style.transitionDuration = savedTransition;
2804
3076
  const explicit = resolveDuration(props.duration, "enter");
2805
- whenTransitionEnds(el, props.type, explicit, () => {
3077
+ (_a3 = entry.cancelMoveWait) == null ? void 0 : _a3.call(entry);
3078
+ entry.cancelMoveWait = whenTransitionEnds(el, props.type, explicit, () => {
3079
+ entry.cancelMoveWait = void 0;
2806
3080
  removeClass(el, moveClass);
2807
3081
  });
2808
3082
  };