@askrjs/askr 0.0.51 → 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/{runtime/scheduler.js → access-Bg4RJNC8.js} +190 -20
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +103 -0
- package/dist/{common/attr-names.js → attr-names-CjhzmHOn.js} +1 -3
- package/dist/benchmark.d.ts +7 -4
- package/dist/benchmark.js +63 -13
- package/dist/boot/index.d.ts +62 -4
- package/dist/boot/index.js +1 -194
- package/dist/boot-j2KoN6ss.js +647 -0
- package/dist/cleanup-COv77su2.js +487 -0
- package/dist/component-internal-B3z7GXlD.js +614 -0
- package/dist/component-lifecycle-CO4hXlP4.js +357 -0
- package/dist/{runtime/component-scope.js → component-scope-CC3cojX9.js} +35 -9
- package/dist/component-scope-CvPba6O6.d.ts +12 -0
- package/dist/components/index.d.ts +17 -2
- package/dist/components/index.js +39 -1
- package/dist/compose-ref-Cc_YkUpM.js +92 -0
- package/dist/{foundations/utilities/compose-ref.d.ts → compose-ref-Cizq72-x.d.ts} +1 -2
- package/dist/control/index.d.ts +1 -3
- package/dist/control/index.js +1 -3
- package/dist/control-BQvNVfAd.d.ts +436 -0
- package/dist/control-BYyLTFyw.js +165 -0
- package/dist/control-Bf4Wkdvv.d.ts +9 -0
- package/dist/{common/control.js → control-DhFRTIoE.js} +1 -3
- package/dist/data/index.d.ts +2 -6
- package/dist/data/index.js +4 -5
- package/dist/data-DnxnDxD-.js +559 -0
- package/dist/{data/data-runtime.js → data-runtime-SJ1BSUvk.js} +35 -36
- package/dist/deferred-lKE8uR0z.js +386 -0
- package/dist/effect-BwnIvLah.js +260 -0
- package/dist/fastlane-Dw8SOBr9.js +343 -0
- package/dist/for-internal-BKf_Tnv1.js +1563 -0
- package/dist/foundations/icon/index.d.ts +68 -2
- package/dist/foundations/icon/index.js +85 -1
- package/dist/foundations/index.d.ts +2 -5
- package/dist/foundations/index.js +2 -5
- package/dist/foundations/interactions/index.d.ts +264 -6
- package/dist/foundations/interactions/index.js +1 -6
- package/dist/foundations/state/index.d.ts +32 -1
- package/dist/foundations/state/index.js +78 -1
- package/dist/foundations/structures/index.d.ts +2 -7
- package/dist/foundations/structures/index.js +2 -7
- package/dist/foundations/utilities/index.d.ts +2 -6
- package/dist/foundations/utilities/index.js +2 -5
- package/dist/fx/index.d.ts +190 -3
- package/dist/fx/index.js +454 -4
- package/dist/index-31Uoz_NS.d.ts +239 -0
- package/dist/index-Bki2rqcr.d.ts +233 -0
- package/dist/index-BnU0NPwM.d.ts +101 -0
- package/dist/index-D73jgYx1.d.ts +48 -0
- package/dist/{runtime/runtime.d.ts → index-R2JJIbM-.d.ts} +31 -9
- package/dist/index-SJXJkssx.d.ts +44 -0
- package/dist/index.d.ts +8 -13
- package/dist/index.js +150 -17
- package/dist/interactions-w7gQN4ha.js +280 -0
- package/dist/{data/invalidation-listeners.js → invalidation-listeners-Des3AHYs.js} +1 -3
- package/dist/{common/props.d.ts → jsx-CP0gmYwJ.d.ts} +17 -6
- package/dist/{common/jsx.js → jsx-CUpRxrLH.js} +1 -3
- package/dist/jsx-dev-runtime.d.ts +17 -5
- package/dist/jsx-dev-runtime.js +3 -10
- package/dist/jsx-runtime-92bV2hSa.d.ts +34 -0
- package/dist/jsx-runtime-BVVgDSdq.d.ts +1 -0
- package/dist/jsx-runtime.d.ts +3 -22
- package/dist/jsx-runtime.js +17 -20
- package/dist/{runtime/lifecycle-operations.js → lifecycle-operations-D9va7GOU.js} +9 -11
- package/dist/navigate-BVDCzOuB.d.ts +34 -0
- package/dist/navigate-CmPLSXyw.js +1449 -0
- package/dist/{runtime/portal.js → portal-CyU3Ucf2.js} +124 -35
- package/dist/query-registry-CQIT4mXr.js +73 -0
- package/dist/{common/render-context.js → render-context-Clw3rFiO.js} +14 -8
- package/dist/renderer-DzPjeLby.js +6197 -0
- package/dist/resource-operation-CEzfpnDk.js +276 -0
- package/dist/resources/index.d.ts +42 -3
- package/dist/resources/index.js +3 -4
- package/dist/{common/route-activity.js → route-activity-CNJfpwx-.js} +1 -3
- package/dist/route-matching-vJpvLVbX.js +515 -0
- package/dist/router/index.d.ts +166 -14
- package/dist/router/index.js +150 -12
- package/dist/{common/router.d.ts → router-CeYvjj5_.d.ts} +72 -29
- package/dist/{common/router-internal.js → router-internal-BC0w1_xk.js} +1 -3
- package/dist/{runtime/scheduler.d.ts → scheduler-CmLO4Dfm.d.ts} +1 -4
- package/dist/{runtime/selector.js → selector-DafVYzV4.js} +35 -20
- package/dist/{runtime/snapshot-source.js → snapshot-source-BB42xgwb.js} +1 -3
- package/dist/ssg/index.d.ts +252 -4
- package/dist/ssg/index.js +857 -1
- package/dist/ssr/index.d.ts +225 -8
- package/dist/ssr/index.js +3 -6
- package/dist/{common/ssr.js → ssr-CbQO5xd3.js} +1 -3
- package/dist/ssr-D3t80Rc0.js +1413 -0
- package/dist/{runtime/state.js → state-DPl8lffD.js} +4 -8
- package/dist/structures-DUB3HchX.js +221 -0
- package/dist/testing/index.d.ts +4 -4
- package/dist/testing/index.js +2 -7
- package/dist/{jsx/types.d.ts → types-DnQVG4ZY.d.ts} +2 -6
- package/dist/{foundations/utilities/use-id.js → utilities-C_CGX4Dz.js} +1 -3
- package/dist/{ssr/verify-hydration.js → verify-hydration-io9ahUeq.js} +2 -4
- package/dist/{common/vnode.js → vnode-CGMJYPMB.js} +2 -4
- package/package.json +63 -45
- package/dist/bench/components/benchmark-row.d.ts +0 -20
- package/dist/bench/components/benchmark-row.d.ts.map +0 -1
- package/dist/bench/components/benchmark-row.js +0 -42
- package/dist/bench/components/benchmark-row.js.map +0 -1
- package/dist/bench/components/benchmark-table.js +0 -25
- 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 +0 -28
- package/dist/bin/askr-ssg.d.ts.map +0 -1
- package/dist/bin/askr-ssg.js +0 -171
- package/dist/bin/askr-ssg.js.map +0 -1
- package/dist/boot/hydration.js +0 -140
- 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 +0 -15
- package/dist/boot/root-lifecycle.d.ts.map +0 -1
- package/dist/boot/root-lifecycle.js +0 -205
- package/dist/boot/root-lifecycle.js.map +0 -1
- package/dist/boot/route-startup.js +0 -45
- package/dist/boot/route-startup.js.map +0 -1
- package/dist/boot/types.d.ts +0 -62
- package/dist/boot/types.d.ts.map +0 -1
- package/dist/common/attr-names.js.map +0 -1
- package/dist/common/component.d.ts +0 -19
- package/dist/common/component.d.ts.map +0 -1
- package/dist/common/control.d.ts +0 -13
- package/dist/common/control.d.ts.map +0 -1
- package/dist/common/control.js.map +0 -1
- package/dist/common/env.js +0 -47
- package/dist/common/env.js.map +0 -1
- package/dist/common/error-boundary.d.ts +0 -16
- package/dist/common/error-boundary.d.ts.map +0 -1
- package/dist/common/invariant.js +0 -17
- package/dist/common/invariant.js.map +0 -1
- package/dist/common/jsx.d.ts +0 -23
- package/dist/common/jsx.d.ts.map +0 -1
- package/dist/common/jsx.js.map +0 -1
- package/dist/common/logger.js +0 -36
- package/dist/common/logger.js.map +0 -1
- package/dist/common/promise.js +0 -8
- 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 +0 -11
- package/dist/common/ssr-errors.d.ts.map +0 -1
- package/dist/common/ssr-errors.js +0 -16
- package/dist/common/ssr-errors.js.map +0 -1
- package/dist/common/ssr.d.ts +0 -42
- package/dist/common/ssr.d.ts.map +0 -1
- package/dist/common/ssr.js.map +0 -1
- package/dist/common/vnode.d.ts +0 -22
- package/dist/common/vnode.d.ts.map +0 -1
- package/dist/common/vnode.js.map +0 -1
- package/dist/components/error-boundary.d.ts +0 -15
- package/dist/components/error-boundary.d.ts.map +0 -1
- package/dist/components/error-boundary.js +0 -43
- package/dist/components/error-boundary.js.map +0 -1
- package/dist/components/link.d.ts +0 -68
- package/dist/components/link.d.ts.map +0 -1
- package/dist/components/link.js +0 -76
- package/dist/components/link.js.map +0 -1
- package/dist/control/case.d.ts +0 -19
- package/dist/control/case.d.ts.map +0 -1
- package/dist/control/case.js +0 -70
- package/dist/control/case.js.map +0 -1
- package/dist/control/for.d.ts +0 -24
- package/dist/control/for.d.ts.map +0 -1
- package/dist/control/for.js +0 -63
- package/dist/control/for.js.map +0 -1
- package/dist/control/shared.d.ts +0 -9
- package/dist/control/shared.d.ts.map +0 -1
- package/dist/control/shared.js +0 -20
- package/dist/control/shared.js.map +0 -1
- package/dist/control/show.d.ts +0 -15
- package/dist/control/show.d.ts.map +0 -1
- package/dist/control/show.js +0 -34
- package/dist/control/show.js.map +0 -1
- package/dist/data/data-runtime.d.ts +0 -28
- 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 +0 -9
- package/dist/data/invalidation.d.ts.map +0 -1
- package/dist/data/invalidation.js +0 -27
- package/dist/data/invalidation.js.map +0 -1
- package/dist/data/mutation-cell.d.ts +0 -28
- package/dist/data/mutation-cell.d.ts.map +0 -1
- package/dist/data/mutation-cell.js +0 -132
- package/dist/data/mutation-cell.js.map +0 -1
- package/dist/data/query-cell.d.ts +0 -46
- package/dist/data/query-cell.d.ts.map +0 -1
- package/dist/data/query-cell.js +0 -290
- package/dist/data/query-cell.js.map +0 -1
- package/dist/data/query-key.js +0 -42
- package/dist/data/query-key.js.map +0 -1
- package/dist/data/shared.js +0 -21
- package/dist/data/shared.js.map +0 -1
- package/dist/data/testing.js +0 -2
- package/dist/data/types.d.ts +0 -161
- package/dist/data/types.d.ts.map +0 -1
- package/dist/foundations/icon/icon.d.ts +0 -53
- package/dist/foundations/icon/icon.d.ts.map +0 -1
- package/dist/foundations/icon/icon.js +0 -88
- package/dist/foundations/icon/icon.js.map +0 -1
- package/dist/foundations/icon/icon.types.d.ts +0 -22
- package/dist/foundations/icon/icon.types.d.ts.map +0 -1
- package/dist/foundations/interactions/dismissable.d.ts +0 -72
- package/dist/foundations/interactions/dismissable.d.ts.map +0 -1
- package/dist/foundations/interactions/dismissable.js +0 -26
- package/dist/foundations/interactions/dismissable.js.map +0 -1
- package/dist/foundations/interactions/focusable.d.ts +0 -22
- package/dist/foundations/interactions/focusable.d.ts.map +0 -1
- package/dist/foundations/interactions/focusable.js +0 -18
- package/dist/foundations/interactions/focusable.js.map +0 -1
- package/dist/foundations/interactions/hoverable.d.ts +0 -26
- package/dist/foundations/interactions/hoverable.d.ts.map +0 -1
- package/dist/foundations/interactions/hoverable.js +0 -15
- package/dist/foundations/interactions/hoverable.js.map +0 -1
- package/dist/foundations/interactions/interaction-policy.d.ts +0 -50
- package/dist/foundations/interactions/interaction-policy.d.ts.map +0 -1
- package/dist/foundations/interactions/interaction-policy.js +0 -122
- package/dist/foundations/interactions/interaction-policy.js.map +0 -1
- package/dist/foundations/interactions/pressable.d.ts +0 -61
- package/dist/foundations/interactions/pressable.d.ts.map +0 -1
- package/dist/foundations/interactions/pressable.js +0 -51
- package/dist/foundations/interactions/pressable.js.map +0 -1
- package/dist/foundations/interactions/roving-focus.d.ts +0 -52
- package/dist/foundations/interactions/roving-focus.d.ts.map +0 -1
- package/dist/foundations/interactions/roving-focus.js +0 -71
- package/dist/foundations/interactions/roving-focus.js.map +0 -1
- package/dist/foundations/state/controllable.d.ts +0 -33
- package/dist/foundations/state/controllable.d.ts.map +0 -1
- package/dist/foundations/state/controllable.js +0 -82
- package/dist/foundations/state/controllable.js.map +0 -1
- package/dist/foundations/structures/collection.d.ts +0 -52
- package/dist/foundations/structures/collection.d.ts.map +0 -1
- package/dist/foundations/structures/collection.js +0 -51
- package/dist/foundations/structures/collection.js.map +0 -1
- package/dist/foundations/structures/layer.d.ts +0 -81
- package/dist/foundations/structures/layer.d.ts.map +0 -1
- package/dist/foundations/structures/layer.js +0 -81
- package/dist/foundations/structures/layer.js.map +0 -1
- package/dist/foundations/structures/layout.d.ts +0 -33
- package/dist/foundations/structures/layout.d.ts.map +0 -1
- package/dist/foundations/structures/layout.js +0 -13
- package/dist/foundations/structures/layout.js.map +0 -1
- package/dist/foundations/structures/portal.d.ts +0 -2
- package/dist/foundations/structures/portal.js +0 -3
- package/dist/foundations/structures/presence.d.ts +0 -37
- package/dist/foundations/structures/presence.d.ts.map +0 -1
- package/dist/foundations/structures/presence.js +0 -39
- package/dist/foundations/structures/presence.js.map +0 -1
- package/dist/foundations/structures/slot.d.ts +0 -35
- package/dist/foundations/structures/slot.d.ts.map +0 -1
- package/dist/foundations/structures/slot.js +0 -41
- package/dist/foundations/structures/slot.js.map +0 -1
- package/dist/foundations/utilities/aria.d.ts +0 -16
- package/dist/foundations/utilities/aria.d.ts.map +0 -1
- package/dist/foundations/utilities/aria.js +0 -17
- package/dist/foundations/utilities/aria.js.map +0 -1
- package/dist/foundations/utilities/compose-handlers.d.ts +0 -37
- package/dist/foundations/utilities/compose-handlers.d.ts.map +0 -1
- package/dist/foundations/utilities/compose-handlers.js +0 -20
- 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 +0 -18
- package/dist/foundations/utilities/compose-ref.js.map +0 -1
- package/dist/foundations/utilities/event-types.d.ts +0 -20
- package/dist/foundations/utilities/event-types.d.ts.map +0 -1
- package/dist/foundations/utilities/merge-props.d.ts +0 -5
- package/dist/foundations/utilities/merge-props.d.ts.map +0 -1
- package/dist/foundations/utilities/merge-props.js +0 -49
- package/dist/foundations/utilities/merge-props.js.map +0 -1
- package/dist/foundations/utilities/use-id.d.ts +0 -32
- 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 +0 -33
- package/dist/fx/fx.d.ts.map +0 -1
- package/dist/fx/fx.js +0 -213
- package/dist/fx/fx.js.map +0 -1
- package/dist/fx/noop.js +0 -9
- package/dist/fx/noop.js.map +0 -1
- package/dist/fx/timing.d.ts +0 -159
- package/dist/fx/timing.d.ts.map +0 -1
- package/dist/fx/timing.js +0 -243
- package/dist/fx/timing.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jsx/index.d.ts +0 -2
- package/dist/jsx/index.js +0 -4
- package/dist/jsx/types.d.ts.map +0 -1
- package/dist/jsx/types.js +0 -2
- package/dist/jsx/utils.d.ts +0 -5
- package/dist/jsx/utils.d.ts.map +0 -1
- package/dist/jsx/utils.js +0 -19
- 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/jsx-runtime2.d.ts +0 -3
- package/dist/jsx-runtime2.js +0 -4
- package/dist/renderer/attributes.js +0 -232
- package/dist/renderer/attributes.js.map +0 -1
- package/dist/renderer/boundaries.js +0 -266
- package/dist/renderer/boundaries.js.map +0 -1
- package/dist/renderer/child-shape.js +0 -85
- package/dist/renderer/child-shape.js.map +0 -1
- package/dist/renderer/children-fastpath.js +0 -149
- package/dist/renderer/children-fastpath.js.map +0 -1
- package/dist/renderer/children.js +0 -160
- package/dist/renderer/children.js.map +0 -1
- package/dist/renderer/cleanup.js +0 -210
- package/dist/renderer/cleanup.js.map +0 -1
- package/dist/renderer/component-host-cleanup.js +0 -68
- package/dist/renderer/component-host-cleanup.js.map +0 -1
- package/dist/renderer/component-host-instances.js +0 -65
- package/dist/renderer/component-host-instances.js.map +0 -1
- package/dist/renderer/component-host.js +0 -247
- package/dist/renderer/component-host.js.map +0 -1
- package/dist/renderer/dom-host.js +0 -13
- package/dist/renderer/dom-host.js.map +0 -1
- package/dist/renderer/dom-internal.js +0 -186
- package/dist/renderer/dom-internal.js.map +0 -1
- package/dist/renderer/dom.js +0 -10
- package/dist/renderer/element-children.js +0 -279
- package/dist/renderer/element-children.js.map +0 -1
- package/dist/renderer/env.js +0 -2
- package/dist/renderer/error-boundary-dom.js +0 -78
- package/dist/renderer/error-boundary-dom.js.map +0 -1
- package/dist/renderer/evaluate-dom-range.js +0 -85
- package/dist/renderer/evaluate-dom-range.js.map +0 -1
- package/dist/renderer/evaluate-reconcile.js +0 -282
- package/dist/renderer/evaluate-reconcile.js.map +0 -1
- package/dist/renderer/evaluate.js +0 -84
- package/dist/renderer/evaluate.js.map +0 -1
- package/dist/renderer/fastpath.js +0 -150
- package/dist/renderer/fastpath.js.map +0 -1
- package/dist/renderer/for-commit-dom-map.js +0 -83
- package/dist/renderer/for-commit-dom-map.js.map +0 -1
- package/dist/renderer/for-commit-removal.js +0 -36
- package/dist/renderer/for-commit-removal.js.map +0 -1
- package/dist/renderer/for-commit-reorder.js +0 -89
- package/dist/renderer/for-commit-reorder.js.map +0 -1
- package/dist/renderer/for-commit.js +0 -314
- package/dist/renderer/for-commit.js.map +0 -1
- package/dist/renderer/index.js +0 -38
- package/dist/renderer/index.js.map +0 -1
- package/dist/renderer/keyed-children.js +0 -32
- package/dist/renderer/keyed-children.js.map +0 -1
- package/dist/renderer/keyed.js +0 -167
- package/dist/renderer/keyed.js.map +0 -1
- package/dist/renderer/namespaces.js +0 -23
- package/dist/renderer/namespaces.js.map +0 -1
- package/dist/renderer/prop-bindings.js +0 -280
- package/dist/renderer/prop-bindings.js.map +0 -1
- package/dist/renderer/reactive-child-dom.js +0 -133
- package/dist/renderer/reactive-child-dom.js.map +0 -1
- package/dist/renderer/reactive-child-sources.js +0 -184
- package/dist/renderer/reactive-child-sources.js.map +0 -1
- package/dist/renderer/reactive-children.js +0 -294
- package/dist/renderer/reactive-children.js.map +0 -1
- package/dist/renderer/reconcile-commit.js +0 -38
- package/dist/renderer/reconcile-commit.js.map +0 -1
- package/dist/renderer/reconcile-fastpaths.js +0 -107
- package/dist/renderer/reconcile-fastpaths.js.map +0 -1
- package/dist/renderer/reconcile-resolution.js +0 -187
- package/dist/renderer/reconcile-resolution.js.map +0 -1
- package/dist/renderer/reconcile.js +0 -39
- package/dist/renderer/reconcile.js.map +0 -1
- package/dist/renderer/retained-element-rollback.js +0 -277
- package/dist/renderer/retained-element-rollback.js.map +0 -1
- package/dist/renderer/stable-patch.js +0 -81
- package/dist/renderer/stable-patch.js.map +0 -1
- package/dist/renderer/static-reuse.js +0 -96
- package/dist/renderer/static-reuse.js.map +0 -1
- package/dist/renderer/types.js +0 -2
- package/dist/renderer/utils.js +0 -256
- package/dist/renderer/utils.js.map +0 -1
- package/dist/router/access.js +0 -36
- package/dist/router/access.js.map +0 -1
- package/dist/router/activity.d.ts +0 -10
- package/dist/router/activity.d.ts.map +0 -1
- package/dist/router/activity.js +0 -87
- package/dist/router/activity.js.map +0 -1
- package/dist/router/authoring.d.ts +0 -22
- package/dist/router/authoring.d.ts.map +0 -1
- package/dist/router/authoring.js +0 -198
- package/dist/router/authoring.js.map +0 -1
- package/dist/router/internal-types.d.ts +0 -31
- package/dist/router/internal-types.d.ts.map +0 -1
- package/dist/router/lazy.d.ts +0 -19
- package/dist/router/lazy.d.ts.map +0 -1
- package/dist/router/lazy.js +0 -52
- package/dist/router/lazy.js.map +0 -1
- package/dist/router/manifest.d.ts +0 -10
- package/dist/router/manifest.d.ts.map +0 -1
- package/dist/router/manifest.js +0 -49
- package/dist/router/manifest.js.map +0 -1
- package/dist/router/match.js +0 -122
- package/dist/router/match.js.map +0 -1
- package/dist/router/navigate.d.ts +0 -11
- package/dist/router/navigate.d.ts.map +0 -1
- package/dist/router/navigate.js +0 -76
- package/dist/router/navigate.js.map +0 -1
- package/dist/router/navigation-registry.d.ts +0 -32
- package/dist/router/navigation-registry.d.ts.map +0 -1
- package/dist/router/navigation-registry.js +0 -105
- package/dist/router/navigation-registry.js.map +0 -1
- package/dist/router/navigation-scroll.d.ts +0 -14
- package/dist/router/navigation-scroll.d.ts.map +0 -1
- package/dist/router/navigation-scroll.js +0 -93
- package/dist/router/navigation-scroll.js.map +0 -1
- package/dist/router/navigation-targets.d.ts +0 -31
- package/dist/router/navigation-targets.d.ts.map +0 -1
- package/dist/router/navigation-targets.js +0 -255
- package/dist/router/navigation-targets.js.map +0 -1
- package/dist/router/policy.d.ts +0 -28
- package/dist/router/policy.d.ts.map +0 -1
- package/dist/router/policy.js +0 -132
- package/dist/router/policy.js.map +0 -1
- package/dist/router/rendering.d.ts +0 -10
- package/dist/router/rendering.d.ts.map +0 -1
- package/dist/router/rendering.js +0 -46
- package/dist/router/rendering.js.map +0 -1
- package/dist/router/resolution.d.ts +0 -4
- package/dist/router/resolution.d.ts.map +0 -1
- package/dist/router/resolution.js +0 -86
- package/dist/router/resolution.js.map +0 -1
- package/dist/router/route-context.js +0 -79
- package/dist/router/route-context.js.map +0 -1
- package/dist/router/route-matching.d.ts +0 -20
- package/dist/router/route-matching.d.ts.map +0 -1
- package/dist/router/route-matching.js +0 -175
- package/dist/router/route-matching.js.map +0 -1
- package/dist/router/route-query.d.ts +0 -17
- package/dist/router/route-query.d.ts.map +0 -1
- package/dist/router/route-query.js +0 -47
- package/dist/router/route-query.js.map +0 -1
- package/dist/router/route.d.ts +0 -8
- package/dist/router/route.js +0 -10
- package/dist/router/store.d.ts +0 -50
- package/dist/router/store.d.ts.map +0 -1
- package/dist/router/store.js +0 -171
- package/dist/router/store.js.map +0 -1
- package/dist/router/testing.js +0 -4
- package/dist/runtime/access.d.ts +0 -20
- package/dist/runtime/access.d.ts.map +0 -1
- package/dist/runtime/access.js +0 -45
- package/dist/runtime/access.js.map +0 -1
- package/dist/runtime/child-scope.d.ts +0 -22
- package/dist/runtime/child-scope.d.ts.map +0 -1
- package/dist/runtime/child-scope.js +0 -87
- package/dist/runtime/child-scope.js.map +0 -1
- package/dist/runtime/component-cleanup.d.ts +0 -16
- package/dist/runtime/component-cleanup.d.ts.map +0 -1
- package/dist/runtime/component-cleanup.js +0 -70
- package/dist/runtime/component-cleanup.js.map +0 -1
- package/dist/runtime/component-commit.js +0 -165
- package/dist/runtime/component-commit.js.map +0 -1
- package/dist/runtime/component-facade.d.ts +0 -5
- package/dist/runtime/component-facade.js +0 -4
- package/dist/runtime/component-internal.d.ts +0 -100
- package/dist/runtime/component-internal.d.ts.map +0 -1
- package/dist/runtime/component-internal.js +0 -219
- package/dist/runtime/component-internal.js.map +0 -1
- package/dist/runtime/component-lifecycle.d.ts +0 -49
- package/dist/runtime/component-lifecycle.d.ts.map +0 -1
- package/dist/runtime/component-lifecycle.js +0 -176
- package/dist/runtime/component-lifecycle.js.map +0 -1
- package/dist/runtime/component-scope.d.ts +0 -55
- package/dist/runtime/component-scope.d.ts.map +0 -1
- package/dist/runtime/component-scope.js.map +0 -1
- package/dist/runtime/component.d.ts +0 -5
- package/dist/runtime/component.js +0 -5
- package/dist/runtime/context.d.ts +0 -69
- package/dist/runtime/context.d.ts.map +0 -1
- package/dist/runtime/context.js +0 -210
- package/dist/runtime/context.js.map +0 -1
- package/dist/runtime/control.d.ts +0 -43
- package/dist/runtime/control.d.ts.map +0 -1
- package/dist/runtime/control.js +0 -126
- package/dist/runtime/control.js.map +0 -1
- package/dist/runtime/derive.d.ts +0 -17
- package/dist/runtime/derive.d.ts.map +0 -1
- package/dist/runtime/derive.js +0 -142
- package/dist/runtime/derive.js.map +0 -1
- package/dist/runtime/dev-namespace.d.ts +0 -31
- package/dist/runtime/dev-namespace.d.ts.map +0 -1
- package/dist/runtime/dev-namespace.js +0 -57
- package/dist/runtime/dev-namespace.js.map +0 -1
- package/dist/runtime/effect.d.ts +0 -32
- package/dist/runtime/effect.d.ts.map +0 -1
- package/dist/runtime/effect.js +0 -177
- package/dist/runtime/effect.js.map +0 -1
- package/dist/runtime/error-boundary.d.ts +0 -5
- package/dist/runtime/error-boundary.d.ts.map +0 -1
- package/dist/runtime/error-boundary.js +0 -31
- package/dist/runtime/error-boundary.js.map +0 -1
- package/dist/runtime/events.d.ts +0 -58
- package/dist/runtime/events.d.ts.map +0 -1
- package/dist/runtime/events.js +0 -204
- package/dist/runtime/events.js.map +0 -1
- package/dist/runtime/execution-model.d.ts +0 -7
- package/dist/runtime/execution-model.d.ts.map +0 -1
- package/dist/runtime/execution-model.js +0 -15
- package/dist/runtime/execution-model.js.map +0 -1
- package/dist/runtime/fastlane.d.ts +0 -34
- package/dist/runtime/fastlane.d.ts.map +0 -1
- package/dist/runtime/fastlane.js +0 -175
- package/dist/runtime/fastlane.js.map +0 -1
- package/dist/runtime/for-bench.d.ts +0 -41
- package/dist/runtime/for-bench.d.ts.map +0 -1
- package/dist/runtime/for-bench.js +0 -171
- package/dist/runtime/for-bench.js.map +0 -1
- package/dist/runtime/for-internal.d.ts +0 -43
- package/dist/runtime/for-internal.d.ts.map +0 -1
- package/dist/runtime/for-internal.js +0 -98
- package/dist/runtime/for-internal.js.map +0 -1
- package/dist/runtime/for-reconcile.d.ts +0 -8
- package/dist/runtime/for-reconcile.d.ts.map +0 -1
- package/dist/runtime/for-reconcile.js +0 -389
- package/dist/runtime/for-reconcile.js.map +0 -1
- package/dist/runtime/for-scopes.d.ts +0 -26
- package/dist/runtime/for-scopes.d.ts.map +0 -1
- package/dist/runtime/for-scopes.js +0 -160
- package/dist/runtime/for-scopes.js.map +0 -1
- package/dist/runtime/for-signals.d.ts +0 -30
- package/dist/runtime/for-signals.d.ts.map +0 -1
- package/dist/runtime/for-signals.js +0 -139
- package/dist/runtime/for-signals.js.map +0 -1
- package/dist/runtime/for-types.d.ts +0 -9
- package/dist/runtime/for-types.d.ts.map +0 -1
- package/dist/runtime/for.d.ts +0 -4
- package/dist/runtime/for.js +0 -5
- package/dist/runtime/index.d.ts +0 -24
- package/dist/runtime/index.js +0 -31
- package/dist/runtime/lifecycle-operations.d.ts +0 -31
- package/dist/runtime/lifecycle-operations.d.ts.map +0 -1
- package/dist/runtime/lifecycle-operations.js.map +0 -1
- package/dist/runtime/operations.d.ts +0 -3
- package/dist/runtime/operations.js +0 -3
- package/dist/runtime/perf-metrics.d.ts +0 -26
- package/dist/runtime/perf-metrics.d.ts.map +0 -1
- package/dist/runtime/perf-metrics.js +0 -70
- package/dist/runtime/perf-metrics.js.map +0 -1
- package/dist/runtime/portal.d.ts +0 -22
- package/dist/runtime/portal.d.ts.map +0 -1
- package/dist/runtime/portal.js.map +0 -1
- package/dist/runtime/readable.d.ts +0 -29
- package/dist/runtime/readable.d.ts.map +0 -1
- package/dist/runtime/readable.js +0 -159
- package/dist/runtime/readable.js.map +0 -1
- package/dist/runtime/resource-cell.js +0 -114
- package/dist/runtime/resource-cell.js.map +0 -1
- package/dist/runtime/resource-operation.d.ts +0 -13
- package/dist/runtime/resource-operation.d.ts.map +0 -1
- package/dist/runtime/resource-operation.js +0 -170
- package/dist/runtime/resource-operation.js.map +0 -1
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/runtime.js +0 -59
- 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-store.js +0 -24
- package/dist/runtime/selector-store.js.map +0 -1
- package/dist/runtime/selector.d.ts +0 -11
- package/dist/runtime/selector.d.ts.map +0 -1
- package/dist/runtime/selector.js.map +0 -1
- package/dist/runtime/snapshot-source.d.ts +0 -10
- 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 +0 -55
- package/dist/runtime/state.d.ts.map +0 -1
- package/dist/runtime/state.js.map +0 -1
- package/dist/ssg/batch-render.js +0 -103
- package/dist/ssg/batch-render.js.map +0 -1
- package/dist/ssg/create-static-gen.d.ts +0 -64
- package/dist/ssg/create-static-gen.d.ts.map +0 -1
- package/dist/ssg/create-static-gen.js +0 -199
- package/dist/ssg/create-static-gen.js.map +0 -1
- package/dist/ssg/generate-metadata.js +0 -94
- package/dist/ssg/generate-metadata.js.map +0 -1
- package/dist/ssg/generation-plan.js +0 -70
- package/dist/ssg/generation-plan.js.map +0 -1
- package/dist/ssg/incremental-manifest.js +0 -56
- package/dist/ssg/incremental-manifest.js.map +0 -1
- package/dist/ssg/resolve-ssg-data.js +0 -105
- package/dist/ssg/resolve-ssg-data.js.map +0 -1
- package/dist/ssg/route-utils.js +0 -24
- package/dist/ssg/route-utils.js.map +0 -1
- package/dist/ssg/static-routes.js +0 -102
- package/dist/ssg/static-routes.js.map +0 -1
- package/dist/ssg/types.d.ts +0 -189
- package/dist/ssg/types.d.ts.map +0 -1
- package/dist/ssg/write-static-files.js +0 -73
- package/dist/ssg/write-static-files.js.map +0 -1
- package/dist/ssr/attrs.js +0 -94
- package/dist/ssr/attrs.js.map +0 -1
- package/dist/ssr/boundaries.js +0 -113
- package/dist/ssr/boundaries.js.map +0 -1
- package/dist/ssr/component-runtime.js +0 -111
- package/dist/ssr/component-runtime.js.map +0 -1
- package/dist/ssr/context.d.ts +0 -50
- package/dist/ssr/context.d.ts.map +0 -1
- package/dist/ssr/context.js +0 -91
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/errors.d.ts +0 -10
- package/dist/ssr/errors.d.ts.map +0 -1
- package/dist/ssr/errors.js +0 -14
- package/dist/ssr/errors.js.map +0 -1
- package/dist/ssr/escape.js +0 -193
- package/dist/ssr/escape.js.map +0 -1
- package/dist/ssr/hydration-data.js +0 -10
- package/dist/ssr/hydration-data.js.map +0 -1
- package/dist/ssr/hydration-verify.d.ts +0 -12
- package/dist/ssr/hydration-verify.d.ts.map +0 -1
- package/dist/ssr/hydration-verify.js +0 -144
- package/dist/ssr/hydration-verify.js.map +0 -1
- package/dist/ssr/index-internal.d.ts +0 -15
- package/dist/ssr/index-internal.d.ts.map +0 -1
- package/dist/ssr/index-internal.js +0 -19
- package/dist/ssr/index-internal.js.map +0 -1
- package/dist/ssr/render-keys.js +0 -16
- package/dist/ssr/render-keys.js.map +0 -1
- package/dist/ssr/render-resolved.d.ts +0 -20
- package/dist/ssr/render-resolved.d.ts.map +0 -1
- package/dist/ssr/render-resolved.js +0 -35
- package/dist/ssr/render-resolved.js.map +0 -1
- package/dist/ssr/render-sync.d.ts +0 -21
- package/dist/ssr/render-sync.d.ts.map +0 -1
- package/dist/ssr/render-sync.js +0 -275
- package/dist/ssr/render-sync.js.map +0 -1
- package/dist/ssr/route-policy-resolution.js +0 -78
- package/dist/ssr/route-policy-resolution.js.map +0 -1
- package/dist/ssr/route-render.d.ts +0 -77
- package/dist/ssr/route-render.d.ts.map +0 -1
- package/dist/ssr/route-render.js +0 -120
- package/dist/ssr/route-render.js.map +0 -1
- package/dist/ssr/sink.d.ts +0 -26
- package/dist/ssr/sink.d.ts.map +0 -1
- package/dist/ssr/sink.js +0 -86
- package/dist/ssr/sink.js.map +0 -1
- package/dist/ssr/types.d.ts +0 -23
- 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,94 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs/promises";
|
|
2
|
-
import * as pathModule from "node:path";
|
|
3
|
-
//#region src/ssg/generate-metadata.ts
|
|
4
|
-
/**
|
|
5
|
-
* Metadata generation for SSG
|
|
6
|
-
*
|
|
7
|
-
* Generates and serializes metadata about generated static files.
|
|
8
|
-
* This module is Node-only and not intended for browser builds.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Generate SSGResult from render results
|
|
12
|
-
*/
|
|
13
|
-
function generateSSGResult(results, options = {}) {
|
|
14
|
-
let successful = 0;
|
|
15
|
-
let failed = 0;
|
|
16
|
-
let totalDuration = 0;
|
|
17
|
-
let rebuilt = 0;
|
|
18
|
-
let skipped = 0;
|
|
19
|
-
let removed = 0;
|
|
20
|
-
for (let index = 0; index < results.length; index += 1) {
|
|
21
|
-
const result = results[index];
|
|
22
|
-
totalDuration += result.renderDuration;
|
|
23
|
-
if (result.status === "success") {
|
|
24
|
-
successful += 1;
|
|
25
|
-
rebuilt += 1;
|
|
26
|
-
} else if (result.status === "error") {
|
|
27
|
-
failed += 1;
|
|
28
|
-
rebuilt += 1;
|
|
29
|
-
} else if (result.status === "skipped") skipped += 1;
|
|
30
|
-
else if (result.status === "removed") removed += 1;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
34
|
-
totalRoutes: results.length,
|
|
35
|
-
successful,
|
|
36
|
-
failed,
|
|
37
|
-
totalDuration: Math.round(totalDuration),
|
|
38
|
-
mode: options.mode ?? "full",
|
|
39
|
-
rebuilt,
|
|
40
|
-
skipped,
|
|
41
|
-
removed,
|
|
42
|
-
cacheHits: options.cacheHits ?? 0,
|
|
43
|
-
invalidatedKeys: options.invalidatedKeys?.slice() ?? [],
|
|
44
|
-
invalidatedRoutes: options.invalidatedRoutes?.slice() ?? [],
|
|
45
|
-
routes: results
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Convert SSGResult to metadata for JSON serialization
|
|
50
|
-
*/
|
|
51
|
-
function resultToMetadata(result) {
|
|
52
|
-
const routes = [];
|
|
53
|
-
for (let index = 0; index < result.routes.length; index += 1) {
|
|
54
|
-
const route = result.routes[index];
|
|
55
|
-
routes.push({
|
|
56
|
-
path: route.path,
|
|
57
|
-
filePath: route.filePath,
|
|
58
|
-
fileSize: route.fileSize,
|
|
59
|
-
renderDuration: route.renderDuration,
|
|
60
|
-
resourceCount: route.resourceCount,
|
|
61
|
-
status: route.status,
|
|
62
|
-
reason: route.reason,
|
|
63
|
-
written: route.written,
|
|
64
|
-
error: route.error
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
generatedAt: result.generatedAt,
|
|
69
|
-
totalRoutes: result.totalRoutes,
|
|
70
|
-
successful: result.successful,
|
|
71
|
-
failed: result.failed,
|
|
72
|
-
totalDuration: result.totalDuration,
|
|
73
|
-
mode: result.mode,
|
|
74
|
-
rebuilt: result.rebuilt,
|
|
75
|
-
skipped: result.skipped,
|
|
76
|
-
removed: result.removed,
|
|
77
|
-
cacheHits: result.cacheHits,
|
|
78
|
-
invalidatedKeys: result.invalidatedKeys.slice(),
|
|
79
|
-
invalidatedRoutes: result.invalidatedRoutes.slice(),
|
|
80
|
-
routes
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Write metadata.json to output directory
|
|
85
|
-
*/
|
|
86
|
-
async function writeMetadata(metadata, outputDir) {
|
|
87
|
-
const filePath = pathModule.join(outputDir, "metadata.json");
|
|
88
|
-
await fs.mkdir(outputDir, { recursive: true });
|
|
89
|
-
await fs.writeFile(filePath, JSON.stringify(metadata, null, 2), "utf8");
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
export { generateSSGResult, resultToMetadata, writeMetadata };
|
|
93
|
-
|
|
94
|
-
//# sourceMappingURL=generate-metadata.js.map
|
|
@@ -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,kBAC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O;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,70 +0,0 @@
|
|
|
1
|
-
//#region src/ssg/generation-plan.ts
|
|
2
|
-
function dedupeStrings(values) {
|
|
3
|
-
return values ? Array.from(new Set(values)) : [];
|
|
4
|
-
}
|
|
5
|
-
function getRoutesToRender(selected) {
|
|
6
|
-
const routes = [];
|
|
7
|
-
for (let index = 0; index < selected.length; index += 1) routes.push(selected[index].descriptor.route);
|
|
8
|
-
return routes;
|
|
9
|
-
}
|
|
10
|
-
function selectRouteForGeneration(descriptor, previous, mode, changedKeys, changedRoutes) {
|
|
11
|
-
if (mode === "full") return {
|
|
12
|
-
descriptor,
|
|
13
|
-
reason: "full",
|
|
14
|
-
previous
|
|
15
|
-
};
|
|
16
|
-
if (!previous) return {
|
|
17
|
-
descriptor,
|
|
18
|
-
reason: "new-route",
|
|
19
|
-
previous
|
|
20
|
-
};
|
|
21
|
-
if (previous.lastStatus === "error" || previous.htmlHash === null) return {
|
|
22
|
-
descriptor,
|
|
23
|
-
reason: "new-route",
|
|
24
|
-
previous
|
|
25
|
-
};
|
|
26
|
-
if (descriptor.invalidationKeys.length === 0) return {
|
|
27
|
-
descriptor,
|
|
28
|
-
reason: "no-keys",
|
|
29
|
-
previous
|
|
30
|
-
};
|
|
31
|
-
if (changedRoutes.includes(descriptor.path)) return {
|
|
32
|
-
descriptor,
|
|
33
|
-
reason: "changed-route",
|
|
34
|
-
previous
|
|
35
|
-
};
|
|
36
|
-
if (descriptor.invalidationKeys.some((key) => changedKeys.includes(key))) return {
|
|
37
|
-
descriptor,
|
|
38
|
-
reason: "changed-key",
|
|
39
|
-
previous
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
descriptor,
|
|
43
|
-
reason: "unchanged",
|
|
44
|
-
previous
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function collectRemovedRouteResults(manifest, currentRouteIds) {
|
|
48
|
-
if (!manifest) return [];
|
|
49
|
-
const results = [];
|
|
50
|
-
for (let index = 0; index < manifest.routes.length; index += 1) {
|
|
51
|
-
const entry = manifest.routes[index];
|
|
52
|
-
if (currentRouteIds.has(entry.routeId)) continue;
|
|
53
|
-
results.push({
|
|
54
|
-
path: entry.path,
|
|
55
|
-
filePath: entry.filePath,
|
|
56
|
-
html: "",
|
|
57
|
-
fileSize: 0,
|
|
58
|
-
renderDuration: 0,
|
|
59
|
-
resourceCount: 0,
|
|
60
|
-
status: "removed",
|
|
61
|
-
reason: "deleted",
|
|
62
|
-
written: false
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return results;
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
export { collectRemovedRouteResults, dedupeStrings, getRoutesToRender, selectRouteForGeneration };
|
|
69
|
-
|
|
70
|
-
//# sourceMappingURL=generation-plan.js.map
|
|
@@ -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,56 +0,0 @@
|
|
|
1
|
-
import * as fsPromises from "node:fs/promises";
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
import * as pathModule from "node:path";
|
|
4
|
-
const MANIFEST_DIR = ".askr";
|
|
5
|
-
const MANIFEST_FILE = "ssg-manifest.json";
|
|
6
|
-
function hashHtml(html) {
|
|
7
|
-
let hash = 2166136261;
|
|
8
|
-
for (let index = 0; index < html.length; index += 1) {
|
|
9
|
-
hash ^= html.charCodeAt(index);
|
|
10
|
-
hash = Math.imul(hash, 16777619);
|
|
11
|
-
}
|
|
12
|
-
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
13
|
-
}
|
|
14
|
-
function getIncrementalManifestPath(outputDir) {
|
|
15
|
-
return pathModule.join(outputDir, MANIFEST_DIR, MANIFEST_FILE);
|
|
16
|
-
}
|
|
17
|
-
function readIncrementalManifest(outputDir, seed) {
|
|
18
|
-
const manifestPath = getIncrementalManifestPath(outputDir);
|
|
19
|
-
if (!fs.existsSync(manifestPath)) return null;
|
|
20
|
-
try {
|
|
21
|
-
const raw = fs.readFileSync(manifestPath, "utf8");
|
|
22
|
-
const parsed = JSON.parse(raw);
|
|
23
|
-
if (parsed.schemaVersion !== 1 || parsed.seed !== seed || !Array.isArray(parsed.routes)) return null;
|
|
24
|
-
const routes = parsed.routes.filter((entry) => !!entry && typeof entry.routeId === "string" && typeof entry.path === "string" && typeof entry.filePath === "string" && Array.isArray(entry.invalidationKeys) && (entry.htmlHash === null || typeof entry.htmlHash === "string") && (entry.lastStatus === "success" || entry.lastStatus === "error"));
|
|
25
|
-
if (routes.length !== parsed.routes.length) return null;
|
|
26
|
-
return {
|
|
27
|
-
schemaVersion: 1,
|
|
28
|
-
seed,
|
|
29
|
-
mode: parsed.mode === "incremental" ? "incremental" : "full",
|
|
30
|
-
routes
|
|
31
|
-
};
|
|
32
|
-
} catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async function writeIncrementalManifest(manifest, outputDir) {
|
|
37
|
-
const manifestPath = getIncrementalManifestPath(outputDir);
|
|
38
|
-
await fsPromises.mkdir(pathModule.dirname(manifestPath), { recursive: true });
|
|
39
|
-
await fsPromises.writeFile(manifestPath, JSON.stringify(manifest, null, 2), "utf8");
|
|
40
|
-
}
|
|
41
|
-
function getExistingOutputFileSize(outputDir, filePath) {
|
|
42
|
-
const fullPath = pathModule.join(outputDir, filePath);
|
|
43
|
-
if (!fs.existsSync(fullPath)) return 0;
|
|
44
|
-
try {
|
|
45
|
-
return fs.statSync(fullPath).size;
|
|
46
|
-
} catch {
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function outputFileExists(outputDir, filePath) {
|
|
51
|
-
return fs.existsSync(pathModule.join(outputDir, filePath));
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { getExistingOutputFileSize, getIncrementalManifestPath, hashHtml, outputFileExists, readIncrementalManifest, writeIncrementalManifest };
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=incremental-manifest.js.map
|
|
@@ -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,gBAAg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,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,105 +0,0 @@
|
|
|
1
|
-
import { interpolateRoutePath } from "./route-utils.js";
|
|
2
|
-
//#region src/ssg/resolve-ssg-data.ts
|
|
3
|
-
function hasOwnRouteData(dataMap, path) {
|
|
4
|
-
return Object.prototype.hasOwnProperty.call(dataMap, path);
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Resolve and validate data for SSG routes
|
|
8
|
-
* Returns a map of route path -> SSRData
|
|
9
|
-
*
|
|
10
|
-
* In phase 1: accepts user-supplied dataOverrides
|
|
11
|
-
* In phase 2: can be extended to auto-discover resources
|
|
12
|
-
*/
|
|
13
|
-
function resolveSsgData(routes, options = {}) {
|
|
14
|
-
const { dataOverrides = {} } = options;
|
|
15
|
-
const dataMap = {};
|
|
16
|
-
for (const route of routes) {
|
|
17
|
-
const concretePath = interpolateRoutePath(route.path, route.params);
|
|
18
|
-
const overridePath = concretePath in dataOverrides ? concretePath : route.path in dataOverrides ? route.path : null;
|
|
19
|
-
if (overridePath) {
|
|
20
|
-
const data = dataOverrides[overridePath];
|
|
21
|
-
if (typeof data !== "object" || data === null || Array.isArray(data)) throw new Error(`data for route "${overridePath}" must be an object, got ${typeof data}`);
|
|
22
|
-
dataMap[overridePath] = data;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return dataMap;
|
|
26
|
-
}
|
|
27
|
-
function resolveSsgRouteData(dataMap, routePath, concretePath) {
|
|
28
|
-
if (hasOwnRouteData(dataMap, concretePath)) return {
|
|
29
|
-
hasData: true,
|
|
30
|
-
data: dataMap[concretePath]
|
|
31
|
-
};
|
|
32
|
-
if (hasOwnRouteData(dataMap, routePath)) return {
|
|
33
|
-
hasData: true,
|
|
34
|
-
data: dataMap[routePath]
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
hasData: false,
|
|
38
|
-
data: void 0
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function isStringRecord(value) {
|
|
42
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
43
|
-
for (const recordValue of Object.values(value)) if (typeof recordValue !== "string") return false;
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
function validateRouteShape(route) {
|
|
47
|
-
if (typeof route.path !== "string" || !route.path.startsWith("/")) throw new Error(`route path must be a string starting with "/", got "${route.path}"`);
|
|
48
|
-
if (typeof (route.handler ?? route.component) !== "function") throw new Error(`route handler must be a function for path "${route.path}"`);
|
|
49
|
-
if (route.params !== void 0 && !isStringRecord(route.params)) throw new Error(`route "${route.path}" params must be an object containing only string values`);
|
|
50
|
-
if (route.invalidationKeys !== void 0) {
|
|
51
|
-
if (!Array.isArray(route.invalidationKeys)) throw new Error(`route "${route.path}" invalidationKeys must be an array of strings`);
|
|
52
|
-
for (const key of route.invalidationKeys) if (typeof key !== "string" || key.length === 0) throw new Error(`route "${route.path}" invalidationKeys must contain only non-empty strings`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function validateEntriesResult(route, entries) {
|
|
56
|
-
if (!Array.isArray(entries)) throw new Error(`route "${route.path}" entries must return an array of param maps`);
|
|
57
|
-
return entries.map((entry, index) => {
|
|
58
|
-
if (!isStringRecord(entry)) throw new Error(`route "${route.path}" entries[${index}] must be an object containing only string values`);
|
|
59
|
-
return entry;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
async function expandRoutes(routes) {
|
|
63
|
-
if (!Array.isArray(routes)) throw new Error("routes must be an array");
|
|
64
|
-
const expanded = [];
|
|
65
|
-
for (const route of routes) {
|
|
66
|
-
validateRouteShape(route);
|
|
67
|
-
if (route.params) expanded.push({
|
|
68
|
-
...route,
|
|
69
|
-
entries: void 0
|
|
70
|
-
});
|
|
71
|
-
if (!route.entries) {
|
|
72
|
-
if (!route.params) expanded.push(route);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const entries = validateEntriesResult(route, await route.entries());
|
|
76
|
-
for (const params of entries) expanded.push({
|
|
77
|
-
...route,
|
|
78
|
-
params,
|
|
79
|
-
entries: void 0
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
return expanded;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Validate routes are properly configured
|
|
86
|
-
*/
|
|
87
|
-
function validateRoutes(routes) {
|
|
88
|
-
if (!Array.isArray(routes)) throw new Error("routes must be an array");
|
|
89
|
-
const seen = /* @__PURE__ */ new Set();
|
|
90
|
-
for (const route of routes) {
|
|
91
|
-
validateRouteShape(route);
|
|
92
|
-
const key = `${route.path}::${JSON.stringify(route.params || {})}`;
|
|
93
|
-
if (seen.has(key)) throw new Error(`duplicate route entry detected for path "${route.path}"`);
|
|
94
|
-
seen.add(key);
|
|
95
|
-
if (route.path.includes("{")) {
|
|
96
|
-
const paramNames = Array.from(route.path.matchAll(/\{([^}]+)\}/g)).map((m) => m[1]);
|
|
97
|
-
if (!route.params) throw new Error(`route "${route.path}" uses path parameters and requires params`);
|
|
98
|
-
for (const name of paramNames) if (!(name in route.params)) throw new Error(`route "${route.path}" missing required param "${name}"`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
export { expandRoutes, resolveSsgData, resolveSsgRouteData, validateRoutes };
|
|
104
|
-
|
|
105
|
-
//# sourceMappingURL=resolve-ssg-data.js.map
|
|
@@ -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;AAC3D;;;;;;;;AASA,SAAgB,eACd,QACA,UAAiC,CAAC,GACT;CACzB,MAAM,EAAE,gBAAgB,CAAC,MAAM;CAC/B,MAAM,UAAmC,CAAC;CAE1C,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,eAAe,qBAAqB,MAAM,MAAM,MAAM,MAAM;EAClE,MAAM,eACJ,gBAAgB,gBACZ,eACA,MAAM,QAAQ,gBACZ,MAAM,OACN;EAGR,IAAI,cAAc;GAChB,MAAM,OAAO,cAAc;GAC3B,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,IAAI,GACjE,MAAM,IAAI,MACR,mBAAmB,aAAa,2BAA2B,OAAO,MACpE;GAEF,QAAQ,gBAAgB;EAC1B;CAGF;CAEA,OAAO;AACT;AAEA,SAAgB,oBACd,SACA,WACA,cACsB;CACtB,IAAI,gBAAgB,SAAS,YAAY,GACvC,OAAO;EACL,SAAS;EACT,MAAM,QAAQ;CAChB;CAGF,IAAI,gBAAgB,SAAS,SAAS,GACpC,OA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-
function getOutputFilePath(pathStr) {
|
|
3
|
-
if (pathStr === "/") return "index.html";
|
|
4
|
-
return `${pathStr.replace(/^\/|\/$/g, "")}/index.html`;
|
|
5
|
-
}
|
|
6
|
-
function interpolateRoutePath(routePath, params) {
|
|
7
|
-
if (!params) return routePath;
|
|
8
|
-
return routePath.replace(/\{([^}]+)\}/g, (_, key) => params[key] ?? "");
|
|
9
|
-
}
|
|
10
|
-
function resolveRouteDescriptor(route) {
|
|
11
|
-
const path = interpolateRoutePath(route.path, route.params);
|
|
12
|
-
const filePath = getOutputFilePath(path);
|
|
13
|
-
return {
|
|
14
|
-
route,
|
|
15
|
-
path,
|
|
16
|
-
filePath,
|
|
17
|
-
routeId: `${path}::${filePath}`,
|
|
18
|
-
invalidationKeys: route.invalidationKeys?.slice() ?? []
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { getOutputFilePath, interpolateRoutePath, resolveRouteDescriptor };
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=route-utils.js.map
|
|
@@ -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,102 +0,0 @@
|
|
|
1
|
-
import { _getBuiltInRoutePolicy } from "../router/policy.js";
|
|
2
|
-
import "../router/route.js";
|
|
3
|
-
import { getOutputFilePath, interpolateRoutePath, resolveRouteDescriptor } from "./route-utils.js";
|
|
4
|
-
import { expandRoutes } from "./resolve-ssg-data.js";
|
|
5
|
-
//#region src/ssg/static-routes.ts
|
|
6
|
-
function getRuntimeOnlyDiagnostic(route, path) {
|
|
7
|
-
const policies = route.policies ?? [];
|
|
8
|
-
if (route.auth === true) return `Skipped prerender for "${path}": authenticated routes are runtime-only by default.`;
|
|
9
|
-
if (route.role) return `Skipped prerender for "${path}": role-gated routes are runtime-only by default.`;
|
|
10
|
-
if (route.permission) return `Skipped prerender for "${path}": permission-gated routes are runtime-only by default.`;
|
|
11
|
-
if (policies.length > 0) {
|
|
12
|
-
let hasAuthPolicy = false;
|
|
13
|
-
let hasRolePolicy = false;
|
|
14
|
-
let hasPermissionPolicy = false;
|
|
15
|
-
for (const policy of policies) {
|
|
16
|
-
const metadata = _getBuiltInRoutePolicy(policy);
|
|
17
|
-
if (!metadata) return `Skipped prerender for "${path}": routes with custom policies are runtime-only by default.`;
|
|
18
|
-
if (metadata.kind === "auth") hasAuthPolicy = true;
|
|
19
|
-
else if (metadata.kind === "role") hasRolePolicy = true;
|
|
20
|
-
else if (metadata.kind === "permission") hasPermissionPolicy = true;
|
|
21
|
-
}
|
|
22
|
-
if (hasAuthPolicy) return `Skipped prerender for "${path}": authenticated routes are runtime-only by default.`;
|
|
23
|
-
if (hasRolePolicy) return `Skipped prerender for "${path}": role-gated routes are runtime-only by default.`;
|
|
24
|
-
if (hasPermissionPolicy) return `Skipped prerender for "${path}": permission-gated routes are runtime-only by default.`;
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
function getRouteResultPath(route) {
|
|
30
|
-
return route.params ? interpolateRoutePath(route.path, route.params) : route.path;
|
|
31
|
-
}
|
|
32
|
-
function createRuntimeOnlyRoute(route, diagnostic) {
|
|
33
|
-
const path = getRouteResultPath(route);
|
|
34
|
-
const filePath = getOutputFilePath(path);
|
|
35
|
-
return {
|
|
36
|
-
routeId: `${path}::${filePath}`,
|
|
37
|
-
result: {
|
|
38
|
-
path,
|
|
39
|
-
filePath,
|
|
40
|
-
html: "",
|
|
41
|
-
fileSize: 0,
|
|
42
|
-
renderDuration: 0,
|
|
43
|
-
resourceCount: 0,
|
|
44
|
-
status: "skipped",
|
|
45
|
-
reason: "runtime-only",
|
|
46
|
-
written: false,
|
|
47
|
-
error: diagnostic
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
async function splitStaticRoutes(routes) {
|
|
52
|
-
const prerenderableRoutes = [];
|
|
53
|
-
const runtimeOnly = [];
|
|
54
|
-
const outputRouteIds = [];
|
|
55
|
-
for (const route of routes) {
|
|
56
|
-
const diagnostic = getRuntimeOnlyDiagnostic(route, getRouteResultPath(route));
|
|
57
|
-
if (diagnostic) {
|
|
58
|
-
const runtimeRoute = createRuntimeOnlyRoute(route, diagnostic);
|
|
59
|
-
runtimeOnly.push(runtimeRoute);
|
|
60
|
-
outputRouteIds.push(runtimeRoute.routeId);
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const expanded = await expandRoutes([route]);
|
|
64
|
-
prerenderableRoutes.push(...expanded);
|
|
65
|
-
for (const expandedRoute of expanded) outputRouteIds.push(resolveRouteDescriptor(expandedRoute).routeId);
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
routes: prerenderableRoutes,
|
|
69
|
-
runtimeOnly,
|
|
70
|
-
outputRouteIds
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function normalizeStaticRoutes(options) {
|
|
74
|
-
if (options.registry) return routeRegistryToRouteConfigs(options.registry);
|
|
75
|
-
return [...options.routes ?? []];
|
|
76
|
-
}
|
|
77
|
-
function routeRegistryToRouteConfigs(registry) {
|
|
78
|
-
const routeConfigs = [];
|
|
79
|
-
for (const record of registry.manifest.records) {
|
|
80
|
-
if (record.isFallback) continue;
|
|
81
|
-
routeConfigs.push({
|
|
82
|
-
path: record.path,
|
|
83
|
-
handler: record.handler,
|
|
84
|
-
namespace: record.options.namespace,
|
|
85
|
-
auth: record.options.auth,
|
|
86
|
-
role: record.options.role,
|
|
87
|
-
permission: record.options.permission,
|
|
88
|
-
policies: stripRegistryGuestPolicies(record.options.policies),
|
|
89
|
-
entries: record.options.entries
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return routeConfigs;
|
|
93
|
-
}
|
|
94
|
-
function stripRegistryGuestPolicies(policies) {
|
|
95
|
-
if (!policies || policies.length === 0) return;
|
|
96
|
-
const filtered = policies.filter((policy) => _getBuiltInRoutePolicy(policy)?.kind !== "guest");
|
|
97
|
-
return filtered.length > 0 ? filtered : void 0;
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
export { normalizeStaticRoutes, splitStaticRoutes };
|
|
101
|
-
|
|
102
|
-
//# sourceMappingURL=static-routes.js.map
|
|
@@ -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/route';\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,SAAS,QAC3B,gBAAgB;QACX,IAAI,SAAS,SAAS,cAC3B,sBAAsB;EAE1B;EAEA,IAAI,eACF,OAAO,0BAA0B,KAAK;EAGxC,IAAI,eACF,OAAO,0BAA0B,KAAK;EAGxC,IAAI,qBACF,OAAO,0BAA0B,KAAK;EAGxC,OAAO;CACT;CAEA,OAAO;AACT;AAEA,SAAS,mBAAmB,OAA4B;CACtD,OAAO,MAAM,SACT,qBAAqB,MAAM,MAAM,MAAM,MAAM,IAC7C,MAAM;AACZ;AAEA,SAAS,uBACP,OACA,YACkB;CAClB,MAAM,OAAO,mBAAmB,KAAK;CACrC,MAAM,WAAW,kBAAkB,IAAI;CAEvC,OAAO;EACL,SAAS,GAAG,KAAK,IAAI;EACrB,QA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