@askrjs/askr 0.0.35 → 0.0.37

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.
Files changed (202) hide show
  1. package/README.md +17 -9
  2. package/dist/bench/components/benchmark-row.js.map +1 -1
  3. package/dist/bench/components/benchmark-table.js +1 -1
  4. package/dist/bench/components/benchmark-table.js.map +1 -1
  5. package/dist/benchmark.js +3 -3
  6. package/dist/benchmark.js.map +1 -1
  7. package/dist/bin/askr-ssg.js.map +1 -1
  8. package/dist/boot/index.d.ts +1 -7
  9. package/dist/boot/index.d.ts.map +1 -1
  10. package/dist/boot/index.js +31 -42
  11. package/dist/boot/index.js.map +1 -1
  12. package/dist/common/control.js.map +1 -1
  13. package/dist/common/env.js.map +1 -1
  14. package/dist/common/ssr-errors.js.map +1 -1
  15. package/dist/common/vnode.js.map +1 -1
  16. package/dist/components/error-boundary.js.map +1 -1
  17. package/dist/components/index.d.ts +2 -0
  18. package/dist/components/index.js +2 -0
  19. package/dist/components/link.d.ts +4 -5
  20. package/dist/components/link.d.ts.map +1 -1
  21. package/dist/components/link.js +2 -1
  22. package/dist/components/link.js.map +1 -1
  23. package/dist/control/case.js.map +1 -1
  24. package/dist/control/for.js.map +1 -1
  25. package/dist/control/shared.js.map +1 -1
  26. package/dist/control/show.js.map +1 -1
  27. package/dist/data/index.d.ts.map +1 -1
  28. package/dist/data/index.js +165 -23
  29. package/dist/data/index.js.map +1 -1
  30. package/dist/dev/invariant.js.map +1 -1
  31. package/dist/dev/logger.js.map +1 -1
  32. package/dist/foundations/icon/icon.d.ts.map +1 -1
  33. package/dist/foundations/icon/icon.js.map +1 -1
  34. package/dist/foundations/icon/icon.types.d.ts +2 -1
  35. package/dist/foundations/icon/icon.types.d.ts.map +1 -1
  36. package/dist/foundations/icon/index.d.ts +3 -0
  37. package/dist/foundations/icon/index.js +2 -0
  38. package/dist/foundations/index.d.ts +1 -18
  39. package/dist/foundations/index.js +2 -18
  40. package/dist/foundations/interactions/dismissable.js.map +1 -1
  41. package/dist/foundations/interactions/focusable.js.map +1 -1
  42. package/dist/foundations/interactions/hoverable.js.map +1 -1
  43. package/dist/foundations/interactions/index.d.ts +7 -0
  44. package/dist/foundations/interactions/index.js +7 -0
  45. package/dist/foundations/interactions/interaction-policy.js +2 -2
  46. package/dist/foundations/interactions/interaction-policy.js.map +1 -1
  47. package/dist/foundations/interactions/pressable.js.map +1 -1
  48. package/dist/foundations/interactions/roving-focus.js.map +1 -1
  49. package/dist/foundations/state/controllable.js.map +1 -1
  50. package/dist/foundations/state/index.d.ts +2 -0
  51. package/dist/foundations/state/index.js +2 -0
  52. package/dist/foundations/structures/collection.js.map +1 -1
  53. package/dist/foundations/structures/index.d.ts +8 -0
  54. package/dist/foundations/structures/index.js +7 -0
  55. package/dist/foundations/structures/layer.js.map +1 -1
  56. package/dist/foundations/structures/layout.js.map +1 -1
  57. package/dist/foundations/structures/portal.js.map +1 -1
  58. package/dist/foundations/structures/presence.js.map +1 -1
  59. package/dist/foundations/structures/slot.js.map +1 -1
  60. package/dist/foundations/utilities/aria.js.map +1 -1
  61. package/dist/foundations/utilities/compose-handlers.js.map +1 -1
  62. package/dist/foundations/utilities/compose-ref.js.map +1 -1
  63. package/dist/foundations/utilities/index.d.ts +7 -0
  64. package/dist/foundations/utilities/index.js +6 -0
  65. package/dist/foundations/utilities/merge-props.js.map +1 -1
  66. package/dist/foundations/utilities/use-id.js.map +1 -1
  67. package/dist/fx/fx.js.map +1 -1
  68. package/dist/fx/timing.js.map +1 -1
  69. package/dist/index.d.ts +2 -16
  70. package/dist/index.js +1 -17
  71. package/dist/index.js.map +1 -1
  72. package/dist/jsx/utils.js.map +1 -1
  73. package/dist/jsx-dev-runtime.d.ts +1 -1
  74. package/dist/jsx-dev-runtime.js.map +1 -1
  75. package/dist/jsx-runtime.d.ts +1 -1
  76. package/dist/jsx-runtime.js.map +1 -1
  77. package/dist/renderer/children.js.map +1 -1
  78. package/dist/renderer/cleanup.js.map +1 -1
  79. package/dist/renderer/dom.js +92 -357
  80. package/dist/renderer/dom.js.map +1 -1
  81. package/dist/renderer/evaluate.js +7 -0
  82. package/dist/renderer/evaluate.js.map +1 -1
  83. package/dist/renderer/fastpath.js +20 -18
  84. package/dist/renderer/fastpath.js.map +1 -1
  85. package/dist/renderer/for-commit.js +486 -0
  86. package/dist/renderer/for-commit.js.map +1 -0
  87. package/dist/renderer/index.js.map +1 -1
  88. package/dist/renderer/keyed.js +84 -23
  89. package/dist/renderer/keyed.js.map +1 -1
  90. package/dist/renderer/reconcile.js +11 -18
  91. package/dist/renderer/reconcile.js.map +1 -1
  92. package/dist/renderer/utils.js +5 -1
  93. package/dist/renderer/utils.js.map +1 -1
  94. package/dist/resources/index.d.ts +1 -2
  95. package/dist/resources/index.js +1 -2
  96. package/dist/router/index.d.ts +2 -2
  97. package/dist/router/index.js +2 -2
  98. package/dist/router/match.js.map +1 -1
  99. package/dist/router/navigate.d.ts.map +1 -1
  100. package/dist/router/navigate.js +4 -2
  101. package/dist/router/navigate.js.map +1 -1
  102. package/dist/router/policy.js.map +1 -1
  103. package/dist/router/route-context.js.map +1 -1
  104. package/dist/router/route.d.ts +1 -1
  105. package/dist/router/route.d.ts.map +1 -1
  106. package/dist/router/route.js +2 -33
  107. package/dist/router/route.js.map +1 -1
  108. package/dist/runtime/child-scope.d.ts +1 -0
  109. package/dist/runtime/child-scope.d.ts.map +1 -1
  110. package/dist/runtime/child-scope.js +2 -0
  111. package/dist/runtime/child-scope.js.map +1 -1
  112. package/dist/runtime/component.js +1 -1
  113. package/dist/runtime/component.js.map +1 -1
  114. package/dist/runtime/context.js.map +1 -1
  115. package/dist/runtime/control.js.map +1 -1
  116. package/dist/runtime/derive.d.ts +2 -1
  117. package/dist/runtime/derive.d.ts.map +1 -1
  118. package/dist/runtime/derive.js +15 -10
  119. package/dist/runtime/derive.js.map +1 -1
  120. package/dist/runtime/dev-namespace.js.map +1 -1
  121. package/dist/runtime/effect.d.ts.map +1 -1
  122. package/dist/runtime/effect.js +34 -9
  123. package/dist/runtime/effect.js.map +1 -1
  124. package/dist/runtime/events.js.map +1 -1
  125. package/dist/runtime/execution-model.js.map +1 -1
  126. package/dist/runtime/fastlane.js.map +1 -1
  127. package/dist/runtime/for-bench.d.ts +1 -1
  128. package/dist/runtime/for-bench.d.ts.map +1 -1
  129. package/dist/runtime/for-bench.js +15 -14
  130. package/dist/runtime/for-bench.js.map +1 -1
  131. package/dist/runtime/for.d.ts +1 -0
  132. package/dist/runtime/for.d.ts.map +1 -1
  133. package/dist/runtime/for.js +90 -31
  134. package/dist/runtime/for.js.map +1 -1
  135. package/dist/runtime/operations.d.ts.map +1 -1
  136. package/dist/runtime/operations.js +10 -8
  137. package/dist/runtime/operations.js.map +1 -1
  138. package/dist/runtime/perf-metrics.js +8 -2
  139. package/dist/runtime/perf-metrics.js.map +1 -1
  140. package/dist/runtime/readable.js.map +1 -1
  141. package/dist/runtime/resource-cell.js +3 -2
  142. package/dist/runtime/resource-cell.js.map +1 -1
  143. package/dist/runtime/scheduler.d.ts +0 -1
  144. package/dist/runtime/scheduler.d.ts.map +1 -1
  145. package/dist/runtime/scheduler.js +6 -19
  146. package/dist/runtime/scheduler.js.map +1 -1
  147. package/dist/runtime/selector.d.ts.map +1 -1
  148. package/dist/runtime/selector.js +182 -103
  149. package/dist/runtime/selector.js.map +1 -1
  150. package/dist/runtime/snapshot-source.d.ts +10 -0
  151. package/dist/runtime/snapshot-source.d.ts.map +1 -0
  152. package/dist/runtime/snapshot-source.js +17 -0
  153. package/dist/runtime/snapshot-source.js.map +1 -0
  154. package/dist/runtime/ssr-bridge.js.map +1 -1
  155. package/dist/runtime/state.d.ts.map +1 -1
  156. package/dist/runtime/state.js +1 -5
  157. package/dist/runtime/state.js.map +1 -1
  158. package/dist/ssg/batch-render.js.map +1 -1
  159. package/dist/ssg/create-static-gen.js.map +1 -1
  160. package/dist/ssg/generate-metadata.js.map +1 -1
  161. package/dist/ssg/incremental-manifest.js.map +1 -1
  162. package/dist/ssg/index.d.ts +1 -6
  163. package/dist/ssg/index.js +1 -6
  164. package/dist/ssg/resolve-ssg-data.js.map +1 -1
  165. package/dist/ssg/route-utils.js.map +1 -1
  166. package/dist/ssg/write-static-files.js.map +1 -1
  167. package/dist/ssr/attrs.js.map +1 -1
  168. package/dist/ssr/context.d.ts +3 -1
  169. package/dist/ssr/context.d.ts.map +1 -1
  170. package/dist/ssr/context.js +31 -11
  171. package/dist/ssr/context.js.map +1 -1
  172. package/dist/ssr/escape.js +56 -16
  173. package/dist/ssr/escape.js.map +1 -1
  174. package/dist/ssr/index.d.ts +2 -31
  175. package/dist/ssr/index.d.ts.map +1 -1
  176. package/dist/ssr/index.js +19 -49
  177. package/dist/ssr/index.js.map +1 -1
  178. package/dist/ssr/render-keys.js +1 -12
  179. package/dist/ssr/render-keys.js.map +1 -1
  180. package/dist/ssr/sink.js.map +1 -1
  181. package/dist/ssr/verify-hydration.js +25 -0
  182. package/dist/ssr/verify-hydration.js.map +1 -0
  183. package/package.json +44 -19
  184. package/dist/_virtual/_rolldown/runtime.js +0 -7
  185. package/dist/foundations/core.d.ts +0 -15
  186. package/dist/foundations/core.js +0 -13
  187. package/dist/foundations/structures.d.ts +0 -7
  188. package/dist/foundations/structures.js +0 -6
  189. package/dist/ssg/batch-render.d.ts +0 -16
  190. package/dist/ssg/batch-render.d.ts.map +0 -1
  191. package/dist/ssg/generate-metadata.d.ts +0 -24
  192. package/dist/ssg/generate-metadata.d.ts.map +0 -1
  193. package/dist/ssg/resolve-ssg-data.d.ts +0 -23
  194. package/dist/ssg/resolve-ssg-data.d.ts.map +0 -1
  195. package/dist/ssg/route-utils.d.ts +0 -16
  196. package/dist/ssg/route-utils.d.ts.map +0 -1
  197. package/dist/ssg/write-static-files.d.ts +0 -15
  198. package/dist/ssg/write-static-files.d.ts.map +0 -1
  199. package/dist/ssr/render-keys.d.ts +0 -37
  200. package/dist/ssr/render-keys.d.ts.map +0 -1
  201. package/dist/ssr/stream-render.js +0 -76
  202. package/dist/ssr/stream-render.js.map +0 -1
@@ -15,9 +15,10 @@ import { addDelegatedListener, getDelegatedHandlerForElement, getDelegatedHandle
15
15
  import { REACTIVE_CHILDREN_KEY, elementListeners, elementReactivePropsCleanup, removeAllListeners, removeElementListeners, removeElementReactiveProps, teardownNodeSubtree } from "./cleanup.js";
16
16
  import "../jsx-runtime.js";
17
17
  import { createChildScope, disposeChildScope, rerenderChildScope } from "../runtime/child-scope.js";
18
- import { isBenchMetricScopeActive, recordBenchCounter, recordBenchEvent, recordBenchTiming, withBenchMetricScope } from "../runtime/for-bench.js";
18
+ import { isBenchMetricScopeActive, recordBenchCounter, recordBenchEvent } from "../runtime/for-bench.js";
19
19
  import { clearForDomUpdateState, evaluateForState } from "../runtime/for.js";
20
20
  import { clearCaseDomUpdateState, clearShowDomUpdateState, evaluateCaseState, evaluateShowState } from "../runtime/control.js";
21
+ import { commitForStateBoundaryChildren } from "./for-commit.js";
21
22
  import { reconcileKeyedChildren } from "./reconcile.js";
22
23
  import { isBulkTextFastPathEligible, performBulkTextReplace } from "./children.js";
23
24
  import { createFineGrainedEffect, markFineGrainedEffectsDirtySource } from "../runtime/effect.js";
@@ -1254,10 +1255,48 @@ function normalizeComponentChildren(result) {
1254
1255
  }
1255
1256
  return [result];
1256
1257
  }
1257
- function syncComponentElement(currentDom, node, type, props, parentNamespace) {
1258
+ function syncComponentElement(currentDom, node, type, props, parentNamespace, forceChildrenUpdate = false) {
1258
1259
  const existingHost = currentDom instanceof Element ? currentDom : null;
1259
1260
  const existingInstance = existingHost ? findHostInstanceByType(existingHost, type) : null;
1260
- if (!existingHost || !existingInstance || existingInstance.fn !== type) return null;
1261
+ if (!existingHost) return null;
1262
+ if (!existingInstance || existingInstance.fn !== type) {
1263
+ const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame() || null;
1264
+ const hydrationInstance = createComponentInstance(nextComponentInstanceId(), type, props || {}, existingHost);
1265
+ setVNodeComponentInstance(node, hydrationInstance);
1266
+ if (snapshot) hydrationInstance.ownerFrame = snapshot;
1267
+ const result = withContext(snapshot, () => renderComponentInline(hydrationInstance));
1268
+ if (result instanceof Promise) throw new Error("Async components are not supported. Components must return synchronously.");
1269
+ const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);
1270
+ if (scopedResult && typeof scopedResult === "object" && "type" in scopedResult && typeof scopedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, scopedResult.type)) {
1271
+ withContext(snapshot, () => {
1272
+ updateElementFromVnode(existingHost, inheritComponentKey(scopedResult, node), true, forceChildrenUpdate || hydrationInstance.mounted === false);
1273
+ materializeKey(existingHost, node, props);
1274
+ });
1275
+ mountInstanceInline(hydrationInstance, existingHost);
1276
+ itemInstanceHydrationComplete(existingHost);
1277
+ warnUnusedStateReads(hydrationInstance);
1278
+ return existingHost;
1279
+ }
1280
+ const resolvedResult = resolveNestedComponentResult(scopedResult, snapshot ?? null);
1281
+ if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)) {
1282
+ withContext(snapshot, () => {
1283
+ updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || hydrationInstance.mounted === false);
1284
+ materializeKey(existingHost, node, props);
1285
+ });
1286
+ mountInstanceInline(hydrationInstance, existingHost);
1287
+ itemInstanceHydrationComplete(existingHost);
1288
+ warnUnusedStateReads(hydrationInstance);
1289
+ return existingHost;
1290
+ }
1291
+ const nextDom = materializeComponentResultNode(hydrationInstance, scopedResult, parentNamespace);
1292
+ if (nextDom instanceof Element) materializeKey(nextDom, node, props);
1293
+ if (nextDom !== existingHost && existingHost.parentNode) {
1294
+ existingHost.parentNode.replaceChild(nextDom, existingHost);
1295
+ cleanupDetachedComponentHost(existingHost, hydrationInstance);
1296
+ }
1297
+ warnUnusedStateReads(hydrationInstance);
1298
+ return nextDom;
1299
+ }
1261
1300
  const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame() || existingInstance.ownerFrame || null;
1262
1301
  existingInstance.props = props || {};
1263
1302
  if (snapshot) existingInstance.ownerFrame = snapshot;
@@ -1271,7 +1310,7 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace) {
1271
1310
  }
1272
1311
  if (scopedResult && typeof scopedResult === "object" && "type" in scopedResult && typeof scopedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, scopedResult.type)) {
1273
1312
  withContext(snapshot, () => {
1274
- updateElementFromVnode(existingHost, inheritComponentKey(scopedResult, node), true);
1313
+ updateElementFromVnode(existingHost, inheritComponentKey(scopedResult, node), true, forceChildrenUpdate || existingInstance.mounted === false);
1275
1314
  materializeKey(existingHost, node, props);
1276
1315
  });
1277
1316
  warnUnusedStateReads(existingInstance);
@@ -1280,13 +1319,14 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace) {
1280
1319
  const resolvedResult = resolveNestedComponentResult(scopedResult, snapshot ?? null);
1281
1320
  if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)) {
1282
1321
  withContext(snapshot, () => {
1283
- updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true);
1322
+ updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || existingInstance.mounted === false);
1284
1323
  materializeKey(existingHost, node, props);
1285
1324
  });
1286
1325
  warnUnusedStateReads(existingInstance);
1287
1326
  return existingHost;
1288
1327
  }
1289
1328
  const nextDom = materializeComponentResultNode(existingInstance, scopedResult, parentNamespace);
1329
+ if (nextDom instanceof Element) materializeKey(nextDom, node, props);
1290
1330
  if (nextDom !== existingHost && existingHost.parentNode) {
1291
1331
  existingHost.parentNode.replaceChild(nextDom, existingHost);
1292
1332
  cleanupDetachedComponentHost(existingHost, existingInstance);
@@ -1294,6 +1334,13 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace) {
1294
1334
  warnUnusedStateReads(existingInstance);
1295
1335
  return nextDom;
1296
1336
  }
1337
+ function itemInstanceHydrationComplete(host) {
1338
+ const instance = host.__ASKR_INSTANCE;
1339
+ if (instance) {
1340
+ const scope = instance.scope;
1341
+ if (scope) scope.hydrationPending = false;
1342
+ }
1343
+ }
1297
1344
  function createComponentElement(node, type, props, parentNamespace) {
1298
1345
  const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame();
1299
1346
  const componentFn = type;
@@ -1511,7 +1558,6 @@ function createErrorBoundaryElement(node, props, parentNamespace) {
1511
1558
  function syncForItemDom(parent, scope, vnode) {
1512
1559
  let dom = scope.dom ?? null;
1513
1560
  const parentNamespace = parent.namespaceURI === SVG_NAMESPACE ? SVG_NAMESPACE : void 0;
1514
- if (dom && !scope.needsDomUpdate) return dom;
1515
1561
  if (_isDOMElement(vnode) && typeof vnode.type === "function") {
1516
1562
  const syncedComponentDom = syncComponentElement(dom, vnode, vnode.type, vnode.props ?? {}, parentNamespace);
1517
1563
  if (syncedComponentDom) {
@@ -1593,87 +1639,16 @@ function resolveStableIntrinsicPatchVNode(dom, vnode) {
1593
1639
  return null;
1594
1640
  }
1595
1641
  function tryPatchStableForDirtyItem(scope) {
1642
+ incDevCounter("stableForPatchAttempt");
1596
1643
  if (!(scope.dom instanceof Element) || scope.vnode === void 0) return false;
1597
1644
  const nextIntrinsic = resolveStableIntrinsicPatchVNode(scope.dom, scope.vnode);
1598
1645
  if (!nextIntrinsic) return false;
1599
1646
  const didPatch = patchStableIntrinsicElement(scope.dom, nextIntrinsic);
1600
1647
  const existingInstance = scope.dom.__ASKR_INSTANCE;
1601
1648
  if (didPatch && existingInstance) warnUnusedStateReads(existingInstance);
1649
+ if (didPatch) incDevCounter("stableForPatchHit");
1602
1650
  return didPatch;
1603
1651
  }
1604
- function removeForBoundaryNodes(parent, removedNodes) {
1605
- if (removedNodes.length > 0 && removedNodes.length === parent.childNodes.length) {
1606
- let canBulkClear = true;
1607
- for (let i = 0; i < removedNodes.length; i++) if (removedNodes[i].parentNode !== parent) {
1608
- canBulkClear = false;
1609
- break;
1610
- }
1611
- if (canBulkClear) {
1612
- for (let i = 0; i < removedNodes.length; i++) recordBenchEvent("domRemove");
1613
- withBenchMetricScope("fullClear", () => {
1614
- recordBenchCounter("bulkClearCommits");
1615
- removeAllListeners(parent);
1616
- parent.textContent = "";
1617
- });
1618
- return;
1619
- }
1620
- }
1621
- for (let i = 0; i < removedNodes.length; i++) {
1622
- const node = removedNodes[i];
1623
- if (node.parentNode === parent) {
1624
- recordBenchEvent("domRemove");
1625
- parent.removeChild(node);
1626
- }
1627
- }
1628
- }
1629
- function syncKeyedMapFromForState(parent, forState, strategy, removedNodes) {
1630
- const existing = keyedElements.get(parent);
1631
- const ensureMapEntry = (map, key, element) => {
1632
- map.set(key, element);
1633
- const keyString = String(key);
1634
- map.set(keyString, element);
1635
- const keyNumber = Number(keyString);
1636
- if (!Number.isNaN(keyNumber)) map.set(keyNumber, element);
1637
- };
1638
- if (strategy === "SWAP") {
1639
- if (existing) return;
1640
- }
1641
- if (strategy === "NO_REORDER") {
1642
- if (existing && removedNodes.length === 0) return;
1643
- if (existing) {
1644
- for (const [mapKey, element] of existing) if (element.parentNode !== parent) existing.delete(mapKey);
1645
- if (existing.size > 0) keyedElements.set(parent, existing);
1646
- else keyedElements.delete(parent);
1647
- return;
1648
- }
1649
- }
1650
- if (strategy === "TRUNCATE" && forState.orderedKeys.length === 0) {
1651
- if (existing) existing.clear();
1652
- keyedElements.delete(parent);
1653
- return;
1654
- }
1655
- if (strategy === "APPEND" && existing) {
1656
- for (let i = 0; i < forState.orderedKeys.length; i++) {
1657
- const key = forState.orderedKeys[i];
1658
- if (key === null || existing.has(key)) continue;
1659
- const itemInstance = forState.items.get(key);
1660
- if (itemInstance?.scope.dom instanceof Element) ensureMapEntry(existing, key, itemInstance.scope.dom);
1661
- }
1662
- if (existing.size > 0) keyedElements.set(parent, existing);
1663
- else keyedElements.delete(parent);
1664
- return;
1665
- }
1666
- const nextMap = existing ?? /* @__PURE__ */ new Map();
1667
- nextMap.clear();
1668
- for (let i = 0; i < forState.orderedKeys.length; i++) {
1669
- const key = forState.orderedKeys[i];
1670
- if (key === null) continue;
1671
- const itemInstance = forState.items.get(key);
1672
- if (itemInstance?.scope.dom instanceof Element) ensureMapEntry(nextMap, key, itemInstance.scope.dom);
1673
- }
1674
- if (nextMap.size > 0) keyedElements.set(parent, nextMap);
1675
- else keyedElements.delete(parent);
1676
- }
1677
1652
  function commitForBoundaryChildren(parent, controlState, childrenVNodes) {
1678
1653
  if (controlState.kind !== "for") {
1679
1654
  const activeScope = controlState.activeScope;
@@ -1694,269 +1669,16 @@ function commitForBoundaryChildren(parent, controlState, childrenVNodes) {
1694
1669
  clearControlBoundaryDomUpdateState(controlState);
1695
1670
  return;
1696
1671
  }
1697
- const forState = controlState;
1698
- const domCommitStart = performance.now();
1699
- const hydrateExistingForDom = () => {
1700
- const domKeyMap = getOrBuildDomKeyMap(parent);
1701
- if (!domKeyMap) return;
1702
- for (let i = 0; i < forState.orderedKeys.length; i++) {
1703
- const itemKey = forState.orderedKeys[i];
1704
- const itemInstance = forState.items.get(itemKey);
1705
- if (!itemInstance || itemInstance.scope.dom) continue;
1706
- const existingDom = domKeyMap.get(itemKey);
1707
- if (!existingDom || checkVNodeShapeChanged(existingDom, childrenVNodes[i])) continue;
1708
- itemInstance.scope.dom = existingDom;
1709
- }
1710
- };
1711
- if (forState.orderedKeys.length === 0) {
1712
- removeForBoundaryNodes(parent, forState.lastRemovedNodes);
1713
- const fallbackScope = forState.fallbackScope;
1714
- const fallbackVNode = childrenVNodes[0];
1715
- const nextDom = fallbackScope && fallbackVNode !== void 0 ? syncForItemDom(parent, fallbackScope, fallbackVNode) : null;
1716
- if (nextDom) {
1717
- if (parent.childNodes.length !== 1 || parent.firstChild !== nextDom || forState.lastRemovedNodes.length > 0) parent.replaceChildren(nextDom);
1718
- } else if (parent.firstChild) parent.textContent = "";
1719
- keyedElements.delete(parent);
1720
- forState._hasResolvedItemDom = false;
1721
- recordBenchTiming("domCommit", performance.now() - domCommitStart);
1722
- clearForDomUpdateState(forState);
1723
- return;
1724
- }
1725
- if (!forState._hasResolvedItemDom && parent.childNodes.length > 0) hydrateExistingForDom();
1726
- const getDirtyForIndices = () => {
1727
- const pendingDirtyIndices = forState.pendingDirtyIndices;
1728
- if (pendingDirtyIndices && pendingDirtyIndices.length > 0) return pendingDirtyIndices;
1729
- const dirtyIndices = [];
1730
- for (let index = 0; index < forState.orderedKeys.length; index += 1) {
1731
- const itemKey = forState.orderedKeys[index];
1732
- if (forState.items.get(itemKey)?.scope.needsDomUpdate) dirtyIndices.push(index);
1733
- }
1734
- return dirtyIndices;
1735
- };
1736
- let dirtyIndicesCache = null;
1737
- const ensureDirtyIndices = () => {
1738
- if (dirtyIndicesCache) return dirtyIndicesCache;
1739
- dirtyIndicesCache = getDirtyForIndices();
1740
- return dirtyIndicesCache;
1741
- };
1742
- const commitDirtyNoReorder = (dirtyIndices) => {
1743
- if (dirtyIndices.length === 0) return;
1744
- for (let dirtyIndex = 0; dirtyIndex < dirtyIndices.length; dirtyIndex++) {
1745
- const i = dirtyIndices[dirtyIndex];
1746
- const itemKey = forState.orderedKeys[i];
1747
- const itemInstance = forState.items.get(itemKey);
1748
- if (!itemInstance) continue;
1749
- if (tryPatchStableForDirtyItem(itemInstance.scope)) continue;
1750
- const dom = syncForItemDom(parent, itemInstance.scope, childrenVNodes[i]);
1751
- if (!dom) continue;
1752
- const anchor = parent.childNodes[i] ?? null;
1753
- if (dom.parentNode !== parent || dom !== anchor) {
1754
- recordBenchEvent("domInsert");
1755
- parent.insertBefore(dom, anchor);
1756
- }
1757
- }
1758
- };
1759
- const commitPositional = () => {
1760
- for (let i = 0; i < forState.orderedKeys.length; i++) {
1761
- const itemKey = forState.orderedKeys[i];
1762
- const itemInstance = forState.items.get(itemKey);
1763
- if (!itemInstance) continue;
1764
- const dom = syncForItemDom(parent, itemInstance.scope, childrenVNodes[i]);
1765
- if (!dom) continue;
1766
- if (dom.parentNode !== parent) {
1767
- const anchor = parent.childNodes[i] ?? null;
1768
- recordBenchEvent("domInsert");
1769
- parent.insertBefore(dom, anchor);
1770
- }
1771
- }
1772
- };
1773
- const commitAppend = () => {
1774
- withBenchMetricScope("coldCreate", () => {
1775
- const fragment = parent.ownerDocument.createDocumentFragment();
1776
- let hasPendingAppend = false;
1777
- for (let i = 0; i < forState.orderedKeys.length; i++) {
1778
- const itemKey = forState.orderedKeys[i];
1779
- const itemInstance = forState.items.get(itemKey);
1780
- if (!itemInstance) continue;
1781
- if (itemInstance.scope.dom?.parentNode === parent && !itemInstance.scope.needsDomUpdate) continue;
1782
- const dom = syncForItemDom(parent, itemInstance.scope, childrenVNodes[i]);
1783
- if (!dom) continue;
1784
- if (dom.parentNode !== parent) {
1785
- recordBenchEvent("domInsert");
1786
- fragment.appendChild(dom);
1787
- hasPendingAppend = true;
1788
- }
1789
- }
1790
- if (hasPendingAppend) parent.appendChild(fragment);
1791
- });
1792
- };
1793
- const commitSwap = () => {
1794
- const swapIndices = forState.pendingSwapIndices;
1795
- if (!swapIndices) return;
1796
- let [firstIndex, secondIndex] = swapIndices;
1797
- if (firstIndex === secondIndex) return;
1798
- if (firstIndex > secondIndex) [firstIndex, secondIndex] = [secondIndex, firstIndex];
1799
- const firstKey = forState.orderedKeys[firstIndex];
1800
- const secondKey = forState.orderedKeys[secondIndex];
1801
- const firstItem = forState.items.get(firstKey);
1802
- const secondItem = forState.items.get(secondKey);
1803
- if (!firstItem || !secondItem) {
1804
- commitReorder();
1805
- return;
1806
- }
1807
- const firstDom = syncForItemDom(parent, firstItem.scope, childrenVNodes[firstIndex]);
1808
- const secondDom = syncForItemDom(parent, secondItem.scope, childrenVNodes[secondIndex]);
1809
- if (!firstDom || !secondDom) {
1810
- commitReorder();
1811
- return;
1812
- }
1813
- if (firstDom.parentNode !== parent || secondDom.parentNode !== parent) {
1814
- commitReorder();
1815
- return;
1816
- }
1817
- if ((firstDom.compareDocumentPosition(secondDom) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) return;
1818
- const firstNextSibling = firstDom.nextSibling;
1819
- recordBenchEvent("domMove");
1820
- parent.insertBefore(firstDom, secondDom);
1821
- recordBenchEvent("domMove");
1822
- parent.insertBefore(secondDom, firstNextSibling);
1823
- };
1824
- const commitReorder = () => {
1825
- const keys = forState.orderedKeys;
1826
- const count = keys.length;
1827
- if (forState.pendingMoveOnly && forState.lastRemovedNodes.length === 0) {
1828
- const frag = parent.ownerDocument.createDocumentFragment();
1829
- for (let i = 0; i < count; i++) {
1830
- const itemKey = keys[i];
1831
- const dom = forState.items.get(itemKey)?.scope.dom;
1832
- if (!dom) return;
1833
- recordBenchEvent(dom.parentNode === parent ? "domMove" : "domInsert");
1834
- frag.appendChild(dom);
1835
- }
1836
- parent.replaceChildren(frag);
1837
- return;
1838
- }
1839
- let hasExistingChild = false;
1840
- for (let i = 0; i < count; i++) if (forState.items.get(keys[i])?.scope.dom?.parentNode === parent) {
1841
- hasExistingChild = true;
1842
- break;
1843
- }
1844
- if (!hasExistingChild) {
1845
- withBenchMetricScope("coldCreate", () => {
1846
- const frag = parent.ownerDocument.createDocumentFragment();
1847
- for (let i = 0; i < count; i++) {
1848
- const itemKey = keys[i];
1849
- const itemInstance = forState.items.get(itemKey);
1850
- if (!itemInstance) continue;
1851
- const dom = syncForItemDom(parent, itemInstance.scope, childrenVNodes[i]);
1852
- if (dom) {
1853
- recordBenchEvent("domInsert");
1854
- frag.appendChild(dom);
1855
- }
1856
- }
1857
- recordBenchCounter("replaceChildrenCommits");
1858
- parent.replaceChildren(frag);
1859
- });
1860
- return;
1861
- }
1862
- if (forState.lastRemovedNodes.length === 0) {
1863
- const frag = parent.ownerDocument.createDocumentFragment();
1864
- for (let i = 0; i < count; i++) {
1865
- const itemKey = keys[i];
1866
- const itemInstance = forState.items.get(itemKey);
1867
- if (!itemInstance) continue;
1868
- const dom = syncForItemDom(parent, itemInstance.scope, childrenVNodes[i]);
1869
- if (!dom) continue;
1870
- recordBenchEvent(dom.parentNode === parent ? "domMove" : "domInsert");
1871
- frag.appendChild(dom);
1872
- }
1873
- parent.replaceChildren(frag);
1874
- return;
1875
- }
1876
- for (let i = 0; i < count; i++) {
1877
- const itemKey = keys[i];
1878
- const itemInstance = forState.items.get(itemKey);
1879
- if (!itemInstance) continue;
1880
- const dom = syncForItemDom(parent, itemInstance.scope, childrenVNodes[i]);
1881
- if (!dom) continue;
1882
- const anchor = parent.childNodes[i] ?? null;
1883
- if (dom !== anchor) {
1884
- recordBenchEvent("domMove");
1885
- parent.insertBefore(dom, anchor);
1886
- }
1887
- }
1888
- };
1889
- const isCurrentForDomOrder = () => {
1890
- for (let index = 0; index < forState.orderedKeys.length; index += 1) {
1891
- const itemKey = forState.orderedKeys[index];
1892
- const itemInstance = forState.items.get(itemKey);
1893
- if (!itemInstance?.scope.dom) return false;
1894
- if (parent.childNodes[index] !== itemInstance.scope.dom) return false;
1895
- }
1896
- return true;
1897
- };
1898
- if (forState.lastCommitStrategy === "NO_REORDER" && ensureDirtyIndices().length > 0 && forState.pendingDirtyIndices === null && forState.pendingSwapIndices === null && !forState.pendingMoveOnly && forState.lastRemovedNodes.length === 0 && parent.childNodes.length === forState.orderedKeys.length) {
1899
- if (isCurrentForDomOrder()) {
1900
- commitDirtyNoReorder(ensureDirtyIndices());
1901
- syncKeyedMapFromForState(parent, forState, "NO_REORDER", []);
1902
- } else {
1903
- commitReorder();
1904
- syncKeyedMapFromForState(parent, forState, "FULL_KEYED", []);
1905
- }
1906
- recordBenchTiming("domCommit", performance.now() - domCommitStart);
1907
- clearForDomUpdateState(forState);
1908
- return;
1909
- }
1910
- switch (forState.lastCommitStrategy) {
1911
- case "NO_REORDER":
1912
- commitDirtyNoReorder(ensureDirtyIndices());
1913
- break;
1914
- case "TRUNCATE":
1915
- commitPositional();
1916
- break;
1917
- case "APPEND":
1918
- commitAppend();
1919
- break;
1920
- case "SWAP":
1921
- commitSwap();
1922
- break;
1923
- default:
1924
- commitReorder();
1925
- break;
1926
- }
1927
- removeForBoundaryNodes(parent, forState.lastRemovedNodes);
1928
- syncKeyedMapFromForState(parent, forState, forState.lastCommitStrategy, forState.lastRemovedNodes);
1929
- const syncExactForBoundaryChildren = () => {
1930
- const expectedNodes = [];
1931
- for (let i = 0; i < forState.orderedKeys.length; i++) {
1932
- const itemKey = forState.orderedKeys[i];
1933
- const itemInstance = forState.items.get(itemKey);
1934
- if (!itemInstance) continue;
1935
- const dom = itemInstance.scope.dom ?? syncForItemDom(parent, itemInstance.scope, childrenVNodes[i]);
1936
- if (dom) expectedNodes.push(dom);
1937
- }
1938
- const currentNodes = Array.from(parent.childNodes);
1939
- if (currentNodes.length === expectedNodes.length && currentNodes.every((node, index) => node === expectedNodes[index])) return;
1940
- const expectedNodeSet = new Set(expectedNodes);
1941
- for (const currentNode of currentNodes) {
1942
- if (expectedNodeSet.has(currentNode)) continue;
1943
- if (currentNode instanceof Element) teardownNodeSubtree(currentNode);
1944
- if (currentNode.parentNode === parent) {
1945
- recordBenchEvent("domRemove");
1946
- currentNode.remove();
1947
- }
1948
- }
1949
- parent.replaceChildren(...expectedNodes);
1950
- };
1951
- syncExactForBoundaryChildren();
1952
- forState._hasResolvedItemDom = true;
1953
- recordBenchTiming("domCommit", performance.now() - domCommitStart);
1954
- clearForDomUpdateState(forState);
1672
+ commitForStateBoundaryChildren(parent, controlState, childrenVNodes, {
1673
+ isProduction: () => getRuntimeEnv().NODE_ENV === "production",
1674
+ syncForItemDom,
1675
+ tryPatchStableForDirtyItem
1676
+ });
1955
1677
  }
1956
1678
  /**
1957
1679
  * Update an existing element's attributes and children from vnode
1958
1680
  */
1959
- function updateElementFromVnode(el, vnode, updateChildren = true) {
1681
+ function updateElementFromVnode(el, vnode, updateChildren = true, forceChildrenUpdate = false) {
1960
1682
  if (!_isDOMElement(vnode)) return;
1961
1683
  const props = vnode.props || {};
1962
1684
  const domVNode = vnode;
@@ -1968,11 +1690,11 @@ function updateElementFromVnode(el, vnode, updateChildren = true) {
1968
1690
  const existingListeners = elementListeners.get(el);
1969
1691
  const existingReactiveProps = elementReactivePropsCleanup.get(el);
1970
1692
  if ((!existingListeners || existingListeners.size === 0) && (!existingReactiveProps || existingReactiveProps.size === 0)) {
1971
- if (hasMatchingStaticProps(el, props, vnode.type)) {
1693
+ if (!forceChildrenUpdate && hasMatchingStaticProps(el, props, vnode.type)) {
1972
1694
  if (updateChildren) {
1973
1695
  const children = props.children ?? vnode.children;
1974
- if (canReuseStaticSubtree(el, domVNode)) return;
1975
- updateElementChildren(el, children);
1696
+ if (!forceChildrenUpdate && canReuseStaticSubtree(el, domVNode)) return;
1697
+ updateElementChildren(el, children, forceChildrenUpdate);
1976
1698
  }
1977
1699
  return;
1978
1700
  }
@@ -2122,10 +1844,10 @@ function updateElementFromVnode(el, vnode, updateChildren = true) {
2122
1844
  if (updateChildren) {
2123
1845
  const children = props.children ?? vnode.children;
2124
1846
  if (usesReactiveChildren) return;
2125
- updateElementChildren(el, children);
1847
+ updateElementChildren(el, children, forceChildrenUpdate);
2126
1848
  }
2127
1849
  }
2128
- function updateElementChildren(el, children) {
1850
+ function updateElementChildren(el, children, forceUpdate = false) {
2129
1851
  const directControlBoundary = getDirectControlBoundaryVNode(children);
2130
1852
  if (directControlBoundary) {
2131
1853
  const controlState = getControlBoundaryState(directControlBoundary);
@@ -2145,7 +1867,7 @@ function updateElementChildren(el, children) {
2145
1867
  return;
2146
1868
  }
2147
1869
  if (!Array.isArray(children) && isFragmentVNode(children)) {
2148
- updateUnkeyedChildren(el, normalizeComponentChildren(children));
1870
+ updateUnkeyedChildren(el, normalizeComponentChildren(children), forceUpdate);
2149
1871
  return;
2150
1872
  }
2151
1873
  if (!Array.isArray(children) && (typeof children === "string" || typeof children === "number")) {
@@ -2178,11 +1900,11 @@ function updateElementChildren(el, children) {
2178
1900
  keyedElements.delete(el);
2179
1901
  return;
2180
1902
  }
2181
- updateUnkeyedChildren(el, children);
1903
+ updateUnkeyedChildren(el, children, forceUpdate);
2182
1904
  return;
2183
1905
  }
2184
1906
  if (_isDOMElement(children)) {
2185
- updateUnkeyedChildren(el, [children]);
1907
+ updateUnkeyedChildren(el, [children], forceUpdate);
2186
1908
  return;
2187
1909
  }
2188
1910
  for (let n = el.firstChild; n;) {
@@ -2236,6 +1958,11 @@ function tagsEqualIgnoreCase(elementTagName, vnodeType) {
2236
1958
  if (upperCommon !== null && elementTagName === upperCommon) return true;
2237
1959
  return tagNamesEqualIgnoreCase(elementTagName, vnodeType);
2238
1960
  }
1961
+ const STATIC_CHILD_SLOTS_CACHE = Symbol.for("__askrStaticChildSlots");
1962
+ let staticChildSlotsCacheEnabled = true;
1963
+ function setStaticChildSlotsCacheEnabled(enabled) {
1964
+ staticChildSlotsCacheEnabled = enabled;
1965
+ }
2239
1966
  function collectStaticChildSlots(children, slots) {
2240
1967
  if (isFragmentVNode(children)) return collectStaticChildSlots(children.props?.children ?? children.children, slots);
2241
1968
  if (Array.isArray(children)) {
@@ -2259,9 +1986,18 @@ function collectStaticChildSlots(children, slots) {
2259
1986
  }
2260
1987
  return false;
2261
1988
  }
2262
- function getStaticChildSlots(children) {
1989
+ function getStaticChildSlots(vnode) {
1990
+ if (staticChildSlotsCacheEnabled) {
1991
+ const cached = vnode[STATIC_CHILD_SLOTS_CACHE];
1992
+ if (cached !== void 0) return cached;
1993
+ }
2263
1994
  const slots = [];
2264
- return collectStaticChildSlots(children, slots) ? slots : null;
1995
+ const staticSlots = collectStaticChildSlots(vnode.props?.children ?? vnode.children, slots) ? slots : null;
1996
+ if (staticChildSlotsCacheEnabled) {
1997
+ const cacheNode = vnode;
1998
+ if (Object.isExtensible(vnode)) cacheNode[STATIC_CHILD_SLOTS_CACHE] = staticSlots;
1999
+ }
2000
+ return staticSlots;
2265
2001
  }
2266
2002
  function hasMatchingStaticProps(el, props, vnodeType) {
2267
2003
  let staticPropCount = 0;
@@ -2299,9 +2035,8 @@ function hasMatchingStaticProps(el, props, vnodeType) {
2299
2035
  }
2300
2036
  function canReuseStaticSubtree(el, vnode) {
2301
2037
  if (typeof vnode.type !== "string" || !tagsEqualIgnoreCase(el.tagName, vnode.type)) return false;
2302
- const props = vnode.props || {};
2303
- if (!hasMatchingStaticProps(el, props, vnode.type)) return false;
2304
- const slots = getStaticChildSlots(props.children ?? vnode.children);
2038
+ if (!hasMatchingStaticProps(el, vnode.props || {}, vnode.type)) return false;
2039
+ const slots = getStaticChildSlots(vnode);
2305
2040
  if (!slots) return false;
2306
2041
  if (el.childNodes.length !== slots.length) return false;
2307
2042
  for (let index = 0; index < slots.length; index += 1) {
@@ -2317,11 +2052,11 @@ function canReuseStaticSubtree(el, vnode) {
2317
2052
  }
2318
2053
  return true;
2319
2054
  }
2320
- function updateUnkeyedChildren(parent, newChildren) {
2055
+ function updateUnkeyedChildren(parent, newChildren, forceUpdate = false) {
2321
2056
  const parentNamespace = parent.namespaceURI === SVG_NAMESPACE ? SVG_NAMESPACE : void 0;
2322
2057
  const trySyncComponentChild = (currentDom, next) => {
2323
2058
  if (typeof next.type !== "function") return null;
2324
- return syncComponentElement(currentDom, next, next.type, (next.props ?? {}) || {}, parentNamespace);
2059
+ return syncComponentElement(currentDom, next, next.type, (next.props ?? {}) || {}, parentNamespace, forceUpdate);
2325
2060
  };
2326
2061
  const hasText = newChildren.some((c) => typeof c === "string" || typeof c === "number");
2327
2062
  const hasElements = newChildren.some((c) => _isDOMElement(c));
@@ -2334,7 +2069,7 @@ function updateUnkeyedChildren(parent, newChildren) {
2334
2069
  const next = newChildren[i];
2335
2070
  const current = c[i];
2336
2071
  if (!current || next === void 0) continue;
2337
- if (_isDOMElement(next) && typeof next.type === "string") if (tagsEqualIgnoreCase(current.tagName, next.type)) updateElementFromVnode(current, next);
2072
+ if (_isDOMElement(next) && typeof next.type === "string") if (tagsEqualIgnoreCase(current.tagName, next.type)) updateElementFromVnode(current, next, true, forceUpdate);
2338
2073
  else {
2339
2074
  const dom = createDOMNode(next, parentNamespace);
2340
2075
  if (dom) {
@@ -2388,7 +2123,7 @@ function updateUnkeyedChildren(parent, newChildren) {
2388
2123
  }
2389
2124
  else if (_isDOMElement(next)) if (currentNode.nodeType === 1) {
2390
2125
  const currentEl = currentNode;
2391
- if (typeof next.type === "string") if (tagsEqualIgnoreCase(currentEl.tagName, next.type)) updateElementFromVnode(currentEl, next);
2126
+ if (typeof next.type === "string") if (tagsEqualIgnoreCase(currentEl.tagName, next.type)) updateElementFromVnode(currentEl, next, true, forceUpdate);
2392
2127
  else {
2393
2128
  const dom = createDOMNode(next, parentNamespace);
2394
2129
  if (dom) {
@@ -2450,7 +2185,7 @@ function updateUnkeyedChildren(parent, newChildren) {
2450
2185
  const textNode = document.createTextNode(String(next));
2451
2186
  teardownNodeSubtree(current);
2452
2187
  parent.replaceChild(textNode, current);
2453
- } else if (_isDOMElement(next)) if (typeof next.type === "string") if (tagsEqualIgnoreCase(current.tagName, next.type)) updateElementFromVnode(current, next);
2188
+ } else if (_isDOMElement(next)) if (typeof next.type === "string") if (tagsEqualIgnoreCase(current.tagName, next.type)) updateElementFromVnode(current, next, true, forceUpdate);
2454
2189
  else {
2455
2190
  const dom = createDOMNode(next, parentNamespace);
2456
2191
  if (dom) {
@@ -2479,6 +2214,6 @@ function updateUnkeyedChildren(parent, newChildren) {
2479
2214
  }
2480
2215
  }
2481
2216
  //#endregion
2482
- export { IS_DOM_AVAILABLE, commitForBoundaryChildren, createDOMNode, createForBoundary, markReactivePropsDirtySource, syncComponentElement, tryPatchStableForDirtyItem, updateElementChildren, updateElementFromVnode, updateUnkeyedChildren };
2217
+ export { IS_DOM_AVAILABLE, commitForBoundaryChildren, createDOMNode, createForBoundary, markReactivePropsDirtySource, setStaticChildSlotsCacheEnabled, syncComponentElement, tryPatchStableForDirtyItem, updateElementChildren, updateElementFromVnode, updateUnkeyedChildren };
2483
2218
 
2484
2219
  //# sourceMappingURL=dom.js.map