@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
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { isFragmentVNode, normalizeComponentChildren } from "./child-shape.js";
|
|
4
|
-
//#region src/renderer/reactive-child-sources.ts
|
|
5
|
-
function collectReactiveScalarSequenceValue(value, normalized) {
|
|
6
|
-
if (isFragmentVNode(value)) return collectReactiveScalarSequenceValue(value.props?.children ?? value.children, normalized);
|
|
7
|
-
if (Array.isArray(value)) {
|
|
8
|
-
for (const child of value) if (!collectReactiveScalarSequenceValue(child, normalized)) return false;
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
if (value === null || value === void 0 || value === false) return true;
|
|
12
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
13
|
-
normalized.push(String(value));
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
function collectReactiveScalarChildSource(children, slots, state) {
|
|
19
|
-
if (isFragmentVNode(children)) return collectReactiveScalarChildSource(children.props?.children ?? children.children, slots, state);
|
|
20
|
-
if (Array.isArray(children)) {
|
|
21
|
-
for (const child of children) if (!collectReactiveScalarChildSource(child, slots, state)) return false;
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
if (children === null || children === void 0 || children === false) return true;
|
|
25
|
-
if (typeof children === "function") {
|
|
26
|
-
slots.push({
|
|
27
|
-
kind: "dynamic",
|
|
28
|
-
compute: children
|
|
29
|
-
});
|
|
30
|
-
state.hasDynamic = true;
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (typeof children === "string" || typeof children === "number") {
|
|
34
|
-
slots.push({
|
|
35
|
-
kind: "static",
|
|
36
|
-
value: String(children)
|
|
37
|
-
});
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
function getReactiveScalarChildSource(children) {
|
|
43
|
-
const slots = [];
|
|
44
|
-
const state = { hasDynamic: false };
|
|
45
|
-
if (!collectReactiveScalarChildSource(children, slots, state)) return null;
|
|
46
|
-
return state.hasDynamic ? slots : null;
|
|
47
|
-
}
|
|
48
|
-
function getSingleReactiveChildBoundarySource(children) {
|
|
49
|
-
if (isFragmentVNode(children)) return getSingleReactiveChildBoundarySource(children.props?.children ?? children.children);
|
|
50
|
-
if (Array.isArray(children)) {
|
|
51
|
-
if (children.length !== 1) return null;
|
|
52
|
-
return getSingleReactiveChildBoundarySource(children[0]);
|
|
53
|
-
}
|
|
54
|
-
if (typeof children === "function") return children;
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
function collectReactiveChildBoundarySequenceSource(children, slots, state) {
|
|
58
|
-
if (isFragmentVNode(children)) return collectReactiveChildBoundarySequenceSource(children.props?.children ?? children.children, slots, state);
|
|
59
|
-
if (Array.isArray(children)) {
|
|
60
|
-
for (const child of children) if (!collectReactiveChildBoundarySequenceSource(child, slots, state)) return false;
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
if (children === null || children === void 0 || children === false) return true;
|
|
64
|
-
if (typeof children === "function") {
|
|
65
|
-
slots.push({
|
|
66
|
-
kind: "dynamic",
|
|
67
|
-
compute: children
|
|
68
|
-
});
|
|
69
|
-
state.dynamicCount += 1;
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
if (typeof children === "string" || typeof children === "number") {
|
|
73
|
-
slots.push({
|
|
74
|
-
kind: "static-text",
|
|
75
|
-
value: String(children)
|
|
76
|
-
});
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
if (_isDOMElement(children)) {
|
|
80
|
-
slots.push({
|
|
81
|
-
kind: "static-node",
|
|
82
|
-
value: children
|
|
83
|
-
});
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
function getReactiveChildBoundarySequenceSource(children) {
|
|
89
|
-
const slots = [];
|
|
90
|
-
const state = { dynamicCount: 0 };
|
|
91
|
-
if (!collectReactiveChildBoundarySequenceSource(children, slots, state)) return null;
|
|
92
|
-
return state.dynamicCount >= 1 && slots.length > 1 ? slots : null;
|
|
93
|
-
}
|
|
94
|
-
function areReactiveChildBoundarySequenceSourcesEqual(previousSource, nextSource) {
|
|
95
|
-
if (!Array.isArray(previousSource) || previousSource.length !== nextSource.length) return false;
|
|
96
|
-
for (let index = 0; index < nextSource.length; index += 1) {
|
|
97
|
-
const previousSlot = previousSource[index];
|
|
98
|
-
const nextSlot = nextSource[index];
|
|
99
|
-
if (!previousSlot || previousSlot.kind !== nextSlot.kind) return false;
|
|
100
|
-
if (nextSlot.kind === "static-text") {
|
|
101
|
-
if (previousSlot.kind !== "static-text" || previousSlot.value !== nextSlot.value) return false;
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (nextSlot.kind === "static-node") {
|
|
105
|
-
if (previousSlot.kind !== "static-node" || previousSlot.value !== nextSlot.value) return false;
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
if (previousSlot.kind !== "dynamic" || previousSlot.compute !== nextSlot.compute) return false;
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
function canUpdateReactiveChildBoundarySequenceSource(previousSource, nextSource) {
|
|
113
|
-
if (!Array.isArray(previousSource) || previousSource.length !== nextSource.length) return false;
|
|
114
|
-
for (let index = 0; index < nextSource.length; index += 1) {
|
|
115
|
-
const previousSlot = previousSource[index];
|
|
116
|
-
const nextSlot = nextSource[index];
|
|
117
|
-
if (!previousSlot || previousSlot.kind !== nextSlot.kind) return false;
|
|
118
|
-
if (nextSlot.kind === "static-text") {
|
|
119
|
-
if (previousSlot.kind !== "static-text" || previousSlot.value !== nextSlot.value) return false;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (nextSlot.kind === "static-node") {
|
|
123
|
-
if (previousSlot.kind !== "static-node" || previousSlot.value !== nextSlot.value) return false;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
function areReactiveScalarChildSourcesEqual(previousSource, nextSource) {
|
|
129
|
-
if (!Array.isArray(previousSource) || previousSource.length !== nextSource.length) return false;
|
|
130
|
-
for (let index = 0; index < nextSource.length; index += 1) {
|
|
131
|
-
const previousSlot = previousSource[index];
|
|
132
|
-
const nextSlot = nextSource[index];
|
|
133
|
-
if (!previousSlot || previousSlot.kind !== nextSlot.kind) return false;
|
|
134
|
-
if (nextSlot.kind === "static") {
|
|
135
|
-
if (previousSlot.kind !== "static" || previousSlot.value !== nextSlot.value) return false;
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
if (previousSlot.kind !== "dynamic" || previousSlot.compute !== nextSlot.compute) return false;
|
|
139
|
-
}
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
function normalizeReactiveScalarSequenceValues(values) {
|
|
143
|
-
const normalized = [];
|
|
144
|
-
for (const value of values) if (!collectReactiveScalarSequenceValue(value, normalized)) return null;
|
|
145
|
-
return normalized;
|
|
146
|
-
}
|
|
147
|
-
function normalizeOwnedReactiveTextValue(value) {
|
|
148
|
-
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
function collectReactiveChildValuesAsVNodes(values, children) {
|
|
152
|
-
for (const value of values) collectReactiveChildBoundaryVNodes(value, children);
|
|
153
|
-
}
|
|
154
|
-
function normalizeReactiveChildBoundaryVNode(value) {
|
|
155
|
-
if (!isFragmentVNode(value)) return value;
|
|
156
|
-
const children = normalizeComponentChildren(value);
|
|
157
|
-
if (children.length !== 1) return value;
|
|
158
|
-
return normalizeReactiveChildBoundaryVNode(children[0]);
|
|
159
|
-
}
|
|
160
|
-
function isSingleRootReactiveChildBoundaryValue(value) {
|
|
161
|
-
if (value === null || value === void 0 || value === false) return true;
|
|
162
|
-
if (Array.isArray(value)) return value.length === 1 && isSingleRootReactiveChildBoundaryValue(value[0]);
|
|
163
|
-
if (isFragmentVNode(value)) {
|
|
164
|
-
const children = normalizeComponentChildren(value);
|
|
165
|
-
return children.length === 1 && isSingleRootReactiveChildBoundaryValue(children[0]);
|
|
166
|
-
}
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
function collectReactiveChildBoundaryVNodes(value, children) {
|
|
170
|
-
if (value === null || value === void 0 || value === false) return;
|
|
171
|
-
if (Array.isArray(value)) {
|
|
172
|
-
for (const child of value) collectReactiveChildBoundaryVNodes(child, children);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (isFragmentVNode(value)) {
|
|
176
|
-
collectReactiveChildBoundaryVNodes(value.props?.children ?? value.children, children);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
children.push(value);
|
|
180
|
-
}
|
|
181
|
-
//#endregion
|
|
182
|
-
export { areReactiveChildBoundarySequenceSourcesEqual, areReactiveScalarChildSourcesEqual, canUpdateReactiveChildBoundarySequenceSource, collectReactiveChildBoundaryVNodes, collectReactiveChildValuesAsVNodes, getReactiveChildBoundarySequenceSource, getReactiveScalarChildSource, getSingleReactiveChildBoundarySource, isSingleRootReactiveChildBoundaryValue, normalizeOwnedReactiveTextValue, normalizeReactiveChildBoundaryVNode, normalizeReactiveScalarSequenceValues };
|
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import { getRuntimeEnv } from "../common/env.js";
|
|
2
|
-
import { logger } from "../common/logger.js";
|
|
3
|
-
import { incDevCounter } from "../runtime/dev-namespace.js";
|
|
4
|
-
import { getCurrentInstance } from "../runtime/component-scope.js";
|
|
5
|
-
import { createChildScope, disposeChildScope, rerenderChildScope } from "../runtime/child-scope.js";
|
|
6
|
-
import { createFineGrainedEffect } from "../runtime/effect.js";
|
|
7
|
-
import "../runtime/index.js";
|
|
8
|
-
import { REACTIVE_CHILDREN_KEY, elementReactivePropsCleanup, getElementReactivePropsCleanupMap, teardownNodeSubtree } from "./cleanup.js";
|
|
9
|
-
import "./env.js";
|
|
10
|
-
import { getParentNamespace } from "./namespaces.js";
|
|
11
|
-
import { areReactiveChildBoundarySequenceSourcesEqual, areReactiveScalarChildSourcesEqual, canUpdateReactiveChildBoundarySequenceSource, collectReactiveChildValuesAsVNodes, getReactiveChildBoundarySequenceSource, getReactiveScalarChildSource, getSingleReactiveChildBoundarySource, normalizeOwnedReactiveTextValue, normalizeReactiveChildBoundaryVNode, normalizeReactiveScalarSequenceValues } from "./reactive-child-sources.js";
|
|
12
|
-
import { commitReactiveChildBoundaryEntryNodes, createReactiveChildBoundaryHost, disposeReactiveChildBoundaryNodes, materializeReactiveChildBoundaryNodes, syncReactiveChildExpectedNodes, syncReactiveChildSequenceNodes, syncReactiveScalarTextNodes } from "./reactive-child-dom.js";
|
|
13
|
-
//#region src/renderer/reactive-children.ts
|
|
14
|
-
let reactiveChildScopeId = 0;
|
|
15
|
-
function getOrCreateElementReactiveCleanupMap(el) {
|
|
16
|
-
return getElementReactivePropsCleanupMap(el, true);
|
|
17
|
-
}
|
|
18
|
-
function trySyncScalarChildSequenceInPlace(el, children, host) {
|
|
19
|
-
const normalized = normalizeReactiveScalarSequenceValues(children);
|
|
20
|
-
if (!normalized) return false;
|
|
21
|
-
if (el.childNodes.length !== normalized.length) return false;
|
|
22
|
-
for (let index = 0; index < el.childNodes.length; index += 1) if (el.childNodes[index]?.nodeType !== Node.TEXT_NODE) return false;
|
|
23
|
-
syncReactiveScalarTextNodes(el, children, normalized, host);
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
function setupReactiveScalarChild(el, source, host) {
|
|
27
|
-
let currentSource = source;
|
|
28
|
-
if (source.length === 1 && source[0]?.kind === "dynamic") {
|
|
29
|
-
let ownedTextNode = el.childNodes.length === 1 && el.firstChild?.nodeType === Node.TEXT_NODE ? el.firstChild : null;
|
|
30
|
-
let effectHandle = createFineGrainedEffect({
|
|
31
|
-
lane: "reactive",
|
|
32
|
-
compute: () => {
|
|
33
|
-
const currentSlot = currentSource[0];
|
|
34
|
-
if (!currentSlot || currentSlot.kind !== "dynamic") throw new Error("[Askr] Direct reactive text bindings require a single dynamic slot.");
|
|
35
|
-
const rawValue = currentSlot.compute();
|
|
36
|
-
return normalizeOwnedReactiveTextValue(rawValue) ?? rawValue;
|
|
37
|
-
},
|
|
38
|
-
commit: (value) => {
|
|
39
|
-
const normalized = normalizeOwnedReactiveTextValue(value);
|
|
40
|
-
if (normalized === null) {
|
|
41
|
-
ownedTextNode = null;
|
|
42
|
-
host.updateElementChildren(el, value);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (!ownedTextNode && el.childNodes.length === 0) {
|
|
46
|
-
ownedTextNode = el.ownerDocument.createTextNode(normalized);
|
|
47
|
-
el.appendChild(ownedTextNode);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (!ownedTextNode || el.childNodes.length !== 1 || el.firstChild !== ownedTextNode) {
|
|
51
|
-
host.updateElementChildren(el, normalized);
|
|
52
|
-
ownedTextNode = el.childNodes.length === 1 && el.firstChild?.nodeType === Node.TEXT_NODE ? el.firstChild : null;
|
|
53
|
-
}
|
|
54
|
-
if (!ownedTextNode) return;
|
|
55
|
-
if (ownedTextNode.data !== normalized) {
|
|
56
|
-
ownedTextNode.data = normalized;
|
|
57
|
-
incDevCounter("textNodeWrites");
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
onError: (err) => {
|
|
61
|
-
if (getRuntimeEnv().NODE_ENV !== "production") logger.warn("[Askr] Reactive child update failed:", err);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
cleanup: () => {
|
|
66
|
-
effectHandle?.cleanup();
|
|
67
|
-
effectHandle = null;
|
|
68
|
-
},
|
|
69
|
-
updateFn: (nextSource) => {
|
|
70
|
-
if (!effectHandle) return;
|
|
71
|
-
currentSource = nextSource;
|
|
72
|
-
effectHandle.updateCompute(() => {
|
|
73
|
-
const currentSlot = currentSource[0];
|
|
74
|
-
if (!currentSlot || currentSlot.kind !== "dynamic") throw new Error("[Askr] Direct reactive text bindings require a single dynamic slot.");
|
|
75
|
-
const rawValue = currentSlot.compute();
|
|
76
|
-
return normalizeOwnedReactiveTextValue(rawValue) ?? rawValue;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
let effectHandle = createFineGrainedEffect({
|
|
82
|
-
lane: "reactive",
|
|
83
|
-
compute: () => currentSource.map((slot) => slot.kind === "static" ? slot.value : slot.compute()),
|
|
84
|
-
commit: (values) => {
|
|
85
|
-
if (!Array.isArray(values)) throw new Error("[Askr] Reactive scalar children must evaluate to a slot array.");
|
|
86
|
-
const normalized = normalizeReactiveScalarSequenceValues(values);
|
|
87
|
-
if (normalized) {
|
|
88
|
-
syncReactiveScalarTextNodes(el, values, normalized, host);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const nextChildren = [];
|
|
92
|
-
collectReactiveChildValuesAsVNodes(values, nextChildren);
|
|
93
|
-
const boundaryHost = createReactiveChildBoundaryHost(el);
|
|
94
|
-
for (let node = el.firstChild; node;) {
|
|
95
|
-
const next = node.nextSibling;
|
|
96
|
-
boundaryHost.appendChild(node);
|
|
97
|
-
node = next;
|
|
98
|
-
}
|
|
99
|
-
host.updateElementChildren(boundaryHost, nextChildren);
|
|
100
|
-
syncReactiveChildExpectedNodes(el, Array.from(boundaryHost.childNodes));
|
|
101
|
-
},
|
|
102
|
-
equals: (previousValue, nextValue) => {
|
|
103
|
-
if (!Array.isArray(previousValue) || !Array.isArray(nextValue)) return false;
|
|
104
|
-
const previousNormalized = normalizeReactiveScalarSequenceValues(previousValue);
|
|
105
|
-
const nextNormalized = normalizeReactiveScalarSequenceValues(nextValue);
|
|
106
|
-
if (!previousNormalized || !nextNormalized) return false;
|
|
107
|
-
if (previousNormalized.length !== nextNormalized.length) return false;
|
|
108
|
-
for (let index = 0; index < previousNormalized.length; index += 1) if (previousNormalized[index] !== nextNormalized[index]) return false;
|
|
109
|
-
return true;
|
|
110
|
-
},
|
|
111
|
-
onError: (err) => {
|
|
112
|
-
if (getRuntimeEnv().NODE_ENV !== "production") logger.warn("[Askr] Reactive child update failed:", err);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
return {
|
|
116
|
-
cleanup: () => {
|
|
117
|
-
effectHandle?.cleanup();
|
|
118
|
-
effectHandle = null;
|
|
119
|
-
},
|
|
120
|
-
updateFn: (nextSource) => {
|
|
121
|
-
if (!effectHandle) return;
|
|
122
|
-
currentSource = nextSource;
|
|
123
|
-
effectHandle.updateCompute(() => currentSource.map((slot) => slot.kind === "static" ? slot.value : slot.compute()));
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
/** @internal Create a standalone scalar-child binding for rollback restoration. */
|
|
128
|
-
function createReactiveScalarChildCleanupEntry(el, source, host) {
|
|
129
|
-
const reactive = setupReactiveScalarChild(el, source, host);
|
|
130
|
-
return {
|
|
131
|
-
cleanup: reactive.cleanup,
|
|
132
|
-
updateFn: (nextValue) => {
|
|
133
|
-
reactive.updateFn(nextValue);
|
|
134
|
-
},
|
|
135
|
-
restoreFn: (nextValue) => createReactiveScalarChildCleanupEntry(el, nextValue, host),
|
|
136
|
-
fnRef: source
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function setupReactiveChildBoundary(el, childFn, host) {
|
|
140
|
-
let currentChildFn = childFn;
|
|
141
|
-
const entry = {
|
|
142
|
-
scope: createChildScope(getCurrentInstance(), `__reactive-child__:${reactiveChildScopeId += 1}`, () => {
|
|
143
|
-
syncReactiveChildExpectedNodes(el, commitReactiveChildBoundaryEntryNodes(el, entry, host));
|
|
144
|
-
}),
|
|
145
|
-
nodes: []
|
|
146
|
-
};
|
|
147
|
-
entry.scope.render(() => normalizeReactiveChildBoundaryVNode(currentChildFn()));
|
|
148
|
-
syncReactiveChildExpectedNodes(el, commitReactiveChildBoundaryEntryNodes(el, entry, host));
|
|
149
|
-
return {
|
|
150
|
-
cleanup: () => {
|
|
151
|
-
const dom = entry.scope.dom;
|
|
152
|
-
const nodes = entry.nodes;
|
|
153
|
-
disposeChildScope(entry.scope);
|
|
154
|
-
entry.nodes = [];
|
|
155
|
-
if (nodes.length > 0) {
|
|
156
|
-
disposeReactiveChildBoundaryNodes(nodes);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
if (dom?.parentNode === el) {
|
|
160
|
-
teardownNodeSubtree(dom);
|
|
161
|
-
el.removeChild(dom);
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
updateFn: (nextValue) => {
|
|
165
|
-
currentChildFn = nextValue;
|
|
166
|
-
rerenderChildScope(entry.scope);
|
|
167
|
-
syncReactiveChildExpectedNodes(el, commitReactiveChildBoundaryEntryNodes(el, entry, host));
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function setupReactiveChildBoundarySequence(el, source, host) {
|
|
172
|
-
let currentSource = source;
|
|
173
|
-
const parentInstance = getCurrentInstance();
|
|
174
|
-
const entries = [];
|
|
175
|
-
const dynamicEntries = [];
|
|
176
|
-
if (!currentSource.some((slot) => slot.kind === "dynamic")) throw new Error("[Askr] Reactive child boundary sequence requires at least one dynamic slot.");
|
|
177
|
-
const syncSequence = () => {
|
|
178
|
-
syncReactiveChildSequenceNodes(el, entries, host);
|
|
179
|
-
};
|
|
180
|
-
const parentNamespace = getParentNamespace(el);
|
|
181
|
-
for (let index = 0; index < currentSource.length; index += 1) {
|
|
182
|
-
const slot = currentSource[index];
|
|
183
|
-
if (!slot) continue;
|
|
184
|
-
if (slot.kind === "static-text") {
|
|
185
|
-
entries.push({
|
|
186
|
-
kind: "static",
|
|
187
|
-
nodes: [document.createTextNode(slot.value)]
|
|
188
|
-
});
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
if (slot.kind === "static-node") {
|
|
192
|
-
entries.push({
|
|
193
|
-
kind: "static",
|
|
194
|
-
nodes: materializeReactiveChildBoundaryNodes(slot.value, parentNamespace, host)
|
|
195
|
-
});
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
const dynamicEntry = {
|
|
199
|
-
kind: "dynamic",
|
|
200
|
-
scope: createChildScope(parentInstance, `__reactive-child-seq__:${reactiveChildScopeId += 1}`, syncSequence),
|
|
201
|
-
nodes: []
|
|
202
|
-
};
|
|
203
|
-
entries.push(dynamicEntry);
|
|
204
|
-
dynamicEntries.push({
|
|
205
|
-
index,
|
|
206
|
-
entry: dynamicEntry
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
for (const dynamicEntry of dynamicEntries) dynamicEntry.entry.scope.render(() => normalizeReactiveChildBoundaryVNode(currentSource[dynamicEntry.index].compute()));
|
|
210
|
-
syncSequence();
|
|
211
|
-
return {
|
|
212
|
-
cleanup: () => {
|
|
213
|
-
for (const dynamicEntry of dynamicEntries) {
|
|
214
|
-
const dom = dynamicEntry.entry.scope.dom;
|
|
215
|
-
const nodes = dynamicEntry.entry.nodes;
|
|
216
|
-
disposeChildScope(dynamicEntry.entry.scope);
|
|
217
|
-
if (nodes.length > 0) {
|
|
218
|
-
disposeReactiveChildBoundaryNodes(nodes);
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
if (dom?.parentNode === el) {
|
|
222
|
-
teardownNodeSubtree(dom);
|
|
223
|
-
el.removeChild(dom);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
for (const entry of entries) if (entry.kind === "static") disposeReactiveChildBoundaryNodes(entry.nodes);
|
|
227
|
-
},
|
|
228
|
-
updateFn: (nextValue) => {
|
|
229
|
-
currentSource = nextValue;
|
|
230
|
-
for (const dynamicEntry of dynamicEntries) rerenderChildScope(dynamicEntry.entry.scope);
|
|
231
|
-
syncSequence();
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function syncReactiveScalarChild(el, children, host) {
|
|
236
|
-
const reactiveChildSource = getReactiveScalarChildSource(children);
|
|
237
|
-
const reactiveChildBoundary = getSingleReactiveChildBoundarySource(children);
|
|
238
|
-
const reactiveChildBoundarySequence = getReactiveChildBoundarySequenceSource(children);
|
|
239
|
-
const cleanupMap = getElementReactivePropsCleanupMap(el);
|
|
240
|
-
const existingReactiveEntry = cleanupMap?.get(REACTIVE_CHILDREN_KEY);
|
|
241
|
-
if (!reactiveChildSource && !reactiveChildBoundary && !reactiveChildBoundarySequence) {
|
|
242
|
-
if (existingReactiveEntry) {
|
|
243
|
-
existingReactiveEntry.cleanup();
|
|
244
|
-
cleanupMap?.delete(REACTIVE_CHILDREN_KEY);
|
|
245
|
-
if (cleanupMap && cleanupMap.size === 0) elementReactivePropsCleanup.delete(el);
|
|
246
|
-
}
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
if (reactiveChildSource && !reactiveChildBoundarySequence) {
|
|
250
|
-
if (existingReactiveEntry?.groupedScalar && existingReactiveEntry.updateFn && reactiveChildSource.length === 1 && reactiveChildSource[0]?.kind === "dynamic") {
|
|
251
|
-
const nextCompute = reactiveChildSource[0].compute;
|
|
252
|
-
existingReactiveEntry.updateFn(nextCompute);
|
|
253
|
-
existingReactiveEntry.fnRef = nextCompute;
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
if (existingReactiveEntry && Array.isArray(existingReactiveEntry.fnRef) && areReactiveScalarChildSourcesEqual(existingReactiveEntry.fnRef, reactiveChildSource)) return true;
|
|
257
|
-
if (existingReactiveEntry?.updateFn && Array.isArray(existingReactiveEntry.fnRef)) {
|
|
258
|
-
existingReactiveEntry.updateFn(reactiveChildSource);
|
|
259
|
-
existingReactiveEntry.fnRef = reactiveChildSource;
|
|
260
|
-
return true;
|
|
261
|
-
}
|
|
262
|
-
existingReactiveEntry?.cleanup();
|
|
263
|
-
try {
|
|
264
|
-
getOrCreateElementReactiveCleanupMap(el).set(REACTIVE_CHILDREN_KEY, createReactiveScalarChildCleanupEntry(el, reactiveChildSource, host));
|
|
265
|
-
return true;
|
|
266
|
-
} catch (error) {
|
|
267
|
-
if (!reactiveChildBoundary && !reactiveChildBoundarySequence) throw error;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
if (reactiveChildBoundarySequence) {
|
|
271
|
-
if (existingReactiveEntry && Array.isArray(existingReactiveEntry.fnRef) && areReactiveChildBoundarySequenceSourcesEqual(existingReactiveEntry.fnRef, reactiveChildBoundarySequence)) return true;
|
|
272
|
-
if (existingReactiveEntry?.updateFn && Array.isArray(existingReactiveEntry.fnRef) && canUpdateReactiveChildBoundarySequenceSource(existingReactiveEntry.fnRef, reactiveChildBoundarySequence)) {
|
|
273
|
-
existingReactiveEntry.updateFn(reactiveChildBoundarySequence);
|
|
274
|
-
existingReactiveEntry.fnRef = reactiveChildBoundarySequence;
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
existingReactiveEntry?.cleanup();
|
|
278
|
-
const reactive = setupReactiveChildBoundarySequence(el, reactiveChildBoundarySequence, host);
|
|
279
|
-
getOrCreateElementReactiveCleanupMap(el).set(REACTIVE_CHILDREN_KEY, {
|
|
280
|
-
cleanup: reactive.cleanup,
|
|
281
|
-
updateFn: reactive.updateFn,
|
|
282
|
-
fnRef: reactiveChildBoundarySequence
|
|
283
|
-
});
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
if (existingReactiveEntry?.fnRef === reactiveChildBoundary) return true;
|
|
287
|
-
if (existingReactiveEntry?.updateFn && !Array.isArray(existingReactiveEntry.fnRef)) {
|
|
288
|
-
existingReactiveEntry.updateFn(reactiveChildBoundary);
|
|
289
|
-
existingReactiveEntry.fnRef = reactiveChildBoundary;
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
292
|
-
existingReactiveEntry?.cleanup();
|
|
293
|
-
if (!reactiveChildBoundary) return false;
|
|
294
|
-
const reactive = setupReactiveChildBoundary(el, reactiveChildBoundary, host);
|
|
295
|
-
getOrCreateElementReactiveCleanupMap(el).set(REACTIVE_CHILDREN_KEY, {
|
|
296
|
-
cleanup: reactive.cleanup,
|
|
297
|
-
updateFn: reactive.updateFn,
|
|
298
|
-
fnRef: reactiveChildBoundary
|
|
299
|
-
});
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
//#endregion
|
|
303
|
-
export { createReactiveScalarChildCleanupEntry, syncReactiveScalarChild, trySyncScalarChildSequenceInPlace };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { teardownNodeSubtree } from "./cleanup.js";
|
|
2
|
-
import { recordDOMReplace } from "./utils.js";
|
|
3
|
-
//#region src/renderer/reconcile-commit.ts
|
|
4
|
-
function commitReconciliation(parent, finalNodes) {
|
|
5
|
-
try {
|
|
6
|
-
const finalSet = new Set(finalNodes);
|
|
7
|
-
for (let n = parent.firstChild; n;) {
|
|
8
|
-
const next = n.nextSibling;
|
|
9
|
-
if (!finalSet.has(n)) {
|
|
10
|
-
teardownNodeSubtree(n);
|
|
11
|
-
parent.removeChild(n);
|
|
12
|
-
}
|
|
13
|
-
n = next;
|
|
14
|
-
}
|
|
15
|
-
for (let i = 0; i < finalNodes.length; i++) {
|
|
16
|
-
const desiredNode = finalNodes[i];
|
|
17
|
-
const anchor = parent.childNodes[i] ?? null;
|
|
18
|
-
if (desiredNode !== anchor) parent.insertBefore(desiredNode, anchor);
|
|
19
|
-
}
|
|
20
|
-
} catch {
|
|
21
|
-
const fragment = document.createDocumentFragment();
|
|
22
|
-
for (let i = 0; i < finalNodes.length; i++) fragment.appendChild(finalNodes[i]);
|
|
23
|
-
try {
|
|
24
|
-
for (let n = parent.firstChild; n;) {
|
|
25
|
-
const next = n.nextSibling;
|
|
26
|
-
teardownNodeSubtree(n);
|
|
27
|
-
n = next;
|
|
28
|
-
}
|
|
29
|
-
} catch {}
|
|
30
|
-
recordDOMReplace("reconcile");
|
|
31
|
-
parent.replaceChildren(fragment);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { commitReconciliation };
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { getRuntimeEnv } from "../common/env.js";
|
|
2
|
-
import "./env.js";
|
|
3
|
-
import { checkPropChanges, getMaterializedKey, recordFastPathStats } from "./utils.js";
|
|
4
|
-
import { keyedElements, planKeyedReorderFastPath } from "./keyed.js";
|
|
5
|
-
import { canReuseIntrinsicElementInNamespace, getParentNamespace } from "./namespaces.js";
|
|
6
|
-
import { performBulkPositionalKeyedTextUpdate } from "./children-fastpath.js";
|
|
7
|
-
import "./children.js";
|
|
8
|
-
import { applyRendererFastPath } from "./fastpath.js";
|
|
9
|
-
//#region src/renderer/reconcile-fastpaths.ts
|
|
10
|
-
function tryFastPaths(parent, newChildren, keyedVnodes, oldKeyMap) {
|
|
11
|
-
try {
|
|
12
|
-
const forcedResult = tryForcedPositionalBulkUpdate(parent, newChildren, keyedVnodes);
|
|
13
|
-
if (forcedResult) return forcedResult;
|
|
14
|
-
const rendererResult = tryRendererFastPath(parent, keyedVnodes, newChildren.length, oldKeyMap);
|
|
15
|
-
if (rendererResult) return rendererResult;
|
|
16
|
-
const positionalResult = tryPositionalBulkUpdate(parent, keyedVnodes);
|
|
17
|
-
if (positionalResult) return positionalResult;
|
|
18
|
-
} catch {}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
function tryRendererFastPath(parent, keyedVnodes, totalChildren, oldKeyMap) {
|
|
22
|
-
if (planKeyedReorderFastPath(parent, keyedVnodes, totalChildren, oldKeyMap).useFastPath) try {
|
|
23
|
-
const map = applyRendererFastPath(parent, keyedVnodes, oldKeyMap);
|
|
24
|
-
if (map) {
|
|
25
|
-
keyedElements.set(parent, map);
|
|
26
|
-
return map;
|
|
27
|
-
}
|
|
28
|
-
} catch {}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
function tryForcedPositionalBulkUpdate(parent, newChildren, keyedVnodes) {
|
|
32
|
-
if (getRuntimeEnv().ASKR_FORCE_BULK_POSREUSE !== "1") return null;
|
|
33
|
-
if (keyedVnodes.length === 0 || keyedVnodes.length !== newChildren.length) return null;
|
|
34
|
-
try {
|
|
35
|
-
recordFastPathStats(performBulkPositionalKeyedTextUpdate(parent, keyedVnodes), "bulkKeyedPositionalForced");
|
|
36
|
-
rebuildKeyedMap(parent);
|
|
37
|
-
return keyedElements.get(parent);
|
|
38
|
-
} catch {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function tryPositionalBulkUpdate(parent, keyedVnodes) {
|
|
43
|
-
const total = keyedVnodes.length;
|
|
44
|
-
if (total < 10) return null;
|
|
45
|
-
if (parent.children.length !== total) return null;
|
|
46
|
-
const matchCount = countPositionalMatches(parent, keyedVnodes, getParentNamespace(parent));
|
|
47
|
-
const matchFraction = matchCount / total;
|
|
48
|
-
if (keyedVnodes.length > 0) {
|
|
49
|
-
if (matchCount !== total && matchFraction >= .1) return null;
|
|
50
|
-
} else if (matchFraction < .9) return null;
|
|
51
|
-
if (hasPositionalPropChanges(parent, keyedVnodes)) return null;
|
|
52
|
-
try {
|
|
53
|
-
recordFastPathStats(performBulkPositionalKeyedTextUpdate(parent, keyedVnodes), "bulkKeyedPositionalHits");
|
|
54
|
-
rebuildKeyedMap(parent);
|
|
55
|
-
return keyedElements.get(parent);
|
|
56
|
-
} catch {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function countPositionalMatches(parent, keyedVnodes, parentNamespace) {
|
|
61
|
-
let matchCount = 0;
|
|
62
|
-
try {
|
|
63
|
-
for (let i = 0; i < keyedVnodes.length; i++) {
|
|
64
|
-
const vnode = keyedVnodes[i].vnode;
|
|
65
|
-
const expectedKey = keyedVnodes[i].key;
|
|
66
|
-
if (!vnode || typeof vnode !== "object" || typeof vnode.type !== "string") continue;
|
|
67
|
-
const el = parent.children[i];
|
|
68
|
-
if (!el) continue;
|
|
69
|
-
if (canReuseIntrinsicElementInNamespace(el, vnode.type, parentNamespace)) {
|
|
70
|
-
if (getMaterializedKey(el) === expectedKey) matchCount++;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} catch {}
|
|
74
|
-
return matchCount;
|
|
75
|
-
}
|
|
76
|
-
function hasPositionalPropChanges(parent, keyedVnodes) {
|
|
77
|
-
try {
|
|
78
|
-
for (let i = 0; i < keyedVnodes.length; i++) {
|
|
79
|
-
const vnode = keyedVnodes[i].vnode;
|
|
80
|
-
const el = parent.children[i];
|
|
81
|
-
if (!el || !vnode || typeof vnode !== "object") continue;
|
|
82
|
-
if (checkPropChanges(el, vnode.props || {})) return true;
|
|
83
|
-
}
|
|
84
|
-
} catch {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
function rebuildKeyedMap(parent) {
|
|
90
|
-
try {
|
|
91
|
-
const map = /* @__PURE__ */ new Map();
|
|
92
|
-
for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {
|
|
93
|
-
const key = getMaterializedKey(el);
|
|
94
|
-
if (key !== void 0) map.set(key, el);
|
|
95
|
-
}
|
|
96
|
-
keyedElements.set(parent, map);
|
|
97
|
-
} catch {}
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
export { tryFastPaths };
|