@askrjs/askr 0.0.52 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/{runtime/scheduler.js → access-Bg4RJNC8.js} +182 -9
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +103 -0
- package/dist/{common/attr-names.js → attr-names-CjhzmHOn.js} +1 -1
- package/dist/benchmark.d.ts +6 -2
- package/dist/benchmark.js +63 -11
- package/dist/boot/index.d.ts +61 -2
- package/dist/boot/index.js +1 -203
- package/dist/boot-2ZR3MtO0.js +647 -0
- package/dist/cleanup-DScKZG2i.js +487 -0
- package/dist/component-internal-D9PLuFUc.js +614 -0
- package/dist/component-lifecycle-C7lnU9Bt.js +359 -0
- package/dist/{runtime/component-scope.js → component-scope-CC3cojX9.js} +8 -1
- package/dist/component-scope-CvPba6O6.d.ts +12 -0
- package/dist/components/index.d.ts +17 -2
- package/dist/components/index.js +39 -1
- package/dist/compose-ref-Cc_YkUpM.js +92 -0
- package/dist/{foundations/utilities/compose-ref.d.ts → compose-ref-Cizq72-x.d.ts} +1 -1
- package/dist/control/index.d.ts +1 -3
- package/dist/control/index.js +1 -3
- package/dist/control-BI4RMD2z.d.ts +437 -0
- package/dist/control-Bf4Wkdvv.d.ts +9 -0
- package/dist/{common/control.js → control-DhFRTIoE.js} +1 -1
- package/dist/control-mXROCjL3.js +165 -0
- package/dist/data/index.d.ts +2 -6
- package/dist/data/index.js +4 -5
- package/dist/data-B9dauyDn.js +559 -0
- package/dist/{data/data-runtime.js → data-runtime-SJ1BSUvk.js} +32 -31
- package/dist/deferred-DklLG4qM.js +386 -0
- package/dist/{runtime/effect.js → effect-BwnIvLah.js} +4 -4
- package/dist/fastlane-Dw8SOBr9.js +343 -0
- package/dist/for-internal-CSz8Unkq.js +1563 -0
- package/dist/foundations/icon/index.d.ts +68 -2
- package/dist/foundations/icon/index.js +85 -1
- package/dist/foundations/index.d.ts +2 -5
- package/dist/foundations/index.js +2 -5
- package/dist/foundations/interactions/index.d.ts +264 -6
- package/dist/foundations/interactions/index.js +1 -6
- package/dist/foundations/state/index.d.ts +32 -1
- package/dist/foundations/state/index.js +78 -1
- package/dist/foundations/structures/index.d.ts +2 -7
- package/dist/foundations/structures/index.js +2 -7
- package/dist/foundations/utilities/index.d.ts +2 -6
- package/dist/foundations/utilities/index.js +2 -5
- package/dist/fx/index.d.ts +190 -3
- package/dist/fx/index.js +454 -4
- package/dist/index-B1LNotpU.d.ts +239 -0
- package/dist/index-Bki2rqcr.d.ts +233 -0
- package/dist/index-BnU0NPwM.d.ts +101 -0
- package/dist/index-C8iW3xCt.d.ts +44 -0
- package/dist/index-DwxdIA-t.d.ts +48 -0
- package/dist/{runtime/runtime.d.ts → index-Zb31mCiU.d.ts} +31 -8
- package/dist/index.d.ts +8 -13
- package/dist/index.js +150 -15
- package/dist/interactions-w7gQN4ha.js +280 -0
- package/dist/{data/invalidation-listeners.js → invalidation-listeners-Des3AHYs.js} +1 -1
- package/dist/{common/props.d.ts → jsx-CP0gmYwJ.d.ts} +17 -5
- package/dist/{common/jsx.js → jsx-CUpRxrLH.js} +1 -1
- package/dist/jsx-dev-runtime.d.ts +2 -4
- package/dist/jsx-dev-runtime.js +7 -5
- package/dist/jsx-runtime-92bV2hSa.d.ts +34 -0
- package/dist/jsx-runtime-BVVgDSdq.d.ts +1 -0
- package/dist/jsx-runtime.d.ts +2 -35
- package/dist/jsx-runtime.js +11 -5
- package/dist/{runtime/lifecycle-operations.js → lifecycle-operations-CdRjdsHo.js} +4 -5
- package/dist/navigate-BVDCzOuB.d.ts +34 -0
- package/dist/navigate-D17eVQyI.js +1449 -0
- package/dist/{runtime/portal.js → portal-C47xkwXj.js} +71 -41
- package/dist/query-registry-CQIT4mXr.js +73 -0
- package/dist/{common/render-context.js → render-context-Clw3rFiO.js} +14 -6
- package/dist/renderer-DrLRAD5y.js +6266 -0
- package/dist/{runtime/resource-operation.js → resource-operation-BNY29MVH.js} +118 -15
- package/dist/resources/index.d.ts +42 -3
- package/dist/resources/index.js +3 -4
- package/dist/{common/route-activity.js → route-activity-CNJfpwx-.js} +1 -1
- package/dist/route-matching-vJpvLVbX.js +515 -0
- package/dist/router/index.d.ts +166 -14
- package/dist/router/index.js +150 -12
- package/dist/{common/router.d.ts → router-DCfwLBr-.d.ts} +72 -28
- package/dist/{common/router-internal.js → router-internal-BC0w1_xk.js} +1 -1
- package/dist/{runtime/scheduler.d.ts → scheduler-CmLO4Dfm.d.ts} +1 -3
- package/dist/{runtime/selector.js → selector-DafVYzV4.js} +34 -11
- package/dist/{runtime/snapshot-source.js → snapshot-source-BB42xgwb.js} +1 -1
- package/dist/ssg/index.d.ts +252 -4
- package/dist/ssg/index.js +857 -1
- package/dist/ssr/index.d.ts +225 -8
- package/dist/ssr/index.js +3 -6
- package/dist/{common/ssr.js → ssr-CbQO5xd3.js} +1 -1
- package/dist/ssr-DEARZxJ5.js +1413 -0
- package/dist/{runtime/state.js → state-DPl8lffD.js} +3 -5
- package/dist/structures-DUB3HchX.js +221 -0
- package/dist/testing/index.d.ts +3 -2
- package/dist/testing/index.js +2 -5
- package/dist/{jsx/types.d.ts → types-DnQVG4ZY.d.ts} +2 -5
- package/dist/{foundations/utilities/use-id.js → utilities-C_CGX4Dz.js} +1 -1
- package/dist/{ssr/verify-hydration.js → verify-hydration-BWwu-mWu.js} +2 -2
- package/dist/{common/vnode.js → vnode-CGMJYPMB.js} +2 -2
- package/package.json +12 -7
- package/dist/bench/components/benchmark-row.d.ts +0 -20
- package/dist/bench/components/benchmark-row.js +0 -40
- package/dist/bench/components/benchmark-table.js +0 -23
- package/dist/bin/askr-ssg.d.ts +0 -27
- package/dist/bin/askr-ssg.js +0 -186
- package/dist/boot/hydration.js +0 -139
- package/dist/boot/root-lifecycle.d.ts +0 -18
- package/dist/boot/root-lifecycle.js +0 -209
- package/dist/boot/route-startup.js +0 -54
- package/dist/boot/types.d.ts +0 -61
- package/dist/common/component.d.ts +0 -18
- package/dist/common/control.d.ts +0 -12
- package/dist/common/dom-range.d.ts +0 -13
- package/dist/common/env.js +0 -41
- package/dist/common/error-boundary.d.ts +0 -15
- package/dist/common/invariant.js +0 -15
- package/dist/common/jsx.d.ts +0 -22
- package/dist/common/logger.js +0 -34
- package/dist/common/promise.js +0 -6
- package/dist/common/ssr-errors.d.ts +0 -10
- package/dist/common/ssr-errors.js +0 -14
- package/dist/common/ssr.d.ts +0 -41
- package/dist/common/vnode.d.ts +0 -21
- package/dist/components/error-boundary.d.ts +0 -14
- package/dist/components/error-boundary.js +0 -41
- package/dist/components/link.d.ts +0 -68
- package/dist/components/link.js +0 -74
- package/dist/control/case.d.ts +0 -18
- package/dist/control/case.js +0 -68
- package/dist/control/for.d.ts +0 -23
- package/dist/control/for.js +0 -61
- package/dist/control/shared.d.ts +0 -8
- package/dist/control/shared.js +0 -18
- package/dist/control/show.d.ts +0 -14
- package/dist/control/show.js +0 -32
- package/dist/data/data-runtime.d.ts +0 -27
- package/dist/data/invalidation.d.ts +0 -8
- package/dist/data/invalidation.js +0 -25
- package/dist/data/mutation-cell.d.ts +0 -27
- package/dist/data/mutation-cell.js +0 -133
- package/dist/data/query-cell.d.ts +0 -47
- package/dist/data/query-cell.js +0 -324
- package/dist/data/query-key.js +0 -40
- package/dist/data/shared.js +0 -20
- package/dist/data/testing.js +0 -2
- package/dist/data/types.d.ts +0 -160
- package/dist/foundations/icon/icon.d.ts +0 -52
- package/dist/foundations/icon/icon.js +0 -86
- package/dist/foundations/icon/icon.types.d.ts +0 -21
- package/dist/foundations/interactions/dismissable.d.ts +0 -71
- package/dist/foundations/interactions/dismissable.js +0 -24
- package/dist/foundations/interactions/focusable.d.ts +0 -21
- package/dist/foundations/interactions/focusable.js +0 -16
- package/dist/foundations/interactions/hoverable.d.ts +0 -25
- package/dist/foundations/interactions/hoverable.js +0 -13
- package/dist/foundations/interactions/interaction-policy.d.ts +0 -49
- package/dist/foundations/interactions/interaction-policy.js +0 -120
- package/dist/foundations/interactions/pressable.d.ts +0 -60
- package/dist/foundations/interactions/pressable.js +0 -49
- package/dist/foundations/interactions/roving-focus.d.ts +0 -51
- package/dist/foundations/interactions/roving-focus.js +0 -69
- package/dist/foundations/state/controllable.d.ts +0 -32
- package/dist/foundations/state/controllable.js +0 -80
- package/dist/foundations/structures/collection.d.ts +0 -51
- package/dist/foundations/structures/collection.js +0 -49
- package/dist/foundations/structures/layer.d.ts +0 -80
- package/dist/foundations/structures/layer.js +0 -79
- package/dist/foundations/structures/layout.d.ts +0 -32
- package/dist/foundations/structures/layout.js +0 -11
- package/dist/foundations/structures/portal.d.ts +0 -2
- package/dist/foundations/structures/portal.js +0 -3
- package/dist/foundations/structures/presence.d.ts +0 -36
- package/dist/foundations/structures/presence.js +0 -37
- package/dist/foundations/structures/slot.d.ts +0 -34
- package/dist/foundations/structures/slot.js +0 -39
- package/dist/foundations/utilities/aria.d.ts +0 -15
- package/dist/foundations/utilities/aria.js +0 -15
- package/dist/foundations/utilities/compose-handlers.d.ts +0 -36
- package/dist/foundations/utilities/compose-handlers.js +0 -18
- package/dist/foundations/utilities/compose-ref.js +0 -16
- package/dist/foundations/utilities/event-types.d.ts +0 -19
- package/dist/foundations/utilities/merge-props.d.ts +0 -4
- package/dist/foundations/utilities/merge-props.js +0 -47
- package/dist/foundations/utilities/use-id.d.ts +0 -31
- package/dist/fx/fx.d.ts +0 -32
- package/dist/fx/fx.js +0 -211
- package/dist/fx/noop.js +0 -7
- package/dist/fx/timing.d.ts +0 -158
- package/dist/fx/timing.js +0 -241
- package/dist/jsx/index.d.ts +0 -2
- package/dist/jsx/index.js +0 -4
- package/dist/jsx/types.js +0 -2
- package/dist/jsx/utils.d.ts +0 -4
- package/dist/jsx/utils.js +0 -17
- package/dist/jsx-runtime2.d.ts +0 -3
- package/dist/jsx-runtime2.js +0 -4
- package/dist/renderer/attributes.js +0 -254
- package/dist/renderer/boundaries.js +0 -142
- package/dist/renderer/boundary-materialization.js +0 -72
- package/dist/renderer/boundary-range-adoption.js +0 -76
- package/dist/renderer/boundary-range-sync.js +0 -101
- package/dist/renderer/boundary-state.js +0 -50
- package/dist/renderer/child-shape.js +0 -83
- package/dist/renderer/children-fastpath.js +0 -149
- package/dist/renderer/children.js +0 -158
- package/dist/renderer/cleanup.js +0 -267
- package/dist/renderer/component-host-cleanup.js +0 -143
- package/dist/renderer/component-host-instances.js +0 -116
- package/dist/renderer/component-host-replacement.js +0 -105
- package/dist/renderer/component-host-results.js +0 -138
- package/dist/renderer/component-host.js +0 -172
- package/dist/renderer/dom-host.js +0 -11
- package/dist/renderer/dom-internal.js +0 -243
- package/dist/renderer/dom-range.js +0 -161
- package/dist/renderer/dom.js +0 -11
- package/dist/renderer/element-children.js +0 -359
- package/dist/renderer/env.js +0 -2
- package/dist/renderer/error-boundary-dom.js +0 -86
- package/dist/renderer/evaluate-dom-range.js +0 -84
- package/dist/renderer/evaluate-reconcile.js +0 -257
- package/dist/renderer/evaluate.js +0 -95
- package/dist/renderer/fastpath.js +0 -142
- package/dist/renderer/for-commit-dom-map.js +0 -71
- package/dist/renderer/for-commit-removal.js +0 -27
- package/dist/renderer/for-commit-reorder.js +0 -87
- package/dist/renderer/for-commit.js +0 -442
- package/dist/renderer/hydration-boundaries.js +0 -60
- package/dist/renderer/hydration-listener-transaction.js +0 -49
- package/dist/renderer/index.js +0 -39
- package/dist/renderer/intrinsic-blueprint-analysis.js +0 -202
- package/dist/renderer/intrinsic-blueprint-bindings.js +0 -152
- package/dist/renderer/intrinsic-blueprint-materialization.js +0 -100
- package/dist/renderer/intrinsic-blueprint.js +0 -30
- package/dist/renderer/intrinsic-hydration-adoption.js +0 -66
- package/dist/renderer/keyed-children.js +0 -26
- package/dist/renderer/keyed.js +0 -167
- package/dist/renderer/namespaces.js +0 -21
- package/dist/renderer/prop-bindings.js +0 -315
- package/dist/renderer/reactive-child-dom.js +0 -139
- package/dist/renderer/reactive-child-sources.js +0 -182
- package/dist/renderer/reactive-children.js +0 -303
- package/dist/renderer/reconcile-commit.js +0 -36
- package/dist/renderer/reconcile-fastpaths.js +0 -100
- package/dist/renderer/reconcile-resolution.js +0 -163
- package/dist/renderer/reconcile.js +0 -37
- package/dist/renderer/retained-element-rollback.js +0 -288
- package/dist/renderer/stable-patch.js +0 -80
- package/dist/renderer/static-reuse.js +0 -94
- package/dist/renderer/types.js +0 -2
- package/dist/renderer/utils.js +0 -265
- package/dist/router/access.js +0 -34
- package/dist/router/activity.d.ts +0 -9
- package/dist/router/activity.js +0 -85
- package/dist/router/authoring.d.ts +0 -21
- package/dist/router/authoring.js +0 -196
- package/dist/router/internal-types.d.ts +0 -30
- package/dist/router/lazy.d.ts +0 -18
- package/dist/router/lazy.js +0 -50
- package/dist/router/manifest.d.ts +0 -9
- package/dist/router/manifest.js +0 -47
- package/dist/router/match.js +0 -120
- package/dist/router/navigate.d.ts +0 -10
- package/dist/router/navigate.js +0 -73
- package/dist/router/navigation-registry.d.ts +0 -31
- package/dist/router/navigation-registry.js +0 -103
- package/dist/router/navigation-scroll.d.ts +0 -13
- package/dist/router/navigation-scroll.js +0 -91
- package/dist/router/navigation-targets.d.ts +0 -30
- package/dist/router/navigation-targets.js +0 -634
- package/dist/router/policy.d.ts +0 -27
- package/dist/router/policy.js +0 -130
- package/dist/router/rendering.d.ts +0 -9
- package/dist/router/rendering.js +0 -47
- package/dist/router/resolution.d.ts +0 -3
- package/dist/router/resolution.js +0 -84
- package/dist/router/route-context.js +0 -77
- package/dist/router/route-matching.d.ts +0 -19
- package/dist/router/route-matching.js +0 -173
- package/dist/router/route-query.d.ts +0 -16
- package/dist/router/route-query.js +0 -45
- package/dist/router/route.d.ts +0 -8
- package/dist/router/route.js +0 -10
- package/dist/router/store.d.ts +0 -49
- package/dist/router/store.js +0 -169
- package/dist/router/testing.js +0 -4
- package/dist/runtime/access.d.ts +0 -19
- package/dist/runtime/access.js +0 -43
- package/dist/runtime/child-scope.d.ts +0 -41
- package/dist/runtime/child-scope.js +0 -134
- package/dist/runtime/component-cleanup.d.ts +0 -15
- package/dist/runtime/component-cleanup.js +0 -68
- package/dist/runtime/component-commit.js +0 -167
- package/dist/runtime/component-facade.d.ts +0 -5
- package/dist/runtime/component-facade.js +0 -6
- package/dist/runtime/component-internal.d.ts +0 -105
- package/dist/runtime/component-internal.js +0 -237
- package/dist/runtime/component-lifecycle.d.ts +0 -10
- package/dist/runtime/component-lifecycle.js +0 -33
- package/dist/runtime/component-scope.d.ts +0 -54
- package/dist/runtime/component.d.ts +0 -5
- package/dist/runtime/component.js +0 -6
- package/dist/runtime/context.d.ts +0 -72
- package/dist/runtime/context.js +0 -236
- package/dist/runtime/control.d.ts +0 -62
- package/dist/runtime/control.js +0 -239
- package/dist/runtime/derive.d.ts +0 -16
- package/dist/runtime/derive.js +0 -140
- package/dist/runtime/dev-namespace.d.ts +0 -30
- package/dist/runtime/dev-namespace.js +0 -64
- package/dist/runtime/effect.d.ts +0 -35
- package/dist/runtime/error-boundary.d.ts +0 -4
- package/dist/runtime/error-boundary.js +0 -29
- package/dist/runtime/events.d.ts +0 -58
- package/dist/runtime/events.js +0 -201
- package/dist/runtime/execution-model.d.ts +0 -6
- package/dist/runtime/execution-model.js +0 -13
- package/dist/runtime/fastlane.d.ts +0 -33
- package/dist/runtime/fastlane.js +0 -173
- package/dist/runtime/for-bench.d.ts +0 -40
- package/dist/runtime/for-bench.js +0 -13
- package/dist/runtime/for-internal.d.ts +0 -106
- package/dist/runtime/for-internal.js +0 -285
- package/dist/runtime/for-reconcile.d.ts +0 -7
- package/dist/runtime/for-reconcile.js +0 -442
- package/dist/runtime/for-scopes.d.ts +0 -26
- package/dist/runtime/for-scopes.js +0 -280
- package/dist/runtime/for-signals.d.ts +0 -39
- package/dist/runtime/for-signals.js +0 -213
- package/dist/runtime/for-types.d.ts +0 -8
- package/dist/runtime/for.d.ts +0 -4
- package/dist/runtime/for.js +0 -5
- package/dist/runtime/index.d.ts +0 -24
- package/dist/runtime/index.js +0 -33
- package/dist/runtime/lifecycle-batch.d.ts +0 -59
- package/dist/runtime/lifecycle-batch.js +0 -178
- package/dist/runtime/lifecycle-operation-settlement.d.ts +0 -5
- package/dist/runtime/lifecycle-operation-settlement.js +0 -51
- package/dist/runtime/lifecycle-operations.d.ts +0 -30
- package/dist/runtime/operations.d.ts +0 -3
- package/dist/runtime/operations.js +0 -3
- package/dist/runtime/perf-metrics.d.ts +0 -27
- package/dist/runtime/perf-metrics.js +0 -6
- package/dist/runtime/portal.d.ts +0 -21
- package/dist/runtime/readable.d.ts +0 -34
- package/dist/runtime/readable.js +0 -183
- package/dist/runtime/resource-cell.js +0 -112
- package/dist/runtime/resource-operation.d.ts +0 -12
- package/dist/runtime/runtime.js +0 -57
- package/dist/runtime/selector-store.js +0 -22
- package/dist/runtime/selector.d.ts +0 -10
- package/dist/runtime/snapshot-source.d.ts +0 -9
- package/dist/runtime/state.d.ts +0 -54
- package/dist/ssg/batch-render.js +0 -101
- package/dist/ssg/create-static-gen.d.ts +0 -66
- package/dist/ssg/create-static-gen.js +0 -250
- package/dist/ssg/generate-metadata.js +0 -92
- package/dist/ssg/generation-plan.js +0 -68
- package/dist/ssg/incremental-manifest.js +0 -54
- package/dist/ssg/resolve-ssg-data.js +0 -103
- package/dist/ssg/route-utils.js +0 -22
- package/dist/ssg/static-routes.js +0 -100
- package/dist/ssg/types.d.ts +0 -188
- package/dist/ssg/write-static-files.js +0 -77
- package/dist/ssr/attrs.js +0 -92
- package/dist/ssr/boundaries.js +0 -124
- package/dist/ssr/component-runtime.js +0 -85
- package/dist/ssr/context.d.ts +0 -49
- package/dist/ssr/context.js +0 -89
- package/dist/ssr/errors.d.ts +0 -9
- package/dist/ssr/errors.js +0 -12
- package/dist/ssr/escape.js +0 -191
- package/dist/ssr/hydration-data.js +0 -8
- package/dist/ssr/hydration-verify.d.ts +0 -11
- package/dist/ssr/hydration-verify.js +0 -171
- package/dist/ssr/index-internal.d.ts +0 -14
- package/dist/ssr/index-internal.js +0 -17
- package/dist/ssr/render-keys.js +0 -14
- package/dist/ssr/render-resolved.d.ts +0 -19
- package/dist/ssr/render-resolved.js +0 -33
- package/dist/ssr/render-sync.d.ts +0 -20
- package/dist/ssr/render-sync.js +0 -283
- package/dist/ssr/route-policy-resolution.js +0 -76
- package/dist/ssr/route-render.d.ts +0 -76
- package/dist/ssr/route-render.js +0 -118
- package/dist/ssr/sink.d.ts +0 -25
- package/dist/ssr/sink.js +0 -84
- package/dist/ssr/types.d.ts +0 -22
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
import { b as isDevelopmentEnvironment, r as flushRuntimeScheduler, v as logger, x as isProductionEnvironment } from "./access-Bg4RJNC8.js";
|
|
2
|
+
import { n as Fragment, t as ELEMENT_TYPE } from "./jsx-CUpRxrLH.js";
|
|
3
|
+
import { n as createComponentInstance, r as mountComponent } from "./component-internal-D9PLuFUc.js";
|
|
4
|
+
import { h as cleanupComponent, m as isPromiseLike } from "./component-lifecycle-C7lnU9Bt.js";
|
|
5
|
+
import { a as withIntrinsicHydrationAdoption, i as registerDeferredHydrationBoundary, n as activateHydrationBoundary$1, o as setStaticChildSlotsCacheEnabled, r as clearDeferredHydrationBoundaries, t as installRendererBridge } from "./renderer-DrLRAD5y.js";
|
|
6
|
+
import { _ as teardownNodeSubtree, d as removeAllListeners } from "./cleanup-DScKZG2i.js";
|
|
7
|
+
import { D as assertExecutionModel, E as route, a as resolveRouteMeta, b as createAppRenderRuntime, c as registerAppInstance, d as clearRoutes, g as _snapshotRouteSourceLazy, h as _snapshotLazy, i as reconcileRouteMeta, l as unregisterAppInstance, m as _drainLazy, s as configureScrollRestoration, t as initializeNavigation, u as _applyManifest, y as setServerLocation } from "./navigate-D17eVQyI.js";
|
|
8
|
+
import { a as startHydrationRenderPhase, s as stopHydrationRenderPhase } from "./render-context-Clw3rFiO.js";
|
|
9
|
+
import { a as disposeDefaultPortalScope, t as DefaultPortal } from "./portal-C47xkwXj.js";
|
|
10
|
+
import { i as getDefaultDataRuntime } from "./data-runtime-SJ1BSUvk.js";
|
|
11
|
+
import { a as hydrateDataRuntime } from "./query-registry-CQIT4mXr.js";
|
|
12
|
+
import { a as resolveRouteFromRoutes, d as _setActiveRouteAuthOptions, j as lockRouteRegistration, k as hasRegisteredRoutes } from "./route-matching-vJpvLVbX.js";
|
|
13
|
+
import { _ as pageRenderEnvelope, d as hasRouteRenderData, f as resolveRouteRequest, l as getRouteRenderContext, o as reviveDeferredValue, u as getRouteRenderData } from "./deferred-DklLG4qM.js";
|
|
14
|
+
import "./ssr-CbQO5xd3.js";
|
|
15
|
+
//#region src/boot/hydration.ts
|
|
16
|
+
const DEFERRED_PAYLOAD = "__askr_deferred__";
|
|
17
|
+
function applyDeferredStreamPatches(rootElement) {
|
|
18
|
+
const patches = Array.from(rootElement.querySelectorAll("template[data-askr-deferred-patch]"));
|
|
19
|
+
for (const template of patches) {
|
|
20
|
+
const id = template.getAttribute("data-askr-deferred-patch");
|
|
21
|
+
if (!id) continue;
|
|
22
|
+
const boundary = Array.from(rootElement.querySelectorAll("askr-resolve[data-askr-deferred]")).find((candidate) => candidate.getAttribute("data-askr-deferred") === id);
|
|
23
|
+
if (boundary) boundary.replaceWith(template.content.cloneNode(true));
|
|
24
|
+
template.remove();
|
|
25
|
+
for (const script of Array.from(rootElement.querySelectorAll("script[data-askr-deferred-apply]"))) if (script.getAttribute("data-askr-deferred-apply") === id) script.remove();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function hydrationReviver(_key, value) {
|
|
29
|
+
if (!value || typeof value !== "object") return value;
|
|
30
|
+
const payload = value;
|
|
31
|
+
if (payload[DEFERRED_PAYLOAD] === "fulfilled") return reviveDeferredValue("fulfilled", payload.value, void 0);
|
|
32
|
+
if (payload[DEFERRED_PAYLOAD] === "rejected") return reviveDeferredValue("rejected", void 0, payload.error);
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function takeHydrationRenderData(rootElement) {
|
|
36
|
+
for (const child of Array.from(rootElement.children)) if (child instanceof HTMLScriptElement && child.getAttribute("data-askr-render-data") === "true") {
|
|
37
|
+
const raw = child.textContent ?? "";
|
|
38
|
+
child.remove();
|
|
39
|
+
if (!raw) return pageRenderEnvelope(void 0);
|
|
40
|
+
try {
|
|
41
|
+
return pageRenderEnvelope(JSON.parse(raw, hydrationReviver));
|
|
42
|
+
} catch (err) {
|
|
43
|
+
const error = /* @__PURE__ */ new Error("[Askr] Failed to parse embedded SSR render data during hydration.");
|
|
44
|
+
error.cause = err;
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
function markSkippedElements(root, skipSelectors) {
|
|
51
|
+
if (skipSelectors.length === 0) return;
|
|
52
|
+
const selectorList = Array.from(new Set(skipSelectors)).join(", ");
|
|
53
|
+
root.querySelectorAll(selectorList).forEach((el) => el.setAttribute("data-skip-hydrate", "true"));
|
|
54
|
+
}
|
|
55
|
+
function collectDeferredBelowFoldBoundaries(root, foldY) {
|
|
56
|
+
const boundaries = [];
|
|
57
|
+
const stack = [];
|
|
58
|
+
for (let index = root.children.length - 1; index >= 0; index -= 1) stack.push(root.children[index]);
|
|
59
|
+
while (stack.length > 0) {
|
|
60
|
+
const element = stack.pop();
|
|
61
|
+
if (element.hasAttribute("data-skip-hydrate")) continue;
|
|
62
|
+
if (element.getBoundingClientRect().top >= foldY) {
|
|
63
|
+
element.setAttribute("data-skip-hydrate", "true");
|
|
64
|
+
registerDeferredHydrationBoundary(root, element);
|
|
65
|
+
boundaries.push(element);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
for (let index = element.children.length - 1; index >= 0; index -= 1) stack.push(element.children[index]);
|
|
69
|
+
}
|
|
70
|
+
return boundaries;
|
|
71
|
+
}
|
|
72
|
+
function activateVisibleDeferredBoundaries(root, boundaries, foldY, activate) {
|
|
73
|
+
let activated = false;
|
|
74
|
+
let remaining = 0;
|
|
75
|
+
for (const element of boundaries) {
|
|
76
|
+
if (!element.hasAttribute("data-skip-hydrate")) continue;
|
|
77
|
+
if (element.getBoundingClientRect().top < foldY) try {
|
|
78
|
+
if (activate(root, element)) activated = true;
|
|
79
|
+
} catch {}
|
|
80
|
+
if (element.hasAttribute("data-skip-hydrate")) remaining += 1;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
activated,
|
|
84
|
+
remaining
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function queueIdleWork(work) {
|
|
88
|
+
return new Promise((resolve) => {
|
|
89
|
+
if (typeof requestIdleCallback !== "undefined") {
|
|
90
|
+
requestIdleCallback(() => {
|
|
91
|
+
work();
|
|
92
|
+
resolve();
|
|
93
|
+
}, { timeout: 2e3 });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
work();
|
|
98
|
+
resolve();
|
|
99
|
+
}, 0);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function shouldVerifyHydrationMarkup(config) {
|
|
103
|
+
const explicit = config.hydrate?.verifyMarkup;
|
|
104
|
+
if (typeof explicit === "boolean") return explicit;
|
|
105
|
+
return !isProductionEnvironment();
|
|
106
|
+
}
|
|
107
|
+
async function applySelectiveHydration(rootElement, resolved, path, cleanupStrict, hydrateOptions, source, hooks) {
|
|
108
|
+
const hasPermanentSkips = (hydrateOptions.skipSelectors?.length ?? 0) > 0;
|
|
109
|
+
const hasBelowFoldDeferral = !!hydrateOptions.deferBelowFold;
|
|
110
|
+
const hasSelectiveBoundaries = hasPermanentSkips || hasBelowFoldDeferral;
|
|
111
|
+
let staticChildSlotsCacheSuspended = false;
|
|
112
|
+
let releaseSelectiveHydrationResources = () => {};
|
|
113
|
+
const restoreStaticChildSlotsCache = () => {
|
|
114
|
+
if (!staticChildSlotsCacheSuspended) return;
|
|
115
|
+
setStaticChildSlotsCacheEnabled(true);
|
|
116
|
+
staticChildSlotsCacheSuspended = false;
|
|
117
|
+
};
|
|
118
|
+
if (hydrateOptions.skipSelectors?.length) markSkippedElements(rootElement, hydrateOptions.skipSelectors);
|
|
119
|
+
let deferredBoundaries = [];
|
|
120
|
+
if (hydrateOptions.deferBelowFold) {
|
|
121
|
+
setStaticChildSlotsCacheEnabled(false);
|
|
122
|
+
staticChildSlotsCacheSuspended = true;
|
|
123
|
+
const foldY = hydrateOptions.foldThreshold ?? window.innerHeight;
|
|
124
|
+
deferredBoundaries = collectDeferredBelowFoldBoundaries(rootElement, foldY);
|
|
125
|
+
let selectiveHydrationResourcesReleased = false;
|
|
126
|
+
let unregisterRootCleanupCallback = () => {};
|
|
127
|
+
function handleScroll() {
|
|
128
|
+
const { activated, remaining } = activateVisibleDeferredBoundaries(rootElement, deferredBoundaries, foldY, hooks.activateHydrationBoundary);
|
|
129
|
+
if (!activated) return;
|
|
130
|
+
if (remaining === 0) releaseSelectiveHydrationResources();
|
|
131
|
+
}
|
|
132
|
+
releaseSelectiveHydrationResources = () => {
|
|
133
|
+
if (selectiveHydrationResourcesReleased) return;
|
|
134
|
+
selectiveHydrationResourcesReleased = true;
|
|
135
|
+
unregisterRootCleanupCallback();
|
|
136
|
+
window.removeEventListener("scroll", handleScroll);
|
|
137
|
+
restoreStaticChildSlotsCache();
|
|
138
|
+
};
|
|
139
|
+
unregisterRootCleanupCallback = hooks.registerRootCleanupCallback(rootElement, releaseSelectiveHydrationResources);
|
|
140
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
141
|
+
}
|
|
142
|
+
if (hydrateOptions.deferUntilIdle && !hasSelectiveBoundaries) {
|
|
143
|
+
await queueIdleWork(() => {
|
|
144
|
+
hooks.mountOrUpdate(rootElement, (() => resolved.handler(resolved.params)), {
|
|
145
|
+
cleanupStrict,
|
|
146
|
+
appRuntime: source?.runtime
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
await hooks.registerAppNavigation(rootElement, path, source);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
hooks.mountOrUpdate(rootElement, (() => resolved.handler(resolved.params)), {
|
|
154
|
+
cleanupStrict,
|
|
155
|
+
appRuntime: source?.runtime
|
|
156
|
+
});
|
|
157
|
+
await hooks.registerAppNavigation(rootElement, path, source);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
releaseSelectiveHydrationResources();
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
if (hydrateOptions.deferUntilIdle && deferredBoundaries.length > 0) await queueIdleWork(() => {
|
|
163
|
+
try {
|
|
164
|
+
activateVisibleDeferredBoundaries(rootElement, deferredBoundaries, Number.POSITIVE_INFINITY, hooks.activateHydrationBoundary);
|
|
165
|
+
} finally {
|
|
166
|
+
releaseSelectiveHydrationResources();
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
if (deferredBoundaries.length === 0) releaseSelectiveHydrationResources();
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/boot/root-element.ts
|
|
173
|
+
function resolveRootElement(root) {
|
|
174
|
+
if (typeof root !== "string") return root;
|
|
175
|
+
const id = root.startsWith("#") ? root.slice(1) : root;
|
|
176
|
+
return document.getElementById(id);
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/boot/root-lifecycle.ts
|
|
180
|
+
installRendererBridge();
|
|
181
|
+
let componentIdCounter = 0;
|
|
182
|
+
const instancesByRoot = /* @__PURE__ */ new WeakMap();
|
|
183
|
+
const routedRoots = /* @__PURE__ */ new Set();
|
|
184
|
+
const CLEANUP_SYMBOL = Symbol.for("__askrCleanup__");
|
|
185
|
+
const ROOT_CLEANUP_CALLBACKS_SYMBOL = Symbol.for("__askrRootCleanupCallbacks__");
|
|
186
|
+
function clearRootCleanupCallbacks(rootElement) {
|
|
187
|
+
try {
|
|
188
|
+
delete rootElement[ROOT_CLEANUP_CALLBACKS_SYMBOL];
|
|
189
|
+
} catch {
|
|
190
|
+
rootElement[ROOT_CLEANUP_CALLBACKS_SYMBOL]?.clear();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function registerRootCleanupCallback(rootElement, callback) {
|
|
194
|
+
const elementWithCleanup = rootElement;
|
|
195
|
+
const callbacks = elementWithCleanup[ROOT_CLEANUP_CALLBACKS_SYMBOL] ?? /* @__PURE__ */ new Set();
|
|
196
|
+
callbacks.add(callback);
|
|
197
|
+
elementWithCleanup[ROOT_CLEANUP_CALLBACKS_SYMBOL] = callbacks;
|
|
198
|
+
return () => {
|
|
199
|
+
callbacks.delete(callback);
|
|
200
|
+
if (callbacks.size === 0) clearRootCleanupCallbacks(rootElement);
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function runRootCleanupCallbacks(rootElement, errors) {
|
|
204
|
+
const callbacks = rootElement[ROOT_CLEANUP_CALLBACKS_SYMBOL];
|
|
205
|
+
if (!callbacks || callbacks.size === 0) {
|
|
206
|
+
clearRootCleanupCallbacks(rootElement);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
clearRootCleanupCallbacks(rootElement);
|
|
210
|
+
for (const callback of callbacks) try {
|
|
211
|
+
callback();
|
|
212
|
+
} catch (e) {
|
|
213
|
+
errors.push(e);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function cleanupRootInstance(rootElement, instance, options) {
|
|
217
|
+
const errors = [];
|
|
218
|
+
try {
|
|
219
|
+
teardownNodeSubtree(rootElement);
|
|
220
|
+
} catch (e) {
|
|
221
|
+
errors.push(e);
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
cleanupComponent(instance);
|
|
225
|
+
} catch (e) {
|
|
226
|
+
errors.push(e);
|
|
227
|
+
}
|
|
228
|
+
runRootCleanupCallbacks(rootElement, errors);
|
|
229
|
+
clearDeferredHydrationBoundaries(rootElement);
|
|
230
|
+
if (!options?.preserveInstance) {
|
|
231
|
+
unregisterAppInstance(instance);
|
|
232
|
+
instancesByRoot.delete(rootElement);
|
|
233
|
+
clearRootCleanupCallbacks(rootElement);
|
|
234
|
+
try {
|
|
235
|
+
delete rootElement[CLEANUP_SYMBOL];
|
|
236
|
+
} catch {}
|
|
237
|
+
}
|
|
238
|
+
if (errors.length > 0) {
|
|
239
|
+
if (instance.cleanupStrict) throw new AggregateError(errors, `cleanup failed for app root`);
|
|
240
|
+
else if (isDevelopmentEnvironment()) for (const err of errors) logger.warn("[Askr] cleanup error:", err);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function attachCleanupForRoot(rootElement, instance) {
|
|
244
|
+
rootElement[CLEANUP_SYMBOL] = (options) => {
|
|
245
|
+
cleanupRootInstance(rootElement, instance, options);
|
|
246
|
+
};
|
|
247
|
+
try {
|
|
248
|
+
const descriptor = Object.getOwnPropertyDescriptor(rootElement, "innerHTML") || Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rootElement), "innerHTML") || Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML");
|
|
249
|
+
if (descriptor && (descriptor.get || descriptor.set)) Object.defineProperty(rootElement, "innerHTML", {
|
|
250
|
+
get: descriptor.get ? function() {
|
|
251
|
+
return descriptor.get.call(this);
|
|
252
|
+
} : void 0,
|
|
253
|
+
set: function(value) {
|
|
254
|
+
if (value === "" && instancesByRoot.get(this) === instance) cleanupRootInstance(rootElement, instance);
|
|
255
|
+
if (descriptor.set) return descriptor.set.call(this, value);
|
|
256
|
+
},
|
|
257
|
+
configurable: true
|
|
258
|
+
});
|
|
259
|
+
} catch {}
|
|
260
|
+
}
|
|
261
|
+
function mountOrUpdate(rootElement, componentFn, options) {
|
|
262
|
+
const wrappedFn = (props, ctx) => {
|
|
263
|
+
const out = componentFn(props, ctx);
|
|
264
|
+
if (isPromiseLike(out)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
265
|
+
const portalVNode = {
|
|
266
|
+
$$typeof: ELEMENT_TYPE,
|
|
267
|
+
type: DefaultPortal,
|
|
268
|
+
props: { __askrAutoDefaultPortal: true },
|
|
269
|
+
key: "__default_portal"
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
$$typeof: ELEMENT_TYPE,
|
|
273
|
+
type: Fragment,
|
|
274
|
+
props: { children: out === void 0 || out === null ? [portalVNode] : [out, portalVNode] }
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
Object.defineProperty(wrappedFn, "name", { value: componentFn.name || "Component" });
|
|
278
|
+
const existingCleanup = rootElement[CLEANUP_SYMBOL];
|
|
279
|
+
const reusedExistingInstance = typeof existingCleanup === "function";
|
|
280
|
+
if (reusedExistingInstance) existingCleanup({ preserveInstance: true });
|
|
281
|
+
let instance = instancesByRoot.get(rootElement);
|
|
282
|
+
if (instance) {
|
|
283
|
+
const shouldResetHookState = instance._rootComponentFn !== componentFn;
|
|
284
|
+
if (!reusedExistingInstance) {
|
|
285
|
+
removeAllListeners(rootElement);
|
|
286
|
+
try {
|
|
287
|
+
cleanupComponent(instance);
|
|
288
|
+
} catch (e) {
|
|
289
|
+
if (isDevelopmentEnvironment()) logger.warn("[Askr] prior cleanup threw:", e);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
instance.fn = wrappedFn;
|
|
293
|
+
instance._rootComponentFn = componentFn;
|
|
294
|
+
instance.evaluationGeneration++;
|
|
295
|
+
instance.mounted = false;
|
|
296
|
+
instance.expectedStateIndices = [];
|
|
297
|
+
instance.firstRenderComplete = false;
|
|
298
|
+
instance.isRoot = true;
|
|
299
|
+
instance.portalScope = instance;
|
|
300
|
+
instance._appRenderRuntime = options?.appRuntime;
|
|
301
|
+
if (shouldResetHookState) {
|
|
302
|
+
instance.stateValues = [];
|
|
303
|
+
instance.hasPendingUpdate = false;
|
|
304
|
+
instance.notifyUpdate = null;
|
|
305
|
+
instance.stateIndexCheck = -1;
|
|
306
|
+
instance.mountOperations = void 0;
|
|
307
|
+
instance.commitOperations = void 0;
|
|
308
|
+
instance.lifecycleSlots = void 0;
|
|
309
|
+
instance.cleanupFns = void 0;
|
|
310
|
+
instance._currentRenderToken = void 0;
|
|
311
|
+
instance.lastRenderToken = 0;
|
|
312
|
+
instance._pendingReadSources = void 0;
|
|
313
|
+
instance._lastReadSources = void 0;
|
|
314
|
+
instance._placeholder = void 0;
|
|
315
|
+
instance.errorBoundaryState = void 0;
|
|
316
|
+
instance.devWarningsEmitted = void 0;
|
|
317
|
+
}
|
|
318
|
+
if (options && typeof options.cleanupStrict === "boolean") instance.cleanupStrict = options.cleanupStrict;
|
|
319
|
+
} else {
|
|
320
|
+
instance = createComponentInstance(String(++componentIdCounter), wrappedFn, {}, rootElement);
|
|
321
|
+
instancesByRoot.set(rootElement, instance);
|
|
322
|
+
instance.isRoot = true;
|
|
323
|
+
instance._rootComponentFn = componentFn;
|
|
324
|
+
instance.portalScope = instance;
|
|
325
|
+
instance._appRenderRuntime = options?.appRuntime;
|
|
326
|
+
if (options && typeof options.cleanupStrict === "boolean") instance.cleanupStrict = options.cleanupStrict;
|
|
327
|
+
}
|
|
328
|
+
attachCleanupForRoot(rootElement, instance);
|
|
329
|
+
registerRootCleanupCallback(rootElement, () => {
|
|
330
|
+
disposeDefaultPortalScope(instance.portalScope ?? instance);
|
|
331
|
+
});
|
|
332
|
+
mountComponent(instance);
|
|
333
|
+
flushRuntimeScheduler();
|
|
334
|
+
}
|
|
335
|
+
/** @internal Activate one deferred boundary without rerunning its root. */
|
|
336
|
+
function activateHydrationBoundary(rootElement, boundary) {
|
|
337
|
+
if (!instancesByRoot.has(rootElement)) return false;
|
|
338
|
+
const activated = activateHydrationBoundary$1(boundary);
|
|
339
|
+
if (activated) flushRuntimeScheduler();
|
|
340
|
+
return activated;
|
|
341
|
+
}
|
|
342
|
+
async function registerAppNavigation(rootElement, path, source) {
|
|
343
|
+
const instance = instancesByRoot.get(rootElement);
|
|
344
|
+
if (!instance) throw new Error("Internal error: app instance missing");
|
|
345
|
+
routedRoots.add(rootElement);
|
|
346
|
+
registerAppInstance(instance, path, source);
|
|
347
|
+
initializeNavigation();
|
|
348
|
+
}
|
|
349
|
+
function cleanupApp(root) {
|
|
350
|
+
const rootElement = resolveRootElement(root);
|
|
351
|
+
if (!rootElement) return;
|
|
352
|
+
const cleanupFn = rootElement[CLEANUP_SYMBOL];
|
|
353
|
+
try {
|
|
354
|
+
if (typeof cleanupFn === "function") cleanupFn();
|
|
355
|
+
} finally {
|
|
356
|
+
const wasRoutedRoot = routedRoots.delete(rootElement);
|
|
357
|
+
instancesByRoot.delete(rootElement);
|
|
358
|
+
clearRootCleanupCallbacks(rootElement);
|
|
359
|
+
if (wasRoutedRoot && routedRoots.size === 0) clearRoutes();
|
|
360
|
+
try {
|
|
361
|
+
delete rootElement[CLEANUP_SYMBOL];
|
|
362
|
+
} catch {}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function hasApp(root) {
|
|
366
|
+
const rootElement = resolveRootElement(root);
|
|
367
|
+
if (!rootElement) return false;
|
|
368
|
+
return instancesByRoot.has(rootElement);
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/boot/route-startup.ts
|
|
372
|
+
const MAX_INITIAL_ROUTE_REDIRECTS = 20;
|
|
373
|
+
function bindResolvedRouteHandler(resolved) {
|
|
374
|
+
return () => resolved.handler(resolved.params);
|
|
375
|
+
}
|
|
376
|
+
function createDeniedStatusNode(status) {
|
|
377
|
+
return {
|
|
378
|
+
type: "div",
|
|
379
|
+
props: { "data-route-denied": String(status) },
|
|
380
|
+
children: [String(status)]
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function bindDeniedStatus(status) {
|
|
384
|
+
return () => createDeniedStatusNode(status);
|
|
385
|
+
}
|
|
386
|
+
function bindDeniedRouteHandler(status) {
|
|
387
|
+
return () => createDeniedStatusNode(status);
|
|
388
|
+
}
|
|
389
|
+
async function reconcileInitialRouteMetadata(resolved) {
|
|
390
|
+
if (resolved?.kind !== "render" || !resolved.record) return;
|
|
391
|
+
if (!resolved.record.options.title && !resolved.record.options.meta && !resolved.record.metaChain?.length) return;
|
|
392
|
+
const context = getRouteRenderContext(resolved);
|
|
393
|
+
if (!context) return;
|
|
394
|
+
reconcileRouteMeta(await resolveRouteMeta(resolved.record, context));
|
|
395
|
+
}
|
|
396
|
+
async function resolveInitialRoute(auth, source) {
|
|
397
|
+
let path = typeof window !== "undefined" ? window.location.pathname : "/";
|
|
398
|
+
let href = typeof window !== "undefined" ? `${window.location.pathname}${window.location.search}${window.location.hash}` : path;
|
|
399
|
+
const visited = /* @__PURE__ */ new Set();
|
|
400
|
+
for (let redirects = 0; redirects <= MAX_INITIAL_ROUTE_REDIRECTS; redirects++) {
|
|
401
|
+
if (visited.has(href)) throw new Error(`[Askr] Route redirect cycle detected at ${href}.`);
|
|
402
|
+
visited.add(href);
|
|
403
|
+
const resolved = source?.manifest ? await resolveRouteRequest(href, {
|
|
404
|
+
manifest: source.manifest,
|
|
405
|
+
auth,
|
|
406
|
+
load: source.load
|
|
407
|
+
}) : source?.routes ? (() => {
|
|
408
|
+
const match = resolveRouteFromRoutes(path, source.routes);
|
|
409
|
+
return match ? {
|
|
410
|
+
kind: "render",
|
|
411
|
+
handler: match.handler,
|
|
412
|
+
params: match.params
|
|
413
|
+
} : null;
|
|
414
|
+
})() : await resolveRouteRequest(href, { auth });
|
|
415
|
+
if (typeof window === "undefined" || !resolved || resolved.kind !== "redirect") return {
|
|
416
|
+
path,
|
|
417
|
+
href,
|
|
418
|
+
resolved
|
|
419
|
+
};
|
|
420
|
+
const redirectTarget = new URL(resolved.to, window.location.href);
|
|
421
|
+
const redirectHref = `${redirectTarget.pathname}${redirectTarget.search}${redirectTarget.hash}`;
|
|
422
|
+
window.history.replaceState({ path: redirectHref }, "", redirectHref);
|
|
423
|
+
path = redirectTarget.pathname;
|
|
424
|
+
href = redirectHref;
|
|
425
|
+
}
|
|
426
|
+
throw new Error(`[Askr] Route redirect limit exceeded (${MAX_INITIAL_ROUTE_REDIRECTS}).`);
|
|
427
|
+
}
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/boot/index.ts
|
|
430
|
+
/**
|
|
431
|
+
* App bootstrap and mount
|
|
432
|
+
*/
|
|
433
|
+
/**
|
|
434
|
+
* createIsland: Enhances existing DOM (no router, mounts once)
|
|
435
|
+
*/
|
|
436
|
+
function createIsland(config) {
|
|
437
|
+
assertExecutionModel("islands");
|
|
438
|
+
if (!config || typeof config !== "object") throw new Error("createIsland requires a config object");
|
|
439
|
+
if (typeof config.component !== "function") throw new Error("createIsland: component must be a function");
|
|
440
|
+
const rootElement = resolveRootElement(config.root);
|
|
441
|
+
if (!rootElement) throw new Error(`Root element not found: ${config.root}`);
|
|
442
|
+
if ("routes" in config) throw new Error("createIsland does not accept routes; use createSPA for routed apps");
|
|
443
|
+
if (hasRegisteredRoutes()) throw new Error("Routes are not supported with islands. Use createSPA (client) or createSSR (server) instead.");
|
|
444
|
+
mountOrUpdate(rootElement, config.component, { cleanupStrict: config.cleanupStrict });
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* createIslands: Enhances one or more existing DOM roots (no router).
|
|
448
|
+
* The only public islands constructor.
|
|
449
|
+
*/
|
|
450
|
+
function createIslands(config) {
|
|
451
|
+
assertExecutionModel("islands");
|
|
452
|
+
if (!config || typeof config !== "object") throw new Error("createIslands requires a config object");
|
|
453
|
+
if (!Array.isArray(config.islands) || config.islands.length === 0) throw new Error("createIslands requires a non-empty islands array");
|
|
454
|
+
for (const island of config.islands) createIsland(island);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* createSPA: Initializes router and mounts the app with the provided route manifest or route table.
|
|
458
|
+
*
|
|
459
|
+
* Preferred usage with manifest:
|
|
460
|
+
* ```ts
|
|
461
|
+
* import { getManifest } from '@askrjs/askr/router';
|
|
462
|
+
* await createSPA({ root: '#app', manifest: getManifest() });
|
|
463
|
+
* ```
|
|
464
|
+
*
|
|
465
|
+
* Legacy usage with plain routes array (still supported):
|
|
466
|
+
* ```ts
|
|
467
|
+
* await createSPA({ root: '#app', routes: getRoutes() });
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
async function createSPA(config) {
|
|
471
|
+
assertExecutionModel("spa");
|
|
472
|
+
if (!config || typeof config !== "object") throw new Error("createSPA requires a config object");
|
|
473
|
+
const manifest = config.manifest ?? config.registry?.manifest;
|
|
474
|
+
const routeTable = config.routes ?? config.registry?.routes;
|
|
475
|
+
const hasManifest = manifest != null && manifest.records.length > 0;
|
|
476
|
+
const hasRoutes = Array.isArray(routeTable) && routeTable.length > 0;
|
|
477
|
+
if (!hasManifest && !hasRoutes) throw new Error("createSPA requires a route manifest or route table. Pass `manifest: getManifest()` or `routes: getRoutes()`. If you are enhancing existing HTML, use createIsland instead.");
|
|
478
|
+
const rootElement = resolveRootElement(config.root);
|
|
479
|
+
if (!rootElement) throw new Error(`Root element not found: ${config.root}`);
|
|
480
|
+
const pendingLazyAtBoot = [..._snapshotLazy(), ..._snapshotRouteSourceLazy({
|
|
481
|
+
registry: config.registry,
|
|
482
|
+
manifest
|
|
483
|
+
})];
|
|
484
|
+
configureScrollRestoration(config.scrollRestoration);
|
|
485
|
+
clearRoutes();
|
|
486
|
+
if (hasManifest) _applyManifest(manifest);
|
|
487
|
+
else for (const r of routeTable) route(r.path, r.handler);
|
|
488
|
+
const routeAuth = config.auth ?? manifest?.auth;
|
|
489
|
+
const activeManifest = hasManifest ? manifest : void 0;
|
|
490
|
+
const appRouteSource = {
|
|
491
|
+
manifest: activeManifest,
|
|
492
|
+
routes: hasManifest ? void 0 : routeTable,
|
|
493
|
+
auth: routeAuth
|
|
494
|
+
};
|
|
495
|
+
_setActiveRouteAuthOptions(routeAuth);
|
|
496
|
+
await _drainLazy(pendingLazyAtBoot);
|
|
497
|
+
if (isProductionEnvironment()) lockRouteRegistration();
|
|
498
|
+
const { path, resolved } = await resolveInitialRoute(routeAuth, {
|
|
499
|
+
manifest: activeManifest,
|
|
500
|
+
routes: hasManifest ? void 0 : routeTable
|
|
501
|
+
});
|
|
502
|
+
const appRuntime = createAppRenderRuntime(resolved?.kind === "render" && hasRouteRenderData(resolved) ? {
|
|
503
|
+
route: getRouteRenderData(resolved),
|
|
504
|
+
hasRoute: true
|
|
505
|
+
} : {});
|
|
506
|
+
if (!resolved) {
|
|
507
|
+
mountOrUpdate(rootElement, () => ({
|
|
508
|
+
type: "div",
|
|
509
|
+
children: []
|
|
510
|
+
}), {
|
|
511
|
+
cleanupStrict: config.cleanupStrict,
|
|
512
|
+
appRuntime
|
|
513
|
+
});
|
|
514
|
+
await registerAppNavigation(rootElement, path, { ...appRouteSource });
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (resolved.kind === "redirect") {
|
|
518
|
+
mountOrUpdate(rootElement, () => ({
|
|
519
|
+
type: "div",
|
|
520
|
+
children: []
|
|
521
|
+
}), {
|
|
522
|
+
cleanupStrict: config.cleanupStrict,
|
|
523
|
+
appRuntime
|
|
524
|
+
});
|
|
525
|
+
await registerAppNavigation(rootElement, path, { ...appRouteSource });
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
await reconcileInitialRouteMetadata(resolved);
|
|
529
|
+
mountOrUpdate(rootElement, resolved.kind === "deny" ? bindDeniedStatus(resolved.status) : bindResolvedRouteHandler({
|
|
530
|
+
handler: resolved.handler,
|
|
531
|
+
params: resolved.params
|
|
532
|
+
}), {
|
|
533
|
+
cleanupStrict: config.cleanupStrict,
|
|
534
|
+
appRuntime
|
|
535
|
+
});
|
|
536
|
+
await registerAppNavigation(rootElement, path, { ...appRouteSource });
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* hydrateSPA: Hydrate server-rendered HTML.
|
|
540
|
+
* Accepts either a `manifest` (preferred) or a legacy `routes` array.
|
|
541
|
+
*/
|
|
542
|
+
async function hydrateSPA(config) {
|
|
543
|
+
assertExecutionModel("spa");
|
|
544
|
+
if (!config || typeof config !== "object") throw new Error("hydrateSPA requires a config object");
|
|
545
|
+
const manifest = config.manifest ?? config.registry?.manifest;
|
|
546
|
+
const routeTable = config.routes ?? config.registry?.routes;
|
|
547
|
+
const hasManifest = manifest != null && manifest.records.length > 0;
|
|
548
|
+
const hasRoutes = Array.isArray(routeTable) && routeTable.length > 0;
|
|
549
|
+
if (!hasManifest && !hasRoutes) throw new Error("hydrateSPA requires a route manifest or route table. Pass `manifest: getManifest()` or `routes: getRoutes()`. If you are enhancing existing HTML, use createIsland instead.");
|
|
550
|
+
const rootElement = resolveRootElement(config.root);
|
|
551
|
+
if (!rootElement) throw new Error(`Root element not found: ${config.root}`);
|
|
552
|
+
applyDeferredStreamPatches(rootElement);
|
|
553
|
+
const hydrationRenderData = takeHydrationRenderData(rootElement);
|
|
554
|
+
const hydrationQueryCache = hydrationRenderData?.resources;
|
|
555
|
+
if (hydrationQueryCache) hydrateDataRuntime(config.dataRuntime ?? getDefaultDataRuntime(), hydrationQueryCache);
|
|
556
|
+
const hydrationRenderDataForApp = hydrationRenderData;
|
|
557
|
+
const pendingLazyAtHydrationBoot = [..._snapshotLazy(), ..._snapshotRouteSourceLazy({
|
|
558
|
+
registry: config.registry,
|
|
559
|
+
manifest
|
|
560
|
+
})];
|
|
561
|
+
configureScrollRestoration(config.scrollRestoration);
|
|
562
|
+
clearRoutes();
|
|
563
|
+
if (hasManifest) _applyManifest(manifest);
|
|
564
|
+
else for (const r of routeTable) route(r.path, r.handler);
|
|
565
|
+
const routeAuth = config.auth ?? manifest?.auth;
|
|
566
|
+
const activeManifest = hasManifest ? manifest : void 0;
|
|
567
|
+
const appRouteSource = {
|
|
568
|
+
manifest: activeManifest,
|
|
569
|
+
routes: hasManifest ? void 0 : routeTable,
|
|
570
|
+
auth: routeAuth,
|
|
571
|
+
runtime: createAppRenderRuntime({
|
|
572
|
+
framework: hydrationRenderData?.framework,
|
|
573
|
+
route: hydrationRenderData?.route,
|
|
574
|
+
hasRoute: hydrationRenderData !== null
|
|
575
|
+
})
|
|
576
|
+
};
|
|
577
|
+
_setActiveRouteAuthOptions(routeAuth);
|
|
578
|
+
await _drainLazy(pendingLazyAtHydrationBoot);
|
|
579
|
+
const { path, href: currentUrl, resolved } = await resolveInitialRoute(routeAuth, {
|
|
580
|
+
manifest: activeManifest,
|
|
581
|
+
routes: hasManifest ? void 0 : routeTable,
|
|
582
|
+
load: false
|
|
583
|
+
});
|
|
584
|
+
setServerLocation(currentUrl);
|
|
585
|
+
if (isProductionEnvironment()) lockRouteRegistration();
|
|
586
|
+
if (!resolved) throw new Error(`hydrateSPA: no route found for current path (${path}).`);
|
|
587
|
+
if (resolved.kind === "redirect") throw new Error(`hydrateSPA: unresolved redirect for current path (${path}).`);
|
|
588
|
+
await reconcileInitialRouteMetadata(resolved);
|
|
589
|
+
const hydrationResolved = resolved.kind === "deny" ? {
|
|
590
|
+
handler: bindDeniedRouteHandler(resolved.status),
|
|
591
|
+
params: {}
|
|
592
|
+
} : {
|
|
593
|
+
handler: resolved.handler,
|
|
594
|
+
params: resolved.params
|
|
595
|
+
};
|
|
596
|
+
const mountHydratedRoot = (...args) => withIntrinsicHydrationAdoption(() => mountOrUpdate(...args));
|
|
597
|
+
if (shouldVerifyHydrationMarkup(config)) {
|
|
598
|
+
const legacyRouteTable = hasManifest ? manifest.records.map((r) => ({
|
|
599
|
+
...r,
|
|
600
|
+
path: r.path,
|
|
601
|
+
handler: r.handler,
|
|
602
|
+
namespace: r.options.namespace
|
|
603
|
+
})) : routeTable;
|
|
604
|
+
const { verifyHydrationSyncForUrl } = await import("./verify-hydration-BWwu-mWu.js");
|
|
605
|
+
if (!verifyHydrationSyncForUrl({
|
|
606
|
+
root: rootElement,
|
|
607
|
+
url: currentUrl,
|
|
608
|
+
routes: legacyRouteTable,
|
|
609
|
+
resolved: hydrationResolved,
|
|
610
|
+
options: {
|
|
611
|
+
data: hydrationRenderDataForApp?.resources,
|
|
612
|
+
dataRuntime: config.dataRuntime ?? getDefaultDataRuntime(),
|
|
613
|
+
envelope: hydrationRenderDataForApp ?? void 0
|
|
614
|
+
}
|
|
615
|
+
})) throw new Error("[Askr] Hydration mismatch detected. Server HTML does not match expected server-render output.");
|
|
616
|
+
}
|
|
617
|
+
const hydrateOptions = config.hydrate;
|
|
618
|
+
if (hydrateOptions) {
|
|
619
|
+
if (hydrateOptions.deferUntilIdle || hydrateOptions.deferBelowFold) {
|
|
620
|
+
if (hydrationRenderDataForApp) startHydrationRenderPhase(hydrationRenderDataForApp);
|
|
621
|
+
try {
|
|
622
|
+
await applySelectiveHydration(rootElement, hydrationResolved, path, config.cleanupStrict, hydrateOptions, appRouteSource, {
|
|
623
|
+
mountOrUpdate: mountHydratedRoot,
|
|
624
|
+
registerAppNavigation,
|
|
625
|
+
registerRootCleanupCallback,
|
|
626
|
+
activateHydrationBoundary
|
|
627
|
+
});
|
|
628
|
+
} finally {
|
|
629
|
+
if (hydrationRenderDataForApp) stopHydrationRenderPhase();
|
|
630
|
+
}
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
if (hydrateOptions.skipSelectors?.length) markSkippedElements(rootElement, hydrateOptions.skipSelectors);
|
|
634
|
+
}
|
|
635
|
+
if (hydrationRenderDataForApp) startHydrationRenderPhase(hydrationRenderDataForApp);
|
|
636
|
+
try {
|
|
637
|
+
mountHydratedRoot(rootElement, resolved.kind === "deny" ? bindDeniedStatus(resolved.status) : bindResolvedRouteHandler(hydrationResolved), {
|
|
638
|
+
cleanupStrict: config.cleanupStrict,
|
|
639
|
+
appRuntime: appRouteSource.runtime
|
|
640
|
+
});
|
|
641
|
+
} finally {
|
|
642
|
+
if (hydrationRenderDataForApp) stopHydrationRenderPhase();
|
|
643
|
+
}
|
|
644
|
+
await registerAppNavigation(rootElement, path, { ...appRouteSource });
|
|
645
|
+
}
|
|
646
|
+
//#endregion
|
|
647
|
+
export { cleanupApp as a, hydrateSPA as i, createIslands as n, hasApp as o, createSPA as r, createIsland as t };
|