@askrjs/askr 0.0.28 → 0.0.30
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 +44 -172
- package/dist/_virtual/_rolldown/runtime.js +7 -0
- package/dist/bench/components/benchmark-row.d.ts +20 -0
- package/dist/bench/components/benchmark-row.d.ts.map +1 -0
- package/dist/bench/components/benchmark-row.js +42 -0
- package/dist/bench/components/benchmark-row.js.map +1 -0
- package/dist/bench/components/benchmark-table.js +25 -0
- package/dist/bench/components/benchmark-table.js.map +1 -0
- package/dist/benchmark.d.ts +22 -0
- package/dist/benchmark.d.ts.map +1 -0
- package/dist/benchmark.js +64 -1
- package/dist/benchmark.js.map +1 -0
- package/dist/bin/askr-ssg.d.ts +22 -26
- package/dist/bin/askr-ssg.d.ts.map +1 -1
- package/dist/bin/askr-ssg.js +149 -2
- package/dist/bin/askr-ssg.js.map +1 -0
- package/dist/boot/index.d.ts +64 -42
- package/dist/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +416 -2
- package/dist/boot/index.js.map +1 -0
- package/dist/common/component.d.ts +14 -13
- package/dist/common/component.d.ts.map +1 -1
- package/dist/common/control.d.ts +13 -0
- package/dist/common/control.d.ts.map +1 -0
- package/dist/common/control.js +14 -0
- package/dist/common/control.js.map +1 -0
- package/dist/common/env.js +47 -0
- package/dist/common/env.js.map +1 -0
- package/dist/common/jsx.d.ts +17 -15
- package/dist/common/jsx.d.ts.map +1 -1
- package/dist/common/jsx.js +8 -1
- package/dist/common/jsx.js.map +1 -0
- package/dist/common/props.d.ts +14 -11
- package/dist/common/props.d.ts.map +1 -1
- package/dist/common/router.d.ts +190 -32
- package/dist/common/router.d.ts.map +1 -1
- package/dist/common/ssr-errors.d.ts +6 -3
- package/dist/common/ssr-errors.d.ts.map +1 -1
- package/dist/common/ssr-errors.js +16 -1
- package/dist/common/ssr-errors.js.map +1 -0
- package/dist/common/ssr.d.ts +12 -9
- package/dist/common/ssr.d.ts.map +1 -1
- package/dist/common/vnode.d.ts +17 -15
- package/dist/common/vnode.d.ts.map +1 -1
- package/dist/common/vnode.js +10 -1
- package/dist/common/vnode.js.map +1 -0
- package/dist/components/link.d.ts +37 -25
- package/dist/components/link.d.ts.map +1 -1
- package/dist/components/link.js +64 -1
- package/dist/components/link.js.map +1 -0
- package/dist/control/case.d.ts +17 -0
- package/dist/control/case.d.ts.map +1 -0
- package/dist/control/case.js +69 -0
- package/dist/control/case.js.map +1 -0
- package/dist/control/for.d.ts +23 -0
- package/dist/control/for.d.ts.map +1 -0
- package/dist/control/for.js +62 -0
- package/dist/control/for.js.map +1 -0
- package/dist/control/index.d.ts +4 -0
- package/dist/control/index.js +4 -0
- package/dist/control/shared.js +20 -0
- package/dist/control/shared.js.map +1 -0
- package/dist/control/show.d.ts +14 -0
- package/dist/control/show.d.ts.map +1 -0
- package/dist/control/show.js +33 -0
- package/dist/control/show.js.map +1 -0
- package/dist/dev/invariant.js +29 -2
- package/dist/dev/invariant.js.map +1 -0
- package/dist/dev/logger.js +37 -1
- package/dist/dev/logger.js.map +1 -0
- package/dist/foundations/core.d.ts +15 -23
- package/dist/foundations/core.js +13 -1
- package/dist/foundations/icon/icon.d.ts +53 -0
- package/dist/foundations/icon/icon.d.ts.map +1 -0
- package/dist/foundations/icon/icon.js +88 -0
- package/dist/foundations/icon/icon.js.map +1 -0
- package/dist/foundations/icon/icon.types.d.ts +21 -0
- package/dist/foundations/icon/icon.types.d.ts.map +1 -0
- package/dist/foundations/index.d.ts +23 -3
- package/dist/foundations/index.js +22 -1
- package/dist/foundations/interactions/dismissable.d.ts +25 -17
- package/dist/foundations/interactions/dismissable.d.ts.map +1 -1
- package/dist/foundations/interactions/dismissable.js +26 -1
- package/dist/foundations/interactions/dismissable.js.map +1 -0
- package/dist/foundations/interactions/focusable.d.ts +13 -7
- package/dist/foundations/interactions/focusable.d.ts.map +1 -1
- package/dist/foundations/interactions/focusable.js +18 -1
- package/dist/foundations/interactions/focusable.js.map +1 -0
- package/dist/foundations/interactions/hoverable.d.ts +17 -10
- package/dist/foundations/interactions/hoverable.d.ts.map +1 -1
- package/dist/foundations/interactions/hoverable.js +15 -1
- package/dist/foundations/interactions/hoverable.js.map +1 -0
- package/dist/foundations/interactions/interaction-policy.d.ts +32 -78
- package/dist/foundations/interactions/interaction-policy.d.ts.map +1 -1
- package/dist/foundations/interactions/interaction-policy.js +122 -1
- package/dist/foundations/interactions/interaction-policy.js.map +1 -0
- package/dist/foundations/interactions/pressable.d.ts +25 -18
- package/dist/foundations/interactions/pressable.d.ts.map +1 -1
- package/dist/foundations/interactions/pressable.js +51 -1
- package/dist/foundations/interactions/pressable.js.map +1 -0
- package/dist/foundations/interactions/roving-focus.d.ts +49 -114
- package/dist/foundations/interactions/roving-focus.d.ts.map +1 -1
- package/dist/foundations/interactions/roving-focus.js +71 -1
- package/dist/foundations/interactions/roving-focus.js.map +1 -0
- package/dist/foundations/state/controllable.d.ts +22 -41
- package/dist/foundations/state/controllable.d.ts.map +1 -1
- package/dist/foundations/state/controllable.js +81 -1
- package/dist/foundations/state/controllable.js.map +1 -0
- package/dist/foundations/structures/collection.d.ts +25 -40
- package/dist/foundations/structures/collection.d.ts.map +1 -1
- package/dist/foundations/structures/collection.js +51 -1
- package/dist/foundations/structures/collection.js.map +1 -0
- package/dist/foundations/structures/layer.d.ts +47 -68
- package/dist/foundations/structures/layer.d.ts.map +1 -1
- package/dist/foundations/structures/layer.js +81 -1
- package/dist/foundations/structures/layer.js.map +1 -0
- package/dist/foundations/structures/layout.d.ts +6 -3
- package/dist/foundations/structures/layout.d.ts.map +1 -1
- package/dist/foundations/structures/layout.js +13 -1
- package/dist/foundations/structures/layout.js.map +1 -0
- package/dist/foundations/structures/portal.d.ts +17 -10
- package/dist/foundations/structures/portal.d.ts.map +1 -1
- package/dist/foundations/structures/portal.js +105 -1
- package/dist/foundations/structures/portal.js.map +1 -0
- package/dist/foundations/structures/presence.d.ts +11 -5
- package/dist/foundations/structures/presence.d.ts.map +1 -1
- package/dist/foundations/structures/presence.js +39 -1
- package/dist/foundations/structures/presence.js.map +1 -0
- package/dist/foundations/structures/slot.d.ts +11 -8
- package/dist/foundations/structures/slot.d.ts.map +1 -1
- package/dist/foundations/structures/slot.js +41 -1
- package/dist/foundations/structures/slot.js.map +1 -0
- package/dist/foundations/structures.d.ts +7 -14
- package/dist/foundations/structures.js +6 -1
- package/dist/foundations/utilities/aria.d.ts +9 -6
- package/dist/foundations/utilities/aria.d.ts.map +1 -1
- package/dist/foundations/utilities/aria.js +17 -1
- package/dist/foundations/utilities/aria.js.map +1 -0
- package/dist/foundations/utilities/compose-handlers.d.ts +10 -7
- package/dist/foundations/utilities/compose-handlers.d.ts.map +1 -1
- package/dist/foundations/utilities/compose-handlers.js +20 -1
- package/dist/foundations/utilities/compose-handlers.js.map +1 -0
- package/dist/foundations/utilities/compose-ref.d.ts +7 -4
- package/dist/foundations/utilities/compose-ref.d.ts.map +1 -1
- package/dist/foundations/utilities/compose-ref.js +18 -1
- package/dist/foundations/utilities/compose-ref.js.map +1 -0
- package/dist/foundations/utilities/event-types.d.ts +14 -11
- package/dist/foundations/utilities/event-types.d.ts.map +1 -1
- package/dist/foundations/utilities/merge-props.d.ts +4 -1
- package/dist/foundations/utilities/merge-props.d.ts.map +1 -1
- package/dist/foundations/utilities/merge-props.js +49 -1
- package/dist/foundations/utilities/merge-props.js.map +1 -0
- package/dist/foundations/utilities/use-id.d.ts +9 -6
- package/dist/foundations/utilities/use-id.d.ts.map +1 -1
- package/dist/foundations/utilities/use-id.js +29 -1
- package/dist/foundations/utilities/use-id.js.map +1 -0
- package/dist/fx/fx.d.ts +24 -21
- package/dist/fx/fx.d.ts.map +1 -1
- package/dist/fx/fx.js +212 -1
- package/dist/fx/fx.js.map +1 -0
- package/dist/fx/index.d.ts +4 -7
- package/dist/fx/index.js +4 -1
- package/dist/fx/noop.js +9 -1
- package/dist/fx/noop.js.map +1 -0
- package/dist/fx/timing.d.ts +24 -21
- package/dist/fx/timing.d.ts.map +1 -1
- package/dist/fx/timing.js +236 -1
- package/dist/fx/timing.js.map +1 -0
- package/dist/index.d.ts +21 -23
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -0
- package/dist/jsx/index.d.ts +1 -4
- package/dist/jsx/index.js +3 -1
- package/dist/jsx/types.d.ts +18 -25
- package/dist/jsx/types.d.ts.map +1 -1
- package/dist/jsx/types.js +1 -1
- package/dist/jsx/utils.d.ts +4 -3
- package/dist/jsx/utils.d.ts.map +1 -1
- package/dist/jsx/utils.js +19 -1
- package/dist/jsx/utils.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +8 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +32 -1
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +12 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +45 -1
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx-runtime2.d.ts +2 -0
- package/dist/jsx-runtime2.js +3 -0
- package/dist/renderer/children.js +293 -0
- package/dist/renderer/children.js.map +1 -0
- package/dist/renderer/cleanup.js +150 -1
- package/dist/renderer/cleanup.js.map +1 -0
- package/dist/renderer/dom.js +2439 -1
- package/dist/renderer/dom.js.map +1 -0
- package/dist/renderer/env.js +1 -0
- package/dist/renderer/evaluate.js +450 -1
- package/dist/renderer/evaluate.js.map +1 -0
- package/dist/renderer/fastpath.js +145 -1
- package/dist/renderer/fastpath.js.map +1 -0
- package/dist/renderer/index.js +24 -1
- package/dist/renderer/index.js.map +1 -0
- package/dist/renderer/keyed.js +119 -1
- package/dist/renderer/keyed.js.map +1 -0
- package/dist/renderer/reconcile.js +359 -1
- package/dist/renderer/reconcile.js.map +1 -0
- package/dist/renderer/types.js +1 -1
- package/dist/renderer/utils.js +220 -1
- package/dist/renderer/utils.js.map +1 -0
- package/dist/resources/index.d.ts +3 -9
- package/dist/resources/index.js +3 -1
- package/dist/router/index.d.ts +6 -10
- package/dist/router/index.js +5 -1
- package/dist/router/match.js +83 -1
- package/dist/router/match.js.map +1 -0
- package/dist/router/navigate.d.ts +20 -8
- package/dist/router/navigate.d.ts.map +1 -1
- package/dist/router/navigate.js +288 -1
- package/dist/router/navigate.js.map +1 -0
- package/dist/router/policy.d.ts +22 -0
- package/dist/router/policy.d.ts.map +1 -0
- package/dist/router/policy.js +116 -0
- package/dist/router/policy.js.map +1 -0
- package/dist/router/route-context.js +79 -0
- package/dist/router/route-context.js.map +1 -0
- package/dist/router/route.d.ts +101 -34
- package/dist/router/route.d.ts.map +1 -1
- package/dist/router/route.js +599 -1
- package/dist/router/route.js.map +1 -0
- package/dist/runtime/child-scope.d.ts +21 -0
- package/dist/runtime/child-scope.d.ts.map +1 -0
- package/dist/runtime/child-scope.js +77 -0
- package/dist/runtime/child-scope.js.map +1 -0
- package/dist/runtime/component.d.ts +67 -56
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/component.js +462 -1
- package/dist/runtime/component.js.map +1 -0
- package/dist/runtime/context.d.ts +28 -42
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/context.js +205 -1
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/control.d.ts +43 -0
- package/dist/runtime/control.d.ts.map +1 -0
- package/dist/runtime/control.js +125 -0
- package/dist/runtime/control.js.map +1 -0
- package/dist/runtime/derive.d.ts +12 -9
- package/dist/runtime/derive.d.ts.map +1 -1
- package/dist/runtime/derive.js +134 -1
- package/dist/runtime/derive.js.map +1 -0
- package/dist/runtime/dev-namespace.js +57 -1
- package/dist/runtime/dev-namespace.js.map +1 -0
- package/dist/runtime/effect.d.ts +32 -0
- package/dist/runtime/effect.d.ts.map +1 -0
- package/dist/runtime/effect.js +146 -0
- package/dist/runtime/effect.js.map +1 -0
- package/dist/runtime/events.js +162 -1
- package/dist/runtime/events.js.map +1 -0
- package/dist/runtime/execution-model.js +15 -1
- package/dist/runtime/execution-model.js.map +1 -0
- package/dist/runtime/fastlane.js +204 -1
- package/dist/runtime/fastlane.js.map +1 -0
- package/dist/runtime/for-bench.d.ts +41 -0
- package/dist/runtime/for-bench.d.ts.map +1 -0
- package/dist/runtime/for-bench.js +173 -0
- package/dist/runtime/for-bench.js.map +1 -0
- package/dist/runtime/for.d.ts +62 -49
- package/dist/runtime/for.d.ts.map +1 -1
- package/dist/runtime/for.js +668 -1
- package/dist/runtime/for.js.map +1 -0
- package/dist/runtime/operations.d.ts +18 -15
- package/dist/runtime/operations.d.ts.map +1 -1
- package/dist/runtime/operations.js +209 -1
- package/dist/runtime/operations.js.map +1 -0
- package/dist/runtime/perf-metrics.js +64 -1
- package/dist/runtime/perf-metrics.js.map +1 -0
- package/dist/runtime/readable.d.ts +24 -18
- package/dist/runtime/readable.d.ts.map +1 -1
- package/dist/runtime/readable.js +118 -1
- package/dist/runtime/readable.js.map +1 -0
- package/dist/runtime/resource-cell.js +102 -1
- package/dist/runtime/resource-cell.js.map +1 -0
- package/dist/runtime/scheduler.d.ts +51 -50
- package/dist/runtime/scheduler.d.ts.map +1 -1
- package/dist/runtime/scheduler.js +328 -1
- package/dist/runtime/scheduler.js.map +1 -0
- package/dist/runtime/selector.d.ts +7 -5
- package/dist/runtime/selector.d.ts.map +1 -1
- package/dist/runtime/selector.js +188 -1
- package/dist/runtime/selector.js.map +1 -0
- package/dist/runtime/ssr-bridge.js +24 -1
- package/dist/runtime/ssr-bridge.js.map +1 -0
- package/dist/runtime/state.d.ts +11 -19
- package/dist/runtime/state.d.ts.map +1 -1
- package/dist/runtime/state.js +99 -1
- package/dist/runtime/state.js.map +1 -0
- package/dist/ssg/batch-render.d.ts +10 -10
- package/dist/ssg/batch-render.d.ts.map +1 -1
- package/dist/ssg/batch-render.js +84 -1
- package/dist/ssg/batch-render.js.map +1 -0
- package/dist/ssg/create-static-gen.d.ts +28 -29
- package/dist/ssg/create-static-gen.d.ts.map +1 -1
- package/dist/ssg/create-static-gen.js +282 -1
- package/dist/ssg/create-static-gen.js.map +1 -0
- package/dist/ssg/generate-metadata.d.ts +12 -15
- package/dist/ssg/generate-metadata.d.ts.map +1 -1
- package/dist/ssg/generate-metadata.js +94 -1
- package/dist/ssg/generate-metadata.js.map +1 -0
- package/dist/ssg/incremental-manifest.js +56 -1
- package/dist/ssg/incremental-manifest.js.map +1 -0
- package/dist/ssg/index.d.ts +8 -28
- package/dist/ssg/index.js +7 -1
- package/dist/ssg/resolve-ssg-data.d.ts +10 -13
- package/dist/ssg/resolve-ssg-data.d.ts.map +1 -1
- package/dist/ssg/resolve-ssg-data.js +46 -1
- package/dist/ssg/resolve-ssg-data.js.map +1 -0
- package/dist/ssg/route-utils.d.ts +14 -10
- package/dist/ssg/route-utils.d.ts.map +1 -1
- package/dist/ssg/route-utils.js +24 -1
- package/dist/ssg/route-utils.js.map +1 -0
- package/dist/ssg/types.d.ts +157 -144
- package/dist/ssg/types.d.ts.map +1 -1
- package/dist/ssg/write-static-files.d.ts +8 -14
- package/dist/ssg/write-static-files.d.ts.map +1 -1
- package/dist/ssg/write-static-files.js +73 -1
- package/dist/ssg/write-static-files.js.map +1 -0
- package/dist/ssr/attrs.js +93 -1
- package/dist/ssr/attrs.js.map +1 -0
- package/dist/ssr/context.d.ts +31 -35
- package/dist/ssr/context.d.ts.map +1 -1
- package/dist/ssr/context.js +63 -1
- package/dist/ssr/context.js.map +1 -0
- package/dist/ssr/errors.d.ts +6 -4
- package/dist/ssr/errors.d.ts.map +1 -1
- package/dist/ssr/errors.js +4 -1
- package/dist/ssr/errors.js.map +1 -0
- package/dist/ssr/escape.js +153 -1
- package/dist/ssr/escape.js.map +1 -0
- package/dist/ssr/index.d.ts +74 -72
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +543 -1
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/render-keys.d.ts +27 -29
- package/dist/ssr/render-keys.d.ts.map +1 -1
- package/dist/ssr/render-keys.js +39 -1
- package/dist/ssr/render-keys.js.map +1 -0
- package/dist/ssr/sink.js +86 -1
- package/dist/ssr/sink.js.map +1 -0
- package/dist/ssr/stream-render.js +76 -1
- package/dist/ssr/stream-render.js.map +1 -0
- package/dist/ssr/types.d.ts +14 -13
- package/dist/ssr/types.d.ts.map +1 -1
- package/package.json +49 -69
- package/dist/_virtual/___vite-browser-external.js +0 -1
- package/dist/_virtual/__vite-browser-external.js +0 -1
- package/dist/_virtual/_commonjsHelpers.js +0 -1
- package/dist/_virtual/_fs.js +0 -1
- package/dist/_virtual/_path.js +0 -1
- package/dist/_virtual/main.js +0 -1
- package/dist/_virtual/preload-helper.js +0 -1
- package/dist/bench/benchmark-entry.d.ts +0 -14
- package/dist/bench/benchmark-entry.d.ts.map +0 -1
- package/dist/common/errors.d.ts +0 -53
- package/dist/common/errors.d.ts.map +0 -1
- package/dist/common/index.d.ts +0 -14
- package/dist/common/index.d.ts.map +0 -1
- package/dist/dev/invariant.d.ts +0 -83
- package/dist/dev/invariant.d.ts.map +0 -1
- package/dist/dev/logger.d.ts +0 -13
- package/dist/dev/logger.d.ts.map +0 -1
- package/dist/dev/vite-plugin-askr.d.ts +0 -25
- package/dist/dev/vite-plugin-askr.d.ts.map +0 -1
- package/dist/dev/warnings.d.ts +0 -5
- package/dist/dev/warnings.d.ts.map +0 -1
- package/dist/for/for.d.ts +0 -16
- package/dist/for/for.d.ts.map +0 -1
- package/dist/for/for.js +0 -1
- package/dist/for/index.d.ts +0 -2
- package/dist/for/index.d.ts.map +0 -1
- package/dist/for/index.js +0 -1
- package/dist/foundations/core.d.ts.map +0 -1
- package/dist/foundations/index.d.ts.map +0 -1
- package/dist/foundations/interactions/index.d.ts +0 -5
- package/dist/foundations/interactions/index.d.ts.map +0 -1
- package/dist/foundations/state/index.d.ts +0 -2
- package/dist/foundations/state/index.d.ts.map +0 -1
- package/dist/foundations/structures/index.d.ts +0 -5
- package/dist/foundations/structures/index.d.ts.map +0 -1
- package/dist/foundations/structures.d.ts.map +0 -1
- package/dist/foundations/utilities/index.d.ts +0 -7
- package/dist/foundations/utilities/index.d.ts.map +0 -1
- package/dist/fx/index.d.ts.map +0 -1
- package/dist/fx/noop.d.ts +0 -12
- package/dist/fx/noop.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/jsx/index.d.ts.map +0 -1
- package/dist/jsx/jsx-dev-runtime.d.ts +0 -4
- package/dist/jsx/jsx-dev-runtime.d.ts.map +0 -1
- package/dist/jsx/jsx-runtime.d.ts +0 -10
- package/dist/jsx/jsx-runtime.d.ts.map +0 -1
- package/dist/node_modules/esbuild/lib/main.js +0 -65
- package/dist/renderer/cleanup.d.ts +0 -28
- package/dist/renderer/cleanup.d.ts.map +0 -1
- package/dist/renderer/dom.d.ts +0 -64
- package/dist/renderer/dom.d.ts.map +0 -1
- package/dist/renderer/evaluate.d.ts +0 -4
- package/dist/renderer/evaluate.d.ts.map +0 -1
- package/dist/renderer/fastpath.d.ts +0 -7
- package/dist/renderer/fastpath.d.ts.map +0 -1
- package/dist/renderer/index.d.ts +0 -6
- package/dist/renderer/index.d.ts.map +0 -1
- package/dist/renderer/keyed.d.ts +0 -23
- package/dist/renderer/keyed.d.ts.map +0 -1
- package/dist/renderer/reconcile.d.ts +0 -88
- package/dist/renderer/reconcile.d.ts.map +0 -1
- package/dist/renderer/types.d.ts +0 -3
- package/dist/renderer/types.d.ts.map +0 -1
- package/dist/renderer/utils.d.ts +0 -63
- package/dist/renderer/utils.d.ts.map +0 -1
- package/dist/resources/index.d.ts.map +0 -1
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/match.d.ts +0 -22
- package/dist/router/match.d.ts.map +0 -1
- package/dist/runtime/dev-namespace.d.ts +0 -31
- package/dist/runtime/dev-namespace.d.ts.map +0 -1
- package/dist/runtime/events.d.ts +0 -53
- package/dist/runtime/events.d.ts.map +0 -1
- package/dist/runtime/execution-model.d.ts +0 -4
- package/dist/runtime/execution-model.d.ts.map +0 -1
- package/dist/runtime/fastlane.d.ts +0 -27
- package/dist/runtime/fastlane.d.ts.map +0 -1
- package/dist/runtime/hydration.d.ts +0 -25
- package/dist/runtime/hydration.d.ts.map +0 -1
- package/dist/runtime/perf-metrics.d.ts +0 -25
- package/dist/runtime/perf-metrics.d.ts.map +0 -1
- package/dist/runtime/resource-cell.d.ts +0 -35
- package/dist/runtime/resource-cell.d.ts.map +0 -1
- package/dist/runtime/snapshot.d.ts +0 -25
- package/dist/runtime/snapshot.d.ts.map +0 -1
- package/dist/runtime/ssr-bridge.d.ts +0 -10
- package/dist/runtime/ssr-bridge.d.ts.map +0 -1
- package/dist/ssg/discover-resources.d.ts +0 -15
- package/dist/ssg/discover-resources.d.ts.map +0 -1
- package/dist/ssg/incremental-manifest.d.ts +0 -23
- package/dist/ssg/incremental-manifest.d.ts.map +0 -1
- package/dist/ssg/index.d.ts.map +0 -1
- package/dist/ssr/attrs.d.ts +0 -26
- package/dist/ssr/attrs.d.ts.map +0 -1
- package/dist/ssr/create-ssr.d.ts +0 -19
- package/dist/ssr/create-ssr.d.ts.map +0 -1
- package/dist/ssr/escape.d.ts +0 -38
- package/dist/ssr/escape.d.ts.map +0 -1
- package/dist/ssr/sink.d.ts +0 -23
- package/dist/ssr/sink.d.ts.map +0 -1
- package/dist/ssr/stream-render.d.ts +0 -7
- package/dist/ssr/stream-render.d.ts.map +0 -1
- package/dist/vite/index.js +0 -4
|
@@ -1 +1,359 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getRuntimeEnv } from "../common/env.js";
|
|
2
|
+
import "./env.js";
|
|
3
|
+
import { checkPropChanges, extractKey, recordDOMReplace, recordFastPathStats, tagNamesEqualIgnoreCase } from "./utils.js";
|
|
4
|
+
import { isKeyedReorderFastPathEligible, keyedElements } from "./keyed.js";
|
|
5
|
+
import { teardownNodeSubtree } from "./cleanup.js";
|
|
6
|
+
import { applyRendererFastPath } from "./fastpath.js";
|
|
7
|
+
import { performBulkPositionalKeyedTextUpdate } from "./children.js";
|
|
8
|
+
import { createDOMNode, syncComponentElement, updateElementFromVnode } from "./dom.js";
|
|
9
|
+
function reconcileKeyedChildren(parent, newChildren, oldKeyMap) {
|
|
10
|
+
const { keyedVnodes, unkeyedVnodes } = partitionChildren(newChildren);
|
|
11
|
+
const ensuredOldKeyMap = oldKeyMap || buildKeyMapFromDOM(parent);
|
|
12
|
+
const fastPathResult = tryFastPaths(parent, newChildren, keyedVnodes, unkeyedVnodes, ensuredOldKeyMap);
|
|
13
|
+
if (fastPathResult) return fastPathResult;
|
|
14
|
+
return performFullReconciliation(parent, newChildren, keyedVnodes, ensuredOldKeyMap);
|
|
15
|
+
}
|
|
16
|
+
/** Build key map from DOM children */
|
|
17
|
+
function buildKeyMapFromDOM(parent) {
|
|
18
|
+
const keyMap = /* @__PURE__ */ new Map();
|
|
19
|
+
try {
|
|
20
|
+
for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {
|
|
21
|
+
const k = el.getAttribute("data-key");
|
|
22
|
+
if (k !== null) {
|
|
23
|
+
keyMap.set(k, el);
|
|
24
|
+
const n = Number(k);
|
|
25
|
+
if (!Number.isNaN(n)) keyMap.set(n, el);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch {}
|
|
29
|
+
return keyMap;
|
|
30
|
+
}
|
|
31
|
+
/** Partition children into keyed and unkeyed */
|
|
32
|
+
function partitionChildren(newChildren) {
|
|
33
|
+
const keyedVnodes = [];
|
|
34
|
+
const unkeyedVnodes = [];
|
|
35
|
+
for (let i = 0; i < newChildren.length; i++) {
|
|
36
|
+
const child = newChildren[i];
|
|
37
|
+
const key = extractKey(child);
|
|
38
|
+
if (key !== void 0) keyedVnodes.push({
|
|
39
|
+
key,
|
|
40
|
+
vnode: child
|
|
41
|
+
});
|
|
42
|
+
else unkeyedVnodes.push(child);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
keyedVnodes,
|
|
46
|
+
unkeyedVnodes
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Try fast paths before full reconciliation */
|
|
50
|
+
function tryFastPaths(parent, newChildren, keyedVnodes, unkeyedVnodes, oldKeyMap) {
|
|
51
|
+
try {
|
|
52
|
+
const forcedResult = tryForcedPositionalBulkUpdate(parent, newChildren, keyedVnodes);
|
|
53
|
+
if (forcedResult) return forcedResult;
|
|
54
|
+
const rendererResult = tryRendererFastPath(parent, newChildren, keyedVnodes, unkeyedVnodes, oldKeyMap);
|
|
55
|
+
if (rendererResult) return rendererResult;
|
|
56
|
+
const positionalResult = tryPositionalBulkUpdate(parent, keyedVnodes);
|
|
57
|
+
if (positionalResult) return positionalResult;
|
|
58
|
+
} catch {}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
/** Try renderer fast-path */
|
|
62
|
+
function tryRendererFastPath(parent, newChildren, keyedVnodes, unkeyedVnodes, oldKeyMap) {
|
|
63
|
+
const decision = isKeyedReorderFastPathEligible(parent, newChildren, oldKeyMap);
|
|
64
|
+
const isWholeKeyedList = keyedVnodes.length === newChildren.length && unkeyedVnodes.length === 0;
|
|
65
|
+
if (decision.useFastPath && keyedVnodes.length >= 64 && isWholeKeyedList) try {
|
|
66
|
+
const map = applyRendererFastPath(parent, keyedVnodes, oldKeyMap, unkeyedVnodes);
|
|
67
|
+
if (map) {
|
|
68
|
+
keyedElements.set(parent, map);
|
|
69
|
+
return map;
|
|
70
|
+
}
|
|
71
|
+
} catch {}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/** Try the explicit test/bench forced positional keyed path. */
|
|
75
|
+
function tryForcedPositionalBulkUpdate(parent, newChildren, keyedVnodes) {
|
|
76
|
+
if (getRuntimeEnv().ASKR_FORCE_BULK_POSREUSE !== "1") return null;
|
|
77
|
+
if (keyedVnodes.length === 0 || keyedVnodes.length !== newChildren.length) return null;
|
|
78
|
+
try {
|
|
79
|
+
recordFastPathStats(performBulkPositionalKeyedTextUpdate(parent, keyedVnodes), "bulkKeyedPositionalForced");
|
|
80
|
+
rebuildKeyedMap(parent);
|
|
81
|
+
return keyedElements.get(parent);
|
|
82
|
+
} catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Try positional bulk update for medium-sized lists */
|
|
87
|
+
function tryPositionalBulkUpdate(parent, keyedVnodes) {
|
|
88
|
+
const total = keyedVnodes.length;
|
|
89
|
+
if (total < 10) return null;
|
|
90
|
+
if (parent.children.length !== total) return null;
|
|
91
|
+
const matchCount = countPositionalMatches(parent, keyedVnodes);
|
|
92
|
+
const matchFraction = matchCount / total;
|
|
93
|
+
if (keyedVnodes.length > 0) {
|
|
94
|
+
if (matchCount !== total && matchFraction >= .1) return null;
|
|
95
|
+
} else if (matchFraction < .9) return null;
|
|
96
|
+
if (hasPositionalPropChanges(parent, keyedVnodes)) return null;
|
|
97
|
+
try {
|
|
98
|
+
recordFastPathStats(performBulkPositionalKeyedTextUpdate(parent, keyedVnodes), "bulkKeyedPositionalHits");
|
|
99
|
+
rebuildKeyedMap(parent);
|
|
100
|
+
return keyedElements.get(parent);
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Count how many vnodes match parent children by position and tag */
|
|
106
|
+
function countPositionalMatches(parent, keyedVnodes) {
|
|
107
|
+
let matchCount = 0;
|
|
108
|
+
try {
|
|
109
|
+
for (let i = 0; i < keyedVnodes.length; i++) {
|
|
110
|
+
const vnode = keyedVnodes[i].vnode;
|
|
111
|
+
const expectedKey = keyedVnodes[i].key;
|
|
112
|
+
if (!vnode || typeof vnode !== "object" || typeof vnode.type !== "string") continue;
|
|
113
|
+
const el = parent.children[i];
|
|
114
|
+
if (!el) continue;
|
|
115
|
+
if (tagNamesEqualIgnoreCase(el.tagName, vnode.type)) {
|
|
116
|
+
const actualKey = el.getAttribute("data-key");
|
|
117
|
+
if (actualKey === String(expectedKey) || actualKey !== null && !Number.isNaN(Number(actualKey)) && Number(actualKey) === expectedKey) matchCount++;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} catch {}
|
|
121
|
+
return matchCount;
|
|
122
|
+
}
|
|
123
|
+
/** Check if positional prop changes would prevent bulk update */
|
|
124
|
+
function hasPositionalPropChanges(parent, keyedVnodes) {
|
|
125
|
+
try {
|
|
126
|
+
for (let i = 0; i < keyedVnodes.length; i++) {
|
|
127
|
+
const vnode = keyedVnodes[i].vnode;
|
|
128
|
+
const el = parent.children[i];
|
|
129
|
+
if (!el || !vnode || typeof vnode !== "object") continue;
|
|
130
|
+
if (checkPropChanges(el, vnode.props || {})) return true;
|
|
131
|
+
}
|
|
132
|
+
} catch {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
/** Rebuild keyed map from parent children */
|
|
138
|
+
function rebuildKeyedMap(parent) {
|
|
139
|
+
try {
|
|
140
|
+
const map = /* @__PURE__ */ new Map();
|
|
141
|
+
for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {
|
|
142
|
+
const k = el.getAttribute("data-key");
|
|
143
|
+
if (k !== null) {
|
|
144
|
+
map.set(k, el);
|
|
145
|
+
const n = Number(k);
|
|
146
|
+
if (!Number.isNaN(n)) map.set(n, el);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
keyedElements.set(parent, map);
|
|
150
|
+
} catch {}
|
|
151
|
+
}
|
|
152
|
+
/** Perform full reconciliation when fast paths don't apply */
|
|
153
|
+
function performFullReconciliation(parent, newChildren, keyedVnodes, oldKeyMap) {
|
|
154
|
+
const newKeyMap = /* @__PURE__ */ new Map();
|
|
155
|
+
const finalNodes = [];
|
|
156
|
+
const usedOldEls = /* @__PURE__ */ new WeakSet();
|
|
157
|
+
const resolveOldElOnce = createOldElResolver(parent, oldKeyMap, usedOldEls);
|
|
158
|
+
const unkeyedEls = collectUnkeyedElements(parent);
|
|
159
|
+
let unkeyedIndex = 0;
|
|
160
|
+
const resolveUnkeyedOnce = () => {
|
|
161
|
+
while (unkeyedIndex < unkeyedEls.length) {
|
|
162
|
+
const candidate = unkeyedEls[unkeyedIndex++];
|
|
163
|
+
if (!usedOldEls.has(candidate)) return candidate;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
for (let i = 0; i < newChildren.length; i++) {
|
|
167
|
+
const child = newChildren[i];
|
|
168
|
+
const node = reconcileSingleChild(child, i, parent, resolveOldElOnce, resolveUnkeyedOnce, usedOldEls, newKeyMap);
|
|
169
|
+
if (node) finalNodes.push(node);
|
|
170
|
+
}
|
|
171
|
+
if (typeof document === "undefined") return newKeyMap;
|
|
172
|
+
commitReconciliation(parent, finalNodes);
|
|
173
|
+
keyedElements.delete(parent);
|
|
174
|
+
return newKeyMap;
|
|
175
|
+
}
|
|
176
|
+
/** Create resolver for finding old elements by key */
|
|
177
|
+
function createOldElResolver(parent, oldKeyMap, usedOldEls) {
|
|
178
|
+
return (k) => {
|
|
179
|
+
if (!oldKeyMap) return void 0;
|
|
180
|
+
const direct = oldKeyMap.get(k);
|
|
181
|
+
if (direct && !usedOldEls.has(direct)) {
|
|
182
|
+
usedOldEls.add(direct);
|
|
183
|
+
return direct;
|
|
184
|
+
}
|
|
185
|
+
const s = String(k);
|
|
186
|
+
const byString = oldKeyMap.get(s);
|
|
187
|
+
if (byString && !usedOldEls.has(byString)) {
|
|
188
|
+
usedOldEls.add(byString);
|
|
189
|
+
return byString;
|
|
190
|
+
}
|
|
191
|
+
const n = Number(s);
|
|
192
|
+
if (!Number.isNaN(n)) {
|
|
193
|
+
const byNum = oldKeyMap.get(n);
|
|
194
|
+
if (byNum && !usedOldEls.has(byNum)) {
|
|
195
|
+
usedOldEls.add(byNum);
|
|
196
|
+
return byNum;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return scanForElementByKey(parent, k, s, usedOldEls);
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/** Scan parent children for element with matching key */
|
|
203
|
+
function scanForElementByKey(parent, k, keyStr, usedOldEls) {
|
|
204
|
+
try {
|
|
205
|
+
for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {
|
|
206
|
+
if (usedOldEls.has(ch)) continue;
|
|
207
|
+
const attr = ch.getAttribute("data-key");
|
|
208
|
+
if (attr === keyStr) {
|
|
209
|
+
usedOldEls.add(ch);
|
|
210
|
+
return ch;
|
|
211
|
+
}
|
|
212
|
+
if (attr !== null) {
|
|
213
|
+
const numAttr = Number(attr);
|
|
214
|
+
if (!Number.isNaN(numAttr) && numAttr === k) {
|
|
215
|
+
usedOldEls.add(ch);
|
|
216
|
+
return ch;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} catch {}
|
|
221
|
+
}
|
|
222
|
+
/** Reconcile a single child */
|
|
223
|
+
function reconcileSingleChild(child, index, parent, resolveOldElOnce, resolveUnkeyedOnce, usedOldEls, newKeyMap) {
|
|
224
|
+
const key = extractKey(child);
|
|
225
|
+
if (key !== void 0) return reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap);
|
|
226
|
+
return reconcileUnkeyedChild(child, index, parent, resolveUnkeyedOnce, usedOldEls);
|
|
227
|
+
}
|
|
228
|
+
/** Reconcile a keyed child */
|
|
229
|
+
function reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap) {
|
|
230
|
+
const el = resolveOldElOnce(key);
|
|
231
|
+
if (el && el.parentElement === parent) try {
|
|
232
|
+
const childObj = child;
|
|
233
|
+
if (childObj && typeof childObj === "object" && typeof childObj.type === "string") {
|
|
234
|
+
if (tagNamesEqualIgnoreCase(el.tagName, childObj.type)) {
|
|
235
|
+
updateElementFromVnode(el, child);
|
|
236
|
+
newKeyMap.set(key, el);
|
|
237
|
+
return el;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (isComponentVNode(child)) {
|
|
241
|
+
const synced = syncComponentElement(el, child, child.type, (child.props ?? {}) || {});
|
|
242
|
+
if (synced) {
|
|
243
|
+
if (synced instanceof Element) newKeyMap.set(key, synced);
|
|
244
|
+
return synced;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} catch {}
|
|
248
|
+
const dom = createDOMNode(child);
|
|
249
|
+
if (dom) {
|
|
250
|
+
if (dom instanceof Element) newKeyMap.set(key, dom);
|
|
251
|
+
return dom;
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
/** Reconcile an unkeyed or primitive child */
|
|
256
|
+
function reconcileUnkeyedChild(child, index, parent, resolveUnkeyedOnce, usedOldEls) {
|
|
257
|
+
try {
|
|
258
|
+
const existing = parent.childNodes[index];
|
|
259
|
+
if (typeof child === "string" || typeof child === "number") {
|
|
260
|
+
if (existing && existing.nodeType === 3) {
|
|
261
|
+
existing.data = String(child);
|
|
262
|
+
usedOldEls.add(existing);
|
|
263
|
+
return existing;
|
|
264
|
+
}
|
|
265
|
+
return createDOMNode(child);
|
|
266
|
+
}
|
|
267
|
+
if (existing instanceof Element) {
|
|
268
|
+
const synced = trySyncComponentChild(existing, child, usedOldEls);
|
|
269
|
+
if (synced) return synced;
|
|
270
|
+
}
|
|
271
|
+
if (existing instanceof Element && canReuseElement(existing, child)) {
|
|
272
|
+
updateElementFromVnode(existing, child);
|
|
273
|
+
usedOldEls.add(existing);
|
|
274
|
+
return existing;
|
|
275
|
+
}
|
|
276
|
+
const avail = resolveUnkeyedOnce();
|
|
277
|
+
if (avail) {
|
|
278
|
+
const reuseResult = tryReuseElement(avail, child, usedOldEls);
|
|
279
|
+
if (reuseResult) return reuseResult;
|
|
280
|
+
}
|
|
281
|
+
} catch {}
|
|
282
|
+
return createDOMNode(child);
|
|
283
|
+
}
|
|
284
|
+
function isComponentVNode(child) {
|
|
285
|
+
return typeof child === "object" && child !== null && "type" in child && typeof child.type === "function";
|
|
286
|
+
}
|
|
287
|
+
function trySyncComponentChild(existing, child, usedOldEls) {
|
|
288
|
+
if (!isComponentVNode(child)) return null;
|
|
289
|
+
const synced = syncComponentElement(existing, child, child.type, (child.props ?? {}) || {});
|
|
290
|
+
if (!synced) return null;
|
|
291
|
+
usedOldEls.add(existing);
|
|
292
|
+
usedOldEls.add(synced);
|
|
293
|
+
return synced;
|
|
294
|
+
}
|
|
295
|
+
/** Check if existing element can be reused for child */
|
|
296
|
+
function canReuseElement(existing, child) {
|
|
297
|
+
if (!existing) return false;
|
|
298
|
+
if (typeof child !== "object" || child === null || !("type" in child)) return false;
|
|
299
|
+
const childObj = child;
|
|
300
|
+
const existingKey = existing.getAttribute("data-key");
|
|
301
|
+
return (existingKey === null || existingKey === void 0) && typeof childObj.type === "string" && tagNamesEqualIgnoreCase(existing.tagName, childObj.type);
|
|
302
|
+
}
|
|
303
|
+
/** Collect unkeyed element children in DOM order. */
|
|
304
|
+
function collectUnkeyedElements(parent) {
|
|
305
|
+
const elements = [];
|
|
306
|
+
for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) if (ch.getAttribute("data-key") === null) elements.push(ch);
|
|
307
|
+
return elements;
|
|
308
|
+
}
|
|
309
|
+
/** Try to reuse available element for child */
|
|
310
|
+
function tryReuseElement(avail, child, usedOldEls) {
|
|
311
|
+
if (typeof child === "string" || typeof child === "number") return null;
|
|
312
|
+
const synced = trySyncComponentChild(avail, child, usedOldEls);
|
|
313
|
+
if (synced) return synced;
|
|
314
|
+
if (typeof child === "object" && child !== null && "type" in child) {
|
|
315
|
+
const childObj = child;
|
|
316
|
+
if (typeof childObj.type === "string" && tagNamesEqualIgnoreCase(avail.tagName, childObj.type)) {
|
|
317
|
+
updateElementFromVnode(avail, child);
|
|
318
|
+
usedOldEls.add(avail);
|
|
319
|
+
return avail;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
/** Commit reconciliation by replacing parent children */
|
|
325
|
+
function commitReconciliation(parent, finalNodes) {
|
|
326
|
+
try {
|
|
327
|
+
const finalSet = new Set(finalNodes);
|
|
328
|
+
for (let n = parent.firstChild; n;) {
|
|
329
|
+
const next = n.nextSibling;
|
|
330
|
+
if (!finalSet.has(n)) {
|
|
331
|
+
teardownNodeSubtree(n);
|
|
332
|
+
parent.removeChild(n);
|
|
333
|
+
}
|
|
334
|
+
n = next;
|
|
335
|
+
}
|
|
336
|
+
for (let i = 0; i < finalNodes.length; i++) {
|
|
337
|
+
const desiredNode = finalNodes[i];
|
|
338
|
+
const anchor = parent.childNodes[i] ?? null;
|
|
339
|
+
if (desiredNode !== anchor) parent.insertBefore(desiredNode, anchor);
|
|
340
|
+
}
|
|
341
|
+
} catch {
|
|
342
|
+
const fragment = document.createDocumentFragment();
|
|
343
|
+
for (let i = 0; i < finalNodes.length; i++) fragment.appendChild(finalNodes[i]);
|
|
344
|
+
try {
|
|
345
|
+
for (let n = parent.firstChild; n;) {
|
|
346
|
+
const next = n.nextSibling;
|
|
347
|
+
teardownNodeSubtree(n);
|
|
348
|
+
n = next;
|
|
349
|
+
}
|
|
350
|
+
} catch {}
|
|
351
|
+
recordDOMReplace("reconcile");
|
|
352
|
+
parent.replaceChildren(fragment);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
export { reconcileKeyedChildren };
|
|
358
|
+
|
|
359
|
+
//# sourceMappingURL=reconcile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcile.js","names":[],"sources":["../../src/renderer/reconcile.ts"],"sourcesContent":["/**\n * ─────────────────────────────────────────────────────────────────────────────\n * RENDERER & RECONCILIATION INVARIANTS (LOCKED)\n * ─────────────────────────────────────────────────────────────────────────────\n *\n * These invariants are NON-NEGOTIABLE. Any optimization or fast-path MUST\n * preserve them. Violations WILL produce incorrect DOM.\n *\n * 1. DOM ORDER DERIVES ONLY FROM CURRENT VNODE ORDER\n * --------------------------------------------------\n * - Final DOM child order MUST be reconstructed from the current vnode list.\n * - Reusing an existing DOM node does NOT imply it stays in the same position.\n * - Appending an existing Node to a DocumentFragment is the ONLY valid way\n * to express reordering (it moves the node).\n *\n * ❌ NEVER skip fragment insertion because a node already has a parent.\n * ✅ ALWAYS append reused nodes into the fragment to establish order.\n *\n *\n * 2. VNODE IDENTITY ≠ VNODE STABILITY\n * ----------------------------------\n * - VNodes are mutable.\n * - `vnodeA === vnodeB` does NOT imply semantic equality.\n * - DOM reuse MUST NOT be gated on vnode identity alone.\n *\n * DOM reuse is allowed ONLY when:\n * - element type is unchanged\n * - structural shape is compatible\n * - updates are applied explicitly via updateElementFromVnode\n *\n * ❌ NEVER assume \"same object\" means \"no changes\".\n *\n *\n * 3. KEYED RECONCILIATION IS ELEMENT-ONLY\n * --------------------------------------\n * - Keyed reconciliation assumes ELEMENT nodes, not Text or Comment nodes.\n * - Any fast-path using `parent.children[i]` MUST prove:\n * - all children are elements\n * - no text nodes are present\n *\n * ❌ NEVER index `parent.children` when text nodes may exist.\n * ✅ Use `parent.childNodes` or bail out to full reconciliation.\n *\n *\n * 4. PRIMITIVES MAP TO TEXT NODES\n * -------------------------------\n * - string/number children represent Text nodes, not Elements.\n * - Reconciliation MUST attempt Text-to-Text reuse before replacement.\n *\n * ❌ NEVER update element.textContent as a substitute for text reconciliation\n * unless the shape is explicitly guaranteed.\n *\n *\n * 5. FAST-PATHS MUST BE STRICTLY SAFE\n * ----------------------------------\n * - Fast-paths are OPTIONAL.\n * - Correctness always beats performance.\n *\n * A fast-path MUST:\n * - prove its eligibility\n * - fall back cleanly on ANY ambiguity\n * - never partially apply\n *\n *\n * 6. CLEANUP IS POSITION-INDEPENDENT\n * ---------------------------------\n * - Cleanup is based on removal from the DOM, not vnode position.\n * - Any node removed or replaced MUST:\n * - remove listeners\n * - cleanup component instances\n *\n *\n * 7. FOR-BOUNDARY & KEYED LISTS OBEY THE SAME RULES\n * ------------------------------------------------\n * - For-boundaries are NOT special in ordering semantics.\n * - Cached DOM nodes MUST still be reordered via fragment insertion.\n * - Cache is an optimization, not an ownership claim.\n *\n *\n * If you are unsure whether an optimization preserves these invariants:\n * DO NOT APPLY IT.\n *\n * ─────────────────────────────────────────────────────────────────────────────\n */\n\nimport type { DOMElement, VNode } from './types';\nimport {\n createDOMNode,\n syncComponentElement,\n updateElementFromVnode,\n performBulkPositionalKeyedTextUpdate,\n} from './dom';\nimport type { Props } from '../common/props';\nimport {\n keyedElements,\n _reconcilerRecordedParents,\n isKeyedReorderFastPathEligible,\n} from './keyed';\nimport { teardownNodeSubtree } from './cleanup';\nimport { applyRendererFastPath } from './fastpath';\nimport { getRuntimeEnv } from './env';\nimport {\n extractKey,\n checkPropChanges,\n recordFastPathStats,\n recordDOMReplace,\n tagNamesEqualIgnoreCase,\n} from './utils';\n\nexport const IS_DOM_AVAILABLE = typeof document !== 'undefined';\n\n// Helper type for narrowings\ntype VnodeObj = VNode & { type?: unknown; props?: Record<string, unknown> };\ntype ComponentVNode = DOMElement & { type: (props: Props) => unknown };\n\nexport function reconcileKeyedChildren(\n parent: Element,\n newChildren: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> {\n const { keyedVnodes, unkeyedVnodes } = partitionChildren(newChildren);\n\n // Ensure we have a key map before reconciliation to avoid O(n) DOM scans\n // during O(n) reconciliation loop (which would be O(n²))\n const ensuredOldKeyMap = oldKeyMap || buildKeyMapFromDOM(parent);\n\n // Try fast paths first\n const fastPathResult = tryFastPaths(\n parent,\n newChildren,\n keyedVnodes,\n unkeyedVnodes,\n ensuredOldKeyMap\n );\n if (fastPathResult) {\n return fastPathResult;\n }\n\n // Full reconciliation\n return performFullReconciliation(\n parent,\n newChildren,\n keyedVnodes,\n ensuredOldKeyMap\n );\n}\n\n/** Build key map from DOM children */\nfunction buildKeyMapFromDOM(parent: Element): Map<string | number, Element> {\n const keyMap = new Map<string | number, Element>();\n try {\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const k = el.getAttribute('data-key');\n if (k !== null) {\n keyMap.set(k, el);\n const n = Number(k);\n if (!Number.isNaN(n)) keyMap.set(n, el);\n }\n }\n } catch {\n // Ignore\n }\n return keyMap;\n}\n\n/** Partition children into keyed and unkeyed */\nfunction partitionChildren(newChildren: VNode[]): {\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>;\n unkeyedVnodes: VNode[];\n} {\n const keyedVnodes: Array<{ key: string | number; vnode: VNode }> = [];\n const unkeyedVnodes: VNode[] = [];\n\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i];\n const key = extractKey(child);\n if (key !== undefined) {\n keyedVnodes.push({ key, vnode: child });\n } else {\n unkeyedVnodes.push(child);\n }\n }\n\n return { keyedVnodes, unkeyedVnodes };\n}\n\n/** Try fast paths before full reconciliation */\nfunction tryFastPaths(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n unkeyedVnodes: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> | null {\n try {\n const forcedResult = tryForcedPositionalBulkUpdate(\n parent,\n newChildren,\n keyedVnodes\n );\n if (forcedResult) {\n return forcedResult;\n }\n\n // Try renderer fast-path for large keyed reorder-only updates\n const rendererResult = tryRendererFastPath(\n parent,\n newChildren,\n keyedVnodes,\n unkeyedVnodes,\n oldKeyMap\n );\n if (rendererResult) {\n return rendererResult;\n }\n\n // Try positional bulk update for medium-sized lists\n const positionalResult = tryPositionalBulkUpdate(parent, keyedVnodes);\n if (positionalResult) {\n return positionalResult;\n }\n } catch {\n // Fall through to full reconciliation\n }\n\n return null;\n}\n\n/** Try renderer fast-path */\nfunction tryRendererFastPath(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n unkeyedVnodes: VNode[],\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> | null {\n const decision = isKeyedReorderFastPathEligible(\n parent,\n newChildren,\n oldKeyMap\n );\n const isWholeKeyedList =\n keyedVnodes.length === newChildren.length && unkeyedVnodes.length === 0;\n const canUseFastPath =\n decision.useFastPath && keyedVnodes.length >= 64 && isWholeKeyedList;\n\n // Apply fast-path only for a whole keyed list. Mixed root fragments may\n // contain a keyed portal sibling, but they are not reorder-only lists.\n if (canUseFastPath) {\n try {\n const map = applyRendererFastPath(\n parent,\n keyedVnodes,\n oldKeyMap,\n unkeyedVnodes\n );\n if (map) {\n keyedElements.set(parent, map);\n return map;\n }\n } catch {\n // Fall through\n }\n }\n\n return null;\n}\n\n/** Try the explicit test/bench forced positional keyed path. */\nfunction tryForcedPositionalBulkUpdate(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): Map<string | number, Element> | null {\n if (getRuntimeEnv().ASKR_FORCE_BULK_POSREUSE !== '1') return null;\n if (keyedVnodes.length === 0 || keyedVnodes.length !== newChildren.length) {\n return null;\n }\n\n try {\n const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);\n recordFastPathStats(stats, 'bulkKeyedPositionalForced');\n\n rebuildKeyedMap(parent);\n return keyedElements.get(parent) as Map<string | number, Element>;\n } catch {\n return null;\n }\n}\n\n/** Try positional bulk update for medium-sized lists */\nfunction tryPositionalBulkUpdate(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): Map<string | number, Element> | null {\n const total = keyedVnodes.length;\n if (total < 10) return null;\n\n // CRITICAL INVARIANT: Only use children[] indexing if element-only is guaranteed\n // If parent has text nodes or comment nodes, bail to full reconciliation\n if (parent.children.length !== total) {\n return null;\n }\n\n const matchCount = countPositionalMatches(parent, keyedVnodes);\n\n // For keyed lists, the positional bulk update path makes sense in two cases:\n // 1. Perfect match (100%): All keys are in the right positions, just update text\n // 2. Very low match (<10%): Keys changed en-masse, treat as bulk re-key, reuse nodes by position\n // ANY mismatch at all means we have a reorder and need full reconciliation\n // to preserve DOM node identity correctly.\n const matchFraction = matchCount / total;\n\n if (keyedVnodes.length > 0) {\n // For keyed lists: require perfect match or very low match\n // matchCount !== total catches ANY reordering, even just 2 swapped elements\n if (matchCount !== total && matchFraction >= 0.1) {\n return null;\n }\n } else {\n // For unkeyed lists: use original threshold\n if (matchFraction < 0.9) {\n return null;\n }\n }\n\n // Check for prop changes that would prevent positional update\n if (hasPositionalPropChanges(parent, keyedVnodes)) {\n return null;\n }\n\n // Perform positional update\n try {\n const stats = performBulkPositionalKeyedTextUpdate(parent, keyedVnodes);\n recordFastPathStats(stats, 'bulkKeyedPositionalHits');\n\n rebuildKeyedMap(parent);\n return keyedElements.get(parent) as Map<string | number, Element>;\n } catch {\n return null;\n }\n}\n\n/** Count how many vnodes match parent children by position and tag */\nfunction countPositionalMatches(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): number {\n let matchCount = 0;\n\n try {\n // For keyed children, use children (elements only) since keyed nodes are elements\n for (let i = 0; i < keyedVnodes.length; i++) {\n const vnode = keyedVnodes[i].vnode as VnodeObj;\n const expectedKey = keyedVnodes[i].key;\n\n if (!vnode || typeof vnode !== 'object' || typeof vnode.type !== 'string')\n continue;\n\n const el = parent.children[i] as Element | undefined;\n if (!el) continue;\n\n // For keyed lists, check BOTH tag name AND key match\n if (tagNamesEqualIgnoreCase(el.tagName, vnode.type)) {\n // Check if the element at this position has the expected key\n const actualKey = el.getAttribute('data-key');\n const keyMatches =\n actualKey === String(expectedKey) ||\n (actualKey !== null &&\n !Number.isNaN(Number(actualKey)) &&\n Number(actualKey) === expectedKey);\n\n if (keyMatches) {\n matchCount++;\n }\n }\n }\n } catch {\n // Ignore\n }\n\n return matchCount;\n}\n\n/** Check if positional prop changes would prevent bulk update */\nfunction hasPositionalPropChanges(\n parent: Element,\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>\n): boolean {\n try {\n // For keyed children, use children (elements only) since keyed nodes are elements\n for (let i = 0; i < keyedVnodes.length; i++) {\n const vnode = keyedVnodes[i].vnode as VnodeObj;\n const el = parent.children[i] as Element | undefined;\n if (!el || !vnode || typeof vnode !== 'object') continue;\n\n if (checkPropChanges(el, vnode.props || {})) {\n return true;\n }\n }\n } catch {\n return true;\n }\n\n return false;\n}\n\n/** Rebuild keyed map from parent children */\nfunction rebuildKeyedMap(parent: Element): void {\n try {\n const map = new Map<string | number, Element>();\n for (let el = parent.firstElementChild; el; el = el.nextElementSibling) {\n const k = el.getAttribute('data-key');\n if (k !== null) {\n map.set(k, el);\n const n = Number(k);\n if (!Number.isNaN(n)) map.set(n, el);\n }\n }\n keyedElements.set(parent, map);\n } catch {\n // Ignore\n }\n}\n\n/** Perform full reconciliation when fast paths don't apply */\nfunction performFullReconciliation(\n parent: Element,\n newChildren: VNode[],\n keyedVnodes: Array<{ key: string | number; vnode: VNode }>,\n oldKeyMap: Map<string | number, Element> | undefined\n): Map<string | number, Element> {\n const newKeyMap = new Map<string | number, Element>();\n const finalNodes: Node[] = [];\n const usedOldEls = new WeakSet<Node>();\n\n const resolveOldElOnce = createOldElResolver(parent, oldKeyMap, usedOldEls);\n const unkeyedEls = collectUnkeyedElements(parent);\n let unkeyedIndex = 0;\n const resolveUnkeyedOnce = (): Element | undefined => {\n while (unkeyedIndex < unkeyedEls.length) {\n const candidate = unkeyedEls[unkeyedIndex++];\n if (!usedOldEls.has(candidate)) return candidate;\n }\n return undefined;\n };\n\n // Positional reconciliation\n for (let i = 0; i < newChildren.length; i++) {\n const child = newChildren[i];\n const node = reconcileSingleChild(\n child,\n i,\n parent,\n resolveOldElOnce,\n resolveUnkeyedOnce,\n usedOldEls,\n newKeyMap\n );\n if (node) finalNodes.push(node);\n }\n\n // SSR guard\n if (typeof document === 'undefined') return newKeyMap;\n\n commitReconciliation(parent, finalNodes);\n keyedElements.delete(parent);\n\n return newKeyMap;\n}\n\n/** Create resolver for finding old elements by key */\nfunction createOldElResolver(\n parent: Element,\n oldKeyMap: Map<string | number, Element> | undefined,\n usedOldEls: WeakSet<Node>\n): (k: string | number) => Element | undefined {\n return (k: string | number) => {\n if (!oldKeyMap) return undefined;\n\n // Fast-path: directly from oldKeyMap\n const direct = oldKeyMap.get(k);\n if (direct && !usedOldEls.has(direct)) {\n usedOldEls.add(direct);\n return direct;\n }\n\n // Try string form\n const s = String(k);\n const byString = oldKeyMap.get(s);\n if (byString && !usedOldEls.has(byString)) {\n usedOldEls.add(byString);\n return byString;\n }\n\n // Try numeric form\n const n = Number(s);\n if (!Number.isNaN(n)) {\n const byNum = oldKeyMap.get(n);\n if (byNum && !usedOldEls.has(byNum)) {\n usedOldEls.add(byNum);\n return byNum;\n }\n }\n\n // Fallback: scan parent children\n return scanForElementByKey(parent, k, s, usedOldEls);\n };\n}\n\n/** Scan parent children for element with matching key */\nfunction scanForElementByKey(\n parent: Element,\n k: string | number,\n keyStr: string,\n usedOldEls: WeakSet<Node>\n): Element | undefined {\n try {\n for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {\n if (usedOldEls.has(ch)) continue;\n const attr = ch.getAttribute('data-key');\n if (attr === keyStr) {\n usedOldEls.add(ch);\n return ch;\n }\n if (attr !== null) {\n const numAttr = Number(attr);\n if (!Number.isNaN(numAttr) && numAttr === (k as number)) {\n usedOldEls.add(ch);\n return ch;\n }\n }\n }\n } catch {\n // Ignore\n }\n return undefined;\n}\n\n/** Reconcile a single child */\nfunction reconcileSingleChild(\n child: VNode,\n index: number,\n parent: Element,\n resolveOldElOnce: (k: string | number) => Element | undefined,\n resolveUnkeyedOnce: () => Element | undefined,\n usedOldEls: WeakSet<Node>,\n newKeyMap: Map<string | number, Element>\n): Node | null {\n // Keyed child\n const key = extractKey(child);\n\n if (key !== undefined) {\n return reconcileKeyedChild(child, key, parent, resolveOldElOnce, newKeyMap);\n }\n\n // Unkeyed or primitive child\n return reconcileUnkeyedChild(\n child,\n index,\n parent,\n resolveUnkeyedOnce,\n usedOldEls\n );\n}\n\n/** Reconcile a keyed child */\nfunction reconcileKeyedChild(\n child: VNode,\n key: string | number,\n parent: Element,\n resolveOldElOnce: (k: string | number) => Element | undefined,\n newKeyMap: Map<string | number, Element>\n): Node | null {\n const el = resolveOldElOnce(key);\n\n if (el && el.parentElement === parent) {\n // Strict keyed guarantee: if the element tag changes for an existing key,\n // replace the DOM node rather than mutating in place.\n try {\n const childObj = child as VnodeObj;\n if (\n childObj &&\n typeof childObj === 'object' &&\n typeof childObj.type === 'string'\n ) {\n if (tagNamesEqualIgnoreCase(el.tagName, childObj.type)) {\n updateElementFromVnode(el, child);\n newKeyMap.set(key, el);\n return el;\n }\n }\n if (isComponentVNode(child)) {\n const synced = syncComponentElement(\n el,\n child,\n child.type,\n ((child.props ?? {}) as Props) || {}\n );\n if (synced) {\n if (synced instanceof Element) newKeyMap.set(key, synced);\n return synced;\n }\n }\n } catch {\n // Fall through to replacement\n }\n }\n\n const dom = createDOMNode(child);\n if (dom) {\n if (dom instanceof Element) newKeyMap.set(key, dom);\n return dom;\n }\n\n return null;\n}\n\n/** Reconcile an unkeyed or primitive child */\nfunction reconcileUnkeyedChild(\n child: VNode,\n index: number,\n parent: Element,\n resolveUnkeyedOnce: () => Element | undefined,\n usedOldEls: WeakSet<Node>\n): Node | null {\n try {\n // Use childNodes (includes Text nodes) instead of children (elements only)\n const existing = parent.childNodes[index] as Node | undefined;\n\n // Primitive child: try to reuse Text node if available\n if (typeof child === 'string' || typeof child === 'number') {\n if (existing && existing.nodeType === 3) {\n // Text node: reuse in-place\n (existing as Text).data = String(child);\n usedOldEls.add(existing);\n return existing;\n }\n return createDOMNode(child);\n }\n\n if (existing instanceof Element) {\n const synced = trySyncComponentChild(existing, child, usedOldEls);\n if (synced) return synced;\n }\n\n // Element child matching existing unkeyed element\n if (existing instanceof Element && canReuseElement(existing, child)) {\n updateElementFromVnode(existing, child);\n usedOldEls.add(existing);\n return existing;\n }\n\n // Try to find available unkeyed element elsewhere\n const avail = resolveUnkeyedOnce();\n if (avail) {\n const reuseResult = tryReuseElement(avail, child, usedOldEls);\n if (reuseResult) return reuseResult;\n }\n } catch {\n // Fall through to create new\n }\n\n const dom = createDOMNode(child);\n return dom;\n}\n\nfunction isComponentVNode(child: VNode): child is ComponentVNode {\n return (\n typeof child === 'object' &&\n child !== null &&\n 'type' in child &&\n typeof (child as VnodeObj).type === 'function'\n );\n}\n\nfunction trySyncComponentChild(\n existing: Element,\n child: VNode,\n usedOldEls: WeakSet<Node>\n): Node | null {\n if (!isComponentVNode(child)) return null;\n\n const synced = syncComponentElement(\n existing,\n child,\n child.type,\n ((child.props ?? {}) as Props) || {}\n );\n if (!synced) return null;\n\n usedOldEls.add(existing);\n usedOldEls.add(synced);\n return synced;\n}\n\n/** Check if existing element can be reused for child */\nfunction canReuseElement(existing: Element | undefined, child: VNode): boolean {\n if (!existing) return false;\n if (typeof child !== 'object' || child === null || !('type' in child))\n return false;\n\n const childObj = child as VnodeObj;\n const existingKey = existing.getAttribute('data-key');\n const hasNoKey = existingKey === null || existingKey === undefined;\n\n return (\n hasNoKey &&\n typeof childObj.type === 'string' &&\n tagNamesEqualIgnoreCase(existing.tagName, childObj.type)\n );\n}\n\n/** Collect unkeyed element children in DOM order. */\nfunction collectUnkeyedElements(parent: Element): Element[] {\n const elements: Element[] = [];\n for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {\n if (ch.getAttribute('data-key') === null) elements.push(ch);\n }\n return elements;\n}\n\n/** Try to reuse available element for child */\nfunction tryReuseElement(\n avail: Element,\n child: VNode,\n usedOldEls: WeakSet<Node>\n): Node | null {\n if (typeof child === 'string' || typeof child === 'number') {\n return null;\n }\n\n const synced = trySyncComponentChild(avail, child, usedOldEls);\n if (synced) {\n return synced;\n }\n\n if (typeof child === 'object' && child !== null && 'type' in child) {\n const childObj = child as VnodeObj;\n if (\n typeof childObj.type === 'string' &&\n tagNamesEqualIgnoreCase(avail.tagName, childObj.type)\n ) {\n updateElementFromVnode(avail, child);\n usedOldEls.add(avail);\n return avail;\n }\n }\n\n return null;\n}\n\n/** Commit reconciliation by replacing parent children */\nfunction commitReconciliation(parent: Element, finalNodes: Node[]): void {\n try {\n const finalSet = new Set<Node>(finalNodes);\n\n for (let n = parent.firstChild; n; ) {\n const next = n.nextSibling;\n if (!finalSet.has(n)) {\n teardownNodeSubtree(n);\n parent.removeChild(n);\n }\n n = next;\n }\n\n for (let i = 0; i < finalNodes.length; i++) {\n const desiredNode = finalNodes[i];\n const anchor = parent.childNodes[i] ?? null;\n if (desiredNode !== anchor) {\n parent.insertBefore(desiredNode, anchor);\n }\n }\n } catch {\n const fragment = document.createDocumentFragment();\n for (let i = 0; i < finalNodes.length; i++) {\n fragment.appendChild(finalNodes[i]);\n }\n\n try {\n for (let n = parent.firstChild; n; ) {\n const next = n.nextSibling;\n teardownNodeSubtree(n);\n n = next;\n }\n } catch {\n // Ignore fallback cleanup failures.\n }\n\n recordDOMReplace('reconcile');\n parent.replaceChildren(fragment);\n return;\n }\n}\n"],"mappings":";;;;;;;;AAmHA,SAAgB,uBACd,QACA,aACA,WAC+B;CAC/B,MAAM,EAAE,aAAa,kBAAkB,kBAAkB,YAAY;CAIrE,MAAM,mBAAmB,aAAa,mBAAmB,OAAO;CAGhE,MAAM,iBAAiB,aACrB,QACA,aACA,aACA,eACA,iBACD;AACD,KAAI,eACF,QAAO;AAIT,QAAO,0BACL,QACA,aACA,aACA,iBACD;;;AAIH,SAAS,mBAAmB,QAAgD;CAC1E,MAAM,yBAAS,IAAI,KAA+B;AAClD,KAAI;AACF,OAAK,IAAI,KAAK,OAAO,mBAAmB,IAAI,KAAK,GAAG,oBAAoB;GACtE,MAAM,IAAI,GAAG,aAAa,WAAW;AACrC,OAAI,MAAM,MAAM;AACd,WAAO,IAAI,GAAG,GAAG;IACjB,MAAM,IAAI,OAAO,EAAE;AACnB,QAAI,CAAC,OAAO,MAAM,EAAE,CAAE,QAAO,IAAI,GAAG,GAAG;;;SAGrC;AAGR,QAAO;;;AAIT,SAAS,kBAAkB,aAGzB;CACA,MAAM,cAA6D,EAAE;CACrE,MAAM,gBAAyB,EAAE;AAEjC,MAAK,IAAI,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK;EAC3C,MAAM,QAAQ,YAAY;EAC1B,MAAM,MAAM,WAAW,MAAM;AAC7B,MAAI,QAAQ,OACV,aAAY,KAAK;GAAE;GAAK,OAAO;GAA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GtC;EACN,MAAM,WAAW,SAAS,wBAAwB;AAClD,OAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IACrC,UAAS,YAAY,WAAW,GAAG;AAGrC,MAAI;AACF,QAAK,IAAI,IAAI,OAAO,YAAY,IAAK;IACnC,MAAM,OAAO,EAAE;AACf,wBAAoB,EAAE;AACtB,QAAI;;UAEA;AAIR,mBAAiB,YAAY;AAC7B,SAAO,gBAAgB,SAAS;AAChC"}
|
package/dist/renderer/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../common/vnode.js";
|
package/dist/renderer/utils.js
CHANGED
|
@@ -1 +1,220 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { getRuntimeEnv } from "../common/env.js";
|
|
2
|
+
import { logger } from "../dev/logger.js";
|
|
3
|
+
import { globalScheduler } from "../runtime/scheduler.js";
|
|
4
|
+
import { incDevCounter, setDevValue } from "../runtime/dev-namespace.js";
|
|
5
|
+
import "./env.js";
|
|
6
|
+
//#region src/renderer/utils.ts
|
|
7
|
+
/**
|
|
8
|
+
* Shared utilities for the renderer module.
|
|
9
|
+
* Consolidates common patterns to reduce code duplication.
|
|
10
|
+
*/
|
|
11
|
+
const handlerCache = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
let cacheSize = 0;
|
|
13
|
+
const MAX_CACHE_SIZE = 1e3;
|
|
14
|
+
/**
|
|
15
|
+
* Parse an event prop name (e.g., 'onClick') to its DOM event name (e.g., 'click')
|
|
16
|
+
*/
|
|
17
|
+
function parseEventName(propName) {
|
|
18
|
+
if (!propName.startsWith("on") || propName.length <= 2) return null;
|
|
19
|
+
return propName.slice(2).charAt(0).toLowerCase() + propName.slice(3).toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get default event listener options for passive events
|
|
23
|
+
*/
|
|
24
|
+
function getPassiveOptions(eventName) {
|
|
25
|
+
if (eventName === "wheel" || eventName === "scroll" || eventName.startsWith("touch")) return { passive: true };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a wrapped event handler that integrates with the scheduler
|
|
29
|
+
* Uses caching to avoid recreating wrappers for the same handler
|
|
30
|
+
*/
|
|
31
|
+
function createWrappedHandler(handler, flushAfter = false) {
|
|
32
|
+
const cachedByFlush = handlerCache.get(handler);
|
|
33
|
+
if (cachedByFlush) {
|
|
34
|
+
const cached = cachedByFlush.get(flushAfter);
|
|
35
|
+
if (cached) return cached;
|
|
36
|
+
}
|
|
37
|
+
const wrapped = (event) => {
|
|
38
|
+
try {
|
|
39
|
+
globalScheduler.runInHandlerScope(() => {
|
|
40
|
+
try {
|
|
41
|
+
handler(event);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
logger.error("[Askr] Event handler error:", error);
|
|
44
|
+
}
|
|
45
|
+
}, flushAfter ? "sync" : "defer");
|
|
46
|
+
} catch (err) {
|
|
47
|
+
if (flushAfter) queueMicrotask(() => {
|
|
48
|
+
throw err;
|
|
49
|
+
});
|
|
50
|
+
else logger.error("[Askr] Event handler error:", err);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
if (!handlerCache.has(handler)) if (cacheSize >= MAX_CACHE_SIZE) {} else {
|
|
55
|
+
cacheSize++;
|
|
56
|
+
handlerCache.set(handler, /* @__PURE__ */ new Map());
|
|
57
|
+
}
|
|
58
|
+
handlerCache.get(handler)?.set(flushAfter, wrapped);
|
|
59
|
+
} catch {}
|
|
60
|
+
return wrapped;
|
|
61
|
+
}
|
|
62
|
+
function createMutableWrappedHandler(handler, flushAfter = false) {
|
|
63
|
+
let currentHandler = handler;
|
|
64
|
+
const wrapped = (event) => {
|
|
65
|
+
try {
|
|
66
|
+
globalScheduler.runInHandlerScope(() => {
|
|
67
|
+
try {
|
|
68
|
+
currentHandler(event);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
logger.error("[Askr] Event handler error:", error);
|
|
71
|
+
}
|
|
72
|
+
}, flushAfter ? "sync" : "defer");
|
|
73
|
+
} catch (err) {
|
|
74
|
+
if (flushAfter) queueMicrotask(() => {
|
|
75
|
+
throw err;
|
|
76
|
+
});
|
|
77
|
+
else logger.error("[Askr] Event handler error:", err);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
handler: wrapped,
|
|
82
|
+
updateHandler(nextHandler) {
|
|
83
|
+
currentHandler = nextHandler;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Props that should be skipped during attribute processing */
|
|
88
|
+
function isSkippedProp(key) {
|
|
89
|
+
return key === "children" || key === "key" || key === "ref";
|
|
90
|
+
}
|
|
91
|
+
/** Check if prop should be ignored for prop-change detection */
|
|
92
|
+
function isIgnoredForPropChanges(key) {
|
|
93
|
+
if (key === "children" || key === "key") return true;
|
|
94
|
+
if (key.startsWith("on") && key.length > 2) return true;
|
|
95
|
+
if (key.startsWith("data-")) return true;
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if an element's current attribute value differs from vnode value
|
|
100
|
+
*/
|
|
101
|
+
function hasPropChanged(el, key, value) {
|
|
102
|
+
try {
|
|
103
|
+
if (key === "class" || key === "className") return readElementClassName(el) !== String(value);
|
|
104
|
+
if (key === "value" || key === "checked") return el[key] !== value;
|
|
105
|
+
const attr = el.getAttribute(key);
|
|
106
|
+
if (value === void 0 || value === null || value === false) return attr !== null;
|
|
107
|
+
return String(value) !== attr;
|
|
108
|
+
} catch {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function isSVGDomElement(el) {
|
|
113
|
+
return typeof SVGElement !== "undefined" && el instanceof SVGElement;
|
|
114
|
+
}
|
|
115
|
+
function readElementClassName(el) {
|
|
116
|
+
if (isSVGDomElement(el)) return el.getAttribute("class") ?? "";
|
|
117
|
+
return el.className;
|
|
118
|
+
}
|
|
119
|
+
function writeElementClassName(el, value) {
|
|
120
|
+
if (isSVGDomElement(el)) {
|
|
121
|
+
if (value.length > 0) el.setAttribute("class", value);
|
|
122
|
+
else el.removeAttribute("class");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
el.className = value;
|
|
126
|
+
}
|
|
127
|
+
function tagNamesEqualIgnoreCase(a, b) {
|
|
128
|
+
if (a === b) return true;
|
|
129
|
+
if (a.length !== b.length) return false;
|
|
130
|
+
for (let index = 0; index < a.length; index += 1) {
|
|
131
|
+
const aCode = a.charCodeAt(index);
|
|
132
|
+
const bCode = b.charCodeAt(index);
|
|
133
|
+
if (aCode === bCode) continue;
|
|
134
|
+
if ((aCode >= 65 && aCode <= 90 ? aCode + 32 : aCode) !== (bCode >= 65 && bCode <= 90 ? bCode + 32 : bCode)) return false;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Check if a vnode has non-trivial props (excluding events and data-*)
|
|
140
|
+
*/
|
|
141
|
+
function hasNonTrivialProps(props) {
|
|
142
|
+
for (const k of Object.keys(props)) {
|
|
143
|
+
if (isIgnoredForPropChanges(k)) continue;
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check for prop changes between vnode and existing element
|
|
150
|
+
*/
|
|
151
|
+
function checkPropChanges(el, props) {
|
|
152
|
+
for (const k of Object.keys(props)) {
|
|
153
|
+
if (isIgnoredForPropChanges(k)) continue;
|
|
154
|
+
if (hasPropChanged(el, k, props[k])) return true;
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Extract key from a vnode object
|
|
160
|
+
*/
|
|
161
|
+
function extractKey(vnode) {
|
|
162
|
+
if (typeof vnode !== "object" || vnode === null) return void 0;
|
|
163
|
+
const obj = vnode;
|
|
164
|
+
const rawKey = obj.key ?? obj.props?.key;
|
|
165
|
+
if (rawKey === void 0 || rawKey === null) return void 0;
|
|
166
|
+
return typeof rawKey === "symbol" ? String(rawKey) : rawKey;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Build a key map from element's children
|
|
170
|
+
*/
|
|
171
|
+
function buildKeyMapFromChildren(parent) {
|
|
172
|
+
const map = /* @__PURE__ */ new Map();
|
|
173
|
+
for (let ch = parent.firstElementChild; ch; ch = ch.nextElementSibling) {
|
|
174
|
+
const k = ch.getAttribute("data-key");
|
|
175
|
+
if (k !== null) {
|
|
176
|
+
map.set(k, ch);
|
|
177
|
+
const n = Number(k);
|
|
178
|
+
if (!Number.isNaN(n)) map.set(n, ch);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return map;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Record DOM replace operation for diagnostics
|
|
185
|
+
*/
|
|
186
|
+
function recordDOMReplace(source) {
|
|
187
|
+
try {
|
|
188
|
+
incDevCounter("__DOM_REPLACE_COUNT");
|
|
189
|
+
setDevValue(`__LAST_DOM_REPLACE_STACK_${source}`, (/* @__PURE__ */ new Error()).stack);
|
|
190
|
+
} catch {}
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Record fast-path stats for diagnostics
|
|
194
|
+
*/
|
|
195
|
+
function recordFastPathStats(stats, counterName) {
|
|
196
|
+
try {
|
|
197
|
+
setDevValue("__LAST_FASTPATH_STATS", stats);
|
|
198
|
+
setDevValue("__LAST_FASTPATH_COMMIT_COUNT", 1);
|
|
199
|
+
if (counterName) incDevCounter(counterName);
|
|
200
|
+
} catch {}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Conditionally log debug info for fast-path operations
|
|
204
|
+
*/
|
|
205
|
+
function logFastPathDebug(message, indexOrData, data) {
|
|
206
|
+
const env = getRuntimeEnv();
|
|
207
|
+
if (env.ASKR_FASTPATH_DEBUG === "1" || env.ASKR_FASTPATH_DEBUG === "true") if (data !== void 0) logger.warn(`[Askr][FASTPATH] ${message}`, indexOrData, data);
|
|
208
|
+
else if (indexOrData !== void 0) logger.warn(`[Askr][FASTPATH] ${message}`, indexOrData);
|
|
209
|
+
else logger.warn(`[Askr][FASTPATH] ${message}`);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get current high-resolution timestamp
|
|
213
|
+
*/
|
|
214
|
+
function now() {
|
|
215
|
+
return typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
218
|
+
export { buildKeyMapFromChildren, checkPropChanges, createMutableWrappedHandler, createWrappedHandler, extractKey, getPassiveOptions, hasNonTrivialProps, hasPropChanged, isIgnoredForPropChanges, isSkippedProp, logFastPathDebug, now, parseEventName, readElementClassName, recordDOMReplace, recordFastPathStats, tagNamesEqualIgnoreCase, writeElementClassName };
|
|
219
|
+
|
|
220
|
+
//# sourceMappingURL=utils.js.map
|