@qwik.dev/router 2.0.0-beta.3 → 2.0.0-beta.31
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/adapters/static/vite.d.ts +1 -1
- package/lib/adapters/azure-swa/vite/index.d.ts +2 -2
- package/lib/adapters/azure-swa/vite/index.mjs +39 -44
- package/lib/adapters/bun-server/vite/index.d.ts +2 -2
- package/lib/adapters/bun-server/vite/index.mjs +6 -7
- package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
- package/lib/adapters/cloud-run/vite/index.mjs +6 -7
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
- package/lib/adapters/cloudflare-pages/vite/index.mjs +23 -32
- package/lib/adapters/deno-server/vite/index.d.ts +2 -2
- package/lib/adapters/deno-server/vite/index.mjs +13 -9
- package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.mjs +22 -36
- package/lib/adapters/node-server/vite/index.d.ts +2 -2
- package/lib/adapters/node-server/vite/index.mjs +6 -7
- package/lib/adapters/shared/vite/index.d.ts +7 -19
- package/lib/adapters/shared/vite/index.mjs +244 -233
- package/lib/adapters/ssg/vite/index.d.ts +13 -0
- package/lib/adapters/ssg/vite/index.mjs +17 -0
- package/lib/adapters/vercel-edge/vite/index.d.ts +3 -3
- package/lib/adapters/vercel-edge/vite/index.mjs +33 -19
- package/lib/chunks/deepFreeze.qwik.mjs +18 -0
- package/lib/chunks/error-handler.mjs +57 -0
- package/lib/chunks/fs.mjs +144 -0
- package/lib/chunks/http-error.qwik.mjs +35 -0
- package/lib/chunks/not-found-wrapper.qwik.mjs +25 -0
- package/lib/chunks/pathname.mjs +105 -0
- package/lib/chunks/redirect-handler.mjs +6 -0
- package/lib/chunks/routing.qwik.mjs +821 -0
- package/lib/chunks/system.mjs +333 -0
- package/lib/chunks/url.mjs +61 -0
- package/lib/chunks/use-functions.qwik.mjs +35 -0
- package/lib/chunks/worker-thread.qwik.mjs +2573 -0
- package/lib/index.d.ts +362 -142
- package/lib/index.qwik.mjs +949 -1244
- package/lib/middleware/aws-lambda/index.d.ts +0 -5
- package/lib/middleware/aws-lambda/index.mjs +14 -17
- package/lib/middleware/azure-swa/index.mjs +16 -221
- package/lib/middleware/bun/index.d.ts +11 -0
- package/lib/middleware/bun/index.mjs +50 -97
- package/lib/middleware/cloudflare-pages/index.mjs +22 -31
- package/lib/middleware/deno/index.d.ts +11 -0
- package/lib/middleware/deno/index.mjs +49 -97
- package/lib/middleware/firebase/index.mjs +6 -15
- package/lib/middleware/netlify-edge/index.mjs +22 -32
- package/lib/middleware/node/index.mjs +31 -105
- package/lib/middleware/request-handler/index.d.ts +163 -88
- package/lib/middleware/request-handler/index.mjs +1458 -1260
- package/lib/middleware/vercel-edge/index.mjs +27 -36
- package/lib/modules.d.ts +11 -16
- package/lib/service-worker/index.mjs +4 -0
- package/lib/{static → ssg}/index.d.ts +45 -13
- package/lib/ssg/index.mjs +336 -0
- package/lib/vite/index.d.ts +38 -10
- package/lib/vite/index.mjs +2067 -26841
- package/modules.d.ts +11 -16
- package/package.json +62 -67
- package/ssg.d.ts +2 -0
- package/static.d.ts +1 -1
- package/lib/adapters/azure-swa/vite/index.cjs +0 -96
- package/lib/adapters/bun-server/vite/index.cjs +0 -50
- package/lib/adapters/cloud-run/vite/index.cjs +0 -47
- package/lib/adapters/cloudflare-pages/vite/index.cjs +0 -115
- package/lib/adapters/deno-server/vite/index.cjs +0 -62
- package/lib/adapters/netlify-edge/vite/index.cjs +0 -129
- package/lib/adapters/node-server/vite/index.cjs +0 -50
- package/lib/adapters/shared/vite/index.cjs +0 -378
- package/lib/adapters/static/vite/index.cjs +0 -368
- package/lib/adapters/static/vite/index.d.ts +0 -10
- package/lib/adapters/static/vite/index.mjs +0 -331
- package/lib/adapters/vercel-edge/vite/index.cjs +0 -118
- package/lib/index.qwik.cjs +0 -1947
- package/lib/middleware/node/index.cjs +0 -314
- package/lib/middleware/request-handler/index.cjs +0 -1614
- package/lib/service-worker.cjs +0 -17
- package/lib/service-worker.mjs +0 -15
- package/lib/static/deno.mjs +0 -8
- package/lib/static/index.cjs +0 -67
- package/lib/static/index.mjs +0 -48
- package/lib/static/node.cjs +0 -1124
- package/lib/static/node.mjs +0 -1086
- package/lib/vite/index.cjs +0 -27445
- package/middleware/request-handler/generated/not-found-paths.ts +0 -7
- package/middleware/request-handler/generated/static-paths.ts +0 -35
package/lib/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/// <reference path="./modules.d.ts" />
|
|
2
2
|
|
|
3
|
+
import type { AsyncSignal } from '@qwik.dev/core';
|
|
3
4
|
import { Component } from '@qwik.dev/core';
|
|
4
5
|
import { Cookie } from '@qwik.dev/router/middleware/request-handler';
|
|
5
6
|
import { CookieOptions } from '@qwik.dev/router/middleware/request-handler';
|
|
6
7
|
import { CookieValue } from '@qwik.dev/router/middleware/request-handler';
|
|
7
8
|
import { DeferReturn } from '@qwik.dev/router/middleware/request-handler';
|
|
8
9
|
import type { EnvGetter } from '@qwik.dev/router/middleware/request-handler';
|
|
9
|
-
import { JSXOutput
|
|
10
|
+
import { JSXOutput } from '@qwik.dev/core';
|
|
10
11
|
import { QRL } from '@qwik.dev/core';
|
|
11
12
|
import { QRLEventHandlerMulti } from '@qwik.dev/core';
|
|
12
13
|
import { QwikIntrinsicElements } from '@qwik.dev/core';
|
|
13
14
|
import { QwikJSX } from '@qwik.dev/core';
|
|
14
|
-
import
|
|
15
|
+
import { Render } from '@qwik.dev/core/server';
|
|
16
|
+
import { RenderOptions } from '@qwik.dev/core/server';
|
|
15
17
|
import { RequestEvent } from '@qwik.dev/router/middleware/request-handler';
|
|
16
18
|
import { RequestEventAction } from '@qwik.dev/router/middleware/request-handler';
|
|
17
19
|
import { RequestEventBase } from '@qwik.dev/router/middleware/request-handler';
|
|
@@ -19,8 +21,11 @@ import { RequestEventCommon } from '@qwik.dev/router/middleware/request-handler'
|
|
|
19
21
|
import { RequestEventLoader } from '@qwik.dev/router/middleware/request-handler';
|
|
20
22
|
import { RequestHandler } from '@qwik.dev/router/middleware/request-handler';
|
|
21
23
|
import type { ResolveSyncValue } from '@qwik.dev/router/middleware/request-handler';
|
|
24
|
+
import type { SerializationStrategy } from '@qwik.dev/core/internal';
|
|
25
|
+
import type { Signal } from '@qwik.dev/core';
|
|
22
26
|
import type * as v from 'valibot';
|
|
23
27
|
import type { ValueOrPromise } from '@qwik.dev/core';
|
|
28
|
+
import { ValueOrPromise as ValueOrPromise_2 } from '@qwik.dev/core/internal';
|
|
24
29
|
import { z } from 'zod';
|
|
25
30
|
import type * as z_2 from 'zod';
|
|
26
31
|
|
|
@@ -156,6 +161,17 @@ export declare type ActionStore<RETURN, INPUT, OPTIONAL extends boolean = true>
|
|
|
156
161
|
|
|
157
162
|
declare type AnchorAttributes = QwikIntrinsicElements['a'];
|
|
158
163
|
|
|
164
|
+
/**
|
|
165
|
+
* The cacheKey export type. When exported from a page module alongside eTag, enables in-memory SSR
|
|
166
|
+
* caching.
|
|
167
|
+
*
|
|
168
|
+
* - `true`: use the default cache key `status|eTag|pathname`
|
|
169
|
+
* - Function: receives status, eTag, and pathname; returns a cache key string or null (no cache)
|
|
170
|
+
*
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
export declare type CacheKeyFn = true | ((status: number, eTag: string, pathname: string) => string | null);
|
|
174
|
+
|
|
159
175
|
/** @public */
|
|
160
176
|
export declare interface ContentHeading {
|
|
161
177
|
readonly text: string;
|
|
@@ -172,9 +188,17 @@ export declare interface ContentMenu {
|
|
|
172
188
|
|
|
173
189
|
declare type ContentModule = PageModule | LayoutModule;
|
|
174
190
|
|
|
175
|
-
|
|
191
|
+
/**
|
|
192
|
+
* The eTag export type: a static string or a function receiving DocumentHeadProps.
|
|
193
|
+
*
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
export declare type ContentModuleETag = string | ((props: DocumentHeadProps) => string | null);
|
|
197
|
+
|
|
198
|
+
/** @public */
|
|
199
|
+
export declare type ContentModuleHead = DocumentHead | ResolvedDocumentHead;
|
|
176
200
|
|
|
177
|
-
declare type ContentModuleLoader = () =>
|
|
201
|
+
declare type ContentModuleLoader = () => ValueOrPromise<ContentModule>;
|
|
178
202
|
|
|
179
203
|
/** @public */
|
|
180
204
|
declare interface ContentState {
|
|
@@ -188,6 +212,38 @@ export { CookieOptions }
|
|
|
188
212
|
|
|
189
213
|
export { CookieValue }
|
|
190
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Creates the `render()` function that is required by `createQwikRouter()`. It requires a function
|
|
217
|
+
* that returns the `jsx` and `options` for the renderer.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
*
|
|
221
|
+
* ```tsx
|
|
222
|
+
* const renderer = createRenderer((opts) => {
|
|
223
|
+
* if (opts.requestHeaders['x-hello'] === 'world') {
|
|
224
|
+
* return { jsx: <Hello />, options: opts };
|
|
225
|
+
* }
|
|
226
|
+
* return { jsx: <Root />, options: {
|
|
227
|
+
* ...opts,
|
|
228
|
+
* serverData: {
|
|
229
|
+
* ...opts.serverData,
|
|
230
|
+
* documentHead: {
|
|
231
|
+
* meta: [
|
|
232
|
+
* { name: 'renderedAt', content: new Date().toISOString() },
|
|
233
|
+
* ],
|
|
234
|
+
* },
|
|
235
|
+
* },
|
|
236
|
+
* } };
|
|
237
|
+
* });
|
|
238
|
+
* ```
|
|
239
|
+
*
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
export declare const createRenderer: (getOptions: (options: RendererOptions) => {
|
|
243
|
+
jsx: JSXOutput;
|
|
244
|
+
options: RendererOutputOptions;
|
|
245
|
+
}) => Render;
|
|
246
|
+
|
|
191
247
|
/** @public */
|
|
192
248
|
export declare type DataValidator<T extends Record<string, any> = {}> = {
|
|
193
249
|
validate(ev: RequestEvent, data: unknown): Promise<ValidatorReturn<T>>;
|
|
@@ -195,32 +251,48 @@ export declare type DataValidator<T extends Record<string, any> = {}> = {
|
|
|
195
251
|
|
|
196
252
|
export { DeferReturn }
|
|
197
253
|
|
|
198
|
-
/** @public */
|
|
199
|
-
declare interface DevJSX {
|
|
200
|
-
fileName: string;
|
|
201
|
-
lineNumber: number;
|
|
202
|
-
columnNumber: number;
|
|
203
|
-
stack?: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
254
|
/** @public */
|
|
207
255
|
export declare type DocumentHead = DocumentHeadValue | ((props: DocumentHeadProps) => DocumentHeadValue);
|
|
208
256
|
|
|
209
257
|
/** @public */
|
|
210
258
|
export declare interface DocumentHeadProps extends RouteLocation {
|
|
211
259
|
readonly head: ResolvedDocumentHead;
|
|
260
|
+
/** The HTTP status code of the response (e.g. 200, 404). */
|
|
261
|
+
readonly status: number;
|
|
262
|
+
/** @deprecated This is not necessary, it works correctly without */
|
|
212
263
|
readonly withLocale: <T>(fn: () => T) => T;
|
|
213
264
|
readonly resolveValue: ResolveSyncValue;
|
|
214
265
|
}
|
|
215
266
|
|
|
267
|
+
/**
|
|
268
|
+
* This renders all the tags collected from `head`.
|
|
269
|
+
*
|
|
270
|
+
* You can partially override the head, for example if you want to change the title:
|
|
271
|
+
*
|
|
272
|
+
* ```tsx
|
|
273
|
+
* import { DocumentHeadTags, useDocumentHead } from '@qwik.dev/router';
|
|
274
|
+
*
|
|
275
|
+
* export default component$(() => {
|
|
276
|
+
* const head = useDocumentHead();
|
|
277
|
+
* return <DocumentHeadTags title={`${head.title} - My App`} />;
|
|
278
|
+
* });
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* You don't have to use this component, you can also do it yourself for full control. Just copy the
|
|
282
|
+
* code from this component and modify it to your needs.
|
|
283
|
+
*
|
|
284
|
+
* Note that this component normally only runs once, during SSR. You can use Signals in your
|
|
285
|
+
* `src/root.tsx` to make runtime changes to `<head>` if needed.
|
|
286
|
+
*
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
289
|
+
export declare const DocumentHeadTags: Component<DocumentHeadValue<Record<string, unknown>>>;
|
|
290
|
+
|
|
216
291
|
/** @public */
|
|
217
292
|
export declare interface DocumentHeadValue<FrontMatter extends Record<string, any> = Record<string, unknown>> {
|
|
218
293
|
/** Sets `document.title`. */
|
|
219
294
|
readonly title?: string;
|
|
220
|
-
/**
|
|
221
|
-
* Used to manually set meta tags in the head. Additionally, the `data` property could be used to
|
|
222
|
-
* set arbitrary data which the `<head>` component could later use to generate `<meta>` tags.
|
|
223
|
-
*/
|
|
295
|
+
/** Used to manually set meta tags in the head. */
|
|
224
296
|
readonly meta?: readonly DocumentMeta[];
|
|
225
297
|
/** Used to manually append `<link>` elements to the `<head>`. */
|
|
226
298
|
readonly links?: readonly DocumentLink[];
|
|
@@ -237,53 +309,60 @@ export declare interface DocumentHeadValue<FrontMatter extends Record<string, an
|
|
|
237
309
|
}
|
|
238
310
|
|
|
239
311
|
/** @public */
|
|
240
|
-
export declare
|
|
241
|
-
as?: string;
|
|
242
|
-
crossorigin?: string;
|
|
243
|
-
disabled?: boolean;
|
|
244
|
-
href?: string;
|
|
245
|
-
hreflang?: string;
|
|
246
|
-
id?: string;
|
|
247
|
-
imagesizes?: string;
|
|
248
|
-
imagesrcset?: string;
|
|
249
|
-
integrity?: string;
|
|
250
|
-
media?: string;
|
|
251
|
-
prefetch?: string;
|
|
252
|
-
referrerpolicy?: string;
|
|
253
|
-
rel?: string;
|
|
254
|
-
sizes?: string;
|
|
255
|
-
title?: string;
|
|
256
|
-
type?: string;
|
|
257
|
-
key?: string;
|
|
258
|
-
}
|
|
312
|
+
export declare type DocumentLink = QwikIntrinsicElements['link'];
|
|
259
313
|
|
|
260
314
|
/** @public */
|
|
261
|
-
export declare
|
|
262
|
-
readonly content?: string;
|
|
263
|
-
readonly httpEquiv?: string;
|
|
264
|
-
readonly name?: string;
|
|
265
|
-
readonly property?: string;
|
|
266
|
-
readonly key?: string;
|
|
267
|
-
readonly itemprop?: string;
|
|
268
|
-
readonly media?: string;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/** @beta */
|
|
272
|
-
export declare interface DocumentScript {
|
|
273
|
-
readonly script?: string;
|
|
274
|
-
readonly props?: Readonly<QwikIntrinsicElements['script']>;
|
|
275
|
-
readonly key?: string;
|
|
276
|
-
}
|
|
315
|
+
export declare type DocumentMeta = QwikIntrinsicElements['meta'];
|
|
277
316
|
|
|
278
317
|
/** @public */
|
|
279
|
-
export declare
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
318
|
+
export declare type DocumentScript = ((Omit<QwikIntrinsicElements['script'], 'dangerouslySetInnerHTML'> & {
|
|
319
|
+
props?: never;
|
|
320
|
+
}) | {
|
|
321
|
+
key?: string;
|
|
322
|
+
/**
|
|
323
|
+
* The props of the script element. @deprecated Prefer setting the properties directly instead
|
|
324
|
+
* of using this property.
|
|
325
|
+
*/
|
|
326
|
+
props: Readonly<QwikIntrinsicElements['script']>;
|
|
327
|
+
}) & ({
|
|
328
|
+
/** The inline script content. */
|
|
329
|
+
script?: string;
|
|
330
|
+
dangerouslySetInnerHTML?: never;
|
|
331
|
+
} | {
|
|
332
|
+
dangerouslySetInnerHTML?: string;
|
|
333
|
+
script?: never;
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
/** @public */
|
|
337
|
+
export declare type DocumentStyle = Readonly<((Omit<QwikIntrinsicElements['style'], 'dangerouslySetInnerHTML'> & {
|
|
338
|
+
props?: never;
|
|
339
|
+
}) | {
|
|
340
|
+
key?: string;
|
|
341
|
+
/**
|
|
342
|
+
* The props of the style element. @deprecated Prefer setting the properties directly
|
|
343
|
+
* instead of using this property.
|
|
344
|
+
*/
|
|
345
|
+
props: Readonly<QwikIntrinsicElements['style']>;
|
|
346
|
+
}) & ({
|
|
347
|
+
/** The inline style content. */
|
|
348
|
+
style?: string;
|
|
349
|
+
dangerouslySetInnerHTML?: never;
|
|
350
|
+
} | {
|
|
351
|
+
dangerouslySetInnerHTML?: string;
|
|
352
|
+
style?: never;
|
|
353
|
+
})>;
|
|
354
|
+
|
|
355
|
+
declare type EndpointModuleLoader = () => ValueOrPromise<RouteModule>;
|
|
356
|
+
|
|
357
|
+
declare interface EndpointResponse {
|
|
358
|
+
status: number;
|
|
359
|
+
statusMessage?: string;
|
|
360
|
+
loaders: Record<string, unknown>;
|
|
361
|
+
loadersSerializationStrategy: Map<string, SerializationStrategy>;
|
|
362
|
+
formData?: FormData;
|
|
363
|
+
action?: string;
|
|
283
364
|
}
|
|
284
365
|
|
|
285
|
-
declare type EndpointModuleLoader = () => Promise<RouteModule>;
|
|
286
|
-
|
|
287
366
|
/** @public */
|
|
288
367
|
export declare const ErrorBoundary: Component<ErrorBoundaryProps>;
|
|
289
368
|
|
|
@@ -303,7 +382,7 @@ export declare type FailOfRest<REST extends readonly DataValidator[]> = REST ext
|
|
|
303
382
|
export declare type FailReturn<T> = T & Failed;
|
|
304
383
|
|
|
305
384
|
/** @public */
|
|
306
|
-
export declare const Form: <O, I>({ action, spaReset, reloadDocument, onSubmit$, ...rest }: FormProps<O, I>, key: string | null) =>
|
|
385
|
+
export declare const Form: <O, I>({ action, spaReset, reloadDocument, onSubmit$, ...rest }: FormProps<O, I>, key: string | null) => JSXOutput;
|
|
307
386
|
|
|
308
387
|
/** @public */
|
|
309
388
|
export declare interface FormProps<O, I> extends Omit<QwikJSX.IntrinsicElements['form'], 'action' | 'method'> {
|
|
@@ -334,17 +413,6 @@ export declare interface FormSubmitSuccessDetail<T> {
|
|
|
334
413
|
value: T;
|
|
335
414
|
}
|
|
336
415
|
|
|
337
|
-
/**
|
|
338
|
-
* Any function taking a props object that returns JSXOutput.
|
|
339
|
-
*
|
|
340
|
-
* The `key`, `flags` and `dev` parameters are for internal use.
|
|
341
|
-
*
|
|
342
|
-
* @public
|
|
343
|
-
*/
|
|
344
|
-
declare type FunctionComponent<P = unknown> = {
|
|
345
|
-
renderFn(props: P, key: string | null, flags: number, dev?: DevJSX): JSXOutput;
|
|
346
|
-
}['renderFn'];
|
|
347
|
-
|
|
348
416
|
/** @public */
|
|
349
417
|
export declare type GetValidatorInputType<VALIDATOR extends TypedDataValidator> = VALIDATOR extends ValibotDataValidator<infer TYPE> ? v.InferInput<TYPE> : VALIDATOR extends ZodDataValidator<infer TYPE> ? z_2.input<TYPE> : never;
|
|
350
418
|
|
|
@@ -359,6 +427,14 @@ export declare const globalAction$: ActionConstructor;
|
|
|
359
427
|
|
|
360
428
|
/* Excluded from this release type: globalActionQrl */
|
|
361
429
|
|
|
430
|
+
/** @public */
|
|
431
|
+
export declare type HttpErrorProps = {
|
|
432
|
+
/** The HTTP status code, e.g. 404 */
|
|
433
|
+
status: number;
|
|
434
|
+
/** The error message, e.g. "Not Found" */
|
|
435
|
+
message: string;
|
|
436
|
+
};
|
|
437
|
+
|
|
362
438
|
declare type IsAny<Type> = 0 extends 1 & Type ? true : false;
|
|
363
439
|
|
|
364
440
|
/** @public */
|
|
@@ -371,31 +447,9 @@ export declare type JSONValue = string | number | boolean | {
|
|
|
371
447
|
[x: string]: JSONValue;
|
|
372
448
|
} | Array<JSONValue>;
|
|
373
449
|
|
|
374
|
-
/** @public */
|
|
375
|
-
declare type JSXChildren = string | number | boolean | null | undefined | Function | RegExp | JSXChildren[] | Promise<JSXChildren> | Signal<JSXChildren> | JSXNode;
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* A JSX Node, an internal structure. You probably want to use `JSXOutput` instead.
|
|
379
|
-
*
|
|
380
|
-
* @public
|
|
381
|
-
*/
|
|
382
|
-
declare interface JSXNode<T extends string | FunctionComponent | unknown = unknown> {
|
|
383
|
-
type: T;
|
|
384
|
-
props: T extends FunctionComponent<infer P> ? P : Record<any, unknown>;
|
|
385
|
-
children: JSXChildren | null;
|
|
386
|
-
key: string | null;
|
|
387
|
-
dev?: DevJSX;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Any valid output for a component
|
|
392
|
-
*
|
|
393
|
-
* @public
|
|
394
|
-
*/
|
|
395
|
-
declare type JSXOutput = JSXNode | string | number | boolean | null | undefined | JSXOutput[];
|
|
396
|
-
|
|
397
450
|
declare interface LayoutModule extends RouteModule {
|
|
398
|
-
readonly default:
|
|
451
|
+
readonly default?: (props: Record<string, never>) => JSXOutput;
|
|
452
|
+
readonly routeConfig?: RouteConfig;
|
|
399
453
|
readonly head?: ContentModuleHead;
|
|
400
454
|
}
|
|
401
455
|
|
|
@@ -412,7 +466,7 @@ export declare interface LinkProps extends AnchorAttributes {
|
|
|
412
466
|
*
|
|
413
467
|
* This **improves UX performance** for client-side (**SPA**) navigations.
|
|
414
468
|
*
|
|
415
|
-
* Prefetching occurs when a the Link enters the viewport in production (**`
|
|
469
|
+
* Prefetching occurs when a the Link enters the viewport in production (**`q-e:qvisible`**), or
|
|
416
470
|
* with **`mouseover`/`focus`** during dev.
|
|
417
471
|
*
|
|
418
472
|
* Prefetching will not occur if the user has the **data saver** setting enabled.
|
|
@@ -426,6 +480,24 @@ export declare interface LinkProps extends AnchorAttributes {
|
|
|
426
480
|
scroll?: boolean;
|
|
427
481
|
}
|
|
428
482
|
|
|
483
|
+
/** The route to render */
|
|
484
|
+
declare interface LoadedRoute {
|
|
485
|
+
/** The canonical path of the route, e.g. `/products/[id]` */
|
|
486
|
+
$routeName$: string;
|
|
487
|
+
/** The route parameters, e.g. `{ id: '123' }` */
|
|
488
|
+
$params$: PathParams;
|
|
489
|
+
/** The modules associated with this route (on 404, contains only the error component) */
|
|
490
|
+
$mods$: (RouteModule | ContentModule)[];
|
|
491
|
+
/** The menu associated with this route */
|
|
492
|
+
$menu$?: ContentMenu | undefined;
|
|
493
|
+
/** The bundle names for this route */
|
|
494
|
+
$routeBundleNames$?: string[] | undefined;
|
|
495
|
+
/** Whether this route is a not-found (404) route */
|
|
496
|
+
$notFound$?: boolean;
|
|
497
|
+
/** The error module loader (nearest _E ancestor), for rendering ServerErrors */
|
|
498
|
+
$errorLoader$?: ContentModuleLoader;
|
|
499
|
+
}
|
|
500
|
+
|
|
429
501
|
/** @public */
|
|
430
502
|
declare type Loader_2<RETURN> = {
|
|
431
503
|
/**
|
|
@@ -450,14 +522,13 @@ declare type LoaderConstructorQRL = {
|
|
|
450
522
|
|
|
451
523
|
/** @public */
|
|
452
524
|
declare type LoaderOptions = {
|
|
453
|
-
id?: string;
|
|
525
|
+
readonly id?: string;
|
|
526
|
+
readonly validation?: DataValidator[];
|
|
527
|
+
readonly serializationStrategy?: SerializationStrategy;
|
|
454
528
|
};
|
|
455
529
|
|
|
456
530
|
/** @public */
|
|
457
|
-
export declare type LoaderSignal<TYPE> = TYPE extends () => ValueOrPromise<infer VALIDATOR> ?
|
|
458
|
-
|
|
459
|
-
/** @public */
|
|
460
|
-
export declare type MenuData = [pathname: string, menuLoader: MenuModuleLoader];
|
|
531
|
+
export declare type LoaderSignal<TYPE> = (TYPE extends () => ValueOrPromise<infer VALIDATOR> ? Signal<ValueOrPromise<VALIDATOR>> : Signal<TYPE>) & Pick<AsyncSignal, 'promise' | 'loading' | 'error'>;
|
|
461
532
|
|
|
462
533
|
declare interface MenuModule {
|
|
463
534
|
readonly default: ContentMenu;
|
|
@@ -480,12 +551,15 @@ export { NavigationType_2 as NavigationType }
|
|
|
480
551
|
export declare function omitProps<T, KEYS extends keyof T>(obj: T, keys: KEYS[]): Omit<T, KEYS>;
|
|
481
552
|
|
|
482
553
|
/** @public */
|
|
483
|
-
export declare
|
|
484
|
-
readonly default:
|
|
554
|
+
export declare type PageModule = RouteModule & {
|
|
555
|
+
readonly default: (props: Record<string, never>) => JSXOutput;
|
|
556
|
+
readonly routeConfig?: RouteConfig;
|
|
485
557
|
readonly head?: ContentModuleHead;
|
|
558
|
+
readonly eTag?: ContentModuleETag;
|
|
559
|
+
readonly cacheKey?: CacheKeyFn;
|
|
486
560
|
readonly headings?: ContentHeading[];
|
|
487
561
|
readonly onStaticGenerate?: StaticGenerateHandler;
|
|
488
|
-
}
|
|
562
|
+
};
|
|
489
563
|
|
|
490
564
|
/** @public */
|
|
491
565
|
export declare type PathParams = Record<string, string>;
|
|
@@ -507,6 +581,9 @@ declare type Prettify<T> = {} & {
|
|
|
507
581
|
*/
|
|
508
582
|
export declare type PreventNavigateCallback = (url?: number | URL) => ValueOrPromise<boolean>;
|
|
509
583
|
|
|
584
|
+
/** @public */
|
|
585
|
+
export declare const Q_ROUTE = "q:route";
|
|
586
|
+
|
|
510
587
|
/**
|
|
511
588
|
* @deprecated Use `QWIK_ROUTER_SCROLLER` instead (will be removed in V3)
|
|
512
589
|
* @public
|
|
@@ -517,13 +594,7 @@ export declare const QWIK_CITY_SCROLLER = "_qCityScroller";
|
|
|
517
594
|
export declare const QWIK_ROUTER_SCROLLER = "_qRouterScroller";
|
|
518
595
|
|
|
519
596
|
/**
|
|
520
|
-
* @deprecated Use `
|
|
521
|
-
* @public
|
|
522
|
-
*/
|
|
523
|
-
export declare type QwikCityMockProps = QwikRouterMockProps;
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* @deprecated Use `QwikRouterMockProvider` instead. Will be removed in V3
|
|
597
|
+
* @deprecated Use `useQwikMockRouter()` instead. Will be removed in V3
|
|
527
598
|
* @public
|
|
528
599
|
*/
|
|
529
600
|
export declare const QwikCityMockProvider: Component<QwikRouterMockProps>;
|
|
@@ -535,32 +606,93 @@ export declare const QwikCityMockProvider: Component<QwikRouterMockProps>;
|
|
|
535
606
|
export declare type QwikCityPlan = QwikRouterConfig;
|
|
536
607
|
|
|
537
608
|
/**
|
|
538
|
-
* @deprecated Use `QwikRouterProps` instead.
|
|
609
|
+
* @deprecated Use `QwikRouterProps` instead. Will be removed in v3.
|
|
539
610
|
* @public
|
|
540
611
|
*/
|
|
541
612
|
export declare type QwikCityProps = QwikRouterProps;
|
|
542
613
|
|
|
543
614
|
/**
|
|
544
|
-
* @deprecated Use `
|
|
615
|
+
* @deprecated Use `useQwikRouter()` instead. Will be removed in v3.
|
|
545
616
|
* @public
|
|
546
617
|
*/
|
|
547
618
|
export declare const QwikCityProvider: Component<QwikRouterProps>;
|
|
548
619
|
|
|
549
620
|
/** @public */
|
|
550
621
|
export declare interface QwikRouterConfig {
|
|
551
|
-
readonly routes: RouteData
|
|
622
|
+
readonly routes: RouteData;
|
|
552
623
|
readonly serverPlugins?: RouteModule[];
|
|
553
624
|
readonly basePathname?: string;
|
|
554
|
-
readonly menus?: MenuData[];
|
|
555
625
|
readonly trailingSlash?: boolean;
|
|
556
626
|
readonly cacheModules?: boolean;
|
|
627
|
+
/** When true, return null instead of rendering the 404 page, letting the adapter handle it */
|
|
628
|
+
readonly fallthrough?: boolean;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** @public */
|
|
632
|
+
export declare interface QwikRouterEnvData {
|
|
633
|
+
routeName: string;
|
|
634
|
+
ev: RequestEvent;
|
|
635
|
+
params: PathParams;
|
|
636
|
+
response: EndpointResponse;
|
|
637
|
+
loadedRoute: LoadedRoute;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/** @public */
|
|
641
|
+
export declare interface QwikRouterMockActionProp<T = any> {
|
|
642
|
+
/** The action function to mock. */
|
|
643
|
+
action: Action<T>;
|
|
644
|
+
/** The QRL function that will be called when the action is submitted. */
|
|
645
|
+
handler: QRL<(data: T) => ValueOrPromise_2<RouteActionResolver>>;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** @public */
|
|
649
|
+
export declare interface QwikRouterMockLoaderProp<T = any> {
|
|
650
|
+
/** The loader function to mock. */
|
|
651
|
+
loader: Loader_2<T>;
|
|
652
|
+
/** The data to return when the loader is called. */
|
|
653
|
+
data: T;
|
|
557
654
|
}
|
|
558
655
|
|
|
559
656
|
/** @public */
|
|
560
657
|
export declare interface QwikRouterMockProps {
|
|
658
|
+
/**
|
|
659
|
+
* Allow mocking the url returned by `useLocation` hook.
|
|
660
|
+
*
|
|
661
|
+
* Default: `http://localhost/`
|
|
662
|
+
*/
|
|
561
663
|
url?: string;
|
|
664
|
+
/** Allow mocking the route params returned by `useLocation` hook. */
|
|
562
665
|
params?: Record<string, string>;
|
|
666
|
+
/** Allow mocking the `goto` function returned by `useNavigate` hook. */
|
|
563
667
|
goto?: RouteNavigate;
|
|
668
|
+
/**
|
|
669
|
+
* Allow mocking data for loaders defined with `routeLoader$` function.
|
|
670
|
+
*
|
|
671
|
+
* ```
|
|
672
|
+
* [
|
|
673
|
+
* {
|
|
674
|
+
* loader: useProductData,
|
|
675
|
+
* data: { product: { name: 'Test Product' } },
|
|
676
|
+
* },
|
|
677
|
+
* ];
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
loaders?: Array<QwikRouterMockLoaderProp<any>>;
|
|
681
|
+
/**
|
|
682
|
+
* Allow mocking actions defined with `routeAction$` function.
|
|
683
|
+
*
|
|
684
|
+
* ```
|
|
685
|
+
* [
|
|
686
|
+
* {
|
|
687
|
+
* action: useAddUser,
|
|
688
|
+
* handler: $(async (data) => {
|
|
689
|
+
* console.log('useAddUser action called with data:', data);
|
|
690
|
+
* }),
|
|
691
|
+
* },
|
|
692
|
+
* ];
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
actions?: Array<QwikRouterMockActionProp<any>>;
|
|
564
696
|
}
|
|
565
697
|
|
|
566
698
|
/** @public */
|
|
@@ -575,18 +707,25 @@ export declare interface QwikRouterProps {
|
|
|
575
707
|
*
|
|
576
708
|
* @see https://github.com/WICG/view-transitions/blob/main/explainer.md
|
|
577
709
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
|
|
578
|
-
* @see https://caniuse.com/
|
|
710
|
+
* @see https://caniuse.com/mdn_api_viewtransition
|
|
579
711
|
*/
|
|
580
712
|
viewTransition?: boolean;
|
|
581
713
|
}
|
|
582
714
|
|
|
583
|
-
/** @public */
|
|
715
|
+
/** @public This is a wrapper around the `useQwikRouter()` hook. We recommend using the hook instead of this component, unless you have a good reason to make your root component reactive. */
|
|
584
716
|
export declare const QwikRouterProvider: Component<QwikRouterProps>;
|
|
585
717
|
|
|
586
718
|
/** @public */
|
|
587
|
-
declare
|
|
588
|
-
|
|
589
|
-
}
|
|
719
|
+
export declare type RendererOptions = Omit<RenderOptions, 'serverData'> & {
|
|
720
|
+
serverData: ServerData;
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
/** @public */
|
|
724
|
+
export declare type RendererOutputOptions = Omit<RenderOptions, 'serverData'> & {
|
|
725
|
+
serverData: ServerData & {
|
|
726
|
+
documentHead?: DocumentHeadValue;
|
|
727
|
+
} & Record<string, unknown>;
|
|
728
|
+
};
|
|
590
729
|
|
|
591
730
|
export { RequestEvent }
|
|
592
731
|
|
|
@@ -601,20 +740,88 @@ export { RequestEventLoader }
|
|
|
601
740
|
export { RequestHandler }
|
|
602
741
|
|
|
603
742
|
/** @public */
|
|
604
|
-
export declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter
|
|
743
|
+
export declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter>> & {
|
|
744
|
+
/** The build's manifest hash, used for per-loader data URLs. Always defined (`'dev'` in dev). */
|
|
745
|
+
readonly manifestHash: string;
|
|
746
|
+
};
|
|
605
747
|
|
|
606
748
|
/** @public */
|
|
607
749
|
export declare const routeAction$: ActionConstructor;
|
|
608
750
|
|
|
609
751
|
/* Excluded from this release type: routeActionQrl */
|
|
610
752
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
753
|
+
declare type RouteActionResolver = {
|
|
754
|
+
status: number;
|
|
755
|
+
result: unknown;
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Unified route configuration export. Groups head, eTag, and cacheKey with the same resolution
|
|
760
|
+
* rules as DocumentHead: can be a static object or a function receiving DocumentHeadProps.
|
|
761
|
+
*
|
|
762
|
+
* When a module exports `routeConfig`, the separate `head`, `eTag`, and `cacheKey` exports are
|
|
763
|
+
* ignored for that module.
|
|
764
|
+
*
|
|
765
|
+
* @public
|
|
766
|
+
*/
|
|
767
|
+
export declare type RouteConfig = RouteConfigValue | ((props: DocumentHeadProps) => RouteConfigValue);
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* The value shape returned by a routeConfig export (object form or function return).
|
|
771
|
+
*
|
|
772
|
+
* @public
|
|
773
|
+
*/
|
|
774
|
+
export declare interface RouteConfigValue {
|
|
775
|
+
readonly head?: DocumentHeadValue;
|
|
776
|
+
readonly eTag?: ContentModuleETag;
|
|
777
|
+
readonly cacheKey?: CacheKeyFn;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* A nested route trie structure. The root represents `/` and each level represents a URL segment.
|
|
782
|
+
*
|
|
783
|
+
* Keys starting with `_` are metadata; all other keys are child route segments.
|
|
784
|
+
*
|
|
785
|
+
* - Use `_W` as the key for a single dynamic segment (param); `_P` on that node names the param.
|
|
786
|
+
* - Use `_A` as the key for a rest/catch-all segment; `_P` on that node names the param.
|
|
787
|
+
* - For infix params like `pre[slug]post`, use `_W` with `_0` (prefix) and `_9` (suffix).
|
|
788
|
+
* - Use `_M` for an array of group (pathless layout) nodes, sorted by group name.
|
|
789
|
+
*
|
|
790
|
+
* When matching, exact segments are tried first (case-insensitive), then `_W` (with optional
|
|
791
|
+
* prefix/suffix), then `_A`. When no route matches, the closest `_E` (error.tsx) or `_4` (404.tsx)
|
|
792
|
+
* loader in the ancestor chain is used to render the error page.
|
|
793
|
+
*
|
|
794
|
+
* @public
|
|
795
|
+
*/
|
|
796
|
+
export declare interface RouteData {
|
|
797
|
+
/** This node's layout loader (single). Runtime accumulates these during trie traversal. */
|
|
798
|
+
_L?: ContentModuleLoader;
|
|
799
|
+
/**
|
|
800
|
+
* This node's index/page loader. Single = normal (runtime prepends gathered _L). Array = override
|
|
801
|
+
* (layout stop / named layout — IS the complete chain).
|
|
802
|
+
*/
|
|
803
|
+
_I?: ContentModuleLoader | ModuleLoader[];
|
|
804
|
+
/** Rewrite/goto target path. Matcher re-walks trie from root using this path's keys. */
|
|
805
|
+
_G?: string;
|
|
806
|
+
/** The JS bundle names for this route (SSR only) */
|
|
807
|
+
_B?: string[];
|
|
808
|
+
/** The not-found (404) module loader for this subtree */
|
|
809
|
+
_4?: ContentModuleLoader;
|
|
810
|
+
/** The error page module loader for this subtree (error.tsx, takes precedence over _4) */
|
|
811
|
+
_E?: ContentModuleLoader;
|
|
812
|
+
/** The parameter name when this node is reached via `_W` or `_A` from the parent */
|
|
813
|
+
_P?: string;
|
|
814
|
+
/** Prefix for infix params (e.g. "pre" for `pre[slug]post`) — only on `_W` nodes */
|
|
815
|
+
_0?: string;
|
|
816
|
+
/** Suffix for infix params (e.g. "post" for `pre[slug]post`) — only on `_W` nodes */
|
|
817
|
+
_9?: string;
|
|
818
|
+
/** Group (pathless layout) nodes merged into this level, sorted by group name */
|
|
819
|
+
_M?: RouteData[];
|
|
820
|
+
/** Menu loader for this subtree (from menu.md). Runtime uses nearest ancestor during traversal. */
|
|
821
|
+
_N?: MenuModuleLoader;
|
|
822
|
+
/** Child route segments (any key not starting with `_`) */
|
|
823
|
+
[part: string]: RouteData | RouteData[] | ModuleLoader[] | ContentModuleLoader | MenuModuleLoader | string[] | string | undefined;
|
|
824
|
+
}
|
|
618
825
|
|
|
619
826
|
/** @public */
|
|
620
827
|
export declare const routeLoader$: LoaderConstructor;
|
|
@@ -662,6 +869,18 @@ declare interface ServerConfig {
|
|
|
662
869
|
fetchOptions?: any;
|
|
663
870
|
}
|
|
664
871
|
|
|
872
|
+
/** @public The server data that is provided by Qwik Router during SSR rendering. It can be retrieved with `useServerData(key)` in the server, but it is not available in the client. */
|
|
873
|
+
export declare type ServerData = {
|
|
874
|
+
url: string;
|
|
875
|
+
requestHeaders: Record<string, string>;
|
|
876
|
+
locale: string | undefined;
|
|
877
|
+
nonce: string | undefined;
|
|
878
|
+
containerAttributes: Record<string, string> & {
|
|
879
|
+
[Q_ROUTE]: string;
|
|
880
|
+
};
|
|
881
|
+
qwikrouter: QwikRouterEnvData;
|
|
882
|
+
};
|
|
883
|
+
|
|
665
884
|
/** @public */
|
|
666
885
|
export declare type ServerFunction = {
|
|
667
886
|
(this: RequestEventBase, ...args: any[]): any;
|
|
@@ -683,28 +902,18 @@ export declare type ServerQRL<T extends ServerFunction> = QRL<((abort: AbortSign
|
|
|
683
902
|
* JS extensions are allowed) will be picked up, bundled into a separate file, and registered as a
|
|
684
903
|
* service worker.
|
|
685
904
|
*
|
|
905
|
+
* Qwik 1.14.0 and above now use `<link rel="modulepreload">` by default. If you didn't add custom
|
|
906
|
+
* service-worker logic, you should remove your service-worker.ts file(s) for the
|
|
907
|
+
* `ServiceWorkerRegister` Component to actually unregister the service-worker.js and delete its
|
|
908
|
+
* related cache. Make sure to keep the `ServiceWorkerRegister` Component in your app (without any
|
|
909
|
+
* service-worker.ts file) as long as you want to unregister the service-worker.js for your users.
|
|
910
|
+
*
|
|
686
911
|
* @public
|
|
687
912
|
*/
|
|
688
913
|
export declare const ServiceWorkerRegister: (props: {
|
|
689
914
|
nonce?: string;
|
|
690
915
|
}) => JSXOutput;
|
|
691
916
|
|
|
692
|
-
/**
|
|
693
|
-
* A signal is a reactive value which can be read and written. When the signal is written, all tasks
|
|
694
|
-
* which are tracking the signal will be re-run and all components that read the signal will be
|
|
695
|
-
* re-rendered.
|
|
696
|
-
*
|
|
697
|
-
* Furthermore, when a signal value is passed as a prop to a component, the optimizer will
|
|
698
|
-
* automatically forward the signal. This means that `return <div title={signal.value}>hi</div>`
|
|
699
|
-
* will update the `title` attribute when the signal changes without having to re-render the
|
|
700
|
-
* component.
|
|
701
|
-
*
|
|
702
|
-
* @public
|
|
703
|
-
*/
|
|
704
|
-
declare interface Signal<T = any> extends ReadonlySignal_2<T> {
|
|
705
|
-
value: T;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
917
|
/** @public */
|
|
709
918
|
export declare interface StaticGenerate {
|
|
710
919
|
params?: PathParams[];
|
|
@@ -741,6 +950,9 @@ export declare const useContent: () => ContentState;
|
|
|
741
950
|
*/
|
|
742
951
|
export declare const useDocumentHead: <FrontMatter extends Record<string, unknown> = Record<string, any>>() => Required<ResolvedDocumentHead<FrontMatter>>;
|
|
743
952
|
|
|
953
|
+
/** @public */
|
|
954
|
+
export declare const useHttpStatus: () => HttpErrorProps;
|
|
955
|
+
|
|
744
956
|
/** @public */
|
|
745
957
|
export declare const useLocation: () => RouteLocation;
|
|
746
958
|
|
|
@@ -785,6 +997,14 @@ export declare const usePreventNavigate$: (qrl: PreventNavigateCallback) => void
|
|
|
785
997
|
|
|
786
998
|
/* Excluded from this release type: usePreventNavigateQrl */
|
|
787
999
|
|
|
1000
|
+
/**
|
|
1001
|
+
* @public
|
|
1002
|
+
* This hook initializes Qwik Router, providing the necessary context for it to work.
|
|
1003
|
+
*
|
|
1004
|
+
* This hook should be used once, at the root of your application.
|
|
1005
|
+
*/
|
|
1006
|
+
export declare const useQwikRouter: (props?: QwikRouterProps) => void;
|
|
1007
|
+
|
|
788
1008
|
/** @beta */
|
|
789
1009
|
export declare const valibot$: ValibotConstructor;
|
|
790
1010
|
|