@askrjs/askr 0.0.52 → 0.0.54
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-2ZR3MtO0.js +647 -0
- package/dist/cleanup-DScKZG2i.js +487 -0
- package/dist/component-internal-D9PLuFUc.js +614 -0
- package/dist/component-lifecycle-C7lnU9Bt.js +359 -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-BI4RMD2z.d.ts +437 -0
- package/dist/control-Bf4Wkdvv.d.ts +9 -0
- package/dist/{common/control.js → control-DhFRTIoE.js} +1 -1
- package/dist/control-mXROCjL3.js +165 -0
- package/dist/data/index.d.ts +2 -6
- package/dist/data/index.js +4 -5
- package/dist/data-B9dauyDn.js +559 -0
- package/dist/{data/data-runtime.js → data-runtime-SJ1BSUvk.js} +32 -31
- package/dist/deferred-DklLG4qM.js +386 -0
- package/dist/{runtime/effect.js → effect-BwnIvLah.js} +4 -4
- package/dist/fastlane-Dw8SOBr9.js +343 -0
- package/dist/for-internal-CSz8Unkq.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-B1LNotpU.d.ts +239 -0
- package/dist/index-Bki2rqcr.d.ts +233 -0
- package/dist/index-BnU0NPwM.d.ts +101 -0
- package/dist/index-C8iW3xCt.d.ts +44 -0
- package/dist/index-DwxdIA-t.d.ts +48 -0
- package/dist/{runtime/runtime.d.ts → index-Zb31mCiU.d.ts} +31 -8
- 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-CdRjdsHo.js} +4 -5
- package/dist/navigate-BVDCzOuB.d.ts +34 -0
- package/dist/navigate-D17eVQyI.js +1449 -0
- package/dist/{runtime/portal.js → portal-C47xkwXj.js} +71 -41
- package/dist/query-registry-CQIT4mXr.js +73 -0
- package/dist/{common/render-context.js → render-context-Clw3rFiO.js} +14 -6
- package/dist/renderer-DrLRAD5y.js +6266 -0
- package/dist/{runtime/resource-operation.js → resource-operation-BNY29MVH.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-DCfwLBr-.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-DEARZxJ5.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-BWwu-mWu.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,105 +0,0 @@
|
|
|
1
|
-
import { cleanupComponent } from "../runtime/component-cleanup.js";
|
|
2
|
-
import { registerLifecycleRollback, registerLifecycleTransaction } from "../runtime/lifecycle-batch.js";
|
|
3
|
-
import "../runtime/index.js";
|
|
4
|
-
import { elementRefs, removeElementRef, updateElementRef } from "./cleanup.js";
|
|
5
|
-
import { cleanupDetachedComponentHost } from "./component-host-cleanup.js";
|
|
6
|
-
import { restoreVNodeComponentInstance } from "./component-host-instances.js";
|
|
7
|
-
//#region src/renderer/component-host-replacement.ts
|
|
8
|
-
function cleanupProvisionalComponentInstance(instance) {
|
|
9
|
-
try {
|
|
10
|
-
cleanupComponent(instance);
|
|
11
|
-
} catch {}
|
|
12
|
-
}
|
|
13
|
-
function cleanupProvisionalComponentInstances(instances) {
|
|
14
|
-
for (let index = instances.length - 1; index >= 0; index -= 1) cleanupProvisionalComponentInstance(instances[index]);
|
|
15
|
-
}
|
|
16
|
-
function createRetainedHostInstanceSet(owner, additional) {
|
|
17
|
-
const retained = /* @__PURE__ */ new Set([owner]);
|
|
18
|
-
for (const instance of additional ?? []) retained.add(instance);
|
|
19
|
-
return retained;
|
|
20
|
-
}
|
|
21
|
-
function cleanupReplacementNode(node, retainedInstance) {
|
|
22
|
-
if (node instanceof Element) {
|
|
23
|
-
cleanupDetachedComponentHost(node, retainedInstance);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
delete node.__ASKR_INSTANCE;
|
|
28
|
-
} catch {}
|
|
29
|
-
}
|
|
30
|
-
function beginComponentHostReplacement(existingHost, retainedInstance, previousTarget, retainedInstances = [retainedInstance], disposeOnRollback = false) {
|
|
31
|
-
const parent = existingHost.parentNode;
|
|
32
|
-
const previousRef = elementRefs.get(existingHost);
|
|
33
|
-
let previousRefDetached = false;
|
|
34
|
-
let nextDom = null;
|
|
35
|
-
let didReplace = false;
|
|
36
|
-
let replacementAttempted = false;
|
|
37
|
-
let finished = false;
|
|
38
|
-
const commit = () => {
|
|
39
|
-
if (finished) return;
|
|
40
|
-
finished = true;
|
|
41
|
-
if (replacementAttempted && didReplace) cleanupDetachedComponentHost(existingHost, retainedInstances);
|
|
42
|
-
};
|
|
43
|
-
const rollback = () => {
|
|
44
|
-
if (finished) return;
|
|
45
|
-
finished = true;
|
|
46
|
-
if (!replacementAttempted) return;
|
|
47
|
-
const rollbackErrors = [];
|
|
48
|
-
if (nextDom && nextDom !== existingHost) try {
|
|
49
|
-
cleanupReplacementNode(nextDom, retainedInstance);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
rollbackErrors.push(error);
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
if (disposeOnRollback) cleanupComponent(retainedInstance);
|
|
55
|
-
else retainedInstance.target = previousTarget;
|
|
56
|
-
} catch (error) {
|
|
57
|
-
rollbackErrors.push(error);
|
|
58
|
-
}
|
|
59
|
-
if (previousRefDetached && previousRef) try {
|
|
60
|
-
updateElementRef(existingHost, previousRef);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
rollbackErrors.push(error);
|
|
63
|
-
}
|
|
64
|
-
if (rollbackErrors.length > 0) throw new AggregateError(rollbackErrors, "Component host replacement rollback failed");
|
|
65
|
-
};
|
|
66
|
-
const staged = registerLifecycleTransaction({}, commit, rollback);
|
|
67
|
-
const replace = (materialize, prepareNextDom) => {
|
|
68
|
-
replacementAttempted = true;
|
|
69
|
-
if (!staged && previousRef) {
|
|
70
|
-
removeElementRef(existingHost);
|
|
71
|
-
previousRefDetached = true;
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
nextDom = materialize();
|
|
75
|
-
prepareNextDom(nextDom);
|
|
76
|
-
if (parent && nextDom !== existingHost) {
|
|
77
|
-
parent.replaceChild(nextDom, existingHost);
|
|
78
|
-
didReplace = true;
|
|
79
|
-
}
|
|
80
|
-
} catch (error) {
|
|
81
|
-
if (!staged) try {
|
|
82
|
-
rollback();
|
|
83
|
-
} catch {}
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
if (!staged) commit();
|
|
87
|
-
return nextDom;
|
|
88
|
-
};
|
|
89
|
-
return { replace };
|
|
90
|
-
}
|
|
91
|
-
function registerVNodeComponentInstanceRollback(node, previousInstance, provisionalInstance) {
|
|
92
|
-
let restored = false;
|
|
93
|
-
const restoreOwnership = () => {
|
|
94
|
-
if (restored) return;
|
|
95
|
-
restored = true;
|
|
96
|
-
restoreVNodeComponentInstance(node, previousInstance);
|
|
97
|
-
};
|
|
98
|
-
(provisionalInstance.cleanupFns ??= []).push(restoreOwnership);
|
|
99
|
-
registerLifecycleRollback(() => {
|
|
100
|
-
restoreOwnership();
|
|
101
|
-
cleanupProvisionalComponentInstance(provisionalInstance);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
//#endregion
|
|
105
|
-
export { beginComponentHostReplacement, cleanupProvisionalComponentInstance, cleanupProvisionalComponentInstances, createRetainedHostInstanceSet, registerVNodeComponentInstanceRollback };
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { getVNodeContextFrame, markVNodeTreeWithContextFrame, withContext } from "../runtime/context.js";
|
|
4
|
-
import { getCurrentInstance } from "../runtime/component-scope.js";
|
|
5
|
-
import { cleanupComponent } from "../runtime/component-cleanup.js";
|
|
6
|
-
import { isPromiseLike } from "../common/promise.js";
|
|
7
|
-
import { captureInlineRenderSnapshot, createComponentInstance, mountInstanceInline, renderComponentInline, warnUnusedStateReads } from "../runtime/component-internal.js";
|
|
8
|
-
import "../runtime/index.js";
|
|
9
|
-
import { getRendererDOMHost } from "./dom-host.js";
|
|
10
|
-
import { findHostInstanceByType, getVNodeComponentInstance, inheritComponentCleanupStrict, isRouteRootComponentVNode, nextComponentInstanceId, restoreVNodeComponentInstance, setComponentOwnershipIdentity, setVNodeComponentInstance } from "./component-host-instances.js";
|
|
11
|
-
import { cleanupProvisionalComponentInstance, cleanupProvisionalComponentInstances, registerVNodeComponentInstanceRollback } from "./component-host-replacement.js";
|
|
12
|
-
//#region src/renderer/component-host-results.ts
|
|
13
|
-
function materializeComponentResultNode(childInstance, result, parentNamespace) {
|
|
14
|
-
const dom = getRendererDOMHost().createComponentResultNode(childInstance.fn, result, parentNamespace);
|
|
15
|
-
if (dom instanceof Element) {
|
|
16
|
-
mountInstanceInline(childInstance, dom);
|
|
17
|
-
return dom;
|
|
18
|
-
}
|
|
19
|
-
if (!dom) {
|
|
20
|
-
const placeholder = document.createComment("");
|
|
21
|
-
try {
|
|
22
|
-
placeholder.__ASKR_INSTANCE = childInstance;
|
|
23
|
-
} catch {}
|
|
24
|
-
childInstance._placeholder = placeholder;
|
|
25
|
-
mountInstanceInline(childInstance, null);
|
|
26
|
-
return placeholder;
|
|
27
|
-
}
|
|
28
|
-
const host = document.createElement("div");
|
|
29
|
-
host.appendChild(dom);
|
|
30
|
-
host.__ASKR_WRAPPER_HOST = true;
|
|
31
|
-
mountInstanceInline(childInstance, host);
|
|
32
|
-
return host;
|
|
33
|
-
}
|
|
34
|
-
function resolveNestedComponentResult(result, snapshot, parentInstance) {
|
|
35
|
-
let currentResult = result;
|
|
36
|
-
let activeSnapshot = snapshot;
|
|
37
|
-
let depth = 0;
|
|
38
|
-
while (_isDOMElement(currentResult) && typeof currentResult.type === "function" && depth < 16) {
|
|
39
|
-
const nestedSnapshot = getVNodeContextFrame(currentResult) ?? activeSnapshot;
|
|
40
|
-
const nestedInstance = createComponentInstance(nextComponentInstanceId(), currentResult.type, currentResult.props ?? {}, null);
|
|
41
|
-
nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
|
|
42
|
-
nestedInstance.parentInstance = parentInstance;
|
|
43
|
-
nestedInstance.portalScope = parentInstance?.portalScope ?? nestedInstance.portalScope;
|
|
44
|
-
inheritComponentCleanupStrict(nestedInstance);
|
|
45
|
-
if (nestedSnapshot) nestedInstance.ownerFrame = nestedSnapshot;
|
|
46
|
-
let nextResult;
|
|
47
|
-
try {
|
|
48
|
-
nextResult = withContext(nestedSnapshot ?? null, () => renderComponentInline(nestedInstance));
|
|
49
|
-
if (isPromiseLike(nextResult)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
50
|
-
} catch (error) {
|
|
51
|
-
cleanupProvisionalComponentInstance(nestedInstance);
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
54
|
-
cleanupComponent(nestedInstance);
|
|
55
|
-
activeSnapshot = nestedSnapshot ?? null;
|
|
56
|
-
currentResult = nextResult;
|
|
57
|
-
depth += 1;
|
|
58
|
-
}
|
|
59
|
-
return currentResult;
|
|
60
|
-
}
|
|
61
|
-
function resolveHostNestedComponentResult(host, retainedInstance, result, snapshot, retainedInstances) {
|
|
62
|
-
let currentResult = result;
|
|
63
|
-
let activeSnapshot = snapshot;
|
|
64
|
-
let depth = 0;
|
|
65
|
-
const createdInstances = [];
|
|
66
|
-
const createdVNodeOwners = [];
|
|
67
|
-
try {
|
|
68
|
-
while (_isDOMElement(currentResult) && typeof currentResult.type === "function" && depth < 16) {
|
|
69
|
-
const nestedVNode = currentResult;
|
|
70
|
-
const nestedSnapshot = getVNodeContextFrame(currentResult) ?? activeSnapshot;
|
|
71
|
-
let nestedInstance = findHostInstanceByType(host, currentResult.type, nestedVNode, retainedInstance, depth);
|
|
72
|
-
const hadNestedInstance = !!nestedInstance;
|
|
73
|
-
if (!nestedInstance) {
|
|
74
|
-
nestedInstance = createComponentInstance(nextComponentInstanceId(), currentResult.type, nestedVNode.props ?? {}, null);
|
|
75
|
-
createdInstances.push(nestedInstance);
|
|
76
|
-
const previous = getVNodeComponentInstance(nestedVNode);
|
|
77
|
-
createdVNodeOwners.push({
|
|
78
|
-
node: nestedVNode,
|
|
79
|
-
previous
|
|
80
|
-
});
|
|
81
|
-
registerVNodeComponentInstanceRollback(nestedVNode, previous, nestedInstance);
|
|
82
|
-
}
|
|
83
|
-
setComponentOwnershipIdentity(nestedInstance, nestedVNode, retainedInstance, depth);
|
|
84
|
-
if (hadNestedInstance) captureInlineRenderSnapshot(nestedInstance);
|
|
85
|
-
setVNodeComponentInstance(currentResult, nestedInstance);
|
|
86
|
-
nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
|
|
87
|
-
nestedInstance.parentInstance = retainedInstance;
|
|
88
|
-
nestedInstance.portalScope = retainedInstance.portalScope ?? nestedInstance.portalScope;
|
|
89
|
-
inheritComponentCleanupStrict(nestedInstance);
|
|
90
|
-
nestedInstance.props = (nestedVNode.props ?? {}) || {};
|
|
91
|
-
if (nestedSnapshot) nestedInstance.ownerFrame = nestedSnapshot;
|
|
92
|
-
const nextResult = withContext(nestedSnapshot ?? null, () => renderComponentInline(nestedInstance));
|
|
93
|
-
if (isPromiseLike(nextResult)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
94
|
-
retainedInstances.add(nestedInstance);
|
|
95
|
-
warnUnusedStateReads(nestedInstance);
|
|
96
|
-
activeSnapshot = nestedSnapshot ?? null;
|
|
97
|
-
currentResult = markVNodeTreeWithContextFrame(nextResult, activeSnapshot);
|
|
98
|
-
depth += 1;
|
|
99
|
-
}
|
|
100
|
-
for (const instance of createdInstances) mountInstanceInline(instance, host);
|
|
101
|
-
} catch (error) {
|
|
102
|
-
for (let index = createdVNodeOwners.length - 1; index >= 0; index -= 1) {
|
|
103
|
-
const owner = createdVNodeOwners[index];
|
|
104
|
-
restoreVNodeComponentInstance(owner.node, owner.previous);
|
|
105
|
-
}
|
|
106
|
-
cleanupProvisionalComponentInstances(createdInstances);
|
|
107
|
-
throw error;
|
|
108
|
-
}
|
|
109
|
-
return currentResult;
|
|
110
|
-
}
|
|
111
|
-
function resolveWrapperHostResult(host, result, snapshot, retainedInstances) {
|
|
112
|
-
let currentResult = result;
|
|
113
|
-
let activeSnapshot = snapshot;
|
|
114
|
-
let depth = 0;
|
|
115
|
-
while (_isDOMElement(currentResult) && typeof currentResult.type === "function" && depth < 16) {
|
|
116
|
-
const nestedSnapshot = getVNodeContextFrame(currentResult) ?? activeSnapshot;
|
|
117
|
-
const nestedInstance = findHostInstanceByType(host, currentResult.type, currentResult, getCurrentInstance(), depth);
|
|
118
|
-
if (!nestedInstance) break;
|
|
119
|
-
captureInlineRenderSnapshot(nestedInstance);
|
|
120
|
-
setComponentOwnershipIdentity(nestedInstance, currentResult, getCurrentInstance(), depth);
|
|
121
|
-
nestedInstance.props = (currentResult.props ?? {}) || {};
|
|
122
|
-
nestedInstance.parentInstance = getCurrentInstance();
|
|
123
|
-
nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
|
|
124
|
-
nestedInstance.portalScope = getCurrentInstance()?.portalScope ?? nestedInstance.portalScope;
|
|
125
|
-
inheritComponentCleanupStrict(nestedInstance);
|
|
126
|
-
if (nestedSnapshot) nestedInstance.ownerFrame = nestedSnapshot;
|
|
127
|
-
const nextResult = withContext(nestedSnapshot ?? null, () => renderComponentInline(nestedInstance));
|
|
128
|
-
if (isPromiseLike(nextResult)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
129
|
-
retainedInstances.add(nestedInstance);
|
|
130
|
-
warnUnusedStateReads(nestedInstance);
|
|
131
|
-
activeSnapshot = nestedSnapshot ?? null;
|
|
132
|
-
currentResult = nextResult;
|
|
133
|
-
depth += 1;
|
|
134
|
-
}
|
|
135
|
-
return markVNodeTreeWithContextFrame(currentResult, activeSnapshot);
|
|
136
|
-
}
|
|
137
|
-
//#endregion
|
|
138
|
-
export { materializeComponentResultNode, resolveHostNestedComponentResult, resolveNestedComponentResult, resolveWrapperHostResult };
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { _isDOMElement } from "../common/vnode.js";
|
|
2
|
-
import "./types.js";
|
|
3
|
-
import { getCurrentContextFrame, getVNodeContextFrame, markVNodeTreeWithContextFrame, withContext } from "../runtime/context.js";
|
|
4
|
-
import { getCurrentInstance } from "../runtime/component-scope.js";
|
|
5
|
-
import { isPromiseLike } from "../common/promise.js";
|
|
6
|
-
import { captureInlineRenderSnapshot, createComponentInstance, mountInstanceInline, renderComponentInline, warnUnusedStateReads } from "../runtime/component-internal.js";
|
|
7
|
-
import "../runtime/index.js";
|
|
8
|
-
import { tagNamesEqualIgnoreCase } from "./utils.js";
|
|
9
|
-
import { materializeFreshKey, materializeKey } from "./attributes.js";
|
|
10
|
-
import { getRendererDOMHost } from "./dom-host.js";
|
|
11
|
-
import { normalizeComponentChildren } from "./child-shape.js";
|
|
12
|
-
import { pruneComponentHostInstances } from "./component-host-cleanup.js";
|
|
13
|
-
import { findHostInstanceByType, getVNodeComponentInstance, inheritComponentCleanupStrict, inheritComponentKey, isRouteRootComponentVNode, nextComponentInstanceId, restoreVNodeComponentInstance, setComponentOwnershipIdentity, setVNodeComponentInstance } from "./component-host-instances.js";
|
|
14
|
-
import { beginComponentHostReplacement, cleanupProvisionalComponentInstance, createRetainedHostInstanceSet, registerVNodeComponentInstanceRollback } from "./component-host-replacement.js";
|
|
15
|
-
import { materializeComponentResultNode, resolveHostNestedComponentResult, resolveNestedComponentResult, resolveWrapperHostResult } from "./component-host-results.js";
|
|
16
|
-
//#region src/renderer/component-host.ts
|
|
17
|
-
function syncComponentElement(currentDom, node, type, props, parentNamespace, forceChildrenUpdate = false, retainedHostInstances) {
|
|
18
|
-
const existingHost = currentDom instanceof Element ? currentDom : null;
|
|
19
|
-
const existingInstance = existingHost ? findHostInstanceByType(existingHost, type, node, getCurrentInstance(), 0) : null;
|
|
20
|
-
if (!existingHost) return null;
|
|
21
|
-
const domHost = getRendererDOMHost();
|
|
22
|
-
if (!existingInstance || existingInstance.fn !== type) {
|
|
23
|
-
const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame() || null;
|
|
24
|
-
const hydrationInstance = createComponentInstance(nextComponentInstanceId(), type, props || {}, existingHost);
|
|
25
|
-
setComponentOwnershipIdentity(hydrationInstance, node, getCurrentInstance(), 0);
|
|
26
|
-
hydrationInstance.isRoot = isRouteRootComponentVNode(node);
|
|
27
|
-
hydrationInstance.portalScope = getCurrentInstance()?.portalScope ?? hydrationInstance.portalScope;
|
|
28
|
-
inheritComponentCleanupStrict(hydrationInstance);
|
|
29
|
-
const previousVNodeInstance = getVNodeComponentInstance(node);
|
|
30
|
-
const liveRetainedInstances = createRetainedHostInstanceSet(hydrationInstance, retainedHostInstances);
|
|
31
|
-
pruneComponentHostInstances(existingHost, liveRetainedInstances);
|
|
32
|
-
const replacement = beginComponentHostReplacement(existingHost, hydrationInstance, hydrationInstance.target, liveRetainedInstances, true);
|
|
33
|
-
try {
|
|
34
|
-
registerVNodeComponentInstanceRollback(node, previousVNodeInstance, hydrationInstance);
|
|
35
|
-
setVNodeComponentInstance(node, hydrationInstance);
|
|
36
|
-
if (snapshot) hydrationInstance.ownerFrame = snapshot;
|
|
37
|
-
const result = withContext(snapshot, () => renderComponentInline(hydrationInstance));
|
|
38
|
-
if (isPromiseLike(result)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
39
|
-
const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);
|
|
40
|
-
if (scopedResult && typeof scopedResult === "object" && "type" in scopedResult && typeof scopedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, scopedResult.type)) {
|
|
41
|
-
withContext(snapshot, () => {
|
|
42
|
-
domHost.updateElementFromVnode(existingHost, inheritComponentKey(scopedResult, node), true, forceChildrenUpdate || hydrationInstance.mounted === false);
|
|
43
|
-
materializeKey(existingHost, node, props);
|
|
44
|
-
});
|
|
45
|
-
mountInstanceInline(hydrationInstance, existingHost);
|
|
46
|
-
itemInstanceHydrationComplete(existingHost);
|
|
47
|
-
warnUnusedStateReads(hydrationInstance);
|
|
48
|
-
return existingHost;
|
|
49
|
-
}
|
|
50
|
-
const resolvedResult = resolveHostNestedComponentResult(existingHost, hydrationInstance, scopedResult, snapshot ?? null, liveRetainedInstances);
|
|
51
|
-
if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)) {
|
|
52
|
-
withContext(snapshot, () => {
|
|
53
|
-
domHost.updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || hydrationInstance.mounted === false);
|
|
54
|
-
materializeKey(existingHost, node, props);
|
|
55
|
-
});
|
|
56
|
-
mountInstanceInline(hydrationInstance, existingHost);
|
|
57
|
-
itemInstanceHydrationComplete(existingHost);
|
|
58
|
-
warnUnusedStateReads(hydrationInstance);
|
|
59
|
-
return existingHost;
|
|
60
|
-
}
|
|
61
|
-
const nextDom = replacement.replace(() => materializeComponentResultNode(hydrationInstance, scopedResult, parentNamespace), (replacement) => {
|
|
62
|
-
if (replacement instanceof Element) {
|
|
63
|
-
materializeKey(replacement, node, props);
|
|
64
|
-
retainReplacementOwnerChain(replacement, hydrationInstance, liveRetainedInstances);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
warnUnusedStateReads(hydrationInstance);
|
|
68
|
-
return nextDom;
|
|
69
|
-
} catch (error) {
|
|
70
|
-
restoreVNodeComponentInstance(node, previousVNodeInstance);
|
|
71
|
-
if (!hydrationInstance.mounted) cleanupProvisionalComponentInstance(hydrationInstance);
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame() || existingInstance.ownerFrame || null;
|
|
76
|
-
const liveRetainedInstances = createRetainedHostInstanceSet(existingInstance, retainedHostInstances);
|
|
77
|
-
pruneComponentHostInstances(existingHost, liveRetainedInstances);
|
|
78
|
-
const replacement = beginComponentHostReplacement(existingHost, existingInstance, existingInstance.target, liveRetainedInstances);
|
|
79
|
-
captureInlineRenderSnapshot(existingInstance);
|
|
80
|
-
existingInstance.props = props || {};
|
|
81
|
-
setComponentOwnershipIdentity(existingInstance, node, getCurrentInstance(), 0);
|
|
82
|
-
existingInstance.isRoot = isRouteRootComponentVNode(node);
|
|
83
|
-
existingInstance.portalScope = getCurrentInstance()?.portalScope ?? existingInstance.portalScope;
|
|
84
|
-
inheritComponentCleanupStrict(existingInstance);
|
|
85
|
-
if (snapshot) existingInstance.ownerFrame = snapshot;
|
|
86
|
-
const result = withContext(snapshot, () => renderComponentInline(existingInstance));
|
|
87
|
-
if (isPromiseLike(result)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
88
|
-
const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);
|
|
89
|
-
if (existingHost.__ASKR_WRAPPER_HOST) {
|
|
90
|
-
const wrapperResult = resolveWrapperHostResult(existingHost, scopedResult, snapshot ?? null, liveRetainedInstances);
|
|
91
|
-
domHost.updateElementChildren(existingHost, normalizeComponentChildren(wrapperResult));
|
|
92
|
-
warnUnusedStateReads(existingInstance);
|
|
93
|
-
return existingHost;
|
|
94
|
-
}
|
|
95
|
-
if (scopedResult && typeof scopedResult === "object" && "type" in scopedResult && typeof scopedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, scopedResult.type)) {
|
|
96
|
-
withContext(snapshot, () => {
|
|
97
|
-
domHost.updateElementFromVnode(existingHost, inheritComponentKey(scopedResult, node), true, forceChildrenUpdate || existingInstance.mounted === false);
|
|
98
|
-
materializeKey(existingHost, node, props);
|
|
99
|
-
});
|
|
100
|
-
warnUnusedStateReads(existingInstance);
|
|
101
|
-
return existingHost;
|
|
102
|
-
}
|
|
103
|
-
const resolvedResult = resolveHostNestedComponentResult(existingHost, existingInstance, scopedResult, snapshot ?? null, liveRetainedInstances);
|
|
104
|
-
if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)) {
|
|
105
|
-
withContext(snapshot, () => {
|
|
106
|
-
domHost.updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || existingInstance.mounted === false);
|
|
107
|
-
materializeKey(existingHost, node, props);
|
|
108
|
-
});
|
|
109
|
-
warnUnusedStateReads(existingInstance);
|
|
110
|
-
return existingHost;
|
|
111
|
-
}
|
|
112
|
-
const nextDom = replacement.replace(() => materializeComponentResultNode(existingInstance, scopedResult, parentNamespace), (replacement) => {
|
|
113
|
-
if (replacement instanceof Element) {
|
|
114
|
-
materializeKey(replacement, node, props);
|
|
115
|
-
retainReplacementOwnerChain(replacement, existingInstance, liveRetainedInstances);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
warnUnusedStateReads(existingInstance);
|
|
119
|
-
return nextDom;
|
|
120
|
-
}
|
|
121
|
-
function retainReplacementOwnerChain(host, owner, retainedInstances) {
|
|
122
|
-
const componentHost = host;
|
|
123
|
-
const next = [...componentHost.__ASKR_INSTANCES ?? []];
|
|
124
|
-
for (const instance of retainedInstances) if (!next.includes(instance)) next.push(instance);
|
|
125
|
-
componentHost.__ASKR_INSTANCES = next;
|
|
126
|
-
componentHost.__ASKR_INSTANCE = owner;
|
|
127
|
-
}
|
|
128
|
-
function itemInstanceHydrationComplete(host) {
|
|
129
|
-
const instance = host.__ASKR_INSTANCE;
|
|
130
|
-
if (instance) {
|
|
131
|
-
const scope = instance.scope;
|
|
132
|
-
if (scope) scope.hydrationPending = false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function createComponentElement(node, type, props, parentNamespace) {
|
|
136
|
-
const snapshot = getVNodeContextFrame(node) || getCurrentContextFrame();
|
|
137
|
-
const componentFn = type;
|
|
138
|
-
if (componentFn.constructor.name === "AsyncFunction") throw new Error("Async components are not supported. Use resource() for async work.");
|
|
139
|
-
let childInstance = getVNodeComponentInstance(node);
|
|
140
|
-
const hadChildInstance = !!childInstance;
|
|
141
|
-
const previousVNodeInstance = childInstance;
|
|
142
|
-
if (!childInstance) {
|
|
143
|
-
childInstance = createComponentInstance(nextComponentInstanceId(), componentFn, props || {}, null);
|
|
144
|
-
registerVNodeComponentInstanceRollback(node, previousVNodeInstance, childInstance);
|
|
145
|
-
setVNodeComponentInstance(node, childInstance);
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
if (hadChildInstance) captureInlineRenderSnapshot(childInstance);
|
|
149
|
-
childInstance.portalScope = getCurrentInstance()?.portalScope ?? childInstance.portalScope;
|
|
150
|
-
setComponentOwnershipIdentity(childInstance, node, getCurrentInstance(), 0);
|
|
151
|
-
childInstance.parentInstance = getCurrentInstance();
|
|
152
|
-
childInstance.props = props || {};
|
|
153
|
-
childInstance.isRoot = isRouteRootComponentVNode(node);
|
|
154
|
-
inheritComponentCleanupStrict(childInstance);
|
|
155
|
-
if (snapshot) childInstance.ownerFrame = snapshot;
|
|
156
|
-
const result = snapshot ? withContext(snapshot, () => renderComponentInline(childInstance)) : renderComponentInline(childInstance);
|
|
157
|
-
if (isPromiseLike(result)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
158
|
-
const scopedResult = markVNodeTreeWithContextFrame(result, snapshot ?? null);
|
|
159
|
-
const dom = snapshot ? withContext(snapshot, () => materializeComponentResultNode(childInstance, scopedResult, parentNamespace)) : materializeComponentResultNode(childInstance, scopedResult, parentNamespace);
|
|
160
|
-
warnUnusedStateReads(childInstance);
|
|
161
|
-
if (dom instanceof Element) materializeFreshKey(dom, node, props);
|
|
162
|
-
return dom;
|
|
163
|
-
} catch (error) {
|
|
164
|
-
if (!hadChildInstance) {
|
|
165
|
-
restoreVNodeComponentInstance(node, previousVNodeInstance);
|
|
166
|
-
cleanupProvisionalComponentInstance(childInstance);
|
|
167
|
-
}
|
|
168
|
-
throw error;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
//#endregion
|
|
172
|
-
export { createComponentElement, findHostInstanceByType, inheritComponentCleanupStrict, inheritComponentKey, isRouteRootComponentVNode, resolveNestedComponentResult, syncComponentElement };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/renderer/dom-host.ts
|
|
2
|
-
let rendererDOMHost = null;
|
|
3
|
-
function configureRendererDOMHost(host) {
|
|
4
|
-
rendererDOMHost = host;
|
|
5
|
-
}
|
|
6
|
-
function getRendererDOMHost() {
|
|
7
|
-
if (!rendererDOMHost) throw new Error("[askr] Renderer DOM host is not configured.");
|
|
8
|
-
return rendererDOMHost;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { configureRendererDOMHost, getRendererDOMHost };
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { __ERROR_BOUNDARY__, __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 } from "../common/jsx.js";
|
|
6
|
-
import { getCurrentInstance } from "../runtime/component-scope.js";
|
|
7
|
-
import { beginLifecycleCommitBatch, discardLifecycleCommitBatch, flushLifecycleCommitBatch } from "../runtime/lifecycle-batch.js";
|
|
8
|
-
import { isBenchMetricScopeActive, recordBenchCounter } from "../runtime/for-bench.js";
|
|
9
|
-
import "../runtime/index.js";
|
|
10
|
-
import { removeAllListeners, removeElementReactiveProps, teardownNodeSubtree, updateElementRef } from "./cleanup.js";
|
|
11
|
-
import "./env.js";
|
|
12
|
-
import "../jsx-runtime.js";
|
|
13
|
-
import { applyStaticScalarPropsToElement, hasMatchingStaticProps, materializeFreshKey, materializeKey } from "./attributes.js";
|
|
14
|
-
import { createElementForNamespace, resolveChildNamespace } from "./namespaces.js";
|
|
15
|
-
import { performBulkPositionalKeyedTextUpdate } from "./children-fastpath.js";
|
|
16
|
-
import { isBulkTextFastPathEligible, performBulkTextReplace } from "./children.js";
|
|
17
|
-
import { configureRendererDOMHost } from "./dom-host.js";
|
|
18
|
-
import { maybeWarnMissingKeys, tryGetStaticCreateFastPathShape } from "./child-shape.js";
|
|
19
|
-
import { syncReactiveScalarChild } from "./reactive-children.js";
|
|
20
|
-
import { canReuseStaticSubtree, setStaticChildSlotsCacheEnabled } from "./static-reuse.js";
|
|
21
|
-
import { rendererReactiveChildDOMHost, updateElementChildren, updateUnkeyedChildren } from "./element-children.js";
|
|
22
|
-
import { runRetainedElementUpdate } from "./retained-element-rollback.js";
|
|
23
|
-
import { beginHydrationListenerTransaction, commitHydrationListenerTransaction, discardHydrationListenerTransaction } from "./hydration-listener-transaction.js";
|
|
24
|
-
import { applyPropsToElement, hasTrackedElementPropBindings, markReactivePropsDirtySource, syncElementPropBindings } from "./prop-bindings.js";
|
|
25
|
-
import { tryAdoptMatchingIntrinsicSubtree, withIntrinsicHydrationAdoption } from "./intrinsic-hydration-adoption.js";
|
|
26
|
-
import { getControlBoundaryState, getDirectControlBoundaryVNode } from "./boundary-state.js";
|
|
27
|
-
import { createForBoundary } from "./boundary-materialization.js";
|
|
28
|
-
import { configureBoundaryDOMHost, registerControlBoundaryCommitOwner } from "./boundaries.js";
|
|
29
|
-
import { createComponentElement, syncComponentElement } from "./component-host.js";
|
|
30
|
-
import { createErrorBoundaryElement } from "./error-boundary-dom.js";
|
|
31
|
-
import { tryPatchStableForDirtyItem } from "./stable-patch.js";
|
|
32
|
-
import { beginDeferredHydrationActivation, commitDeferredHydrationActivation, rememberDeferredHydrationVNode, rollbackDeferredHydrationActivation } from "./hydration-boundaries.js";
|
|
33
|
-
import { createComponentResultNodeWithBlueprint, createResultNodeWithBlueprint } from "./intrinsic-blueprint.js";
|
|
34
|
-
//#region src/renderer/dom-internal.ts
|
|
35
|
-
const IS_DOM_AVAILABLE = typeof document !== "undefined";
|
|
36
|
-
function cleanupFailedDOMConstruction(root) {
|
|
37
|
-
const nodes = root instanceof DocumentFragment ? Array.from(root.childNodes) : [root];
|
|
38
|
-
for (const node of nodes) try {
|
|
39
|
-
teardownNodeSubtree(node);
|
|
40
|
-
} catch {}
|
|
41
|
-
}
|
|
42
|
-
function getHydrationSkipBoundary(el) {
|
|
43
|
-
return el.closest("[data-skip-hydrate=\"true\"]");
|
|
44
|
-
}
|
|
45
|
-
function isHydrationSkipped(el) {
|
|
46
|
-
return getHydrationSkipBoundary(el) !== null;
|
|
47
|
-
}
|
|
48
|
-
function clearHydrationDeferredSubtree(el) {
|
|
49
|
-
const boundary = getHydrationSkipBoundary(el);
|
|
50
|
-
if (!boundary) return;
|
|
51
|
-
if (boundary === el) {
|
|
52
|
-
removeAllListeners(el);
|
|
53
|
-
removeElementReactiveProps(el);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function createDOMNode(node, parentNamespace) {
|
|
57
|
-
if (!IS_DOM_AVAILABLE) {
|
|
58
|
-
if (getRuntimeEnv().NODE_ENV !== "production") try {
|
|
59
|
-
logger.warn("[Askr] createDOMNode called in non-DOM environment");
|
|
60
|
-
} catch {}
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
if (typeof node === "string") {
|
|
64
|
-
if (isBenchMetricScopeActive("coldCreate")) recordBenchCounter("domNodesCreated");
|
|
65
|
-
return document.createTextNode(node);
|
|
66
|
-
}
|
|
67
|
-
if (typeof node === "number") {
|
|
68
|
-
if (isBenchMetricScopeActive("coldCreate")) recordBenchCounter("domNodesCreated");
|
|
69
|
-
return document.createTextNode(String(node));
|
|
70
|
-
}
|
|
71
|
-
if (!node) return null;
|
|
72
|
-
if (Array.isArray(node)) {
|
|
73
|
-
maybeWarnMissingKeys(node);
|
|
74
|
-
const fragment = document.createDocumentFragment();
|
|
75
|
-
try {
|
|
76
|
-
for (const child of node) {
|
|
77
|
-
const dom = createDOMNode(child, parentNamespace);
|
|
78
|
-
if (dom) fragment.appendChild(dom);
|
|
79
|
-
}
|
|
80
|
-
return fragment;
|
|
81
|
-
} catch (error) {
|
|
82
|
-
cleanupFailedDOMConstruction(fragment);
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (typeof node === "object" && node !== null && "type" in node) {
|
|
87
|
-
const type = node.type;
|
|
88
|
-
const props = node.props || {};
|
|
89
|
-
if (typeof type === "string") return createIntrinsicElement(node, type, props, parentNamespace);
|
|
90
|
-
if (typeof type === "function") return createComponentElement(node, type, props, parentNamespace);
|
|
91
|
-
if (type === __FOR_BOUNDARY__) return createForBoundary(node, props, parentNamespace);
|
|
92
|
-
if (type === __ERROR_BOUNDARY__) return createErrorBoundaryElement(node, props, parentNamespace);
|
|
93
|
-
if (typeof type === "symbol" && (type === Fragment || String(type) === "Symbol(Fragment)")) return createFragmentElement(node, props, parentNamespace);
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
function createComponentResultNode(component, node, parentNamespace) {
|
|
98
|
-
return createComponentResultNodeWithBlueprint(component, node, parentNamespace, () => createDOMNode(node, parentNamespace), rendererReactiveChildDOMHost);
|
|
99
|
-
}
|
|
100
|
-
function createOwnedResultNodeWithBlueprint(owner, node, parentNamespace) {
|
|
101
|
-
return createResultNodeWithBlueprint(owner, node, parentNamespace, () => createDOMNode(node, parentNamespace), rendererReactiveChildDOMHost);
|
|
102
|
-
}
|
|
103
|
-
function createIntrinsicElement(node, type, props, parentNamespace) {
|
|
104
|
-
const children = props.children ?? node.children;
|
|
105
|
-
const elementNamespace = resolveChildNamespace(type, parentNamespace);
|
|
106
|
-
const el = createElementForNamespace(type, parentNamespace);
|
|
107
|
-
try {
|
|
108
|
-
if (isBenchMetricScopeActive("coldCreate")) recordBenchCounter("domNodesCreated");
|
|
109
|
-
materializeFreshKey(el, node, props);
|
|
110
|
-
const staticCreateFastPath = tryGetStaticCreateFastPathShape(props, children);
|
|
111
|
-
if (staticCreateFastPath) {
|
|
112
|
-
applyStaticScalarPropsToElement(el, props, type);
|
|
113
|
-
if (staticCreateFastPath.textContent !== null) {
|
|
114
|
-
el.textContent = staticCreateFastPath.textContent;
|
|
115
|
-
if (isBenchMetricScopeActive("coldCreate")) recordBenchCounter("domNodesCreated");
|
|
116
|
-
}
|
|
117
|
-
return el;
|
|
118
|
-
}
|
|
119
|
-
applyPropsToElement(el, props, type, isHydrationSkipped);
|
|
120
|
-
if (children !== null && children !== void 0) {
|
|
121
|
-
const controlBoundaryVNode = getDirectControlBoundaryVNode(children);
|
|
122
|
-
if (controlBoundaryVNode) {
|
|
123
|
-
const controlState = getControlBoundaryState(controlBoundaryVNode);
|
|
124
|
-
if (!controlState) throw new Error("[createIntrinsicElement] Control boundary missing internal state");
|
|
125
|
-
registerControlBoundaryCommitOwner(el, controlState);
|
|
126
|
-
}
|
|
127
|
-
if (syncReactiveScalarChild(el, children, rendererReactiveChildDOMHost)) return el;
|
|
128
|
-
if (Array.isArray(children)) {
|
|
129
|
-
maybeWarnMissingKeys(children);
|
|
130
|
-
if (children.length > 1) for (const child of children) {
|
|
131
|
-
const dom = createDOMNode(child, elementNamespace);
|
|
132
|
-
if (dom) el.appendChild(dom);
|
|
133
|
-
}
|
|
134
|
-
else if (children.length === 1) {
|
|
135
|
-
const dom = createDOMNode(children[0], elementNamespace);
|
|
136
|
-
if (dom) el.appendChild(dom);
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
const dom = createDOMNode(children, elementNamespace);
|
|
140
|
-
if (dom) el.appendChild(dom);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return el;
|
|
144
|
-
} catch (error) {
|
|
145
|
-
cleanupFailedDOMConstruction(el);
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function createFragmentElement(node, props, parentNamespace) {
|
|
150
|
-
const fragment = document.createDocumentFragment();
|
|
151
|
-
const children = props.children ?? node.children;
|
|
152
|
-
try {
|
|
153
|
-
if (children) if (Array.isArray(children)) {
|
|
154
|
-
maybeWarnMissingKeys(children);
|
|
155
|
-
for (const child of children) {
|
|
156
|
-
const dom = createDOMNode(child, parentNamespace);
|
|
157
|
-
if (dom) fragment.appendChild(dom);
|
|
158
|
-
}
|
|
159
|
-
} else {
|
|
160
|
-
const dom = createDOMNode(children, parentNamespace);
|
|
161
|
-
if (dom) fragment.appendChild(dom);
|
|
162
|
-
}
|
|
163
|
-
return fragment;
|
|
164
|
-
} catch (error) {
|
|
165
|
-
cleanupFailedDOMConstruction(fragment);
|
|
166
|
-
throw error;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function updateElementFromVnode(el, vnode, updateChildren = true, forceChildrenUpdate = false) {
|
|
170
|
-
if (updateChildren && !forceChildrenUpdate && _isDOMElement(vnode) && tryAdoptMatchingIntrinsicSubtree(el, vnode)) return;
|
|
171
|
-
runRetainedElementUpdate(el, teardownNodeSubtree, () => {
|
|
172
|
-
applyElementUpdateFromVnode(el, vnode, updateChildren, forceChildrenUpdate);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
function applyElementUpdateFromVnode(el, vnode, updateChildren, forceChildrenUpdate) {
|
|
176
|
-
if (!_isDOMElement(vnode)) return;
|
|
177
|
-
const props = vnode.props || {};
|
|
178
|
-
const domVNode = vnode;
|
|
179
|
-
if (isHydrationSkipped(el)) {
|
|
180
|
-
rememberDeferredHydrationVNode(el, vnode, getCurrentInstance(), getCurrentInstance()?.ownerFrame ?? null);
|
|
181
|
-
clearHydrationDeferredSubtree(el);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
materializeKey(el, vnode, props);
|
|
185
|
-
updateElementRef(el, props.ref);
|
|
186
|
-
if (!hasTrackedElementPropBindings(el)) {
|
|
187
|
-
if (!forceChildrenUpdate && hasMatchingStaticProps(el, props, vnode.type)) {
|
|
188
|
-
if (updateChildren) {
|
|
189
|
-
const children = props.children ?? vnode.children;
|
|
190
|
-
if (!forceChildrenUpdate && canReuseStaticSubtree(el, domVNode)) return;
|
|
191
|
-
updateElementChildren(el, children, forceChildrenUpdate);
|
|
192
|
-
}
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const usesReactiveChildren = syncReactiveScalarChild(el, props.children ?? domVNode.children, rendererReactiveChildDOMHost);
|
|
197
|
-
syncElementPropBindings(el, domVNode, props, usesReactiveChildren);
|
|
198
|
-
if (updateChildren) {
|
|
199
|
-
const children = props.children ?? vnode.children;
|
|
200
|
-
if (usesReactiveChildren) return;
|
|
201
|
-
updateElementChildren(el, children, forceChildrenUpdate);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/** @internal Activate one recorded deferred hydration boundary in place. */
|
|
205
|
-
function activateHydrationBoundary(element) {
|
|
206
|
-
const record = beginDeferredHydrationActivation(element);
|
|
207
|
-
if (!record?.vnode) return false;
|
|
208
|
-
const lifecycleBatch = beginLifecycleCommitBatch();
|
|
209
|
-
const listenerTransaction = beginHydrationListenerTransaction();
|
|
210
|
-
try {
|
|
211
|
-
element.removeAttribute("data-skip-hydrate");
|
|
212
|
-
withIntrinsicHydrationAdoption(() => {
|
|
213
|
-
updateElementFromVnode(element, record.vnode, true, true);
|
|
214
|
-
});
|
|
215
|
-
commitHydrationListenerTransaction(listenerTransaction);
|
|
216
|
-
flushLifecycleCommitBatch(lifecycleBatch);
|
|
217
|
-
commitDeferredHydrationActivation(record);
|
|
218
|
-
return true;
|
|
219
|
-
} catch (error) {
|
|
220
|
-
discardHydrationListenerTransaction(listenerTransaction);
|
|
221
|
-
discardLifecycleCommitBatch(lifecycleBatch);
|
|
222
|
-
element.setAttribute("data-skip-hydrate", "true");
|
|
223
|
-
rollbackDeferredHydrationActivation(record);
|
|
224
|
-
throw error;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
configureRendererDOMHost({
|
|
228
|
-
createDOMNode,
|
|
229
|
-
createComponentResultNode,
|
|
230
|
-
syncComponentElement,
|
|
231
|
-
updateElementFromVnode,
|
|
232
|
-
updateElementChildren,
|
|
233
|
-
tryPatchStableForDirtyItem
|
|
234
|
-
});
|
|
235
|
-
configureBoundaryDOMHost({
|
|
236
|
-
createDOMNode,
|
|
237
|
-
createResultNodeWithBlueprint: createOwnedResultNodeWithBlueprint,
|
|
238
|
-
syncComponentElement,
|
|
239
|
-
updateElementFromVnode,
|
|
240
|
-
tryPatchStableForDirtyItem
|
|
241
|
-
});
|
|
242
|
-
//#endregion
|
|
243
|
-
export { IS_DOM_AVAILABLE, activateHydrationBoundary, createDOMNode, isBulkTextFastPathEligible, markReactivePropsDirtySource, performBulkPositionalKeyedTextUpdate, performBulkTextReplace, setStaticChildSlotsCacheEnabled, syncComponentElement, tryPatchStableForDirtyItem, updateElementChildren, updateElementFromVnode, updateUnkeyedChildren };
|