@askrjs/askr 0.0.52 → 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} +182 -9
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +103 -0
- package/dist/{common/attr-names.js → attr-names-CjhzmHOn.js} +1 -1
- package/dist/benchmark.d.ts +6 -2
- package/dist/benchmark.js +63 -11
- package/dist/boot/index.d.ts +61 -2
- package/dist/boot/index.js +1 -203
- package/dist/boot-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} +8 -1
- package/dist/component-scope-CvPba6O6.d.ts +12 -0
- package/dist/components/index.d.ts +17 -2
- package/dist/components/index.js +39 -1
- package/dist/compose-ref-Cc_YkUpM.js +92 -0
- package/dist/{foundations/utilities/compose-ref.d.ts → compose-ref-Cizq72-x.d.ts} +1 -1
- package/dist/control/index.d.ts +1 -3
- package/dist/control/index.js +1 -3
- package/dist/control-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 -1
- 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} +32 -31
- package/dist/deferred-lKE8uR0z.js +386 -0
- package/dist/{runtime/effect.js → effect-BwnIvLah.js} +4 -4
- 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 -8
- package/dist/index-SJXJkssx.d.ts +44 -0
- package/dist/index.d.ts +8 -13
- package/dist/index.js +150 -15
- package/dist/interactions-w7gQN4ha.js +280 -0
- package/dist/{data/invalidation-listeners.js → invalidation-listeners-Des3AHYs.js} +1 -1
- package/dist/{common/props.d.ts → jsx-CP0gmYwJ.d.ts} +17 -5
- package/dist/{common/jsx.js → jsx-CUpRxrLH.js} +1 -1
- package/dist/jsx-dev-runtime.d.ts +2 -4
- package/dist/jsx-dev-runtime.js +7 -5
- package/dist/jsx-runtime-92bV2hSa.d.ts +34 -0
- package/dist/jsx-runtime-BVVgDSdq.d.ts +1 -0
- package/dist/jsx-runtime.d.ts +2 -35
- package/dist/jsx-runtime.js +11 -5
- package/dist/{runtime/lifecycle-operations.js → lifecycle-operations-D9va7GOU.js} +4 -5
- package/dist/navigate-BVDCzOuB.d.ts +34 -0
- package/dist/navigate-CmPLSXyw.js +1449 -0
- package/dist/{runtime/portal.js → portal-CyU3Ucf2.js} +33 -36
- package/dist/query-registry-CQIT4mXr.js +73 -0
- package/dist/{common/render-context.js → render-context-Clw3rFiO.js} +14 -6
- package/dist/renderer-DzPjeLby.js +6197 -0
- package/dist/{runtime/resource-operation.js → resource-operation-CEzfpnDk.js} +118 -15
- package/dist/resources/index.d.ts +42 -3
- package/dist/resources/index.js +3 -4
- package/dist/{common/route-activity.js → route-activity-CNJfpwx-.js} +1 -1
- package/dist/route-matching-vJpvLVbX.js +515 -0
- package/dist/router/index.d.ts +166 -14
- package/dist/router/index.js +150 -12
- package/dist/{common/router.d.ts → router-CeYvjj5_.d.ts} +72 -28
- package/dist/{common/router-internal.js → router-internal-BC0w1_xk.js} +1 -1
- package/dist/{runtime/scheduler.d.ts → scheduler-CmLO4Dfm.d.ts} +1 -3
- package/dist/{runtime/selector.js → selector-DafVYzV4.js} +34 -11
- package/dist/{runtime/snapshot-source.js → snapshot-source-BB42xgwb.js} +1 -1
- package/dist/ssg/index.d.ts +252 -4
- package/dist/ssg/index.js +857 -1
- package/dist/ssr/index.d.ts +225 -8
- package/dist/ssr/index.js +3 -6
- package/dist/{common/ssr.js → ssr-CbQO5xd3.js} +1 -1
- package/dist/ssr-D3t80Rc0.js +1413 -0
- package/dist/{runtime/state.js → state-DPl8lffD.js} +3 -5
- package/dist/structures-DUB3HchX.js +221 -0
- package/dist/testing/index.d.ts +3 -2
- package/dist/testing/index.js +2 -5
- package/dist/{jsx/types.d.ts → types-DnQVG4ZY.d.ts} +2 -5
- package/dist/{foundations/utilities/use-id.js → utilities-C_CGX4Dz.js} +1 -1
- package/dist/{ssr/verify-hydration.js → verify-hydration-io9ahUeq.js} +2 -2
- package/dist/{common/vnode.js → vnode-CGMJYPMB.js} +2 -2
- package/package.json +12 -7
- package/dist/bench/components/benchmark-row.d.ts +0 -20
- package/dist/bench/components/benchmark-row.js +0 -40
- package/dist/bench/components/benchmark-table.js +0 -23
- package/dist/bin/askr-ssg.d.ts +0 -27
- package/dist/bin/askr-ssg.js +0 -186
- package/dist/boot/hydration.js +0 -139
- package/dist/boot/root-lifecycle.d.ts +0 -18
- package/dist/boot/root-lifecycle.js +0 -209
- package/dist/boot/route-startup.js +0 -54
- package/dist/boot/types.d.ts +0 -61
- package/dist/common/component.d.ts +0 -18
- package/dist/common/control.d.ts +0 -12
- package/dist/common/dom-range.d.ts +0 -13
- package/dist/common/env.js +0 -41
- package/dist/common/error-boundary.d.ts +0 -15
- package/dist/common/invariant.js +0 -15
- package/dist/common/jsx.d.ts +0 -22
- package/dist/common/logger.js +0 -34
- package/dist/common/promise.js +0 -6
- package/dist/common/ssr-errors.d.ts +0 -10
- package/dist/common/ssr-errors.js +0 -14
- package/dist/common/ssr.d.ts +0 -41
- package/dist/common/vnode.d.ts +0 -21
- package/dist/components/error-boundary.d.ts +0 -14
- package/dist/components/error-boundary.js +0 -41
- package/dist/components/link.d.ts +0 -68
- package/dist/components/link.js +0 -74
- package/dist/control/case.d.ts +0 -18
- package/dist/control/case.js +0 -68
- package/dist/control/for.d.ts +0 -23
- package/dist/control/for.js +0 -61
- package/dist/control/shared.d.ts +0 -8
- package/dist/control/shared.js +0 -18
- package/dist/control/show.d.ts +0 -14
- package/dist/control/show.js +0 -32
- package/dist/data/data-runtime.d.ts +0 -27
- package/dist/data/invalidation.d.ts +0 -8
- package/dist/data/invalidation.js +0 -25
- package/dist/data/mutation-cell.d.ts +0 -27
- package/dist/data/mutation-cell.js +0 -133
- package/dist/data/query-cell.d.ts +0 -47
- package/dist/data/query-cell.js +0 -324
- package/dist/data/query-key.js +0 -40
- package/dist/data/shared.js +0 -20
- package/dist/data/testing.js +0 -2
- package/dist/data/types.d.ts +0 -160
- package/dist/foundations/icon/icon.d.ts +0 -52
- package/dist/foundations/icon/icon.js +0 -86
- package/dist/foundations/icon/icon.types.d.ts +0 -21
- package/dist/foundations/interactions/dismissable.d.ts +0 -71
- package/dist/foundations/interactions/dismissable.js +0 -24
- package/dist/foundations/interactions/focusable.d.ts +0 -21
- package/dist/foundations/interactions/focusable.js +0 -16
- package/dist/foundations/interactions/hoverable.d.ts +0 -25
- package/dist/foundations/interactions/hoverable.js +0 -13
- package/dist/foundations/interactions/interaction-policy.d.ts +0 -49
- package/dist/foundations/interactions/interaction-policy.js +0 -120
- package/dist/foundations/interactions/pressable.d.ts +0 -60
- package/dist/foundations/interactions/pressable.js +0 -49
- package/dist/foundations/interactions/roving-focus.d.ts +0 -51
- package/dist/foundations/interactions/roving-focus.js +0 -69
- package/dist/foundations/state/controllable.d.ts +0 -32
- package/dist/foundations/state/controllable.js +0 -80
- package/dist/foundations/structures/collection.d.ts +0 -51
- package/dist/foundations/structures/collection.js +0 -49
- package/dist/foundations/structures/layer.d.ts +0 -80
- package/dist/foundations/structures/layer.js +0 -79
- package/dist/foundations/structures/layout.d.ts +0 -32
- package/dist/foundations/structures/layout.js +0 -11
- package/dist/foundations/structures/portal.d.ts +0 -2
- package/dist/foundations/structures/portal.js +0 -3
- package/dist/foundations/structures/presence.d.ts +0 -36
- package/dist/foundations/structures/presence.js +0 -37
- package/dist/foundations/structures/slot.d.ts +0 -34
- package/dist/foundations/structures/slot.js +0 -39
- package/dist/foundations/utilities/aria.d.ts +0 -15
- package/dist/foundations/utilities/aria.js +0 -15
- package/dist/foundations/utilities/compose-handlers.d.ts +0 -36
- package/dist/foundations/utilities/compose-handlers.js +0 -18
- package/dist/foundations/utilities/compose-ref.js +0 -16
- package/dist/foundations/utilities/event-types.d.ts +0 -19
- package/dist/foundations/utilities/merge-props.d.ts +0 -4
- package/dist/foundations/utilities/merge-props.js +0 -47
- package/dist/foundations/utilities/use-id.d.ts +0 -31
- package/dist/fx/fx.d.ts +0 -32
- package/dist/fx/fx.js +0 -211
- package/dist/fx/noop.js +0 -7
- package/dist/fx/timing.d.ts +0 -158
- package/dist/fx/timing.js +0 -241
- package/dist/jsx/index.d.ts +0 -2
- package/dist/jsx/index.js +0 -4
- package/dist/jsx/types.js +0 -2
- package/dist/jsx/utils.d.ts +0 -4
- package/dist/jsx/utils.js +0 -17
- package/dist/jsx-runtime2.d.ts +0 -3
- package/dist/jsx-runtime2.js +0 -4
- package/dist/renderer/attributes.js +0 -254
- package/dist/renderer/boundaries.js +0 -142
- package/dist/renderer/boundary-materialization.js +0 -72
- package/dist/renderer/boundary-range-adoption.js +0 -76
- package/dist/renderer/boundary-range-sync.js +0 -101
- package/dist/renderer/boundary-state.js +0 -50
- package/dist/renderer/child-shape.js +0 -83
- package/dist/renderer/children-fastpath.js +0 -149
- package/dist/renderer/children.js +0 -158
- package/dist/renderer/cleanup.js +0 -267
- package/dist/renderer/component-host-cleanup.js +0 -143
- package/dist/renderer/component-host-instances.js +0 -116
- package/dist/renderer/component-host-replacement.js +0 -105
- package/dist/renderer/component-host-results.js +0 -138
- package/dist/renderer/component-host.js +0 -172
- package/dist/renderer/dom-host.js +0 -11
- package/dist/renderer/dom-internal.js +0 -243
- package/dist/renderer/dom-range.js +0 -161
- package/dist/renderer/dom.js +0 -11
- package/dist/renderer/element-children.js +0 -359
- package/dist/renderer/env.js +0 -2
- package/dist/renderer/error-boundary-dom.js +0 -86
- package/dist/renderer/evaluate-dom-range.js +0 -84
- package/dist/renderer/evaluate-reconcile.js +0 -257
- package/dist/renderer/evaluate.js +0 -95
- package/dist/renderer/fastpath.js +0 -142
- package/dist/renderer/for-commit-dom-map.js +0 -71
- package/dist/renderer/for-commit-removal.js +0 -27
- package/dist/renderer/for-commit-reorder.js +0 -87
- package/dist/renderer/for-commit.js +0 -442
- package/dist/renderer/hydration-boundaries.js +0 -60
- package/dist/renderer/hydration-listener-transaction.js +0 -49
- package/dist/renderer/index.js +0 -39
- package/dist/renderer/intrinsic-blueprint-analysis.js +0 -202
- package/dist/renderer/intrinsic-blueprint-bindings.js +0 -152
- package/dist/renderer/intrinsic-blueprint-materialization.js +0 -100
- package/dist/renderer/intrinsic-blueprint.js +0 -30
- package/dist/renderer/intrinsic-hydration-adoption.js +0 -66
- package/dist/renderer/keyed-children.js +0 -26
- package/dist/renderer/keyed.js +0 -167
- package/dist/renderer/namespaces.js +0 -21
- package/dist/renderer/prop-bindings.js +0 -315
- package/dist/renderer/reactive-child-dom.js +0 -139
- package/dist/renderer/reactive-child-sources.js +0 -182
- package/dist/renderer/reactive-children.js +0 -303
- package/dist/renderer/reconcile-commit.js +0 -36
- package/dist/renderer/reconcile-fastpaths.js +0 -100
- package/dist/renderer/reconcile-resolution.js +0 -163
- package/dist/renderer/reconcile.js +0 -37
- package/dist/renderer/retained-element-rollback.js +0 -288
- package/dist/renderer/stable-patch.js +0 -80
- package/dist/renderer/static-reuse.js +0 -94
- package/dist/renderer/types.js +0 -2
- package/dist/renderer/utils.js +0 -265
- package/dist/router/access.js +0 -34
- package/dist/router/activity.d.ts +0 -9
- package/dist/router/activity.js +0 -85
- package/dist/router/authoring.d.ts +0 -21
- package/dist/router/authoring.js +0 -196
- package/dist/router/internal-types.d.ts +0 -30
- package/dist/router/lazy.d.ts +0 -18
- package/dist/router/lazy.js +0 -50
- package/dist/router/manifest.d.ts +0 -9
- package/dist/router/manifest.js +0 -47
- package/dist/router/match.js +0 -120
- package/dist/router/navigate.d.ts +0 -10
- package/dist/router/navigate.js +0 -73
- package/dist/router/navigation-registry.d.ts +0 -31
- package/dist/router/navigation-registry.js +0 -103
- package/dist/router/navigation-scroll.d.ts +0 -13
- package/dist/router/navigation-scroll.js +0 -91
- package/dist/router/navigation-targets.d.ts +0 -30
- package/dist/router/navigation-targets.js +0 -634
- package/dist/router/policy.d.ts +0 -27
- package/dist/router/policy.js +0 -130
- package/dist/router/rendering.d.ts +0 -9
- package/dist/router/rendering.js +0 -47
- package/dist/router/resolution.d.ts +0 -3
- package/dist/router/resolution.js +0 -84
- package/dist/router/route-context.js +0 -77
- package/dist/router/route-matching.d.ts +0 -19
- package/dist/router/route-matching.js +0 -173
- package/dist/router/route-query.d.ts +0 -16
- package/dist/router/route-query.js +0 -45
- package/dist/router/route.d.ts +0 -8
- package/dist/router/route.js +0 -10
- package/dist/router/store.d.ts +0 -49
- package/dist/router/store.js +0 -169
- package/dist/router/testing.js +0 -4
- package/dist/runtime/access.d.ts +0 -19
- package/dist/runtime/access.js +0 -43
- package/dist/runtime/child-scope.d.ts +0 -41
- package/dist/runtime/child-scope.js +0 -134
- package/dist/runtime/component-cleanup.d.ts +0 -15
- package/dist/runtime/component-cleanup.js +0 -68
- package/dist/runtime/component-commit.js +0 -167
- package/dist/runtime/component-facade.d.ts +0 -5
- package/dist/runtime/component-facade.js +0 -6
- package/dist/runtime/component-internal.d.ts +0 -105
- package/dist/runtime/component-internal.js +0 -237
- package/dist/runtime/component-lifecycle.d.ts +0 -10
- package/dist/runtime/component-lifecycle.js +0 -33
- package/dist/runtime/component-scope.d.ts +0 -54
- package/dist/runtime/component.d.ts +0 -5
- package/dist/runtime/component.js +0 -6
- package/dist/runtime/context.d.ts +0 -72
- package/dist/runtime/context.js +0 -236
- package/dist/runtime/control.d.ts +0 -62
- package/dist/runtime/control.js +0 -239
- package/dist/runtime/derive.d.ts +0 -16
- package/dist/runtime/derive.js +0 -140
- package/dist/runtime/dev-namespace.d.ts +0 -30
- package/dist/runtime/dev-namespace.js +0 -64
- package/dist/runtime/effect.d.ts +0 -35
- package/dist/runtime/error-boundary.d.ts +0 -4
- package/dist/runtime/error-boundary.js +0 -29
- package/dist/runtime/events.d.ts +0 -58
- package/dist/runtime/events.js +0 -201
- package/dist/runtime/execution-model.d.ts +0 -6
- package/dist/runtime/execution-model.js +0 -13
- package/dist/runtime/fastlane.d.ts +0 -33
- package/dist/runtime/fastlane.js +0 -173
- package/dist/runtime/for-bench.d.ts +0 -40
- package/dist/runtime/for-bench.js +0 -13
- package/dist/runtime/for-internal.d.ts +0 -106
- package/dist/runtime/for-internal.js +0 -285
- package/dist/runtime/for-reconcile.d.ts +0 -7
- package/dist/runtime/for-reconcile.js +0 -442
- package/dist/runtime/for-scopes.d.ts +0 -26
- package/dist/runtime/for-scopes.js +0 -280
- package/dist/runtime/for-signals.d.ts +0 -39
- package/dist/runtime/for-signals.js +0 -213
- package/dist/runtime/for-types.d.ts +0 -8
- package/dist/runtime/for.d.ts +0 -4
- package/dist/runtime/for.js +0 -5
- package/dist/runtime/index.d.ts +0 -24
- package/dist/runtime/index.js +0 -33
- package/dist/runtime/lifecycle-batch.d.ts +0 -59
- package/dist/runtime/lifecycle-batch.js +0 -178
- package/dist/runtime/lifecycle-operation-settlement.d.ts +0 -5
- package/dist/runtime/lifecycle-operation-settlement.js +0 -51
- package/dist/runtime/lifecycle-operations.d.ts +0 -30
- package/dist/runtime/operations.d.ts +0 -3
- package/dist/runtime/operations.js +0 -3
- package/dist/runtime/perf-metrics.d.ts +0 -27
- package/dist/runtime/perf-metrics.js +0 -6
- package/dist/runtime/portal.d.ts +0 -21
- package/dist/runtime/readable.d.ts +0 -34
- package/dist/runtime/readable.js +0 -183
- package/dist/runtime/resource-cell.js +0 -112
- package/dist/runtime/resource-operation.d.ts +0 -12
- package/dist/runtime/runtime.js +0 -57
- package/dist/runtime/selector-store.js +0 -22
- package/dist/runtime/selector.d.ts +0 -10
- package/dist/runtime/snapshot-source.d.ts +0 -9
- package/dist/runtime/state.d.ts +0 -54
- package/dist/ssg/batch-render.js +0 -101
- package/dist/ssg/create-static-gen.d.ts +0 -66
- package/dist/ssg/create-static-gen.js +0 -250
- package/dist/ssg/generate-metadata.js +0 -92
- package/dist/ssg/generation-plan.js +0 -68
- package/dist/ssg/incremental-manifest.js +0 -54
- package/dist/ssg/resolve-ssg-data.js +0 -103
- package/dist/ssg/route-utils.js +0 -22
- package/dist/ssg/static-routes.js +0 -100
- package/dist/ssg/types.d.ts +0 -188
- package/dist/ssg/write-static-files.js +0 -77
- package/dist/ssr/attrs.js +0 -92
- package/dist/ssr/boundaries.js +0 -124
- package/dist/ssr/component-runtime.js +0 -85
- package/dist/ssr/context.d.ts +0 -49
- package/dist/ssr/context.js +0 -89
- package/dist/ssr/errors.d.ts +0 -9
- package/dist/ssr/errors.js +0 -12
- package/dist/ssr/escape.js +0 -191
- package/dist/ssr/hydration-data.js +0 -8
- package/dist/ssr/hydration-verify.d.ts +0 -11
- package/dist/ssr/hydration-verify.js +0 -171
- package/dist/ssr/index-internal.d.ts +0 -14
- package/dist/ssr/index-internal.js +0 -17
- package/dist/ssr/render-keys.js +0 -14
- package/dist/ssr/render-resolved.d.ts +0 -19
- package/dist/ssr/render-resolved.js +0 -33
- package/dist/ssr/render-sync.d.ts +0 -20
- package/dist/ssr/render-sync.js +0 -283
- package/dist/ssr/route-policy-resolution.js +0 -76
- package/dist/ssr/route-render.d.ts +0 -76
- package/dist/ssr/route-render.js +0 -118
- package/dist/ssr/sink.d.ts +0 -25
- package/dist/ssr/sink.js +0 -84
- package/dist/ssr/types.d.ts +0 -22
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { markReactivePropsDirtySource,
|
|
2
|
-
import { claimHookIndex, getCurrentInstance } from "./component-scope.js";
|
|
3
|
-
import { isBulkCommitActive } from "./fastlane.js";
|
|
4
|
-
import "./component.js";
|
|
1
|
+
import { f as notifyReadableReaders, l as markReactivePropsDirtySource, p as recordReadableRead, t as isBulkCommitActive, u as markReadableDerivedSubscribersDirty } from "./fastlane-Dw8SOBr9.js";
|
|
2
|
+
import { i as claimHookIndex, p as getCurrentInstance } from "./component-scope-CC3cojX9.js";
|
|
5
3
|
//#region src/runtime/state.ts
|
|
6
4
|
/**
|
|
7
5
|
* State primitive for Askr components
|
|
@@ -91,4 +89,4 @@ function createStateCell(initialValue, instance) {
|
|
|
91
89
|
return read;
|
|
92
90
|
}
|
|
93
91
|
//#endregion
|
|
94
|
-
export { state };
|
|
92
|
+
export { state as t };
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { n as Fragment, t as ELEMENT_TYPE } from "./jsx-CUpRxrLH.js";
|
|
2
|
+
//#region src/jsx/utils.ts
|
|
3
|
+
function isElement(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && value.$$typeof === ELEMENT_TYPE;
|
|
5
|
+
}
|
|
6
|
+
function cloneElement(element, props) {
|
|
7
|
+
return {
|
|
8
|
+
...element,
|
|
9
|
+
props: {
|
|
10
|
+
...element.props,
|
|
11
|
+
...props
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/foundations/structures/layout.tsx
|
|
17
|
+
function layout(Layout) {
|
|
18
|
+
return (children, props) => {
|
|
19
|
+
return Layout({
|
|
20
|
+
...props,
|
|
21
|
+
children
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/foundations/structures/slot.tsx
|
|
27
|
+
/**
|
|
28
|
+
* Slot
|
|
29
|
+
*
|
|
30
|
+
* Structural primitive for prop forwarding patterns.
|
|
31
|
+
*
|
|
32
|
+
* POLICY DECISIONS (LOCKED):
|
|
33
|
+
*
|
|
34
|
+
* 1. asChild Pattern
|
|
35
|
+
* When asChild=true, merges props into the single child element.
|
|
36
|
+
* Child must be a valid JSXElement; non-element children return null.
|
|
37
|
+
* **Slot props override child props** (injection pattern).
|
|
38
|
+
*
|
|
39
|
+
* 2. Fallback Behavior
|
|
40
|
+
* When asChild=false, returns a Fragment (structural no-op).
|
|
41
|
+
* No DOM element is introduced.
|
|
42
|
+
*
|
|
43
|
+
* 3. Type Safety
|
|
44
|
+
* asChild=true requires exactly one JSXElement child (enforced by type).
|
|
45
|
+
* Runtime validates with isElement() check.
|
|
46
|
+
*/
|
|
47
|
+
function Slot(props) {
|
|
48
|
+
if (props.asChild) {
|
|
49
|
+
const { children, asChild: _asChild, ...rest } = props;
|
|
50
|
+
if (isElement(children)) return cloneElement(children, rest);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
$$typeof: ELEMENT_TYPE,
|
|
55
|
+
type: Fragment,
|
|
56
|
+
props: { children: props.children },
|
|
57
|
+
key: null
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/foundations/structures/presence.ts
|
|
62
|
+
/**
|
|
63
|
+
* Presence
|
|
64
|
+
*
|
|
65
|
+
* Structural policy primitive for conditional mount/unmount.
|
|
66
|
+
* - No timers
|
|
67
|
+
* - No animation coupling
|
|
68
|
+
* - No DOM side-effects
|
|
69
|
+
*
|
|
70
|
+
* POLICY DECISIONS (LOCKED):
|
|
71
|
+
*
|
|
72
|
+
* 1. Present as Function
|
|
73
|
+
* Accepts boolean OR function to support lazy evaluation patterns.
|
|
74
|
+
* Function is called once per render. Use boolean form for static values.
|
|
75
|
+
*
|
|
76
|
+
* 2. Children Type
|
|
77
|
+
* Presence forwards normal renderable child content only.
|
|
78
|
+
* Imperative DOM nodes are not part of the public contract.
|
|
79
|
+
*
|
|
80
|
+
* 3. Immediate Mount/Unmount
|
|
81
|
+
* No exit animations or transitions. When `present` becomes false,
|
|
82
|
+
* children are removed immediately. Animation must be layered above
|
|
83
|
+
* this primitive.
|
|
84
|
+
*/
|
|
85
|
+
function Presence({ present, children }) {
|
|
86
|
+
if (!(typeof present === "function" ? present() : Boolean(present))) return null;
|
|
87
|
+
return {
|
|
88
|
+
$$typeof: ELEMENT_TYPE,
|
|
89
|
+
type: Fragment,
|
|
90
|
+
props: { children },
|
|
91
|
+
key: null
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/foundations/structures/collection.ts
|
|
96
|
+
function createCollection() {
|
|
97
|
+
const registry = /* @__PURE__ */ new Map();
|
|
98
|
+
function register(node, metadata) {
|
|
99
|
+
const item = {
|
|
100
|
+
node,
|
|
101
|
+
metadata
|
|
102
|
+
};
|
|
103
|
+
registry.set(node, item);
|
|
104
|
+
return () => {
|
|
105
|
+
registry.delete(node);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function items() {
|
|
109
|
+
return Array.from(registry.values());
|
|
110
|
+
}
|
|
111
|
+
function clear() {
|
|
112
|
+
registry.clear();
|
|
113
|
+
}
|
|
114
|
+
function size() {
|
|
115
|
+
return registry.size;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
register,
|
|
119
|
+
items,
|
|
120
|
+
clear,
|
|
121
|
+
size
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* USAGE EXAMPLE:
|
|
126
|
+
*
|
|
127
|
+
* // Create a collection for menu items
|
|
128
|
+
* const menuItems = createCollection<HTMLElement, { disabled: boolean }>();
|
|
129
|
+
*
|
|
130
|
+
* // Register items
|
|
131
|
+
* const unregister1 = menuItems.register(element1, { disabled: false });
|
|
132
|
+
* const unregister2 = menuItems.register(element2, { disabled: true });
|
|
133
|
+
*
|
|
134
|
+
* // Query items
|
|
135
|
+
* const allItems = menuItems.items();
|
|
136
|
+
* const enabledItems = allItems.filter(item => !item.metadata.disabled);
|
|
137
|
+
*
|
|
138
|
+
* // Cleanup
|
|
139
|
+
* unregister1();
|
|
140
|
+
* unregister2();
|
|
141
|
+
*/
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/foundations/structures/layer.ts
|
|
144
|
+
function createLayer() {
|
|
145
|
+
const stack = [];
|
|
146
|
+
let nextId = 1;
|
|
147
|
+
function register(options) {
|
|
148
|
+
const id = nextId++;
|
|
149
|
+
const entry = {
|
|
150
|
+
id,
|
|
151
|
+
options
|
|
152
|
+
};
|
|
153
|
+
stack.push(entry);
|
|
154
|
+
function isTop() {
|
|
155
|
+
return stack[stack.length - 1]?.id === id;
|
|
156
|
+
}
|
|
157
|
+
function unregister() {
|
|
158
|
+
const index = stack.findIndex((e) => e.id === id);
|
|
159
|
+
if (index !== -1) stack.splice(index, 1);
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
id,
|
|
163
|
+
isTop,
|
|
164
|
+
unregister
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function layers() {
|
|
168
|
+
return stack.map((entry) => ({
|
|
169
|
+
id: entry.id,
|
|
170
|
+
isTop: () => stack[stack.length - 1]?.id === entry.id,
|
|
171
|
+
unregister: () => {
|
|
172
|
+
const index = stack.findIndex((e) => e.id === entry.id);
|
|
173
|
+
if (index !== -1) stack.splice(index, 1);
|
|
174
|
+
}
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
function handleEscape() {
|
|
178
|
+
const top = stack[stack.length - 1];
|
|
179
|
+
if (top) top.options.onEscape?.();
|
|
180
|
+
}
|
|
181
|
+
function handleOutsidePointer(e) {
|
|
182
|
+
const top = stack[stack.length - 1];
|
|
183
|
+
if (!top) return;
|
|
184
|
+
const node = top.options.node;
|
|
185
|
+
if (node && e.target instanceof Node) {
|
|
186
|
+
if (!node.contains(e.target)) top.options.onOutsidePointer?.(e);
|
|
187
|
+
} else top.options.onOutsidePointer?.(e);
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
register,
|
|
191
|
+
layers,
|
|
192
|
+
handleEscape,
|
|
193
|
+
handleOutsidePointer
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* USAGE EXAMPLE:
|
|
198
|
+
*
|
|
199
|
+
* const layerManager = createLayer();
|
|
200
|
+
*
|
|
201
|
+
* function Modal({ onClose }) {
|
|
202
|
+
* const modalRef = ref<HTMLDivElement>();
|
|
203
|
+
*
|
|
204
|
+
* const layer = layerManager.register({
|
|
205
|
+
* node: modalRef.current,
|
|
206
|
+
* onEscape: onClose,
|
|
207
|
+
* onOutsidePointer: onClose,
|
|
208
|
+
* });
|
|
209
|
+
*
|
|
210
|
+
* onUnmount(() => layer.unregister());
|
|
211
|
+
*
|
|
212
|
+
* return (
|
|
213
|
+
* <div ref={modalRef}>
|
|
214
|
+
* <h1>Modal</h1>
|
|
215
|
+
* {layer.isTop() && <p>I am on top!</p>}
|
|
216
|
+
* </div>
|
|
217
|
+
* );
|
|
218
|
+
* }
|
|
219
|
+
*/
|
|
220
|
+
//#endregion
|
|
221
|
+
export { layout as a, Slot as i, createCollection as n, Presence as r, createLayer as t };
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { C as Query, k as QueryStaleReason } from "../index-Bki2rqcr.js";
|
|
2
|
+
import { S as RouteMatch, p as Route, x as RouteManifest } from "../router-CeYvjj5_.js";
|
|
3
|
+
|
|
3
4
|
//#region src/testing/index.d.ts
|
|
4
5
|
type MockRefresh = () => void | Promise<void>;
|
|
5
6
|
interface MockQueryOptions {
|
package/dist/testing/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { computeRouteActivityMatches } from "../
|
|
3
|
-
import { addInvalidationListener } from "../data/invalidation-listeners.js";
|
|
4
|
-
import "../data/testing.js";
|
|
5
|
-
import "../router/testing.js";
|
|
1
|
+
import { t as addInvalidationListener } from "../invalidation-listeners-Des3AHYs.js";
|
|
2
|
+
import { R as parseSegments, r as computeRouteActivityMatches } from "../route-matching-vJpvLVbX.js";
|
|
6
3
|
//#region src/testing/index.ts
|
|
7
4
|
function normalizeRefresh(options) {
|
|
8
5
|
return async () => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IntrinsicFallbackProps, KnownIntrinsicElementProps, Props } from "
|
|
2
|
-
import { Fragment, JSXComponent, JSXElement, JSXElementType } from "../common/jsx.js";
|
|
1
|
+
import { a as IntrinsicFallbackProps, o as KnownIntrinsicElementProps, r as JSXElement, s as Props } from "./jsx-CP0gmYwJ.js";
|
|
3
2
|
|
|
4
3
|
//#region src/jsx/types.d.ts
|
|
5
4
|
declare global {
|
|
@@ -17,6 +16,4 @@ declare global {
|
|
|
17
16
|
children: unknown;
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
} //# sourceMappingURL=types.d.ts.map
|
|
21
|
-
//#endregion
|
|
22
|
-
export { Fragment, type JSXComponent, type JSXElement, type JSXElementType };
|
|
19
|
+
} //# sourceMappingURL=types.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SSR_RENDER_DATA_ATTR } from "
|
|
2
|
-
import { renderResolvedToStringSync } from "./
|
|
1
|
+
import { t as SSR_RENDER_DATA_ATTR } from "./ssr-CbQO5xd3.js";
|
|
2
|
+
import { a as renderResolvedToStringSync } from "./ssr-D3t80Rc0.js";
|
|
3
3
|
//#region src/ssr/verify-hydration.ts
|
|
4
4
|
function normalizeHydrationHtml(html) {
|
|
5
5
|
const template = document.createElement("template");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __CONTROL_BOUNDARY__ } from "./control.js";
|
|
1
|
+
import { t as __CONTROL_BOUNDARY__ } from "./control-DhFRTIoE.js";
|
|
2
2
|
//#region src/common/vnode.ts
|
|
3
3
|
const __ERROR_BOUNDARY__ = Symbol.for("askr.error-boundary");
|
|
4
4
|
const __FOR_BOUNDARY__ = __CONTROL_BOUNDARY__;
|
|
@@ -6,4 +6,4 @@ function _isDOMElement(node) {
|
|
|
6
6
|
return typeof node === "object" && node !== null && "type" in node;
|
|
7
7
|
}
|
|
8
8
|
//#endregion
|
|
9
|
-
export {
|
|
9
|
+
export { __FOR_BOUNDARY__ as n, _isDOMElement as r, __ERROR_BOUNDARY__ as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askrjs/askr",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"description": "Actor-backed deterministic UI framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"askr",
|
|
@@ -22,9 +22,6 @@
|
|
|
22
22
|
"type": "git",
|
|
23
23
|
"url": "git+https://github.com/askrjs/askr.git"
|
|
24
24
|
},
|
|
25
|
-
"bin": {
|
|
26
|
-
"askr-ssg": "./dist/bin/askr-ssg.js"
|
|
27
|
-
},
|
|
28
25
|
"files": [
|
|
29
26
|
"dist/**/*.js",
|
|
30
27
|
"dist/**/*.d.ts"
|
|
@@ -96,6 +93,10 @@
|
|
|
96
93
|
"types": "./dist/router/index.d.ts",
|
|
97
94
|
"import": "./dist/router/index.js"
|
|
98
95
|
},
|
|
96
|
+
"./actions": {
|
|
97
|
+
"types": "./dist/actions/index.d.ts",
|
|
98
|
+
"import": "./dist/actions/index.js"
|
|
99
|
+
},
|
|
99
100
|
"./ssr": {
|
|
100
101
|
"types": "./dist/ssr/index.d.ts",
|
|
101
102
|
"import": "./dist/ssr/index.js"
|
|
@@ -111,7 +112,8 @@
|
|
|
111
112
|
"./jsx-dev-runtime": {
|
|
112
113
|
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
113
114
|
"import": "./dist/jsx-dev-runtime.js"
|
|
114
|
-
}
|
|
115
|
+
},
|
|
116
|
+
"./package.json": "./package.json"
|
|
115
117
|
},
|
|
116
118
|
"publishConfig": {
|
|
117
119
|
"access": "public"
|
|
@@ -130,6 +132,8 @@
|
|
|
130
132
|
"test:types": "vp pack && tsd --files \"tests/types/**/*.test-d.ts\" --files \"tests/types/**/*.test-d.tsx\"",
|
|
131
133
|
"test:publint": "publint",
|
|
132
134
|
"release:verify": "npm run lint && npm run build && npm run test:publint && npm run test:checks && npm run test:types && npm run test:unit && npm run test:jsdom && npm run test:browser",
|
|
135
|
+
"pack:check": "npm pack --ignore-scripts --dry-run --json",
|
|
136
|
+
"check": "npm run release:verify && npm run pack:check",
|
|
133
137
|
"test:unit": "vp test run -c vitest.test.unit.config.ts",
|
|
134
138
|
"bench": "npm run bench:tier1 && npm run bench:tier2 && npm run bench:tier3 && npm run bench:tier4",
|
|
135
139
|
"bench:tier1": "cross-env NODE_ENV=production vp test bench --run --reporter=default --config vitest.bench.tier1.config.ts",
|
|
@@ -137,10 +141,11 @@
|
|
|
137
141
|
"bench:tier3": "cross-env NODE_ENV=production vp test bench --run --reporter=default --config vitest.bench.tier3.config.ts",
|
|
138
142
|
"bench:tier4": "cross-env NODE_ENV=production vp test bench --run --reporter=default --config vitest.bench.tier4.config.ts",
|
|
139
143
|
"prepack": "npm run build",
|
|
140
|
-
"prepublishOnly": "npm run
|
|
144
|
+
"prepublishOnly": "npm run check"
|
|
141
145
|
},
|
|
142
146
|
"dependencies": {
|
|
143
|
-
"
|
|
147
|
+
"@askrjs/auth": ">=0.0.1 <0.1.0",
|
|
148
|
+
"@askrjs/schema": ">=0.0.1 <0.1.0"
|
|
144
149
|
},
|
|
145
150
|
"devDependencies": {
|
|
146
151
|
"@types/node": "^26.1.1",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { JSX } from "../../jsx-runtime.js";
|
|
2
|
-
//#region src/bench/components/benchmark-row.d.ts
|
|
3
|
-
interface BenchmarkRowData {
|
|
4
|
-
id: number;
|
|
5
|
-
label: string;
|
|
6
|
-
}
|
|
7
|
-
interface BenchmarkRowProps {
|
|
8
|
-
item: BenchmarkRowData;
|
|
9
|
-
isSelected: (id: number) => boolean;
|
|
10
|
-
onSelect: (id: number) => void;
|
|
11
|
-
onRemove: (id: number) => void;
|
|
12
|
-
}
|
|
13
|
-
declare function BenchmarkRow({
|
|
14
|
-
item,
|
|
15
|
-
isSelected,
|
|
16
|
-
onSelect,
|
|
17
|
-
onRemove
|
|
18
|
-
}: BenchmarkRowProps): JSX.Element;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { BenchmarkRowData };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "../../jsx-runtime.js";
|
|
2
|
-
import "../../jsx-runtime2.js";
|
|
3
|
-
//#region src/bench/components/benchmark-row.tsx
|
|
4
|
-
function BenchmarkRow({ item, isSelected, onSelect, onRemove }) {
|
|
5
|
-
return /* @__PURE__ */ jsxs("tr", {
|
|
6
|
-
class: () => isSelected(item.id) ? "danger" : "",
|
|
7
|
-
children: [
|
|
8
|
-
/* @__PURE__ */ jsx("td", {
|
|
9
|
-
class: "col-md-1",
|
|
10
|
-
children: () => item.id
|
|
11
|
-
}, "id"),
|
|
12
|
-
/* @__PURE__ */ jsx("td", {
|
|
13
|
-
class: "col-md-4",
|
|
14
|
-
children: /* @__PURE__ */ jsx("a", {
|
|
15
|
-
onClick: (event) => {
|
|
16
|
-
event.preventDefault();
|
|
17
|
-
onSelect(item.id);
|
|
18
|
-
},
|
|
19
|
-
children: () => item.label
|
|
20
|
-
})
|
|
21
|
-
}, "label"),
|
|
22
|
-
/* @__PURE__ */ jsx("td", {
|
|
23
|
-
class: "col-md-1",
|
|
24
|
-
children: /* @__PURE__ */ jsx("a", {
|
|
25
|
-
onClick: (event) => {
|
|
26
|
-
event.preventDefault();
|
|
27
|
-
onRemove(item.id);
|
|
28
|
-
},
|
|
29
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
30
|
-
class: "glyphicon glyphicon-remove",
|
|
31
|
-
"aria-hidden": "true"
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
}, "remove"),
|
|
35
|
-
/* @__PURE__ */ jsx("td", { class: "col-md-6" }, "spacer")
|
|
36
|
-
]
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
export { BenchmarkRow };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx } from "../../jsx-runtime.js";
|
|
2
|
-
import { For } from "../../control/for.js";
|
|
3
|
-
import "../../control/index.js";
|
|
4
|
-
import "../../jsx-runtime2.js";
|
|
5
|
-
import { BenchmarkRow } from "./benchmark-row.js";
|
|
6
|
-
//#region src/bench/components/benchmark-table.tsx
|
|
7
|
-
function BenchmarkTable({ rows, isSelected, onSelect, onRemove }) {
|
|
8
|
-
return /* @__PURE__ */ jsx("table", {
|
|
9
|
-
class: "table table-hover table-striped test-data",
|
|
10
|
-
children: /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx(For, {
|
|
11
|
-
each: () => rows(),
|
|
12
|
-
by: (item) => item.id,
|
|
13
|
-
children: (item) => /* @__PURE__ */ jsx(BenchmarkRow, {
|
|
14
|
-
item,
|
|
15
|
-
isSelected,
|
|
16
|
-
onSelect,
|
|
17
|
-
onRemove
|
|
18
|
-
})
|
|
19
|
-
}) })
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { BenchmarkTable };
|
package/dist/bin/askr-ssg.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createStaticGen } from "../ssg/create-static-gen.js";
|
|
2
|
-
//#region src/bin/askr-ssg.d.ts
|
|
3
|
-
interface ParsedCliArgs {
|
|
4
|
-
configPath: string;
|
|
5
|
-
outputDir: string;
|
|
6
|
-
workers: number | 'auto';
|
|
7
|
-
incremental: boolean;
|
|
8
|
-
changedKeys: string[];
|
|
9
|
-
changedRoutes: string[];
|
|
10
|
-
forceFull: boolean;
|
|
11
|
-
help: boolean;
|
|
12
|
-
}
|
|
13
|
-
interface CliIo {
|
|
14
|
-
log: (...args: unknown[]) => void;
|
|
15
|
-
error: (...args: unknown[]) => void;
|
|
16
|
-
}
|
|
17
|
-
interface CliDeps {
|
|
18
|
-
cwd: () => string;
|
|
19
|
-
now: () => number;
|
|
20
|
-
existsSync: (path: string) => boolean;
|
|
21
|
-
importConfig: (path: string) => Promise<Record<string, unknown>>;
|
|
22
|
-
createStaticGen: typeof createStaticGen;
|
|
23
|
-
}
|
|
24
|
-
declare function parseCliArgs(args: string[]): ParsedCliArgs;
|
|
25
|
-
declare function runCli(args: string[], deps?: Partial<CliDeps>, io?: CliIo): Promise<number>;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { ParsedCliArgs, parseCliArgs, runCli };
|
package/dist/bin/askr-ssg.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createStaticGen } from "../ssg/create-static-gen.js";
|
|
3
|
-
import "../ssg/index.js";
|
|
4
|
-
import * as pathModule from "path";
|
|
5
|
-
import * as fsModule from "fs";
|
|
6
|
-
import { spawnSync } from "node:child_process";
|
|
7
|
-
//#region src/bin/askr-ssg.ts
|
|
8
|
-
/**
|
|
9
|
-
* askr-ssg CLI
|
|
10
|
-
*
|
|
11
|
-
* Usage: askr-ssg --config path/to/config.ts --output dist/static
|
|
12
|
-
*/
|
|
13
|
-
const { resolve } = pathModule;
|
|
14
|
-
const { existsSync } = fsModule;
|
|
15
|
-
function toFileUrl(filePath) {
|
|
16
|
-
const normalized = resolve(filePath).replace(/\\/g, "/");
|
|
17
|
-
return `file://${normalized.startsWith("/") ? "" : "/"}${encodeURI(normalized)}`;
|
|
18
|
-
}
|
|
19
|
-
const defaultCliDeps = {
|
|
20
|
-
cwd: () => process.cwd(),
|
|
21
|
-
now: () => performance.now(),
|
|
22
|
-
existsSync,
|
|
23
|
-
importConfig: async (path) => await import(toFileUrl(path)),
|
|
24
|
-
createStaticGen
|
|
25
|
-
};
|
|
26
|
-
const helpText = `
|
|
27
|
-
askr-ssg - Static Site Generation for Askr
|
|
28
|
-
|
|
29
|
-
Usage:
|
|
30
|
-
askr-ssg --config <path> --output <dir> [--incremental]
|
|
31
|
-
|
|
32
|
-
Options:
|
|
33
|
-
--config <path> Path to SSG config file (TypeScript module)
|
|
34
|
-
--output <dir> Output directory for generated HTML
|
|
35
|
-
--workers <n|auto> Preferred render worker count for SSG throughput
|
|
36
|
-
--incremental Use incremental generation if a manifest exists
|
|
37
|
-
--changed-key <key> Mark an invalidation key as changed (repeatable)
|
|
38
|
-
--changed-route <path> Mark a concrete route path as changed (repeatable)
|
|
39
|
-
--force-full Force a full rebuild even with incremental flags
|
|
40
|
-
--help Show this help message
|
|
41
|
-
|
|
42
|
-
Example:
|
|
43
|
-
askr-ssg --config ./ssg.config.ts --output ./dist/static --incremental --changed-key blog/post-123
|
|
44
|
-
|
|
45
|
-
TypeScript config execution:
|
|
46
|
-
TypeScript configs are loaded automatically by the installed CLI.
|
|
47
|
-
`;
|
|
48
|
-
function parseCliArgs(args) {
|
|
49
|
-
const parsed = {
|
|
50
|
-
configPath: "",
|
|
51
|
-
outputDir: "",
|
|
52
|
-
workers: 1,
|
|
53
|
-
incremental: false,
|
|
54
|
-
changedKeys: [],
|
|
55
|
-
changedRoutes: [],
|
|
56
|
-
forceFull: false,
|
|
57
|
-
help: false
|
|
58
|
-
};
|
|
59
|
-
for (let i = 0; i < args.length; i++) if (args[i] === "--config" && i + 1 < args.length) {
|
|
60
|
-
parsed.configPath = args[i + 1];
|
|
61
|
-
i++;
|
|
62
|
-
} else if (args[i] === "--output" && i + 1 < args.length) {
|
|
63
|
-
parsed.outputDir = args[i + 1];
|
|
64
|
-
i++;
|
|
65
|
-
} else if (args[i] === "--workers" && i + 1 < args.length) {
|
|
66
|
-
parsed.workers = args[i + 1] === "auto" ? "auto" : Number(args[i + 1]);
|
|
67
|
-
i++;
|
|
68
|
-
} else if (args[i] === "--changed-key" && i + 1 < args.length) {
|
|
69
|
-
parsed.changedKeys.push(args[i + 1]);
|
|
70
|
-
i++;
|
|
71
|
-
} else if (args[i] === "--changed-route" && i + 1 < args.length) {
|
|
72
|
-
parsed.changedRoutes.push(args[i + 1]);
|
|
73
|
-
i++;
|
|
74
|
-
} else if (args[i] === "--incremental") parsed.incremental = true;
|
|
75
|
-
else if (args[i] === "--force-full") parsed.forceFull = true;
|
|
76
|
-
else if (args[i] === "--help" || args[i] === "-h") parsed.help = true;
|
|
77
|
-
return parsed;
|
|
78
|
-
}
|
|
79
|
-
function toGenerateOptions(args) {
|
|
80
|
-
return {
|
|
81
|
-
mode: args.incremental ? "incremental" : "full",
|
|
82
|
-
changedKeys: args.changedKeys,
|
|
83
|
-
changedRoutes: args.changedRoutes,
|
|
84
|
-
forceFull: args.forceFull
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function printSummary(io, outputDir, durationSeconds, result) {
|
|
88
|
-
io.log("");
|
|
89
|
-
io.log(`Generation complete in ${durationSeconds}s`);
|
|
90
|
-
io.log(` Mode: ${result.mode}`);
|
|
91
|
-
io.log(` Generated: ${result.successful}/${result.totalRoutes} routes`);
|
|
92
|
-
io.log(` Failed: ${result.failed} routes`);
|
|
93
|
-
io.log(` Rebuilt: ${result.rebuilt} routes`);
|
|
94
|
-
io.log(` Skipped: ${result.skipped} routes`);
|
|
95
|
-
io.log(` Removed: ${result.removed} routes`);
|
|
96
|
-
io.log(` CacheHit: ${result.cacheHits} routes`);
|
|
97
|
-
io.log(` Output: ${outputDir}`);
|
|
98
|
-
io.log(` Metadata: ${outputDir}/metadata.json`);
|
|
99
|
-
io.log("");
|
|
100
|
-
}
|
|
101
|
-
async function runCli(args, deps = {}, io = console) {
|
|
102
|
-
const parsed = parseCliArgs(args);
|
|
103
|
-
if (parsed.help) {
|
|
104
|
-
io.log(helpText);
|
|
105
|
-
return 0;
|
|
106
|
-
}
|
|
107
|
-
if (!parsed.configPath) {
|
|
108
|
-
io.error("Error: --config argument is required");
|
|
109
|
-
return 1;
|
|
110
|
-
}
|
|
111
|
-
if (!parsed.configPath.endsWith(".ts")) {
|
|
112
|
-
io.error("Error: --config must point to a TypeScript file (.ts)");
|
|
113
|
-
return 1;
|
|
114
|
-
}
|
|
115
|
-
if (!parsed.outputDir) {
|
|
116
|
-
io.error("Error: --output argument is required");
|
|
117
|
-
return 1;
|
|
118
|
-
}
|
|
119
|
-
const resolvedDeps = {
|
|
120
|
-
...defaultCliDeps,
|
|
121
|
-
...deps
|
|
122
|
-
};
|
|
123
|
-
const resolvedConfigPath = resolve(resolvedDeps.cwd(), parsed.configPath);
|
|
124
|
-
const resolvedOutputDir = resolve(resolvedDeps.cwd(), parsed.outputDir);
|
|
125
|
-
if (!resolvedDeps.existsSync(resolvedConfigPath)) {
|
|
126
|
-
io.error(`Error: Config file not found: ${resolvedConfigPath}`);
|
|
127
|
-
return 1;
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
io.log(`Loading config: ${resolvedConfigPath}`);
|
|
131
|
-
const configModule = await resolvedDeps.importConfig(resolvedConfigPath);
|
|
132
|
-
const config = configModule.default || configModule;
|
|
133
|
-
if (!Array.isArray(config.routes)) {
|
|
134
|
-
io.error("Error: Config must export routes array");
|
|
135
|
-
return 1;
|
|
136
|
-
}
|
|
137
|
-
io.log(`Generating ${config.routes.length} routes...`);
|
|
138
|
-
const ssg = resolvedDeps.createStaticGen({
|
|
139
|
-
routes: config.routes,
|
|
140
|
-
outputDir: resolvedOutputDir,
|
|
141
|
-
seed: config.seed,
|
|
142
|
-
dataOverrides: config.dataOverrides,
|
|
143
|
-
concurrency: config.concurrency,
|
|
144
|
-
parallelism: parsed.workers
|
|
145
|
-
});
|
|
146
|
-
const startTime = resolvedDeps.now();
|
|
147
|
-
const result = await ssg.generate(toGenerateOptions(parsed));
|
|
148
|
-
printSummary(io, resolvedOutputDir, ((resolvedDeps.now() - startTime) / 1e3).toFixed(2), result);
|
|
149
|
-
if (result.failed > 0) {
|
|
150
|
-
io.log("Errors encountered:");
|
|
151
|
-
for (const route of result.routes) if (route.status === "error") io.log(` ${route.path}: ${route.error}`);
|
|
152
|
-
io.log("");
|
|
153
|
-
return 1;
|
|
154
|
-
}
|
|
155
|
-
return 0;
|
|
156
|
-
} catch (error) {
|
|
157
|
-
io.error("Generation failed:");
|
|
158
|
-
io.error(error instanceof Error ? error.message : String(error));
|
|
159
|
-
if (error instanceof Error && error.stack) io.error(error.stack);
|
|
160
|
-
return 1;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
async function main() {
|
|
164
|
-
const args = process.argv.slice(2);
|
|
165
|
-
const configIndex = args.indexOf("--config");
|
|
166
|
-
if ((configIndex === -1 ? void 0 : args[configIndex + 1])?.endsWith(".ts") && !process.env.ASKR_TS_CONFIG_LOADER) {
|
|
167
|
-
const child = spawnSync(process.execPath, [
|
|
168
|
-
"--import",
|
|
169
|
-
"tsx",
|
|
170
|
-
process.argv[1],
|
|
171
|
-
...args
|
|
172
|
-
], {
|
|
173
|
-
env: {
|
|
174
|
-
...process.env,
|
|
175
|
-
ASKR_TS_CONFIG_LOADER: "1"
|
|
176
|
-
},
|
|
177
|
-
stdio: "inherit"
|
|
178
|
-
});
|
|
179
|
-
process.exit(child.status ?? 1);
|
|
180
|
-
}
|
|
181
|
-
const exitCode = await runCli(args);
|
|
182
|
-
process.exit(exitCode);
|
|
183
|
-
}
|
|
184
|
-
if (process.argv[1] && (import.meta.url === toFileUrl(process.argv[1]) || process.argv[1].endsWith("/askr-ssg"))) main();
|
|
185
|
-
//#endregion
|
|
186
|
-
export { parseCliArgs, runCli };
|