@zeus-js/runtime-dom 0.1.0 → 0.1.1-beta.1

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,18 +1,29 @@
1
1
  /**
2
- * runtime-dom v0.1.0
2
+ * runtime-dom v0.1.1-beta.1
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
6
6
  var ZeusRuntimeDOM = (function(exports) {
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  //#region packages/core/runtime-dom/src/template.ts
9
- function template(html, _isImportNode = false, _isSVG = false, _isMathML = false) {
10
- const t = document.createElement("template");
11
- t.innerHTML = html;
9
+ function template(html, _isImportNode = false, isSVG = false, _isMathML = false) {
10
+ const content = isSVG ? createSvgContent(html) : createHtmlContent(html);
12
11
  return function clone() {
13
- return t.content.cloneNode(true);
12
+ return content.cloneNode(true);
14
13
  };
15
14
  }
15
+ function createHtmlContent(html) {
16
+ const template = document.createElement("template");
17
+ template.innerHTML = html;
18
+ return template.content;
19
+ }
20
+ function createSvgContent(html) {
21
+ const wrapper = document.createElementNS("http://www.w3.org/2000/svg", "svg");
22
+ wrapper.innerHTML = html;
23
+ const content = document.createDocumentFragment();
24
+ while (wrapper.firstChild) content.appendChild(wrapper.firstChild);
25
+ return content;
26
+ }
16
27
  //#endregion
17
28
  //#region packages/core/shared/src/makeMap.ts
18
29
  /**
@@ -495,6 +506,31 @@ var ZeusRuntimeDOM = (function(exports) {
495
506
  }
496
507
  }
497
508
  }
509
+ /**
510
+ * Batches reactive updates synchronously within the given function.
511
+ * All updates triggered inside `fn` are deferred until the function completes,
512
+ * then flushed together in a single batch.
513
+ */
514
+ function batch(fn) {
515
+ startBatch();
516
+ try {
517
+ return fn();
518
+ } finally {
519
+ endBatch();
520
+ }
521
+ }
522
+ /**
523
+ * Executes the given function without tracking reactive dependencies.
524
+ * Any reactive reads inside `fn` will not trigger effect re-runs.
525
+ */
526
+ function untrack(fn) {
527
+ pauseTracking();
528
+ try {
529
+ return fn();
530
+ } finally {
531
+ resetTracking();
532
+ }
533
+ }
498
534
  //#endregion
499
535
  //#region packages/core/signal/src/dep.ts
500
536
  /**
@@ -872,60 +908,6 @@ var ZeusRuntimeDOM = (function(exports) {
872
908
  return res;
873
909
  }
874
910
  //#endregion
875
- //#region packages/core/signal/src/ref.ts
876
- let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
877
- /*@__NO_SIDE_EFFECTS__*/
878
- function isRef(r) {
879
- return r ? r["__v_isRef"] === true : false;
880
- }
881
- /*@__NO_SIDE_EFFECTS__*/
882
- function ref(value) {
883
- return createRef(value, false);
884
- }
885
- function createRef(rawValue, shallow) {
886
- if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
887
- return new RefImpl(rawValue, shallow);
888
- }
889
- _ReactiveFlags$IS_REF = "__v_isRef";
890
- _ReactiveFlags$IS_SHA = "__v_isShallow";
891
- /**
892
- * @internal
893
- */
894
- var RefImpl = class {
895
- constructor(value, isShallow) {
896
- this.dep = new Dep();
897
- this[_ReactiveFlags$IS_REF] = true;
898
- this[_ReactiveFlags$IS_SHA] = false;
899
- this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
900
- this._value = isShallow ? value : toReactive(value);
901
- this["__v_isShallow"] = isShallow;
902
- }
903
- get value() {
904
- this.dep.track({
905
- target: this,
906
- type: "get",
907
- key: "value"
908
- });
909
- return this._value;
910
- }
911
- set value(newValue) {
912
- const oldValue = this._rawValue;
913
- const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
914
- newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
915
- if (hasChanged(newValue, oldValue)) {
916
- this._rawValue = newValue;
917
- this._value = useDirectValue ? newValue : toReactive(newValue);
918
- this.dep.trigger({
919
- target: this,
920
- type: "set",
921
- key: "value",
922
- newValue,
923
- oldValue
924
- });
925
- }
926
- }
927
- };
928
- //#endregion
929
911
  //#region packages/core/signal/src/baseHandlers.ts
930
912
  const isNonTrackableKeys = /*@__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
931
913
  const builtInSymbols = new Set(/*@__PURE__*/ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
@@ -1358,11 +1340,84 @@ var ZeusRuntimeDOM = (function(exports) {
1358
1340
  */
1359
1341
  const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
1360
1342
  //#endregion
1343
+ //#region packages/core/signal/src/ref.ts
1344
+ let _ReactiveFlags$IS_REF, _ReactiveFlags$IS_SHA;
1345
+ /*@__NO_SIDE_EFFECTS__*/
1346
+ function isRef(r) {
1347
+ return r ? r["__v_isRef"] === true : false;
1348
+ }
1349
+ /*@__NO_SIDE_EFFECTS__*/
1350
+ function ref(value) {
1351
+ return createRef(value, false);
1352
+ }
1353
+ /*@__NO_SIDE_EFFECTS__*/
1354
+ function shallowRef(value) {
1355
+ return createRef(value, true);
1356
+ }
1357
+ function createRef(rawValue, shallow) {
1358
+ if (/* @__PURE__ */ isRef(rawValue)) return rawValue;
1359
+ return new RefImpl(rawValue, shallow);
1360
+ }
1361
+ _ReactiveFlags$IS_REF = "__v_isRef";
1362
+ _ReactiveFlags$IS_SHA = "__v_isShallow";
1363
+ /**
1364
+ * @internal
1365
+ */
1366
+ var RefImpl = class {
1367
+ constructor(value, isShallow) {
1368
+ this.dep = new Dep();
1369
+ this[_ReactiveFlags$IS_REF] = true;
1370
+ this[_ReactiveFlags$IS_SHA] = false;
1371
+ this._rawValue = isShallow ? value : /* @__PURE__ */ toRaw(value);
1372
+ this._value = isShallow ? value : toReactive(value);
1373
+ this["__v_isShallow"] = isShallow;
1374
+ }
1375
+ get value() {
1376
+ this.dep.track({
1377
+ target: this,
1378
+ type: "get",
1379
+ key: "value"
1380
+ });
1381
+ return this._value;
1382
+ }
1383
+ set value(newValue) {
1384
+ const oldValue = this._rawValue;
1385
+ const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue);
1386
+ newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue);
1387
+ if (hasChanged(newValue, oldValue)) {
1388
+ this._rawValue = newValue;
1389
+ this._value = useDirectValue ? newValue : toReactive(newValue);
1390
+ this.dep.trigger({
1391
+ target: this,
1392
+ type: "set",
1393
+ key: "value",
1394
+ newValue,
1395
+ oldValue
1396
+ });
1397
+ }
1398
+ }
1399
+ };
1400
+ //#endregion
1401
+ //#region packages/core/signal/src/primitives.ts
1402
+ function createSignal(initialValue) {
1403
+ const source = /* @__PURE__ */ shallowRef(initialValue);
1404
+ const read = () => source.value;
1405
+ const write = (value) => {
1406
+ const next = typeof value === "function" ? value(source.value) : value;
1407
+ source.value = next;
1408
+ return next;
1409
+ };
1410
+ return [read, write];
1411
+ }
1412
+ //#endregion
1361
1413
  //#region packages/core/signal/src/state.ts
1362
1414
  function state(value) {
1363
1415
  if (arguments.length === 0) return /* @__PURE__ */ ref();
1364
1416
  return isProxyable(value) ? /* @__PURE__ */ reactive(value) : /* @__PURE__ */ ref(value);
1365
1417
  }
1418
+ function shallowState(value) {
1419
+ return arguments.length === 0 ? /* @__PURE__ */ shallowRef() : /* @__PURE__ */ shallowRef(value);
1420
+ }
1366
1421
  function isProxyable(value) {
1367
1422
  if (value === null || typeof value !== "object") return false;
1368
1423
  if (Array.isArray(value)) return true;
@@ -1374,6 +1429,32 @@ var ZeusRuntimeDOM = (function(exports) {
1374
1429
  return proto === Object.prototype || proto === null;
1375
1430
  }
1376
1431
  //#endregion
1432
+ //#region packages/core/runtime-dom/src/domMove.ts
1433
+ const activeMoveRoots = /* @__PURE__ */ new Set();
1434
+ function moveNodeBefore(parent, node, marker) {
1435
+ activeMoveRoots.add(node);
1436
+ try {
1437
+ const moveBefore = parent.moveBefore;
1438
+ if (typeof moveBefore === "function") moveBefore.call(parent, node, marker);
1439
+ else parent.insertBefore(node, marker);
1440
+ } finally {
1441
+ activeMoveRoots.delete(node);
1442
+ }
1443
+ }
1444
+ function isWithinRuntimeDomMove(node) {
1445
+ let current = node;
1446
+ while (current) {
1447
+ if (activeMoveRoots.has(current)) return true;
1448
+ if (current.parentNode) {
1449
+ current = current.parentNode;
1450
+ continue;
1451
+ }
1452
+ const root = current.getRootNode();
1453
+ current = "host" in root ? root.host : null;
1454
+ }
1455
+ return false;
1456
+ }
1457
+ //#endregion
1377
1458
  //#region packages/core/runtime-dom/src/domOwnership.ts
1378
1459
  const activeLightDomHosts = /* @__PURE__ */ new WeakMap();
1379
1460
  const runtimeOwnedNodes = /* @__PURE__ */ new WeakSet();
@@ -1408,6 +1489,14 @@ var ZeusRuntimeDOM = (function(exports) {
1408
1489
  for (const item of value) nodes.push(...insertTracked(parent, item, marker));
1409
1490
  return nodes;
1410
1491
  }
1492
+ if (value instanceof Node && value.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
1493
+ const nodes = Array.from(value.childNodes);
1494
+ for (const node of nodes) {
1495
+ trackRuntimeDomInsertion(parent, node);
1496
+ parent.insertBefore(node, marker);
1497
+ }
1498
+ return nodes;
1499
+ }
1411
1500
  const node = value instanceof Node ? value : document.createTextNode(String(value));
1412
1501
  trackRuntimeDomInsertion(parent, node);
1413
1502
  parent.insertBefore(node, marker);
@@ -1422,7 +1511,7 @@ var ZeusRuntimeDOM = (function(exports) {
1422
1511
  function moveRangeBefore(nodes, parent, marker = null) {
1423
1512
  for (const node of nodes) {
1424
1513
  trackRuntimeDomInsertion(parent, node);
1425
- parent.insertBefore(node, marker);
1514
+ moveNodeBefore(parent, node, marker);
1426
1515
  }
1427
1516
  }
1428
1517
  //#endregion
@@ -1467,10 +1556,11 @@ var ZeusRuntimeDOM = (function(exports) {
1467
1556
  replace(render) {
1468
1557
  this.dispose();
1469
1558
  const scope = effectScope(true);
1559
+ const parent = this.resolveParent(this.marker);
1470
1560
  let nodes = [];
1471
1561
  try {
1472
1562
  scope.run(() => {
1473
- nodes = runWithOwner(this.context.owner, () => withHostContext(this.context.host, () => insertTracked(this.parent, render(), this.marker)));
1563
+ nodes = runWithOwner(this.context.owner, () => withHostContext(this.context.host, () => insertTracked(parent, render(), this.marker)));
1474
1564
  });
1475
1565
  } catch (error) {
1476
1566
  scope.stop();
@@ -1488,11 +1578,15 @@ var ZeusRuntimeDOM = (function(exports) {
1488
1578
  this.nodes = [];
1489
1579
  }
1490
1580
  moveBefore(marker) {
1491
- moveRangeBefore(this.nodes, this.parent, marker);
1581
+ moveRangeBefore(this.nodes, this.resolveParent(marker), marker);
1492
1582
  }
1493
1583
  current() {
1494
1584
  return this.nodes;
1495
1585
  }
1586
+ resolveParent(marker) {
1587
+ var _ref, _marker$parentNode, _this$marker;
1588
+ return (_ref = (_marker$parentNode = marker === null || marker === void 0 ? void 0 : marker.parentNode) !== null && _marker$parentNode !== void 0 ? _marker$parentNode : (_this$marker = this.marker) === null || _this$marker === void 0 ? void 0 : _this$marker.parentNode) !== null && _ref !== void 0 ? _ref : this.parent;
1589
+ }
1496
1590
  };
1497
1591
  //#endregion
1498
1592
  //#region packages/core/runtime-dom/src/insert.ts
@@ -1702,14 +1796,23 @@ var ZeusRuntimeDOM = (function(exports) {
1702
1796
  }
1703
1797
  //#endregion
1704
1798
  //#region packages/core/runtime-dom/src/bindings.ts
1705
- function bindText(node, value) {
1706
- effect(() => {
1707
- node.data = stringifyText(value());
1799
+ function bindText(node, value, once = false) {
1800
+ applyBinding(value, once, (next) => {
1801
+ node.data = stringifyText(next);
1708
1802
  });
1709
1803
  }
1710
- function bindTextContent(el, value) {
1804
+ function bindTextContent(el, value, once = false) {
1805
+ applyBinding(value, once, (next) => {
1806
+ el.textContent = stringifyText(next);
1807
+ });
1808
+ }
1809
+ function applyBinding(value, once, apply) {
1810
+ if (once) {
1811
+ untrack(() => apply(value()));
1812
+ return;
1813
+ }
1711
1814
  effect(() => {
1712
- el.textContent = stringifyText(value());
1815
+ apply(value());
1713
1816
  });
1714
1817
  }
1715
1818
  function stringifyText(value) {
@@ -1762,19 +1865,19 @@ var ZeusRuntimeDOM = (function(exports) {
1762
1865
  function normalizeAttrName(name) {
1763
1866
  return name === "className" ? "class" : name;
1764
1867
  }
1765
- function bindAttr(el, name, value) {
1766
- effect(() => {
1767
- setAttr(el, name, value());
1868
+ function bindAttr(el, name, value, once = false) {
1869
+ applyBinding(value, once, (next) => {
1870
+ setAttr(el, name, next);
1768
1871
  });
1769
1872
  }
1770
- function bindProp(el, name, value) {
1771
- effect(() => {
1772
- el[name] = value();
1873
+ function bindProp(el, name, value, once = false) {
1874
+ applyBinding(value, once, (next) => {
1875
+ el[name] = next;
1773
1876
  });
1774
1877
  }
1775
- function bindClass(el, value) {
1776
- effect(() => {
1777
- const next = normalizeClass(value());
1878
+ function bindClass(el, value, once = false) {
1879
+ applyBinding(value, once, (value) => {
1880
+ const next = normalizeClass(value);
1778
1881
  if (next) el.setAttribute("class", next);
1779
1882
  else el.removeAttribute("class");
1780
1883
  });
@@ -1786,10 +1889,9 @@ var ZeusRuntimeDOM = (function(exports) {
1786
1889
  if (typeof value === "object") return Object.keys(value).filter((key) => value[key]).join(" ");
1787
1890
  return "";
1788
1891
  }
1789
- function bindStyle(el, value) {
1892
+ function bindStyle(el, value, once = false) {
1790
1893
  let prev;
1791
- effect(() => {
1792
- const next = value();
1894
+ applyBinding(value, once, (next) => {
1793
1895
  if (next == null) {
1794
1896
  el.removeAttribute("style");
1795
1897
  prev = void 0;
@@ -1945,6 +2047,30 @@ var ZeusRuntimeDOM = (function(exports) {
1945
2047
  function disposeListRecord(record) {
1946
2048
  record.subtree.dispose();
1947
2049
  }
2050
+ function isImmediatelyBefore(record, anchor) {
2051
+ const nodes = record.subtree.current();
2052
+ const last = nodes[nodes.length - 1];
2053
+ return last === void 0 || last.nextSibling === anchor;
2054
+ }
2055
+ function containsNode(record, node) {
2056
+ let current = node;
2057
+ while (current) {
2058
+ if (record.subtree.current().some((root) => root === current || root.contains(current))) return true;
2059
+ const treeRoot = current.getRootNode();
2060
+ current = "host" in treeRoot ? treeRoot.host : null;
2061
+ }
2062
+ return false;
2063
+ }
2064
+ function getDeepestActiveElement(parent) {
2065
+ var _parent$ownerDocument, _parent$ownerDocument2, _active$shadowRoot;
2066
+ const treeRoot = parent.getRootNode();
2067
+ let active = "activeElement" in treeRoot ? treeRoot.activeElement : (_parent$ownerDocument = (_parent$ownerDocument2 = parent.ownerDocument) === null || _parent$ownerDocument2 === void 0 ? void 0 : _parent$ownerDocument2.activeElement) !== null && _parent$ownerDocument !== void 0 ? _parent$ownerDocument : null;
2068
+ while (active === null || active === void 0 || (_active$shadowRoot = active.shadowRoot) === null || _active$shadowRoot === void 0 ? void 0 : _active$shadowRoot.activeElement) active = active.shadowRoot.activeElement;
2069
+ return active;
2070
+ }
2071
+ function duplicateKeyError(key, index) {
2072
+ return /* @__PURE__ */ new Error(`[Zeus runtime] <For> received duplicate key ${String(key)} at index ${index}.`);
2073
+ }
1948
2074
  function mountFor$1(parent, marker, each, key, render) {
1949
2075
  if (!key) {
1950
2076
  mountIndexFor(parent, marker, each, render);
@@ -1954,63 +2080,210 @@ var ZeusRuntimeDOM = (function(exports) {
1954
2080
  }
1955
2081
  function mountIndexFor(parent, marker, each, render) {
1956
2082
  const subtree = new ScopedSubtree(parent, marker, captureScopedSubtreeContext());
1957
- const runner = effect(() => {
1958
- var _each;
1959
- const list = (_each = each()) !== null && _each !== void 0 ? _each : [];
1960
- subtree.replace(() => list.map((item, index) => render(item, index)));
1961
- });
1962
- onScopeDispose(() => {
2083
+ let latestItems = [];
2084
+ let reconcileRequested = false;
2085
+ let reconciling = false;
2086
+ let disposed = false;
2087
+ let runner;
2088
+ const dispose = () => {
2089
+ if (disposed) return;
2090
+ disposed = true;
2091
+ if (runner) stop(runner);
2092
+ subtree.dispose();
2093
+ };
2094
+ onScopeDispose(dispose, true);
2095
+ const drainReconciliations = () => {
2096
+ if (disposed || reconciling) return;
2097
+ reconciling = true;
2098
+ try {
2099
+ while (reconcileRequested && !disposed) {
2100
+ reconcileRequested = false;
2101
+ untrack(() => {
2102
+ subtree.replace(() => latestItems.map((item, index) => render(() => item, () => index)));
2103
+ });
2104
+ }
2105
+ } finally {
2106
+ reconciling = false;
2107
+ if (disposed) subtree.dispose();
2108
+ }
2109
+ };
2110
+ const scheduleReconciliation = () => {
2111
+ if (disposed || !runner) return;
2112
+ runner();
2113
+ if (disposed) return;
2114
+ reconcileRequested = true;
2115
+ drainReconciliations();
2116
+ };
2117
+ try {
2118
+ runner = effect(() => {
2119
+ var _each;
2120
+ const nextItems = (_each = each()) !== null && _each !== void 0 ? _each : [];
2121
+ for (let i = 0; i < nextItems.length; i++) nextItems[i];
2122
+ latestItems = nextItems;
2123
+ }, { scheduler: scheduleReconciliation });
2124
+ } catch (error) {
2125
+ dispose();
2126
+ throw error;
2127
+ }
2128
+ if (disposed) {
1963
2129
  stop(runner);
1964
2130
  subtree.dispose();
1965
- }, true);
2131
+ return;
2132
+ }
2133
+ reconcileRequested = true;
2134
+ try {
2135
+ drainReconciliations();
2136
+ } catch (error) {
2137
+ dispose();
2138
+ throw error;
2139
+ }
1966
2140
  }
1967
2141
  function mountKeyedFor(parent, marker, each, key, render) {
1968
2142
  let records = [];
1969
2143
  const subtreeContext = captureScopedSubtreeContext();
1970
- const runner = effect(() => {
1971
- var _each2;
1972
- const nextItems = (_each2 = each()) !== null && _each2 !== void 0 ? _each2 : [];
2144
+ let latestEntries = [];
2145
+ let reconcileRequested = false;
2146
+ let reconciling = false;
2147
+ let disposed = false;
2148
+ let runner;
2149
+ const dispose = () => {
2150
+ if (disposed) return;
2151
+ disposed = true;
2152
+ if (runner) stop(runner);
2153
+ const currentRecords = records;
2154
+ records = [];
2155
+ for (const record of currentRecords) disposeListRecord(record);
2156
+ };
2157
+ onScopeDispose(dispose, true);
2158
+ const reconcile = (nextEntries) => {
2159
+ if (disposed) return;
1973
2160
  const oldMap = /* @__PURE__ */ new Map();
1974
2161
  for (const record of records) oldMap.set(record.key, record);
1975
2162
  const nextRecords = [];
1976
- for (let i = 0; i < nextItems.length; i++) {
1977
- const item = nextItems[i];
1978
- const itemKey = key(item, i);
1979
- const oldRecord = oldMap.get(itemKey);
1980
- if (oldRecord) {
1981
- oldMap.delete(itemKey);
1982
- oldRecord.item = item;
1983
- oldRecord.index = i;
1984
- nextRecords.push(oldRecord);
1985
- } else {
1986
- const subtree = new ScopedSubtree(parent, marker, subtreeContext);
1987
- subtree.replace(() => render(item, i));
1988
- nextRecords.push({
1989
- key: itemKey,
1990
- item,
1991
- index: i,
1992
- subtree
1993
- });
2163
+ const createdRecords = [];
2164
+ try {
2165
+ batch(() => {
2166
+ for (let i = 0; i < nextEntries.length; i++) {
2167
+ const { item, key: itemKey } = nextEntries[i];
2168
+ const oldRecord = oldMap.get(itemKey);
2169
+ if (oldRecord) {
2170
+ oldMap.delete(itemKey);
2171
+ oldRecord.setItem(() => item);
2172
+ oldRecord.setIndex(i);
2173
+ nextRecords.push(oldRecord);
2174
+ } else {
2175
+ const [readItem, setItem] = createSignal(item);
2176
+ const [readIndex, setIndex] = createSignal(i);
2177
+ const subtree = new ScopedSubtree(parent, marker, subtreeContext);
2178
+ const record = {
2179
+ key: itemKey,
2180
+ setItem,
2181
+ setIndex,
2182
+ subtree
2183
+ };
2184
+ createdRecords.push(record);
2185
+ subtree.replace(() => render(readItem, readIndex));
2186
+ nextRecords.push(record);
2187
+ }
2188
+ if (disposed) break;
2189
+ }
2190
+ });
2191
+ } catch (error) {
2192
+ for (const record of createdRecords) disposeListRecord(record);
2193
+ throw error;
2194
+ }
2195
+ if (disposed) {
2196
+ for (const record of createdRecords) disposeListRecord(record);
2197
+ return;
2198
+ }
2199
+ const activeElement = getDeepestActiveElement(parent);
2200
+ const shouldRestoreFocus = Boolean(activeElement && nextRecords.some((record) => containsNode(record, activeElement)));
2201
+ let committed = false;
2202
+ try {
2203
+ for (const record of oldMap.values()) disposeListRecord(record);
2204
+ if (disposed) {
2205
+ for (const record of createdRecords) disposeListRecord(record);
2206
+ return;
2207
+ }
2208
+ records = nextRecords;
2209
+ committed = true;
2210
+ let moved = false;
2211
+ let anchor = marker;
2212
+ for (let i = nextRecords.length - 1; i >= 0; i--) {
2213
+ var _record$subtree$curre;
2214
+ const record = nextRecords[i];
2215
+ if (!isImmediatelyBefore(record, anchor)) {
2216
+ record.subtree.moveBefore(anchor);
2217
+ moved = true;
2218
+ }
2219
+ anchor = (_record$subtree$curre = record.subtree.current()[0]) !== null && _record$subtree$curre !== void 0 ? _record$subtree$curre : anchor;
2220
+ }
2221
+ if (disposed) return;
2222
+ if (moved && shouldRestoreFocus) {
2223
+ var _focus;
2224
+ (_focus = activeElement.focus) === null || _focus === void 0 || _focus.call(activeElement, { preventScroll: true });
1994
2225
  }
2226
+ if (!disposed) emitDevtoolsEvent({
2227
+ type: "mount-for",
2228
+ length: nextRecords.length
2229
+ });
2230
+ } catch (error) {
2231
+ if (!committed) for (const record of createdRecords) disposeListRecord(record);
2232
+ throw error;
1995
2233
  }
1996
- for (const record of oldMap.values()) disposeListRecord(record);
1997
- for (let i = nextRecords.length - 1; i >= 0; i--) {
1998
- var _nextRecords$subtree$;
1999
- const record = nextRecords[i];
2000
- const anchor = i === nextRecords.length - 1 ? marker : (_nextRecords$subtree$ = nextRecords[i + 1].subtree.current()[0]) !== null && _nextRecords$subtree$ !== void 0 ? _nextRecords$subtree$ : marker;
2001
- record.subtree.moveBefore(anchor);
2234
+ };
2235
+ const drainReconciliations = () => {
2236
+ if (reconciling) return;
2237
+ reconciling = true;
2238
+ try {
2239
+ while (reconcileRequested) {
2240
+ reconcileRequested = false;
2241
+ untrack(() => reconcile(latestEntries));
2242
+ }
2243
+ } finally {
2244
+ reconciling = false;
2002
2245
  }
2003
- emitDevtoolsEvent({
2004
- type: "mount-for",
2005
- length: nextRecords.length
2006
- });
2007
- records = nextRecords;
2008
- });
2009
- onScopeDispose(() => {
2246
+ };
2247
+ const scheduleReconciliation = () => {
2248
+ if (disposed || !runner) return;
2249
+ runner();
2250
+ if (disposed) return;
2251
+ reconcileRequested = true;
2252
+ drainReconciliations();
2253
+ };
2254
+ try {
2255
+ runner = effect(() => {
2256
+ var _each2;
2257
+ const nextItems = (_each2 = each()) !== null && _each2 !== void 0 ? _each2 : [];
2258
+ const nextEntries = [];
2259
+ const nextKeys = /* @__PURE__ */ new Set();
2260
+ for (let i = 0; i < nextItems.length; i++) {
2261
+ const item = nextItems[i];
2262
+ const itemKey = key(item, i);
2263
+ if (nextKeys.has(itemKey)) throw duplicateKeyError(itemKey, i);
2264
+ nextKeys.add(itemKey);
2265
+ nextEntries.push({
2266
+ item,
2267
+ key: itemKey
2268
+ });
2269
+ }
2270
+ latestEntries = nextEntries;
2271
+ }, { scheduler: scheduleReconciliation });
2272
+ } catch (error) {
2273
+ dispose();
2274
+ throw error;
2275
+ }
2276
+ if (disposed) {
2010
2277
  stop(runner);
2011
- for (const record of records) disposeListRecord(record);
2012
- records = [];
2013
- }, true);
2278
+ return;
2279
+ }
2280
+ reconcileRequested = true;
2281
+ try {
2282
+ drainReconciliations();
2283
+ } catch (error) {
2284
+ dispose();
2285
+ throw error;
2286
+ }
2014
2287
  }
2015
2288
  //#endregion
2016
2289
  //#region packages/core/runtime-dom/src/controlFlow.ts
@@ -2235,7 +2508,14 @@ var ZeusRuntimeDOM = (function(exports) {
2235
2508
  function replaceOutletNodes(outlet, nextNodes) {
2236
2509
  const parent = outlet.end.parentNode;
2237
2510
  if (!parent || parent !== outlet.start.parentNode) return;
2511
+ const currentNodes = [];
2238
2512
  let current = outlet.start.nextSibling;
2513
+ while (current && current !== outlet.end) {
2514
+ currentNodes.push(current);
2515
+ current = current.nextSibling;
2516
+ }
2517
+ if (currentNodes.length === nextNodes.length && currentNodes.every((node, index) => node === nextNodes[index])) return;
2518
+ current = outlet.start.nextSibling;
2239
2519
  while (current && current !== outlet.end) {
2240
2520
  const next = current.nextSibling;
2241
2521
  parent.removeChild(current);
@@ -2289,6 +2569,7 @@ var ZeusRuntimeDOM = (function(exports) {
2289
2569
  values: input,
2290
2570
  attr: options.attr,
2291
2571
  reflect: options.reflect,
2572
+ reactivity: options.reactivity,
2292
2573
  default: options.default,
2293
2574
  serialize: options.serialize,
2294
2575
  deserialize: options.deserialize
@@ -2298,6 +2579,7 @@ var ZeusRuntimeDOM = (function(exports) {
2298
2579
  type,
2299
2580
  attr: options.attr,
2300
2581
  reflect: type === Boolean ? (_options$reflect = options.reflect) !== null && _options$reflect !== void 0 ? _options$reflect : true : options.reflect,
2582
+ reactivity: options.reactivity,
2301
2583
  default: type === Boolean ? (_options$default = options.default) !== null && _options$default !== void 0 ? _options$default : false : options.default,
2302
2584
  serialize: options.serialize,
2303
2585
  deserialize: options.deserialize
@@ -2320,7 +2602,7 @@ var ZeusRuntimeDOM = (function(exports) {
2320
2602
  const slots = /* @__PURE__ */ new Map();
2321
2603
  const props = {};
2322
2604
  for (const def of defs) {
2323
- const slot = state();
2605
+ const slot = def.reactivity === "shallow" ? shallowState() : state();
2324
2606
  slots.set(def.name, slot);
2325
2607
  Object.defineProperty(props, def.name, {
2326
2608
  configurable: false,
@@ -2389,6 +2671,7 @@ var ZeusRuntimeDOM = (function(exports) {
2389
2671
  this.mountLifecycle.connect();
2390
2672
  }
2391
2673
  disconnectedCallback() {
2674
+ if (isWithinRuntimeDomMove(this)) return;
2392
2675
  this.mountLifecycle.disconnect();
2393
2676
  }
2394
2677
  mountElement() {
@@ -2579,7 +2862,8 @@ var ZeusRuntimeDOM = (function(exports) {
2579
2862
  name: propKey,
2580
2863
  attrName: isAttributeBackedConstructor(type) ? toKebabCase(propKey) : false,
2581
2864
  type: normalizePropType(type),
2582
- reflect: false
2865
+ reflect: false,
2866
+ reactivity: "deep"
2583
2867
  };
2584
2868
  }
2585
2869
  const type = input === null || input === void 0 ? void 0 : input.type;
@@ -2589,6 +2873,7 @@ var ZeusRuntimeDOM = (function(exports) {
2589
2873
  attrName: (input === null || input === void 0 ? void 0 : input.attr) === void 0 ? defaultAttr : input.attr,
2590
2874
  type: normalizePropType(type),
2591
2875
  reflect: Boolean(input === null || input === void 0 ? void 0 : input.reflect),
2876
+ reactivity: (input === null || input === void 0 ? void 0 : input.reactivity) === "shallow" ? "shallow" : "deep",
2592
2877
  default: input === null || input === void 0 ? void 0 : input.default,
2593
2878
  serialize: input === null || input === void 0 ? void 0 : input.serialize,
2594
2879
  deserialize: input === null || input === void 0 ? void 0 : input.deserialize