@qwik.dev/router 2.0.0-beta.37 → 2.0.0-beta.39
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/cloudflare-pages/vite/index.mjs +2 -2
- package/lib/adapters/shared/vite/index.d.ts +3 -4
- package/lib/adapters/shared/vite/index.mjs +158 -143
- package/lib/chunks/dev-preloaded-route-loader.mjs +3 -0
- package/lib/chunks/fs.mjs +6 -2
- package/lib/chunks/head.qwik.mjs +814 -93
- package/lib/chunks/request-body-limit.mjs +37 -0
- package/lib/chunks/request-path.mjs +2 -2
- package/lib/chunks/routes.mjs +47 -0
- package/lib/chunks/server-error.mjs +19 -0
- package/lib/chunks/system.mjs +2 -1
- package/lib/chunks/use-functions.qwik.mjs +1 -1
- package/lib/chunks/{worker-thread.qwik.mjs → user-response.mjs} +1053 -1749
- package/lib/chunks/worker-thread.mjs +317 -0
- package/lib/index.d.ts +89 -55
- package/lib/index.qwik.mjs +178 -100
- package/lib/middleware/azure-swa/index.mjs +13 -9
- package/lib/middleware/cloudflare-pages/index.mjs +2 -2
- package/lib/middleware/deno/index.d.ts +2 -0
- package/lib/middleware/deno/index.mjs +2 -1
- package/lib/middleware/netlify-edge/index.mjs +2 -2
- package/lib/middleware/node/index.d.ts +9 -1
- package/lib/middleware/node/index.mjs +28 -3
- package/lib/middleware/request-handler/index.d.ts +9 -10
- package/lib/middleware/request-handler/index.mjs +26 -1105
- package/lib/middleware/vercel-edge/index.mjs +2 -2
- package/lib/ssg/index.d.ts +2 -10
- package/lib/ssg/index.mjs +10 -50
- package/lib/vite/index.d.ts +8 -0
- package/lib/vite/index.mjs +406 -117
- package/package.json +5 -4
- package/lib/chunks/action-handler.mjs +0 -782
- package/lib/chunks/deepFreeze.qwik.mjs +0 -608
- package/lib/chunks/error-handler.mjs +0 -57
- package/lib/chunks/not-found-wrapper.qwik.mjs +0 -25
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
|
-
import { isStaticPath, mergeHeadersCookies, requestHandler,
|
|
2
|
+
import { isStaticPath, mergeHeadersCookies, requestHandler, getErrorHtml } from '@qwik.dev/router/middleware/request-handler';
|
|
3
3
|
import { isDev } from '@qwik.dev/core/build';
|
|
4
4
|
|
|
5
5
|
const COUNTRY_HEADER_NAME = "x-vercel-ip-country";
|
|
@@ -74,7 +74,7 @@ function createQwikRouter(opts) {
|
|
|
74
74
|
return response;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
const notFoundHtml = !request.headers.get("accept")?.includes("text/html") || isStaticPath(request.method || "GET", url) ? "Not Found" :
|
|
77
|
+
const notFoundHtml = !request.headers.get("accept")?.includes("text/html") || isStaticPath(request.method || "GET", url) ? "Not Found" : getErrorHtml(404, "Not Found");
|
|
78
78
|
return new Response(notFoundHtml, {
|
|
79
79
|
status: 404,
|
|
80
80
|
headers: {
|
package/lib/ssg/index.d.ts
CHANGED
|
@@ -26,14 +26,11 @@ export declare function runSsg(opts: SsgInternalOptions): Promise<never>;
|
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
28
|
export declare interface SsgInternalOptions extends SsgOptions {
|
|
29
|
-
/**
|
|
29
|
+
/** SSR render function (default export from `entry.ssr`); worker-only — the main entry omits it. */
|
|
30
30
|
render: Render;
|
|
31
31
|
/** The Qwik Router Config object (default export from `@qwik-router-config`). */
|
|
32
32
|
qwikRouterConfig: QwikRouterConfig;
|
|
33
|
-
/**
|
|
34
|
-
* Path or URL to the worker entry file. Workers are spawned using this file. When run-ssg.js
|
|
35
|
-
* serves as both main and worker entry, this should be `import.meta.url` of that file.
|
|
36
|
-
*/
|
|
33
|
+
/** Path or URL to the worker entry file (`run-ssg-worker.js`); workers are spawned from it. */
|
|
37
34
|
workerFilePath?: string | URL;
|
|
38
35
|
}
|
|
39
36
|
|
|
@@ -88,11 +85,6 @@ export declare interface SsgRenderOptions extends RenderOptions {
|
|
|
88
85
|
* to `true`.
|
|
89
86
|
*/
|
|
90
87
|
emitData?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Set to `false` if the static build should not write custom or default `404.html` pages.
|
|
93
|
-
* Defaults to `true`.
|
|
94
|
-
*/
|
|
95
|
-
emit404Pages?: boolean;
|
|
96
88
|
/**
|
|
97
89
|
* Defines file system routes relative to the source `routes` directory that should be static
|
|
98
90
|
* generated. Accepts wildcard behavior. This should not include the "base" pathname. If not
|
package/lib/ssg/index.mjs
CHANGED
|
@@ -2,57 +2,9 @@ import { bold, green, dim, red, magenta } from 'kleur/colors';
|
|
|
2
2
|
import { relative } from 'node:path';
|
|
3
3
|
import { m as msToString } from '../chunks/format.mjs';
|
|
4
4
|
import { e as ensureSlash, g as getPathnameForDynamicRoute } from '../chunks/pathname.mjs';
|
|
5
|
-
|
|
6
|
-
function routeToRegExp(rule) {
|
|
7
|
-
let transformedRule;
|
|
8
|
-
if (rule === "/" || rule === "/*") {
|
|
9
|
-
transformedRule = rule;
|
|
10
|
-
} else if (rule.endsWith("/*")) {
|
|
11
|
-
transformedRule = `${rule.substring(0, rule.length - 2)}(/*)?`;
|
|
12
|
-
} else if (rule.endsWith("/")) {
|
|
13
|
-
transformedRule = `${rule.substring(0, rule.length - 1)}(/)?`;
|
|
14
|
-
} else if (rule.endsWith("*")) {
|
|
15
|
-
transformedRule = rule;
|
|
16
|
-
} else {
|
|
17
|
-
transformedRule = `${rule}(/)?`;
|
|
18
|
-
}
|
|
19
|
-
transformedRule = `^${transformedRule.replace(/\*/g, ".*")}$`;
|
|
20
|
-
return new RegExp(transformedRule);
|
|
21
|
-
}
|
|
22
|
-
function routesToRegExps(routes) {
|
|
23
|
-
if (!Array.isArray(routes)) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
return routes.filter((r) => typeof r === "string").map(routeToRegExp);
|
|
27
|
-
}
|
|
28
|
-
function createRouteTester(basePathname, includeRoutes, excludeRoutes) {
|
|
29
|
-
const includes = routesToRegExps(includeRoutes);
|
|
30
|
-
const excludes = routesToRegExps(excludeRoutes);
|
|
31
|
-
return (pathname) => {
|
|
32
|
-
if (pathname.endsWith("404.html")) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
if (basePathname !== "/") {
|
|
36
|
-
pathname = pathname.slice(basePathname.length - 1);
|
|
37
|
-
}
|
|
38
|
-
for (const exclude of excludes) {
|
|
39
|
-
if (exclude.test(pathname)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
for (const include of includes) {
|
|
44
|
-
if (include.test(pathname)) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
5
|
+
import { c as createRouteTester } from '../chunks/routes.mjs';
|
|
51
6
|
|
|
52
7
|
function validateOptions(opts) {
|
|
53
|
-
if (!opts.render) {
|
|
54
|
-
throw new Error(`Missing "render" option`);
|
|
55
|
-
}
|
|
56
8
|
if (!opts.qwikRouterConfig) {
|
|
57
9
|
throw new Error(`Missing "qwikRouterConfig" option`);
|
|
58
10
|
}
|
|
@@ -247,6 +199,14 @@ ${bold(red(`!!! ${result.pathname}: Error during SSG`))}`);
|
|
|
247
199
|
}
|
|
248
200
|
}
|
|
249
201
|
}
|
|
202
|
+
if (node._4 || node._E) {
|
|
203
|
+
const isStaticDir = !pathParts.some((p) => p.startsWith("["));
|
|
204
|
+
if (isStaticDir) {
|
|
205
|
+
const joinedParts = pathParts.join("/");
|
|
206
|
+
const dirPathname = basePathname + (joinedParts ? ensureSlash(joinedParts) : "");
|
|
207
|
+
addToQueue(dirPathname + "404.html", void 0);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
250
210
|
if (node._M) {
|
|
251
211
|
for (const group of node._M) {
|
|
252
212
|
await traverseRouteTree(group, pathParts, basePathname, currentLoaders);
|
|
@@ -329,7 +289,7 @@ async function startWorker(opts) {
|
|
|
329
289
|
qwikRouterConfig: opts.qwikRouterConfig
|
|
330
290
|
};
|
|
331
291
|
const { createSystem } = await import('../chunks/system.mjs');
|
|
332
|
-
const { workerThread } = await import('../chunks/worker-thread.
|
|
292
|
+
const { workerThread } = await import('../chunks/worker-thread.mjs');
|
|
333
293
|
const sys = await createSystem(mergedOpts, workerData?.threadId);
|
|
334
294
|
await workerThread(sys);
|
|
335
295
|
}
|
package/lib/vite/index.d.ts
CHANGED
|
@@ -159,6 +159,13 @@ declare interface QwikRouterPluginApi {
|
|
|
159
159
|
getBasePathname: () => string;
|
|
160
160
|
getRoutes: () => BuiltRoute[];
|
|
161
161
|
getServiceWorkers: () => BuiltEntry[];
|
|
162
|
+
/**
|
|
163
|
+
* Hand the adapter's SSG include/exclude patterns to the router so the production server route
|
|
164
|
+
* plan can drop fully-prerendered, server-free routes. Called by the SSG adapter.
|
|
165
|
+
*
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
_setSsgRoutes?: (include: string[] | undefined, exclude: string[] | undefined) => void;
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
/** @public */
|
|
@@ -192,6 +199,7 @@ export declare interface QwikRouterVitePluginOptions extends Omit<PluginOptions,
|
|
|
192
199
|
declare interface RewriteRouteOption {
|
|
193
200
|
prefix?: string;
|
|
194
201
|
paths: Record<string, string>;
|
|
202
|
+
exclude?: string[];
|
|
195
203
|
}
|
|
196
204
|
|
|
197
205
|
export { }
|