@qwik.dev/router 2.0.0-alpha.8 → 2.0.0-beta.1

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.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/lib/adapters/azure-swa/vite/index.cjs +3 -3
  3. package/lib/adapters/azure-swa/vite/index.d.ts +13 -13
  4. package/lib/adapters/bun-server/vite/index.cjs +3 -3
  5. package/lib/adapters/bun-server/vite/index.d.ts +14 -14
  6. package/lib/adapters/cloud-run/vite/index.cjs +3 -3
  7. package/lib/adapters/cloud-run/vite/index.d.ts +13 -13
  8. package/lib/adapters/cloudflare-pages/vite/index.cjs +3 -3
  9. package/lib/adapters/cloudflare-pages/vite/index.d.ts +27 -27
  10. package/lib/adapters/deno-server/vite/index.cjs +3 -3
  11. package/lib/adapters/deno-server/vite/index.d.ts +14 -14
  12. package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
  13. package/lib/adapters/netlify-edge/vite/index.d.ts +44 -44
  14. package/lib/adapters/node-server/vite/index.cjs +3 -3
  15. package/lib/adapters/node-server/vite/index.d.ts +14 -14
  16. package/lib/adapters/shared/vite/index.cjs +10 -3
  17. package/lib/adapters/shared/vite/index.d.ts +114 -114
  18. package/lib/adapters/shared/vite/index.mjs +7 -0
  19. package/lib/adapters/static/vite/index.cjs +10 -3
  20. package/lib/adapters/static/vite/index.d.ts +10 -10
  21. package/lib/adapters/static/vite/index.mjs +7 -0
  22. package/lib/adapters/vercel-edge/vite/index.cjs +3 -3
  23. package/lib/adapters/vercel-edge/vite/index.d.ts +45 -45
  24. package/lib/index.d.ts +878 -801
  25. package/lib/index.qwik.cjs +127 -51
  26. package/lib/index.qwik.mjs +130 -54
  27. package/lib/middleware/aws-lambda/index.d.ts +48 -50
  28. package/lib/middleware/azure-swa/index.d.ts +28 -28
  29. package/lib/middleware/bun/index.d.ts +35 -35
  30. package/lib/middleware/cloudflare-pages/index.d.ts +35 -35
  31. package/lib/middleware/deno/index.d.ts +47 -47
  32. package/lib/middleware/firebase/index.d.ts +26 -26
  33. package/lib/middleware/netlify-edge/index.d.ts +27 -27
  34. package/lib/middleware/node/index.cjs +3 -3
  35. package/lib/middleware/node/index.d.ts +64 -66
  36. package/lib/middleware/request-handler/index.cjs +133 -75
  37. package/lib/middleware/request-handler/index.d.ts +710 -681
  38. package/lib/middleware/request-handler/index.mjs +129 -72
  39. package/lib/middleware/vercel-edge/index.d.ts +26 -26
  40. package/lib/service-worker.cjs +13 -263
  41. package/lib/service-worker.d.ts +15 -4
  42. package/lib/service-worker.mjs +13 -263
  43. package/lib/static/index.cjs +3 -3
  44. package/lib/static/index.d.ts +96 -98
  45. package/lib/static/node.cjs +3 -3
  46. package/lib/vite/index.cjs +199 -262
  47. package/lib/vite/index.d.ts +154 -154
  48. package/lib/vite/index.mjs +197 -260
  49. package/package.json +8 -8
@@ -1,681 +1,710 @@
1
- import type { Action } from '@qwik.dev/router';
2
- import type { _deserialize } from '@qwik.dev/core/internal';
3
- import type { EnvGetter as EnvGetter_2 } from '@qwik.dev/router/middleware/request-handler';
4
- import type { FailReturn } from '@qwik.dev/router';
5
- import type { Loader as Loader_2 } from '@qwik.dev/router';
6
- import type { QwikCityPlan } from '@qwik.dev/router';
7
- import type { QwikIntrinsicElements } from '@qwik.dev/core';
8
- import type { QwikRouterConfig } from '@qwik.dev/router';
9
- import type { Render } from '@qwik.dev/core/server';
10
- import type { RenderOptions } from '@qwik.dev/core/server';
11
- import type { RequestEvent as RequestEvent_2 } from '@qwik.dev/router';
12
- import type { RequestHandler as RequestHandler_2 } from '@qwik.dev/router/middleware/request-handler';
13
- import type { ResolveSyncValue as ResolveSyncValue_2 } from '@qwik.dev/router/middleware/request-handler';
14
- import type { _serialize } from '@qwik.dev/core/internal';
15
- import type { ValueOrPromise } from '@qwik.dev/core';
16
- import type { _verifySerializable } from '@qwik.dev/core/internal';
17
-
18
- /** @public */
19
- export declare class AbortMessage {
20
- }
21
-
22
- /** @public */
23
- export declare type CacheControl = CacheControlOptions | number | 'day' | 'week' | 'month' | 'year' | 'no-cache' | 'immutable' | 'private';
24
-
25
- /** @public */
26
- declare interface CacheControlOptions {
27
- /**
28
- * The max-age=N response directive indicates that the response remains fresh until N seconds
29
- * after the response is generated. Note that max-age is not the elapsed time since the response
30
- * was received; it is the elapsed time since the response was generated on the origin server. So
31
- * if the other cache(s) — on the network route taken by the response — store the response for 100
32
- * seconds (indicated using the Age response header field), the browser cache would deduct 100
33
- * seconds from its freshness lifetime.
34
- */
35
- maxAge?: number;
36
- /**
37
- * The s-maxage response directive also indicates how long the response is fresh for (similar to
38
- * max-age) — but it is specific to shared caches, and they will ignore max-age when it is
39
- * present.
40
- */
41
- sMaxAge?: number;
42
- /**
43
- * The stale-while-revalidate response directive indicates that the cache could reuse a stale
44
- * response while it revalidates it to a cache.
45
- */
46
- staleWhileRevalidate?: number;
47
- /**
48
- * The stale-if-error response directive that indicates if a stale response can be used when
49
- * there's an error from the origin.
50
- */
51
- staleIfError?: number;
52
- /**
53
- * The no-store response directive indicates that any caches of any kind (private or shared)
54
- * should not store this response.
55
- */
56
- noStore?: boolean;
57
- /**
58
- * The no-cache response directive indicates that the response can be stored in caches, but the
59
- * response must be validated with the origin server before each reuse, even when the cache is
60
- * disconnected from the origin server.
61
- */
62
- noCache?: boolean;
63
- /**
64
- * The public response directive indicates that the response can be stored in a shared cache.
65
- * Responses for requests with Authorization header fields must not be stored in a shared cache;
66
- * however, the public directive will cause such responses to be stored in a shared cache.
67
- */
68
- public?: boolean;
69
- /**
70
- * The private response directive indicates that the response can be stored only in a private
71
- * cache (e.g. local caches in browsers). You should add the private directive for
72
- * user-personalized content, especially for responses received after login and for sessions
73
- * managed via cookies. If you forget to add private to a response with personalized content, then
74
- * that response can be stored in a shared cache and end up being reused for multiple users, which
75
- * can cause personal information to leak.
76
- */
77
- private?: boolean;
78
- /**
79
- * The immutable response directive indicates that the response will not be updated while it's
80
- * fresh.
81
- *
82
- * A modern best practice for static resources is to include version/hashes in their URLs, while
83
- * never modifying the resources — but instead, when necessary, updating the resources with newer
84
- * versions that have new version-numbers/hashes, so that their URLs are different. That's called
85
- * the cache-busting pattern.
86
- */
87
- immutable?: boolean;
88
- }
89
-
90
- /** @public */
91
- declare type CacheControlTarget = 'Cache-Control' | 'CDN-Cache-Control' | 'Cloudflare-CDN-Cache-Control' | 'Vercel-CDN-Cache-Control' | '~ANY-OTHER-STRING' | (string & {});
92
-
93
- /** @public */
94
- export declare interface ClientConn {
95
- ip?: string;
96
- country?: string;
97
- }
98
-
99
- /**
100
- * HTTP Client Error Status Codes Status codes in the 4xx range indicate that the client's request
101
- * was malformed or invalid and could not be understood or processed by the server.
102
- */
103
- declare type ClientErrorCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
104
-
105
- /** @public */
106
- declare interface ContentHeading {
107
- readonly text: string;
108
- readonly id: string;
109
- readonly level: number;
110
- }
111
-
112
- /** @public */
113
- declare interface ContentMenu {
114
- readonly text: string;
115
- readonly href?: string;
116
- readonly items?: ContentMenu[];
117
- }
118
-
119
- declare type ContentModule = PageModule | LayoutModule;
120
-
121
- declare type ContentModuleHead = DocumentHead | ResolvedDocumentHead;
122
-
123
- /** @public */
124
- export declare interface Cookie {
125
- /** Gets a `Request` cookie header value by name. */
126
- get(name: string): CookieValue | null;
127
- /** Gets all `Request` cookie headers. */
128
- getAll(): Record<string, CookieValue>;
129
- /** Checks if the `Request` cookie header name exists. */
130
- has(name: string): boolean;
131
- /** Sets a `Response` cookie header using the `Set-Cookie` header. */
132
- set(name: string, value: string | number | Record<string, any>, options?: CookieOptions): void;
133
- /**
134
- * Appends a `Response` cookie header using the `Set-Cookie` header.
135
- *
136
- * The difference between `set()` and `append()` is that if the specified header already exists,
137
- * `set()` will overwrite the existing value with the new one, whereas `append()` will append the
138
- * new value onto the end of the set of values.
139
- */
140
- append(name: string, value: string | number | Record<string, any>, options?: CookieOptions): void;
141
- /** Deletes cookie value by name using the `Response` cookie header. */
142
- delete(name: string, options?: Pick<CookieOptions, 'path' | 'domain' | 'sameSite'>): void;
143
- /** Returns an array of all the set `Response` `Set-Cookie` header values. */
144
- headers(): string[];
145
- }
146
-
147
- /** @public */
148
- /**
149
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
150
- *
151
- * @public
152
- */
153
- export declare interface CookieOptions {
154
- /**
155
- * Defines the host to which the cookie will be sent. If omitted, this attribute defaults to the
156
- * host of the current document URL, not including subdomains.
157
- */
158
- domain?: string;
159
- /**
160
- * Indicates the maximum lifetime of the cookie as an HTTP-date timestamp. If both `expires` and
161
- * `maxAge` are set, `maxAge` has precedence.
162
- */
163
- expires?: Date | string;
164
- /**
165
- * Forbids JavaScript from accessing the cookie, for example, through the `document.cookie`
166
- * property.
167
- */
168
- httpOnly?: boolean;
169
- /**
170
- * Indicates the number of seconds until the cookie expires. A zero or negative number will expire
171
- * the cookie immediately. If both `expires` and `maxAge` are set, `maxAge` has precedence. You
172
- * can also use the array syntax to set the max-age using minutes, hours, days or weeks. For
173
- * example, `{ maxAge: [3, "days"] }` would set the cookie to expire in 3 days.
174
- */
175
- maxAge?: number | [number, 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks'];
176
- /**
177
- * Indicates the path that must exist in the requested URL for the browser to send the Cookie
178
- * header.
179
- */
180
- path?: string;
181
- /**
182
- * Controls whether or not a cookie is sent with cross-site requests, providing some protection
183
- * against cross-site request forgery attacks (CSRF).
184
- */
185
- sameSite?: 'strict' | 'lax' | 'none' | 'Strict' | 'Lax' | 'None' | boolean;
186
- /**
187
- * Indicates that the cookie is sent to the server only when a request is made with the `https:`
188
- * scheme (except on localhost)
189
- */
190
- secure?: boolean;
191
- }
192
-
193
- /** @public */
194
- export declare interface CookieValue {
195
- value: string;
196
- json: <T = unknown>() => T;
197
- number: () => number;
198
- }
199
-
200
- /** @public */
201
- export declare type DeferReturn<T> = () => Promise<T>;
202
-
203
- /** @public */
204
- declare type DocumentHead = DocumentHeadValue | ((props: DocumentHeadProps) => DocumentHeadValue);
205
-
206
- /** @public */
207
- declare interface DocumentHeadProps extends RouteLocation {
208
- readonly head: ResolvedDocumentHead;
209
- readonly withLocale: <T>(fn: () => T) => T;
210
- readonly resolveValue: ResolveSyncValue_2;
211
- }
212
-
213
- /** @public */
214
- declare interface DocumentHeadValue<FrontMatter extends Record<string, any> = Record<string, unknown>> {
215
- /** Sets `document.title`. */
216
- readonly title?: string;
217
- /**
218
- * Used to manually set meta tags in the head. Additionally, the `data` property could be used to
219
- * set arbitrary data which the `<head>` component could later use to generate `<meta>` tags.
220
- */
221
- readonly meta?: readonly DocumentMeta[];
222
- /** Used to manually append `<link>` elements to the `<head>`. */
223
- readonly links?: readonly DocumentLink[];
224
- /** Used to manually append `<style>` elements to the `<head>`. */
225
- readonly styles?: readonly DocumentStyle[];
226
- /** Used to manually append `<script>` elements to the `<head>`. */
227
- readonly scripts?: readonly DocumentScript[];
228
- /**
229
- * Arbitrary object containing custom data. When the document head is created from markdown files,
230
- * the frontmatter attributes that are not recognized as a well-known meta names (such as title,
231
- * description, author, etc...), are stored in this property.
232
- */
233
- readonly frontmatter?: Readonly<FrontMatter>;
234
- }
235
-
236
- /** @public */
237
- declare interface DocumentLink {
238
- as?: string;
239
- crossorigin?: string;
240
- disabled?: boolean;
241
- href?: string;
242
- hreflang?: string;
243
- id?: string;
244
- imagesizes?: string;
245
- imagesrcset?: string;
246
- integrity?: string;
247
- media?: string;
248
- prefetch?: string;
249
- referrerpolicy?: string;
250
- rel?: string;
251
- sizes?: string;
252
- title?: string;
253
- type?: string;
254
- key?: string;
255
- }
256
-
257
- /** @public */
258
- declare interface DocumentMeta {
259
- readonly content?: string;
260
- readonly httpEquiv?: string;
261
- readonly name?: string;
262
- readonly property?: string;
263
- readonly key?: string;
264
- readonly itemprop?: string;
265
- readonly media?: string;
266
- }
267
-
268
- /** @beta */
269
- declare interface DocumentScript {
270
- readonly script?: string;
271
- readonly props?: Readonly<QwikIntrinsicElements['script']>;
272
- readonly key?: string;
273
- }
274
-
275
- /** @public */
276
- declare interface DocumentStyle {
277
- readonly style: string;
278
- readonly props?: Readonly<QwikIntrinsicElements['style']>;
279
- readonly key?: string;
280
- }
281
-
282
- /** @public */
283
- export declare interface EnvGetter {
284
- get(key: string): string | undefined;
285
- }
286
-
287
- declare type ErrorCodes = ClientErrorCode | ServerErrorCode;
288
-
289
- declare class ErrorResponse extends Error {
290
- status: number;
291
- constructor(status: number, message?: string);
292
- }
293
-
294
- /** @public */
295
- export declare function getErrorHtml(status: number, e: any): string;
296
-
297
- /**
298
- * HTTP Informational Status Codes Status codes in the 1xx range indicate that the server has
299
- * received and is processing the request, but no response is available yet.
300
- */
301
- declare type InformationalCode = 100 | 101 | 102 | 103;
302
-
303
- declare interface LayoutModule extends RouteModule {
304
- readonly default: unknown;
305
- readonly head?: ContentModuleHead;
306
- }
307
-
308
- declare type LoadedRoute = [
309
- routeName: string,
310
- params: PathParams,
311
- mods: (RouteModule | ContentModule)[],
312
- menu: ContentMenu | undefined,
313
- routeBundleNames: string[] | undefined
314
- ];
315
-
316
- /** @public */
317
- export declare const mergeHeadersCookies: (headers: Headers, cookies: Cookie) => Headers;
318
-
319
- /** @public */
320
- declare interface PageModule extends RouteModule {
321
- readonly default: unknown;
322
- readonly head?: ContentModuleHead;
323
- readonly headings?: ContentHeading[];
324
- readonly onStaticGenerate?: StaticGenerateHandler;
325
- }
326
-
327
- /** @public */
328
- declare type PathParams = Record<string, string>;
329
-
330
- declare interface QwikRouterRun<T> {
331
- response: Promise<T | null>;
332
- requestEv: RequestEvent_2;
333
- completion: Promise<unknown>;
334
- }
335
-
336
- /** @public */
337
- declare interface QwikSerializer {
338
- _deserialize: typeof _deserialize;
339
- _serialize: typeof _serialize;
340
- _verifySerializable: typeof _verifySerializable;
341
- }
342
-
343
- /**
344
- * HTTP Redirect Status Codes Status codes in the 3xx range indicate that further action must be
345
- * taken by the client to complete the request.
346
- */
347
- declare type RedirectCode = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;
348
-
349
- /** @public */
350
- export declare class RedirectMessage extends AbortMessage {
351
- }
352
-
353
- /** @public */
354
- export declare interface RequestEvent<PLATFORM = QwikRouterPlatform> extends RequestEventCommon<PLATFORM> {
355
- /** True if headers have been sent, preventing any more headers from being set. */
356
- readonly headersSent: boolean;
357
- /** True if the middleware chain has finished executing. */
358
- readonly exited: boolean;
359
- /**
360
- * Low-level access to write to the HTTP response stream. Once `getWritableStream()` is called,
361
- * the status and headers can no longer be modified and will be sent over the network.
362
- */
363
- readonly getWritableStream: () => WritableStream<Uint8Array>;
364
- /**
365
- * Invoke the next middleware function in the chain.
366
- *
367
- * NOTE: Ensure that the call to `next()` is `await`ed.
368
- */
369
- readonly next: () => Promise<void>;
370
- }
371
-
372
- /** @public */
373
- export declare interface RequestEventAction<PLATFORM = QwikRouterPlatform> extends RequestEventCommon<PLATFORM> {
374
- fail: <T extends Record<string, any>>(status: number, returnData: T) => FailReturn<T>;
375
- }
376
-
377
- /** @public */
378
- export declare interface RequestEventBase<PLATFORM = QwikRouterPlatform> {
379
- /**
380
- * HTTP response headers. Notice it will be empty until you first add a header. If you want to
381
- * read the request headers, use `request.headers` instead.
382
- *
383
- * https://developer.mozilla.org/en-US/docs/Glossary/Response_header
384
- */
385
- readonly headers: Headers;
386
- /**
387
- * HTTP request and response cookie. Use the `get()` method to retrieve a request cookie value.
388
- * Use the `set()` method to set a response cookie value.
389
- *
390
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
391
- */
392
- readonly cookie: Cookie;
393
- /**
394
- * HTTP request method.
395
- *
396
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
397
- */
398
- readonly method: string;
399
- /**
400
- * URL pathname. Does not include the protocol, domain, query string (search params) or hash.
401
- *
402
- * https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname
403
- */
404
- readonly pathname: string;
405
- /**
406
- * URL path params which have been parsed from the current url pathname segments. Use `query` to
407
- * instead retrieve the query string search params.
408
- */
409
- readonly params: Readonly<Record<string, string>>;
410
- /**
411
- * URL Query Strings (URL Search Params). Use `params` to instead retrieve the route params found
412
- * in the url pathname.
413
- *
414
- * https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
415
- */
416
- readonly query: URLSearchParams;
417
- /** HTTP request URL. */
418
- readonly url: URL;
419
- /** The base pathname of the request, which can be configured at build time. Defaults to `/`. */
420
- readonly basePathname: string;
421
- /** HTTP request information. */
422
- readonly request: Request;
423
- /** Platform specific data and functions */
424
- readonly platform: PLATFORM;
425
- /** Platform provided environment variables. */
426
- readonly env: EnvGetter;
427
- /**
428
- * Shared Map across all the request handlers. Every HTTP request will get a new instance of the
429
- * shared map. The shared map is useful for sharing data between request handlers.
430
- */
431
- readonly sharedMap: Map<string, any>;
432
- /**
433
- * This method will check the request headers for a `Content-Type` header and parse the body
434
- * accordingly. It supports `application/json`, `application/x-www-form-urlencoded`, and
435
- * `multipart/form-data` content types.
436
- *
437
- * If the `Content-Type` header is not set, it will return `null`.
438
- */
439
- readonly parseBody: () => Promise<unknown>;
440
- /**
441
- * Convenience method to set the Cache-Control header. Depending on your CDN, you may want to add
442
- * another cacheControl with the second argument set to `CDN-Cache-Control` or any other value (we
443
- * provide the most common values for auto-complete, but you can use any string you want).
444
- *
445
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control and
446
- * https://qwik.dev/docs/caching/#CDN-Cache-Controls for more information.
447
- */
448
- readonly cacheControl: (cacheControl: CacheControl, target?: CacheControlTarget) => void;
449
- /**
450
- * Provides information about the client connection, such as the IP address and the country the
451
- * request originated from.
452
- */
453
- readonly clientConn: ClientConn;
454
- /**
455
- * Request's AbortSignal (same as `request.signal`). This signal indicates that the request has
456
- * been aborted.
457
- */
458
- readonly signal: AbortSignal;
459
- }
460
-
461
- /** @public */
462
- export declare interface RequestEventCommon<PLATFORM = QwikRouterPlatform> extends RequestEventBase<PLATFORM> {
463
- /**
464
- * HTTP response status code. Sets the status code when called with an argument. Always returns
465
- * the status code, so calling `status()` without an argument will can be used to return the
466
- * current status code.
467
- *
468
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
469
- */
470
- readonly status: (statusCode?: StatusCodes) => number;
471
- /**
472
- * Which locale the content is in.
473
- *
474
- * The locale value can be retrieved from selected methods using `getLocale()`:
475
- */
476
- readonly locale: (local?: string) => string;
477
- /**
478
- * URL to redirect to. When called, the response will immediately end with the correct redirect
479
- * status and headers.
480
- *
481
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
482
- */
483
- readonly redirect: (statusCode: RedirectCode, url: string) => RedirectMessage;
484
- /**
485
- * When called, the response will immediately end with the given status code. This could be useful
486
- * to end a response with `404`, and use the 404 handler in the routes directory. See
487
- * https://developer.mozilla.org/en-US/docs/Web/HTTP/Status for which status code should be used.
488
- */
489
- readonly error: (statusCode: ErrorCodes, message: string) => ErrorResponse;
490
- /**
491
- * Convenience method to send an text body response. The response will be automatically set the
492
- * `Content-Type` header to`text/plain; charset=utf-8`. An `text()` response can only be called
493
- * once.
494
- */
495
- readonly text: (statusCode: StatusCodes, text: string) => AbortMessage;
496
- /**
497
- * Convenience method to send an HTML body response. The response will be automatically set the
498
- * `Content-Type` header to`text/html; charset=utf-8`. An `html()` response can only be called
499
- * once.
500
- */
501
- readonly html: (statusCode: StatusCodes, html: string) => AbortMessage;
502
- /**
503
- * Convenience method to JSON stringify the data and send it in the response. The response will be
504
- * automatically set the `Content-Type` header to `application/json; charset=utf-8`. A `json()`
505
- * response can only be called once.
506
- */
507
- readonly json: (statusCode: StatusCodes, data: any) => AbortMessage;
508
- /**
509
- * Send a body response. The `Content-Type` response header is not automatically set when using
510
- * `send()` and must be set manually. A `send()` response can only be called once.
511
- */
512
- readonly send: SendMethod;
513
- readonly exit: () => AbortMessage;
514
- }
515
-
516
- declare interface RequestEventInternal extends RequestEvent, RequestEventLoader {
517
- [RequestEvLoaders]: Record<string, ValueOrPromise<unknown> | undefined>;
518
- [RequestEvMode]: ServerRequestMode;
519
- [RequestEvTrailingSlash]: boolean;
520
- [RequestEvRoute]: LoadedRoute | null;
521
- [RequestEvQwikSerializer]: QwikSerializer;
522
- /**
523
- * Check if this request is already written to.
524
- *
525
- * @returns `true`, if `getWritableStream()` has already been called.
526
- */
527
- isDirty(): boolean;
528
- }
529
-
530
- /** @public */
531
- export declare interface RequestEventLoader<PLATFORM = QwikRouterPlatform> extends RequestEventAction<PLATFORM> {
532
- resolveValue: ResolveValue;
533
- defer: <T>(returnData: Promise<T> | (() => Promise<T>)) => DeferReturn<T>;
534
- }
535
-
536
- declare const RequestEvLoaders: unique symbol;
537
-
538
- declare const RequestEvMode: unique symbol;
539
-
540
- declare const RequestEvQwikSerializer: unique symbol;
541
-
542
- declare const RequestEvRoute: unique symbol;
543
-
544
- declare const RequestEvTrailingSlash: unique symbol;
545
-
546
- /** @public */
547
- export declare type RequestHandler<PLATFORM = QwikRouterPlatform> = (ev: RequestEvent<PLATFORM>) => Promise<void> | void;
548
-
549
- /**
550
- * The request handler for QwikRouter. Called by every integration.
551
- *
552
- * @public
553
- */
554
- export declare function requestHandler<T = unknown>(serverRequestEv: ServerRequestEvent<T>, opts: ServerRenderOptions, qwikSerializer: QwikSerializer): Promise<QwikRouterRun<T> | null>;
555
-
556
- /** @public */
557
- declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter>>;
558
-
559
- /** @public */
560
- export declare interface ResolveSyncValue {
561
- <T>(loader: Loader_2<T>): Awaited<T> extends () => any ? never : Awaited<T>;
562
- <T>(action: Action<T>): Awaited<T> | undefined;
563
- }
564
-
565
- /** @public */
566
- export declare interface ResolveValue {
567
- <T>(loader: Loader_2<T>): Awaited<T> extends () => any ? never : Promise<T>;
568
- <T>(action: Action<T>): Promise<T | undefined>;
569
- }
570
-
571
- /** @public */
572
- declare interface RouteLocation {
573
- readonly params: Readonly<Record<string, string>>;
574
- readonly url: URL;
575
- readonly isNavigating: boolean;
576
- readonly prevUrl: URL | undefined;
577
- }
578
-
579
- declare interface RouteModule<BODY = unknown> {
580
- onDelete?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
581
- onGet?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
582
- onHead?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
583
- onOptions?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
584
- onPatch?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
585
- onPost?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
586
- onPut?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
587
- onRequest?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
588
- }
589
-
590
- /** @public */
591
- declare interface SendMethod {
592
- (statusCode: StatusCodes, data: any): AbortMessage;
593
- (response: Response): AbortMessage;
594
- }
595
-
596
- /** @public */
597
- export declare class ServerError<T = Record<any, any>> extends Error {
598
- status: number;
599
- data: T;
600
- constructor(status: number, data: T);
601
- }
602
-
603
- /**
604
- * HTTP Server Error Status Codes Status codes in the 5xx range indicate that the server encountered
605
- * an error or was unable to fulfill the request due to unexpected conditions.
606
- */
607
- declare type ServerErrorCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
608
-
609
- /** @public */
610
- export declare interface ServerRenderOptions extends RenderOptions {
611
- render: Render;
612
- /** @deprecated Use `QwikRouterConfig` instead. Will be removed in V3 */
613
- qwikCityPlan?: QwikCityPlan;
614
- qwikRouterConfig?: QwikRouterConfig;
615
- /**
616
- * Protection against cross-site request forgery (CSRF) attacks.
617
- *
618
- * When `true`, for every incoming POST, PUT, PATCH, or DELETE form submissions, the request
619
- * origin is checked to match the server's origin.
620
- *
621
- * Be careful when disabling this option as it may lead to CSRF attacks.
622
- *
623
- * Defaults to `true`.
624
- */
625
- checkOrigin?: boolean;
626
- }
627
-
628
- /**
629
- * @public
630
- * Request event created by the server.
631
- */
632
- export declare interface ServerRequestEvent<T = unknown> {
633
- mode: ServerRequestMode;
634
- url: URL;
635
- locale: string | undefined;
636
- platform: QwikRouterPlatform;
637
- request: Request;
638
- env: EnvGetter;
639
- getClientConn: () => ClientConn;
640
- getWritableStream: ServerResponseHandler<T>;
641
- }
642
-
643
- /** @public */
644
- export declare type ServerRequestMode = 'dev' | 'static' | 'server';
645
-
646
- /** @public */
647
- export declare type ServerResponseHandler<T = any> = (status: number, headers: Headers, cookies: Cookie, resolve: (response: T) => void, requestEv: RequestEventInternal) => WritableStream<Uint8Array>;
648
-
649
- /** @public */
650
- declare interface StaticGenerate {
651
- params?: PathParams[];
652
- }
653
-
654
- /** @public */
655
- declare type StaticGenerateHandler = ({ env, }: {
656
- env: EnvGetter_2;
657
- }) => Promise<StaticGenerate> | StaticGenerate;
658
-
659
- declare type StatusCodes = InformationalCode | SuccessCode | ClientErrorCode | ServerErrorCode | RedirectCode | number;
660
-
661
- /**
662
- * HTTP Success Status Codes Status codes in the 2xx range indicate that the client's request was
663
- * successfully received, understood, and accepted by the server.
664
- */
665
- declare type SuccessCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
666
-
667
- /**
668
- * TextEncoderStream polyfill based on Node.js' implementation
669
- * https://github.com/nodejs/node/blob/3f3226c8e363a5f06c1e6a37abd59b6b8c1923f1/lib/internal/webstreams/encoding.js#L38-L119
670
- * (MIT License)
671
- */
672
- /** @internal */
673
- export declare class _TextEncoderStream_polyfill {
674
- #private;
675
- get encoding(): string;
676
- get readable(): ReadableStream<Uint8Array>;
677
- get writable(): WritableStream<string>;
678
- get [Symbol.toStringTag](): string;
679
- }
680
-
681
- export { }
1
+ import type { Action } from '@qwik.dev/router';
2
+ import type { _deserialize } from '@qwik.dev/core/internal';
3
+ import type { EnvGetter as EnvGetter_2 } from '@qwik.dev/router/middleware/request-handler';
4
+ import type { FailReturn } from '@qwik.dev/router';
5
+ import type { Loader as Loader_2 } from '@qwik.dev/router';
6
+ import type { QwikCityPlan } from '@qwik.dev/router';
7
+ import type { QwikIntrinsicElements } from '@qwik.dev/core';
8
+ import type { QwikRouterConfig } from '@qwik.dev/router';
9
+ import type { Render } from '@qwik.dev/core/server';
10
+ import type { RenderOptions } from '@qwik.dev/core/server';
11
+ import { RequestEvent as RequestEvent_2 } from '@qwik.dev/router/middleware/request-handler';
12
+ import type { RequestHandler as RequestHandler_2 } from '@qwik.dev/router/middleware/request-handler';
13
+ import type { ResolveSyncValue as ResolveSyncValue_2 } from '@qwik.dev/router/middleware/request-handler';
14
+ import type { _serialize } from '@qwik.dev/core/internal';
15
+ import type { ValueOrPromise } from '@qwik.dev/core';
16
+ import type { _verifySerializable } from '@qwik.dev/core/internal';
17
+
18
+ /** @public */
19
+ export declare class AbortMessage {
20
+ }
21
+
22
+ /** @public */
23
+ export declare type CacheControl = CacheControlOptions | number | 'day' | 'week' | 'month' | 'year' | 'no-cache' | 'immutable' | 'private';
24
+
25
+ /** @public */
26
+ declare interface CacheControlOptions {
27
+ /**
28
+ * The max-age=N response directive indicates that the response remains fresh until N seconds
29
+ * after the response is generated. Note that max-age is not the elapsed time since the response
30
+ * was received; it is the elapsed time since the response was generated on the origin server. So
31
+ * if the other cache(s) — on the network route taken by the response — store the response for 100
32
+ * seconds (indicated using the Age response header field), the browser cache would deduct 100
33
+ * seconds from its freshness lifetime.
34
+ */
35
+ maxAge?: number;
36
+ /**
37
+ * The s-maxage response directive also indicates how long the response is fresh for (similar to
38
+ * max-age) — but it is specific to shared caches, and they will ignore max-age when it is
39
+ * present.
40
+ */
41
+ sMaxAge?: number;
42
+ /**
43
+ * The stale-while-revalidate response directive indicates that the cache could reuse a stale
44
+ * response while it revalidates it to a cache.
45
+ */
46
+ staleWhileRevalidate?: number;
47
+ /**
48
+ * The stale-if-error response directive that indicates if a stale response can be used when
49
+ * there's an error from the origin.
50
+ */
51
+ staleIfError?: number;
52
+ /**
53
+ * The no-store response directive indicates that any caches of any kind (private or shared)
54
+ * should not store this response.
55
+ */
56
+ noStore?: boolean;
57
+ /**
58
+ * The no-cache response directive indicates that the response can be stored in caches, but the
59
+ * response must be validated with the origin server before each reuse, even when the cache is
60
+ * disconnected from the origin server.
61
+ */
62
+ noCache?: boolean;
63
+ /**
64
+ * The public response directive indicates that the response can be stored in a shared cache.
65
+ * Responses for requests with Authorization header fields must not be stored in a shared cache;
66
+ * however, the public directive will cause such responses to be stored in a shared cache.
67
+ */
68
+ public?: boolean;
69
+ /**
70
+ * The private response directive indicates that the response can be stored only in a private
71
+ * cache (e.g. local caches in browsers). You should add the private directive for
72
+ * user-personalized content, especially for responses received after login and for sessions
73
+ * managed via cookies. If you forget to add private to a response with personalized content, then
74
+ * that response can be stored in a shared cache and end up being reused for multiple users, which
75
+ * can cause personal information to leak.
76
+ */
77
+ private?: boolean;
78
+ /**
79
+ * The immutable response directive indicates that the response will not be updated while it's
80
+ * fresh.
81
+ *
82
+ * A modern best practice for static resources is to include version/hashes in their URLs, while
83
+ * never modifying the resources — but instead, when necessary, updating the resources with newer
84
+ * versions that have new version-numbers/hashes, so that their URLs are different. That's called
85
+ * the cache-busting pattern.
86
+ */
87
+ immutable?: boolean;
88
+ }
89
+
90
+ /** @public */
91
+ declare type CacheControlTarget = 'Cache-Control' | 'CDN-Cache-Control' | 'Cloudflare-CDN-Cache-Control' | 'Vercel-CDN-Cache-Control' | '~ANY-OTHER-STRING' | (string & {});
92
+
93
+ /** @public */
94
+ export declare interface ClientConn {
95
+ ip?: string;
96
+ country?: string;
97
+ }
98
+
99
+ /**
100
+ * HTTP Client Error Status Codes Status codes in the 4xx range indicate that the client's request
101
+ * was malformed or invalid and could not be understood or processed by the server.
102
+ */
103
+ declare type ClientErrorCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 499;
104
+
105
+ /** @public */
106
+ declare interface ContentHeading {
107
+ readonly text: string;
108
+ readonly id: string;
109
+ readonly level: number;
110
+ }
111
+
112
+ /** @public */
113
+ declare interface ContentMenu {
114
+ readonly text: string;
115
+ readonly href?: string;
116
+ readonly items?: ContentMenu[];
117
+ }
118
+
119
+ declare type ContentModule = PageModule | LayoutModule;
120
+
121
+ declare type ContentModuleHead = DocumentHead | ResolvedDocumentHead;
122
+
123
+ /** @public */
124
+ export declare interface Cookie {
125
+ /** Gets a `Request` cookie header value by name. */
126
+ get(name: string): CookieValue | null;
127
+ /** Gets all `Request` cookie headers. */
128
+ getAll(): Record<string, CookieValue>;
129
+ /** Checks if the `Request` cookie header name exists. */
130
+ has(name: string): boolean;
131
+ /** Sets a `Response` cookie header using the `Set-Cookie` header. */
132
+ set(name: string, value: string | number | Record<string, any>, options?: CookieOptions): void;
133
+ /**
134
+ * Appends a `Response` cookie header using the `Set-Cookie` header.
135
+ *
136
+ * The difference between `set()` and `append()` is that if the specified header already exists,
137
+ * `set()` will overwrite the existing value with the new one, whereas `append()` will append the
138
+ * new value onto the end of the set of values.
139
+ */
140
+ append(name: string, value: string | number | Record<string, any>, options?: CookieOptions): void;
141
+ /** Deletes cookie value by name using the `Response` cookie header. */
142
+ delete(name: string, options?: Pick<CookieOptions, 'path' | 'domain' | 'sameSite'>): void;
143
+ /** Returns an array of all the set `Response` `Set-Cookie` header values. */
144
+ headers(): string[];
145
+ }
146
+
147
+ /** @public */
148
+ /**
149
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
150
+ *
151
+ * @public
152
+ */
153
+ export declare interface CookieOptions {
154
+ /**
155
+ * Defines the host to which the cookie will be sent. If omitted, this attribute defaults to the
156
+ * host of the current document URL, not including subdomains.
157
+ */
158
+ domain?: string;
159
+ /**
160
+ * Indicates the maximum lifetime of the cookie as an HTTP-date timestamp. If both `expires` and
161
+ * `maxAge` are set, `maxAge` has precedence.
162
+ */
163
+ expires?: Date | string;
164
+ /**
165
+ * Forbids JavaScript from accessing the cookie, for example, through the `document.cookie`
166
+ * property.
167
+ */
168
+ httpOnly?: boolean;
169
+ /**
170
+ * Indicates the number of seconds until the cookie expires. A zero or negative number will expire
171
+ * the cookie immediately. If both `expires` and `maxAge` are set, `maxAge` has precedence. You
172
+ * can also use the array syntax to set the max-age using minutes, hours, days or weeks. For
173
+ * example, `{ maxAge: [3, "days"] }` would set the cookie to expire in 3 days.
174
+ */
175
+ maxAge?: number | [number, 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks'];
176
+ /**
177
+ * Indicates the path that must exist in the requested URL for the browser to send the Cookie
178
+ * header.
179
+ */
180
+ path?: string;
181
+ /**
182
+ * Controls whether or not a cookie is sent with cross-site requests, providing some protection
183
+ * against cross-site request forgery attacks (CSRF).
184
+ */
185
+ sameSite?: 'strict' | 'lax' | 'none' | 'Strict' | 'Lax' | 'None' | boolean;
186
+ /**
187
+ * Indicates that the cookie is sent to the server only when a request is made with the `https:`
188
+ * scheme (except on localhost)
189
+ */
190
+ secure?: boolean;
191
+ }
192
+
193
+ /** @public */
194
+ export declare interface CookieValue {
195
+ value: string;
196
+ json: <T = unknown>() => T;
197
+ number: () => number;
198
+ }
199
+
200
+ /** @public */
201
+ export declare type DeferReturn<T> = () => Promise<T>;
202
+
203
+ /** @public */
204
+ declare type DocumentHead = DocumentHeadValue | ((props: DocumentHeadProps) => DocumentHeadValue);
205
+
206
+ /** @public */
207
+ declare interface DocumentHeadProps extends RouteLocation {
208
+ readonly head: ResolvedDocumentHead;
209
+ readonly withLocale: <T>(fn: () => T) => T;
210
+ readonly resolveValue: ResolveSyncValue_2;
211
+ }
212
+
213
+ /** @public */
214
+ declare interface DocumentHeadValue<FrontMatter extends Record<string, any> = Record<string, unknown>> {
215
+ /** Sets `document.title`. */
216
+ readonly title?: string;
217
+ /**
218
+ * Used to manually set meta tags in the head. Additionally, the `data` property could be used to
219
+ * set arbitrary data which the `<head>` component could later use to generate `<meta>` tags.
220
+ */
221
+ readonly meta?: readonly DocumentMeta[];
222
+ /** Used to manually append `<link>` elements to the `<head>`. */
223
+ readonly links?: readonly DocumentLink[];
224
+ /** Used to manually append `<style>` elements to the `<head>`. */
225
+ readonly styles?: readonly DocumentStyle[];
226
+ /** Used to manually append `<script>` elements to the `<head>`. */
227
+ readonly scripts?: readonly DocumentScript[];
228
+ /**
229
+ * Arbitrary object containing custom data. When the document head is created from markdown files,
230
+ * the frontmatter attributes that are not recognized as a well-known meta names (such as title,
231
+ * description, author, etc...), are stored in this property.
232
+ */
233
+ readonly frontmatter?: Readonly<FrontMatter>;
234
+ }
235
+
236
+ /** @public */
237
+ declare interface DocumentLink {
238
+ as?: string;
239
+ crossorigin?: string;
240
+ disabled?: boolean;
241
+ href?: string;
242
+ hreflang?: string;
243
+ id?: string;
244
+ imagesizes?: string;
245
+ imagesrcset?: string;
246
+ integrity?: string;
247
+ media?: string;
248
+ prefetch?: string;
249
+ referrerpolicy?: string;
250
+ rel?: string;
251
+ sizes?: string;
252
+ title?: string;
253
+ type?: string;
254
+ key?: string;
255
+ }
256
+
257
+ /** @public */
258
+ declare interface DocumentMeta {
259
+ readonly content?: string;
260
+ readonly httpEquiv?: string;
261
+ readonly name?: string;
262
+ readonly property?: string;
263
+ readonly key?: string;
264
+ readonly itemprop?: string;
265
+ readonly media?: string;
266
+ }
267
+
268
+ /** @beta */
269
+ declare interface DocumentScript {
270
+ readonly script?: string;
271
+ readonly props?: Readonly<QwikIntrinsicElements['script']>;
272
+ readonly key?: string;
273
+ }
274
+
275
+ /** @public */
276
+ declare interface DocumentStyle {
277
+ readonly style: string;
278
+ readonly props?: Readonly<QwikIntrinsicElements['style']>;
279
+ readonly key?: string;
280
+ }
281
+
282
+ /** @public */
283
+ export declare interface EnvGetter {
284
+ get(key: string): string | undefined;
285
+ }
286
+
287
+ declare type ErrorCodes = ClientErrorCode | ServerErrorCode;
288
+
289
+ /** @public */
290
+ export declare function getErrorHtml(status: number, e: any): string;
291
+
292
+ /**
293
+ * HTTP Informational Status Codes Status codes in the 1xx range indicate that the server has
294
+ * received and is processing the request, but no response is available yet.
295
+ */
296
+ declare type InformationalCode = 100 | 101 | 102 | 103;
297
+
298
+ declare interface LayoutModule extends RouteModule {
299
+ readonly default: unknown;
300
+ readonly head?: ContentModuleHead;
301
+ }
302
+
303
+ declare type LoadedRoute = [
304
+ routeName: string,
305
+ params: PathParams,
306
+ mods: (RouteModule | ContentModule)[],
307
+ menu: ContentMenu | undefined,
308
+ routeBundleNames: string[] | undefined
309
+ ];
310
+
311
+ /** @public */
312
+ export declare const mergeHeadersCookies: (headers: Headers, cookies: Cookie) => Headers;
313
+
314
+ /** @public */
315
+ declare interface PageModule extends RouteModule {
316
+ readonly default: unknown;
317
+ readonly head?: ContentModuleHead;
318
+ readonly headings?: ContentHeading[];
319
+ readonly onStaticGenerate?: StaticGenerateHandler;
320
+ }
321
+
322
+ /** @public */
323
+ declare type PathParams = Record<string, string>;
324
+
325
+ declare interface QwikRouterRun<T> {
326
+ response: Promise<T | null>;
327
+ requestEv: RequestEvent_2;
328
+ completion: Promise<unknown>;
329
+ }
330
+
331
+ /** @public */
332
+ declare interface QwikSerializer {
333
+ _deserialize: typeof _deserialize;
334
+ _serialize: typeof _serialize;
335
+ _verifySerializable: typeof _verifySerializable;
336
+ }
337
+
338
+ /**
339
+ * HTTP Redirect Status Codes Status codes in the 3xx range indicate that further action must be
340
+ * taken by the client to complete the request.
341
+ */
342
+ declare type RedirectCode = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;
343
+
344
+ /** @public */
345
+ export declare class RedirectMessage extends AbortMessage {
346
+ }
347
+
348
+ /** @public */
349
+ export declare interface RequestEvent<PLATFORM = QwikRouterPlatform> extends RequestEventCommon<PLATFORM> {
350
+ /** True if headers have been sent, preventing any more headers from being set. */
351
+ readonly headersSent: boolean;
352
+ /** True if the middleware chain has finished executing. */
353
+ readonly exited: boolean;
354
+ /**
355
+ * Low-level access to write to the HTTP response stream. Once `getWritableStream()` is called,
356
+ * the status and headers can no longer be modified and will be sent over the network.
357
+ */
358
+ readonly getWritableStream: () => WritableStream<Uint8Array>;
359
+ /**
360
+ * Invoke the next middleware function in the chain.
361
+ *
362
+ * NOTE: Ensure that the call to `next()` is `await`ed.
363
+ */
364
+ readonly next: () => Promise<void>;
365
+ }
366
+
367
+ /** @public */
368
+ export declare interface RequestEventAction<PLATFORM = QwikRouterPlatform> extends RequestEventCommon<PLATFORM> {
369
+ fail: <T extends Record<string, any>>(status: number, returnData: T) => FailReturn<T>;
370
+ }
371
+
372
+ /** @public */
373
+ export declare interface RequestEventBase<PLATFORM = QwikRouterPlatform> {
374
+ /**
375
+ * HTTP response headers. Notice it will be empty until you first add a header. If you want to
376
+ * read the request headers, use `request.headers` instead.
377
+ *
378
+ * https://developer.mozilla.org/en-US/docs/Glossary/Response_header
379
+ */
380
+ readonly headers: Headers;
381
+ /**
382
+ * HTTP request and response cookie. Use the `get()` method to retrieve a request cookie value.
383
+ * Use the `set()` method to set a response cookie value.
384
+ *
385
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
386
+ */
387
+ readonly cookie: Cookie;
388
+ /**
389
+ * HTTP request method.
390
+ *
391
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
392
+ */
393
+ readonly method: string;
394
+ /**
395
+ * URL pathname. Does not include the protocol, domain, query string (search params) or hash.
396
+ *
397
+ * https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname
398
+ */
399
+ readonly pathname: string;
400
+ /**
401
+ * URL path params which have been parsed from the current url pathname segments. Use `query` to
402
+ * instead retrieve the query string search params.
403
+ */
404
+ readonly params: Readonly<Record<string, string>>;
405
+ /**
406
+ * URL Query Strings (URL Search Params). Use `params` to instead retrieve the route params found
407
+ * in the url pathname.
408
+ *
409
+ * https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
410
+ */
411
+ readonly query: URLSearchParams;
412
+ /** HTTP request URL. */
413
+ readonly url: URL;
414
+ /**
415
+ * The original HTTP request URL.
416
+ *
417
+ * This property was introduced to support the rewrite feature.
418
+ *
419
+ * If rewrite is called, the url property will be changed to the rewritten url. while originalUrl
420
+ * will stay the same(e.g the url inserted to the address bar).
421
+ *
422
+ * If rewrite is never called as part of the request, the url property and the originalUrl are
423
+ * equal.
424
+ */
425
+ readonly originalUrl: URL;
426
+ /** The base pathname of the request, which can be configured at build time. Defaults to `/`. */
427
+ readonly basePathname: string;
428
+ /** HTTP request information. */
429
+ readonly request: Request;
430
+ /** Platform specific data and functions */
431
+ readonly platform: PLATFORM;
432
+ /** Platform provided environment variables. */
433
+ readonly env: EnvGetter;
434
+ /**
435
+ * Shared Map across all the request handlers. Every HTTP request will get a new instance of the
436
+ * shared map. The shared map is useful for sharing data between request handlers.
437
+ */
438
+ readonly sharedMap: Map<string, any>;
439
+ /**
440
+ * This method will check the request headers for a `Content-Type` header and parse the body
441
+ * accordingly. It supports `application/json`, `application/x-www-form-urlencoded`, and
442
+ * `multipart/form-data` content types.
443
+ *
444
+ * If the `Content-Type` header is not set, it will return `null`.
445
+ */
446
+ readonly parseBody: () => Promise<unknown>;
447
+ /**
448
+ * Convenience method to set the Cache-Control header. Depending on your CDN, you may want to add
449
+ * another cacheControl with the second argument set to `CDN-Cache-Control` or any other value (we
450
+ * provide the most common values for auto-complete, but you can use any string you want).
451
+ *
452
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control and
453
+ * https://qwik.dev/docs/caching/#CDN-Cache-Controls for more information.
454
+ */
455
+ readonly cacheControl: (cacheControl: CacheControl, target?: CacheControlTarget) => void;
456
+ /**
457
+ * Provides information about the client connection, such as the IP address and the country the
458
+ * request originated from.
459
+ */
460
+ readonly clientConn: ClientConn;
461
+ /**
462
+ * Request's AbortSignal (same as `request.signal`). This signal indicates that the request has
463
+ * been aborted.
464
+ */
465
+ readonly signal: AbortSignal;
466
+ }
467
+
468
+ /** @public */
469
+ export declare interface RequestEventCommon<PLATFORM = QwikRouterPlatform> extends RequestEventBase<PLATFORM> {
470
+ /**
471
+ * HTTP response status code. Sets the status code when called with an argument. Always returns
472
+ * the status code, so calling `status()` without an argument will can be used to return the
473
+ * current status code.
474
+ *
475
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
476
+ */
477
+ readonly status: (statusCode?: StatusCodes) => number;
478
+ /**
479
+ * Which locale the content is in.
480
+ *
481
+ * The locale value can be retrieved from selected methods using `getLocale()`:
482
+ */
483
+ readonly locale: (local?: string) => string;
484
+ /**
485
+ * URL to redirect to. When called, the response will immediately end with the correct redirect
486
+ * status and headers.
487
+ *
488
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
489
+ */
490
+ readonly redirect: (statusCode: RedirectCode, url: string) => RedirectMessage;
491
+ /**
492
+ * When called, qwik-router will execute the path's matching route flow.
493
+ *
494
+ * The url in the browser will remain unchanged.
495
+ *
496
+ * @param pathname - The pathname to rewrite to.
497
+ */
498
+ readonly rewrite: (pathname: string) => RewriteMessage;
499
+ /**
500
+ * When called, the response will immediately end with the given status code. This could be useful
501
+ * to end a response with `404`, and use the 404 handler in the routes directory. See
502
+ * https://developer.mozilla.org/en-US/docs/Web/HTTP/Status for which status code should be used.
503
+ */
504
+ readonly error: <T = any>(statusCode: ErrorCodes, message: T) => ServerError<T>;
505
+ /**
506
+ * Convenience method to send an text body response. The response will be automatically set the
507
+ * `Content-Type` header to`text/plain; charset=utf-8`. An `text()` response can only be called
508
+ * once.
509
+ */
510
+ readonly text: (statusCode: StatusCodes, text: string) => AbortMessage;
511
+ /**
512
+ * Convenience method to send an HTML body response. The response will be automatically set the
513
+ * `Content-Type` header to`text/html; charset=utf-8`. An `html()` response can only be called
514
+ * once.
515
+ */
516
+ readonly html: (statusCode: StatusCodes, html: string) => AbortMessage;
517
+ /**
518
+ * Convenience method to JSON stringify the data and send it in the response. The response will be
519
+ * automatically set the `Content-Type` header to `application/json; charset=utf-8`. A `json()`
520
+ * response can only be called once.
521
+ */
522
+ readonly json: (statusCode: StatusCodes, data: any) => AbortMessage;
523
+ /**
524
+ * Send a body response. The `Content-Type` response header is not automatically set when using
525
+ * `send()` and must be set manually. A `send()` response can only be called once.
526
+ */
527
+ readonly send: SendMethod;
528
+ readonly exit: () => AbortMessage;
529
+ }
530
+
531
+ declare interface RequestEventInternal extends RequestEvent, RequestEventLoader {
532
+ [RequestEvLoaders]: Record<string, ValueOrPromise<unknown> | undefined>;
533
+ [RequestEvMode]: ServerRequestMode;
534
+ [RequestEvTrailingSlash]: boolean;
535
+ [RequestEvRoute]: LoadedRoute | null;
536
+ [RequestEvQwikSerializer]: QwikSerializer;
537
+ /**
538
+ * Check if this request is already written to.
539
+ *
540
+ * @returns `true`, if `getWritableStream()` has already been called.
541
+ */
542
+ isDirty(): boolean;
543
+ /**
544
+ * Reset the request event to the given route data.
545
+ *
546
+ * @param loadedRoute - The new loaded route.
547
+ * @param requestHandlers - The new request handlers.
548
+ * @param url - The new URL of the route.
549
+ */
550
+ resetRoute(loadedRoute: LoadedRoute | null, requestHandlers: RequestHandler<any>[], url: URL): void;
551
+ }
552
+
553
+ /** @public */
554
+ export declare interface RequestEventLoader<PLATFORM = QwikRouterPlatform> extends RequestEventAction<PLATFORM> {
555
+ resolveValue: ResolveValue;
556
+ defer: <T>(returnData: Promise<T> | (() => Promise<T>)) => DeferReturn<T>;
557
+ }
558
+
559
+ declare const RequestEvLoaders: unique symbol;
560
+
561
+ declare const RequestEvMode: unique symbol;
562
+
563
+ declare const RequestEvQwikSerializer: unique symbol;
564
+
565
+ declare const RequestEvRoute: unique symbol;
566
+
567
+ declare const RequestEvTrailingSlash: unique symbol;
568
+
569
+ /** @public */
570
+ export declare type RequestHandler<PLATFORM = QwikRouterPlatform> = (ev: RequestEvent<PLATFORM>) => Promise<void> | void;
571
+
572
+ /**
573
+ * The request handler for QwikRouter. Called by every integration.
574
+ *
575
+ * @public
576
+ */
577
+ export declare function requestHandler<T = unknown>(serverRequestEv: ServerRequestEvent<T>, opts: ServerRenderOptions, qwikSerializer: QwikSerializer): Promise<QwikRouterRun<T> | null>;
578
+
579
+ /** @public */
580
+ declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter>>;
581
+
582
+ /** @public */
583
+ export declare interface ResolveSyncValue {
584
+ <T>(loader: Loader_2<T>): Awaited<T> extends () => any ? never : Awaited<T>;
585
+ <T>(action: Action<T>): Awaited<T> | undefined;
586
+ }
587
+
588
+ /** @public */
589
+ export declare interface ResolveValue {
590
+ <T>(loader: Loader_2<T>): Awaited<T> extends () => any ? never : Promise<T>;
591
+ <T>(action: Action<T>): Promise<T | undefined>;
592
+ }
593
+
594
+ /** @public */
595
+ export declare class RewriteMessage extends AbortMessage {
596
+ readonly pathname: string;
597
+ constructor(pathname: string);
598
+ }
599
+
600
+ /** @public */
601
+ declare interface RouteLocation {
602
+ readonly params: Readonly<Record<string, string>>;
603
+ readonly url: URL;
604
+ readonly isNavigating: boolean;
605
+ readonly prevUrl: URL | undefined;
606
+ }
607
+
608
+ declare interface RouteModule<BODY = unknown> {
609
+ onDelete?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
610
+ onGet?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
611
+ onHead?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
612
+ onOptions?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
613
+ onPatch?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
614
+ onPost?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
615
+ onPut?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
616
+ onRequest?: RequestHandler_2<BODY> | RequestHandler_2<BODY>[];
617
+ }
618
+
619
+ /** @public */
620
+ declare interface SendMethod {
621
+ (statusCode: StatusCodes, data: any): AbortMessage;
622
+ (response: Response): AbortMessage;
623
+ }
624
+
625
+ /** @public */
626
+ export declare class ServerError<T = any> extends Error {
627
+ status: number;
628
+ data: T;
629
+ constructor(status: number, data: T);
630
+ }
631
+
632
+ /**
633
+ * HTTP Server Error Status Codes Status codes in the 5xx range indicate that the server encountered
634
+ * an error or was unable to fulfill the request due to unexpected conditions.
635
+ */
636
+ declare type ServerErrorCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
637
+
638
+ /** @public */
639
+ export declare interface ServerRenderOptions extends RenderOptions {
640
+ render: Render;
641
+ /** @deprecated Use `QwikRouterConfig` instead. Will be removed in V3 */
642
+ qwikCityPlan?: QwikCityPlan;
643
+ qwikRouterConfig?: QwikRouterConfig;
644
+ /**
645
+ * Protection against cross-site request forgery (CSRF) attacks.
646
+ *
647
+ * When `true`, for every incoming POST, PUT, PATCH, or DELETE form submissions, the request
648
+ * origin is checked to match the server's origin.
649
+ *
650
+ * Be careful when disabling this option as it may lead to CSRF attacks.
651
+ *
652
+ * Defaults to `true`.
653
+ */
654
+ checkOrigin?: boolean;
655
+ }
656
+
657
+ /**
658
+ * @public
659
+ * Request event created by the server.
660
+ */
661
+ export declare interface ServerRequestEvent<T = unknown> {
662
+ mode: ServerRequestMode;
663
+ url: URL;
664
+ locale: string | undefined;
665
+ platform: QwikRouterPlatform;
666
+ request: Request;
667
+ env: EnvGetter;
668
+ getClientConn: () => ClientConn;
669
+ getWritableStream: ServerResponseHandler<T>;
670
+ }
671
+
672
+ /** @public */
673
+ export declare type ServerRequestMode = 'dev' | 'static' | 'server';
674
+
675
+ /** @public */
676
+ export declare type ServerResponseHandler<T = any> = (status: number, headers: Headers, cookies: Cookie, resolve: (response: T) => void, requestEv: RequestEventInternal) => WritableStream<Uint8Array>;
677
+
678
+ /** @public */
679
+ declare interface StaticGenerate {
680
+ params?: PathParams[];
681
+ }
682
+
683
+ /** @public */
684
+ declare type StaticGenerateHandler = ({ env, }: {
685
+ env: EnvGetter_2;
686
+ }) => Promise<StaticGenerate> | StaticGenerate;
687
+
688
+ declare type StatusCodes = InformationalCode | SuccessCode | ClientErrorCode | ServerErrorCode | RedirectCode | number;
689
+
690
+ /**
691
+ * HTTP Success Status Codes Status codes in the 2xx range indicate that the client's request was
692
+ * successfully received, understood, and accepted by the server.
693
+ */
694
+ declare type SuccessCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
695
+
696
+ /**
697
+ * TextEncoderStream polyfill based on Node.js' implementation
698
+ * https://github.com/nodejs/node/blob/3f3226c8e363a5f06c1e6a37abd59b6b8c1923f1/lib/internal/webstreams/encoding.js#L38-L119
699
+ * (MIT License)
700
+ */
701
+ /** @internal */
702
+ export declare class _TextEncoderStream_polyfill {
703
+ #private;
704
+ get encoding(): string;
705
+ get readable(): ReadableStream<Uint8Array<ArrayBufferLike>>;
706
+ get writable(): WritableStream<string>;
707
+ get [Symbol.toStringTag](): string;
708
+ }
709
+
710
+ export { }