@qwik.dev/router 2.0.0-beta.13 → 2.0.0-beta.14
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.mjs +7 -7
- package/lib/adapters/bun-server/vite/index.mjs +7 -7
- package/lib/adapters/cloud-run/vite/index.mjs +7 -7
- package/lib/adapters/cloudflare-pages/vite/index.mjs +8 -8
- package/lib/adapters/deno-server/vite/index.mjs +7 -7
- package/lib/adapters/netlify-edge/vite/index.mjs +7 -7
- package/lib/adapters/node-server/vite/index.mjs +7 -7
- package/lib/adapters/shared/vite/index.mjs +8 -8
- package/lib/adapters/ssg/vite/index.mjs +7 -8
- package/lib/adapters/vercel-edge/vite/index.mjs +7 -7
- package/lib/chunks/error-handler.mjs +2 -4
- package/lib/chunks/format-error.mjs +6 -6
- package/lib/chunks/fs.mjs +6 -27
- package/lib/chunks/index.mjs +39 -31
- package/lib/chunks/mime-types.mjs +2 -3
- package/lib/chunks/routing.qwik.mjs +23 -47
- package/lib/chunks/types.qwik.mjs +2 -5
- package/lib/index.d.ts +2 -1
- package/lib/index.qwik.mjs +48 -68
- package/lib/middleware/aws-lambda/index.mjs +4 -5
- package/lib/middleware/azure-swa/index.mjs +6 -7
- package/lib/middleware/bun/index.mjs +8 -9
- package/lib/middleware/cloudflare-pages/index.mjs +5 -6
- package/lib/middleware/deno/index.mjs +7 -8
- package/lib/middleware/firebase/index.mjs +4 -5
- package/lib/middleware/netlify-edge/index.mjs +5 -6
- package/lib/middleware/node/index.mjs +15 -11
- package/lib/middleware/request-handler/index.d.ts +2 -2
- package/lib/middleware/request-handler/index.mjs +64 -79
- package/lib/middleware/vercel-edge/index.mjs +5 -6
- package/lib/service-worker/index.mjs +2 -3
- package/lib/ssg/index.mjs +3 -4
- package/lib/vite/index.d.ts +7 -1
- package/lib/vite/index.mjs +91 -68
- package/package.json +21 -39
- package/lib/adapters/azure-swa/vite/index.cjs +0 -61
- package/lib/adapters/bun-server/vite/index.cjs +0 -27
- package/lib/adapters/cloud-run/vite/index.cjs +0 -24
- package/lib/adapters/cloudflare-pages/vite/index.cjs +0 -65
- package/lib/adapters/deno-server/vite/index.cjs +0 -39
- package/lib/adapters/netlify-edge/vite/index.cjs +0 -88
- package/lib/adapters/node-server/vite/index.cjs +0 -27
- package/lib/adapters/shared/vite/index.cjs +0 -306
- package/lib/adapters/ssg/vite/index.cjs +0 -19
- package/lib/adapters/vercel-edge/vite/index.cjs +0 -81
- package/lib/chunks/error-handler.cjs +0 -58
- package/lib/chunks/format-error.cjs +0 -136
- package/lib/chunks/fs.cjs +0 -274
- package/lib/chunks/index.cjs +0 -877
- package/lib/chunks/mime-types.cjs +0 -52
- package/lib/chunks/routing.qwik.cjs +0 -452
- package/lib/chunks/types.qwik.cjs +0 -24
- package/lib/index.qwik.cjs +0 -1662
- package/lib/middleware/aws-lambda/index.cjs +0 -52
- package/lib/middleware/azure-swa/index.cjs +0 -92
- package/lib/middleware/bun/index.cjs +0 -143
- package/lib/middleware/cloudflare-pages/index.cjs +0 -96
- package/lib/middleware/deno/index.cjs +0 -130
- package/lib/middleware/firebase/index.cjs +0 -33
- package/lib/middleware/netlify-edge/index.cjs +0 -71
- package/lib/middleware/node/index.cjs +0 -219
- package/lib/middleware/request-handler/index.cjs +0 -1488
- package/lib/middleware/vercel-edge/index.cjs +0 -98
- package/lib/service-worker/index.cjs +0 -5
- package/lib/ssg/index.cjs +0 -15
- package/lib/vite/index.cjs +0 -2021
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import { join } from
|
|
3
|
-
import { viteAdapter } from
|
|
4
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { viteAdapter } from '../../shared/vite/index.mjs';
|
|
4
|
+
import '../../../chunks/error-handler.mjs';
|
|
5
|
+
|
|
5
6
|
function azureSwaAdapter(opts = {}) {
|
|
6
7
|
const env = process?.env;
|
|
7
8
|
return viteAdapter({
|
|
@@ -56,6 +57,5 @@ function azureSwaAdapter(opts = {}) {
|
|
|
56
57
|
}
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
60
|
+
|
|
61
|
+
export { azureSwaAdapter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { viteAdapter } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { viteAdapter } from '../../shared/vite/index.mjs';
|
|
2
|
+
import 'node:path';
|
|
3
|
+
import 'node:fs';
|
|
4
|
+
import '../../../chunks/error-handler.mjs';
|
|
5
|
+
|
|
5
6
|
function bunServerAdapter(opts = {}) {
|
|
6
7
|
const env = process?.env;
|
|
7
8
|
return viteAdapter({
|
|
@@ -22,6 +23,5 @@ function bunServerAdapter(opts = {}) {
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
26
|
+
|
|
27
|
+
export { bunServerAdapter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { viteAdapter } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { viteAdapter } from '../../shared/vite/index.mjs';
|
|
2
|
+
import 'node:path';
|
|
3
|
+
import 'node:fs';
|
|
4
|
+
import '../../../chunks/error-handler.mjs';
|
|
5
|
+
|
|
5
6
|
function cloudRunAdapter(opts = {}) {
|
|
6
7
|
const env = process?.env;
|
|
7
8
|
return viteAdapter({
|
|
@@ -19,6 +20,5 @@ function cloudRunAdapter(opts = {}) {
|
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
23
|
+
|
|
24
|
+
export { cloudRunAdapter };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import { join, relative } from
|
|
3
|
-
import { n as normalizePathSlash } from
|
|
4
|
-
import { viteAdapter } from
|
|
5
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { join, relative } from 'node:path';
|
|
3
|
+
import { n as normalizePathSlash } from '../../../chunks/fs.mjs';
|
|
4
|
+
import { viteAdapter } from '../../shared/vite/index.mjs';
|
|
5
|
+
import '../../../chunks/error-handler.mjs';
|
|
6
|
+
|
|
6
7
|
function cloudflarePagesAdapter(opts = {}) {
|
|
7
8
|
const env = process?.env;
|
|
8
9
|
return viteAdapter({
|
|
@@ -60,6 +61,5 @@ function cloudflarePagesAdapter(opts = {}) {
|
|
|
60
61
|
}
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
64
|
+
|
|
65
|
+
export { cloudflarePagesAdapter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { viteAdapter } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { viteAdapter } from '../../shared/vite/index.mjs';
|
|
2
|
+
import 'node:path';
|
|
3
|
+
import 'node:fs';
|
|
4
|
+
import '../../../chunks/error-handler.mjs';
|
|
5
|
+
|
|
5
6
|
function denoServerAdapter(opts = {}) {
|
|
6
7
|
const env = process?.env;
|
|
7
8
|
return viteAdapter({
|
|
@@ -34,6 +35,5 @@ function denoServerAdapter(opts = {}) {
|
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
38
|
+
|
|
39
|
+
export { denoServerAdapter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import fs, { existsSync } from
|
|
2
|
-
import { join } from
|
|
3
|
-
import { viteAdapter, getParentDir } from
|
|
4
|
-
import
|
|
1
|
+
import fs, { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { viteAdapter, getParentDir } from '../../shared/vite/index.mjs';
|
|
4
|
+
import '../../../chunks/error-handler.mjs';
|
|
5
|
+
|
|
5
6
|
function netlifyEdgeAdapter(opts = {}) {
|
|
6
7
|
const env = process?.env;
|
|
7
8
|
return viteAdapter({
|
|
@@ -83,6 +84,5 @@ function netlifyEdgeAdapter(opts = {}) {
|
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
87
|
+
|
|
88
|
+
export { netlifyEdgeAdapter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { viteAdapter } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { viteAdapter } from '../../shared/vite/index.mjs';
|
|
2
|
+
import 'node:path';
|
|
3
|
+
import 'node:fs';
|
|
4
|
+
import '../../../chunks/error-handler.mjs';
|
|
5
|
+
|
|
5
6
|
function nodeServerAdapter(opts = {}) {
|
|
6
7
|
const env = process?.env;
|
|
7
8
|
return viteAdapter({
|
|
@@ -22,6 +23,5 @@ function nodeServerAdapter(opts = {}) {
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
26
|
+
|
|
27
|
+
export { nodeServerAdapter };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { join, resolve, dirname, basename } from
|
|
2
|
-
import fs from
|
|
3
|
-
import { g as getErrorHtml } from
|
|
1
|
+
import { join, resolve, dirname, basename } from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { g as getErrorHtml } from '../../../chunks/error-handler.mjs';
|
|
4
|
+
|
|
4
5
|
async function postBuild(clientOutDir, serverOutDir, pathName, userStaticPaths, cleanStatic) {
|
|
5
6
|
if (pathName && !pathName.endsWith("/")) {
|
|
6
7
|
pathName += "/";
|
|
@@ -109,6 +110,7 @@ const injectStatics = async (staticPathsCode, notFoundPathsCode, outDir) => {
|
|
|
109
110
|
await walk(outDir);
|
|
110
111
|
await Promise.all(promises);
|
|
111
112
|
};
|
|
113
|
+
|
|
112
114
|
function viteAdapter(opts) {
|
|
113
115
|
let qwikRouterPlugin = null;
|
|
114
116
|
let qwikVitePlugin = null;
|
|
@@ -224,7 +226,7 @@ function viteAdapter(opts) {
|
|
|
224
226
|
);
|
|
225
227
|
ssgOrigin = `https://yoursite.qwik.dev`;
|
|
226
228
|
}
|
|
227
|
-
const staticGenerate = await import(
|
|
229
|
+
const staticGenerate = await import('../../../ssg/index.mjs');
|
|
228
230
|
const generateOpts = {
|
|
229
231
|
maxWorkers: opts.maxWorkers,
|
|
230
232
|
basePathname,
|
|
@@ -300,7 +302,5 @@ function getParentDir(startDir, dirName) {
|
|
|
300
302
|
}
|
|
301
303
|
throw new Error(`Unable to find "${dirName}" directory from "${startDir}"`);
|
|
302
304
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
viteAdapter
|
|
306
|
-
};
|
|
305
|
+
|
|
306
|
+
export { getParentDir, viteAdapter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { viteAdapter } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { viteAdapter } from '../../shared/vite/index.mjs';
|
|
2
|
+
import 'node:path';
|
|
3
|
+
import 'node:fs';
|
|
4
|
+
import '../../../chunks/error-handler.mjs';
|
|
5
|
+
|
|
5
6
|
function ssgAdapter(opts) {
|
|
6
7
|
return viteAdapter({
|
|
7
8
|
name: "static-site-generation",
|
|
@@ -13,7 +14,5 @@ function ssgAdapter(opts) {
|
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
const staticAdapter = ssgAdapter;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
staticAdapter
|
|
19
|
-
};
|
|
17
|
+
|
|
18
|
+
export { ssgAdapter, staticAdapter };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import { join, dirname } from
|
|
3
|
-
import { viteAdapter, getParentDir } from
|
|
4
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { join, dirname } from 'node:path';
|
|
3
|
+
import { viteAdapter, getParentDir } from '../../shared/vite/index.mjs';
|
|
4
|
+
import '../../../chunks/error-handler.mjs';
|
|
5
|
+
|
|
5
6
|
function vercelEdgeAdapter(opts = {}) {
|
|
6
7
|
return viteAdapter({
|
|
7
8
|
name: "vercel-edge",
|
|
@@ -76,6 +77,5 @@ function vercelEdgeAdapter(opts = {}) {
|
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
80
|
+
|
|
81
|
+
export { vercelEdgeAdapter };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { l as normalizePath } from
|
|
2
|
-
import fs from
|
|
1
|
+
import { l as normalizePath } from './fs.mjs';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
|
|
3
4
|
const findLocation = (e) => {
|
|
4
5
|
const stack = e.stack;
|
|
5
6
|
if (typeof stack === "string") {
|
|
@@ -108,6 +109,7 @@ function parseId(originalId) {
|
|
|
108
109
|
params: new URLSearchParams(queryStr)
|
|
109
110
|
};
|
|
110
111
|
}
|
|
112
|
+
|
|
111
113
|
function formatError(e) {
|
|
112
114
|
if (e instanceof Error) {
|
|
113
115
|
const err = e;
|
|
@@ -131,7 +133,5 @@ function formatError(e) {
|
|
|
131
133
|
}
|
|
132
134
|
return e;
|
|
133
135
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
parseId as p
|
|
137
|
-
};
|
|
136
|
+
|
|
137
|
+
export { formatError as f, parseId as p };
|
package/lib/chunks/fs.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { normalize, basename, dirname, relative } from
|
|
1
|
+
import { normalize, basename, dirname, relative } from 'node:path';
|
|
2
|
+
|
|
2
3
|
function toTitleCase(str) {
|
|
3
4
|
return str.replace(/\w\S*/g, (txt) => {
|
|
4
5
|
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
|
|
@@ -28,6 +29,7 @@ function msToString(ms) {
|
|
|
28
29
|
}
|
|
29
30
|
return (ms / 6e4).toFixed(1) + " m";
|
|
30
31
|
}
|
|
32
|
+
|
|
31
33
|
function normalizePathname(pathname, basePathname) {
|
|
32
34
|
if (typeof pathname === "string") {
|
|
33
35
|
pathname = pathname.trim();
|
|
@@ -101,6 +103,7 @@ const PROTOCOLS = {
|
|
|
101
103
|
javascript: true,
|
|
102
104
|
file: true
|
|
103
105
|
};
|
|
106
|
+
|
|
104
107
|
function parseRouteIndexName(extlessName) {
|
|
105
108
|
let layoutName = "";
|
|
106
109
|
const layoutStop = extlessName.endsWith("!");
|
|
@@ -247,29 +250,5 @@ function isGroupedLayoutName(dirName, warn = true) {
|
|
|
247
250
|
}
|
|
248
251
|
return dirName.startsWith("(") && dirName.endsWith(")");
|
|
249
252
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
isLayoutModule as b,
|
|
253
|
-
isEntryName as c,
|
|
254
|
-
isMenuFileName as d,
|
|
255
|
-
isServiceWorkerName as e,
|
|
256
|
-
isPageModuleExt as f,
|
|
257
|
-
getExtension as g,
|
|
258
|
-
isModuleExt as h,
|
|
259
|
-
isIndexModule as i,
|
|
260
|
-
isMarkdownExt as j,
|
|
261
|
-
isSameOriginUrl as k,
|
|
262
|
-
normalizePath as l,
|
|
263
|
-
getPathnameFromDirPath as m,
|
|
264
|
-
normalizePathSlash as n,
|
|
265
|
-
getMenuPathname as o,
|
|
266
|
-
createFileId as p,
|
|
267
|
-
parseRouteIndexName as q,
|
|
268
|
-
removeExtension as r,
|
|
269
|
-
isPluginModule as s,
|
|
270
|
-
addError as t,
|
|
271
|
-
addWarning as u,
|
|
272
|
-
isPageExt as v,
|
|
273
|
-
msToString as w,
|
|
274
|
-
getPathnameForDynamicRoute as x
|
|
275
|
-
};
|
|
253
|
+
|
|
254
|
+
export { isErrorName as a, isLayoutModule as b, isEntryName as c, isMenuFileName as d, isServiceWorkerName as e, isPageModuleExt as f, getExtension as g, isModuleExt as h, isIndexModule as i, isMarkdownExt as j, isSameOriginUrl as k, normalizePath as l, getPathnameFromDirPath as m, normalizePathSlash as n, getMenuPathname as o, createFileId as p, parseRouteIndexName as q, removeExtension as r, isPluginModule as s, addError as t, addWarning as u, isPageExt as v, msToString as w, getPathnameForDynamicRoute as x };
|
package/lib/chunks/index.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import { isAbsolute, resolve, extname, join, dirname, relative } from
|
|
3
|
-
import { cpus } from
|
|
4
|
-
import { Worker, parentPort, isMainThread, workerData, threadId } from
|
|
5
|
-
import { l as normalizePath, w as msToString, x as getPathnameForDynamicRoute } from
|
|
6
|
-
import { bold, green, dim, red, magenta } from
|
|
7
|
-
import { pathToFileURL } from
|
|
8
|
-
import { buildErrorMessage } from
|
|
9
|
-
import { f as formatError } from
|
|
10
|
-
import { getErrorHtml, RequestEvShareQData, requestHandler, RedirectMessage } from
|
|
11
|
-
import { R as RouteDataProp } from
|
|
12
|
-
import { _serialize } from
|
|
13
|
-
import { WritableStream } from
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { isAbsolute, resolve, extname, join, dirname, relative } from 'node:path';
|
|
3
|
+
import { cpus } from 'node:os';
|
|
4
|
+
import { Worker, parentPort, isMainThread, workerData, threadId } from 'node:worker_threads';
|
|
5
|
+
import { l as normalizePath, w as msToString, x as getPathnameForDynamicRoute } from './fs.mjs';
|
|
6
|
+
import { bold, green, dim, red, magenta } from 'kleur/colors';
|
|
7
|
+
import { pathToFileURL } from 'node:url';
|
|
8
|
+
import { buildErrorMessage } from 'vite';
|
|
9
|
+
import { f as formatError } from './format-error.mjs';
|
|
10
|
+
import { getErrorHtml, RequestEvShareQData, requestHandler, RedirectMessage } from '@qwik.dev/router/middleware/request-handler';
|
|
11
|
+
import { R as RouteDataProp } from './types.qwik.mjs';
|
|
12
|
+
import { _serialize } from '@qwik.dev/core/internal';
|
|
13
|
+
import { WritableStream } from 'node:stream/web';
|
|
14
|
+
|
|
14
15
|
async function createNodeMainProcess(sys, opts) {
|
|
15
16
|
const ssgWorkers = [];
|
|
16
17
|
const sitemapBuffer = [];
|
|
@@ -200,6 +201,7 @@ function ssgWorkerCompare(a, b) {
|
|
|
200
201
|
}
|
|
201
202
|
return a.totalTasks < b.totalTasks ? -1 : 1;
|
|
202
203
|
}
|
|
204
|
+
|
|
203
205
|
async function createNodeWorkerProcess(onMessage) {
|
|
204
206
|
parentPort?.on("message", async (msg) => {
|
|
205
207
|
parentPort?.postMessage(await onMessage(msg));
|
|
@@ -208,7 +210,8 @@ async function createNodeWorkerProcess(onMessage) {
|
|
|
208
210
|
}
|
|
209
211
|
});
|
|
210
212
|
}
|
|
211
|
-
|
|
213
|
+
|
|
214
|
+
async function createSystem(opts, threadId) {
|
|
212
215
|
const createWriteStream = (filePath) => {
|
|
213
216
|
return fs.createWriteStream(filePath, {
|
|
214
217
|
flags: "w"
|
|
@@ -224,12 +227,12 @@ async function createSystem(opts, threadId2) {
|
|
|
224
227
|
};
|
|
225
228
|
};
|
|
226
229
|
const createLogger = async () => {
|
|
227
|
-
if (
|
|
230
|
+
if (threadId !== void 0) {
|
|
228
231
|
return {
|
|
229
|
-
debug: opts.log === "debug" ? console.debug.bind(console, `[${
|
|
232
|
+
debug: opts.log === "debug" ? console.debug.bind(console, `[${threadId}]`) : () => {
|
|
230
233
|
},
|
|
231
|
-
error: console.error.bind(console, `[${
|
|
232
|
-
info: console.info.bind(console, `[${
|
|
234
|
+
error: console.error.bind(console, `[${threadId}]`),
|
|
235
|
+
info: console.info.bind(console, `[${threadId}]`)
|
|
233
236
|
};
|
|
234
237
|
}
|
|
235
238
|
return {
|
|
@@ -299,6 +302,7 @@ const access = async (path) => {
|
|
|
299
302
|
return false;
|
|
300
303
|
}
|
|
301
304
|
};
|
|
305
|
+
|
|
302
306
|
function extractParamNames(routeName) {
|
|
303
307
|
const params = [];
|
|
304
308
|
let idx = 0;
|
|
@@ -315,6 +319,7 @@ function extractParamNames(routeName) {
|
|
|
315
319
|
}
|
|
316
320
|
return params;
|
|
317
321
|
}
|
|
322
|
+
|
|
318
323
|
async function generateNotFoundPages(sys, opts, routes) {
|
|
319
324
|
if (opts.emit404Pages !== false) {
|
|
320
325
|
const basePathname = opts.basePathname || "/";
|
|
@@ -326,14 +331,15 @@ async function generateNotFoundPages(sys, opts, routes) {
|
|
|
326
331
|
const filePath = sys.getRouteFilePath(rootNotFoundPathname, true);
|
|
327
332
|
const html = getErrorHtml(404, "Resource Not Found");
|
|
328
333
|
await sys.ensureDir(filePath);
|
|
329
|
-
return new Promise((
|
|
334
|
+
return new Promise((resolve) => {
|
|
330
335
|
const writer = sys.createWriteStream(filePath);
|
|
331
336
|
writer.write(html);
|
|
332
|
-
writer.end(
|
|
337
|
+
writer.end(resolve);
|
|
333
338
|
});
|
|
334
339
|
}
|
|
335
340
|
}
|
|
336
341
|
}
|
|
342
|
+
|
|
337
343
|
function createRouteTester(basePathname, includeRoutes, excludeRoutes) {
|
|
338
344
|
const includes = routesToRegExps(includeRoutes);
|
|
339
345
|
const excludes = routesToRegExps(excludeRoutes);
|
|
@@ -379,6 +385,7 @@ function routeToRegExp(rule) {
|
|
|
379
385
|
transformedRule = `^${transformedRule.replace(/\*/g, ".*")}$`;
|
|
380
386
|
return new RegExp(transformedRule);
|
|
381
387
|
}
|
|
388
|
+
|
|
382
389
|
async function mainThread(sys) {
|
|
383
390
|
const opts = sys.getOptions();
|
|
384
391
|
validateOptions(opts);
|
|
@@ -391,7 +398,7 @@ async function mainThread(sys) {
|
|
|
391
398
|
const routes = qwikRouterConfig.routes || [];
|
|
392
399
|
const trailingSlash = !!qwikRouterConfig.trailingSlash;
|
|
393
400
|
const includeRoute = createRouteTester(opts.basePathname || "/", opts.include, opts.exclude);
|
|
394
|
-
return new Promise((
|
|
401
|
+
return new Promise((resolve, reject) => {
|
|
395
402
|
try {
|
|
396
403
|
const timer = sys.createTimer();
|
|
397
404
|
const generatorResult = {
|
|
@@ -426,7 +433,7 @@ ${green("SSG results")}`);
|
|
|
426
433
|
log.info(``);
|
|
427
434
|
}
|
|
428
435
|
closePromise.then(() => {
|
|
429
|
-
setTimeout(() =>
|
|
436
|
+
setTimeout(() => resolve(generatorResult));
|
|
430
437
|
}).catch(reject);
|
|
431
438
|
};
|
|
432
439
|
const next = () => {
|
|
@@ -591,6 +598,7 @@ function validateOptions(opts) {
|
|
|
591
598
|
throw new Error(`Invalid "origin"`, { cause: e });
|
|
592
599
|
}
|
|
593
600
|
}
|
|
601
|
+
|
|
594
602
|
async function workerThread(sys) {
|
|
595
603
|
delete globalThis.__qwik;
|
|
596
604
|
const ssgOpts = sys.getOptions();
|
|
@@ -607,8 +615,8 @@ async function workerThread(sys) {
|
|
|
607
615
|
switch (msg.type) {
|
|
608
616
|
case "render": {
|
|
609
617
|
log.debug(`Worker thread rendering: ${msg.pathname}`);
|
|
610
|
-
return new Promise((
|
|
611
|
-
workerRender(sys, opts, msg, pendingPromises,
|
|
618
|
+
return new Promise((resolve) => {
|
|
619
|
+
workerRender(sys, opts, msg, pendingPromises, resolve).catch((e) => {
|
|
612
620
|
console.error("Error during render", msg.pathname, e);
|
|
613
621
|
});
|
|
614
622
|
});
|
|
@@ -735,18 +743,18 @@ async function workerRender(sys, opts, staticRoute, pendingPromises, callback) {
|
|
|
735
743
|
const serialized = await _serialize([qData]);
|
|
736
744
|
dataWriter.write(serialized);
|
|
737
745
|
writePromises.push(
|
|
738
|
-
new Promise((
|
|
746
|
+
new Promise((resolve) => {
|
|
739
747
|
result.filePath = routeFilePath;
|
|
740
|
-
dataWriter.end(
|
|
748
|
+
dataWriter.end(resolve);
|
|
741
749
|
})
|
|
742
750
|
);
|
|
743
751
|
}
|
|
744
752
|
}
|
|
745
753
|
if (routeWriter) {
|
|
746
754
|
writePromises.push(
|
|
747
|
-
new Promise((
|
|
755
|
+
new Promise((resolve) => {
|
|
748
756
|
result.filePath = routeFilePath;
|
|
749
|
-
routeWriter.end(
|
|
757
|
+
routeWriter.end(resolve);
|
|
750
758
|
}).finally(closeResolved)
|
|
751
759
|
);
|
|
752
760
|
}
|
|
@@ -847,6 +855,7 @@ const noopWritableStream = {
|
|
|
847
855
|
return noopWriter;
|
|
848
856
|
}
|
|
849
857
|
};
|
|
858
|
+
|
|
850
859
|
async function generate(opts) {
|
|
851
860
|
if (isMainThread) {
|
|
852
861
|
const sys = await createSystem(opts);
|
|
@@ -871,6 +880,5 @@ if (!isMainThread && workerData) {
|
|
|
871
880
|
console.error(e);
|
|
872
881
|
});
|
|
873
882
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
};
|
|
883
|
+
|
|
884
|
+
export { generate };
|