@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.
@@ -1,6 +1,6 @@
1
1
  import { getActiveScope, runWithScope, onCleanup, __objRest, createScope, disposeScope, __async } from './chunk-PYFF2HI3.dev.js';
2
2
  import { normalizeClassName, SPREAD_NAME, isObject, warn, startsWith, isSpecialBooleanAttr, isBooleanAttr, includeBooleanAttr, isSymbol, isString, isArray, kebabCase, camelCase, capitalize, HYDRATION_ANCHOR_ATTR, isBrowser, error, isPromise, isFunction, isOn, coerceArray, isNumber } from '@estjs/shared';
3
- import { effect, shallowReactive, isSignal, isComputed, isReactive, signal } from '@estjs/signals';
3
+ import { effect, shallowReactive, isSignal, isComputed, isReactive, signal, untrack } from '@estjs/signals';
4
4
 
5
5
  var REF_KEY = "ref";
6
6
  var KEY_PROP = "key";
@@ -14,6 +14,24 @@ 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
16
  var DANGEROUS_DATA_MIME_RE = /^data:\s*(?:text\/html|text\/xml|application\/xhtml\+xml|image\/svg\+xml|application\/xml)/;
17
+ var BOOLEAN_PROPERTY_ALIASES = {
18
+ allowfullscreen: "allowFullscreen",
19
+ formnovalidate: "formNoValidate",
20
+ ismap: "isMap",
21
+ nomodule: "noModule",
22
+ novalidate: "noValidate",
23
+ readonly: "readOnly"
24
+ };
25
+ function syncBooleanProperty(el, key, value) {
26
+ var _a2;
27
+ if (el.namespaceURI === SVG_NAMESPACE) return;
28
+ const prop = (_a2 = BOOLEAN_PROPERTY_ALIASES[key.toLowerCase()]) != null ? _a2 : key;
29
+ if (!(prop in el) || typeof el[prop] !== "boolean") return;
30
+ try {
31
+ el[prop] = value;
32
+ } catch (e) {
33
+ }
34
+ }
17
35
  function isUnsafeUrl(value) {
18
36
  const v = value.replaceAll(/[\u0000-\u0020]+/g, "").toLowerCase();
19
37
  if (startsWith(v, "javascript:") || startsWith(v, "vbscript:")) {
@@ -90,14 +108,19 @@ function patchAttr(el, key, prev, next2) {
90
108
  } else {
91
109
  el.removeAttribute(key);
92
110
  }
111
+ if (isBoolean || lowerKey === "indeterminate") {
112
+ syncBooleanProperty(el, key, false);
113
+ }
93
114
  return;
94
115
  }
95
116
  if (isBoolean) {
96
- if (includeBooleanAttr(next2)) {
117
+ const included = includeBooleanAttr(next2);
118
+ if (included) {
97
119
  el.setAttribute(key, "");
98
120
  } else {
99
121
  el.removeAttribute(key);
100
122
  }
123
+ syncBooleanProperty(el, key, included);
101
124
  return;
102
125
  }
103
126
  const attrValue = isSymbol(next2) ? String(next2) : next2;
@@ -326,19 +349,31 @@ function endHydration() {
326
349
  _teleportTargetStarts.clear();
327
350
  }
328
351
  function claimHydratedNodes(parent, expected, before) {
329
- var _a2, _b;
352
+ var _a2, _b, _c;
330
353
  if (!_isHydrating || before && before.parentNode !== parent) return null;
331
354
  if (expected.length === 0) return [];
332
355
  const claimed = new Array(expected.length);
333
356
  let cursor = before ? before.previousSibling : parent.lastChild;
334
357
  for (let i = expected.length - 1; i >= 0; i--) {
335
- if (!cursor) return null;
336
358
  const expectedNode = expected[i];
337
359
  const expectedType = expectedNode.nodeType;
338
360
  if (expectedType === Node.TEXT_NODE) {
339
361
  const expectedText = (_a2 = expectedNode.textContent) != null ? _a2 : "";
340
- if (!expectedText || cursor.nodeType !== Node.TEXT_NODE) return null;
341
- const existingText = (_b = cursor.textContent) != null ? _b : "";
362
+ if (expectedText === "") {
363
+ if ((cursor == null ? void 0 : cursor.nodeType) === Node.TEXT_NODE && ((_b = cursor.textContent) != null ? _b : "") === "") {
364
+ claimed[i] = cursor;
365
+ cursor = cursor.previousSibling;
366
+ } else {
367
+ const emptyNode = document.createTextNode("");
368
+ const anchor = i + 1 < expected.length ? claimed[i + 1] : before != null ? before : null;
369
+ parent.insertBefore(emptyNode, anchor);
370
+ claimed[i] = emptyNode;
371
+ }
372
+ continue;
373
+ }
374
+ if (!cursor) return null;
375
+ if (cursor.nodeType !== Node.TEXT_NODE) return null;
376
+ const existingText = (_c = cursor.textContent) != null ? _c : "";
342
377
  if (existingText === expectedText) {
343
378
  claimed[i] = cursor;
344
379
  cursor = cursor.previousSibling;
@@ -354,6 +389,7 @@ function claimHydratedNodes(parent, expected, before) {
354
389
  cursor = prefixNode;
355
390
  continue;
356
391
  }
392
+ if (!cursor) return null;
357
393
  if (cursor.nodeType !== expectedType) return null;
358
394
  if (expectedType === Node.ELEMENT_NODE) {
359
395
  if (cursor.tagName !== expectedNode.tagName) return null;
@@ -661,6 +697,8 @@ function insert(parent, nodeFactory, before) {
661
697
  const effectRunner = effect(() => {
662
698
  const executeUpdate = () => {
663
699
  const rawNodes = isFunction(nodeFactory) ? nodeFactory() : nodeFactory;
700
+ const rawType = typeof rawNodes;
701
+ const canPatchText = rawNodes == null || rawType === "string" || rawType === "number" || rawType === "boolean" || rawType === "symbol";
664
702
  const nodes = resolveNodes(rawNodes);
665
703
  if (isFirstRun && isHydrating() && nodes.every((node) => node instanceof Node && node.parentNode === parent)) {
666
704
  renderedNodes = nodes;
@@ -675,6 +713,13 @@ function insert(parent, nodeFactory, before) {
675
713
  return;
676
714
  }
677
715
  }
716
+ if (canPatchText && renderedNodes.length === 1 && nodes.length === 1 && renderedNodes[0].nodeType === Node.TEXT_NODE && nodes[0].nodeType === Node.TEXT_NODE) {
717
+ const current = renderedNodes[0];
718
+ const nextText = nodes[0].textContent;
719
+ if (current.textContent !== nextText) current.textContent = nextText;
720
+ isFirstRun = false;
721
+ return;
722
+ }
678
723
  renderedNodes = reconcileArrays(parent, renderedNodes, nodes, before);
679
724
  isFirstRun = false;
680
725
  };
@@ -721,7 +766,7 @@ function addEvent(el, event, handler, options) {
721
766
  const selector = options.delegate;
722
767
  const wrappedHandler = (e) => {
723
768
  const target = e.target;
724
- if (target.matches(selector) || target.closest(selector)) {
769
+ if (target.closest(selector)) {
725
770
  handler.call(el, e);
726
771
  }
727
772
  };
@@ -954,28 +999,34 @@ var Component = class {
954
999
  */
955
1000
  syncSpecialProps(props) {
956
1001
  if (!props) return;
957
- const root = this.firstChild;
958
- if (!root || !(root instanceof Element)) return;
1002
+ const roots = this.getRootElements();
1003
+ if (roots.length === 0) return;
1004
+ const refRoot = roots[0];
959
1005
  this.releaseSpecialProps();
960
1006
  for (const key of Reflect.ownKeys(props)) {
961
1007
  if (!isString(key)) continue;
962
1008
  if (key === REF_KEY) {
963
1009
  const value = readDescriptorValue(props, key);
964
- this.rootRefCleanup = this.bindRootRef(value, root);
1010
+ this.rootRefCleanup = this.bindRootRef(value, refRoot);
965
1011
  continue;
966
1012
  }
967
1013
  if (isOn(key)) {
968
1014
  const value = readDescriptorValue(props, key);
969
1015
  if (!isFunction(value)) continue;
970
1016
  const eventName = key.slice(2).toLowerCase();
971
- this.bindRootEvent(
972
- root,
973
- eventName,
974
- value
975
- );
1017
+ for (const root of roots) {
1018
+ this.bindRootEvent(root, eventName, value);
1019
+ }
976
1020
  }
977
1021
  }
978
1022
  }
1023
+ getRootElements() {
1024
+ const roots = [];
1025
+ for (const node of this.renderedNodes) {
1026
+ if (node instanceof Element) roots.push(node);
1027
+ }
1028
+ return roots;
1029
+ }
979
1030
  bindRootEvent(target, eventName, handler) {
980
1031
  const slot = `_$${eventName}`;
981
1032
  const prev = target[slot];
@@ -1183,7 +1234,9 @@ function eventHandler(e) {
1183
1234
  return true;
1184
1235
  };
1185
1236
  const walkUpTree = () => {
1186
- while (handleNode() && (node = node._$host || node.parentNode || node.host)) ;
1237
+ while (handleNode() && (node = node._$host || node.parentNode || node.host)) {
1238
+ if (node === oriCurrentTarget) break;
1239
+ }
1187
1240
  };
1188
1241
  Object.defineProperty(e, "currentTarget", {
1189
1242
  configurable: true,
@@ -1194,23 +1247,26 @@ function eventHandler(e) {
1194
1247
  return node || document;
1195
1248
  }
1196
1249
  });
1197
- if (e.composedPath) {
1198
- const path = e.composedPath();
1199
- reTargetEvent(e, path[0]);
1200
- for (let i = 0; i < path.length - 2; i++) {
1201
- node = path[i];
1202
- if (!handleNode()) break;
1203
- if (node._$host) {
1204
- node = node._$host;
1205
- walkUpTree();
1206
- break;
1207
- }
1208
- if (node.parentNode === oriCurrentTarget) {
1209
- break;
1250
+ try {
1251
+ if (e.composedPath) {
1252
+ const path = e.composedPath();
1253
+ reTargetEvent(e, path[0]);
1254
+ for (let i = 0; i < path.length - 2; i++) {
1255
+ node = path[i];
1256
+ if (!handleNode()) break;
1257
+ if (node._$host) {
1258
+ node = node._$host;
1259
+ walkUpTree();
1260
+ break;
1261
+ }
1262
+ if (node.parentNode === oriCurrentTarget) {
1263
+ break;
1264
+ }
1210
1265
  }
1211
- }
1212
- } else walkUpTree();
1213
- reTargetEvent(e, oriTarget);
1266
+ } else walkUpTree();
1267
+ } finally {
1268
+ reTargetEvent(e, oriTarget);
1269
+ }
1214
1270
  }
1215
1271
  var $EVENTS = /* @__PURE__ */ Symbol("_$EVENTS");
1216
1272
  function delegateEvents(eventNames, document2 = globalThis.document) {
@@ -1248,6 +1304,7 @@ var EMPTY_FILES = (() => {
1248
1304
  if (typeof DataTransfer !== "undefined") return new DataTransfer().files;
1249
1305
  return [];
1250
1306
  })();
1307
+ var checkboxArraySnapshots = /* @__PURE__ */ new WeakMap();
1251
1308
  function writeValue(el, v) {
1252
1309
  const target = el;
1253
1310
  const next2 = v == null ? "" : String(v);
@@ -1364,11 +1421,16 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1364
1421
  const getModel = isFunction(getter) ? getter : () => getter;
1365
1422
  const cast = shouldCast ? (v) => applyModifiers(v, trim, toNum) : IDENTITY;
1366
1423
  const computeNext = checkboxArray ? (raw) => {
1424
+ var _a2;
1367
1425
  const current = getModel();
1368
- if (!isArray(current)) return cast(raw);
1426
+ if (!isArray(current)) {
1427
+ return cast(raw);
1428
+ }
1369
1429
  const own = node.value;
1370
- const next2 = current.filter((item) => String(item) !== own);
1430
+ const source = (_a2 = checkboxArraySnapshots.get(current)) != null ? _a2 : current;
1431
+ const next2 = source.filter((item) => String(item) !== own);
1371
1432
  if (raw) next2.push(own);
1433
+ checkboxArraySnapshots.set(current, next2);
1372
1434
  return next2;
1373
1435
  } : cast;
1374
1436
  let composing = false;
@@ -1395,6 +1457,9 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1395
1457
  }
1396
1458
  const runner = effect(() => {
1397
1459
  const value = getModel();
1460
+ if (checkboxArray) {
1461
+ if (isArray(value)) checkboxArraySnapshots.set(value, [...value]);
1462
+ }
1398
1463
  if (ime && composing) return;
1399
1464
  if (ime && !lazy && isFocused(node) && Object.is(cast(read(node)), value)) return;
1400
1465
  write(node, value);
@@ -1405,7 +1470,7 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1405
1470
  }
1406
1471
  function unwrapSlotValue(raw) {
1407
1472
  let v = raw;
1408
- if (Array.isArray(v) && v.length === 1) v = v[0];
1473
+ if (isArray(v) && v.length === 1) v = v[0];
1409
1474
  return isFunction(v) ? v() : v;
1410
1475
  }
1411
1476
  function useChildren(props) {
@@ -1486,7 +1551,9 @@ function Portal(props) {
1486
1551
  if (children == null) return placeholder;
1487
1552
  const parentScope = getActiveScope();
1488
1553
  let innerScope = null;
1554
+ let disposed = false;
1489
1555
  const mountAt = (parent, before) => {
1556
+ if (disposed || (parentScope == null ? void 0 : parentScope.isDestroyed)) return;
1490
1557
  innerScope = createScope(parentScope);
1491
1558
  runWithScope(innerScope, () => {
1492
1559
  insert(parent, () => children, before);
@@ -1499,6 +1566,7 @@ function Portal(props) {
1499
1566
  }
1500
1567
  };
1501
1568
  const apply = (disabled, target) => {
1569
+ if (disposed) return;
1502
1570
  teardown();
1503
1571
  if (disabled) {
1504
1572
  const parent = placeholder.parentNode;
@@ -1531,11 +1599,13 @@ function Portal(props) {
1531
1599
  return;
1532
1600
  }
1533
1601
  queueMicrotask(() => {
1602
+ if (disposed) return;
1534
1603
  if (!placeholder.parentNode) return;
1535
1604
  apply(evalDisabled(props), resolveTarget(props));
1536
1605
  });
1537
1606
  });
1538
1607
  onCleanup(() => {
1608
+ disposed = true;
1539
1609
  effectRunner.stop();
1540
1610
  teardown();
1541
1611
  });
@@ -1581,12 +1651,15 @@ function resolveNodeValue(value) {
1581
1651
  if (isSignal(current) || isComputed(current)) {
1582
1652
  return resolveNodeValue(current.value);
1583
1653
  }
1584
- if (Array.isArray(current)) {
1654
+ if (isArray(current)) {
1585
1655
  return current.map((item) => resolveNodeValue(item));
1586
1656
  }
1587
1657
  return current;
1588
1658
  }
1589
1659
  var SuspenseContext = /* @__PURE__ */ Symbol("SuspenseContext");
1660
+ function isAbortError(error4) {
1661
+ return !!error4 && typeof error4 === "object" && error4.name === "AbortError";
1662
+ }
1590
1663
  function Suspense(props) {
1591
1664
  var _a2;
1592
1665
  if (!isBrowser()) {
@@ -1600,10 +1673,14 @@ function Suspense(props) {
1600
1673
  let mounted = true;
1601
1674
  let pending = 0;
1602
1675
  let mounting = false;
1676
+ let boundaryVersion = 0;
1677
+ let currentChildren = null;
1603
1678
  let contentScope = null;
1604
1679
  let parked = null;
1605
1680
  let fallbackScope = null;
1606
1681
  let resolved = null;
1682
+ let hasResolved = false;
1683
+ let manualReleases = [];
1607
1684
  const parkContent = () => {
1608
1685
  const off = document.createDocumentFragment();
1609
1686
  while (end.previousSibling && end.previousSibling !== start) {
@@ -1633,14 +1710,35 @@ function Suspense(props) {
1633
1710
  disposeScope(fallbackScope);
1634
1711
  fallbackScope = null;
1635
1712
  };
1636
- const mountContent = (children2) => {
1713
+ const disposeContent = () => {
1714
+ if (contentScope) {
1715
+ disposeScope(contentScope);
1716
+ contentScope = null;
1717
+ }
1718
+ if (parked) {
1719
+ while (parked.firstChild) parked.firstChild.remove();
1720
+ parked = null;
1721
+ }
1722
+ };
1723
+ const mountContent = (children) => {
1724
+ const scope = createScope(owner);
1637
1725
  mounting = true;
1638
- contentScope = createScope(owner);
1639
- runWithScope(contentScope, () => {
1640
- var _a3;
1641
- insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(children2), end);
1642
- });
1643
- mounting = false;
1726
+ contentScope = scope;
1727
+ try {
1728
+ runWithScope(scope, () => {
1729
+ var _a3;
1730
+ insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(children), end);
1731
+ });
1732
+ } catch (error4) {
1733
+ if (contentScope === scope) contentScope = null;
1734
+ disposeScope(scope);
1735
+ pending = 0;
1736
+ manualReleases = [];
1737
+ boundaryVersion++;
1738
+ throw error4;
1739
+ } finally {
1740
+ mounting = false;
1741
+ }
1644
1742
  if (pending && !parked) {
1645
1743
  parkContent();
1646
1744
  mountFallback();
@@ -1654,53 +1752,89 @@ function Suspense(props) {
1654
1752
  };
1655
1753
  const showContent = () => {
1656
1754
  if (!parked) return;
1657
- const hasSyncChildren = props.children != null && !isPromise(props.children);
1658
- if (contentScope == null && resolved == null && !hasSyncChildren) return;
1755
+ const hasSyncChildren = currentChildren != null && !isPromise(currentChildren);
1756
+ if (contentScope == null && !hasResolved && !hasSyncChildren) return;
1659
1757
  disposeFallback();
1660
1758
  restoreContent();
1661
1759
  if (!contentScope) {
1662
- if (resolved) {
1760
+ if (hasResolved) {
1663
1761
  mountContent(resolved);
1664
1762
  } else if (hasSyncChildren) {
1665
- mountContent(props.children);
1763
+ mountContent(currentChildren);
1666
1764
  }
1667
1765
  }
1668
1766
  };
1669
- const settle = () => {
1767
+ const addPending = (version = boundaryVersion) => {
1768
+ pending++;
1769
+ showFallback();
1770
+ const release = (() => {
1771
+ if (!release.active) return;
1772
+ release.active = false;
1773
+ if (!mounted || version !== boundaryVersion) return;
1774
+ if (--pending === 0) showContent();
1775
+ });
1776
+ release.active = true;
1777
+ return release;
1778
+ };
1779
+ const settle = (release) => {
1670
1780
  if (!mounted) return;
1671
- if (--pending === 0) showContent();
1781
+ release();
1782
+ };
1783
+ const dequeueManualRelease = () => {
1784
+ while (manualReleases.length > 0) {
1785
+ const release = manualReleases.shift();
1786
+ if (release.active) return release;
1787
+ }
1788
+ return void 0;
1672
1789
  };
1673
1790
  const ctx = {
1674
1791
  register: (promise) => {
1675
- pending++;
1676
- showFallback();
1677
- promise.then(settle).catch((error4) => {
1678
- warn("[Suspense] Resource failed:", error4);
1679
- settle();
1680
- });
1792
+ const release = addPending();
1793
+ promise.then(
1794
+ () => settle(release),
1795
+ (error4) => {
1796
+ if (!isAbortError(error4)) warn("[Suspense] Resource failed:", error4);
1797
+ settle(release);
1798
+ }
1799
+ );
1800
+ return release;
1681
1801
  },
1682
1802
  increment: () => {
1683
- pending++;
1684
- showFallback();
1803
+ const release = addPending();
1804
+ manualReleases.push(release);
1805
+ return release;
1685
1806
  },
1686
1807
  decrement: () => {
1687
- pending = Math.max(0, pending - 1);
1688
- if (pending === 0) showContent();
1808
+ const release = dequeueManualRelease();
1809
+ if (release) settle(release);
1689
1810
  }
1690
1811
  };
1691
1812
  provide(SuspenseContext, ctx);
1692
- const children = props.children;
1693
- if (isPromise(children)) {
1694
- children.then((value) => {
1695
- resolved = value;
1696
- }).catch(() => {
1697
- });
1698
- ctx.register(children);
1699
- } else if (children != null) {
1700
- mountContent(children);
1701
- } else if (props.fallback != null) {
1702
- showFallback();
1703
- }
1813
+ const renderChildren = (children) => {
1814
+ const version = ++boundaryVersion;
1815
+ currentChildren = children != null ? children : null;
1816
+ pending = 0;
1817
+ resolved = null;
1818
+ hasResolved = false;
1819
+ manualReleases = [];
1820
+ disposeContent();
1821
+ disposeFallback();
1822
+ if (isPromise(children)) {
1823
+ children.then((value) => {
1824
+ if (!mounted || version !== boundaryVersion) return;
1825
+ resolved = value;
1826
+ hasResolved = true;
1827
+ }).catch(() => {
1828
+ });
1829
+ ctx.register(children);
1830
+ } else if (children != null) {
1831
+ mountContent(children);
1832
+ } else if (props.fallback != null) {
1833
+ showFallback();
1834
+ }
1835
+ };
1836
+ renderChildren(props.children);
1837
+ onUpdate(() => renderChildren(props.children));
1704
1838
  onCleanup(() => {
1705
1839
  mounted = false;
1706
1840
  pending = 0;
@@ -1718,6 +1852,9 @@ Suspense[SUSPENSE_COMPONENT] = true;
1718
1852
  function isSuspense(node) {
1719
1853
  return !!node && !!node[SUSPENSE_COMPONENT];
1720
1854
  }
1855
+ function isAbortError2(error4) {
1856
+ return !!error4 && typeof error4 === "object" && error4.name === "AbortError";
1857
+ }
1721
1858
  function createResource(fetcher, options) {
1722
1859
  const value = signal(options == null ? void 0 : options.initialValue);
1723
1860
  const loading = signal(true);
@@ -1752,7 +1889,7 @@ function createResource(fetcher, options) {
1752
1889
  }
1753
1890
  } catch (error_) {
1754
1891
  if (id !== fetchId) return;
1755
- if (error_ instanceof DOMException && error_.name === "AbortError") {
1892
+ if (isAbortError2(error_)) {
1756
1893
  loading.value = false;
1757
1894
  return;
1758
1895
  }
@@ -1807,17 +1944,26 @@ function defineServerAsyncComponent(loader, ssr) {
1807
1944
  function defineClientAsyncComponent(loader, options) {
1808
1945
  const { loading, error: errorComp, delay = 200, timeout, onError } = options;
1809
1946
  let component = null;
1810
- let error4 = null;
1947
+ let loadError = null;
1811
1948
  let status = "pending";
1812
1949
  let loadPromise = null;
1813
- const load = () => loadPromise != null ? loadPromise : loadPromise = loader().then((mod) => {
1814
- component = resolveModule(mod);
1815
- status = "resolved";
1816
- }).catch((error_) => {
1817
- error4 = error_ instanceof Error ? error_ : new Error(String(error_));
1818
- status = "errored";
1819
- loadPromise = null;
1820
- });
1950
+ let loadId = 0;
1951
+ const currentLoad = (id) => id !== loadId ? loadPromise != null ? loadPromise : void 0 : void 0;
1952
+ const load = (forceId) => {
1953
+ if (loadPromise && forceId === void 0) return loadPromise;
1954
+ const id = forceId != null ? forceId : ++loadId;
1955
+ loadPromise = loader().then((mod) => {
1956
+ if (id !== loadId) return currentLoad(id);
1957
+ component = resolveModule(mod);
1958
+ status = "resolved";
1959
+ }).catch((error_) => {
1960
+ if (id !== loadId) return currentLoad(id);
1961
+ loadError = error_ instanceof Error ? error_ : new Error(String(error_));
1962
+ status = "errored";
1963
+ loadPromise = null;
1964
+ });
1965
+ return loadPromise;
1966
+ };
1821
1967
  load();
1822
1968
  function AsyncWrapper(props) {
1823
1969
  var _a2;
@@ -1829,6 +1975,7 @@ function defineClientAsyncComponent(loader, options) {
1829
1975
  let viewScope = null;
1830
1976
  let delayTimer = null;
1831
1977
  let timeoutTimer = null;
1978
+ let instanceRetryId = 0;
1832
1979
  const clearTimers = () => {
1833
1980
  if (delayTimer != null) clearTimeout(delayTimer);
1834
1981
  if (timeoutTimer != null) clearTimeout(timeoutTimer);
@@ -1858,28 +2005,34 @@ function defineClientAsyncComponent(loader, options) {
1858
2005
  end.remove();
1859
2006
  });
1860
2007
  const retryWith = (retryProps) => () => {
2008
+ if (!alive) return;
2009
+ const retryLoadId = ++loadId;
1861
2010
  loadPromise = null;
1862
2011
  status = "pending";
1863
- error4 = null;
2012
+ loadError = null;
2013
+ instanceRetryId++;
2014
+ const capturedRetry = instanceRetryId;
1864
2015
  if (loading) render(loading);
1865
- load().then(() => settle(retryProps));
2016
+ load(retryLoadId).then(() => {
2017
+ if (alive && capturedRetry === instanceRetryId) settle(retryProps);
2018
+ });
1866
2019
  };
1867
2020
  const settle = (renderProps) => {
1868
2021
  if (!alive) return;
1869
2022
  clearTimers();
1870
2023
  if (status === "resolved" && component) {
1871
2024
  render(component, renderProps);
1872
- } else if (status === "errored" && error4) {
1873
- if (errorComp) render(errorComp, { error: error4, retry: retryWith(renderProps) });
1874
- if (onError) onError(error4, retryWith(renderProps));
2025
+ } else if (status === "errored" && loadError) {
2026
+ if (errorComp) render(errorComp, { error: loadError, retry: retryWith(renderProps) });
2027
+ if (onError) onError(loadError, retryWith(renderProps));
1875
2028
  }
1876
2029
  };
1877
2030
  if (status === "resolved" && component) {
1878
2031
  render(component, props);
1879
2032
  return frag;
1880
2033
  }
1881
- if (status === "errored" && error4) {
1882
- if (errorComp) render(errorComp, { error: error4, retry: retryWith(props) });
2034
+ if (status === "errored" && loadError) {
2035
+ if (errorComp) render(errorComp, { error: loadError, retry: retryWith(props) });
1883
2036
  return frag;
1884
2037
  }
1885
2038
  const pending = load().then(() => settle(props));
@@ -1894,10 +2047,9 @@ function defineClientAsyncComponent(loader, options) {
1894
2047
  if (timeout != null) {
1895
2048
  timeoutTimer = setTimeout(() => {
1896
2049
  if (!alive || status !== "pending") return;
1897
- error4 = new Error(`[defineAsyncComponent] Timeout after ${timeout}ms`);
1898
- status = "errored";
1899
- if (errorComp) render(errorComp, { error: error4, retry: retryWith(props) });
1900
- if (onError) onError(error4, retryWith(props));
2050
+ const err = new Error(`[defineAsyncComponent] Timeout after ${timeout}ms`);
2051
+ if (errorComp) render(errorComp, { error: err, retry: retryWith(props) });
2052
+ if (onError) onError(err, retryWith(props));
1901
2053
  }, timeout);
1902
2054
  }
1903
2055
  return frag;
@@ -1916,9 +2068,11 @@ function For(props) {
1916
2068
  fragment.appendChild(marker);
1917
2069
  let entries = [];
1918
2070
  let fallbackNodes = [];
2071
+ let fallbackScope = null;
2072
+ const ownerScope = getActiveScope();
1919
2073
  const keyFn = props.key;
1920
2074
  const raw = props.children;
1921
- const renderFn = Array.isArray(raw) && raw.length === 1 && isFunction(raw[0]) ? raw[0] : props.children;
2075
+ const renderFn = isArray(raw) && raw.length === 1 && isFunction(raw[0]) ? raw[0] : props.children;
1922
2076
  if (!isFunction(renderFn)) {
1923
2077
  throw new TypeError("<For> requires `children` to be a function (item, index) => Node");
1924
2078
  }
@@ -1930,9 +2084,31 @@ function For(props) {
1930
2084
  return input != null ? input : [];
1931
2085
  };
1932
2086
  const getKey = (item, index) => keyFn ? keyFn(item, index) : item;
2087
+ const formatKeyForWarning = (key) => {
2088
+ if (typeof key === "string") return JSON.stringify(key);
2089
+ return String(key);
2090
+ };
2091
+ const getKeys = (items) => {
2092
+ const keys = new Array(items.length);
2093
+ {
2094
+ const seen = /* @__PURE__ */ new Set();
2095
+ for (const [i, item] of items.entries()) {
2096
+ const key = getKey(item, i);
2097
+ keys[i] = key;
2098
+ if (seen.has(key)) {
2099
+ warn(
2100
+ `[For] duplicate key ${formatKeyForWarning(key)} detected. Duplicate keys may cause rows to remount or lose state.`
2101
+ );
2102
+ } else {
2103
+ seen.add(key);
2104
+ }
2105
+ }
2106
+ return keys;
2107
+ }
2108
+ };
1933
2109
  const mountValue = (value, parent, before) => {
1934
2110
  if (value == null || value === false) return [];
1935
- if (Array.isArray(value)) {
2111
+ if (isArray(value)) {
1936
2112
  const nodes = [];
1937
2113
  for (const child2 of value) nodes.push(...mountValue(child2, parent, before));
1938
2114
  return nodes;
@@ -1946,17 +2122,30 @@ function For(props) {
1946
2122
  return [node];
1947
2123
  };
1948
2124
  const mountFallback = (parent, before) => {
2125
+ var _a2;
1949
2126
  if (!props.fallback) return;
1950
- const nodes = mountValue(props.fallback(), parent, before);
1951
- fallbackNodes = nodes;
2127
+ fallbackScope = createScope((_a2 = getActiveScope()) != null ? _a2 : ownerScope);
2128
+ try {
2129
+ runWithScope(fallbackScope, () => {
2130
+ fallbackNodes = mountValue(props.fallback(), parent, before);
2131
+ });
2132
+ } catch (error4) {
2133
+ disposeScope(fallbackScope);
2134
+ fallbackScope = null;
2135
+ fallbackNodes = [];
2136
+ throw error4;
2137
+ }
1952
2138
  };
1953
2139
  const clearFallback = () => {
2140
+ if (fallbackScope) {
2141
+ disposeScope(fallbackScope);
2142
+ fallbackScope = null;
2143
+ }
1954
2144
  for (const node of fallbackNodes) {
1955
2145
  removeNode(node);
1956
2146
  }
1957
2147
  fallbackNodes = [];
1958
2148
  };
1959
- const ownerScope = getActiveScope();
1960
2149
  const renderItem = (item, index, parent, before, key = getKey(item, index)) => {
1961
2150
  var _a2;
1962
2151
  const parentScope = (_a2 = getActiveScope()) != null ? _a2 : ownerScope;
@@ -1988,10 +2177,9 @@ function For(props) {
1988
2177
  mountFallback(fragment, marker);
1989
2178
  } else {
1990
2179
  entries = new Array(newItems.length);
1991
- let idx = 0;
1992
- for (const newItem of newItems) {
1993
- entries[idx] = renderItem(newItem, idx, fragment, marker);
1994
- idx++;
2180
+ const newKeys = getKeys(newItems);
2181
+ for (const [i, newItem] of newItems.entries()) {
2182
+ entries[i] = renderItem(newItem, i, fragment, marker, newKeys[i]);
1995
2183
  }
1996
2184
  }
1997
2185
  return;
@@ -2017,10 +2205,13 @@ function For(props) {
2017
2205
  }
2018
2206
  entries = new Array(newLen);
2019
2207
  const batchFragment2 = document.createDocumentFragment();
2208
+ const newKeys2 = getKeys(newItems);
2020
2209
  for (let i = 0; i < newLen; i++) {
2021
- entries[i] = renderItem(newItems[i], i, batchFragment2, null);
2210
+ entries[i] = renderItem(newItems[i], i, batchFragment2, null, newKeys2[i]);
2022
2211
  }
2023
- parent.insertBefore(batchFragment2, marker);
2212
+ untrack(() => {
2213
+ parent.insertBefore(batchFragment2, marker);
2214
+ });
2024
2215
  return;
2025
2216
  }
2026
2217
  const oldKeyMap = /* @__PURE__ */ new Map();
@@ -2037,10 +2228,7 @@ function For(props) {
2037
2228
  const newIndexToOldIndex = new Int32Array(newLen);
2038
2229
  let moved = false;
2039
2230
  let maxOldSeen = 0;
2040
- const newKeys = new Array(newLen);
2041
- for (let i = 0; i < newLen; i++) {
2042
- newKeys[i] = getKey(newItems[i], i);
2043
- }
2231
+ const newKeys = getKeys(newItems);
2044
2232
  for (let i = 0; i < newLen; i++) {
2045
2233
  const item = newItems[i];
2046
2234
  const key = newKeys[i];
@@ -2055,7 +2243,7 @@ function For(props) {
2055
2243
  else maxOldSeen = oldIndex;
2056
2244
  } else {
2057
2245
  if (!batchFragment) batchFragment = document.createDocumentFragment();
2058
- disposeItem(reused);
2246
+ untrack(() => disposeItem(reused));
2059
2247
  newEntries[i] = renderItem(item, i, batchFragment, null, key);
2060
2248
  }
2061
2249
  } else {
@@ -2066,28 +2254,30 @@ function For(props) {
2066
2254
  for (const list of oldKeyMap.values()) {
2067
2255
  for (const [entry] of list) toRemove.push(entry);
2068
2256
  }
2069
- for (const entry of toRemove) disposeItem(entry);
2070
- const lis = moved ? getSequence(newIndexToOldIndex) : [];
2071
- let lisCursor = lis.length - 1;
2072
- let nextNode = marker;
2073
- for (let i = newLen - 1; i >= 0; i--) {
2074
- const entry = newEntries[i];
2075
- const nodes = entry.nodes;
2076
- const isFresh = newIndexToOldIndex[i] === 0;
2077
- const inLis = !isFresh && moved && lisCursor >= 0 && i === lis[lisCursor];
2078
- if (inLis) {
2079
- lisCursor--;
2080
- for (let j = nodes.length - 1; j >= 0; j--) nextNode = nodes[j];
2081
- continue;
2082
- }
2083
- for (let j = nodes.length - 1; j >= 0; j--) {
2084
- const node = nodes[j];
2085
- if (node.nextSibling !== nextNode) {
2086
- parent.insertBefore(node, nextNode);
2257
+ for (const entry of toRemove) untrack(() => disposeItem(entry));
2258
+ untrack(() => {
2259
+ const lis = moved ? getSequence(newIndexToOldIndex) : [];
2260
+ let lisCursor = lis.length - 1;
2261
+ let nextNode = marker;
2262
+ for (let i = newLen - 1; i >= 0; i--) {
2263
+ const entry = newEntries[i];
2264
+ const nodes = entry.nodes;
2265
+ const isFresh = newIndexToOldIndex[i] === 0;
2266
+ const inLis = !isFresh && moved && lisCursor >= 0 && i === lis[lisCursor];
2267
+ if (inLis) {
2268
+ lisCursor--;
2269
+ for (let j = nodes.length - 1; j >= 0; j--) nextNode = nodes[j];
2270
+ continue;
2271
+ }
2272
+ for (let j = nodes.length - 1; j >= 0; j--) {
2273
+ const node = nodes[j];
2274
+ if (node.nextSibling !== nextNode) {
2275
+ parent.insertBefore(node, nextNode);
2276
+ }
2277
+ nextNode = node;
2087
2278
  }
2088
- nextNode = node;
2089
2279
  }
2090
- }
2280
+ });
2091
2281
  entries = newEntries;
2092
2282
  }
2093
2283
  onCleanup(() => {
@@ -2150,21 +2340,40 @@ function addClass(el, cls) {
2150
2340
  function removeClass(el, cls) {
2151
2341
  for (const c of cls.split(/\s+/)) if (c) el.classList.remove(c);
2152
2342
  }
2153
- function nextFrame(cb) {
2154
- requestAnimationFrame(() => requestAnimationFrame(cb));
2343
+ function nextFrameCancellable(cb) {
2344
+ let cancelled = false;
2345
+ let innerId = null;
2346
+ const outerId = requestAnimationFrame(() => {
2347
+ if (cancelled) return;
2348
+ innerId = requestAnimationFrame(cb);
2349
+ });
2350
+ return () => {
2351
+ cancelled = true;
2352
+ cancelAnimationFrame(outerId);
2353
+ if (innerId != null) cancelAnimationFrame(innerId);
2354
+ };
2155
2355
  }
2156
2356
  function forceReflow(el) {
2157
2357
  void el.offsetHeight;
2158
2358
  }
2159
2359
  function whenTransitionEnds(el, type, explicit, resolve2) {
2160
2360
  if (explicit != null) {
2161
- setTimeout(resolve2, explicit);
2162
- return;
2361
+ let done2 = false;
2362
+ const timer2 = setTimeout(() => {
2363
+ if (done2) return;
2364
+ done2 = true;
2365
+ resolve2();
2366
+ }, explicit);
2367
+ return () => {
2368
+ done2 = true;
2369
+ clearTimeout(timer2);
2370
+ };
2163
2371
  }
2164
2372
  const info = getTransitionInfo(el, type);
2165
2373
  if (!info) {
2166
2374
  resolve2();
2167
- return;
2375
+ return () => {
2376
+ };
2168
2377
  }
2169
2378
  let done = false;
2170
2379
  const finish = () => {
@@ -2174,9 +2383,18 @@ function whenTransitionEnds(el, type, explicit, resolve2) {
2174
2383
  el.removeEventListener(info.event, onEnd);
2175
2384
  resolve2();
2176
2385
  };
2177
- const onEnd = () => finish();
2386
+ const onEnd = (event) => {
2387
+ if (event.target !== el) return;
2388
+ finish();
2389
+ };
2178
2390
  el.addEventListener(info.event, onEnd);
2179
2391
  const timer = setTimeout(finish, info.timeout + 1);
2392
+ return () => {
2393
+ if (done) return;
2394
+ done = true;
2395
+ clearTimeout(timer);
2396
+ el.removeEventListener(info.event, onEnd);
2397
+ };
2180
2398
  }
2181
2399
  function resolveDuration(d, dir) {
2182
2400
  if (d == null) return null;
@@ -2185,7 +2403,7 @@ function resolveDuration(d, dir) {
2185
2403
  }
2186
2404
  function validateSlot(value) {
2187
2405
  if (value == null || value === false) return null;
2188
- if (Array.isArray(value)) {
2406
+ if (isArray(value)) {
2189
2407
  {
2190
2408
  throw new Error(
2191
2409
  "[essor] <Transition> expects a single root child. Use <TransitionGroup> for multiple children."
@@ -2231,8 +2449,26 @@ function Transition(props) {
2231
2449
  let hasPending = false;
2232
2450
  let scheduled = false;
2233
2451
  let disposed = false;
2452
+ let cancelEnterWait = null;
2453
+ let cancelLeaveWait = null;
2454
+ const stopEnterWait = () => {
2455
+ cancelEnterWait == null ? void 0 : cancelEnterWait();
2456
+ cancelEnterWait = null;
2457
+ };
2458
+ const stopLeaveWait = () => {
2459
+ cancelLeaveWait == null ? void 0 : cancelLeaveWait();
2460
+ cancelLeaveWait = null;
2461
+ };
2234
2462
  const enter = (el, phase) => {
2235
2463
  var _a2;
2464
+ stopEnterWait();
2465
+ let cancelWait = null;
2466
+ const stopWait = () => {
2467
+ cancelWait == null ? void 0 : cancelWait();
2468
+ cancelWait = null;
2469
+ if (cancelEnterWait === stopWait) cancelEnterWait = null;
2470
+ };
2471
+ cancelEnterWait = stopWait;
2236
2472
  const prevLeave = el[LEAVE_CB];
2237
2473
  if (prevLeave) prevLeave(true);
2238
2474
  state = "entering";
@@ -2249,6 +2485,7 @@ function Transition(props) {
2249
2485
  var _a3, _b;
2250
2486
  if (called) return;
2251
2487
  called = true;
2488
+ stopWait();
2252
2489
  el[ENTER_CB] = void 0;
2253
2490
  if (useCss) {
2254
2491
  removeClass(el, fromCls);
@@ -2263,7 +2500,8 @@ function Transition(props) {
2263
2500
  }
2264
2501
  };
2265
2502
  el[ENTER_CB] = done;
2266
- nextFrame(() => {
2503
+ cancelWait = nextFrameCancellable(() => {
2504
+ cancelWait = null;
2267
2505
  if (called) return;
2268
2506
  if (useCss) {
2269
2507
  removeClass(el, fromCls);
@@ -2273,7 +2511,10 @@ function Transition(props) {
2273
2511
  props.onEnter(el, () => done(false));
2274
2512
  } else if (useCss) {
2275
2513
  const explicit = resolveDuration(props.duration, "enter");
2276
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2514
+ cancelWait = whenTransitionEnds(el, props.type, explicit, () => {
2515
+ cancelWait = null;
2516
+ done(false);
2517
+ });
2277
2518
  } else {
2278
2519
  done(false);
2279
2520
  }
@@ -2281,6 +2522,14 @@ function Transition(props) {
2281
2522
  };
2282
2523
  const leave = (el, after) => {
2283
2524
  var _a2;
2525
+ stopLeaveWait();
2526
+ let cancelWait = null;
2527
+ const stopWait = () => {
2528
+ cancelWait == null ? void 0 : cancelWait();
2529
+ cancelWait = null;
2530
+ if (cancelLeaveWait === stopWait) cancelLeaveWait = null;
2531
+ };
2532
+ cancelLeaveWait = stopWait;
2284
2533
  const prevEnter = el[ENTER_CB];
2285
2534
  if (prevEnter) {
2286
2535
  prevEnter(true);
@@ -2297,6 +2546,7 @@ function Transition(props) {
2297
2546
  var _a3, _b;
2298
2547
  if (called) return;
2299
2548
  called = true;
2549
+ stopWait();
2300
2550
  el[LEAVE_CB] = void 0;
2301
2551
  if (useCss) {
2302
2552
  removeClass(el, classes.leaveFrom);
@@ -2318,7 +2568,8 @@ function Transition(props) {
2318
2568
  done(false);
2319
2569
  return;
2320
2570
  }
2321
- nextFrame(() => {
2571
+ cancelWait = nextFrameCancellable(() => {
2572
+ cancelWait = null;
2322
2573
  if (called) return;
2323
2574
  if (useCss) {
2324
2575
  removeClass(el, classes.leaveFrom);
@@ -2327,7 +2578,10 @@ function Transition(props) {
2327
2578
  if (props.onLeave) {
2328
2579
  props.onLeave(el, () => done(false));
2329
2580
  } else if (useCss) {
2330
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2581
+ cancelWait = whenTransitionEnds(el, props.type, explicit, () => {
2582
+ cancelWait = null;
2583
+ done(false);
2584
+ });
2331
2585
  } else {
2332
2586
  done(false);
2333
2587
  }
@@ -2402,6 +2656,8 @@ function Transition(props) {
2402
2656
  });
2403
2657
  onCleanup(() => {
2404
2658
  disposed = true;
2659
+ stopEnterWait();
2660
+ stopLeaveWait();
2405
2661
  effectRunner.stop();
2406
2662
  for (const el of [currentEl, leavingEl]) {
2407
2663
  if (!el) continue;
@@ -2423,7 +2679,7 @@ function isTransition(node) {
2423
2679
  }
2424
2680
  function resolveItemElement(raw, parent) {
2425
2681
  if (raw == null || raw === false) return { el: null, comp: null };
2426
- if (Array.isArray(raw) && raw.length === 1) {
2682
+ if (isArray(raw) && raw.length === 1) {
2427
2683
  return resolveItemElement(raw[0], parent);
2428
2684
  }
2429
2685
  if (isFunction(raw)) {
@@ -2478,7 +2734,7 @@ function TransitionGroup(props) {
2478
2734
  const moveClass = (_c = props.moveClass) != null ? _c : `${(_b = props.name) != null ? _b : "v"}-move`;
2479
2735
  const keyFn = props.key;
2480
2736
  const rawChildren = props.children;
2481
- const childrenFn = Array.isArray(rawChildren) && rawChildren.length === 1 && isFunction(rawChildren[0]) ? rawChildren[0] : props.children;
2737
+ const childrenFn = isArray(rawChildren) && rawChildren.length === 1 && isFunction(rawChildren[0]) ? rawChildren[0] : props.children;
2482
2738
  if (!isFunction(childrenFn) || !isFunction(keyFn)) {
2483
2739
  throw new TypeError(
2484
2740
  "<TransitionGroup> requires `children: (item, index) => Node` and `key: (item, index) => unknown`"
@@ -2529,9 +2785,12 @@ function TransitionGroup(props) {
2529
2785
  if (entry.el.parentNode === wrapper) wrapper.removeChild(entry.el);
2530
2786
  };
2531
2787
  const disposeEntry = (entry) => {
2532
- var _a3, _b2;
2788
+ var _a3, _b2, _c2, _d, _e;
2533
2789
  (_a3 = entry.cancelEnter) == null ? void 0 : _a3.call(entry, true);
2534
2790
  (_b2 = entry.cancelLeave) == null ? void 0 : _b2.call(entry, true);
2791
+ (_c2 = entry.cancelEnterWait) == null ? void 0 : _c2.call(entry);
2792
+ (_d = entry.cancelLeaveWait) == null ? void 0 : _d.call(entry);
2793
+ (_e = entry.cancelMoveWait) == null ? void 0 : _e.call(entry);
2535
2794
  if (entry.comp) entry.comp.destroy();
2536
2795
  detachEntryDom(entry);
2537
2796
  disposeScope(entry.scope);
@@ -2550,23 +2809,26 @@ function TransitionGroup(props) {
2550
2809
  addClass(el, classes.enterActive);
2551
2810
  let called = false;
2552
2811
  const done = (cancelled) => {
2553
- var _a4, _b3;
2812
+ var _a4, _b3, _c3;
2554
2813
  if (called) return;
2555
2814
  called = true;
2556
2815
  entry.cancelEnter = void 0;
2816
+ (_a4 = entry.cancelEnterWait) == null ? void 0 : _a4.call(entry);
2817
+ entry.cancelEnterWait = void 0;
2557
2818
  removeClass(el, classes.enterFrom);
2558
2819
  removeClass(el, classes.enterActive);
2559
2820
  removeClass(el, classes.enterTo);
2560
2821
  if (cancelled) {
2561
- (_a4 = props.onEnterCancelled) == null ? void 0 : _a4.call(props, el);
2822
+ (_b3 = props.onEnterCancelled) == null ? void 0 : _b3.call(props, el);
2562
2823
  } else {
2563
2824
  entry.state = "present";
2564
- (_b3 = props.onAfterEnter) == null ? void 0 : _b3.call(props, el);
2825
+ (_c3 = props.onAfterEnter) == null ? void 0 : _c3.call(props, el);
2565
2826
  }
2566
2827
  };
2567
2828
  entry.cancelEnter = done;
2568
2829
  entry.state = "entering";
2569
- nextFrame(() => {
2830
+ entry.cancelEnterWait = nextFrameCancellable(() => {
2831
+ entry.cancelEnterWait = void 0;
2570
2832
  if (called) return;
2571
2833
  removeClass(el, classes.enterFrom);
2572
2834
  addClass(el, classes.enterTo);
@@ -2574,7 +2836,10 @@ function TransitionGroup(props) {
2574
2836
  props.onEnter(el, () => done(false));
2575
2837
  } else {
2576
2838
  const explicit = resolveDuration(props.duration, "enter");
2577
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2839
+ entry.cancelEnterWait = whenTransitionEnds(el, props.type, explicit, () => {
2840
+ entry.cancelEnterWait = void 0;
2841
+ done(false);
2842
+ });
2578
2843
  }
2579
2844
  });
2580
2845
  };
@@ -2606,17 +2871,19 @@ function TransitionGroup(props) {
2606
2871
  addClass(el, classes.leaveActive);
2607
2872
  let called = false;
2608
2873
  const done = (cancelled) => {
2609
- var _a4, _b3;
2874
+ var _a4, _b3, _c2;
2610
2875
  if (called) return;
2611
2876
  called = true;
2612
2877
  entry.cancelLeave = void 0;
2878
+ (_a4 = entry.cancelLeaveWait) == null ? void 0 : _a4.call(entry);
2879
+ entry.cancelLeaveWait = void 0;
2613
2880
  removeClass(el, classes.leaveFrom);
2614
2881
  removeClass(el, classes.leaveActive);
2615
2882
  removeClass(el, classes.leaveTo);
2616
2883
  if (cancelled) {
2617
2884
  if (entry.savedStyles) restoreStyles(el, entry.savedStyles);
2618
2885
  entry.savedStyles = void 0;
2619
- (_a4 = props.onLeaveCancelled) == null ? void 0 : _a4.call(props, el);
2886
+ (_b3 = props.onLeaveCancelled) == null ? void 0 : _b3.call(props, el);
2620
2887
  return;
2621
2888
  }
2622
2889
  if (entry.savedStyles) restoreStyles(el, entry.savedStyles);
@@ -2624,10 +2891,11 @@ function TransitionGroup(props) {
2624
2891
  detachEntryDom(entry);
2625
2892
  disposeScope(entry.scope);
2626
2893
  if (entry.comp) entry.comp.destroy();
2627
- (_b3 = props.onAfterLeave) == null ? void 0 : _b3.call(props, el);
2894
+ (_c2 = props.onAfterLeave) == null ? void 0 : _c2.call(props, el);
2628
2895
  };
2629
2896
  entry.cancelLeave = done;
2630
- nextFrame(() => {
2897
+ entry.cancelLeaveWait = nextFrameCancellable(() => {
2898
+ entry.cancelLeaveWait = void 0;
2631
2899
  if (called) return;
2632
2900
  removeClass(el, classes.leaveFrom);
2633
2901
  addClass(el, classes.leaveTo);
@@ -2635,11 +2903,15 @@ function TransitionGroup(props) {
2635
2903
  props.onLeave(el, () => done(false));
2636
2904
  } else {
2637
2905
  const explicit = resolveDuration(props.duration, "leave");
2638
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2906
+ entry.cancelLeaveWait = whenTransitionEnds(el, props.type, explicit, () => {
2907
+ entry.cancelLeaveWait = void 0;
2908
+ done(false);
2909
+ });
2639
2910
  }
2640
2911
  });
2641
2912
  };
2642
2913
  const runMove = (entry, prevRect) => {
2914
+ var _a3;
2643
2915
  if (!useCss || entry.state !== "present") return;
2644
2916
  const el = entry.el;
2645
2917
  const newRect = el.getBoundingClientRect();
@@ -2655,7 +2927,9 @@ function TransitionGroup(props) {
2655
2927
  el.style.transform = savedTransform;
2656
2928
  el.style.transitionDuration = savedTransition;
2657
2929
  const explicit = resolveDuration(props.duration, "enter");
2658
- whenTransitionEnds(el, props.type, explicit, () => {
2930
+ (_a3 = entry.cancelMoveWait) == null ? void 0 : _a3.call(entry);
2931
+ entry.cancelMoveWait = whenTransitionEnds(el, props.type, explicit, () => {
2932
+ entry.cancelMoveWait = void 0;
2659
2933
  removeClass(el, moveClass);
2660
2934
  });
2661
2935
  };