@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
package/dist/renderer/keyed.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { buildKeyMapFromChildren, getMaterializedKey, hasPropChanged, isIgnoredForPropChanges } from "./utils.js";
|
|
2
|
-
import { extractKeyedVnodes } from "./keyed-children.js";
|
|
3
|
-
//#region src/renderer/keyed.ts
|
|
4
|
-
const keyedElements = /* @__PURE__ */ new WeakMap();
|
|
5
|
-
/**
|
|
6
|
-
* Retrieve existing keyed map for a parent element (runtime use)
|
|
7
|
-
*/
|
|
8
|
-
function getKeyMapForElement(el) {
|
|
9
|
-
return keyedElements.get(el);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Populate a keyed map for an element by scanning its immediate children
|
|
13
|
-
* for `data-key` attributes. Proactive initialization for runtime layers.
|
|
14
|
-
*/
|
|
15
|
-
function populateKeyMapForElement(parent) {
|
|
16
|
-
try {
|
|
17
|
-
if (keyedElements.has(parent)) return;
|
|
18
|
-
let domMap = buildKeyMapFromChildren(parent);
|
|
19
|
-
if (domMap.size === 0) {
|
|
20
|
-
domMap = /* @__PURE__ */ new Map();
|
|
21
|
-
const children = Array.from(parent.children);
|
|
22
|
-
for (const ch of children) {
|
|
23
|
-
const text = (ch.textContent || "").trim();
|
|
24
|
-
if (text) {
|
|
25
|
-
domMap.set(text, ch);
|
|
26
|
-
const n = Number(text);
|
|
27
|
-
if (!Number.isNaN(n)) domMap.set(n, ch);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (domMap.size > 0) keyedElements.set(parent, domMap);
|
|
32
|
-
} catch {}
|
|
33
|
-
}
|
|
34
|
-
const _reconcilerRecordedParents = /* @__PURE__ */ new WeakSet();
|
|
35
|
-
const LIS_THRESHOLD_MIN = 64;
|
|
36
|
-
/**
|
|
37
|
-
* Compute LIS (Longest Increasing Subsequence) length for positions
|
|
38
|
-
*/
|
|
39
|
-
function computeLISLength(positions) {
|
|
40
|
-
const tails = [];
|
|
41
|
-
for (const pos of positions) {
|
|
42
|
-
if (pos === -1) continue;
|
|
43
|
-
let lo = 0;
|
|
44
|
-
let hi = tails.length;
|
|
45
|
-
while (lo < hi) {
|
|
46
|
-
const mid = lo + hi >> 1;
|
|
47
|
-
if (tails[mid] < pos) lo = mid + 1;
|
|
48
|
-
else hi = mid;
|
|
49
|
-
}
|
|
50
|
-
if (lo === tails.length) tails.push(pos);
|
|
51
|
-
else tails[lo] = pos;
|
|
52
|
-
}
|
|
53
|
-
return tails.length;
|
|
54
|
-
}
|
|
55
|
-
function keyToken(key) {
|
|
56
|
-
return `${typeof key}:${String(key)}`;
|
|
57
|
-
}
|
|
58
|
-
function collectCurrentKeyOrder(parent, oldKeyMap) {
|
|
59
|
-
const currentKeys = [];
|
|
60
|
-
if (oldKeyMap && oldKeyMap.size > 0) {
|
|
61
|
-
let lastElement = null;
|
|
62
|
-
let keyCount = 0;
|
|
63
|
-
for (const [key, el] of oldKeyMap) {
|
|
64
|
-
if (el === lastElement) continue;
|
|
65
|
-
lastElement = el;
|
|
66
|
-
currentKeys.push(keyToken(key));
|
|
67
|
-
keyCount++;
|
|
68
|
-
}
|
|
69
|
-
if (keyCount > 0) return {
|
|
70
|
-
keyCount,
|
|
71
|
-
currentKeys
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
let keyCount = 0;
|
|
75
|
-
try {
|
|
76
|
-
for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {
|
|
77
|
-
const key = getMaterializedKey(el);
|
|
78
|
-
if (key === void 0) continue;
|
|
79
|
-
currentKeys.push(keyToken(key));
|
|
80
|
-
keyCount++;
|
|
81
|
-
}
|
|
82
|
-
} catch {}
|
|
83
|
-
return {
|
|
84
|
-
keyCount,
|
|
85
|
-
currentKeys
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function checkVnodePropChanges(keyedVnodes, oldKeyMap) {
|
|
89
|
-
for (const { key, vnode } of keyedVnodes) {
|
|
90
|
-
const el = oldKeyMap?.get(key);
|
|
91
|
-
if (!el || typeof vnode !== "object" || vnode === null) continue;
|
|
92
|
-
const props = vnode.props || {};
|
|
93
|
-
for (const k of Object.keys(props)) {
|
|
94
|
-
if (isIgnoredForPropChanges(k)) continue;
|
|
95
|
-
if (hasPropChanged(el, k, props[k])) return true;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Plan keyed reorder eligibility from one snapshot of keyed order and props.
|
|
102
|
-
*/
|
|
103
|
-
function planKeyedReorderFastPath(parent, keyedVnodes, totalChildren, oldKeyMap) {
|
|
104
|
-
const totalKeyed = keyedVnodes.length;
|
|
105
|
-
const isWholeKeyedList = totalKeyed === totalChildren;
|
|
106
|
-
const shouldEvaluateShape = isWholeKeyedList && totalKeyed >= LIS_THRESHOLD_MIN;
|
|
107
|
-
if (!shouldEvaluateShape) return {
|
|
108
|
-
useFastPath: false,
|
|
109
|
-
totalKeyed,
|
|
110
|
-
totalChildren,
|
|
111
|
-
currentKeyCount: 0,
|
|
112
|
-
moveCount: 0,
|
|
113
|
-
lisLen: 0,
|
|
114
|
-
hasPropChanges: false,
|
|
115
|
-
isWholeKeyedList
|
|
116
|
-
};
|
|
117
|
-
const hasPropChanges = checkVnodePropChanges(keyedVnodes, oldKeyMap);
|
|
118
|
-
if (hasPropChanges) return {
|
|
119
|
-
useFastPath: false,
|
|
120
|
-
totalKeyed,
|
|
121
|
-
totalChildren,
|
|
122
|
-
currentKeyCount: 0,
|
|
123
|
-
moveCount: 0,
|
|
124
|
-
lisLen: 0,
|
|
125
|
-
hasPropChanges,
|
|
126
|
-
isWholeKeyedList
|
|
127
|
-
};
|
|
128
|
-
const { keyCount: currentKeyCount, currentKeys } = collectCurrentKeyOrder(parent, oldKeyMap);
|
|
129
|
-
let moveCount = 0;
|
|
130
|
-
for (let i = 0; i < totalKeyed; i++) if (currentKeys[i] !== keyToken(keyedVnodes[i].key)) moveCount++;
|
|
131
|
-
const cheapMoveTrigger = shouldEvaluateShape && currentKeyCount > 0 && moveCount > Math.max(64, Math.floor(totalKeyed * .1));
|
|
132
|
-
let lisTrigger = false;
|
|
133
|
-
let lisLen = 0;
|
|
134
|
-
if (shouldEvaluateShape && !cheapMoveTrigger) {
|
|
135
|
-
const indexByKey = /* @__PURE__ */ new Map();
|
|
136
|
-
for (let i = 0; i < currentKeys.length; i++) indexByKey.set(currentKeys[i], i);
|
|
137
|
-
const positions = Array(totalKeyed).fill(-1);
|
|
138
|
-
for (let i = 0; i < totalKeyed; i++) positions[i] = indexByKey.get(keyToken(keyedVnodes[i].key)) ?? -1;
|
|
139
|
-
lisLen = computeLISLength(positions);
|
|
140
|
-
lisTrigger = lisLen < Math.floor(totalKeyed * .5);
|
|
141
|
-
}
|
|
142
|
-
if (!shouldEvaluateShape || !(cheapMoveTrigger || lisTrigger)) return {
|
|
143
|
-
useFastPath: false,
|
|
144
|
-
totalKeyed,
|
|
145
|
-
totalChildren,
|
|
146
|
-
currentKeyCount,
|
|
147
|
-
moveCount,
|
|
148
|
-
lisLen,
|
|
149
|
-
hasPropChanges: false,
|
|
150
|
-
isWholeKeyedList
|
|
151
|
-
};
|
|
152
|
-
return {
|
|
153
|
-
useFastPath: true,
|
|
154
|
-
totalKeyed,
|
|
155
|
-
totalChildren,
|
|
156
|
-
currentKeyCount,
|
|
157
|
-
moveCount,
|
|
158
|
-
lisLen,
|
|
159
|
-
hasPropChanges: false,
|
|
160
|
-
isWholeKeyedList
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
function isKeyedReorderFastPathEligible(parent, newChildren, oldKeyMap) {
|
|
164
|
-
return planKeyedReorderFastPath(parent, extractKeyedVnodes(newChildren), newChildren.length, oldKeyMap);
|
|
165
|
-
}
|
|
166
|
-
//#endregion
|
|
167
|
-
export { _reconcilerRecordedParents, getKeyMapForElement, isKeyedReorderFastPathEligible, keyedElements, planKeyedReorderFastPath, populateKeyMapForElement };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { tagNamesEqualIgnoreCase } from "./utils.js";
|
|
2
|
-
//#region src/renderer/namespaces.ts
|
|
3
|
-
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
4
|
-
function getParentNamespace(parent) {
|
|
5
|
-
return parent.namespaceURI === "http://www.w3.org/2000/svg" ? SVG_NAMESPACE : void 0;
|
|
6
|
-
}
|
|
7
|
-
function resolveChildNamespace(type, parentNamespace) {
|
|
8
|
-
if (type === "svg") return SVG_NAMESPACE;
|
|
9
|
-
if (parentNamespace === "http://www.w3.org/2000/svg" && type !== "foreignObject") return SVG_NAMESPACE;
|
|
10
|
-
}
|
|
11
|
-
function createElementForNamespace(type, parentNamespace, ownerDocument = document) {
|
|
12
|
-
const namespace = resolveChildNamespace(type, parentNamespace);
|
|
13
|
-
return namespace ? ownerDocument.createElementNS(namespace, type) : ownerDocument.createElement(type);
|
|
14
|
-
}
|
|
15
|
-
function canReuseIntrinsicElementInNamespace(existing, type, parentNamespace) {
|
|
16
|
-
if (!tagNamesEqualIgnoreCase(existing.tagName, type)) return false;
|
|
17
|
-
const expectedNamespace = resolveChildNamespace(type, parentNamespace);
|
|
18
|
-
return expectedNamespace === void 0 ? true : existing.namespaceURI === expectedNamespace;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { SVG_NAMESPACE, canReuseIntrinsicElementInNamespace, createElementForNamespace, getParentNamespace, resolveChildNamespace };
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { getRuntimeEnv } from "../common/env.js";
|
|
2
|
-
import { logger } from "../common/logger.js";
|
|
3
|
-
import { incrementPerfMetric } from "../runtime/perf-metrics.js";
|
|
4
|
-
import { incDevCounter } from "../runtime/dev-namespace.js";
|
|
5
|
-
import { createFineGrainedEffect, markFineGrainedEffectsDirtySource } from "../runtime/effect.js";
|
|
6
|
-
import { addDelegatedListener, addFreshDelegatedListener, getDelegatedHandlerForElement, getDelegatedHandlersForElement, isDelegatedEvent, isEventDelegationEnabled, removeDelegatedListener, updateDelegatedListener } from "../runtime/events.js";
|
|
7
|
-
import "../runtime/for-bench.js";
|
|
8
|
-
import "../runtime/index.js";
|
|
9
|
-
import { REACTIVE_CHILDREN_KEY, elementListeners, elementReactivePropsCleanup, elementRefs, getElementReactivePropCleanupSize, getElementReactivePropsCleanupMap, updateElementRef } from "./cleanup.js";
|
|
10
|
-
import "./env.js";
|
|
11
|
-
import { createMutableWrappedHandler, getEventListenerKey, getEventListenerOptions, isSkippedProp, parseEventProp } from "./utils.js";
|
|
12
|
-
import { applyScalarPropValue, removeStaleAttributes } from "./attributes.js";
|
|
13
|
-
import { stageHydrationListener } from "./hydration-listener-transaction.js";
|
|
14
|
-
const reactivePropRegistry = /* @__PURE__ */ new Set();
|
|
15
|
-
function addTrackedListener(el, eventName, handler, capture = false, fresh = false) {
|
|
16
|
-
const useDelegation = !capture && isEventDelegationEnabled() && isDelegatedEvent(eventName);
|
|
17
|
-
const listenerKey = getEventListenerKey(eventName, capture);
|
|
18
|
-
if (stageHydrationListener({
|
|
19
|
-
kind: useDelegation ? "delegated" : "direct",
|
|
20
|
-
eventName,
|
|
21
|
-
publish: () => addTrackedListener(el, eventName, handler, capture, fresh),
|
|
22
|
-
rollback: () => removeTrackedListener(el, eventName, capture)
|
|
23
|
-
})) return;
|
|
24
|
-
if (useDelegation) {
|
|
25
|
-
if (fresh) addFreshDelegatedListener(el, eventName, handler, handler, void 0);
|
|
26
|
-
else addDelegatedListener(el, eventName, handler, handler, void 0);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const options = getEventListenerOptions(eventName, capture);
|
|
30
|
-
const mutableHandler = createMutableWrappedHandler(handler, true);
|
|
31
|
-
const trackedHandler = mutableHandler.handler;
|
|
32
|
-
if (options !== void 0) el.addEventListener(eventName, trackedHandler, options);
|
|
33
|
-
else el.addEventListener(eventName, trackedHandler);
|
|
34
|
-
incDevCounter("listenerAdds");
|
|
35
|
-
if (!elementListeners.has(el)) elementListeners.set(el, /* @__PURE__ */ new Map());
|
|
36
|
-
elementListeners.get(el).set(listenerKey, {
|
|
37
|
-
handler: trackedHandler,
|
|
38
|
-
original: handler,
|
|
39
|
-
eventName,
|
|
40
|
-
options,
|
|
41
|
-
isDelegated: false,
|
|
42
|
-
updateHandler: mutableHandler?.updateHandler
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function removeTrackedListener(el, eventName, capture) {
|
|
46
|
-
if (!capture && getDelegatedHandlerForElement(el, eventName)) {
|
|
47
|
-
removeDelegatedListener(el, eventName);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const listenerKey = getEventListenerKey(eventName, capture);
|
|
51
|
-
const entry = elementListeners.get(el)?.get(listenerKey);
|
|
52
|
-
if (!entry) return;
|
|
53
|
-
if (entry.options !== void 0) el.removeEventListener(entry.eventName, entry.handler, entry.options);
|
|
54
|
-
else el.removeEventListener(entry.eventName, entry.handler);
|
|
55
|
-
incDevCounter("listenerRemoves");
|
|
56
|
-
const listeners = elementListeners.get(el);
|
|
57
|
-
listeners?.delete(listenerKey);
|
|
58
|
-
if (listeners?.size === 0) elementListeners.delete(el);
|
|
59
|
-
}
|
|
60
|
-
function markReactivePropsDirtySource(source) {
|
|
61
|
-
markFineGrainedEffectsDirtySource(source);
|
|
62
|
-
}
|
|
63
|
-
function setupReactiveProp(el, propName, propFn, tagName) {
|
|
64
|
-
const descriptor = {
|
|
65
|
-
el,
|
|
66
|
-
propName,
|
|
67
|
-
propFn,
|
|
68
|
-
tagName,
|
|
69
|
-
lastClassTokens: null
|
|
70
|
-
};
|
|
71
|
-
let effectHandle = null;
|
|
72
|
-
reactivePropRegistry.add(descriptor);
|
|
73
|
-
effectHandle = createFineGrainedEffect({
|
|
74
|
-
lane: "reactive",
|
|
75
|
-
compute: () => descriptor.propFn(),
|
|
76
|
-
commit: (value, previousValue) => {
|
|
77
|
-
incrementPerfMetric("reactivePropReevaluations");
|
|
78
|
-
applyScalarPropValue(el, propName, value, tagName, previousValue, descriptor);
|
|
79
|
-
},
|
|
80
|
-
equals: (previousValue, nextValue) => {
|
|
81
|
-
if (Object.is(previousValue, nextValue)) {
|
|
82
|
-
incrementPerfMetric("skippedDomPropWrites");
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
},
|
|
87
|
-
onError: (err) => {
|
|
88
|
-
if (getRuntimeEnv().NODE_ENV !== "production") logger.warn("[Askr] Reactive prop update failed:", err);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
const cleanup = () => {
|
|
92
|
-
reactivePropRegistry.delete(descriptor);
|
|
93
|
-
effectHandle?.cleanup();
|
|
94
|
-
effectHandle = null;
|
|
95
|
-
};
|
|
96
|
-
const updateFn = (nextFn) => {
|
|
97
|
-
if (!effectHandle) return;
|
|
98
|
-
descriptor.propFn = nextFn;
|
|
99
|
-
try {
|
|
100
|
-
effectHandle.updateCompute(nextFn);
|
|
101
|
-
} catch (err) {
|
|
102
|
-
if (getRuntimeEnv().NODE_ENV !== "production") logger.warn("[Askr] Reactive prop update failed:", err);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return {
|
|
106
|
-
cleanup,
|
|
107
|
-
updateFn
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function getOrCreateReactivePropsCleanupMap(el) {
|
|
111
|
-
return getElementReactivePropsCleanupMap(el, true);
|
|
112
|
-
}
|
|
113
|
-
/** @internal Create a standalone reactive prop entry for rollback restoration. */
|
|
114
|
-
function createReactivePropCleanupEntry(el, propName, propFn, tagName) {
|
|
115
|
-
const reactive = setupReactiveProp(el, propName, propFn, tagName);
|
|
116
|
-
return {
|
|
117
|
-
cleanup: reactive.cleanup,
|
|
118
|
-
updateFn: (nextValue) => {
|
|
119
|
-
reactive.updateFn(nextValue);
|
|
120
|
-
},
|
|
121
|
-
restoreFn: (nextValue) => createReactivePropCleanupEntry(el, propName, nextValue, tagName),
|
|
122
|
-
fnRef: propFn
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function hasTrackedElementPropBindings(el) {
|
|
126
|
-
const existingListeners = elementListeners.get(el);
|
|
127
|
-
return existingListeners !== void 0 && existingListeners.size > 0 || getElementReactivePropCleanupSize(el) > 0;
|
|
128
|
-
}
|
|
129
|
-
function hasAnyElementBindingState(el) {
|
|
130
|
-
return hasTrackedElementPropBindings(el) || getDelegatedHandlersForElement(el) !== void 0 || elementRefs.has(el);
|
|
131
|
-
}
|
|
132
|
-
function applyMatchingElementBindings(el, props) {
|
|
133
|
-
if (Object.prototype.hasOwnProperty.call(props, "ref")) updateElementRef(el, props.ref);
|
|
134
|
-
for (const key in props) {
|
|
135
|
-
const eventProp = parseEventProp(key);
|
|
136
|
-
if (!eventProp) continue;
|
|
137
|
-
const value = props[key];
|
|
138
|
-
if (typeof value === "function") addTrackedListener(el, eventProp.eventName, value, eventProp.capture);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/** @internal Attach stateful bindings to a newly cloned blueprint element. */
|
|
142
|
-
function applyFreshElementBindings(el, props) {
|
|
143
|
-
if (Object.prototype.hasOwnProperty.call(props, "ref")) updateElementRef(el, props.ref);
|
|
144
|
-
for (const key in props) {
|
|
145
|
-
const eventProp = parseEventProp(key);
|
|
146
|
-
if (eventProp) {
|
|
147
|
-
const value = props[key];
|
|
148
|
-
if (typeof value === "function") addTrackedListener(el, eventProp.eventName, value, eventProp.capture, true);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function applyPropsToElement(el, props, tagName, isHydrationSkipped) {
|
|
153
|
-
if (isHydrationSkipped(el)) return;
|
|
154
|
-
for (const key in props) {
|
|
155
|
-
const value = props[key];
|
|
156
|
-
if (key === "ref") {
|
|
157
|
-
updateElementRef(el, value);
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
if (isSkippedProp(key)) continue;
|
|
161
|
-
if (value === void 0 || value === null || value === false) continue;
|
|
162
|
-
const eventProp = parseEventProp(key);
|
|
163
|
-
if (eventProp) {
|
|
164
|
-
addTrackedListener(el, eventProp.eventName, value, eventProp.capture);
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (typeof value === "function" && key !== "ref") {
|
|
168
|
-
getOrCreateReactivePropsCleanupMap(el).set(key, createReactivePropCleanupEntry(el, key, value, tagName));
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
applyScalarPropValue(el, key, value, tagName);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function syncElementPropBindings(el, domVNode, props, usesReactiveChildren) {
|
|
175
|
-
const existingListeners = elementListeners.get(el);
|
|
176
|
-
const existingReactiveProps = getElementReactivePropsCleanupMap(el);
|
|
177
|
-
let desiredListenerKeys = null;
|
|
178
|
-
let desiredDelegatedEventNames = null;
|
|
179
|
-
let desiredReactivePropNames = null;
|
|
180
|
-
if (usesReactiveChildren) (desiredReactivePropNames ??= /* @__PURE__ */ new Set()).add(REACTIVE_CHILDREN_KEY);
|
|
181
|
-
for (const key in props) {
|
|
182
|
-
const value = props[key];
|
|
183
|
-
if (key === "ref") continue;
|
|
184
|
-
if (isSkippedProp(key)) continue;
|
|
185
|
-
const eventProp = parseEventProp(key);
|
|
186
|
-
const eventName = eventProp?.eventName;
|
|
187
|
-
const eventCapture = eventProp?.capture ?? false;
|
|
188
|
-
const listenerKey = eventName === void 0 ? null : getEventListenerKey(eventName, eventCapture);
|
|
189
|
-
if (value === void 0 || value === null || value === false) {
|
|
190
|
-
if (listenerKey && existingListeners?.has(listenerKey)) {
|
|
191
|
-
const entry = existingListeners.get(listenerKey);
|
|
192
|
-
incDevCounter("listenerRemoves");
|
|
193
|
-
if (entry.isDelegated) removeDelegatedListener(el, entry.eventName);
|
|
194
|
-
else if (entry.options !== void 0) el.removeEventListener(entry.eventName, entry.handler, entry.options);
|
|
195
|
-
else el.removeEventListener(entry.eventName, entry.handler);
|
|
196
|
-
existingListeners.delete(listenerKey);
|
|
197
|
-
} else {
|
|
198
|
-
const entry = existingReactiveProps?.get(key);
|
|
199
|
-
if (entry) {
|
|
200
|
-
entry.cleanup();
|
|
201
|
-
existingReactiveProps?.delete(key);
|
|
202
|
-
} else applyScalarPropValue(el, key, value, domVNode.type);
|
|
203
|
-
}
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
if (typeof value === "function" && !eventProp && key !== "ref") {
|
|
207
|
-
const existingEntry = existingReactiveProps?.get(key);
|
|
208
|
-
if (existingReactiveProps && existingReactiveProps.size > 0) (desiredReactivePropNames ??= /* @__PURE__ */ new Set()).add(key);
|
|
209
|
-
if (existingEntry && existingEntry.fnRef === value) continue;
|
|
210
|
-
if (existingEntry?.updateFn) {
|
|
211
|
-
existingEntry.updateFn(value);
|
|
212
|
-
existingEntry.fnRef = value;
|
|
213
|
-
continue;
|
|
214
|
-
}
|
|
215
|
-
if (existingEntry) existingEntry.cleanup();
|
|
216
|
-
getOrCreateReactivePropsCleanupMap(el).set(key, createReactivePropCleanupEntry(el, key, value, domVNode.type));
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
const existingReactiveEntry = existingReactiveProps?.get(key);
|
|
220
|
-
if (existingReactiveEntry) {
|
|
221
|
-
existingReactiveEntry.cleanup();
|
|
222
|
-
existingReactiveProps?.delete(key);
|
|
223
|
-
}
|
|
224
|
-
if (eventProp && listenerKey) {
|
|
225
|
-
const eventName = eventProp.eventName;
|
|
226
|
-
const eventCapture = eventProp.capture;
|
|
227
|
-
const useDelegation = !eventCapture && isEventDelegationEnabled() && isDelegatedEvent(eventName);
|
|
228
|
-
if (useDelegation) (desiredDelegatedEventNames ??= /* @__PURE__ */ new Set()).add(eventName);
|
|
229
|
-
if (useDelegation) {
|
|
230
|
-
const existingDelegated = getDelegatedHandlerForElement(el, eventName);
|
|
231
|
-
if (existingDelegated?.original === value) continue;
|
|
232
|
-
if (existingDelegated && updateDelegatedListener(el, eventName, value, value, void 0)) continue;
|
|
233
|
-
addDelegatedListener(el, eventName, value, value, void 0);
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
(desiredListenerKeys ??= /* @__PURE__ */ new Set()).add(listenerKey);
|
|
237
|
-
const existing = existingListeners?.get(listenerKey);
|
|
238
|
-
if (existing && existing.original === value) continue;
|
|
239
|
-
if (existing) {
|
|
240
|
-
if (useDelegation && existing.isDelegated && updateDelegatedListener(el, eventName, value, value, void 0)) {
|
|
241
|
-
existing.handler = value;
|
|
242
|
-
existing.original = value;
|
|
243
|
-
existing.options = void 0;
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
if (!useDelegation && !existing.isDelegated && existing.updateHandler) {
|
|
247
|
-
existing.updateHandler(value);
|
|
248
|
-
existing.original = value;
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
if (existing.isDelegated) removeDelegatedListener(el, existing.eventName);
|
|
252
|
-
else if (existing.options !== void 0) el.removeEventListener(existing.eventName, existing.handler, existing.options);
|
|
253
|
-
else el.removeEventListener(existing.eventName, existing.handler);
|
|
254
|
-
}
|
|
255
|
-
const options = getEventListenerOptions(eventName, eventCapture);
|
|
256
|
-
const mutableHandler = createMutableWrappedHandler(value, true);
|
|
257
|
-
const trackedHandler = mutableHandler.handler;
|
|
258
|
-
if (options !== void 0) el.addEventListener(eventName, trackedHandler, options);
|
|
259
|
-
else el.addEventListener(eventName, trackedHandler);
|
|
260
|
-
incDevCounter("listenerAdds");
|
|
261
|
-
const listenerEntry = {
|
|
262
|
-
handler: trackedHandler,
|
|
263
|
-
original: value,
|
|
264
|
-
eventName,
|
|
265
|
-
options,
|
|
266
|
-
isDelegated: false,
|
|
267
|
-
updateHandler: mutableHandler?.updateHandler
|
|
268
|
-
};
|
|
269
|
-
if (!elementListeners.has(el)) elementListeners.set(el, /* @__PURE__ */ new Map());
|
|
270
|
-
elementListeners.get(el).set(listenerKey, listenerEntry);
|
|
271
|
-
} else applyScalarPropValue(el, key, value, domVNode.type);
|
|
272
|
-
}
|
|
273
|
-
removeStaleAttributes(el, domVNode, props);
|
|
274
|
-
if (existingListeners && existingListeners.size > 0) if (desiredListenerKeys === null) {
|
|
275
|
-
existingListeners.forEach((entry) => {
|
|
276
|
-
incDevCounter("listenerRemoves");
|
|
277
|
-
if (entry.isDelegated) removeDelegatedListener(el, entry.eventName);
|
|
278
|
-
else if (entry.options !== void 0) el.removeEventListener(entry.eventName, entry.handler, entry.options);
|
|
279
|
-
else el.removeEventListener(entry.eventName, entry.handler);
|
|
280
|
-
});
|
|
281
|
-
elementListeners.delete(el);
|
|
282
|
-
} else {
|
|
283
|
-
existingListeners.forEach((entry, listenerKey) => {
|
|
284
|
-
if (!desiredListenerKeys.has(listenerKey)) {
|
|
285
|
-
incDevCounter("listenerRemoves");
|
|
286
|
-
if (entry.isDelegated) removeDelegatedListener(el, entry.eventName);
|
|
287
|
-
else if (entry.options !== void 0) el.removeEventListener(entry.eventName, entry.handler, entry.options);
|
|
288
|
-
else el.removeEventListener(entry.eventName, entry.handler);
|
|
289
|
-
existingListeners.delete(listenerKey);
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
if (existingListeners.size === 0) elementListeners.delete(el);
|
|
293
|
-
}
|
|
294
|
-
const delegatedHandlers = getDelegatedHandlersForElement(el);
|
|
295
|
-
if (delegatedHandlers && delegatedHandlers.size > 0) {
|
|
296
|
-
if (desiredDelegatedEventNames === null) for (const eventName of delegatedHandlers.keys()) removeDelegatedListener(el, eventName);
|
|
297
|
-
else for (const eventName of delegatedHandlers.keys()) if (!desiredDelegatedEventNames.has(eventName)) removeDelegatedListener(el, eventName);
|
|
298
|
-
}
|
|
299
|
-
if (existingReactiveProps && existingReactiveProps.size > 0) if (desiredReactivePropNames === null) {
|
|
300
|
-
existingReactiveProps.forEach((entry) => {
|
|
301
|
-
entry.cleanup();
|
|
302
|
-
});
|
|
303
|
-
elementReactivePropsCleanup.delete(el);
|
|
304
|
-
} else {
|
|
305
|
-
existingReactiveProps.forEach((entry, key) => {
|
|
306
|
-
if (!desiredReactivePropNames.has(key)) {
|
|
307
|
-
entry.cleanup();
|
|
308
|
-
existingReactiveProps.delete(key);
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
if (existingReactiveProps.size === 0) elementReactivePropsCleanup.delete(el);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
//#endregion
|
|
315
|
-
export { applyFreshElementBindings, applyMatchingElementBindings, applyPropsToElement, createReactivePropCleanupEntry, hasAnyElementBindingState, hasTrackedElementPropBindings, markReactivePropsDirtySource, syncElementPropBindings };
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { teardownNodeSubtree } from "./cleanup.js";
|
|
2
|
-
import { getRangeNodes } from "./dom-range.js";
|
|
3
|
-
import { createElementForNamespace, getParentNamespace } from "./namespaces.js";
|
|
4
|
-
import { collectReactiveChildBoundaryVNodes, isSingleRootReactiveChildBoundaryValue } from "./reactive-child-sources.js";
|
|
5
|
-
import { syncControlBoundaryScopeDom } from "./boundary-range-sync.js";
|
|
6
|
-
import "./boundaries.js";
|
|
7
|
-
//#region src/renderer/reactive-child-dom.ts
|
|
8
|
-
function materializeReactiveChildBoundaryNodes(value, parentNamespace, host) {
|
|
9
|
-
const nodes = [];
|
|
10
|
-
const dom = host.createDOMNode(value, parentNamespace);
|
|
11
|
-
if (!dom) return nodes;
|
|
12
|
-
if (dom instanceof DocumentFragment) {
|
|
13
|
-
for (let child = dom.firstChild; child; child = dom.firstChild) {
|
|
14
|
-
nodes.push(child);
|
|
15
|
-
dom.removeChild(child);
|
|
16
|
-
}
|
|
17
|
-
return nodes;
|
|
18
|
-
}
|
|
19
|
-
nodes.push(dom);
|
|
20
|
-
return nodes;
|
|
21
|
-
}
|
|
22
|
-
function createReactiveChildBoundaryHost(el) {
|
|
23
|
-
const ownerDocument = el.ownerDocument;
|
|
24
|
-
const parentNamespace = getParentNamespace(el);
|
|
25
|
-
return parentNamespace === "http://www.w3.org/2000/svg" ? createElementForNamespace("g", parentNamespace, ownerDocument) : createElementForNamespace("div", parentNamespace, ownerDocument);
|
|
26
|
-
}
|
|
27
|
-
function disposeReactiveChildBoundaryNodes(nodes) {
|
|
28
|
-
for (const node of nodes) {
|
|
29
|
-
if (node.parentNode) node.parentNode.removeChild(node);
|
|
30
|
-
teardownNodeSubtree(node);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function syncReactiveChildExpectedNodes(el, expectedNodes) {
|
|
34
|
-
const expectedNodeSet = new Set(expectedNodes);
|
|
35
|
-
for (let node = el.firstChild; node;) {
|
|
36
|
-
const next = node.nextSibling;
|
|
37
|
-
if (!expectedNodeSet.has(node)) {
|
|
38
|
-
teardownNodeSubtree(node);
|
|
39
|
-
el.removeChild(node);
|
|
40
|
-
}
|
|
41
|
-
node = next;
|
|
42
|
-
}
|
|
43
|
-
let anchor = el.firstChild;
|
|
44
|
-
for (const node of expectedNodes) {
|
|
45
|
-
if (node === anchor) {
|
|
46
|
-
anchor = anchor.nextSibling;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
el.insertBefore(node, anchor);
|
|
50
|
-
anchor = node.nextSibling;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function commitReactiveChildBoundaryEntryNodes(el, entry, host) {
|
|
54
|
-
if (!entry.scope.needsDomUpdate) return entry.nodes;
|
|
55
|
-
if (entry.scope.vnode === null || entry.scope.vnode === void 0 || entry.scope.vnode === false) {
|
|
56
|
-
if (entry.nodes.length > 0) {
|
|
57
|
-
disposeReactiveChildBoundaryNodes(entry.nodes);
|
|
58
|
-
entry.nodes = [];
|
|
59
|
-
}
|
|
60
|
-
const dom = entry.scope.dom;
|
|
61
|
-
if (dom?.parentNode === el) {
|
|
62
|
-
teardownNodeSubtree(dom);
|
|
63
|
-
el.removeChild(dom);
|
|
64
|
-
}
|
|
65
|
-
entry.scope.dom = void 0;
|
|
66
|
-
entry.scope.needsDomUpdate = false;
|
|
67
|
-
return entry.nodes;
|
|
68
|
-
}
|
|
69
|
-
if (!isSingleRootReactiveChildBoundaryValue(entry.scope.vnode)) {
|
|
70
|
-
const nextChildren = [];
|
|
71
|
-
collectReactiveChildBoundaryVNodes(entry.scope.vnode, nextChildren);
|
|
72
|
-
const boundaryHost = createReactiveChildBoundaryHost(el);
|
|
73
|
-
for (const node of entry.nodes) boundaryHost.appendChild(node);
|
|
74
|
-
host.updateElementChildren(boundaryHost, nextChildren);
|
|
75
|
-
const nextNodes = Array.from(boundaryHost.childNodes);
|
|
76
|
-
entry.scope.dom = void 0;
|
|
77
|
-
entry.scope.range = void 0;
|
|
78
|
-
entry.scope.needsDomUpdate = false;
|
|
79
|
-
entry.nodes = nextNodes;
|
|
80
|
-
return nextNodes;
|
|
81
|
-
}
|
|
82
|
-
if (entry.nodes.length > 1) {
|
|
83
|
-
disposeReactiveChildBoundaryNodes(entry.nodes);
|
|
84
|
-
entry.nodes = [];
|
|
85
|
-
entry.scope.dom = void 0;
|
|
86
|
-
entry.scope.range = void 0;
|
|
87
|
-
}
|
|
88
|
-
const nextDom = syncControlBoundaryScopeDom(el, entry.scope, entry.scope.vnode ?? null);
|
|
89
|
-
if (!nextDom) {
|
|
90
|
-
entry.nodes = [];
|
|
91
|
-
entry.scope.needsDomUpdate = false;
|
|
92
|
-
return entry.nodes;
|
|
93
|
-
}
|
|
94
|
-
entry.nodes = nextDom.single ? [nextDom.start] : [
|
|
95
|
-
nextDom.start,
|
|
96
|
-
...getRangeNodes(nextDom),
|
|
97
|
-
nextDom.end
|
|
98
|
-
];
|
|
99
|
-
entry.scope.needsDomUpdate = false;
|
|
100
|
-
return entry.nodes;
|
|
101
|
-
}
|
|
102
|
-
function syncReactiveChildSequenceNodes(el, entries, host) {
|
|
103
|
-
const expectedNodes = [];
|
|
104
|
-
for (const entry of entries) {
|
|
105
|
-
if (entry.kind === "static") {
|
|
106
|
-
expectedNodes.push(...entry.nodes);
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
expectedNodes.push(...commitReactiveChildBoundaryEntryNodes(el, entry, host));
|
|
110
|
-
}
|
|
111
|
-
syncReactiveChildExpectedNodes(el, expectedNodes);
|
|
112
|
-
}
|
|
113
|
-
function syncReactiveScalarTextNodes(el, slotValues, values, host) {
|
|
114
|
-
const childNodes = el.childNodes;
|
|
115
|
-
if (childNodes.length === values.length) {
|
|
116
|
-
let allText = true;
|
|
117
|
-
for (let index = 0; index < childNodes.length; index += 1) if (childNodes[index]?.nodeType !== Node.TEXT_NODE) {
|
|
118
|
-
allText = false;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
if (allText) {
|
|
122
|
-
for (let index = 0; index < values.length; index += 1) {
|
|
123
|
-
const textNode = childNodes[index];
|
|
124
|
-
if (textNode.data !== values[index]) textNode.data = values[index];
|
|
125
|
-
}
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const boundaryHost = createReactiveChildBoundaryHost(el);
|
|
130
|
-
for (let node = el.firstChild; node;) {
|
|
131
|
-
const next = node.nextSibling;
|
|
132
|
-
boundaryHost.appendChild(node);
|
|
133
|
-
node = next;
|
|
134
|
-
}
|
|
135
|
-
host.updateElementChildren(boundaryHost, slotValues);
|
|
136
|
-
syncReactiveChildExpectedNodes(el, Array.from(boundaryHost.childNodes));
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
export { commitReactiveChildBoundaryEntryNodes, createReactiveChildBoundaryHost, disposeReactiveChildBoundaryNodes, materializeReactiveChildBoundaryNodes, syncReactiveChildExpectedNodes, syncReactiveChildSequenceNodes, syncReactiveScalarTextNodes };
|