@qwik.dev/router 2.0.0-beta.10 → 2.0.0-beta.11
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.cjs +2 -2
- package/lib/adapters/azure-swa/vite/index.mjs +73 -69
- package/lib/adapters/bun-server/vite/index.cjs +2 -2
- package/lib/adapters/bun-server/vite/index.mjs +77 -73
- package/lib/adapters/cloud-run/vite/index.cjs +2 -2
- package/lib/adapters/cloud-run/vite/index.mjs +104 -100
- package/lib/adapters/cloudflare-pages/vite/{index-DwovcBp3.js → index-Bg_9YkM5.js} +1 -1
- package/lib/adapters/cloudflare-pages/vite/{index-C455V8_A.cjs → index-C1aDmh1S.cjs} +1 -1
- package/lib/adapters/cloudflare-pages/vite/index-CHT9Y93A.js +254 -0
- package/lib/adapters/cloudflare-pages/vite/{index-DKcVHRBy.cjs → index-Ck7KvpK1.cjs} +1 -1
- package/lib/adapters/cloudflare-pages/vite/{index-D3HITboM.js → index-Cp1cjAds.js} +1 -1
- package/lib/adapters/cloudflare-pages/vite/index-D9RL9dvJ.cjs +5 -0
- package/lib/adapters/cloudflare-pages/vite/index.cjs +1 -1
- package/lib/adapters/cloudflare-pages/vite/index.mjs +1 -1
- package/lib/adapters/deno-server/vite/index.cjs +2 -2
- package/lib/adapters/deno-server/vite/index.mjs +81 -77
- package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
- package/lib/adapters/netlify-edge/vite/index.mjs +119 -115
- package/lib/adapters/node-server/vite/index.cjs +2 -2
- package/lib/adapters/node-server/vite/index.mjs +78 -74
- package/lib/adapters/shared/vite/index.cjs +2 -2
- package/lib/adapters/shared/vite/index.mjs +108 -104
- package/lib/adapters/ssg/vite/index.cjs +2 -2
- package/lib/adapters/ssg/vite/index.mjs +100 -96
- package/lib/adapters/vercel-edge/vite/index.cjs +2 -2
- package/lib/adapters/vercel-edge/vite/index.mjs +114 -110
- package/lib/index.qwik.cjs +39 -33
- package/lib/index.qwik.mjs +39 -33
- package/lib/middleware/request-handler/index.cjs +8 -8
- package/lib/middleware/request-handler/index.mjs +598 -587
- package/lib/vite/index.cjs +17 -17
- package/lib/vite/index.d.ts +3 -3
- package/lib/vite/index.mjs +242 -230
- package/package.json +4 -4
- package/lib/adapters/cloudflare-pages/vite/index-BIeHg2Cj.cjs +0 -5
- package/lib/adapters/cloudflare-pages/vite/index-bogwy7wh.js +0 -250
package/lib/vite/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { mergeConfig as pe, loadEnv as me } from "vite";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import x, { existsSync as ge } from "node:fs";
|
|
3
|
+
import Q, { normalize as ye, basename as M, dirname as R, relative as ee, join as j, resolve as T, isAbsolute as q, extname as we } from "node:path";
|
|
4
4
|
import { marked as ve } from "marked";
|
|
5
5
|
import { SourceMapGenerator as be } from "source-map";
|
|
6
|
-
import { visit as
|
|
6
|
+
import { visit as E } from "unist-util-visit";
|
|
7
7
|
import { parse as Pe } from "yaml";
|
|
8
8
|
import xe from "github-slugger";
|
|
9
9
|
import { valueToEstree as Se } from "estree-util-value-to-estree";
|
|
10
10
|
import { headingRank as te } from "hast-util-heading-rank";
|
|
11
|
-
import { toString as
|
|
12
|
-
import { refractor as
|
|
11
|
+
import { toString as B } from "hast-util-to-string";
|
|
12
|
+
import { refractor as F } from "refractor";
|
|
13
13
|
import ke from "refractor/lang/tsx.js";
|
|
14
14
|
import { optimize as Ee } from "svgo";
|
|
15
15
|
function yr(e, t) {
|
|
@@ -83,18 +83,18 @@ function _e(e) {
|
|
|
83
83
|
const n = e.split("@");
|
|
84
84
|
return n.length > 1 && (n.shift(), t = n.join("@")), { layoutName: t, layoutStop: r };
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function L(e, t) {
|
|
87
87
|
const r = ee(e.routesDir, t);
|
|
88
|
-
let n =
|
|
88
|
+
let n = v(r);
|
|
89
89
|
return n = ne(n, e.basePathname).split("/").filter((s) => !qe(s)).join("/"), n === "" ? "/" : n;
|
|
90
90
|
}
|
|
91
91
|
function De(e, t) {
|
|
92
|
-
let r =
|
|
93
|
-
r = "/" +
|
|
92
|
+
let r = v(ee(e.routesDir, t));
|
|
93
|
+
r = "/" + v(R(r));
|
|
94
94
|
let n = ne(r, e.basePathname);
|
|
95
95
|
return n.endsWith("/") || (n += "/"), n;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function $(e) {
|
|
98
98
|
if (typeof e == "string") {
|
|
99
99
|
const t = e.trim().toLowerCase().split(".");
|
|
100
100
|
if (t.length > 1) {
|
|
@@ -104,26 +104,26 @@ function N(e) {
|
|
|
104
104
|
}
|
|
105
105
|
return "";
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function S(e) {
|
|
108
108
|
if (typeof e == "string") {
|
|
109
109
|
e = e.trim();
|
|
110
|
-
const t =
|
|
110
|
+
const t = $(e);
|
|
111
111
|
return e.slice(0, e.length - t.length);
|
|
112
112
|
}
|
|
113
113
|
return "";
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function v(e) {
|
|
116
116
|
return Oe(ye(e));
|
|
117
117
|
}
|
|
118
118
|
function Oe(e) {
|
|
119
119
|
const t = /^\\\\\?\\/.test(e), r = /[^\u0000-\u0080]+/.test(e);
|
|
120
120
|
return t || r || (e = e.replace(/\\/g, "/"), e.endsWith("/") && (e = e.slice(0, e.length - 1))), e;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function I(e, t, r) {
|
|
123
123
|
const n = [];
|
|
124
124
|
for (let s = 0; s < 25; s++) {
|
|
125
|
-
let i =
|
|
126
|
-
if (i = i.replace(/[\W_]+/g, ""), i === "" ? i = "Q" + s : isNaN(i.charAt(0)) || (i = "Q" + i), n.push(Ne(i)), t =
|
|
125
|
+
let i = S(M(t));
|
|
126
|
+
if (i = i.replace(/[\W_]+/g, ""), i === "" ? i = "Q" + s : isNaN(i.charAt(0)) || (i = "Q" + i), n.push(Ne(i)), t = v(R(t)), t === e)
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
129
129
|
return n.length > 1 && n[0] === "Index" && n.shift(), n.reverse().join("").concat(r || "");
|
|
@@ -150,10 +150,10 @@ function Ae(e) {
|
|
|
150
150
|
function ae(e) {
|
|
151
151
|
return e in ie;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function U(e) {
|
|
154
154
|
return e in Te;
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function J(e) {
|
|
157
157
|
return e in oe;
|
|
158
158
|
}
|
|
159
159
|
function Ce(e) {
|
|
@@ -184,7 +184,7 @@ function qe(e, t = !0) {
|
|
|
184
184
|
), !0) : e.startsWith("(") && e.endsWith(")");
|
|
185
185
|
}
|
|
186
186
|
function le(e) {
|
|
187
|
-
const t =
|
|
187
|
+
const t = $(e), r = S(e), n = ae(t), s = U(t), i = J(t);
|
|
188
188
|
let o = null;
|
|
189
189
|
return (We(r) || He(r)) && (n || s || i) ? o = "route" : Ae(r) && (n || s) ? o = "layout" : Le(r) && s ? o = "entry" : ue(e) ? o = "menu" : s && Me(r) && (o = "service-worker"), o !== null ? {
|
|
190
190
|
type: o,
|
|
@@ -192,22 +192,22 @@ function le(e) {
|
|
|
192
192
|
ext: t
|
|
193
193
|
} : null;
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function C(e, t, r, n) {
|
|
196
196
|
if (typeof r != "string" || !se(r))
|
|
197
197
|
return r;
|
|
198
|
-
const s = r.split("?"), i = r.split("#"), o = r.split("?")[0].split("#")[0], a =
|
|
199
|
-
if (
|
|
200
|
-
const u = o.startsWith("/"), c =
|
|
198
|
+
const s = r.split("?"), i = r.split("#"), o = r.split("?")[0].split("#")[0], a = $(o);
|
|
199
|
+
if (J(a)) {
|
|
200
|
+
const u = o.startsWith("/"), c = v(o).split("/").filter((w) => w.length > 0), l = u ? j(e.routesDir, ...c) : j(R(t), ...c);
|
|
201
201
|
n && !ge(l) && console.warn(
|
|
202
202
|
`
|
|
203
203
|
The link "${r}", found within "${t}" does not have a matching source file.
|
|
204
204
|
`
|
|
205
205
|
);
|
|
206
|
-
const f =
|
|
206
|
+
const f = M(l);
|
|
207
207
|
if (le(f)) {
|
|
208
|
-
const
|
|
209
|
-
let
|
|
210
|
-
return s.length > 1 ?
|
|
208
|
+
const w = R(l);
|
|
209
|
+
let d = L(e, w);
|
|
210
|
+
return s.length > 1 ? d += "?" + s[1] : i.length > 1 && (d += "#" + i[1]), d;
|
|
211
211
|
}
|
|
212
212
|
} else a === "" && (r.endsWith("/") ? globalThis.__NO_TRAILING_SLASH__ && (r = r.slice(0, -1)) : globalThis.__NO_TRAILING_SLASH__ || (r += "/"));
|
|
213
213
|
return r;
|
|
@@ -222,7 +222,7 @@ function Be(e, t) {
|
|
|
222
222
|
return Fe(e, t.filePath);
|
|
223
223
|
}
|
|
224
224
|
async function Ue(e, t, r) {
|
|
225
|
-
const n = Je(e, t, r), s =
|
|
225
|
+
const n = Je(e, t, r), s = I(e.routesDir, t);
|
|
226
226
|
return `${`const ${s} = ${JSON.stringify(n, null, 2)};`} export default ${s}`;
|
|
227
227
|
}
|
|
228
228
|
function Je(e, t, r, n = !0) {
|
|
@@ -247,7 +247,7 @@ function Je(e, t, r, n = !0) {
|
|
|
247
247
|
if (l.type === "text")
|
|
248
248
|
f.text = l.text;
|
|
249
249
|
else if (l.type === "link")
|
|
250
|
-
f.text = l.text, f.href =
|
|
250
|
+
f.text = l.text, f.href = C(e, t, l.href, n);
|
|
251
251
|
else
|
|
252
252
|
throw new Error(
|
|
253
253
|
`Headings can only be a text or link. Received "${l.type}", value "${l.raw}", in menu: ${t}`
|
|
@@ -267,7 +267,7 @@ function Je(e, t, r, n = !0) {
|
|
|
267
267
|
else if (f.type === "link")
|
|
268
268
|
u.items.push({
|
|
269
269
|
text: f.text,
|
|
270
|
-
href:
|
|
270
|
+
href: C(e, t, f.href, n)
|
|
271
271
|
});
|
|
272
272
|
else
|
|
273
273
|
throw new Error(
|
|
@@ -276,7 +276,7 @@ function Je(e, t, r, n = !0) {
|
|
|
276
276
|
else if (l.type === "link")
|
|
277
277
|
u.items.push({
|
|
278
278
|
text: l.text,
|
|
279
|
-
href:
|
|
279
|
+
href: C(e, t, l.href, n)
|
|
280
280
|
});
|
|
281
281
|
else
|
|
282
282
|
throw new Error(
|
|
@@ -297,7 +297,7 @@ function Je(e, t, r, n = !0) {
|
|
|
297
297
|
throw new Error(`Menu must start with an h1 in the index: ${t}`);
|
|
298
298
|
return o[0];
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function G(e, t) {
|
|
301
301
|
if (t === e)
|
|
302
302
|
return {
|
|
303
303
|
pattern: new RegExp("^" + t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "$"),
|
|
@@ -315,8 +315,8 @@ function U(e, t) {
|
|
|
315
315
|
if (c % 2) {
|
|
316
316
|
const l = Ge.exec(u);
|
|
317
317
|
if (l) {
|
|
318
|
-
const [, f,
|
|
319
|
-
return n.push(
|
|
318
|
+
const [, f, p] = l;
|
|
319
|
+
return n.push(p), f ? "(.*?)" : "([^/]+?)";
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
return encodeURI(u).normalize().replace(/%5[Bb]/g, "[").replace(/%5[Dd]/g, "]").replace(/#/g, "%23").replace(/\?/g, "%3F").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -364,81 +364,81 @@ function Qe(e, t) {
|
|
|
364
364
|
return e.pathname === t.pathname ? e.ext > t.ext ? -1 : 1 : e.pathname < t.pathname ? -1 : 1;
|
|
365
365
|
}
|
|
366
366
|
function Ke(e, t) {
|
|
367
|
-
const r = t.filter((l) => l.type === "layout").map((l) =>
|
|
367
|
+
const r = t.filter((l) => l.type === "layout").map((l) => Ve(e, l)).sort((l, f) => l.id < f.id ? -1 : 1), n = t.filter((l) => l.type === "route").map((l) => Ze(e, r, l)).sort(Qe), s = t.filter((l) => l.type === "entry").map((l) => et(e, l)).sort((l, f) => l.chunkFileName < f.chunkFileName ? -1 : 1), i = t.filter((l) => l.type === "service-worker").map((l) => tt(e, l)).sort((l, f) => l.chunkFileName < f.chunkFileName ? -1 : 1), o = t.filter((l) => l.type === "menu").map((l) => Be(e, l)).sort((l, f) => l.pathname < f.pathname ? -1 : 1);
|
|
368
368
|
let a = 0;
|
|
369
369
|
const u = /* @__PURE__ */ new Set(), c = (l) => {
|
|
370
370
|
for (const f of l) {
|
|
371
|
-
let
|
|
372
|
-
for (; u.has(
|
|
373
|
-
|
|
374
|
-
f.id =
|
|
371
|
+
let p = f.id;
|
|
372
|
+
for (; u.has(p); )
|
|
373
|
+
p = `${f.id}_${a++}`;
|
|
374
|
+
f.id = p, u.add(p);
|
|
375
375
|
}
|
|
376
376
|
};
|
|
377
377
|
return c(r), c(n), c(s), c(i), { layouts: r, routes: n, entries: s, menus: o, serviceWorkers: i };
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function Ve(e, t) {
|
|
380
380
|
let r = t.extlessName;
|
|
381
381
|
const n = t.filePath, s = t.dirPath;
|
|
382
382
|
let i, o;
|
|
383
|
-
return r.endsWith(
|
|
384
|
-
id:
|
|
383
|
+
return r.endsWith(Xe) ? (o = "top", r = r.slice(0, r.length - 1)) : o = "nested", r.startsWith(K) ? i = r.slice(K.length) : i = "", {
|
|
384
|
+
id: I(e.routesDir, n),
|
|
385
385
|
filePath: n,
|
|
386
386
|
dirPath: s,
|
|
387
387
|
layoutType: o,
|
|
388
388
|
layoutName: i
|
|
389
389
|
};
|
|
390
390
|
}
|
|
391
|
-
const
|
|
391
|
+
const Ye = "layout", K = Ye + "-", Xe = "!";
|
|
392
392
|
function Ze(e, t, r) {
|
|
393
393
|
const n = r.filePath, s = [], i = e.routesDir, { layoutName: o, layoutStop: a } = _e(r.extlessName);
|
|
394
|
-
let u =
|
|
394
|
+
let u = L(e, r.dirPath);
|
|
395
395
|
if (r.extlessName === "404" && (u += r.extlessName + ".html"), !a) {
|
|
396
|
-
let l =
|
|
397
|
-
const
|
|
398
|
-
for (let
|
|
399
|
-
let
|
|
400
|
-
if (
|
|
396
|
+
let l = v(R(n)), f = !1;
|
|
397
|
+
const p = o !== "";
|
|
398
|
+
for (let w = 0; w < 20; w++) {
|
|
399
|
+
let d;
|
|
400
|
+
if (p && !f ? (d = t.find((h) => h.dirPath === l && h.layoutName === o), d && (f = !0)) : d = t.find((h) => h.dirPath === l && h.layoutName === ""), d && (s.push(d), d.layoutType === "top") || l === i)
|
|
401
401
|
break;
|
|
402
|
-
l =
|
|
402
|
+
l = v(R(l));
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
return {
|
|
406
|
-
id:
|
|
406
|
+
id: I(e.routesDir, n, "Route"),
|
|
407
407
|
filePath: n,
|
|
408
408
|
pathname: u,
|
|
409
409
|
layouts: s.reverse(),
|
|
410
410
|
ext: r.ext,
|
|
411
|
-
...
|
|
411
|
+
...G(e.basePathname, u)
|
|
412
412
|
};
|
|
413
413
|
}
|
|
414
414
|
function et(e, t) {
|
|
415
|
-
const r =
|
|
415
|
+
const r = L(e, t.dirPath), n = r.slice(e.basePathname.length);
|
|
416
416
|
return {
|
|
417
|
-
id:
|
|
417
|
+
id: I(e.routesDir, t.filePath, "Route"),
|
|
418
418
|
filePath: t.filePath,
|
|
419
419
|
chunkFileName: n,
|
|
420
|
-
...
|
|
420
|
+
...G(e.basePathname, r)
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
423
|
function tt(e, t) {
|
|
424
|
-
const n =
|
|
424
|
+
const n = L(e, t.dirPath) + t.extlessName + ".js", s = n.slice(e.basePathname.length);
|
|
425
425
|
return {
|
|
426
|
-
id:
|
|
426
|
+
id: I(e.routesDir, t.filePath, "ServiceWorker"),
|
|
427
427
|
filePath: t.filePath,
|
|
428
428
|
chunkFileName: s,
|
|
429
|
-
...
|
|
429
|
+
...G(e.basePathname, n)
|
|
430
430
|
};
|
|
431
431
|
}
|
|
432
432
|
async function rt(e) {
|
|
433
433
|
const t = [];
|
|
434
|
-
return await ce(t,
|
|
434
|
+
return await ce(t, v(e), M(e)), t;
|
|
435
435
|
}
|
|
436
436
|
async function ce(e, t, r) {
|
|
437
|
-
const n = await
|
|
437
|
+
const n = await x.promises.readdir(t);
|
|
438
438
|
await Promise.all(
|
|
439
439
|
n.map(async (s) => {
|
|
440
|
-
const i =
|
|
441
|
-
if ((await
|
|
440
|
+
const i = v(j(t, s));
|
|
441
|
+
if ((await x.promises.stat(i)).isDirectory())
|
|
442
442
|
await ce(e, i, s);
|
|
443
443
|
else {
|
|
444
444
|
const a = le(s);
|
|
@@ -454,12 +454,12 @@ async function ce(e, t, r) {
|
|
|
454
454
|
);
|
|
455
455
|
}
|
|
456
456
|
async function nt(e) {
|
|
457
|
-
const t = e.serverPluginsDir, r = await
|
|
457
|
+
const t = e.serverPluginsDir, r = await x.promises.readdir(t), n = [];
|
|
458
458
|
return await Promise.all(
|
|
459
459
|
r.map(async (s) => {
|
|
460
|
-
const i =
|
|
461
|
-
(
|
|
462
|
-
id:
|
|
460
|
+
const i = v(j(t, s)), o = $(s), a = S(s);
|
|
461
|
+
(U(o) || ae(o)) && je(a) && n.push({
|
|
462
|
+
id: I(e.serverPluginsDir, i, "Plugin"),
|
|
463
463
|
filePath: i,
|
|
464
464
|
ext: o
|
|
465
465
|
});
|
|
@@ -507,31 +507,31 @@ function it(e, t) {
|
|
|
507
507
|
}), t.routes = r;
|
|
508
508
|
}
|
|
509
509
|
function ot(e, t, r) {
|
|
510
|
-
const n = (
|
|
511
|
-
|
|
510
|
+
const n = (k) => (t.paths || {})[k] ?? k, s = t.prefix ? "/" + t.prefix : "", i = t.prefix ? t.prefix + "/" : "", o = t.prefix?.toUpperCase().replace(/-/g, ""), a = t.prefix ? [t.prefix] : [], c = e.pathname.split("/").map(n), f = e.routeName.split("/").map(n), p = e.pattern.toString().split("\\/"), [w, ...d] = p.map(n), m = [
|
|
511
|
+
w,
|
|
512
512
|
...a,
|
|
513
|
-
...
|
|
514
|
-
].join("\\/"),
|
|
513
|
+
...d
|
|
514
|
+
].join("\\/"), g = m.substring(
|
|
515
515
|
1,
|
|
516
|
-
e.pathname === "/" ?
|
|
517
|
-
),
|
|
518
|
-
(
|
|
516
|
+
e.pathname === "/" ? m.length - 1 : m.length - 2
|
|
517
|
+
), b = e.segments.map(
|
|
518
|
+
(k) => k.map((A) => ({ ...A, content: n(A.content) }))
|
|
519
519
|
);
|
|
520
|
-
t.prefix &&
|
|
520
|
+
t.prefix && b.splice(0, 0, [
|
|
521
521
|
{
|
|
522
522
|
content: t.prefix,
|
|
523
523
|
dynamic: !1,
|
|
524
524
|
rest: !1
|
|
525
525
|
}
|
|
526
526
|
]);
|
|
527
|
-
const
|
|
527
|
+
const P = c.join("/"), y = f.join("/");
|
|
528
528
|
return {
|
|
529
529
|
...e,
|
|
530
530
|
id: e.id + (o || r),
|
|
531
|
-
pathname: s +
|
|
532
|
-
routeName: i + (
|
|
533
|
-
pattern: new RegExp(
|
|
534
|
-
segments:
|
|
531
|
+
pathname: s + P,
|
|
532
|
+
routeName: i + (y !== "/" ? y : ""),
|
|
533
|
+
pattern: new RegExp(g),
|
|
534
|
+
segments: b
|
|
535
535
|
};
|
|
536
536
|
}
|
|
537
537
|
function at(e) {
|
|
@@ -554,7 +554,7 @@ ${n.map((s) => ` - ${s.filePath}`).join(`
|
|
|
554
554
|
}
|
|
555
555
|
function ut(e, t, r, n, s) {
|
|
556
556
|
return {
|
|
557
|
-
rootDir:
|
|
557
|
+
rootDir: v(e),
|
|
558
558
|
opts: ct(e, t, r),
|
|
559
559
|
routes: [],
|
|
560
560
|
serverPlugins: [],
|
|
@@ -578,7 +578,7 @@ function ct(e, t, r) {
|
|
|
578
578
|
"warning: vite's config.base must begin and end with /. This will be an error in v2. If you have a valid use case, please open an issue."
|
|
579
579
|
), t.endsWith("/") || (t += "/"));
|
|
580
580
|
const n = { ...r };
|
|
581
|
-
typeof n.routesDir != "string" ? n.routesDir =
|
|
581
|
+
typeof n.routesDir != "string" ? n.routesDir = T(e, "src", "routes") : q(n.routesDir) || (n.routesDir = T(e, n.routesDir)), n.routesDir = v(n.routesDir), typeof n.serverPluginsDir != "string" ? n.serverPluginsDir = n.routesDir : q(n.serverPluginsDir) || (n.serverPluginsDir = T(e, n.serverPluginsDir)), n.serverPluginsDir = v(n.serverPluginsDir), typeof n.baseUrl == "string" && (n.basePathname = n.baseUrl), typeof n.basePathname != "string" && (n.basePathname = t), n.basePathname.endsWith("/") || (console.error(
|
|
582
582
|
"Warning: qwik-router plugin basePathname must end with /. This will be an error in v2"
|
|
583
583
|
), n.basePathname += "/");
|
|
584
584
|
const s = new URL(n.basePathname, "https://qwik.dev/");
|
|
@@ -587,17 +587,17 @@ function ct(e, t, r) {
|
|
|
587
587
|
function ft(e) {
|
|
588
588
|
return (t, r) => {
|
|
589
589
|
const n = {};
|
|
590
|
-
|
|
591
|
-
const i =
|
|
590
|
+
E(t, "yaml", (s) => {
|
|
591
|
+
const i = dt(s.value);
|
|
592
592
|
for (const o in i)
|
|
593
593
|
n[o] = i[o];
|
|
594
|
-
}), Object.keys(n).length > 0 && e.frontmatter.set(
|
|
594
|
+
}), Object.keys(n).length > 0 && e.frontmatter.set(v(r.path), n);
|
|
595
595
|
};
|
|
596
596
|
}
|
|
597
|
-
function
|
|
597
|
+
function dt(e) {
|
|
598
598
|
return typeof e == "string" && (e = e.trim(), e !== "") ? Pe(e) : null;
|
|
599
599
|
}
|
|
600
|
-
const
|
|
600
|
+
const ht = {
|
|
601
601
|
author: !0,
|
|
602
602
|
creator: !0,
|
|
603
603
|
"color-scheme": !0,
|
|
@@ -640,7 +640,7 @@ function pt(e) {
|
|
|
640
640
|
content: a?.toString()
|
|
641
641
|
});
|
|
642
642
|
}
|
|
643
|
-
} else
|
|
643
|
+
} else ht[n] ? r.meta.push({
|
|
644
644
|
name: n,
|
|
645
645
|
content: s.toString()
|
|
646
646
|
}) : r.frontmatter[n] = s;
|
|
@@ -653,30 +653,30 @@ function pt(e) {
|
|
|
653
653
|
function mt() {
|
|
654
654
|
return (e) => {
|
|
655
655
|
const t = e, r = new xe();
|
|
656
|
-
|
|
656
|
+
E(t, "element", (n) => {
|
|
657
657
|
if (te(n) && n.properties) {
|
|
658
|
-
const i =
|
|
659
|
-
|
|
658
|
+
const i = B(n);
|
|
659
|
+
de(n, "id") || (n.properties.id = r.slug(i));
|
|
660
660
|
}
|
|
661
661
|
});
|
|
662
662
|
};
|
|
663
663
|
}
|
|
664
664
|
function gt(e) {
|
|
665
665
|
return (t, r) => {
|
|
666
|
-
const n = t, s =
|
|
666
|
+
const n = t, s = v(r.path);
|
|
667
667
|
vt(n, e.opts, s), bt(e, n, s), Pt(e, n, s), xt(n);
|
|
668
668
|
};
|
|
669
669
|
}
|
|
670
670
|
function yt() {
|
|
671
671
|
return (e) => {
|
|
672
|
-
|
|
672
|
+
E(e, "element", (r) => {
|
|
673
673
|
r.properties && r.properties.className && (r.properties.class = r.properties.className, r.properties.className = void 0);
|
|
674
674
|
});
|
|
675
675
|
};
|
|
676
676
|
}
|
|
677
677
|
function wt() {
|
|
678
678
|
return (e) => {
|
|
679
|
-
|
|
679
|
+
E(e, "element", (r) => {
|
|
680
680
|
if (r.tagName === "table" && !r.done) {
|
|
681
681
|
const n = { ...r };
|
|
682
682
|
n.done = !0, r.tagName = "div", r.properties = { className: "table-wrapper" }, r.children = [n];
|
|
@@ -685,12 +685,12 @@ function wt() {
|
|
|
685
685
|
};
|
|
686
686
|
}
|
|
687
687
|
function vt(e, t, r) {
|
|
688
|
-
|
|
688
|
+
E(e, "element", (n) => {
|
|
689
689
|
if ((n && n.type === "element" && n.tagName.toLowerCase()) === "a") {
|
|
690
690
|
const i = (n.properties && n.properties.href || "").trim();
|
|
691
691
|
if (se(i)) {
|
|
692
|
-
const o =
|
|
693
|
-
|
|
692
|
+
const o = $(i);
|
|
693
|
+
J(o) && (n.properties.href = C(
|
|
694
694
|
t,
|
|
695
695
|
r,
|
|
696
696
|
n.properties.href,
|
|
@@ -702,27 +702,27 @@ function vt(e, t, r) {
|
|
|
702
702
|
}
|
|
703
703
|
function bt(e, t, r) {
|
|
704
704
|
const n = e.frontmatter.get(r);
|
|
705
|
-
|
|
705
|
+
z(t, "frontmatter", n);
|
|
706
706
|
}
|
|
707
707
|
function Pt(e, t, r) {
|
|
708
708
|
const n = e.frontmatter.get(r), s = pt(n);
|
|
709
|
-
s &&
|
|
709
|
+
s && z(t, "head", s);
|
|
710
710
|
}
|
|
711
711
|
function xt(e) {
|
|
712
712
|
const t = [];
|
|
713
|
-
|
|
713
|
+
E(e, "element", (r) => {
|
|
714
714
|
const n = te(r);
|
|
715
|
-
if (n && r.properties &&
|
|
716
|
-
const s =
|
|
715
|
+
if (n && r.properties && de(r, "id")) {
|
|
716
|
+
const s = B(r);
|
|
717
717
|
t.push({
|
|
718
718
|
text: s,
|
|
719
719
|
id: r.properties.id,
|
|
720
720
|
level: n
|
|
721
721
|
});
|
|
722
722
|
}
|
|
723
|
-
}), t.length > 0 &&
|
|
723
|
+
}), t.length > 0 && z(e, "headings", t);
|
|
724
724
|
}
|
|
725
|
-
function
|
|
725
|
+
function z(e, t, r) {
|
|
726
726
|
const n = {
|
|
727
727
|
type: "mdxjsEsm",
|
|
728
728
|
value: "",
|
|
@@ -755,17 +755,17 @@ function J(e, t, r) {
|
|
|
755
755
|
e.children.unshift(n);
|
|
756
756
|
}
|
|
757
757
|
const St = {}.hasOwnProperty;
|
|
758
|
-
function
|
|
758
|
+
function de(e, t) {
|
|
759
759
|
const r = e && typeof e == "object" && e.type === "element" && e.properties && St.call(e.properties, t) && e.properties[t];
|
|
760
760
|
return r != null && r !== !1;
|
|
761
761
|
}
|
|
762
762
|
function kt() {
|
|
763
|
-
return
|
|
764
|
-
|
|
763
|
+
return F.register(ke), async (e) => {
|
|
764
|
+
E(e, "element", (t, r, n) => {
|
|
765
765
|
if (!(!n || n.tagName !== "pre" || t.tagName !== "code" || !Array.isArray(t.properties.className)))
|
|
766
766
|
for (let s = 0; s < t.properties.className.length; s++) {
|
|
767
767
|
const i = t.properties.className[s], o = It(i);
|
|
768
|
-
if (o &&
|
|
768
|
+
if (o && F.registered(o)) {
|
|
769
769
|
t.properties.className[s] = "language-" + o, Et(t, o);
|
|
770
770
|
return;
|
|
771
771
|
}
|
|
@@ -774,7 +774,7 @@ function kt() {
|
|
|
774
774
|
};
|
|
775
775
|
}
|
|
776
776
|
function Et(e, t) {
|
|
777
|
-
const r =
|
|
777
|
+
const r = B(e), n = F.highlight(r, t);
|
|
778
778
|
n && Array.isArray(e.children) && (e.children = n.children);
|
|
779
779
|
}
|
|
780
780
|
function It(e) {
|
|
@@ -785,7 +785,7 @@ async function Nt(e) {
|
|
|
785
785
|
(typeof c?.remarkGfm > "u" || c.remarkGfm) && l.push(n);
|
|
786
786
|
const f = [];
|
|
787
787
|
(typeof c?.rehypeSyntaxHighlight > "u" || c.rehypeSyntaxHighlight) && f.push(kt), (typeof c?.rehypeAutolinkHeadings > "u" || c.rehypeAutolinkHeadings) && f.push(s);
|
|
788
|
-
const
|
|
788
|
+
const p = {
|
|
789
789
|
SourceMapGenerator: be,
|
|
790
790
|
jsxImportSource: "@qwik.dev/core",
|
|
791
791
|
...o,
|
|
@@ -805,25 +805,25 @@ async function Nt(e) {
|
|
|
805
805
|
wt
|
|
806
806
|
]
|
|
807
807
|
};
|
|
808
|
-
return async function(
|
|
809
|
-
const
|
|
810
|
-
if ([".mdx", ".md", ".markdown"].includes(
|
|
811
|
-
const
|
|
812
|
-
`,
|
|
808
|
+
return async function(w, d) {
|
|
809
|
+
const h = $(d);
|
|
810
|
+
if ([".mdx", ".md", ".markdown"].includes(h)) {
|
|
811
|
+
const m = new i({ value: w, path: d }), g = await t(m, p), b = String(g.value), P = `import { jsx } from '@qwik.dev/core';
|
|
812
|
+
`, y = `
|
|
813
813
|
function _missingMdxReference(id, component, place) {
|
|
814
|
-
throw new Error("${
|
|
814
|
+
throw new Error("${d}: Expected " + (component ? "component" : "object") + " \`" + id + "\` to be defined: you likely forgot to import, pass, or provide it." + (place ? "\\nIt’s referenced in your code at \`" + place + "\`" : ""));
|
|
815
815
|
}
|
|
816
816
|
const WrappedMdxContent = () => {
|
|
817
817
|
const content = _createMdxContent({});
|
|
818
818
|
return typeof MDXLayout === 'function' ? jsx(MDXLayout, {children: content}) : content;
|
|
819
819
|
};
|
|
820
820
|
export default WrappedMdxContent;
|
|
821
|
-
`,
|
|
822
|
-
if (
|
|
821
|
+
`, _ = b.lastIndexOf("export default ");
|
|
822
|
+
if (_ === -1)
|
|
823
823
|
throw new Error("Could not find default export in mdx output");
|
|
824
824
|
return {
|
|
825
|
-
code:
|
|
826
|
-
map:
|
|
825
|
+
code: P + b.slice(0, _) + y,
|
|
826
|
+
map: g.map
|
|
827
827
|
};
|
|
828
828
|
}
|
|
829
829
|
};
|
|
@@ -846,7 +846,7 @@ function $t(e) {
|
|
|
846
846
|
`) + `
|
|
847
847
|
`;
|
|
848
848
|
}
|
|
849
|
-
function
|
|
849
|
+
function W(e) {
|
|
850
850
|
const t = e.toLowerCase();
|
|
851
851
|
return t.endsWith(".tsx") || t.endsWith(".jsx") ? e.slice(0, e.length - 4) : t.endsWith(".ts") ? e.slice(0, e.length - 3) : e;
|
|
852
852
|
}
|
|
@@ -855,11 +855,11 @@ function _t(e, t, r, n) {
|
|
|
855
855
|
/** Qwik Router Menus (${e.menus.length}) */`), t.push("export const menus = [");
|
|
856
856
|
const s = !n, i = e.opts.routesDir;
|
|
857
857
|
for (const o of e.menus) {
|
|
858
|
-
const a = JSON.stringify(
|
|
858
|
+
const a = JSON.stringify(W(o.filePath));
|
|
859
859
|
if (s)
|
|
860
860
|
t.push(` [${JSON.stringify(o.pathname)}, ()=>import(${a})],`);
|
|
861
861
|
else {
|
|
862
|
-
const u =
|
|
862
|
+
const u = I(i, o.filePath);
|
|
863
863
|
r.push(`import * as ${u} from ${a};`), t.push(` [${JSON.stringify(o.pathname)}, ()=>${u}],`);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
@@ -871,7 +871,7 @@ function Dt(e, t, r, n, s) {
|
|
|
871
871
|
r.push(`
|
|
872
872
|
/** Qwik Router Layouts (${e.layouts.length}) */`);
|
|
873
873
|
for (const a of e.layouts) {
|
|
874
|
-
const u = JSON.stringify(
|
|
874
|
+
const u = JSON.stringify(W(a.filePath));
|
|
875
875
|
o ? r.push(`const ${a.id} = ()=>import(${u});`) : (n.push(`import * as ${a.id}_ from ${u};`), r.push(`const ${a.id} = ()=>${a.id}_;`));
|
|
876
876
|
}
|
|
877
877
|
}
|
|
@@ -882,10 +882,10 @@ function Dt(e, t, r, n, s) {
|
|
|
882
882
|
if (Ce(a.ext)) {
|
|
883
883
|
for (const l of a.layouts)
|
|
884
884
|
u.push(l.id);
|
|
885
|
-
const c =
|
|
885
|
+
const c = W(a.filePath);
|
|
886
886
|
o ? u.push(`()=>import(${JSON.stringify(c)})`) : (n.push(`import * as ${a.id} from ${JSON.stringify(c)};`), u.push(`()=>${a.id}`));
|
|
887
|
-
} else if (i &&
|
|
888
|
-
const c =
|
|
887
|
+
} else if (i && U(a.ext)) {
|
|
888
|
+
const c = W(a.filePath);
|
|
889
889
|
n.push(`import * as ${a.id} from ${JSON.stringify(c)};`);
|
|
890
890
|
for (const l of a.layouts)
|
|
891
891
|
u.push(l.id);
|
|
@@ -907,12 +907,12 @@ function Tt(e, t) {
|
|
|
907
907
|
const r = [], n = e.api.getManifest();
|
|
908
908
|
if (n) {
|
|
909
909
|
const s = Object.keys(n.bundles), i = (o) => {
|
|
910
|
-
o =
|
|
910
|
+
o = S(o);
|
|
911
911
|
for (const a of s) {
|
|
912
912
|
const u = n.bundles[a];
|
|
913
913
|
if (u.origins)
|
|
914
914
|
for (const c of u.origins) {
|
|
915
|
-
const l =
|
|
915
|
+
const l = S(c);
|
|
916
916
|
o.endsWith(l) && (r.includes(a) || r.push(a));
|
|
917
917
|
}
|
|
918
918
|
}
|
|
@@ -927,7 +927,7 @@ function Wt(e, t, r, n, s) {
|
|
|
927
927
|
if (r.push(`
|
|
928
928
|
/** Qwik Router ServerPlugins (${e.serverPlugins.length}) */`), r.push("export const serverPlugins = ["), s) {
|
|
929
929
|
for (const i of e.serverPlugins) {
|
|
930
|
-
const o = JSON.stringify(
|
|
930
|
+
const o = JSON.stringify(W(i.filePath));
|
|
931
931
|
n.push(`import * as ${i.id} from ${o};`);
|
|
932
932
|
}
|
|
933
933
|
for (const i of e.serverPlugins)
|
|
@@ -964,14 +964,14 @@ const Ct = `
|
|
|
964
964
|
function Mt(e, t) {
|
|
965
965
|
const r = {};
|
|
966
966
|
e.forEach((n) => {
|
|
967
|
-
const s =
|
|
967
|
+
const s = S(n.filePath), i = n.layouts ? n.layouts.map((u) => S(u.filePath)) : [], o = [s, ...i], a = [];
|
|
968
968
|
for (const [u, c] of Object.entries(t.bundles))
|
|
969
969
|
Lt(c, o) && a.push(u);
|
|
970
970
|
a.length > 0 && (r[n.routeName] = { dynamicImports: a });
|
|
971
971
|
});
|
|
972
972
|
for (const n of Object.keys(t.bundles)) {
|
|
973
973
|
const s = t.bundles[n];
|
|
974
|
-
if (s.origins?.some((i) => i.endsWith(
|
|
974
|
+
if (s.origins?.some((i) => i.endsWith(N))) {
|
|
975
975
|
r[n] = {
|
|
976
976
|
...s,
|
|
977
977
|
dynamicImports: s.dynamicImports?.filter(
|
|
@@ -987,7 +987,7 @@ function Lt(e, t) {
|
|
|
987
987
|
if (!e.origins)
|
|
988
988
|
return !1;
|
|
989
989
|
for (const r of e.origins) {
|
|
990
|
-
const n =
|
|
990
|
+
const n = S(r);
|
|
991
991
|
return t.some((s) => s.endsWith(n));
|
|
992
992
|
}
|
|
993
993
|
}
|
|
@@ -1001,7 +1001,7 @@ const Ht = (e) => {
|
|
|
1001
1001
|
if (/^\s+at/.test(s)) {
|
|
1002
1002
|
const i = s.indexOf("/"), o = s.lastIndexOf(")", i);
|
|
1003
1003
|
if (i > 0) {
|
|
1004
|
-
const u = s.slice(i, o).split(":"), c =
|
|
1004
|
+
const u = s.slice(i, o).split(":"), c = V(u[u.length - 1]), l = V(u[u.length - 2]);
|
|
1005
1005
|
return typeof c == "number" && typeof l == "number" ? (u.length -= 2, {
|
|
1006
1006
|
file: u.join(":"),
|
|
1007
1007
|
line: l,
|
|
@@ -1019,19 +1019,19 @@ const Ht = (e) => {
|
|
|
1019
1019
|
}
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
1022
|
-
},
|
|
1022
|
+
}, V = (e) => {
|
|
1023
1023
|
try {
|
|
1024
1024
|
return parseInt(e, 10);
|
|
1025
1025
|
} catch {
|
|
1026
1026
|
return;
|
|
1027
1027
|
}
|
|
1028
|
-
},
|
|
1028
|
+
}, he = /\r?\n/, Y = 2;
|
|
1029
1029
|
function qt(e, t) {
|
|
1030
1030
|
if (typeof t == "number")
|
|
1031
1031
|
return t;
|
|
1032
1032
|
if (t.lo != null)
|
|
1033
1033
|
return t.lo;
|
|
1034
|
-
const r = e.split(
|
|
1034
|
+
const r = e.split(he), { line: n, column: s } = t;
|
|
1035
1035
|
let i = 0;
|
|
1036
1036
|
for (let o = 0; o < n - 1 && o < r.length; o++)
|
|
1037
1037
|
i += r[o].length + 1;
|
|
@@ -1039,7 +1039,7 @@ function qt(e, t) {
|
|
|
1039
1039
|
}
|
|
1040
1040
|
function Ft(e, t = 0, r) {
|
|
1041
1041
|
t = qt(e, t), r = r || t;
|
|
1042
|
-
const n = e.split(
|
|
1042
|
+
const n = e.split(he);
|
|
1043
1043
|
let s = 0;
|
|
1044
1044
|
const i = [];
|
|
1045
1045
|
for (let o = 0; o < n.length; o++)
|
|
@@ -1122,9 +1122,9 @@ function Bt(e) {
|
|
|
1122
1122
|
order: "pre",
|
|
1123
1123
|
handler: async (r) => {
|
|
1124
1124
|
const { params: n, pathId: s } = X(r);
|
|
1125
|
-
if (
|
|
1125
|
+
if (Q.extname(s).toLowerCase() === ".svg" && n.has("jsx"))
|
|
1126
1126
|
return {
|
|
1127
|
-
code: await
|
|
1127
|
+
code: await x.promises.readFile(s, "utf-8"),
|
|
1128
1128
|
moduleSideEffects: !1
|
|
1129
1129
|
};
|
|
1130
1130
|
}
|
|
@@ -1133,7 +1133,7 @@ function Bt(e) {
|
|
|
1133
1133
|
n = n.toLowerCase();
|
|
1134
1134
|
const { params: s, pathId: i } = X(n);
|
|
1135
1135
|
if (s.has("jsx")) {
|
|
1136
|
-
const o =
|
|
1136
|
+
const o = Q.extname(i).toLowerCase();
|
|
1137
1137
|
if (t.includes(o)) {
|
|
1138
1138
|
r.includes("srcSet") || this.error(`Image '${n}' could not be optimized to JSX`);
|
|
1139
1139
|
const a = r.indexOf("export default");
|
|
@@ -1205,12 +1205,12 @@ function Ut({ code: e, path: t }, r) {
|
|
|
1205
1205
|
async function Jt(e) {
|
|
1206
1206
|
if (typeof e.routesDir != "string")
|
|
1207
1207
|
throw new Error('qwikRouter plugin "routesDir" option missing');
|
|
1208
|
-
if (!
|
|
1208
|
+
if (!q(e.routesDir))
|
|
1209
1209
|
throw new Error(
|
|
1210
1210
|
`qwikRouter plugin "routesDir" option must be an absolute path: ${e.routesDir}`
|
|
1211
1211
|
);
|
|
1212
1212
|
try {
|
|
1213
|
-
if (!(await
|
|
1213
|
+
if (!(await x.promises.stat(e.routesDir)).isDirectory())
|
|
1214
1214
|
throw new Error(
|
|
1215
1215
|
`qwikRouter plugin "routesDir" option must be a directory: ${e.routesDir}`
|
|
1216
1216
|
);
|
|
@@ -1223,9 +1223,9 @@ function Gt(e) {
|
|
|
1223
1223
|
const t = e;
|
|
1224
1224
|
let r = t.loc;
|
|
1225
1225
|
if (!t.frame && !t.plugin && (r || (r = Ht(t)), r && (t.loc = r, r.file))) {
|
|
1226
|
-
t.id =
|
|
1226
|
+
t.id = v(t.loc.file);
|
|
1227
1227
|
try {
|
|
1228
|
-
const n =
|
|
1228
|
+
const n = x.readFileSync(t.loc.file, "utf-8");
|
|
1229
1229
|
t.frame = Ft(n, t.loc);
|
|
1230
1230
|
} catch {
|
|
1231
1231
|
}
|
|
@@ -1256,7 +1256,7 @@ class zt {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
return this.origSetHeader(s, i);
|
|
1258
1258
|
}, this.response.writeHead = (s, i, o) => {
|
|
1259
|
-
if (o && typeof o == "object") {
|
|
1259
|
+
if (typeof i == "object" && i !== null && (o = i, i = void 0), o && typeof o == "object") {
|
|
1260
1260
|
for (const [a, u] of Object.entries(o))
|
|
1261
1261
|
if (a.toLowerCase() === "content-type") {
|
|
1262
1262
|
const c = String(u).toLowerCase();
|
|
@@ -1309,7 +1309,7 @@ class zt {
|
|
|
1309
1309
|
), n = r.indexOf("[FAKE_HEAD]"), s = r.indexOf("</head>", n);
|
|
1310
1310
|
if (n === -1 || s === -1)
|
|
1311
1311
|
throw new Error("Transformed HTML does not contain [FAKE_HEAD]...</head>");
|
|
1312
|
-
const i = r.slice(12, n), o = r.slice(
|
|
1312
|
+
const i = r.slice(12, n).trim(), o = r.slice(
|
|
1313
1313
|
n + 11,
|
|
1314
1314
|
s
|
|
1315
1315
|
), a = r.indexOf("<body>", s), u = r.indexOf("[FAKE_BODY]", a), c = r.indexOf("</body>", u);
|
|
@@ -1379,32 +1379,33 @@ const Kt = (e, t) => async (r, n, s) => {
|
|
|
1379
1379
|
);
|
|
1380
1380
|
return;
|
|
1381
1381
|
}
|
|
1382
|
+
globalThis.__qwik = void 0;
|
|
1382
1383
|
const { createQwikRouter: u } = await e.ssrLoadModule(
|
|
1383
1384
|
"@qwik.dev/router/middleware/node"
|
|
1384
1385
|
);
|
|
1385
1386
|
try {
|
|
1386
|
-
const c = (async (
|
|
1387
|
-
f(r,
|
|
1388
|
-
l(r,
|
|
1389
|
-
|
|
1387
|
+
const c = (async (d) => await o(d)), { router: l, staticFile: f, notFound: p } = u({ render: c }), w = Qt(r, n, e);
|
|
1388
|
+
f(r, w, () => {
|
|
1389
|
+
l(r, w, () => {
|
|
1390
|
+
p(r, w, s);
|
|
1390
1391
|
});
|
|
1391
1392
|
});
|
|
1392
1393
|
} catch (c) {
|
|
1393
1394
|
c instanceof Error && (e.ssrFixStacktrace(c), Gt(c)), s(c);
|
|
1394
1395
|
return;
|
|
1395
1396
|
}
|
|
1396
|
-
},
|
|
1397
|
+
}, Vt = [".css", ".scss", ".sass", ".less", ".styl", ".stylus"], Yt = /\.[mc]?[tj]sx?$/, Z = (e) => Vt.some((t) => e.endsWith(t)), Xt = (e) => {
|
|
1397
1398
|
const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
1398
1399
|
return Array.from(e.moduleGraph.fileToModulesMap.entries()).forEach(([n, s]) => {
|
|
1399
1400
|
s.forEach((i) => {
|
|
1400
1401
|
const [o, a] = i.url.split("?");
|
|
1401
|
-
if (!a &&
|
|
1402
|
+
if (!a && Z(o)) {
|
|
1402
1403
|
const u = i.importers.size === 0, c = Array.from(i.importers).some((f) => {
|
|
1403
|
-
const
|
|
1404
|
-
return
|
|
1404
|
+
const p = f.url || f.file, w = p && Z(p);
|
|
1405
|
+
return w && i.url && r.add(i.url), w;
|
|
1405
1406
|
}), l = Array.from(i.importers).some((f) => {
|
|
1406
|
-
const
|
|
1407
|
-
return
|
|
1407
|
+
const p = f.url || f.file;
|
|
1408
|
+
return p && Yt.test(p);
|
|
1408
1409
|
});
|
|
1409
1410
|
(u || l) && !c && !r.has(i.url) && t.add(i);
|
|
1410
1411
|
}
|
|
@@ -1412,10 +1413,10 @@ const Kt = (e, t) => async (r, n, s) => {
|
|
|
1412
1413
|
}), [...t].map(
|
|
1413
1414
|
({ url: n, lastHMRTimestamp: s }) => `${n}${s ? `?t=${s}` : ""}`
|
|
1414
1415
|
);
|
|
1415
|
-
}, Zt = (e) =>
|
|
1416
|
+
}, Zt = (e) => Xt(e).map((r) => ({
|
|
1416
1417
|
tag: "link",
|
|
1417
1418
|
attrs: { rel: "stylesheet", href: r }
|
|
1418
|
-
})),
|
|
1419
|
+
})), N = "@qwik-router-config", D = "@qwik-router-entries", H = "@qwik.dev/router", O = "@qwik-router-sw-register";
|
|
1419
1420
|
function wr(e) {
|
|
1420
1421
|
return er(e);
|
|
1421
1422
|
}
|
|
@@ -1424,6 +1425,7 @@ function er(e) {
|
|
|
1424
1425
|
}
|
|
1425
1426
|
function tr(e) {
|
|
1426
1427
|
let t = null, r = null, n = null, s, i = "esm", o = null, a, u = null, c = e?.devSsrServer;
|
|
1428
|
+
const l = e?.routesDir ?? "src/routes", f = e?.serverPluginsDir ?? l;
|
|
1427
1429
|
return {
|
|
1428
1430
|
name: "vite-plugin-qwik-router",
|
|
1429
1431
|
enforce: "pre",
|
|
@@ -1432,8 +1434,8 @@ function tr(e) {
|
|
|
1432
1434
|
getRoutes: () => t?.routes.slice() ?? [],
|
|
1433
1435
|
getServiceWorkers: () => t?.serviceWorkers.slice() ?? []
|
|
1434
1436
|
},
|
|
1435
|
-
async config(
|
|
1436
|
-
return a =
|
|
1437
|
+
async config(d, h) {
|
|
1438
|
+
return a = h.command, {
|
|
1437
1439
|
define: {
|
|
1438
1440
|
"globalThis.__DEFAULT_LOADERS_SERIALIZATION_STRATEGY__": JSON.stringify(
|
|
1439
1441
|
e?.defaultLoadersSerializationStrategy || "never"
|
|
@@ -1442,29 +1444,37 @@ function tr(e) {
|
|
|
1442
1444
|
},
|
|
1443
1445
|
appType: "custom",
|
|
1444
1446
|
resolve: {
|
|
1447
|
+
dedupe: [H, "@builder.io/qwik-city"],
|
|
1445
1448
|
alias: [
|
|
1446
1449
|
{ find: "@builder.io/qwik-city", replacement: "@qwik.dev/router" },
|
|
1447
1450
|
{ find: /^@builder\.io\/qwik-city\/(.*)/, replacement: "@qwik.dev/router/$1" },
|
|
1448
|
-
{ find: "@qwik-city-plan", replacement:
|
|
1449
|
-
{ find: "@qwik-city-entries", replacement:
|
|
1450
|
-
{ find: "@qwik-city-sw-register", replacement:
|
|
1451
|
+
{ find: "@qwik-city-plan", replacement: N },
|
|
1452
|
+
{ find: "@qwik-city-entries", replacement: D },
|
|
1453
|
+
{ find: "@qwik-city-sw-register", replacement: O }
|
|
1451
1454
|
]
|
|
1452
1455
|
},
|
|
1453
1456
|
optimizeDeps: {
|
|
1457
|
+
// Let Vite find all app deps, these are not part of the static imports from `src/root`
|
|
1458
|
+
entries: [
|
|
1459
|
+
`${l}/**/index*`,
|
|
1460
|
+
`${l}/**/layout*`,
|
|
1461
|
+
`${f}/plugin@*`
|
|
1462
|
+
],
|
|
1463
|
+
// These need processing by the optimizer during dev
|
|
1454
1464
|
exclude: [
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1465
|
+
H,
|
|
1466
|
+
N,
|
|
1467
|
+
D,
|
|
1468
|
+
O
|
|
1459
1469
|
]
|
|
1460
1470
|
},
|
|
1461
1471
|
ssr: {
|
|
1462
1472
|
external: ["node:async_hooks"],
|
|
1463
1473
|
noExternal: [
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1474
|
+
H,
|
|
1475
|
+
N,
|
|
1476
|
+
D,
|
|
1477
|
+
O
|
|
1468
1478
|
]
|
|
1469
1479
|
},
|
|
1470
1480
|
server: {
|
|
@@ -1475,37 +1485,39 @@ function tr(e) {
|
|
|
1475
1485
|
}
|
|
1476
1486
|
};
|
|
1477
1487
|
},
|
|
1478
|
-
async configResolved(
|
|
1479
|
-
Object.assign(process.env, me(
|
|
1480
|
-
const
|
|
1488
|
+
async configResolved(d) {
|
|
1489
|
+
Object.assign(process.env, me(d.mode, process.cwd(), "")), n = T(d.root);
|
|
1490
|
+
const h = d.build?.ssr || d.mode === "ssr" ? "ssr" : "client";
|
|
1481
1491
|
if (t = ut(
|
|
1482
1492
|
n,
|
|
1483
|
-
|
|
1493
|
+
d.base,
|
|
1484
1494
|
e,
|
|
1485
|
-
|
|
1495
|
+
h,
|
|
1486
1496
|
!e?.staticImportRoutes
|
|
1487
|
-
), await Jt(t.opts), r = await Nt(t), s =
|
|
1497
|
+
), await Jt(t.opts), r = await Nt(t), s = d.plugins.find(
|
|
1498
|
+
(m) => m.name === "vite-plugin-qwik"
|
|
1499
|
+
), !s)
|
|
1488
1500
|
throw new Error("Missing vite-plugin-qwik");
|
|
1489
|
-
typeof c != "boolean" && (c = s.api._oldDevSsrServer()), s.api.registerBundleGraphAdder?.((
|
|
1501
|
+
typeof c != "boolean" && (c = s.api._oldDevSsrServer()), s.api.registerBundleGraphAdder?.((m) => Mt(t.routes, m)), d.ssr?.format === "cjs" && (i = "cjs"), o = d.build?.outDir;
|
|
1490
1502
|
},
|
|
1491
|
-
async configureServer(
|
|
1492
|
-
u =
|
|
1493
|
-
const
|
|
1503
|
+
async configureServer(d) {
|
|
1504
|
+
u = d;
|
|
1505
|
+
const h = T(
|
|
1494
1506
|
n,
|
|
1495
1507
|
"src/routes/**/{index,layout,entry,service-worker}{.,@,-}*"
|
|
1496
1508
|
);
|
|
1497
|
-
if (
|
|
1498
|
-
if (!/\/(index[.@]|layout[.-]|entry\.|service-worker\.)[^/]*$/.test(
|
|
1509
|
+
if (d.watcher.add(h), await new Promise((m) => setTimeout(m, 1e3)), d.watcher.on("change", (m) => {
|
|
1510
|
+
if (!/\/(index[.@]|layout[.-]|entry\.|service-worker\.)[^/]*$/.test(m))
|
|
1499
1511
|
return;
|
|
1500
1512
|
t.isDirty = !0;
|
|
1501
|
-
const g =
|
|
1513
|
+
const g = d.environments?.ssr?.moduleGraph;
|
|
1502
1514
|
if (g) {
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1515
|
+
const b = g.getModuleById("@qwik-router-config");
|
|
1516
|
+
b && g.invalidateModule(b);
|
|
1505
1517
|
}
|
|
1506
1518
|
}), e?.devSsrServer !== !1)
|
|
1507
1519
|
return () => {
|
|
1508
|
-
|
|
1520
|
+
d.middlewares.use(Kt(d, t));
|
|
1509
1521
|
};
|
|
1510
1522
|
},
|
|
1511
1523
|
transformIndexHtml() {
|
|
@@ -1515,72 +1527,72 @@ function tr(e) {
|
|
|
1515
1527
|
buildStart() {
|
|
1516
1528
|
lt(t);
|
|
1517
1529
|
},
|
|
1518
|
-
resolveId(
|
|
1519
|
-
return
|
|
1520
|
-
id:
|
|
1530
|
+
resolveId(d) {
|
|
1531
|
+
return d === N || d === D ? {
|
|
1532
|
+
id: d,
|
|
1521
1533
|
// user entries added in the routes, like src/routes/service-worker.ts
|
|
1522
1534
|
// are added as dynamic imports to the qwik-router-config as a way to create
|
|
1523
1535
|
// a new entry point for the build. Ensure these are not treeshaken.
|
|
1524
1536
|
moduleSideEffects: "no-treeshake"
|
|
1525
|
-
} :
|
|
1537
|
+
} : d === O ? d : null;
|
|
1526
1538
|
},
|
|
1527
|
-
async load(
|
|
1539
|
+
async load(d, h) {
|
|
1528
1540
|
if (t) {
|
|
1529
|
-
if (
|
|
1541
|
+
if (d.endsWith(D))
|
|
1530
1542
|
return $t(t);
|
|
1531
|
-
const
|
|
1532
|
-
if (
|
|
1533
|
-
if (t.isDirty && (await fe(t), t.isDirty = !1, t.diagnostics.forEach((
|
|
1534
|
-
this.warn(
|
|
1535
|
-
})),
|
|
1536
|
-
return jt(t, s,
|
|
1543
|
+
const m = d.endsWith(N), g = d.endsWith(O);
|
|
1544
|
+
if (m || g) {
|
|
1545
|
+
if (t.isDirty && (await fe(t), t.isDirty = !1, t.diagnostics.forEach((b) => {
|
|
1546
|
+
this.warn(b.message);
|
|
1547
|
+
})), m)
|
|
1548
|
+
return jt(t, s, h?.ssr ?? !1);
|
|
1537
1549
|
if (g)
|
|
1538
1550
|
return At(t, Ie);
|
|
1539
1551
|
}
|
|
1540
1552
|
}
|
|
1541
1553
|
return null;
|
|
1542
1554
|
},
|
|
1543
|
-
async transform(
|
|
1544
|
-
if (
|
|
1555
|
+
async transform(d, h) {
|
|
1556
|
+
if (h.startsWith("\0"))
|
|
1545
1557
|
return;
|
|
1546
|
-
const
|
|
1547
|
-
if (t && (
|
|
1548
|
-
const
|
|
1549
|
-
if (ue(
|
|
1550
|
-
return { code: await Ue(t.opts,
|
|
1558
|
+
const g = we(h).toLowerCase();
|
|
1559
|
+
if (t && (g === ".md" || g === ".mdx")) {
|
|
1560
|
+
const P = M(h);
|
|
1561
|
+
if (ue(P))
|
|
1562
|
+
return { code: await Ue(t.opts, h, d), map: null };
|
|
1551
1563
|
if (r)
|
|
1552
1564
|
try {
|
|
1553
|
-
return await r(
|
|
1554
|
-
} catch (
|
|
1555
|
-
if (
|
|
1556
|
-
const
|
|
1557
|
-
id:
|
|
1565
|
+
return await r(d, h);
|
|
1566
|
+
} catch (y) {
|
|
1567
|
+
if (y && typeof y == "object" && "position" in y && "reason" in y) {
|
|
1568
|
+
const _ = y.position?.start.column, k = y.position?.start.line, A = Object.assign(new Error(y.reason), {
|
|
1569
|
+
id: h,
|
|
1558
1570
|
plugin: "qwik-router-mdx",
|
|
1559
1571
|
loc: {
|
|
1560
|
-
column:
|
|
1561
|
-
line:
|
|
1572
|
+
column: _,
|
|
1573
|
+
line: k
|
|
1562
1574
|
},
|
|
1563
1575
|
stack: ""
|
|
1564
1576
|
});
|
|
1565
|
-
this.error(
|
|
1566
|
-
} else
|
|
1577
|
+
this.error(A);
|
|
1578
|
+
} else y instanceof Error ? this.error(y) : this.error(String(y));
|
|
1567
1579
|
}
|
|
1568
1580
|
}
|
|
1569
1581
|
return null;
|
|
1570
1582
|
},
|
|
1571
|
-
generateBundle(
|
|
1583
|
+
generateBundle(d, h) {
|
|
1572
1584
|
if (t?.target === "client") {
|
|
1573
|
-
const
|
|
1585
|
+
const m = [...t.entries, ...t.serviceWorkers].map((g) => ({
|
|
1574
1586
|
chunkFileName: g.chunkFileName,
|
|
1575
|
-
extensionlessFilePath:
|
|
1587
|
+
extensionlessFilePath: S(g.filePath)
|
|
1576
1588
|
}));
|
|
1577
|
-
for (const g of
|
|
1578
|
-
for (const
|
|
1579
|
-
const
|
|
1580
|
-
if (
|
|
1581
|
-
const
|
|
1582
|
-
if (g.extensionlessFilePath ===
|
|
1583
|
-
|
|
1589
|
+
for (const g of m)
|
|
1590
|
+
for (const b in h) {
|
|
1591
|
+
const P = h[b];
|
|
1592
|
+
if (P.type === "chunk" && P.isDynamicEntry && P.facadeModuleId) {
|
|
1593
|
+
const y = S(v(P.facadeModuleId));
|
|
1594
|
+
if (g.extensionlessFilePath === y) {
|
|
1595
|
+
P.fileName = g.chunkFileName;
|
|
1584
1596
|
continue;
|
|
1585
1597
|
}
|
|
1586
1598
|
}
|
|
@@ -1596,11 +1608,11 @@ function tr(e) {
|
|
|
1596
1608
|
};
|
|
1597
1609
|
}
|
|
1598
1610
|
async function rr(e, t) {
|
|
1599
|
-
await
|
|
1600
|
-
const r =
|
|
1611
|
+
await x.promises.mkdir(e, { recursive: !0 });
|
|
1612
|
+
const r = j(e, "package.json");
|
|
1601
1613
|
let n = {};
|
|
1602
|
-
if (
|
|
1603
|
-
const i = await
|
|
1614
|
+
if (x.existsSync(r)) {
|
|
1615
|
+
const i = await x.promises.readFile(r, "utf-8");
|
|
1604
1616
|
n = {
|
|
1605
1617
|
...JSON.parse(i)
|
|
1606
1618
|
};
|
|
@@ -1610,7 +1622,7 @@ async function rr(e, t) {
|
|
|
1610
1622
|
type: t == "cjs" ? "commonjs" : "module"
|
|
1611
1623
|
};
|
|
1612
1624
|
const s = JSON.stringify(n, null, 2);
|
|
1613
|
-
await
|
|
1625
|
+
await x.promises.writeFile(r, s);
|
|
1614
1626
|
}
|
|
1615
1627
|
export {
|
|
1616
1628
|
yr as extendConfig,
|