@askrjs/askr 0.0.48 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/benchmark.js +6 -6
- package/dist/benchmark.js.map +1 -1
- package/dist/boot/hydration.js +140 -0
- package/dist/boot/hydration.js.map +1 -0
- package/dist/boot/index.d.ts +3 -56
- package/dist/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +62 -410
- package/dist/boot/index.js.map +1 -1
- package/dist/boot/root-lifecycle.d.ts +15 -0
- package/dist/boot/root-lifecycle.d.ts.map +1 -0
- package/dist/boot/root-lifecycle.js +205 -0
- package/dist/boot/root-lifecycle.js.map +1 -0
- package/dist/boot/route-startup.js +45 -0
- package/dist/boot/route-startup.js.map +1 -0
- package/dist/boot/types.d.ts +62 -0
- package/dist/boot/types.d.ts.map +1 -0
- package/dist/common/component.d.ts +3 -1
- package/dist/common/component.d.ts.map +1 -1
- package/dist/common/jsx.d.ts +1 -1
- package/dist/common/jsx.d.ts.map +1 -1
- package/dist/common/jsx.js.map +1 -1
- package/dist/common/props.d.ts +1 -1
- package/dist/common/render-context.js +55 -0
- package/dist/common/render-context.js.map +1 -0
- package/dist/common/router.d.ts +5 -1
- package/dist/common/router.d.ts.map +1 -1
- package/dist/common/ssr.d.ts +1 -1
- package/dist/common/ssr.js.map +1 -1
- package/dist/common/vnode.d.ts +5 -4
- package/dist/common/vnode.d.ts.map +1 -1
- package/dist/common/vnode.js.map +1 -1
- package/dist/components/error-boundary.d.ts +1 -1
- package/dist/components/error-boundary.js +2 -1
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/control/for.js +2 -1
- package/dist/control/for.js.map +1 -1
- package/dist/data/data-runtime.d.ts +28 -0
- package/dist/data/data-runtime.d.ts.map +1 -0
- package/dist/data/data-runtime.js +114 -0
- package/dist/data/data-runtime.js.map +1 -0
- package/dist/data/index.d.ts +6 -142
- package/dist/data/index.js +5 -539
- package/dist/data/invalidation.d.ts +9 -0
- package/dist/data/invalidation.d.ts.map +1 -0
- package/dist/data/invalidation.js +27 -0
- package/dist/data/invalidation.js.map +1 -0
- package/dist/data/mutation-cell.d.ts +28 -0
- package/dist/data/mutation-cell.d.ts.map +1 -0
- package/dist/data/mutation-cell.js +132 -0
- package/dist/data/mutation-cell.js.map +1 -0
- package/dist/data/query-cell.d.ts +46 -0
- package/dist/data/query-cell.d.ts.map +1 -0
- package/dist/data/query-cell.js +290 -0
- package/dist/data/query-cell.js.map +1 -0
- package/dist/data/query-key.js +42 -0
- package/dist/data/query-key.js.map +1 -0
- package/dist/data/shared.js +20 -0
- package/dist/data/shared.js.map +1 -0
- package/dist/data/types.d.ts +161 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/foundations/icon/icon.d.ts.map +1 -1
- package/dist/foundations/icon/icon.js.map +1 -1
- package/dist/foundations/structures/portal.d.ts +1 -1
- package/dist/foundations/structures/portal.d.ts.map +1 -1
- package/dist/foundations/structures/portal.js +2 -1
- package/dist/foundations/structures/portal.js.map +1 -1
- package/dist/fx/fx.d.ts +1 -1
- package/dist/fx/fx.js +5 -4
- package/dist/fx/fx.js.map +1 -1
- package/dist/fx/timing.d.ts.map +1 -1
- package/dist/fx/timing.js +10 -6
- package/dist/fx/timing.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/jsx/index.d.ts +2 -1
- package/dist/jsx/index.js +3 -2
- package/dist/jsx/types.d.ts +2 -0
- package/dist/jsx/types.js +2 -1
- package/dist/jsx-runtime2.d.ts +2 -1
- package/dist/jsx-runtime2.js +3 -2
- package/dist/renderer/attributes.js +231 -0
- package/dist/renderer/attributes.js.map +1 -0
- package/dist/renderer/boundaries.js +266 -0
- package/dist/renderer/boundaries.js.map +1 -0
- package/dist/renderer/child-shape.js +85 -0
- package/dist/renderer/child-shape.js.map +1 -0
- package/dist/renderer/children.js +3 -2
- package/dist/renderer/children.js.map +1 -1
- package/dist/renderer/cleanup.js +2 -1
- package/dist/renderer/cleanup.js.map +1 -1
- package/dist/renderer/component-host-cleanup.js +68 -0
- package/dist/renderer/component-host-cleanup.js.map +1 -0
- package/dist/renderer/component-host-instances.js +65 -0
- package/dist/renderer/component-host-instances.js.map +1 -0
- package/dist/renderer/component-host.js +247 -0
- package/dist/renderer/component-host.js.map +1 -0
- package/dist/renderer/dom-host.js +13 -0
- package/dist/renderer/dom-host.js.map +1 -0
- package/dist/renderer/dom-internal.js +185 -0
- package/dist/renderer/dom-internal.js.map +1 -0
- package/dist/renderer/dom.js +9 -2356
- package/dist/renderer/element-children.js +279 -0
- package/dist/renderer/element-children.js.map +1 -0
- package/dist/renderer/env.js +2 -1
- package/dist/renderer/error-boundary-dom.js +29 -0
- package/dist/renderer/error-boundary-dom.js.map +1 -0
- package/dist/renderer/evaluate-dom-range.js +85 -0
- package/dist/renderer/evaluate-dom-range.js.map +1 -0
- package/dist/renderer/evaluate-reconcile.js +281 -0
- package/dist/renderer/evaluate-reconcile.js.map +1 -0
- package/dist/renderer/evaluate.js +13 -399
- package/dist/renderer/evaluate.js.map +1 -1
- package/dist/renderer/fastpath.js +6 -5
- package/dist/renderer/fastpath.js.map +1 -1
- package/dist/renderer/for-commit-dom-map.js +83 -0
- package/dist/renderer/for-commit-dom-map.js.map +1 -0
- package/dist/renderer/for-commit-removal.js +36 -0
- package/dist/renderer/for-commit-removal.js.map +1 -0
- package/dist/renderer/for-commit-reorder.js +89 -0
- package/dist/renderer/for-commit-reorder.js.map +1 -0
- package/dist/renderer/for-commit.js +6 -188
- package/dist/renderer/for-commit.js.map +1 -1
- package/dist/renderer/index.js +28 -16
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/keyed-children.js +32 -0
- package/dist/renderer/keyed-children.js.map +1 -0
- package/dist/renderer/keyed.js +2 -15
- package/dist/renderer/keyed.js.map +1 -1
- package/dist/renderer/namespaces.js +23 -0
- package/dist/renderer/namespaces.js.map +1 -0
- package/dist/renderer/prop-bindings.js +280 -0
- package/dist/renderer/prop-bindings.js.map +1 -0
- package/dist/renderer/reactive-child-dom.js +133 -0
- package/dist/renderer/reactive-child-dom.js.map +1 -0
- package/dist/renderer/reactive-child-sources.js +184 -0
- package/dist/renderer/reactive-child-sources.js.map +1 -0
- package/dist/renderer/reactive-children.js +294 -0
- package/dist/renderer/reactive-children.js.map +1 -0
- package/dist/renderer/reconcile-commit.js +38 -0
- package/dist/renderer/reconcile-commit.js.map +1 -0
- package/dist/renderer/reconcile-fastpaths.js +106 -0
- package/dist/renderer/reconcile-fastpaths.js.map +1 -0
- package/dist/renderer/reconcile-resolution.js +187 -0
- package/dist/renderer/reconcile-resolution.js.map +1 -0
- package/dist/renderer/reconcile.js +9 -371
- package/dist/renderer/reconcile.js.map +1 -1
- package/dist/renderer/retained-element-rollback.js +276 -0
- package/dist/renderer/retained-element-rollback.js.map +1 -0
- package/dist/renderer/stable-patch.js +82 -0
- package/dist/renderer/stable-patch.js.map +1 -0
- package/dist/renderer/static-reuse.js +96 -0
- package/dist/renderer/static-reuse.js.map +1 -0
- package/dist/renderer/types.js +2 -1
- package/dist/renderer/utils.js +4 -4
- package/dist/renderer/utils.js.map +1 -1
- package/dist/resources/index.d.ts +3 -2
- package/dist/resources/index.js +5 -2
- package/dist/router/access.js +36 -0
- package/dist/router/access.js.map +1 -0
- package/dist/router/activity.d.ts +10 -0
- package/dist/router/activity.d.ts.map +1 -0
- package/dist/router/activity.js +89 -0
- package/dist/router/activity.js.map +1 -0
- package/dist/router/authoring.d.ts +22 -0
- package/dist/router/authoring.d.ts.map +1 -0
- package/dist/router/authoring.js +198 -0
- package/dist/router/authoring.js.map +1 -0
- package/dist/router/index.d.ts +12 -4
- package/dist/router/index.js +10 -3
- package/dist/router/internal-types.d.ts +31 -0
- package/dist/router/internal-types.d.ts.map +1 -0
- package/dist/router/lazy.d.ts +19 -0
- package/dist/router/lazy.d.ts.map +1 -0
- package/dist/router/lazy.js +52 -0
- package/dist/router/lazy.js.map +1 -0
- package/dist/router/manifest.d.ts +10 -0
- package/dist/router/manifest.d.ts.map +1 -0
- package/dist/router/manifest.js +49 -0
- package/dist/router/manifest.js.map +1 -0
- package/dist/router/navigate.d.ts +4 -51
- package/dist/router/navigate.d.ts.map +1 -1
- package/dist/router/navigate.js +16 -459
- package/dist/router/navigate.js.map +1 -1
- package/dist/router/navigation-registry.d.ts +32 -0
- package/dist/router/navigation-registry.d.ts.map +1 -0
- package/dist/router/navigation-registry.js +105 -0
- package/dist/router/navigation-registry.js.map +1 -0
- package/dist/router/navigation-scroll.d.ts +14 -0
- package/dist/router/navigation-scroll.d.ts.map +1 -0
- package/dist/router/navigation-scroll.js +93 -0
- package/dist/router/navigation-scroll.js.map +1 -0
- package/dist/router/navigation-targets.d.ts +31 -0
- package/dist/router/navigation-targets.d.ts.map +1 -0
- package/dist/router/navigation-targets.js +253 -0
- package/dist/router/navigation-targets.js.map +1 -0
- package/dist/router/policy.d.ts +7 -1
- package/dist/router/policy.d.ts.map +1 -1
- package/dist/router/policy.js +27 -9
- package/dist/router/policy.js.map +1 -1
- package/dist/router/rendering.d.ts +10 -0
- package/dist/router/rendering.d.ts.map +1 -0
- package/dist/router/rendering.js +45 -0
- package/dist/router/rendering.js.map +1 -0
- package/dist/router/resolution.d.ts +17 -0
- package/dist/router/resolution.d.ts.map +1 -0
- package/dist/router/resolution.js +253 -0
- package/dist/router/resolution.js.map +1 -0
- package/dist/router/route-query.d.ts +17 -0
- package/dist/router/route-query.d.ts.map +1 -0
- package/dist/router/route-query.js +47 -0
- package/dist/router/route-query.js.map +1 -0
- package/dist/router/route.d.ts +8 -149
- package/dist/router/route.js +8 -854
- package/dist/router/store.d.ts +50 -0
- package/dist/router/store.d.ts.map +1 -0
- package/dist/router/store.js +171 -0
- package/dist/router/store.js.map +1 -0
- package/dist/runtime/access.js +45 -0
- package/dist/runtime/access.js.map +1 -0
- package/dist/runtime/child-scope.d.ts +1 -1
- package/dist/runtime/child-scope.js +4 -1
- package/dist/runtime/child-scope.js.map +1 -1
- package/dist/runtime/component-cleanup.d.ts +16 -0
- package/dist/runtime/component-cleanup.d.ts.map +1 -0
- package/dist/runtime/component-cleanup.js +70 -0
- package/dist/runtime/component-cleanup.js.map +1 -0
- package/dist/runtime/component-commit.js +165 -0
- package/dist/runtime/component-commit.js.map +1 -0
- package/dist/runtime/component-contracts.js +5 -0
- package/dist/runtime/component-facade.d.ts +5 -0
- package/dist/runtime/component-facade.js +4 -0
- package/dist/runtime/component-internal.d.ts +100 -0
- package/dist/runtime/component-internal.d.ts.map +1 -0
- package/dist/runtime/component-internal.js +219 -0
- package/dist/runtime/component-internal.js.map +1 -0
- package/dist/runtime/component-lifecycle.d.ts +49 -0
- package/dist/runtime/component-lifecycle.d.ts.map +1 -0
- package/dist/runtime/component-lifecycle.js +176 -0
- package/dist/runtime/component-lifecycle.js.map +1 -0
- package/dist/runtime/component-scope.d.ts +55 -0
- package/dist/runtime/component-scope.d.ts.map +1 -0
- package/dist/runtime/component-scope.js +154 -0
- package/dist/runtime/component-scope.js.map +1 -0
- package/dist/runtime/component.d.ts +4 -152
- package/dist/runtime/component.js +4 -692
- package/dist/runtime/context.d.ts +1 -1
- package/dist/runtime/context.js +6 -4
- package/dist/runtime/context.js.map +1 -1
- package/dist/runtime/control.d.ts +3 -3
- package/dist/runtime/control.js +2 -1
- package/dist/runtime/control.js.map +1 -1
- package/dist/runtime/derive.d.ts.map +1 -1
- package/dist/runtime/derive.js +6 -5
- package/dist/runtime/derive.js.map +1 -1
- package/dist/runtime/effect.d.ts +1 -1
- package/dist/runtime/effect.d.ts.map +1 -1
- package/dist/runtime/effect.js +2 -2
- package/dist/runtime/effect.js.map +1 -1
- package/dist/runtime/events.js +3 -3
- package/dist/runtime/events.js.map +1 -1
- package/dist/runtime/fastlane.js +13 -27
- package/dist/runtime/fastlane.js.map +1 -1
- package/dist/runtime/for-bench.d.ts +1 -1
- package/dist/runtime/for-bench.js +1 -4
- package/dist/runtime/for-bench.js.map +1 -1
- package/dist/runtime/for-internal.d.ts +43 -0
- package/dist/runtime/for-internal.d.ts.map +1 -0
- package/dist/runtime/for-internal.js +98 -0
- package/dist/runtime/for-internal.js.map +1 -0
- package/dist/runtime/for-reconcile.d.ts +8 -0
- package/dist/runtime/for-reconcile.d.ts.map +1 -0
- package/dist/runtime/for-reconcile.js +389 -0
- package/dist/runtime/for-reconcile.js.map +1 -0
- package/dist/runtime/for-scopes.d.ts +26 -0
- package/dist/runtime/for-scopes.d.ts.map +1 -0
- package/dist/runtime/for-scopes.js +160 -0
- package/dist/runtime/for-scopes.js.map +1 -0
- package/dist/runtime/for-signals.d.ts +30 -0
- package/dist/runtime/for-signals.d.ts.map +1 -0
- package/dist/runtime/for-signals.js +139 -0
- package/dist/runtime/for-signals.js.map +1 -0
- package/dist/runtime/for.d.ts +4 -66
- package/dist/runtime/for.js +5 -773
- package/dist/runtime/lifecycle-operations.d.ts +31 -0
- package/dist/runtime/lifecycle-operations.d.ts.map +1 -0
- package/dist/runtime/lifecycle-operations.js +195 -0
- package/dist/runtime/lifecycle-operations.js.map +1 -0
- package/dist/runtime/operations.d.ts +3 -40
- package/dist/runtime/operations.js +2 -357
- package/dist/runtime/readable.d.ts +2 -3
- package/dist/runtime/readable.d.ts.map +1 -1
- package/dist/runtime/readable.js +6 -5
- package/dist/runtime/readable.js.map +1 -1
- package/dist/runtime/resource-cell.js +2 -2
- package/dist/runtime/resource-cell.js.map +1 -1
- package/dist/runtime/resource-operation.d.ts +13 -0
- package/dist/runtime/resource-operation.d.ts.map +1 -0
- package/dist/runtime/resource-operation.js +170 -0
- package/dist/runtime/resource-operation.js.map +1 -0
- package/dist/runtime/runtime.d.ts +42 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +59 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/scheduler.d.ts +5 -1
- package/dist/runtime/scheduler.d.ts.map +1 -1
- package/dist/runtime/scheduler.js +17 -17
- package/dist/runtime/scheduler.js.map +1 -1
- package/dist/runtime/selector.js +4 -3
- package/dist/runtime/selector.js.map +1 -1
- package/dist/runtime/snapshot-source.d.ts +1 -1
- package/dist/runtime/snapshot-source.js +1 -1
- package/dist/runtime/state.js +2 -1
- package/dist/runtime/state.js.map +1 -1
- package/dist/ssg/batch-render.js +2 -1
- package/dist/ssg/batch-render.js.map +1 -1
- package/dist/ssg/create-static-gen.d.ts +9 -3
- package/dist/ssg/create-static-gen.d.ts.map +1 -1
- package/dist/ssg/create-static-gen.js +12 -99
- package/dist/ssg/create-static-gen.js.map +1 -1
- package/dist/ssg/generation-plan.js +70 -0
- package/dist/ssg/generation-plan.js.map +1 -0
- package/dist/ssg/incremental-manifest.js +1 -1
- package/dist/ssg/static-routes.js +101 -0
- package/dist/ssg/static-routes.js.map +1 -0
- package/dist/ssg/types.d.ts +15 -7
- package/dist/ssg/types.d.ts.map +1 -1
- package/dist/ssr/boundaries.js +113 -0
- package/dist/ssr/boundaries.js.map +1 -0
- package/dist/ssr/component-runtime.js +111 -0
- package/dist/ssr/component-runtime.js.map +1 -0
- package/dist/ssr/context.d.ts +3 -1
- package/dist/ssr/context.d.ts.map +1 -1
- package/dist/ssr/context.js +9 -2
- package/dist/ssr/context.js.map +1 -1
- package/dist/ssr/errors.d.ts +2 -0
- package/dist/ssr/errors.js +11 -1
- package/dist/ssr/errors.js.map +1 -1
- package/dist/ssr/escape.js +3 -3
- package/dist/ssr/escape.js.map +1 -1
- package/dist/ssr/hydration-data.js +10 -0
- package/dist/ssr/hydration-data.js.map +1 -0
- package/dist/ssr/hydration-verify.d.ts +12 -0
- package/dist/ssr/hydration-verify.d.ts.map +1 -0
- package/dist/ssr/hydration-verify.js +144 -0
- package/dist/ssr/hydration-verify.js.map +1 -0
- package/dist/ssr/index-internal.d.ts +15 -0
- package/dist/ssr/index-internal.d.ts.map +1 -0
- package/dist/ssr/index-internal.js +19 -0
- package/dist/ssr/index-internal.js.map +1 -0
- package/dist/ssr/index.d.ts +5 -57
- package/dist/ssr/index.js +3 -738
- package/dist/ssr/render-keys.js +9 -32
- package/dist/ssr/render-keys.js.map +1 -1
- package/dist/ssr/render-resolved.d.ts +1 -1
- package/dist/ssr/render-resolved.d.ts.map +1 -1
- package/dist/ssr/render-resolved.js +4 -2
- package/dist/ssr/render-resolved.js.map +1 -1
- package/dist/ssr/render-sync.d.ts +21 -0
- package/dist/ssr/render-sync.d.ts.map +1 -0
- package/dist/ssr/render-sync.js +275 -0
- package/dist/ssr/render-sync.js.map +1 -0
- package/dist/ssr/route-policy-resolution.js +77 -0
- package/dist/ssr/route-policy-resolution.js.map +1 -0
- package/dist/ssr/route-render.d.ts +77 -0
- package/dist/ssr/route-render.d.ts.map +1 -0
- package/dist/ssr/route-render.js +119 -0
- package/dist/ssr/route-render.js.map +1 -0
- package/dist/ssr/sink.d.ts +26 -0
- package/dist/ssr/sink.d.ts.map +1 -0
- package/dist/ssr/types.d.ts +1 -0
- package/dist/ssr/types.d.ts.map +1 -1
- package/dist/ssr/verify-hydration.js.map +1 -1
- package/dist/testing/index.d.ts +1 -2
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/data/index.d.ts.map +0 -1
- package/dist/data/index.js.map +0 -1
- package/dist/renderer/dom.js.map +0 -1
- package/dist/router/route.d.ts.map +0 -1
- package/dist/router/route.js.map +0 -1
- package/dist/runtime/component.d.ts.map +0 -1
- package/dist/runtime/component.js.map +0 -1
- package/dist/runtime/for.d.ts.map +0 -1
- package/dist/runtime/for.js.map +0 -1
- package/dist/runtime/operations.d.ts.map +0 -1
- package/dist/runtime/operations.js.map +0 -1
- package/dist/runtime/ssr-bridge.js +0 -24
- package/dist/runtime/ssr-bridge.js.map +0 -1
- package/dist/ssr/index.d.ts.map +0 -1
- package/dist/ssr/index.js.map +0 -1
package/dist/boot/index.js
CHANGED
|
@@ -1,218 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { globalScheduler } from "../runtime/scheduler.js";
|
|
4
|
-
import { ELEMENT_TYPE, Fragment } from "../common/jsx.js";
|
|
5
|
-
import { isPromiseLike } from "../common/promise.js";
|
|
6
|
-
import { cleanupComponent, createComponentInstance, mountComponent } from "../runtime/component.js";
|
|
7
|
-
import { removeAllListeners, teardownNodeSubtree } from "../renderer/cleanup.js";
|
|
8
|
-
import { setStaticChildSlotsCacheEnabled } from "../renderer/dom.js";
|
|
9
|
-
import { installRendererBridge } from "../renderer/index.js";
|
|
1
|
+
import { isProductionEnvironment } from "../common/env.js";
|
|
2
|
+
import { configureScrollRestoration } from "../router/navigation-scroll.js";
|
|
10
3
|
import { assertExecutionModel } from "../runtime/execution-model.js";
|
|
11
|
-
import {
|
|
12
|
-
import "../
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import "../
|
|
16
|
-
import {
|
|
4
|
+
import { startHydrationRenderPhase, stopHydrationRenderPhase } from "../common/render-context.js";
|
|
5
|
+
import { _setActiveRouteAuthOptions, hasRegisteredRoutes, lockRouteRegistration } from "../router/store.js";
|
|
6
|
+
import { route } from "../router/authoring.js";
|
|
7
|
+
import { setServerLocation } from "../router/activity.js";
|
|
8
|
+
import { _drainLazy, _snapshotLazy, _snapshotRouteSourceLazy } from "../router/lazy.js";
|
|
9
|
+
import { _applyManifest, clearRoutes } from "../router/manifest.js";
|
|
10
|
+
import "../router/route.js";
|
|
11
|
+
import "../router/navigate.js";
|
|
12
|
+
import { applySelectiveHydration, markSkippedElements, shouldVerifyHydrationMarkup, takeHydrationRenderData } from "./hydration.js";
|
|
13
|
+
import { cleanupApp, flushHydrationActivation, hasApp, mountOrUpdate, registerAppNavigation, registerRootCleanupCallback } from "./root-lifecycle.js";
|
|
14
|
+
import { bindDeniedRouteHandler, bindDeniedStatus, bindResolvedRouteHandler, resolveInitialRoute } from "./route-startup.js";
|
|
17
15
|
//#region src/boot/index.ts
|
|
18
16
|
/**
|
|
19
17
|
* App bootstrap and mount
|
|
20
18
|
*/
|
|
21
|
-
const HAS_ROUTES_KEY = Symbol.for("__ASKR_HAS_ROUTES__");
|
|
22
|
-
let componentIdCounter = 0;
|
|
23
|
-
const instancesByRoot = /* @__PURE__ */ new WeakMap();
|
|
24
|
-
const CLEANUP_SYMBOL = Symbol.for("__askrCleanup__");
|
|
25
|
-
const ROOT_CLEANUP_CALLBACKS_SYMBOL = Symbol.for("__askrRootCleanupCallbacks__");
|
|
26
|
-
function takeHydrationRenderData(rootElement) {
|
|
27
|
-
for (const child of Array.from(rootElement.children)) if (child instanceof HTMLScriptElement && child.getAttribute("data-askr-render-data") === "true") {
|
|
28
|
-
const raw = child.textContent ?? "";
|
|
29
|
-
child.remove();
|
|
30
|
-
if (!raw) return {};
|
|
31
|
-
try {
|
|
32
|
-
return JSON.parse(raw);
|
|
33
|
-
} catch (err) {
|
|
34
|
-
throw new Error("[Askr] Failed to parse embedded SSR render data during hydration.", { cause: err });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
function clearRootCleanupCallbacks(rootElement) {
|
|
40
|
-
try {
|
|
41
|
-
delete rootElement[ROOT_CLEANUP_CALLBACKS_SYMBOL];
|
|
42
|
-
} catch {
|
|
43
|
-
rootElement[ROOT_CLEANUP_CALLBACKS_SYMBOL]?.clear();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function registerRootCleanupCallback(rootElement, callback) {
|
|
47
|
-
const elementWithCleanup = rootElement;
|
|
48
|
-
const callbacks = elementWithCleanup[ROOT_CLEANUP_CALLBACKS_SYMBOL] ?? /* @__PURE__ */ new Set();
|
|
49
|
-
callbacks.add(callback);
|
|
50
|
-
elementWithCleanup[ROOT_CLEANUP_CALLBACKS_SYMBOL] = callbacks;
|
|
51
|
-
return () => {
|
|
52
|
-
callbacks.delete(callback);
|
|
53
|
-
if (callbacks.size === 0) clearRootCleanupCallbacks(rootElement);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function runRootCleanupCallbacks(rootElement, errors) {
|
|
57
|
-
const callbacks = rootElement[ROOT_CLEANUP_CALLBACKS_SYMBOL];
|
|
58
|
-
if (!callbacks || callbacks.size === 0) {
|
|
59
|
-
clearRootCleanupCallbacks(rootElement);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
clearRootCleanupCallbacks(rootElement);
|
|
63
|
-
for (const callback of callbacks) try {
|
|
64
|
-
callback();
|
|
65
|
-
} catch (e) {
|
|
66
|
-
errors.push(e);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function cleanupRootInstance(rootElement, instance, options) {
|
|
70
|
-
const errors = [];
|
|
71
|
-
try {
|
|
72
|
-
teardownNodeSubtree(rootElement);
|
|
73
|
-
} catch (e) {
|
|
74
|
-
errors.push(e);
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
cleanupComponent(instance);
|
|
78
|
-
} catch (e) {
|
|
79
|
-
errors.push(e);
|
|
80
|
-
}
|
|
81
|
-
runRootCleanupCallbacks(rootElement, errors);
|
|
82
|
-
if (!options?.preserveInstance) {
|
|
83
|
-
unregisterAppInstance(instance);
|
|
84
|
-
instancesByRoot.delete(rootElement);
|
|
85
|
-
clearRootCleanupCallbacks(rootElement);
|
|
86
|
-
try {
|
|
87
|
-
delete rootElement[CLEANUP_SYMBOL];
|
|
88
|
-
} catch {}
|
|
89
|
-
}
|
|
90
|
-
if (errors.length > 0) {
|
|
91
|
-
if (instance.cleanupStrict) throw new AggregateError(errors, `cleanup failed for app root`);
|
|
92
|
-
else if (isDevelopmentEnvironment()) for (const err of errors) logger.warn("[Askr] cleanup error:", err);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function attachCleanupForRoot(rootElement, instance) {
|
|
96
|
-
rootElement[CLEANUP_SYMBOL] = (options) => {
|
|
97
|
-
cleanupRootInstance(rootElement, instance, options);
|
|
98
|
-
};
|
|
99
|
-
try {
|
|
100
|
-
const descriptor = Object.getOwnPropertyDescriptor(rootElement, "innerHTML") || Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rootElement), "innerHTML") || Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML");
|
|
101
|
-
if (descriptor && (descriptor.get || descriptor.set)) Object.defineProperty(rootElement, "innerHTML", {
|
|
102
|
-
get: descriptor.get ? function() {
|
|
103
|
-
return descriptor.get.call(this);
|
|
104
|
-
} : void 0,
|
|
105
|
-
set: function(value) {
|
|
106
|
-
if (value === "" && instancesByRoot.get(this) === instance) cleanupRootInstance(rootElement, instance);
|
|
107
|
-
if (descriptor.set) return descriptor.set.call(this, value);
|
|
108
|
-
},
|
|
109
|
-
configurable: true
|
|
110
|
-
});
|
|
111
|
-
} catch {}
|
|
112
|
-
}
|
|
113
|
-
function mountOrUpdate(rootElement, componentFn, options) {
|
|
114
|
-
const wrappedFn = (props, ctx) => {
|
|
115
|
-
const out = componentFn(props, ctx);
|
|
116
|
-
if (isPromiseLike(out)) throw new Error("Async components are not supported. Components must return synchronously.");
|
|
117
|
-
const portalVNode = {
|
|
118
|
-
$$typeof: ELEMENT_TYPE,
|
|
119
|
-
type: DefaultPortal,
|
|
120
|
-
props: {},
|
|
121
|
-
key: "__default_portal"
|
|
122
|
-
};
|
|
123
|
-
return {
|
|
124
|
-
$$typeof: ELEMENT_TYPE,
|
|
125
|
-
type: Fragment,
|
|
126
|
-
props: { children: out === void 0 || out === null ? [portalVNode] : [out, portalVNode] }
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
Object.defineProperty(wrappedFn, "name", { value: componentFn.name || "Component" });
|
|
130
|
-
const existingCleanup = rootElement[CLEANUP_SYMBOL];
|
|
131
|
-
const reusedExistingInstance = typeof existingCleanup === "function";
|
|
132
|
-
if (reusedExistingInstance) existingCleanup({ preserveInstance: true });
|
|
133
|
-
let instance = instancesByRoot.get(rootElement);
|
|
134
|
-
if (instance) {
|
|
135
|
-
const shouldResetHookState = instance.fn.name !== wrappedFn.name;
|
|
136
|
-
if (!reusedExistingInstance) {
|
|
137
|
-
removeAllListeners(rootElement);
|
|
138
|
-
try {
|
|
139
|
-
cleanupComponent(instance);
|
|
140
|
-
} catch (e) {
|
|
141
|
-
if (isDevelopmentEnvironment()) logger.warn("[Askr] prior cleanup threw:", e);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
instance.fn = wrappedFn;
|
|
145
|
-
instance.evaluationGeneration++;
|
|
146
|
-
instance.mounted = false;
|
|
147
|
-
instance.expectedStateIndices = [];
|
|
148
|
-
instance.firstRenderComplete = false;
|
|
149
|
-
instance.isRoot = true;
|
|
150
|
-
instance.portalScope = instance;
|
|
151
|
-
if (shouldResetHookState) {
|
|
152
|
-
instance.stateValues = [];
|
|
153
|
-
instance.hasPendingUpdate = false;
|
|
154
|
-
instance.notifyUpdate = null;
|
|
155
|
-
instance.stateIndexCheck = -1;
|
|
156
|
-
instance.mountOperations = [];
|
|
157
|
-
instance.commitOperations = [];
|
|
158
|
-
instance.lifecycleSlots = [];
|
|
159
|
-
instance.cleanupFns = [];
|
|
160
|
-
instance._currentRenderToken = void 0;
|
|
161
|
-
instance.lastRenderToken = 0;
|
|
162
|
-
instance._pendingReadSources = void 0;
|
|
163
|
-
instance._lastReadSources = void 0;
|
|
164
|
-
instance._placeholder = void 0;
|
|
165
|
-
instance.errorBoundaryState = void 0;
|
|
166
|
-
instance.devWarningsEmitted = void 0;
|
|
167
|
-
}
|
|
168
|
-
if (options && typeof options.cleanupStrict === "boolean") instance.cleanupStrict = options.cleanupStrict;
|
|
169
|
-
} else {
|
|
170
|
-
instance = createComponentInstance(String(++componentIdCounter), wrappedFn, {}, rootElement);
|
|
171
|
-
instancesByRoot.set(rootElement, instance);
|
|
172
|
-
instance.isRoot = true;
|
|
173
|
-
instance.portalScope = instance;
|
|
174
|
-
if (options && typeof options.cleanupStrict === "boolean") instance.cleanupStrict = options.cleanupStrict;
|
|
175
|
-
}
|
|
176
|
-
attachCleanupForRoot(rootElement, instance);
|
|
177
|
-
registerRootCleanupCallback(rootElement, () => {
|
|
178
|
-
disposeDefaultPortalScope(instance.portalScope ?? instance);
|
|
179
|
-
});
|
|
180
|
-
mountComponent(instance);
|
|
181
|
-
globalScheduler.flush();
|
|
182
|
-
}
|
|
183
|
-
function bindResolvedRouteHandler(resolved) {
|
|
184
|
-
return () => resolved.handler(resolved.params);
|
|
185
|
-
}
|
|
186
|
-
function bindDeniedStatus(status) {
|
|
187
|
-
return () => ({
|
|
188
|
-
type: "div",
|
|
189
|
-
props: { "data-route-denied": String(status) },
|
|
190
|
-
children: [String(status)]
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
installRendererBridge();
|
|
194
|
-
const MAX_INITIAL_ROUTE_REDIRECTS = 20;
|
|
195
|
-
async function resolveInitialRoute(auth) {
|
|
196
|
-
let path = typeof window !== "undefined" ? window.location.pathname : "/";
|
|
197
|
-
let href = typeof window !== "undefined" ? `${window.location.pathname}${window.location.search}${window.location.hash}` : path;
|
|
198
|
-
const visited = /* @__PURE__ */ new Set();
|
|
199
|
-
for (let redirects = 0; redirects <= MAX_INITIAL_ROUTE_REDIRECTS; redirects++) {
|
|
200
|
-
if (visited.has(href)) throw new Error(`[Askr] Route redirect cycle detected at ${href}.`);
|
|
201
|
-
visited.add(href);
|
|
202
|
-
const resolved = await resolveRouteRequest(href, { auth });
|
|
203
|
-
if (typeof window === "undefined" || !resolved || resolved.kind !== "redirect") return {
|
|
204
|
-
path,
|
|
205
|
-
href,
|
|
206
|
-
resolved
|
|
207
|
-
};
|
|
208
|
-
const redirectTarget = new URL(resolved.to, window.location.href);
|
|
209
|
-
const redirectHref = `${redirectTarget.pathname}${redirectTarget.search}${redirectTarget.hash}`;
|
|
210
|
-
window.history.replaceState({ path: redirectHref }, "", redirectHref);
|
|
211
|
-
path = redirectTarget.pathname;
|
|
212
|
-
href = redirectHref;
|
|
213
|
-
}
|
|
214
|
-
throw new Error(`[Askr] Route redirect limit exceeded (${MAX_INITIAL_ROUTE_REDIRECTS}).`);
|
|
215
|
-
}
|
|
216
19
|
/**
|
|
217
20
|
* createIsland: Enhances existing DOM (no router, mounts once)
|
|
218
21
|
*/
|
|
@@ -223,9 +26,7 @@ function createIsland(config) {
|
|
|
223
26
|
const rootElement = typeof config.root === "string" ? document.getElementById(config.root) : config.root;
|
|
224
27
|
if (!rootElement) throw new Error(`Root element not found: ${config.root}`);
|
|
225
28
|
if ("routes" in config) throw new Error("createIsland does not accept routes; use createSPA for routed apps");
|
|
226
|
-
|
|
227
|
-
if (globalThis[HAS_ROUTES_KEY]) throw new Error("Routes are not supported with islands. Use createSPA (client) or createSSR (server) instead.");
|
|
228
|
-
} catch {}
|
|
29
|
+
if (hasRegisteredRoutes()) throw new Error("Routes are not supported with islands. Use createSPA (client) or createSSR (server) instead.");
|
|
229
30
|
mountOrUpdate(rootElement, config.component, { cleanupStrict: config.cleanupStrict });
|
|
230
31
|
}
|
|
231
32
|
/**
|
|
@@ -255,17 +56,27 @@ function createIslands(config) {
|
|
|
255
56
|
async function createSPA(config) {
|
|
256
57
|
assertExecutionModel("spa");
|
|
257
58
|
if (!config || typeof config !== "object") throw new Error("createSPA requires a config object");
|
|
258
|
-
const
|
|
259
|
-
const
|
|
59
|
+
const manifest = config.manifest ?? config.registry?.manifest;
|
|
60
|
+
const routeTable = config.routes ?? config.registry?.routes;
|
|
61
|
+
const hasManifest = manifest != null && manifest.records.length > 0;
|
|
62
|
+
const hasRoutes = Array.isArray(routeTable) && routeTable.length > 0;
|
|
260
63
|
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.");
|
|
261
64
|
const rootElement = typeof config.root === "string" ? document.getElementById(config.root) : config.root;
|
|
262
65
|
if (!rootElement) throw new Error(`Root element not found: ${config.root}`);
|
|
263
|
-
const pendingLazyAtBoot = _snapshotLazy()
|
|
66
|
+
const pendingLazyAtBoot = [..._snapshotLazy(), ..._snapshotRouteSourceLazy({
|
|
67
|
+
registry: config.registry,
|
|
68
|
+
manifest
|
|
69
|
+
})];
|
|
264
70
|
configureScrollRestoration(config.scrollRestoration);
|
|
265
71
|
clearRoutes();
|
|
266
|
-
if (hasManifest) _applyManifest(
|
|
267
|
-
else for (const r of
|
|
268
|
-
const routeAuth = config.auth ??
|
|
72
|
+
if (hasManifest) _applyManifest(manifest);
|
|
73
|
+
else for (const r of routeTable) route(r.path, r.handler);
|
|
74
|
+
const routeAuth = config.auth ?? manifest?.auth;
|
|
75
|
+
const appRouteSource = {
|
|
76
|
+
manifest: hasManifest ? manifest : void 0,
|
|
77
|
+
routes: hasManifest ? void 0 : routeTable,
|
|
78
|
+
auth: routeAuth
|
|
79
|
+
};
|
|
269
80
|
_setActiveRouteAuthOptions(routeAuth);
|
|
270
81
|
await _drainLazy(pendingLazyAtBoot);
|
|
271
82
|
if (isProductionEnvironment()) lockRouteRegistration();
|
|
@@ -275,11 +86,7 @@ async function createSPA(config) {
|
|
|
275
86
|
type: "div",
|
|
276
87
|
children: []
|
|
277
88
|
}), { cleanupStrict: config.cleanupStrict });
|
|
278
|
-
await registerAppNavigation(rootElement, path, {
|
|
279
|
-
manifest: config.manifest,
|
|
280
|
-
routes: config.routes,
|
|
281
|
-
auth: routeAuth
|
|
282
|
-
});
|
|
89
|
+
await registerAppNavigation(rootElement, path, { ...appRouteSource });
|
|
283
90
|
return;
|
|
284
91
|
}
|
|
285
92
|
if (resolved.kind === "redirect") {
|
|
@@ -287,156 +94,14 @@ async function createSPA(config) {
|
|
|
287
94
|
type: "div",
|
|
288
95
|
children: []
|
|
289
96
|
}), { cleanupStrict: config.cleanupStrict });
|
|
290
|
-
await registerAppNavigation(rootElement, path, {
|
|
291
|
-
manifest: config.manifest,
|
|
292
|
-
routes: config.routes,
|
|
293
|
-
auth: routeAuth
|
|
294
|
-
});
|
|
97
|
+
await registerAppNavigation(rootElement, path, { ...appRouteSource });
|
|
295
98
|
return;
|
|
296
99
|
}
|
|
297
100
|
mountOrUpdate(rootElement, resolved.kind === "deny" ? bindDeniedStatus(resolved.status) : bindResolvedRouteHandler({
|
|
298
101
|
handler: resolved.handler,
|
|
299
102
|
params: resolved.params
|
|
300
103
|
}), { cleanupStrict: config.cleanupStrict });
|
|
301
|
-
await registerAppNavigation(rootElement, path, {
|
|
302
|
-
manifest: config.manifest,
|
|
303
|
-
routes: config.routes,
|
|
304
|
-
auth: routeAuth
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Mark elements that should be skipped during hydration
|
|
309
|
-
*/
|
|
310
|
-
function markSkippedElements(root, skipSelectors) {
|
|
311
|
-
if (skipSelectors.length === 0) return;
|
|
312
|
-
const selectorList = Array.from(new Set(skipSelectors)).join(", ");
|
|
313
|
-
root.querySelectorAll(selectorList).forEach((el) => el.setAttribute("data-skip-hydrate", "true"));
|
|
314
|
-
}
|
|
315
|
-
function collectDeferredBelowFoldBoundaries(root, foldY) {
|
|
316
|
-
const boundaries = [];
|
|
317
|
-
const stack = [];
|
|
318
|
-
for (let index = root.children.length - 1; index >= 0; index -= 1) stack.push(root.children[index]);
|
|
319
|
-
while (stack.length > 0) {
|
|
320
|
-
const element = stack.pop();
|
|
321
|
-
if (element.hasAttribute("data-skip-hydrate")) continue;
|
|
322
|
-
if (element.getBoundingClientRect().top >= foldY) {
|
|
323
|
-
element.setAttribute("data-skip-hydrate", "true");
|
|
324
|
-
boundaries.push(element);
|
|
325
|
-
continue;
|
|
326
|
-
}
|
|
327
|
-
for (let index = element.children.length - 1; index >= 0; index -= 1) stack.push(element.children[index]);
|
|
328
|
-
}
|
|
329
|
-
return boundaries;
|
|
330
|
-
}
|
|
331
|
-
function activateVisibleDeferredBoundaries(boundaries, foldY) {
|
|
332
|
-
let activated = false;
|
|
333
|
-
let remaining = 0;
|
|
334
|
-
for (const element of boundaries) {
|
|
335
|
-
if (!element.hasAttribute("data-skip-hydrate")) continue;
|
|
336
|
-
if (element.getBoundingClientRect().top < foldY) {
|
|
337
|
-
element.removeAttribute("data-skip-hydrate");
|
|
338
|
-
activated = true;
|
|
339
|
-
} else remaining += 1;
|
|
340
|
-
}
|
|
341
|
-
return {
|
|
342
|
-
activated,
|
|
343
|
-
remaining
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
function queueIdleWork(work) {
|
|
347
|
-
return new Promise((resolve) => {
|
|
348
|
-
if (typeof requestIdleCallback !== "undefined") {
|
|
349
|
-
requestIdleCallback(() => {
|
|
350
|
-
work();
|
|
351
|
-
resolve();
|
|
352
|
-
}, { timeout: 2e3 });
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
setTimeout(() => {
|
|
356
|
-
work();
|
|
357
|
-
resolve();
|
|
358
|
-
}, 0);
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
function flushHydrationActivation(rootElement) {
|
|
362
|
-
const instance = instancesByRoot.get(rootElement);
|
|
363
|
-
if (!instance) return;
|
|
364
|
-
instance._enqueueRun?.();
|
|
365
|
-
globalScheduler.flush();
|
|
366
|
-
}
|
|
367
|
-
function shouldVerifyHydrationMarkup(config) {
|
|
368
|
-
const explicit = config.hydrate?.verifyMarkup;
|
|
369
|
-
if (typeof explicit === "boolean") return explicit;
|
|
370
|
-
return !isProductionEnvironment();
|
|
371
|
-
}
|
|
372
|
-
async function registerAppNavigation(rootElement, path, source) {
|
|
373
|
-
const instance = instancesByRoot.get(rootElement);
|
|
374
|
-
if (!instance) throw new Error("Internal error: app instance missing");
|
|
375
|
-
registerAppInstance(instance, path, source);
|
|
376
|
-
initializeNavigation();
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Apply selective hydration with deferral options
|
|
380
|
-
*/
|
|
381
|
-
async function applySelectiveHydration(rootElement, resolved, path, cleanupStrict, hydrateOptions) {
|
|
382
|
-
const hasPermanentSkips = (hydrateOptions.skipSelectors?.length ?? 0) > 0;
|
|
383
|
-
const hasBelowFoldDeferral = !!hydrateOptions.deferBelowFold;
|
|
384
|
-
const hasSelectiveBoundaries = hasPermanentSkips || hasBelowFoldDeferral;
|
|
385
|
-
let staticChildSlotsCacheSuspended = false;
|
|
386
|
-
let releaseSelectiveHydrationResources = () => {};
|
|
387
|
-
const restoreStaticChildSlotsCache = () => {
|
|
388
|
-
if (!staticChildSlotsCacheSuspended) return;
|
|
389
|
-
setStaticChildSlotsCacheEnabled(true);
|
|
390
|
-
staticChildSlotsCacheSuspended = false;
|
|
391
|
-
};
|
|
392
|
-
if (hydrateOptions.skipSelectors?.length) markSkippedElements(rootElement, hydrateOptions.skipSelectors);
|
|
393
|
-
let deferredBoundaries = [];
|
|
394
|
-
if (hydrateOptions.deferBelowFold) {
|
|
395
|
-
setStaticChildSlotsCacheEnabled(false);
|
|
396
|
-
staticChildSlotsCacheSuspended = true;
|
|
397
|
-
const foldY = hydrateOptions.foldThreshold ?? window.innerHeight;
|
|
398
|
-
deferredBoundaries = collectDeferredBelowFoldBoundaries(rootElement, foldY);
|
|
399
|
-
let selectiveHydrationResourcesReleased = false;
|
|
400
|
-
let unregisterRootCleanupCallback = () => {};
|
|
401
|
-
function handleScroll() {
|
|
402
|
-
const { activated, remaining } = activateVisibleDeferredBoundaries(deferredBoundaries, foldY);
|
|
403
|
-
if (!activated) return;
|
|
404
|
-
flushHydrationActivation(rootElement);
|
|
405
|
-
if (remaining === 0) releaseSelectiveHydrationResources();
|
|
406
|
-
}
|
|
407
|
-
releaseSelectiveHydrationResources = () => {
|
|
408
|
-
if (selectiveHydrationResourcesReleased) return;
|
|
409
|
-
selectiveHydrationResourcesReleased = true;
|
|
410
|
-
unregisterRootCleanupCallback();
|
|
411
|
-
window.removeEventListener("scroll", handleScroll);
|
|
412
|
-
restoreStaticChildSlotsCache();
|
|
413
|
-
};
|
|
414
|
-
unregisterRootCleanupCallback = registerRootCleanupCallback(rootElement, releaseSelectiveHydrationResources);
|
|
415
|
-
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
416
|
-
}
|
|
417
|
-
if (hydrateOptions.deferUntilIdle && !hasSelectiveBoundaries) {
|
|
418
|
-
await queueIdleWork(() => {
|
|
419
|
-
mountOrUpdate(rootElement, (() => resolved.handler(resolved.params)), { cleanupStrict });
|
|
420
|
-
});
|
|
421
|
-
await registerAppNavigation(rootElement, path);
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
try {
|
|
425
|
-
mountOrUpdate(rootElement, (() => resolved.handler(resolved.params)), { cleanupStrict });
|
|
426
|
-
await registerAppNavigation(rootElement, path);
|
|
427
|
-
} catch (error) {
|
|
428
|
-
releaseSelectiveHydrationResources();
|
|
429
|
-
throw error;
|
|
430
|
-
}
|
|
431
|
-
if (hydrateOptions.deferUntilIdle && deferredBoundaries.length > 0) await queueIdleWork(() => {
|
|
432
|
-
try {
|
|
433
|
-
const { activated } = activateVisibleDeferredBoundaries(deferredBoundaries, Number.POSITIVE_INFINITY);
|
|
434
|
-
if (activated) flushHydrationActivation(rootElement);
|
|
435
|
-
} finally {
|
|
436
|
-
releaseSelectiveHydrationResources();
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
if (deferredBoundaries.length === 0) releaseSelectiveHydrationResources();
|
|
104
|
+
await registerAppNavigation(rootElement, path, { ...appRouteSource });
|
|
440
105
|
}
|
|
441
106
|
/**
|
|
442
107
|
* hydrateSPA: Hydrate server-rendered HTML.
|
|
@@ -445,37 +110,49 @@ async function applySelectiveHydration(rootElement, resolved, path, cleanupStric
|
|
|
445
110
|
async function hydrateSPA(config) {
|
|
446
111
|
assertExecutionModel("spa");
|
|
447
112
|
if (!config || typeof config !== "object") throw new Error("hydrateSPA requires a config object");
|
|
448
|
-
const
|
|
449
|
-
const
|
|
113
|
+
const manifest = config.manifest ?? config.registry?.manifest;
|
|
114
|
+
const routeTable = config.routes ?? config.registry?.routes;
|
|
115
|
+
const hasManifest = manifest != null && manifest.records.length > 0;
|
|
116
|
+
const hasRoutes = Array.isArray(routeTable) && routeTable.length > 0;
|
|
450
117
|
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.");
|
|
451
118
|
const rootElement = typeof config.root === "string" ? document.getElementById(config.root) : config.root;
|
|
452
119
|
if (!rootElement) throw new Error(`Root element not found: ${config.root}`);
|
|
453
120
|
const hydrationRenderData = takeHydrationRenderData(rootElement);
|
|
454
|
-
const pendingLazyAtHydrationBoot = _snapshotLazy()
|
|
121
|
+
const pendingLazyAtHydrationBoot = [..._snapshotLazy(), ..._snapshotRouteSourceLazy({
|
|
122
|
+
registry: config.registry,
|
|
123
|
+
manifest
|
|
124
|
+
})];
|
|
455
125
|
configureScrollRestoration(config.scrollRestoration);
|
|
456
126
|
clearRoutes();
|
|
457
|
-
if (hasManifest) _applyManifest(
|
|
458
|
-
else for (const r of
|
|
459
|
-
|
|
127
|
+
if (hasManifest) _applyManifest(manifest);
|
|
128
|
+
else for (const r of routeTable) route(r.path, r.handler);
|
|
129
|
+
const routeAuth = config.auth ?? manifest?.auth;
|
|
130
|
+
const appRouteSource = {
|
|
131
|
+
manifest: hasManifest ? manifest : void 0,
|
|
132
|
+
routes: hasManifest ? void 0 : routeTable,
|
|
133
|
+
auth: routeAuth
|
|
134
|
+
};
|
|
135
|
+
_setActiveRouteAuthOptions(routeAuth);
|
|
460
136
|
await _drainLazy(pendingLazyAtHydrationBoot);
|
|
461
|
-
const { path, href: currentUrl, resolved } = await resolveInitialRoute(
|
|
137
|
+
const { path, href: currentUrl, resolved } = await resolveInitialRoute(routeAuth);
|
|
462
138
|
setServerLocation(currentUrl);
|
|
463
139
|
if (isProductionEnvironment()) lockRouteRegistration();
|
|
464
140
|
if (!resolved) throw new Error(`hydrateSPA: no route found for current path (${path}).`);
|
|
465
141
|
if (resolved.kind === "redirect") throw new Error(`hydrateSPA: unresolved redirect for current path (${path}).`);
|
|
466
142
|
const hydrationResolved = resolved.kind === "deny" ? {
|
|
467
|
-
handler:
|
|
143
|
+
handler: bindDeniedRouteHandler(resolved.status),
|
|
468
144
|
params: {}
|
|
469
145
|
} : {
|
|
470
146
|
handler: resolved.handler,
|
|
471
147
|
params: resolved.params
|
|
472
148
|
};
|
|
473
149
|
if (shouldVerifyHydrationMarkup(config)) {
|
|
474
|
-
const legacyRouteTable = hasManifest ?
|
|
150
|
+
const legacyRouteTable = hasManifest ? manifest.records.map((r) => ({
|
|
151
|
+
...r,
|
|
475
152
|
path: r.path,
|
|
476
153
|
handler: r.handler,
|
|
477
154
|
namespace: r.options.namespace
|
|
478
|
-
})) :
|
|
155
|
+
})) : routeTable;
|
|
479
156
|
const { verifyHydrationSyncForUrl } = await import("../ssr/verify-hydration.js");
|
|
480
157
|
if (!verifyHydrationSyncForUrl({
|
|
481
158
|
root: rootElement,
|
|
@@ -490,7 +167,12 @@ async function hydrateSPA(config) {
|
|
|
490
167
|
if (hydrateOptions.deferUntilIdle || hydrateOptions.deferBelowFold) {
|
|
491
168
|
if (hydrationRenderData) startHydrationRenderPhase(hydrationRenderData);
|
|
492
169
|
try {
|
|
493
|
-
await applySelectiveHydration(rootElement, hydrationResolved, path, config.cleanupStrict, hydrateOptions
|
|
170
|
+
await applySelectiveHydration(rootElement, hydrationResolved, path, config.cleanupStrict, hydrateOptions, appRouteSource, {
|
|
171
|
+
mountOrUpdate,
|
|
172
|
+
registerAppNavigation,
|
|
173
|
+
registerRootCleanupCallback,
|
|
174
|
+
flushHydrationActivation
|
|
175
|
+
});
|
|
494
176
|
} finally {
|
|
495
177
|
if (hydrationRenderData) stopHydrationRenderPhase();
|
|
496
178
|
}
|
|
@@ -504,37 +186,7 @@ async function hydrateSPA(config) {
|
|
|
504
186
|
} finally {
|
|
505
187
|
if (hydrationRenderData) stopHydrationRenderPhase();
|
|
506
188
|
}
|
|
507
|
-
await registerAppNavigation(rootElement, path, {
|
|
508
|
-
manifest: config.manifest,
|
|
509
|
-
routes: config.routes,
|
|
510
|
-
auth: config.auth ?? config.manifest?.auth
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Cleanup an app mounted on a root element (element or id).
|
|
515
|
-
* Safe to call multiple times — no-op when nothing is mounted.
|
|
516
|
-
*/
|
|
517
|
-
function cleanupApp(root) {
|
|
518
|
-
const rootElement = typeof root === "string" ? document.getElementById(root) : root;
|
|
519
|
-
if (!rootElement) return;
|
|
520
|
-
const cleanupFn = rootElement[CLEANUP_SYMBOL];
|
|
521
|
-
try {
|
|
522
|
-
if (typeof cleanupFn === "function") cleanupFn();
|
|
523
|
-
} finally {
|
|
524
|
-
instancesByRoot.delete(rootElement);
|
|
525
|
-
clearRootCleanupCallbacks(rootElement);
|
|
526
|
-
try {
|
|
527
|
-
delete rootElement[CLEANUP_SYMBOL];
|
|
528
|
-
} catch {}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Check whether an app is mounted on the given root
|
|
533
|
-
*/
|
|
534
|
-
function hasApp(root) {
|
|
535
|
-
const rootElement = typeof root === "string" ? document.getElementById(root) : root;
|
|
536
|
-
if (!rootElement) return false;
|
|
537
|
-
return instancesByRoot.has(rootElement);
|
|
189
|
+
await registerAppNavigation(rootElement, path, { ...appRouteSource });
|
|
538
190
|
}
|
|
539
191
|
//#endregion
|
|
540
192
|
export { cleanupApp, createIsland, createIslands, createSPA, hasApp, hydrateSPA };
|