@qwik.dev/router 2.0.0-beta.35 → 2.0.0-beta.37
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 -4
- package/lib/adapters/shared/vite/index.mjs +26 -23
- package/lib/chunks/action-handler.mjs +782 -0
- package/lib/chunks/deepFreeze.qwik.mjs +591 -1
- package/lib/chunks/format.mjs +31 -0
- package/lib/chunks/fs.mjs +4 -6
- package/lib/chunks/{routing.qwik.mjs → head.qwik.mjs} +299 -416
- package/lib/chunks/http-error.qwik.mjs +2 -2
- package/lib/chunks/not-found-wrapper.qwik.mjs +2 -2
- package/lib/chunks/pathname.mjs +3 -32
- package/lib/chunks/request-path.mjs +60 -0
- package/lib/chunks/system.mjs +6 -7
- package/lib/chunks/use-functions.qwik.mjs +3 -15
- package/lib/chunks/worker-thread.qwik.mjs +436 -425
- package/lib/index.d.ts +180 -13
- package/lib/index.qwik.mjs +640 -447
- package/lib/middleware/aws-lambda/index.mjs +2 -1
- package/lib/middleware/request-handler/index.d.ts +56 -16
- package/lib/middleware/request-handler/index.mjs +198 -754
- package/lib/ssg/index.d.ts +3 -3
- package/lib/ssg/index.mjs +4 -3
- package/lib/vite/index.d.ts +15 -0
- package/lib/vite/index.mjs +145 -23
- package/package.json +3 -3
- package/lib/chunks/redirect-handler.mjs +0 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { join, relative } from 'node:path';
|
|
3
3
|
import { n as normalizePathSlash } from '../../../chunks/fs.mjs';
|
|
4
|
+
import { e as ensureSlash } from '../../../chunks/pathname.mjs';
|
|
4
5
|
import { viteAdapter } from '../../shared/vite/index.mjs';
|
|
5
6
|
|
|
6
7
|
function cloudflarePagesAdapter(opts = {}) {
|
|
@@ -42,10 +43,7 @@ function cloudflarePagesAdapter(opts = {}) {
|
|
|
42
43
|
const routesJsonPath = join(clientOutDir, "_routes.json");
|
|
43
44
|
const hasRoutesJson = fs.existsSync(routesJsonPath);
|
|
44
45
|
if (!hasRoutesJson && opts.functionRoutes !== false) {
|
|
45
|
-
|
|
46
|
-
if (!pathName.endsWith("/")) {
|
|
47
|
-
pathName += "/";
|
|
48
|
-
}
|
|
46
|
+
const pathName = ensureSlash(assetsDir ? join(basePathname, assetsDir) : basePathname);
|
|
49
47
|
const routesJson = {
|
|
50
48
|
version: 1,
|
|
51
49
|
include: [
|
|
@@ -2,6 +2,8 @@ import { join, resolve, dirname, basename } from 'node:path';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import { g as getErrorHtml } from '../../../chunks/error-handler.mjs';
|
|
5
|
+
import { L as LOADER_REGEX } from '../../../chunks/request-path.mjs';
|
|
6
|
+
import { e as ensureSlash } from '../../../chunks/pathname.mjs';
|
|
5
7
|
|
|
6
8
|
const SSG_WORKER_IMPORT_PREFIX = "@qwik-router-ssg-worker/";
|
|
7
9
|
function ssgWorkerImportPlugin() {
|
|
@@ -24,12 +26,6 @@ function ssgWorkerImportPlugin() {
|
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
function normalizeTrailingSlash(pathname) {
|
|
28
|
-
if (!pathname.endsWith("/")) {
|
|
29
|
-
return pathname + "/";
|
|
30
|
-
}
|
|
31
|
-
return pathname;
|
|
32
|
-
}
|
|
33
29
|
function createNotFoundPathsCode(basePathname, notFounds) {
|
|
34
30
|
notFounds.sort((a, b) => {
|
|
35
31
|
if (a[0].length > b[0].length) {
|
|
@@ -91,21 +87,22 @@ const injectStatics = async (staticPathsCode, notFoundPathsCode, outDir) => {
|
|
|
91
87
|
};
|
|
92
88
|
async function postBuild(clientOutDir, serverOutDir, pathName, userStaticPaths, cleanStatic) {
|
|
93
89
|
if (pathName && !pathName.endsWith("/")) {
|
|
94
|
-
pathName
|
|
90
|
+
pathName = ensureSlash(pathName);
|
|
95
91
|
}
|
|
92
|
+
const pathNameBase = pathName || "/";
|
|
96
93
|
const ignorePathnames = /* @__PURE__ */ new Set([
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
pathNameBase + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
|
|
95
|
+
pathNameBase + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
|
|
99
96
|
]);
|
|
100
|
-
const staticPaths = new Set(userStaticPaths.map(
|
|
97
|
+
const staticPaths = new Set(userStaticPaths.map(ensureSlash));
|
|
101
98
|
const notFounds = [];
|
|
102
99
|
const loadItem = async (fsDir, fsName, pathname) => {
|
|
103
|
-
pathname =
|
|
100
|
+
pathname = ensureSlash(pathname);
|
|
104
101
|
if (ignorePathnames.has(pathname)) {
|
|
105
102
|
return;
|
|
106
103
|
}
|
|
107
104
|
const fsPath = join(fsDir, fsName);
|
|
108
|
-
if (fsName === "index.html" ||
|
|
105
|
+
if (fsName === "index.html" || LOADER_REGEX.test("/" + fsName)) {
|
|
109
106
|
if (!staticPaths.has(pathname) && cleanStatic) {
|
|
110
107
|
await fs.promises.unlink(fsPath);
|
|
111
108
|
}
|
|
@@ -121,7 +118,7 @@ async function postBuild(clientOutDir, serverOutDir, pathName, userStaticPaths,
|
|
|
121
118
|
}
|
|
122
119
|
const stat = await fs.promises.stat(fsPath);
|
|
123
120
|
if (stat.isDirectory()) {
|
|
124
|
-
await loadDir(fsPath, pathname + fsName
|
|
121
|
+
await loadDir(fsPath, ensureSlash(pathname + fsName));
|
|
125
122
|
} else if (stat.isFile()) {
|
|
126
123
|
staticPaths.add(pathname + fsName);
|
|
127
124
|
}
|
|
@@ -227,16 +224,22 @@ function viteAdapter(opts) {
|
|
|
227
224
|
`if (args.includes('--quiet')) ssgOpts.log = 'quiet';`,
|
|
228
225
|
`if (args.includes('--debug')) ssgOpts.log = 'debug';`,
|
|
229
226
|
``,
|
|
230
|
-
|
|
231
|
-
`
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
`
|
|
235
|
-
`
|
|
236
|
-
`
|
|
237
|
-
`
|
|
238
|
-
`
|
|
239
|
-
`
|
|
227
|
+
// Fire-and-forget instead of top-level await. On the worker/edge SSR target Vite
|
|
228
|
+
// inlines dynamic imports, and Rollup then reads the inlined `./system` namespace
|
|
229
|
+
// before it is initialized across a top-level await. See rollup/rollup#4166.
|
|
230
|
+
// runSsg/startWorker keep the process alive (worker handles) and call process.exit.
|
|
231
|
+
`const ssgRun = isMainThread`,
|
|
232
|
+
` ? runSsg({`,
|
|
233
|
+
` render,`,
|
|
234
|
+
` qwikRouterConfig,`,
|
|
235
|
+
` workerFilePath: new URL(import.meta.url).href,`,
|
|
236
|
+
` ...ssgOpts,`,
|
|
237
|
+
` })`,
|
|
238
|
+
` : startWorker({ render, qwikRouterConfig });`,
|
|
239
|
+
`ssgRun.catch((err) => {`,
|
|
240
|
+
` console.error(err);`,
|
|
241
|
+
` process.exit(1);`,
|
|
242
|
+
`});`
|
|
240
243
|
].join("\n");
|
|
241
244
|
},
|
|
242
245
|
buildStart() {
|