@qwik.dev/router 2.0.0-beta.43 → 2.0.0-beta.47
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 +2 -1
- package/lib/adapters/bun-server/vite/index.d.ts +2 -2
- package/lib/adapters/bun-server/vite/index.mjs +2 -1
- package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
- package/lib/adapters/cloud-run/vite/index.mjs +2 -1
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
- package/lib/adapters/cloudflare-pages/vite/index.mjs +2 -1
- package/lib/adapters/deno-server/vite/index.d.ts +2 -2
- package/lib/adapters/deno-server/vite/index.mjs +2 -1
- package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.mjs +2 -1
- package/lib/adapters/node-server/vite/index.d.ts +2 -2
- package/lib/adapters/node-server/vite/index.mjs +2 -1
- package/lib/adapters/shared/vite/index.d.ts +1 -1
- package/lib/adapters/shared/vite/index.mjs +36 -32
- package/lib/adapters/ssg/vite/index.d.ts +1 -1
- package/lib/adapters/ssg/vite/index.mjs +4 -2
- package/lib/adapters/vercel-edge/vite/index.d.ts +2 -2
- package/lib/adapters/vercel-edge/vite/index.mjs +18 -15
- package/lib/chunks/fs.mjs +28 -25
- package/lib/chunks/head.qwik.mjs +731 -448
- package/lib/chunks/http-error.qwik.mjs +8 -7
- package/lib/chunks/pathname.mjs +9 -8
- package/lib/chunks/request-path.mjs +8 -4
- package/lib/chunks/route-trie-key.mjs +10 -0
- package/lib/chunks/routes.mjs +14 -14
- package/lib/chunks/server-error.mjs +28 -6
- package/lib/chunks/{url.mjs → static-file.mjs} +12 -2
- package/lib/chunks/system.mjs +31 -25
- package/lib/chunks/user-response.mjs +455 -348
- package/lib/chunks/worker-thread.mjs +90 -88
- package/lib/index.d.ts +94 -63
- package/lib/index.qwik.mjs +615 -523
- package/lib/middleware/aws-lambda/index.mjs +6 -3
- package/lib/middleware/azure-swa/index.mjs +4 -2
- package/lib/middleware/bun/index.mjs +12 -12
- package/lib/middleware/cloudflare-pages/index.mjs +19 -4
- package/lib/middleware/deno/index.mjs +12 -12
- package/lib/middleware/firebase/index.mjs +4 -2
- package/lib/middleware/netlify-edge/index.mjs +4 -2
- package/lib/middleware/node/index.mjs +16 -15
- package/lib/middleware/request-handler/index.d.ts +102 -2
- package/lib/middleware/request-handler/index.mjs +30 -34
- package/lib/middleware/vercel-edge/index.mjs +4 -2
- package/lib/service-worker/index.mjs +2 -1
- package/lib/ssg/index.mjs +23 -18
- package/lib/vite/index.d.ts +1 -1
- package/lib/vite/index.mjs +669 -604
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as getRouteLoaderValues, O as getRouteLoaders, d as loadRoute } from "./head.qwik.mjs";
|
|
2
2
|
import { l as trimInternalPathname } from "./request-path.mjs";
|
|
3
3
|
import { i as resolveRequestHandlers, r as renderQwikMiddleware, t as runQwikRouter } from "./user-response.mjs";
|
|
4
4
|
import { _serialize } from "@qwik.dev/core/internal";
|
|
@@ -10,28 +10,72 @@ var staticWorkerThreadDeps = {
|
|
|
10
10
|
trimInternalPathname,
|
|
11
11
|
runQwikRouter
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!qwikRouterConfig) throw new Error("qwikRouterConfig is required.");
|
|
20
|
-
const pathname = deps.trimInternalPathname(serverRequestEv.url.pathname);
|
|
21
|
-
if (pathname === "/.well-known" || pathname.startsWith("/.well-known/")) return null;
|
|
22
|
-
const { routes, serverPlugins, cacheModules } = qwikRouterConfig;
|
|
23
|
-
const loadedRoute = await deps.loadRoute(routes, cacheModules, pathname);
|
|
24
|
-
const requestHandlers = deps.resolveRequestHandlers(serverPlugins, loadedRoute, serverRequestEv.request.method, checkOrigin ?? true, deps.renderQwikMiddleware(render));
|
|
25
|
-
if (qwikRouterConfig.fallthrough && loadedRoute.$notFound$ && !pathname.endsWith("/404.html")) return null;
|
|
26
|
-
const rebuildRouteInfo = async (url) => {
|
|
27
|
-
const cleanPathname = deps.trimInternalPathname(url.pathname);
|
|
28
|
-
const loadedRoute = await deps.loadRoute(routes, cacheModules, cleanPathname);
|
|
29
|
-
return {
|
|
30
|
-
loadedRoute,
|
|
31
|
-
requestHandlers: deps.resolveRequestHandlers(serverPlugins, loadedRoute, serverRequestEv.request.method, checkOrigin ?? true, deps.renderQwikMiddleware(render))
|
|
32
|
-
};
|
|
13
|
+
async function workerThread(sys) {
|
|
14
|
+
const opts = sys.getOptions();
|
|
15
|
+
const pendingPromises = /* @__PURE__ */ new Set();
|
|
16
|
+
const deps = {
|
|
17
|
+
...staticWorkerThreadDeps,
|
|
18
|
+
serialize: _serialize
|
|
33
19
|
};
|
|
34
|
-
|
|
20
|
+
process.on("uncaughtException", (e) => {
|
|
21
|
+
console.error("Worker uncaught exception (suppressed):", e.message);
|
|
22
|
+
});
|
|
23
|
+
process.on("unhandledRejection", (e) => {
|
|
24
|
+
console.error("Worker unhandled rejection (suppressed):", e instanceof Error ? e.message : e);
|
|
25
|
+
});
|
|
26
|
+
const onMessage = async (msg) => {
|
|
27
|
+
switch (msg.type) {
|
|
28
|
+
case "render": return new Promise((resolve) => {
|
|
29
|
+
workerRender(sys, opts, msg, pendingPromises, resolve, deps).catch((e) => {
|
|
30
|
+
console.error("Error during render", msg.pathname, e);
|
|
31
|
+
resolve({
|
|
32
|
+
type: "render",
|
|
33
|
+
pathname: msg.pathname,
|
|
34
|
+
url: "",
|
|
35
|
+
ok: false,
|
|
36
|
+
error: {
|
|
37
|
+
message: e instanceof Error ? e.message : String(e),
|
|
38
|
+
stack: e instanceof Error ? e.stack : void 0
|
|
39
|
+
},
|
|
40
|
+
filePath: null,
|
|
41
|
+
contentType: null,
|
|
42
|
+
resourceType: null
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
case "close":
|
|
47
|
+
if (pendingPromises.size) {
|
|
48
|
+
const promises = Array.from(pendingPromises);
|
|
49
|
+
pendingPromises.clear();
|
|
50
|
+
await Promise.all(promises);
|
|
51
|
+
}
|
|
52
|
+
return { type: "close" };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
parentPort?.on("message", async (msg) => {
|
|
56
|
+
try {
|
|
57
|
+
parentPort?.postMessage(await onMessage(msg));
|
|
58
|
+
} catch (e) {
|
|
59
|
+
if (msg.type === "render") {
|
|
60
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
61
|
+
parentPort?.postMessage({
|
|
62
|
+
type: "render",
|
|
63
|
+
pathname: msg.pathname,
|
|
64
|
+
url: "",
|
|
65
|
+
ok: false,
|
|
66
|
+
error: {
|
|
67
|
+
message: error.message,
|
|
68
|
+
stack: error.stack
|
|
69
|
+
},
|
|
70
|
+
filePath: null,
|
|
71
|
+
contentType: null,
|
|
72
|
+
resourceType: null
|
|
73
|
+
});
|
|
74
|
+
} else console.error("Worker message handler error", e);
|
|
75
|
+
}
|
|
76
|
+
if (msg.type === "close") parentPort?.close();
|
|
77
|
+
});
|
|
78
|
+
parentPort?.postMessage({ type: "ready" });
|
|
35
79
|
}
|
|
36
80
|
async function workerRender(sys, opts, staticRoute, pendingPromises, callback, deps) {
|
|
37
81
|
const url = new URL(staticRoute.pathname, opts.origin);
|
|
@@ -156,10 +200,10 @@ async function workerRender(sys, opts, staticRoute, pendingPromises, callback, d
|
|
|
156
200
|
}, opts, deps).then((rsp) => {
|
|
157
201
|
if (rsp != null) return rsp.completion.then((r) => {
|
|
158
202
|
const failRouteOnCaughtBoundary = (completion) => {
|
|
159
|
-
if (completion === void 0 && rsp.requestEv.sharedMap.get("@
|
|
203
|
+
if (completion === void 0 && rsp.requestEv.sharedMap.get("@caughtError")) {
|
|
160
204
|
result.ok = false;
|
|
161
205
|
result.filePath = null;
|
|
162
|
-
return /* @__PURE__ */ new Error(`
|
|
206
|
+
return /* @__PURE__ */ new Error(`A <Catch> caught an error while rendering ${staticRoute.pathname}`);
|
|
163
207
|
}
|
|
164
208
|
return completion;
|
|
165
209
|
};
|
|
@@ -203,70 +247,28 @@ async function workerRender(sys, opts, staticRoute, pendingPromises, callback, d
|
|
|
203
247
|
callback(result);
|
|
204
248
|
}
|
|
205
249
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
url: "",
|
|
228
|
-
ok: false,
|
|
229
|
-
error: {
|
|
230
|
-
message: e instanceof Error ? e.message : String(e),
|
|
231
|
-
stack: e instanceof Error ? e.stack : void 0
|
|
232
|
-
},
|
|
233
|
-
filePath: null,
|
|
234
|
-
contentType: null,
|
|
235
|
-
resourceType: null
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
case "close":
|
|
240
|
-
if (pendingPromises.size) {
|
|
241
|
-
const promises = Array.from(pendingPromises);
|
|
242
|
-
pendingPromises.clear();
|
|
243
|
-
await Promise.all(promises);
|
|
244
|
-
}
|
|
245
|
-
return { type: "close" };
|
|
246
|
-
}
|
|
250
|
+
/** Create a fresh no-op WritableStream (must be a real instance for pipeTo checks). */
|
|
251
|
+
var createNoopWritableStream = () => new WritableStream();
|
|
252
|
+
function isRedirectMessage(value) {
|
|
253
|
+
return typeof value === "object" && value !== null && value.constructor?.name === "RedirectMessage";
|
|
254
|
+
}
|
|
255
|
+
async function requestHandlerForSsg(serverRequestEv, opts, deps) {
|
|
256
|
+
const { render, checkOrigin, qwikRouterConfig } = opts;
|
|
257
|
+
if (!qwikRouterConfig) throw new Error("qwikRouterConfig is required.");
|
|
258
|
+
const pathname = deps.trimInternalPathname(serverRequestEv.url.pathname);
|
|
259
|
+
if (pathname === "/.well-known" || pathname.startsWith("/.well-known/")) return null;
|
|
260
|
+
const { routes, serverPlugins, cacheModules } = qwikRouterConfig;
|
|
261
|
+
const loadedRoute = await deps.loadRoute(routes, cacheModules, pathname);
|
|
262
|
+
const requestHandlers = deps.resolveRequestHandlers(serverPlugins, loadedRoute, serverRequestEv.request.method, checkOrigin ?? true, deps.renderQwikMiddleware(render));
|
|
263
|
+
if (qwikRouterConfig.fallthrough && loadedRoute.$notFound$ && !pathname.endsWith("/404.html")) return null;
|
|
264
|
+
const rebuildRouteInfo = async (url) => {
|
|
265
|
+
const cleanPathname = deps.trimInternalPathname(url.pathname);
|
|
266
|
+
const loadedRoute = await deps.loadRoute(routes, cacheModules, cleanPathname);
|
|
267
|
+
return {
|
|
268
|
+
loadedRoute,
|
|
269
|
+
requestHandlers: deps.resolveRequestHandlers(serverPlugins, loadedRoute, serverRequestEv.request.method, checkOrigin ?? true, deps.renderQwikMiddleware(render))
|
|
270
|
+
};
|
|
247
271
|
};
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
parentPort?.postMessage(await onMessage(msg));
|
|
251
|
-
} catch (e) {
|
|
252
|
-
if (msg.type === "render") {
|
|
253
|
-
const error = e instanceof Error ? e : new Error(String(e));
|
|
254
|
-
parentPort?.postMessage({
|
|
255
|
-
type: "render",
|
|
256
|
-
pathname: msg.pathname,
|
|
257
|
-
url: "",
|
|
258
|
-
ok: false,
|
|
259
|
-
error: {
|
|
260
|
-
message: error.message,
|
|
261
|
-
stack: error.stack
|
|
262
|
-
},
|
|
263
|
-
filePath: null,
|
|
264
|
-
contentType: null,
|
|
265
|
-
resourceType: null
|
|
266
|
-
});
|
|
267
|
-
} else console.error("Worker message handler error", e);
|
|
268
|
-
}
|
|
269
|
-
if (msg.type === "close") parentPort?.close();
|
|
270
|
-
});
|
|
272
|
+
return deps.runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo, qwikRouterConfig.basePathname, qwikRouterConfig);
|
|
271
273
|
}
|
|
272
274
|
export { workerThread };
|
package/lib/index.d.ts
CHANGED
|
@@ -28,11 +28,11 @@ import type { ResolveSyncValue } from '@qwik.dev/router/middleware/request-handl
|
|
|
28
28
|
import type { SerializationStrategy } from '@qwik.dev/core/internal';
|
|
29
29
|
import type { ServerError } from '@qwik.dev/router/middleware/request-handler';
|
|
30
30
|
import type { Signal } from '@qwik.dev/core';
|
|
31
|
-
import
|
|
32
|
-
import
|
|
31
|
+
import * as v from 'valibot';
|
|
32
|
+
import { ValueOrPromise } from '@qwik.dev/core';
|
|
33
33
|
import { ValueOrPromise as ValueOrPromise_2 } from '@qwik.dev/core/internal';
|
|
34
34
|
import { z } from 'zod';
|
|
35
|
-
import
|
|
35
|
+
import * as z_2 from 'zod';
|
|
36
36
|
|
|
37
37
|
/** @public */
|
|
38
38
|
export declare type Action<RETURN, INPUT = Record<string, unknown>, OPTIONAL extends boolean = true> = {
|
|
@@ -61,23 +61,6 @@ export declare type ActionConstructor = {
|
|
|
61
61
|
<OBJ>(actionQrl: (form: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>, options?: ActionOptions): Action<StrictUnion<OBJ>>;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
/** @public */
|
|
65
|
-
declare type ActionConstructorQRL = {
|
|
66
|
-
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: QRL<(data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: ActionOptions & {
|
|
67
|
-
readonly validation: [VALIDATOR, ...REST];
|
|
68
|
-
}): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>> | FailReturn<FailOfRest<REST>>>, GetValidatorInputType<VALIDATOR>, false>;
|
|
69
|
-
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator>(actionQrl: QRL<(data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: ActionOptions & {
|
|
70
|
-
readonly validation: [VALIDATOR];
|
|
71
|
-
}): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>>>, GetValidatorInputType<VALIDATOR>, false>;
|
|
72
|
-
<OBJ extends Record<string, any> | void | null, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: QRL<(data: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: ActionOptions & {
|
|
73
|
-
readonly validation: REST;
|
|
74
|
-
}): Action<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
|
|
75
|
-
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: QRL<(data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: VALIDATOR, ...rest: REST): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>> | FailReturn<FailOfRest<REST>>>, GetValidatorInputType<VALIDATOR>, false>;
|
|
76
|
-
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator>(actionQrl: QRL<(data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: VALIDATOR): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>>>, GetValidatorInputType<VALIDATOR>, false>;
|
|
77
|
-
<OBJ extends Record<string, any> | void | null, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: QRL<(form: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>>, ...rest: REST): Action<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
|
|
78
|
-
<OBJ>(actionQrl: QRL<(form: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>>, options?: ActionOptions): Action<StrictUnion<OBJ>>;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
64
|
/** @public */
|
|
82
65
|
export declare type ActionOptions = {
|
|
83
66
|
readonly id?: string;
|
|
@@ -380,6 +363,11 @@ export declare type DocumentStyle = Readonly<((Omit<QwikIntrinsicElements['style
|
|
|
380
363
|
style?: never;
|
|
381
364
|
})>;
|
|
382
365
|
|
|
366
|
+
/** @public */
|
|
367
|
+
export declare type Editable<T> = {
|
|
368
|
+
-readonly [P in keyof T]: T[P];
|
|
369
|
+
};
|
|
370
|
+
|
|
383
371
|
declare type EndpointModuleLoader = () => ValueOrPromise<RouteModule>;
|
|
384
372
|
|
|
385
373
|
declare interface EndpointResponse {
|
|
@@ -439,6 +427,13 @@ export declare interface FormSubmitSuccessDetail<T> {
|
|
|
439
427
|
value: T;
|
|
440
428
|
}
|
|
441
429
|
|
|
430
|
+
/**
|
|
431
|
+
* The base pathname the app is served under, such as `/` or `/docs/`.
|
|
432
|
+
*
|
|
433
|
+
* @public
|
|
434
|
+
*/
|
|
435
|
+
export declare const getBasePathname: () => string;
|
|
436
|
+
|
|
442
437
|
/**
|
|
443
438
|
* Returns the current RequestEvent if possible. Only usable on the server, and only during request
|
|
444
439
|
* processing.
|
|
@@ -447,6 +442,32 @@ export declare interface FormSubmitSuccessDetail<T> {
|
|
|
447
442
|
*/
|
|
448
443
|
export declare const getRequestEvent: (thisArg?: unknown) => RequestEvent | undefined;
|
|
449
444
|
|
|
445
|
+
/**
|
|
446
|
+
* The app's route config: the route trie, server plugins and build options that the Qwik Router
|
|
447
|
+
* Vite plugin generated. Resolves once the config is loaded and its `server$` modules are
|
|
448
|
+
* registered. On the server, the router copy of a Qwik library kept external reads the config of
|
|
449
|
+
* the app serving the current request.
|
|
450
|
+
*
|
|
451
|
+
* @public
|
|
452
|
+
*/
|
|
453
|
+
export declare const getRouterConfig: () => Promise<QwikRouterConfig>;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* The route trie of the app, as generated by the Qwik Router Vite plugin.
|
|
457
|
+
*
|
|
458
|
+
* @public
|
|
459
|
+
*/
|
|
460
|
+
export declare const getRoutes: () => Promise<RouteData>;
|
|
461
|
+
|
|
462
|
+
/* Excluded from this release type: _getServiceWorkerScript */
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Whether the app's URLs end with a trailing slash.
|
|
466
|
+
*
|
|
467
|
+
* @public
|
|
468
|
+
*/
|
|
469
|
+
export declare const getTrailingSlash: () => boolean;
|
|
470
|
+
|
|
450
471
|
/** @public */
|
|
451
472
|
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;
|
|
452
473
|
|
|
@@ -553,6 +574,8 @@ declare interface LoadedRoute {
|
|
|
553
574
|
$loaders$?: string[];
|
|
554
575
|
/** Runtime-only mapping of routeLoader$ hashes to the matched pathname used for q-loader fetches */
|
|
555
576
|
$loaderPaths$?: Record<string, string>;
|
|
577
|
+
/** Runtime-only mapping of routeLoader$ hashes to params matched at their loader path */
|
|
578
|
+
$loaderParams$?: Record<string, PathParams>;
|
|
556
579
|
}
|
|
557
580
|
|
|
558
581
|
/** @public */
|
|
@@ -571,11 +594,19 @@ declare type LoaderConstructor = {
|
|
|
571
594
|
<OBJ extends Record<string, any> | void | null, REST extends readonly DataValidator[]>(loaderFn: (event: RequestEventLoader) => ValueOrPromise<OBJ>, ...rest: REST): Loader_2<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
|
|
572
595
|
};
|
|
573
596
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
597
|
+
declare interface LoaderInternal extends Loader_2<any> {
|
|
598
|
+
readonly __brand?: 'server_loader';
|
|
599
|
+
__qrl: QRL<(event: RequestEventLoader) => ValueOrPromise<unknown>>;
|
|
600
|
+
__id: string;
|
|
601
|
+
__validators: DataValidator[] | undefined;
|
|
602
|
+
__serializationStrategy: SerializationStrategy;
|
|
603
|
+
__cacheControl: CacheControl | ((ev: RequestEvent) => CacheControl | null) | undefined;
|
|
604
|
+
__eTag: string | ((ev: RequestEvent) => string | null) | undefined;
|
|
605
|
+
__cacheKey: CacheKeyFn | undefined;
|
|
606
|
+
__search: string[] | undefined;
|
|
607
|
+
__blockSSR: boolean;
|
|
608
|
+
(): LoaderSignal<unknown>;
|
|
609
|
+
}
|
|
579
610
|
|
|
580
611
|
/** @public */
|
|
581
612
|
declare type LoaderOptions = {
|
|
@@ -595,7 +626,9 @@ declare type LoaderOptions = {
|
|
|
595
626
|
* object) or a function of the request event; the function may return `null` to skip the header.
|
|
596
627
|
* A `Cache-Control` header set inside the loader function wins over this option.
|
|
597
628
|
*
|
|
598
|
-
* Defaults to `no-cache` (
|
|
629
|
+
* Defaults to `private, no-cache` (browser revalidation without shared caching; combine with
|
|
630
|
+
* `eTag` for cheap 304s). Explicit `'no-cache'` and numeric values allow shared caching; numeric
|
|
631
|
+
* values include `s-maxage`.
|
|
599
632
|
*
|
|
600
633
|
* The literal value `'immutable'` also marks the loader's data as static, so SSG writes a
|
|
601
634
|
* per-loader JSON file at build time.
|
|
@@ -626,7 +659,8 @@ declare type LoaderOptions = {
|
|
|
626
659
|
* - `true` — use the default key `${pathname}|${filteredSearch}|${loaderId}` (suffixed with
|
|
627
660
|
* `|${eTag}` when an eTag is set).
|
|
628
661
|
* - Function `(requestEv, eTag) => string | null` — return a custom key, or `null` to skip caching
|
|
629
|
-
* this request.
|
|
662
|
+
* this request. For user-specific data, include user identity and relevant permissions in the
|
|
663
|
+
* key or disable this cache.
|
|
630
664
|
*
|
|
631
665
|
* On cache miss the loader runs, the serialized response is stored alongside its eTag (computed
|
|
632
666
|
* from the data when no `eTag` option is set), and the response is sent. On cache hit the stored
|
|
@@ -663,7 +697,7 @@ declare type LoaderOptions = {
|
|
|
663
697
|
};
|
|
664
698
|
|
|
665
699
|
/** @public */
|
|
666
|
-
export declare type LoaderSignal<TYPE> = (TYPE extends () => ValueOrPromise<infer VALIDATOR> ? Signal<ValueOrPromise<VALIDATOR>> : Signal<TYPE>) & Pick<ComputedSignal<any>, 'promise'
|
|
700
|
+
export declare type LoaderSignal<TYPE> = (TYPE extends () => ValueOrPromise<infer VALIDATOR> ? Signal<ValueOrPromise<VALIDATOR>> : Signal<TYPE>) & Pick<ComputedSignal<any>, 'promise'>;
|
|
667
701
|
|
|
668
702
|
declare interface MenuModule {
|
|
669
703
|
readonly default: ContentMenu;
|
|
@@ -784,6 +818,14 @@ export declare interface QwikRouterConfig {
|
|
|
784
818
|
readonly cacheModules?: boolean;
|
|
785
819
|
/** When true, return null instead of rendering the 404 page, letting the adapter handle it */
|
|
786
820
|
readonly fallthrough?: boolean;
|
|
821
|
+
/**
|
|
822
|
+
* Imports the modules containing `server$` functions so their registration side effects run.
|
|
823
|
+
* Called by the request handler before serving; deliberately async so the config module itself
|
|
824
|
+
* evaluates without touching the runtime (see the import-cycle notes in `route-loaders.ts`).
|
|
825
|
+
*/
|
|
826
|
+
readonly importEagerModules?: () => Promise<unknown>;
|
|
827
|
+
/** URL of the app's service worker, when the routes define one. */
|
|
828
|
+
readonly serviceWorkerUrl?: string;
|
|
787
829
|
}
|
|
788
830
|
|
|
789
831
|
/** @public */
|
|
@@ -927,8 +969,21 @@ export declare type ResolvedDocumentHead<FrontMatter extends Record<string, any>
|
|
|
927
969
|
*/
|
|
928
970
|
export declare const routeAction$: ActionConstructor;
|
|
929
971
|
|
|
930
|
-
/**
|
|
931
|
-
|
|
972
|
+
/**
|
|
973
|
+
* Hoisted function declarations (not consts) on purpose, like `routeLoaderQrl`: the app's route
|
|
974
|
+
* modules call these factories during their own evaluation, which a bundle may run before this
|
|
975
|
+
* module, where a `const` binding would throw a TDZ ReferenceError.
|
|
976
|
+
*
|
|
977
|
+
* @public
|
|
978
|
+
*/
|
|
979
|
+
export declare function routeActionQrl(actionQrl: QRL<(form: JSONObject, event: RequestEventAction) => unknown>, ...rest: (ActionOptions | DataValidator)[]): {
|
|
980
|
+
(): Editable<ActionStore<unknown, unknown>>;
|
|
981
|
+
__brand: "server_action";
|
|
982
|
+
__validators: DataValidator[];
|
|
983
|
+
__qrl: QRL<(form: JSONObject, event: RequestEventAction) => unknown>;
|
|
984
|
+
__id: string;
|
|
985
|
+
__invalidate: string[] | undefined;
|
|
986
|
+
};
|
|
932
987
|
|
|
933
988
|
declare type RouteActionResolver = {
|
|
934
989
|
status: number;
|
|
@@ -960,7 +1015,8 @@ export declare interface RouteConfigValue {
|
|
|
960
1015
|
/**
|
|
961
1016
|
* A nested route trie structure. The root represents `/` and each level represents a URL segment.
|
|
962
1017
|
*
|
|
963
|
-
* Keys starting with `_` are metadata; all other keys are child route segments.
|
|
1018
|
+
* Keys starting with a single `_` are metadata; all other keys are child route segments. A static
|
|
1019
|
+
* segment that starts with `_` is stored with an extra `_` (`_drafts` → `__drafts`).
|
|
964
1020
|
*
|
|
965
1021
|
* - Use `_W` as the key for a single dynamic segment (param); `_P` on that node names the param.
|
|
966
1022
|
* - Use `_A` as the key for a rest/catch-all segment; `_P` on that node names the param.
|
|
@@ -1002,9 +1058,11 @@ export declare interface RouteData {
|
|
|
1002
1058
|
_M?: RouteData[];
|
|
1003
1059
|
/** Menu loader for this subtree (from menu.md). Runtime uses nearest ancestor during traversal. */
|
|
1004
1060
|
_N?: MenuModuleLoader;
|
|
1005
|
-
/**
|
|
1061
|
+
/** Inherited layout and server plugin routeLoader$ hashes. */
|
|
1006
1062
|
_R?: string[];
|
|
1007
|
-
/**
|
|
1063
|
+
/** Page loader hashes; override pages include their selected layouts and plugins. */
|
|
1064
|
+
_D?: string[];
|
|
1065
|
+
/** Child route segments (any key not starting with a single `_`) */
|
|
1008
1066
|
[part: string]: RouteData | RouteData[] | ModuleLoader[] | ContentModuleLoader | MenuModuleLoader | string[] | string | undefined;
|
|
1009
1067
|
}
|
|
1010
1068
|
|
|
@@ -1037,24 +1095,13 @@ export declare interface RouteData {
|
|
|
1037
1095
|
*/
|
|
1038
1096
|
export declare const routeLoader$: LoaderConstructor;
|
|
1039
1097
|
|
|
1040
|
-
/**
|
|
1041
|
-
* Reactive context for route loaders. On the server this is stored in sharedMap, on the client it's
|
|
1042
|
-
* a store that gets updated on navigation.
|
|
1043
|
-
*
|
|
1044
|
-
* - `loaderPaths`: loader ID → fetch path (the longest route path for that loader)
|
|
1045
|
-
* - `pagePathname` / `pageSearch`: client-only navigation state used for loader invalidation and
|
|
1046
|
-
* q-loader fetches. They are intentionally omitted from SSR state and fall back to `location`
|
|
1047
|
-
* until the first SPA navigation.
|
|
1048
|
-
*/
|
|
1098
|
+
/** Shared SSR paths and client-only loader navigation state. */
|
|
1049
1099
|
declare type RouteLoaderCtx = {
|
|
1050
1100
|
loaderPaths: Record<string, string | undefined>;
|
|
1051
|
-
pagePathname?: string;
|
|
1052
|
-
pageSearch?: string;
|
|
1053
1101
|
/** SPA navigation function. Client-only and intentionally omitted from SSR state. */
|
|
1054
1102
|
goto?: NoSerialize<RouteNavigate>;
|
|
1055
1103
|
/** Client manifest hash for q-loader fetch URLs. */
|
|
1056
1104
|
manifestHash?: string;
|
|
1057
|
-
routeLoaderCandidates?: Record<string, string>;
|
|
1058
1105
|
};
|
|
1059
1106
|
|
|
1060
1107
|
/* Excluded from this release type: routeLoaderQrl */
|
|
@@ -1146,6 +1193,8 @@ export declare const ServiceWorkerRegister: (props: {
|
|
|
1146
1193
|
nonce?: string;
|
|
1147
1194
|
}) => JSXOutput;
|
|
1148
1195
|
|
|
1196
|
+
/* Excluded from this release type: _setRouterConfig */
|
|
1197
|
+
|
|
1149
1198
|
/** @public */
|
|
1150
1199
|
export declare interface StaticGenerate {
|
|
1151
1200
|
params?: PathParams[];
|
|
@@ -1246,12 +1295,6 @@ declare type ValibotConstructor = {
|
|
|
1246
1295
|
<T extends v.GenericSchema | v.GenericSchemaAsync>(schema: (ev: RequestEvent) => T): ValibotDataValidator<T>;
|
|
1247
1296
|
};
|
|
1248
1297
|
|
|
1249
|
-
/** @beta */
|
|
1250
|
-
declare type ValibotConstructorQRL = {
|
|
1251
|
-
<T extends v.GenericSchema | v.GenericSchemaAsync>(schema: QRL<T>): ValibotDataValidator<T>;
|
|
1252
|
-
<T extends v.GenericSchema | v.GenericSchemaAsync>(schema: QRL<(ev: RequestEvent) => T>): ValibotDataValidator<T>;
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
1298
|
/** @beta */
|
|
1256
1299
|
declare type ValibotDataValidator<T extends v.GenericSchema | v.GenericSchemaAsync = v.GenericSchema | v.GenericSchemaAsync> = {
|
|
1257
1300
|
readonly __brand: 'valibot';
|
|
@@ -1267,10 +1310,6 @@ declare type ValidatorConstructor = {
|
|
|
1267
1310
|
<T extends ValidatorReturn>(validator: (ev: RequestEvent, data: unknown) => ValueOrPromise<T>): T extends ValidatorReturnFail<infer ERROR> ? DataValidator<ERROR> : DataValidator<never>;
|
|
1268
1311
|
};
|
|
1269
1312
|
|
|
1270
|
-
declare type ValidatorConstructorQRL = {
|
|
1271
|
-
<T extends ValidatorReturn>(validator: QRL<(ev: RequestEvent, data: unknown) => ValueOrPromise<T>>): T extends ValidatorReturnFail<infer ERROR> ? DataValidator<ERROR> : DataValidator<never>;
|
|
1272
|
-
};
|
|
1273
|
-
|
|
1274
1313
|
/** @public */
|
|
1275
1314
|
export declare type ValidatorErrorKeyDotNotation<T, Prefix extends string = ''> = IsAny<T> extends true ? never : T extends object ? {
|
|
1276
1315
|
[K in keyof T & string]: IsAny<T[K]> extends true ? never : T[K] extends (infer U)[] ? IsAny<U> extends true ? never : U extends object ? `${Prefix}${K}[]` | ValidatorErrorKeyDotNotation<U, `${Prefix}${K}[].`> : `${Prefix}${K}[]` : T[K] extends object ? ValidatorErrorKeyDotNotation<T[K], `${Prefix}${K}.`> : `${Prefix}${K}`;
|
|
@@ -1313,14 +1352,6 @@ export declare type ZodConstructor = {
|
|
|
1313
1352
|
<T extends z_2.ZodType>(schema: (zod: typeof z_2.z, ev: RequestEvent) => T): ZodDataValidator<T>;
|
|
1314
1353
|
};
|
|
1315
1354
|
|
|
1316
|
-
/** @public */
|
|
1317
|
-
declare type ZodConstructorQRL = {
|
|
1318
|
-
<T extends z_2.ZodRawShape>(schema: QRL<T>): ZodDataValidator<z_2.ZodObject<T>>;
|
|
1319
|
-
<T extends z_2.ZodRawShape>(schema: QRL<(zod: typeof z_2.z, ev: RequestEvent) => T>): ZodDataValidator<z_2.ZodObject<T>>;
|
|
1320
|
-
<T extends z_2.ZodType>(schema: QRL<T>): ZodDataValidator<T>;
|
|
1321
|
-
<T extends z_2.ZodType>(schema: QRL<(zod: typeof z_2.z, ev: RequestEvent) => T>): ZodDataValidator<T>;
|
|
1322
|
-
};
|
|
1323
|
-
|
|
1324
1355
|
/** @public */
|
|
1325
1356
|
declare type ZodDataValidator<T extends z_2.ZodType = z_2.ZodType> = {
|
|
1326
1357
|
readonly __brand: 'zod';
|