@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,142 +0,0 @@
|
|
|
1
|
-
import { __FOR_BOUNDARY__ } from "../common/vnode.js";
|
|
2
|
-
import { getRuntimeEnv } from "../common/env.js";
|
|
3
|
-
import { enqueueRuntimeTask } from "../runtime/access.js";
|
|
4
|
-
import { beginLifecycleCommitBatch, discardLifecycleCommitBatch, flushLifecycleCommitBatch } from "../runtime/lifecycle-batch.js";
|
|
5
|
-
import { recordBenchEvent } from "../runtime/for-bench.js";
|
|
6
|
-
import "../runtime/index.js";
|
|
7
|
-
import { teardownNodeSubtree } from "./cleanup.js";
|
|
8
|
-
import "./env.js";
|
|
9
|
-
import { keyedElements } from "./keyed.js";
|
|
10
|
-
import { getRangeNodes, insertRangeBefore, rangeContains, removeRange } from "./dom-range.js";
|
|
11
|
-
import { commitForStateBoundaryChildren } from "./for-commit.js";
|
|
12
|
-
import { configureBoundaryRangeHost } from "./boundary-range-adoption.js";
|
|
13
|
-
import { syncControlBoundaryInMixedParent, syncControlBoundaryScopeDom, syncControlBoundaryScopeNode } from "./boundary-range-sync.js";
|
|
14
|
-
import { clearControlBoundaryDomUpdateState, evaluateControlBoundaryState, getControlBoundaryCommitChildren, getControlBoundaryState, getDirectControlBoundaryVNode } from "./boundary-state.js";
|
|
15
|
-
import { createForBoundary } from "./boundary-materialization.js";
|
|
16
|
-
//#region src/renderer/boundaries.ts
|
|
17
|
-
let boundaryDOMHost = null;
|
|
18
|
-
const controlBoundaryOwners = /* @__PURE__ */ new WeakMap();
|
|
19
|
-
function configureBoundaryDOMHost(host) {
|
|
20
|
-
boundaryDOMHost = host;
|
|
21
|
-
configureBoundaryRangeHost(host);
|
|
22
|
-
}
|
|
23
|
-
function getBoundaryDOMHost() {
|
|
24
|
-
if (!boundaryDOMHost) throw new Error("[askr] Control boundary DOM host is not configured.");
|
|
25
|
-
return boundaryDOMHost;
|
|
26
|
-
}
|
|
27
|
-
function clearControlBoundaryCommitOwner(parent) {
|
|
28
|
-
const owner = controlBoundaryOwners.get(parent);
|
|
29
|
-
if (owner) {
|
|
30
|
-
owner._enqueueBoundaryCommit = null;
|
|
31
|
-
owner._hasPendingBoundaryCommit = false;
|
|
32
|
-
if (owner._commitOwner === parent) owner._commitOwner = null;
|
|
33
|
-
}
|
|
34
|
-
controlBoundaryOwners.delete(parent);
|
|
35
|
-
}
|
|
36
|
-
function registerControlBoundaryCommitOwner(parent, controlState) {
|
|
37
|
-
const ownerState = controlState;
|
|
38
|
-
const previousParent = ownerState._commitOwner;
|
|
39
|
-
if (previousParent && previousParent !== parent && controlBoundaryOwners.get(previousParent) === controlState) controlBoundaryOwners.delete(previousParent);
|
|
40
|
-
const previousOwner = controlBoundaryOwners.get(parent);
|
|
41
|
-
if (previousOwner && previousOwner !== controlState) {
|
|
42
|
-
previousOwner._enqueueBoundaryCommit = null;
|
|
43
|
-
previousOwner._hasPendingBoundaryCommit = false;
|
|
44
|
-
if (previousOwner._commitOwner === parent) previousOwner._commitOwner = null;
|
|
45
|
-
}
|
|
46
|
-
controlBoundaryOwners.set(parent, controlState);
|
|
47
|
-
ownerState._commitOwner = parent;
|
|
48
|
-
controlState._enqueueBoundaryCommit = () => {
|
|
49
|
-
if (controlState._hasPendingBoundaryCommit) return;
|
|
50
|
-
controlState._hasPendingBoundaryCommit = true;
|
|
51
|
-
enqueueRuntimeTask(() => {
|
|
52
|
-
controlState._hasPendingBoundaryCommit = false;
|
|
53
|
-
if (controlBoundaryOwners.get(parent) !== controlState) return;
|
|
54
|
-
const lifecycleBatch = beginLifecycleCommitBatch();
|
|
55
|
-
try {
|
|
56
|
-
commitForBoundaryChildren(parent, controlState, getControlBoundaryCommitChildren(controlState));
|
|
57
|
-
flushLifecycleCommitBatch(lifecycleBatch);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
discardLifecycleCommitBatch(lifecycleBatch);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function commitForBoundaryChildren(parent, controlState, childrenVNodes) {
|
|
66
|
-
if (controlState.kind !== "for") {
|
|
67
|
-
const activeScope = controlState.activeScope;
|
|
68
|
-
const activeVNode = childrenVNodes[0];
|
|
69
|
-
const nextDom = activeScope && activeVNode !== void 0 ? syncControlBoundaryScopeDom(parent, activeScope, activeVNode, parent.firstChild, controlState.lastRemovedRanges.length === 0) : null;
|
|
70
|
-
for (const removedRange of controlState.lastRemovedRanges) removeRange(removedRange, (node) => {
|
|
71
|
-
if (!removedRange.single && (node === removedRange.start || node === removedRange.end)) {
|
|
72
|
-
node.parentNode?.removeChild(node);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
teardownNodeSubtree(node);
|
|
76
|
-
node.parentNode?.removeChild(node);
|
|
77
|
-
});
|
|
78
|
-
for (let i = 0; i < controlState.lastRemovedNodes.length; i++) {
|
|
79
|
-
const removedNode = controlState.lastRemovedNodes[i];
|
|
80
|
-
if (removedNode instanceof Element) teardownNodeSubtree(removedNode);
|
|
81
|
-
if (removedNode.parentNode === parent) {
|
|
82
|
-
recordBenchEvent("domRemove");
|
|
83
|
-
parent.removeChild(removedNode);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (nextDom) {
|
|
87
|
-
if (parent.childNodes.length !== (nextDom.single ? 1 : getRangeNodes(nextDom).length + 2) || parent.firstChild !== nextDom.start || controlState.lastRemovedNodes.length > 0 || controlState.lastRemovedRanges.length > 0) {
|
|
88
|
-
const nodes = nextDom.single ? [nextDom.start] : [
|
|
89
|
-
nextDom.start,
|
|
90
|
-
...getRangeNodes(nextDom),
|
|
91
|
-
nextDom.end
|
|
92
|
-
];
|
|
93
|
-
parent.replaceChildren(...nodes);
|
|
94
|
-
}
|
|
95
|
-
} else if (parent.firstChild) parent.textContent = "";
|
|
96
|
-
keyedElements.delete(parent);
|
|
97
|
-
clearControlBoundaryDomUpdateState(controlState);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
commitForStateBoundaryChildren(parent, controlState, childrenVNodes, {
|
|
101
|
-
isProduction: () => getRuntimeEnv().NODE_ENV === "production",
|
|
102
|
-
syncForItemDom: syncControlBoundaryScopeNode,
|
|
103
|
-
tryPatchStableForDirtyItem: (scope) => getBoundaryDOMHost().tryPatchStableForDirtyItem(scope)
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function trySyncControlBoundaryChild(parent, currentNode, next) {
|
|
107
|
-
if (next.type !== __FOR_BOUNDARY__) return false;
|
|
108
|
-
const controlState = getControlBoundaryState(next);
|
|
109
|
-
if (!controlState || controlState.kind === "for") return false;
|
|
110
|
-
const childrenVNodes = evaluateControlBoundaryState(controlState);
|
|
111
|
-
const activeScope = controlState.activeScope;
|
|
112
|
-
const activeVNode = childrenVNodes[0];
|
|
113
|
-
const nextDom = activeScope && activeVNode !== void 0 ? syncControlBoundaryScopeDom(parent, activeScope, activeVNode) : null;
|
|
114
|
-
for (const removedRange of controlState.lastRemovedRanges) removeRange(removedRange, (node) => {
|
|
115
|
-
if (!removedRange.single && (node === removedRange.start || node === removedRange.end)) {
|
|
116
|
-
node.parentNode?.removeChild(node);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
teardownNodeSubtree(node);
|
|
120
|
-
node.parentNode?.removeChild(node);
|
|
121
|
-
});
|
|
122
|
-
for (let i = 0; i < controlState.lastRemovedNodes.length; i++) {
|
|
123
|
-
const removedNode = controlState.lastRemovedNodes[i];
|
|
124
|
-
if (removedNode.parentNode !== parent) continue;
|
|
125
|
-
teardownNodeSubtree(removedNode);
|
|
126
|
-
if (nextDom && !rangeContains(nextDom, removedNode) && !nextDom.start.parentNode) insertRangeBefore(parent, nextDom, removedNode);
|
|
127
|
-
else parent.removeChild(removedNode);
|
|
128
|
-
}
|
|
129
|
-
if (nextDom && nextDom.start.parentNode !== parent) if (currentNode?.parentNode === parent && !rangeContains(nextDom, currentNode)) {
|
|
130
|
-
teardownNodeSubtree(currentNode);
|
|
131
|
-
insertRangeBefore(parent, nextDom, currentNode);
|
|
132
|
-
currentNode.parentNode?.removeChild(currentNode);
|
|
133
|
-
} else insertRangeBefore(parent, nextDom);
|
|
134
|
-
else if (!nextDom && currentNode?.parentNode === parent) {
|
|
135
|
-
teardownNodeSubtree(currentNode);
|
|
136
|
-
parent.removeChild(currentNode);
|
|
137
|
-
}
|
|
138
|
-
clearControlBoundaryDomUpdateState(controlState);
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
142
|
-
export { clearControlBoundaryCommitOwner, commitForBoundaryChildren, configureBoundaryDOMHost, createForBoundary, evaluateControlBoundaryState, getControlBoundaryState, getDirectControlBoundaryVNode, registerControlBoundaryCommitOwner, syncControlBoundaryInMixedParent, syncControlBoundaryScopeDom, trySyncControlBoundaryChild };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { getRuntimeEnv } from "../common/env.js";
|
|
2
|
-
import { logger } from "../common/logger.js";
|
|
3
|
-
import "./env.js";
|
|
4
|
-
import { appendRange } from "./dom-range.js";
|
|
5
|
-
import { assignScopeRange, checkVNodeShapeChanged, materializeChildScopeRange } from "./boundary-range-adoption.js";
|
|
6
|
-
import { clearControlBoundaryDomUpdateState, evaluateControlBoundaryState, getControlBoundaryState } from "./boundary-state.js";
|
|
7
|
-
//#region src/renderer/boundary-materialization.ts
|
|
8
|
-
/**
|
|
9
|
-
* Create DOM from For/Show/Case control boundaries.
|
|
10
|
-
*
|
|
11
|
-
* DOM order is reconstructed from the current vnode list on every render.
|
|
12
|
-
* Reusing DOM nodes never implies preserving their position; appending an
|
|
13
|
-
* existing node to the fragment expresses reordering per the DOM spec.
|
|
14
|
-
*/
|
|
15
|
-
function createForBoundary(node, props, parentNamespace) {
|
|
16
|
-
const controlState = getControlBoundaryState(node);
|
|
17
|
-
if (!controlState) {
|
|
18
|
-
if (getRuntimeEnv().NODE_ENV !== "production") logger.warn("[Askr] Control boundary missing state");
|
|
19
|
-
return document.createDocumentFragment();
|
|
20
|
-
}
|
|
21
|
-
const childrenVNodes = evaluateControlBoundaryState(controlState);
|
|
22
|
-
const fragment = document.createDocumentFragment();
|
|
23
|
-
if (controlState.kind !== "for") {
|
|
24
|
-
const activeScope = controlState.activeScope;
|
|
25
|
-
const vnode = childrenVNodes[0];
|
|
26
|
-
if (activeScope && vnode !== void 0) {
|
|
27
|
-
const range = materializeChildScopeRange(vnode, parentNamespace, activeScope);
|
|
28
|
-
assignScopeRange(activeScope, range);
|
|
29
|
-
activeScope.hydrationPending = false;
|
|
30
|
-
appendRange(fragment, range);
|
|
31
|
-
}
|
|
32
|
-
clearControlBoundaryDomUpdateState(controlState);
|
|
33
|
-
return fragment;
|
|
34
|
-
}
|
|
35
|
-
const forState = controlState;
|
|
36
|
-
if (forState.orderedKeys.length === 0) {
|
|
37
|
-
const fallbackScope = forState.fallbackScope;
|
|
38
|
-
const fallbackVNode = childrenVNodes[0];
|
|
39
|
-
if (fallbackScope && fallbackVNode !== void 0) {
|
|
40
|
-
const range = materializeChildScopeRange(fallbackVNode, parentNamespace, fallbackScope);
|
|
41
|
-
assignScopeRange(fallbackScope, range);
|
|
42
|
-
fallbackScope.hydrationPending = false;
|
|
43
|
-
appendRange(fragment, range);
|
|
44
|
-
}
|
|
45
|
-
clearControlBoundaryDomUpdateState(controlState);
|
|
46
|
-
return fragment;
|
|
47
|
-
}
|
|
48
|
-
for (let i = 0; i < childrenVNodes.length; i++) {
|
|
49
|
-
const childVNode = childrenVNodes[i];
|
|
50
|
-
const itemKey = forState.orderedKeys[i];
|
|
51
|
-
const itemInstance = itemKey != null ? forState.items.get(itemKey) : null;
|
|
52
|
-
let range = null;
|
|
53
|
-
if (itemInstance && itemInstance.scope.range) {
|
|
54
|
-
const cachedRange = itemInstance.scope.range;
|
|
55
|
-
const cachedDom = cachedRange.single ? cachedRange.start : null;
|
|
56
|
-
if (!cachedDom || !checkVNodeShapeChanged(cachedDom, childVNode)) range = cachedRange;
|
|
57
|
-
}
|
|
58
|
-
if (!range) {
|
|
59
|
-
const materializedRange = materializeChildScopeRange(childVNode, parentNamespace, itemInstance?.scope);
|
|
60
|
-
if (itemInstance) {
|
|
61
|
-
assignScopeRange(itemInstance.scope, materializedRange);
|
|
62
|
-
itemInstance.scope.hydrationPending = false;
|
|
63
|
-
}
|
|
64
|
-
range = materializedRange;
|
|
65
|
-
}
|
|
66
|
-
appendRange(fragment, range);
|
|
67
|
-
}
|
|
68
|
-
clearControlBoundaryDomUpdateState(controlState);
|
|
69
|
-
return fragment;
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
export { createForBoundary };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { Fragment } from "../common/jsx.js";
|
|
4
|
-
import { enterDomCommitScope, restoreDomCommitScope } from "../runtime/component-scope.js";
|
|
5
|
-
import "../runtime/index.js";
|
|
6
|
-
import { createDetachedRange, createEmptyRange, createSingleNodeRange, findRangeEnd, getRangeNodes, isRangeStart } from "./dom-range.js";
|
|
7
|
-
import { getParentNamespace } from "./namespaces.js";
|
|
8
|
-
import "../jsx/index.js";
|
|
9
|
-
//#region src/renderer/boundary-range-adoption.ts
|
|
10
|
-
let boundaryRangeHost = null;
|
|
11
|
-
function configureBoundaryRangeHost(host) {
|
|
12
|
-
boundaryRangeHost = host;
|
|
13
|
-
}
|
|
14
|
-
function getBoundaryRangeHost() {
|
|
15
|
-
if (!boundaryRangeHost) throw new Error("[askr] Control boundary DOM host is not configured.");
|
|
16
|
-
return boundaryRangeHost;
|
|
17
|
-
}
|
|
18
|
-
function assignScopeRange(scope, range) {
|
|
19
|
-
scope.range = range;
|
|
20
|
-
scope.dom = range.single ? range.start : void 0;
|
|
21
|
-
}
|
|
22
|
-
function checkVNodeShapeChanged(dom, vnode) {
|
|
23
|
-
if (!_isDOMElement(vnode) || !(dom instanceof Element)) return true;
|
|
24
|
-
if (typeof vnode.type !== "string") return true;
|
|
25
|
-
return dom.tagName.toLowerCase() !== vnode.type.toLowerCase();
|
|
26
|
-
}
|
|
27
|
-
function adoptHydratedRange(parent, scope, before, vnode) {
|
|
28
|
-
if (!scope.hydrationPending || !before || !isRangeStart(before)) return null;
|
|
29
|
-
const end = findRangeEnd(before);
|
|
30
|
-
if (!end || end.parentNode !== parent) return null;
|
|
31
|
-
const range = {
|
|
32
|
-
start: before,
|
|
33
|
-
end,
|
|
34
|
-
single: false
|
|
35
|
-
};
|
|
36
|
-
const contentNodes = getRangeNodes(range);
|
|
37
|
-
const expectedChildren = _isDOMElement(vnode) && vnode.type === Fragment ? vnode.props?.children ?? [] : [vnode];
|
|
38
|
-
if (contentNodes.length !== expectedChildren.length) return null;
|
|
39
|
-
for (let index = 0; index < expectedChildren.length; index += 1) {
|
|
40
|
-
const expected = expectedChildren[index];
|
|
41
|
-
const actual = contentNodes[index];
|
|
42
|
-
if (_isDOMElement(expected) && typeof expected.type === "string" && (!(actual instanceof Element) || actual.tagName.toLowerCase() !== expected.type.toLowerCase())) return null;
|
|
43
|
-
}
|
|
44
|
-
assignScopeRange(scope, range);
|
|
45
|
-
scope.hydrationPending = false;
|
|
46
|
-
return range;
|
|
47
|
-
}
|
|
48
|
-
function getScopeRange(scope) {
|
|
49
|
-
if (scope.range) return scope.range;
|
|
50
|
-
if (!scope.dom) return null;
|
|
51
|
-
const range = {
|
|
52
|
-
start: scope.dom,
|
|
53
|
-
end: scope.dom,
|
|
54
|
-
single: true
|
|
55
|
-
};
|
|
56
|
-
scope.range = range;
|
|
57
|
-
return range;
|
|
58
|
-
}
|
|
59
|
-
function materializeChildScopeRange(vnode, parentNamespace, scope, scopeAlreadyActive = false) {
|
|
60
|
-
const previousInstance = scope && !scopeAlreadyActive ? enterDomCommitScope(scope.componentInstance) : null;
|
|
61
|
-
let dom;
|
|
62
|
-
try {
|
|
63
|
-
const host = getBoundaryRangeHost();
|
|
64
|
-
dom = scope?.blueprintOwner && _isDOMElement(vnode) && typeof vnode.type === "string" ? host.createResultNodeWithBlueprint(scope.blueprintOwner, vnode, parentNamespace) : host.createDOMNode(vnode, parentNamespace);
|
|
65
|
-
} finally {
|
|
66
|
-
if (scope && !scopeAlreadyActive) restoreDomCommitScope(previousInstance);
|
|
67
|
-
}
|
|
68
|
-
if (!dom) return createEmptyRange(document, scope).range;
|
|
69
|
-
if (!(dom instanceof DocumentFragment)) return createSingleNodeRange(dom, scope);
|
|
70
|
-
return createDetachedRange(dom, scope).range;
|
|
71
|
-
}
|
|
72
|
-
function getBoundaryParentNamespace(parent) {
|
|
73
|
-
return getParentNamespace(parent);
|
|
74
|
-
}
|
|
75
|
-
//#endregion
|
|
76
|
-
export { adoptHydratedRange, assignScopeRange, checkVNodeShapeChanged, configureBoundaryRangeHost, getBoundaryParentNamespace, getBoundaryRangeHost, getScopeRange, materializeChildScopeRange };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { enterDomCommitScope, restoreDomCommitScope } from "../runtime/component-scope.js";
|
|
4
|
-
import { registerLifecycleTransaction } from "../runtime/lifecycle-batch.js";
|
|
5
|
-
import { clearCaseDomUpdateState, clearShowDomUpdateState } from "../runtime/control.js";
|
|
6
|
-
import { clearForDomUpdateState } from "../runtime/for-internal.js";
|
|
7
|
-
import "../runtime/index.js";
|
|
8
|
-
import { teardownNodeSubtree } from "./cleanup.js";
|
|
9
|
-
import { tagNamesEqualIgnoreCase } from "./utils.js";
|
|
10
|
-
import { insertRangeBefore, removeRange } from "./dom-range.js";
|
|
11
|
-
import { adoptHydratedRange, assignScopeRange, getBoundaryParentNamespace, getBoundaryRangeHost, getScopeRange, materializeChildScopeRange } from "./boundary-range-adoption.js";
|
|
12
|
-
//#region src/renderer/boundary-range-sync.ts
|
|
13
|
-
function clearBoundaryState(controlState) {
|
|
14
|
-
if (controlState.kind === "for") clearForDomUpdateState(controlState);
|
|
15
|
-
else if (controlState.kind === "show") clearShowDomUpdateState(controlState);
|
|
16
|
-
else clearCaseDomUpdateState(controlState);
|
|
17
|
-
}
|
|
18
|
-
function syncControlBoundaryScopeDom(parent, scope, vnode, before = null, allowHydrationAdoption = true, insertDetached = true) {
|
|
19
|
-
const previousInstance = enterDomCommitScope(scope.componentInstance);
|
|
20
|
-
try {
|
|
21
|
-
const currentRange = getScopeRange(scope);
|
|
22
|
-
const dom = currentRange?.single ? currentRange.start : null;
|
|
23
|
-
const host = getBoundaryRangeHost();
|
|
24
|
-
const hydratedRange = currentRange || !allowHydrationAdoption ? null : adoptHydratedRange(parent, scope, before, vnode);
|
|
25
|
-
if (hydratedRange) return hydratedRange;
|
|
26
|
-
const resolvedRange = hydratedRange ?? currentRange;
|
|
27
|
-
if (resolvedRange && scope.hydrationPending && !resolvedRange.single) {
|
|
28
|
-
scope.hydrationPending = false;
|
|
29
|
-
return resolvedRange;
|
|
30
|
-
}
|
|
31
|
-
if (_isDOMElement(vnode) && typeof vnode.type === "function") {
|
|
32
|
-
const synced = host.syncComponentElement(dom, vnode, vnode.type, (vnode.props ?? {}) || {}, getBoundaryParentNamespace(parent));
|
|
33
|
-
if (synced) {
|
|
34
|
-
const nextRange = {
|
|
35
|
-
start: synced,
|
|
36
|
-
end: synced,
|
|
37
|
-
single: true
|
|
38
|
-
};
|
|
39
|
-
assignScopeRange(scope, nextRange);
|
|
40
|
-
return nextRange;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (!resolvedRange) {
|
|
44
|
-
const nextRange = materializeChildScopeRange(vnode, getBoundaryParentNamespace(parent), scope, true);
|
|
45
|
-
assignScopeRange(scope, nextRange);
|
|
46
|
-
if (insertDetached) insertRangeBefore(parent, nextRange, before);
|
|
47
|
-
return nextRange;
|
|
48
|
-
}
|
|
49
|
-
if (resolvedRange.single && dom?.nodeType === 3 && (typeof vnode === "string" || typeof vnode === "number")) {
|
|
50
|
-
dom.data = String(vnode);
|
|
51
|
-
return currentRange;
|
|
52
|
-
}
|
|
53
|
-
if (resolvedRange.single && dom?.nodeType === 8 && (vnode === null || vnode === void 0 || vnode === false)) return currentRange;
|
|
54
|
-
if (resolvedRange.single && dom instanceof Element && _isDOMElement(vnode) && typeof vnode.type === "string" && tagNamesEqualIgnoreCase(dom.tagName, vnode.type)) {
|
|
55
|
-
host.updateElementFromVnode(dom, vnode, true);
|
|
56
|
-
return currentRange;
|
|
57
|
-
}
|
|
58
|
-
const nextRange = materializeChildScopeRange(vnode, getBoundaryParentNamespace(parent), scope);
|
|
59
|
-
const previousRange = resolvedRange;
|
|
60
|
-
const previousDom = scope.dom;
|
|
61
|
-
const previousParent = previousRange.start.parentNode;
|
|
62
|
-
const previousNextSibling = previousRange.end.nextSibling;
|
|
63
|
-
const registered = registerLifecycleTransaction({}, () => removeRange(previousRange, teardownBoundaryRangeNode), () => {
|
|
64
|
-
removeRange(nextRange, teardownBoundaryRangeNode);
|
|
65
|
-
if (previousParent && !previousRange.start.parentNode) previousParent.insertBefore(previousRange.start, previousNextSibling?.parentNode === previousParent ? previousNextSibling : null);
|
|
66
|
-
scope.range = previousRange;
|
|
67
|
-
scope.dom = previousDom;
|
|
68
|
-
});
|
|
69
|
-
if (previousRange.single && nextRange.single && previousRange.start.parentNode === parent) parent.replaceChild(nextRange.start, previousRange.start);
|
|
70
|
-
else insertRangeBefore(parent, nextRange, previousRange.start.parentNode === parent ? previousRange.start : null);
|
|
71
|
-
assignScopeRange(scope, nextRange);
|
|
72
|
-
if (!registered) removeRange(previousRange, teardownBoundaryRangeNode);
|
|
73
|
-
return nextRange;
|
|
74
|
-
} finally {
|
|
75
|
-
restoreDomCommitScope(previousInstance);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function teardownBoundaryRangeNode(node) {
|
|
79
|
-
if (node.nodeType === 8) {
|
|
80
|
-
node.parentNode?.removeChild(node);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
teardownNodeSubtree(node);
|
|
84
|
-
node.parentNode?.removeChild(node);
|
|
85
|
-
}
|
|
86
|
-
function syncControlBoundaryScopeNode(parent, scope, vnode) {
|
|
87
|
-
const range = syncControlBoundaryScopeDom(parent, scope, vnode, null, true, false);
|
|
88
|
-
return range?.single ? range.start : null;
|
|
89
|
-
}
|
|
90
|
-
function syncControlBoundaryInMixedParent(parent, controlState, childrenVNodes, before) {
|
|
91
|
-
if (controlState.kind === "for") throw new Error("[askr] For ranges require the keyed boundary commit path.");
|
|
92
|
-
const activeScope = controlState.activeScope;
|
|
93
|
-
const activeVNode = childrenVNodes[0];
|
|
94
|
-
const nextRange = activeScope && activeVNode !== void 0 ? syncControlBoundaryScopeDom(parent, activeScope, activeVNode, before, controlState.lastRemovedRanges.length === 0) : null;
|
|
95
|
-
for (const range of controlState.lastRemovedRanges) if (range !== nextRange) removeRange(range, teardownBoundaryRangeNode);
|
|
96
|
-
for (const node of controlState.lastRemovedNodes) if (node.parentNode === parent) teardownBoundaryRangeNode(node);
|
|
97
|
-
clearBoundaryState(controlState);
|
|
98
|
-
return nextRange ? [nextRange] : [];
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
101
|
-
export { syncControlBoundaryInMixedParent, syncControlBoundaryScopeDom, syncControlBoundaryScopeNode };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { __FOR_BOUNDARY__, _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { clearCaseDomUpdateState, clearShowDomUpdateState, evaluateCaseState, evaluateShowState } from "../runtime/control.js";
|
|
4
|
-
import { clearForDomUpdateState, evaluateForState } from "../runtime/for-internal.js";
|
|
5
|
-
import "../runtime/index.js";
|
|
6
|
-
//#region src/renderer/boundary-state.ts
|
|
7
|
-
function evaluateControlBoundaryState(controlState) {
|
|
8
|
-
if (controlState.kind === "for") return evaluateForState(controlState);
|
|
9
|
-
if (controlState.kind === "show") return evaluateShowState(controlState);
|
|
10
|
-
return evaluateCaseState(controlState);
|
|
11
|
-
}
|
|
12
|
-
function clearControlBoundaryDomUpdateState(controlState) {
|
|
13
|
-
if (controlState.kind === "for") {
|
|
14
|
-
clearForDomUpdateState(controlState);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (controlState.kind === "show") {
|
|
18
|
-
clearShowDomUpdateState(controlState);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
clearCaseDomUpdateState(controlState);
|
|
22
|
-
}
|
|
23
|
-
function getControlBoundaryState(node) {
|
|
24
|
-
return node._controlState ?? node._forState ?? null;
|
|
25
|
-
}
|
|
26
|
-
function getDirectControlBoundaryVNode(children) {
|
|
27
|
-
if (!Array.isArray(children) && _isDOMElement(children) && children.type === __FOR_BOUNDARY__) return children;
|
|
28
|
-
if (Array.isArray(children) && children.length === 1 && _isDOMElement(children[0]) && children[0].type === __FOR_BOUNDARY__) return children[0];
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
function getControlBoundaryCommitChildren(controlState) {
|
|
32
|
-
if (controlState.kind === "for" && controlState._needsSourceReconcile) return evaluateForState(controlState);
|
|
33
|
-
if (controlState.kind !== "for") {
|
|
34
|
-
const activeVNode = controlState.activeScope?.vnode;
|
|
35
|
-
return activeVNode == null || activeVNode === false ? [] : [activeVNode];
|
|
36
|
-
}
|
|
37
|
-
if (controlState.orderedKeys.length === 0) {
|
|
38
|
-
const fallbackVNode = controlState.fallbackScope?.vnode;
|
|
39
|
-
return fallbackVNode == null || fallbackVNode === false ? [] : [fallbackVNode];
|
|
40
|
-
}
|
|
41
|
-
const childrenVNodes = [];
|
|
42
|
-
for (let index = 0; index < controlState.orderedKeys.length; index += 1) {
|
|
43
|
-
const itemKey = controlState.orderedKeys[index];
|
|
44
|
-
const itemInstance = controlState.items.get(itemKey);
|
|
45
|
-
childrenVNodes.push(itemInstance?.scope.vnode ?? null);
|
|
46
|
-
}
|
|
47
|
-
return childrenVNodes;
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
export { clearControlBoundaryDomUpdateState, evaluateControlBoundaryState, getControlBoundaryCommitChildren, getControlBoundaryState, getDirectControlBoundaryVNode };
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { __FOR_BOUNDARY__, _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { getRuntimeEnv } from "../common/env.js";
|
|
4
|
-
import { logger } from "../common/logger.js";
|
|
5
|
-
import { Fragment, STATIC_CHILDREN } from "../common/jsx.js";
|
|
6
|
-
import { getCurrentInstance } from "../runtime/component-scope.js";
|
|
7
|
-
import "../runtime/index.js";
|
|
8
|
-
import "./env.js";
|
|
9
|
-
import { isSkippedProp, parseEventName } from "./utils.js";
|
|
10
|
-
import "../jsx-runtime.js";
|
|
11
|
-
//#region src/renderer/child-shape.ts
|
|
12
|
-
function isFragmentVNode(node) {
|
|
13
|
-
return _isDOMElement(node) && typeof node.type === "symbol" && (node.type === Fragment || String(node.type) === "Symbol(askr.fragment)");
|
|
14
|
-
}
|
|
15
|
-
function normalizeComponentChildren(result) {
|
|
16
|
-
if (result === null || result === void 0 || result === false) return [];
|
|
17
|
-
if (Array.isArray(result)) {
|
|
18
|
-
const children = [];
|
|
19
|
-
for (const child of result) children.push(...normalizeComponentChildren(child));
|
|
20
|
-
return children;
|
|
21
|
-
}
|
|
22
|
-
if (isFragmentVNode(result)) return normalizeComponentChildren(result.props?.children ?? result.children ?? []);
|
|
23
|
-
return [result];
|
|
24
|
-
}
|
|
25
|
-
function warnMissingKeys(children) {
|
|
26
|
-
if (getRuntimeEnv().NODE_ENV === "production") return;
|
|
27
|
-
let hasElements = false;
|
|
28
|
-
let hasKeys = false;
|
|
29
|
-
for (const item of children) if (typeof item === "object" && item !== null && "type" in item) {
|
|
30
|
-
if (item.type === __FOR_BOUNDARY__) continue;
|
|
31
|
-
hasElements = true;
|
|
32
|
-
if ((item.key ?? item.props?.key) !== void 0) {
|
|
33
|
-
hasKeys = true;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (hasElements && !hasKeys) {
|
|
38
|
-
const inst = getCurrentInstance();
|
|
39
|
-
const warnings = inst ? inst.devWarningsEmitted ??= /* @__PURE__ */ new Set() : null;
|
|
40
|
-
if (warnings?.has("missing-keys")) return;
|
|
41
|
-
warnings?.add("missing-keys");
|
|
42
|
-
try {
|
|
43
|
-
const name = inst?.fn?.name || "<anonymous>";
|
|
44
|
-
logger.warn(`Missing keys on dynamic lists in ${name}. Each child in a list should have a unique "key" prop.`);
|
|
45
|
-
} catch {
|
|
46
|
-
logger.warn("Missing keys on dynamic lists. Each child in a list should have a unique \"key\" prop.");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function hasStaticChildrenMarker(children) {
|
|
51
|
-
return children[STATIC_CHILDREN] === true;
|
|
52
|
-
}
|
|
53
|
-
function maybeWarnMissingKeys(children) {
|
|
54
|
-
if (!hasStaticChildrenMarker(children)) warnMissingKeys(children);
|
|
55
|
-
}
|
|
56
|
-
function tryGetStaticCreateChildShape(children) {
|
|
57
|
-
if (children === null || children === void 0 || children === false) return { textContent: null };
|
|
58
|
-
if (typeof children === "string" || typeof children === "number") return { textContent: String(children) };
|
|
59
|
-
if (Array.isArray(children) && children.length === 1) {
|
|
60
|
-
const child = children[0];
|
|
61
|
-
if (child === null || child === void 0 || child === false) return { textContent: null };
|
|
62
|
-
if (typeof child === "string" || typeof child === "number") return { textContent: String(child) };
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
function isStaticCreateScalarValue(value) {
|
|
67
|
-
const valueType = typeof value;
|
|
68
|
-
return valueType === "string" || valueType === "number" || valueType === "boolean";
|
|
69
|
-
}
|
|
70
|
-
function tryGetStaticCreateFastPathShape(props, children) {
|
|
71
|
-
const childShape = tryGetStaticCreateChildShape(children);
|
|
72
|
-
if (!childShape) return null;
|
|
73
|
-
for (const key in props) {
|
|
74
|
-
if (key === "ref") return null;
|
|
75
|
-
if (isSkippedProp(key)) continue;
|
|
76
|
-
const value = props[key];
|
|
77
|
-
if (value === void 0 || value === null || value === false) continue;
|
|
78
|
-
if (parseEventName(key) || !isStaticCreateScalarValue(value)) return null;
|
|
79
|
-
}
|
|
80
|
-
return childShape;
|
|
81
|
-
}
|
|
82
|
-
//#endregion
|
|
83
|
-
export { isFragmentVNode, maybeWarnMissingKeys, normalizeComponentChildren, tryGetStaticCreateFastPathShape };
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { getRuntimeEnv } from "../common/env.js";
|
|
4
|
-
import { teardownNodeSubtree } from "./cleanup.js";
|
|
5
|
-
import "./env.js";
|
|
6
|
-
import { hasNonTrivialProps, logFastPathDebug, now, recordFastPathStats, tagNamesEqualIgnoreCase } from "./utils.js";
|
|
7
|
-
import { keyedElements } from "./keyed.js";
|
|
8
|
-
import { createDOMNode, updateElementFromVnode } from "./dom-internal.js";
|
|
9
|
-
import "./dom.js";
|
|
10
|
-
//#region src/renderer/children-fastpath.ts
|
|
11
|
-
function upperCommonTagName(tag) {
|
|
12
|
-
switch (tag) {
|
|
13
|
-
case "div": return "DIV";
|
|
14
|
-
case "span": return "SPAN";
|
|
15
|
-
case "p": return "P";
|
|
16
|
-
case "a": return "A";
|
|
17
|
-
case "button": return "BUTTON";
|
|
18
|
-
case "input": return "INPUT";
|
|
19
|
-
case "ul": return "UL";
|
|
20
|
-
case "ol": return "OL";
|
|
21
|
-
case "li": return "LI";
|
|
22
|
-
default: return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function tagsEqualIgnoreCase(elementTagName, vnodeType) {
|
|
26
|
-
if (elementTagName === vnodeType) return true;
|
|
27
|
-
const upperCommon = upperCommonTagName(vnodeType);
|
|
28
|
-
if (upperCommon !== null && elementTagName === upperCommon) return true;
|
|
29
|
-
return tagNamesEqualIgnoreCase(elementTagName, vnodeType);
|
|
30
|
-
}
|
|
31
|
-
function performBulkPositionalKeyedTextUpdate(parent, keyedVnodes) {
|
|
32
|
-
const total = keyedVnodes.length;
|
|
33
|
-
let reused = 0;
|
|
34
|
-
let updatedKeys = 0;
|
|
35
|
-
const start = now();
|
|
36
|
-
const env = getRuntimeEnv();
|
|
37
|
-
const debugFastPath = env.ASKR_FASTPATH_DEBUG === "1" || env.ASKR_FASTPATH_DEBUG === "true";
|
|
38
|
-
for (let index = 0; index < total; index += 1) {
|
|
39
|
-
const { key, vnode } = keyedVnodes[index];
|
|
40
|
-
const child = parent.children[index];
|
|
41
|
-
if (child && _isDOMElement(vnode) && typeof vnode.type === "string") {
|
|
42
|
-
const vnodeType = vnode.type;
|
|
43
|
-
if (tagsEqualIgnoreCase(child.tagName, vnodeType)) {
|
|
44
|
-
const children = vnode.children || vnode.props?.children;
|
|
45
|
-
if (debugFastPath) logFastPathDebug("positional idx", index, {
|
|
46
|
-
chTag: child.tagName,
|
|
47
|
-
vnodeType,
|
|
48
|
-
chChildNodes: child.childNodes.length,
|
|
49
|
-
childrenType: Array.isArray(children) ? "array" : typeof children
|
|
50
|
-
});
|
|
51
|
-
updateTextContent(child, children, vnode);
|
|
52
|
-
setDataKey(child, key, () => updatedKeys += 1);
|
|
53
|
-
reused += 1;
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (debugFastPath) logFastPathDebug("positional tag mismatch", index, {
|
|
57
|
-
chTag: child.tagName,
|
|
58
|
-
vnodeType
|
|
59
|
-
});
|
|
60
|
-
} else if (debugFastPath) logFastPathDebug("positional missing or invalid", index, { ch: !!child });
|
|
61
|
-
replaceNodeAtPosition(parent, index, vnode);
|
|
62
|
-
}
|
|
63
|
-
const elapsed = now() - start;
|
|
64
|
-
updateKeyedElementsMap(parent, keyedVnodes);
|
|
65
|
-
const stats = {
|
|
66
|
-
n: total,
|
|
67
|
-
reused,
|
|
68
|
-
updatedKeys,
|
|
69
|
-
t: elapsed
|
|
70
|
-
};
|
|
71
|
-
recordFastPathStats(stats, "bulkKeyedPositionalHits");
|
|
72
|
-
return stats;
|
|
73
|
-
}
|
|
74
|
-
function updateTextContent(el, children, vnode) {
|
|
75
|
-
if (typeof children === "string" || typeof children === "number") {
|
|
76
|
-
setTextNodeData(el, String(children));
|
|
77
|
-
if (vnode.props && hasNonTrivialProps(vnode.props)) updateElementFromVnode(el, vnode, false);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (Array.isArray(children) && children.length === 1 && (typeof children[0] === "string" || typeof children[0] === "number")) {
|
|
81
|
-
setTextNodeData(el, String(children[0]));
|
|
82
|
-
if (vnode.props && hasNonTrivialProps(vnode.props)) updateElementFromVnode(el, vnode, false);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (!tryUpdateTwoChildTextPattern(el, vnode)) updateElementFromVnode(el, vnode);
|
|
86
|
-
}
|
|
87
|
-
function tryUpdateTwoChildTextPattern(parentEl, vnode) {
|
|
88
|
-
const vnodeChildren = vnode.props?.children ?? vnode.children;
|
|
89
|
-
if (!Array.isArray(vnodeChildren) || vnodeChildren.length !== 2) return false;
|
|
90
|
-
const firstChild = vnodeChildren[0];
|
|
91
|
-
const secondChild = vnodeChildren[1];
|
|
92
|
-
if (!_isDOMElement(firstChild) || !_isDOMElement(secondChild)) return false;
|
|
93
|
-
if (typeof firstChild.type !== "string" || typeof secondChild.type !== "string") return false;
|
|
94
|
-
const firstElement = parentEl.children[0];
|
|
95
|
-
const secondElement = parentEl.children[1];
|
|
96
|
-
if (!firstElement || !secondElement) return false;
|
|
97
|
-
if (parentEl.children.length !== 2 || parentEl.childNodes.length !== 2) return false;
|
|
98
|
-
if (!tagsEqualIgnoreCase(firstElement.tagName, firstChild.type)) return false;
|
|
99
|
-
if (!tagsEqualIgnoreCase(secondElement.tagName, secondChild.type)) return false;
|
|
100
|
-
const firstText = firstChild.children || firstChild.props?.children;
|
|
101
|
-
const secondText = secondChild.children || secondChild.props?.children;
|
|
102
|
-
if (typeof firstText === "string" || typeof firstText === "number") setTextNodeData(firstElement, String(firstText));
|
|
103
|
-
else if (Array.isArray(firstText) && firstText.length === 1 && (typeof firstText[0] === "string" || typeof firstText[0] === "number")) setTextNodeData(firstElement, String(firstText[0]));
|
|
104
|
-
else return false;
|
|
105
|
-
if (typeof secondText === "string" || typeof secondText === "number") setTextNodeData(secondElement, String(secondText));
|
|
106
|
-
else if (Array.isArray(secondText) && secondText.length === 1 && (typeof secondText[0] === "string" || typeof secondText[0] === "number")) setTextNodeData(secondElement, String(secondText[0]));
|
|
107
|
-
else return false;
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
function setTextNodeData(el, text) {
|
|
111
|
-
if (el.childNodes.length === 1 && el.firstChild?.nodeType === 3) {
|
|
112
|
-
const textNode = el.firstChild;
|
|
113
|
-
if (textNode.data !== text) textNode.data = text;
|
|
114
|
-
} else el.textContent = text;
|
|
115
|
-
}
|
|
116
|
-
function setDataKey(el, key, onSet) {
|
|
117
|
-
try {
|
|
118
|
-
const next = String(key);
|
|
119
|
-
const keyKind = typeof key;
|
|
120
|
-
if (el.getAttribute("data-key") === next && el.getAttribute("data-askr-key-kind") === keyKind) return;
|
|
121
|
-
el.setAttribute("data-key", next);
|
|
122
|
-
el.setAttribute("data-askr-key-kind", keyKind);
|
|
123
|
-
onSet();
|
|
124
|
-
} catch {}
|
|
125
|
-
}
|
|
126
|
-
function replaceNodeAtPosition(parent, index, vnode) {
|
|
127
|
-
const dom = createDOMNode(vnode);
|
|
128
|
-
if (dom) {
|
|
129
|
-
const existing = parent.children[index];
|
|
130
|
-
if (existing) {
|
|
131
|
-
teardownNodeSubtree(existing);
|
|
132
|
-
parent.replaceChild(dom, existing);
|
|
133
|
-
} else parent.appendChild(dom);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function updateKeyedElementsMap(parent, keyedVnodes) {
|
|
137
|
-
try {
|
|
138
|
-
const existing = keyedElements.get(parent);
|
|
139
|
-
const newKeyMap = existing ? (existing.clear(), existing) : /* @__PURE__ */ new Map();
|
|
140
|
-
for (let index = 0; index < keyedVnodes.length; index += 1) {
|
|
141
|
-
const key = keyedVnodes[index].key;
|
|
142
|
-
const child = parent.children[index];
|
|
143
|
-
if (child) newKeyMap.set(key, child);
|
|
144
|
-
}
|
|
145
|
-
keyedElements.set(parent, newKeyMap);
|
|
146
|
-
} catch {}
|
|
147
|
-
}
|
|
148
|
-
//#endregion
|
|
149
|
-
export { performBulkPositionalKeyedTextUpdate, tagsEqualIgnoreCase };
|