@askrjs/askr 0.0.91 → 0.0.94
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 +3 -0
- package/dist/{access-Dpfoi4cA.js → access-d_DCdwqn.js} +8 -2
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.js +4 -3
- package/dist/{activity-dKH6nlpj.js → activity-BshyLB3_.js} +9 -5
- package/dist/{activity-CF2_JvJs.d.ts → activity-CJIQyo5X.d.ts} +5 -1
- package/dist/benchmark.d.ts +1 -1
- package/dist/benchmark.js +8 -8
- package/dist/boot/index.d.ts +12 -4
- package/dist/boot/index.js +1 -1
- package/dist/{boot-D3zVVWuN.js → boot-BsMB_ySP.js} +34 -22
- package/dist/{cleanup-c837KVij.js → cleanup-DefafSjG.js} +8 -5
- package/dist/{component-cleanup-BUfUleGZ.js → component-cleanup-hrqSikl2.js} +3 -3
- package/dist/{component-internal-C4uwwUaK.js → component-internal-DOVVMjG7.js} +8 -6
- package/dist/{component-scope-DzJEbYGE.js → component-scope-4I3yEMkb.js} +13 -1
- package/dist/components/index.d.ts +7 -2
- package/dist/components/index.js +2 -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-CsGs2bLS.d.ts → control-DdFw-Caz.d.ts} +1 -1
- package/dist/{control-CON10J1p.js → control-DqOzkgc7.js} +9 -5
- package/dist/{csp-nonce-DH0TrDij.js → csp-nonce-BBxq1zq4.js} +8 -1
- package/dist/data/index.d.ts +1 -2
- package/dist/data/index.js +3 -3
- package/dist/{data-Bh_3OETq.js → data-DYqokZzc.js} +23 -12
- package/dist/{data-runtime-wbooGyu7.js → data-runtime-JxoRgrrt.js} +3 -1
- package/dist/{deferred-D6nZaIPs.js → deferred-BS0Xpstg.js} +10 -5
- package/dist/{effect-lnxQIpJG.js → effect-BdvdgMvV.js} +73 -14
- package/dist/{fastlane-CrfB3QG0.js → fastlane-DGo7SxBQ.js} +23 -4
- package/dist/{for-internal-Bsm0B8GZ.js → for-internal-jrliHZmF.js} +6 -6
- package/dist/foundations/icon/index.d.ts +14 -3
- 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 +8 -2
- package/dist/{index-Cf2ANwPL.d.ts → index-C29SEGIv.d.ts} +30 -3
- package/dist/{index-BnU0NPwM.d.ts → index-CzH-0LcA.d.ts} +18 -0
- package/dist/index-KQ7Vl4-8.d.ts +1364 -0
- package/dist/index.d.ts +3 -7
- package/dist/index.js +34 -18
- 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 -3
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime-BTzDdBJ_.d.ts +2 -0
- package/dist/{jsx-runtime-LHh5tcTe.d.ts → jsx-runtime-Cdd6Gkb0.d.ts} +4 -3
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +1 -1
- package/dist/{lifecycle-batch-Dfpid9-A.js → lifecycle-batch-BH0fax4F.js} +2 -2
- package/dist/{lifecycle-operations-CMK1AN2C.js → lifecycle-operations-Qxq6ABrC.js} +7 -2
- package/dist/{manifest-fBb2ynKL.js → manifest-D6rfj_jC.js} +5 -1
- package/dist/{navigate-BO7M2iUG.d.ts → navigate-BL_FIIJ6.d.ts} +6 -1
- package/dist/{navigate-CnQMXze1.js → navigate-CECCMPAr.js} +16 -11
- package/dist/{query-registry-B4LpVtlT.js → query-registry-CimB1YeW.js} +11 -1
- package/dist/{readable-B5NtV7V0.js → readable-BsdGWsDE.js} +9 -6
- package/dist/{renderer-y2DL627q.js → renderer-CLvq458M.js} +235 -189
- package/dist/{resolution-C9A31xQi.js → resolution-D8PgnTzh.js} +12 -6
- package/dist/{resource-operation-whZDJAYv.js → resource-operation-CLQXCn1p.js} +5 -5
- package/dist/resources/index.d.ts +15 -2
- package/dist/resources/index.js +7 -6
- package/dist/{route-matching-xlgdQXg_.js → route-matching-Bo6UqG-5.js} +13 -4
- package/dist/router/index.d.ts +46 -6
- package/dist/router/index.js +16 -9
- package/dist/{selector-BLNkRZ2i.js → selector-CyK-sDwB.js} +24 -6
- package/dist/ssg/index.d.ts +5 -2
- package/dist/ssg/index.js +6 -6
- package/dist/ssr/index.d.ts +16 -5
- package/dist/ssr/index.js +1 -1
- package/dist/{ssr-DNJUPmMq.js → ssr-8_vHDWqV.js} +20 -12
- package/dist/{state-DCjONcHK.js → state-DmkGM_LN.js} +5 -5
- package/dist/{structures-m-cphWI-.js → structures-umvVUD-M.js} +20 -6
- package/dist/testing/index.d.ts +31 -3
- package/dist/testing/index.js +24 -6
- package/dist/{jsx-BYXe_Nnk.d.ts → types-DkVJhVs9.d.ts} +20 -0
- package/dist/{verify-hydration-D8938Fw2.js → verify-hydration-jf8X2V3x.js} +1 -1
- package/package.json +1 -1
- package/dist/control-D-FIa-n-.d.ts +0 -451
- package/dist/index-BU17hud9.d.ts +0 -52
- package/dist/index-CPlPDbEY.d.ts +0 -64
- package/dist/index-Izwp_ESC.d.ts +0 -458
- package/dist/jsx-runtime-BqhMEuT4.d.ts +0 -2
- package/dist/scheduler-CmLO4Dfm.d.ts +0 -65
- package/dist/types-CsPtBGWb.d.ts +0 -16
- package/dist/types-iAmDSV6o.d.ts +0 -179
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as enqueueRuntimeLane,
|
|
2
|
-
import { f as getCurrentComponentInstance } from "./component-scope-
|
|
3
|
-
import { c as registerCommitOperationForInstance, f as getCurrentContextFrame, y as withAsyncResourceContext } from "./component-internal-
|
|
4
|
-
import { p as isPromiseLike } from "./lifecycle-batch-
|
|
1
|
+
import { t as enqueueRuntimeLane, y as logger } from "./access-d_DCdwqn.js";
|
|
2
|
+
import { f as getCurrentComponentInstance } from "./component-scope-4I3yEMkb.js";
|
|
3
|
+
import { c as registerCommitOperationForInstance, f as getCurrentContextFrame, y as withAsyncResourceContext } from "./component-internal-DOVVMjG7.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-KQ7Vl4-8.js";
|
|
2
|
+
import { i as onRouteChange, n as RouteChangeOptions, t as RouteChangeCleanup } from "../activity-CJIQyo5X.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-
|
|
2
|
-
import { f as getCurrentComponentInstance, g as getSignal, i as claimHookIndex } from "../component-scope-
|
|
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-
|
|
1
|
+
import { t as enqueueRuntimeLane } from "../access-d_DCdwqn.js";
|
|
2
|
+
import { f as getCurrentComponentInstance, g as getSignal, i as claimHookIndex } from "../component-scope-4I3yEMkb.js";
|
|
3
|
+
import { a as registerCommitOperation } from "../component-internal-DOVVMjG7.js";
|
|
4
|
+
import { t as resource } from "../resource-operation-CLQXCn1p.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-Qxq6ABrC.js";
|
|
6
|
+
import { n as onRouteChange } from "../activity-BshyLB3_.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);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { d as getCurrentAppRenderRuntime } from "./component-scope-4I3yEMkb.js";
|
|
1
2
|
import { n as getActiveRenderContext } from "./render-context-B7ohlh6t.js";
|
|
2
3
|
//#region src/router/match.ts
|
|
3
4
|
function splitPathSegments(path) {
|
|
@@ -160,11 +161,15 @@ function addRouteToStores(routeObj) {
|
|
|
160
161
|
if (routeObj.namespace) namespaces.add(routeObj.namespace);
|
|
161
162
|
}
|
|
162
163
|
function getActiveRoutes() {
|
|
163
|
-
return getActiveRenderContext()?.routes ?? routes;
|
|
164
|
+
return getActiveRenderContext()?.routes ?? getCurrentAppRenderRuntime()?.routeRegistry?.routes ?? routes;
|
|
164
165
|
}
|
|
165
166
|
function getActiveRouteAuthOptions(override) {
|
|
166
|
-
if (override) return override;
|
|
167
|
-
|
|
167
|
+
if (override !== void 0) return override;
|
|
168
|
+
const renderContext = getActiveRenderContext();
|
|
169
|
+
if (renderContext) return renderContext.routeAuth;
|
|
170
|
+
const appRuntime = getCurrentAppRenderRuntime();
|
|
171
|
+
if (appRuntime) return appRuntime.routeAuth;
|
|
172
|
+
return activeClientRouteAuthOptions ?? defaultRouteAuthOptions;
|
|
168
173
|
}
|
|
169
174
|
function _setActiveRouteAuthOptions(auth) {
|
|
170
175
|
activeClientRouteAuthOptions = auth;
|
|
@@ -182,7 +187,11 @@ function setDefaultRouteBasePath(basePath) {
|
|
|
182
187
|
defaultRouteBasePath = basePath;
|
|
183
188
|
}
|
|
184
189
|
function getActiveRouteBasePath() {
|
|
185
|
-
|
|
190
|
+
const renderContext = getActiveRenderContext();
|
|
191
|
+
if (renderContext?.basePath !== void 0) return renderContext.basePath;
|
|
192
|
+
const appRegistry = getCurrentAppRenderRuntime()?.routeRegistry;
|
|
193
|
+
if (appRegistry) return appRegistry.manifest.basePath ?? "";
|
|
194
|
+
return defaultRouteBasePath;
|
|
186
195
|
}
|
|
187
196
|
function getCurrentLayoutChain() {
|
|
188
197
|
const layoutChain = [];
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as JSXElement, s as Props } from "../
|
|
3
|
-
import {
|
|
4
|
-
import "../
|
|
5
|
-
import { a as ScrollRestorationOptions, i as NavigationScrollBehavior, n as NavigateOptions, r as HistoryScrollBehavior, t as navigate } from "../navigate-BO7M2iUG.js";
|
|
6
|
-
import { i as onRouteChange, n as RouteChangeOptions, r as currentRoute, t as RouteChangeCleanup } from "../activity-CF2_JvJs.js";
|
|
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-KQ7Vl4-8.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-BL_FIIJ6.js";
|
|
4
|
+
import { i as onRouteChange, n as RouteChangeOptions, r as currentRoute, t as RouteChangeCleanup } from "../activity-CJIQyo5X.js";
|
|
7
5
|
import { AuthContext, AuthContext as AuthContext$1, AuthRequirement, AuthRequirement as AuthRequirement$1 } from "@askrjs/auth";
|
|
8
6
|
import { ObjectSchema } from "@askrjs/schema";
|
|
9
7
|
//#region src/router/route-query.d.ts
|
|
8
|
+
/** A single query-string value accepted by {@link updateRouteQuery}. */
|
|
10
9
|
type RouteQueryParamValue = string | number | boolean | null | undefined;
|
|
10
|
+
/** A query-string value, or an array of them for a repeated param. */
|
|
11
11
|
type RouteQueryParamInput = RouteQueryParamValue | readonly RouteQueryParamValue[];
|
|
12
|
+
/** A map of query param updates for {@link updateRouteQuery}; `null`/`undefined` removes the key. */
|
|
12
13
|
type RouteQueryUpdates = Record<string, RouteQueryParamInput>;
|
|
14
|
+
/** A function that mutates a `URLSearchParams` directly, for {@link updateRouteQuery}. */
|
|
13
15
|
type RouteQueryUpdater = (searchParams: URLSearchParams) => void;
|
|
16
|
+
/** Options for {@link updateRouteQuery}. */
|
|
14
17
|
type UpdateRouteQueryOptions = {
|
|
15
18
|
/**
|
|
16
19
|
* Defaults to replace so high-frequency controls such as search inputs do not
|
|
@@ -30,13 +33,21 @@ type CompatibleAbsoluteRouteComponent<Path extends string, TComponent extends An
|
|
|
30
33
|
type CompatibleRelativeRouteComponent<Path extends string, TComponent extends AnyRouteComponent> = Parameters<TComponent> extends [] ? TComponent : RouteComponentParam<TComponent> extends Record<keyof RoutePathParams<Path>, string> ? TComponent : never;
|
|
31
34
|
type CompatibleRouteComponent<Path extends string, TComponent extends AnyRouteComponent> = Path extends `/${string}` ? CompatibleAbsoluteRouteComponent<Path, TComponent> : CompatibleRelativeRouteComponent<Path, TComponent>;
|
|
32
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). */
|
|
33
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
|
+
*/
|
|
34
42
|
declare function page<const TPath extends string>(path: TPath, Component: RouteComponent<RoutePathParams<TPath>>, fn: RouteDefinition): void;
|
|
35
43
|
declare function page<const TPath extends string, TComponent extends AnyRouteComponent>(path: TPath, Component: CompatibleRouteComponent<TPath, TComponent>, fn: RouteDefinition): void;
|
|
36
44
|
declare function page<const TPath extends string>(path: TPath, Component: RouteComponent<RoutePathParams<TPath>>, options: PageHelperOptions, fn: RouteDefinition): void;
|
|
37
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. */
|
|
38
47
|
declare function index(Component: RouteComponent, options?: RouteOptions): void;
|
|
48
|
+
/** Declare the catch-all `/*` fallback route for the enclosing scope. */
|
|
39
49
|
declare function fallback(Component: RouteComponent): void;
|
|
50
|
+
/** Declare a route at `path` rendering `Component`, returning a typed {@link RouteRef} for building destinations. */
|
|
40
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>>;
|
|
41
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>>;
|
|
42
53
|
//#endregion
|
|
@@ -45,20 +56,28 @@ declare function route<const TPath extends string, TComponent extends AnyRouteCo
|
|
|
45
56
|
declare function currentAuth(): AuthContext$1;
|
|
46
57
|
//#endregion
|
|
47
58
|
//#region src/router/resolution.d.ts
|
|
59
|
+
/** Resolve `target` against a route registry, applying auth/policies to produce a render/redirect/deny result. */
|
|
48
60
|
declare function resolveRouteRequest(target: string, options: RouteRequestOptions): RouteRequestResult | Promise<RouteRequestResult>;
|
|
49
61
|
//#endregion
|
|
50
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
|
+
*/
|
|
51
67
|
declare function createRouteRegistry(definition: RouteDefinition, options?: RouteRegistryOptions): RouteRegistry;
|
|
52
68
|
//#endregion
|
|
53
69
|
//#region src/router/lazy.d.ts
|
|
70
|
+
/** A route component loaded on demand via {@link lazy}, with an explicit `preload()`. */
|
|
54
71
|
type LazyRouteComponent<TComponent extends AnyRouteComponent> = TComponent & {
|
|
55
72
|
preload(): Promise<void>;
|
|
56
73
|
};
|
|
74
|
+
/** A route data loader loaded on demand via {@link lazyRouteData}, with an explicit `preload()`. */
|
|
57
75
|
type LazyRouteDataLoader<TModule, TData = TModule> = ((context: RouteContext & {
|
|
58
76
|
request?: Request;
|
|
59
77
|
}) => Promise<TData>) & {
|
|
60
78
|
preload(): Promise<void>;
|
|
61
79
|
};
|
|
80
|
+
/** Wrap a dynamic-import factory as a {@link LazyRouteComponent}, loaded on first use. */
|
|
62
81
|
declare function lazy<TComponent extends AnyRouteComponent>(factory: () => Promise<{
|
|
63
82
|
default: TComponent;
|
|
64
83
|
} | TComponent>): LazyRouteComponent<TComponent>;
|
|
@@ -71,10 +90,13 @@ declare function lazyRouteData<TModule, TData = TModule>(factory: () => PromiseL
|
|
|
71
90
|
}) => TData | PromiseLike<TData>): LazyRouteDataLoader<TModule, TData>;
|
|
72
91
|
//#endregion
|
|
73
92
|
//#region src/router/rendering.d.ts
|
|
93
|
+
/** Renders the nested route content for the enclosing layout or page scope. */
|
|
74
94
|
declare function Outlet(): JSXElement;
|
|
75
95
|
//#endregion
|
|
76
96
|
//#region src/router/route-data-loader.d.ts
|
|
97
|
+
/** Which environment a route's data loader ran (or failed) in. */
|
|
77
98
|
type RouteDataLoadPhase = 'client' | 'server' | 'ssg';
|
|
99
|
+
/** Thrown when a route's `loader` rejects; wraps the original `cause`. */
|
|
78
100
|
declare class RouteDataLoadError extends Error {
|
|
79
101
|
readonly route: string;
|
|
80
102
|
readonly phase: RouteDataLoadPhase;
|
|
@@ -83,28 +105,39 @@ declare class RouteDataLoadError extends Error {
|
|
|
83
105
|
}
|
|
84
106
|
//#endregion
|
|
85
107
|
//#region src/router/policy.d.ts
|
|
108
|
+
/** Policy decision: allow the route to render. */
|
|
86
109
|
declare function allow(): AccessAllowDecision;
|
|
110
|
+
/** Policy decision: redirect the visitor to `to`. */
|
|
87
111
|
declare function redirect(to: string, init?: {
|
|
88
112
|
status?: AccessRedirectStatus;
|
|
89
113
|
replace?: boolean;
|
|
90
114
|
}): AccessRedirectDecision;
|
|
115
|
+
/** Policy decision: deny the request with the given HTTP status. */
|
|
91
116
|
declare function deny(status: AccessDenyStatus): AccessDenyDecision;
|
|
117
|
+
/** Policy decision: deny with 401 Unauthorized. */
|
|
92
118
|
declare function unauthorized(): AccessDenyDecision;
|
|
119
|
+
/** Policy decision: deny with 403 Forbidden. */
|
|
93
120
|
declare function forbidden(): AccessDenyDecision;
|
|
121
|
+
/** Policy decision: deny with 404 Not Found. */
|
|
94
122
|
declare function notFound(): AccessDenyDecision;
|
|
95
123
|
//#endregion
|
|
96
124
|
//#region src/router/destination.d.ts
|
|
125
|
+
/** Build a {@link RouteDestination} (with a computed `href`) for a {@link RouteRef} and params/search. */
|
|
97
126
|
declare function to$1<TParams extends RouteParams, TSearch extends RouteSearch = RouteSearch>(route: RouteRef<TParams, TSearch>, params: TParams, search?: TSearch): RouteDestination;
|
|
98
127
|
//#endregion
|
|
99
128
|
//#region src/router/metadata.d.ts
|
|
129
|
+
/** Resolve a route's merged {@link RouteMeta} by running its metadata chain against `context`. */
|
|
100
130
|
declare function resolveRouteMeta(record: RouteRecord, context: RouteContext): Promise<Readonly<RouteMeta>>;
|
|
101
131
|
/** Replace only Askr-owned head nodes after a successful client navigation. */
|
|
102
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>`. */
|
|
103
134
|
declare function serializeRouteMeta(meta: RouteMeta): string;
|
|
104
135
|
//#endregion
|
|
105
136
|
//#region src/common/deferred-value.d.ts
|
|
106
137
|
declare const DEFERRED_VALUE: unique symbol;
|
|
138
|
+
/** Lifecycle state of a {@link Deferred} value. */
|
|
107
139
|
type DeferredState = 'pending' | 'fulfilled' | 'rejected';
|
|
140
|
+
/** A promise-backed value that can be read synchronously once settled, produced by {@link defer}. */
|
|
108
141
|
interface Deferred<T> {
|
|
109
142
|
readonly state: DeferredState;
|
|
110
143
|
readonly value: T | undefined;
|
|
@@ -112,18 +145,24 @@ interface Deferred<T> {
|
|
|
112
145
|
readonly promise: Promise<T>;
|
|
113
146
|
readonly [DEFERRED_VALUE]: true;
|
|
114
147
|
}
|
|
148
|
+
/** Wrap a promise as a {@link Deferred} value that tracks its settled state and result. */
|
|
115
149
|
declare function defer<T>(promise: PromiseLike<T>): Deferred<T>;
|
|
150
|
+
/** Check whether `value` is a {@link Deferred} produced by {@link defer}. */
|
|
116
151
|
declare function isDeferred<T = unknown>(value: unknown): value is Deferred<T>;
|
|
117
152
|
//#endregion
|
|
118
153
|
//#region src/router/deferred.d.ts
|
|
154
|
+
/** Props for {@link Resolve}. */
|
|
119
155
|
interface ResolveProps<T> {
|
|
120
156
|
value: Deferred<T>;
|
|
121
157
|
pending?: RenderableChild;
|
|
122
158
|
rejected?: RenderableChild | ((error: unknown) => RenderableChild);
|
|
123
159
|
children: (value: T) => RenderableChild;
|
|
124
160
|
}
|
|
161
|
+
/** Recursively await any {@link Deferred} values nested within `input`, returning it once fully resolved. */
|
|
125
162
|
declare function resolveDeferredValues<T>(input: T, signal?: AbortSignal): Promise<T>;
|
|
163
|
+
/** Read the current route's server loader data during render or hydration. */
|
|
126
164
|
declare function routeData<T>(): T;
|
|
165
|
+
/** Render a {@link Deferred} value's fulfilled state, a pending placeholder, or a rejected fallback. */
|
|
127
166
|
declare function Resolve<T>(props: ResolveProps<T>): JSXElement;
|
|
128
167
|
//#endregion
|
|
129
168
|
//#region src/components/link.d.ts
|
|
@@ -152,6 +191,7 @@ type LinkBaseProps = Omit<Props, 'children' | 'href' | 'class' | 'rel' | 'target
|
|
|
152
191
|
onPress?: (event: Event) => void;
|
|
153
192
|
onClick?: (event: MouseEvent) => void;
|
|
154
193
|
};
|
|
194
|
+
/** Props for {@link Link}: either a raw `href` or a typed route `to` destination. */
|
|
155
195
|
type LinkProps = LinkBaseProps & ({
|
|
156
196
|
href: string;
|
|
157
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-BBxq1zq4.js";
|
|
3
3
|
import { jsx } from "../jsx-runtime.js";
|
|
4
|
-
import { o as addRouteBasePath, y as getActiveRouteBasePath } from "../route-matching-
|
|
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-
|
|
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-BS0Xpstg.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-D8PgnTzh.js";
|
|
7
|
+
import { n as onRouteChange, t as currentRoute } from "../activity-BshyLB3_.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-CECCMPAr.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-
|
|
2
|
-
import { i as claimHookIndex, p as getCurrentInstance } from "./component-scope-
|
|
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-
|
|
1
|
+
import { t as enqueueRuntimeLane } from "./access-d_DCdwqn.js";
|
|
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-BsdGWsDE.js";
|
|
4
4
|
//#region src/runtime/selector-store.ts
|
|
5
5
|
const dirtySelectorRecords = /* @__PURE__ */ new Set();
|
|
6
6
|
let hasPendingSelectorFlush = false;
|
|
@@ -37,11 +37,18 @@ function markSelectorRecordDirty(record) {
|
|
|
37
37
|
markDirtySelectorRecord(record, flushDirtySelectorRecords);
|
|
38
38
|
}
|
|
39
39
|
function flushDirtySelectorRecords() {
|
|
40
|
+
let failures = null;
|
|
40
41
|
for (const record of takeDirtySelectorRecords()) {
|
|
41
42
|
record._scheduled = false;
|
|
42
43
|
if (!record._dirty) continue;
|
|
43
|
-
|
|
44
|
+
try {
|
|
45
|
+
recomputeSelectorSourceRecord(record, true);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
(failures ??= []).push(error);
|
|
48
|
+
}
|
|
44
49
|
}
|
|
50
|
+
if (failures?.length === 1) throw failures[0];
|
|
51
|
+
if (failures && failures.length > 1) throw new AggregateError(failures, "selector() recompute failures");
|
|
45
52
|
}
|
|
46
53
|
function isObjectCandidate(value) {
|
|
47
54
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
@@ -140,7 +147,7 @@ function createSelectorLane(record, equals) {
|
|
|
140
147
|
return lane;
|
|
141
148
|
}
|
|
142
149
|
function notifySelectorSource(source) {
|
|
143
|
-
markReadableDerivedSubscribersDirty(source);
|
|
150
|
+
markReadableDerivedSubscribersDirty(source, true);
|
|
144
151
|
markReactivePropsDirtySource(source);
|
|
145
152
|
notifyReadableReaders(source);
|
|
146
153
|
}
|
|
@@ -163,8 +170,8 @@ function notifySelectorLaneValueChange(lane, prevValue, nextValue) {
|
|
|
163
170
|
}
|
|
164
171
|
}
|
|
165
172
|
function recomputeSelectorSourceRecord(record, notifyDownstream) {
|
|
166
|
-
if (!record._dirty && record._hasValue) return record._value;
|
|
167
173
|
if (record._evaluating) throw new Error("selector() cannot read itself recursively");
|
|
174
|
+
if (!record._dirty && record._hasValue) return record._value;
|
|
168
175
|
record._evaluating = true;
|
|
169
176
|
record._dirty = false;
|
|
170
177
|
record._pendingDependencySources = /* @__PURE__ */ new Set();
|
|
@@ -223,11 +230,13 @@ function ensureSelectorHookBinding(hook) {
|
|
|
223
230
|
function createSelectorHook(instance, generation, store, hookIndex, source, equals) {
|
|
224
231
|
const hook = function selectorPredicate(candidate) {
|
|
225
232
|
const selectorHook = hook;
|
|
233
|
+
if (!selectorHook._active) return selectorHook._hasDisposedValue && selectorHook._equals(selectorHook._disposedValue, candidate);
|
|
226
234
|
const record = selectorHook._record ?? ensureSelectorHookBinding(selectorHook);
|
|
227
235
|
const lane = selectorHook._lane;
|
|
228
236
|
if (!lane) throw new Error("selector() binding could not be established.");
|
|
229
237
|
const sourceRef = getCandidateSource(lane, candidate);
|
|
230
238
|
recordReadableRead(sourceRef);
|
|
239
|
+
if (record._evaluating) throw new Error("selector() cannot read itself recursively");
|
|
231
240
|
const current = record._dirty || !record._hasValue ? recomputeSelectorSourceRecord(record, record._scheduled) : record._value;
|
|
232
241
|
return lane._equals(current, candidate);
|
|
233
242
|
};
|
|
@@ -237,7 +246,16 @@ function createSelectorHook(instance, generation, store, hookIndex, source, equa
|
|
|
237
246
|
hook._equals = equals;
|
|
238
247
|
hook._record = null;
|
|
239
248
|
hook._lane = null;
|
|
249
|
+
hook._active = true;
|
|
250
|
+
hook._disposedValue = void 0;
|
|
251
|
+
hook._hasDisposedValue = false;
|
|
240
252
|
hook._cleanup = () => {
|
|
253
|
+
if (!hook._active) return;
|
|
254
|
+
if (hook._record?._hasValue) {
|
|
255
|
+
hook._disposedValue = hook._record._value;
|
|
256
|
+
hook._hasDisposedValue = true;
|
|
257
|
+
}
|
|
258
|
+
hook._active = false;
|
|
241
259
|
detachSelectorHookBinding(hook);
|
|
242
260
|
};
|
|
243
261
|
attachSelectorHookBinding(hook, source, equals);
|
package/dist/ssg/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as RouteHandler, I as RouteOptions, R as RoutePathParams, W as RouteRegistry, z as RoutePolicy } from "../index-Izwp_ESC.js";
|
|
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-KQ7Vl4-8.js";
|
|
3
2
|
import { AuthRequirement } from "@askrjs/auth";
|
|
4
3
|
import "node:fs/promises";
|
|
5
4
|
//#region src/ssg/types.d.ts
|
|
5
|
+
/** Whether an SSG run rebuilds every route (`full`) or only changed ones (`incremental`). */
|
|
6
6
|
type SSGMode = 'full' | 'incremental';
|
|
7
|
+
/** Outcome of generating a single route's static HTML. */
|
|
7
8
|
type RouteRenderStatus = 'success' | 'error' | 'skipped' | 'removed';
|
|
9
|
+
/** Why a route was rendered, skipped, or removed during generation. */
|
|
8
10
|
type RouteRenderReason = 'full' | 'changed-key' | 'changed-route' | 'new-route' | 'no-keys' | 'unchanged' | 'deleted' | 'runtime-only';
|
|
9
11
|
type RouteConfigParams<Path extends string> = string extends Path ? Record<string, string> : RoutePathParams<Path>;
|
|
10
12
|
/**
|
|
@@ -67,6 +69,7 @@ interface SSGBaseOptions {
|
|
|
67
69
|
/** Preferred render parallelism. `'auto'` resolves from the host machine. */
|
|
68
70
|
parallelism?: number | 'auto';
|
|
69
71
|
}
|
|
72
|
+
/** A static file or directory to copy alongside generated routes. */
|
|
70
73
|
interface SSGAssetSource {
|
|
71
74
|
/** Source file or directory. Relative paths resolve from the current working directory. */
|
|
72
75
|
from: string;
|
package/dist/ssg/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "../access-
|
|
2
|
-
import { n as createRouteRegistry } from "../manifest-
|
|
3
|
-
import { o as addRouteBasePath } from "../route-matching-
|
|
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-
|
|
1
|
+
import "../access-d_DCdwqn.js";
|
|
2
|
+
import { n as createRouteRegistry } from "../manifest-D6rfj_jC.js";
|
|
3
|
+
import { o as addRouteBasePath } from "../route-matching-Bo6UqG-5.js";
|
|
4
|
+
import { c as route, n as resolveDeferredValues } from "../deferred-BS0Xpstg.js";
|
|
5
|
+
import { S as RouteDataLoadError, c as prepareRouteHydrationData, t as bindResolvedRouteData, v as getRenderHandler, y as _preloadRouteHandler } from "../resolution-D8PgnTzh.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-8_vHDWqV.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,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as JSXElement, s as Props } from "../
|
|
3
|
-
import { f as QueryPrefetchContext, t as DataRuntime } from "../types-iAmDSV6o.js";
|
|
4
|
-
import { A as RouteHandler, C as Route, J as RouteRequestResult, V as RouteRecord, W as RouteRegistry, g as AccessRedirectDecision, l as DeferredBoundaryRegistration, m as AccessDenyDecision, u as SSRPortalState, w as RouteAuthOptions } from "../index-Izwp_ESC.js";
|
|
5
|
-
import { _ as CoreTelemetry, n as ServerQueryRegistry } from "../index-CPlPDbEY.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-KQ7Vl4-8.js";
|
|
2
|
+
import { r as JSXElement, s as Props } from "../types-DkVJhVs9.js";
|
|
6
3
|
import { AuthContext } from "@askrjs/auth";
|
|
7
4
|
//#region src/common/page-render-envelope.d.ts
|
|
8
5
|
declare const PAGE_RENDER_ENVELOPE_VERSION: 1;
|
|
@@ -47,6 +44,7 @@ interface RenderContext {
|
|
|
47
44
|
ssrPortals: SSRPortalState;
|
|
48
45
|
cspNonce?: string;
|
|
49
46
|
}
|
|
47
|
+
/** Build a fresh SSR render context (data cache, routes, seed) for a render pass. */
|
|
50
48
|
declare function createRenderContext(seed?: number, opts?: {
|
|
51
49
|
url?: string;
|
|
52
50
|
data?: SSRData;
|
|
@@ -67,6 +65,7 @@ declare function createRenderContext(seed?: number, opts?: {
|
|
|
67
65
|
* Concurrency-safe in Node.js via AsyncLocalStorage.
|
|
68
66
|
*/
|
|
69
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. */
|
|
70
69
|
declare function withRenderContextAsync<T>(ctx: RenderContext, fn: () => T | PromiseLike<T>): Promise<T>;
|
|
71
70
|
/**
|
|
72
71
|
* Get the current render context.
|
|
@@ -75,6 +74,7 @@ declare function withRenderContextAsync<T>(ctx: RenderContext, fn: () => T | Pro
|
|
|
75
74
|
declare function getRenderContext(): RenderContext | null;
|
|
76
75
|
//#endregion
|
|
77
76
|
//#region src/ssr/route-render.d.ts
|
|
77
|
+
/** A single path-to-handler route binding accepted by low-level SSR route rendering. */
|
|
78
78
|
type SSRRoute = {
|
|
79
79
|
path: string;
|
|
80
80
|
handler: RouteHandler;
|
|
@@ -102,6 +102,7 @@ type RouteStreamOptions = RouteRenderOptions & {
|
|
|
102
102
|
onChunk(html: string): void;
|
|
103
103
|
onComplete(): void;
|
|
104
104
|
};
|
|
105
|
+
/** Resolve a URL against a route registry for SSR, applying auth/policies before render. */
|
|
105
106
|
declare function resolveRequest(opts: {
|
|
106
107
|
url: string;
|
|
107
108
|
registry: RouteRegistry;
|
|
@@ -129,6 +130,7 @@ type SSRComponent = (props: Props, context?: {
|
|
|
129
130
|
}) => VNode | JSXElement | string | number | boolean | null | undefined;
|
|
130
131
|
//#endregion
|
|
131
132
|
//#region src/ssr/render-sync.d.ts
|
|
133
|
+
/** Synchronously render a component to an HTML string, without route resolution. */
|
|
132
134
|
declare function renderToStringSync(component: (props?: Record<string, unknown>) => VNode | JSXElement | string | number | boolean | null | undefined, props?: Record<string, unknown>, options?: {
|
|
133
135
|
seed?: number;
|
|
134
136
|
data?: SSRData;
|
|
@@ -140,6 +142,7 @@ declare function renderToStringSync(component: (props?: Record<string, unknown>)
|
|
|
140
142
|
}): string;
|
|
141
143
|
//#endregion
|
|
142
144
|
//#region src/ssr/render-resolved.d.ts
|
|
145
|
+
/** Synchronously render an already-resolved route handler to an HTML string. */
|
|
143
146
|
declare function renderResolvedToStringSync(opts: {
|
|
144
147
|
url: string;
|
|
145
148
|
registry: RouteRegistry;
|
|
@@ -155,6 +158,7 @@ declare function renderResolvedToStringSync(opts: {
|
|
|
155
158
|
}): string;
|
|
156
159
|
//#endregion
|
|
157
160
|
//#region src/ssr/route-request-render.d.ts
|
|
161
|
+
/** Options for {@link renderRouteRequest} and {@link renderRouteRequestToString}. */
|
|
158
162
|
interface RenderRouteRequestOptions {
|
|
159
163
|
url: string;
|
|
160
164
|
registry: RouteRegistry;
|
|
@@ -172,6 +176,7 @@ interface RenderRouteRequestOptions {
|
|
|
172
176
|
telemetry?: CoreTelemetry;
|
|
173
177
|
cspNonce?: string;
|
|
174
178
|
}
|
|
179
|
+
/** Outcome of rendering a route request for SSR: a render, redirect, deny, or no-match. */
|
|
175
180
|
type RenderRouteRequestResult = {
|
|
176
181
|
kind: 'render';
|
|
177
182
|
html: string;
|
|
@@ -182,12 +187,18 @@ type RenderRouteRequestResult = {
|
|
|
182
187
|
} | AccessRedirectDecision | AccessDenyDecision | {
|
|
183
188
|
kind: 'no-match';
|
|
184
189
|
};
|
|
190
|
+
/** Resolve and render a route request for SSR, streaming the body when possible. */
|
|
185
191
|
declare function renderRouteRequest(options: RenderRouteRequestOptions): Promise<RenderRouteRequestResult>;
|
|
192
|
+
/** Resolve and render a route request for SSR, always fully buffering the HTML. */
|
|
186
193
|
declare function renderRouteRequestToString(options: RenderRouteRequestOptions): Promise<RenderRouteRequestResult>;
|
|
187
194
|
//#endregion
|
|
188
195
|
//#region src/ssr/index-internal.d.ts
|
|
196
|
+
/**
|
|
197
|
+
* Render a component or route request to a complete HTML string, synchronously.
|
|
198
|
+
*/
|
|
189
199
|
declare function renderToString(component: (props?: Record<string, unknown>) => VNode | JSXElement | string | number | null): string;
|
|
190
200
|
declare function renderToString(opts: RouteRenderOptions): string;
|
|
201
|
+
/** Stream a route request's rendered HTML to the response sink described by `opts`. */
|
|
191
202
|
declare function renderToStream(opts: RouteStreamOptions): void;
|
|
192
203
|
//#endregion
|
|
193
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-8_vHDWqV.js";
|
|
3
3
|
export { SSRDataMissingError, createRenderContext, getRenderContext, renderResolvedToStringSync, renderRouteRequest, renderRouteRequestToString, renderToStream, renderToString, renderToStringSync, resolveRequest, withRenderContext, withRenderContextAsync };
|