@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,163 +0,0 @@
|
|
|
1
|
-
import { __FOR_BOUNDARY__ } from "../common/vnode.js";
|
|
2
|
-
import { evaluateCaseState, evaluateShowState } from "../runtime/control.js";
|
|
3
|
-
import { clearForDomUpdateState, evaluateForState } from "../runtime/for-internal.js";
|
|
4
|
-
import "../runtime/index.js";
|
|
5
|
-
import { extractKey, getMaterializedKey } from "./utils.js";
|
|
6
|
-
import { canReuseIntrinsicElementInNamespace, getParentNamespace } from "./namespaces.js";
|
|
7
|
-
import { getRendererDOMHost } from "./dom-host.js";
|
|
8
|
-
//#region src/renderer/reconcile-resolution.ts
|
|
9
|
-
function createOldElResolver(parent, oldKeyMap, usedOldEls) {
|
|
10
|
-
return (k) => {
|
|
11
|
-
if (!oldKeyMap) return void 0;
|
|
12
|
-
const direct = oldKeyMap.get(k);
|
|
13
|
-
if (direct && !usedOldEls.has(direct)) {
|
|
14
|
-
usedOldEls.add(direct);
|
|
15
|
-
return direct;
|
|
16
|
-
}
|
|
17
|
-
return scanForElementByKey(parent, k, usedOldEls);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function scanForElementByKey(parent, k, usedOldEls) {
|
|
21
|
-
try {
|
|
22
|
-
for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {
|
|
23
|
-
if (usedOldEls.has(ch)) continue;
|
|
24
|
-
if (getMaterializedKey(ch) === k) {
|
|
25
|
-
usedOldEls.add(ch);
|
|
26
|
-
return ch;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
} catch {}
|
|
30
|
-
}
|
|
31
|
-
function reconcileSingleChild(child, index, parent, resolveOldElOnce, resolveUnkeyedOnce, usedOldEls, newKeyMap) {
|
|
32
|
-
const resolvedControlBoundary = prepareControlBoundaryResolution(child);
|
|
33
|
-
if (resolvedControlBoundary !== null) {
|
|
34
|
-
if (resolvedControlBoundary.remount) return getRendererDOMHost().createDOMNode(resolvedControlBoundary.vnode, getParentNamespace(parent));
|
|
35
|
-
return reconcileSingleChild(resolvedControlBoundary.vnode, index, parent, resolveOldElOnce, resolveUnkeyedOnce, usedOldEls, newKeyMap);
|
|
36
|
-
}
|
|
37
|
-
const key = extractKey(child);
|
|
38
|
-
if (key !== void 0) return reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap);
|
|
39
|
-
return reconcileUnkeyedChild(child, index, parent, resolveUnkeyedOnce, usedOldEls);
|
|
40
|
-
}
|
|
41
|
-
function reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap) {
|
|
42
|
-
const el = resolveOldElOnce(key);
|
|
43
|
-
const parentNamespace = getParentNamespace(parent);
|
|
44
|
-
const domHost = getRendererDOMHost();
|
|
45
|
-
if (el && el.parentElement === parent) {
|
|
46
|
-
const childObj = child;
|
|
47
|
-
if (childObj && typeof childObj === "object" && typeof childObj.type === "string") {
|
|
48
|
-
if (canReuseIntrinsicElementInNamespace(el, childObj.type, parentNamespace)) {
|
|
49
|
-
domHost.updateElementFromVnode(el, child);
|
|
50
|
-
newKeyMap.set(key, el);
|
|
51
|
-
return el;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (isComponentVNode(child)) {
|
|
55
|
-
const synced = domHost.syncComponentElement(el, child, child.type, (child.props ?? {}) || {}, parentNamespace);
|
|
56
|
-
if (synced) {
|
|
57
|
-
if (synced instanceof Element) newKeyMap.set(key, synced);
|
|
58
|
-
return synced;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const dom = domHost.createDOMNode(child, parentNamespace);
|
|
63
|
-
if (dom) {
|
|
64
|
-
if (dom instanceof Element) newKeyMap.set(key, dom);
|
|
65
|
-
return dom;
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
function reconcileUnkeyedChild(child, index, parent, resolveUnkeyedOnce, usedOldEls) {
|
|
70
|
-
const parentNamespace = getParentNamespace(parent);
|
|
71
|
-
const domHost = getRendererDOMHost();
|
|
72
|
-
const existing = parent.childNodes[index];
|
|
73
|
-
if (typeof child === "string" || typeof child === "number") {
|
|
74
|
-
if (existing && existing.nodeType === 3) {
|
|
75
|
-
existing.data = String(child);
|
|
76
|
-
usedOldEls.add(existing);
|
|
77
|
-
return existing;
|
|
78
|
-
}
|
|
79
|
-
return domHost.createDOMNode(child, parentNamespace);
|
|
80
|
-
}
|
|
81
|
-
if (existing instanceof Element) {
|
|
82
|
-
const synced = trySyncComponentChild(existing, child, usedOldEls, parentNamespace);
|
|
83
|
-
if (synced) return synced;
|
|
84
|
-
}
|
|
85
|
-
if (existing instanceof Element && canReuseElement(existing, child, parentNamespace)) {
|
|
86
|
-
domHost.updateElementFromVnode(existing, child);
|
|
87
|
-
usedOldEls.add(existing);
|
|
88
|
-
return existing;
|
|
89
|
-
}
|
|
90
|
-
const avail = resolveUnkeyedOnce();
|
|
91
|
-
if (avail) {
|
|
92
|
-
const reuseResult = tryReuseElement(avail, child, usedOldEls, parentNamespace);
|
|
93
|
-
if (reuseResult) return reuseResult;
|
|
94
|
-
}
|
|
95
|
-
return domHost.createDOMNode(child, parentNamespace);
|
|
96
|
-
}
|
|
97
|
-
function isComponentVNode(child) {
|
|
98
|
-
return typeof child === "object" && child !== null && "type" in child && typeof child.type === "function";
|
|
99
|
-
}
|
|
100
|
-
function isControlBoundaryVNode(child) {
|
|
101
|
-
return typeof child === "object" && child !== null && "type" in child && child.type === __FOR_BOUNDARY__;
|
|
102
|
-
}
|
|
103
|
-
function prepareControlBoundaryResolution(child) {
|
|
104
|
-
if (!isControlBoundaryVNode(child)) return null;
|
|
105
|
-
const controlState = child._controlState ?? child._forState;
|
|
106
|
-
if (!controlState) return null;
|
|
107
|
-
if (controlState.kind === "for") {
|
|
108
|
-
const childrenVNodes = evaluateControlBoundaryChildren(controlState);
|
|
109
|
-
if (childrenVNodes.length !== 1) return null;
|
|
110
|
-
clearForDomUpdateState(controlState);
|
|
111
|
-
return {
|
|
112
|
-
remount: false,
|
|
113
|
-
vnode: childrenVNodes[0] ?? null
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const previousActiveKey = controlState.activeKey;
|
|
117
|
-
const childrenVNodes = evaluateControlBoundaryChildren(controlState);
|
|
118
|
-
return {
|
|
119
|
-
remount: previousActiveKey !== null && controlState.activeKey !== previousActiveKey,
|
|
120
|
-
vnode: childrenVNodes[0] ?? null
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function evaluateControlBoundaryChildren(controlState) {
|
|
124
|
-
if (controlState.kind === "for") return evaluateForState(controlState);
|
|
125
|
-
if (controlState.kind === "show") return evaluateShowState(controlState);
|
|
126
|
-
return evaluateCaseState(controlState);
|
|
127
|
-
}
|
|
128
|
-
function trySyncComponentChild(existing, child, usedOldEls, parentNamespace) {
|
|
129
|
-
if (!isComponentVNode(child)) return null;
|
|
130
|
-
const synced = getRendererDOMHost().syncComponentElement(existing, child, child.type, (child.props ?? {}) || {}, parentNamespace);
|
|
131
|
-
if (!synced) return null;
|
|
132
|
-
usedOldEls.add(existing);
|
|
133
|
-
usedOldEls.add(synced);
|
|
134
|
-
return synced;
|
|
135
|
-
}
|
|
136
|
-
function canReuseElement(existing, child, parentNamespace) {
|
|
137
|
-
if (!existing) return false;
|
|
138
|
-
if (typeof child !== "object" || child === null || !("type" in child)) return false;
|
|
139
|
-
const childObj = child;
|
|
140
|
-
const existingKey = existing.getAttribute("data-key");
|
|
141
|
-
return (existingKey === null || existingKey === void 0) && typeof childObj.type === "string" && canReuseIntrinsicElementInNamespace(existing, childObj.type, parentNamespace);
|
|
142
|
-
}
|
|
143
|
-
function collectUnkeyedElements(parent) {
|
|
144
|
-
const elements = [];
|
|
145
|
-
for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) if (ch.getAttribute("data-key") === null) elements.push(ch);
|
|
146
|
-
return elements;
|
|
147
|
-
}
|
|
148
|
-
function tryReuseElement(avail, child, usedOldEls, parentNamespace) {
|
|
149
|
-
if (typeof child === "string" || typeof child === "number") return null;
|
|
150
|
-
const synced = trySyncComponentChild(avail, child, usedOldEls, parentNamespace);
|
|
151
|
-
if (synced) return synced;
|
|
152
|
-
if (typeof child === "object" && child !== null && "type" in child) {
|
|
153
|
-
const childObj = child;
|
|
154
|
-
if (typeof childObj.type === "string" && canReuseIntrinsicElementInNamespace(avail, childObj.type, parentNamespace)) {
|
|
155
|
-
getRendererDOMHost().updateElementFromVnode(avail, child);
|
|
156
|
-
usedOldEls.add(avail);
|
|
157
|
-
return avail;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
export { collectUnkeyedElements, createOldElResolver, reconcileSingleChild };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { buildDOMKeyMap, extractKeyedVnodes } from "./keyed-children.js";
|
|
2
|
-
import { keyedElements } from "./keyed.js";
|
|
3
|
-
import { commitReconciliation } from "./reconcile-commit.js";
|
|
4
|
-
import { tryFastPaths } from "./reconcile-fastpaths.js";
|
|
5
|
-
import { collectUnkeyedElements, createOldElResolver, reconcileSingleChild } from "./reconcile-resolution.js";
|
|
6
|
-
function reconcileKeyedChildren(parent, newChildren, oldKeyMap) {
|
|
7
|
-
const keyedVnodes = extractKeyedVnodes(newChildren);
|
|
8
|
-
const ensuredOldKeyMap = oldKeyMap || buildDOMKeyMap(parent);
|
|
9
|
-
const fastPathResult = tryFastPaths(parent, newChildren, keyedVnodes, ensuredOldKeyMap);
|
|
10
|
-
if (fastPathResult) return fastPathResult;
|
|
11
|
-
return performFullReconciliation(parent, newChildren, ensuredOldKeyMap);
|
|
12
|
-
}
|
|
13
|
-
function performFullReconciliation(parent, newChildren, oldKeyMap) {
|
|
14
|
-
const newKeyMap = /* @__PURE__ */ new Map();
|
|
15
|
-
const finalNodes = [];
|
|
16
|
-
const usedOldEls = /* @__PURE__ */ new WeakSet();
|
|
17
|
-
const resolveOldElOnce = createOldElResolver(parent, oldKeyMap, usedOldEls);
|
|
18
|
-
const unkeyedEls = collectUnkeyedElements(parent);
|
|
19
|
-
let unkeyedIndex = 0;
|
|
20
|
-
const resolveUnkeyedOnce = () => {
|
|
21
|
-
while (unkeyedIndex < unkeyedEls.length) {
|
|
22
|
-
const candidate = unkeyedEls[unkeyedIndex++];
|
|
23
|
-
if (!usedOldEls.has(candidate)) return candidate;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
for (let i = 0; i < newChildren.length; i++) {
|
|
27
|
-
const child = newChildren[i];
|
|
28
|
-
const node = reconcileSingleChild(child, i, parent, resolveOldElOnce, resolveUnkeyedOnce, usedOldEls, newKeyMap);
|
|
29
|
-
if (node) finalNodes.push(node);
|
|
30
|
-
}
|
|
31
|
-
if (typeof document === "undefined") return newKeyMap;
|
|
32
|
-
commitReconciliation(parent, finalNodes);
|
|
33
|
-
keyedElements.delete(parent);
|
|
34
|
-
return newKeyMap;
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
export { reconcileKeyedChildren };
|
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { logger } from "../common/logger.js";
|
|
2
|
-
import { getCurrentLifecycleCommitBatch, registerLifecycleTransaction } from "../runtime/lifecycle-batch.js";
|
|
3
|
-
import { addDelegatedListener, getDelegatedHandlersForElement, removeDelegatedListener, updateDelegatedListener } from "../runtime/events.js";
|
|
4
|
-
import "../runtime/index.js";
|
|
5
|
-
import { elementListeners, elementReactivePropsCleanup, elementRefs, getElementReactivePropsCleanupMap } from "./cleanup.js";
|
|
6
|
-
import { keyedElements } from "./keyed.js";
|
|
7
|
-
//#region src/renderer/retained-element-rollback.ts
|
|
8
|
-
function collectTextSnapshots(root) {
|
|
9
|
-
const snapshots = [];
|
|
10
|
-
for (let index = 0; index < root.childNodes.length; index += 1) {
|
|
11
|
-
const node = root.childNodes[index];
|
|
12
|
-
if (node.nodeType === 3) {
|
|
13
|
-
const text = node;
|
|
14
|
-
snapshots.push({
|
|
15
|
-
node: text,
|
|
16
|
-
data: text.data
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return snapshots;
|
|
21
|
-
}
|
|
22
|
-
function getFormControlSnapshot(element) {
|
|
23
|
-
const control = element;
|
|
24
|
-
const snapshot = {};
|
|
25
|
-
if ("value" in control) snapshot.value = String(control.value ?? "");
|
|
26
|
-
if ("checked" in control) snapshot.checked = Boolean(control.checked);
|
|
27
|
-
return snapshot.value !== void 0 || snapshot.checked !== void 0 ? snapshot : null;
|
|
28
|
-
}
|
|
29
|
-
function cloneListenerEntry(entry) {
|
|
30
|
-
return {
|
|
31
|
-
handler: entry.handler,
|
|
32
|
-
original: entry.original,
|
|
33
|
-
eventName: entry.eventName,
|
|
34
|
-
options: entry.options,
|
|
35
|
-
isDelegated: entry.isDelegated,
|
|
36
|
-
updateHandler: entry.updateHandler
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function cloneReactivePropEntry(entry) {
|
|
40
|
-
return {
|
|
41
|
-
cleanup: entry.cleanup,
|
|
42
|
-
fnRef: entry.fnRef,
|
|
43
|
-
groupedScalar: entry.groupedScalar,
|
|
44
|
-
restoreFn: entry.restoreFn,
|
|
45
|
-
updateFn: entry.updateFn
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function snapshotRetainedElement(element, bindingsOnly = false) {
|
|
49
|
-
const listenerMap = elementListeners.get(element);
|
|
50
|
-
const delegatedHandlerMap = getDelegatedHandlersForElement(element);
|
|
51
|
-
const reactivePropMap = getElementReactivePropsCleanupMap(element);
|
|
52
|
-
const keyedMap = keyedElements.get(element);
|
|
53
|
-
return {
|
|
54
|
-
attributes: bindingsOnly ? [] : Array.from(element.attributes, (attribute) => [attribute.name, attribute.value]),
|
|
55
|
-
childNodes: bindingsOnly ? [] : Array.from(element.childNodes),
|
|
56
|
-
delegatedListeners: delegatedHandlerMap ? Array.from(delegatedHandlerMap, ([eventName, entry]) => ({
|
|
57
|
-
eventName,
|
|
58
|
-
handler: entry.handler,
|
|
59
|
-
original: entry.original,
|
|
60
|
-
options: entry.options
|
|
61
|
-
})) : [],
|
|
62
|
-
domCaptured: !bindingsOnly,
|
|
63
|
-
formControl: bindingsOnly ? null : getFormControlSnapshot(element),
|
|
64
|
-
keyedMap: keyedMap ? new Map(keyedMap) : void 0,
|
|
65
|
-
listeners: listenerMap ? Array.from(listenerMap, ([listenerKey, entry]) => ({
|
|
66
|
-
listenerKey,
|
|
67
|
-
entry: cloneListenerEntry(entry)
|
|
68
|
-
})) : [],
|
|
69
|
-
reactiveProps: reactivePropMap ? Array.from(reactivePropMap, ([propName, entry]) => ({
|
|
70
|
-
propName,
|
|
71
|
-
entry: cloneReactivePropEntry(entry)
|
|
72
|
-
})) : [],
|
|
73
|
-
ref: elementRefs.get(element),
|
|
74
|
-
textNodes: bindingsOnly ? [] : collectTextSnapshots(element)
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function sameChildOrder(element, childNodes) {
|
|
78
|
-
if (element.childNodes.length !== childNodes.length) return false;
|
|
79
|
-
for (let index = 0; index < childNodes.length; index += 1) if (element.childNodes[index] !== childNodes[index]) return false;
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
function restoreAttributes(element, snapshot) {
|
|
83
|
-
const expectedNames = new Set(snapshot.attributes.map(([name]) => name));
|
|
84
|
-
for (const attribute of Array.from(element.attributes)) if (!expectedNames.has(attribute.name)) element.removeAttribute(attribute.name);
|
|
85
|
-
for (const [name, value] of snapshot.attributes) if (element.getAttribute(name) !== value) element.setAttribute(name, value);
|
|
86
|
-
}
|
|
87
|
-
function restoreFormControl(element, snapshot) {
|
|
88
|
-
if (!snapshot.formControl) return;
|
|
89
|
-
const { value, checked } = snapshot.formControl;
|
|
90
|
-
const control = element;
|
|
91
|
-
if (value !== void 0 && "value" in control) control.value = value;
|
|
92
|
-
if (checked !== void 0 && "checked" in control) control.checked = checked;
|
|
93
|
-
}
|
|
94
|
-
function applyRefValue(ref, value) {
|
|
95
|
-
if (!ref) return;
|
|
96
|
-
try {
|
|
97
|
-
if (typeof ref === "function") {
|
|
98
|
-
ref(value);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (Object.isExtensible(ref)) ref.current = value;
|
|
102
|
-
} catch {}
|
|
103
|
-
}
|
|
104
|
-
function restoreRef(element, snapshot) {
|
|
105
|
-
const currentRef = elementRefs.get(element);
|
|
106
|
-
if (currentRef !== snapshot.ref) applyRefValue(currentRef, null);
|
|
107
|
-
if (snapshot.ref) {
|
|
108
|
-
applyRefValue(snapshot.ref, element);
|
|
109
|
-
elementRefs.set(element, snapshot.ref);
|
|
110
|
-
} else elementRefs.delete(element);
|
|
111
|
-
}
|
|
112
|
-
function removeDirectListener(element, entry) {
|
|
113
|
-
if (entry.isDelegated) return;
|
|
114
|
-
if (entry.options !== void 0) element.removeEventListener(entry.eventName, entry.handler, entry.options);
|
|
115
|
-
else element.removeEventListener(entry.eventName, entry.handler);
|
|
116
|
-
}
|
|
117
|
-
function addDirectListener(element, entry) {
|
|
118
|
-
if (entry.isDelegated) return;
|
|
119
|
-
if (entry.options !== void 0) element.addEventListener(entry.eventName, entry.handler, entry.options);
|
|
120
|
-
else element.addEventListener(entry.eventName, entry.handler);
|
|
121
|
-
}
|
|
122
|
-
function restoreListeners(element, snapshot) {
|
|
123
|
-
const errors = [];
|
|
124
|
-
const expectedKeys = new Set(snapshot.listeners.map(({ listenerKey }) => listenerKey));
|
|
125
|
-
let currentMap = elementListeners.get(element);
|
|
126
|
-
if (currentMap) {
|
|
127
|
-
for (const [listenerKey, entry] of Array.from(currentMap)) if (!expectedKeys.has(listenerKey)) {
|
|
128
|
-
try {
|
|
129
|
-
removeDirectListener(element, entry);
|
|
130
|
-
} catch (error) {
|
|
131
|
-
errors.push(error);
|
|
132
|
-
}
|
|
133
|
-
currentMap.delete(listenerKey);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (snapshot.listeners.length === 0) {
|
|
137
|
-
if (currentMap?.size === 0) elementListeners.delete(element);
|
|
138
|
-
} else {
|
|
139
|
-
if (!currentMap) {
|
|
140
|
-
currentMap = /* @__PURE__ */ new Map();
|
|
141
|
-
elementListeners.set(element, currentMap);
|
|
142
|
-
}
|
|
143
|
-
for (const { listenerKey, entry } of snapshot.listeners) {
|
|
144
|
-
const currentEntry = currentMap.get(listenerKey);
|
|
145
|
-
entry.updateHandler?.(entry.original);
|
|
146
|
-
if (currentEntry && currentEntry.handler !== entry.handler) try {
|
|
147
|
-
removeDirectListener(element, currentEntry);
|
|
148
|
-
} catch (error) {
|
|
149
|
-
errors.push(error);
|
|
150
|
-
}
|
|
151
|
-
if (!currentEntry || currentEntry.handler !== entry.handler) try {
|
|
152
|
-
addDirectListener(element, entry);
|
|
153
|
-
} catch (error) {
|
|
154
|
-
errors.push(error);
|
|
155
|
-
}
|
|
156
|
-
else currentEntry.updateHandler?.(entry.original);
|
|
157
|
-
currentMap.set(listenerKey, cloneListenerEntry(entry));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (errors.length > 0) throw new AggregateError(errors, "Listener rollback failed");
|
|
161
|
-
}
|
|
162
|
-
function restoreDelegatedListeners(element, snapshot) {
|
|
163
|
-
const errors = [];
|
|
164
|
-
const expectedEventNames = new Set(snapshot.delegatedListeners.map(({ eventName }) => eventName));
|
|
165
|
-
const currentMap = getDelegatedHandlersForElement(element);
|
|
166
|
-
if (currentMap) {
|
|
167
|
-
for (const eventName of currentMap.keys()) if (!expectedEventNames.has(eventName)) try {
|
|
168
|
-
removeDelegatedListener(element, eventName);
|
|
169
|
-
} catch (error) {
|
|
170
|
-
errors.push(error);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
for (const { eventName, handler, original, options } of snapshot.delegatedListeners) try {
|
|
174
|
-
if (!updateDelegatedListener(element, eventName, handler, original, options)) addDelegatedListener(element, eventName, handler, original, options);
|
|
175
|
-
} catch (error) {
|
|
176
|
-
errors.push(error);
|
|
177
|
-
}
|
|
178
|
-
if (errors.length > 0) throw new AggregateError(errors, "Delegated listener rollback failed");
|
|
179
|
-
}
|
|
180
|
-
function restoreReactiveProps(element, snapshot) {
|
|
181
|
-
const errors = [];
|
|
182
|
-
const expectedPropNames = new Set(snapshot.reactiveProps.map(({ propName }) => propName));
|
|
183
|
-
let currentMap = getElementReactivePropsCleanupMap(element);
|
|
184
|
-
if (currentMap) {
|
|
185
|
-
for (const [propName, entry] of Array.from(currentMap)) if (!expectedPropNames.has(propName)) {
|
|
186
|
-
try {
|
|
187
|
-
entry.cleanup();
|
|
188
|
-
} catch (error) {
|
|
189
|
-
errors.push(error);
|
|
190
|
-
}
|
|
191
|
-
currentMap.delete(propName);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (snapshot.reactiveProps.length === 0) {
|
|
195
|
-
if (currentMap?.size === 0) elementReactivePropsCleanup.delete(element);
|
|
196
|
-
} else {
|
|
197
|
-
if (!currentMap) {
|
|
198
|
-
currentMap = /* @__PURE__ */ new Map();
|
|
199
|
-
elementReactivePropsCleanup.set(element, currentMap);
|
|
200
|
-
}
|
|
201
|
-
for (const { propName, entry } of snapshot.reactiveProps) {
|
|
202
|
-
const currentEntry = currentMap.get(propName);
|
|
203
|
-
if (currentEntry) {
|
|
204
|
-
currentEntry.updateFn?.(entry.fnRef);
|
|
205
|
-
currentEntry.fnRef = entry.fnRef;
|
|
206
|
-
currentMap.set(propName, currentEntry);
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
currentMap.set(propName, (() => {
|
|
210
|
-
try {
|
|
211
|
-
return entry.restoreFn?.(entry.fnRef) ?? cloneReactivePropEntry(entry);
|
|
212
|
-
} catch (error) {
|
|
213
|
-
errors.push(error);
|
|
214
|
-
return cloneReactivePropEntry(entry);
|
|
215
|
-
}
|
|
216
|
-
})());
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if (errors.length > 0) throw new AggregateError(errors, "Reactive property rollback failed");
|
|
220
|
-
}
|
|
221
|
-
function restoreChildNodes(element, snapshot, cleanupRangeNode) {
|
|
222
|
-
const errors = [];
|
|
223
|
-
const expectedChildren = new Set(snapshot.childNodes);
|
|
224
|
-
for (const child of Array.from(element.childNodes)) if (!expectedChildren.has(child)) try {
|
|
225
|
-
cleanupRangeNode(child);
|
|
226
|
-
} catch (error) {
|
|
227
|
-
errors.push(error);
|
|
228
|
-
}
|
|
229
|
-
if (!sameChildOrder(element, snapshot.childNodes)) element.replaceChildren(...snapshot.childNodes);
|
|
230
|
-
if (errors.length > 0) throw new AggregateError(errors, "DOM range rollback cleanup failed");
|
|
231
|
-
}
|
|
232
|
-
function restoreTextNodes(snapshot) {
|
|
233
|
-
for (const { node, data } of snapshot.textNodes) if (node.data !== data) node.data = data;
|
|
234
|
-
}
|
|
235
|
-
function restoreKeyedMap(element, snapshot) {
|
|
236
|
-
if (snapshot.keyedMap) keyedElements.set(element, new Map(snapshot.keyedMap));
|
|
237
|
-
else keyedElements.delete(element);
|
|
238
|
-
}
|
|
239
|
-
function restoreRetainedElement(element, snapshot, cleanupRangeNode) {
|
|
240
|
-
const errors = [];
|
|
241
|
-
const phases = [
|
|
242
|
-
...snapshot.domCaptured ? [
|
|
243
|
-
() => restoreChildNodes(element, snapshot, cleanupRangeNode),
|
|
244
|
-
() => restoreTextNodes(snapshot),
|
|
245
|
-
() => restoreFormControl(element, snapshot),
|
|
246
|
-
() => restoreAttributes(element, snapshot)
|
|
247
|
-
] : [],
|
|
248
|
-
() => restoreReactiveProps(element, snapshot),
|
|
249
|
-
() => restoreRef(element, snapshot),
|
|
250
|
-
() => restoreListeners(element, snapshot),
|
|
251
|
-
() => restoreDelegatedListeners(element, snapshot),
|
|
252
|
-
...snapshot.domCaptured ? [() => restoreKeyedMap(element, snapshot)] : []
|
|
253
|
-
];
|
|
254
|
-
for (const phase of phases) try {
|
|
255
|
-
phase();
|
|
256
|
-
} catch (error) {
|
|
257
|
-
errors.push(error);
|
|
258
|
-
}
|
|
259
|
-
if (errors.length > 0) throw new AggregateError(errors, "Retained element rollback failed");
|
|
260
|
-
}
|
|
261
|
-
function runRetainedElementUpdate(element, cleanupRangeNode, update, onError, bindingsOnly = false) {
|
|
262
|
-
const batch = getCurrentLifecycleCommitBatch();
|
|
263
|
-
const existingSnapshot = batch?.retainedElementSnapshots.get(element);
|
|
264
|
-
const snapshot = existingSnapshot ?? snapshotRetainedElement(element, bindingsOnly);
|
|
265
|
-
let restored = false;
|
|
266
|
-
if (batch && !existingSnapshot) {
|
|
267
|
-
batch.retainedElementSnapshots.set(element, snapshot);
|
|
268
|
-
registerLifecycleTransaction(element, () => void 0, () => {
|
|
269
|
-
if (restored) return;
|
|
270
|
-
restored = true;
|
|
271
|
-
restoreRetainedElement(element, snapshot, cleanupRangeNode);
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
try {
|
|
275
|
-
update();
|
|
276
|
-
} catch (err) {
|
|
277
|
-
onError?.();
|
|
278
|
-
try {
|
|
279
|
-
restored = true;
|
|
280
|
-
restoreRetainedElement(element, snapshot, cleanupRangeNode);
|
|
281
|
-
} catch (rollbackError) {
|
|
282
|
-
logger.warn("[Askr] retained element rollback failed:", new AggregateError([err, rollbackError], "Render failed and retained rollback reported errors"));
|
|
283
|
-
}
|
|
284
|
-
throw err;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
//#endregion
|
|
288
|
-
export { restoreRetainedElement, runRetainedElementUpdate, snapshotRetainedElement };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { getCurrentContextFrame, getVNodeContextFrame, withContext } from "../runtime/context.js";
|
|
4
|
-
import { incDevCounter } from "../runtime/dev-namespace.js";
|
|
5
|
-
import { getCurrentInstance } from "../runtime/component-scope.js";
|
|
6
|
-
import { isPromiseLike } from "../common/promise.js";
|
|
7
|
-
import { captureInlineRenderSnapshot, renderComponentInline, warnUnusedStateReads } from "../runtime/component-internal.js";
|
|
8
|
-
import { recordBenchEvent } from "../runtime/for-bench.js";
|
|
9
|
-
import "../runtime/index.js";
|
|
10
|
-
import { tagNamesEqualIgnoreCase } from "./utils.js";
|
|
11
|
-
import { getRendererDOMHost } from "./dom-host.js";
|
|
12
|
-
import { findHostInstanceByType, inheritComponentCleanupStrict, inheritComponentKey, isRouteRootComponentVNode } from "./component-host-instances.js";
|
|
13
|
-
import { resolveNestedComponentResult } from "./component-host-results.js";
|
|
14
|
-
import "./component-host.js";
|
|
15
|
-
//#region src/renderer/stable-patch.ts
|
|
16
|
-
function normalizeStableIntrinsicChildren(children) {
|
|
17
|
-
if (children === null || children === void 0 || children === false) return [];
|
|
18
|
-
return Array.isArray(children) ? children : [children];
|
|
19
|
-
}
|
|
20
|
-
function getStableIntrinsicChildren(vnode) {
|
|
21
|
-
return normalizeStableIntrinsicChildren(vnode.props?.children ?? vnode.children);
|
|
22
|
-
}
|
|
23
|
-
function patchStableIntrinsicText(domNode, nextVNode) {
|
|
24
|
-
if (domNode.nodeType !== 3 || typeof nextVNode !== "string" && typeof nextVNode !== "number") return false;
|
|
25
|
-
const nextText = String(nextVNode);
|
|
26
|
-
const textNode = domNode;
|
|
27
|
-
if (textNode.data !== nextText) {
|
|
28
|
-
recordBenchEvent("domTextSet");
|
|
29
|
-
textNode.data = nextText;
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
function patchStableIntrinsicElement(dom, nextVNode) {
|
|
34
|
-
if (typeof nextVNode.type !== "string" || !tagNamesEqualIgnoreCase(dom.tagName, nextVNode.type)) return false;
|
|
35
|
-
getRendererDOMHost().updateElementFromVnode(dom, nextVNode, false);
|
|
36
|
-
const nextChildren = getStableIntrinsicChildren(nextVNode);
|
|
37
|
-
if (dom.childNodes.length !== nextChildren.length) return false;
|
|
38
|
-
for (let index = 0; index < nextChildren.length; index += 1) {
|
|
39
|
-
const nextChild = nextChildren[index];
|
|
40
|
-
const currentChildNode = dom.childNodes[index];
|
|
41
|
-
if (!currentChildNode) return false;
|
|
42
|
-
if (patchStableIntrinsicText(currentChildNode, nextChild)) continue;
|
|
43
|
-
if (currentChildNode instanceof Element && _isDOMElement(nextChild) && typeof nextChild.type === "string" && patchStableIntrinsicElement(currentChildNode, nextChild)) continue;
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
function resolveStableIntrinsicPatchVNode(dom, vnode) {
|
|
49
|
-
if (!_isDOMElement(vnode)) return null;
|
|
50
|
-
if (typeof vnode.type === "string") return tagNamesEqualIgnoreCase(dom.tagName, vnode.type) ? vnode : null;
|
|
51
|
-
if (typeof vnode.type !== "function") return null;
|
|
52
|
-
const host = dom;
|
|
53
|
-
const existingInstance = findHostInstanceByType(host, vnode.type, vnode, getCurrentInstance());
|
|
54
|
-
if (!existingInstance || existingInstance.fn !== vnode.type || host.__ASKR_WRAPPER_HOST) return null;
|
|
55
|
-
const snapshot = getVNodeContextFrame(vnode) || getCurrentContextFrame() || existingInstance.ownerFrame || null;
|
|
56
|
-
captureInlineRenderSnapshot(existingInstance);
|
|
57
|
-
existingInstance.props = (vnode.props ?? {}) || {};
|
|
58
|
-
existingInstance.isRoot = isRouteRootComponentVNode(vnode);
|
|
59
|
-
existingInstance.portalScope = getCurrentInstance()?.portalScope ?? existingInstance.portalScope;
|
|
60
|
-
inheritComponentCleanupStrict(existingInstance);
|
|
61
|
-
if (snapshot) existingInstance.ownerFrame = snapshot;
|
|
62
|
-
const result = withContext(snapshot, () => renderComponentInline(existingInstance));
|
|
63
|
-
if (isPromiseLike(result)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
64
|
-
const resolvedResult = resolveNestedComponentResult(result, snapshot ?? null, existingInstance);
|
|
65
|
-
if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(dom.tagName, resolvedResult.type)) return inheritComponentKey(resolvedResult, vnode);
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
function tryPatchStableForDirtyItem(scope) {
|
|
69
|
-
incDevCounter("stableForPatchAttempt");
|
|
70
|
-
if (!(scope.dom instanceof Element) || scope.vnode === void 0) return false;
|
|
71
|
-
const nextIntrinsic = resolveStableIntrinsicPatchVNode(scope.dom, scope.vnode);
|
|
72
|
-
if (!nextIntrinsic) return false;
|
|
73
|
-
const didPatch = patchStableIntrinsicElement(scope.dom, nextIntrinsic);
|
|
74
|
-
const existingInstance = scope.dom.__ASKR_INSTANCE;
|
|
75
|
-
if (didPatch && existingInstance) warnUnusedStateReads(existingInstance);
|
|
76
|
-
if (didPatch) incDevCounter("stableForPatchHit");
|
|
77
|
-
return didPatch;
|
|
78
|
-
}
|
|
79
|
-
//#endregion
|
|
80
|
-
export { tryPatchStableForDirtyItem };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { Fragment } from "../common/jsx.js";
|
|
4
|
-
import { tagNamesEqualIgnoreCase } from "./utils.js";
|
|
5
|
-
import "../jsx-runtime.js";
|
|
6
|
-
import { hasMatchingStaticProps } from "./attributes.js";
|
|
7
|
-
//#region src/renderer/static-reuse.ts
|
|
8
|
-
/**
|
|
9
|
-
* Static subtree reuse checks for intrinsic DOM children.
|
|
10
|
-
*/
|
|
11
|
-
function isFragmentVNode(node) {
|
|
12
|
-
return _isDOMElement(node) && typeof node.type === "symbol" && (node.type === Fragment || String(node.type) === "Symbol(askr.fragment)");
|
|
13
|
-
}
|
|
14
|
-
function upperCommonTagName(tag) {
|
|
15
|
-
switch (tag) {
|
|
16
|
-
case "div": return "DIV";
|
|
17
|
-
case "span": return "SPAN";
|
|
18
|
-
case "p": return "P";
|
|
19
|
-
case "a": return "A";
|
|
20
|
-
case "button": return "BUTTON";
|
|
21
|
-
case "input": return "INPUT";
|
|
22
|
-
case "ul": return "UL";
|
|
23
|
-
case "ol": return "OL";
|
|
24
|
-
case "li": return "LI";
|
|
25
|
-
default: return null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function tagsEqualIgnoreCase(elementTagName, vnodeType) {
|
|
29
|
-
const upperCommon = upperCommonTagName(vnodeType);
|
|
30
|
-
if (upperCommon !== null && elementTagName === upperCommon) return true;
|
|
31
|
-
return tagNamesEqualIgnoreCase(elementTagName, vnodeType);
|
|
32
|
-
}
|
|
33
|
-
const STATIC_CHILD_SLOTS_CACHE = Symbol.for("__askrStaticChildSlots");
|
|
34
|
-
let staticChildSlotsCacheEnabled = true;
|
|
35
|
-
function setStaticChildSlotsCacheEnabled(enabled) {
|
|
36
|
-
staticChildSlotsCacheEnabled = enabled;
|
|
37
|
-
}
|
|
38
|
-
function collectStaticChildSlots(children, slots) {
|
|
39
|
-
if (isFragmentVNode(children)) return collectStaticChildSlots(children.props?.children ?? children.children, slots);
|
|
40
|
-
if (Array.isArray(children)) {
|
|
41
|
-
for (const child of children) if (!collectStaticChildSlots(child, slots)) return false;
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
if (children === null || children === void 0 || children === false) return true;
|
|
45
|
-
if (typeof children === "string" || typeof children === "number") {
|
|
46
|
-
slots.push({
|
|
47
|
-
kind: "text",
|
|
48
|
-
value: String(children)
|
|
49
|
-
});
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
if (_isDOMElement(children) && typeof children.type === "string") {
|
|
53
|
-
slots.push({
|
|
54
|
-
kind: "element",
|
|
55
|
-
value: children
|
|
56
|
-
});
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
function getStaticChildSlots(vnode) {
|
|
62
|
-
if (staticChildSlotsCacheEnabled) {
|
|
63
|
-
const cached = vnode[STATIC_CHILD_SLOTS_CACHE];
|
|
64
|
-
if (cached !== void 0) return cached;
|
|
65
|
-
}
|
|
66
|
-
const slots = [];
|
|
67
|
-
const staticSlots = collectStaticChildSlots(vnode.props?.children ?? vnode.children, slots) ? slots : null;
|
|
68
|
-
if (staticChildSlotsCacheEnabled) {
|
|
69
|
-
const cacheNode = vnode;
|
|
70
|
-
if (Object.isExtensible(vnode)) cacheNode[STATIC_CHILD_SLOTS_CACHE] = staticSlots;
|
|
71
|
-
}
|
|
72
|
-
return staticSlots;
|
|
73
|
-
}
|
|
74
|
-
function canReuseStaticSubtree(el, vnode) {
|
|
75
|
-
if (typeof vnode.type !== "string" || !tagsEqualIgnoreCase(el.tagName, vnode.type)) return false;
|
|
76
|
-
if (!hasMatchingStaticProps(el, vnode.props || {}, vnode.type)) return false;
|
|
77
|
-
const slots = getStaticChildSlots(vnode);
|
|
78
|
-
if (!slots) return false;
|
|
79
|
-
if (el.childNodes.length !== slots.length) return false;
|
|
80
|
-
for (let index = 0; index < slots.length; index += 1) {
|
|
81
|
-
const slot = slots[index];
|
|
82
|
-
const current = el.childNodes[index];
|
|
83
|
-
if (!current) return false;
|
|
84
|
-
if (slot.kind === "text") {
|
|
85
|
-
if (current.nodeType !== 3 || current.data !== slot.value) return false;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (!(current instanceof Element)) return false;
|
|
89
|
-
if (!canReuseStaticSubtree(current, slot.value)) return false;
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
|
-
export { canReuseStaticSubtree, setStaticChildSlotsCacheEnabled, tagsEqualIgnoreCase };
|
package/dist/renderer/types.js
DELETED