@qwik.dev/router 2.0.0-alpha.9 → 2.0.0-beta.1
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/README.md +1 -1
- package/lib/adapters/azure-swa/vite/index.cjs +3 -3
- package/lib/adapters/azure-swa/vite/index.d.ts +13 -13
- package/lib/adapters/bun-server/vite/index.cjs +3 -3
- package/lib/adapters/bun-server/vite/index.d.ts +14 -14
- package/lib/adapters/cloud-run/vite/index.cjs +3 -3
- package/lib/adapters/cloud-run/vite/index.d.ts +13 -13
- package/lib/adapters/cloudflare-pages/vite/index.cjs +3 -3
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +27 -27
- package/lib/adapters/deno-server/vite/index.cjs +3 -3
- package/lib/adapters/deno-server/vite/index.d.ts +14 -14
- package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
- package/lib/adapters/netlify-edge/vite/index.d.ts +44 -44
- package/lib/adapters/node-server/vite/index.cjs +3 -3
- package/lib/adapters/node-server/vite/index.d.ts +14 -14
- package/lib/adapters/shared/vite/index.cjs +10 -3
- package/lib/adapters/shared/vite/index.d.ts +114 -114
- package/lib/adapters/shared/vite/index.mjs +7 -0
- package/lib/adapters/static/vite/index.cjs +10 -3
- package/lib/adapters/static/vite/index.d.ts +10 -10
- package/lib/adapters/static/vite/index.mjs +7 -0
- package/lib/adapters/vercel-edge/vite/index.cjs +3 -3
- package/lib/adapters/vercel-edge/vite/index.d.ts +45 -45
- package/lib/index.d.ts +878 -810
- package/lib/index.qwik.cjs +110 -48
- package/lib/index.qwik.mjs +112 -50
- package/lib/middleware/aws-lambda/index.d.ts +48 -48
- package/lib/middleware/azure-swa/index.d.ts +28 -28
- package/lib/middleware/bun/index.d.ts +35 -35
- package/lib/middleware/cloudflare-pages/index.d.ts +35 -35
- package/lib/middleware/deno/index.d.ts +47 -47
- package/lib/middleware/firebase/index.d.ts +26 -26
- package/lib/middleware/netlify-edge/index.d.ts +27 -27
- package/lib/middleware/node/index.cjs +3 -3
- package/lib/middleware/node/index.d.ts +64 -64
- package/lib/middleware/request-handler/index.cjs +142 -73
- package/lib/middleware/request-handler/index.d.ts +710 -676
- package/lib/middleware/request-handler/index.mjs +138 -70
- package/lib/middleware/vercel-edge/index.d.ts +26 -26
- package/lib/service-worker.cjs +13 -263
- package/lib/service-worker.d.ts +15 -4
- package/lib/service-worker.mjs +13 -263
- package/lib/static/index.cjs +3 -3
- package/lib/static/index.d.ts +96 -96
- package/lib/static/node.cjs +3 -3
- package/lib/vite/index.cjs +209 -261
- package/lib/vite/index.d.ts +154 -154
- package/lib/vite/index.mjs +207 -259
- package/package.json +7 -7
package/lib/vite/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
7
7
|
var __esm = (fn, res) => function __init() {
|
|
8
8
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
9
|
};
|
|
10
|
-
var __commonJS = (cb, mod) => function
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
12
|
};
|
|
13
13
|
var __export = (target, all3) => {
|
|
@@ -14285,7 +14285,7 @@ function extendConfig(baseConfigExport, serverConfigExport) {
|
|
|
14285
14285
|
}
|
|
14286
14286
|
|
|
14287
14287
|
// sw-reg:@qwik-router-sw-register-build
|
|
14288
|
-
var qwik_router_sw_register_build_default = '
|
|
14288
|
+
var qwik_router_sw_register_build_default = '"serviceWorker"in navigator?navigator.serviceWorker.register("__url").catch(r=>console.error(r)):console.log("Service worker not supported in this browser.")';
|
|
14289
14289
|
|
|
14290
14290
|
// packages/qwik-router/src/buildtime/vite/plugin.ts
|
|
14291
14291
|
import fs8 from "node:fs";
|
|
@@ -14501,6 +14501,14 @@ var AbortMessage = class {
|
|
|
14501
14501
|
var RedirectMessage = class extends AbortMessage {
|
|
14502
14502
|
};
|
|
14503
14503
|
|
|
14504
|
+
// packages/qwik-router/src/middleware/request-handler/rewrite-handler.ts
|
|
14505
|
+
var RewriteMessage = class extends AbortMessage {
|
|
14506
|
+
constructor(pathname) {
|
|
14507
|
+
super();
|
|
14508
|
+
this.pathname = pathname;
|
|
14509
|
+
}
|
|
14510
|
+
};
|
|
14511
|
+
|
|
14504
14512
|
// packages/qwik-router/src/runtime/src/constants.ts
|
|
14505
14513
|
var QACTION_KEY = "qaction";
|
|
14506
14514
|
var QFN_KEY = "qfunc";
|
|
@@ -14664,8 +14672,7 @@ function createCacheControl(cacheControl) {
|
|
|
14664
14672
|
cacheControl = {
|
|
14665
14673
|
public: true,
|
|
14666
14674
|
immutable: true,
|
|
14667
|
-
maxAge: 60 * 60 * 24 * 365
|
|
14668
|
-
staleWhileRevalidate: 60 * 60 * 24 * 365
|
|
14675
|
+
maxAge: 60 * 60 * 24 * 365
|
|
14669
14676
|
};
|
|
14670
14677
|
} else if (cacheControl === "no-cache") {
|
|
14671
14678
|
cacheControl = {
|
|
@@ -14675,8 +14682,7 @@ function createCacheControl(cacheControl) {
|
|
|
14675
14682
|
if (typeof cacheControl === "number") {
|
|
14676
14683
|
cacheControl = {
|
|
14677
14684
|
maxAge: cacheControl,
|
|
14678
|
-
sMaxAge: cacheControl
|
|
14679
|
-
staleWhileRevalidate: cacheControl
|
|
14685
|
+
sMaxAge: cacheControl
|
|
14680
14686
|
};
|
|
14681
14687
|
}
|
|
14682
14688
|
if (cacheControl.immutable) {
|
|
@@ -14721,14 +14727,13 @@ import("node:async_hooks").then((module) => {
|
|
|
14721
14727
|
err
|
|
14722
14728
|
);
|
|
14723
14729
|
});
|
|
14724
|
-
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers,
|
|
14730
|
+
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo, trailingSlash = true, basePathname = "/", qwikSerializer) {
|
|
14725
14731
|
let resolve4;
|
|
14726
14732
|
const responsePromise = new Promise((r2) => resolve4 = r2);
|
|
14727
14733
|
const requestEv = createRequestEvent(
|
|
14728
14734
|
serverRequestEv,
|
|
14729
14735
|
loadedRoute,
|
|
14730
14736
|
requestHandlers,
|
|
14731
|
-
manifest,
|
|
14732
14737
|
trailingSlash,
|
|
14733
14738
|
basePathname,
|
|
14734
14739
|
qwikSerializer,
|
|
@@ -14737,55 +14742,71 @@ function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, manifest,
|
|
|
14737
14742
|
return {
|
|
14738
14743
|
response: responsePromise,
|
|
14739
14744
|
requestEv,
|
|
14740
|
-
completion: asyncStore ? asyncStore.run(requestEv, runNext, requestEv, resolve4) : runNext(requestEv, resolve4)
|
|
14745
|
+
completion: asyncStore ? asyncStore.run(requestEv, runNext, requestEv, rebuildRouteInfo, resolve4) : runNext(requestEv, rebuildRouteInfo, resolve4)
|
|
14741
14746
|
};
|
|
14742
14747
|
}
|
|
14743
|
-
async function runNext(requestEv, resolve4) {
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14751
|
-
|
|
14752
|
-
|
|
14753
|
-
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
}
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
if (!
|
|
14767
|
-
|
|
14768
|
-
requestEv.
|
|
14769
|
-
requestEv.status(
|
|
14748
|
+
async function runNext(requestEv, rebuildRouteInfo, resolve4) {
|
|
14749
|
+
let rewriteAttempt = 1;
|
|
14750
|
+
async function _runNext() {
|
|
14751
|
+
try {
|
|
14752
|
+
await requestEv.next();
|
|
14753
|
+
} catch (e) {
|
|
14754
|
+
if (e instanceof RedirectMessage) {
|
|
14755
|
+
const stream = requestEv.getWritableStream();
|
|
14756
|
+
await stream.close();
|
|
14757
|
+
} else if (e instanceof RewriteMessage) {
|
|
14758
|
+
if (rewriteAttempt > 50) {
|
|
14759
|
+
throw new Error(`Infinite rewrite loop`);
|
|
14760
|
+
}
|
|
14761
|
+
rewriteAttempt += 1;
|
|
14762
|
+
const url = new URL(requestEv.url);
|
|
14763
|
+
url.pathname = e.pathname;
|
|
14764
|
+
const { loadedRoute, requestHandlers } = await rebuildRouteInfo(url);
|
|
14765
|
+
requestEv.resetRoute(loadedRoute, requestHandlers, url);
|
|
14766
|
+
return await _runNext();
|
|
14767
|
+
} else if (e instanceof ServerError) {
|
|
14768
|
+
if (!requestEv.headersSent) {
|
|
14769
|
+
const status = e.status;
|
|
14770
|
+
const accept = requestEv.request.headers.get("Accept");
|
|
14771
|
+
if (accept && !accept.includes("text/html")) {
|
|
14772
|
+
const qwikSerializer = requestEv[RequestEvQwikSerializer];
|
|
14773
|
+
requestEv.headers.set("Content-Type", "application/qwik-json");
|
|
14774
|
+
requestEv.send(status, await qwikSerializer._serialize([e.data]));
|
|
14775
|
+
} else {
|
|
14776
|
+
const html5 = getErrorHtml(e.status, e.data);
|
|
14777
|
+
requestEv.html(status, html5);
|
|
14770
14778
|
}
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14779
|
+
}
|
|
14780
|
+
} else if (!(e instanceof AbortMessage)) {
|
|
14781
|
+
if (getRequestMode(requestEv) !== "dev") {
|
|
14782
|
+
try {
|
|
14783
|
+
if (!requestEv.headersSent) {
|
|
14784
|
+
requestEv.headers.set("content-type", "text/html; charset=utf-8");
|
|
14785
|
+
requestEv.cacheControl({ noCache: true });
|
|
14786
|
+
requestEv.status(500);
|
|
14787
|
+
}
|
|
14788
|
+
const stream = requestEv.getWritableStream();
|
|
14789
|
+
if (!stream.locked) {
|
|
14790
|
+
const writer = stream.getWriter();
|
|
14791
|
+
await writer.write(encoder.encode(minimalHtmlResponse(500, "Internal Server Error")));
|
|
14792
|
+
await writer.close();
|
|
14793
|
+
}
|
|
14794
|
+
} catch {
|
|
14795
|
+
console.error("Unable to render error page");
|
|
14776
14796
|
}
|
|
14777
|
-
} catch {
|
|
14778
|
-
console.error("Unable to render error page");
|
|
14779
14797
|
}
|
|
14798
|
+
return e;
|
|
14780
14799
|
}
|
|
14781
|
-
return e;
|
|
14782
14800
|
}
|
|
14801
|
+
return void 0;
|
|
14802
|
+
}
|
|
14803
|
+
try {
|
|
14804
|
+
return await _runNext();
|
|
14783
14805
|
} finally {
|
|
14784
14806
|
if (!requestEv.isDirty()) {
|
|
14785
14807
|
resolve4(null);
|
|
14786
14808
|
}
|
|
14787
14809
|
}
|
|
14788
|
-
return void 0;
|
|
14789
14810
|
}
|
|
14790
14811
|
function getRouteMatchPathname(pathname, trailingSlash) {
|
|
14791
14812
|
if (pathname.endsWith(QDATA_JSON)) {
|
|
@@ -14811,7 +14832,8 @@ var RequestRouteName = "@routeName";
|
|
|
14811
14832
|
var RequestEvSharedActionId = "@actionId";
|
|
14812
14833
|
var RequestEvSharedActionFormData = "@actionFormData";
|
|
14813
14834
|
var RequestEvSharedNonce = "@nonce";
|
|
14814
|
-
|
|
14835
|
+
var RequestEvIsRewrite = "@rewrite";
|
|
14836
|
+
function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trailingSlash, basePathname, qwikSerializer, resolved) {
|
|
14815
14837
|
const { request, platform, env: env2 } = serverRequestEv;
|
|
14816
14838
|
const sharedMap = /* @__PURE__ */ new Map();
|
|
14817
14839
|
const cookie = new Cookie(request.headers.get("cookie"));
|
|
@@ -14824,7 +14846,6 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14824
14846
|
}
|
|
14825
14847
|
sharedMap.set(IsQData, true);
|
|
14826
14848
|
}
|
|
14827
|
-
sharedMap.set("@manifest", manifest);
|
|
14828
14849
|
let routeModuleIndex = -1;
|
|
14829
14850
|
let writableStream = null;
|
|
14830
14851
|
let requestData = void 0;
|
|
@@ -14842,6 +14863,13 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14842
14863
|
routeModuleIndex++;
|
|
14843
14864
|
}
|
|
14844
14865
|
};
|
|
14866
|
+
const resetRoute = (_loadedRoute, _requestHandlers, _url = url) => {
|
|
14867
|
+
loadedRoute = _loadedRoute;
|
|
14868
|
+
requestHandlers = _requestHandlers;
|
|
14869
|
+
url.pathname = _url.pathname;
|
|
14870
|
+
url.search = _url.search;
|
|
14871
|
+
routeModuleIndex = -1;
|
|
14872
|
+
};
|
|
14845
14873
|
const check = () => {
|
|
14846
14874
|
if (writableStream !== null) {
|
|
14847
14875
|
throw new Error("Response already sent");
|
|
@@ -14876,11 +14904,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14876
14904
|
const writableStream2 = requestEv.getWritableStream();
|
|
14877
14905
|
statusOrResponse.body.pipeTo(writableStream2);
|
|
14878
14906
|
} else {
|
|
14879
|
-
|
|
14880
|
-
return new RedirectMessage();
|
|
14881
|
-
} else {
|
|
14882
|
-
requestEv.getWritableStream().getWriter().close();
|
|
14883
|
-
}
|
|
14907
|
+
requestEv.getWritableStream().getWriter().close();
|
|
14884
14908
|
}
|
|
14885
14909
|
}
|
|
14886
14910
|
return exit2();
|
|
@@ -14894,17 +14918,26 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14894
14918
|
[RequestEvLoaders]: loaders,
|
|
14895
14919
|
[RequestEvMode]: serverRequestEv.mode,
|
|
14896
14920
|
[RequestEvTrailingSlash]: trailingSlash,
|
|
14897
|
-
[RequestEvRoute]
|
|
14921
|
+
get [RequestEvRoute]() {
|
|
14922
|
+
return loadedRoute;
|
|
14923
|
+
},
|
|
14898
14924
|
[RequestEvQwikSerializer]: qwikSerializer,
|
|
14899
14925
|
cookie,
|
|
14900
14926
|
headers,
|
|
14901
14927
|
env: env2,
|
|
14902
14928
|
method: request.method,
|
|
14903
14929
|
signal: request.signal,
|
|
14904
|
-
|
|
14905
|
-
|
|
14930
|
+
originalUrl: new URL(url),
|
|
14931
|
+
get params() {
|
|
14932
|
+
return (loadedRoute == null ? void 0 : loadedRoute[1]) ?? {};
|
|
14933
|
+
},
|
|
14934
|
+
get pathname() {
|
|
14935
|
+
return url.pathname;
|
|
14936
|
+
},
|
|
14906
14937
|
platform,
|
|
14907
|
-
query
|
|
14938
|
+
get query() {
|
|
14939
|
+
return url.searchParams;
|
|
14940
|
+
},
|
|
14908
14941
|
request,
|
|
14909
14942
|
url,
|
|
14910
14943
|
basePathname,
|
|
@@ -14919,6 +14952,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14919
14952
|
return serverRequestEv.getClientConn();
|
|
14920
14953
|
},
|
|
14921
14954
|
next,
|
|
14955
|
+
resetRoute,
|
|
14922
14956
|
exit: exit2,
|
|
14923
14957
|
cacheControl: (cacheControl, target = "Cache-Control") => {
|
|
14924
14958
|
check();
|
|
@@ -14969,6 +15003,14 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14969
15003
|
exit2();
|
|
14970
15004
|
return new RedirectMessage();
|
|
14971
15005
|
},
|
|
15006
|
+
rewrite: (pathname) => {
|
|
15007
|
+
check();
|
|
15008
|
+
if (pathname.startsWith("http")) {
|
|
15009
|
+
throw new Error("Rewrite does not support absolute urls");
|
|
15010
|
+
}
|
|
15011
|
+
sharedMap.set(RequestEvIsRewrite, true);
|
|
15012
|
+
return new RewriteMessage(pathname.replace(/\/+/g, "/"));
|
|
15013
|
+
},
|
|
14972
15014
|
defer: (returnData) => {
|
|
14973
15015
|
return typeof returnData === "function" ? returnData : () => returnData;
|
|
14974
15016
|
},
|
|
@@ -15080,7 +15122,7 @@ var formToObj = (formData) => {
|
|
|
15080
15122
|
|
|
15081
15123
|
// packages/qwik-router/src/middleware/request-handler/response-page.ts
|
|
15082
15124
|
function getQwikRouterServerData(requestEv) {
|
|
15083
|
-
const {
|
|
15125
|
+
const { params, request, status, locale, originalUrl } = requestEv;
|
|
15084
15126
|
const requestHeaders = {};
|
|
15085
15127
|
request.headers.forEach((value2, key) => requestHeaders[key] = value2);
|
|
15086
15128
|
const action = requestEv.sharedMap.get(RequestEvSharedActionId);
|
|
@@ -15088,7 +15130,7 @@ function getQwikRouterServerData(requestEv) {
|
|
|
15088
15130
|
const routeName = requestEv.sharedMap.get(RequestRouteName);
|
|
15089
15131
|
const nonce = requestEv.sharedMap.get(RequestEvSharedNonce);
|
|
15090
15132
|
const headers = requestEv.request.headers;
|
|
15091
|
-
const reconstructedUrl = new URL(
|
|
15133
|
+
const reconstructedUrl = new URL(originalUrl.pathname + originalUrl.search, originalUrl);
|
|
15092
15134
|
const host = headers.get("X-Forwarded-Host");
|
|
15093
15135
|
const protocol = headers.get("X-Forwarded-Proto");
|
|
15094
15136
|
if (host) {
|
|
@@ -15354,14 +15396,21 @@ async function pureServerFunction(ev) {
|
|
|
15354
15396
|
const [qrl, ...args] = data;
|
|
15355
15397
|
if (isQrl(qrl) && qrl.getHash() === fn) {
|
|
15356
15398
|
let result;
|
|
15357
|
-
|
|
15358
|
-
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
|
|
15363
|
-
|
|
15364
|
-
|
|
15399
|
+
try {
|
|
15400
|
+
if (isDev) {
|
|
15401
|
+
result = await measure(
|
|
15402
|
+
ev,
|
|
15403
|
+
`server_${qrl.getSymbol()}`,
|
|
15404
|
+
() => qrl.apply(ev, args)
|
|
15405
|
+
);
|
|
15406
|
+
} else {
|
|
15407
|
+
result = await qrl.apply(ev, args);
|
|
15408
|
+
}
|
|
15409
|
+
} catch (err) {
|
|
15410
|
+
if (err instanceof ServerError) {
|
|
15411
|
+
throw ev.error(err.status, err.data);
|
|
15412
|
+
}
|
|
15413
|
+
throw ev.error(500, "Invalid request");
|
|
15365
15414
|
}
|
|
15366
15415
|
if (isAsyncIterator(result)) {
|
|
15367
15416
|
ev.headers.set("Content-Type", "text/qwik-json-stream");
|
|
@@ -15393,18 +15442,19 @@ async function pureServerFunction(ev) {
|
|
|
15393
15442
|
}
|
|
15394
15443
|
function fixTrailingSlash(ev) {
|
|
15395
15444
|
const trailingSlash = getRequestTrailingSlash(ev);
|
|
15396
|
-
const { basePathname,
|
|
15445
|
+
const { basePathname, originalUrl, sharedMap } = ev;
|
|
15446
|
+
const { pathname, search: search2 } = originalUrl;
|
|
15397
15447
|
const isQData = sharedMap.has(IsQData);
|
|
15398
15448
|
if (!isQData && pathname !== basePathname && !pathname.endsWith(".html")) {
|
|
15399
15449
|
if (trailingSlash) {
|
|
15400
15450
|
if (!pathname.endsWith("/")) {
|
|
15401
|
-
throw ev.redirect(301 /* MovedPermanently */, pathname + "/" +
|
|
15451
|
+
throw ev.redirect(301 /* MovedPermanently */, pathname + "/" + search2);
|
|
15402
15452
|
}
|
|
15403
15453
|
} else {
|
|
15404
15454
|
if (pathname.endsWith("/")) {
|
|
15405
15455
|
throw ev.redirect(
|
|
15406
15456
|
301 /* MovedPermanently */,
|
|
15407
|
-
pathname.slice(0, pathname.length - 1) +
|
|
15457
|
+
pathname.slice(0, pathname.length - 1) + search2
|
|
15408
15458
|
);
|
|
15409
15459
|
}
|
|
15410
15460
|
}
|
|
@@ -15481,10 +15531,10 @@ async function handleRedirect(requestEv) {
|
|
|
15481
15531
|
return;
|
|
15482
15532
|
}
|
|
15483
15533
|
const status = requestEv.status();
|
|
15484
|
-
const
|
|
15485
|
-
const isRedirect = status >= 301 && status <= 308 &&
|
|
15534
|
+
const location = requestEv.headers.get("Location");
|
|
15535
|
+
const isRedirect = status >= 301 && status <= 308 && location;
|
|
15486
15536
|
if (isRedirect) {
|
|
15487
|
-
const adaptedLocation = makeQDataPath(
|
|
15537
|
+
const adaptedLocation = makeQDataPath(location);
|
|
15488
15538
|
if (adaptedLocation) {
|
|
15489
15539
|
requestEv.headers.set("Location", adaptedLocation);
|
|
15490
15540
|
requestEv.getWritableStream().close();
|
|
@@ -15505,7 +15555,7 @@ async function renderQData(requestEv) {
|
|
|
15505
15555
|
return;
|
|
15506
15556
|
}
|
|
15507
15557
|
const status = requestEv.status();
|
|
15508
|
-
const
|
|
15558
|
+
const redirectLocation = requestEv.headers.get("Location");
|
|
15509
15559
|
const trailingSlash = getRequestTrailingSlash(requestEv);
|
|
15510
15560
|
const requestHeaders = {};
|
|
15511
15561
|
requestEv.request.headers.forEach((value2, key) => requestHeaders[key] = value2);
|
|
@@ -15515,7 +15565,8 @@ async function renderQData(requestEv) {
|
|
|
15515
15565
|
action: requestEv.sharedMap.get(RequestEvSharedActionId),
|
|
15516
15566
|
status: status !== 200 ? status : 200,
|
|
15517
15567
|
href: getPathname(requestEv.url, trailingSlash),
|
|
15518
|
-
redirect:
|
|
15568
|
+
redirect: redirectLocation ?? void 0,
|
|
15569
|
+
isRewrite: requestEv.sharedMap.get(RequestEvIsRewrite)
|
|
15519
15570
|
};
|
|
15520
15571
|
const writer = requestEv.getWritableStream().getWriter();
|
|
15521
15572
|
const qwikSerializer = requestEv[RequestEvQwikSerializer];
|
|
@@ -25953,6 +26004,9 @@ async function createMdxTransformer(ctx) {
|
|
|
25953
26004
|
const addImport = `import { jsx } from '@qwik.dev/core';
|
|
25954
26005
|
`;
|
|
25955
26006
|
const newDefault = `
|
|
26007
|
+
function _missingMdxReference(id, component, place) {
|
|
26008
|
+
throw new Error("${id}: Expected " + (component ? "component" : "object") + " \`" + id + "\` to be defined: you likely forgot to import, pass, or provide it." + (place ? "\\nIt\u2019s referenced in your code at \`" + place + "\`" : ""));
|
|
26009
|
+
}
|
|
25956
26010
|
const WrappedMdxContent = () => {
|
|
25957
26011
|
const content = _createMdxContent({});
|
|
25958
26012
|
return typeof MDXLayout === 'function' ? jsx(MDXLayout, {children: content}) : content;
|
|
@@ -26167,130 +26221,6 @@ function generateServiceWorkerRegister(ctx, swRegister) {
|
|
|
26167
26221
|
}
|
|
26168
26222
|
return `export default ${JSON.stringify(swReg)};`;
|
|
26169
26223
|
}
|
|
26170
|
-
function prependManifestToServiceWorker(ctx, manifest, prefetch, swCode) {
|
|
26171
|
-
const key = `/* Qwik Service Worker */`;
|
|
26172
|
-
if (swCode.includes(key)) {
|
|
26173
|
-
return null;
|
|
26174
|
-
}
|
|
26175
|
-
const appBundles = [];
|
|
26176
|
-
const appBundlesCode = generateAppBundles(appBundles, manifest);
|
|
26177
|
-
const libraryBundlesCode = generateLibraryBundles(appBundles, manifest);
|
|
26178
|
-
const [linkBundlesCode] = generateLinkBundles(ctx, appBundles, manifest, prefetch);
|
|
26179
|
-
return [key, appBundlesCode, libraryBundlesCode, linkBundlesCode, swCode].join("\n");
|
|
26180
|
-
}
|
|
26181
|
-
function generateAppBundles(appBundles, manifest) {
|
|
26182
|
-
const sortedBundles = Object.keys(manifest.bundles).sort();
|
|
26183
|
-
for (const appBundleName of sortedBundles) {
|
|
26184
|
-
const appBundle = [appBundleName, []];
|
|
26185
|
-
appBundles.push(appBundle);
|
|
26186
|
-
const symbolHashesInBundle = [];
|
|
26187
|
-
const manifestBundle = manifest.bundles[appBundleName];
|
|
26188
|
-
const importedBundleNames = Array.isArray(manifestBundle.imports) ? manifestBundle.imports : [];
|
|
26189
|
-
const depsSet = new Set(importedBundleNames);
|
|
26190
|
-
for (const importedBundleName of importedBundleNames) {
|
|
26191
|
-
clearTransitiveDeps(depsSet, /* @__PURE__ */ new Set(), importedBundleName);
|
|
26192
|
-
}
|
|
26193
|
-
appBundle[1] = Array.from(depsSet).map((dep) => sortedBundles.indexOf(dep));
|
|
26194
|
-
if (manifestBundle.symbols) {
|
|
26195
|
-
for (const manifestBundleSymbolName of manifestBundle.symbols) {
|
|
26196
|
-
const symbol = manifest.symbols[manifestBundleSymbolName];
|
|
26197
|
-
if ((symbol == null ? void 0 : symbol.hash) && !symbolHashesInBundle.includes(symbol.hash)) {
|
|
26198
|
-
symbolHashesInBundle.push(symbol.hash);
|
|
26199
|
-
}
|
|
26200
|
-
}
|
|
26201
|
-
}
|
|
26202
|
-
if (symbolHashesInBundle.length > 0) {
|
|
26203
|
-
appBundle[2] = symbolHashesInBundle;
|
|
26204
|
-
}
|
|
26205
|
-
}
|
|
26206
|
-
function clearTransitiveDeps(deps, seen, depName) {
|
|
26207
|
-
const childBundle = manifest.bundles[depName];
|
|
26208
|
-
for (const childDepImport of childBundle.imports || []) {
|
|
26209
|
-
if (deps.has(childDepImport)) {
|
|
26210
|
-
deps.delete(childDepImport);
|
|
26211
|
-
}
|
|
26212
|
-
if (!seen.has(childDepImport)) {
|
|
26213
|
-
seen.add(childDepImport);
|
|
26214
|
-
clearTransitiveDeps(deps, seen, childDepImport);
|
|
26215
|
-
}
|
|
26216
|
-
}
|
|
26217
|
-
}
|
|
26218
|
-
return `const appBundles=${JSON.stringify(appBundles)};`;
|
|
26219
|
-
}
|
|
26220
|
-
function generateLibraryBundles(appBundles, manifest) {
|
|
26221
|
-
const libraryBundleIds = [];
|
|
26222
|
-
for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
|
|
26223
|
-
if (bundle.origins && bundle.origins.includes("@qwik-router-config")) {
|
|
26224
|
-
libraryBundleIds.push(getAppBundleIndex(appBundles, bundleName));
|
|
26225
|
-
break;
|
|
26226
|
-
}
|
|
26227
|
-
}
|
|
26228
|
-
return `const libraryBundleIds=${JSON.stringify(libraryBundleIds)};`;
|
|
26229
|
-
}
|
|
26230
|
-
function generateLinkBundles(ctx, appBundles, manifest, prefetch) {
|
|
26231
|
-
var _a, _b;
|
|
26232
|
-
const linkBundles = [];
|
|
26233
|
-
const symbolToBundle = /* @__PURE__ */ new Map();
|
|
26234
|
-
const routeToBundles = {};
|
|
26235
|
-
for (const bundleName in manifest.bundles || []) {
|
|
26236
|
-
(_a = manifest.bundles[bundleName].symbols) == null ? void 0 : _a.forEach((symbol) => {
|
|
26237
|
-
const idx = symbol.lastIndexOf("_");
|
|
26238
|
-
symbolToBundle.set(idx === -1 ? symbol : symbol.substring(idx + 1), bundleName);
|
|
26239
|
-
});
|
|
26240
|
-
}
|
|
26241
|
-
for (const r2 of ctx.routes) {
|
|
26242
|
-
const linkBundleNames = [];
|
|
26243
|
-
const addFileBundles = (filePath) => {
|
|
26244
|
-
for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
|
|
26245
|
-
if (bundle.origins) {
|
|
26246
|
-
for (const bundleOrigin of bundle.origins) {
|
|
26247
|
-
const srcPath = removeExtension(filePath);
|
|
26248
|
-
const bundleOriginPath = removeExtension(bundleOrigin);
|
|
26249
|
-
if (srcPath.endsWith(bundleOriginPath)) {
|
|
26250
|
-
if (!linkBundleNames.includes(bundleName)) {
|
|
26251
|
-
linkBundleNames.push(bundleName);
|
|
26252
|
-
}
|
|
26253
|
-
if (bundle.dynamicImports) {
|
|
26254
|
-
for (const dynamicImport of bundle.dynamicImports) {
|
|
26255
|
-
if (!linkBundleNames.includes(dynamicImport)) {
|
|
26256
|
-
linkBundleNames.push(dynamicImport);
|
|
26257
|
-
}
|
|
26258
|
-
}
|
|
26259
|
-
}
|
|
26260
|
-
}
|
|
26261
|
-
}
|
|
26262
|
-
}
|
|
26263
|
-
}
|
|
26264
|
-
};
|
|
26265
|
-
for (const layout of r2.layouts) {
|
|
26266
|
-
addFileBundles(layout.filePath);
|
|
26267
|
-
}
|
|
26268
|
-
addFileBundles(r2.filePath);
|
|
26269
|
-
if (prefetch) {
|
|
26270
|
-
const symbolsForRoute = prefetch.find((p) => p.route === r2.routeName);
|
|
26271
|
-
(_b = symbolsForRoute == null ? void 0 : symbolsForRoute.symbols) == null ? void 0 : _b.reverse().forEach((symbol) => {
|
|
26272
|
-
const bundle = symbolToBundle.get(symbol);
|
|
26273
|
-
if (bundle) {
|
|
26274
|
-
const idx = linkBundleNames.indexOf(bundle);
|
|
26275
|
-
if (idx !== -1) {
|
|
26276
|
-
linkBundleNames.splice(idx, 1);
|
|
26277
|
-
}
|
|
26278
|
-
linkBundleNames.unshift(bundle);
|
|
26279
|
-
}
|
|
26280
|
-
});
|
|
26281
|
-
}
|
|
26282
|
-
linkBundles.push(
|
|
26283
|
-
`[${r2.pattern.toString()},${JSON.stringify(
|
|
26284
|
-
linkBundleNames.map((bundleName) => getAppBundleIndex(appBundles, bundleName))
|
|
26285
|
-
)}]`
|
|
26286
|
-
);
|
|
26287
|
-
routeToBundles[r2.routeName] = linkBundleNames;
|
|
26288
|
-
}
|
|
26289
|
-
return [`const linkBundles=[${linkBundles.join(",")}];`, routeToBundles];
|
|
26290
|
-
}
|
|
26291
|
-
function getAppBundleIndex(appBundles, bundleName) {
|
|
26292
|
-
return appBundles.findIndex((b) => b[0] === bundleName);
|
|
26293
|
-
}
|
|
26294
26224
|
var SW_UNREGISTER = `
|
|
26295
26225
|
navigator.serviceWorker?.getRegistrations().then((regs) => {
|
|
26296
26226
|
for (const reg of regs) {
|
|
@@ -26521,6 +26451,16 @@ function generateCodeFrame(source, start = 0, end) {
|
|
|
26521
26451
|
}
|
|
26522
26452
|
return res.join("\n");
|
|
26523
26453
|
}
|
|
26454
|
+
function parseId(originalId) {
|
|
26455
|
+
const [pathId, query] = originalId.split("?");
|
|
26456
|
+
const queryStr = query || "";
|
|
26457
|
+
return {
|
|
26458
|
+
originalId,
|
|
26459
|
+
pathId,
|
|
26460
|
+
query: queryStr ? `?${query}` : "",
|
|
26461
|
+
params: new URLSearchParams(queryStr)
|
|
26462
|
+
};
|
|
26463
|
+
}
|
|
26524
26464
|
|
|
26525
26465
|
// packages/qwik-router/src/buildtime/vite/format-error.ts
|
|
26526
26466
|
import fs4 from "node:fs";
|
|
@@ -26703,21 +26643,27 @@ function ssrDevMiddleware(ctx, server) {
|
|
|
26703
26643
|
if (requestHandlers.length > 0) {
|
|
26704
26644
|
const serverRequestEv = await fromNodeHttp(url, req, res, "dev");
|
|
26705
26645
|
Object.assign(serverRequestEv.platform, ctx.opts.platform);
|
|
26706
|
-
const manifest = {
|
|
26707
|
-
manifestHash: "",
|
|
26708
|
-
symbols: {},
|
|
26709
|
-
mapping: {},
|
|
26710
|
-
bundles: {},
|
|
26711
|
-
injections: [],
|
|
26712
|
-
version: "1"
|
|
26713
|
-
};
|
|
26714
26646
|
const { _deserialize, _serialize, _verifySerializable } = await server.ssrLoadModule("@qwik-serializer");
|
|
26715
26647
|
const qwikSerializer = { _deserialize, _serialize, _verifySerializable };
|
|
26648
|
+
const rebuildRouteInfo = async (url2) => {
|
|
26649
|
+
const { serverPlugins: serverPlugins2, loadedRoute: loadedRoute2 } = await resolveRoute2(routeModulePaths, url2);
|
|
26650
|
+
const requestHandlers2 = resolveRequestHandlers(
|
|
26651
|
+
serverPlugins2,
|
|
26652
|
+
loadedRoute2,
|
|
26653
|
+
req.method ?? "GET",
|
|
26654
|
+
false,
|
|
26655
|
+
renderFn
|
|
26656
|
+
);
|
|
26657
|
+
return {
|
|
26658
|
+
loadedRoute: loadedRoute2,
|
|
26659
|
+
requestHandlers: requestHandlers2
|
|
26660
|
+
};
|
|
26661
|
+
};
|
|
26716
26662
|
const { completion, requestEv } = runQwikRouter(
|
|
26717
26663
|
serverRequestEv,
|
|
26718
26664
|
loadedRoute,
|
|
26719
26665
|
requestHandlers,
|
|
26720
|
-
|
|
26666
|
+
rebuildRouteInfo,
|
|
26721
26667
|
ctx.opts.trailingSlash,
|
|
26722
26668
|
ctx.opts.basePathname,
|
|
26723
26669
|
qwikSerializer
|
|
@@ -26880,7 +26826,7 @@ function staticDistMiddleware({ config }) {
|
|
|
26880
26826
|
fs5.createReadStream(filePath).pipe(res);
|
|
26881
26827
|
return;
|
|
26882
26828
|
}
|
|
26883
|
-
} catch
|
|
26829
|
+
} catch {
|
|
26884
26830
|
}
|
|
26885
26831
|
}
|
|
26886
26832
|
next();
|
|
@@ -26912,7 +26858,7 @@ function formatDevSerializeError(err, routeModulePaths) {
|
|
|
26912
26858
|
if (line > -1) {
|
|
26913
26859
|
err.loc.line = line + 1;
|
|
26914
26860
|
}
|
|
26915
|
-
} catch
|
|
26861
|
+
} catch {
|
|
26916
26862
|
}
|
|
26917
26863
|
}
|
|
26918
26864
|
}
|
|
@@ -26976,29 +26922,55 @@ self.addEventListener('install', () => self.skipWaiting());
|
|
|
26976
26922
|
self.addEventListener('activate', (ev) => ev.waitUntil(self.clients.claim()));
|
|
26977
26923
|
`;
|
|
26978
26924
|
|
|
26925
|
+
// packages/qwik-router/src/buildtime/vite/get-route-imports.ts
|
|
26926
|
+
function getRouteImports(routes, manifest) {
|
|
26927
|
+
var _a, _b;
|
|
26928
|
+
const result = {};
|
|
26929
|
+
routes.forEach((route) => {
|
|
26930
|
+
const routePath = removeExtension(route.filePath);
|
|
26931
|
+
const layoutPaths = route.layouts ? route.layouts.map((layout) => removeExtension(layout.filePath)) : [];
|
|
26932
|
+
const routeAndLayoutPaths = [routePath, ...layoutPaths];
|
|
26933
|
+
const bundles = [];
|
|
26934
|
+
for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
|
|
26935
|
+
if (isBundlePartOfRoute(bundle, routeAndLayoutPaths)) {
|
|
26936
|
+
bundles.push(bundleName);
|
|
26937
|
+
}
|
|
26938
|
+
}
|
|
26939
|
+
if (bundles.length > 0) {
|
|
26940
|
+
result[route.routeName] = { dynamicImports: bundles };
|
|
26941
|
+
}
|
|
26942
|
+
});
|
|
26943
|
+
for (const bundleName of Object.keys(manifest.bundles)) {
|
|
26944
|
+
const bundle = manifest.bundles[bundleName];
|
|
26945
|
+
if ((_a = bundle.origins) == null ? void 0 : _a.some((s2) => s2.endsWith(QWIK_ROUTER_CONFIG_ID))) {
|
|
26946
|
+
result[bundleName] = {
|
|
26947
|
+
...bundle,
|
|
26948
|
+
dynamicImports: (_b = bundle.dynamicImports) == null ? void 0 : _b.filter(
|
|
26949
|
+
(d) => {
|
|
26950
|
+
var _a2;
|
|
26951
|
+
return (_a2 = manifest.bundles[d].origins) == null ? void 0 : _a2.some((s2) => s2.endsWith("menu.md"));
|
|
26952
|
+
}
|
|
26953
|
+
)
|
|
26954
|
+
};
|
|
26955
|
+
break;
|
|
26956
|
+
}
|
|
26957
|
+
}
|
|
26958
|
+
return result;
|
|
26959
|
+
}
|
|
26960
|
+
function isBundlePartOfRoute(bundle, routeAndLayoutPaths) {
|
|
26961
|
+
if (!bundle.origins) {
|
|
26962
|
+
return false;
|
|
26963
|
+
}
|
|
26964
|
+
for (const bundleOrigin of bundle.origins) {
|
|
26965
|
+
const originPath = removeExtension(bundleOrigin);
|
|
26966
|
+
return routeAndLayoutPaths.some((path3) => path3.endsWith(originPath));
|
|
26967
|
+
}
|
|
26968
|
+
}
|
|
26969
|
+
|
|
26979
26970
|
// packages/qwik-router/src/buildtime/vite/image-jsx.ts
|
|
26980
26971
|
import fs6 from "node:fs";
|
|
26981
26972
|
import path2 from "node:path";
|
|
26982
26973
|
import { optimize } from "svgo";
|
|
26983
|
-
|
|
26984
|
-
// packages/qwik/src/optimizer/src/versions.ts
|
|
26985
|
-
var versions = {
|
|
26986
|
-
qwik: globalThis.QWIK_VERSION
|
|
26987
|
-
};
|
|
26988
|
-
|
|
26989
|
-
// packages/qwik/src/optimizer/src/plugins/plugin.ts
|
|
26990
|
-
function parseId(originalId) {
|
|
26991
|
-
const [pathId, query] = originalId.split("?");
|
|
26992
|
-
const queryStr = query || "";
|
|
26993
|
-
return {
|
|
26994
|
-
originalId,
|
|
26995
|
-
pathId,
|
|
26996
|
-
query: queryStr ? `?${query}` : "",
|
|
26997
|
-
params: new URLSearchParams(queryStr)
|
|
26998
|
-
};
|
|
26999
|
-
}
|
|
27000
|
-
|
|
27001
|
-
// packages/qwik-router/src/buildtime/vite/image-jsx.ts
|
|
27002
26974
|
function imagePlugin(userOpts) {
|
|
27003
26975
|
const supportedExtensions = [".jpg", ".jpeg", ".png", ".webp", ".gif", ".avif", ".tiff"];
|
|
27004
26976
|
return [
|
|
@@ -27031,7 +27003,7 @@ function imagePlugin(userOpts) {
|
|
|
27031
27003
|
defaultDirectives: (url) => {
|
|
27032
27004
|
var _a;
|
|
27033
27005
|
if (url.searchParams.has("jsx")) {
|
|
27034
|
-
const { jsx:
|
|
27006
|
+
const { jsx: _2, ...params } = Object.fromEntries(url.searchParams.entries());
|
|
27035
27007
|
return new URLSearchParams({
|
|
27036
27008
|
format: "webp",
|
|
27037
27009
|
quality: "75",
|
|
@@ -27255,7 +27227,7 @@ function qwikRouterPlugin(userOpts) {
|
|
|
27255
27227
|
return updatedViteConfig;
|
|
27256
27228
|
},
|
|
27257
27229
|
async configResolved(config) {
|
|
27258
|
-
var _a, _b, _c;
|
|
27230
|
+
var _a, _b, _c, _d, _e;
|
|
27259
27231
|
Object.assign(process.env, loadEnv(config.mode, process.cwd(), ""));
|
|
27260
27232
|
rootDir = resolve3(config.root);
|
|
27261
27233
|
const target = ((_a = config.build) == null ? void 0 : _a.ssr) || config.mode === "ssr" ? "ssr" : "client";
|
|
@@ -27268,10 +27240,13 @@ function qwikRouterPlugin(userOpts) {
|
|
|
27268
27240
|
if (!qwikPlugin) {
|
|
27269
27241
|
throw new Error("Missing vite-plugin-qwik");
|
|
27270
27242
|
}
|
|
27271
|
-
|
|
27243
|
+
(_c = (_b = qwikPlugin.api).registerBundleGraphAdder) == null ? void 0 : _c.call(_b, (manifest) => {
|
|
27244
|
+
return getRouteImports(ctx.routes, manifest);
|
|
27245
|
+
});
|
|
27246
|
+
if (((_d = config.ssr) == null ? void 0 : _d.format) === "cjs") {
|
|
27272
27247
|
ssrFormat = "cjs";
|
|
27273
27248
|
}
|
|
27274
|
-
outDir = (
|
|
27249
|
+
outDir = (_e = config.build) == null ? void 0 : _e.outDir;
|
|
27275
27250
|
},
|
|
27276
27251
|
configureServer(server) {
|
|
27277
27252
|
return () => {
|
|
@@ -27413,34 +27388,7 @@ function qwikRouterPlugin(userOpts) {
|
|
|
27413
27388
|
sequential: true,
|
|
27414
27389
|
async handler() {
|
|
27415
27390
|
if ((ctx == null ? void 0 : ctx.target) === "ssr" && !(ctx == null ? void 0 : ctx.isDevServer)) {
|
|
27416
|
-
const manifest = qwikPlugin.api.getManifest();
|
|
27417
27391
|
const clientOutDir = qwikPlugin.api.getClientOutDir();
|
|
27418
|
-
if (manifest && clientOutDir) {
|
|
27419
|
-
const basePathRelDir = api.getBasePathname().replace(/^\/|\/$/, "");
|
|
27420
|
-
const clientOutBaseDir = join6(clientOutDir, basePathRelDir);
|
|
27421
|
-
const insightsManifest = await qwikPlugin.api.getInsightsManifest(clientOutDir);
|
|
27422
|
-
for (const swEntry of ctx.serviceWorkers) {
|
|
27423
|
-
try {
|
|
27424
|
-
const swClientDistPath = join6(clientOutBaseDir, swEntry.chunkFileName);
|
|
27425
|
-
const swCode = await fs8.promises.readFile(swClientDistPath, "utf-8");
|
|
27426
|
-
try {
|
|
27427
|
-
const swCodeUpdate = prependManifestToServiceWorker(
|
|
27428
|
-
ctx,
|
|
27429
|
-
manifest,
|
|
27430
|
-
(insightsManifest == null ? void 0 : insightsManifest.prefetch) || null,
|
|
27431
|
-
swCode
|
|
27432
|
-
);
|
|
27433
|
-
if (swCodeUpdate) {
|
|
27434
|
-
await fs8.promises.mkdir(clientOutDir, { recursive: true });
|
|
27435
|
-
await fs8.promises.writeFile(swClientDistPath, swCodeUpdate);
|
|
27436
|
-
}
|
|
27437
|
-
} catch (e2) {
|
|
27438
|
-
console.error(e2);
|
|
27439
|
-
}
|
|
27440
|
-
} catch (e) {
|
|
27441
|
-
}
|
|
27442
|
-
}
|
|
27443
|
-
}
|
|
27444
27392
|
if (outDir && clientOutDir) {
|
|
27445
27393
|
const assetsDir = qwikPlugin.api.getAssetsDir();
|
|
27446
27394
|
const { staticPathsCode, notFoundPathsCode } = await postBuild(
|