@estjs/template 0.0.17-beta.6 → 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
  };
@@ -969,17 +1014,18 @@ function triggerUpdateHooks(scope) {
969
1014
 
970
1015
  // src/component.ts
971
1016
  function syncDescriptors(target, source, pruneMissing = false) {
972
- for (const key of Object.getOwnPropertyNames(source)) {
1017
+ const sourceKeys = Reflect.ownKeys(source);
1018
+ for (const key of sourceKeys) {
973
1019
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
974
1020
  }
975
1021
  if (pruneMissing) {
976
- const sourceKeySet = new Set(Object.getOwnPropertyNames(source));
977
- for (const key of Object.getOwnPropertyNames(target)) {
1022
+ const sourceKeySet = new Set(sourceKeys);
1023
+ for (const key of Reflect.ownKeys(target)) {
978
1024
  if (!sourceKeySet.has(key)) delete target[key];
979
1025
  }
980
1026
  }
981
1027
  }
982
- function readProp(source, key) {
1028
+ function readDescriptorValue(source, key) {
983
1029
  const descriptor = Object.getOwnPropertyDescriptor(source, key);
984
1030
  return descriptor.get ? descriptor.get.call(source) : descriptor.value;
985
1031
  }
@@ -998,9 +1044,9 @@ var Component = class {
998
1044
  this.parentNode = void 0;
999
1045
  this.rootEventCleanups = [];
1000
1046
  this.parentScope = getActiveScope();
1001
- const container = {};
1002
- syncDescriptors(container, props);
1003
- this.reactiveProps = signals.shallowReactive(container);
1047
+ const reactiveProps = /* @__PURE__ */ Object.create(null);
1048
+ syncDescriptors(reactiveProps, props);
1049
+ this.reactiveProps = signals.shallowReactive(reactiveProps);
1004
1050
  }
1005
1051
  /**
1006
1052
  * Mount the component into `parentNode` (optionally before `beforeNode`).
@@ -1048,14 +1094,14 @@ var Component = class {
1048
1094
  */
1049
1095
  update(props) {
1050
1096
  this.props = props;
1051
- const scope = this.scope;
1052
- if (!scope || scope.isDestroyed) return;
1053
1097
  syncDescriptors(
1054
1098
  this.reactiveProps,
1055
1099
  props != null ? props : {},
1056
1100
  /* pruneMissing */
1057
1101
  true
1058
1102
  );
1103
+ const scope = this.scope;
1104
+ if (!scope || scope.isDestroyed) return;
1059
1105
  this.syncSpecialProps(props);
1060
1106
  triggerUpdateHooks(scope);
1061
1107
  }
@@ -1067,7 +1113,10 @@ var Component = class {
1067
1113
  if (!this.parentNode) return;
1068
1114
  const parent = this.parentNode;
1069
1115
  const before = this.beforeNode;
1116
+ const savedProps = /* @__PURE__ */ Object.create(null);
1117
+ syncDescriptors(savedProps, this.reactiveProps);
1070
1118
  this.destroy();
1119
+ syncDescriptors(this.reactiveProps, savedProps);
1071
1120
  this.mount(parent, before);
1072
1121
  }
1073
1122
  /**
@@ -1084,7 +1133,7 @@ var Component = class {
1084
1133
  this.renderedNodes = [];
1085
1134
  this.firstChild = void 0;
1086
1135
  this.parentNode = void 0;
1087
- for (const key of Object.getOwnPropertyNames(this.reactiveProps)) {
1136
+ for (const key of Reflect.ownKeys(this.reactiveProps)) {
1088
1137
  delete this.reactiveProps[key];
1089
1138
  }
1090
1139
  this.state = 0 /* INITIAL */;
@@ -1097,38 +1146,51 @@ var Component = class {
1097
1146
  */
1098
1147
  syncSpecialProps(props) {
1099
1148
  if (!props) return;
1100
- const root = this.firstChild;
1101
- if (!root || !(root instanceof Element)) return;
1149
+ const roots = this.getRootElements();
1150
+ if (roots.length === 0) return;
1151
+ const refRoot = roots[0];
1102
1152
  this.releaseSpecialProps();
1103
- for (const key of Object.getOwnPropertyNames(props)) {
1153
+ for (const key of Reflect.ownKeys(props)) {
1154
+ if (!shared.isString(key)) continue;
1104
1155
  if (key === REF_KEY) {
1105
- const value = readProp(props, key);
1106
- this.rootRefCleanup = this.bindRootRef(value, root);
1156
+ const value = readDescriptorValue(props, key);
1157
+ this.rootRefCleanup = this.bindRootRef(value, refRoot);
1107
1158
  continue;
1108
1159
  }
1109
1160
  if (shared.isOn(key)) {
1110
- const value = readProp(props, key);
1161
+ const value = readDescriptorValue(props, key);
1111
1162
  if (!shared.isFunction(value)) continue;
1112
1163
  const eventName = key.slice(2).toLowerCase();
1113
- const target = root;
1114
- const slot = `_$${eventName}`;
1115
- const prev = target[slot];
1116
- if (shared.isFunction(prev)) {
1117
- target[slot] = value;
1118
- this.rootEventCleanups.push(() => {
1119
- if (target[slot] === value) target[slot] = prev;
1120
- });
1121
- continue;
1164
+ for (const root of roots) {
1165
+ this.bindRootEvent(root, eventName, value);
1122
1166
  }
1123
- const fn = value;
1124
- const handler = (event) => {
1125
- if (target.disabled) return;
1126
- fn.call(target, event);
1127
- };
1128
- this.rootEventCleanups.push(addEvent(target, eventName, handler));
1129
1167
  }
1130
1168
  }
1131
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
+ }
1177
+ bindRootEvent(target, eventName, handler) {
1178
+ const slot = `_$${eventName}`;
1179
+ const prev = target[slot];
1180
+ if (shared.isFunction(prev)) {
1181
+ target[slot] = handler;
1182
+ this.rootEventCleanups.push(() => {
1183
+ if (target[slot] === handler) target[slot] = prev;
1184
+ });
1185
+ return;
1186
+ }
1187
+ this.rootEventCleanups.push(
1188
+ addEvent(target, eventName, (event) => {
1189
+ if (target.disabled) return;
1190
+ handler.call(target, event);
1191
+ })
1192
+ );
1193
+ }
1132
1194
  /**
1133
1195
  * Remove all listeners/ref bindings currently attached to the root element.
1134
1196
  */
@@ -1319,7 +1381,9 @@ function eventHandler(e) {
1319
1381
  return true;
1320
1382
  };
1321
1383
  const walkUpTree = () => {
1322
- 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
+ }
1323
1387
  };
1324
1388
  Object.defineProperty(e, "currentTarget", {
1325
1389
  configurable: true,
@@ -1330,26 +1394,30 @@ function eventHandler(e) {
1330
1394
  return node || document;
1331
1395
  }
1332
1396
  });
1333
- if (e.composedPath) {
1334
- const path = e.composedPath();
1335
- reTargetEvent(e, path[0]);
1336
- for (let i = 0; i < path.length - 2; i++) {
1337
- node = path[i];
1338
- if (!handleNode()) break;
1339
- if (node._$host) {
1340
- node = node._$host;
1341
- walkUpTree();
1342
- break;
1343
- }
1344
- if (node.parentNode === oriCurrentTarget) {
1345
- 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
+ }
1346
1412
  }
1347
- }
1348
- } else walkUpTree();
1349
- reTargetEvent(e, oriTarget);
1413
+ } else walkUpTree();
1414
+ } finally {
1415
+ reTargetEvent(e, oriTarget);
1416
+ }
1350
1417
  }
1351
1418
  var $EVENTS = /* @__PURE__ */ Symbol("_$EVENTS");
1352
1419
  function delegateEvents(eventNames, document2 = globalThis.document) {
1420
+ if (!document2) return;
1353
1421
  const docWithEvents = document2;
1354
1422
  const eventSet = docWithEvents[$EVENTS] || (docWithEvents[$EVENTS] = /* @__PURE__ */ new Set());
1355
1423
  for (const name of eventNames) {
@@ -1360,6 +1428,7 @@ function delegateEvents(eventNames, document2 = globalThis.document) {
1360
1428
  }
1361
1429
  }
1362
1430
  function clearDelegatedEvents(document2 = globalThis.document) {
1431
+ if (!document2) return;
1363
1432
  const docWithEvents = document2;
1364
1433
  const eventSet = docWithEvents[$EVENTS];
1365
1434
  if (eventSet) {
@@ -1382,6 +1451,7 @@ var EMPTY_FILES = (() => {
1382
1451
  if (typeof DataTransfer !== "undefined") return new DataTransfer().files;
1383
1452
  return [];
1384
1453
  })();
1454
+ var checkboxArraySnapshots = /* @__PURE__ */ new WeakMap();
1385
1455
  function writeValue(el, v) {
1386
1456
  const target = el;
1387
1457
  const next2 = v == null ? "" : String(v);
@@ -1498,11 +1568,16 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1498
1568
  const getModel = shared.isFunction(getter) ? getter : () => getter;
1499
1569
  const cast = shouldCast ? (v) => applyModifiers(v, trim, toNum) : IDENTITY;
1500
1570
  const computeNext = checkboxArray ? (raw) => {
1571
+ var _a2;
1501
1572
  const current = getModel();
1502
- if (!shared.isArray(current)) return cast(raw);
1573
+ if (!shared.isArray(current)) {
1574
+ return cast(raw);
1575
+ }
1503
1576
  const own = node.value;
1504
- 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);
1505
1579
  if (raw) next2.push(own);
1580
+ checkboxArraySnapshots.set(current, next2);
1506
1581
  return next2;
1507
1582
  } : cast;
1508
1583
  let composing = false;
@@ -1529,6 +1604,9 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1529
1604
  }
1530
1605
  const runner = signals.effect(() => {
1531
1606
  const value = getModel();
1607
+ if (checkboxArray) {
1608
+ if (shared.isArray(value)) checkboxArraySnapshots.set(value, [...value]);
1609
+ }
1532
1610
  if (ime && composing) return;
1533
1611
  if (ime && !lazy && isFocused(node) && Object.is(cast(read(node)), value)) return;
1534
1612
  write(node, value);
@@ -1539,7 +1617,7 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
1539
1617
  }
1540
1618
  function unwrapSlotValue(raw) {
1541
1619
  let v = raw;
1542
- if (Array.isArray(v) && v.length === 1) v = v[0];
1620
+ if (shared.isArray(v) && v.length === 1) v = v[0];
1543
1621
  return shared.isFunction(v) ? v() : v;
1544
1622
  }
1545
1623
  function useChildren(props) {
@@ -1620,7 +1698,9 @@ function Portal(props) {
1620
1698
  if (children == null) return placeholder;
1621
1699
  const parentScope = getActiveScope();
1622
1700
  let innerScope = null;
1701
+ let disposed = false;
1623
1702
  const mountAt = (parent, before) => {
1703
+ if (disposed || (parentScope == null ? void 0 : parentScope.isDestroyed)) return;
1624
1704
  innerScope = createScope(parentScope);
1625
1705
  runWithScope(innerScope, () => {
1626
1706
  insert(parent, () => children, before);
@@ -1633,6 +1713,7 @@ function Portal(props) {
1633
1713
  }
1634
1714
  };
1635
1715
  const apply = (disabled, target) => {
1716
+ if (disposed) return;
1636
1717
  teardown();
1637
1718
  if (disabled) {
1638
1719
  const parent = placeholder.parentNode;
@@ -1665,11 +1746,13 @@ function Portal(props) {
1665
1746
  return;
1666
1747
  }
1667
1748
  queueMicrotask(() => {
1749
+ if (disposed) return;
1668
1750
  if (!placeholder.parentNode) return;
1669
1751
  apply(evalDisabled(props), resolveTarget(props));
1670
1752
  });
1671
1753
  });
1672
1754
  onCleanup(() => {
1755
+ disposed = true;
1673
1756
  effectRunner.stop();
1674
1757
  teardown();
1675
1758
  });
@@ -1715,12 +1798,15 @@ function resolveNodeValue(value) {
1715
1798
  if (signals.isSignal(current) || signals.isComputed(current)) {
1716
1799
  return resolveNodeValue(current.value);
1717
1800
  }
1718
- if (Array.isArray(current)) {
1801
+ if (shared.isArray(current)) {
1719
1802
  return current.map((item) => resolveNodeValue(item));
1720
1803
  }
1721
1804
  return current;
1722
1805
  }
1723
1806
  var SuspenseContext = /* @__PURE__ */ Symbol("SuspenseContext");
1807
+ function isAbortError(error5) {
1808
+ return !!error5 && typeof error5 === "object" && error5.name === "AbortError";
1809
+ }
1724
1810
  function Suspense(props) {
1725
1811
  var _a2;
1726
1812
  if (!shared.isBrowser()) {
@@ -1734,10 +1820,14 @@ function Suspense(props) {
1734
1820
  let mounted = true;
1735
1821
  let pending = 0;
1736
1822
  let mounting = false;
1823
+ let boundaryVersion = 0;
1824
+ let currentChildren = null;
1737
1825
  let contentScope = null;
1738
1826
  let parked = null;
1739
1827
  let fallbackScope = null;
1740
1828
  let resolved = null;
1829
+ let hasResolved = false;
1830
+ let manualReleases = [];
1741
1831
  const parkContent = () => {
1742
1832
  const off = document.createDocumentFragment();
1743
1833
  while (end.previousSibling && end.previousSibling !== start) {
@@ -1767,14 +1857,35 @@ function Suspense(props) {
1767
1857
  disposeScope(fallbackScope);
1768
1858
  fallbackScope = null;
1769
1859
  };
1770
- 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);
1771
1872
  mounting = true;
1772
- contentScope = createScope(owner);
1773
- runWithScope(contentScope, () => {
1774
- var _a3;
1775
- insert((_a3 = end.parentNode) != null ? _a3 : frag, () => resolveNodeValue(children2), end);
1776
- });
1777
- 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
+ }
1778
1889
  if (pending && !parked) {
1779
1890
  parkContent();
1780
1891
  mountFallback();
@@ -1788,53 +1899,89 @@ function Suspense(props) {
1788
1899
  };
1789
1900
  const showContent = () => {
1790
1901
  if (!parked) return;
1791
- const hasSyncChildren = props.children != null && !shared.isPromise(props.children);
1792
- if (contentScope == null && resolved == null && !hasSyncChildren) return;
1902
+ const hasSyncChildren = currentChildren != null && !shared.isPromise(currentChildren);
1903
+ if (contentScope == null && !hasResolved && !hasSyncChildren) return;
1793
1904
  disposeFallback();
1794
1905
  restoreContent();
1795
1906
  if (!contentScope) {
1796
- if (resolved) {
1907
+ if (hasResolved) {
1797
1908
  mountContent(resolved);
1798
1909
  } else if (hasSyncChildren) {
1799
- mountContent(props.children);
1910
+ mountContent(currentChildren);
1800
1911
  }
1801
1912
  }
1802
1913
  };
1803
- 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) => {
1804
1927
  if (!mounted) return;
1805
- 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;
1806
1936
  };
1807
1937
  const ctx = {
1808
1938
  register: (promise) => {
1809
- pending++;
1810
- showFallback();
1811
- promise.then(settle).catch((error5) => {
1812
- shared.warn("[Suspense] Resource failed:", error5);
1813
- settle();
1814
- });
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;
1815
1948
  },
1816
1949
  increment: () => {
1817
- pending++;
1818
- showFallback();
1950
+ const release = addPending();
1951
+ manualReleases.push(release);
1952
+ return release;
1819
1953
  },
1820
1954
  decrement: () => {
1821
- pending = Math.max(0, pending - 1);
1822
- if (pending === 0) showContent();
1955
+ const release = dequeueManualRelease();
1956
+ if (release) settle(release);
1823
1957
  }
1824
1958
  };
1825
1959
  provide(SuspenseContext, ctx);
1826
- const children = props.children;
1827
- if (shared.isPromise(children)) {
1828
- children.then((value) => {
1829
- resolved = value;
1830
- }).catch(() => {
1831
- });
1832
- ctx.register(children);
1833
- } else if (children != null) {
1834
- mountContent(children);
1835
- } else if (props.fallback != null) {
1836
- showFallback();
1837
- }
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));
1838
1985
  onCleanup(() => {
1839
1986
  mounted = false;
1840
1987
  pending = 0;
@@ -1852,6 +1999,9 @@ Suspense[SUSPENSE_COMPONENT] = true;
1852
1999
  function isSuspense(node) {
1853
2000
  return !!node && !!node[SUSPENSE_COMPONENT];
1854
2001
  }
2002
+ function isAbortError2(error5) {
2003
+ return !!error5 && typeof error5 === "object" && error5.name === "AbortError";
2004
+ }
1855
2005
  function createResource(fetcher, options) {
1856
2006
  const value = signals.signal(options == null ? void 0 : options.initialValue);
1857
2007
  const loading = signals.signal(true);
@@ -1886,7 +2036,7 @@ function createResource(fetcher, options) {
1886
2036
  }
1887
2037
  } catch (error_) {
1888
2038
  if (id !== fetchId) return;
1889
- if (error_ instanceof DOMException && error_.name === "AbortError") {
2039
+ if (isAbortError2(error_)) {
1890
2040
  loading.value = false;
1891
2041
  return;
1892
2042
  }
@@ -1941,17 +2091,26 @@ function defineServerAsyncComponent(loader, ssr) {
1941
2091
  function defineClientAsyncComponent(loader, options) {
1942
2092
  const { loading, error: errorComp, delay = 200, timeout, onError } = options;
1943
2093
  let component = null;
1944
- let error5 = null;
2094
+ let loadError = null;
1945
2095
  let status = "pending";
1946
2096
  let loadPromise = null;
1947
- const load = () => loadPromise != null ? loadPromise : loadPromise = loader().then((mod) => {
1948
- component = resolveModule(mod);
1949
- status = "resolved";
1950
- }).catch((error_) => {
1951
- error5 = error_ instanceof Error ? error_ : new Error(String(error_));
1952
- status = "errored";
1953
- loadPromise = null;
1954
- });
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
+ };
1955
2114
  load();
1956
2115
  function AsyncWrapper(props) {
1957
2116
  var _a2;
@@ -1963,6 +2122,7 @@ function defineClientAsyncComponent(loader, options) {
1963
2122
  let viewScope = null;
1964
2123
  let delayTimer = null;
1965
2124
  let timeoutTimer = null;
2125
+ let instanceRetryId = 0;
1966
2126
  const clearTimers = () => {
1967
2127
  if (delayTimer != null) clearTimeout(delayTimer);
1968
2128
  if (timeoutTimer != null) clearTimeout(timeoutTimer);
@@ -1992,28 +2152,34 @@ function defineClientAsyncComponent(loader, options) {
1992
2152
  end.remove();
1993
2153
  });
1994
2154
  const retryWith = (retryProps) => () => {
2155
+ if (!alive) return;
2156
+ const retryLoadId = ++loadId;
1995
2157
  loadPromise = null;
1996
2158
  status = "pending";
1997
- error5 = null;
2159
+ loadError = null;
2160
+ instanceRetryId++;
2161
+ const capturedRetry = instanceRetryId;
1998
2162
  if (loading) render(loading);
1999
- load().then(() => settle(retryProps));
2163
+ load(retryLoadId).then(() => {
2164
+ if (alive && capturedRetry === instanceRetryId) settle(retryProps);
2165
+ });
2000
2166
  };
2001
2167
  const settle = (renderProps) => {
2002
2168
  if (!alive) return;
2003
2169
  clearTimers();
2004
2170
  if (status === "resolved" && component) {
2005
2171
  render(component, renderProps);
2006
- } else if (status === "errored" && error5) {
2007
- if (errorComp) render(errorComp, { error: error5, retry: retryWith(renderProps) });
2008
- 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));
2009
2175
  }
2010
2176
  };
2011
2177
  if (status === "resolved" && component) {
2012
2178
  render(component, props);
2013
2179
  return frag;
2014
2180
  }
2015
- if (status === "errored" && error5) {
2016
- if (errorComp) render(errorComp, { error: error5, retry: retryWith(props) });
2181
+ if (status === "errored" && loadError) {
2182
+ if (errorComp) render(errorComp, { error: loadError, retry: retryWith(props) });
2017
2183
  return frag;
2018
2184
  }
2019
2185
  const pending = load().then(() => settle(props));
@@ -2028,10 +2194,9 @@ function defineClientAsyncComponent(loader, options) {
2028
2194
  if (timeout != null) {
2029
2195
  timeoutTimer = setTimeout(() => {
2030
2196
  if (!alive || status !== "pending") return;
2031
- error5 = new Error(`[defineAsyncComponent] Timeout after ${timeout}ms`);
2032
- status = "errored";
2033
- if (errorComp) render(errorComp, { error: error5, retry: retryWith(props) });
2034
- 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));
2035
2200
  }, timeout);
2036
2201
  }
2037
2202
  return frag;
@@ -2050,9 +2215,11 @@ function For(props) {
2050
2215
  fragment.appendChild(marker);
2051
2216
  let entries = [];
2052
2217
  let fallbackNodes = [];
2218
+ let fallbackScope = null;
2219
+ const ownerScope = getActiveScope();
2053
2220
  const keyFn = props.key;
2054
2221
  const raw = props.children;
2055
- 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;
2056
2223
  if (!shared.isFunction(renderFn)) {
2057
2224
  throw new TypeError("<For> requires `children` to be a function (item, index) => Node");
2058
2225
  }
@@ -2064,9 +2231,31 @@ function For(props) {
2064
2231
  return input != null ? input : [];
2065
2232
  };
2066
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
+ };
2067
2256
  const mountValue = (value, parent, before) => {
2068
2257
  if (value == null || value === false) return [];
2069
- if (Array.isArray(value)) {
2258
+ if (shared.isArray(value)) {
2070
2259
  const nodes = [];
2071
2260
  for (const child2 of value) nodes.push(...mountValue(child2, parent, before));
2072
2261
  return nodes;
@@ -2080,17 +2269,30 @@ function For(props) {
2080
2269
  return [node];
2081
2270
  };
2082
2271
  const mountFallback = (parent, before) => {
2272
+ var _a2;
2083
2273
  if (!props.fallback) return;
2084
- const nodes = mountValue(props.fallback(), parent, before);
2085
- 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
+ }
2086
2285
  };
2087
2286
  const clearFallback = () => {
2287
+ if (fallbackScope) {
2288
+ disposeScope(fallbackScope);
2289
+ fallbackScope = null;
2290
+ }
2088
2291
  for (const node of fallbackNodes) {
2089
2292
  removeNode(node);
2090
2293
  }
2091
2294
  fallbackNodes = [];
2092
2295
  };
2093
- const ownerScope = getActiveScope();
2094
2296
  const renderItem = (item, index, parent, before, key = getKey(item, index)) => {
2095
2297
  var _a2;
2096
2298
  const parentScope = (_a2 = getActiveScope()) != null ? _a2 : ownerScope;
@@ -2122,10 +2324,9 @@ function For(props) {
2122
2324
  mountFallback(fragment, marker);
2123
2325
  } else {
2124
2326
  entries = new Array(newItems.length);
2125
- let idx = 0;
2126
- for (const newItem of newItems) {
2127
- entries[idx] = renderItem(newItem, idx, fragment, marker);
2128
- idx++;
2327
+ const newKeys = getKeys(newItems);
2328
+ for (const [i, newItem] of newItems.entries()) {
2329
+ entries[i] = renderItem(newItem, i, fragment, marker, newKeys[i]);
2129
2330
  }
2130
2331
  }
2131
2332
  return;
@@ -2151,10 +2352,13 @@ function For(props) {
2151
2352
  }
2152
2353
  entries = new Array(newLen);
2153
2354
  const batchFragment2 = document.createDocumentFragment();
2355
+ const newKeys2 = getKeys(newItems);
2154
2356
  for (let i = 0; i < newLen; i++) {
2155
- entries[i] = renderItem(newItems[i], i, batchFragment2, null);
2357
+ entries[i] = renderItem(newItems[i], i, batchFragment2, null, newKeys2[i]);
2156
2358
  }
2157
- parent.insertBefore(batchFragment2, marker);
2359
+ signals.untrack(() => {
2360
+ parent.insertBefore(batchFragment2, marker);
2361
+ });
2158
2362
  return;
2159
2363
  }
2160
2364
  const oldKeyMap = /* @__PURE__ */ new Map();
@@ -2171,10 +2375,7 @@ function For(props) {
2171
2375
  const newIndexToOldIndex = new Int32Array(newLen);
2172
2376
  let moved = false;
2173
2377
  let maxOldSeen = 0;
2174
- const newKeys = new Array(newLen);
2175
- for (let i = 0; i < newLen; i++) {
2176
- newKeys[i] = getKey(newItems[i], i);
2177
- }
2378
+ const newKeys = getKeys(newItems);
2178
2379
  for (let i = 0; i < newLen; i++) {
2179
2380
  const item = newItems[i];
2180
2381
  const key = newKeys[i];
@@ -2189,7 +2390,7 @@ function For(props) {
2189
2390
  else maxOldSeen = oldIndex;
2190
2391
  } else {
2191
2392
  if (!batchFragment) batchFragment = document.createDocumentFragment();
2192
- disposeItem(reused);
2393
+ signals.untrack(() => disposeItem(reused));
2193
2394
  newEntries[i] = renderItem(item, i, batchFragment, null, key);
2194
2395
  }
2195
2396
  } else {
@@ -2200,28 +2401,30 @@ function For(props) {
2200
2401
  for (const list of oldKeyMap.values()) {
2201
2402
  for (const [entry] of list) toRemove.push(entry);
2202
2403
  }
2203
- for (const entry of toRemove) disposeItem(entry);
2204
- const lis = moved ? getSequence(newIndexToOldIndex) : [];
2205
- let lisCursor = lis.length - 1;
2206
- let nextNode = marker;
2207
- for (let i = newLen - 1; i >= 0; i--) {
2208
- const entry = newEntries[i];
2209
- const nodes = entry.nodes;
2210
- const isFresh = newIndexToOldIndex[i] === 0;
2211
- const inLis = !isFresh && moved && lisCursor >= 0 && i === lis[lisCursor];
2212
- if (inLis) {
2213
- lisCursor--;
2214
- for (let j = nodes.length - 1; j >= 0; j--) nextNode = nodes[j];
2215
- continue;
2216
- }
2217
- for (let j = nodes.length - 1; j >= 0; j--) {
2218
- const node = nodes[j];
2219
- if (node.nextSibling !== nextNode) {
2220
- 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;
2221
2425
  }
2222
- nextNode = node;
2223
2426
  }
2224
- }
2427
+ });
2225
2428
  entries = newEntries;
2226
2429
  }
2227
2430
  onCleanup(() => {
@@ -2284,21 +2487,40 @@ function addClass(el, cls) {
2284
2487
  function removeClass(el, cls) {
2285
2488
  for (const c of cls.split(/\s+/)) if (c) el.classList.remove(c);
2286
2489
  }
2287
- function nextFrame(cb) {
2288
- 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
+ };
2289
2502
  }
2290
2503
  function forceReflow(el) {
2291
2504
  void el.offsetHeight;
2292
2505
  }
2293
2506
  function whenTransitionEnds(el, type, explicit, resolve2) {
2294
2507
  if (explicit != null) {
2295
- setTimeout(resolve2, explicit);
2296
- 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
+ };
2297
2518
  }
2298
2519
  const info = getTransitionInfo(el, type);
2299
2520
  if (!info) {
2300
2521
  resolve2();
2301
- return;
2522
+ return () => {
2523
+ };
2302
2524
  }
2303
2525
  let done = false;
2304
2526
  const finish = () => {
@@ -2308,9 +2530,18 @@ function whenTransitionEnds(el, type, explicit, resolve2) {
2308
2530
  el.removeEventListener(info.event, onEnd);
2309
2531
  resolve2();
2310
2532
  };
2311
- const onEnd = () => finish();
2533
+ const onEnd = (event) => {
2534
+ if (event.target !== el) return;
2535
+ finish();
2536
+ };
2312
2537
  el.addEventListener(info.event, onEnd);
2313
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
+ };
2314
2545
  }
2315
2546
  function resolveDuration(d, dir) {
2316
2547
  if (d == null) return null;
@@ -2319,7 +2550,7 @@ function resolveDuration(d, dir) {
2319
2550
  }
2320
2551
  function validateSlot(value) {
2321
2552
  if (value == null || value === false) return null;
2322
- if (Array.isArray(value)) {
2553
+ if (shared.isArray(value)) {
2323
2554
  {
2324
2555
  throw new Error(
2325
2556
  "[essor] <Transition> expects a single root child. Use <TransitionGroup> for multiple children."
@@ -2365,8 +2596,26 @@ function Transition(props) {
2365
2596
  let hasPending = false;
2366
2597
  let scheduled = false;
2367
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
+ };
2368
2609
  const enter = (el, phase) => {
2369
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;
2370
2619
  const prevLeave = el[LEAVE_CB];
2371
2620
  if (prevLeave) prevLeave(true);
2372
2621
  state = "entering";
@@ -2383,6 +2632,7 @@ function Transition(props) {
2383
2632
  var _a3, _b;
2384
2633
  if (called) return;
2385
2634
  called = true;
2635
+ stopWait();
2386
2636
  el[ENTER_CB] = void 0;
2387
2637
  if (useCss) {
2388
2638
  removeClass(el, fromCls);
@@ -2397,7 +2647,8 @@ function Transition(props) {
2397
2647
  }
2398
2648
  };
2399
2649
  el[ENTER_CB] = done;
2400
- nextFrame(() => {
2650
+ cancelWait = nextFrameCancellable(() => {
2651
+ cancelWait = null;
2401
2652
  if (called) return;
2402
2653
  if (useCss) {
2403
2654
  removeClass(el, fromCls);
@@ -2407,7 +2658,10 @@ function Transition(props) {
2407
2658
  props.onEnter(el, () => done(false));
2408
2659
  } else if (useCss) {
2409
2660
  const explicit = resolveDuration(props.duration, "enter");
2410
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2661
+ cancelWait = whenTransitionEnds(el, props.type, explicit, () => {
2662
+ cancelWait = null;
2663
+ done(false);
2664
+ });
2411
2665
  } else {
2412
2666
  done(false);
2413
2667
  }
@@ -2415,6 +2669,14 @@ function Transition(props) {
2415
2669
  };
2416
2670
  const leave = (el, after) => {
2417
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;
2418
2680
  const prevEnter = el[ENTER_CB];
2419
2681
  if (prevEnter) {
2420
2682
  prevEnter(true);
@@ -2431,6 +2693,7 @@ function Transition(props) {
2431
2693
  var _a3, _b;
2432
2694
  if (called) return;
2433
2695
  called = true;
2696
+ stopWait();
2434
2697
  el[LEAVE_CB] = void 0;
2435
2698
  if (useCss) {
2436
2699
  removeClass(el, classes.leaveFrom);
@@ -2452,7 +2715,8 @@ function Transition(props) {
2452
2715
  done(false);
2453
2716
  return;
2454
2717
  }
2455
- nextFrame(() => {
2718
+ cancelWait = nextFrameCancellable(() => {
2719
+ cancelWait = null;
2456
2720
  if (called) return;
2457
2721
  if (useCss) {
2458
2722
  removeClass(el, classes.leaveFrom);
@@ -2461,7 +2725,10 @@ function Transition(props) {
2461
2725
  if (props.onLeave) {
2462
2726
  props.onLeave(el, () => done(false));
2463
2727
  } else if (useCss) {
2464
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2728
+ cancelWait = whenTransitionEnds(el, props.type, explicit, () => {
2729
+ cancelWait = null;
2730
+ done(false);
2731
+ });
2465
2732
  } else {
2466
2733
  done(false);
2467
2734
  }
@@ -2536,6 +2803,8 @@ function Transition(props) {
2536
2803
  });
2537
2804
  onCleanup(() => {
2538
2805
  disposed = true;
2806
+ stopEnterWait();
2807
+ stopLeaveWait();
2539
2808
  effectRunner.stop();
2540
2809
  for (const el of [currentEl, leavingEl]) {
2541
2810
  if (!el) continue;
@@ -2557,7 +2826,7 @@ function isTransition(node) {
2557
2826
  }
2558
2827
  function resolveItemElement(raw, parent) {
2559
2828
  if (raw == null || raw === false) return { el: null, comp: null };
2560
- if (Array.isArray(raw) && raw.length === 1) {
2829
+ if (shared.isArray(raw) && raw.length === 1) {
2561
2830
  return resolveItemElement(raw[0], parent);
2562
2831
  }
2563
2832
  if (shared.isFunction(raw)) {
@@ -2612,7 +2881,7 @@ function TransitionGroup(props) {
2612
2881
  const moveClass = (_c = props.moveClass) != null ? _c : `${(_b = props.name) != null ? _b : "v"}-move`;
2613
2882
  const keyFn = props.key;
2614
2883
  const rawChildren = props.children;
2615
- 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;
2616
2885
  if (!shared.isFunction(childrenFn) || !shared.isFunction(keyFn)) {
2617
2886
  throw new TypeError(
2618
2887
  "<TransitionGroup> requires `children: (item, index) => Node` and `key: (item, index) => unknown`"
@@ -2663,9 +2932,12 @@ function TransitionGroup(props) {
2663
2932
  if (entry.el.parentNode === wrapper) wrapper.removeChild(entry.el);
2664
2933
  };
2665
2934
  const disposeEntry = (entry) => {
2666
- var _a3, _b2;
2935
+ var _a3, _b2, _c2, _d, _e;
2667
2936
  (_a3 = entry.cancelEnter) == null ? void 0 : _a3.call(entry, true);
2668
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);
2669
2941
  if (entry.comp) entry.comp.destroy();
2670
2942
  detachEntryDom(entry);
2671
2943
  disposeScope(entry.scope);
@@ -2684,23 +2956,26 @@ function TransitionGroup(props) {
2684
2956
  addClass(el, classes.enterActive);
2685
2957
  let called = false;
2686
2958
  const done = (cancelled) => {
2687
- var _a4, _b3;
2959
+ var _a4, _b3, _c3;
2688
2960
  if (called) return;
2689
2961
  called = true;
2690
2962
  entry.cancelEnter = void 0;
2963
+ (_a4 = entry.cancelEnterWait) == null ? void 0 : _a4.call(entry);
2964
+ entry.cancelEnterWait = void 0;
2691
2965
  removeClass(el, classes.enterFrom);
2692
2966
  removeClass(el, classes.enterActive);
2693
2967
  removeClass(el, classes.enterTo);
2694
2968
  if (cancelled) {
2695
- (_a4 = props.onEnterCancelled) == null ? void 0 : _a4.call(props, el);
2969
+ (_b3 = props.onEnterCancelled) == null ? void 0 : _b3.call(props, el);
2696
2970
  } else {
2697
2971
  entry.state = "present";
2698
- (_b3 = props.onAfterEnter) == null ? void 0 : _b3.call(props, el);
2972
+ (_c3 = props.onAfterEnter) == null ? void 0 : _c3.call(props, el);
2699
2973
  }
2700
2974
  };
2701
2975
  entry.cancelEnter = done;
2702
2976
  entry.state = "entering";
2703
- nextFrame(() => {
2977
+ entry.cancelEnterWait = nextFrameCancellable(() => {
2978
+ entry.cancelEnterWait = void 0;
2704
2979
  if (called) return;
2705
2980
  removeClass(el, classes.enterFrom);
2706
2981
  addClass(el, classes.enterTo);
@@ -2708,7 +2983,10 @@ function TransitionGroup(props) {
2708
2983
  props.onEnter(el, () => done(false));
2709
2984
  } else {
2710
2985
  const explicit = resolveDuration(props.duration, "enter");
2711
- whenTransitionEnds(el, props.type, explicit, () => done(false));
2986
+ entry.cancelEnterWait = whenTransitionEnds(el, props.type, explicit, () => {
2987
+ entry.cancelEnterWait = void 0;
2988
+ done(false);
2989
+ });
2712
2990
  }
2713
2991
  });
2714
2992
  };
@@ -2740,17 +3018,19 @@ function TransitionGroup(props) {
2740
3018
  addClass(el, classes.leaveActive);
2741
3019
  let called = false;
2742
3020
  const done = (cancelled) => {
2743
- var _a4, _b3;
3021
+ var _a4, _b3, _c2;
2744
3022
  if (called) return;
2745
3023
  called = true;
2746
3024
  entry.cancelLeave = void 0;
3025
+ (_a4 = entry.cancelLeaveWait) == null ? void 0 : _a4.call(entry);
3026
+ entry.cancelLeaveWait = void 0;
2747
3027
  removeClass(el, classes.leaveFrom);
2748
3028
  removeClass(el, classes.leaveActive);
2749
3029
  removeClass(el, classes.leaveTo);
2750
3030
  if (cancelled) {
2751
3031
  if (entry.savedStyles) restoreStyles(el, entry.savedStyles);
2752
3032
  entry.savedStyles = void 0;
2753
- (_a4 = props.onLeaveCancelled) == null ? void 0 : _a4.call(props, el);
3033
+ (_b3 = props.onLeaveCancelled) == null ? void 0 : _b3.call(props, el);
2754
3034
  return;
2755
3035
  }
2756
3036
  if (entry.savedStyles) restoreStyles(el, entry.savedStyles);
@@ -2758,10 +3038,11 @@ function TransitionGroup(props) {
2758
3038
  detachEntryDom(entry);
2759
3039
  disposeScope(entry.scope);
2760
3040
  if (entry.comp) entry.comp.destroy();
2761
- (_b3 = props.onAfterLeave) == null ? void 0 : _b3.call(props, el);
3041
+ (_c2 = props.onAfterLeave) == null ? void 0 : _c2.call(props, el);
2762
3042
  };
2763
3043
  entry.cancelLeave = done;
2764
- nextFrame(() => {
3044
+ entry.cancelLeaveWait = nextFrameCancellable(() => {
3045
+ entry.cancelLeaveWait = void 0;
2765
3046
  if (called) return;
2766
3047
  removeClass(el, classes.leaveFrom);
2767
3048
  addClass(el, classes.leaveTo);
@@ -2769,11 +3050,15 @@ function TransitionGroup(props) {
2769
3050
  props.onLeave(el, () => done(false));
2770
3051
  } else {
2771
3052
  const explicit = resolveDuration(props.duration, "leave");
2772
- whenTransitionEnds(el, props.type, explicit, () => done(false));
3053
+ entry.cancelLeaveWait = whenTransitionEnds(el, props.type, explicit, () => {
3054
+ entry.cancelLeaveWait = void 0;
3055
+ done(false);
3056
+ });
2773
3057
  }
2774
3058
  });
2775
3059
  };
2776
3060
  const runMove = (entry, prevRect) => {
3061
+ var _a3;
2777
3062
  if (!useCss || entry.state !== "present") return;
2778
3063
  const el = entry.el;
2779
3064
  const newRect = el.getBoundingClientRect();
@@ -2789,7 +3074,9 @@ function TransitionGroup(props) {
2789
3074
  el.style.transform = savedTransform;
2790
3075
  el.style.transitionDuration = savedTransition;
2791
3076
  const explicit = resolveDuration(props.duration, "enter");
2792
- 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;
2793
3080
  removeClass(el, moveClass);
2794
3081
  });
2795
3082
  };