@askrjs/askr 0.0.50 → 0.0.52
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/dist/bench/components/benchmark-row.d.ts +2 -2
- package/dist/bench/components/benchmark-row.js +0 -2
- package/dist/bench/components/benchmark-table.js +0 -2
- package/dist/benchmark.d.ts +1 -2
- package/dist/benchmark.js +5 -6
- package/dist/bin/askr-ssg.d.ts +1 -2
- package/dist/bin/askr-ssg.js +21 -6
- package/dist/boot/hydration.js +10 -11
- package/dist/boot/index.d.ts +1 -2
- package/dist/boot/index.js +21 -11
- package/dist/boot/root-lifecycle.d.ts +6 -3
- package/dist/boot/root-lifecycle.js +18 -14
- package/dist/boot/route-startup.js +13 -4
- package/dist/boot/types.d.ts +1 -2
- package/dist/common/attr-names.js +0 -2
- package/dist/common/component.d.ts +1 -2
- package/dist/common/control.d.ts +1 -2
- package/dist/common/control.js +0 -2
- package/dist/common/dom-range.d.ts +13 -0
- package/dist/common/env.js +1 -7
- package/dist/common/error-boundary.d.ts +15 -0
- package/dist/common/invariant.js +15 -0
- package/dist/common/jsx.d.ts +1 -2
- package/dist/common/jsx.js +0 -2
- package/dist/{dev → common}/logger.js +5 -8
- package/dist/common/promise.js +0 -2
- package/dist/common/props.d.ts +1 -2
- package/dist/common/render-context.js +0 -2
- package/dist/common/route-activity.js +0 -2
- package/dist/common/router-internal.js +0 -2
- package/dist/common/router.d.ts +1 -2
- package/dist/common/ssr-errors.d.ts +1 -2
- package/dist/common/ssr-errors.js +0 -2
- package/dist/common/ssr.d.ts +1 -2
- package/dist/common/ssr.js +0 -2
- package/dist/common/vnode.d.ts +1 -2
- package/dist/common/vnode.js +0 -2
- package/dist/components/error-boundary.d.ts +2 -16
- package/dist/components/error-boundary.js +2 -76
- package/dist/components/index.d.ts +2 -1
- package/dist/components/link.d.ts +2 -2
- package/dist/components/link.js +2 -2
- package/dist/control/case.d.ts +1 -2
- package/dist/control/case.js +1 -2
- package/dist/control/for.d.ts +3 -4
- package/dist/control/for.js +2 -4
- package/dist/control/shared.d.ts +1 -2
- package/dist/control/shared.js +0 -2
- package/dist/control/show.d.ts +1 -2
- package/dist/control/show.js +1 -2
- package/dist/data/data-runtime.d.ts +1 -2
- package/dist/data/data-runtime.js +3 -5
- package/dist/data/invalidation-listeners.js +0 -2
- package/dist/data/invalidation.d.ts +1 -2
- package/dist/data/invalidation.js +2 -4
- package/dist/data/mutation-cell.d.ts +1 -2
- package/dist/data/mutation-cell.js +7 -6
- package/dist/data/query-cell.d.ts +3 -2
- package/dist/data/query-cell.js +45 -11
- package/dist/data/query-key.js +0 -2
- package/dist/data/shared.js +3 -3
- package/dist/data/testing.js +2 -0
- package/dist/data/types.d.ts +1 -2
- package/dist/foundations/icon/icon.d.ts +1 -2
- package/dist/foundations/icon/icon.js +0 -2
- package/dist/foundations/icon/icon.types.d.ts +1 -2
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/dismissable.d.ts +1 -2
- package/dist/foundations/interactions/dismissable.js +0 -2
- package/dist/foundations/interactions/focusable.d.ts +1 -2
- package/dist/foundations/interactions/focusable.js +0 -2
- package/dist/foundations/interactions/hoverable.d.ts +1 -2
- package/dist/foundations/interactions/hoverable.js +0 -2
- package/dist/foundations/interactions/interaction-policy.d.ts +1 -2
- package/dist/foundations/interactions/interaction-policy.js +0 -2
- package/dist/foundations/interactions/pressable.d.ts +1 -2
- package/dist/foundations/interactions/pressable.js +0 -2
- package/dist/foundations/interactions/roving-focus.d.ts +1 -2
- package/dist/foundations/interactions/roving-focus.js +0 -2
- package/dist/foundations/state/controllable.d.ts +1 -3
- package/dist/foundations/state/controllable.js +1 -2
- package/dist/foundations/structures/collection.d.ts +1 -2
- package/dist/foundations/structures/collection.js +0 -2
- package/dist/foundations/structures/index.d.ts +1 -1
- package/dist/foundations/structures/index.js +2 -1
- package/dist/foundations/structures/layer.d.ts +1 -2
- package/dist/foundations/structures/layer.js +0 -2
- package/dist/foundations/structures/layout.d.ts +1 -2
- package/dist/foundations/structures/layout.js +0 -2
- package/dist/foundations/structures/portal.d.ts +2 -24
- package/dist/foundations/structures/portal.js +3 -187
- package/dist/foundations/structures/presence.d.ts +1 -2
- package/dist/foundations/structures/presence.js +0 -2
- package/dist/foundations/structures/slot.d.ts +1 -2
- package/dist/foundations/structures/slot.js +0 -2
- package/dist/foundations/utilities/aria.d.ts +1 -2
- package/dist/foundations/utilities/aria.js +0 -2
- package/dist/foundations/utilities/compose-handlers.d.ts +1 -2
- package/dist/foundations/utilities/compose-handlers.js +0 -2
- package/dist/foundations/utilities/compose-ref.d.ts +1 -2
- package/dist/foundations/utilities/compose-ref.js +0 -2
- package/dist/foundations/utilities/event-types.d.ts +1 -2
- package/dist/foundations/utilities/merge-props.d.ts +1 -2
- package/dist/foundations/utilities/merge-props.js +0 -2
- package/dist/foundations/utilities/use-id.d.ts +1 -2
- package/dist/foundations/utilities/use-id.js +0 -2
- package/dist/fx/fx.d.ts +1 -2
- package/dist/fx/fx.js +2 -4
- package/dist/fx/index.js +1 -0
- package/dist/fx/noop.js +0 -2
- package/dist/fx/timing.d.ts +1 -2
- package/dist/fx/timing.js +0 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -6
- package/dist/jsx/types.d.ts +1 -2
- package/dist/jsx/utils.d.ts +1 -2
- package/dist/jsx/utils.js +0 -2
- package/dist/jsx-dev-runtime.d.ts +16 -2
- package/dist/jsx-dev-runtime.js +4 -12
- package/dist/jsx-runtime.d.ts +16 -2
- package/dist/jsx-runtime.js +16 -24
- package/dist/jsx-runtime2.d.ts +1 -1
- package/dist/renderer/attributes.js +29 -6
- package/dist/renderer/boundaries.js +50 -174
- package/dist/renderer/boundary-materialization.js +72 -0
- package/dist/renderer/boundary-range-adoption.js +76 -0
- package/dist/renderer/boundary-range-sync.js +101 -0
- package/dist/renderer/boundary-state.js +50 -0
- package/dist/renderer/child-shape.js +2 -4
- package/dist/renderer/children-fastpath.js +149 -0
- package/dist/renderer/children.js +3 -140
- package/dist/renderer/cleanup.js +72 -15
- package/dist/renderer/component-host-cleanup.js +124 -49
- package/dist/renderer/component-host-instances.js +60 -9
- package/dist/renderer/component-host-replacement.js +105 -0
- package/dist/renderer/component-host-results.js +138 -0
- package/dist/renderer/component-host.js +95 -170
- package/dist/renderer/dom-host.js +0 -2
- package/dist/renderer/dom-internal.js +115 -57
- package/dist/renderer/dom-range.js +161 -0
- package/dist/renderer/dom.js +7 -5
- package/dist/renderer/element-children.js +112 -32
- package/dist/renderer/error-boundary-dom.js +70 -13
- package/dist/renderer/evaluate-dom-range.js +3 -4
- package/dist/renderer/evaluate-reconcile.js +18 -42
- package/dist/renderer/evaluate.js +14 -3
- package/dist/renderer/fastpath.js +7 -14
- package/dist/renderer/for-commit-dom-map.js +6 -18
- package/dist/renderer/for-commit-removal.js +8 -17
- package/dist/renderer/for-commit-reorder.js +2 -4
- package/dist/renderer/for-commit.js +173 -45
- package/dist/renderer/hydration-boundaries.js +60 -0
- package/dist/renderer/hydration-listener-transaction.js +49 -0
- package/dist/renderer/index.js +11 -8
- package/dist/renderer/intrinsic-blueprint-analysis.js +202 -0
- package/dist/renderer/intrinsic-blueprint-bindings.js +152 -0
- package/dist/renderer/intrinsic-blueprint-materialization.js +100 -0
- package/dist/renderer/intrinsic-blueprint.js +30 -0
- package/dist/renderer/intrinsic-hydration-adoption.js +66 -0
- package/dist/renderer/keyed-children.js +3 -9
- package/dist/renderer/keyed.js +10 -10
- package/dist/renderer/namespaces.js +0 -2
- package/dist/renderer/prop-bindings.js +59 -24
- package/dist/renderer/reactive-child-dom.js +10 -4
- package/dist/renderer/reactive-child-sources.js +0 -2
- package/dist/renderer/reactive-children.js +33 -24
- package/dist/renderer/reconcile-commit.js +0 -2
- package/dist/renderer/reconcile-fastpaths.js +6 -12
- package/dist/renderer/reconcile-resolution.js +32 -56
- package/dist/renderer/reconcile.js +0 -2
- package/dist/renderer/retained-element-rollback.js +161 -149
- package/dist/renderer/stable-patch.js +5 -7
- package/dist/renderer/static-reuse.js +0 -2
- package/dist/renderer/utils.js +20 -10
- package/dist/resources/index.js +1 -2
- package/dist/router/access.js +0 -2
- package/dist/router/activity.d.ts +1 -2
- package/dist/router/activity.js +20 -24
- package/dist/router/authoring.d.ts +1 -2
- package/dist/router/authoring.js +1 -3
- package/dist/router/index.d.ts +1 -1
- package/dist/router/internal-types.d.ts +1 -2
- package/dist/router/lazy.d.ts +1 -2
- package/dist/router/lazy.js +0 -2
- package/dist/router/manifest.d.ts +1 -2
- package/dist/router/manifest.js +0 -2
- package/dist/router/match.js +0 -2
- package/dist/router/navigate.d.ts +1 -2
- package/dist/router/navigate.js +5 -8
- package/dist/router/navigation-registry.d.ts +1 -2
- package/dist/router/navigation-registry.js +1 -3
- package/dist/router/navigation-scroll.d.ts +1 -2
- package/dist/router/navigation-scroll.js +0 -2
- package/dist/router/navigation-targets.d.ts +3 -4
- package/dist/router/navigation-targets.js +425 -44
- package/dist/router/policy.d.ts +1 -2
- package/dist/router/policy.js +0 -2
- package/dist/router/rendering.d.ts +1 -2
- package/dist/router/rendering.js +5 -3
- package/dist/router/resolution.d.ts +2 -16
- package/dist/router/resolution.js +6 -175
- package/dist/router/route-context.js +0 -2
- package/dist/router/route-matching.d.ts +19 -0
- package/dist/router/route-matching.js +173 -0
- package/dist/router/route-query.d.ts +1 -2
- package/dist/router/route-query.js +1 -3
- package/dist/router/route.js +4 -2
- package/dist/router/store.d.ts +1 -2
- package/dist/router/store.js +0 -2
- package/dist/router/testing.js +4 -0
- package/dist/runtime/access.d.ts +19 -0
- package/dist/runtime/access.js +0 -2
- package/dist/runtime/child-scope.d.ts +21 -2
- package/dist/runtime/child-scope.js +101 -54
- package/dist/runtime/component-cleanup.d.ts +1 -2
- package/dist/runtime/component-cleanup.js +3 -5
- package/dist/runtime/component-commit.js +26 -24
- package/dist/runtime/component-facade.js +5 -3
- package/dist/runtime/component-internal.d.ts +12 -7
- package/dist/runtime/component-internal.js +64 -46
- package/dist/runtime/component-lifecycle.d.ts +2 -41
- package/dist/runtime/component-lifecycle.js +6 -149
- package/dist/runtime/component-scope.d.ts +4 -5
- package/dist/runtime/component-scope.js +27 -8
- package/dist/runtime/component.js +4 -3
- package/dist/runtime/context.d.ts +5 -2
- package/dist/runtime/context.js +29 -3
- package/dist/runtime/control.d.ts +22 -3
- package/dist/runtime/control.js +168 -55
- package/dist/runtime/derive.d.ts +1 -2
- package/dist/runtime/derive.js +0 -2
- package/dist/runtime/dev-namespace.d.ts +30 -0
- package/dist/runtime/dev-namespace.js +32 -25
- package/dist/runtime/effect.d.ts +8 -5
- package/dist/runtime/effect.js +158 -75
- package/dist/runtime/error-boundary.d.ts +4 -0
- package/dist/runtime/error-boundary.js +29 -0
- package/dist/runtime/events.d.ts +58 -0
- package/dist/runtime/events.js +67 -70
- package/dist/runtime/execution-model.d.ts +6 -0
- package/dist/runtime/execution-model.js +0 -2
- package/dist/runtime/fastlane.d.ts +33 -0
- package/dist/runtime/fastlane.js +0 -2
- package/dist/runtime/for-bench.d.ts +1 -2
- package/dist/runtime/for-bench.js +9 -167
- package/dist/runtime/for-internal.d.ts +73 -10
- package/dist/runtime/for-internal.js +201 -14
- package/dist/runtime/for-reconcile.d.ts +1 -2
- package/dist/runtime/for-reconcile.js +76 -23
- package/dist/runtime/for-scopes.d.ts +5 -5
- package/dist/runtime/for-scopes.js +168 -48
- package/dist/runtime/for-signals.d.ts +14 -5
- package/dist/runtime/for-signals.js +157 -83
- package/dist/runtime/for-types.d.ts +8 -0
- package/dist/runtime/for.d.ts +2 -2
- package/dist/runtime/for.js +3 -3
- package/dist/runtime/index.d.ts +24 -0
- package/dist/runtime/index.js +33 -0
- package/dist/runtime/lifecycle-batch.d.ts +59 -0
- package/dist/runtime/lifecycle-batch.js +178 -0
- package/dist/runtime/lifecycle-operation-settlement.d.ts +5 -0
- package/dist/runtime/lifecycle-operation-settlement.js +51 -0
- package/dist/runtime/lifecycle-operations.d.ts +1 -2
- package/dist/runtime/lifecycle-operations.js +5 -6
- package/dist/runtime/perf-metrics.d.ts +27 -0
- package/dist/runtime/perf-metrics.js +4 -68
- package/dist/runtime/portal.d.ts +21 -0
- package/dist/runtime/portal.js +305 -0
- package/dist/runtime/readable.d.ts +9 -4
- package/dist/runtime/readable.js +41 -17
- package/dist/runtime/resource-cell.js +3 -5
- package/dist/runtime/resource-operation.d.ts +1 -2
- package/dist/runtime/resource-operation.js +38 -35
- package/dist/runtime/runtime.d.ts +2 -3
- package/dist/runtime/runtime.js +0 -2
- package/dist/runtime/scheduler.d.ts +1 -2
- package/dist/runtime/scheduler.js +10 -13
- package/dist/runtime/selector-store.js +22 -0
- package/dist/runtime/selector.d.ts +1 -2
- package/dist/runtime/selector.js +6 -29
- package/dist/runtime/snapshot-source.d.ts +1 -2
- package/dist/runtime/snapshot-source.js +0 -2
- package/dist/runtime/state.d.ts +1 -2
- package/dist/runtime/state.js +1 -3
- package/dist/ssg/batch-render.js +0 -2
- package/dist/ssg/create-static-gen.d.ts +4 -2
- package/dist/ssg/create-static-gen.js +66 -14
- package/dist/ssg/generate-metadata.js +0 -2
- package/dist/ssg/generation-plan.js +0 -2
- package/dist/ssg/incremental-manifest.js +1 -3
- package/dist/ssg/resolve-ssg-data.js +0 -2
- package/dist/ssg/route-utils.js +0 -2
- package/dist/ssg/static-routes.js +1 -2
- package/dist/ssg/types.d.ts +2 -3
- package/dist/ssg/write-static-files.js +16 -12
- package/dist/ssr/attrs.js +0 -2
- package/dist/ssr/boundaries.js +17 -6
- package/dist/ssr/component-runtime.js +4 -30
- package/dist/ssr/context.d.ts +1 -2
- package/dist/ssr/context.js +0 -2
- package/dist/ssr/errors.d.ts +1 -2
- package/dist/ssr/errors.js +0 -2
- package/dist/ssr/escape.js +0 -2
- package/dist/ssr/hydration-data.js +0 -2
- package/dist/ssr/hydration-verify.d.ts +1 -2
- package/dist/ssr/hydration-verify.js +34 -7
- package/dist/ssr/index-internal.d.ts +1 -2
- package/dist/ssr/index-internal.js +0 -2
- package/dist/ssr/render-keys.js +0 -2
- package/dist/ssr/render-resolved.d.ts +1 -2
- package/dist/ssr/render-resolved.js +1 -3
- package/dist/ssr/render-sync.d.ts +1 -2
- package/dist/ssr/render-sync.js +28 -20
- package/dist/ssr/route-policy-resolution.js +2 -3
- package/dist/ssr/route-render.d.ts +1 -2
- package/dist/ssr/route-render.js +2 -3
- package/dist/ssr/sink.d.ts +1 -2
- package/dist/ssr/sink.js +0 -2
- package/dist/ssr/types.d.ts +1 -2
- package/dist/ssr/verify-hydration.js +0 -2
- package/dist/testing/index.d.ts +1 -2
- package/dist/testing/index.js +3 -4
- package/package.json +60 -47
- package/dist/bench/components/benchmark-row.d.ts.map +0 -1
- package/dist/bench/components/benchmark-row.js.map +0 -1
- package/dist/bench/components/benchmark-table.js.map +0 -1
- package/dist/benchmark.d.ts.map +0 -1
- package/dist/benchmark.js.map +0 -1
- package/dist/bin/askr-ssg.d.ts.map +0 -1
- package/dist/bin/askr-ssg.js.map +0 -1
- package/dist/boot/hydration.js.map +0 -1
- package/dist/boot/index.d.ts.map +0 -1
- package/dist/boot/index.js.map +0 -1
- package/dist/boot/root-lifecycle.d.ts.map +0 -1
- package/dist/boot/root-lifecycle.js.map +0 -1
- package/dist/boot/route-startup.js.map +0 -1
- package/dist/boot/types.d.ts.map +0 -1
- package/dist/common/attr-names.js.map +0 -1
- package/dist/common/component.d.ts.map +0 -1
- package/dist/common/control.d.ts.map +0 -1
- package/dist/common/control.js.map +0 -1
- package/dist/common/env.js.map +0 -1
- package/dist/common/jsx.d.ts.map +0 -1
- package/dist/common/jsx.js.map +0 -1
- package/dist/common/promise.js.map +0 -1
- package/dist/common/props.d.ts.map +0 -1
- package/dist/common/render-context.js.map +0 -1
- package/dist/common/route-activity.js.map +0 -1
- package/dist/common/router-internal.js.map +0 -1
- package/dist/common/router.d.ts.map +0 -1
- package/dist/common/ssr-errors.d.ts.map +0 -1
- package/dist/common/ssr-errors.js.map +0 -1
- package/dist/common/ssr.d.ts.map +0 -1
- package/dist/common/ssr.js.map +0 -1
- package/dist/common/vnode.d.ts.map +0 -1
- package/dist/common/vnode.js.map +0 -1
- package/dist/components/error-boundary.d.ts.map +0 -1
- package/dist/components/error-boundary.js.map +0 -1
- package/dist/components/link.d.ts.map +0 -1
- package/dist/components/link.js.map +0 -1
- package/dist/control/case.d.ts.map +0 -1
- package/dist/control/case.js.map +0 -1
- package/dist/control/for.d.ts.map +0 -1
- package/dist/control/for.js.map +0 -1
- package/dist/control/shared.d.ts.map +0 -1
- package/dist/control/shared.js.map +0 -1
- package/dist/control/show.d.ts.map +0 -1
- package/dist/control/show.js.map +0 -1
- package/dist/data/data-runtime.d.ts.map +0 -1
- package/dist/data/data-runtime.js.map +0 -1
- package/dist/data/invalidation-listeners.js.map +0 -1
- package/dist/data/invalidation.d.ts.map +0 -1
- package/dist/data/invalidation.js.map +0 -1
- package/dist/data/mutation-cell.d.ts.map +0 -1
- package/dist/data/mutation-cell.js.map +0 -1
- package/dist/data/query-cell.d.ts.map +0 -1
- package/dist/data/query-cell.js.map +0 -1
- package/dist/data/query-key.js.map +0 -1
- package/dist/data/shared.js.map +0 -1
- package/dist/data/types.d.ts.map +0 -1
- package/dist/dev/invariant.js +0 -29
- package/dist/dev/invariant.js.map +0 -1
- package/dist/dev/logger.js.map +0 -1
- package/dist/foundations/icon/icon.d.ts.map +0 -1
- package/dist/foundations/icon/icon.js.map +0 -1
- package/dist/foundations/icon/icon.types.d.ts.map +0 -1
- package/dist/foundations/interactions/dismissable.d.ts.map +0 -1
- package/dist/foundations/interactions/dismissable.js.map +0 -1
- package/dist/foundations/interactions/focusable.d.ts.map +0 -1
- package/dist/foundations/interactions/focusable.js.map +0 -1
- package/dist/foundations/interactions/hoverable.d.ts.map +0 -1
- package/dist/foundations/interactions/hoverable.js.map +0 -1
- package/dist/foundations/interactions/interaction-policy.d.ts.map +0 -1
- package/dist/foundations/interactions/interaction-policy.js.map +0 -1
- package/dist/foundations/interactions/pressable.d.ts.map +0 -1
- package/dist/foundations/interactions/pressable.js.map +0 -1
- package/dist/foundations/interactions/roving-focus.d.ts.map +0 -1
- package/dist/foundations/interactions/roving-focus.js.map +0 -1
- package/dist/foundations/state/controllable.d.ts.map +0 -1
- package/dist/foundations/state/controllable.js.map +0 -1
- package/dist/foundations/structures/collection.d.ts.map +0 -1
- package/dist/foundations/structures/collection.js.map +0 -1
- package/dist/foundations/structures/layer.d.ts.map +0 -1
- package/dist/foundations/structures/layer.js.map +0 -1
- package/dist/foundations/structures/layout.d.ts.map +0 -1
- package/dist/foundations/structures/layout.js.map +0 -1
- package/dist/foundations/structures/portal.d.ts.map +0 -1
- package/dist/foundations/structures/portal.js.map +0 -1
- package/dist/foundations/structures/presence.d.ts.map +0 -1
- package/dist/foundations/structures/presence.js.map +0 -1
- package/dist/foundations/structures/slot.d.ts.map +0 -1
- package/dist/foundations/structures/slot.js.map +0 -1
- package/dist/foundations/utilities/aria.d.ts.map +0 -1
- package/dist/foundations/utilities/aria.js.map +0 -1
- package/dist/foundations/utilities/compose-handlers.d.ts.map +0 -1
- package/dist/foundations/utilities/compose-handlers.js.map +0 -1
- package/dist/foundations/utilities/compose-ref.d.ts.map +0 -1
- package/dist/foundations/utilities/compose-ref.js.map +0 -1
- package/dist/foundations/utilities/event-types.d.ts.map +0 -1
- package/dist/foundations/utilities/merge-props.d.ts.map +0 -1
- package/dist/foundations/utilities/merge-props.js.map +0 -1
- package/dist/foundations/utilities/use-id.d.ts.map +0 -1
- package/dist/foundations/utilities/use-id.js.map +0 -1
- package/dist/fx/fx.d.ts.map +0 -1
- package/dist/fx/fx.js.map +0 -1
- package/dist/fx/noop.js.map +0 -1
- package/dist/fx/timing.d.ts.map +0 -1
- package/dist/fx/timing.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jsx/types.d.ts.map +0 -1
- package/dist/jsx/utils.d.ts.map +0 -1
- package/dist/jsx/utils.js.map +0 -1
- package/dist/jsx-dev-runtime.d.ts.map +0 -1
- package/dist/jsx-dev-runtime.js.map +0 -1
- package/dist/jsx-runtime.d.ts.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- package/dist/renderer/attributes.js.map +0 -1
- package/dist/renderer/boundaries.js.map +0 -1
- package/dist/renderer/child-shape.js.map +0 -1
- package/dist/renderer/children.js.map +0 -1
- package/dist/renderer/cleanup.js.map +0 -1
- package/dist/renderer/component-host-cleanup.js.map +0 -1
- package/dist/renderer/component-host-instances.js.map +0 -1
- package/dist/renderer/component-host.js.map +0 -1
- package/dist/renderer/dom-host.js.map +0 -1
- package/dist/renderer/dom-internal.js.map +0 -1
- package/dist/renderer/element-children.js.map +0 -1
- package/dist/renderer/error-boundary-dom.js.map +0 -1
- package/dist/renderer/evaluate-dom-range.js.map +0 -1
- package/dist/renderer/evaluate-reconcile.js.map +0 -1
- package/dist/renderer/evaluate.js.map +0 -1
- package/dist/renderer/fastpath.js.map +0 -1
- package/dist/renderer/for-commit-dom-map.js.map +0 -1
- package/dist/renderer/for-commit-removal.js.map +0 -1
- package/dist/renderer/for-commit-reorder.js.map +0 -1
- package/dist/renderer/for-commit.js.map +0 -1
- package/dist/renderer/index.js.map +0 -1
- package/dist/renderer/keyed-children.js.map +0 -1
- package/dist/renderer/keyed.js.map +0 -1
- package/dist/renderer/namespaces.js.map +0 -1
- package/dist/renderer/prop-bindings.js.map +0 -1
- package/dist/renderer/reactive-child-dom.js.map +0 -1
- package/dist/renderer/reactive-child-sources.js.map +0 -1
- package/dist/renderer/reactive-children.js.map +0 -1
- package/dist/renderer/reconcile-commit.js.map +0 -1
- package/dist/renderer/reconcile-fastpaths.js.map +0 -1
- package/dist/renderer/reconcile-resolution.js.map +0 -1
- package/dist/renderer/reconcile.js.map +0 -1
- package/dist/renderer/retained-element-rollback.js.map +0 -1
- package/dist/renderer/stable-patch.js.map +0 -1
- package/dist/renderer/static-reuse.js.map +0 -1
- package/dist/renderer/utils.js.map +0 -1
- package/dist/router/access.js.map +0 -1
- package/dist/router/activity.d.ts.map +0 -1
- package/dist/router/activity.js.map +0 -1
- package/dist/router/authoring.d.ts.map +0 -1
- package/dist/router/authoring.js.map +0 -1
- package/dist/router/internal-types.d.ts.map +0 -1
- package/dist/router/lazy.d.ts.map +0 -1
- package/dist/router/lazy.js.map +0 -1
- package/dist/router/manifest.d.ts.map +0 -1
- package/dist/router/manifest.js.map +0 -1
- package/dist/router/match.js.map +0 -1
- package/dist/router/navigate.d.ts.map +0 -1
- package/dist/router/navigate.js.map +0 -1
- package/dist/router/navigation-registry.d.ts.map +0 -1
- package/dist/router/navigation-registry.js.map +0 -1
- package/dist/router/navigation-scroll.d.ts.map +0 -1
- package/dist/router/navigation-scroll.js.map +0 -1
- package/dist/router/navigation-targets.d.ts.map +0 -1
- package/dist/router/navigation-targets.js.map +0 -1
- package/dist/router/policy.d.ts.map +0 -1
- package/dist/router/policy.js.map +0 -1
- package/dist/router/rendering.d.ts.map +0 -1
- package/dist/router/rendering.js.map +0 -1
- package/dist/router/resolution.d.ts.map +0 -1
- package/dist/router/resolution.js.map +0 -1
- package/dist/router/route-context.js.map +0 -1
- package/dist/router/route-query.d.ts.map +0 -1
- package/dist/router/route-query.js.map +0 -1
- package/dist/router/store.d.ts.map +0 -1
- package/dist/router/store.js.map +0 -1
- package/dist/runtime/access.js.map +0 -1
- package/dist/runtime/child-scope.d.ts.map +0 -1
- package/dist/runtime/child-scope.js.map +0 -1
- package/dist/runtime/component-cleanup.d.ts.map +0 -1
- package/dist/runtime/component-cleanup.js.map +0 -1
- package/dist/runtime/component-commit.js.map +0 -1
- package/dist/runtime/component-contracts.js +0 -5
- package/dist/runtime/component-internal.d.ts.map +0 -1
- package/dist/runtime/component-internal.js.map +0 -1
- package/dist/runtime/component-lifecycle.d.ts.map +0 -1
- package/dist/runtime/component-lifecycle.js.map +0 -1
- package/dist/runtime/component-scope.d.ts.map +0 -1
- package/dist/runtime/component-scope.js.map +0 -1
- package/dist/runtime/context.d.ts.map +0 -1
- package/dist/runtime/context.js.map +0 -1
- package/dist/runtime/control.d.ts.map +0 -1
- package/dist/runtime/control.js.map +0 -1
- package/dist/runtime/derive.d.ts.map +0 -1
- package/dist/runtime/derive.js.map +0 -1
- package/dist/runtime/dev-namespace.js.map +0 -1
- package/dist/runtime/effect.d.ts.map +0 -1
- package/dist/runtime/effect.js.map +0 -1
- package/dist/runtime/events.js.map +0 -1
- package/dist/runtime/execution-model.js.map +0 -1
- package/dist/runtime/fastlane.js.map +0 -1
- package/dist/runtime/for-bench.d.ts.map +0 -1
- package/dist/runtime/for-bench.js.map +0 -1
- package/dist/runtime/for-internal.d.ts.map +0 -1
- package/dist/runtime/for-internal.js.map +0 -1
- package/dist/runtime/for-reconcile.d.ts.map +0 -1
- package/dist/runtime/for-reconcile.js.map +0 -1
- package/dist/runtime/for-scopes.d.ts.map +0 -1
- package/dist/runtime/for-scopes.js.map +0 -1
- package/dist/runtime/for-signals.d.ts.map +0 -1
- package/dist/runtime/for-signals.js.map +0 -1
- package/dist/runtime/lifecycle-operations.d.ts.map +0 -1
- package/dist/runtime/lifecycle-operations.js.map +0 -1
- package/dist/runtime/perf-metrics.js.map +0 -1
- package/dist/runtime/readable.d.ts.map +0 -1
- package/dist/runtime/readable.js.map +0 -1
- package/dist/runtime/resource-cell.js.map +0 -1
- package/dist/runtime/resource-operation.d.ts.map +0 -1
- package/dist/runtime/resource-operation.js.map +0 -1
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/runtime.js.map +0 -1
- package/dist/runtime/scheduler.d.ts.map +0 -1
- package/dist/runtime/scheduler.js.map +0 -1
- package/dist/runtime/selector.d.ts.map +0 -1
- package/dist/runtime/selector.js.map +0 -1
- package/dist/runtime/snapshot-source.d.ts.map +0 -1
- package/dist/runtime/snapshot-source.js.map +0 -1
- package/dist/runtime/state.d.ts.map +0 -1
- package/dist/runtime/state.js.map +0 -1
- package/dist/ssg/batch-render.js.map +0 -1
- package/dist/ssg/create-static-gen.d.ts.map +0 -1
- package/dist/ssg/create-static-gen.js.map +0 -1
- package/dist/ssg/generate-metadata.js.map +0 -1
- package/dist/ssg/generation-plan.js.map +0 -1
- package/dist/ssg/incremental-manifest.js.map +0 -1
- package/dist/ssg/resolve-ssg-data.js.map +0 -1
- package/dist/ssg/route-utils.js.map +0 -1
- package/dist/ssg/static-routes.js.map +0 -1
- package/dist/ssg/types.d.ts.map +0 -1
- package/dist/ssg/write-static-files.js.map +0 -1
- package/dist/ssr/attrs.js.map +0 -1
- package/dist/ssr/boundaries.js.map +0 -1
- package/dist/ssr/component-runtime.js.map +0 -1
- package/dist/ssr/context.d.ts.map +0 -1
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/errors.d.ts.map +0 -1
- package/dist/ssr/errors.js.map +0 -1
- package/dist/ssr/escape.js.map +0 -1
- package/dist/ssr/hydration-data.js.map +0 -1
- package/dist/ssr/hydration-verify.d.ts.map +0 -1
- package/dist/ssr/hydration-verify.js.map +0 -1
- package/dist/ssr/index-internal.d.ts.map +0 -1
- package/dist/ssr/index-internal.js.map +0 -1
- package/dist/ssr/render-keys.js.map +0 -1
- package/dist/ssr/render-resolved.d.ts.map +0 -1
- package/dist/ssr/render-resolved.js.map +0 -1
- package/dist/ssr/render-sync.d.ts.map +0 -1
- package/dist/ssr/render-sync.js.map +0 -1
- package/dist/ssr/route-policy-resolution.js.map +0 -1
- package/dist/ssr/route-render.d.ts.map +0 -1
- package/dist/ssr/route-render.js.map +0 -1
- package/dist/ssr/sink.d.ts.map +0 -1
- package/dist/ssr/sink.js.map +0 -1
- package/dist/ssr/types.d.ts.map +0 -1
- package/dist/ssr/verify-hydration.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"for-signals.js","names":[],"sources":["../../src/runtime/for-signals.ts"],"sourcesContent":["import type { ChildScope } from './child-scope';\nimport type { ComponentInstance } from './component';\nimport {\n markReactivePropsDirtySource,\n markReadableDerivedSubscribersDirty,\n notifyReadableReaders,\n recordReadableRead,\n type ReadableSource,\n} from './readable';\n\nexport type ForItemSignal<T> = ReadableSource<T> &\n (() => T) & {\n peek(): T;\n set(newValue: T, notifyReaders?: boolean): void;\n };\n\nexport type ForItemPropertySignal = ReadableSource<unknown> &\n (() => unknown) & {\n peek(): unknown;\n set(newValue: unknown, notifyReaders?: boolean): void;\n };\n\nexport type ForIndexSignal = ReadableSource<number> &\n (() => number) & {\n peek(): number;\n set(\n newValue: number | ((prev: number) => number),\n notifyReaders?: boolean\n ): void;\n };\n\nexport function notifyForSignalReaders(\n source: ReadableSource<unknown>,\n skipInstance?: ComponentInstance | null\n): void {\n markReadableDerivedSubscribersDirty(source);\n markReactivePropsDirtySource(source);\n notifyReadableReaders(source, skipInstance);\n}\n\nexport function createForIndexSignal(initialIndex: number): ForIndexSignal {\n let indexValue = initialIndex;\n const readers = new Map<ComponentInstance, number>();\n\n const indexSignal = (() => {\n indexSignal._hasBeenRead = true;\n recordReadableRead(indexSignal);\n return indexValue;\n }) as ForIndexSignal;\n indexSignal._readers = readers;\n indexSignal.peek = () => indexValue;\n indexSignal.set = (\n newValue: number | ((prev: number) => number),\n notifyReaders = true\n ) => {\n const nextValue =\n typeof newValue === 'function' ? newValue(indexValue) : newValue;\n if (nextValue !== indexValue) {\n indexValue = nextValue;\n if (notifyReaders) {\n notifyForSignalReaders(indexSignal);\n }\n }\n };\n indexSignal._hasBeenRead = false;\n\n return indexSignal;\n}\n\nexport function syncForIndexSignal(\n indexSignal: ForIndexSignal,\n nextIndex: number\n): boolean {\n if (indexSignal.peek() === nextIndex) {\n return false;\n }\n\n indexSignal.set(nextIndex, indexSignal._hasBeenRead);\n return indexSignal._hasBeenRead === true;\n}\n\nexport function createForItemSignal<T>(initialItem: T): ForItemSignal<T> {\n let itemValue = initialItem;\n const readers = new Map<ComponentInstance, number>();\n\n const itemSignal = (() => {\n itemSignal._hasBeenRead = true;\n recordReadableRead(itemSignal);\n return itemValue;\n }) as ForItemSignal<T>;\n\n itemSignal._readers = readers;\n itemSignal.peek = () => itemValue;\n itemSignal.set = (newValue: T, notifyReaders = true) => {\n if (Object.is(itemValue, newValue)) {\n return;\n }\n\n itemValue = newValue;\n if (notifyReaders) {\n notifyForSignalReaders(itemSignal);\n }\n };\n itemSignal._hasBeenRead = false;\n\n return itemSignal;\n}\n\nfunction createForItemPropertySignal(\n initialValue: unknown\n): ForItemPropertySignal {\n let propertyValue = initialValue;\n const readers = new Map<ComponentInstance, number>();\n\n const propertySignal = (() => {\n propertySignal._hasBeenRead = true;\n recordReadableRead(propertySignal);\n return propertyValue;\n }) as ForItemPropertySignal;\n\n propertySignal._readers = readers;\n propertySignal.peek = () => propertyValue;\n propertySignal.set = (newValue: unknown, notifyReaders = true) => {\n if (Object.is(propertyValue, newValue)) {\n return;\n }\n\n propertyValue = newValue;\n if (notifyReaders) {\n notifyForSignalReaders(propertySignal);\n }\n };\n propertySignal._hasBeenRead = false;\n\n return propertySignal;\n}\n\nexport function readForItemProperty(item: unknown, prop: PropertyKey): unknown {\n return Reflect.get(Object(item), prop);\n}\n\nexport function haveSameOwnKeys(\n previousItem: unknown,\n nextItem: unknown\n): boolean {\n const previousKeys = Reflect.ownKeys(Object(previousItem));\n const nextKeys = Reflect.ownKeys(Object(nextItem));\n\n if (previousKeys.length !== nextKeys.length) {\n return false;\n }\n\n for (let i = 0; i < previousKeys.length; i += 1) {\n if (previousKeys[i] !== nextKeys[i]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function scopeReadsSource(\n scope: ChildScope,\n source: ReadableSource<unknown>\n): boolean {\n return source._readers?.has(scope.componentInstance) ?? false;\n}\n\nfunction isForParentReader(\n parentInstance: ComponentInstance | null,\n reader: ComponentInstance\n): boolean {\n let current = parentInstance;\n\n while (current) {\n if (current === reader) {\n return true;\n }\n current = current.parentInstance;\n }\n\n return false;\n}\n\nexport function removeForParentReaders(\n parentInstance: ComponentInstance | null,\n source: ReadableSource<unknown>\n): void {\n const readers = source._readers;\n if (!readers || readers.size === 0) {\n return;\n }\n\n for (const reader of readers.keys()) {\n if (isForParentReader(parentInstance, reader)) {\n readers.delete(reader);\n }\n }\n}\n\nfunction getOrCreateForItemPropertySignal<T>(\n item: T,\n propertySignals: Map<PropertyKey, ForItemPropertySignal>,\n prop: PropertyKey\n): ForItemPropertySignal {\n const existingSignal = propertySignals.get(prop);\n if (existingSignal) {\n return existingSignal;\n }\n\n const propertySignal = createForItemPropertySignal(\n readForItemProperty(item, prop)\n );\n propertySignals.set(prop, propertySignal);\n return propertySignal;\n}\n\nexport function canProxyForItem(item: unknown): item is object {\n return (\n (typeof item === 'object' && item !== null) || typeof item === 'function'\n );\n}\n\nexport function createReactiveForItem<T>(\n itemSignal: ForItemSignal<T>,\n propertySignals: Map<PropertyKey, ForItemPropertySignal>\n): T {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n\n return new Proxy(target, {\n get(target, prop, receiver) {\n const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, prop);\n if (ownDescriptor) {\n return Reflect.get(target, prop, receiver);\n }\n\n const currentItem = itemSignal.peek();\n\n if (typeof prop !== 'symbol') {\n return getOrCreateForItemPropertySignal(\n currentItem,\n propertySignals,\n prop\n )();\n }\n\n recordReadableRead(itemSignal);\n return Reflect.get(Object(currentItem), prop, receiver);\n },\n has(target, prop) {\n recordReadableRead(itemSignal);\n return prop in target || prop in Object(itemSignal.peek());\n },\n ownKeys(target) {\n recordReadableRead(itemSignal);\n const keys = new Set<string | symbol>(Reflect.ownKeys(target));\n for (const key of Reflect.ownKeys(Object(itemSignal.peek()))) {\n keys.add(key);\n }\n\n return Array.from(keys);\n },\n getOwnPropertyDescriptor(target, prop) {\n recordReadableRead(itemSignal);\n const ownDescriptor = Reflect.getOwnPropertyDescriptor(target, prop);\n if (ownDescriptor) {\n return ownDescriptor;\n }\n\n return Object.getOwnPropertyDescriptor(Object(itemSignal.peek()), prop);\n },\n getPrototypeOf() {\n recordReadableRead(itemSignal);\n return Object.getPrototypeOf(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A,YAA6B,iBAAiB;AAAA;AAAA,iBAsDvC,WAAA,CACd,WAAA,+BACC,iBAAiB;AAAA,iBAIJ,eAAA,IAAmB,iBAAiB;AAAA,iBAKpC,aAAA,IAAiB,iBAAiB;AAAA,KAO7C,eAAA,aAA4B,uBAAuB;AAAA,iBAuGxC,EAAA,CACd,MAAA,EAAQ,WAAA,EACR,KAAA,UACA,OAAA,EAAS,aAAA,EACT,OAAA,GAAU,eAAA;AAAA,iBA8FI,KAAA,CACd,UAAA,UACA,EAAA,cACA,OAAA,GAAU,YAAY;AAAA,iBA8BR,MAAA,IACd,OAAA,WACA,QAAA,GAAW,MAAA;EACR,KAAA,EAAO,CAAA;EAAU,OAAA;EAAkB,KAAA,EAAO,KAAA;AAAA;AAAA,iBAK/B,IAAA,CACd,EAAgE,8BAAhC,WAAW;;;;AAnQzB;AAIpB;;;;AAAoD;AAKpD;iBAqSgB,OAAA,IAAW,EAAA,QAAU,CAAA,SAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-operations.js","names":[],"sources":["../../src/runtime/lifecycle-operations.ts"],"sourcesContent":["import {\n claimHookIndex,\n getCurrentComponentInstance,\n registerCommitOperation,\n type ComponentInstance,\n} from './component';\nimport { isRouteActivityActive } from '../common/route-activity';\n\nexport type ActivityPredicate = () => boolean;\n\nexport interface TimerOptions {\n when?: ActivityPredicate | readonly ActivityPredicate[];\n}\n\nfunction normalizePredicates(\n predicates: TimerOptions['when']\n): readonly ActivityPredicate[] {\n if (!predicates) {\n return [];\n }\n\n return typeof predicates === 'function' ? [predicates] : predicates;\n}\n\nfunction allPredicatesPass(predicates: readonly ActivityPredicate[]): boolean {\n for (const predicate of predicates) {\n if (!predicate()) {\n return false;\n }\n }\n\n return true;\n}\n\ntype LifecycleSlotKind = 'timer' | 'listener' | 'task';\n\ntype LifecycleSlot = {\n kind: LifecycleSlotKind;\n};\n\nfunction getLifecycleSlot<TSlot extends LifecycleSlot>(\n instance: ComponentInstance,\n index: number,\n kind: TSlot['kind'],\n create: () => TSlot\n): TSlot {\n const existing = instance.lifecycleSlots[index];\n\n if (existing) {\n const slot = existing as LifecycleSlot;\n if (slot.kind !== kind) {\n throw new Error(\n `${kind}() lifecycle order violation: slot ${index} already belongs to ${slot.kind}(). ` +\n 'Keep lifecycle primitives in a stable top-level order.'\n );\n }\n\n return existing as TSlot;\n }\n\n const slot = create();\n instance.lifecycleSlots[index] = slot;\n return slot;\n}\n\nexport function routeActive(\n pathOrPaths: string | readonly string[]\n): ActivityPredicate {\n return () => isRouteActivityActive(pathOrPaths);\n}\n\nexport function documentVisible(): ActivityPredicate {\n return () =>\n typeof document === 'undefined' || document.visibilityState !== 'hidden';\n}\n\nexport function windowFocused(): ActivityPredicate {\n return () =>\n typeof document === 'undefined' ||\n typeof document.hasFocus !== 'function' ||\n document.hasFocus();\n}\n\ntype ListenerOptions = boolean | AddEventListenerOptions | undefined;\n\ntype NormalizedListenerOptions =\n | boolean\n | {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n signal?: AbortSignal;\n }\n | undefined;\n\ninterface ListenerSlot extends LifecycleSlot {\n kind: 'listener';\n target: EventTarget | null;\n event: string;\n handler: EventListener;\n listener: EventListener;\n options: NormalizedListenerOptions;\n pendingTarget: EventTarget;\n pendingEvent: string;\n pendingHandler: EventListener;\n pendingOptions: NormalizedListenerOptions;\n attached: boolean;\n cleanupRegistered: boolean;\n}\n\nfunction normalizeListenerOptions(\n options: ListenerOptions\n): NormalizedListenerOptions {\n if (options === undefined || typeof options === 'boolean') {\n return options;\n }\n\n return {\n ...(options.capture !== undefined ? { capture: options.capture } : {}),\n ...(options.once !== undefined ? { once: options.once } : {}),\n ...(options.passive !== undefined ? { passive: options.passive } : {}),\n ...(options.signal !== undefined ? { signal: options.signal } : {}),\n };\n}\n\nfunction listenerOptionsEqual(\n a: NormalizedListenerOptions,\n b: NormalizedListenerOptions\n): boolean {\n if (a === b) {\n return true;\n }\n if (typeof a === 'boolean' || typeof b === 'boolean') {\n return a === b;\n }\n if (!a || !b) {\n return a === b;\n }\n\n return (\n a.capture === b.capture &&\n a.once === b.once &&\n a.passive === b.passive &&\n a.signal === b.signal\n );\n}\n\nfunction detachListenerSlot(slot: ListenerSlot): void {\n if (!slot.attached || !slot.target) {\n return;\n }\n\n slot.target.removeEventListener(slot.event, slot.listener, slot.options);\n slot.attached = false;\n}\n\nfunction commitListenerSlot(\n instance: ComponentInstance,\n slot: ListenerSlot\n): void {\n slot.handler = slot.pendingHandler;\n\n const shouldReattach =\n !slot.attached ||\n slot.target !== slot.pendingTarget ||\n slot.event !== slot.pendingEvent ||\n !listenerOptionsEqual(slot.options, slot.pendingOptions);\n\n if (shouldReattach) {\n detachListenerSlot(slot);\n slot.target = slot.pendingTarget;\n slot.event = slot.pendingEvent;\n slot.options = slot.pendingOptions;\n slot.target.addEventListener(slot.event, slot.listener, slot.options);\n slot.attached = true;\n }\n\n if (!slot.cleanupRegistered) {\n slot.cleanupRegistered = true;\n instance.cleanupFns.push(() => {\n detachListenerSlot(slot);\n slot.cleanupRegistered = false;\n });\n }\n}\n\nexport function on(\n target: EventTarget,\n event: string,\n handler: EventListener,\n options?: ListenerOptions\n): void {\n const instance = getCurrentComponentInstance();\n if (!instance) {\n return;\n }\n\n const index = claimHookIndex(instance, 'on');\n const normalizedOptions = normalizeListenerOptions(options);\n const slot = getLifecycleSlot<ListenerSlot>(\n instance,\n index,\n 'listener',\n () => {\n const createdSlot = {\n kind: 'listener' as const,\n target: null,\n event,\n handler,\n listener: ((evt: Event) => {\n createdSlot.handler.call(createdSlot.target, evt);\n }) as EventListener,\n options: undefined,\n pendingTarget: target,\n pendingEvent: event,\n pendingHandler: handler,\n pendingOptions: normalizedOptions,\n attached: false,\n cleanupRegistered: false,\n };\n return createdSlot;\n }\n );\n\n slot.pendingTarget = target;\n slot.pendingEvent = event;\n slot.pendingHandler = handler;\n slot.pendingOptions = normalizedOptions;\n\n registerCommitOperation(() => {\n commitListenerSlot(instance, slot);\n });\n}\n\ninterface TimerSlot extends LifecycleSlot {\n kind: 'timer';\n id: ReturnType<typeof setInterval> | null;\n intervalMs: number | null;\n pendingIntervalMs: number;\n callback: () => void;\n predicates: readonly ActivityPredicate[];\n pendingCallback: () => void;\n pendingPredicates: readonly ActivityPredicate[];\n cleanupRegistered: boolean;\n}\n\nfunction stopTimerSlot(slot: TimerSlot): void {\n if (slot.id === null) {\n return;\n }\n\n clearInterval(slot.id);\n slot.id = null;\n}\n\nfunction startTimerSlot(slot: TimerSlot): void {\n slot.id = setInterval(() => {\n if (allPredicatesPass(slot.predicates)) {\n slot.callback();\n }\n }, slot.intervalMs ?? slot.pendingIntervalMs);\n}\n\nfunction commitTimerSlot(instance: ComponentInstance, slot: TimerSlot): void {\n const intervalChanged = slot.intervalMs !== slot.pendingIntervalMs;\n\n slot.callback = slot.pendingCallback;\n slot.predicates = slot.pendingPredicates;\n\n if (slot.id === null || intervalChanged) {\n stopTimerSlot(slot);\n slot.intervalMs = slot.pendingIntervalMs;\n startTimerSlot(slot);\n }\n\n if (!slot.cleanupRegistered) {\n slot.cleanupRegistered = true;\n instance.cleanupFns.push(() => {\n stopTimerSlot(slot);\n slot.cleanupRegistered = false;\n });\n }\n}\n\nexport function timer(\n intervalMs: number,\n fn: () => void,\n options?: TimerOptions\n): void {\n const instance = getCurrentComponentInstance();\n if (!instance) {\n return;\n }\n\n const index = claimHookIndex(instance, 'timer');\n const predicates = normalizePredicates(options?.when);\n const slot = getLifecycleSlot<TimerSlot>(instance, index, 'timer', () => ({\n kind: 'timer',\n id: null,\n intervalMs: null,\n pendingIntervalMs: intervalMs,\n callback: fn,\n predicates,\n pendingCallback: fn,\n pendingPredicates: predicates,\n cleanupRegistered: false,\n }));\n\n slot.pendingIntervalMs = intervalMs;\n slot.pendingCallback = fn;\n slot.pendingPredicates = predicates;\n\n registerCommitOperation(() => {\n commitTimerSlot(instance, slot);\n });\n}\n\nexport function stream<T>(\n _source: unknown,\n _options?: Record<string, unknown>\n): { value: T | null; pending: boolean; error: Error | null } {\n // Stub implementation: no-op.\n return { value: null, pending: true, error: null };\n}\n\nexport function task(\n fn: () => void | (() => void) | PromiseLike<void | (() => void)>\n): void {\n const instance = getCurrentComponentInstance();\n if (!instance) {\n return;\n }\n\n const index = claimHookIndex(instance, 'task');\n const slot = getLifecycleSlot<\n LifecycleSlot & {\n kind: 'task';\n started: boolean;\n task: typeof fn;\n }\n >(instance, index, 'task', () => ({\n kind: 'task',\n started: false,\n task: fn,\n }));\n\n if (!slot.started) {\n slot.task = fn;\n registerCommitOperation(async () => {\n if (slot.started) {\n return;\n }\n\n slot.started = true;\n return await slot.task();\n });\n }\n}\n\n/**\n * Capture the result of a synchronous expression at call time and return a\n * thunk that returns the captured value later. This is a low-level helper for\n * cases where async continuations need to observe a snapshot of values at the\n * moment scheduling occurred.\n *\n * Usage (public API):\n * const snapshot = capture(() => someState());\n * Promise.resolve().then(() => { use(snapshot()); });\n */\nexport function capture<T>(fn: () => T): () => T {\n const value = fn();\n return () => value;\n}\n"],"mappings":";;;;;AAcA,SAAS,oBACP,YAC8B;CAC9B,IAAI,CAAC,YACH,OAAO,CAAC;CAGV,OAAO,OAAO,eAAe,aAAa,CAAC,UAAU,IAAI;AAC3D;AAEA,SAAS,kBAAkB,YAAmD;CAC5E,KAAK,MAAM,aAAa,YACtB,IAAI,CAAC,UAAU,GACb,OAAO;CAIX,OAAO;AACT;AAQA,SAAS,iBACP,UACA,OACA,MACA,QACO;CACP,MAAM,WAAW,SAAS,eAAe;CAEzC,IAAI,UAAU;EACZ,MAAM,OAAO;EACb,IAAI,KAAK,SAAS,MAChB,MAAM,IAAI,MACR,GAAG,KAAK,qCAAqC,MAAM,sBAAsB,KAAK,KAAK,2DAErF;EAGF,OAAO;CACT;CAEA,MAAM,OAAO,OAAO;CACpB,SAAS,eAAe,SAAS;CACjC,OAAO;AACT;AAEA,SAAgB,YACd,aACmB;CACnB,aAAa,sBAAsB,WAAW;AAChD;AAEA,SA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src/runtime/perf-metrics.ts"],"sourcesContent":["import {\n isDevelopmentEnvironment,\n isRuntimeEnvFlagEnabled,\n} from '../common/env';\n\ntype PerfMetrics = {\n selectorInvalidations: number;\n selectorCandidateReads: number;\n reactivePropReevaluations: number;\n skippedDomPropWrites: number;\n classListPatchOps: number;\n delegatedAncestorHops: number;\n hydrationBoundaryActivations: number;\n ssrTagCacheHits: number;\n lastSchedulerTaskCountPerFlush: number;\n maxSchedulerTaskCountPerFlush: number;\n schedulerFlushCount: number;\n schedulerTaskExecutions: number;\n ssgWorkerCount: number;\n ssgRenderTimeMs: number;\n ssgWorkerRenderTimeMs: number;\n ssgWriteTimeMs: number;\n};\n\ntype PerfMetricsKey = keyof PerfMetrics;\n\ntype AskrPerfGlobal = typeof globalThis & {\n __ASKR_BENCH__?: boolean;\n __ASKR_PERF__?: PerfMetrics;\n};\n\nconst BENCH_BUILD_ENABLED = isRuntimeEnvFlagEnabled('ASKR_BENCH');\nlet cachedPerfStore: PerfMetrics | undefined;\n\nfunction createInitialPerfMetrics(): PerfMetrics {\n return {\n selectorInvalidations: 0,\n selectorCandidateReads: 0,\n reactivePropReevaluations: 0,\n skippedDomPropWrites: 0,\n classListPatchOps: 0,\n delegatedAncestorHops: 0,\n hydrationBoundaryActivations: 0,\n ssrTagCacheHits: 0,\n lastSchedulerTaskCountPerFlush: 0,\n maxSchedulerTaskCountPerFlush: 0,\n schedulerFlushCount: 0,\n schedulerTaskExecutions: 0,\n ssgWorkerCount: 0,\n ssgRenderTimeMs: 0,\n ssgWorkerRenderTimeMs: 0,\n ssgWriteTimeMs: 0,\n };\n}\n\nfunction shouldCollectPerfMetrics(): boolean {\n if (isDevelopmentEnvironment()) {\n return true;\n }\n if (!BENCH_BUILD_ENABLED) {\n return false;\n }\n try {\n return !!(globalThis as AskrPerfGlobal).__ASKR_BENCH__;\n } catch {\n return false;\n }\n}\n\nfunction getPerfStore(): PerfMetrics | null {\n if (cachedPerfStore) {\n return cachedPerfStore;\n }\n\n if (!shouldCollectPerfMetrics()) {\n return null;\n }\n\n try {\n const g = globalThis as AskrPerfGlobal;\n if (!g.__ASKR_PERF__) {\n g.__ASKR_PERF__ = createInitialPerfMetrics();\n }\n cachedPerfStore = g.__ASKR_PERF__;\n return cachedPerfStore;\n } catch {\n return null;\n }\n}\n\nexport function getPerfMetricsStore(): PerfMetrics | null {\n return getPerfStore();\n}\n\nexport function incrementPerfMetric(\n key:\n | 'selectorInvalidations'\n | 'selectorCandidateReads'\n | 'reactivePropReevaluations'\n | 'skippedDomPropWrites'\n | 'classListPatchOps'\n | 'delegatedAncestorHops'\n | 'hydrationBoundaryActivations'\n | 'ssrTagCacheHits'\n | 'ssgWorkerCount',\n delta = 1\n): void {\n const store = getPerfStore();\n if (!store) return;\n store[key] += delta;\n}\n\nexport function addPerfDuration(\n key: 'ssgRenderTimeMs' | 'ssgWorkerRenderTimeMs' | 'ssgWriteTimeMs',\n deltaMs: number\n): void {\n const store = getPerfStore();\n if (!store) return;\n store[key] += deltaMs;\n}\n\nexport function recordSchedulerFlushTaskCount(taskCount: number): void {\n const store = getPerfStore();\n if (!store) return;\n store.lastSchedulerTaskCountPerFlush = taskCount;\n store.maxSchedulerTaskCountPerFlush = Math.max(\n store.maxSchedulerTaskCountPerFlush,\n taskCount\n );\n store.schedulerFlushCount += 1;\n store.schedulerTaskExecutions += taskCount;\n}\n\nexport function getPerfMetrics(): Readonly<PerfMetrics> | undefined {\n const store = getPerfStore();\n return store ? { ...store } : undefined;\n}\n\nexport function resetPerfMetrics(): void {\n const store = getPerfStore();\n if (!store) return;\n const next = createInitialPerfMetrics();\n (Object.keys(next) as PerfMetricsKey[]).forEach((key) => {\n store[key] = next[key];\n });\n}\n"],"mappings":";;AA+BA,MAAM,sBAAsB,wBAAwB,YAAY;AAChE,IAAI;AAEJ,SAAS,2BAAwC;CAC/C,OAAO;EACL,uBAAuB;EACvB,wBAAwB;EACxB,2BAA2B;EAC3B,sBAAsB;EACtB,mBAAmB;EACnB,uBAAu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;EACA,QAAA,GAAW,GAAA,CAAI,iBAAA;EACf,mBAAA,GAAsB,GAAA,CAAI,iBAAA;EAC1B,QAAA;AAAA;AAAA,iBAGc,iBAAA,CAAkB,MAAe;AAAA,iBAkCjC,kBAAA,CAAmB,MAA+B,EAAvB,cAAc;AAAA,iBAsCzC,2BAAA,IACd,cAAA,EAAgB,GAAA,CAAI,cAAA,YACpB,EAAA,QAAU,CAAA,GACT,CAAA;AAAA,iBAWa,6BAAA,CACd,QAA2B,EAAjB,iBAAiB;AAAA,iBAiBb,yCAAA,CACd,QAAA,EAAU,iBAAA,EACV,KAAA,sBACA,MAAA,EAAQ,GAAA,CAAI,cAAA,wBACZ,yBAAA,GACI,GAAA,CAAI,cAAA;AAAA,iBAkDM,4BAAA,CACd,QAA2B,EAAjB,iBAAiB;AAAA,iBAiBb,uBAAA,IACd,UAAA,EAAY,iBAAA,EACZ,EAAA,QAAU,CAAA,GACT,CAAA;AAAA,iBAaa,kCAAA,CACd,UAAA,EAAY,iBAAA,EACZ,WAAA,EAAa,GAAA,CAAI,cAAA,YACjB,WAAA,EAAa,GAAA,CAAI,cAAA;AAAA,iBAkBH,mCAAA,CACd,UAAA,EAAY,iBAAA,EACZ,OAAA,EAAS,GAAA,CAAI,cAAA;AAAA,iBAQC,mCAAA,CACd,MAA+B,EAAvB,cAAc;AAAA,iBAYR,4BAAA,CACd,MAA+B,EAAvB,cAAc;AAAA,iBASR,qBAAA,CACd,MAAA,EAAQ,cAAA,WACR,YAAA,GAAe,iBAAiB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readable.js","names":[],"sources":["../../src/runtime/readable.ts"],"sourcesContent":["import {\n enqueueRuntimeTask,\n markRuntimeReactivePropsDirtySource,\n} from './access';\nimport { getCurrentInstance, type ComponentInstance } from './component';\n\nexport interface DerivedSubscriber {\n _markDirty(): void;\n _pendingDependencySources?: Set<ReadableSource<unknown>>;\n}\n\nexport interface ReadableSource<T = unknown> {\n (): T;\n _hasBeenRead?: boolean;\n _hasEverBeenRead?: boolean;\n _readers?: Map<ComponentInstance, number>;\n _derivedSubscribers?: Set<DerivedSubscriber>;\n _version?: number;\n}\n\nexport function markReadableUsage(source: unknown): void {\n if (\n source &&\n typeof source === 'function' &&\n ('_hasBeenRead' in source || '_readers' in source)\n ) {\n const readable = source as ReadableSource<unknown>;\n readable._hasBeenRead = true;\n readable._hasEverBeenRead = true;\n }\n}\n\nlet currentDerivedSubscriber: DerivedSubscriber | null = null;\nlet suppressComponentReadTrackingDepth = 0;\nlet currentFineGrainedReadSources: Set<ReadableSource<unknown>> | null = null;\n\nfunction scheduleReadableInstanceUpdate(instance: ComponentInstance): void {\n if (instance.hasPendingUpdate) {\n return;\n }\n\n instance.hasPendingUpdate = true;\n const task = instance._pendingFlushTask;\n if (task) {\n enqueueRuntimeTask(task);\n return;\n }\n\n enqueueRuntimeTask(() => {\n instance.hasPendingUpdate = false;\n instance.notifyUpdate?.();\n });\n}\n\nexport function recordReadableRead(source: ReadableSource<unknown>): void {\n source._hasEverBeenRead = true;\n\n if (currentFineGrainedReadSources) {\n currentFineGrainedReadSources.add(source);\n return;\n }\n\n if (currentDerivedSubscriber) {\n if (!currentDerivedSubscriber._pendingDependencySources) {\n currentDerivedSubscriber._pendingDependencySources = new Set();\n }\n currentDerivedSubscriber._pendingDependencySources.add(source);\n }\n\n if (suppressComponentReadTrackingDepth > 0) {\n return;\n }\n\n const inst = getCurrentInstance();\n if (!inst || inst._currentRenderToken === undefined) {\n return;\n }\n\n if (!inst._pendingReadSources) {\n inst._pendingReadSources = new Set();\n }\n inst._pendingReadSources.add(source);\n\n const sourceVersion = source._version ?? 0;\n let pendingVersions = inst._pendingReadSourceVersions;\n if (!pendingVersions) {\n pendingVersions = new Map();\n inst._pendingReadSourceVersions = pendingVersions;\n }\n pendingVersions.set(source, sourceVersion);\n}\n\nexport function withFineGrainedReadTracking<T>(\n pendingSources: Set<ReadableSource<unknown>>,\n fn: () => T\n): T {\n const previousPendingSources = currentFineGrainedReadSources;\n currentFineGrainedReadSources = pendingSources;\n\n try {\n return fn();\n } finally {\n currentFineGrainedReadSources = previousPendingSources;\n }\n}\n\nexport function finalizeReadableSubscriptions(\n instance: ComponentInstance\n): void {\n const newSet = instance._pendingReadSources;\n const token = instance._currentRenderToken;\n const pendingVersions = instance._pendingReadSourceVersions;\n\n finalizeReadableSubscriptionsFromSnapshot(\n instance,\n token,\n newSet,\n pendingVersions\n );\n instance._pendingReadSources = undefined;\n instance._currentRenderToken = undefined;\n instance._pendingReadSourceVersions = undefined;\n}\n\nexport function finalizeReadableSubscriptionsFromSnapshot(\n instance: ComponentInstance,\n token: number | undefined,\n newSet: Set<ReadableSource<unknown>> | undefined,\n pendingReadSourceVersions:\n | Map<ReadableSource<unknown>, number>\n | undefined = instance._pendingReadSourceVersions\n): void {\n if (token === undefined) {\n return;\n }\n\n const oldSet = instance._lastReadSources;\n const pendingVersions = pendingReadSourceVersions;\n let needsFollowUpUpdate = false;\n\n if (oldSet) {\n for (const source of oldSet) {\n if (!newSet?.has(source)) {\n source._readers?.delete(instance);\n }\n }\n }\n\n instance.lastRenderToken = token;\n\n if (newSet) {\n for (const source of newSet) {\n // Replay only for sources already owned by this instance, or for its\n // first committed read set. Newly entered branches in mounted components\n // keep their existing scheduler-visible intermediate states.\n if (pendingVersions && (!oldSet || oldSet.has(source))) {\n const sourceVersion = source._version ?? 0;\n const readVersion = pendingVersions.get(source);\n if (readVersion !== undefined && sourceVersion !== readVersion) {\n needsFollowUpUpdate = true;\n }\n }\n\n let readers = source._readers;\n if (!readers) {\n readers = new Map();\n source._readers = readers;\n }\n readers.set(instance, instance.lastRenderToken ?? 0);\n }\n }\n\n instance._lastReadSources = newSet ?? new Set();\n\n if (needsFollowUpUpdate) {\n scheduleReadableInstanceUpdate(instance);\n }\n}\n\nexport function cleanupReadableSubscriptions(\n instance: ComponentInstance\n): void {\n const sources = instance._lastReadSources;\n if (!sources || sources.size === 0) {\n instance._pendingReadSources = undefined;\n instance._pendingReadSourceVersions = undefined;\n return;\n }\n\n for (const source of sources) {\n source._readers?.delete(instance);\n }\n instance._lastReadSources = new Set();\n instance._pendingReadSources = undefined;\n instance._pendingReadSourceVersions = undefined;\n}\n\nexport function withDerivedReadTracking<T>(\n subscriber: DerivedSubscriber,\n fn: () => T\n): T {\n const prevDerivedSubscriber = currentDerivedSubscriber;\n currentDerivedSubscriber = subscriber;\n suppressComponentReadTrackingDepth += 1;\n\n try {\n return fn();\n } finally {\n suppressComponentReadTrackingDepth -= 1;\n currentDerivedSubscriber = prevDerivedSubscriber;\n }\n}\n\nexport function syncDerivedDependencySubscriptions(\n subscriber: DerivedSubscriber,\n prevSources: Set<ReadableSource<unknown>>,\n nextSources: Set<ReadableSource<unknown>>\n): void {\n for (const source of prevSources) {\n if (!nextSources.has(source)) {\n source._derivedSubscribers?.delete(subscriber);\n }\n }\n\n for (const source of nextSources) {\n let subscribers = source._derivedSubscribers;\n if (!subscribers) {\n subscribers = new Set();\n source._derivedSubscribers = subscribers;\n }\n subscribers.add(subscriber);\n }\n}\n\nexport function clearDerivedDependencySubscriptions(\n subscriber: DerivedSubscriber,\n sources: Set<ReadableSource<unknown>>\n): void {\n for (const source of sources) {\n source._derivedSubscribers?.delete(subscriber);\n }\n sources.clear();\n}\n\nexport function markReadableDerivedSubscribersDirty(\n source: ReadableSource<unknown>\n): void {\n const subscribers = source._derivedSubscribers;\n if (!subscribers || subscribers.size === 0) {\n return;\n }\n\n for (const subscriber of subscribers) {\n subscriber._markDirty();\n }\n}\n\nexport function markReactivePropsDirtySource(\n source: ReadableSource<unknown>\n): void {\n try {\n markRuntimeReactivePropsDirtySource(source);\n } catch {\n // Keep readable notifications side-effect safe.\n }\n}\n\nexport function notifyReadableReaders(\n source: ReadableSource<unknown>,\n skipInstance?: ComponentInstance | null\n): boolean {\n source._version = (source._version ?? 0) + 1;\n const readers = source._readers;\n let didScheduleUpdate = false;\n\n if (!readers || readers.size === 0) {\n return false;\n }\n\n for (const [instance, token] of readers) {\n if (skipInstance && instance === skipInstance) {\n continue;\n }\n if (instance.lastRenderToken !== token) {\n continue;\n }\n if (instance.hasPendingUpdate) {\n continue;\n }\n\n scheduleReadableInstanceUpdate(instance);\n didScheduleUpdate = true;\n }\n\n return didScheduleUpdate;\n}\n"],"mappings":";;;;AAoBA,SAAgB,kBAAkB,QAAuB;CACvD,IACE,UACA,OAAO,WAAW,eACjB,kBAAkB,UAAU,cAAc,SAC3C;EACA,MAAM,WAAW;EACjB,SAAS,eAAe;EACxB,SAAS,mBAAmB;CAC9B;AACF;AAEA,IAAI,2BAAqD;AACzD,IAAI,qCAAqC;AACzC,IAAI,gCAAqE;AAEzE,SAAS,+BAA+B,UAAmC;CACzE,IAAI,SAAS,kBACX;CAGF,SAAS,mBAAmB;CAC5B,MAAM,OAAO,SAAS;CACtB,IAAI,MAAM;EACR,mBAAmB,IAAI;EACvB;CACF;CAEA,yBAAyB;EACvB,SAAS,mBAAmB;EAC5B,SAAS,eAAe;CAC1B,CAAC;AACH;AAEA,SAAgB,mBAAmB,QAAuC;CACxE,OAAO,mBAAmB;CAE1B,IAAI,+BAA+B;EACjC,8BAA8B,IAAI,MAAM;EACxC;CACF;CAEA,IAAI,0BAA0B;EAC5B,IAAI,CAAC,yBAAyB,2BAC5B,yBAAyB,4CAA4B,IAAI,IAAI;EAE/D,yBAAyB,0BAA0B,IAAI,MAAM;CAC/D;CAEA,IAAI,qCAAqC,GACvC;CAGF,MAAM,OAAO,mBAAmB;CAChC,IAAI,CAAC,QAAQ,KAAK,wBAAwB,QACxC;CAGF,IAAI,CAAC,KAAK,qBACR,KAAK,sCAAsB,IAAI,IAAI;CAErC,KAAK,oBAAoB,IAAI,MAAM;CAEnC,MAAM,gBAAgB,OAAO,YAAY;CACzC,IAAI,kBAAkB,KAAK;CAC3B,IAAI,CAAC,iBAAiB;EACpB,kCAAkB,IAAI,IAAI;EAC1B,KAAK,6BAA6B;CACpC;CACA,gBAAgB,IAAI,QAAQ,aAAa;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CACtB;CAEA,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-cell.js","names":[],"sources":["../../src/runtime/resource-cell.ts"],"sourcesContent":["import { withAsyncResourceContext, type ContextFrame } from './context';\nimport { logger } from '../dev/logger';\nimport {\n brandSnapshotSource,\n type SnapshotSourceBrand,\n} from './snapshot-source';\nimport { isPromiseLike } from '../common/promise';\nimport { throwSSRDataMissing } from '../common/render-context';\n\n/**\n * Pure, component-agnostic ResourceCell state machine.\n * - Holds value/pending/error/generation/controller\n * - Exposes a stable `snapshot` object: { value, pending, error, refresh }\n * - Uses `withAsyncResourceContext` to bind the synchronous execution step\n * to a captured frame. Continuations after await do not see the frame.\n */\nexport class ResourceCell<U> {\n value: U | null = null;\n pending = true;\n error: Error | null = null;\n generation = 0;\n controller: AbortController | null = null;\n deps: readonly unknown[] | null = null;\n resourceFrame: ContextFrame | null = null;\n\n // Optional debug label set by caller (component name) to improve logs\n ownerName?: string;\n\n private subscribers = new Set<() => void>();\n private disposed = false;\n\n readonly snapshot: {\n value: U | null;\n pending: boolean;\n error: Error | null;\n refresh: () => void;\n } & SnapshotSourceBrand;\n\n private fn: (opts: { signal: AbortSignal }) => PromiseLike<U> | U;\n\n constructor(\n fn: (opts: { signal: AbortSignal }) => PromiseLike<U> | U,\n deps: readonly unknown[] | null,\n resourceFrame: ContextFrame | null\n ) {\n this.fn = fn;\n this.deps = deps ? deps.slice() : null;\n this.resourceFrame = resourceFrame;\n this.snapshot = brandSnapshotSource({\n value: null,\n pending: true,\n error: null,\n refresh: () => this.refresh(),\n });\n }\n\n setLoader(fn: (opts: { signal: AbortSignal }) => PromiseLike<U> | U): void {\n this.fn = fn;\n }\n\n subscribe(cb: () => void): () => void {\n this.subscribers.add(cb);\n return () => this.subscribers.delete(cb);\n }\n\n private notifySubscribers() {\n this.snapshot.value = this.value;\n this.snapshot.pending = this.pending;\n this.snapshot.error = this.error;\n for (const cb of this.subscribers) cb();\n }\n\n start(ssr = false, notify = true) {\n if (this.disposed) {\n return;\n }\n\n const generation = this.generation;\n\n this.controller?.abort();\n const controller = new AbortController();\n this.controller = controller;\n this.pending = true;\n this.error = null;\n if (notify) this.notifySubscribers();\n\n let result: PromiseLike<U> | U;\n try {\n // Execute only the synchronous step inside the frozen resource frame.\n result = withAsyncResourceContext(this.resourceFrame, () =>\n this.fn({ signal: controller.signal })\n );\n } catch (err) {\n this.pending = false;\n this.error = err as Error;\n if (notify) this.notifySubscribers();\n return;\n }\n\n if (!isPromiseLike<U>(result)) {\n this.value = result as U;\n this.pending = false;\n this.error = null;\n if (notify) this.notifySubscribers();\n return;\n }\n\n if (ssr) {\n // During SSR async results are disallowed\n throwSSRDataMissing();\n }\n\n Promise.resolve(result)\n .then((val) => {\n if (this.generation !== generation) return;\n if (this.controller !== controller) return;\n // A loader that does not reject on abort (e.g. a plain Promise) would\n // otherwise commit its value after the fetch was cancelled by a deps\n // change, refresh(), or unmount. Mirror the AbortError guard used in\n // the rejection path so an aborted fetch's resolution stays inert.\n if (controller.signal.aborted) return;\n this.value = val;\n this.pending = false;\n this.error = null;\n this.notifySubscribers();\n })\n .catch((err) => {\n if (this.generation !== generation) return;\n if (this.controller !== controller) return;\n\n const isAbortError =\n controller.signal.aborted ||\n (err instanceof Error && err.name === 'AbortError') ||\n (typeof DOMException !== 'undefined' &&\n err instanceof DOMException &&\n err.name === 'AbortError');\n\n if (isAbortError) {\n return;\n }\n\n this.pending = false;\n this.error = err as Error;\n try {\n if (this.ownerName) {\n logger.error(\n `[Askr] Async resource error in ${this.ownerName}:`,\n err\n );\n } else {\n logger.error('[Askr] Async resource error:', err);\n }\n } catch {\n /* ignore logging errors */\n }\n this.notifySubscribers();\n });\n }\n\n refresh() {\n if (this.disposed) {\n return;\n }\n\n this.generation++;\n this.controller?.abort();\n this.start();\n }\n\n abort() {\n this.controller?.abort();\n }\n\n dispose() {\n if (this.disposed) {\n return;\n }\n\n this.disposed = true;\n this.controller?.abort();\n this.subscribers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oB;EAGtB,QAAQ,QAAQ,MAAM,CAAC,CACpB,MAAM,QAAQ;GACb,IAAI,KAAK,eAAe,YAAY;GACpC,IAAI,KAAK,eAAe,YAAY;GAKpC,IAAI,WAAW,OAAO,SAAS;GAC/B,KAAK,QAAQ;GACb,KAAK,UAAU;GACf,KAAK,QAAQ;GACb,KAAK,kBAAkB;EACzB,CAAC,CAAC,CACD,OAAO,QAAQ;GACd,IAAI,KAAK,eAAe,YAAY;GACpC,IAAI,KAAK,eAAe,YAAY;GASpC,IANE,WAAW,OAAO,WACjB,eAAe,SAAS,IAAI,SAAS,gBACrC,OAAO,iBAAiB,eACvB,eAAe,gBACf,IAAI,SAAS,cAGf;GAGF,KAAK,UAAU;GACf,KAAK,QAAQ;GACb,IAAI;IACF,IAAI,KAAK,WACP,OAAO,MACL,kCAAkC,KAAK,UAAU,IACjD,GACF;SAEA,OAAO,MAAM,gCAAgC,GAAG;GAEpD,QAAQ,CAER;GACA,KAAK,kBAAkB;EACzB,CAAC;CACL;CAEA,UAAU;EACR,IAAI,KAAK,UACP;EAGF,KAAK;EACL,KAAK,YAAY,MAAM;EACvB,KAAK,MAAM;CACb;CAEA,QAAQ;EACN,KAAK,YAAY,MAAM;CACzB;CAEA,UAAU;EACR,IAAI,KAAK,UACP;EAGF,KAAK,WAAW;EAChB,KAAK,YAAY,MAAM;EACvB,KAAK,YAAY,MAAM;CACzB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-operation.d.ts","names":[],"sources":["../../src/runtime/resource-operation.ts"],"mappings":";UAiBiB,cAAA;EACf,KAAA,EAAO,CAAA;EACP,OAAA;EACA,KAAA,EAAO,KAAK;EACZ,OAAA;AAAA;AAAA,iBAGc,QAAA,4CACd,EAAA,GAAK,IAAA;EAAQ,MAAA,EAAQ,WAAA;AAAA,MAAkB,WAAA,CAAY,CAAA,IAAK,CAAA,EACxD,IAAA,EAAM,KAAA,GACL,cAAA,CAAe,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-operation.js","names":[],"sources":["../../src/runtime/resource-operation.ts"],"sourcesContent":["import {\n getCurrentComponentInstance,\n type ComponentInstance,\n} from './component';\nimport { getCurrentContextFrame } from './context';\nimport { ResourceCell } from './resource-cell';\nimport { state } from './state';\nimport { enqueueRuntimeLane } from './access';\nimport { brandSnapshotSource } from './snapshot-source';\nimport { SSRDataMissingError } from '../common/ssr-errors';\nimport {\n getActiveRenderContext,\n getCurrentRenderData,\n getNextRenderKey,\n throwSSRDataMissing,\n} from '../common/render-context';\n\nexport interface ResourceResult<T> {\n value: T | null;\n pending: boolean;\n error: Error | null;\n refresh(): void;\n}\n\nexport function resource<T, const TDeps extends readonly unknown[]>(\n fn: (opts: { signal: AbortSignal }) => PromiseLike<T> | T,\n deps: TDeps\n): ResourceResult<T>;\n\n/**\n * Resource primitive — simple, deterministic async primitive\n * Usage: resource(fn, deps)\n * - fn receives { signal }\n * - captures execution context once at creation (synchronous step only)\n * - executes at most once per generation; stale async results are ignored\n * - refresh() cancels in-flight execution, increments generation and re-runs\n * - exposes { value, pending, error, refresh }\n * - during SSR, async results are disallowed and will throw synchronously\n */\nexport function resource<T>(\n fn: (opts: { signal: AbortSignal }) => PromiseLike<T> | T,\n deps: readonly unknown[] = []\n): ResourceResult<T> {\n const instance = getCurrentComponentInstance();\n // Create a non-null alias early so it can be used in nested closures\n // without TypeScript complaining about possible null access.\n const inst = instance as ComponentInstance;\n\n if (!instance) {\n // If we're in a synchronous SSR render that has resolved data, use it.\n const renderData = getCurrentRenderData();\n if (renderData) {\n const key = getNextRenderKey();\n if (!(key in renderData)) {\n throwSSRDataMissing();\n }\n const val = renderData[key] as T;\n return brandSnapshotSource({\n value: val,\n pending: false,\n error: null,\n refresh: () => {},\n }) as ResourceResult<T>;\n }\n\n // If we are in an SSR render pass without supplied data, throw for clarity.\n const ssrCtx = getActiveRenderContext();\n if (ssrCtx) {\n throwSSRDataMissing();\n }\n\n // No active component instance and not in SSR render with data.\n // Autopilot invariant: resources must be created during render within an app.\n throw new Error(\n '[Askr] resource() must be called during component render inside an app. ' +\n 'Do not create resources at module scope or outside render.'\n );\n }\n\n // Internal ResourceCell — pure state machine now moved to its own module\n // to keep component wiring separate and ensure no component access here.\n // (See ./resource-cell.ts)\n\n // If we're in a synchronous SSR render that was supplied resolved data, use it\n const renderData = getCurrentRenderData();\n if (renderData) {\n // Deterministic key generation: the collection step and render step use\n // the same incremental key generation to align resources.\n const key = getNextRenderKey();\n if (!(key in renderData)) {\n throwSSRDataMissing();\n }\n\n // Commit synchronous value from render data and return a stable snapshot\n const val = renderData[key] as T;\n\n const holder = state<{\n cell?: ResourceCell<T>;\n snapshot: ResourceResult<T>;\n }>({\n cell: undefined,\n snapshot: brandSnapshotSource({\n value: val,\n pending: false,\n error: null,\n refresh: () => {},\n }) as ResourceResult<T>,\n });\n\n const h = holder();\n h.snapshot.value = val;\n h.snapshot.pending = false;\n h.snapshot.error = null;\n return h.snapshot;\n }\n\n // Persist a holder so the snapshot identity is stable across renders.\n const holder = state<{ cell?: ResourceCell<T>; snapshot: ResourceResult<T> }>(\n {\n cell: undefined,\n snapshot: brandSnapshotSource({\n value: null,\n pending: true,\n error: null,\n refresh: () => {},\n }) as ResourceResult<T>,\n }\n );\n\n const h = holder();\n\n // Initialize cell on first call\n if (!h.cell) {\n const frame = getCurrentContextFrame();\n const cell = new ResourceCell<T>(fn, deps, frame);\n // Attach debug label (component name) for richer logs\n cell.ownerName = inst.fn?.name || '<anonymous>';\n h.cell = cell;\n h.snapshot = cell.snapshot as ResourceResult<T>;\n\n // Subscribe and schedule component updates when cell changes\n const unsubscribe = cell.subscribe(() => {\n const cur = holder();\n cur.snapshot.value = cell.snapshot.value;\n cur.snapshot.pending = cell.snapshot.pending;\n cur.snapshot.error = cell.snapshot.error;\n holder.set(cur);\n try {\n inst.notifyUpdate?.();\n } catch {\n // ignore\n }\n });\n\n // Cleanup on unmount\n (inst.cleanupFns ??= []).push(() => {\n unsubscribe();\n cell.dispose();\n });\n\n // Render invariant: do NOT start async work during render on the client.\n // SSR remains strict/synchronous and must throw immediately if async is encountered.\n if (inst.ssr) {\n // SSR: must run synchronously so missing data throws during render\n cell.start(true, false);\n if (!cell.pending) {\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n }\n } else {\n // Client: start after render via scheduler (never inline)\n const scheduledGeneration = cell.generation;\n enqueueRuntimeLane('post', () => {\n if (!inst.notifyUpdate || cell.generation !== scheduledGeneration) {\n return;\n }\n\n try {\n cell.start(false, false);\n } catch (err) {\n // Non-SSR: reflect synchronous errors into snapshot via manual update\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = (err as Error) ?? null;\n holder.set(cur);\n inst.notifyUpdate?.();\n return;\n }\n\n // If the resource completed synchronously, subscribers were not notified.\n // Force a re-render so the component can observe the value.\n if (!cell.pending) {\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n holder.set(cur);\n inst.notifyUpdate?.();\n }\n });\n }\n }\n\n const cell = h.cell!;\n cell.setLoader(fn);\n\n // Detect dependency changes and refresh immediately\n const depsChanged =\n !cell.deps ||\n cell.deps.length !== deps.length ||\n cell.deps.some((d, i) => !Object.is(d, deps[i]));\n\n if (depsChanged) {\n cell.deps = deps.slice();\n cell.generation++;\n cell.pending = true;\n cell.error = null;\n\n // Synchronously reflect the pending state into the stable snapshot so the\n // render that triggered the deps change can surface a loading indicator.\n // The async start() runs with notify=false and the deps-change branch never\n // re-published the snapshot, so without this a deps-driven refetch jumped\n // straight from the old value to the new value, never exposing pending.\n // Stale-while-revalidate: the previous value is retained until the new\n // fetch resolves.\n h.snapshot.pending = true;\n h.snapshot.error = null;\n try {\n if (inst.ssr) {\n cell.start(true, false);\n if (!cell.pending) {\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n }\n } else {\n const scheduledGeneration = cell.generation;\n enqueueRuntimeLane('post', () => {\n if (!inst.notifyUpdate || cell.generation !== scheduledGeneration) {\n return;\n }\n\n cell.start(false, false);\n if (!cell.pending) {\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n holder.set(cur);\n inst.notifyUpdate?.();\n }\n });\n }\n } catch (err) {\n if (err instanceof SSRDataMissingError) throw err;\n cell.error = err as Error;\n cell.pending = false;\n const cur = holder();\n cur.snapshot.value = cell.value;\n cur.snapshot.pending = cell.pending;\n cur.snapshot.error = cell.error;\n // Do not call holder.set() here; this is still render.\n }\n }\n\n // Return the stable snapshot object owned by the cell\n return h.snapshot;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,SACd,IACA,OAA2B,CAAC,GACT;CACnB,MAAM,WAAW,4BAA4B;CAG7C,MAAM,OAAO;CAEb,IAAI,CAAC,UAAU;EAEb,MAAM,aAAa,qBAAqB;EACxC,IAAI,YAAY;GACd,MAAM,MAAM,iBAAiB;GAC7B,IAAI,EAAE,OAAO,aACX,oBAAoB;GAEtB,MAAM,MAAM,WAAW;GACvB,OAAO,oBAAoB;IACzB,OAAO;IACP,SAAS;IACT,OAAO;IACP,eAAe,CAAC;GAClB,CAAC;EACH;EAIA,IADe,uBACX,GACF,oBAAoB;EAKtB,MAAM,IAAI,MACR,oIAEF;CACF;CAOA,MAAM,aAAa,qBAAqB;CACxC,IAAI,YAAY;EAGd,MAAM,MAAM,iBAAiB;EAC7B,IAAI,EAAE,OAAO,aACX,oBAAoB;EAItB,MAAM,MAAM,WAAW;EAevB,MAAM,IAbS,MAGZ;GACD,MAAM;GACN,UAAU,oBAAoB;IAC5B,OAAO;IACP,SAAS;IACT,OAAO;IACP,eAAe,CAAC;GAClB,CAAC;EACH,CAEU,CAAA,CAAO;EACjB,EAAE,SAAS,QAAQ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A,GAAS,WAA4B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","names":[],"sources":["../../src/runtime/runtime.ts"],"sourcesContent":["import { globalScheduler, type Scheduler } from './scheduler';\nimport type { ComponentInstance } from './component';\nimport type { ReadableSource } from './readable';\n\nexport interface RuntimeKeyedReorderDecision {\n useFastPath: boolean;\n totalKeyed: number;\n totalChildren: number;\n currentKeyCount: number;\n moveCount: number;\n lisLen: number;\n hasPropChanges: boolean;\n isWholeKeyedList: boolean;\n}\n\nexport interface RuntimeRendererHost {\n evaluate(\n node: unknown,\n target: Element | null,\n context?: object,\n retainedOwner?: ComponentInstance\n ): void;\n cleanupInstancesUnder(node: Node): void;\n teardownNodeSubtree(root: Element): void;\n populateKeyMapForElement(parent: Element): void;\n getKeyMapForElement(\n parent: Element\n ): Map<string | number, Element> | undefined;\n isKeyedReorderFastPathEligible(\n parent: Element,\n children: unknown[],\n oldKeyMap: Map<string | number, Element> | undefined\n ): RuntimeKeyedReorderDecision;\n markReactivePropsDirtySource(source: ReadableSource<unknown>): void;\n}\n\nexport interface AskrRuntimeOptions {\n scheduler?: Scheduler;\n renderer?: RuntimeRendererHost;\n}\n\nfunction createMissingRendererHost(): RuntimeRendererHost {\n const missing = (method: string): never => {\n throw new Error(\n `[Askr] renderer host is not configured; cannot call ${method}().`\n );\n };\n\n return {\n evaluate() {\n missing('evaluate');\n },\n cleanupInstancesUnder() {\n missing('cleanupInstancesUnder');\n },\n teardownNodeSubtree() {\n missing('teardownNodeSubtree');\n },\n populateKeyMapForElement() {\n // Fast-lane callers treat an empty key map as a normal decline.\n },\n getKeyMapForElement() {\n return undefined;\n },\n isKeyedReorderFastPathEligible() {\n return {\n useFastPath: false,\n totalKeyed: 0,\n totalChildren: 0,\n currentKeyCount: 0,\n moveCount: 0,\n lisLen: 0,\n hasPropChanges: false,\n isWholeKeyedList: false,\n };\n },\n markReactivePropsDirtySource() {\n // Reactive prop tracking is renderer-owned and optional for runtimes.\n },\n };\n}\n\nexport class AskrRuntime {\n readonly scheduler: Scheduler;\n private rendererHost: RuntimeRendererHost;\n\n constructor(options: AskrRuntimeOptions = {}) {\n this.scheduler = options.scheduler ?? globalScheduler;\n this.rendererHost = options.renderer ?? createMissingRendererHost();\n }\n\n get renderer(): RuntimeRendererHost {\n return this.rendererHost;\n }\n\n configureRenderer(renderer: RuntimeRendererHost): void {\n this.rendererHost = renderer;\n }\n}\n\nexport const defaultRuntime = new AskrRuntime({\n scheduler: globalScheduler,\n});\n\nexport function createRuntime(options: AskrRuntimeOptions = {}): AskrRuntime {\n return new AskrRuntime(options);\n}\n\nexport function getDefaultRuntime(): AskrRuntime {\n return defaultRuntime;\n}\n\nexport function configureRuntimeRenderer(\n renderer: RuntimeRendererHost,\n runtime: AskrRuntime = defaultRuntime\n): void {\n runtime.configureRenderer(renderer);\n}\n"],"mappings":";;AAyCA,SAAS,4BAAiD;CACxD,MAAM,WAAW,WAA0B;EACzC,MAAM,IAAI,MACR,uDAAuD,OAAO,IAChE;CACF;CAEA,OAAO;EACL,WAAW;GACT,QAAQ,UAAU;EACpB;EACA,wBAAwB;GACtB,QAAQ,uBAAuB;EACjC;EACA,sBAAsB;GACpB,QAAQ,qBAAqB;EAC/B;EACA,2BAA2B,CAE3B;EACA,sBAAsB,CAEtB;EACA,iCAAiC;GAC/B,OAAO;IACL,aAAa;IACb,YAAY;IACZ,eAAe;IACf,iBAAiB;IACjB,WAAW;IACX,QAAQ;IACR,gBAAgB;IAChB,kBAAkB;GACpB;EACF;EACA,+BAA+B,CAE/B;CACF;AACF;AAEA,IAAa,cAAb,MAAyB;CAIvB,YAAY,UAA8B,CAAC,GAAG;EAC5C,KAAK,YAAY,QAAQ,aAAa;EACtC,KAAK,eAAe,QAAQ,YAAY,0BAA0B;CACpE;CAEA,IAAI,WAAgC;EAClC,OAAO,KAAK;CACd;CAEA,kBAAkB,UAAqC;EACrD,KAAK,eAAe;CACtB;AACF;AAEA,MAAa,iBAAiB,IAAI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BAAA,CAAqB,OAAA,EAAS,aAAA,GAAgB,aAAa"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","names":[],"sources":["../../src/runtime/scheduler.ts"],"sourcesContent":["/**\n * Serialized update scheduler — safer design (no inline execution, explicit flush)\n *\n * Key ideas:\n * - Never execute a task inline from `enqueue`.\n * - `flush()` is explicit and non-reentrant.\n * - `runWithSyncProgress()` allows enqueues temporarily but does not run tasks\n * inline; it runs `fn` and then does an explicit `flush()`.\n * - `waitForFlush()` is race-free with a monotonic `flushVersion`.\n */\n\nimport { isDevelopmentEnvironment } from '../common/env';\nimport { assertSchedulingPrecondition, invariant } from '../dev/invariant';\nimport { logger } from '../dev/logger';\nimport { recordSchedulerFlushTaskCount } from './perf-metrics';\n\nconst MAX_FLUSH_DEPTH = 50;\n\ntype Task = () => void;\nexport type SchedulerLane = 'derived' | 'component' | 'reactive' | 'post';\nexport type SchedulerBulkCommitProbe = () => boolean;\n\nconst SCHEDULER_LANES: SchedulerLane[] = [\n 'derived',\n 'component',\n 'reactive',\n 'post',\n];\n\ninterface LaneQueue {\n tasks: Task[];\n head: number;\n}\n\nexport class Scheduler {\n private bulkCommitProbe: SchedulerBulkCommitProbe = () => false;\n\n private lanes: Record<SchedulerLane, LaneQueue> = {\n derived: { tasks: [], head: 0 },\n component: { tasks: [], head: 0 },\n reactive: { tasks: [], head: 0 },\n post: { tasks: [], head: 0 },\n };\n\n private running = false;\n private inHandler = false;\n private depth = 0;\n private executionDepth = 0; // for compat with existing diagnostics\n\n // Monotonic flush version increments at end of each flush\n private flushVersion = 0;\n\n // Best-effort microtask kick scheduling\n private kickScheduled = false;\n\n // Escape hatch flag for runWithSyncProgress\n private allowSyncProgress = false;\n\n // Waiters waiting for flushVersion >= target\n private waiters: Array<{\n target: number;\n resolve: () => void;\n reject: (err: unknown) => void;\n timer?: ReturnType<typeof setTimeout>;\n }> = [];\n\n // Keep a lightweight taskCount for compatibility/diagnostics\n private taskCount = 0;\n\n setBulkCommitProbe(probe: SchedulerBulkCommitProbe): void {\n this.bulkCommitProbe = probe;\n }\n\n private isBulkCommitActive(): boolean {\n try {\n return this.bulkCommitProbe();\n } catch (e) {\n void e;\n return false;\n }\n }\n\n private hasPendingTasks(): boolean {\n for (const lane of SCHEDULER_LANES) {\n const queue = this.lanes[lane];\n if (queue.head < queue.tasks.length) {\n return true;\n }\n }\n return false;\n }\n\n private getPendingTaskCount(): number {\n let total = 0;\n for (const lane of SCHEDULER_LANES) {\n const queue = this.lanes[lane];\n total += queue.tasks.length - queue.head;\n }\n return total;\n }\n\n private compactLane(queue: LaneQueue): void {\n if (queue.head >= queue.tasks.length) {\n queue.tasks.length = 0;\n queue.head = 0;\n return;\n }\n\n if (queue.head <= 0) {\n return;\n }\n\n const remaining = queue.tasks.length - queue.head;\n for (let i = 0; i < remaining; i++) {\n queue.tasks[i] = queue.tasks[queue.head + i];\n }\n queue.tasks.length = remaining;\n queue.head = 0;\n }\n\n private scheduleFlushKick(): void {\n if (\n this.running ||\n this.kickScheduled ||\n this.inHandler ||\n this.allowSyncProgress ||\n this.isBulkCommitActive() ||\n !this.hasPendingTasks()\n ) {\n return;\n }\n\n this.kickScheduled = true;\n queueMicrotask(() => {\n this.kickScheduled = false;\n if (\n this.running ||\n this.isBulkCommitActive() ||\n !this.hasPendingTasks()\n ) {\n return;\n }\n try {\n this.flush();\n } catch (err) {\n setTimeout(() => {\n throw err;\n });\n }\n });\n }\n\n enqueue(task: Task): void {\n this.enqueueInLane('component', task);\n }\n\n enqueueInLane(lane: SchedulerLane, task: Task): void {\n assertSchedulingPrecondition(\n typeof task === 'function',\n 'enqueue() requires a function'\n );\n\n // Strict rule: during bulk commit, only allow enqueues if runWithSyncProgress enabled\n if (this.isBulkCommitActive() && !this.allowSyncProgress) {\n if (isDevelopmentEnvironment()) {\n throw new Error(\n '[Scheduler] enqueue() during bulk commit (not allowed)'\n );\n }\n return;\n }\n\n // Enqueue task and account counts\n this.lanes[lane].tasks.push(task);\n this.taskCount++;\n\n this.scheduleFlushKick();\n }\n\n flush(): void {\n invariant(\n !this.running,\n '[Scheduler] flush() called while already running'\n );\n\n // Dev-only guard: disallow flush during bulk commit unless allowed\n if (isDevelopmentEnvironment()) {\n if (this.isBulkCommitActive() && !this.allowSyncProgress) {\n throw new Error(\n '[Scheduler] flush() started during bulk commit (not allowed)'\n );\n }\n }\n\n this.running = true;\n this.depth = 0;\n let fatal: unknown = null;\n let executedTaskCount = 0;\n const checkFlushDepth = isDevelopmentEnvironment();\n const executionsByTask = checkFlushDepth ? new Map<Task, number>() : null;\n\n try {\n while (fatal === null) {\n let didRunTask = false;\n\n for (const lane of SCHEDULER_LANES) {\n const laneQueue = this.lanes[lane];\n let executedInLane = 0;\n\n while (laneQueue.head < laneQueue.tasks.length) {\n const task = laneQueue.tasks[laneQueue.head++];\n if (executionsByTask) {\n const taskExecutions = (executionsByTask.get(task) ?? 0) + 1;\n executionsByTask.set(task, taskExecutions);\n this.depth = Math.max(this.depth, taskExecutions);\n if (taskExecutions > MAX_FLUSH_DEPTH) {\n throw new Error(\n `[Scheduler] exceeded MAX_FLUSH_DEPTH (${MAX_FLUSH_DEPTH}). Likely infinite update loop.`\n );\n }\n }\n\n try {\n this.executionDepth++;\n task();\n this.executionDepth--;\n executedTaskCount++;\n executedInLane++;\n didRunTask = true;\n } catch (err) {\n // ensure executionDepth stays balanced for the task that threw\n if (this.executionDepth > 0) this.executionDepth--;\n fatal = err;\n break;\n }\n }\n\n if (executedInLane > 0) {\n this.taskCount = Math.max(0, this.taskCount - executedInLane);\n }\n\n if (fatal !== null) {\n break;\n }\n }\n\n if (!didRunTask) {\n break;\n }\n }\n } finally {\n this.running = false;\n this.depth = 0;\n this.executionDepth = 0;\n\n for (const lane of SCHEDULER_LANES) {\n const queue = this.lanes[lane];\n if (queue.head > 0) {\n this.compactLane(queue);\n }\n }\n\n // Advance flush epoch and resolve waiters\n this.flushVersion++;\n this.resolveWaiters();\n recordSchedulerFlushTaskCount(executedTaskCount);\n }\n\n if (fatal) throw fatal;\n }\n\n runWithSyncProgress<T>(fn: () => T): T {\n const prev = this.allowSyncProgress;\n this.allowSyncProgress = true;\n\n // Snapshot flushVersion so we can ensure we always complete an epoch\n const startVersion = this.flushVersion;\n\n try {\n const res = fn();\n\n // Flush deterministically if tasks were enqueued (and we're not already running)\n if (!this.running && this.hasPendingTasks()) {\n this.flush();\n }\n\n if (isDevelopmentEnvironment()) {\n if (!this.running && this.hasPendingTasks()) {\n throw new Error(\n '[Scheduler] tasks remain after runWithSyncProgress flush'\n );\n }\n }\n\n return res;\n } finally {\n // If no flush happened during the protected window, complete an epoch so\n // observers (tests) see progress even when fast-lane did synchronous work\n // without enqueuing tasks.\n try {\n if (this.flushVersion === startVersion) {\n this.flushVersion++;\n this.resolveWaiters();\n }\n } catch (e) {\n void e;\n }\n\n this.allowSyncProgress = prev;\n }\n }\n\n waitForFlush(targetVersion?: number, timeoutMs = 2000): Promise<void> {\n const target =\n typeof targetVersion === 'number' ? targetVersion : this.flushVersion + 1;\n if (this.flushVersion >= target) return Promise.resolve();\n\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n const ns =\n (\n globalThis as unknown as Record<string, unknown> & {\n __ASKR__?: Record<string, unknown>;\n }\n ).__ASKR__ || {};\n const diag = {\n flushVersion: this.flushVersion,\n queueLen: this.getPendingTaskCount(),\n running: this.running,\n inHandler: this.inHandler,\n bulk: this.isBulkCommitActive(),\n namespace: ns,\n };\n reject(\n new Error(\n `waitForFlush timeout ${timeoutMs}ms: ${JSON.stringify(diag)}`\n )\n );\n }, timeoutMs);\n\n this.waiters.push({ target, resolve, reject, timer });\n });\n }\n\n getState() {\n // Provide the compatibility shape expected by diagnostics/tests\n return {\n queueLength: this.getPendingTaskCount(),\n running: this.running,\n depth: this.depth,\n executionDepth: this.executionDepth,\n taskCount: this.taskCount,\n flushVersion: this.flushVersion,\n laneQueues: {\n derived: this.lanes.derived.tasks.length - this.lanes.derived.head,\n component:\n this.lanes.component.tasks.length - this.lanes.component.head,\n reactive: this.lanes.reactive.tasks.length - this.lanes.reactive.head,\n post: this.lanes.post.tasks.length - this.lanes.post.head,\n },\n // New fields for optional inspection\n inHandler: this.inHandler,\n allowSyncProgress: this.allowSyncProgress,\n };\n }\n\n getFlushVersion(): number {\n return this.flushVersion;\n }\n\n flushIfQueued(): void {\n if (!this.running && this.hasPendingTasks()) {\n this.flush();\n }\n }\n\n runInHandlerScope<T>(fn: () => T, flushMode: 'defer' | 'sync' = 'defer'): T {\n const prevInHandler = this.inHandler;\n this.inHandler = true;\n\n try {\n return fn();\n } finally {\n this.inHandler = prevInHandler;\n\n if (!this.inHandler) {\n if (flushMode === 'sync') {\n this.flushIfQueued();\n } else {\n this.scheduleFlushKick();\n }\n }\n }\n }\n\n setInHandler(v: boolean) {\n this.inHandler = v;\n if (!v) {\n this.scheduleFlushKick();\n }\n }\n\n isInHandler(): boolean {\n return this.inHandler;\n }\n\n isExecuting(): boolean {\n return this.running || this.executionDepth > 0;\n }\n\n // Clear pending synchronous tasks (used by fastlane enter/exit)\n clearPendingSyncTasks(): number {\n const remaining = this.getPendingTaskCount();\n if (remaining <= 0) return 0;\n\n if (this.running) {\n for (const lane of SCHEDULER_LANES) {\n const queue = this.lanes[lane];\n queue.tasks.length = queue.head;\n }\n this.taskCount = Math.max(0, this.taskCount - remaining);\n queueMicrotask(() => {\n try {\n this.flushVersion++;\n this.resolveWaiters();\n } catch (e) {\n void e;\n }\n });\n return remaining;\n }\n\n for (const lane of SCHEDULER_LANES) {\n const queue = this.lanes[lane];\n queue.tasks.length = 0;\n queue.head = 0;\n }\n this.taskCount = Math.max(0, this.taskCount - remaining);\n this.flushVersion++;\n this.resolveWaiters();\n return remaining;\n }\n\n private resolveWaiters() {\n if (this.waiters.length === 0) return;\n const ready: Array<() => void> = [];\n const remaining: typeof this.waiters = [];\n\n for (const w of this.waiters) {\n if (this.flushVersion >= w.target) {\n if (w.timer) clearTimeout(w.timer);\n ready.push(w.resolve);\n } else {\n remaining.push(w);\n }\n }\n\n this.waiters = remaining;\n for (const r of ready) r();\n }\n}\n\nexport const globalScheduler = new Scheduler();\n\nexport function isSchedulerExecuting(): boolean {\n return globalScheduler.isExecuting();\n}\n\nexport function scheduleEventHandler(handler: EventListener): EventListener {\n return (event: Event) => {\n try {\n globalScheduler.runInHandlerScope(() => {\n handler.call(null, event);\n });\n } catch (error) {\n logger.error('[Askr] Event handler error:', error);\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAM,kBAAkB;AAMxB,MAAM,kBAAmC;CACvC;CACA;CACA;CACA;AACF;AAOA,IAAa,YAAb,MAAuB;;+BACqC;eAER;GAChD,SAAS;IAAE,OAAO,CAAC;IAAG,MAAM;GAAE;GAC9B,WAAW;IAAE,OAAO,CAAC;IAAG,MAAM;GAAE;GAChC,UAAU;IAAE,OAAO,CAAC;IAAG,MAAM;GAAE;GAC/B,MAAM;IAAE,OAAO,CAAC;IAAG,MAAM;GAAE;EAC7B;iBAEkB;mBACE;eACJ;wBACS;sBAGF;uBAGC;2BAGI;iBAQvB,CAAC;mBAGc;;CAEpB,mBAAmB,OAAuC;EACxD,KAAK,kBAAkB;CACzB;CAEA,qBAAsC;EACpC,IAAI;GACF,OAAO,KAAK,gBAAgB;EAC9B,SAAS,GAAG;GAEV,OAAO;EACT;CACF;CAEA,kBAAmC;EACjC,KAAK,MAAM,QAAQ,iBAAiB;GAClC,MAAM,QAAQ,KAAK,MAAM;GACzB,IAAI,MAAM,OAAO,MAAM,MAAM,QAC3B,OAAO;EAEX;EACA,OAAO;CACT;CAEA,sBAAsC;EACpC,IAAI,QAAQ;EACZ,KAAK,MAAM,QAAQ,iBAAiB;GAClC,MAAM,QAAQ,KAAK,MAAM;GACzB,SAAS,MAAM,MAAM,SAAS,MAAM;EACtC;EACA,OAAO;CACT;CAEA,YAAoB,OAAwB;EAC1C,IAAI,MAAM,QAAQ,MAAM,MAAM,QAAQ;GACpC,MAAM,MAAM,S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E,QAAQ;GACjC,IAAI,EAAE,OAAO,aAAa,EAAE,KAAK;GACjC,MAAM,KAAK,EAAE,OAAO;EACtB,OACE,UAAU,KAAK,CAAC;EAIpB,KAAK,UAAU;EACf,KAAK,MAAM,KAAK,OAAO,EAAE;CAC3B;AACF;AAEA,MAAa,kBAAkB,IAAI,UAAU;AAM7C,SAAgB,qBAAqB,SAAuC;CAC1E,QAAQ,UAAiB;EACvB,IAAI;GACF,gBAAgB,wBAAwB;IACtC,QAAQ,KAAK,MAAM,KAAK;GAC1B,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,+BAA+B,KAAK;EACnD;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selector.d.ts","names":[],"sources":["../../src/runtime/selector.ts"],"mappings":";UA6BiB,QAAA;EAAA,CACd,SAAA,EAAW,CAAC;AAAA;AAAA,KAOV,cAAA;EACH,cAAA,CAAe,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAC;AAAA;AAAA,iBA0dX,QAAA,IACd,MAAA,QAAc,CAAA,EACd,MAAA,GAAQ,cAAA,CAAe,CAAA,IACtB,QAAA,CAAS,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selector.js","names":[],"sources":["../../src/runtime/selector.ts"],"sourcesContent":["import {\n claimHookIndex,\n getCurrentInstance,\n type ComponentInstance,\n} from './component';\nimport { enqueueRuntimeLane } from './access';\nimport {\n clearDerivedDependencySubscriptions,\n markReadableDerivedSubscribersDirty,\n markReadableUsage,\n markReactivePropsDirtySource,\n notifyReadableReaders,\n recordReadableRead,\n syncDerivedDependencySubscriptions,\n withDerivedReadTracking,\n type DerivedSubscriber,\n type ReadableSource,\n} from './readable';\nimport { getPerfMetricsStore, incrementPerfMetric } from './perf-metrics';\n\ntype PrimitiveKey =\n | string\n | number\n | boolean\n | symbol\n | bigint\n | null\n | undefined;\n\nexport interface Selector<T> {\n (candidate: T): boolean;\n}\n\ninterface SelectorCandidateSource<T> extends ReadableSource<boolean> {\n _candidate: T;\n}\n\ntype SelectorEquals<T> = {\n bivarianceHack(a: T, b: T): boolean;\n}['bivarianceHack'];\n\ninterface SelectorLane<T> {\n _record: SelectorSourceRecord<T>;\n _equals: SelectorEquals<T>;\n _bindingCount: number;\n _primitiveCandidates: Map<PrimitiveKey, SelectorCandidateSource<T>>;\n _objectCandidates: WeakMap<object, SelectorCandidateSource<T>>;\n _objectCandidateSources: Set<SelectorCandidateSource<T>>;\n _cleanup(): void;\n}\n\ninterface SelectorSourceRecord<T> extends DerivedSubscriber {\n _source: () => T;\n _value: T;\n _hasValue: boolean;\n _dirty: boolean;\n _scheduled: boolean;\n _evaluating: boolean;\n _sources: Set<ReadableSource<unknown>>;\n _pendingDependencySources?: Set<ReadableSource<unknown>>;\n _lanes: Map<SelectorEquals<T>, SelectorLane<T>>;\n _cleanup(): void;\n}\n\ninterface SelectorHook<T> extends Selector<T> {\n _owner: ComponentInstance;\n _hookIndex: number;\n _source: () => T;\n _equals: SelectorEquals<T>;\n _record: SelectorSourceRecord<T> | null;\n _lane: SelectorLane<T> | null;\n _cleanup(): void;\n}\n\nconst selectorCells = new WeakMap<\n ComponentInstance,\n Map<number, SelectorHook<unknown>>\n>();\nconst selectorRecords = new WeakMap<\n ReadableSource<unknown>,\n SelectorSourceRecord<unknown>\n>();\nconst dirtySelectorRecords = new Set<SelectorSourceRecord<unknown>>();\nlet hasPendingSelectorFlush = false;\n\nfunction getSelectorStore(\n instance: ComponentInstance\n): Map<number, SelectorHook<unknown>> {\n let store = selectorCells.get(instance);\n if (!store) {\n store = new Map();\n selectorCells.set(instance, store);\n }\n return store;\n}\n\nfunction scheduleSelectorFlush(): void {\n if (hasPendingSelectorFlush) {\n return;\n }\n\n hasPendingSelectorFlush = true;\n enqueueRuntimeLane('derived', flushDirtySelectorRecords);\n}\n\nfunction markSelectorRecordDirty(record: SelectorSourceRecord<unknown>): void {\n record._dirty = true;\n if (record._scheduled) {\n return;\n }\n\n record._scheduled = true;\n dirtySelectorRecords.add(record);\n scheduleSelectorFlush();\n}\n\nfunction flushDirtySelectorRecords(): void {\n hasPendingSelectorFlush = false;\n\n if (dirtySelectorRecords.size === 0) {\n return;\n }\n\n const pending = Array.from(dirtySelectorRecords);\n dirtySelectorRecords.clear();\n\n for (const record of pending) {\n record._scheduled = false;\n if (!record._dirty) {\n continue;\n }\n recomputeSelectorSourceRecord(record, true);\n }\n}\n\nfunction isObjectCandidate(value: unknown): value is object {\n return (\n (typeof value === 'object' && value !== null) || typeof value === 'function'\n );\n}\n\nfunction isDefaultSelectorEquals<T>(equals: SelectorEquals<T>): boolean {\n return equals === Object.is;\n}\n\nfunction createCandidateSource<T>(candidate: T): SelectorCandidateSource<T> {\n const source = (() => false) as SelectorCandidateSource<T>;\n source._candidate = candidate;\n return source;\n}\n\nfunction getCandidateSource<T>(\n lane: SelectorLane<T>,\n candidate: T\n): SelectorCandidateSource<T> {\n if (isObjectCandidate(candidate)) {\n const cached = lane._objectCandidates.get(candidate);\n if (cached) {\n return cached;\n }\n\n const created = createCandidateSource(candidate);\n lane._objectCandidates.set(candidate, created);\n lane._objectCandidateSources.add(created);\n return created;\n }\n\n const key = candidate as PrimitiveKey;\n const cached = lane._primitiveCandidates.get(key);\n if (cached) {\n return cached;\n }\n\n const created = createCandidateSource(candidate);\n lane._primitiveCandidates.set(key, created);\n return created;\n}\n\nfunction peekCandidateSource<T>(\n lane: SelectorLane<T>,\n candidate: T\n): SelectorCandidateSource<T> | undefined {\n if (isObjectCandidate(candidate)) {\n return lane._objectCandidates.get(candidate);\n }\n return lane._primitiveCandidates.get(candidate as PrimitiveKey);\n}\n\nfunction getSelectorSourceRecord<T>(source: () => T): SelectorSourceRecord<T> {\n const cached = selectorRecords.get(source);\n if (cached) {\n return cached as SelectorSourceRecord<T>;\n }\n\n const record = createSelectorSourceRecord(source);\n selectorRecords.set(source, record as SelectorSourceRecord<unknown>);\n return record;\n}\n\nfunction createSelectorSourceRecord<T>(\n source: () => T\n): SelectorSourceRecord<T> {\n let record!: SelectorSourceRecord<T>;\n\n record = {\n _source: source,\n _value: undefined as T,\n _hasValue: false,\n _dirty: true,\n _scheduled: false,\n _evaluating: false,\n _sources: new Set(),\n _lanes: new Map(),\n _markDirty: () => {\n markSelectorRecordDirty(record as SelectorSourceRecord<unknown>);\n },\n _cleanup: () => {\n record._scheduled = false;\n record._dirty = false;\n record._hasValue = false;\n record._evaluating = false;\n record._pendingDependencySources = undefined;\n clearDerivedDependencySubscriptions(record, record._sources);\n record._lanes.clear();\n selectorRecords.delete(source as ReadableSource<unknown>);\n },\n };\n\n return record;\n}\n\nfunction getSelectorLane<T>(\n record: SelectorSourceRecord<T>,\n equals: SelectorEquals<T>\n): SelectorLane<T> {\n const cached = record._lanes.get(equals);\n if (cached) {\n return cached;\n }\n\n const lane = createSelectorLane(record, equals);\n record._lanes.set(equals, lane);\n return lane;\n}\n\nfunction createSelectorLane<T>(\n record: SelectorSourceRecord<T>,\n equals: SelectorEquals<T>\n): SelectorLane<T> {\n const lane: SelectorLane<T> = {\n _record: record,\n _equals: equals,\n _bindingCount: 0,\n _primitiveCandidates: new Map(),\n _objectCandidates: new WeakMap(),\n _objectCandidateSources: new Set(),\n _cleanup: () => {\n for (const sourceRef of lane._primitiveCandidates.values()) {\n sourceRef._readers?.clear();\n sourceRef._derivedSubscribers?.clear();\n }\n for (const sourceRef of lane._objectCandidateSources) {\n sourceRef._readers?.clear();\n sourceRef._derivedSubscribers?.clear();\n }\n lane._primitiveCandidates.clear();\n lane._objectCandidates = new WeakMap();\n lane._objectCandidateSources.clear();\n },\n };\n\n return lane;\n}\n\nfunction notifySelectorSource(source: SelectorCandidateSource<unknown>): void {\n incrementPerfMetric('selectorInvalidations');\n markReadableDerivedSubscribersDirty(source);\n markReactivePropsDirtySource(source);\n notifyReadableReaders(source);\n}\n\nfunction notifyAllSelectorSources<T>(lane: SelectorLane<T>): void {\n for (const source of lane._primitiveCandidates.values()) {\n notifySelectorSource(source);\n }\n for (const source of lane._objectCandidateSources) {\n notifySelectorSource(source);\n }\n}\n\nfunction notifySelectorLaneValueChange<T>(\n lane: SelectorLane<T>,\n prevValue: T,\n nextValue: T\n): void {\n if (!lane._bindingCount) {\n return;\n }\n\n if (!isDefaultSelectorEquals(lane._equals)) {\n if (lane._equals(prevValue, nextValue)) {\n return;\n }\n notifyAllSelectorSources(lane);\n return;\n }\n\n if (!Object.is(prevValue, nextValue)) {\n // Only notify candidate sources that were actually materialized by a read.\n // Using getCandidateSource here would create-on-miss and leak a candidate\n // source for every distinct value the source ever passed through, even\n // those no component reads. Peek instead so the candidate cache stays\n // bounded to values that components actually compare against.\n const prevSource = peekCandidateSource(lane, prevValue);\n if (prevSource) {\n notifySelectorSource(prevSource);\n }\n const nextSource = peekCandidateSource(lane, nextValue);\n if (nextSource) {\n notifySelectorSource(nextSource);\n }\n }\n}\n\nfunction recomputeSelectorSourceRecord<T>(\n record: SelectorSourceRecord<T>,\n notifyDownstream: boolean\n): T {\n if (!record._dirty && record._hasValue) {\n return record._value;\n }\n\n if (record._evaluating) {\n throw new Error('selector() cannot read itself recursively');\n }\n\n record._evaluating = true;\n record._dirty = false;\n record._pendingDependencySources = new Set();\n\n const prevSources = record._sources;\n const hadValue = record._hasValue;\n const prevValue = record._value;\n let nextValue: T;\n\n try {\n nextValue = withDerivedReadTracking(record, record._source);\n } catch (error) {\n record._dirty = true;\n record._pendingDependencySources = undefined;\n throw error;\n } finally {\n record._evaluating = false;\n }\n\n const nextSources = record._pendingDependencySources ?? new Set();\n record._pendingDependencySources = undefined;\n syncDerivedDependencySubscriptions(record, prevSources, nextSources);\n record._sources = nextSources;\n\n const valueChanged = !record._hasValue || !Object.is(prevValue, nextValue);\n record._hasValue = true;\n record._value = nextValue;\n\n if (valueChanged && notifyDownstream && hadValue) {\n for (const lane of Array.from(record._lanes.values())) {\n notifySelectorLaneValueChange(lane, prevValue, nextValue);\n }\n }\n\n return record._value;\n}\n\nfunction attachSelectorHookBinding<T>(\n hook: SelectorHook<T>,\n source: () => T,\n equals: SelectorEquals<T>\n): void {\n const record = getSelectorSourceRecord(source);\n const lane = getSelectorLane(record, equals);\n\n hook._source = source;\n hook._equals = equals;\n hook._record = record;\n hook._lane = lane;\n lane._bindingCount += 1;\n}\n\nfunction detachSelectorHookBinding<T>(hook: SelectorHook<T>): void {\n const record = hook._record;\n const lane = hook._lane;\n\n hook._record = null;\n hook._lane = null;\n\n if (!record || !lane) {\n return;\n }\n\n if (lane._bindingCount > 0) {\n lane._bindingCount -= 1;\n }\n\n if (lane._bindingCount > 0) {\n return;\n }\n\n lane._cleanup();\n record._lanes.delete(lane._equals);\n\n if (record._lanes.size === 0) {\n record._cleanup();\n }\n}\n\nfunction ensureSelectorHookBinding<T>(\n hook: SelectorHook<T>\n): SelectorSourceRecord<T> {\n const record = hook._record;\n const lane = hook._lane;\n\n if (\n record &&\n lane &&\n lane._bindingCount > 0 &&\n record._lanes.get(hook._equals) === lane &&\n record._source === hook._source\n ) {\n return record;\n }\n\n if (hook._record || hook._lane) {\n detachSelectorHookBinding(hook);\n }\n\n attachSelectorHookBinding(hook, hook._source, hook._equals);\n return hook._record!;\n}\n\nfunction createSelectorHook<T>(\n instance: ComponentInstance,\n hookIndex: number,\n source: () => T,\n equals: SelectorEquals<T>\n): SelectorHook<T> {\n const hook = function selectorPredicate(candidate: T): boolean {\n const selectorHook = hook as SelectorHook<T>;\n const record = ensureSelectorHookBinding(selectorHook);\n const lane = selectorHook._lane;\n if (!lane) {\n throw new Error('selector() binding could not be established.');\n }\n\n const sourceRef = getCandidateSource(lane, candidate);\n recordReadableRead(sourceRef);\n\n const perfMetricsStore = getPerfMetricsStore();\n if (perfMetricsStore) {\n perfMetricsStore.selectorCandidateReads += 1;\n }\n\n const current =\n record._dirty || !record._hasValue\n ? recomputeSelectorSourceRecord(record, record._scheduled)\n : record._value;\n\n return lane._equals(current, candidate);\n } as SelectorHook<T>;\n\n hook._owner = instance;\n hook._hookIndex = hookIndex;\n hook._source = source;\n hook._equals = equals;\n hook._record = null;\n hook._lane = null;\n hook._cleanup = () => {\n detachSelectorHookBinding(hook);\n };\n\n attachSelectorHookBinding(hook, source, equals);\n\n (instance.cleanupFns ??= []).push(() => {\n hook._cleanup();\n selectorCells.get(instance)?.delete(hookIndex);\n });\n\n return hook;\n}\n\nfunction getOrCreateSelectorHook<T>(\n instance: ComponentInstance,\n hookIndex: number,\n source: () => T,\n equals: SelectorEquals<T>\n): SelectorHook<T> {\n const store = getSelectorStore(instance);\n const existing = store.get(hookIndex) as SelectorHook<T> | undefined;\n if (existing) {\n if (existing._source !== source || existing._equals !== equals) {\n detachSelectorHookBinding(existing);\n attachSelectorHookBinding(existing, source, equals);\n } else {\n ensureSelectorHookBinding(existing);\n }\n return existing;\n }\n\n const created = createSelectorHook(instance, hookIndex, source, equals);\n store.set(hookIndex, created as unknown as SelectorHook<unknown>);\n return created;\n}\n\nexport function selector<T>(\n source: () => T,\n equals: SelectorEquals<T> = Object.is\n): Selector<T> {\n markReadableUsage(source);\n\n const instance = getCurrentInstance();\n if (!instance) {\n throw new Error(\n 'selector() can only be called during component render execution. ' +\n 'Move selector() calls to the top level of your component function.'\n );\n }\n\n const hookIndex = claimHookIndex(instance, 'selector');\n const hook = getOrCreateSelectorHook(instance, hookIndex, source, equals);\n if (!hook._record) {\n throw new Error('selector() record binding was not established.');\n }\n\n if (!hook._record._hasValue) {\n // Initialize the shared source once so downstream selectors can subscribe,\n // but do not consume a pending dirty state on later renders.\n recomputeSelectorSourceRecord(hook._record, false);\n }\n return hook;\n}\n"],"mappings":";;;;;;AA0EA,MAAM,gCAAgB,IAAI,QAGxB;AACF,MAAM,kCAAkB,IAAI,QAG1B;AACF,MAAM,uCAAuB,IAAI,IAAmC;AACpE,IAAI,0BAA0B;AAE9B,SAAS,iBACP,UACoC;CACpC,IAAI,QAAQ,cAAc,IAAI,QAAQ;CACtC,IAAI,CAAC,OAAO;EACV,wBAAQ,IAAI,IAAI;EAChB,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BAAmB;CACpC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,qIAEF;CAIF,MAAM,OAAO,wBAAwB,UADnB,eAAe,UAAU,UACI,GAAW,QAAQ,MAAM;CACxE,IAAI,CAAC,KAAK,SACR,MAAM,IAAI,MAAM,gDAAgD;CAGlE,IAAI,CAAC,KAAK,QAAQ,WAGhB,8BAA8B,KAAK,SAAS,KAAK;CAEnD,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-source.d.ts","names":[],"sources":["../../src/runtime/snapshot-source.ts"],"mappings":";cAAa,qBAAA;AAAA,KAED,mBAAA;EAAA,UACA,qBAAqB;AAAA;AAAA,iBAGjB,mBAAA,mBACd,KAAA,EAAO,CAAA,GACN,CAAA,GAAI,mBAAA;AAAA,iBASS,gBAAA,CAAiB,KAAA,YAAiB,KAAA,IAAS,mBAAmB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-source.js","names":[],"sources":["../../src/runtime/snapshot-source.ts"],"sourcesContent":["export const SNAPSHOT_SOURCE_BRAND = Symbol.for('__ASKR_SNAPSHOT_SOURCE__');\n\nexport type SnapshotSourceBrand = {\n readonly [SNAPSHOT_SOURCE_BRAND]: true;\n};\n\nexport function brandSnapshotSource<T extends object>(\n value: T\n): T & SnapshotSourceBrand {\n Object.defineProperty(value, SNAPSHOT_SOURCE_BRAND, {\n value: true,\n enumerable: false,\n configurable: false,\n });\n return value as T & SnapshotSourceBrand;\n}\n\nexport function isSnapshotSource(value: unknown): value is SnapshotSourceBrand {\n return (\n !!value &&\n typeof value === 'object' &&\n (value as Record<PropertyKey, unknown>)[SNAPSHOT_SOURCE_BRAND] === true\n );\n}\n"],"mappings":";AAAA,MAAa,wBAAwB,OAAO,IAAI,0BAA0B;AAM1E,SAAgB,oBACd,OACyB;CACzB,OAAO,eAAe,OAAO,uBAAuB;EAClD,OAAO;EACP,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO;AACT;AAEA,SAAgB,iBAAiB,OAA8C;CAC7E,OACE,CAAC,CAAC,SACF,OAAO,UAAU,YAChB,MAAuC,2BAA2B;AAEvE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","names":[],"sources":["../../src/runtime/state.ts"],"mappings":";;;;;;;;;;UAkCiB,KAAA,YAAiB,cAAA,CAAe,CAAA;EAAA,IAC3C,CAAA;EACJ,GAAA,IAAO,IAAA,EAAM,eAAA,CAAgB,CAAA;EAAA,CAC5B,MAAA,CAAO,QAAA,KAAa,gBAAA,CAAiB,UAAA,CAAW,CAAA;AAAA;AAAA,KAG9C,YAAA,OAAmB,IAAA,EAAM,CAAA,KAAM,CAAC;AAAA,KAEhC,eAAA,OAAsB,OAAA,CAAQ,CAAA,MAAO,IAAA,yCAGrC,KAAA,EAAO,CAAA,KAAM,OAAA,EAAS,YAAA,CAAa,CAAA,MACnC,OAAA,EAAS,YAAA,CAAa,CAAA;;;;KAKf,WAAA,UAAqB,IAAA,EAAM,eAAe,CAAC,CAAA;AAbtD;;;AAAA,KAkBW,UAAA,OAAiB,GAAA,EAAK,KAAA,CAAM,CAAA,GAAI,GAAA,EAAK,WAAA,CAAY,CAAA,KAAM,KAAA,CAAM,CAAA;;;;;;AAhBpC;AAAA;;;;;;;;;;;;;;;;;;;;iBA4CrB,KAAA,IAAS,YAAA,EAAc,CAAA,GAAI,UAAA,CAAW,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","names":[],"sources":["../../src/runtime/state.ts"],"sourcesContent":["/**\n * State primitive for Askr components\n * Optimized for minimal overhead and fast updates\n *\n * INVARIANTS ENFORCED:\n * - state() only callable during component render (currentInstance exists)\n * - state() called at top-level only (indices must be monotonically increasing)\n * - state values persist across re-renders (stored in stateValues array)\n * - state.set() cannot be called during render (causes infinite loops)\n * - state.set() always enqueues through scheduler (never direct mutation)\n * - state.set() callback (notifyUpdate) always available\n */\n\nimport {\n claimHookIndex,\n getCurrentInstance,\n type ComponentInstance,\n} from './component';\nimport { isBulkCommitActive } from './fastlane';\nimport {\n recordReadableRead,\n type ReadableSource,\n markReadableDerivedSubscribersDirty,\n markReactivePropsDirtySource,\n notifyReadableReaders,\n} from './readable';\n\n/**\n * State value holder - callable to read, has set method to update\n * @example\n * const count = state(0);\n * count(); // read: 0\n * count.set(1); // write: triggers re-render\n */\nexport interface State<T> extends ReadableSource<T> {\n (): T;\n set(...args: StateSetterArgs<T>): void;\n [Symbol.iterator](): IterableIterator<StateTuple<T>[number]>; // Allows destructuring: const [get, set] = state(0)\n}\n\ntype StateUpdater<T> = (prev: T) => T;\n\ntype StateSetterArgs<T> = [Extract<T, (...args: any[]) => unknown>] extends [\n never,\n]\n ? [value: T] | [updater: StateUpdater<T>]\n : [updater: StateUpdater<T>];\n\n/**\n * Public setter type for state cells.\n */\nexport type StateSetter<T> = (...args: StateSetterArgs<T>) => void;\n\n/**\n * Tuple-first state handle returned by `state()`.\n */\nexport type StateTuple<T> = [get: State<T>, set: StateSetter<T>] & State<T>;\n\n/**\n * Creates a local state value for a component\n * Optimized for:\n * - O(1) read performance\n * - Minimal allocation per state\n * - Fast scheduler integration\n *\n * IMPORTANT: state() must be called during component render execution.\n * It captures the current component instance from context.\n * Calling outside a component function will throw an error.\n *\n * @example\n * ```ts\n * // ✅ Correct: called during render\n * export function Counter() {\n * const [count, setCount] = state(0);\n * return { type: 'button', children: [count()] };\n * }\n *\n * // ❌ Wrong: called outside component\n * const count = state(0);\n * export function BadComponent() {\n * return { type: 'div' };\n * }\n * ```\n */\nexport function state<T>(initialValue: T): StateTuple<T> {\n // INVARIANT: state() must be called during component render\n const instance = getCurrentInstance();\n if (!instance) {\n throw new Error(\n 'state() can only be called during component render execution. ' +\n 'Move state() calls to the top level of your component function.'\n );\n }\n\n const index = claimHookIndex(instance, 'state');\n const stateValues = instance.stateValues;\n\n // INVARIANT: Reuse existing state if it exists (fast path on re-renders)\n // This ensures state identity and persistence and enforces ownership stability\n if (stateValues[index]) {\n const existing = stateValues[index] as State<T> & {\n _owner?: ComponentInstance;\n };\n // Ownership must be stable: the state cell belongs to the instance that\n // created it and must never change. This checks for accidental reuse.\n if (existing._owner !== instance) {\n throw new Error(\n `State ownership violation: state() called at index ${index} is owned by a different component instance. ` +\n `State ownership is positional and immutable.`\n );\n }\n return existing as StateTuple<T>;\n }\n\n // Create new state (slow path, only on first render) — delegated to helper\n const cell = createStateCell(initialValue, instance);\n\n // INVARIANT: Store state in instance for persistence across renders\n stateValues[index] = cell as unknown as State<unknown>;\n\n return cell as StateTuple<T>;\n}\n\n/**\n * Internal helper: create the backing state cell (value + readers + set semantics)\n * This extraction makes it easier to later split hook wiring from storage.\n */\nfunction createStateCell<T>(\n initialValue: T,\n instance: ComponentInstance\n): State<T> {\n let value = initialValue;\n\n // Per-state reader map: component -> last-committed render token\n const readers = new Map<ComponentInstance, number>();\n\n // Use a function as the state object (callable directly)\n function read(): T {\n (read as State<T>)._hasBeenRead = true;\n recordReadableRead(read as State<T>);\n\n return value;\n }\n\n // Attach the readers map to the callable so other runtime parts can access it\n (read as State<T>)._readers = readers;\n\n // Record explicit ownership of this state cell. Ownership is the component\n // instance that created the state cell and must never change for the life\n // of the cell. We expose this for runtime invariant checks/tests.\n (read as State<T> & { _owner?: ComponentInstance })._owner = instance;\n\n // Attach set method directly to function\n read.set = (newValueOrUpdater: T | ((prev: T) => T)): void => {\n // INVARIANT: State cannot be mutated during component render\n // (when currentInstance is non-null). It must be scheduled for consistency.\n const currentInst = getCurrentInstance();\n if (currentInst !== null) {\n throw new Error(\n `[Askr] state.set() cannot be called during component render. ` +\n `State mutations during render break the actor model and cause infinite loops. ` +\n `Move state updates to event handlers or use conditional rendering instead.`\n );\n }\n\n // Compute new value if an updater was provided\n let newValue: T;\n if (typeof newValueOrUpdater === 'function') {\n // Note: function-valued state cannot be set directly via a function argument;\n // such an argument is treated as a functional updater (this follows the common\n // convention from other libraries). If you need to store a function as state,\n // wrap it in an object.\n const updater = newValueOrUpdater as (prev: T) => T;\n newValue = updater(value);\n } else {\n newValue = newValueOrUpdater as T;\n }\n\n // Skip work if value didn't change\n if (Object.is(value, newValue)) return;\n\n // If a bulk commit is active, update backing value only and DO NOT notify or enqueue.\n // Bulk commits must be side-effect silent with respect to runtime notifications.\n if (isBulkCommitActive()) {\n // In bulk commit mode we must be side-effect free: update backing\n // value only and do not notify, enqueue, or log.\n value = newValue;\n return;\n }\n\n // INVARIANT: Update the value\n value = newValue;\n\n markReadableDerivedSubscribersDirty(read as State<T>);\n markReactivePropsDirtySource(read as State<T>);\n\n // notifyUpdate may be temporarily unavailable (e.g. during hydration).\n // We intentionally avoid logging here to keep the state mutation path\n // side-effect free. The scheduler will process updates when the system\n // is stable.\n // After value change, notify only components that *read* this state in their last committed render.\n void notifyReadableReaders(read as State<T>);\n };\n\n // Allow destructuring assignment: const [get, set] = state(0);\n // The state function is iterable and yields the getter then the setter\n (\n read as unknown as {\n [Symbol.iterator]?: () => Iterator<State<T> | State<T>['set']>;\n }\n )[Symbol.iterator] = function* (): Generator<\n State<T> | State<T>['set'],\n void,\n unknown\n > {\n yield read;\n yield read.set;\n };\n\n return read as State<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAgB,MAAS,cAAgC;CAEvD,MAAM,WAAW,mBAAmB;CACpC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,+HAEF;CAGF,MAAM,QAAQ,eAAe,UAAU,OAAO;CAC9C,MAAM,cAAc,SAAS;CAI7B,IAAI,YAAY,QAAQ;EACtB,MAAM,WAAW,YAAY;EAK7B,IAAI,SAAS,WAAW,UACtB,MAAM,IAAI,MACR,sDAAsD,MAAM,0FAE9D;EAEF,OAAO;CACT;CAGA,MAAM,OAAO,gBAAgB,cAAc,QAAQ;CAGnD,YAAY,SAAS;CAErB,OAAO;AACT;;;;;AAMA,SAAS,gBACP,cACA,UACU;CACV,IAAI,QAAQ;CAGZ,MAAM,0BAAU,IAAI,IAA+B;CAGnD,SAAS,OAAU;EACjB,KAAmB,eAAe;EAClC,mBAAmB,IAAgB;EAEnC,OAAO;CACT;CAGA,KAAmB,WAAW;CAK9B,KAAoD,SAAS;CAG7D,KAAK,OAAO,sBAAkD;EAI5D,IADoB,mBAChB,MAAgB,MAClB,MAAM,IAAI,MACR,uNAGF;EAIF,IAAI;EACJ,IAAI,OAAO,sBAAsB,YAM/B,WAAW,kBAAQ,KAAK;OAExB,WAAW;EAIb,IAAI,OAAO,GAAG,OAAO,QAAQ,GAAG;EAIhC,IAAI,mBAAmB,GAAG;GAGxB,QAAQ;GACR;EACF;EAGA,QAAQ;EAER,oCAAoC,IAAgB;EACpD,6BAA6B,IAAgB;EAO7C,AAAK,sBAAsB,IAAgB;CAC7C;CAIA,KAIE,OAAO,YAAY,aAInB;EACA,MAAM;EACN,MAAM,KAAK;CACb;CAEA,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batch-render.js","names":[],"sources":["../../src/ssg/batch-render.ts"],"sourcesContent":["/**\n * Batch rendering of multiple routes for SSG\n */\n\nimport { renderToString } from '../ssr';\nimport { renderDocument, type DocumentRenderer } from '../common/ssr';\nimport type { RouteConfig, RouteRenderResult } from './types';\nimport type { RouteHandler } from '../common/router';\nimport type { ComponentFunction } from '../common/component';\nimport type { SSRData } from '../common/ssr';\nimport { resolveSsgRouteData } from './resolve-ssg-data';\nimport { getOutputFilePath, interpolateRoutePath } from './route-utils';\n\ninterface BatchRenderOptions {\n seed?: number;\n dataMap?: Record<string, SSRData>;\n concurrency?: number;\n document?: DocumentRenderer;\n}\n\n/**\n * Render multiple routes in parallel with error handling\n */\nexport async function batchRenderRoutes(\n routes: RouteConfig[],\n options: BatchRenderOptions = {}\n): Promise<RouteRenderResult[]> {\n const { seed = 12345, dataMap = {}, concurrency = 1, document } = options;\n\n const workerCount = Math.max(1, Math.min(concurrency, routes.length || 1));\n const results: RouteRenderResult[] = [];\n results.length = routes.length;\n let nextIndex = 0;\n\n const renderOne = async (route: RouteConfig): Promise<RouteRenderResult> => {\n const startTime = performance.now();\n const url = interpolateRoutePath(route.path, route.params);\n const requestUrl = new URL(url, 'http://localhost');\n const resolvedData = resolveSsgRouteData(dataMap, route.path, url);\n const baseData = resolvedData.hasData ? resolvedData.data : undefined;\n const resourceCount =\n resolvedData.hasData && baseData ? Object.keys(baseData).length : 0;\n\n const mergedHandler: RouteHandler = route.handler\n ? route.handler\n : (params, ctx?: unknown) => {\n const component = route.component as ComponentFunction;\n return component(\n { ...route.props, ...params },\n ctx as Parameters<ComponentFunction>[1]\n );\n };\n\n try {\n const routeEntry = {\n path: route.path,\n handler: mergedHandler,\n namespace: route.namespace,\n };\n\n const html = renderToString({\n url,\n routes: [routeEntry],\n seed,\n data: baseData,\n document:\n document === undefined\n ? undefined\n : ({ appHtml }) =>\n renderDocument(\n document,\n {\n appHtml,\n context: {\n mode: 'ssg',\n url,\n pathname: requestUrl.pathname,\n search: requestUrl.search,\n hash: requestUrl.hash,\n params: route.params ?? {},\n data: baseData,\n seed,\n route: {\n path: route.path,\n namespace: route.namespace,\n },\n },\n },\n 'createStaticGen()'\n ),\n });\n\n const duration = performance.now() - startTime;\n return {\n path: url,\n filePath: getOutputFilePath(url),\n html,\n fileSize: Buffer.byteLength(html, 'utf8'),\n renderDuration: Math.round(duration),\n resourceCount,\n status: 'success',\n reason: 'full',\n written: false,\n };\n } catch (error) {\n const duration = performance.now() - startTime;\n return {\n path: url,\n filePath: getOutputFilePath(url),\n html: '',\n fileSize: 0,\n renderDuration: Math.round(duration),\n resourceCount,\n status: 'error',\n reason: 'full',\n written: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n };\n\n const worker = async () => {\n while (true) {\n const current = nextIndex;\n nextIndex += 1;\n if (current >= routes.length) return;\n results[current] = await renderOne(routes[current]);\n }\n };\n\n await Promise.all(Array.from({ length: workerCount }, () => worker()));\n return results;\n}\n"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;;;;;;iBAiEd,eAAA,gCACiB,cAAA,IAE/B,OAAA,EAAS,IAAA,CAAK,UAAA,CAAW,OAAA,4BACvB,oBAAA,CAAqB,OAAA;EAhEnB;;;;;6BA0FiB,kBAAA,GAChB,OAAA,CAAQ,SAAA;EA5FI;;;;;;;;;;;EAKM;;;;eA+TR,SAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-static-gen.js","names":[],"sources":["../../src/ssg/create-static-gen.ts"],"sourcesContent":["/**\n * Static Site Generation API\n *\n * Main orchestrator for batch rendering, file I/O, and metadata generation\n */\n\nimport type {\n RouteConfig,\n RouteRenderResult,\n SSGGenerateOptions,\n SSGMode,\n SSGOptions,\n SSGResult,\n} from './types';\nimport type { RouteRegistry } from '../common/router';\nimport {\n resolveSsgRouteData,\n resolveSsgData,\n validateRoutes,\n} from './resolve-ssg-data';\nimport { batchRenderRoutes } from './batch-render';\nimport { writeStaticFiles } from './write-static-files';\nimport {\n generateSSGResult,\n resultToMetadata,\n writeMetadata,\n} from './generate-metadata';\nimport {\n getExistingOutputFileSize,\n outputFileExists,\n readIncrementalManifest,\n type IncrementalManifestRouteEntry,\n writeIncrementalManifest,\n hashHtml,\n SSG_MANIFEST_SCHEMA_VERSION,\n} from './incremental-manifest';\nimport { resolveRouteDescriptor } from './route-utils';\nimport {\n collectRemovedRouteResults,\n dedupeStrings,\n getRoutesToRender,\n selectRouteForGeneration,\n type SelectedRoute,\n} from './generation-plan';\nimport { normalizeStaticRoutes, splitStaticRoutes } from './static-routes';\nimport { addPerfDuration, incrementPerfMetric } from '../runtime/perf-metrics';\n\ntype AnyRouteConfig = RouteConfig<string>;\n\ntype StrictRouteConfig<TRoute extends AnyRouteConfig> = Omit<\n TRoute,\n 'params' | 'entries'\n> & {\n params?: RouteConfig<TRoute['path']>['params'];\n entries?: RouteConfig<TRoute['path']>['entries'];\n};\n\ntype StrictRouteConfigs<TRoutes extends readonly AnyRouteConfig[]> = {\n [TIndex in keyof TRoutes]: TRoutes[TIndex] extends AnyRouteConfig\n ? StrictRouteConfig<TRoutes[TIndex]>\n : never;\n};\n\ntype StaticGenRouteSource<TRoutes extends readonly AnyRouteConfig[]> =\n | {\n routes: TRoutes & StrictRouteConfigs<TRoutes>;\n registry?: never;\n }\n | {\n registry: RouteRegistry;\n routes?: never;\n };\n\nfunction resolveParallelism(requested: number | 'auto' | undefined): number {\n if (requested !== 'auto') {\n return Math.max(1, requested ?? 1);\n }\n\n const maybeNavigator = globalThis as typeof globalThis & {\n navigator?: { hardwareConcurrency?: number };\n process?: { env?: Record<string, string | undefined> };\n };\n\n const envWorkers = Number(\n maybeNavigator.process?.env?.ASKR_SSG_WORKERS ??\n maybeNavigator.process?.env?.NUMBER_OF_PROCESSORS ??\n maybeNavigator.process?.env?.UV_THREADPOOL_SIZE\n );\n if (Number.isFinite(envWorkers) && envWorkers > 0) {\n return Math.max(1, Math.trunc(envWorkers));\n }\n\n if (typeof maybeNavigator.navigator?.hardwareConcurrency === 'number') {\n return Math.max(1, maybeNavigator.navigator.hardwareConcurrency);\n }\n\n return 1;\n}\n\n/**\n * Create a Static Site Generator\n *\n * Usage:\n * ```ts\n * const ssg = createStaticGen({\n * routes: [\n * { path: '/', component: HomePage },\n * { path: '/about', component: AboutPage },\n * ],\n * outputDir: './dist',\n * dataOverrides: {\n * '/api/posts': { posts: [...] }\n * }\n * });\n *\n * const result = await ssg.generate();\n * console.log(`Generated ${result.successful}/${result.totalRoutes} routes`);\n * ```\n */\nexport function createStaticGen<\n const TRoutes extends readonly AnyRouteConfig[],\n>(\n options: Omit<SSGOptions<TRoutes>, 'routes' | 'registry'> &\n StaticGenRouteSource<TRoutes>\n) {\n let result: SSGResult | null = null;\n const configuredRoutes = normalizeStaticRoutes(options);\n const seed = options.seed ?? 12345;\n const resolvedParallelism = resolveParallelism(options.parallelism);\n const resolvedConcurrency = Math.max(\n 1,\n options.concurrency ?? resolvedParallelism\n );\n\n if (configuredRoutes.length === 0) {\n throw new Error('routes array or route registry is required');\n }\n\n if (!options.outputDir || options.outputDir.trim().length === 0) {\n throw new Error('outputDir is required');\n }\n\n return {\n /**\n * Generate static HTML for all routes\n * Writes to outputDir with metadata.json\n * Returns detailed results\n */\n async generate(\n generateOptions: SSGGenerateOptions = {}\n ): Promise<SSGResult> {\n const splitRoutes = await splitStaticRoutes(configuredRoutes);\n const routes = splitRoutes.routes;\n validateRoutes(routes);\n\n const changedKeys = dedupeStrings(generateOptions.changedKeys);\n const changedRoutes = dedupeStrings(generateOptions.changedRoutes);\n const requestedMode = generateOptions.mode ?? 'full';\n const previousManifest =\n !generateOptions.forceFull && requestedMode === 'incremental'\n ? readIncrementalManifest(options.outputDir, seed)\n : null;\n const effectiveMode: SSGMode =\n generateOptions.forceFull ||\n requestedMode !== 'incremental' ||\n previousManifest === null\n ? 'full'\n : 'incremental';\n\n // Resolve data\n const dataMap = resolveSsgData(routes, {\n dataOverrides: options.dataOverrides,\n });\n\n const descriptors = routes.map(resolveRouteDescriptor);\n const routeResultsById = new Map<string, RouteRenderResult>();\n for (const runtimeRoute of splitRoutes.runtimeOnly) {\n routeResultsById.set(runtimeRoute.routeId, runtimeRoute.result);\n }\n const eligibleDescriptors = descriptors;\n\n const previousEntries = new Map(\n (previousManifest?.routes ?? []).map((entry) => [entry.routeId, entry])\n );\n const currentRouteIds = new Set(\n eligibleDescriptors.map((descriptor) => descriptor.routeId)\n );\n\n const selected: SelectedRoute[] = [];\n const routesToRender: SelectedRoute[] = [];\n for (let index = 0; index < eligibleDescriptors.length; index += 1) {\n const descriptor = eligibleDescriptors[index];\n const entry = selectRouteForGeneration(\n descriptor,\n previousEntries.get(descriptor.routeId) ?? null,\n effectiveMode,\n changedKeys,\n changedRoutes\n );\n selected.push(entry);\n if (entry.reason !== 'unchanged') {\n routesToRender.push(entry);\n }\n }\n const renderStartTime = performance.now();\n incrementPerfMetric('ssgWorkerCount', resolvedParallelism);\n const renderedResults =\n routesToRender.length > 0\n ? await batchRenderRoutes(getRoutesToRender(routesToRender), {\n seed,\n dataMap,\n concurrency: resolvedConcurrency,\n document: options.document,\n })\n : [];\n addPerfDuration('ssgRenderTimeMs', performance.now() - renderStartTime);\n const renderedByRouteId = new Map<string, RouteRenderResult>();\n for (let index = 0; index < renderedResults.length; index += 1) {\n renderedByRouteId.set(\n routesToRender[index].descriptor.routeId,\n renderedResults[index]\n );\n }\n\n let cacheHits = 0;\n const nextManifestRoutes: IncrementalManifestRouteEntry[] = [];\n\n for (const entry of selected) {\n const { descriptor, previous, reason } = entry;\n const resolvedData = resolveSsgRouteData(\n dataMap,\n descriptor.route.path,\n descriptor.path\n );\n const baseData = resolvedData.hasData ? resolvedData.data : undefined;\n const resourceCount =\n resolvedData.hasData && baseData ? Object.keys(baseData).length : 0;\n\n if (reason === 'unchanged') {\n routeResultsById.set(descriptor.routeId, {\n path: descriptor.path,\n filePath: descriptor.filePath,\n html: '',\n fileSize:\n previous?.htmlHash !== null && previous !== null\n ? getExistingOutputFileSize(\n options.outputDir,\n descriptor.filePath\n )\n : 0,\n renderDuration: 0,\n resourceCount,\n status: 'skipped',\n reason: 'unchanged',\n written: false,\n });\n\n if (previous) {\n nextManifestRoutes.push({\n ...previous,\n path: descriptor.path,\n filePath: descriptor.filePath,\n invalidationKeys: descriptor.invalidationKeys.slice(),\n });\n }\n continue;\n }\n\n const rendered = renderedByRouteId.get(descriptor.routeId);\n if (!rendered) {\n throw new Error(\n `Missing rendered result for route \"${descriptor.path}\"`\n );\n }\n\n const nextResult: RouteRenderResult = {\n ...rendered,\n path: descriptor.path,\n filePath: descriptor.filePath,\n resourceCount,\n reason,\n written: false,\n };\n\n if (nextResult.status === 'success') {\n const htmlDigest = hashHtml(nextResult.html);\n const shouldWrite =\n effectiveMode === 'full' ||\n !previous ||\n previous.htmlHash !== htmlDigest ||\n !outputFileExists(options.outputDir, descriptor.filePath);\n\n nextResult.written = shouldWrite;\n if (!shouldWrite) {\n cacheHits += 1;\n }\n\n nextManifestRoutes.push({\n routeId: descriptor.routeId,\n path: descriptor.path,\n filePath: descriptor.filePath,\n invalidationKeys: descriptor.invalidationKeys.slice(),\n htmlHash: htmlDigest,\n lastStatus: 'success',\n });\n } else {\n nextManifestRoutes.push({\n routeId: descriptor.routeId,\n path: descriptor.path,\n filePath: descriptor.filePath,\n invalidationKeys: descriptor.invalidationKeys.slice(),\n htmlHash: previous?.htmlHash ?? null,\n lastStatus: 'error',\n });\n }\n\n routeResultsById.set(descriptor.routeId, nextResult);\n }\n\n const removedResults = collectRemovedRouteResults(\n previousManifest,\n currentRouteIds\n );\n const routeResults: RouteRenderResult[] = [];\n for (const routeId of splitRoutes.outputRouteIds) {\n const routeResult = routeResultsById.get(routeId);\n if (routeResult) {\n routeResults.push(routeResult);\n }\n }\n routeResults.push(...removedResults);\n\n // Write HTML files to disk and remove stale output\n const writeStartTime = performance.now();\n await writeStaticFiles(routeResults, options.outputDir, {\n concurrency: resolvedConcurrency,\n });\n addPerfDuration('ssgWriteTimeMs', performance.now() - writeStartTime);\n\n // Generate result object\n result = generateSSGResult(routeResults, {\n mode: effectiveMode,\n cacheHits,\n invalidatedKeys: changedKeys,\n invalidatedRoutes: changedRoutes,\n });\n\n // Write metadata\n const metadata = resultToMetadata(result);\n await writeMetadata(metadata, options.outputDir);\n\n await writeIncrementalManifest(\n {\n schemaVersion: SSG_MANIFEST_SCHEMA_VERSION,\n seed,\n mode: effectiveMode,\n routes: nextManifestRoutes,\n },\n options.outputDir\n );\n\n return result;\n },\n\n /**\n * Get effective config in a serializable form for diagnostics.\n */\n getConfig() {\n return {\n routeCount: configuredRoutes.length,\n outputDir: options.outputDir,\n seed,\n concurrency: resolvedConcurrency,\n parallelism: resolvedParallelism,\n hasDataOverrides: !!options.dataOverrides,\n };\n },\n\n /**\n * Get the last generation result\n * Returns null if generate() hasn't been called\n */\n getResult(): SSGResult | null {\n return result;\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAyEA,SAAS,mBAAmB,WAAgD;CAC1E,IAAI,cA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,YAAY;KAChC,YAAY;IACd,CAAC;IAGH,iBAAiB,IAAI,WAAW,SAAS,UAAU;GACrD;GAEA,MAAM,iBAAiB,2BACrB,kBACA,eACF;GACA,MAAM,eAAoC,CAAC;GAC3C,KAAK,MAAM,WAAW,YAAY,gBAAgB;IAChD,MAAM,cAAc,iBAAiB,IAAI,OAAO;IAChD,IAAI,aACF,aAAa,KAAK,WAAW;GAEjC;GACA,aAAa,KAAK,GAAG,cAAc;GAGnC,MAAM,iBAAiB,YAAY,IAAI;GACvC,MAAM,iBAAiB,cAAc,QAAQ,WAAW,EACtD,aAAa,oBACf,CAAC;GACD,gBAAgB,kBAAkB,YAAY,IAAI,IAAI,cAAc;GAGpE,SAAS,kBAAkB,cAAc;IACvC,MAAM;IACN;IACA,iBAAiB;IACjB,mBAAmB;GACrB,CAAC;GAID,MAAM,cADW,iBAAiB,MACd,GAAU,QAAQ,SAAS;GAE/C,MAAM,yBACJ;IACE,eAAA;IACA;IACA,MAAM;IACN,QAAQ;GACV,GACA,QAAQ,SACV;GAEA,OAAO;EACT;;;;EAKA,YAAY;GACV,OAAO;IACL,YAAY,iBAAiB;IAC7B,WAAW,QAAQ;IACnB;IACA,aAAa;IACb,aAAa;IACb,kBAAkB,CAAC,CAAC,QAAQ;GAC9B;EACF;;;;;EAMA,YAA8B;GAC5B,OAAO;EACT;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-metadata.js","names":[],"sources":["../../src/ssg/generate-metadata.ts"],"sourcesContent":["/**\n * Metadata generation for SSG\n *\n * Generates and serializes metadata about generated static files.\n * This module is Node-only and not intended for browser builds.\n */\n\nimport * as fs from 'node:fs/promises';\nimport * as pathModule from 'node:path';\nimport type {\n RouteRenderResult,\n SSGMetadata,\n SSGMode,\n SSGResult,\n} from './types';\n\ninterface GenerateResultOptions {\n mode?: SSGMode;\n cacheHits?: number;\n invalidatedKeys?: string[];\n invalidatedRoutes?: string[];\n}\n\n/**\n * Generate SSGResult from render results\n */\nexport function generateSSGResult(\n results: RouteRenderResult[],\n options: GenerateResultOptions = {}\n): SSGResult {\n let successful = 0;\n let failed = 0;\n let totalDuration = 0;\n let rebuilt = 0;\n let skipped = 0;\n let removed = 0;\n\n for (let index = 0; index < results.length; index += 1) {\n const result = results[index];\n totalDuration += result.renderDuration;\n\n if (result.status === 'success') {\n successful += 1;\n rebuilt += 1;\n } else if (result.status === 'error') {\n failed += 1;\n rebuilt += 1;\n } else if (result.status === 'skipped') {\n skipped += 1;\n } else if (result.status === 'removed') {\n removed += 1;\n }\n }\n\n return {\n generatedAt: new Date().toISOString(),\n totalRoutes: results.length,\n successful,\n failed,\n totalDuration: Math.round(totalDuration),\n mode: options.mode ?? 'full',\n rebuilt,\n skipped,\n removed,\n cacheHits: options.cacheHits ?? 0,\n invalidatedKeys: options.invalidatedKeys?.slice() ?? [],\n invalidatedRoutes: options.invalidatedRoutes?.slice() ?? [],\n routes: results,\n };\n}\n\n/**\n * Convert SSGResult to metadata for JSON serialization\n */\nexport function resultToMetadata(result: SSGResult): SSGMetadata {\n const routes: SSGMetadata['routes'] = [];\n\n for (let index = 0; index < result.routes.length; index += 1) {\n const route = result.routes[index];\n routes.push({\n path: route.path,\n filePath: route.filePath,\n fileSize: route.fileSize,\n renderDuration: route.renderDuration,\n resourceCount: route.resourceCount,\n status: route.status,\n reason: route.reason,\n written: route.written,\n error: route.error,\n });\n }\n\n return {\n generatedAt: result.generatedAt,\n totalRoutes: result.totalRoutes,\n successful: result.successful,\n failed: result.failed,\n totalDuration: result.totalDuration,\n mode: result.mode,\n rebuilt: result.rebuilt,\n skipped: result.skipped,\n removed: result.removed,\n cacheHits: result.cacheHits,\n invalidatedKeys: result.invalidatedKeys.slice(),\n invalidatedRoutes: result.invalidatedRoutes.slice(),\n routes,\n };\n}\n\n/**\n * Write metadata.json to output directory\n */\nexport async function writeMetadata(\n metadata: Record<string, unknown>,\n outputDir: string\n): Promise<void> {\n const filePath = pathModule.join(outputDir, 'metadata.json');\n\n // Ensure directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n // Write metadata file with formatting\n await fs.writeFile(filePath, JSON.stringify(metadata, null, 2), 'utf8');\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAgB,kBACd,SACA,UAAiC,CAAC,GACvB;CACX,IAAI,aAAa;CACjB,IAAI,SAAS;CACb,IAAI,gBAAgB;CACpB,IAAI,UAAU;CACd,IAAI,UAAU;CACd,IAAI,UAAU;CAEd,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,GAAG;EACtD,MAAM,SAAS,QAAQ;EACvB,iBAAiB,OAAO;EAExB,IAAI,OAAO,WAAW,WAAW;GAC/B,cAAc;GACd,WAAW;EACb,OAAO,IAAI,OAAO,WAAW,SAAS;GACpC,UAAU;GACV,WAAW;EACb,OAAO,IAAI,OAAO,WAAW,WAC3B,WAAW;OACN,IAAI,OAAO,WAAW,WAC3B,WAAW;CAEf;CAEA,OAAO;EACL,8BAAa,IAAI,KAAK,EAAC,CAAC,YAAY;EACpC,aAAa,QAAQ;EACrB;EACA;EACA,eAAe,KAAK,MAAM,aAAa;EACvC,MAAM,QAAQ,QAAQ;EACtB;EACA;EACA;EACA,WAAW,QAAQ,aAAa;EAChC,iBAAiB,QAAQ,iBAAiB,MAAM,KAAK,CAAC;EACtD,mBAAmB,QAAQ,mBAAmB,MAAM,KAAK,CAAC;EAC1D,QAAQ;CACV;AACF;;;;AAKA,SAAgB,iBAAiB,QAAgC;CAC/D,MAAM,SAAgC,CAAC;CAEvC,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,OAAO,QAAQ,SAAS,GAAG;EAC5D,MAAM,QAAQ,OAAO,OAAO;EAC5B,OAAO,KAAK;GACV,MAAM,MAAM;GACZ,UAAU,MAAM;GAChB,UAAU,MAAM;GAChB,gBAAgB,MAAM;GACtB,eAAe,MAAM;GACrB,QAAQ,MAAM;GACd,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,OAAO,MAAM;EACf,CAAC;CACH;CAEA,OAAO;EACL,aAAa,OAAO;EACpB,aAAa,OAAO;EACpB,YAAY,OAAO;EACnB,QAAQ,OAAO;EACf,eAAe,OAAO;EACtB,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,WAAW,OAAO;EAClB,iBAAiB,OAAO,gBAAgB,MAAM;EAC9C,mBAAmB,OAAO,kBAAkB,MAAM;EAClD;CACF;AACF;;;;AAKA,eAAsB,cACpB,UACA,WACe;CACf,MAAM,WAAW,WAAW,KAAK,WAAW,eAAe;CAG3D,MAAM,GAAG,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;CAG7C,MAAM,GAAG,UAAU,UAAU,KAAK,UAAU,UAAU,MAAM,CAAC,GAAG,MAAM;AACxE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generation-plan.js","names":[],"sources":["../../src/ssg/generation-plan.ts"],"sourcesContent":["/**\n * SSG incremental generation planning.\n */\n\nimport type {\n RouteConfig,\n RouteRenderReason,\n RouteRenderResult,\n SSGMode,\n} from './types';\nimport type {\n IncrementalManifest,\n IncrementalManifestRouteEntry,\n} from './incremental-manifest';\nimport type { ResolvedRouteDescriptor } from './route-utils';\n\nexport interface SelectedRoute {\n descriptor: ResolvedRouteDescriptor;\n reason: RouteRenderReason;\n previous: IncrementalManifestRouteEntry | null;\n}\n\nexport function dedupeStrings(values?: string[]): string[] {\n return values ? Array.from(new Set(values)) : [];\n}\n\nexport function getRoutesToRender(selected: SelectedRoute[]): RouteConfig[] {\n const routes: RouteConfig[] = [];\n for (let index = 0; index < selected.length; index += 1) {\n routes.push(selected[index].descriptor.route);\n }\n return routes;\n}\n\nexport function selectRouteForGeneration(\n descriptor: ResolvedRouteDescriptor,\n previous: IncrementalManifestRouteEntry | null,\n mode: SSGMode,\n changedKeys: string[],\n changedRoutes: string[]\n): SelectedRoute {\n if (mode === 'full') {\n return { descriptor, reason: 'full', previous };\n }\n\n if (!previous) {\n return { descriptor, reason: 'new-route', previous };\n }\n\n if (previous.lastStatus === 'error' || previous.htmlHash === null) {\n return { descriptor, reason: 'new-route', previous };\n }\n\n if (descriptor.invalidationKeys.length === 0) {\n return { descriptor, reason: 'no-keys', previous };\n }\n\n if (changedRoutes.includes(descriptor.path)) {\n return { descriptor, reason: 'changed-route', previous };\n }\n\n if (descriptor.invalidationKeys.some((key) => changedKeys.includes(key))) {\n return { descriptor, reason: 'changed-key', previous };\n }\n\n return { descriptor, reason: 'unchanged', previous };\n}\n\nexport function collectRemovedRouteResults(\n manifest: IncrementalManifest | null,\n currentRouteIds: Set<string>\n): RouteRenderResult[] {\n if (!manifest) {\n return [];\n }\n\n const results: RouteRenderResult[] = [];\n for (let index = 0; index < manifest.routes.length; index += 1) {\n const entry = manifest.routes[index];\n if (currentRouteIds.has(entry.routeId)) {\n continue;\n }\n results.push({\n path: entry.path,\n filePath: entry.filePath,\n html: '',\n fileSize: 0,\n renderDuration: 0,\n resourceCount: 0,\n status: 'removed' as const,\n reason: 'deleted' as const,\n written: false,\n });\n }\n\n return results;\n}\n"],"mappings":";AAsBA,SAAgB,cAAc,QAA6B;CACzD,OAAO,SAAS,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC;AACjD;AAEA,SAAgB,kBAAkB,UAA0C;CAC1E,MAAM,SAAwB,CAAC;CAC/B,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS,GACpD,OAAO,KAAK,SAAS,MAAM,CAAC,WAAW,KAAK;CAE9C,OAAO;AACT;AAEA,SAAgB,yBACd,YACA,UACA,MACA,aACA,eACe;CACf,IAAI,SAAS,QACX,OAAO;EAAE;EAAY,QAAQ;EAAQ;CAAS;CAGhD,IAAI,CAAC,UACH,OAAO;EAAE;EAAY,QAAQ;EAAa;CAAS;CAGrD,IAAI,SAAS,eAAe,WAAW,SAAS,aAAa,MAC3D,OAAO;EAAE;EAAY,QAAQ;EAAa;CAAS;CAGrD,IAAI,WAAW,iBAAiB,WAAW,GACzC,OAAO;EAAE;EAAY,QAAQ;EAAW;CAAS;CAGnD,IAAI,cAAc,SAAS,WAAW,IAAI,GACxC,OAAO;EAAE;EAAY,QAAQ;EAAiB;CAAS;CAGzD,IAAI,WAAW,iBAAiB,MAAM,QAAQ,YAAY,SAAS,GAAG,CAAC,GACrE,OAAO;EAAE;EAAY,QAAQ;EAAe;CAAS;CAGvD,OAAO;EAAE;EAAY,QAAQ;EAAa;CAAS;AACrD;AAEA,SAAgB,2BACd,UACA,iBACqB;CACrB,IAAI,CAAC,UACH,OAAO,CAAC;CAGV,MAAM,UAA+B,CAAC;CACtC,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,OAAO,QAAQ,SAAS,GAAG;EAC9D,MAAM,QAAQ,SAAS,OAAO;EAC9B,IAAI,gBAAgB,IAAI,MAAM,OAAO,GACnC;EAEF,QAAQ,KAAK;GACX,MAAM,MAAM;GACZ,UAAU,MAAM;GAChB,MAAM;GACN,UAAU;GACV,gBAAgB;GAChB,eAAe;GACf,QAAQ;GACR,QAAQ;GACR,SAAS;EACX,CAAC;CACH;CAEA,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"incremental-manifest.js","names":[],"sources":["../../src/ssg/incremental-manifest.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as fsPromises from 'node:fs/promises';\nimport * as pathModule from 'node:path';\nimport type { RouteRenderStatus, SSGMode } from './types';\n\nexport const SSG_MANIFEST_SCHEMA_VERSION = 1;\nconst MANIFEST_DIR = '.askr';\nconst MANIFEST_FILE = 'ssg-manifest.json';\n\nexport interface IncrementalManifestRouteEntry {\n routeId: string;\n path: string;\n filePath: string;\n invalidationKeys: string[];\n htmlHash: string | null;\n lastStatus: Extract<RouteRenderStatus, 'success' | 'error'>;\n}\n\nexport interface IncrementalManifest {\n schemaVersion: number;\n seed: number;\n mode: SSGMode;\n routes: IncrementalManifestRouteEntry[];\n}\n\nexport function hashHtml(html: string): string {\n // Deterministic 32-bit FNV-1a hash is sufficient for incremental change checks.\n let hash = 0x811c9dc5;\n for (let index = 0; index < html.length; index += 1) {\n hash ^= html.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n return (hash >>> 0).toString(16).padStart(8, '0');\n}\n\nexport function getIncrementalManifestPath(outputDir: string): string {\n return pathModule.join(outputDir, MANIFEST_DIR, MANIFEST_FILE);\n}\n\nexport function readIncrementalManifest(\n outputDir: string,\n seed: number\n): IncrementalManifest | null {\n const manifestPath = getIncrementalManifestPath(outputDir);\n if (!fs.existsSync(manifestPath)) {\n return null;\n }\n\n try {\n const raw = fs.readFileSync(manifestPath, 'utf8');\n const parsed = JSON.parse(raw) as Partial<IncrementalManifest>;\n\n if (\n parsed.schemaVersion !== SSG_MANIFEST_SCHEMA_VERSION ||\n parsed.seed !== seed ||\n !Array.isArray(parsed.routes)\n ) {\n return null;\n }\n\n const routes = parsed.routes.filter(\n (entry): entry is IncrementalManifestRouteEntry =>\n !!entry &&\n typeof entry.routeId === 'string' &&\n typeof entry.path === 'string' &&\n typeof entry.filePath === 'string' &&\n Array.isArray(entry.invalidationKeys) &&\n (entry.htmlHash === null || typeof entry.htmlHash === 'string') &&\n (entry.lastStatus === 'success' || entry.lastStatus === 'error')\n );\n\n if (routes.length !== parsed.routes.length) {\n return null;\n }\n\n return {\n schemaVersion: SSG_MANIFEST_SCHEMA_VERSION,\n seed,\n mode: parsed.mode === 'incremental' ? 'incremental' : 'full',\n routes,\n };\n } catch {\n return null;\n }\n}\n\nexport async function writeIncrementalManifest(\n manifest: IncrementalManifest,\n outputDir: string\n): Promise<void> {\n const manifestPath = getIncrementalManifestPath(outputDir);\n await fsPromises.mkdir(pathModule.dirname(manifestPath), { recursive: true });\n await fsPromises.writeFile(\n manifestPath,\n JSON.stringify(manifest, null, 2),\n 'utf8'\n );\n}\n\nexport function getExistingOutputFileSize(\n outputDir: string,\n filePath: string\n): number {\n const fullPath = pathModule.join(outputDir, filePath);\n if (!fs.existsSync(fullPath)) {\n return 0;\n }\n\n try {\n return fs.statSync(fullPath).size;\n } catch {\n return 0;\n }\n}\n\nexport function outputFileExists(outputDir: string, filePath: string): boolean {\n return fs.existsSync(pathModule.join(outputDir, filePath));\n}\n"],"mappings":";;;AAMA,MAAM,eAAe;AACrB,MAAM,gBAAgB;AAkBtB,SAAgB,SAAS,MAAsB;CAE7C,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,QAAQ,KAAK,WAAW,KAAK;EAC7B,OAAO,KAAK,KAAK,MAAM,QAAU;CACnC;CACA,QAAQ,SAAS,EAAA,CAAG,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AAClD;AAEA,SAAgB,2BAA2B,WAA2B;CACpE,OAAO,WAAW,KAAK,WAAW,cAAc,aAAa;AAC/D;AAEA,SAAgB,wBACd,WACA,MAC4B;CAC5B,MAAM,eAAe,2BAA2B,SAAS;CACzD,IAAI,CAAC,GAAG,WAAW,YAAY,GAC7B,OAAO;CAGT,IAAI;EACF,MAAM,MAAM,GAAG,aAAa,cAAc,MAAM;EAChD,MAAM,SAAS,KAAK,MAAM,GAAG;EAE7B,IACE,OAAO,kBAAA,KACP,OAAO,SAAS,QAChB,CAAC,MAAM,QAAQ,OAAO,MAAM,GAE5B,OAAO;EAGT,MAAM,SAAS,OAAO,OAAO,QAC1B,UACC,CAAC,CAAC,SACF,OAAO,MAAM,YAAY,YACzB,OAAO,MAAM,SAAS,YACtB,OAAO,MAAM,aAAa,YAC1B,MAAM,QAAQ,MAAM,gBAAgB,MACnC,MAAM,aAAa,QAAQ,OAAO,MAAM,aAAa,cACrD,MAAM,eAAe,aAAa,MAAM,eAAe,QAC5D;EAEA,IAAI,OAAO,WAAW,OAAO,OAAO,QAClC,OAAO;EAGT,OAAO;GACL,eAAA;GACA;GACA,MAAM,OAAO,SAAS,gBAAgB,gBAAgB;GACtD;EACF;CACF,QAAQ;EACN,OAAO;CACT;AACF;AAEA,eAAsB,yBACpB,UACA,WACe;CACf,MAAM,eAAe,2BAA2B,SAAS;CACzD,MAAM,WAAW,MAAM,WAAW,QAAQ,YAAY,GAAG,EAAE,WAAW,KAAK,CAAC;CAC5E,MAAM,WAAW,UACf,cACA,KAAK,UAAU,UAAU,MAAM,CAAC,GAChC,MACF;AACF;AAEA,SAAgB,0BACd,WACA,UACQ;CACR,MAAM,WAAW,WAAW,KAAK,WAAW,QAAQ;CACpD,IAAI,CAAC,GAAG,WAAW,QAAQ,GACzB,OAAO;CAGT,IAAI;EACF,OAAO,GAAG,SAAS,QAAQ,CAAC,CAAC;CAC/B,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAgB,iBAAiB,WAAmB,UAA2B;CAC7E,OAAO,GAAG,WAAW,WAAW,KAAK,WAAW,QAAQ,CAAC;AAC3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-ssg-data.js","names":[],"sources":["../../src/ssg/resolve-ssg-data.ts"],"sourcesContent":["/**\n * Data resolution for SSG\n *\n * Merges user-supplied data overrides with any auto-discovered resources.\n * In phase 1, primarily handles user-supplied data.\n */\n\nimport type { SSRData } from '../common/ssr';\nimport type { RouteConfig } from './types';\nimport { interpolateRoutePath } from './route-utils';\n\ninterface DataResolutionOptions {\n /** User-supplied data overrides per route path */\n dataOverrides?: Record<string, unknown>;\n}\n\nexport interface ResolvedSsgRouteData {\n hasData: boolean;\n data?: SSRData;\n}\n\nfunction hasOwnRouteData(\n dataMap: Record<string, SSRData>,\n path: string\n): boolean {\n return Object.prototype.hasOwnProperty.call(dataMap, path);\n}\n\n/**\n * Resolve and validate data for SSG routes\n * Returns a map of route path -> SSRData\n *\n * In phase 1: accepts user-supplied dataOverrides\n * In phase 2: can be extended to auto-discover resources\n */\nexport function resolveSsgData(\n routes: RouteConfig[],\n options: DataResolutionOptions = {}\n): Record<string, SSRData> {\n const { dataOverrides = {} } = options;\n const dataMap: Record<string, SSRData> = {};\n\n for (const route of routes) {\n const concretePath = interpolateRoutePath(route.path, route.params);\n const overridePath =\n concretePath in dataOverrides\n ? concretePath\n : route.path in dataOverrides\n ? route.path\n : null;\n\n // Check if user provided data for this route\n if (overridePath) {\n const data = dataOverrides[overridePath];\n if (typeof data !== 'object' || data === null || Array.isArray(data)) {\n throw new Error(\n `data for route \"${overridePath}\" must be an object, got ${typeof data}`\n );\n }\n dataMap[overridePath] = data as SSRData;\n }\n // In phase 1, routes without data are rendered with no SSR data\n // Phase 2 can add auto-discovery here\n }\n\n return dataMap;\n}\n\nexport function resolveSsgRouteData(\n dataMap: Record<string, SSRData>,\n routePath: string,\n concretePath: string\n): ResolvedSsgRouteData {\n if (hasOwnRouteData(dataMap, concretePath)) {\n return {\n hasData: true,\n data: dataMap[concretePath],\n };\n }\n\n if (hasOwnRouteData(dataMap, routePath)) {\n return {\n hasData: true,\n data: dataMap[routePath],\n };\n }\n\n return {\n hasData: false,\n data: undefined,\n };\n}\n\nfunction isStringRecord(value: unknown): value is Record<string, string> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return false;\n }\n\n for (const recordValue of Object.values(value)) {\n if (typeof recordValue !== 'string') {\n return false;\n }\n }\n\n return true;\n}\n\nfunction validateRouteShape(route: RouteConfig): void {\n if (typeof route.path !== 'string' || !route.path.startsWith('/')) {\n throw new Error(\n `route path must be a string starting with \"/\", got \"${route.path}\"`\n );\n }\n\n const handler = route.handler ?? route.component;\n if (typeof handler !== 'function') {\n throw new Error(\n `route handler must be a function for path \"${route.path}\"`\n );\n }\n\n if (route.params !== undefined && !isStringRecord(route.params)) {\n throw new Error(\n `route \"${route.path}\" params must be an object containing only string values`\n );\n }\n\n if (route.invalidationKeys !== undefined) {\n if (!Array.isArray(route.invalidationKeys)) {\n throw new Error(\n `route \"${route.path}\" invalidationKeys must be an array of strings`\n );\n }\n for (const key of route.invalidationKeys) {\n if (typeof key !== 'string' || key.length === 0) {\n throw new Error(\n `route \"${route.path}\" invalidationKeys must contain only non-empty strings`\n );\n }\n }\n }\n}\n\nfunction validateEntriesResult(\n route: RouteConfig,\n entries: unknown\n): Array<Record<string, string>> {\n if (!Array.isArray(entries)) {\n throw new Error(\n `route \"${route.path}\" entries must return an array of param maps`\n );\n }\n\n return entries.map((entry, index) => {\n if (!isStringRecord(entry)) {\n throw new Error(\n `route \"${route.path}\" entries[${index}] must be an object containing only string values`\n );\n }\n\n return entry;\n });\n}\n\nexport async function expandRoutes(\n routes: RouteConfig[]\n): Promise<RouteConfig[]> {\n if (!Array.isArray(routes)) {\n throw new Error('routes must be an array');\n }\n\n const expanded: RouteConfig[] = [];\n\n for (const route of routes) {\n validateRouteShape(route);\n\n if (route.params) {\n expanded.push({ ...route, entries: undefined });\n }\n\n if (!route.entries) {\n if (!route.params) {\n expanded.push(route);\n }\n continue;\n }\n\n const entries = validateEntriesResult(route, await route.entries());\n for (const params of entries) {\n expanded.push({ ...route, params, entries: undefined });\n }\n }\n\n return expanded;\n}\n\n/**\n * Validate routes are properly configured\n */\nexport function validateRoutes(routes: RouteConfig[]): void {\n if (!Array.isArray(routes)) {\n throw new Error('routes must be an array');\n }\n\n const seen = new Set<string>();\n\n for (const route of routes) {\n validateRouteShape(route);\n\n const key = `${route.path}::${JSON.stringify(route.params || {})}`;\n if (seen.has(key)) {\n throw new Error(\n `duplicate route entry detected for path \"${route.path}\"`\n );\n }\n seen.add(key);\n\n if (route.path.includes('{')) {\n const paramNames = Array.from(route.path.matchAll(/\\{([^}]+)\\}/g)).map(\n (m) => m[1]\n );\n if (!route.params) {\n throw new Error(\n `route \"${route.path}\" uses path parameters and requires params`\n );\n }\n for (const name of paramNames) {\n if (!(name in route.params)) {\n throw new Error(\n `route \"${route.path}\" missing required param \"${name}\"`\n );\n }\n }\n }\n }\n}\n"],"mappings":";;AAqBA,SAAS,gBACP,SACA,MACS;CACT,OAAO,OAAO,UAAU,eAAe,KAAK,SAAS,IAAI;A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;EAC1B,mBAAmB,KAAK;EAExB,MAAM,MAAM,GAAG,MAAM,KAAK,IAAI,KAAK,UAAU,MAAM,UAAU,CAAC,CAAC;EAC/D,IAAI,KAAK,IAAI,GAAG,GACd,MAAM,IAAI,MACR,4CAA4C,MAAM,KAAK,EACzD;EAEF,KAAK,IAAI,GAAG;EAEZ,IAAI,MAAM,KAAK,SAAS,GAAG,GAAG;GAC5B,MAAM,aAAa,MAAM,KAAK,MAAM,KAAK,SAAS,cAAc,CAAC,CAAC,CAAC,KAChE,MAAM,EAAE,EACX;GACA,IAAI,CAAC,MAAM,QACT,MAAM,IAAI,MACR,UAAU,MAAM,KAAK,2CACvB;GAEF,KAAK,MAAM,QAAQ,YACjB,IAAI,EAAE,QAAQ,MAAM,SAClB,MAAM,IAAI,MACR,UAAU,MAAM,KAAK,4BAA4B,KAAK,EACxD;EAGN;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-utils.js","names":[],"sources":["../../src/ssg/route-utils.ts"],"sourcesContent":["import type { RouteConfig } from './types';\n\nexport interface ResolvedRouteDescriptor {\n route: RouteConfig;\n path: string;\n filePath: string;\n routeId: string;\n invalidationKeys: string[];\n}\n\nexport function getOutputFilePath(pathStr: string): string {\n if (pathStr === '/') {\n return 'index.html';\n }\n const normalized = pathStr.replace(/^\\/|\\/$/g, '');\n return `${normalized}/index.html`;\n}\n\nexport function interpolateRoutePath(\n routePath: string,\n params?: Record<string, string>\n): string {\n if (!params) return routePath;\n return routePath.replace(\n /\\{([^}]+)\\}/g,\n (_, key: string) => params[key] ?? ''\n );\n}\n\nexport function resolveRouteDescriptor(\n route: RouteConfig\n): ResolvedRouteDescriptor {\n const path = interpolateRoutePath(route.path, route.params);\n const filePath = getOutputFilePath(path);\n return {\n route,\n path,\n filePath,\n routeId: `${path}::${filePath}`,\n invalidationKeys: route.invalidationKeys?.slice() ?? [],\n };\n}\n"],"mappings":";AAUA,SAAgB,kBAAkB,SAAyB;CACzD,IAAI,YAAY,KACd,OAAO;CAGT,OAAO,GADY,QAAQ,QAAQ,YAAY,EACrC,EAAW;AACvB;AAEA,SAAgB,qBACd,WACA,QACQ;CACR,IAAI,CAAC,QAAQ,OAAO;CACpB,OAAO,UAAU,QACf,iBACC,GAAG,QAAgB,OAAO,QAAQ,EACrC;AACF;AAEA,SAAgB,uBACd,OACyB;CACzB,MAAM,OAAO,qBAAqB,MAAM,MAAM,MAAM,MAAM;CAC1D,MAAM,WAAW,kBAAkB,IAAI;CACvC,OAAO;EACL;EACA;EACA;EACA,SAAS,GAAG,KAAK,IAAI;EACrB,kBAAkB,MAAM,kBAAkB,MAAM,KAAK,CAAC;CACxD;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"static-routes.js","names":[],"sources":["../../src/ssg/static-routes.ts"],"sourcesContent":["/**\n * SSG route source normalization and runtime-only filtering.\n */\n\nimport type { RouteConfig, RouteRenderResult } from './types';\nimport type { RoutePolicy, RouteRegistry } from '../common/router';\nimport { _getBuiltInRoutePolicy } from '../router/policy';\nimport { expandRoutes } from './resolve-ssg-data';\nimport {\n getOutputFilePath,\n interpolateRoutePath,\n resolveRouteDescriptor,\n} from './route-utils';\n\ntype StaticRouteSource = {\n registry?: RouteRegistry;\n routes?: readonly RouteConfig[];\n};\n\nexport type RuntimeOnlyRoute = {\n routeId: string;\n result: RouteRenderResult;\n};\n\nexport interface SplitStaticRoutesResult {\n routes: RouteConfig[];\n runtimeOnly: RuntimeOnlyRoute[];\n outputRouteIds: string[];\n}\n\nfunction getRuntimeOnlyDiagnostic(\n route: RouteConfig,\n path: string\n): string | null {\n const policies = route.policies ?? [];\n\n if (route.auth === true) {\n return `Skipped prerender for \"${path}\": authenticated routes are runtime-only by default.`;\n }\n\n if (route.role) {\n return `Skipped prerender for \"${path}\": role-gated routes are runtime-only by default.`;\n }\n\n if (route.permission) {\n return `Skipped prerender for \"${path}\": permission-gated routes are runtime-only by default.`;\n }\n\n if (policies.length > 0) {\n let hasAuthPolicy = false;\n let hasRolePolicy = false;\n let hasPermissionPolicy = false;\n\n for (const policy of policies) {\n const metadata = _getBuiltInRoutePolicy(policy);\n if (!metadata) {\n return `Skipped prerender for \"${path}\": routes with custom policies are runtime-only by default.`;\n }\n\n if (metadata.kind === 'auth') {\n hasAuthPolicy = true;\n } else if (metadata.kind === 'role') {\n hasRolePolicy = true;\n } else if (metadata.kind === 'permission') {\n hasPermissionPolicy = true;\n }\n }\n\n if (hasAuthPolicy) {\n return `Skipped prerender for \"${path}\": authenticated routes are runtime-only by default.`;\n }\n\n if (hasRolePolicy) {\n return `Skipped prerender for \"${path}\": role-gated routes are runtime-only by default.`;\n }\n\n if (hasPermissionPolicy) {\n return `Skipped prerender for \"${path}\": permission-gated routes are runtime-only by default.`;\n }\n\n return null;\n }\n\n return null;\n}\n\nfunction getRouteResultPath(route: RouteConfig): string {\n return route.params\n ? interpolateRoutePath(route.path, route.params)\n : route.path;\n}\n\nfunction createRuntimeOnlyRoute(\n route: RouteConfig,\n diagnostic: string\n): RuntimeOnlyRoute {\n const path = getRouteResultPath(route);\n const filePath = getOutputFilePath(path);\n\n return {\n routeId: `${path}::${filePath}`,\n result: {\n path,\n filePath,\n html: '',\n fileSize: 0,\n renderDuration: 0,\n resourceCount: 0,\n status: 'skipped',\n reason: 'runtime-only',\n written: false,\n error: diagnostic,\n },\n };\n}\n\nexport async function splitStaticRoutes(\n routes: readonly RouteConfig[]\n): Promise<SplitStaticRoutesResult> {\n const prerenderableRoutes: RouteConfig[] = [];\n const runtimeOnly: RuntimeOnlyRoute[] = [];\n const outputRouteIds: string[] = [];\n\n for (const route of routes) {\n const routePath = getRouteResultPath(route);\n const diagnostic = getRuntimeOnlyDiagnostic(route, routePath);\n if (diagnostic) {\n const runtimeRoute = createRuntimeOnlyRoute(route, diagnostic);\n runtimeOnly.push(runtimeRoute);\n outputRouteIds.push(runtimeRoute.routeId);\n continue;\n }\n\n const expanded = await expandRoutes([route]);\n prerenderableRoutes.push(...expanded);\n for (const expandedRoute of expanded) {\n outputRouteIds.push(resolveRouteDescriptor(expandedRoute).routeId);\n }\n }\n\n return {\n routes: prerenderableRoutes,\n runtimeOnly,\n outputRouteIds,\n };\n}\n\nexport function normalizeStaticRoutes(\n options: StaticRouteSource\n): RouteConfig[] {\n if (options.registry) {\n return routeRegistryToRouteConfigs(options.registry);\n }\n\n return [...(options.routes ?? [])];\n}\n\nfunction routeRegistryToRouteConfigs(registry: RouteRegistry): RouteConfig[] {\n const routeConfigs: RouteConfig[] = [];\n\n for (const record of registry.manifest.records) {\n if (record.isFallback) {\n continue;\n }\n\n routeConfigs.push({\n path: record.path,\n handler: record.handler,\n namespace: record.options.namespace,\n auth: record.options.auth,\n role: record.options.role,\n permission: record.options.permission,\n policies: stripRegistryGuestPolicies(record.options.policies),\n entries: record.options.entries,\n });\n }\n\n return routeConfigs;\n}\n\nfunction stripRegistryGuestPolicies(\n policies: readonly RoutePolicy[] | undefined\n): readonly RoutePolicy[] | undefined {\n if (!policies || policies.length === 0) {\n return undefined;\n }\n\n const filtered = policies.filter(\n (policy) => _getBuiltInRoutePolicy(policy)?.kind !== 'guest'\n );\n\n return filtered.length > 0 ? filtered : undefined;\n}\n"],"mappings":";;;;AA8BA,SAAS,yBACP,OACA,MACe;CACf,MAAM,WAAW,MAAM,YAAY,CAAC;CAEpC,IAAI,MAAM,SAAS,MACjB,OAAO,0BAA0B,KAAK;CAGxC,IAAI,MAAM,MACR,OAAO,0BAA0B,KAAK;CAGxC,IAAI,MAAM,YACR,OAAO,0BAA0B,KAAK;CAGxC,IAAI,SAAS,SAAS,GAAG;EACvB,IAAI,gBAAgB;EACpB,IAAI,gBAAgB;EACpB,IAAI,sBAAsB;EAE1B,KAAK,MAAM,UAAU,UAAU;GAC7B,MAAM,WAAW,uBAAuB,MAAM;GAC9C,IAAI,CAAC,UACH,OAAO,0BAA0B,KAAK;GAGxC,IAAI,SAAS,SAAS,QACpB,gBAAgB;QACX,IAAI,SAAS,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EW;EA8EX,OAAA;EA1EA;EA4EA,SAAA;EA5EW;EA8EX,eAAA;EA1EoB;EA4EpB,iBAAA;EA5E8C;EA8E9C,MAAA,EAAQ,iBAAiB;AAAA;;UAIV,WAAA,SAAoB,MAAA;EAxEJ;EA0E/B,WAAA;EApFqB;EAsFrB,WAAA;EAtF8D;EAwF9D,UAAA;EAnFQ;EAqFR,MAAA;EApFQ;EAsFR,aAAA;EAlFkB;EAoFlB,IAAA,EAAM,OAAA;EAnFQ;EAqFd,OAAA;EAhFe;EAkFf,OAAA;;EAEA,OAAA;EAlFA;EAoFA,SAAA;EAlFA;EAoFA,eAAA;EAhFA;EAkFA,iBAAA;EAlFS;EAoFT,MAAA,EAAQ,KAAA;IAhFwB,eAkF9B,IAAA,UAlEuB;IAoEvB,QAAA,UAhFF;IAkFE,QAAA,UA9EF;IAgFE,cAAA,UA5EF;IA8EE,aAAA,UA5EM;IA8EN,MAAA,EAAQ,iBAAA,EA5EF;IA8EN,MAAA,EAAQ,iBAAA,EA1EV;IA4EE,OAAA,WA5EG;IA8EH,KAAA;EAAA;AAAA;;UAKa,mBAAA;EAAA,CACd,GAAA;IACC,KAAA;IACA,YAAA;EAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write-static-files.js","names":[],"sources":["../../src/ssg/write-static-files.ts"],"sourcesContent":["/**\n * File I/O for Static Site Generation\n *\n * Uses Node.js fs/path modules to write rendered HTML files to disk.\n * This module is Node-only and not intended for browser builds.\n */\n\nimport * as fs from 'node:fs/promises';\nimport * as fsSync from 'node:fs';\nimport * as pathModule from 'node:path';\nimport type { RouteRenderResult } from './types';\n\ninterface WriteStaticFilesOptions {\n concurrency?: number;\n}\n\n/**\n * Write rendered routes to disk\n * Creates outputDir/{route-path}/index.html structure\n */\nexport async function writeStaticFiles(\n results: RouteRenderResult[],\n outputDir: string,\n options: WriteStaticFilesOptions = {}\n): Promise<void> {\n await fs.mkdir(outputDir, { recursive: true });\n\n for (const result of results) {\n if (result.status !== 'removed') {\n continue;\n }\n\n const fullPath = pathModule.join(outputDir, result.filePath);\n if (fsSync.existsSync(fullPath)) {\n await fs.rm(fullPath, { force: true });\n await pruneEmptyDirs(pathModule.dirname(fullPath), outputDir);\n }\n }\n\n const pendingWrites: RouteRenderResult[] = [];\n for (let index = 0; index < results.length; index += 1) {\n const result = results[index];\n if (result.status === 'error') {\n console.warn(`Skipping failed route: ${result.path} - ${result.error}`);\n continue;\n }\n if (result.status === 'success' && result.written) {\n pendingWrites.push(result);\n }\n }\n\n const directories: string[] = [];\n const seenDirectories = new Set<string>();\n for (const result of pendingWrites) {\n const dir = pathModule.dirname(pathModule.join(outputDir, result.filePath));\n if (!seenDirectories.has(dir)) {\n seenDirectories.add(dir);\n directories.push(dir);\n }\n }\n\n for (const dir of directories) {\n await fs.mkdir(dir, { recursive: true });\n }\n\n const concurrency = Math.max(\n 1,\n Math.min(options.concurrency ?? 8, pendingWrites.length || 1)\n );\n let nextIndex = 0;\n\n const worker = async () => {\n while (true) {\n const current = nextIndex;\n nextIndex += 1;\n if (current >= pendingWrites.length) {\n return;\n }\n\n const result = pendingWrites[current];\n const fullPath = pathModule.join(outputDir, result.filePath);\n await fs.writeFile(fullPath, result.html, 'utf8');\n }\n };\n\n await Promise.all(Array.from({ length: concurrency }, () => worker()));\n}\n\n/**\n * Get the output file path for a route\n * E.g., \"/blog/post\" -> \"blog/post\" or \"/\" -> \"\"\n */\nexport { getOutputFilePath } from './route-utils';\n\nasync function pruneEmptyDirs(\n startDir: string,\n rootDir: string\n): Promise<void> {\n let current = startDir;\n const normalizedRoot = pathModule.resolve(rootDir);\n\n while (current.startsWith(normalizedRoot)) {\n if (!fsSync.existsSync(current)) {\n break;\n }\n\n if ((await fs.readdir(current)).length > 0) {\n break;\n }\n\n await fs.rmdir(current);\n if (pathModule.resolve(current) === normalizedRoot) {\n break;\n }\n current = pathModule.dirname(current);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,eA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,MAAM,WAAW,WAAW,KAAK,WAAW,OAAO,QAAQ;GAC3D,MAAM,GAAG,UAAU,UAAU,OAAO,MAAM,MAAM;EAClD;CACF;CAEA,MAAM,QAAQ,IAAI,MAAM,KAAK,EAAE,QAAQ,YAAY,SAAS,OAAO,CAAC,CAAC;AACvE;AAQA,eAAe,eACb,UACA,SACe;CACf,IAAI,UAAU;CACd,MAAM,iBAAiB,WAAW,QAAQ,OAAO;CAEjD,OAAO,QAAQ,WAAW,cAAc,GAAG;EACzC,IAAI,CAAC,OAAO,WAAW,OAAO,GAC5B;EAGF,KAAK,MAAM,GAAG,QAAQ,OAAO,EAAA,CAAG,SAAS,GACvC;EAGF,MAAM,GAAG,MAAM,OAAO;EACtB,IAAI,WAAW,QAAQ,OAAO,MAAM,gBAClC;EAEF,UAAU,WAAW,QAAQ,OAAO;CACtC;AACF"}
|
package/dist/ssr/attrs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attrs.js","names":[],"sources":["../../src/ssr/attrs.ts"],"sourcesContent":["/**\n * HTML attribute rendering for SSR\n */\n\nimport type { Props } from '../common/props';\nimport { getPublicAttributeName } from '../common/attr-names';\nimport type { RenderSink } from './sink';\nimport { escapeAttr, needsEscapeAttr, styleObjToCss } from './escape';\n\n/** Result of renderAttrs including any raw HTML from dangerouslySetInnerHTML */\nexport type AttrsResult = {\n attrs: string;\n dangerousHtml?: string;\n};\n\nconst ESCAPED_ATTR_VALUE_CACHE_LIMIT = 512;\nconst escapedAttrValueCache = new Map<string, string>();\n\n// Fast check for event handler pattern (on + uppercase letter)\nfunction isEventHandler(key: string): boolean {\n return (\n key.length >= 3 &&\n key.charCodeAt(0) === 111 && // 'o'\n key.charCodeAt(1) === 110 && // 'n'\n key.charCodeAt(2) >= 65 &&\n key.charCodeAt(2) <= 90 // 'A'-'Z'\n );\n}\n\nfunction getEscapedAttrValue(value: string): string {\n if (value.length > 64) {\n return escapeAttr(value);\n }\n\n const cached = escapedAttrValueCache.get(value);\n if (cached !== undefined) {\n return cached;\n }\n\n const escaped = escapeAttr(value);\n // Skip caching strings that required no escaping — same reference returned,\n // no point occupying cache slots with identity entries.\n if (escaped === value) return value;\n if (escapedAttrValueCache.size >= ESCAPED_ATTR_VALUE_CACHE_LIMIT) {\n escapedAttrValueCache.clear();\n }\n escapedAttrValueCache.set(value, escaped);\n return escaped;\n}\n\n/**\n * Render attributes directly to a sink without intermediate string allocations.\n * This is the hot path for streaming SSR.\n */\nexport function renderAttrsDirect(\n props: Props | undefined,\n sink: Pick<RenderSink, 'write'>\n): void {\n if (!props || typeof props !== 'object') return;\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n // Skip special props\n if (\n key === 'children' ||\n key === 'key' ||\n key === 'ref' ||\n key === 'dangerouslySetInnerHTML'\n )\n continue;\n\n // Skip event handlers\n if (isEventHandler(key)) continue;\n\n // Skip internal props\n if (key.charCodeAt(0) === 95) continue; // '_'\n\n // Normalize public JSX prop names to their rendered HTML attribute names.\n const attrName = getPublicAttributeName(key);\n\n // Handle style objects\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (!css) continue;\n sink.write(' style=\"');\n // Escape inline - most style values don't need escaping\n if (needsEscapeAttr(css)) {\n sink.write(getEscapedAttrValue(css));\n } else {\n sink.write(css);\n }\n sink.write('\"');\n continue;\n }\n\n // Boolean attributes\n if (value === true) {\n sink.write(' ');\n sink.write(attrName);\n continue;\n }\n\n if (value === false || value === null || value === undefined) continue;\n\n // Regular attributes\n const strValue = String(value);\n sink.write(' ');\n sink.write(attrName);\n sink.write('=\"');\n // escapeAttr returns the original string when nothing needs escaping,\n // so no separate needsEscapeAttr pre-scan is required.\n sink.write(getEscapedAttrValue(strValue));\n sink.write('\"');\n }\n}\n\n/**\n * Render attributes to HTML string, excluding event handlers\n * Optimized for minimal allocations using push-based approach\n *\n * Returns both the attribute string and any dangerouslySetInnerHTML content.\n */\nexport function renderAttrs(props?: Props): string;\nexport function renderAttrs(\n props: Props | undefined,\n opts: { returnDangerousHtml: true }\n): AttrsResult;\nexport function renderAttrs(\n props?: Props,\n opts?: { returnDangerousHtml?: boolean }\n): string | AttrsResult {\n if (!props || typeof props !== 'object') {\n return opts?.returnDangerousHtml ? { attrs: '' } : '';\n }\n\n const attrParts: string[] = [];\n let dangerousHtml: string | undefined;\n\n const propsObj = props as Record<string, unknown>;\n for (const key in propsObj) {\n const value = propsObj[key];\n\n // Skip children in attrs\n if (key === 'children') continue;\n\n // Skip internal identity refs (framework-only)\n if (key === 'key' || key === 'ref') continue;\n\n // Handle dangerouslySetInnerHTML\n if (key === 'dangerouslySetInnerHTML') {\n if (value && typeof value === 'object' && '__html' in (value as object)) {\n dangerousHtml = String((value as { __html: unknown }).__html);\n }\n continue;\n }\n\n // Skip event handlers\n if (isEventHandler(key)) continue;\n\n // Skip internal props\n if (key.charCodeAt(0) === 95) continue; // '_'\n\n // Normalize public JSX prop names to their rendered HTML attribute names.\n const attrName = key === 'class' ? 'class' : getPublicAttributeName(key);\n\n // Handle style objects\n if (attrName === 'style') {\n const css = typeof value === 'string' ? value : styleObjToCss(value);\n if (css === null || css === '') continue;\n attrParts.push(` style=\"${getEscapedAttrValue(css)}\"`);\n continue;\n }\n\n // Boolean attributes\n if (value === true) {\n attrParts.push(` ${attrName}`);\n } else if (value === false || value === null || value === undefined) {\n continue;\n } else {\n const strValue = String(value);\n attrParts.push(` ${attrName}=\"${getEscapedAttrValue(strValue)}\"`);\n }\n }\n\n const result = attrParts.join('');\n\n if (opts?.returnDangerousHtml) {\n return { attrs: result, dangerousHtml };\n }\n return result;\n}\n"],"mappings":";;;AAeA,MAAM,iCAAiC;AACvC,MAAM,wCAAwB,IAAI,IAAoB;AAGtD,SAAS,eAAe,KAAsB;CAC5C,OACE,IAAI,UAAU,KACd,IAAI,WAAW,CAAC,MAAM,OACtB,IAAI,WAAW,CAAC,MAAM,OACtB,IAAI,WAAW,CAAC,KAAK,M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,SAAgB,YACd,OACA,MACsB;CACtB,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO,MAAM,sBAAsB,EAAE,OAAO,GAAG,IAAI;CAGrD,MAAM,YAAsB,CAAC;CAC7B,IAAI;CAEJ,MAAM,WAAW;CACjB,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,QAAQ,SAAS;EAGvB,IAAI,QAAQ,YAAY;EAGxB,IAAI,QAAQ,SAAS,QAAQ,OAAO;EAGpC,IAAI,QAAQ,2BAA2B;GACrC,IAAI,SAAS,OAAO,UAAU,YAAY,YAAa,OACrD,gBAAgB,OAAQ,MAA8B,MAAM;GAE9D;EACF;EAGA,IAAI,eAAe,GAAG,GAAG;EAGzB,IAAI,IAAI,WAAW,CAAC,MAAM,IAAI;EAG9B,MAAM,WAAW,QAAQ,UAAU,UAAU,uBAAuB,GAAG;EAGvE,IAAI,aAAa,SAAS;GACxB,MAAM,MAAM,OAAO,UAAU,WAAW,QAAQ,cAAc,KAAK;GACnE,IAAI,QAAQ,QAAQ,QAAQ,IAAI;GAChC,UAAU,KAAK,WAAW,oBAAoB,GAAG,EAAE,EAAE;GACrD;EACF;EAGA,IAAI,UAAU,MACZ,UAAU,KAAK,IAAI,UAAU;OACxB,IAAI,UAAU,SAAS,UAAU,QAAQ,UAAU,QACxD;OACK;GACL,MAAM,WAAW,OAAO,KAAK;GAC7B,UAAU,KAAK,IAAI,SAAS,IAAI,oBAAoB,QAAQ,EAAE,EAAE;EAClE;CACF;CAEA,MAAM,SAAS,UAAU,KAAK,EAAE;CAEhC,IAAI,MAAM,qBACR,OAAO;EAAE,OAAO;EAAQ;CAAc;CAExC,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundaries.js","names":[],"sources":["../../src/ssr/boundaries.ts"],"sourcesContent":["/**\n * Shared SSR boundary state and renderable child helpers.\n */\n\nimport type { JSXElement } from '../common/jsx';\nimport { __CONTROL_BOUNDARY__ } from '../common/control';\nimport type { DOMElement } from '../common/vnode';\nimport { ELEMENT_TYPE } from '../jsx';\nimport type { ComponentInstance } from '../runtime/component';\nimport {\n type ControlBoundaryState,\n evaluateCaseState,\n evaluateShowState,\n} from '../runtime/control';\nimport { evaluateForState } from '../runtime/for';\nimport type { VNode } from './types';\n\ntype ErrorBoundaryState = NonNullable<ComponentInstance['errorBoundaryState']>;\n\nexport function normalizeRenderableChildren(value: unknown): unknown[] {\n if (value === null || value === undefined || value === false) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n}\n\nexport function getRenderableChildren(\n node: VNode | JSXElement\n): unknown[] | undefined {\n if (Array.isArray((node as VNode).children)) {\n return (node as VNode).children;\n }\n if (Array.isArray(node.props?.children)) {\n return node.props.children as unknown[];\n }\n if (\n node.props?.children !== undefined &&\n node.props.children !== null &&\n node.props.children !== false\n ) {\n return [node.props.children];\n }\n return undefined;\n}\n\nexport function getErrorBoundaryState(\n node: VNode | JSXElement\n): ErrorBoundaryState | null {\n return (\n (node as DOMElement & { __instance?: ComponentInstance }).__instance\n ?.errorBoundaryState ?? null\n );\n}\n\nexport function resetErrorBoundaryState(node: VNode | JSXElement): void {\n const instance = (node as DOMElement & { __instance?: ComponentInstance })\n .__instance;\n const state = instance?.errorBoundaryState;\n if (state) {\n state.error = null;\n state.notified = false;\n }\n}\n\nexport function createErrorBoundaryReset(node: VNode | JSXElement): () => void {\n return () => resetErrorBoundaryState(node);\n}\n\nfunction createDefaultErrorBoundaryFallbackVNode(error: unknown): JSXElement {\n const message =\n error instanceof Error\n ? error.stack || error.message || error.name\n : typeof error === 'string'\n ? error\n : (() => {\n try {\n return JSON.stringify(error);\n } catch {\n return String(error);\n }\n })();\n\n return {\n $$typeof: ELEMENT_TYPE,\n type: 'div',\n props: {\n role: 'alert',\n 'data-askr-error-boundary': 'true',\n style: {\n boxSizing: 'border-box',\n padding: '1rem',\n border: '1px solid currentColor',\n borderRadius: '0.75rem',\n display: 'grid',\n gap: '0.75rem',\n maxWidth: '100%',\n },\n children: [\n {\n $$typeof: ELEMENT_TYPE,\n type: 'strong',\n props: {\n children: ['Something went wrong while rendering this view.'],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'p',\n props: {\n style: { margin: '0' },\n children: [\n 'The app recovered into a visible fallback so the error is not hidden in the console.',\n ],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'details',\n props: {\n open: process.env.NODE_ENV !== 'production',\n children: [\n {\n $$typeof: ELEMENT_TYPE,\n type: 'summary',\n props: {\n children: ['Error details'],\n },\n },\n {\n $$typeof: ELEMENT_TYPE,\n type: 'pre',\n props: {\n style: {\n margin: '0',\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n },\n children: [message],\n },\n },\n ],\n },\n },\n ],\n },\n key: null,\n } as JSXElement;\n}\n\nexport function resolveErrorBoundaryFallbackNode(\n fallback: unknown,\n error: unknown,\n reset: () => void\n): unknown {\n return typeof fallback === 'function'\n ? (fallback as (error: unknown, reset: () => void) => unknown)(error, reset)\n : fallback !== undefined\n ? fallback\n : createDefaultErrorBoundaryFallbackVNode(error);\n}\n\nexport function getControlBoundaryState(\n node: VNode | JSXElement\n): ControlBoundaryState | null {\n const boundaryNode = node as DOMElement;\n\n return (\n boundaryNode._controlState ??\n (boundaryNode._forState as ControlBoundaryState | undefined) ??\n null\n );\n}\n\nexport function evaluateControlBoundaryChildren(\n node: VNode | JSXElement\n): unknown[] | undefined {\n if (node.type !== __CONTROL_BOUNDARY__) {\n return undefined;\n }\n\n const controlState = getControlBoundaryState(node);\n if (!controlState) {\n return [];\n }\n\n if (controlState.kind === 'for') {\n return evaluateForState(controlState);\n }\n if (controlState.kind === 'show') {\n return evaluateShowState(controlState);\n }\n return evaluateCaseState(controlState);\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,4BAA4B,OAA2B;CACrE,IAAI,UAAU,QAAQ,UAAU,UAAa,UAAU,OACrD,OAAO,CAAC;CAGV,OAAO,MAAM,QAAQ,KAAK,IAA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