@qwik.dev/router 2.0.0-beta.9 → 2.0.0-rc.2
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/lib/adapters/azure-swa/vite/index.d.ts +2 -2
- package/lib/adapters/azure-swa/vite/index.mjs +44 -57
- package/lib/adapters/bun-server/vite/index.d.ts +2 -2
- package/lib/adapters/bun-server/vite/index.mjs +16 -22
- package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
- package/lib/adapters/cloud-run/vite/index.mjs +15 -19
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
- package/lib/adapters/cloudflare-pages/vite/index.mjs +45 -76
- package/lib/adapters/deno-server/vite/index.d.ts +2 -2
- package/lib/adapters/deno-server/vite/index.mjs +25 -34
- package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.mjs +49 -89
- package/lib/adapters/node-server/vite/index.d.ts +2 -2
- package/lib/adapters/node-server/vite/index.mjs +16 -22
- package/lib/adapters/shared/vite/index.d.ts +9 -16
- package/lib/adapters/shared/vite/index.mjs +280 -293
- package/lib/adapters/ssg/vite/index.d.ts +1 -1
- package/lib/adapters/ssg/vite/index.mjs +13 -299
- package/lib/adapters/vercel-edge/vite/index.d.ts +3 -3
- package/lib/adapters/vercel-edge/vite/index.mjs +75 -79
- package/lib/chunks/dev-preloaded-route-loader.mjs +2 -0
- package/lib/chunks/format.mjs +24 -0
- package/lib/chunks/fs.mjs +143 -0
- package/lib/chunks/head.qwik.mjs +1570 -0
- package/lib/chunks/http-error.qwik.mjs +28 -0
- package/lib/chunks/pathname.mjs +58 -0
- package/lib/chunks/request-body-limit.mjs +27 -0
- package/lib/chunks/request-path.mjs +53 -0
- package/lib/chunks/route-trie-key.mjs +10 -0
- package/lib/chunks/routes.mjs +26 -0
- package/lib/chunks/server-error.mjs +38 -0
- package/lib/chunks/static-file.mjs +70 -0
- package/lib/chunks/system.mjs +271 -0
- package/lib/chunks/user-response.mjs +1878 -0
- package/lib/chunks/worker-thread.mjs +274 -0
- package/lib/index.d.ts +550 -182
- package/lib/index.qwik.mjs +1746 -2057
- package/lib/middleware/aws-lambda/index.d.ts +15 -17
- package/lib/middleware/aws-lambda/index.mjs +46 -50
- package/lib/middleware/azure-swa/index.mjs +85 -294
- package/lib/middleware/bun/index.d.ts +22 -5
- package/lib/middleware/bun/index.mjs +118 -201
- package/lib/middleware/cloudflare-pages/index.d.ts +2 -0
- package/lib/middleware/cloudflare-pages/index.mjs +103 -101
- package/lib/middleware/deno/index.d.ts +22 -5
- package/lib/middleware/deno/index.mjs +103 -191
- package/lib/middleware/firebase/index.mjs +22 -31
- package/lib/middleware/netlify-edge/index.d.ts +2 -0
- package/lib/middleware/netlify-edge/index.mjs +64 -80
- package/lib/middleware/node/index.d.ts +17 -5
- package/lib/middleware/node/index.mjs +298 -269
- package/lib/middleware/request-handler/index.d.ts +259 -58
- package/lib/middleware/request-handler/index.mjs +108 -1730
- package/lib/middleware/vercel-edge/index.d.ts +2 -0
- package/lib/middleware/vercel-edge/index.mjs +77 -100
- package/lib/modules.d.ts +7 -4
- package/lib/service-worker/index.mjs +14 -0
- package/lib/ssg/index.d.ts +50 -26
- package/lib/ssg/index.mjs +257 -43
- package/lib/vite/index.d.ts +59 -11
- package/lib/vite/index.mjs +2534 -27536
- package/modules.d.ts +7 -4
- package/package.json +53 -70
- 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 -130
- package/lib/adapters/node-server/vite/index.cjs +0 -50
- package/lib/adapters/shared/vite/index.cjs +0 -338
- package/lib/adapters/ssg/vite/index.cjs +0 -339
- package/lib/adapters/vercel-edge/vite/index.cjs +0 -118
- package/lib/index.qwik.cjs +0 -2112
- package/lib/middleware/node/index.cjs +0 -310
- package/lib/middleware/request-handler/index.cjs +0 -1766
- package/lib/service-worker.cjs +0 -17
- package/lib/service-worker.mjs +0 -15
- package/lib/ssg/deno.mjs +0 -8
- package/lib/ssg/index.cjs +0 -67
- package/lib/ssg/node.cjs +0 -1128
- package/lib/ssg/node.mjs +0 -1090
- package/lib/vite/index.cjs +0 -27607
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import type { Action } from '@qwik.dev/router';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
3
|
import type { EnvGetter as EnvGetter_2 } from '@qwik.dev/router/middleware/request-handler';
|
|
4
4
|
import type { FailReturn } from '@qwik.dev/router';
|
|
5
|
+
import type { JSXOutput } from '@qwik.dev/core';
|
|
5
6
|
import type { Loader as Loader_2 } from '@qwik.dev/router';
|
|
6
|
-
import type { QwikCityPlan } from '@qwik.dev/router';
|
|
7
7
|
import type { QwikIntrinsicElements } from '@qwik.dev/core';
|
|
8
|
-
import type { QwikRouterConfig } from '@qwik.dev/router';
|
|
9
8
|
import type { Render } from '@qwik.dev/core/server';
|
|
10
9
|
import type { RenderOptions } from '@qwik.dev/core/server';
|
|
11
10
|
import { RequestEvent as RequestEvent_2 } from '@qwik.dev/router/middleware/request-handler';
|
|
12
11
|
import type { RequestHandler as RequestHandler_2 } from '@qwik.dev/router/middleware/request-handler';
|
|
13
12
|
import type { ResolveSyncValue as ResolveSyncValue_2 } from '@qwik.dev/router/middleware/request-handler';
|
|
14
|
-
import { SerializationStrategy } from '@qwik.dev/core/internal';
|
|
15
|
-
import type { _serialize } from '@qwik.dev/core/internal';
|
|
16
13
|
import type { ValueOrPromise } from '@qwik.dev/core';
|
|
17
|
-
import type { _verifySerializable } from '@qwik.dev/core/internal';
|
|
18
14
|
|
|
19
15
|
/** @public */
|
|
20
16
|
export declare class AbortMessage {
|
|
17
|
+
/** Type-only brand so `Exclude<>` can drop control-flow signals from resolved loader/action data. */
|
|
18
|
+
readonly __controlFlow: true;
|
|
21
19
|
}
|
|
22
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Shared with the router copy of a Qwik library kept external on the server, so its
|
|
23
|
+
* `getRequestEvent()` and `server$` see the request the app is serving.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare const _asyncRequestStore: AsyncLocalStorage<RequestEventInternal> | undefined;
|
|
28
|
+
|
|
23
29
|
/** @public */
|
|
24
30
|
export declare type CacheControl = CacheControlOptions | number | 'day' | 'week' | 'month' | 'year' | 'no-cache' | 'immutable' | 'private';
|
|
25
31
|
|
|
@@ -91,6 +97,47 @@ declare interface CacheControlOptions {
|
|
|
91
97
|
/** @public */
|
|
92
98
|
declare type CacheControlTarget = 'Cache-Control' | 'CDN-Cache-Control' | 'Cloudflare-CDN-Cache-Control' | 'Vercel-CDN-Cache-Control' | '~ANY-OTHER-STRING' | (string & {});
|
|
93
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Cache key function. Used by `routeConfig.cacheKey` (SSR HTML cache) and by `routeLoader$`'s
|
|
102
|
+
* `cacheKey` option (per-loader JSON cache).
|
|
103
|
+
*
|
|
104
|
+
* - `true`: use the surface's default key.
|
|
105
|
+
*
|
|
106
|
+
* - SSR default: `${status}|${eTag}|${pathname}` when an eTag is set, otherwise
|
|
107
|
+
* `${status}|${pathname}`.
|
|
108
|
+
* - Loader default: `${pathname}|${filteredSearch}|${loaderId}|${eTag}` when an eTag is set,
|
|
109
|
+
* otherwise `${pathname}|${filteredSearch}|${loaderId}`.
|
|
110
|
+
* - Function: receives the request event and the normalized, unquoted eTag (or an empty string when
|
|
111
|
+
* none was provided). Return the cache key string, or `null` or `''` to skip caching for this
|
|
112
|
+
* request. Loader callbacks receive the loader-scoped request event, with `url`, `query`, and
|
|
113
|
+
* `request.url` filtered by the loader's `search` allowlist.
|
|
114
|
+
*
|
|
115
|
+
* Note: valid cacheKeys are non-empty strings.
|
|
116
|
+
*
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
declare type CacheKeyFn = true | ((requestEv: RequestEvent_2, eTag: string) => string | null);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Clear the in-memory loader cache. Call after deployments or data changes.
|
|
123
|
+
*
|
|
124
|
+
* When `cacheKey` is provided, only that single entry is removed; otherwise the entire cache is
|
|
125
|
+
* cleared.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare function clearLoaderCache(cacheKey?: string): void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Clear the in-memory SSR cache. Call after deployments or data changes.
|
|
133
|
+
*
|
|
134
|
+
* When `cacheKey` is provided, only that single entry is removed; otherwise the entire cache is
|
|
135
|
+
* cleared.
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export declare function clearSsrCache(cacheKey?: string): void;
|
|
140
|
+
|
|
94
141
|
/** @public */
|
|
95
142
|
export declare interface ClientConn {
|
|
96
143
|
ip?: string;
|
|
@@ -119,8 +166,29 @@ declare interface ContentMenu {
|
|
|
119
166
|
|
|
120
167
|
declare type ContentModule = PageModule | LayoutModule;
|
|
121
168
|
|
|
169
|
+
/**
|
|
170
|
+
* The eTag export type for routeConfig.
|
|
171
|
+
*
|
|
172
|
+
* - `string` — static ETag value.
|
|
173
|
+
* - `(props: DocumentHeadProps) => string | null` — compute the ETag from route context (params, URL,
|
|
174
|
+
* loaded data via `resolveValue`, etc.). Return `null` to skip eTag for this request.
|
|
175
|
+
*
|
|
176
|
+
* Qwik normalizes eTag values by stripping weak-form `W/` prefixes, quotes, and forbidden chars,
|
|
177
|
+
* then sends a strong `ETag` header. Values that normalize to an empty string are treated as
|
|
178
|
+
* absent.
|
|
179
|
+
*
|
|
180
|
+
* When set (and a value is produced), the server includes an `ETag` header and returns `304` if
|
|
181
|
+
* `If-None-Match` matches.
|
|
182
|
+
*
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
declare type ContentModuleETag = string | ((props: DocumentHeadProps) => string | null);
|
|
186
|
+
|
|
187
|
+
/** @public */
|
|
122
188
|
declare type ContentModuleHead = DocumentHead | ResolvedDocumentHead;
|
|
123
189
|
|
|
190
|
+
declare type ContentModuleLoader = () => ValueOrPromise<ContentModule>;
|
|
191
|
+
|
|
124
192
|
/** @public */
|
|
125
193
|
export declare interface Cookie {
|
|
126
194
|
/** Gets a `Request` cookie header value by name. */
|
|
@@ -207,6 +275,9 @@ declare type DocumentHead = DocumentHeadValue | ((props: DocumentHeadProps) => D
|
|
|
207
275
|
/** @public */
|
|
208
276
|
declare interface DocumentHeadProps extends RouteLocation {
|
|
209
277
|
readonly head: ResolvedDocumentHead;
|
|
278
|
+
/** The HTTP status code of the response (e.g. 200, 404). */
|
|
279
|
+
readonly status: number;
|
|
280
|
+
/** @deprecated This is not necessary, it works correctly without */
|
|
210
281
|
readonly withLocale: <T>(fn: () => T) => T;
|
|
211
282
|
readonly resolveValue: ResolveSyncValue_2;
|
|
212
283
|
}
|
|
@@ -275,6 +346,8 @@ declare type DocumentStyle = Readonly<((Omit<QwikIntrinsicElements['style'], 'da
|
|
|
275
346
|
style?: never;
|
|
276
347
|
})>;
|
|
277
348
|
|
|
349
|
+
declare type EndpointModuleLoader = () => ValueOrPromise<RouteModule>;
|
|
350
|
+
|
|
278
351
|
/** @public */
|
|
279
352
|
export declare interface EnvGetter {
|
|
280
353
|
get(key: string): string | undefined;
|
|
@@ -285,19 +358,19 @@ declare type ErrorCodes = ClientErrorCode | ServerErrorCode;
|
|
|
285
358
|
/** @public */
|
|
286
359
|
export declare function getErrorHtml(status: number, e: any): string;
|
|
287
360
|
|
|
288
|
-
/**
|
|
289
|
-
* Return the HTML for a 404 page.
|
|
290
|
-
*
|
|
291
|
-
* @internal
|
|
292
|
-
*/
|
|
293
|
-
export declare function getNotFound(prefix: string): string;
|
|
294
|
-
|
|
295
361
|
/**
|
|
296
362
|
* HTTP Informational Status Codes Status codes in the 1xx range indicate that the server has
|
|
297
363
|
* received and is processing the request, but no response is available yet.
|
|
298
364
|
*/
|
|
299
365
|
declare type InformationalCode = 100 | 101 | 102 | 103;
|
|
300
366
|
|
|
367
|
+
/**
|
|
368
|
+
* Internal JSON request kind handled by Qwik Router, or `false` for normal page requests.
|
|
369
|
+
*
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
export declare type InternalRequest = false | 'loader' | 'action';
|
|
373
|
+
|
|
301
374
|
/**
|
|
302
375
|
* Decide whether a given request path is a static path, for optimizing file access.
|
|
303
376
|
*
|
|
@@ -306,43 +379,85 @@ declare type InformationalCode = 100 | 101 | 102 | 103;
|
|
|
306
379
|
export declare function isStaticPath(method: string, url: URL): boolean;
|
|
307
380
|
|
|
308
381
|
declare interface LayoutModule extends RouteModule {
|
|
309
|
-
readonly default:
|
|
382
|
+
readonly default?: (props: Record<string, never>) => JSXOutput;
|
|
383
|
+
readonly routeConfig?: RouteConfig;
|
|
310
384
|
readonly head?: ContentModuleHead;
|
|
311
385
|
}
|
|
312
386
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
387
|
+
/** The route to render */
|
|
388
|
+
declare interface LoadedRoute {
|
|
389
|
+
/** The canonical path of the route, e.g. `/products/[id]` */
|
|
390
|
+
$routeName$: string;
|
|
391
|
+
/** The route parameters, e.g. `{ id: '123' }` */
|
|
392
|
+
$params$: PathParams;
|
|
393
|
+
/** The modules associated with this route (on 404, contains only the error component) */
|
|
394
|
+
$mods$: (RouteModule | ContentModule)[];
|
|
395
|
+
/** The menu associated with this route */
|
|
396
|
+
$menu$?: ContentMenu | undefined;
|
|
397
|
+
/** The bundle names for this route */
|
|
398
|
+
$routeBundleNames$?: string[] | undefined;
|
|
399
|
+
/** Whether this route is a not-found (404) route */
|
|
400
|
+
$notFound$?: boolean;
|
|
401
|
+
/** The nearest _E (error.tsx) boundary's chain to render on a thrown ServerError (in its layouts). */
|
|
402
|
+
$errorLoader$?: ModuleLoader[];
|
|
403
|
+
/** Merged array of routeLoader$ hashes from all matched nodes (layouts + page) */
|
|
404
|
+
$loaders$?: string[];
|
|
405
|
+
/** Runtime-only mapping of routeLoader$ hashes to the matched pathname used for q-loader fetches */
|
|
406
|
+
$loaderPaths$?: Record<string, string>;
|
|
407
|
+
/** Runtime-only mapping of routeLoader$ hashes to params matched at their loader path */
|
|
408
|
+
$loaderParams$?: Record<string, PathParams>;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
declare interface MenuModule {
|
|
412
|
+
readonly default: ContentMenu;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
declare type MenuModuleLoader = () => Promise<MenuModule>;
|
|
320
416
|
|
|
321
417
|
/** @public */
|
|
322
418
|
export declare const mergeHeadersCookies: (headers: Headers, cookies: Cookie) => Headers;
|
|
323
419
|
|
|
420
|
+
declare type ModuleLoader = ContentModuleLoader | EndpointModuleLoader;
|
|
421
|
+
|
|
324
422
|
/** @public */
|
|
325
|
-
declare
|
|
326
|
-
readonly default:
|
|
423
|
+
declare type PageModule = RouteModule & {
|
|
424
|
+
readonly default: (props: Record<string, never>) => JSXOutput;
|
|
425
|
+
readonly routeConfig?: RouteConfig;
|
|
327
426
|
readonly head?: ContentModuleHead;
|
|
427
|
+
readonly eTag?: ContentModuleETag;
|
|
428
|
+
readonly cacheKey?: CacheKeyFn;
|
|
328
429
|
readonly headings?: ContentHeading[];
|
|
329
430
|
readonly onStaticGenerate?: StaticGenerateHandler;
|
|
330
|
-
}
|
|
431
|
+
};
|
|
331
432
|
|
|
332
433
|
/** @public */
|
|
333
434
|
declare type PathParams = Record<string, string>;
|
|
334
435
|
|
|
436
|
+
declare type QwikRouterCompletion = Error | undefined | object;
|
|
437
|
+
|
|
438
|
+
/** @public */
|
|
439
|
+
declare interface QwikRouterConfig {
|
|
440
|
+
readonly routes: RouteData;
|
|
441
|
+
readonly serverPlugins?: RouteModule[];
|
|
442
|
+
readonly basePathname?: string;
|
|
443
|
+
readonly trailingSlash?: boolean;
|
|
444
|
+
readonly cacheModules?: boolean;
|
|
445
|
+
/** When true, return null instead of rendering the 404 page, letting the adapter handle it */
|
|
446
|
+
readonly fallthrough?: boolean;
|
|
447
|
+
/**
|
|
448
|
+
* Imports the modules containing `server$` functions so their registration side effects run.
|
|
449
|
+
* Called by the request handler before serving; deliberately async so the config module itself
|
|
450
|
+
* evaluates without touching the runtime (see the import-cycle notes in `route-loaders.ts`).
|
|
451
|
+
*/
|
|
452
|
+
readonly importEagerModules?: () => Promise<unknown>;
|
|
453
|
+
/** URL of the app's service worker, when the routes define one. */
|
|
454
|
+
readonly serviceWorkerUrl?: string;
|
|
455
|
+
}
|
|
456
|
+
|
|
335
457
|
declare interface QwikRouterRun<T> {
|
|
336
458
|
response: Promise<T | null>;
|
|
337
459
|
requestEv: RequestEvent_2;
|
|
338
|
-
completion: Promise<
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/** @public */
|
|
342
|
-
declare interface QwikSerializer {
|
|
343
|
-
_deserialize: typeof _deserialize;
|
|
344
|
-
_serialize: typeof _serialize;
|
|
345
|
-
_verifySerializable: typeof _verifySerializable;
|
|
460
|
+
completion: Promise<QwikRouterCompletion>;
|
|
346
461
|
}
|
|
347
462
|
|
|
348
463
|
/**
|
|
@@ -421,6 +536,14 @@ export declare interface RequestEventBase<PLATFORM = QwikRouterPlatform> {
|
|
|
421
536
|
readonly query: URLSearchParams;
|
|
422
537
|
/** HTTP request URL. */
|
|
423
538
|
readonly url: URL;
|
|
539
|
+
/**
|
|
540
|
+
* Identifies Qwik Router internal JSON requests, such as route loader fetches and fetch-based
|
|
541
|
+
* action submissions. Returns `false` for normal page requests.
|
|
542
|
+
*
|
|
543
|
+
* Check this before applying broad rewrite rules so internal JSON requests keep their routing
|
|
544
|
+
* behavior.
|
|
545
|
+
*/
|
|
546
|
+
readonly internalRequest: InternalRequest;
|
|
424
547
|
/**
|
|
425
548
|
* The original HTTP request URL.
|
|
426
549
|
*
|
|
@@ -538,12 +661,10 @@ export declare interface RequestEventCommon<PLATFORM = QwikRouterPlatform> exten
|
|
|
538
661
|
readonly exit: () => AbortMessage;
|
|
539
662
|
}
|
|
540
663
|
|
|
541
|
-
declare interface RequestEventInternal extends RequestEvent
|
|
542
|
-
[
|
|
543
|
-
[
|
|
544
|
-
[
|
|
545
|
-
[RequestEvRoute]: LoadedRoute | null;
|
|
546
|
-
[RequestEvQwikSerializer]: QwikSerializer;
|
|
664
|
+
declare interface RequestEventInternal extends Readonly<RequestEvent>, Readonly<RequestEventLoader> {
|
|
665
|
+
readonly [RequestEvMode]: ServerRequestMode;
|
|
666
|
+
readonly [RequestEvRoute]: LoadedRoute;
|
|
667
|
+
readonly [RequestEvRouterConfig]: QwikRouterConfig | undefined;
|
|
547
668
|
/**
|
|
548
669
|
* Check if this request is already written to.
|
|
549
670
|
*
|
|
@@ -566,42 +687,39 @@ export declare interface RequestEventLoader<PLATFORM = QwikRouterPlatform> exten
|
|
|
566
687
|
defer: <T>(returnData: Promise<T> | (() => Promise<T>)) => DeferReturn<T>;
|
|
567
688
|
}
|
|
568
689
|
|
|
569
|
-
declare const RequestEvLoaders: unique symbol;
|
|
570
|
-
|
|
571
|
-
declare const RequestEvLoaderSerializationStrategyMap: unique symbol;
|
|
572
|
-
|
|
573
690
|
declare const RequestEvMode: unique symbol;
|
|
574
691
|
|
|
575
|
-
declare const RequestEvQwikSerializer: unique symbol;
|
|
576
|
-
|
|
577
692
|
declare const RequestEvRoute: unique symbol;
|
|
578
693
|
|
|
579
|
-
/**
|
|
580
|
-
|
|
694
|
+
/** The request event's key for the config of the app serving it. */
|
|
695
|
+
declare const RequestEvRouterConfig: unique symbol;
|
|
581
696
|
|
|
582
697
|
/** @public */
|
|
583
|
-
export declare type RequestHandler<PLATFORM = QwikRouterPlatform> = (ev: RequestEvent<PLATFORM>) => Promise<void> | void;
|
|
698
|
+
export declare type RequestHandler<PLATFORM = QwikRouterPlatform> = (ev: RequestEvent<PLATFORM>) => Promise<void | AbortMessage | ServerError> | void | AbortMessage | ServerError;
|
|
584
699
|
|
|
585
700
|
/**
|
|
586
|
-
* The request handler for QwikRouter. Called by every
|
|
701
|
+
* The request handler for QwikRouter. Called by every adapter.
|
|
587
702
|
*
|
|
588
703
|
* @public
|
|
589
704
|
*/
|
|
590
|
-
export declare function requestHandler<T = unknown>(serverRequestEv: ServerRequestEvent<T>, opts: ServerRenderOptions
|
|
705
|
+
export declare function requestHandler<T = unknown>(serverRequestEv: ServerRequestEvent<T>, opts: ServerRenderOptions): Promise<QwikRouterRun<T> | null>;
|
|
591
706
|
|
|
592
707
|
/** @public */
|
|
593
|
-
declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter
|
|
708
|
+
declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter>> & {
|
|
709
|
+
/** The build's manifest hash, used for per-loader data URLs. Always defined (`'dev'` in dev). */
|
|
710
|
+
readonly manifestHash: string;
|
|
711
|
+
};
|
|
594
712
|
|
|
595
713
|
/** @public */
|
|
596
714
|
export declare interface ResolveSyncValue {
|
|
715
|
+
<T, INPUT, OPTIONAL extends boolean>(action: Action<T, INPUT, OPTIONAL>): Awaited<T> | undefined;
|
|
597
716
|
<T>(loader: Loader_2<T>): Awaited<T> extends () => any ? never : Awaited<T>;
|
|
598
|
-
<T>(action: Action<T>): Awaited<T> | undefined;
|
|
599
717
|
}
|
|
600
718
|
|
|
601
719
|
/** @public */
|
|
602
720
|
export declare interface ResolveValue {
|
|
721
|
+
<T, INPUT, OPTIONAL extends boolean>(action: Action<T, INPUT, OPTIONAL>): Promise<T | undefined>;
|
|
603
722
|
<T>(loader: Loader_2<T>): Awaited<T> extends () => any ? never : Promise<T>;
|
|
604
|
-
<T>(action: Action<T>): Promise<T | undefined>;
|
|
605
723
|
}
|
|
606
724
|
|
|
607
725
|
/** @public */
|
|
@@ -610,6 +728,83 @@ export declare class RewriteMessage extends AbortMessage {
|
|
|
610
728
|
constructor(pathname: string);
|
|
611
729
|
}
|
|
612
730
|
|
|
731
|
+
/**
|
|
732
|
+
* Unified route configuration export. Groups head, eTag, and cacheKey with the same resolution
|
|
733
|
+
* rules as DocumentHead: can be a static object or a function receiving DocumentHeadProps.
|
|
734
|
+
*
|
|
735
|
+
* When a module exports `routeConfig`, the separate `head`, `eTag`, and `cacheKey` exports are
|
|
736
|
+
* ignored for that module.
|
|
737
|
+
*
|
|
738
|
+
* @public
|
|
739
|
+
*/
|
|
740
|
+
declare type RouteConfig = RouteConfigValue | ((props: DocumentHeadProps) => RouteConfigValue);
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* The value shape returned by a routeConfig export (object form or function return).
|
|
744
|
+
*
|
|
745
|
+
* @public
|
|
746
|
+
*/
|
|
747
|
+
declare interface RouteConfigValue {
|
|
748
|
+
readonly head?: DocumentHeadValue;
|
|
749
|
+
readonly eTag?: ContentModuleETag;
|
|
750
|
+
readonly cacheKey?: CacheKeyFn;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* A nested route trie structure. The root represents `/` and each level represents a URL segment.
|
|
755
|
+
*
|
|
756
|
+
* Keys starting with a single `_` are metadata; all other keys are child route segments. A static
|
|
757
|
+
* segment that starts with `_` is stored with an extra `_` (`_drafts` → `__drafts`).
|
|
758
|
+
*
|
|
759
|
+
* - Use `_W` as the key for a single dynamic segment (param); `_P` on that node names the param.
|
|
760
|
+
* - Use `_A` as the key for a rest/catch-all segment; `_P` on that node names the param.
|
|
761
|
+
* - For infix params like `pre[slug]post`, use `_W` with `_0` (prefix) and `_9` (suffix).
|
|
762
|
+
* - Use `_M` for an array of group (pathless layout) nodes, sorted by group name.
|
|
763
|
+
*
|
|
764
|
+
* Exact segments match case-insensitively. When several routes match, the most specific wins,
|
|
765
|
+
* compared segment by segment: an exact segment beats `_W` (with optional prefix/suffix), which
|
|
766
|
+
* beats `_A`. When no route matches, the closest `_E` (error.tsx) or `_4` (404.tsx) loader in the
|
|
767
|
+
* ancestor chain is used to render the error page.
|
|
768
|
+
*
|
|
769
|
+
* @public
|
|
770
|
+
*/
|
|
771
|
+
declare interface RouteData {
|
|
772
|
+
/** This node's layout loader (single). Runtime accumulates these during trie traversal. */
|
|
773
|
+
_L?: ContentModuleLoader;
|
|
774
|
+
/**
|
|
775
|
+
* This node's index/page loader. Single = normal (runtime prepends gathered _L). Array = override
|
|
776
|
+
* (layout stop / named layout — IS the complete chain).
|
|
777
|
+
*/
|
|
778
|
+
_I?: ContentModuleLoader | ModuleLoader[];
|
|
779
|
+
/** Rewrite/goto target path. Matcher re-walks trie from root using this path's keys. */
|
|
780
|
+
_G?: string;
|
|
781
|
+
/** The JS bundle names for this route (SSR only) */
|
|
782
|
+
_B?: string[];
|
|
783
|
+
/**
|
|
784
|
+
* Not-found (404) boundary: single loader (runtime prepends layouts) or override chain
|
|
785
|
+
* (`404@layout`/`!`).
|
|
786
|
+
*/
|
|
787
|
+
_4?: ContentModuleLoader | ModuleLoader[];
|
|
788
|
+
/** Error (error.tsx) boundary, same single-or-override-chain shape as `_4`. */
|
|
789
|
+
_E?: ContentModuleLoader | ModuleLoader[];
|
|
790
|
+
/** The parameter name when this node is reached via `_W` or `_A` from the parent */
|
|
791
|
+
_P?: string;
|
|
792
|
+
/** Prefix for infix params (e.g. "pre" for `pre[slug]post`) — only on `_W` nodes */
|
|
793
|
+
_0?: string;
|
|
794
|
+
/** Suffix for infix params (e.g. "post" for `pre[slug]post`) — only on `_W` nodes */
|
|
795
|
+
_9?: string;
|
|
796
|
+
/** Group (pathless layout) nodes merged into this level, sorted by group name */
|
|
797
|
+
_M?: RouteData[];
|
|
798
|
+
/** Menu loader for this subtree (from menu.md). Runtime uses nearest ancestor during traversal. */
|
|
799
|
+
_N?: MenuModuleLoader;
|
|
800
|
+
/** Inherited layout and server plugin routeLoader$ hashes. */
|
|
801
|
+
_R?: string[];
|
|
802
|
+
/** Page loader hashes; override pages include their selected layouts and plugins. */
|
|
803
|
+
_D?: string[];
|
|
804
|
+
/** Child route segments (any key not starting with a single `_`) */
|
|
805
|
+
[part: string]: RouteData | RouteData[] | ModuleLoader[] | ContentModuleLoader | MenuModuleLoader | string[] | string | undefined;
|
|
806
|
+
}
|
|
807
|
+
|
|
613
808
|
/** @public */
|
|
614
809
|
declare interface RouteLocation {
|
|
615
810
|
readonly params: Readonly<Record<string, string>>;
|
|
@@ -651,10 +846,6 @@ declare type ServerErrorCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 5
|
|
|
651
846
|
/** @public */
|
|
652
847
|
export declare interface ServerRenderOptions extends RenderOptions {
|
|
653
848
|
render: Render;
|
|
654
|
-
/** @deprecated Not used */
|
|
655
|
-
qwikCityPlan?: QwikCityPlan;
|
|
656
|
-
/** @deprecated Not used */
|
|
657
|
-
qwikRouterConfig?: QwikRouterConfig;
|
|
658
849
|
/**
|
|
659
850
|
* Protection against cross-site request forgery (CSRF) attacks.
|
|
660
851
|
*
|
|
@@ -666,6 +857,16 @@ export declare interface ServerRenderOptions extends RenderOptions {
|
|
|
666
857
|
* Defaults to `true`.
|
|
667
858
|
*/
|
|
668
859
|
checkOrigin?: boolean | 'lax-proto';
|
|
860
|
+
/**
|
|
861
|
+
* Use the `X-Forwarded-Host` and `X-Forwarded-Proto` request headers to compute the URL exposed
|
|
862
|
+
* by `useLocation()` during SSR.
|
|
863
|
+
*
|
|
864
|
+
* Only enable this when the server is behind a proxy that overwrites these headers, otherwise
|
|
865
|
+
* clients can spoof the URL.
|
|
866
|
+
*
|
|
867
|
+
* Defaults to `false`.
|
|
868
|
+
*/
|
|
869
|
+
trustForwardedHeaders?: boolean;
|
|
669
870
|
}
|
|
670
871
|
|
|
671
872
|
/**
|
|
@@ -684,10 +885,10 @@ export declare interface ServerRequestEvent<T = unknown> {
|
|
|
684
885
|
}
|
|
685
886
|
|
|
686
887
|
/** @public */
|
|
687
|
-
export declare type ServerRequestMode = '
|
|
888
|
+
export declare type ServerRequestMode = 'static' | 'server';
|
|
688
889
|
|
|
689
890
|
/** @public */
|
|
690
|
-
export declare type ServerResponseHandler<T = any> = (status: number, headers: Headers, cookies: Cookie, resolve: (response: T) => void, requestEv:
|
|
891
|
+
export declare type ServerResponseHandler<T = any> = (status: number, headers: Headers, cookies: Cookie, resolve: (response: T) => void, requestEv: RequestEvent) => WritableStream<Uint8Array>;
|
|
691
892
|
|
|
692
893
|
/** @public */
|
|
693
894
|
declare interface StaticGenerate {
|