@askrjs/askr 0.0.92 → 0.0.95
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/CHANGELOG.md +5 -0
- package/README.md +3 -1
- package/dist/{access-DSkccuEI.js → access-d_DCdwqn.js} +3 -0
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.js +3 -2
- package/dist/{activity-DxUcygE5.d.ts → activity-D_5x2HXQ.d.ts} +5 -1
- package/dist/{activity-DodHdC0L.js → activity-d4t3CdzK.js} +4 -2
- package/dist/benchmark.d.ts +1 -1
- package/dist/benchmark.js +8 -8
- package/dist/boot/index.d.ts +12 -3
- package/dist/boot/index.js +1 -1
- package/dist/{boot-D71bjP4r.js → boot-C1wT3Vfs.js} +23 -15
- package/dist/{cleanup-DAAhJjx5.js → cleanup-D7uN-Z1s.js} +4 -4
- package/dist/{component-cleanup-CJCfu5ed.js → component-cleanup-DYG80yhG.js} +4 -2
- package/dist/{component-internal-DlAkCgBE.js → component-internal-D0yE2Ch3.js} +79 -13
- package/dist/components/index.d.ts +11 -3
- package/dist/components/index.js +5 -2
- package/dist/{compose-ref-Cc_YkUpM.js → compose-ref-1Fhs7mbF.js} +13 -0
- package/dist/{compose-ref-Cizq72-x.d.ts → compose-ref-DOJHoW5X.d.ts} +3 -0
- package/dist/control/index.d.ts +1 -1
- package/dist/control/index.js +1 -1
- package/dist/{control-Dv540XtV.js → control-C0klPV7Q.js} +9 -5
- package/dist/{control-CdzY49Q2.d.ts → control-DdFw-Caz.d.ts} +1 -1
- package/dist/{csp-nonce-ByMbWv8s.js → csp-nonce-BVybpV1v.js} +8 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.js +3 -3
- package/dist/{data-DcikEH9N.js → data-Bm8L6JOm.js} +15 -4
- package/dist/{data-runtime-oIdQWnPW.js → data-runtime-JxoRgrrt.js} +2 -0
- package/dist/{deferred-B6CafO5u.js → deferred-p8hyanxJ.js} +8 -3
- package/dist/{effect-BdZcHblj.js → effect-BdvdgMvV.js} +2 -2
- package/dist/{fastlane-B2s24fWt.js → fastlane-DGo7SxBQ.js} +3 -3
- package/dist/{for-internal-T1C7jd7x.js → for-internal-DkBwTG4S.js} +5 -5
- package/dist/foundations/icon/index.d.ts +14 -2
- package/dist/foundations/icon/index.js +8 -0
- package/dist/foundations/index.d.ts +2 -2
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/index.d.ts +18 -2
- package/dist/foundations/interactions/index.js +1 -1
- package/dist/foundations/state/index.d.ts +8 -1
- package/dist/foundations/state/index.js +7 -1
- package/dist/foundations/structures/index.d.ts +2 -2
- package/dist/foundations/structures/index.js +1 -1
- package/dist/foundations/utilities/index.d.ts +2 -2
- package/dist/foundations/utilities/index.js +1 -1
- package/dist/fx/index.d.ts +10 -1
- package/dist/fx/index.js +7 -1
- package/dist/{index-DA3g8lm8.d.ts → index-CTIBOqUB.d.ts} +418 -5
- package/dist/{index-BnU0NPwM.d.ts → index-CzH-0LcA.d.ts} +18 -0
- package/dist/{index-oswRaMn6.d.ts → index-S2IqSJib.d.ts} +30 -2
- package/dist/index.d.ts +3 -4
- package/dist/index.js +13 -12
- package/dist/{interactions-CWkNEq_C.js → interactions-B4XaFxt1.js} +6 -1
- package/dist/{jsx-C3IECePB.js → jsx-DRS-qjiN.js} +2 -0
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime-BTzDdBJ_.d.ts +2 -0
- package/dist/{jsx-runtime-Cfb2umb4.d.ts → jsx-runtime-Cdd6Gkb0.d.ts} +4 -2
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +1 -1
- package/dist/{lifecycle-batch-Cyfd07rf.js → lifecycle-batch-BH0fax4F.js} +2 -2
- package/dist/{lifecycle-operations-CQ8fsc94.js → lifecycle-operations-CBzG5PyB.js} +6 -1
- package/dist/{manifest-Dv0bO6kg.js → manifest-D6rfj_jC.js} +4 -0
- package/dist/{navigate-BbWj-QU-.js → navigate-DChM5m8m.js} +13 -10
- package/dist/{navigate-CZHPEUC4.d.ts → navigate-eGm4omPj.d.ts} +6 -1
- package/dist/{query-registry-qm13pEdK.js → query-registry-CimB1YeW.js} +11 -1
- package/dist/{readable-B99wh5Z_.js → readable-BsdGWsDE.js} +1 -1
- package/dist/{renderer-C6jz9nIN.js → renderer-tXX_xj86.js} +10 -37
- package/dist/{resolution-B21kmOkp.js → resolution-BQyo7qNn.js} +11 -5
- package/dist/{resource-operation-CaAttQqz.js → resource-operation-B62UQKHV.js} +4 -4
- package/dist/resources/index.d.ts +15 -2
- package/dist/resources/index.js +6 -5
- package/dist/router/index.d.ts +46 -4
- package/dist/router/index.js +15 -8
- package/dist/{selector-BLWwI55m.js → selector-CyK-sDwB.js} +4 -3
- package/dist/ssg/index.d.ts +5 -1
- package/dist/ssg/index.js +5 -5
- package/dist/ssr/index.d.ts +16 -3
- package/dist/ssr/index.js +1 -1
- package/dist/{ssr-CaZfvQWn.js → ssr-DYcK20IX.js} +18 -10
- package/dist/{state-XPZYUzHL.js → state-DmkGM_LN.js} +3 -3
- package/dist/{structures-DKjkAmM5.js → structures-CPycoyZj.js} +63 -14
- package/dist/testing/index.d.ts +31 -2
- package/dist/testing/index.js +23 -5
- package/dist/{types-BA9FJtfR.d.ts → types-DkVJhVs9.d.ts} +4 -0
- package/dist/{verify-hydration-CcF-HJil.js → verify-hydration-m-wVbYOD.js} +1 -1
- package/package.json +1 -1
- package/dist/index-2bk8nldG.d.ts +0 -241
- package/dist/jsx-runtime-C_0v1pMN.d.ts +0 -2
- package/dist/scheduler-CmLO4Dfm.d.ts +0 -65
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { n as Fragment, t as ELEMENT_TYPE } from "./jsx-
|
|
2
|
-
import {
|
|
3
|
-
import { p as isPromiseLike } from "./lifecycle-batch-
|
|
1
|
+
import { n as Fragment, t as ELEMENT_TYPE } from "./jsx-DRS-qjiN.js";
|
|
2
|
+
import { p as defineScope, y as readScope } from "./component-internal-D0yE2Ch3.js";
|
|
3
|
+
import { p as isPromiseLike } from "./lifecycle-batch-BH0fax4F.js";
|
|
4
4
|
import { S as withPageFramework, b as replacePageRoute, n as getActiveRenderContext } from "./render-context-B7ohlh6t.js";
|
|
5
|
-
import { i as ROUTE_ROOT_COMPONENT } from "./csp-nonce-
|
|
6
|
-
import { c as withTelemetry, t as createQueryPrefetchContext } from "./query-registry-
|
|
5
|
+
import { i as ROUTE_ROOT_COMPONENT } from "./csp-nonce-BVybpV1v.js";
|
|
6
|
+
import { c as withTelemetry, t as createQueryPrefetchContext } from "./query-registry-CimB1YeW.js";
|
|
7
7
|
import { c as removeRouteBasePath, i as getMatchingRouteRecord, l as buildRouteContext, o as addRouteBasePath, s as normalizeRouteBasePath, u as buildRouteContextBase, v as getActiveRouteAuthOptions } from "./route-matching-Bo6UqG-5.js";
|
|
8
8
|
//#region src/router/route-data-loader.ts
|
|
9
|
+
/** Thrown when a route's `loader` rejects; wraps the original `cause`. */
|
|
9
10
|
var RouteDataLoadError = class extends Error {
|
|
10
11
|
constructor(route, phase, cause) {
|
|
11
12
|
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -48,6 +49,7 @@ function startLazyLoad(state) {
|
|
|
48
49
|
pendingLazy.add(promise);
|
|
49
50
|
return promise;
|
|
50
51
|
}
|
|
52
|
+
/** Wrap a dynamic-import factory as a {@link LazyRouteComponent}, loaded on first use. */
|
|
51
53
|
function lazy(factory) {
|
|
52
54
|
const state = {
|
|
53
55
|
factory,
|
|
@@ -99,6 +101,7 @@ function _preloadRouteHandler(handler) {
|
|
|
99
101
|
//#endregion
|
|
100
102
|
//#region src/router/rendering.ts
|
|
101
103
|
const outletScope = defineScope(null);
|
|
104
|
+
/** Renders the nested route content for the enclosing layout or page scope. */
|
|
102
105
|
function Outlet() {
|
|
103
106
|
return {
|
|
104
107
|
$$typeof: ELEMENT_TYPE,
|
|
@@ -166,6 +169,7 @@ function setCurrentAuth(context) {
|
|
|
166
169
|
//#region src/common/deferred-value.ts
|
|
167
170
|
const DEFERRED_VALUE = Symbol.for("@askrjs/askr/deferred-value");
|
|
168
171
|
const DEFERRED_BOUNDARY = Symbol.for("@askrjs/askr/deferred-boundary");
|
|
172
|
+
/** Wrap a promise as a {@link Deferred} value that tracks its settled state and result. */
|
|
169
173
|
function defer(promise) {
|
|
170
174
|
let state = "pending";
|
|
171
175
|
let value;
|
|
@@ -195,6 +199,7 @@ function defer(promise) {
|
|
|
195
199
|
[DEFERRED_VALUE]: { value: true }
|
|
196
200
|
}));
|
|
197
201
|
}
|
|
202
|
+
/** Check whether `value` is a {@link Deferred} produced by {@link defer}. */
|
|
198
203
|
function isDeferred(value) {
|
|
199
204
|
if (!value || typeof value !== "object") return false;
|
|
200
205
|
const marker = Object.getOwnPropertyDescriptor(value, DEFERRED_VALUE);
|
|
@@ -510,6 +515,7 @@ function resolveMatchedRoute(record, params, context, authOptions, request, tele
|
|
|
510
515
|
const decision = record.options.auth(context.auth);
|
|
511
516
|
return isPromiseLike(decision) ? Promise.resolve(decision).then(continueResolution) : continueResolution(decision);
|
|
512
517
|
}
|
|
518
|
+
/** Resolve `target` against a route registry, applying auth/policies to produce a render/redirect/deny result. */
|
|
513
519
|
function resolveRouteRequest(target, options) {
|
|
514
520
|
if (!options?.registry) throw new TypeError("resolveRouteRequest requires options.registry.");
|
|
515
521
|
const basePath = normalizeRouteBasePath(options.registry.manifest.basePath);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as enqueueRuntimeLane, y as logger } from "./access-
|
|
1
|
+
import { t as enqueueRuntimeLane, y as logger } from "./access-d_DCdwqn.js";
|
|
2
2
|
import { f as getCurrentComponentInstance } from "./component-scope-4I3yEMkb.js";
|
|
3
|
-
import {
|
|
4
|
-
import { p as isPromiseLike } from "./lifecycle-batch-
|
|
3
|
+
import { m as getCurrentContextFrame, u as registerCommitOperationForInstance, x as withAsyncResourceContext } from "./component-internal-D0yE2Ch3.js";
|
|
4
|
+
import { p as isPromiseLike } from "./lifecycle-batch-BH0fax4F.js";
|
|
5
5
|
import { t as brandSnapshotSource } from "./snapshot-source-BB42xgwb.js";
|
|
6
6
|
import { C as SSRDataMissingError, a as getResourceVerificationSnapshot, i as getNextRenderKey, n as getActiveRenderContext, o as isHydrationVerificationRender, p as throwSSRDataMissing, r as getCurrentRenderData, s as recordResourceVerificationSnapshot } from "./render-context-B7ohlh6t.js";
|
|
7
|
-
import { t as state } from "./state-
|
|
7
|
+
import { t as state } from "./state-DmkGM_LN.js";
|
|
8
8
|
//#region src/runtime/resource-cell.ts
|
|
9
9
|
/**
|
|
10
10
|
* Pure, component-agnostic ResourceCell state machine.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as onRouteChange, n as RouteChangeOptions, t as RouteChangeCleanup } from "../activity-
|
|
1
|
+
import { Z as getSignal } from "../index-CTIBOqUB.js";
|
|
2
|
+
import { i as onRouteChange, n as RouteChangeOptions, t as RouteChangeCleanup } from "../activity-D_5x2HXQ.js";
|
|
3
3
|
//#region src/runtime/resource-operation.d.ts
|
|
4
|
+
/** Reactive result of a {@link resource}: current value, loading state, and controls. */
|
|
4
5
|
interface ResourceResult<T> {
|
|
5
6
|
value: T | null;
|
|
6
7
|
pending: boolean;
|
|
@@ -13,7 +14,9 @@ declare function resource<T, const TDeps extends readonly unknown[]>(fn: (opts:
|
|
|
13
14
|
}) => PromiseLike<T> | T, deps: TDeps): ResourceResult<T>;
|
|
14
15
|
//#endregion
|
|
15
16
|
//#region src/runtime/stream-operation.d.ts
|
|
17
|
+
/** Connection status of a {@link stream}. */
|
|
16
18
|
type StreamStatus = 'connecting' | 'connected' | 'reconnecting' | 'closed' | 'error';
|
|
19
|
+
/** Reactive result of a {@link stream}: current value, connection status, and controls. */
|
|
17
20
|
interface StreamResult<T> {
|
|
18
21
|
value: T | null;
|
|
19
22
|
status: StreamStatus;
|
|
@@ -23,6 +26,7 @@ interface StreamResult<T> {
|
|
|
23
26
|
restart(): void;
|
|
24
27
|
close(): void;
|
|
25
28
|
}
|
|
29
|
+
/** Options for {@link stream}. */
|
|
26
30
|
interface StreamOptions<T> {
|
|
27
31
|
deps?: readonly unknown[];
|
|
28
32
|
initialValue?: T;
|
|
@@ -30,19 +34,28 @@ interface StreamOptions<T> {
|
|
|
30
34
|
type StreamSource<T> = (context: {
|
|
31
35
|
signal: AbortSignal;
|
|
32
36
|
}) => AsyncIterable<T> | PromiseLike<AsyncIterable<T>>;
|
|
37
|
+
/** Subscribe to a streaming data source for the current component's lifetime, with auto reconnect/cleanup. */
|
|
33
38
|
declare function stream<T>(source: StreamSource<T>, options?: StreamOptions<T>): StreamResult<T>;
|
|
34
39
|
//#endregion
|
|
35
40
|
//#region src/runtime/lifecycle-operations.d.ts
|
|
41
|
+
/** A gating condition for lifecycle primitives like {@link timer}; `true` means active. */
|
|
36
42
|
type ActivityPredicate = () => boolean;
|
|
43
|
+
/** Options for {@link timer}. */
|
|
37
44
|
interface TimerOptions {
|
|
38
45
|
when?: ActivityPredicate | readonly ActivityPredicate[];
|
|
39
46
|
}
|
|
47
|
+
/** {@link ActivityPredicate} that is true while the current route matches `pathOrPaths`. */
|
|
40
48
|
declare function routeActive(pathOrPaths: string | readonly string[]): ActivityPredicate;
|
|
49
|
+
/** {@link ActivityPredicate} that is true while the document is visible. */
|
|
41
50
|
declare function documentVisible(): ActivityPredicate;
|
|
51
|
+
/** {@link ActivityPredicate} that is true while the window has focus. */
|
|
42
52
|
declare function windowFocused(): ActivityPredicate;
|
|
53
|
+
/** An event target, or a function resolving one, accepted by {@link on}. */
|
|
43
54
|
type ListenerTarget = EventTarget | (() => EventTarget | null | undefined);
|
|
44
55
|
type ListenerOptions = boolean | AddEventListenerOptions | undefined;
|
|
56
|
+
/** Attach an owned event listener to `target` for the current component's lifetime. */
|
|
45
57
|
declare function on(target: ListenerTarget, event: string, handler: EventListener, options?: ListenerOptions): void;
|
|
58
|
+
/** Run `fn` on an owned interval for the current component's lifetime, optionally gated by `options.when`. */
|
|
46
59
|
declare function timer(intervalMs: number, fn: () => void, options?: TimerOptions): void;
|
|
47
60
|
/** Runs an owned task after commit. */
|
|
48
61
|
declare function task(fn: () => void | (() => void) | PromiseLike<void | (() => void)>): void;
|
package/dist/resources/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as enqueueRuntimeLane } from "../access-
|
|
1
|
+
import { t as enqueueRuntimeLane } from "../access-d_DCdwqn.js";
|
|
2
2
|
import { f as getCurrentComponentInstance, g as getSignal, i as claimHookIndex } from "../component-scope-4I3yEMkb.js";
|
|
3
|
-
import { a as registerCommitOperation } from "../component-internal-
|
|
4
|
-
import { t as resource } from "../resource-operation-
|
|
5
|
-
import { a as task, i as routeActive, n as documentVisible, o as timer, r as on, s as windowFocused, t as capture } from "../lifecycle-operations-
|
|
6
|
-
import { n as onRouteChange } from "../activity-
|
|
3
|
+
import { a as registerCommitOperation } from "../component-internal-D0yE2Ch3.js";
|
|
4
|
+
import { t as resource } from "../resource-operation-B62UQKHV.js";
|
|
5
|
+
import { a as task, i as routeActive, n as documentVisible, o as timer, r as on, s as windowFocused, t as capture } from "../lifecycle-operations-CBzG5PyB.js";
|
|
6
|
+
import { n as onRouteChange } from "../activity-d4t3CdzK.js";
|
|
7
7
|
//#region src/runtime/stream-operation.ts
|
|
8
8
|
function toError(value) {
|
|
9
9
|
return value instanceof Error ? value : new Error(String(value));
|
|
@@ -205,6 +205,7 @@ function getStreamSlot(instance, index, source, options) {
|
|
|
205
205
|
slots[index] = slot;
|
|
206
206
|
return slot;
|
|
207
207
|
}
|
|
208
|
+
/** Subscribe to a streaming data source for the current component's lifetime, with auto reconnect/cleanup. */
|
|
208
209
|
function stream(source, options = {}) {
|
|
209
210
|
const instance = getCurrentComponentInstance();
|
|
210
211
|
if (!instance) return createSnapshot(options);
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { r as JSXElement, s as Props } from "../types-
|
|
3
|
-
import { a as ScrollRestorationOptions, i as NavigationScrollBehavior, n as NavigateOptions, r as HistoryScrollBehavior, t as navigate } from "../navigate-
|
|
4
|
-
import { i as onRouteChange, n as RouteChangeOptions, r as currentRoute, t as RouteChangeCleanup } from "../activity-
|
|
1
|
+
import { $ as AccessDecision, At as RouteRegistry, Ct as RouteParams, Dt as RouteRecord, Et as RouteQuery, Ft as RouteSearch, It as RouteSearchValue, Lt as RouteSnapshot, Mt as RouteRenderResult, Nt as RouteRequestOptions, Ot as RouteRef, Pt as RouteRequestResult, Q as AccessAllowDecision, St as RouteOptions, Tt as RoutePolicy, _t as RouteManifest, at as LayoutScopeRecord, bt as RouteMetaSource, ct as ParsedSegment, dt as RouteAuthResolver, et as AccessDenyDecision, ft as RouteComponent, gt as RouteHandler, ht as RouteDestination, it as GroupHelperOptions, jt as RouteRegistryOptions, kt as RouteRefSearch, lt as Route, mt as RouteDefinition, nt as AccessRedirectDecision, ot as PageHelperOptions, pt as RouteContext, rn as RenderableChild, rt as AccessRedirectStatus, st as PageScopeRecord, tt as AccessDenyStatus, ut as RouteAuthOptions, vt as RouteMatch, wt as RoutePathParams, xt as RouteMode, yt as RouteMeta } from "../index-CTIBOqUB.js";
|
|
2
|
+
import { r as JSXElement, s as Props } from "../types-DkVJhVs9.js";
|
|
3
|
+
import { a as ScrollRestorationOptions, i as NavigationScrollBehavior, n as NavigateOptions, r as HistoryScrollBehavior, t as navigate } from "../navigate-eGm4omPj.js";
|
|
4
|
+
import { i as onRouteChange, n as RouteChangeOptions, r as currentRoute, t as RouteChangeCleanup } from "../activity-D_5x2HXQ.js";
|
|
5
5
|
import { AuthContext, AuthContext as AuthContext$1, AuthRequirement, AuthRequirement as AuthRequirement$1 } from "@askrjs/auth";
|
|
6
6
|
import { ObjectSchema } from "@askrjs/schema";
|
|
7
7
|
//#region src/router/route-query.d.ts
|
|
8
|
+
/** A single query-string value accepted by {@link updateRouteQuery}. */
|
|
8
9
|
type RouteQueryParamValue = string | number | boolean | null | undefined;
|
|
10
|
+
/** A query-string value, or an array of them for a repeated param. */
|
|
9
11
|
type RouteQueryParamInput = RouteQueryParamValue | readonly RouteQueryParamValue[];
|
|
12
|
+
/** A map of query param updates for {@link updateRouteQuery}; `null`/`undefined` removes the key. */
|
|
10
13
|
type RouteQueryUpdates = Record<string, RouteQueryParamInput>;
|
|
14
|
+
/** A function that mutates a `URLSearchParams` directly, for {@link updateRouteQuery}. */
|
|
11
15
|
type RouteQueryUpdater = (searchParams: URLSearchParams) => void;
|
|
16
|
+
/** Options for {@link updateRouteQuery}. */
|
|
12
17
|
type UpdateRouteQueryOptions = {
|
|
13
18
|
/**
|
|
14
19
|
* Defaults to replace so high-frequency controls such as search inputs do not
|
|
@@ -28,13 +33,21 @@ type CompatibleAbsoluteRouteComponent<Path extends string, TComponent extends An
|
|
|
28
33
|
type CompatibleRelativeRouteComponent<Path extends string, TComponent extends AnyRouteComponent> = Parameters<TComponent> extends [] ? TComponent : RouteComponentParam<TComponent> extends Record<keyof RoutePathParams<Path>, string> ? TComponent : never;
|
|
29
34
|
type CompatibleRouteComponent<Path extends string, TComponent extends AnyRouteComponent> = Path extends `/${string}` ? CompatibleAbsoluteRouteComponent<Path, TComponent> : CompatibleRelativeRouteComponent<Path, TComponent>;
|
|
30
35
|
type RouteOptionsForComponent<Path extends string, TComponent extends AnyRouteComponent, TSearchSchema extends ObjectSchema<RouteSearch> | undefined = ObjectSchema<RouteSearch> | undefined, TLoaderData = unknown, TDehydratedData = TLoaderData> = Parameters<TComponent> extends [] ? RouteOptions<RoutePathParams<Path>, TSearchSchema, TLoaderData, TDehydratedData> : RouteComponentParam<TComponent> extends RouteParams ? RouteOptions<RouteComponentParam<TComponent>, TSearchSchema, TLoaderData, TDehydratedData> : RouteOptions<RoutePathParams<Path>, TSearchSchema, TLoaderData, TDehydratedData>;
|
|
36
|
+
/** Declare a group of routes sharing `options` (auth, policies, layout, meta). */
|
|
31
37
|
declare function group(options: GroupHelperOptions, fn: RouteDefinition): void;
|
|
38
|
+
/**
|
|
39
|
+
* Declare a route page at `path`, nesting a sub-scope for `index`/`page`/`fallback`
|
|
40
|
+
* declarations and options like `preload`/`meta`/`auth`.
|
|
41
|
+
*/
|
|
32
42
|
declare function page<const TPath extends string>(path: TPath, Component: RouteComponent<RoutePathParams<TPath>>, fn: RouteDefinition): void;
|
|
33
43
|
declare function page<const TPath extends string, TComponent extends AnyRouteComponent>(path: TPath, Component: CompatibleRouteComponent<TPath, TComponent>, fn: RouteDefinition): void;
|
|
34
44
|
declare function page<const TPath extends string>(path: TPath, Component: RouteComponent<RoutePathParams<TPath>>, options: PageHelperOptions, fn: RouteDefinition): void;
|
|
35
45
|
declare function page<const TPath extends string, TComponent extends AnyRouteComponent>(path: TPath, Component: CompatibleRouteComponent<TPath, TComponent>, options: PageHelperOptions, fn: RouteDefinition): void;
|
|
46
|
+
/** Declare the index route for the enclosing `page()` scope. */
|
|
36
47
|
declare function index(Component: RouteComponent, options?: RouteOptions): void;
|
|
48
|
+
/** Declare the catch-all `/*` fallback route for the enclosing scope. */
|
|
37
49
|
declare function fallback(Component: RouteComponent): void;
|
|
50
|
+
/** Declare a route at `path` rendering `Component`, returning a typed {@link RouteRef} for building destinations. */
|
|
38
51
|
declare function route<const TPath extends string, const TSearchSchema extends ObjectSchema<RouteSearch> | undefined = undefined, TLoaderData = unknown, TDehydratedData = TLoaderData>(path: TPath, Component: RouteComponent<RoutePathParams<TPath>>, options?: RouteOptions<RoutePathParams<TPath>, TSearchSchema, TLoaderData, TDehydratedData>): RouteRef<RoutePathParams<TPath>, RouteRefSearch<TSearchSchema>>;
|
|
39
52
|
declare function route<const TPath extends string, TComponent extends AnyRouteComponent, const TSearchSchema extends ObjectSchema<RouteSearch> | undefined = undefined, TLoaderData = unknown, TDehydratedData = TLoaderData>(path: TPath, Component: CompatibleRouteComponent<TPath, TComponent>, options?: RouteOptionsForComponent<TPath, TComponent, TSearchSchema, TLoaderData, TDehydratedData>): RouteRef<RoutePathParams<TPath>, RouteRefSearch<TSearchSchema>>;
|
|
40
53
|
//#endregion
|
|
@@ -43,20 +56,28 @@ declare function route<const TPath extends string, TComponent extends AnyRouteCo
|
|
|
43
56
|
declare function currentAuth(): AuthContext$1;
|
|
44
57
|
//#endregion
|
|
45
58
|
//#region src/router/resolution.d.ts
|
|
59
|
+
/** Resolve `target` against a route registry, applying auth/policies to produce a render/redirect/deny result. */
|
|
46
60
|
declare function resolveRouteRequest(target: string, options: RouteRequestOptions): RouteRequestResult | Promise<RouteRequestResult>;
|
|
47
61
|
//#endregion
|
|
48
62
|
//#region src/router/manifest.d.ts
|
|
63
|
+
/**
|
|
64
|
+
* Run `definition` to declare routes (via `route`/`page`/`group`/`fallback`)
|
|
65
|
+
* and build a {@link RouteRegistry} to pass to `createSPA`/`hydrateSPA`.
|
|
66
|
+
*/
|
|
49
67
|
declare function createRouteRegistry(definition: RouteDefinition, options?: RouteRegistryOptions): RouteRegistry;
|
|
50
68
|
//#endregion
|
|
51
69
|
//#region src/router/lazy.d.ts
|
|
70
|
+
/** A route component loaded on demand via {@link lazy}, with an explicit `preload()`. */
|
|
52
71
|
type LazyRouteComponent<TComponent extends AnyRouteComponent> = TComponent & {
|
|
53
72
|
preload(): Promise<void>;
|
|
54
73
|
};
|
|
74
|
+
/** A route data loader loaded on demand via {@link lazyRouteData}, with an explicit `preload()`. */
|
|
55
75
|
type LazyRouteDataLoader<TModule, TData = TModule> = ((context: RouteContext & {
|
|
56
76
|
request?: Request;
|
|
57
77
|
}) => Promise<TData>) & {
|
|
58
78
|
preload(): Promise<void>;
|
|
59
79
|
};
|
|
80
|
+
/** Wrap a dynamic-import factory as a {@link LazyRouteComponent}, loaded on first use. */
|
|
60
81
|
declare function lazy<TComponent extends AnyRouteComponent>(factory: () => Promise<{
|
|
61
82
|
default: TComponent;
|
|
62
83
|
} | TComponent>): LazyRouteComponent<TComponent>;
|
|
@@ -69,10 +90,13 @@ declare function lazyRouteData<TModule, TData = TModule>(factory: () => PromiseL
|
|
|
69
90
|
}) => TData | PromiseLike<TData>): LazyRouteDataLoader<TModule, TData>;
|
|
70
91
|
//#endregion
|
|
71
92
|
//#region src/router/rendering.d.ts
|
|
93
|
+
/** Renders the nested route content for the enclosing layout or page scope. */
|
|
72
94
|
declare function Outlet(): JSXElement;
|
|
73
95
|
//#endregion
|
|
74
96
|
//#region src/router/route-data-loader.d.ts
|
|
97
|
+
/** Which environment a route's data loader ran (or failed) in. */
|
|
75
98
|
type RouteDataLoadPhase = 'client' | 'server' | 'ssg';
|
|
99
|
+
/** Thrown when a route's `loader` rejects; wraps the original `cause`. */
|
|
76
100
|
declare class RouteDataLoadError extends Error {
|
|
77
101
|
readonly route: string;
|
|
78
102
|
readonly phase: RouteDataLoadPhase;
|
|
@@ -81,28 +105,39 @@ declare class RouteDataLoadError extends Error {
|
|
|
81
105
|
}
|
|
82
106
|
//#endregion
|
|
83
107
|
//#region src/router/policy.d.ts
|
|
108
|
+
/** Policy decision: allow the route to render. */
|
|
84
109
|
declare function allow(): AccessAllowDecision;
|
|
110
|
+
/** Policy decision: redirect the visitor to `to`. */
|
|
85
111
|
declare function redirect(to: string, init?: {
|
|
86
112
|
status?: AccessRedirectStatus;
|
|
87
113
|
replace?: boolean;
|
|
88
114
|
}): AccessRedirectDecision;
|
|
115
|
+
/** Policy decision: deny the request with the given HTTP status. */
|
|
89
116
|
declare function deny(status: AccessDenyStatus): AccessDenyDecision;
|
|
117
|
+
/** Policy decision: deny with 401 Unauthorized. */
|
|
90
118
|
declare function unauthorized(): AccessDenyDecision;
|
|
119
|
+
/** Policy decision: deny with 403 Forbidden. */
|
|
91
120
|
declare function forbidden(): AccessDenyDecision;
|
|
121
|
+
/** Policy decision: deny with 404 Not Found. */
|
|
92
122
|
declare function notFound(): AccessDenyDecision;
|
|
93
123
|
//#endregion
|
|
94
124
|
//#region src/router/destination.d.ts
|
|
125
|
+
/** Build a {@link RouteDestination} (with a computed `href`) for a {@link RouteRef} and params/search. */
|
|
95
126
|
declare function to$1<TParams extends RouteParams, TSearch extends RouteSearch = RouteSearch>(route: RouteRef<TParams, TSearch>, params: TParams, search?: TSearch): RouteDestination;
|
|
96
127
|
//#endregion
|
|
97
128
|
//#region src/router/metadata.d.ts
|
|
129
|
+
/** Resolve a route's merged {@link RouteMeta} by running its metadata chain against `context`. */
|
|
98
130
|
declare function resolveRouteMeta(record: RouteRecord, context: RouteContext): Promise<Readonly<RouteMeta>>;
|
|
99
131
|
/** Replace only Askr-owned head nodes after a successful client navigation. */
|
|
100
132
|
declare function reconcileRouteMeta(meta: Readonly<RouteMeta>, target?: Document): void;
|
|
133
|
+
/** Render a {@link RouteMeta} to the `<title>`/`<meta>`/`<link>`/JSON-LD markup for the document `<head>`. */
|
|
101
134
|
declare function serializeRouteMeta(meta: RouteMeta): string;
|
|
102
135
|
//#endregion
|
|
103
136
|
//#region src/common/deferred-value.d.ts
|
|
104
137
|
declare const DEFERRED_VALUE: unique symbol;
|
|
138
|
+
/** Lifecycle state of a {@link Deferred} value. */
|
|
105
139
|
type DeferredState = 'pending' | 'fulfilled' | 'rejected';
|
|
140
|
+
/** A promise-backed value that can be read synchronously once settled, produced by {@link defer}. */
|
|
106
141
|
interface Deferred<T> {
|
|
107
142
|
readonly state: DeferredState;
|
|
108
143
|
readonly value: T | undefined;
|
|
@@ -110,18 +145,24 @@ interface Deferred<T> {
|
|
|
110
145
|
readonly promise: Promise<T>;
|
|
111
146
|
readonly [DEFERRED_VALUE]: true;
|
|
112
147
|
}
|
|
148
|
+
/** Wrap a promise as a {@link Deferred} value that tracks its settled state and result. */
|
|
113
149
|
declare function defer<T>(promise: PromiseLike<T>): Deferred<T>;
|
|
150
|
+
/** Check whether `value` is a {@link Deferred} produced by {@link defer}. */
|
|
114
151
|
declare function isDeferred<T = unknown>(value: unknown): value is Deferred<T>;
|
|
115
152
|
//#endregion
|
|
116
153
|
//#region src/router/deferred.d.ts
|
|
154
|
+
/** Props for {@link Resolve}. */
|
|
117
155
|
interface ResolveProps<T> {
|
|
118
156
|
value: Deferred<T>;
|
|
119
157
|
pending?: RenderableChild;
|
|
120
158
|
rejected?: RenderableChild | ((error: unknown) => RenderableChild);
|
|
121
159
|
children: (value: T) => RenderableChild;
|
|
122
160
|
}
|
|
161
|
+
/** Recursively await any {@link Deferred} values nested within `input`, returning it once fully resolved. */
|
|
123
162
|
declare function resolveDeferredValues<T>(input: T, signal?: AbortSignal): Promise<T>;
|
|
163
|
+
/** Read the current route's server loader data during render or hydration. */
|
|
124
164
|
declare function routeData<T>(): T;
|
|
165
|
+
/** Render a {@link Deferred} value's fulfilled state, a pending placeholder, or a rejected fallback. */
|
|
125
166
|
declare function Resolve<T>(props: ResolveProps<T>): JSXElement;
|
|
126
167
|
//#endregion
|
|
127
168
|
//#region src/components/link.d.ts
|
|
@@ -150,6 +191,7 @@ type LinkBaseProps = Omit<Props, 'children' | 'href' | 'class' | 'rel' | 'target
|
|
|
150
191
|
onPress?: (event: Event) => void;
|
|
151
192
|
onClick?: (event: MouseEvent) => void;
|
|
152
193
|
};
|
|
194
|
+
/** Props for {@link Link}: either a raw `href` or a typed route `to` destination. */
|
|
153
195
|
type LinkProps = LinkBaseProps & ({
|
|
154
196
|
href: string;
|
|
155
197
|
to?: never;
|
package/dist/router/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { n as createRouteRegistry } from "../manifest-
|
|
2
|
-
import { a as isSafeHref } from "../csp-nonce-
|
|
1
|
+
import { n as createRouteRegistry } from "../manifest-D6rfj_jC.js";
|
|
2
|
+
import { a as isSafeHref } from "../csp-nonce-BVybpV1v.js";
|
|
3
3
|
import { jsx } from "../jsx-runtime.js";
|
|
4
4
|
import { o as addRouteBasePath, y as getActiveRouteBasePath } from "../route-matching-Bo6UqG-5.js";
|
|
5
|
-
import { a as group, c as route, i as fallback, n as resolveDeferredValues, o as index, r as routeData, s as page, t as Resolve } from "../deferred-
|
|
6
|
-
import { S as RouteDataLoadError, a as resolveRouteRequest, b as lazy, f as defer, g as Outlet, h as currentAuth, p as isDeferred, x as lazyRouteData } from "../resolution-
|
|
7
|
-
import { n as onRouteChange, t as currentRoute } from "../activity-
|
|
8
|
-
import { a as serializeRouteMeta, c as getCurrentHref, d as parseTargetUrl, h as syncRegisteredRouteSnapshot, i as resolveRouteMeta, l as getRegisteredAppsSnapshot, m as syncAppRegistrationLocation, n as navigate, p as setCurrentRouteLocation, r as reconcileRouteMeta, s as saveScrollPosition, u as getWindowHref } from "../navigate-
|
|
9
|
-
import { o as mergeProps } from "../compose-ref-
|
|
10
|
-
import { t as applyInteractionPolicy } from "../interactions-
|
|
5
|
+
import { a as group, c as route, i as fallback, n as resolveDeferredValues, o as index, r as routeData, s as page, t as Resolve } from "../deferred-p8hyanxJ.js";
|
|
6
|
+
import { S as RouteDataLoadError, a as resolveRouteRequest, b as lazy, f as defer, g as Outlet, h as currentAuth, p as isDeferred, x as lazyRouteData } from "../resolution-BQyo7qNn.js";
|
|
7
|
+
import { n as onRouteChange, t as currentRoute } from "../activity-d4t3CdzK.js";
|
|
8
|
+
import { a as serializeRouteMeta, c as getCurrentHref, d as parseTargetUrl, h as syncRegisteredRouteSnapshot, i as resolveRouteMeta, l as getRegisteredAppsSnapshot, m as syncAppRegistrationLocation, n as navigate, p as setCurrentRouteLocation, r as reconcileRouteMeta, s as saveScrollPosition, u as getWindowHref } from "../navigate-DChM5m8m.js";
|
|
9
|
+
import { o as mergeProps } from "../compose-ref-1Fhs7mbF.js";
|
|
10
|
+
import { t as applyInteractionPolicy } from "../interactions-B4XaFxt1.js";
|
|
11
11
|
//#region src/router/route-query.ts
|
|
12
12
|
function getRouteQueryHistoryMode(options) {
|
|
13
13
|
if (options.history) return options.history;
|
|
@@ -51,9 +51,11 @@ function updateRouteQuery(updates, options = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region src/router/policy.ts
|
|
54
|
+
/** Policy decision: allow the route to render. */
|
|
54
55
|
function allow() {
|
|
55
56
|
return { kind: "allow" };
|
|
56
57
|
}
|
|
58
|
+
/** Policy decision: redirect the visitor to `to`. */
|
|
57
59
|
function redirect(to, init = {}) {
|
|
58
60
|
return {
|
|
59
61
|
kind: "redirect",
|
|
@@ -62,18 +64,22 @@ function redirect(to, init = {}) {
|
|
|
62
64
|
...init.replace !== void 0 ? { replace: init.replace } : {}
|
|
63
65
|
};
|
|
64
66
|
}
|
|
67
|
+
/** Policy decision: deny the request with the given HTTP status. */
|
|
65
68
|
function deny(status) {
|
|
66
69
|
return {
|
|
67
70
|
kind: "deny",
|
|
68
71
|
status
|
|
69
72
|
};
|
|
70
73
|
}
|
|
74
|
+
/** Policy decision: deny with 401 Unauthorized. */
|
|
71
75
|
function unauthorized() {
|
|
72
76
|
return deny(401);
|
|
73
77
|
}
|
|
78
|
+
/** Policy decision: deny with 403 Forbidden. */
|
|
74
79
|
function forbidden() {
|
|
75
80
|
return deny(403);
|
|
76
81
|
}
|
|
82
|
+
/** Policy decision: deny with 404 Not Found. */
|
|
77
83
|
function notFound() {
|
|
78
84
|
return deny(404);
|
|
79
85
|
}
|
|
@@ -117,6 +123,7 @@ function appendSearchValue(query, key, value) {
|
|
|
117
123
|
function formatSearchIssues(issues) {
|
|
118
124
|
return issues.map((issue) => `${issue.path.length ? issue.path.join(".") : "search"}: ${issue.message}`).join("; ");
|
|
119
125
|
}
|
|
126
|
+
/** Build a {@link RouteDestination} (with a computed `href`) for a {@link RouteRef} and params/search. */
|
|
120
127
|
function to(route, params, search) {
|
|
121
128
|
const path = addRouteBasePath(buildPath(route, params), route.basePath ?? "");
|
|
122
129
|
const parsedSearch = route.searchSchema?.safeParse(search ?? {});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as enqueueRuntimeLane } from "./access-
|
|
1
|
+
import { t as enqueueRuntimeLane } from "./access-d_DCdwqn.js";
|
|
2
2
|
import { i as claimHookIndex, p as getCurrentInstance } from "./component-scope-4I3yEMkb.js";
|
|
3
|
-
import { c as markReadableUsage, f as syncDerivedDependencySubscriptions, l as notifyReadableReaders, o as markReactivePropsDirtySource, p as withDerivedReadTracking, r as clearDerivedDependencySubscriptions, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-
|
|
3
|
+
import { c as markReadableUsage, f as syncDerivedDependencySubscriptions, l as notifyReadableReaders, o as markReactivePropsDirtySource, p as withDerivedReadTracking, r as clearDerivedDependencySubscriptions, s as markReadableDerivedSubscribersDirty, u as recordReadableRead } from "./readable-BsdGWsDE.js";
|
|
4
4
|
//#region src/runtime/selector-store.ts
|
|
5
5
|
const dirtySelectorRecords = /* @__PURE__ */ new Set();
|
|
6
6
|
let hasPendingSelectorFlush = false;
|
|
@@ -170,8 +170,8 @@ function notifySelectorLaneValueChange(lane, prevValue, nextValue) {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
function recomputeSelectorSourceRecord(record, notifyDownstream) {
|
|
173
|
-
if (!record._dirty && record._hasValue) return record._value;
|
|
174
173
|
if (record._evaluating) throw new Error("selector() cannot read itself recursively");
|
|
174
|
+
if (!record._dirty && record._hasValue) return record._value;
|
|
175
175
|
record._evaluating = true;
|
|
176
176
|
record._dirty = false;
|
|
177
177
|
record._pendingDependencySources = /* @__PURE__ */ new Set();
|
|
@@ -236,6 +236,7 @@ function createSelectorHook(instance, generation, store, hookIndex, source, equa
|
|
|
236
236
|
if (!lane) throw new Error("selector() binding could not be established.");
|
|
237
237
|
const sourceRef = getCandidateSource(lane, candidate);
|
|
238
238
|
recordReadableRead(sourceRef);
|
|
239
|
+
if (record._evaluating) throw new Error("selector() cannot read itself recursively");
|
|
239
240
|
const current = record._dirty || !record._hasValue ? recomputeSelectorSourceRecord(record, record._scheduled) : record._value;
|
|
240
241
|
return lane._equals(current, candidate);
|
|
241
242
|
};
|
package/dist/ssg/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as RouteRegistry, St as RouteOptions, Tt as RoutePolicy, an as DocumentRenderArgs, gt as RouteHandler, on as DocumentRenderContext, sn as DocumentRenderer, un as SSRStyleRegistrationValidation, wt as RoutePathParams } from "../index-CTIBOqUB.js";
|
|
2
2
|
import { AuthRequirement } from "@askrjs/auth";
|
|
3
3
|
import "node:fs/promises";
|
|
4
4
|
//#region src/ssg/types.d.ts
|
|
5
|
+
/** Whether an SSG run rebuilds every route (`full`) or only changed ones (`incremental`). */
|
|
5
6
|
type SSGMode = 'full' | 'incremental';
|
|
7
|
+
/** Outcome of generating a single route's static HTML. */
|
|
6
8
|
type RouteRenderStatus = 'success' | 'error' | 'skipped' | 'removed';
|
|
9
|
+
/** Why a route was rendered, skipped, or removed during generation. */
|
|
7
10
|
type RouteRenderReason = 'full' | 'changed-key' | 'changed-route' | 'new-route' | 'no-keys' | 'unchanged' | 'deleted' | 'runtime-only';
|
|
8
11
|
type RouteConfigParams<Path extends string> = string extends Path ? Record<string, string> : RoutePathParams<Path>;
|
|
9
12
|
/**
|
|
@@ -66,6 +69,7 @@ interface SSGBaseOptions {
|
|
|
66
69
|
/** Preferred render parallelism. `'auto'` resolves from the host machine. */
|
|
67
70
|
parallelism?: number | 'auto';
|
|
68
71
|
}
|
|
72
|
+
/** A static file or directory to copy alongside generated routes. */
|
|
69
73
|
interface SSGAssetSource {
|
|
70
74
|
/** Source file or directory. Relative paths resolve from the current working directory. */
|
|
71
75
|
from: string;
|
package/dist/ssg/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../access-
|
|
2
|
-
import { n as createRouteRegistry } from "../manifest-
|
|
1
|
+
import "../access-d_DCdwqn.js";
|
|
2
|
+
import { n as createRouteRegistry } from "../manifest-D6rfj_jC.js";
|
|
3
3
|
import { o as addRouteBasePath } from "../route-matching-Bo6UqG-5.js";
|
|
4
|
-
import { c as route, n as resolveDeferredValues } from "../deferred-
|
|
5
|
-
import { S as RouteDataLoadError, c as prepareRouteHydrationData, t as bindResolvedRouteData, v as getRenderHandler, y as _preloadRouteHandler } from "../resolution-
|
|
4
|
+
import { c as route, n as resolveDeferredValues } from "../deferred-p8hyanxJ.js";
|
|
5
|
+
import { S as RouteDataLoadError, c as prepareRouteHydrationData, t as bindResolvedRouteData, v as getRenderHandler, y as _preloadRouteHandler } from "../resolution-BQyo7qNn.js";
|
|
6
6
|
import { n as renderDocument } from "../ssr-DSHd_Q9K.js";
|
|
7
|
-
import { n as renderToString } from "../ssr-
|
|
7
|
+
import { n as renderToString } from "../ssr-DYcK20IX.js";
|
|
8
8
|
import * as fs from "node:fs/promises";
|
|
9
9
|
import * as pathModule from "node:path";
|
|
10
10
|
import * as os from "node:os";
|
package/dist/ssr/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as JSXElement, s as Props } from "../types-
|
|
3
|
-
import { O as QueryPrefetchContext, _ as CoreTelemetry, n as ServerQueryRegistry, v as DataRuntime } from "../index-2bk8nldG.js";
|
|
1
|
+
import { At as RouteRegistry, Dt as RouteRecord, E as SSRPortalState, Pt as RouteRequestResult, Rt as CoreTelemetry, T as DeferredBoundaryRegistration, Yt as QueryPrefetchContext, an as DocumentRenderArgs, c as ServerQueryRegistry, cn as SSRData, et as AccessDenyDecision, gt as RouteHandler, ln as SSRStyleRegistration, lt as Route, nt as AccessRedirectDecision, on as DocumentRenderContext, sn as DocumentRenderer, un as SSRStyleRegistrationValidation, ut as RouteAuthOptions, zt as DataRuntime } from "../index-CTIBOqUB.js";
|
|
2
|
+
import { r as JSXElement, s as Props } from "../types-DkVJhVs9.js";
|
|
4
3
|
import { AuthContext } from "@askrjs/auth";
|
|
5
4
|
//#region src/common/page-render-envelope.d.ts
|
|
6
5
|
declare const PAGE_RENDER_ENVELOPE_VERSION: 1;
|
|
@@ -45,6 +44,7 @@ interface RenderContext {
|
|
|
45
44
|
ssrPortals: SSRPortalState;
|
|
46
45
|
cspNonce?: string;
|
|
47
46
|
}
|
|
47
|
+
/** Build a fresh SSR render context (data cache, routes, seed) for a render pass. */
|
|
48
48
|
declare function createRenderContext(seed?: number, opts?: {
|
|
49
49
|
url?: string;
|
|
50
50
|
data?: SSRData;
|
|
@@ -65,6 +65,7 @@ declare function createRenderContext(seed?: number, opts?: {
|
|
|
65
65
|
* Concurrency-safe in Node.js via AsyncLocalStorage.
|
|
66
66
|
*/
|
|
67
67
|
declare function withRenderContext<T>(ctx: RenderContext, fn: () => T): T;
|
|
68
|
+
/** Run `fn` with `ctx` as the active SSR render context, using async-local storage. */
|
|
68
69
|
declare function withRenderContextAsync<T>(ctx: RenderContext, fn: () => T | PromiseLike<T>): Promise<T>;
|
|
69
70
|
/**
|
|
70
71
|
* Get the current render context.
|
|
@@ -73,6 +74,7 @@ declare function withRenderContextAsync<T>(ctx: RenderContext, fn: () => T | Pro
|
|
|
73
74
|
declare function getRenderContext(): RenderContext | null;
|
|
74
75
|
//#endregion
|
|
75
76
|
//#region src/ssr/route-render.d.ts
|
|
77
|
+
/** A single path-to-handler route binding accepted by low-level SSR route rendering. */
|
|
76
78
|
type SSRRoute = {
|
|
77
79
|
path: string;
|
|
78
80
|
handler: RouteHandler;
|
|
@@ -100,6 +102,7 @@ type RouteStreamOptions = RouteRenderOptions & {
|
|
|
100
102
|
onChunk(html: string): void;
|
|
101
103
|
onComplete(): void;
|
|
102
104
|
};
|
|
105
|
+
/** Resolve a URL against a route registry for SSR, applying auth/policies before render. */
|
|
103
106
|
declare function resolveRequest(opts: {
|
|
104
107
|
url: string;
|
|
105
108
|
registry: RouteRegistry;
|
|
@@ -127,6 +130,7 @@ type SSRComponent = (props: Props, context?: {
|
|
|
127
130
|
}) => VNode | JSXElement | string | number | boolean | null | undefined;
|
|
128
131
|
//#endregion
|
|
129
132
|
//#region src/ssr/render-sync.d.ts
|
|
133
|
+
/** Synchronously render a component to an HTML string, without route resolution. */
|
|
130
134
|
declare function renderToStringSync(component: (props?: Record<string, unknown>) => VNode | JSXElement | string | number | boolean | null | undefined, props?: Record<string, unknown>, options?: {
|
|
131
135
|
seed?: number;
|
|
132
136
|
data?: SSRData;
|
|
@@ -138,6 +142,7 @@ declare function renderToStringSync(component: (props?: Record<string, unknown>)
|
|
|
138
142
|
}): string;
|
|
139
143
|
//#endregion
|
|
140
144
|
//#region src/ssr/render-resolved.d.ts
|
|
145
|
+
/** Synchronously render an already-resolved route handler to an HTML string. */
|
|
141
146
|
declare function renderResolvedToStringSync(opts: {
|
|
142
147
|
url: string;
|
|
143
148
|
registry: RouteRegistry;
|
|
@@ -153,6 +158,7 @@ declare function renderResolvedToStringSync(opts: {
|
|
|
153
158
|
}): string;
|
|
154
159
|
//#endregion
|
|
155
160
|
//#region src/ssr/route-request-render.d.ts
|
|
161
|
+
/** Options for {@link renderRouteRequest} and {@link renderRouteRequestToString}. */
|
|
156
162
|
interface RenderRouteRequestOptions {
|
|
157
163
|
url: string;
|
|
158
164
|
registry: RouteRegistry;
|
|
@@ -170,6 +176,7 @@ interface RenderRouteRequestOptions {
|
|
|
170
176
|
telemetry?: CoreTelemetry;
|
|
171
177
|
cspNonce?: string;
|
|
172
178
|
}
|
|
179
|
+
/** Outcome of rendering a route request for SSR: a render, redirect, deny, or no-match. */
|
|
173
180
|
type RenderRouteRequestResult = {
|
|
174
181
|
kind: 'render';
|
|
175
182
|
html: string;
|
|
@@ -180,12 +187,18 @@ type RenderRouteRequestResult = {
|
|
|
180
187
|
} | AccessRedirectDecision | AccessDenyDecision | {
|
|
181
188
|
kind: 'no-match';
|
|
182
189
|
};
|
|
190
|
+
/** Resolve and render a route request for SSR, streaming the body when possible. */
|
|
183
191
|
declare function renderRouteRequest(options: RenderRouteRequestOptions): Promise<RenderRouteRequestResult>;
|
|
192
|
+
/** Resolve and render a route request for SSR, always fully buffering the HTML. */
|
|
184
193
|
declare function renderRouteRequestToString(options: RenderRouteRequestOptions): Promise<RenderRouteRequestResult>;
|
|
185
194
|
//#endregion
|
|
186
195
|
//#region src/ssr/index-internal.d.ts
|
|
196
|
+
/**
|
|
197
|
+
* Render a component or route request to a complete HTML string, synchronously.
|
|
198
|
+
*/
|
|
187
199
|
declare function renderToString(component: (props?: Record<string, unknown>) => VNode | JSXElement | string | number | null): string;
|
|
188
200
|
declare function renderToString(opts: RouteRenderOptions): string;
|
|
201
|
+
/** Stream a route request's rendered HTML to the response sink described by `opts`. */
|
|
189
202
|
declare function renderToStream(opts: RouteStreamOptions): void;
|
|
190
203
|
//#endregion
|
|
191
204
|
export { type DocumentRenderArgs, type DocumentRenderContext, type DocumentRenderer, type RenderRouteRequestOptions, type RenderRouteRequestResult, type SSRComponent, SSRDataMissingError, type SSRRoute, type SSRStyleRegistration, type SSRStyleRegistrationValidation, type VNode, createRenderContext, getRenderContext, renderResolvedToStringSync, renderRouteRequest, renderRouteRequestToString, renderToStream, renderToString, renderToStringSync, resolveRequest, withRenderContext, withRenderContextAsync };
|
package/dist/ssr/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { C as SSRDataMissingError } from "../render-context-B7ohlh6t.js";
|
|
2
|
-
import { a as renderResolvedToStringSync, c as createRenderContext, d as withRenderContextAsync, i as renderRouteRequestToString, l as getRenderContext, n as renderToString, o as renderToStringSync, r as renderRouteRequest, s as resolveRequest, t as renderToStream, u as withRenderContext } from "../ssr-
|
|
2
|
+
import { a as renderResolvedToStringSync, c as createRenderContext, d as withRenderContextAsync, i as renderRouteRequestToString, l as getRenderContext, n as renderToString, o as renderToStringSync, r as renderRouteRequest, s as resolveRequest, t as renderToStream, u as withRenderContext } from "../ssr-DYcK20IX.js";
|
|
3
3
|
export { SSRDataMissingError, createRenderContext, getRenderContext, renderResolvedToStringSync, renderRouteRequest, renderRouteRequestToString, renderToStream, renderToString, renderToStringSync, resolveRequest, withRenderContext, withRenderContextAsync };
|