@askrjs/askr 0.0.92 → 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-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-DodHdC0L.js → activity-BshyLB3_.js} +4 -2
- package/dist/{activity-DxUcygE5.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 -3
- package/dist/boot/index.js +1 -1
- package/dist/{boot-D71bjP4r.js → boot-BsMB_ySP.js} +21 -15
- package/dist/{cleanup-DAAhJjx5.js → cleanup-DefafSjG.js} +4 -4
- package/dist/{component-cleanup-CJCfu5ed.js → component-cleanup-hrqSikl2.js} +2 -2
- package/dist/{component-internal-DlAkCgBE.js → component-internal-DOVVMjG7.js} +7 -5
- package/dist/components/index.d.ts +7 -2
- package/dist/components/index.js +1 -1
- 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-CdzY49Q2.d.ts → control-DdFw-Caz.d.ts} +1 -1
- package/dist/{control-Dv540XtV.js → control-DqOzkgc7.js} +9 -5
- package/dist/{csp-nonce-ByMbWv8s.js → csp-nonce-BBxq1zq4.js} +8 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/index.js +3 -3
- package/dist/{data-DcikEH9N.js → data-DYqokZzc.js} +15 -4
- package/dist/{data-runtime-oIdQWnPW.js → data-runtime-JxoRgrrt.js} +2 -0
- package/dist/{deferred-B6CafO5u.js → deferred-BS0Xpstg.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-jrliHZmF.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-oswRaMn6.d.ts → index-C29SEGIv.d.ts} +30 -2
- package/dist/{index-BnU0NPwM.d.ts → index-CzH-0LcA.d.ts} +18 -0
- package/dist/{index-DA3g8lm8.d.ts → index-KQ7Vl4-8.d.ts} +414 -5
- 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-Qxq6ABrC.js} +6 -1
- package/dist/{manifest-Dv0bO6kg.js → manifest-D6rfj_jC.js} +4 -0
- package/dist/{navigate-CZHPEUC4.d.ts → navigate-BL_FIIJ6.d.ts} +6 -1
- package/dist/{navigate-BbWj-QU-.js → navigate-CECCMPAr.js} +13 -10
- 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-CLvq458M.js} +10 -10
- package/dist/{resolution-B21kmOkp.js → resolution-D8PgnTzh.js} +11 -5
- package/dist/{resource-operation-CaAttQqz.js → resource-operation-CLQXCn1p.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-8_vHDWqV.js} +18 -10
- package/dist/{state-XPZYUzHL.js → state-DmkGM_LN.js} +3 -3
- package/dist/{structures-DKjkAmM5.js → structures-umvVUD-M.js} +19 -5
- 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-jf8X2V3x.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,7 +1,5 @@
|
|
|
1
|
-
import { i as JSXElementType, r as JSXElement, s as Props } from "./types-
|
|
2
|
-
import
|
|
3
|
-
import { t as Scheduler } from "./scheduler-CmLO4Dfm.js";
|
|
4
|
-
import "./jsx-runtime-C_0v1pMN.js";
|
|
1
|
+
import { i as JSXElementType, r as JSXElement, s as Props } from "./types-DkVJhVs9.js";
|
|
2
|
+
import "./jsx-runtime-BTzDdBJ_.js";
|
|
5
3
|
import { AuthContext, AuthRequirement } from "@askrjs/auth";
|
|
6
4
|
import { InferSchema, ObjectSchema } from "@askrjs/schema";
|
|
7
5
|
//#region src/runtime/state.d.ts
|
|
@@ -59,6 +57,7 @@ declare function state<T>(initialValue: T): StateTuple<T>;
|
|
|
59
57
|
/**
|
|
60
58
|
* Common call contracts: SSR types
|
|
61
59
|
*/
|
|
60
|
+
/** Arbitrary serializable data attached to an SSR render pass (e.g. loader output). */
|
|
62
61
|
type SSRData = Record<string, unknown>;
|
|
63
62
|
/** Styles produced while rendering a request, kept with that request's SSR context. */
|
|
64
63
|
interface SSRStyleRegistration {
|
|
@@ -69,6 +68,7 @@ interface DocumentRenderRoute {
|
|
|
69
68
|
path: string;
|
|
70
69
|
namespace?: string;
|
|
71
70
|
}
|
|
71
|
+
/** Request/render metadata passed to a {@link DocumentRenderer}. */
|
|
72
72
|
interface DocumentRenderContext {
|
|
73
73
|
mode: 'ssr' | 'ssg';
|
|
74
74
|
url: string;
|
|
@@ -82,11 +82,14 @@ interface DocumentRenderContext {
|
|
|
82
82
|
cspNonce?: string;
|
|
83
83
|
styles?: readonly SSRStyleRegistration[];
|
|
84
84
|
}
|
|
85
|
+
/** Arguments passed to a {@link DocumentRenderer}: the rendered app HTML and its context. */
|
|
85
86
|
interface DocumentRenderArgs {
|
|
86
87
|
appHtml: string;
|
|
87
88
|
context: DocumentRenderContext;
|
|
88
89
|
}
|
|
90
|
+
/** Wraps rendered app HTML in a full document (`<html>`, `<head>`, etc.) for SSR/SSG output. */
|
|
89
91
|
type DocumentRenderer = (args: DocumentRenderArgs) => string;
|
|
92
|
+
/** How to react when SSR styles were registered but not included in the rendered document. */
|
|
90
93
|
type SSRStyleRegistrationValidation = 'warn' | 'error' | 'off';
|
|
91
94
|
/** Full context for sink-based streaming SSR */
|
|
92
95
|
type SSRContext = {
|
|
@@ -120,6 +123,7 @@ type ComponentFunction = (props: Props, context?: ComponentContext) => JSXElemen
|
|
|
120
123
|
type ContextKey = symbol;
|
|
121
124
|
type Renderable = RenderableChild;
|
|
122
125
|
type ContextScopeChildren = Renderable | (() => Renderable);
|
|
126
|
+
/** A lexical scope created by {@link defineScope}; render it as a provider component, read it with {@link readScope}. */
|
|
123
127
|
interface Scope<T> {
|
|
124
128
|
(props: {
|
|
125
129
|
value: T;
|
|
@@ -132,7 +136,9 @@ interface ContextFrame {
|
|
|
132
136
|
parent: ContextFrame | null;
|
|
133
137
|
values: Map<ContextKey, unknown> | null;
|
|
134
138
|
}
|
|
139
|
+
/** Create a new lexical {@link Scope} with `defaultValue`, readable via {@link readScope}. */
|
|
135
140
|
declare function defineScope<T>(defaultValue: T): Scope<T>;
|
|
141
|
+
/** Read the current value of a {@link Scope} during component render or an async resource. */
|
|
136
142
|
declare function readScope<T>(context: Scope<T>): T;
|
|
137
143
|
//#endregion
|
|
138
144
|
//#region src/runtime/component-cleanup.d.ts
|
|
@@ -141,16 +147,232 @@ type OwnedChildScope = {
|
|
|
141
147
|
dispose(): void;
|
|
142
148
|
};
|
|
143
149
|
//#endregion
|
|
150
|
+
//#region src/data/types.d.ts
|
|
151
|
+
/** Freshness classification for a {@link Query}'s current data. */
|
|
152
|
+
type QueryConsistency = 'fresh' | 'stale' | 'refreshing' | 'pending-write';
|
|
153
|
+
/** Why a {@link Query} is stale. */
|
|
154
|
+
type QueryStaleReason = 'aborted' | 'error' | 'inconsistent';
|
|
155
|
+
/** Isolated cache/state container backing queries and mutations, e.g. one per test or request. */
|
|
156
|
+
interface DataRuntime {
|
|
157
|
+
readonly queryCache: Map<string, unknown>;
|
|
158
|
+
readonly queryData: Map<string, unknown>;
|
|
159
|
+
/** Test-only query overrides keyed by the canonical query key. */
|
|
160
|
+
readonly queryTestOverrides: Map<string, unknown>;
|
|
161
|
+
/** Test-only mutation overrides keyed by the canonical mutation key. */
|
|
162
|
+
readonly mutationTestOverrides: Map<string, unknown>;
|
|
163
|
+
}
|
|
164
|
+
/** Options for {@link createDataRuntime}. */
|
|
165
|
+
interface DataRuntimeOptions {
|
|
166
|
+
queryCache?: Map<string, unknown>;
|
|
167
|
+
queryData?: Map<string, unknown>;
|
|
168
|
+
queryTestOverrides?: Map<string, unknown>;
|
|
169
|
+
mutationTestOverrides?: Map<string, unknown>;
|
|
170
|
+
}
|
|
171
|
+
/** Reusable query definition for {@link defineQuery}: key, fetcher, and freshness checks. */
|
|
172
|
+
interface QueryDefinition<TInput, TResult extends {}> {
|
|
173
|
+
readonly key: (input: TInput) => string;
|
|
174
|
+
readonly fetch: (context: TInput & {
|
|
175
|
+
signal: AbortSignal;
|
|
176
|
+
}) => Promise<TResult>;
|
|
177
|
+
readonly isConsistent?: (data: TResult) => boolean;
|
|
178
|
+
readonly reconcile?: (data: TResult, context: {
|
|
179
|
+
key: string;
|
|
180
|
+
}) => Promise<boolean> | boolean;
|
|
181
|
+
}
|
|
182
|
+
/** Context passed to server prefetch callbacks, exposing a scoped `prefetch` helper. */
|
|
183
|
+
interface QueryPrefetchContext {
|
|
184
|
+
readonly runtime: DataRuntime;
|
|
185
|
+
readonly request?: Request;
|
|
186
|
+
readonly signal: AbortSignal;
|
|
187
|
+
readonly mode: 'ssr' | 'spa';
|
|
188
|
+
prefetch<TInput, TResult extends {}>(query: QueryDefinition<TInput, TResult>, input: TInput): Promise<boolean>;
|
|
189
|
+
}
|
|
190
|
+
/** Server-side handler that resolves a {@link QueryDefinition}'s data for `serveQuery`. */
|
|
191
|
+
type ServerQueryHandler<TInput, TResult extends {}> = (context: {
|
|
192
|
+
input: TInput;
|
|
193
|
+
request?: Request;
|
|
194
|
+
signal: AbortSignal;
|
|
195
|
+
}) => Promise<TResult> | TResult;
|
|
196
|
+
/** Options for {@link invalidate} and {@link QueryScope.invalidate}. */
|
|
197
|
+
interface InvalidateOptions {
|
|
198
|
+
markPendingWrite?: boolean;
|
|
199
|
+
runtime?: DataRuntime;
|
|
200
|
+
}
|
|
201
|
+
/** Options for {@link invalidateOnInterval}. */
|
|
202
|
+
interface InvalidateOnIntervalOptions extends InvalidateOptions {
|
|
203
|
+
intervalMs: number;
|
|
204
|
+
activeOn?: string | readonly string[];
|
|
205
|
+
visibleOnly?: boolean;
|
|
206
|
+
focusedOnly?: boolean;
|
|
207
|
+
}
|
|
208
|
+
/** A JSON-serializable value usable as part of a query key or invalidation prefix. */
|
|
209
|
+
type QueryKeyPart = string | number | boolean | null | undefined | readonly QueryKeyPart[] | {
|
|
210
|
+
readonly [key: string]: QueryKeyPart;
|
|
211
|
+
};
|
|
212
|
+
/** Namespaced key-building and invalidation helper returned by {@link queryScope}. */
|
|
213
|
+
interface QueryScope {
|
|
214
|
+
key(...parts: QueryKeyPart[]): string;
|
|
215
|
+
prefix(...parts: QueryKeyPart[]): string;
|
|
216
|
+
invalidate(parts: readonly QueryKeyPart[], options?: InvalidateOptions): void;
|
|
217
|
+
}
|
|
218
|
+
type QueryControls = {
|
|
219
|
+
refresh(): Promise<void>;
|
|
220
|
+
};
|
|
221
|
+
type QueryLoading = {
|
|
222
|
+
data: null;
|
|
223
|
+
error: null;
|
|
224
|
+
loading: true;
|
|
225
|
+
refreshing: false;
|
|
226
|
+
stale: false;
|
|
227
|
+
consistency: 'fresh';
|
|
228
|
+
staleReason: null;
|
|
229
|
+
};
|
|
230
|
+
type QueryFresh<T> = {
|
|
231
|
+
data: T;
|
|
232
|
+
error: null;
|
|
233
|
+
loading: false;
|
|
234
|
+
refreshing: false;
|
|
235
|
+
stale: false;
|
|
236
|
+
consistency: 'fresh';
|
|
237
|
+
staleReason: null;
|
|
238
|
+
};
|
|
239
|
+
type QueryRefreshing<T> = {
|
|
240
|
+
data: T;
|
|
241
|
+
error: null;
|
|
242
|
+
loading: false;
|
|
243
|
+
refreshing: true;
|
|
244
|
+
stale: true;
|
|
245
|
+
consistency: 'refreshing';
|
|
246
|
+
staleReason: null;
|
|
247
|
+
};
|
|
248
|
+
type QueryPendingWrite<T> = {
|
|
249
|
+
data: T;
|
|
250
|
+
error: null;
|
|
251
|
+
loading: false;
|
|
252
|
+
refreshing: true;
|
|
253
|
+
stale: true;
|
|
254
|
+
consistency: 'pending-write';
|
|
255
|
+
staleReason: null;
|
|
256
|
+
};
|
|
257
|
+
type QueryStaleValue<T> = {
|
|
258
|
+
data: T;
|
|
259
|
+
error: null;
|
|
260
|
+
loading: false;
|
|
261
|
+
refreshing: false;
|
|
262
|
+
stale: true;
|
|
263
|
+
consistency: 'stale';
|
|
264
|
+
staleReason: 'aborted' | 'inconsistent';
|
|
265
|
+
};
|
|
266
|
+
type QueryStaleErrorWithValue<T> = {
|
|
267
|
+
data: T;
|
|
268
|
+
error: {};
|
|
269
|
+
loading: false;
|
|
270
|
+
refreshing: false;
|
|
271
|
+
stale: true;
|
|
272
|
+
consistency: 'stale';
|
|
273
|
+
staleReason: 'error';
|
|
274
|
+
};
|
|
275
|
+
type QueryStaleError = {
|
|
276
|
+
data: null;
|
|
277
|
+
error: {};
|
|
278
|
+
loading: false;
|
|
279
|
+
refreshing: false;
|
|
280
|
+
stale: true;
|
|
281
|
+
consistency: 'stale';
|
|
282
|
+
staleReason: 'error';
|
|
283
|
+
};
|
|
284
|
+
/** Reactive read state for a query cell: data, loading/refresh flags, and freshness. */
|
|
285
|
+
type Query<T extends {}> = QueryControls & (QueryLoading | QueryFresh<T> | QueryRefreshing<T> | QueryPendingWrite<T> | QueryStaleValue<T> | QueryStaleErrorWithValue<T> | QueryStaleError);
|
|
286
|
+
type MutationControls<TInput, TResult> = {
|
|
287
|
+
execute(input: TInput): Promise<TResult>;
|
|
288
|
+
abort(): void;
|
|
289
|
+
reset(): void;
|
|
290
|
+
};
|
|
291
|
+
type MutationIdle = {
|
|
292
|
+
status: 'idle';
|
|
293
|
+
pending: false;
|
|
294
|
+
error: null;
|
|
295
|
+
result: null;
|
|
296
|
+
};
|
|
297
|
+
type MutationPending = {
|
|
298
|
+
status: 'pending';
|
|
299
|
+
pending: true;
|
|
300
|
+
error: null;
|
|
301
|
+
result: null;
|
|
302
|
+
};
|
|
303
|
+
type MutationSuccess<TResult> = {
|
|
304
|
+
status: 'success';
|
|
305
|
+
pending: false;
|
|
306
|
+
error: null;
|
|
307
|
+
result: TResult;
|
|
308
|
+
};
|
|
309
|
+
type MutationError = {
|
|
310
|
+
status: 'error';
|
|
311
|
+
pending: false;
|
|
312
|
+
error: {};
|
|
313
|
+
result: null;
|
|
314
|
+
};
|
|
315
|
+
/** Reactive state for a mutation cell: status, error/result, and execute/abort/reset controls. */
|
|
316
|
+
type Mutation<TInput, TResult> = MutationControls<TInput, TResult> & (MutationIdle | MutationPending | MutationSuccess<TResult> | MutationError);
|
|
317
|
+
type QueryOptions<T> = {
|
|
318
|
+
key: string;
|
|
319
|
+
fetch: (ctx: {
|
|
320
|
+
signal: AbortSignal;
|
|
321
|
+
}) => Promise<T>;
|
|
322
|
+
isConsistent?: (data: T) => boolean;
|
|
323
|
+
reconcile?: (data: T, ctx: {
|
|
324
|
+
key: string;
|
|
325
|
+
}) => Promise<boolean> | boolean;
|
|
326
|
+
runtime?: DataRuntime;
|
|
327
|
+
initialData?: T;
|
|
328
|
+
skipInitialFetch?: boolean;
|
|
329
|
+
};
|
|
330
|
+
/** Options for {@link createMutation}. */
|
|
331
|
+
type MutationOptions<TInput, TResult> = {
|
|
332
|
+
/** Stable identity used by runtime-scoped mutation test overrides. */
|
|
333
|
+
key?: string;
|
|
334
|
+
action: (input: TInput, ctx: {
|
|
335
|
+
signal: AbortSignal;
|
|
336
|
+
}) => Promise<TResult>;
|
|
337
|
+
affects?: (input: TInput, result: TResult) => string[];
|
|
338
|
+
afterSuccess?: 'invalidate';
|
|
339
|
+
runtime?: DataRuntime;
|
|
340
|
+
};
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/common/telemetry.d.ts
|
|
343
|
+
interface TelemetryFields {
|
|
344
|
+
requestId?: string;
|
|
345
|
+
traceId?: string;
|
|
346
|
+
route?: string;
|
|
347
|
+
action?: string;
|
|
348
|
+
operation?: string;
|
|
349
|
+
status?: number;
|
|
350
|
+
durationMs?: number;
|
|
351
|
+
}
|
|
352
|
+
type TelemetrySpan = <T>(fields: TelemetryFields, work: () => T) => T;
|
|
353
|
+
/**
|
|
354
|
+
* Structural subset implemented by `createTelemetry()` from `@askrjs/otel`.
|
|
355
|
+
* Core does not install an OpenTelemetry SDK, backend, or exporter.
|
|
356
|
+
*/
|
|
357
|
+
interface CoreTelemetry {
|
|
358
|
+
routeMatch?: TelemetrySpan;
|
|
359
|
+
loader?: TelemetrySpan;
|
|
360
|
+
queryPrefetch?: TelemetrySpan;
|
|
361
|
+
ssrRender?: TelemetrySpan;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
144
364
|
//#region src/common/router.d.ts
|
|
145
365
|
/**
|
|
146
366
|
* Common call contracts: Router types
|
|
147
367
|
*/
|
|
368
|
+
/** Path parameters captured for a matched route, keyed by parameter name. */
|
|
148
369
|
type RouteParams = Record<string, string>;
|
|
149
370
|
type StripRoutePathSuffix<Path extends string> = Path extends `${infer Base}?${string}` ? StripRoutePathSuffix<Base> : Path extends `${infer Base}#${string}` ? StripRoutePathSuffix<Base> : Path;
|
|
150
371
|
type TrimRoutePathSlashes<Path extends string> = Path extends `/${infer Rest}` ? TrimRoutePathSlashes<Rest> : Path extends `${infer Rest}/` ? TrimRoutePathSlashes<Rest> : Path;
|
|
151
372
|
type TrimRoutePathWhitespace<Path extends string> = Path extends `${' ' | '\n' | '\t' | '\r'}${infer Rest}` ? TrimRoutePathWhitespace<Rest> : Path extends `${infer Rest}${' ' | '\n' | '\t' | '\r'}` ? TrimRoutePathWhitespace<Rest> : Path;
|
|
152
373
|
type ExtractRouteSegmentParam<Segment extends string> = Segment extends `{${infer Param}}` ? TrimRoutePathWhitespace<Param> extends `*${infer SplatParam}` ? TrimRoutePathWhitespace<SplatParam> extends '' ? never : TrimRoutePathWhitespace<SplatParam> extends '*' ? never : TrimRoutePathWhitespace<SplatParam> : TrimRoutePathWhitespace<Param> extends '' ? never : TrimRoutePathWhitespace<Param> : Segment extends '*' ? '*' : never;
|
|
153
374
|
type ExtractRoutePathParamNames<Path extends string> = TrimRoutePathSlashes<StripRoutePathSuffix<Path>> extends `${infer Segment}/${infer Rest}` ? ExtractRouteSegmentParam<Segment> | ExtractRoutePathParamNames<Rest> : ExtractRouteSegmentParam<TrimRoutePathSlashes<StripRoutePathSuffix<Path>>>;
|
|
375
|
+
/** Statically infers the param record shape from a route path string literal, e.g. `/posts/{id}`. */
|
|
154
376
|
type RoutePathParams<Path extends string> = [ExtractRoutePathParamNames<Path>] extends [never] ? Record<never, string> : { [Key in ExtractRoutePathParamNames<Path>]: string; };
|
|
155
377
|
/**
|
|
156
378
|
* A route page component: a regular component that receives route params as
|
|
@@ -160,23 +382,28 @@ type RoutePathParams<Path extends string> = [ExtractRoutePathParamNames<Path>] e
|
|
|
160
382
|
* assignable.
|
|
161
383
|
*/
|
|
162
384
|
type RouteComponent<TParams extends RouteParams = RouteParams> = (props: TParams) => RenderableChild;
|
|
385
|
+
/** The rendering mode a route is currently being evaluated under. */
|
|
163
386
|
type RouteMode = 'spa' | 'ssr' | 'ssg';
|
|
164
387
|
type AccessRedirectStatus = 301 | 302 | 303 | 307 | 308;
|
|
165
388
|
type AccessDenyStatus = 401 | 403 | 404;
|
|
166
389
|
interface AccessAllowDecision {
|
|
167
390
|
kind: 'allow';
|
|
168
391
|
}
|
|
392
|
+
/** Policy decision produced by {@link redirect}: sends the visitor to another URL. */
|
|
169
393
|
interface AccessRedirectDecision {
|
|
170
394
|
kind: 'redirect';
|
|
171
395
|
to: string;
|
|
172
396
|
status?: AccessRedirectStatus;
|
|
173
397
|
replace?: boolean;
|
|
174
398
|
}
|
|
399
|
+
/** Policy decision produced by {@link deny}/{@link unauthorized}/{@link forbidden}/{@link notFound}. */
|
|
175
400
|
interface AccessDenyDecision {
|
|
176
401
|
kind: 'deny';
|
|
177
402
|
status: AccessDenyStatus;
|
|
178
403
|
}
|
|
404
|
+
/** Outcome of a {@link RoutePolicy} evaluation: allow, redirect, or deny. */
|
|
179
405
|
type AccessDecision = AccessAllowDecision | AccessRedirectDecision | AccessDenyDecision;
|
|
406
|
+
/** Context passed to route policies, auth resolvers, and loaders. */
|
|
180
407
|
interface RouteContext<TParams extends RouteParams = RouteParams> {
|
|
181
408
|
mode: RouteMode;
|
|
182
409
|
params: TParams;
|
|
@@ -187,8 +414,11 @@ interface RouteContext<TParams extends RouteParams = RouteParams> {
|
|
|
187
414
|
auth: AuthContext;
|
|
188
415
|
signal: AbortSignal;
|
|
189
416
|
}
|
|
417
|
+
/** A route access-control check, evaluated against {@link RouteContext} to produce an {@link AccessDecision}. */
|
|
190
418
|
type RoutePolicy = (context: RouteContext) => AccessDecision | PromiseLike<AccessDecision>;
|
|
419
|
+
/** Resolves the {@link AuthContext} for a route request. */
|
|
191
420
|
type RouteAuthResolver = (context: Omit<RouteContext, 'auth'>) => AuthContext | PromiseLike<AuthContext>;
|
|
421
|
+
/** Auth configuration shared across a route registry or a single route. */
|
|
192
422
|
interface RouteAuthOptions {
|
|
193
423
|
resolve: RouteAuthResolver;
|
|
194
424
|
loginPath?: string | ((context: RouteContext) => string | PromiseLike<string>);
|
|
@@ -198,6 +428,7 @@ interface CommonAccessOptions {
|
|
|
198
428
|
auth?: AuthRequirement;
|
|
199
429
|
policies?: readonly RoutePolicy[];
|
|
200
430
|
}
|
|
431
|
+
/** A route's metadata, or a function computing it from the resolved context. */
|
|
201
432
|
type RouteMetaSource<TParams extends RouteParams = RouteParams> = RouteMeta | ((context: RouteContext<TParams>) => RouteMeta | PromiseLike<RouteMeta>);
|
|
202
433
|
/**
|
|
203
434
|
* Options for `route()` declarations.
|
|
@@ -253,7 +484,9 @@ interface RouteMeta {
|
|
|
253
484
|
}
|
|
254
485
|
/** A stable, typed reference returned by route() for destination construction. */
|
|
255
486
|
type RouteSearchValue = string | number | boolean | null | undefined | readonly (string | number | boolean | null)[];
|
|
487
|
+
/** A route's query-string parameters, keyed by name. */
|
|
256
488
|
type RouteSearch = Record<string, RouteSearchValue>;
|
|
489
|
+
/** Stable, typed reference to a route returned by `route()`, used to build destinations. */
|
|
257
490
|
interface RouteRef<TParams extends RouteParams = RouteParams, TSearch = RouteSearch> {
|
|
258
491
|
readonly path: string;
|
|
259
492
|
/** @internal Executable schema retained for destination validation. */
|
|
@@ -264,9 +497,11 @@ interface RouteRef<TParams extends RouteParams = RouteParams, TSearch = RouteSea
|
|
|
264
497
|
readonly __search?: TSearch;
|
|
265
498
|
}
|
|
266
499
|
type RouteRefSearch<TSchema extends ObjectSchema<RouteSearch> | undefined> = TSchema extends ObjectSchema<RouteSearch> ? InferSchema<TSchema> : RouteSearch;
|
|
500
|
+
/** A resolved navigation target with a computed `href`, produced by {@link to}. */
|
|
267
501
|
interface RouteDestination {
|
|
268
502
|
readonly href: string;
|
|
269
503
|
}
|
|
504
|
+
/** Options accepted by the `page()` route-declaration helper. */
|
|
270
505
|
interface PageHelperOptions extends CommonAccessOptions {
|
|
271
506
|
preload?: (context: RouteContext & {
|
|
272
507
|
request?: Request;
|
|
@@ -298,12 +533,15 @@ interface LayoutScopeRecord {
|
|
|
298
533
|
interface PageScopeRecord {
|
|
299
534
|
component: RouteComponent;
|
|
300
535
|
}
|
|
536
|
+
/** Options for {@link createRouteRegistry}. */
|
|
301
537
|
interface RouteRegistryOptions {
|
|
302
538
|
auth?: RouteAuthOptions;
|
|
303
539
|
/** Public pathname prefix for applications mounted below the origin root. */
|
|
304
540
|
basePath?: string;
|
|
305
541
|
}
|
|
542
|
+
/** A callback that declares routes via `route()`/`page()`/`group()`, passed to {@link createRouteRegistry}. */
|
|
306
543
|
type RouteDefinition = () => void;
|
|
544
|
+
/** Options for resolving a route request (used internally by `createSPA`/`hydrateSPA`/SSR). */
|
|
307
545
|
interface RouteRequestOptions {
|
|
308
546
|
/** Explicit route source shared by the application renderers. */
|
|
309
547
|
registry: RouteRegistry;
|
|
@@ -316,13 +554,16 @@ interface RouteRequestOptions {
|
|
|
316
554
|
request?: Request;
|
|
317
555
|
telemetry?: CoreTelemetry;
|
|
318
556
|
}
|
|
557
|
+
/** A resolved route request that should render `handler` with `params`. */
|
|
319
558
|
interface RouteRenderResult<TParams extends RouteParams = RouteParams> {
|
|
320
559
|
kind: 'render';
|
|
321
560
|
handler: RouteHandler<TParams>;
|
|
322
561
|
params: TParams;
|
|
323
562
|
record?: RouteRecord;
|
|
324
563
|
}
|
|
564
|
+
/** Outcome of resolving a route request: render, redirect, deny, or no match. */
|
|
325
565
|
type RouteRequestResult<TParams extends RouteParams = RouteParams> = RouteRenderResult<TParams> | AccessRedirectDecision | AccessDenyDecision | null;
|
|
566
|
+
/** Options accepted by the `group()` route-declaration helper. */
|
|
326
567
|
interface GroupHelperOptions extends CommonAccessOptions {
|
|
327
568
|
layout?: (props: {
|
|
328
569
|
children?: RenderableChild;
|
|
@@ -381,34 +622,40 @@ interface RouteManifest {
|
|
|
381
622
|
basePath?: string;
|
|
382
623
|
}
|
|
383
624
|
declare const routeRegistryBrand: unique symbol;
|
|
625
|
+
/** A function rendering a matched route's page content, with layouts already composed. */
|
|
384
626
|
interface RouteHandler<TParams extends RouteParams = RouteParams> {
|
|
385
627
|
(params: TParams, context?: {
|
|
386
628
|
signal: AbortSignal;
|
|
387
629
|
}): RenderableChild;
|
|
388
630
|
}
|
|
631
|
+
/** A single path-to-handler binding as seen by low-level navigation code. */
|
|
389
632
|
interface Route<TParams extends RouteParams = RouteParams> {
|
|
390
633
|
path: string;
|
|
391
634
|
handler: RouteHandler<TParams>;
|
|
392
635
|
namespace?: string;
|
|
393
636
|
}
|
|
637
|
+
/** Opaque handle produced by {@link createRouteRegistry}, required by `createSPA`/`hydrateSPA`. */
|
|
394
638
|
interface RouteRegistry {
|
|
395
639
|
/** Internal brand: registries must come from createRouteRegistry(). */
|
|
396
640
|
readonly [routeRegistryBrand]: true;
|
|
397
641
|
manifest: RouteManifest;
|
|
398
642
|
routes: readonly Route[];
|
|
399
643
|
}
|
|
644
|
+
/** A single matched route, as reported by {@link currentRoute} and activity predicates. */
|
|
400
645
|
interface RouteMatch<TParams extends RouteParams = RouteParams> {
|
|
401
646
|
path: string;
|
|
402
647
|
params: Readonly<TParams>;
|
|
403
648
|
name?: string;
|
|
404
649
|
namespace?: string;
|
|
405
650
|
}
|
|
651
|
+
/** Read-only accessor for the current route's query-string parameters. */
|
|
406
652
|
interface RouteQuery {
|
|
407
653
|
get(key: string): string | null;
|
|
408
654
|
getAll(key: string): string[];
|
|
409
655
|
has(key: string): boolean;
|
|
410
656
|
toJSON(): Record<string, string | string[]>;
|
|
411
657
|
}
|
|
658
|
+
/** Full description of the currently active route, returned by {@link currentRoute}. */
|
|
412
659
|
interface RouteSnapshot<TParams extends RouteParams = RouteParams> {
|
|
413
660
|
path: string;
|
|
414
661
|
params: Readonly<TParams>;
|
|
@@ -514,6 +761,70 @@ interface ReadableSource<T = unknown> {
|
|
|
514
761
|
_version?: number;
|
|
515
762
|
}
|
|
516
763
|
//#endregion
|
|
764
|
+
//#region src/runtime/scheduler.d.ts
|
|
765
|
+
/**
|
|
766
|
+
* Serialized update scheduler — safer design (no inline execution, explicit flush)
|
|
767
|
+
*
|
|
768
|
+
* Key ideas:
|
|
769
|
+
* - Never execute a task inline from `enqueue`.
|
|
770
|
+
* - `flush()` is explicit and non-reentrant.
|
|
771
|
+
* - `runWithSyncProgress()` allows enqueues temporarily but does not run tasks
|
|
772
|
+
* inline; it runs `fn` and then does an explicit `flush()`.
|
|
773
|
+
* - `waitForFlush()` is race-free with a monotonic `flushVersion`.
|
|
774
|
+
*/
|
|
775
|
+
type Task = () => void;
|
|
776
|
+
type SchedulerLane = 'derived' | 'component' | 'reactive' | 'post';
|
|
777
|
+
type SchedulerBulkCommitProbe = () => boolean;
|
|
778
|
+
declare class Scheduler {
|
|
779
|
+
private bulkCommitProbe;
|
|
780
|
+
private lanes;
|
|
781
|
+
private running;
|
|
782
|
+
private inHandler;
|
|
783
|
+
private depth;
|
|
784
|
+
private executionDepth;
|
|
785
|
+
private flushVersion;
|
|
786
|
+
private kickScheduled;
|
|
787
|
+
private allowSyncProgress;
|
|
788
|
+
private waiters;
|
|
789
|
+
private taskCount;
|
|
790
|
+
setBulkCommitProbe(probe: SchedulerBulkCommitProbe): void;
|
|
791
|
+
private isBulkCommitActive;
|
|
792
|
+
private hasPendingTasks;
|
|
793
|
+
private getPendingTaskCount;
|
|
794
|
+
private compactLane;
|
|
795
|
+
private scheduleFlushKick;
|
|
796
|
+
enqueue(task: Task): void;
|
|
797
|
+
enqueueInLane(lane: SchedulerLane, task: Task): void;
|
|
798
|
+
flush(): void;
|
|
799
|
+
runWithSyncProgress<T>(fn: () => T): T;
|
|
800
|
+
waitForFlush(targetVersion?: number, timeoutMs?: number): Promise<void>;
|
|
801
|
+
getState(): {
|
|
802
|
+
queueLength: number;
|
|
803
|
+
running: boolean;
|
|
804
|
+
depth: number;
|
|
805
|
+
executionDepth: number;
|
|
806
|
+
taskCount: number;
|
|
807
|
+
flushVersion: number;
|
|
808
|
+
laneQueues: {
|
|
809
|
+
derived: number;
|
|
810
|
+
component: number;
|
|
811
|
+
reactive: number;
|
|
812
|
+
post: number;
|
|
813
|
+
};
|
|
814
|
+
inHandler: boolean;
|
|
815
|
+
allowSyncProgress: boolean;
|
|
816
|
+
};
|
|
817
|
+
getFlushVersion(): number;
|
|
818
|
+
flushIfQueued(): void;
|
|
819
|
+
runInHandlerScope<T>(fn: () => T, flushMode?: 'defer' | 'sync'): T;
|
|
820
|
+
setInHandler(v: boolean): void;
|
|
821
|
+
isInHandler(): boolean;
|
|
822
|
+
isExecuting(): boolean;
|
|
823
|
+
clearPendingSyncTasks(): number;
|
|
824
|
+
private resolveWaiters;
|
|
825
|
+
}
|
|
826
|
+
declare function scheduleEventHandler(handler: EventListener): EventListener;
|
|
827
|
+
//#endregion
|
|
517
828
|
//#region src/common/dom-range.d.ts
|
|
518
829
|
/**
|
|
519
830
|
* Internal DOM range shape shared by runtime ownership records and the
|
|
@@ -562,6 +873,7 @@ interface ChildScopeTransactionSnapshot {
|
|
|
562
873
|
}
|
|
563
874
|
//#endregion
|
|
564
875
|
//#region src/runtime/runtime.d.ts
|
|
876
|
+
/** Diagnostic breakdown of a keyed-list reorder decision, returned by {@link RuntimeRendererHost.isKeyedReorderFastPathEligible}. */
|
|
565
877
|
interface RuntimeKeyedReorderDecision {
|
|
566
878
|
useFastPath: boolean;
|
|
567
879
|
totalKeyed: number;
|
|
@@ -572,6 +884,7 @@ interface RuntimeKeyedReorderDecision {
|
|
|
572
884
|
hasPropChanges: boolean;
|
|
573
885
|
isWholeKeyedList: boolean;
|
|
574
886
|
}
|
|
887
|
+
/** The renderer implementation an {@link AskrRuntime} delegates DOM evaluation and cleanup to. */
|
|
575
888
|
interface RuntimeRendererHost {
|
|
576
889
|
evaluate(node: unknown, target: Element | null, context?: object, retainedOwner?: ComponentInstance): void;
|
|
577
890
|
cleanupInstancesUnder(node: Node): void;
|
|
@@ -583,10 +896,12 @@ interface RuntimeRendererHost {
|
|
|
583
896
|
isKeyedReorderFastPathEligible(parent: Element, children: unknown[], oldKeyMap: Map<string | number, Element> | undefined): RuntimeKeyedReorderDecision;
|
|
584
897
|
markReactivePropsDirtySource(source: ReadableSource<unknown>): void;
|
|
585
898
|
}
|
|
899
|
+
/** Options for {@link createRuntime}. */
|
|
586
900
|
interface AskrRuntimeOptions {
|
|
587
901
|
scheduler?: Scheduler;
|
|
588
902
|
renderer?: RuntimeRendererHost;
|
|
589
903
|
}
|
|
904
|
+
/** A scheduler + renderer host pairing; owns scheduling and renderer wiring for an app instance. */
|
|
590
905
|
declare class AskrRuntime {
|
|
591
906
|
readonly scheduler: Scheduler;
|
|
592
907
|
private rendererHost;
|
|
@@ -594,7 +909,9 @@ declare class AskrRuntime {
|
|
|
594
909
|
get renderer(): RuntimeRendererHost;
|
|
595
910
|
configureRenderer(renderer: RuntimeRendererHost): void;
|
|
596
911
|
}
|
|
912
|
+
/** Create a new {@link AskrRuntime} instance with its own scheduler/renderer wiring. */
|
|
597
913
|
declare function createRuntime(options?: AskrRuntimeOptions): AskrRuntime;
|
|
914
|
+
/** Get the process-wide default {@link AskrRuntime}. */
|
|
598
915
|
declare function getDefaultRuntime(): AskrRuntime;
|
|
599
916
|
//#endregion
|
|
600
917
|
//#region src/runtime/for-signals.d.ts
|
|
@@ -786,6 +1103,7 @@ type SnapshotSourceBrand = {
|
|
|
786
1103
|
};
|
|
787
1104
|
//#endregion
|
|
788
1105
|
//#region src/runtime/derive.d.ts
|
|
1106
|
+
/** A reactive derived value produced by {@link derive}; call it to read the current result. */
|
|
789
1107
|
interface Derived<T> extends ReadableSource<T> {
|
|
790
1108
|
(): T;
|
|
791
1109
|
}
|
|
@@ -813,6 +1131,7 @@ interface RenderDiagnosticsOptions {
|
|
|
813
1131
|
declare function configureRenderDiagnostics(options: RenderDiagnosticsOptions): () => void;
|
|
814
1132
|
//#endregion
|
|
815
1133
|
//#region src/runtime/selector.d.ts
|
|
1134
|
+
/** A fine-grained reactive membership check produced by {@link selector}. */
|
|
816
1135
|
interface Selector<T> {
|
|
817
1136
|
(candidate: T): boolean;
|
|
818
1137
|
}
|
|
@@ -851,35 +1170,50 @@ type IndexedForProps<T> = ForBaseProps<T> & {
|
|
|
851
1170
|
by?: never;
|
|
852
1171
|
byIndex: true;
|
|
853
1172
|
};
|
|
1173
|
+
/** Props for {@link For}. */
|
|
854
1174
|
type ForProps<T, K extends string | number = string | number> = KeyedForProps<T, K> | IndexedForProps<T>;
|
|
1175
|
+
/** Render a keyed or indexed list, reconciling items by key instead of position. */
|
|
855
1176
|
declare const For: <T, K extends string | number = string | number>(props: ForProps<T, K>) => JSXElement;
|
|
856
1177
|
//#endregion
|
|
857
1178
|
//#region src/control/show.d.ts
|
|
858
1179
|
type ShowSource<T> = T | (() => T);
|
|
859
1180
|
type Truthy<T> = T extends false | '' | 0 | 0n | null | undefined ? never : T;
|
|
1181
|
+
/** Props for {@link Show}. */
|
|
860
1182
|
type ShowProps<T> = {
|
|
861
1183
|
when: ShowSource<T>;
|
|
862
1184
|
fallback?: BoundaryChild;
|
|
863
1185
|
children: BoundaryChild | ((value: Truthy<T>) => BoundaryChild);
|
|
864
1186
|
};
|
|
1187
|
+
/** Conditionally render children based on `when`, narrowing truthy values for the render function form. */
|
|
865
1188
|
declare const Show: <T>(props: ShowProps<T>) => JSXElement;
|
|
866
1189
|
//#endregion
|
|
867
1190
|
//#region src/control/case.d.ts
|
|
868
1191
|
type MatchChild = BoundaryChild | (() => BoundaryChild);
|
|
1192
|
+
/** Props for {@link Match}, valid only as a direct child of {@link Case}. */
|
|
869
1193
|
type MatchProps = {
|
|
870
1194
|
key?: string | number | null;
|
|
871
1195
|
when: unknown;
|
|
872
1196
|
children: MatchChild;
|
|
873
1197
|
};
|
|
1198
|
+
/** Props for {@link Case}. */
|
|
874
1199
|
type CaseProps = {
|
|
875
1200
|
fallback?: BoundaryChild;
|
|
876
1201
|
children?: unknown;
|
|
877
1202
|
};
|
|
1203
|
+
/** Declares one branch of a {@link Case}; only valid as its direct child. */
|
|
878
1204
|
declare function Match(_props: MatchProps): null;
|
|
1205
|
+
/** Render the first matching {@link Match} child (by `when`), or `fallback` if none match. */
|
|
879
1206
|
declare const Case: (props: CaseProps) => JSXElement;
|
|
880
1207
|
//#endregion
|
|
881
1208
|
//#region src/csp-nonce.d.ts
|
|
1209
|
+
/** Lexical scope carrying the CSP nonce for the current render, if any. */
|
|
882
1210
|
declare const CspNonceScope: Scope<string | undefined>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Read the CSP nonce for the current render from {@link CspNonceScope}.
|
|
1213
|
+
*
|
|
1214
|
+
* @returns The active nonce, or `undefined` when called outside of a
|
|
1215
|
+
* component render or when no nonce was configured.
|
|
1216
|
+
*/
|
|
883
1217
|
declare function cspNonce(): string | undefined;
|
|
884
1218
|
//#endregion
|
|
885
1219
|
//#region src/common/render-context.d.ts
|
|
@@ -915,14 +1249,87 @@ declare function registerSSRStyle(id: string, cssText: string): void;
|
|
|
915
1249
|
interface Ref<T extends Element = Element> {
|
|
916
1250
|
current: T | null;
|
|
917
1251
|
}
|
|
1252
|
+
/** Create a new, empty {@link Ref} holder. */
|
|
918
1253
|
declare function createRef<T extends Element = Element>(): Ref<T>;
|
|
919
1254
|
//#endregion
|
|
1255
|
+
//#region src/data/mutation-cell.d.ts
|
|
1256
|
+
/**
|
|
1257
|
+
* Create a reactive {@link Mutation} cell bound to the current component,
|
|
1258
|
+
* running `options.action` on `execute()` and optionally invalidating
|
|
1259
|
+
* affected query prefixes on success.
|
|
1260
|
+
*/
|
|
1261
|
+
declare function createMutation<TInput, TResult>(options: MutationOptions<TInput, TResult>): Mutation<TInput, TResult>;
|
|
1262
|
+
//#endregion
|
|
1263
|
+
//#region src/data/query-cell.d.ts
|
|
1264
|
+
/**
|
|
1265
|
+
* Create a reactive {@link Query} cell bound to the current component, either
|
|
1266
|
+
* from inline `options` (key + fetch) or a reusable {@link QueryDefinition}
|
|
1267
|
+
* plus its input.
|
|
1268
|
+
*/
|
|
1269
|
+
declare function createQuery<T extends {}>(options: QueryOptions<T>): Query<T>;
|
|
1270
|
+
declare function createQuery<TInput, TResult extends {}>(definition: QueryDefinition<TInput, TResult>, input: TInput, options?: Omit<QueryOptions<TResult>, 'key' | 'fetch'>): Query<TResult>;
|
|
1271
|
+
//#endregion
|
|
1272
|
+
//#region src/data/data-runtime.d.ts
|
|
1273
|
+
/** Create a new, isolated {@link DataRuntime} with its own query/mutation caches. */
|
|
1274
|
+
declare function createDataRuntime(options?: DataRuntimeOptions): DataRuntime;
|
|
1275
|
+
/** Get the process-wide default {@link DataRuntime} used when none is provided explicitly. */
|
|
1276
|
+
declare function getDefaultDataRuntime(): DataRuntime;
|
|
1277
|
+
//#endregion
|
|
1278
|
+
//#region src/data/invalidation.d.ts
|
|
1279
|
+
/** Mark all cached queries whose key starts with `prefix` as stale, triggering a refresh. */
|
|
1280
|
+
declare function invalidate(prefix: string, options?: InvalidateOptions): void;
|
|
1281
|
+
/** Create a {@link QueryScope} that namespaces keys and invalidations under `namespace`. */
|
|
1282
|
+
declare function queryScope(namespace: string): QueryScope;
|
|
1283
|
+
/**
|
|
1284
|
+
* Periodically invalidate queries matching `prefix` on a fixed interval,
|
|
1285
|
+
* optionally gated by active route, document visibility, or window focus.
|
|
1286
|
+
*/
|
|
1287
|
+
declare function invalidateOnInterval(prefix: string, options: InvalidateOnIntervalOptions): void;
|
|
1288
|
+
//#endregion
|
|
1289
|
+
//#region src/data/query-registry.d.ts
|
|
1290
|
+
/** Lookup table of server handlers keyed by their {@link QueryDefinition}, built by {@link defineServerQueries}. */
|
|
1291
|
+
interface ServerQueryRegistry {
|
|
1292
|
+
readonly entries: readonly ServerQueryEntry<unknown, {}>[];
|
|
1293
|
+
get<TInput, TResult extends {}>(query: QueryDefinition<TInput, TResult>): ServerQueryHandler<TInput, TResult> | undefined;
|
|
1294
|
+
}
|
|
1295
|
+
/** A query paired with the server handler that resolves it, produced by {@link serveQuery}. */
|
|
1296
|
+
interface ServerQueryEntry<TInput, TResult extends {}> {
|
|
1297
|
+
readonly query: QueryDefinition<TInput, TResult>;
|
|
1298
|
+
readonly handler: ServerQueryHandler<TInput, TResult>;
|
|
1299
|
+
}
|
|
1300
|
+
/** Pair a {@link QueryDefinition} with the server-side handler that resolves it. */
|
|
1301
|
+
declare function serveQuery<TInput, TResult extends {}>(query: QueryDefinition<TInput, TResult>, handler: ServerQueryHandler<TInput, TResult>): ServerQueryEntry<TInput, TResult>;
|
|
1302
|
+
/** Build a {@link ServerQueryRegistry} from one or more {@link serveQuery} entries. */
|
|
1303
|
+
declare function defineServerQueries(...entries: readonly ServerQueryEntry<any, any>[]): ServerQueryRegistry;
|
|
1304
|
+
/** Freeze and return a reusable {@link QueryDefinition}. */
|
|
1305
|
+
declare function defineQuery<TInput, TResult extends {}>(definition: QueryDefinition<TInput, TResult>): QueryDefinition<TInput, TResult>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Create a {@link QueryPrefetchContext} for prefetching query data ahead of
|
|
1308
|
+
* render, e.g. during SSR route resolution.
|
|
1309
|
+
*/
|
|
1310
|
+
declare function createQueryPrefetchContext(options?: {
|
|
1311
|
+
runtime?: DataRuntime;
|
|
1312
|
+
registry?: ServerQueryRegistry;
|
|
1313
|
+
request?: Request;
|
|
1314
|
+
signal?: AbortSignal;
|
|
1315
|
+
mode?: 'ssr' | 'spa';
|
|
1316
|
+
telemetry?: CoreTelemetry;
|
|
1317
|
+
}): QueryPrefetchContext;
|
|
1318
|
+
/** Prefetch `query` with `input` into a {@link QueryPrefetchContext}'s runtime. */
|
|
1319
|
+
declare function prefetchQuery<TInput, TResult extends {}>(context: QueryPrefetchContext, query: QueryDefinition<TInput, TResult>, input: TInput): Promise<boolean>;
|
|
1320
|
+
/** Extract a runtime's cached query data into a JSON-serializable snapshot, dropping non-serializable values. */
|
|
1321
|
+
declare function dehydrateDataRuntime(runtime: DataRuntime): Record<string, unknown>;
|
|
1322
|
+
/** Load a {@link dehydrateDataRuntime} snapshot back into a runtime's query cache. */
|
|
1323
|
+
declare function hydrateDataRuntime(runtime: DataRuntime, data: unknown): void;
|
|
1324
|
+
//#endregion
|
|
920
1325
|
//#region src/actions/index.d.ts
|
|
1326
|
+
/** A declared server action, built by {@link defineAction}, bound to a form via {@link ActionForm}. */
|
|
921
1327
|
interface ActionDescriptor<TInput extends Record<string, unknown> = Record<string, unknown>> {
|
|
922
1328
|
readonly id: string;
|
|
923
1329
|
readonly input: ObjectSchema<TInput>;
|
|
924
1330
|
readonly invalidates: readonly string[];
|
|
925
1331
|
}
|
|
1332
|
+
/** Declare a server action with a stable id, input schema, and query prefixes to invalidate on success. */
|
|
926
1333
|
declare function defineAction<TInput extends Record<string, unknown>>(options: {
|
|
927
1334
|
readonly id: string;
|
|
928
1335
|
readonly input: ObjectSchema<TInput>;
|
|
@@ -934,6 +1341,7 @@ declare function ActionForm<TInput extends Record<string, unknown>>({ action, ch
|
|
|
934
1341
|
readonly children?: RenderableChild;
|
|
935
1342
|
readonly [key: string]: unknown;
|
|
936
1343
|
}): JSXElement;
|
|
1344
|
+
/** Server-replayed validation failure for an {@link ActionForm} submission. */
|
|
937
1345
|
interface ActionValidationError {
|
|
938
1346
|
readonly kind: 'invalid';
|
|
939
1347
|
readonly action: string;
|
|
@@ -941,6 +1349,7 @@ interface ActionValidationError {
|
|
|
941
1349
|
readonly issues: readonly unknown[];
|
|
942
1350
|
readonly fieldErrors: Readonly<Record<string, readonly string[]>>;
|
|
943
1351
|
}
|
|
1352
|
+
/** Pending/result/error status for an action, as reported by the `action()` hook. */
|
|
944
1353
|
interface ActionStatus<TResult = unknown> {
|
|
945
1354
|
readonly pending: boolean;
|
|
946
1355
|
readonly result?: TResult;
|
|
@@ -952,4 +1361,4 @@ declare function action<TInput extends Record<string, unknown>, TResult = unknow
|
|
|
952
1361
|
submit(input: TInput): Promise<TResult>;
|
|
953
1362
|
};
|
|
954
1363
|
//#endregion
|
|
955
|
-
export {
|
|
1364
|
+
export { AccessDecision as $, Scope as $t, Case as A, RouteRegistry as At, RenderDiagnosticsOptions as B, DataRuntimeOptions as Bt, Ref as C, RouteParams as Ct, registerSSRStyle as D, RouteRecord as Dt, SSRPortalState as E, RouteQuery as Et, ShowProps as F, RouteSearch as Ft, AskrRuntimeOptions as G, Query as Gt, Derived as H, InvalidateOptions as Ht, For as I, RouteSearchValue as It, createRuntime as J, QueryKeyPart as Jt, RuntimeKeyedReorderDecision as K, QueryConsistency as Kt, ForProps as L, RouteSnapshot as Lt, Match as M, RouteRenderResult as Mt, MatchProps as N, RouteRequestOptions as Nt, CspNonceScope as O, RouteRef as Ot, Show as P, RouteRequestResult as Pt, AccessAllowDecision as Q, ServerQueryHandler as Qt, Selector as R, CoreTelemetry as Rt, createMutation as S, RouteOptions as St, DeferredBoundaryRegistration as T, RoutePolicy as Tt, derive as U, Mutation as Ut, configureRenderDiagnostics as V, InvalidateOnIntervalOptions as Vt, AskrRuntime as W, MutationOptions as Wt, scheduleEventHandler as X, QueryScope as Xt, getDefaultRuntime as Y, QueryPrefetchContext as Yt, getSignal as Z, QueryStaleReason as Zt, invalidateOnInterval as _, RouteManifest as _t, action as a, DocumentRenderArgs as an, LayoutScopeRecord as at, getDefaultDataRuntime as b, RouteMetaSource as bt, ServerQueryRegistry as c, SSRData as cn, ParsedSegment as ct, defineServerQueries as d, State as dn, RouteAuthResolver as dt, defineScope as en, AccessDenyDecision as et, dehydrateDataRuntime as f, StateSetter as fn, RouteComponent as ft, invalidate as g, RouteHandler as gt, serveQuery as h, RouteDestination as ht, ActionValidationError as i, VNode as in, GroupHelperOptions as it, CaseProps as j, RouteRegistryOptions as jt, cspNonce as k, RouteRefSearch as kt, createQueryPrefetchContext as l, SSRStyleRegistration as ln, Route as lt, prefetchQuery as m, state as mn, RouteDefinition as mt, ActionForm as n, ComponentFunction as nn, AccessRedirectDecision as nt, defineAction as o, DocumentRenderContext as on, PageHelperOptions as ot, hydrateDataRuntime as p, StateTuple as pn, RouteContext as pt, RuntimeRendererHost as q, QueryDefinition as qt, ActionStatus as r, RenderableChild as rn, AccessRedirectStatus as rt, ServerQueryEntry as s, DocumentRenderer as sn, PageScopeRecord as st, ActionDescriptor as t, readScope as tn, AccessDenyStatus as tt, defineQuery as u, SSRStyleRegistrationValidation as un, RouteAuthOptions as ut, queryScope as v, RouteMatch as vt, createRef as w, RoutePathParams as wt, createQuery as x, RouteMode as xt, createDataRuntime as y, RouteMeta as yt, selector as z, DataRuntime as zt };
|