@askrjs/askr 0.0.52 → 0.0.53
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.
- package/README.md +5 -1
- package/dist/{runtime/scheduler.js → access-Bg4RJNC8.js} +182 -9
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +103 -0
- package/dist/{common/attr-names.js → attr-names-CjhzmHOn.js} +1 -1
- package/dist/benchmark.d.ts +6 -2
- package/dist/benchmark.js +63 -11
- package/dist/boot/index.d.ts +61 -2
- package/dist/boot/index.js +1 -203
- package/dist/boot-j2KoN6ss.js +647 -0
- package/dist/cleanup-COv77su2.js +487 -0
- package/dist/component-internal-B3z7GXlD.js +614 -0
- package/dist/component-lifecycle-CO4hXlP4.js +357 -0
- package/dist/{runtime/component-scope.js → component-scope-CC3cojX9.js} +8 -1
- package/dist/component-scope-CvPba6O6.d.ts +12 -0
- package/dist/components/index.d.ts +17 -2
- package/dist/components/index.js +39 -1
- package/dist/compose-ref-Cc_YkUpM.js +92 -0
- package/dist/{foundations/utilities/compose-ref.d.ts → compose-ref-Cizq72-x.d.ts} +1 -1
- package/dist/control/index.d.ts +1 -3
- package/dist/control/index.js +1 -3
- package/dist/control-BQvNVfAd.d.ts +436 -0
- package/dist/control-BYyLTFyw.js +165 -0
- package/dist/control-Bf4Wkdvv.d.ts +9 -0
- package/dist/{common/control.js → control-DhFRTIoE.js} +1 -1
- package/dist/data/index.d.ts +2 -6
- package/dist/data/index.js +4 -5
- package/dist/data-DnxnDxD-.js +559 -0
- package/dist/{data/data-runtime.js → data-runtime-SJ1BSUvk.js} +32 -31
- package/dist/deferred-lKE8uR0z.js +386 -0
- package/dist/{runtime/effect.js → effect-BwnIvLah.js} +4 -4
- package/dist/fastlane-Dw8SOBr9.js +343 -0
- package/dist/for-internal-BKf_Tnv1.js +1563 -0
- package/dist/foundations/icon/index.d.ts +68 -2
- package/dist/foundations/icon/index.js +85 -1
- package/dist/foundations/index.d.ts +2 -5
- package/dist/foundations/index.js +2 -5
- package/dist/foundations/interactions/index.d.ts +264 -6
- package/dist/foundations/interactions/index.js +1 -6
- package/dist/foundations/state/index.d.ts +32 -1
- package/dist/foundations/state/index.js +78 -1
- package/dist/foundations/structures/index.d.ts +2 -7
- package/dist/foundations/structures/index.js +2 -7
- package/dist/foundations/utilities/index.d.ts +2 -6
- package/dist/foundations/utilities/index.js +2 -5
- package/dist/fx/index.d.ts +190 -3
- package/dist/fx/index.js +454 -4
- package/dist/index-31Uoz_NS.d.ts +239 -0
- package/dist/index-Bki2rqcr.d.ts +233 -0
- package/dist/index-BnU0NPwM.d.ts +101 -0
- package/dist/index-D73jgYx1.d.ts +48 -0
- package/dist/{runtime/runtime.d.ts → index-R2JJIbM-.d.ts} +31 -8
- package/dist/index-SJXJkssx.d.ts +44 -0
- package/dist/index.d.ts +8 -13
- package/dist/index.js +150 -15
- package/dist/interactions-w7gQN4ha.js +280 -0
- package/dist/{data/invalidation-listeners.js → invalidation-listeners-Des3AHYs.js} +1 -1
- package/dist/{common/props.d.ts → jsx-CP0gmYwJ.d.ts} +17 -5
- package/dist/{common/jsx.js → jsx-CUpRxrLH.js} +1 -1
- package/dist/jsx-dev-runtime.d.ts +2 -4
- package/dist/jsx-dev-runtime.js +7 -5
- package/dist/jsx-runtime-92bV2hSa.d.ts +34 -0
- package/dist/jsx-runtime-BVVgDSdq.d.ts +1 -0
- package/dist/jsx-runtime.d.ts +2 -35
- package/dist/jsx-runtime.js +11 -5
- package/dist/{runtime/lifecycle-operations.js → lifecycle-operations-D9va7GOU.js} +4 -5
- package/dist/navigate-BVDCzOuB.d.ts +34 -0
- package/dist/navigate-CmPLSXyw.js +1449 -0
- package/dist/{runtime/portal.js → portal-CyU3Ucf2.js} +33 -36
- package/dist/query-registry-CQIT4mXr.js +73 -0
- package/dist/{common/render-context.js → render-context-Clw3rFiO.js} +14 -6
- package/dist/renderer-DzPjeLby.js +6197 -0
- package/dist/{runtime/resource-operation.js → resource-operation-CEzfpnDk.js} +118 -15
- package/dist/resources/index.d.ts +42 -3
- package/dist/resources/index.js +3 -4
- package/dist/{common/route-activity.js → route-activity-CNJfpwx-.js} +1 -1
- package/dist/route-matching-vJpvLVbX.js +515 -0
- package/dist/router/index.d.ts +166 -14
- package/dist/router/index.js +150 -12
- package/dist/{common/router.d.ts → router-CeYvjj5_.d.ts} +72 -28
- package/dist/{common/router-internal.js → router-internal-BC0w1_xk.js} +1 -1
- package/dist/{runtime/scheduler.d.ts → scheduler-CmLO4Dfm.d.ts} +1 -3
- package/dist/{runtime/selector.js → selector-DafVYzV4.js} +34 -11
- package/dist/{runtime/snapshot-source.js → snapshot-source-BB42xgwb.js} +1 -1
- package/dist/ssg/index.d.ts +252 -4
- package/dist/ssg/index.js +857 -1
- package/dist/ssr/index.d.ts +225 -8
- package/dist/ssr/index.js +3 -6
- package/dist/{common/ssr.js → ssr-CbQO5xd3.js} +1 -1
- package/dist/ssr-D3t80Rc0.js +1413 -0
- package/dist/{runtime/state.js → state-DPl8lffD.js} +3 -5
- package/dist/structures-DUB3HchX.js +221 -0
- package/dist/testing/index.d.ts +3 -2
- package/dist/testing/index.js +2 -5
- package/dist/{jsx/types.d.ts → types-DnQVG4ZY.d.ts} +2 -5
- package/dist/{foundations/utilities/use-id.js → utilities-C_CGX4Dz.js} +1 -1
- package/dist/{ssr/verify-hydration.js → verify-hydration-io9ahUeq.js} +2 -2
- package/dist/{common/vnode.js → vnode-CGMJYPMB.js} +2 -2
- package/package.json +12 -7
- package/dist/bench/components/benchmark-row.d.ts +0 -20
- package/dist/bench/components/benchmark-row.js +0 -40
- package/dist/bench/components/benchmark-table.js +0 -23
- package/dist/bin/askr-ssg.d.ts +0 -27
- package/dist/bin/askr-ssg.js +0 -186
- package/dist/boot/hydration.js +0 -139
- package/dist/boot/root-lifecycle.d.ts +0 -18
- package/dist/boot/root-lifecycle.js +0 -209
- package/dist/boot/route-startup.js +0 -54
- package/dist/boot/types.d.ts +0 -61
- package/dist/common/component.d.ts +0 -18
- package/dist/common/control.d.ts +0 -12
- package/dist/common/dom-range.d.ts +0 -13
- package/dist/common/env.js +0 -41
- package/dist/common/error-boundary.d.ts +0 -15
- package/dist/common/invariant.js +0 -15
- package/dist/common/jsx.d.ts +0 -22
- package/dist/common/logger.js +0 -34
- package/dist/common/promise.js +0 -6
- package/dist/common/ssr-errors.d.ts +0 -10
- package/dist/common/ssr-errors.js +0 -14
- package/dist/common/ssr.d.ts +0 -41
- package/dist/common/vnode.d.ts +0 -21
- package/dist/components/error-boundary.d.ts +0 -14
- package/dist/components/error-boundary.js +0 -41
- package/dist/components/link.d.ts +0 -68
- package/dist/components/link.js +0 -74
- package/dist/control/case.d.ts +0 -18
- package/dist/control/case.js +0 -68
- package/dist/control/for.d.ts +0 -23
- package/dist/control/for.js +0 -61
- package/dist/control/shared.d.ts +0 -8
- package/dist/control/shared.js +0 -18
- package/dist/control/show.d.ts +0 -14
- package/dist/control/show.js +0 -32
- package/dist/data/data-runtime.d.ts +0 -27
- package/dist/data/invalidation.d.ts +0 -8
- package/dist/data/invalidation.js +0 -25
- package/dist/data/mutation-cell.d.ts +0 -27
- package/dist/data/mutation-cell.js +0 -133
- package/dist/data/query-cell.d.ts +0 -47
- package/dist/data/query-cell.js +0 -324
- package/dist/data/query-key.js +0 -40
- package/dist/data/shared.js +0 -20
- package/dist/data/testing.js +0 -2
- package/dist/data/types.d.ts +0 -160
- package/dist/foundations/icon/icon.d.ts +0 -52
- package/dist/foundations/icon/icon.js +0 -86
- package/dist/foundations/icon/icon.types.d.ts +0 -21
- package/dist/foundations/interactions/dismissable.d.ts +0 -71
- package/dist/foundations/interactions/dismissable.js +0 -24
- package/dist/foundations/interactions/focusable.d.ts +0 -21
- package/dist/foundations/interactions/focusable.js +0 -16
- package/dist/foundations/interactions/hoverable.d.ts +0 -25
- package/dist/foundations/interactions/hoverable.js +0 -13
- package/dist/foundations/interactions/interaction-policy.d.ts +0 -49
- package/dist/foundations/interactions/interaction-policy.js +0 -120
- package/dist/foundations/interactions/pressable.d.ts +0 -60
- package/dist/foundations/interactions/pressable.js +0 -49
- package/dist/foundations/interactions/roving-focus.d.ts +0 -51
- package/dist/foundations/interactions/roving-focus.js +0 -69
- package/dist/foundations/state/controllable.d.ts +0 -32
- package/dist/foundations/state/controllable.js +0 -80
- package/dist/foundations/structures/collection.d.ts +0 -51
- package/dist/foundations/structures/collection.js +0 -49
- package/dist/foundations/structures/layer.d.ts +0 -80
- package/dist/foundations/structures/layer.js +0 -79
- package/dist/foundations/structures/layout.d.ts +0 -32
- package/dist/foundations/structures/layout.js +0 -11
- package/dist/foundations/structures/portal.d.ts +0 -2
- package/dist/foundations/structures/portal.js +0 -3
- package/dist/foundations/structures/presence.d.ts +0 -36
- package/dist/foundations/structures/presence.js +0 -37
- package/dist/foundations/structures/slot.d.ts +0 -34
- package/dist/foundations/structures/slot.js +0 -39
- package/dist/foundations/utilities/aria.d.ts +0 -15
- package/dist/foundations/utilities/aria.js +0 -15
- package/dist/foundations/utilities/compose-handlers.d.ts +0 -36
- package/dist/foundations/utilities/compose-handlers.js +0 -18
- package/dist/foundations/utilities/compose-ref.js +0 -16
- package/dist/foundations/utilities/event-types.d.ts +0 -19
- package/dist/foundations/utilities/merge-props.d.ts +0 -4
- package/dist/foundations/utilities/merge-props.js +0 -47
- package/dist/foundations/utilities/use-id.d.ts +0 -31
- package/dist/fx/fx.d.ts +0 -32
- package/dist/fx/fx.js +0 -211
- package/dist/fx/noop.js +0 -7
- package/dist/fx/timing.d.ts +0 -158
- package/dist/fx/timing.js +0 -241
- package/dist/jsx/index.d.ts +0 -2
- package/dist/jsx/index.js +0 -4
- package/dist/jsx/types.js +0 -2
- package/dist/jsx/utils.d.ts +0 -4
- package/dist/jsx/utils.js +0 -17
- package/dist/jsx-runtime2.d.ts +0 -3
- package/dist/jsx-runtime2.js +0 -4
- package/dist/renderer/attributes.js +0 -254
- package/dist/renderer/boundaries.js +0 -142
- package/dist/renderer/boundary-materialization.js +0 -72
- package/dist/renderer/boundary-range-adoption.js +0 -76
- package/dist/renderer/boundary-range-sync.js +0 -101
- package/dist/renderer/boundary-state.js +0 -50
- package/dist/renderer/child-shape.js +0 -83
- package/dist/renderer/children-fastpath.js +0 -149
- package/dist/renderer/children.js +0 -158
- package/dist/renderer/cleanup.js +0 -267
- package/dist/renderer/component-host-cleanup.js +0 -143
- package/dist/renderer/component-host-instances.js +0 -116
- package/dist/renderer/component-host-replacement.js +0 -105
- package/dist/renderer/component-host-results.js +0 -138
- package/dist/renderer/component-host.js +0 -172
- package/dist/renderer/dom-host.js +0 -11
- package/dist/renderer/dom-internal.js +0 -243
- package/dist/renderer/dom-range.js +0 -161
- package/dist/renderer/dom.js +0 -11
- package/dist/renderer/element-children.js +0 -359
- package/dist/renderer/env.js +0 -2
- package/dist/renderer/error-boundary-dom.js +0 -86
- package/dist/renderer/evaluate-dom-range.js +0 -84
- package/dist/renderer/evaluate-reconcile.js +0 -257
- package/dist/renderer/evaluate.js +0 -95
- package/dist/renderer/fastpath.js +0 -142
- package/dist/renderer/for-commit-dom-map.js +0 -71
- package/dist/renderer/for-commit-removal.js +0 -27
- package/dist/renderer/for-commit-reorder.js +0 -87
- package/dist/renderer/for-commit.js +0 -442
- package/dist/renderer/hydration-boundaries.js +0 -60
- package/dist/renderer/hydration-listener-transaction.js +0 -49
- package/dist/renderer/index.js +0 -39
- package/dist/renderer/intrinsic-blueprint-analysis.js +0 -202
- package/dist/renderer/intrinsic-blueprint-bindings.js +0 -152
- package/dist/renderer/intrinsic-blueprint-materialization.js +0 -100
- package/dist/renderer/intrinsic-blueprint.js +0 -30
- package/dist/renderer/intrinsic-hydration-adoption.js +0 -66
- package/dist/renderer/keyed-children.js +0 -26
- package/dist/renderer/keyed.js +0 -167
- package/dist/renderer/namespaces.js +0 -21
- package/dist/renderer/prop-bindings.js +0 -315
- package/dist/renderer/reactive-child-dom.js +0 -139
- package/dist/renderer/reactive-child-sources.js +0 -182
- package/dist/renderer/reactive-children.js +0 -303
- package/dist/renderer/reconcile-commit.js +0 -36
- package/dist/renderer/reconcile-fastpaths.js +0 -100
- package/dist/renderer/reconcile-resolution.js +0 -163
- package/dist/renderer/reconcile.js +0 -37
- package/dist/renderer/retained-element-rollback.js +0 -288
- package/dist/renderer/stable-patch.js +0 -80
- package/dist/renderer/static-reuse.js +0 -94
- package/dist/renderer/types.js +0 -2
- package/dist/renderer/utils.js +0 -265
- package/dist/router/access.js +0 -34
- package/dist/router/activity.d.ts +0 -9
- package/dist/router/activity.js +0 -85
- package/dist/router/authoring.d.ts +0 -21
- package/dist/router/authoring.js +0 -196
- package/dist/router/internal-types.d.ts +0 -30
- package/dist/router/lazy.d.ts +0 -18
- package/dist/router/lazy.js +0 -50
- package/dist/router/manifest.d.ts +0 -9
- package/dist/router/manifest.js +0 -47
- package/dist/router/match.js +0 -120
- package/dist/router/navigate.d.ts +0 -10
- package/dist/router/navigate.js +0 -73
- package/dist/router/navigation-registry.d.ts +0 -31
- package/dist/router/navigation-registry.js +0 -103
- package/dist/router/navigation-scroll.d.ts +0 -13
- package/dist/router/navigation-scroll.js +0 -91
- package/dist/router/navigation-targets.d.ts +0 -30
- package/dist/router/navigation-targets.js +0 -634
- package/dist/router/policy.d.ts +0 -27
- package/dist/router/policy.js +0 -130
- package/dist/router/rendering.d.ts +0 -9
- package/dist/router/rendering.js +0 -47
- package/dist/router/resolution.d.ts +0 -3
- package/dist/router/resolution.js +0 -84
- package/dist/router/route-context.js +0 -77
- package/dist/router/route-matching.d.ts +0 -19
- package/dist/router/route-matching.js +0 -173
- package/dist/router/route-query.d.ts +0 -16
- package/dist/router/route-query.js +0 -45
- package/dist/router/route.d.ts +0 -8
- package/dist/router/route.js +0 -10
- package/dist/router/store.d.ts +0 -49
- package/dist/router/store.js +0 -169
- package/dist/router/testing.js +0 -4
- package/dist/runtime/access.d.ts +0 -19
- package/dist/runtime/access.js +0 -43
- package/dist/runtime/child-scope.d.ts +0 -41
- package/dist/runtime/child-scope.js +0 -134
- package/dist/runtime/component-cleanup.d.ts +0 -15
- package/dist/runtime/component-cleanup.js +0 -68
- package/dist/runtime/component-commit.js +0 -167
- package/dist/runtime/component-facade.d.ts +0 -5
- package/dist/runtime/component-facade.js +0 -6
- package/dist/runtime/component-internal.d.ts +0 -105
- package/dist/runtime/component-internal.js +0 -237
- package/dist/runtime/component-lifecycle.d.ts +0 -10
- package/dist/runtime/component-lifecycle.js +0 -33
- package/dist/runtime/component-scope.d.ts +0 -54
- package/dist/runtime/component.d.ts +0 -5
- package/dist/runtime/component.js +0 -6
- package/dist/runtime/context.d.ts +0 -72
- package/dist/runtime/context.js +0 -236
- package/dist/runtime/control.d.ts +0 -62
- package/dist/runtime/control.js +0 -239
- package/dist/runtime/derive.d.ts +0 -16
- package/dist/runtime/derive.js +0 -140
- package/dist/runtime/dev-namespace.d.ts +0 -30
- package/dist/runtime/dev-namespace.js +0 -64
- package/dist/runtime/effect.d.ts +0 -35
- package/dist/runtime/error-boundary.d.ts +0 -4
- package/dist/runtime/error-boundary.js +0 -29
- package/dist/runtime/events.d.ts +0 -58
- package/dist/runtime/events.js +0 -201
- package/dist/runtime/execution-model.d.ts +0 -6
- package/dist/runtime/execution-model.js +0 -13
- package/dist/runtime/fastlane.d.ts +0 -33
- package/dist/runtime/fastlane.js +0 -173
- package/dist/runtime/for-bench.d.ts +0 -40
- package/dist/runtime/for-bench.js +0 -13
- package/dist/runtime/for-internal.d.ts +0 -106
- package/dist/runtime/for-internal.js +0 -285
- package/dist/runtime/for-reconcile.d.ts +0 -7
- package/dist/runtime/for-reconcile.js +0 -442
- package/dist/runtime/for-scopes.d.ts +0 -26
- package/dist/runtime/for-scopes.js +0 -280
- package/dist/runtime/for-signals.d.ts +0 -39
- package/dist/runtime/for-signals.js +0 -213
- package/dist/runtime/for-types.d.ts +0 -8
- package/dist/runtime/for.d.ts +0 -4
- package/dist/runtime/for.js +0 -5
- package/dist/runtime/index.d.ts +0 -24
- package/dist/runtime/index.js +0 -33
- package/dist/runtime/lifecycle-batch.d.ts +0 -59
- package/dist/runtime/lifecycle-batch.js +0 -178
- package/dist/runtime/lifecycle-operation-settlement.d.ts +0 -5
- package/dist/runtime/lifecycle-operation-settlement.js +0 -51
- package/dist/runtime/lifecycle-operations.d.ts +0 -30
- package/dist/runtime/operations.d.ts +0 -3
- package/dist/runtime/operations.js +0 -3
- package/dist/runtime/perf-metrics.d.ts +0 -27
- package/dist/runtime/perf-metrics.js +0 -6
- package/dist/runtime/portal.d.ts +0 -21
- package/dist/runtime/readable.d.ts +0 -34
- package/dist/runtime/readable.js +0 -183
- package/dist/runtime/resource-cell.js +0 -112
- package/dist/runtime/resource-operation.d.ts +0 -12
- package/dist/runtime/runtime.js +0 -57
- package/dist/runtime/selector-store.js +0 -22
- package/dist/runtime/selector.d.ts +0 -10
- package/dist/runtime/snapshot-source.d.ts +0 -9
- package/dist/runtime/state.d.ts +0 -54
- package/dist/ssg/batch-render.js +0 -101
- package/dist/ssg/create-static-gen.d.ts +0 -66
- package/dist/ssg/create-static-gen.js +0 -250
- package/dist/ssg/generate-metadata.js +0 -92
- package/dist/ssg/generation-plan.js +0 -68
- package/dist/ssg/incremental-manifest.js +0 -54
- package/dist/ssg/resolve-ssg-data.js +0 -103
- package/dist/ssg/route-utils.js +0 -22
- package/dist/ssg/static-routes.js +0 -100
- package/dist/ssg/types.d.ts +0 -188
- package/dist/ssg/write-static-files.js +0 -77
- package/dist/ssr/attrs.js +0 -92
- package/dist/ssr/boundaries.js +0 -124
- package/dist/ssr/component-runtime.js +0 -85
- package/dist/ssr/context.d.ts +0 -49
- package/dist/ssr/context.js +0 -89
- package/dist/ssr/errors.d.ts +0 -9
- package/dist/ssr/errors.js +0 -12
- package/dist/ssr/escape.js +0 -191
- package/dist/ssr/hydration-data.js +0 -8
- package/dist/ssr/hydration-verify.d.ts +0 -11
- package/dist/ssr/hydration-verify.js +0 -171
- package/dist/ssr/index-internal.d.ts +0 -14
- package/dist/ssr/index-internal.js +0 -17
- package/dist/ssr/render-keys.js +0 -14
- package/dist/ssr/render-resolved.d.ts +0 -19
- package/dist/ssr/render-resolved.js +0 -33
- package/dist/ssr/render-sync.d.ts +0 -20
- package/dist/ssr/render-sync.js +0 -283
- package/dist/ssr/route-policy-resolution.js +0 -76
- package/dist/ssr/route-render.d.ts +0 -76
- package/dist/ssr/route-render.js +0 -118
- package/dist/ssr/sink.d.ts +0 -25
- package/dist/ssr/sink.js +0 -84
- package/dist/ssr/types.d.ts +0 -22
|
@@ -0,0 +1,1563 @@
|
|
|
1
|
+
import { r as _isDOMElement } from "./vnode-CGMJYPMB.js";
|
|
2
|
+
import { b as isDevelopmentEnvironment, o as getRuntimeRenderer, v as logger } from "./access-Bg4RJNC8.js";
|
|
3
|
+
import { f as notifyReadableReaders, l as markReactivePropsDirtySource, m as shouldCoalesceFineGrainedItemReads, p as recordReadableRead, u as markReadableDerivedSubscribersDirty } from "./fastlane-Dw8SOBr9.js";
|
|
4
|
+
import { n as createComponentInstance, s as renderScopedComponent } from "./component-internal-B3z7GXlD.js";
|
|
5
|
+
import { h as getCurrentStateIndex, i as claimHookIndex, o as clearRenderTracking, p as getCurrentInstance } from "./component-scope-CC3cojX9.js";
|
|
6
|
+
import { _ as registerOwnedChildScope, c as finalizeInlineReadSubscriptions, f as registerLifecycleTransaction, h as cleanupComponent, v as unregisterOwnedChildScope } from "./component-lifecycle-CO4hXlP4.js";
|
|
7
|
+
//#region src/runtime/child-scope.ts
|
|
8
|
+
const EMPTY_CHILD_SCOPE_PROPS = {};
|
|
9
|
+
const childScopesByInstance = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
function executeChildScopeComponent() {
|
|
11
|
+
const instance = getCurrentInstance();
|
|
12
|
+
const scope = instance ? childScopesByInstance.get(instance) : void 0;
|
|
13
|
+
if (!scope?._renderFn) return null;
|
|
14
|
+
return scope._renderFn();
|
|
15
|
+
}
|
|
16
|
+
function ensureChildScopeFlushTask(scope) {
|
|
17
|
+
const instance = scope.componentInstance;
|
|
18
|
+
if (instance._pendingFlushTask) return;
|
|
19
|
+
instance._pendingFlushTask = () => {
|
|
20
|
+
instance.hasPendingUpdate = false;
|
|
21
|
+
if (instance.notifyUpdate === null || scope._disposed) return;
|
|
22
|
+
renderScope(scope);
|
|
23
|
+
scope._onDirty?.();
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var ChildScopeImpl = class {
|
|
27
|
+
constructor(parent, key, onDirty, ownership) {
|
|
28
|
+
this.previousVnode = void 0;
|
|
29
|
+
this.vnode = void 0;
|
|
30
|
+
this.dom = void 0;
|
|
31
|
+
this.range = void 0;
|
|
32
|
+
this.needsDomUpdate = true;
|
|
33
|
+
this.hydrationPending = true;
|
|
34
|
+
this.blueprintOwner = void 0;
|
|
35
|
+
this._renderFn = void 0;
|
|
36
|
+
this._disposed = false;
|
|
37
|
+
this.key = key;
|
|
38
|
+
this._parent = parent;
|
|
39
|
+
this._onDirty = onDirty;
|
|
40
|
+
this._ownership = ownership;
|
|
41
|
+
this._startStateIndex = getCurrentStateIndex();
|
|
42
|
+
this.componentInstance = createComponentInstance("child-scope", executeChildScopeComponent, EMPTY_CHILD_SCOPE_PROPS, null);
|
|
43
|
+
childScopesByInstance.set(this.componentInstance, this);
|
|
44
|
+
if (parent) {
|
|
45
|
+
this.componentInstance.parentInstance = parent;
|
|
46
|
+
this.componentInstance.ownerFrame = parent.ownerFrame;
|
|
47
|
+
this.componentInstance.portalScope = parent.portalScope;
|
|
48
|
+
if (ownership) ownership.add(this);
|
|
49
|
+
else registerOwnedChildScope(parent, this);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
markDirty() {
|
|
53
|
+
this.needsDomUpdate = true;
|
|
54
|
+
}
|
|
55
|
+
render(renderFn) {
|
|
56
|
+
this._renderFn = renderFn;
|
|
57
|
+
return renderScope(this);
|
|
58
|
+
}
|
|
59
|
+
dispose() {
|
|
60
|
+
if (this._disposed) return;
|
|
61
|
+
this._disposed = true;
|
|
62
|
+
if (this._parent) if (this._ownership) this._ownership.delete(this);
|
|
63
|
+
else unregisterOwnedChildScope(this._parent, this);
|
|
64
|
+
childScopesByInstance.delete(this.componentInstance);
|
|
65
|
+
cleanupComponent(this.componentInstance);
|
|
66
|
+
this._renderFn = void 0;
|
|
67
|
+
this.previousVnode = void 0;
|
|
68
|
+
this.vnode = void 0;
|
|
69
|
+
this.dom = void 0;
|
|
70
|
+
this.range = void 0;
|
|
71
|
+
this.needsDomUpdate = false;
|
|
72
|
+
this.hydrationPending = false;
|
|
73
|
+
this.blueprintOwner = void 0;
|
|
74
|
+
this.componentInstance.hasPendingUpdate = false;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function renderScope(scope) {
|
|
78
|
+
if (scope._disposed) {
|
|
79
|
+
if (isDevelopmentEnvironment()) throw new Error(`[askr] Attempted to render disposed child scope ${String(scope.key)}.`);
|
|
80
|
+
return scope.vnode;
|
|
81
|
+
}
|
|
82
|
+
if (!scope._renderFn) return scope.vnode;
|
|
83
|
+
const { componentInstance } = scope;
|
|
84
|
+
const previousVNode = scope.vnode;
|
|
85
|
+
try {
|
|
86
|
+
const nextVNode = renderScopedComponent(componentInstance, scope._startStateIndex, scope._renderFn);
|
|
87
|
+
if (previousVNode && nextVNode && _isDOMElement(previousVNode) && _isDOMElement(nextVNode) && typeof previousVNode.type === "function" && previousVNode.type === nextVNode.type && "__instance" in previousVNode && !("__instance" in nextVNode)) nextVNode.__instance = previousVNode.__instance;
|
|
88
|
+
scope.previousVnode = previousVNode;
|
|
89
|
+
scope.vnode = nextVNode;
|
|
90
|
+
scope.markDirty();
|
|
91
|
+
if ((componentInstance._pendingReadSources?.size ?? 0) > 0) ensureChildScopeFlushTask(scope);
|
|
92
|
+
finalizeInlineReadSubscriptions(componentInstance, componentInstance._currentRenderToken, componentInstance._pendingReadSources, componentInstance._pendingReadSourceVersions);
|
|
93
|
+
clearRenderTracking(componentInstance);
|
|
94
|
+
return scope.vnode;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
componentInstance.hasPendingUpdate = false;
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function rerenderChildScope(scope) {
|
|
101
|
+
return renderScope(scope);
|
|
102
|
+
}
|
|
103
|
+
/** @internal */
|
|
104
|
+
function captureChildScopeTransactionSnapshot(scope) {
|
|
105
|
+
const mutableScope = scope;
|
|
106
|
+
return {
|
|
107
|
+
previousVnode: scope.previousVnode,
|
|
108
|
+
vnode: scope.vnode,
|
|
109
|
+
dom: scope.dom,
|
|
110
|
+
range: scope.range,
|
|
111
|
+
domTextData: scope.dom?.nodeType === 3 ? scope.dom.data : void 0,
|
|
112
|
+
needsDomUpdate: scope.needsDomUpdate,
|
|
113
|
+
hydrationPending: scope.hydrationPending,
|
|
114
|
+
renderFn: mutableScope._renderFn
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** @internal */
|
|
118
|
+
function restoreChildScopeTransactionSnapshot(scope, snapshot) {
|
|
119
|
+
const mutableScope = scope;
|
|
120
|
+
scope.previousVnode = snapshot.previousVnode;
|
|
121
|
+
scope.vnode = snapshot.vnode;
|
|
122
|
+
scope.dom = snapshot.dom;
|
|
123
|
+
scope.range = snapshot.range;
|
|
124
|
+
if (snapshot.domTextData !== void 0 && snapshot.dom?.nodeType === 3) snapshot.dom.data = snapshot.domTextData;
|
|
125
|
+
scope.needsDomUpdate = snapshot.needsDomUpdate;
|
|
126
|
+
scope.hydrationPending = snapshot.hydrationPending;
|
|
127
|
+
mutableScope._renderFn = snapshot.renderFn;
|
|
128
|
+
}
|
|
129
|
+
function disposeChildScope(scope) {
|
|
130
|
+
scope.dispose();
|
|
131
|
+
}
|
|
132
|
+
function createChildScope(parent, key, onDirty, ownership) {
|
|
133
|
+
return new ChildScopeImpl(parent, key, onDirty, ownership);
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/runtime/control.ts
|
|
137
|
+
const SHOW_TRUTHY_KEY = "__show-truthy__";
|
|
138
|
+
const SHOW_FALLBACK_KEY = "__show-fallback__";
|
|
139
|
+
const CASE_FALLBACK_KEY = "__case-fallback__";
|
|
140
|
+
function getBranchScopes(state) {
|
|
141
|
+
const scopes = [];
|
|
142
|
+
if (state.activeScope) scopes.push(state.activeScope);
|
|
143
|
+
if (state instanceof Object && "fallbackScope" in state) {
|
|
144
|
+
if (state.fallbackScope) scopes.push(state.fallbackScope);
|
|
145
|
+
}
|
|
146
|
+
if (state instanceof Object && "truthyScope" in state) {
|
|
147
|
+
if (state.truthyScope) scopes.push(state.truthyScope);
|
|
148
|
+
}
|
|
149
|
+
return scopes;
|
|
150
|
+
}
|
|
151
|
+
function beginControlTransaction(state) {
|
|
152
|
+
if (state._transaction) return state._transaction;
|
|
153
|
+
const scopeSnapshots = /* @__PURE__ */ new Map();
|
|
154
|
+
for (const scope of getBranchScopes(state)) scopeSnapshots.set(scope, captureChildScopeTransactionSnapshot(scope));
|
|
155
|
+
const transaction = {
|
|
156
|
+
state,
|
|
157
|
+
snapshot: {
|
|
158
|
+
activeKey: state.activeKey,
|
|
159
|
+
activeScope: state.activeScope,
|
|
160
|
+
activeVNodes: state.activeVNodes.slice(),
|
|
161
|
+
lastRemovedNodes: state.lastRemovedNodes.slice(),
|
|
162
|
+
lastRemovedRanges: state.lastRemovedRanges.slice(),
|
|
163
|
+
scopeSnapshots,
|
|
164
|
+
fallbackScope: "fallbackScope" in state ? state.fallbackScope : void 0,
|
|
165
|
+
truthyScope: "truthyScope" in state ? state.truthyScope : void 0
|
|
166
|
+
},
|
|
167
|
+
removedScopes: [],
|
|
168
|
+
shouldClearDomUpdateState: false,
|
|
169
|
+
registered: false
|
|
170
|
+
};
|
|
171
|
+
state._transaction = transaction;
|
|
172
|
+
transaction.registered = registerLifecycleTransaction(transaction, () => commitControlTransaction(state, transaction), () => rollbackControlTransaction(state, transaction));
|
|
173
|
+
return transaction;
|
|
174
|
+
}
|
|
175
|
+
function stageBranchRemoval(state, scope) {
|
|
176
|
+
if (!scope) return;
|
|
177
|
+
const transaction = state._transaction;
|
|
178
|
+
if (transaction && !transaction.removedScopes.includes(scope)) transaction.removedScopes.push(scope);
|
|
179
|
+
else if (!transaction) disposeChildScope(scope);
|
|
180
|
+
const removedDom = scope.dom;
|
|
181
|
+
if (removedDom) state.lastRemovedNodes.push(removedDom);
|
|
182
|
+
if (scope.range) state.lastRemovedRanges.push(scope.range);
|
|
183
|
+
}
|
|
184
|
+
function commitControlTransaction(state, transaction) {
|
|
185
|
+
if (state._transaction !== transaction) return;
|
|
186
|
+
const errors = [];
|
|
187
|
+
for (const scope of transaction.removedScopes) try {
|
|
188
|
+
disposeChildScope(scope);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
errors.push(error);
|
|
191
|
+
}
|
|
192
|
+
if (transaction.shouldClearDomUpdateState) {
|
|
193
|
+
if ("truthyScope" in state && state.truthyScope) state.truthyScope.needsDomUpdate = false;
|
|
194
|
+
if ("fallbackScope" in state && state.fallbackScope) state.fallbackScope.needsDomUpdate = false;
|
|
195
|
+
if (state.activeScope) state.activeScope.needsDomUpdate = false;
|
|
196
|
+
state.lastRemovedNodes = [];
|
|
197
|
+
state.lastRemovedRanges = [];
|
|
198
|
+
}
|
|
199
|
+
state._transaction = null;
|
|
200
|
+
if (errors.length > 0) throw new AggregateError(errors, "Control branch cleanup failed");
|
|
201
|
+
}
|
|
202
|
+
function rollbackControlTransaction(state, transaction) {
|
|
203
|
+
if (state._transaction !== transaction) return;
|
|
204
|
+
const committedScopes = new Set(transaction.snapshot.scopeSnapshots.keys());
|
|
205
|
+
const currentScopes = getBranchScopes(state);
|
|
206
|
+
const errors = [];
|
|
207
|
+
for (const scope of currentScopes) {
|
|
208
|
+
if (committedScopes.has(scope)) continue;
|
|
209
|
+
try {
|
|
210
|
+
disposeChildScope(scope);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
errors.push(error);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
state.activeKey = transaction.snapshot.activeKey;
|
|
216
|
+
state.activeScope = transaction.snapshot.activeScope;
|
|
217
|
+
state.activeVNodes = transaction.snapshot.activeVNodes;
|
|
218
|
+
state.lastRemovedNodes = transaction.snapshot.lastRemovedNodes;
|
|
219
|
+
state.lastRemovedRanges = transaction.snapshot.lastRemovedRanges;
|
|
220
|
+
if ("truthyScope" in state) state.truthyScope = transaction.snapshot.truthyScope ?? null;
|
|
221
|
+
if ("fallbackScope" in state) state.fallbackScope = transaction.snapshot.fallbackScope ?? null;
|
|
222
|
+
for (const [scope, snapshot] of transaction.snapshot.scopeSnapshots) restoreChildScopeTransactionSnapshot(scope, snapshot);
|
|
223
|
+
state._transaction = null;
|
|
224
|
+
if (errors.length > 0) throw new AggregateError(errors, "Control branch rollback cleanup failed");
|
|
225
|
+
}
|
|
226
|
+
function finishImmediateControlTransaction(state, transaction) {
|
|
227
|
+
if (state._transaction === transaction && !transaction.registered) commitControlTransaction(state, transaction);
|
|
228
|
+
}
|
|
229
|
+
function createBranchScope(state, key) {
|
|
230
|
+
return createChildScope(state.parentInstance, key, () => {
|
|
231
|
+
if (state._enqueueBoundaryCommit) {
|
|
232
|
+
state._enqueueBoundaryCommit();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
state.parentInstance?._enqueueRun?.();
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function createShowState(value, renderTruthy, renderFallback) {
|
|
239
|
+
return {
|
|
240
|
+
kind: "show",
|
|
241
|
+
activeKey: null,
|
|
242
|
+
activeScope: null,
|
|
243
|
+
activeVNodes: [],
|
|
244
|
+
fallbackScope: null,
|
|
245
|
+
lastRemovedNodes: [],
|
|
246
|
+
lastRemovedRanges: [],
|
|
247
|
+
parentInstance: getCurrentInstance(),
|
|
248
|
+
_enqueueBoundaryCommit: null,
|
|
249
|
+
_hasPendingBoundaryCommit: false,
|
|
250
|
+
_transaction: null,
|
|
251
|
+
renderFallback,
|
|
252
|
+
renderTruthy,
|
|
253
|
+
selectedValue: value,
|
|
254
|
+
truthyScope: null
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function evaluateShowState(state) {
|
|
258
|
+
const transaction = beginControlTransaction(state);
|
|
259
|
+
state.lastRemovedNodes = [];
|
|
260
|
+
state.lastRemovedRanges = [];
|
|
261
|
+
try {
|
|
262
|
+
if (state.selectedValue) {
|
|
263
|
+
if (state.fallbackScope) {
|
|
264
|
+
stageBranchRemoval(state, state.fallbackScope);
|
|
265
|
+
state.fallbackScope = null;
|
|
266
|
+
}
|
|
267
|
+
const truthyScope = state.truthyScope ?? createBranchScope(state, SHOW_TRUTHY_KEY);
|
|
268
|
+
state.truthyScope = truthyScope;
|
|
269
|
+
state.activeScope = truthyScope;
|
|
270
|
+
state.activeKey = SHOW_TRUTHY_KEY;
|
|
271
|
+
const vnode = truthyScope.render(() => state.renderTruthy(state.selectedValue));
|
|
272
|
+
state.activeVNodes = vnode == null || vnode === false ? [] : [vnode];
|
|
273
|
+
} else {
|
|
274
|
+
if (state.truthyScope) {
|
|
275
|
+
stageBranchRemoval(state, state.truthyScope);
|
|
276
|
+
state.truthyScope = null;
|
|
277
|
+
}
|
|
278
|
+
if (!state.renderFallback) {
|
|
279
|
+
if (state.fallbackScope) {
|
|
280
|
+
stageBranchRemoval(state, state.fallbackScope);
|
|
281
|
+
state.fallbackScope = null;
|
|
282
|
+
}
|
|
283
|
+
state.activeKey = null;
|
|
284
|
+
state.activeScope = null;
|
|
285
|
+
state.activeVNodes = [];
|
|
286
|
+
} else {
|
|
287
|
+
const fallbackScope = state.fallbackScope ?? createBranchScope(state, SHOW_FALLBACK_KEY);
|
|
288
|
+
state.fallbackScope = fallbackScope;
|
|
289
|
+
state.activeScope = fallbackScope;
|
|
290
|
+
state.activeKey = SHOW_FALLBACK_KEY;
|
|
291
|
+
const vnode = fallbackScope.render(state.renderFallback);
|
|
292
|
+
state.activeVNodes = vnode == null || vnode === false ? [] : [vnode];
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
finishImmediateControlTransaction(state, transaction);
|
|
296
|
+
return state.activeVNodes;
|
|
297
|
+
} catch (error) {
|
|
298
|
+
rollbackControlTransaction(state, transaction);
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function clearShowDomUpdateState(state) {
|
|
303
|
+
if (state.truthyScope) state.truthyScope.needsDomUpdate = false;
|
|
304
|
+
if (state.fallbackScope) state.fallbackScope.needsDomUpdate = false;
|
|
305
|
+
if (state._transaction) {
|
|
306
|
+
state._transaction.shouldClearDomUpdateState = true;
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
state.lastRemovedNodes = [];
|
|
310
|
+
state.lastRemovedRanges = [];
|
|
311
|
+
}
|
|
312
|
+
function createCaseState(matches, fallback) {
|
|
313
|
+
return {
|
|
314
|
+
kind: "case",
|
|
315
|
+
activeKey: null,
|
|
316
|
+
activeScope: null,
|
|
317
|
+
activeVNodes: [],
|
|
318
|
+
fallback,
|
|
319
|
+
lastRemovedNodes: [],
|
|
320
|
+
lastRemovedRanges: [],
|
|
321
|
+
matches,
|
|
322
|
+
parentInstance: getCurrentInstance(),
|
|
323
|
+
_enqueueBoundaryCommit: null,
|
|
324
|
+
_hasPendingBoundaryCommit: false,
|
|
325
|
+
_transaction: null
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function evaluateCaseState(state) {
|
|
329
|
+
const transaction = beginControlTransaction(state);
|
|
330
|
+
state.lastRemovedNodes = [];
|
|
331
|
+
state.lastRemovedRanges = [];
|
|
332
|
+
try {
|
|
333
|
+
const selectedMatch = state.matches.find((candidate) => Boolean(candidate.when)) ?? null;
|
|
334
|
+
const nextKey = selectedMatch?.key ?? (state.fallback ? CASE_FALLBACK_KEY : null);
|
|
335
|
+
if (nextKey === null) {
|
|
336
|
+
if (state.activeScope) stageBranchRemoval(state, state.activeScope);
|
|
337
|
+
state.activeKey = null;
|
|
338
|
+
state.activeScope = null;
|
|
339
|
+
state.activeVNodes = [];
|
|
340
|
+
} else {
|
|
341
|
+
if (state.activeScope && state.activeKey !== nextKey) {
|
|
342
|
+
stageBranchRemoval(state, state.activeScope);
|
|
343
|
+
state.activeScope = null;
|
|
344
|
+
}
|
|
345
|
+
const activeScope = state.activeScope ?? createBranchScope(state, nextKey);
|
|
346
|
+
state.activeKey = nextKey;
|
|
347
|
+
state.activeScope = activeScope;
|
|
348
|
+
const renderBranch = selectedMatch?.render ?? state.fallback;
|
|
349
|
+
const vnode = renderBranch ? activeScope.render(renderBranch) : null;
|
|
350
|
+
state.activeVNodes = vnode == null || vnode === false ? [] : [vnode];
|
|
351
|
+
}
|
|
352
|
+
finishImmediateControlTransaction(state, transaction);
|
|
353
|
+
return state.activeVNodes;
|
|
354
|
+
} catch (error) {
|
|
355
|
+
rollbackControlTransaction(state, transaction);
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function clearCaseDomUpdateState(state) {
|
|
360
|
+
if (state.activeScope) state.activeScope.needsDomUpdate = false;
|
|
361
|
+
if (state._transaction) {
|
|
362
|
+
state._transaction.shouldClearDomUpdateState = true;
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
state.lastRemovedNodes = [];
|
|
366
|
+
state.lastRemovedRanges = [];
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/runtime/for-signals.ts
|
|
370
|
+
function peekForSignal() {
|
|
371
|
+
return this._value;
|
|
372
|
+
}
|
|
373
|
+
function setForValueSignal(newValue, notifyReaders = true) {
|
|
374
|
+
if (Object.is(this._value, newValue)) return;
|
|
375
|
+
this._value = newValue;
|
|
376
|
+
if (notifyReaders) notifyForSignalReaders(this);
|
|
377
|
+
}
|
|
378
|
+
function setForIndexValue(newValue, notifyReaders = true) {
|
|
379
|
+
const nextValue = typeof newValue === "function" ? newValue(this._value) : newValue;
|
|
380
|
+
if (nextValue === this._value) return;
|
|
381
|
+
this._value = nextValue;
|
|
382
|
+
if (notifyReaders) notifyForSignalReaders(this);
|
|
383
|
+
}
|
|
384
|
+
function notifyForSignalReaders(source, skipInstance, skipOwnedBy) {
|
|
385
|
+
markReadableDerivedSubscribersDirty(source);
|
|
386
|
+
markReactivePropsDirtySource(source);
|
|
387
|
+
notifyReadableReaders(source, skipInstance, skipOwnedBy);
|
|
388
|
+
}
|
|
389
|
+
function createForIndexSignal(initialIndex) {
|
|
390
|
+
function readIndexSignal() {
|
|
391
|
+
const signal = readIndexSignal;
|
|
392
|
+
signal._hasBeenRead = true;
|
|
393
|
+
recordReadableRead(signal);
|
|
394
|
+
return signal._value;
|
|
395
|
+
}
|
|
396
|
+
const indexSignal = readIndexSignal;
|
|
397
|
+
indexSignal._value = initialIndex;
|
|
398
|
+
indexSignal.peek = peekForSignal;
|
|
399
|
+
indexSignal.set = setForIndexValue;
|
|
400
|
+
indexSignal._hasBeenRead = false;
|
|
401
|
+
return indexSignal;
|
|
402
|
+
}
|
|
403
|
+
function syncForIndexSignal(indexSignal, nextIndex) {
|
|
404
|
+
if (indexSignal.peek() === nextIndex) return false;
|
|
405
|
+
indexSignal.set(nextIndex, indexSignal._hasBeenRead);
|
|
406
|
+
return indexSignal._hasBeenRead === true;
|
|
407
|
+
}
|
|
408
|
+
function createForItemSignal(initialItem) {
|
|
409
|
+
function readItemSignal() {
|
|
410
|
+
const signal = readItemSignal;
|
|
411
|
+
signal._hasBeenRead = true;
|
|
412
|
+
recordReadableRead(signal);
|
|
413
|
+
return signal._value;
|
|
414
|
+
}
|
|
415
|
+
const itemSignal = readItemSignal;
|
|
416
|
+
itemSignal._value = initialItem;
|
|
417
|
+
itemSignal.peek = peekForSignal;
|
|
418
|
+
itemSignal.set = setForValueSignal;
|
|
419
|
+
itemSignal._hasBeenRead = false;
|
|
420
|
+
return itemSignal;
|
|
421
|
+
}
|
|
422
|
+
function createForItemPropertySignal(initialValue) {
|
|
423
|
+
function readPropertySignal() {
|
|
424
|
+
const signal = readPropertySignal;
|
|
425
|
+
signal._hasBeenRead = true;
|
|
426
|
+
recordReadableRead(signal);
|
|
427
|
+
return signal._value;
|
|
428
|
+
}
|
|
429
|
+
const propertySignal = readPropertySignal;
|
|
430
|
+
propertySignal._value = initialValue;
|
|
431
|
+
propertySignal.peek = peekForSignal;
|
|
432
|
+
propertySignal.set = setForValueSignal;
|
|
433
|
+
propertySignal._hasBeenRead = false;
|
|
434
|
+
return propertySignal;
|
|
435
|
+
}
|
|
436
|
+
function readForItemProperty(item, prop) {
|
|
437
|
+
return Reflect.get(Object(item), prop);
|
|
438
|
+
}
|
|
439
|
+
function haveSameOwnKeys(previousItem, nextItem) {
|
|
440
|
+
const previousKeys = Reflect.ownKeys(Object(previousItem));
|
|
441
|
+
const nextKeys = Reflect.ownKeys(Object(nextItem));
|
|
442
|
+
if (previousKeys.length !== nextKeys.length) return false;
|
|
443
|
+
for (let i = 0; i < previousKeys.length; i += 1) if (previousKeys[i] !== nextKeys[i]) return false;
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
function scopeReadsSource(scope, source) {
|
|
447
|
+
const readers = source._readers;
|
|
448
|
+
if (!readers || readers.size === 0) return false;
|
|
449
|
+
for (const reader of readers.keys()) {
|
|
450
|
+
let current = reader;
|
|
451
|
+
while (current) {
|
|
452
|
+
if (current === scope.componentInstance) return true;
|
|
453
|
+
current = current.parentInstance;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
function scopeDirectlyReadsSource(scope, source) {
|
|
459
|
+
return source._readers?.has(scope.componentInstance) ?? false;
|
|
460
|
+
}
|
|
461
|
+
function isForParentReader(parentInstance, reader) {
|
|
462
|
+
let current = parentInstance;
|
|
463
|
+
while (current) {
|
|
464
|
+
if (current === reader) return true;
|
|
465
|
+
current = current.parentInstance;
|
|
466
|
+
}
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
function removeForParentReaders(parentInstance, source) {
|
|
470
|
+
const readers = source._readers;
|
|
471
|
+
if (!readers || readers.size === 0) return;
|
|
472
|
+
for (const reader of readers.keys()) if (isForParentReader(parentInstance, reader)) {
|
|
473
|
+
if (readers.delete(reader) && false);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
function getOrCreateForItemPropertySignal(state, prop) {
|
|
477
|
+
const item = state.currentItem;
|
|
478
|
+
const propertySignals = state.propertySignals ?? (state.propertySignals = /* @__PURE__ */ new Map());
|
|
479
|
+
const existingSignal = propertySignals.get(prop);
|
|
480
|
+
if (existingSignal) return existingSignal;
|
|
481
|
+
const propertySignal = createForItemPropertySignal(readForItemProperty(item, prop));
|
|
482
|
+
propertySignals.set(prop, propertySignal);
|
|
483
|
+
return propertySignal;
|
|
484
|
+
}
|
|
485
|
+
function canProxyForItem(item) {
|
|
486
|
+
return typeof item === "function" || typeof item === "object" && item !== null && !Array.isArray(item);
|
|
487
|
+
}
|
|
488
|
+
function createReactiveForItem(item) {
|
|
489
|
+
const target = Object.create(null);
|
|
490
|
+
const state = {
|
|
491
|
+
currentItem: item,
|
|
492
|
+
itemSignal: null,
|
|
493
|
+
propertySignals: null,
|
|
494
|
+
coalescedProperties: null,
|
|
495
|
+
coalescedProperty2: null,
|
|
496
|
+
wholeItemRead: false,
|
|
497
|
+
proxy: void 0
|
|
498
|
+
};
|
|
499
|
+
target[REACTIVE_FOR_ITEM_STATE] = state;
|
|
500
|
+
state.proxy = new Proxy(target, REACTIVE_FOR_ITEM_PROXY_HANDLER);
|
|
501
|
+
return state;
|
|
502
|
+
}
|
|
503
|
+
const REACTIVE_FOR_ITEM_STATE = Symbol("askr.reactive-for-item-state");
|
|
504
|
+
function getReactiveForItemState(target) {
|
|
505
|
+
return target[REACTIVE_FOR_ITEM_STATE];
|
|
506
|
+
}
|
|
507
|
+
function getWholeItemSignal(state) {
|
|
508
|
+
let signal = state.itemSignal;
|
|
509
|
+
if (!signal) {
|
|
510
|
+
signal = createForItemSignal(state.currentItem);
|
|
511
|
+
state.itemSignal = signal;
|
|
512
|
+
}
|
|
513
|
+
return signal;
|
|
514
|
+
}
|
|
515
|
+
const REACTIVE_FOR_ITEM_PROXY_HANDLER = {
|
|
516
|
+
get(target, prop, receiver) {
|
|
517
|
+
if (prop !== REACTIVE_FOR_ITEM_STATE && prop in target) return Reflect.get(target, prop, receiver);
|
|
518
|
+
const metadata = getReactiveForItemState(target);
|
|
519
|
+
const currentItem = metadata.currentItem;
|
|
520
|
+
if (typeof prop !== "symbol") {
|
|
521
|
+
if (shouldCoalesceFineGrainedItemReads()) {
|
|
522
|
+
const properties = metadata.coalescedProperties;
|
|
523
|
+
if (properties === null) metadata.coalescedProperties = prop;
|
|
524
|
+
else if (Array.isArray(properties)) {
|
|
525
|
+
if (!properties.includes(prop)) properties.push(prop);
|
|
526
|
+
} else if (properties !== prop && metadata.coalescedProperty2 !== prop) if (metadata.coalescedProperty2 === null) metadata.coalescedProperty2 = prop;
|
|
527
|
+
else {
|
|
528
|
+
metadata.coalescedProperties = [
|
|
529
|
+
properties,
|
|
530
|
+
metadata.coalescedProperty2,
|
|
531
|
+
prop
|
|
532
|
+
];
|
|
533
|
+
metadata.coalescedProperty2 = null;
|
|
534
|
+
}
|
|
535
|
+
let itemSignal = metadata.itemSignal;
|
|
536
|
+
if (!itemSignal) {
|
|
537
|
+
itemSignal = createForItemSignal(currentItem);
|
|
538
|
+
metadata.itemSignal = itemSignal;
|
|
539
|
+
}
|
|
540
|
+
itemSignal();
|
|
541
|
+
return readForItemProperty(currentItem, prop);
|
|
542
|
+
}
|
|
543
|
+
return getOrCreateForItemPropertySignal(metadata, prop)();
|
|
544
|
+
}
|
|
545
|
+
metadata.wholeItemRead = true;
|
|
546
|
+
recordReadableRead(getWholeItemSignal(metadata));
|
|
547
|
+
return Reflect.get(Object(currentItem), prop, receiver);
|
|
548
|
+
},
|
|
549
|
+
has(target, prop) {
|
|
550
|
+
if (prop === REACTIVE_FOR_ITEM_STATE) return false;
|
|
551
|
+
const metadata = getReactiveForItemState(target);
|
|
552
|
+
metadata.wholeItemRead = true;
|
|
553
|
+
recordReadableRead(getWholeItemSignal(metadata));
|
|
554
|
+
return prop in target || prop in Object(metadata.currentItem);
|
|
555
|
+
},
|
|
556
|
+
ownKeys(target) {
|
|
557
|
+
const metadata = getReactiveForItemState(target);
|
|
558
|
+
metadata.wholeItemRead = true;
|
|
559
|
+
recordReadableRead(getWholeItemSignal(metadata));
|
|
560
|
+
const keys = /* @__PURE__ */ new Set();
|
|
561
|
+
for (const key of Reflect.ownKeys(target)) if (key !== REACTIVE_FOR_ITEM_STATE) keys.add(key);
|
|
562
|
+
for (const key of Reflect.ownKeys(Object(metadata.currentItem))) keys.add(key);
|
|
563
|
+
return Array.from(keys);
|
|
564
|
+
},
|
|
565
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
566
|
+
if (prop === REACTIVE_FOR_ITEM_STATE) return;
|
|
567
|
+
const metadata = getReactiveForItemState(target);
|
|
568
|
+
metadata.wholeItemRead = true;
|
|
569
|
+
recordReadableRead(getWholeItemSignal(metadata));
|
|
570
|
+
const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
571
|
+
if (ownDescriptor) return ownDescriptor;
|
|
572
|
+
return Object.getOwnPropertyDescriptor(Object(metadata.currentItem), prop);
|
|
573
|
+
},
|
|
574
|
+
getPrototypeOf(target) {
|
|
575
|
+
const metadata = getReactiveForItemState(target);
|
|
576
|
+
metadata.wholeItemRead = true;
|
|
577
|
+
recordReadableRead(getWholeItemSignal(metadata));
|
|
578
|
+
return Object.getPrototypeOf(Object(metadata.currentItem));
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
const recordBenchEvent = (_event) => {};
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region src/runtime/for-scopes.ts
|
|
584
|
+
function recordRemovedBoundary(forState, dom, range) {
|
|
585
|
+
if (range && !range.single) forState.lastRemovedRanges.push(range);
|
|
586
|
+
else if (dom) forState.lastRemovedNodes.push(dom);
|
|
587
|
+
}
|
|
588
|
+
function captureRemovedScopeNodes(forState, dom, range) {
|
|
589
|
+
const transaction = forState._transaction;
|
|
590
|
+
if (!transaction) return;
|
|
591
|
+
const nodes = transaction.removedScopeNodes ??= [];
|
|
592
|
+
if (range && !range.single) for (let node = range.start.nextSibling; node && node !== range.end; node = node.nextSibling) nodes.push(node);
|
|
593
|
+
else if (dom) nodes.push(dom);
|
|
594
|
+
}
|
|
595
|
+
function enqueueForScopeUpdate(parent) {
|
|
596
|
+
parent?._enqueueRun?.();
|
|
597
|
+
}
|
|
598
|
+
const forStatesByScope = /* @__PURE__ */ new WeakMap();
|
|
599
|
+
function enqueueForBoundaryScopeCommit() {
|
|
600
|
+
const forState = this.blueprintOwner ?? forStatesByScope.get(this);
|
|
601
|
+
if (!forState) return;
|
|
602
|
+
if (forState._enqueueBoundaryCommit) {
|
|
603
|
+
forState._enqueueBoundaryCommit();
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
enqueueForScopeUpdate(forState.parentInstance);
|
|
607
|
+
}
|
|
608
|
+
function createForOwnedChildScope(forState, key) {
|
|
609
|
+
return createChildScope(forState.parentInstance, key, enqueueForBoundaryScopeCommit, forState._scopeOwnership);
|
|
610
|
+
}
|
|
611
|
+
function captureForItemTransactionSnapshot(forState, itemInstance) {
|
|
612
|
+
const transaction = forState._transaction;
|
|
613
|
+
if (!transaction || transaction.itemSnapshots?.has(itemInstance)) return;
|
|
614
|
+
if (transaction.collectionSnapshotMode === "reset-empty" || transaction.items.get(itemInstance.key) !== itemInstance) return;
|
|
615
|
+
const itemSnapshots = transaction.itemSnapshots ??= /* @__PURE__ */ new Map();
|
|
616
|
+
const propertySignals = itemInstance.reactiveItemState?.propertySignals ?? null;
|
|
617
|
+
const itemSignal = itemInstance.reactiveItemState?.itemSignal ?? null;
|
|
618
|
+
const propertySnapshots = propertySignals && propertySignals.size > 0 ? new Map(Array.from(propertySignals, ([property, signal]) => [property, {
|
|
619
|
+
signal,
|
|
620
|
+
value: signal.peek(),
|
|
621
|
+
hasBeenRead: signal._hasBeenRead === true
|
|
622
|
+
}])) : null;
|
|
623
|
+
itemSnapshots.set(itemInstance, {
|
|
624
|
+
item: itemInstance.item,
|
|
625
|
+
itemSignalExists: itemSignal !== null,
|
|
626
|
+
itemSignalValue: itemSignal?.peek(),
|
|
627
|
+
itemSignalHasBeenRead: itemSignal?._hasBeenRead === true,
|
|
628
|
+
indexValue: itemInstance.indexSignal.peek(),
|
|
629
|
+
indexHasBeenRead: itemInstance.indexSignal._hasBeenRead === true,
|
|
630
|
+
propertySignalStore: propertySignals,
|
|
631
|
+
propertySignals: propertySnapshots,
|
|
632
|
+
scope: captureChildScopeTransactionSnapshot(itemInstance.scope)
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
function captureForFallbackTransactionSnapshot(forState, fallbackScope = forState.fallbackScope) {
|
|
636
|
+
const transaction = forState._transaction;
|
|
637
|
+
if (!transaction || !fallbackScope || transaction.fallbackScope !== fallbackScope || transaction.fallbackScopeSnapshot) return;
|
|
638
|
+
transaction.fallbackScopeSnapshot = captureChildScopeTransactionSnapshot(fallbackScope);
|
|
639
|
+
}
|
|
640
|
+
function stageForSignalEffect(forState, source, notify, skipInstance = null, skipOwnedBy = null) {
|
|
641
|
+
const transaction = forState._transaction;
|
|
642
|
+
if (!transaction) return false;
|
|
643
|
+
const effects = transaction.signalEffects ??= /* @__PURE__ */ new Map();
|
|
644
|
+
const existing = effects.get(source);
|
|
645
|
+
if (existing) {
|
|
646
|
+
existing.notify ||= notify;
|
|
647
|
+
if (existing.skipInstance !== skipInstance) existing.skipInstance = null;
|
|
648
|
+
if (existing.skipOwnedBy !== skipOwnedBy) existing.skipOwnedBy = null;
|
|
649
|
+
} else effects.set(source, {
|
|
650
|
+
parentInstance: forState.parentInstance,
|
|
651
|
+
notify,
|
|
652
|
+
skipInstance,
|
|
653
|
+
skipOwnedBy
|
|
654
|
+
});
|
|
655
|
+
return true;
|
|
656
|
+
}
|
|
657
|
+
function syncForItemIndex(forState, itemInstance, nextIndex) {
|
|
658
|
+
const indexSignal = itemInstance.indexSignal;
|
|
659
|
+
const previousIndex = indexSignal.peek();
|
|
660
|
+
if (previousIndex === nextIndex) return false;
|
|
661
|
+
if (indexSignal._hasBeenRead !== true) {
|
|
662
|
+
const transaction = forState._transaction;
|
|
663
|
+
if (transaction) {
|
|
664
|
+
const snapshots = transaction.unreadIndexSnapshots ??= /* @__PURE__ */ new Map();
|
|
665
|
+
if (!snapshots.has(indexSignal)) snapshots.set(indexSignal, previousIndex);
|
|
666
|
+
}
|
|
667
|
+
indexSignal.set(nextIndex, false);
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
captureForItemTransactionSnapshot(forState, itemInstance);
|
|
671
|
+
const scopeReadsIndex = scopeReadsSource(itemInstance.scope, indexSignal);
|
|
672
|
+
const scopeDirectlyReadsIndex = scopeDirectlyReadsSource(itemInstance.scope, indexSignal);
|
|
673
|
+
if (forState._transaction) {
|
|
674
|
+
const shouldNotify = indexSignal._hasBeenRead === true;
|
|
675
|
+
indexSignal.set(nextIndex, false);
|
|
676
|
+
stageForSignalEffect(forState, indexSignal, shouldNotify, scopeReadsIndex ? itemInstance.scope.componentInstance : null);
|
|
677
|
+
if (!scopeReadsIndex) return false;
|
|
678
|
+
if (scopeDirectlyReadsIndex) rerenderItemInstance(forState, itemInstance, itemInstance.reactiveItem);
|
|
679
|
+
else itemInstance.scope.markDirty();
|
|
680
|
+
return true;
|
|
681
|
+
}
|
|
682
|
+
if (!scopeReadsIndex) {
|
|
683
|
+
syncForIndexSignal(indexSignal, nextIndex);
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
indexSignal.set(nextIndex, false);
|
|
687
|
+
notifyForSignalReaders(indexSignal, itemInstance.scope.componentInstance);
|
|
688
|
+
rerenderItemInstance(forState, itemInstance, itemInstance.reactiveItem);
|
|
689
|
+
return true;
|
|
690
|
+
}
|
|
691
|
+
function materializeItemVnode(forState, key, vnode) {
|
|
692
|
+
if (vnode && typeof vnode === "object" && "type" in vnode) {
|
|
693
|
+
const vn = vnode;
|
|
694
|
+
vn.key = key;
|
|
695
|
+
if (forState.parentInstance?.ssr && typeof vn.type === "string") {
|
|
696
|
+
if (!vn.props) vn.props = {};
|
|
697
|
+
if (vn.props["data-key"] === void 0) vn.props["data-key"] = String(key);
|
|
698
|
+
if (vn.props["data-askr-key-kind"] === void 0) vn.props["data-askr-key-kind"] = typeof key;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function renderItemScope(forState, scope, item, indexSignal, key) {
|
|
703
|
+
const vnode = scope.render(() => forState.renderFn(item, indexSignal));
|
|
704
|
+
materializeItemVnode(forState, key, vnode);
|
|
705
|
+
return vnode;
|
|
706
|
+
}
|
|
707
|
+
function disposeItemInstance(forState, itemInstance, domCleanup) {
|
|
708
|
+
const removedDom = itemInstance.scope.dom;
|
|
709
|
+
const removedRange = itemInstance.scope.range;
|
|
710
|
+
const transaction = forState._transaction;
|
|
711
|
+
if (transaction) {
|
|
712
|
+
(transaction.removedScopes ??= []).push(itemInstance.scope);
|
|
713
|
+
captureRemovedScopeNodes(forState, removedDom, removedRange);
|
|
714
|
+
recordRemovedBoundary(forState, removedDom, removedRange);
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
try {
|
|
718
|
+
disposeChildScope(itemInstance.scope);
|
|
719
|
+
} catch (err) {
|
|
720
|
+
if (isDevelopmentEnvironment()) console.error("[For] Cleanup error:", err);
|
|
721
|
+
}
|
|
722
|
+
if (!removedDom) return;
|
|
723
|
+
if (removedDom instanceof Element) {
|
|
724
|
+
if (domCleanup === "teardown") getRuntimeRenderer().teardownNodeSubtree(removedDom);
|
|
725
|
+
}
|
|
726
|
+
recordRemovedBoundary(forState, removedDom, removedRange);
|
|
727
|
+
}
|
|
728
|
+
function createItemInstance(key, item, index, forState) {
|
|
729
|
+
const indexSignal = createForIndexSignal(index);
|
|
730
|
+
const reactiveItemState = canProxyForItem(item) ? createReactiveForItem(item) : null;
|
|
731
|
+
const reactiveItem = reactiveItemState?.proxy ?? item;
|
|
732
|
+
const scope = createForOwnedChildScope(forState, key);
|
|
733
|
+
scope.blueprintOwner = forState;
|
|
734
|
+
try {
|
|
735
|
+
renderItemScope(forState, scope, reactiveItem, indexSignal, key);
|
|
736
|
+
} catch (error) {
|
|
737
|
+
disposeChildScope(scope);
|
|
738
|
+
throw error;
|
|
739
|
+
}
|
|
740
|
+
return {
|
|
741
|
+
key,
|
|
742
|
+
item,
|
|
743
|
+
reactiveItem,
|
|
744
|
+
reactiveItemState,
|
|
745
|
+
indexSignal,
|
|
746
|
+
scope
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
function rerenderItemInstance(forState, itemInstance, item) {
|
|
750
|
+
renderItemScope(forState, itemInstance.scope, item, itemInstance.indexSignal, itemInstance.key);
|
|
751
|
+
}
|
|
752
|
+
function updateItemInstance(forState, itemInstance, item) {
|
|
753
|
+
if (itemInstance.item === item) return false;
|
|
754
|
+
captureForItemTransactionSnapshot(forState, itemInstance);
|
|
755
|
+
const previousItem = itemInstance.item;
|
|
756
|
+
itemInstance.item = item;
|
|
757
|
+
const scope = itemInstance.scope;
|
|
758
|
+
let scopeReadsChangedSignal = false;
|
|
759
|
+
const reactiveItemState = itemInstance.reactiveItemState;
|
|
760
|
+
if (!reactiveItemState) {
|
|
761
|
+
rerenderItemInstance(forState, itemInstance, item);
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
const itemSignal = reactiveItemState.itemSignal;
|
|
765
|
+
reactiveItemState.currentItem = item;
|
|
766
|
+
const propertySignals = reactiveItemState.propertySignals;
|
|
767
|
+
const changedPropertySignals = [];
|
|
768
|
+
if (propertySignals && propertySignals.size > 0) for (const [prop, propertySignal] of propertySignals) {
|
|
769
|
+
const previousValue = readForItemProperty(previousItem, prop);
|
|
770
|
+
const nextValue = readForItemProperty(item, prop);
|
|
771
|
+
if (Object.is(previousValue, nextValue)) continue;
|
|
772
|
+
if (scopeReadsSource(scope, propertySignal)) scopeReadsChangedSignal = true;
|
|
773
|
+
changedPropertySignals.push([propertySignal, nextValue]);
|
|
774
|
+
}
|
|
775
|
+
if (itemSignal && scopeReadsSource(scope, itemSignal)) scopeReadsChangedSignal = true;
|
|
776
|
+
let coalescedPropertyChanged = false;
|
|
777
|
+
const coalescedProperties = reactiveItemState.coalescedProperties;
|
|
778
|
+
if (coalescedProperties !== null) if (Array.isArray(coalescedProperties)) {
|
|
779
|
+
for (const property of coalescedProperties) if (!Object.is(readForItemProperty(previousItem, property), readForItemProperty(item, property))) {
|
|
780
|
+
coalescedPropertyChanged = true;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
} else {
|
|
784
|
+
coalescedPropertyChanged = !Object.is(readForItemProperty(previousItem, coalescedProperties), readForItemProperty(item, coalescedProperties));
|
|
785
|
+
const secondProperty = reactiveItemState.coalescedProperty2;
|
|
786
|
+
if (secondProperty !== null && !coalescedPropertyChanged) coalescedPropertyChanged = !Object.is(readForItemProperty(previousItem, secondProperty), readForItemProperty(item, secondProperty));
|
|
787
|
+
}
|
|
788
|
+
const wholeItemChanged = itemSignal?._hasBeenRead === true && (reactiveItemState.wholeItemRead || coalescedPropertyChanged);
|
|
789
|
+
const itemShapeChanged = !wholeItemChanged && changedPropertySignals.length === 0 && !haveSameOwnKeys(previousItem, item);
|
|
790
|
+
const notifyReaders = !scopeReadsChangedSignal && (changedPropertySignals.length > 0 || itemShapeChanged || wholeItemChanged);
|
|
791
|
+
const visibleChange = scopeReadsChangedSignal || changedPropertySignals.length > 0 || itemShapeChanged || wholeItemChanged;
|
|
792
|
+
for (const [propertySignal, nextValue] of changedPropertySignals) if (stageForSignalEffect(forState, propertySignal, notifyReaders, null, itemInstance.scope.componentInstance)) propertySignal.set(nextValue, false);
|
|
793
|
+
else {
|
|
794
|
+
removeForParentReaders(forState.parentInstance, propertySignal);
|
|
795
|
+
propertySignal.set(nextValue, notifyReaders);
|
|
796
|
+
}
|
|
797
|
+
if (itemSignal && stageForSignalEffect(forState, itemSignal, notifyReaders, null, itemInstance.scope.componentInstance)) itemSignal.set(item, false);
|
|
798
|
+
else if (itemSignal) {
|
|
799
|
+
removeForParentReaders(forState.parentInstance, itemSignal);
|
|
800
|
+
itemSignal.set(item, notifyReaders);
|
|
801
|
+
}
|
|
802
|
+
if (scopeReadsChangedSignal) if (itemSignal !== null && scopeDirectlyReadsSource(scope, itemSignal) || changedPropertySignals.some(([propertySignal]) => scopeDirectlyReadsSource(scope, propertySignal))) rerenderItemInstance(forState, itemInstance, itemInstance.reactiveItem);
|
|
803
|
+
else scope.markDirty();
|
|
804
|
+
return visibleChange;
|
|
805
|
+
}
|
|
806
|
+
const FOR_FALLBACK_SCOPE_KEY = "__for-fallback__";
|
|
807
|
+
function disposeFallbackScope(forState, domCleanup) {
|
|
808
|
+
const fallbackScope = forState.fallbackScope;
|
|
809
|
+
if (!fallbackScope) return;
|
|
810
|
+
const removedDom = fallbackScope.dom;
|
|
811
|
+
const removedRange = fallbackScope.range;
|
|
812
|
+
const transaction = forState._transaction;
|
|
813
|
+
if (transaction) {
|
|
814
|
+
(transaction.removedScopes ??= []).push(fallbackScope);
|
|
815
|
+
captureRemovedScopeNodes(forState, removedDom, removedRange);
|
|
816
|
+
} else disposeChildScope(fallbackScope);
|
|
817
|
+
forState.fallbackScope = null;
|
|
818
|
+
if (!removedDom) return;
|
|
819
|
+
if (removedDom instanceof Element) {
|
|
820
|
+
if (domCleanup === "teardown") getRuntimeRenderer().teardownNodeSubtree(removedDom);
|
|
821
|
+
}
|
|
822
|
+
recordRemovedBoundary(forState, removedDom, removedRange);
|
|
823
|
+
}
|
|
824
|
+
function renderFallbackScope(forState) {
|
|
825
|
+
if (forState.fallback == null || forState.fallback === false) {
|
|
826
|
+
if (forState.fallbackScope) disposeFallbackScope(forState, "none");
|
|
827
|
+
forState.orderedVNodes = [];
|
|
828
|
+
forState.orderedItems = [];
|
|
829
|
+
return [];
|
|
830
|
+
}
|
|
831
|
+
const fallbackScope = forState.fallbackScope ?? createForOwnedChildScope(forState, FOR_FALLBACK_SCOPE_KEY);
|
|
832
|
+
if (!forState.fallbackScope) forStatesByScope.set(fallbackScope, forState);
|
|
833
|
+
forState.fallbackScope = fallbackScope;
|
|
834
|
+
captureForFallbackTransactionSnapshot(forState, fallbackScope);
|
|
835
|
+
const fallbackVNode = forState.fallback;
|
|
836
|
+
const vnode = fallbackScope.render(() => fallbackVNode);
|
|
837
|
+
forState.orderedVNodes = vnode == null || vnode === false ? [] : [vnode];
|
|
838
|
+
forState.orderedItems = [];
|
|
839
|
+
return forState.orderedVNodes;
|
|
840
|
+
}
|
|
841
|
+
function disposeAllItems(forState, domCleanup) {
|
|
842
|
+
const { items, orderedKeys } = forState;
|
|
843
|
+
if (forState._transaction?.collectionSnapshotMode === "preserve-clear") {
|
|
844
|
+
const transaction = forState._transaction;
|
|
845
|
+
transaction.removeAllItems = true;
|
|
846
|
+
for (let index = 0; index < forState.orderedItems.length; index++) {
|
|
847
|
+
const scope = forState.orderedItems[index]?.scope;
|
|
848
|
+
const removedDom = scope?.dom;
|
|
849
|
+
const range = scope?.range;
|
|
850
|
+
if (scope) captureRemovedScopeNodes(forState, removedDom, range);
|
|
851
|
+
recordRemovedBoundary(forState, removedDom, range);
|
|
852
|
+
}
|
|
853
|
+
forState.items = /* @__PURE__ */ new Map();
|
|
854
|
+
forState.orderedKeys = [];
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
for (let index = 0; index < orderedKeys.length; index += 1) {
|
|
858
|
+
const key = orderedKeys[index];
|
|
859
|
+
const itemInstance = items.get(key);
|
|
860
|
+
if (!itemInstance) continue;
|
|
861
|
+
disposeItemInstance(forState, itemInstance, domCleanup);
|
|
862
|
+
items.delete(key);
|
|
863
|
+
}
|
|
864
|
+
orderedKeys.length = 0;
|
|
865
|
+
forState.orderedKeys = orderedKeys;
|
|
866
|
+
}
|
|
867
|
+
//#endregion
|
|
868
|
+
//#region src/runtime/for-reconcile.ts
|
|
869
|
+
function failForValidation(message) {
|
|
870
|
+
throw new Error(message);
|
|
871
|
+
}
|
|
872
|
+
function validateForKeys(forState, newArray) {
|
|
873
|
+
if (!isDevelopmentEnvironment()) return;
|
|
874
|
+
const seen = /* @__PURE__ */ new Set();
|
|
875
|
+
const keyKinds = /* @__PURE__ */ new Map();
|
|
876
|
+
for (let i = 0; i < newArray.length; i++) {
|
|
877
|
+
const key = forState.byFn(newArray[i], i);
|
|
878
|
+
if (key === null || key === void 0) failForValidation("[askr] Invalid For key detected. Keys should be stable, non-null, and unique within a For list.");
|
|
879
|
+
if (seen.has(key)) failForValidation(`[askr] Duplicate For key detected: ${String(key)}. Keys should be stable, non-null, and unique within a For list.`);
|
|
880
|
+
seen.add(key);
|
|
881
|
+
const keyKind = typeof key;
|
|
882
|
+
const previousKeyKind = forState.devKeyKinds?.get(key);
|
|
883
|
+
if (previousKeyKind && previousKeyKind !== keyKind) failForValidation(`[askr] For key type changed for ${String(key)}. Keys must remain consistently typed across renders.`);
|
|
884
|
+
keyKinds.set(key, keyKind);
|
|
885
|
+
}
|
|
886
|
+
forState.devKeyKinds = keyKinds;
|
|
887
|
+
}
|
|
888
|
+
function reconcileForItems(forState, newArray) {
|
|
889
|
+
forState.currentItems = newArray;
|
|
890
|
+
validateForKeys(forState, newArray);
|
|
891
|
+
const { items, orderedKeys, byFn } = forState;
|
|
892
|
+
const oldLen = orderedKeys.length;
|
|
893
|
+
const newLen = newArray.length;
|
|
894
|
+
forState.lastRemovedNodes = [];
|
|
895
|
+
forState.lastRemovedRanges = [];
|
|
896
|
+
forState.pendingRemovedKey = null;
|
|
897
|
+
if (newLen === 0) {
|
|
898
|
+
if (oldLen > 0) disposeAllItems(forState, forState.fallback ? "teardown" : "none");
|
|
899
|
+
forState.lastCommitStrategy = "TRUNCATE";
|
|
900
|
+
forState.pendingDirtyIndices = null;
|
|
901
|
+
forState.pendingSwapIndices = null;
|
|
902
|
+
forState.pendingMoveOnly = false;
|
|
903
|
+
return renderFallbackScope(forState);
|
|
904
|
+
}
|
|
905
|
+
if (forState.fallbackScope) disposeFallbackScope(forState, "none");
|
|
906
|
+
if (newLen === oldLen + 1) {
|
|
907
|
+
let oldIndex = 0;
|
|
908
|
+
let insertedIndex = -1;
|
|
909
|
+
let insertedKey = null;
|
|
910
|
+
for (let newIndex = 0; newIndex < newLen; newIndex++) {
|
|
911
|
+
const item = newArray[newIndex];
|
|
912
|
+
const key = byFn(item, newIndex);
|
|
913
|
+
const expectedKey = orderedKeys[oldIndex];
|
|
914
|
+
if (oldIndex < oldLen && key === expectedKey) {
|
|
915
|
+
const existing = items.get(key);
|
|
916
|
+
if (!existing || existing.item !== item || existing.scope.needsDomUpdate || oldIndex !== newIndex && existing.indexSignal._hasBeenRead) {
|
|
917
|
+
insertedIndex = -2;
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
oldIndex++;
|
|
921
|
+
} else if (insertedIndex === -1 && !items.has(key)) {
|
|
922
|
+
insertedIndex = newIndex;
|
|
923
|
+
insertedKey = key;
|
|
924
|
+
} else {
|
|
925
|
+
insertedIndex = -2;
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
if (insertedIndex >= 0 && oldIndex === oldLen && insertedKey !== null) {
|
|
930
|
+
const insertedItem = createItemInstance(insertedKey, newArray[insertedIndex], insertedIndex, forState);
|
|
931
|
+
const resultVNodes = forState.orderedVNodes.slice();
|
|
932
|
+
const resultItems = forState.orderedItems.slice();
|
|
933
|
+
const resultKeys = orderedKeys.slice();
|
|
934
|
+
resultVNodes.splice(insertedIndex, 0, insertedItem.scope.vnode);
|
|
935
|
+
resultItems.splice(insertedIndex, 0, insertedItem);
|
|
936
|
+
resultKeys.splice(insertedIndex, 0, insertedKey);
|
|
937
|
+
items.set(insertedKey, insertedItem);
|
|
938
|
+
forState.lastCommitStrategy = "INSERT_ONE";
|
|
939
|
+
forState.orderedKeys = resultKeys;
|
|
940
|
+
forState.orderedItems = resultItems;
|
|
941
|
+
forState.orderedVNodes = resultVNodes;
|
|
942
|
+
forState.pendingDirtyIndices = null;
|
|
943
|
+
forState.pendingSwapIndices = null;
|
|
944
|
+
forState.pendingMoveOnly = false;
|
|
945
|
+
forState.pendingInsertedIndex = insertedIndex;
|
|
946
|
+
return resultVNodes;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
if (oldLen < newLen) {
|
|
950
|
+
let canUseAppendPath = true;
|
|
951
|
+
let canSkipCommittedPrefix = true;
|
|
952
|
+
for (let i = 0; i < oldLen; i++) {
|
|
953
|
+
const key = byFn(newArray[i], i);
|
|
954
|
+
if (key !== orderedKeys[i]) {
|
|
955
|
+
canUseAppendPath = false;
|
|
956
|
+
break;
|
|
957
|
+
}
|
|
958
|
+
const existing = forState.orderedItems[i] ?? items.get(key);
|
|
959
|
+
if (!existing || existing.item !== newArray[i] || existing.scope.needsDomUpdate || existing.scope.hydrationPending) canSkipCommittedPrefix = false;
|
|
960
|
+
}
|
|
961
|
+
if (canUseAppendPath) {
|
|
962
|
+
forState.lastCommitStrategy = "APPEND";
|
|
963
|
+
const resultVNodes = forState.orderedVNodes;
|
|
964
|
+
const resultItems = forState.orderedItems;
|
|
965
|
+
resultVNodes.length = newLen;
|
|
966
|
+
resultItems.length = newLen;
|
|
967
|
+
if (!canSkipCommittedPrefix) for (let i = 0; i < oldLen; i++) {
|
|
968
|
+
const item = newArray[i];
|
|
969
|
+
const key = orderedKeys[i];
|
|
970
|
+
const existing = resultItems[i] ?? items.get(key);
|
|
971
|
+
updateItemInstance(forState, existing, item);
|
|
972
|
+
resultItems[i] = existing;
|
|
973
|
+
resultVNodes[i] = existing.scope.vnode;
|
|
974
|
+
}
|
|
975
|
+
for (let i = oldLen; i < newLen; i++) {
|
|
976
|
+
const item = newArray[i];
|
|
977
|
+
const key = byFn(item, i);
|
|
978
|
+
const itemInstance = createItemInstance(key, item, i, forState);
|
|
979
|
+
items.set(key, itemInstance);
|
|
980
|
+
resultItems[i] = itemInstance;
|
|
981
|
+
resultVNodes[i] = itemInstance.scope.vnode;
|
|
982
|
+
orderedKeys[i] = key;
|
|
983
|
+
}
|
|
984
|
+
forState.orderedVNodes = resultVNodes;
|
|
985
|
+
forState.pendingDirtyIndices = null;
|
|
986
|
+
forState.pendingSwapIndices = null;
|
|
987
|
+
forState.pendingMoveOnly = false;
|
|
988
|
+
forState.pendingAppendStart = canSkipCommittedPrefix ? oldLen : 0;
|
|
989
|
+
return resultVNodes;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
if (newLen < oldLen) {
|
|
993
|
+
if (oldLen === newLen + 1) {
|
|
994
|
+
let removedIndex = -1;
|
|
995
|
+
for (let i = 0; i < newLen; i++) if (byFn(newArray[i], i) !== orderedKeys[i]) {
|
|
996
|
+
removedIndex = i;
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
if (removedIndex !== -1) {
|
|
1000
|
+
let canUseRemoveOnePath = true;
|
|
1001
|
+
for (let i = removedIndex; i < newLen; i++) if (byFn(newArray[i], i) !== orderedKeys[i + 1]) {
|
|
1002
|
+
canUseRemoveOnePath = false;
|
|
1003
|
+
break;
|
|
1004
|
+
}
|
|
1005
|
+
if (canUseRemoveOnePath) {
|
|
1006
|
+
forState.lastCommitStrategy = "REMOVE_ONE";
|
|
1007
|
+
const resultVNodes = forState.orderedVNodes;
|
|
1008
|
+
const resultItems = forState.orderedItems;
|
|
1009
|
+
const removedKey = orderedKeys[removedIndex];
|
|
1010
|
+
const removedItem = resultItems[removedIndex] ?? items.get(removedKey);
|
|
1011
|
+
orderedKeys.copyWithin(removedIndex, removedIndex + 1);
|
|
1012
|
+
resultItems.copyWithin(removedIndex, removedIndex + 1);
|
|
1013
|
+
resultVNodes.copyWithin(removedIndex, removedIndex + 1);
|
|
1014
|
+
orderedKeys.length = newLen;
|
|
1015
|
+
resultItems.length = newLen;
|
|
1016
|
+
resultVNodes.length = newLen;
|
|
1017
|
+
const dirtyIndices = [];
|
|
1018
|
+
for (let i = 0; i < newLen; i++) {
|
|
1019
|
+
const item = newArray[i];
|
|
1020
|
+
const existing = resultItems[i];
|
|
1021
|
+
const scopeNeedsDomUpdate = existing.scope.needsDomUpdate;
|
|
1022
|
+
const itemChanged = existing.item !== item;
|
|
1023
|
+
const indexSignal = existing.indexSignal;
|
|
1024
|
+
const indexChanged = i >= removedIndex && indexSignal.peek() !== i;
|
|
1025
|
+
if (itemChanged) updateItemInstance(forState, existing, item);
|
|
1026
|
+
const indexVisibleChange = indexChanged ? syncForItemIndex(forState, existing, i) : false;
|
|
1027
|
+
if (itemChanged || indexVisibleChange || scopeNeedsDomUpdate) dirtyIndices.push(i);
|
|
1028
|
+
resultVNodes[i] = existing.scope.vnode;
|
|
1029
|
+
}
|
|
1030
|
+
if (removedItem) {
|
|
1031
|
+
disposeItemInstance(forState, removedItem, "teardown");
|
|
1032
|
+
items.delete(removedKey);
|
|
1033
|
+
}
|
|
1034
|
+
forState.pendingRemovedKey = removedKey;
|
|
1035
|
+
forState.pendingDirtyIndices = dirtyIndices;
|
|
1036
|
+
forState.pendingSwapIndices = null;
|
|
1037
|
+
forState.pendingMoveOnly = false;
|
|
1038
|
+
return resultVNodes;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
let canUseTruncatePath = true;
|
|
1043
|
+
for (let i = 0; i < newLen; i++) if (byFn(newArray[i], i) !== orderedKeys[i]) {
|
|
1044
|
+
canUseTruncatePath = false;
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
if (canUseTruncatePath) {
|
|
1048
|
+
forState.lastCommitStrategy = "TRUNCATE";
|
|
1049
|
+
const resultVNodes = forState.orderedVNodes;
|
|
1050
|
+
const resultItems = forState.orderedItems;
|
|
1051
|
+
resultVNodes.length = newLen;
|
|
1052
|
+
resultItems.length = newLen;
|
|
1053
|
+
const isFullClear = newLen === 0;
|
|
1054
|
+
for (let i = 0; i < newLen; i++) {
|
|
1055
|
+
const item = newArray[i];
|
|
1056
|
+
const key = orderedKeys[i];
|
|
1057
|
+
const existing = items.get(key);
|
|
1058
|
+
updateItemInstance(forState, existing, item);
|
|
1059
|
+
resultItems[i] = existing;
|
|
1060
|
+
resultVNodes[i] = existing.scope.vnode;
|
|
1061
|
+
}
|
|
1062
|
+
for (let i = newLen; i < oldLen; i++) {
|
|
1063
|
+
const key = orderedKeys[i];
|
|
1064
|
+
const itemInstance = items.get(key);
|
|
1065
|
+
if (itemInstance) {
|
|
1066
|
+
disposeItemInstance(forState, itemInstance, isFullClear ? "full-clear" : "teardown");
|
|
1067
|
+
items.delete(key);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
orderedKeys.length = newLen;
|
|
1071
|
+
forState.orderedKeys = orderedKeys;
|
|
1072
|
+
forState.orderedItems.length = newLen;
|
|
1073
|
+
forState.orderedVNodes = resultVNodes;
|
|
1074
|
+
forState.pendingDirtyIndices = null;
|
|
1075
|
+
forState.pendingSwapIndices = null;
|
|
1076
|
+
forState.pendingMoveOnly = false;
|
|
1077
|
+
return resultVNodes;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
if (oldLen === newLen) {
|
|
1081
|
+
let canUseNoReorderPath = true;
|
|
1082
|
+
for (let i = 0; i < oldLen; i++) if (byFn(newArray[i], i) !== orderedKeys[i]) {
|
|
1083
|
+
canUseNoReorderPath = false;
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1086
|
+
if (canUseNoReorderPath) {
|
|
1087
|
+
forState.lastCommitStrategy = "NO_REORDER";
|
|
1088
|
+
const resultVNodes = forState.orderedVNodes;
|
|
1089
|
+
const resultItems = forState.orderedItems;
|
|
1090
|
+
resultVNodes.length = oldLen;
|
|
1091
|
+
resultItems.length = oldLen;
|
|
1092
|
+
const dirtyIndices = [];
|
|
1093
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1094
|
+
const item = newArray[i];
|
|
1095
|
+
const key = orderedKeys[i];
|
|
1096
|
+
const existing = items.get(key);
|
|
1097
|
+
if (existing.item !== item) updateItemInstance(forState, existing, item);
|
|
1098
|
+
if (existing.scope.needsDomUpdate) dirtyIndices.push(i);
|
|
1099
|
+
resultItems[i] = existing;
|
|
1100
|
+
resultVNodes[i] = existing.scope.vnode;
|
|
1101
|
+
}
|
|
1102
|
+
forState.pendingDirtyIndices = dirtyIndices;
|
|
1103
|
+
forState.pendingSwapIndices = null;
|
|
1104
|
+
forState.pendingMoveOnly = false;
|
|
1105
|
+
return resultVNodes;
|
|
1106
|
+
}
|
|
1107
|
+
let firstMismatch = -1;
|
|
1108
|
+
let secondMismatch = -1;
|
|
1109
|
+
let firstMismatchKey = null;
|
|
1110
|
+
let secondMismatchKey = null;
|
|
1111
|
+
let mismatchCount = 0;
|
|
1112
|
+
let canUseSwapPath = true;
|
|
1113
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1114
|
+
const item = newArray[i];
|
|
1115
|
+
const key = byFn(newArray[i], i);
|
|
1116
|
+
if (key === orderedKeys[i]) {
|
|
1117
|
+
const existing = items.get(key);
|
|
1118
|
+
if (existing && existing.item !== item) {
|
|
1119
|
+
canUseSwapPath = false;
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
continue;
|
|
1123
|
+
}
|
|
1124
|
+
mismatchCount++;
|
|
1125
|
+
if (firstMismatch === -1) {
|
|
1126
|
+
firstMismatch = i;
|
|
1127
|
+
firstMismatchKey = key;
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
if (secondMismatch === -1) {
|
|
1131
|
+
secondMismatch = i;
|
|
1132
|
+
secondMismatchKey = key;
|
|
1133
|
+
continue;
|
|
1134
|
+
}
|
|
1135
|
+
mismatchCount = 3;
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
if (canUseSwapPath && mismatchCount === 2 && firstMismatch !== -1 && secondMismatch !== -1 && firstMismatchKey === orderedKeys[secondMismatch] && secondMismatchKey === orderedKeys[firstMismatch]) {
|
|
1139
|
+
forState.lastCommitStrategy = "SWAP";
|
|
1140
|
+
const nextOrderedKeys = orderedKeys.slice();
|
|
1141
|
+
nextOrderedKeys[firstMismatch] = firstMismatchKey;
|
|
1142
|
+
nextOrderedKeys[secondMismatch] = secondMismatchKey;
|
|
1143
|
+
const resultVNodes = forState.orderedVNodes;
|
|
1144
|
+
const firstExisting = items.get(firstMismatchKey);
|
|
1145
|
+
const secondExisting = items.get(secondMismatchKey);
|
|
1146
|
+
const firstItem = newArray[firstMismatch];
|
|
1147
|
+
const secondItem = newArray[secondMismatch];
|
|
1148
|
+
const nextOrderedItems = forState.orderedItems.slice();
|
|
1149
|
+
nextOrderedItems[firstMismatch] = secondExisting;
|
|
1150
|
+
nextOrderedItems[secondMismatch] = firstExisting;
|
|
1151
|
+
if (firstExisting.item !== firstItem) updateItemInstance(forState, firstExisting, firstItem);
|
|
1152
|
+
if (secondExisting.item !== secondItem) updateItemInstance(forState, secondExisting, secondItem);
|
|
1153
|
+
syncForItemIndex(forState, firstExisting, firstMismatch);
|
|
1154
|
+
syncForItemIndex(forState, secondExisting, secondMismatch);
|
|
1155
|
+
resultVNodes[firstMismatch] = firstExisting.scope.vnode;
|
|
1156
|
+
resultVNodes[secondMismatch] = secondExisting.scope.vnode;
|
|
1157
|
+
forState.orderedKeys = nextOrderedKeys;
|
|
1158
|
+
forState.orderedItems = nextOrderedItems;
|
|
1159
|
+
forState.pendingDirtyIndices = null;
|
|
1160
|
+
forState.pendingSwapIndices = [firstMismatch, secondMismatch];
|
|
1161
|
+
forState.pendingMoveOnly = true;
|
|
1162
|
+
return resultVNodes;
|
|
1163
|
+
}
|
|
1164
|
+
let canUseMoveOnlyPath = true;
|
|
1165
|
+
const moveOnlyKeys = [];
|
|
1166
|
+
const moveOnlyItems = [];
|
|
1167
|
+
const moveOnlyVNodes = [];
|
|
1168
|
+
for (let i = 0; i < oldLen; i++) {
|
|
1169
|
+
const item = newArray[i];
|
|
1170
|
+
const key = byFn(item, i);
|
|
1171
|
+
const existing = items.get(key);
|
|
1172
|
+
if (!existing || existing.item !== item || existing.indexSignal._hasBeenRead && existing.indexSignal.peek() !== i) {
|
|
1173
|
+
canUseMoveOnlyPath = false;
|
|
1174
|
+
break;
|
|
1175
|
+
}
|
|
1176
|
+
moveOnlyKeys[i] = key;
|
|
1177
|
+
moveOnlyItems[i] = existing;
|
|
1178
|
+
moveOnlyVNodes[i] = existing.scope.vnode;
|
|
1179
|
+
}
|
|
1180
|
+
if (canUseMoveOnlyPath) {
|
|
1181
|
+
forState.lastCommitStrategy = "FULL_KEYED";
|
|
1182
|
+
for (let i = 0; i < moveOnlyItems.length; i++) {
|
|
1183
|
+
syncForItemIndex(forState, moveOnlyItems[i], i);
|
|
1184
|
+
moveOnlyVNodes[i] = moveOnlyItems[i].scope.vnode;
|
|
1185
|
+
}
|
|
1186
|
+
forState.orderedKeys = moveOnlyKeys;
|
|
1187
|
+
forState.orderedItems = moveOnlyItems;
|
|
1188
|
+
forState.orderedVNodes = moveOnlyVNodes;
|
|
1189
|
+
forState.pendingDirtyIndices = null;
|
|
1190
|
+
forState.pendingSwapIndices = null;
|
|
1191
|
+
forState.pendingMoveOnly = true;
|
|
1192
|
+
return moveOnlyVNodes;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
forState.lastCommitStrategy = "FULL_KEYED";
|
|
1196
|
+
const toRemove = new Set(orderedKeys);
|
|
1197
|
+
const newOrderedKeys = [];
|
|
1198
|
+
const newOrderedItems = [];
|
|
1199
|
+
const resultVNodes = [];
|
|
1200
|
+
let moveOnly = toRemove.size === newArray.length;
|
|
1201
|
+
for (let i = 0; i < newArray.length; i++) {
|
|
1202
|
+
const item = newArray[i];
|
|
1203
|
+
const key = byFn(item, i);
|
|
1204
|
+
toRemove.delete(key);
|
|
1205
|
+
newOrderedKeys.push(key);
|
|
1206
|
+
const existing = items.get(key);
|
|
1207
|
+
if (!existing) {
|
|
1208
|
+
const itemInstance = createItemInstance(key, item, i, forState);
|
|
1209
|
+
items.set(key, itemInstance);
|
|
1210
|
+
newOrderedItems.push(itemInstance);
|
|
1211
|
+
resultVNodes.push(itemInstance.scope.vnode);
|
|
1212
|
+
} else {
|
|
1213
|
+
const itemChanged = existing.item !== item;
|
|
1214
|
+
const indexChanged = existing.indexSignal.peek() !== i;
|
|
1215
|
+
if (itemChanged) {
|
|
1216
|
+
moveOnly = false;
|
|
1217
|
+
updateItemInstance(forState, existing, item);
|
|
1218
|
+
}
|
|
1219
|
+
if (indexChanged) syncForItemIndex(forState, existing, i);
|
|
1220
|
+
newOrderedItems.push(existing);
|
|
1221
|
+
resultVNodes.push(existing.scope.vnode);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
for (const key of toRemove) {
|
|
1225
|
+
moveOnly = false;
|
|
1226
|
+
const itemInstance = items.get(key);
|
|
1227
|
+
if (itemInstance) {
|
|
1228
|
+
disposeItemInstance(forState, itemInstance, "none");
|
|
1229
|
+
items.delete(key);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
forState.orderedKeys = newOrderedKeys;
|
|
1233
|
+
forState.orderedItems = newOrderedItems;
|
|
1234
|
+
forState.orderedVNodes = resultVNodes;
|
|
1235
|
+
forState.pendingDirtyIndices = null;
|
|
1236
|
+
forState.pendingSwapIndices = null;
|
|
1237
|
+
forState.pendingMoveOnly = moveOnly;
|
|
1238
|
+
return resultVNodes;
|
|
1239
|
+
}
|
|
1240
|
+
//#endregion
|
|
1241
|
+
//#region src/runtime/for-internal.ts
|
|
1242
|
+
/**
|
|
1243
|
+
* For primitive runtime
|
|
1244
|
+
*
|
|
1245
|
+
* Manages For state storage, hook binding, source evaluation,
|
|
1246
|
+
* and DOM update state cleanup.
|
|
1247
|
+
*/
|
|
1248
|
+
const forStates = /* @__PURE__ */ new WeakMap();
|
|
1249
|
+
function getForStore(instance) {
|
|
1250
|
+
const generation = instance._ownershipGeneration;
|
|
1251
|
+
let store = forStates.get(generation);
|
|
1252
|
+
if (!store) {
|
|
1253
|
+
store = /* @__PURE__ */ new Map();
|
|
1254
|
+
forStates.set(generation, store);
|
|
1255
|
+
}
|
|
1256
|
+
return store;
|
|
1257
|
+
}
|
|
1258
|
+
function createForState(eachSource, byFn, renderFn, fallback) {
|
|
1259
|
+
const parentInstance = getCurrentInstance();
|
|
1260
|
+
const ownedScopes = /* @__PURE__ */ new Set();
|
|
1261
|
+
let bulkDisposing = false;
|
|
1262
|
+
const scopeOwnership = {
|
|
1263
|
+
add: (scope) => ownedScopes.add(scope),
|
|
1264
|
+
delete: (scope) => bulkDisposing ? false : ownedScopes.delete(scope),
|
|
1265
|
+
bulkDispose(run) {
|
|
1266
|
+
bulkDisposing = true;
|
|
1267
|
+
try {
|
|
1268
|
+
run();
|
|
1269
|
+
} finally {
|
|
1270
|
+
bulkDisposing = false;
|
|
1271
|
+
ownedScopes.clear();
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
if (parentInstance) registerOwnedChildScope(parentInstance, {
|
|
1276
|
+
key: "for-boundary",
|
|
1277
|
+
dispose() {
|
|
1278
|
+
scopeOwnership.bulkDispose(() => {
|
|
1279
|
+
const errors = [];
|
|
1280
|
+
for (const scope of ownedScopes) try {
|
|
1281
|
+
scope.dispose();
|
|
1282
|
+
} catch (error) {
|
|
1283
|
+
errors.push(error);
|
|
1284
|
+
}
|
|
1285
|
+
if (errors.length > 0) throw new AggregateError(errors, "For scope cleanup failed");
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
return {
|
|
1290
|
+
kind: "for",
|
|
1291
|
+
currentItems: [],
|
|
1292
|
+
_committedItems: [],
|
|
1293
|
+
eachSource,
|
|
1294
|
+
fallback,
|
|
1295
|
+
fallbackScope: null,
|
|
1296
|
+
items: /* @__PURE__ */ new Map(),
|
|
1297
|
+
orderedKeys: [],
|
|
1298
|
+
orderedItems: [],
|
|
1299
|
+
orderedVNodes: [],
|
|
1300
|
+
byFn,
|
|
1301
|
+
renderFn,
|
|
1302
|
+
parentInstance,
|
|
1303
|
+
lastCommitStrategy: "NO_REORDER",
|
|
1304
|
+
lastRemovedNodes: [],
|
|
1305
|
+
lastRemovedRanges: [],
|
|
1306
|
+
pendingDirtyIndices: null,
|
|
1307
|
+
pendingSwapIndices: null,
|
|
1308
|
+
pendingMoveOnly: false,
|
|
1309
|
+
pendingInsertedIndex: null,
|
|
1310
|
+
pendingRemovedKey: null,
|
|
1311
|
+
pendingAppendStart: null,
|
|
1312
|
+
_hasResolvedItemDom: false,
|
|
1313
|
+
_needsSourceReconcile: false,
|
|
1314
|
+
_sourceEffect: null,
|
|
1315
|
+
_suspendSourceCommit: false,
|
|
1316
|
+
_enqueueBoundaryCommit: null,
|
|
1317
|
+
_scopeOwnership: scopeOwnership,
|
|
1318
|
+
_hasPendingBoundaryCommit: false,
|
|
1319
|
+
_transaction: null
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
function useForState(eachSource, byFn, renderFn, fallback) {
|
|
1323
|
+
const instance = getCurrentInstance();
|
|
1324
|
+
if (!instance) throw new Error("For can only be created during component render execution.");
|
|
1325
|
+
const hookIndex = claimHookIndex(instance, "For");
|
|
1326
|
+
const generation = instance._ownershipGeneration;
|
|
1327
|
+
const store = getForStore(instance);
|
|
1328
|
+
const existing = store.get(hookIndex);
|
|
1329
|
+
if (existing) {
|
|
1330
|
+
existing.eachSource = eachSource;
|
|
1331
|
+
existing.byFn = byFn;
|
|
1332
|
+
existing.renderFn = renderFn;
|
|
1333
|
+
existing.fallback = fallback;
|
|
1334
|
+
return existing;
|
|
1335
|
+
}
|
|
1336
|
+
const created = createForState(eachSource, byFn, renderFn, fallback);
|
|
1337
|
+
store.set(hookIndex, created);
|
|
1338
|
+
(instance.cleanupFns ??= []).push(() => {
|
|
1339
|
+
created._sourceEffect?.cleanup();
|
|
1340
|
+
created._sourceEffect = null;
|
|
1341
|
+
store.delete(hookIndex);
|
|
1342
|
+
if (store.size === 0 && forStates.get(generation) === store) forStates.delete(generation);
|
|
1343
|
+
});
|
|
1344
|
+
return created;
|
|
1345
|
+
}
|
|
1346
|
+
function evaluateForState(forState) {
|
|
1347
|
+
if (!Array.isArray(forState.currentItems)) throw new Error("For source must evaluate to an array");
|
|
1348
|
+
beginForStateTransaction(forState);
|
|
1349
|
+
forState._needsSourceReconcile = false;
|
|
1350
|
+
try {
|
|
1351
|
+
return reconcileForItems(forState, forState.currentItems);
|
|
1352
|
+
} catch (error) {
|
|
1353
|
+
rollbackForStateTransaction(forState);
|
|
1354
|
+
throw error;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Reconciliation changes ownership before DOM work can fail. Keep a private
|
|
1359
|
+
* structural snapshot until the boundary has committed so failed work cannot
|
|
1360
|
+
* leave provisional child scopes in the parent owner graph.
|
|
1361
|
+
*/
|
|
1362
|
+
function beginForStateTransaction(forState, collectionMode = "auto") {
|
|
1363
|
+
if (forState._transaction) return;
|
|
1364
|
+
const hasEmptyCollections = forState.items.size === 0 && forState.orderedKeys.length === 0 && forState.orderedItems.length === 0 && forState.orderedVNodes.length === 0;
|
|
1365
|
+
const isFullClear = forState.currentItems.length === 0 && forState.orderedKeys.length > 0;
|
|
1366
|
+
const collectionSnapshotMode = collectionMode === "reuse" ? "reuse" : hasEmptyCollections ? "reset-empty" : isFullClear ? "preserve-clear" : "copy";
|
|
1367
|
+
const transaction = {
|
|
1368
|
+
collectionSnapshotMode,
|
|
1369
|
+
currentItems: forState._committedItems,
|
|
1370
|
+
items: collectionSnapshotMode === "copy" ? new Map(forState.items) : forState.items,
|
|
1371
|
+
orderedKeys: collectionSnapshotMode === "copy" ? forState.orderedKeys.slice() : forState.orderedKeys,
|
|
1372
|
+
orderedItems: collectionSnapshotMode === "copy" ? forState.orderedItems.slice() : forState.orderedItems,
|
|
1373
|
+
orderedVNodes: collectionSnapshotMode === "copy" ? forState.orderedVNodes.slice() : forState.orderedVNodes,
|
|
1374
|
+
fallbackScope: forState.fallbackScope,
|
|
1375
|
+
lastCommitStrategy: forState.lastCommitStrategy,
|
|
1376
|
+
lastRemovedNodes: forState.lastRemovedNodes,
|
|
1377
|
+
lastRemovedRanges: forState.lastRemovedRanges,
|
|
1378
|
+
pendingDirtyIndices: forState.pendingDirtyIndices,
|
|
1379
|
+
pendingSwapIndices: forState.pendingSwapIndices,
|
|
1380
|
+
pendingMoveOnly: forState.pendingMoveOnly,
|
|
1381
|
+
pendingInsertedIndex: forState.pendingInsertedIndex,
|
|
1382
|
+
pendingRemovedKey: forState.pendingRemovedKey,
|
|
1383
|
+
pendingAppendStart: forState.pendingAppendStart,
|
|
1384
|
+
hasResolvedItemDom: forState._hasResolvedItemDom,
|
|
1385
|
+
needsSourceReconcile: forState._needsSourceReconcile,
|
|
1386
|
+
devKeyKinds: forState.devKeyKinds,
|
|
1387
|
+
itemSnapshots: null,
|
|
1388
|
+
unreadIndexSnapshots: null,
|
|
1389
|
+
fallbackScopeSnapshot: null,
|
|
1390
|
+
removedScopes: null,
|
|
1391
|
+
removedScopeNodes: null,
|
|
1392
|
+
removeAllItems: false,
|
|
1393
|
+
signalEffects: null,
|
|
1394
|
+
shouldClearDomUpdateState: false
|
|
1395
|
+
};
|
|
1396
|
+
forState._transaction = transaction;
|
|
1397
|
+
registerForStateTransaction(forState, transaction);
|
|
1398
|
+
}
|
|
1399
|
+
function registerForStateTransaction(forState, transaction = forState._transaction) {
|
|
1400
|
+
if (!transaction || forState._transaction !== transaction) return false;
|
|
1401
|
+
return registerLifecycleTransaction(transaction, () => commitForStateTransaction(forState, transaction), () => rollbackForStateTransaction(forState, transaction));
|
|
1402
|
+
}
|
|
1403
|
+
function finalizeForStateRemovals(forState, transaction) {
|
|
1404
|
+
const removedScopes = transaction.removedScopes;
|
|
1405
|
+
if (!transaction.removeAllItems && !removedScopes) return;
|
|
1406
|
+
const cleanupErrors = [];
|
|
1407
|
+
const finalizeScope = (scope) => {
|
|
1408
|
+
const removedDom = scope.dom;
|
|
1409
|
+
const removedRange = scope.range;
|
|
1410
|
+
try {
|
|
1411
|
+
disposeChildScope(scope);
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
cleanupErrors.push(error);
|
|
1414
|
+
}
|
|
1415
|
+
if (transaction.removedScopeNodes) return;
|
|
1416
|
+
if (typeof Element !== "undefined" && removedDom instanceof Element) try {
|
|
1417
|
+
getRuntimeRenderer().teardownNodeSubtree(removedDom);
|
|
1418
|
+
} catch (error) {
|
|
1419
|
+
cleanupErrors.push(error);
|
|
1420
|
+
}
|
|
1421
|
+
if (removedRange && !removedRange.single) for (let node = removedRange.start.nextSibling; node && node !== removedRange.end;) {
|
|
1422
|
+
const next = node.nextSibling;
|
|
1423
|
+
try {
|
|
1424
|
+
getRuntimeRenderer().teardownNodeSubtree(node);
|
|
1425
|
+
} catch (error) {
|
|
1426
|
+
cleanupErrors.push(error);
|
|
1427
|
+
}
|
|
1428
|
+
node = next;
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
if (transaction.removeAllItems) forState._scopeOwnership.bulkDispose(() => {
|
|
1432
|
+
for (let index = 0; index < transaction.orderedItems.length; index++) {
|
|
1433
|
+
const item = transaction.orderedItems[index];
|
|
1434
|
+
if (item) finalizeScope(item.scope);
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
for (const scope of removedScopes ?? []) finalizeScope(scope);
|
|
1438
|
+
const removedScopeNodes = transaction.removedScopeNodes;
|
|
1439
|
+
if (removedScopeNodes) for (const node of removedScopeNodes) try {
|
|
1440
|
+
getRuntimeRenderer().teardownNodeSubtree(node);
|
|
1441
|
+
} catch (error) {
|
|
1442
|
+
cleanupErrors.push(error);
|
|
1443
|
+
}
|
|
1444
|
+
if (removedScopes) removedScopes.length = 0;
|
|
1445
|
+
if (removedScopeNodes) removedScopeNodes.length = 0;
|
|
1446
|
+
transaction.removeAllItems = false;
|
|
1447
|
+
if (cleanupErrors.length > 0) logger.error("[Askr] For removal cleanup failed:", new AggregateError(cleanupErrors, "For removal cleanup failed"));
|
|
1448
|
+
}
|
|
1449
|
+
function finalizeForSignalEffects(transaction) {
|
|
1450
|
+
if (!transaction.signalEffects) return;
|
|
1451
|
+
for (const [source, effect] of transaction.signalEffects) {
|
|
1452
|
+
removeForParentReaders(effect.parentInstance, source);
|
|
1453
|
+
if (effect.notify) notifyForSignalReaders(source, effect.skipInstance, effect.skipOwnedBy);
|
|
1454
|
+
}
|
|
1455
|
+
transaction.signalEffects.clear();
|
|
1456
|
+
}
|
|
1457
|
+
function finalizeForDomUpdateFlags(forState) {
|
|
1458
|
+
for (let index = 0; index < forState.orderedItems.length; index++) {
|
|
1459
|
+
const item = forState.orderedItems[index];
|
|
1460
|
+
if (item) item.scope.needsDomUpdate = false;
|
|
1461
|
+
}
|
|
1462
|
+
if (forState.fallbackScope) forState.fallbackScope.needsDomUpdate = false;
|
|
1463
|
+
}
|
|
1464
|
+
function commitForStateTransaction(forState, transaction = forState._transaction) {
|
|
1465
|
+
if (!transaction || forState._transaction !== transaction) return;
|
|
1466
|
+
try {
|
|
1467
|
+
finalizeForStateRemovals(forState, transaction);
|
|
1468
|
+
finalizeForSignalEffects(transaction);
|
|
1469
|
+
if (transaction.shouldClearDomUpdateState) finalizeForDomUpdateFlags(forState);
|
|
1470
|
+
} finally {
|
|
1471
|
+
transaction.itemSnapshots?.clear();
|
|
1472
|
+
transaction.unreadIndexSnapshots?.clear();
|
|
1473
|
+
transaction.fallbackScopeSnapshot = null;
|
|
1474
|
+
forState._committedItems = forState.currentItems;
|
|
1475
|
+
forState._transaction = null;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
function rollbackForStateTransaction(forState, transaction = forState._transaction) {
|
|
1479
|
+
if (!transaction || forState._transaction !== transaction) return;
|
|
1480
|
+
const rollbackCleanupErrors = [];
|
|
1481
|
+
const scopesToDispose = /* @__PURE__ */ new Set();
|
|
1482
|
+
const committedScopes = transaction.collectionSnapshotMode === "reset-empty" ? null : new Set(transaction.orderedItems.map((item) => item.scope));
|
|
1483
|
+
if (transaction.fallbackScope) committedScopes?.add(transaction.fallbackScope);
|
|
1484
|
+
if (transaction.collectionSnapshotMode === "reset-empty") for (const item of forState.items.values()) scopesToDispose.add(item.scope);
|
|
1485
|
+
else for (const [key, item] of forState.items) if (transaction.items.get(key) !== item) scopesToDispose.add(item.scope);
|
|
1486
|
+
for (const scope of transaction.removedScopes ?? []) if (scope !== transaction.fallbackScope && !committedScopes?.has(scope)) scopesToDispose.add(scope);
|
|
1487
|
+
if (forState.fallbackScope && forState.fallbackScope !== transaction.fallbackScope) scopesToDispose.add(forState.fallbackScope);
|
|
1488
|
+
for (const scope of scopesToDispose) try {
|
|
1489
|
+
disposeChildScope(scope);
|
|
1490
|
+
} catch (error) {
|
|
1491
|
+
rollbackCleanupErrors.push(error);
|
|
1492
|
+
}
|
|
1493
|
+
if (transaction.collectionSnapshotMode === "reset-empty") {
|
|
1494
|
+
forState.items.clear();
|
|
1495
|
+
forState.orderedKeys.length = 0;
|
|
1496
|
+
forState.orderedItems.length = 0;
|
|
1497
|
+
forState.orderedVNodes.length = 0;
|
|
1498
|
+
}
|
|
1499
|
+
for (const [itemInstance, snapshot] of transaction.itemSnapshots ?? []) {
|
|
1500
|
+
itemInstance.item = snapshot.item;
|
|
1501
|
+
const reactiveItemState = itemInstance.reactiveItemState;
|
|
1502
|
+
if (reactiveItemState) reactiveItemState.currentItem = snapshot.item;
|
|
1503
|
+
const itemSignal = reactiveItemState?.itemSignal;
|
|
1504
|
+
if (itemSignal && snapshot.itemSignalExists) {
|
|
1505
|
+
itemSignal.set(snapshot.itemSignalValue, false);
|
|
1506
|
+
itemSignal._hasBeenRead = snapshot.itemSignalHasBeenRead;
|
|
1507
|
+
}
|
|
1508
|
+
itemInstance.indexSignal.set(snapshot.indexValue, false);
|
|
1509
|
+
itemInstance.indexSignal._hasBeenRead = snapshot.indexHasBeenRead;
|
|
1510
|
+
const propertySignals = snapshot.propertySignalStore;
|
|
1511
|
+
if (reactiveItemState) reactiveItemState.propertySignals = propertySignals;
|
|
1512
|
+
if (propertySignals) {
|
|
1513
|
+
propertySignals.clear();
|
|
1514
|
+
for (const [property, propertySnapshot] of snapshot.propertySignals ?? []) {
|
|
1515
|
+
propertySnapshot.signal.set(propertySnapshot.value, false);
|
|
1516
|
+
propertySnapshot.signal._hasBeenRead = propertySnapshot.hasBeenRead;
|
|
1517
|
+
propertySignals.set(property, propertySnapshot.signal);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
restoreChildScopeTransactionSnapshot(itemInstance.scope, snapshot.scope);
|
|
1521
|
+
}
|
|
1522
|
+
for (const [indexSignal, index] of transaction.unreadIndexSnapshots ?? []) indexSignal.set(index, false);
|
|
1523
|
+
if (transaction.fallbackScope && transaction.fallbackScopeSnapshot) restoreChildScopeTransactionSnapshot(transaction.fallbackScope, transaction.fallbackScopeSnapshot);
|
|
1524
|
+
forState.currentItems = transaction.currentItems;
|
|
1525
|
+
forState._committedItems = transaction.currentItems;
|
|
1526
|
+
forState.items = transaction.items;
|
|
1527
|
+
forState.orderedKeys = transaction.orderedKeys;
|
|
1528
|
+
forState.orderedItems = transaction.orderedItems;
|
|
1529
|
+
forState.orderedVNodes = transaction.orderedVNodes;
|
|
1530
|
+
forState.fallbackScope = transaction.fallbackScope;
|
|
1531
|
+
forState.lastCommitStrategy = transaction.lastCommitStrategy;
|
|
1532
|
+
forState.lastRemovedNodes = transaction.lastRemovedNodes;
|
|
1533
|
+
forState.lastRemovedRanges = transaction.lastRemovedRanges;
|
|
1534
|
+
forState.pendingDirtyIndices = transaction.pendingDirtyIndices;
|
|
1535
|
+
forState.pendingSwapIndices = transaction.pendingSwapIndices;
|
|
1536
|
+
forState.pendingMoveOnly = transaction.pendingMoveOnly;
|
|
1537
|
+
forState.pendingInsertedIndex = transaction.pendingInsertedIndex;
|
|
1538
|
+
forState.pendingRemovedKey = transaction.pendingRemovedKey;
|
|
1539
|
+
forState.pendingAppendStart = transaction.pendingAppendStart;
|
|
1540
|
+
forState._hasResolvedItemDom = transaction.hasResolvedItemDom;
|
|
1541
|
+
forState._needsSourceReconcile = transaction.needsSourceReconcile;
|
|
1542
|
+
forState.devKeyKinds = transaction.devKeyKinds;
|
|
1543
|
+
forState._transaction = null;
|
|
1544
|
+
if (rollbackCleanupErrors.length > 0) logger.error("[Askr] transaction rollback cleanup failed:", new AggregateError(rollbackCleanupErrors, "Transaction rollback cleanup failed"));
|
|
1545
|
+
}
|
|
1546
|
+
function clearForDomUpdateState(forState) {
|
|
1547
|
+
const transaction = forState._transaction;
|
|
1548
|
+
if (transaction) transaction.shouldClearDomUpdateState = true;
|
|
1549
|
+
if (transaction && !registerForStateTransaction(forState, transaction)) commitForStateTransaction(forState, transaction);
|
|
1550
|
+
if (!transaction) finalizeForDomUpdateFlags(forState);
|
|
1551
|
+
forState.lastRemovedNodes = [];
|
|
1552
|
+
forState.lastRemovedRanges = [];
|
|
1553
|
+
forState.pendingDirtyIndices = null;
|
|
1554
|
+
forState.pendingSwapIndices = null;
|
|
1555
|
+
forState.pendingMoveOnly = false;
|
|
1556
|
+
forState.pendingInsertedIndex = null;
|
|
1557
|
+
forState.pendingRemovedKey = null;
|
|
1558
|
+
forState.pendingAppendStart = null;
|
|
1559
|
+
forState._needsSourceReconcile = false;
|
|
1560
|
+
forState._hasResolvedItemDom = forState.orderedKeys.length > 0;
|
|
1561
|
+
}
|
|
1562
|
+
//#endregion
|
|
1563
|
+
export { createChildScope as _, registerForStateTransaction as a, captureForFallbackTransactionSnapshot as c, clearCaseDomUpdateState as d, clearShowDomUpdateState as f, evaluateShowState as g, evaluateCaseState as h, evaluateForState as i, captureForItemTransactionSnapshot as l, createShowState as m, clearForDomUpdateState as n, rollbackForStateTransaction as o, createCaseState as p, commitForStateTransaction as r, useForState as s, beginForStateTransaction as t, recordBenchEvent as u, disposeChildScope as v, rerenderChildScope as y };
|