@qwik.dev/router 2.0.0-alpha.9 → 2.0.0-beta.2
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.cjs
CHANGED
|
@@ -14271,13 +14271,13 @@ var init_rehype_autolink_headings = __esm({
|
|
|
14271
14271
|
});
|
|
14272
14272
|
|
|
14273
14273
|
// packages/qwik-router/src/buildtime/vite/index.ts
|
|
14274
|
-
var
|
|
14275
|
-
__export(
|
|
14274
|
+
var index_exports = {};
|
|
14275
|
+
__export(index_exports, {
|
|
14276
14276
|
extendConfig: () => extendConfig,
|
|
14277
14277
|
qwikCity: () => qwikCity,
|
|
14278
14278
|
qwikRouter: () => qwikRouter
|
|
14279
14279
|
});
|
|
14280
|
-
module.exports = __toCommonJS(
|
|
14280
|
+
module.exports = __toCommonJS(index_exports);
|
|
14281
14281
|
|
|
14282
14282
|
// packages/qwik-router/src/buildtime/vite/config.ts
|
|
14283
14283
|
var import_vite = require("vite");
|
|
@@ -14296,7 +14296,7 @@ function extendConfig(baseConfigExport, serverConfigExport) {
|
|
|
14296
14296
|
}
|
|
14297
14297
|
|
|
14298
14298
|
// sw-reg:@qwik-router-sw-register-build
|
|
14299
|
-
var qwik_router_sw_register_build_default = '
|
|
14299
|
+
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.")';
|
|
14300
14300
|
|
|
14301
14301
|
// packages/qwik-router/src/buildtime/vite/plugin.ts
|
|
14302
14302
|
var import_node_fs9 = __toESM(require("node:fs"), 1);
|
|
@@ -14512,6 +14512,14 @@ var AbortMessage = class {
|
|
|
14512
14512
|
var RedirectMessage = class extends AbortMessage {
|
|
14513
14513
|
};
|
|
14514
14514
|
|
|
14515
|
+
// packages/qwik-router/src/middleware/request-handler/rewrite-handler.ts
|
|
14516
|
+
var RewriteMessage = class extends AbortMessage {
|
|
14517
|
+
constructor(pathname) {
|
|
14518
|
+
super();
|
|
14519
|
+
this.pathname = pathname;
|
|
14520
|
+
}
|
|
14521
|
+
};
|
|
14522
|
+
|
|
14515
14523
|
// packages/qwik-router/src/runtime/src/constants.ts
|
|
14516
14524
|
var QACTION_KEY = "qaction";
|
|
14517
14525
|
var QFN_KEY = "qfunc";
|
|
@@ -14675,8 +14683,7 @@ function createCacheControl(cacheControl) {
|
|
|
14675
14683
|
cacheControl = {
|
|
14676
14684
|
public: true,
|
|
14677
14685
|
immutable: true,
|
|
14678
|
-
maxAge: 60 * 60 * 24 * 365
|
|
14679
|
-
staleWhileRevalidate: 60 * 60 * 24 * 365
|
|
14686
|
+
maxAge: 60 * 60 * 24 * 365
|
|
14680
14687
|
};
|
|
14681
14688
|
} else if (cacheControl === "no-cache") {
|
|
14682
14689
|
cacheControl = {
|
|
@@ -14686,8 +14693,7 @@ function createCacheControl(cacheControl) {
|
|
|
14686
14693
|
if (typeof cacheControl === "number") {
|
|
14687
14694
|
cacheControl = {
|
|
14688
14695
|
maxAge: cacheControl,
|
|
14689
|
-
sMaxAge: cacheControl
|
|
14690
|
-
staleWhileRevalidate: cacheControl
|
|
14696
|
+
sMaxAge: cacheControl
|
|
14691
14697
|
};
|
|
14692
14698
|
}
|
|
14693
14699
|
if (cacheControl.immutable) {
|
|
@@ -14732,14 +14738,13 @@ import("node:async_hooks").then((module2) => {
|
|
|
14732
14738
|
err
|
|
14733
14739
|
);
|
|
14734
14740
|
});
|
|
14735
|
-
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers,
|
|
14741
|
+
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo, trailingSlash = true, basePathname = "/", qwikSerializer) {
|
|
14736
14742
|
let resolve4;
|
|
14737
14743
|
const responsePromise = new Promise((r2) => resolve4 = r2);
|
|
14738
14744
|
const requestEv = createRequestEvent(
|
|
14739
14745
|
serverRequestEv,
|
|
14740
14746
|
loadedRoute,
|
|
14741
14747
|
requestHandlers,
|
|
14742
|
-
manifest,
|
|
14743
14748
|
trailingSlash,
|
|
14744
14749
|
basePathname,
|
|
14745
14750
|
qwikSerializer,
|
|
@@ -14748,55 +14753,71 @@ function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, manifest,
|
|
|
14748
14753
|
return {
|
|
14749
14754
|
response: responsePromise,
|
|
14750
14755
|
requestEv,
|
|
14751
|
-
completion: asyncStore ? asyncStore.run(requestEv, runNext, requestEv, resolve4) : runNext(requestEv, resolve4)
|
|
14756
|
+
completion: asyncStore ? asyncStore.run(requestEv, runNext, requestEv, rebuildRouteInfo, resolve4) : runNext(requestEv, rebuildRouteInfo, resolve4)
|
|
14752
14757
|
};
|
|
14753
14758
|
}
|
|
14754
|
-
async function runNext(requestEv, resolve4) {
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
}
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
if (!
|
|
14778
|
-
|
|
14779
|
-
requestEv.
|
|
14780
|
-
requestEv.status(
|
|
14759
|
+
async function runNext(requestEv, rebuildRouteInfo, resolve4) {
|
|
14760
|
+
let rewriteAttempt = 1;
|
|
14761
|
+
async function _runNext() {
|
|
14762
|
+
try {
|
|
14763
|
+
await requestEv.next();
|
|
14764
|
+
} catch (e) {
|
|
14765
|
+
if (e instanceof RedirectMessage) {
|
|
14766
|
+
const stream = requestEv.getWritableStream();
|
|
14767
|
+
await stream.close();
|
|
14768
|
+
} else if (e instanceof RewriteMessage) {
|
|
14769
|
+
if (rewriteAttempt > 50) {
|
|
14770
|
+
throw new Error(`Infinite rewrite loop`);
|
|
14771
|
+
}
|
|
14772
|
+
rewriteAttempt += 1;
|
|
14773
|
+
const url = new URL(requestEv.url);
|
|
14774
|
+
url.pathname = e.pathname;
|
|
14775
|
+
const { loadedRoute, requestHandlers } = await rebuildRouteInfo(url);
|
|
14776
|
+
requestEv.resetRoute(loadedRoute, requestHandlers, url);
|
|
14777
|
+
return await _runNext();
|
|
14778
|
+
} else if (e instanceof ServerError) {
|
|
14779
|
+
if (!requestEv.headersSent) {
|
|
14780
|
+
const status = e.status;
|
|
14781
|
+
const accept = requestEv.request.headers.get("Accept");
|
|
14782
|
+
if (accept && !accept.includes("text/html")) {
|
|
14783
|
+
const qwikSerializer = requestEv[RequestEvQwikSerializer];
|
|
14784
|
+
requestEv.headers.set("Content-Type", "application/qwik-json");
|
|
14785
|
+
requestEv.send(status, await qwikSerializer._serialize([e.data]));
|
|
14786
|
+
} else {
|
|
14787
|
+
const html5 = getErrorHtml(e.status, e.data);
|
|
14788
|
+
requestEv.html(status, html5);
|
|
14781
14789
|
}
|
|
14782
|
-
|
|
14783
|
-
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
|
|
14790
|
+
}
|
|
14791
|
+
} else if (!(e instanceof AbortMessage)) {
|
|
14792
|
+
if (getRequestMode(requestEv) !== "dev") {
|
|
14793
|
+
try {
|
|
14794
|
+
if (!requestEv.headersSent) {
|
|
14795
|
+
requestEv.headers.set("content-type", "text/html; charset=utf-8");
|
|
14796
|
+
requestEv.cacheControl({ noCache: true });
|
|
14797
|
+
requestEv.status(500);
|
|
14798
|
+
}
|
|
14799
|
+
const stream = requestEv.getWritableStream();
|
|
14800
|
+
if (!stream.locked) {
|
|
14801
|
+
const writer = stream.getWriter();
|
|
14802
|
+
await writer.write(encoder.encode(minimalHtmlResponse(500, "Internal Server Error")));
|
|
14803
|
+
await writer.close();
|
|
14804
|
+
}
|
|
14805
|
+
} catch {
|
|
14806
|
+
console.error("Unable to render error page");
|
|
14787
14807
|
}
|
|
14788
|
-
} catch {
|
|
14789
|
-
console.error("Unable to render error page");
|
|
14790
14808
|
}
|
|
14809
|
+
return e;
|
|
14791
14810
|
}
|
|
14792
|
-
return e;
|
|
14793
14811
|
}
|
|
14812
|
+
return void 0;
|
|
14813
|
+
}
|
|
14814
|
+
try {
|
|
14815
|
+
return await _runNext();
|
|
14794
14816
|
} finally {
|
|
14795
14817
|
if (!requestEv.isDirty()) {
|
|
14796
14818
|
resolve4(null);
|
|
14797
14819
|
}
|
|
14798
14820
|
}
|
|
14799
|
-
return void 0;
|
|
14800
14821
|
}
|
|
14801
14822
|
function getRouteMatchPathname(pathname, trailingSlash) {
|
|
14802
14823
|
if (pathname.endsWith(QDATA_JSON)) {
|
|
@@ -14822,7 +14843,8 @@ var RequestRouteName = "@routeName";
|
|
|
14822
14843
|
var RequestEvSharedActionId = "@actionId";
|
|
14823
14844
|
var RequestEvSharedActionFormData = "@actionFormData";
|
|
14824
14845
|
var RequestEvSharedNonce = "@nonce";
|
|
14825
|
-
|
|
14846
|
+
var RequestEvIsRewrite = "@rewrite";
|
|
14847
|
+
function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trailingSlash, basePathname, qwikSerializer, resolved) {
|
|
14826
14848
|
const { request, platform, env: env2 } = serverRequestEv;
|
|
14827
14849
|
const sharedMap = /* @__PURE__ */ new Map();
|
|
14828
14850
|
const cookie = new Cookie(request.headers.get("cookie"));
|
|
@@ -14835,7 +14857,6 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14835
14857
|
}
|
|
14836
14858
|
sharedMap.set(IsQData, true);
|
|
14837
14859
|
}
|
|
14838
|
-
sharedMap.set("@manifest", manifest);
|
|
14839
14860
|
let routeModuleIndex = -1;
|
|
14840
14861
|
let writableStream = null;
|
|
14841
14862
|
let requestData = void 0;
|
|
@@ -14853,6 +14874,13 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14853
14874
|
routeModuleIndex++;
|
|
14854
14875
|
}
|
|
14855
14876
|
};
|
|
14877
|
+
const resetRoute = (_loadedRoute, _requestHandlers, _url = url) => {
|
|
14878
|
+
loadedRoute = _loadedRoute;
|
|
14879
|
+
requestHandlers = _requestHandlers;
|
|
14880
|
+
url.pathname = _url.pathname;
|
|
14881
|
+
url.search = _url.search;
|
|
14882
|
+
routeModuleIndex = -1;
|
|
14883
|
+
};
|
|
14856
14884
|
const check = () => {
|
|
14857
14885
|
if (writableStream !== null) {
|
|
14858
14886
|
throw new Error("Response already sent");
|
|
@@ -14887,11 +14915,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14887
14915
|
const writableStream2 = requestEv.getWritableStream();
|
|
14888
14916
|
statusOrResponse.body.pipeTo(writableStream2);
|
|
14889
14917
|
} else {
|
|
14890
|
-
|
|
14891
|
-
return new RedirectMessage();
|
|
14892
|
-
} else {
|
|
14893
|
-
requestEv.getWritableStream().getWriter().close();
|
|
14894
|
-
}
|
|
14918
|
+
requestEv.getWritableStream().getWriter().close();
|
|
14895
14919
|
}
|
|
14896
14920
|
}
|
|
14897
14921
|
return exit2();
|
|
@@ -14905,17 +14929,26 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14905
14929
|
[RequestEvLoaders]: loaders,
|
|
14906
14930
|
[RequestEvMode]: serverRequestEv.mode,
|
|
14907
14931
|
[RequestEvTrailingSlash]: trailingSlash,
|
|
14908
|
-
[RequestEvRoute]
|
|
14932
|
+
get [RequestEvRoute]() {
|
|
14933
|
+
return loadedRoute;
|
|
14934
|
+
},
|
|
14909
14935
|
[RequestEvQwikSerializer]: qwikSerializer,
|
|
14910
14936
|
cookie,
|
|
14911
14937
|
headers,
|
|
14912
14938
|
env: env2,
|
|
14913
14939
|
method: request.method,
|
|
14914
14940
|
signal: request.signal,
|
|
14915
|
-
|
|
14916
|
-
|
|
14941
|
+
originalUrl: new URL(url),
|
|
14942
|
+
get params() {
|
|
14943
|
+
return (loadedRoute == null ? void 0 : loadedRoute[1]) ?? {};
|
|
14944
|
+
},
|
|
14945
|
+
get pathname() {
|
|
14946
|
+
return url.pathname;
|
|
14947
|
+
},
|
|
14917
14948
|
platform,
|
|
14918
|
-
query
|
|
14949
|
+
get query() {
|
|
14950
|
+
return url.searchParams;
|
|
14951
|
+
},
|
|
14919
14952
|
request,
|
|
14920
14953
|
url,
|
|
14921
14954
|
basePathname,
|
|
@@ -14930,6 +14963,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14930
14963
|
return serverRequestEv.getClientConn();
|
|
14931
14964
|
},
|
|
14932
14965
|
next,
|
|
14966
|
+
resetRoute,
|
|
14933
14967
|
exit: exit2,
|
|
14934
14968
|
cacheControl: (cacheControl, target = "Cache-Control") => {
|
|
14935
14969
|
check();
|
|
@@ -14980,6 +15014,14 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, manif
|
|
|
14980
15014
|
exit2();
|
|
14981
15015
|
return new RedirectMessage();
|
|
14982
15016
|
},
|
|
15017
|
+
rewrite: (pathname) => {
|
|
15018
|
+
check();
|
|
15019
|
+
if (pathname.startsWith("http")) {
|
|
15020
|
+
throw new Error("Rewrite does not support absolute urls");
|
|
15021
|
+
}
|
|
15022
|
+
sharedMap.set(RequestEvIsRewrite, true);
|
|
15023
|
+
return new RewriteMessage(pathname.replace(/\/+/g, "/"));
|
|
15024
|
+
},
|
|
14983
15025
|
defer: (returnData) => {
|
|
14984
15026
|
return typeof returnData === "function" ? returnData : () => returnData;
|
|
14985
15027
|
},
|
|
@@ -15091,7 +15133,7 @@ var formToObj = (formData) => {
|
|
|
15091
15133
|
|
|
15092
15134
|
// packages/qwik-router/src/middleware/request-handler/response-page.ts
|
|
15093
15135
|
function getQwikRouterServerData(requestEv) {
|
|
15094
|
-
const {
|
|
15136
|
+
const { params, request, status, locale, originalUrl } = requestEv;
|
|
15095
15137
|
const requestHeaders = {};
|
|
15096
15138
|
request.headers.forEach((value2, key) => requestHeaders[key] = value2);
|
|
15097
15139
|
const action = requestEv.sharedMap.get(RequestEvSharedActionId);
|
|
@@ -15099,7 +15141,7 @@ function getQwikRouterServerData(requestEv) {
|
|
|
15099
15141
|
const routeName = requestEv.sharedMap.get(RequestRouteName);
|
|
15100
15142
|
const nonce = requestEv.sharedMap.get(RequestEvSharedNonce);
|
|
15101
15143
|
const headers = requestEv.request.headers;
|
|
15102
|
-
const reconstructedUrl = new URL(
|
|
15144
|
+
const reconstructedUrl = new URL(originalUrl.pathname + originalUrl.search, originalUrl);
|
|
15103
15145
|
const host = headers.get("X-Forwarded-Host");
|
|
15104
15146
|
const protocol = headers.get("X-Forwarded-Proto");
|
|
15105
15147
|
if (host) {
|
|
@@ -15365,14 +15407,21 @@ async function pureServerFunction(ev) {
|
|
|
15365
15407
|
const [qrl, ...args] = data;
|
|
15366
15408
|
if (isQrl(qrl) && qrl.getHash() === fn) {
|
|
15367
15409
|
let result;
|
|
15368
|
-
|
|
15369
|
-
|
|
15370
|
-
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15374
|
-
|
|
15375
|
-
|
|
15410
|
+
try {
|
|
15411
|
+
if (isDev) {
|
|
15412
|
+
result = await measure(
|
|
15413
|
+
ev,
|
|
15414
|
+
`server_${qrl.getSymbol()}`,
|
|
15415
|
+
() => qrl.apply(ev, args)
|
|
15416
|
+
);
|
|
15417
|
+
} else {
|
|
15418
|
+
result = await qrl.apply(ev, args);
|
|
15419
|
+
}
|
|
15420
|
+
} catch (err) {
|
|
15421
|
+
if (err instanceof ServerError) {
|
|
15422
|
+
throw ev.error(err.status, err.data);
|
|
15423
|
+
}
|
|
15424
|
+
throw ev.error(500, "Invalid request");
|
|
15376
15425
|
}
|
|
15377
15426
|
if (isAsyncIterator(result)) {
|
|
15378
15427
|
ev.headers.set("Content-Type", "text/qwik-json-stream");
|
|
@@ -15404,18 +15453,19 @@ async function pureServerFunction(ev) {
|
|
|
15404
15453
|
}
|
|
15405
15454
|
function fixTrailingSlash(ev) {
|
|
15406
15455
|
const trailingSlash = getRequestTrailingSlash(ev);
|
|
15407
|
-
const { basePathname,
|
|
15456
|
+
const { basePathname, originalUrl, sharedMap } = ev;
|
|
15457
|
+
const { pathname, search: search2 } = originalUrl;
|
|
15408
15458
|
const isQData = sharedMap.has(IsQData);
|
|
15409
15459
|
if (!isQData && pathname !== basePathname && !pathname.endsWith(".html")) {
|
|
15410
15460
|
if (trailingSlash) {
|
|
15411
15461
|
if (!pathname.endsWith("/")) {
|
|
15412
|
-
throw ev.redirect(301 /* MovedPermanently */, pathname + "/" +
|
|
15462
|
+
throw ev.redirect(301 /* MovedPermanently */, pathname + "/" + search2);
|
|
15413
15463
|
}
|
|
15414
15464
|
} else {
|
|
15415
15465
|
if (pathname.endsWith("/")) {
|
|
15416
15466
|
throw ev.redirect(
|
|
15417
15467
|
301 /* MovedPermanently */,
|
|
15418
|
-
pathname.slice(0, pathname.length - 1) +
|
|
15468
|
+
pathname.slice(0, pathname.length - 1) + search2
|
|
15419
15469
|
);
|
|
15420
15470
|
}
|
|
15421
15471
|
}
|
|
@@ -15492,10 +15542,10 @@ async function handleRedirect(requestEv) {
|
|
|
15492
15542
|
return;
|
|
15493
15543
|
}
|
|
15494
15544
|
const status = requestEv.status();
|
|
15495
|
-
const
|
|
15496
|
-
const isRedirect = status >= 301 && status <= 308 &&
|
|
15545
|
+
const location = requestEv.headers.get("Location");
|
|
15546
|
+
const isRedirect = status >= 301 && status <= 308 && location;
|
|
15497
15547
|
if (isRedirect) {
|
|
15498
|
-
const adaptedLocation = makeQDataPath(
|
|
15548
|
+
const adaptedLocation = makeQDataPath(location);
|
|
15499
15549
|
if (adaptedLocation) {
|
|
15500
15550
|
requestEv.headers.set("Location", adaptedLocation);
|
|
15501
15551
|
requestEv.getWritableStream().close();
|
|
@@ -15516,7 +15566,7 @@ async function renderQData(requestEv) {
|
|
|
15516
15566
|
return;
|
|
15517
15567
|
}
|
|
15518
15568
|
const status = requestEv.status();
|
|
15519
|
-
const
|
|
15569
|
+
const redirectLocation = requestEv.headers.get("Location");
|
|
15520
15570
|
const trailingSlash = getRequestTrailingSlash(requestEv);
|
|
15521
15571
|
const requestHeaders = {};
|
|
15522
15572
|
requestEv.request.headers.forEach((value2, key) => requestHeaders[key] = value2);
|
|
@@ -15526,7 +15576,8 @@ async function renderQData(requestEv) {
|
|
|
15526
15576
|
action: requestEv.sharedMap.get(RequestEvSharedActionId),
|
|
15527
15577
|
status: status !== 200 ? status : 200,
|
|
15528
15578
|
href: getPathname(requestEv.url, trailingSlash),
|
|
15529
|
-
redirect:
|
|
15579
|
+
redirect: redirectLocation ?? void 0,
|
|
15580
|
+
isRewrite: requestEv.sharedMap.get(RequestEvIsRewrite)
|
|
15530
15581
|
};
|
|
15531
15582
|
const writer = requestEv.getWritableStream().getWriter();
|
|
15532
15583
|
const qwikSerializer = requestEv[RequestEvQwikSerializer];
|
|
@@ -25964,6 +26015,9 @@ async function createMdxTransformer(ctx) {
|
|
|
25964
26015
|
const addImport = `import { jsx } from '@qwik.dev/core';
|
|
25965
26016
|
`;
|
|
25966
26017
|
const newDefault = `
|
|
26018
|
+
function _missingMdxReference(id, component, place) {
|
|
26019
|
+
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 + "\`" : ""));
|
|
26020
|
+
}
|
|
25967
26021
|
const WrappedMdxContent = () => {
|
|
25968
26022
|
const content = _createMdxContent({});
|
|
25969
26023
|
return typeof MDXLayout === 'function' ? jsx(MDXLayout, {children: content}) : content;
|
|
@@ -26178,130 +26232,6 @@ function generateServiceWorkerRegister(ctx, swRegister) {
|
|
|
26178
26232
|
}
|
|
26179
26233
|
return `export default ${JSON.stringify(swReg)};`;
|
|
26180
26234
|
}
|
|
26181
|
-
function prependManifestToServiceWorker(ctx, manifest, prefetch, swCode) {
|
|
26182
|
-
const key = `/* Qwik Service Worker */`;
|
|
26183
|
-
if (swCode.includes(key)) {
|
|
26184
|
-
return null;
|
|
26185
|
-
}
|
|
26186
|
-
const appBundles = [];
|
|
26187
|
-
const appBundlesCode = generateAppBundles(appBundles, manifest);
|
|
26188
|
-
const libraryBundlesCode = generateLibraryBundles(appBundles, manifest);
|
|
26189
|
-
const [linkBundlesCode] = generateLinkBundles(ctx, appBundles, manifest, prefetch);
|
|
26190
|
-
return [key, appBundlesCode, libraryBundlesCode, linkBundlesCode, swCode].join("\n");
|
|
26191
|
-
}
|
|
26192
|
-
function generateAppBundles(appBundles, manifest) {
|
|
26193
|
-
const sortedBundles = Object.keys(manifest.bundles).sort();
|
|
26194
|
-
for (const appBundleName of sortedBundles) {
|
|
26195
|
-
const appBundle = [appBundleName, []];
|
|
26196
|
-
appBundles.push(appBundle);
|
|
26197
|
-
const symbolHashesInBundle = [];
|
|
26198
|
-
const manifestBundle = manifest.bundles[appBundleName];
|
|
26199
|
-
const importedBundleNames = Array.isArray(manifestBundle.imports) ? manifestBundle.imports : [];
|
|
26200
|
-
const depsSet = new Set(importedBundleNames);
|
|
26201
|
-
for (const importedBundleName of importedBundleNames) {
|
|
26202
|
-
clearTransitiveDeps(depsSet, /* @__PURE__ */ new Set(), importedBundleName);
|
|
26203
|
-
}
|
|
26204
|
-
appBundle[1] = Array.from(depsSet).map((dep) => sortedBundles.indexOf(dep));
|
|
26205
|
-
if (manifestBundle.symbols) {
|
|
26206
|
-
for (const manifestBundleSymbolName of manifestBundle.symbols) {
|
|
26207
|
-
const symbol = manifest.symbols[manifestBundleSymbolName];
|
|
26208
|
-
if ((symbol == null ? void 0 : symbol.hash) && !symbolHashesInBundle.includes(symbol.hash)) {
|
|
26209
|
-
symbolHashesInBundle.push(symbol.hash);
|
|
26210
|
-
}
|
|
26211
|
-
}
|
|
26212
|
-
}
|
|
26213
|
-
if (symbolHashesInBundle.length > 0) {
|
|
26214
|
-
appBundle[2] = symbolHashesInBundle;
|
|
26215
|
-
}
|
|
26216
|
-
}
|
|
26217
|
-
function clearTransitiveDeps(deps, seen, depName) {
|
|
26218
|
-
const childBundle = manifest.bundles[depName];
|
|
26219
|
-
for (const childDepImport of childBundle.imports || []) {
|
|
26220
|
-
if (deps.has(childDepImport)) {
|
|
26221
|
-
deps.delete(childDepImport);
|
|
26222
|
-
}
|
|
26223
|
-
if (!seen.has(childDepImport)) {
|
|
26224
|
-
seen.add(childDepImport);
|
|
26225
|
-
clearTransitiveDeps(deps, seen, childDepImport);
|
|
26226
|
-
}
|
|
26227
|
-
}
|
|
26228
|
-
}
|
|
26229
|
-
return `const appBundles=${JSON.stringify(appBundles)};`;
|
|
26230
|
-
}
|
|
26231
|
-
function generateLibraryBundles(appBundles, manifest) {
|
|
26232
|
-
const libraryBundleIds = [];
|
|
26233
|
-
for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
|
|
26234
|
-
if (bundle.origins && bundle.origins.includes("@qwik-router-config")) {
|
|
26235
|
-
libraryBundleIds.push(getAppBundleIndex(appBundles, bundleName));
|
|
26236
|
-
break;
|
|
26237
|
-
}
|
|
26238
|
-
}
|
|
26239
|
-
return `const libraryBundleIds=${JSON.stringify(libraryBundleIds)};`;
|
|
26240
|
-
}
|
|
26241
|
-
function generateLinkBundles(ctx, appBundles, manifest, prefetch) {
|
|
26242
|
-
var _a, _b;
|
|
26243
|
-
const linkBundles = [];
|
|
26244
|
-
const symbolToBundle = /* @__PURE__ */ new Map();
|
|
26245
|
-
const routeToBundles = {};
|
|
26246
|
-
for (const bundleName in manifest.bundles || []) {
|
|
26247
|
-
(_a = manifest.bundles[bundleName].symbols) == null ? void 0 : _a.forEach((symbol) => {
|
|
26248
|
-
const idx = symbol.lastIndexOf("_");
|
|
26249
|
-
symbolToBundle.set(idx === -1 ? symbol : symbol.substring(idx + 1), bundleName);
|
|
26250
|
-
});
|
|
26251
|
-
}
|
|
26252
|
-
for (const r2 of ctx.routes) {
|
|
26253
|
-
const linkBundleNames = [];
|
|
26254
|
-
const addFileBundles = (filePath) => {
|
|
26255
|
-
for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
|
|
26256
|
-
if (bundle.origins) {
|
|
26257
|
-
for (const bundleOrigin of bundle.origins) {
|
|
26258
|
-
const srcPath = removeExtension(filePath);
|
|
26259
|
-
const bundleOriginPath = removeExtension(bundleOrigin);
|
|
26260
|
-
if (srcPath.endsWith(bundleOriginPath)) {
|
|
26261
|
-
if (!linkBundleNames.includes(bundleName)) {
|
|
26262
|
-
linkBundleNames.push(bundleName);
|
|
26263
|
-
}
|
|
26264
|
-
if (bundle.dynamicImports) {
|
|
26265
|
-
for (const dynamicImport of bundle.dynamicImports) {
|
|
26266
|
-
if (!linkBundleNames.includes(dynamicImport)) {
|
|
26267
|
-
linkBundleNames.push(dynamicImport);
|
|
26268
|
-
}
|
|
26269
|
-
}
|
|
26270
|
-
}
|
|
26271
|
-
}
|
|
26272
|
-
}
|
|
26273
|
-
}
|
|
26274
|
-
}
|
|
26275
|
-
};
|
|
26276
|
-
for (const layout of r2.layouts) {
|
|
26277
|
-
addFileBundles(layout.filePath);
|
|
26278
|
-
}
|
|
26279
|
-
addFileBundles(r2.filePath);
|
|
26280
|
-
if (prefetch) {
|
|
26281
|
-
const symbolsForRoute = prefetch.find((p) => p.route === r2.routeName);
|
|
26282
|
-
(_b = symbolsForRoute == null ? void 0 : symbolsForRoute.symbols) == null ? void 0 : _b.reverse().forEach((symbol) => {
|
|
26283
|
-
const bundle = symbolToBundle.get(symbol);
|
|
26284
|
-
if (bundle) {
|
|
26285
|
-
const idx = linkBundleNames.indexOf(bundle);
|
|
26286
|
-
if (idx !== -1) {
|
|
26287
|
-
linkBundleNames.splice(idx, 1);
|
|
26288
|
-
}
|
|
26289
|
-
linkBundleNames.unshift(bundle);
|
|
26290
|
-
}
|
|
26291
|
-
});
|
|
26292
|
-
}
|
|
26293
|
-
linkBundles.push(
|
|
26294
|
-
`[${r2.pattern.toString()},${JSON.stringify(
|
|
26295
|
-
linkBundleNames.map((bundleName) => getAppBundleIndex(appBundles, bundleName))
|
|
26296
|
-
)}]`
|
|
26297
|
-
);
|
|
26298
|
-
routeToBundles[r2.routeName] = linkBundleNames;
|
|
26299
|
-
}
|
|
26300
|
-
return [`const linkBundles=[${linkBundles.join(",")}];`, routeToBundles];
|
|
26301
|
-
}
|
|
26302
|
-
function getAppBundleIndex(appBundles, bundleName) {
|
|
26303
|
-
return appBundles.findIndex((b) => b[0] === bundleName);
|
|
26304
|
-
}
|
|
26305
26235
|
var SW_UNREGISTER = `
|
|
26306
26236
|
navigator.serviceWorker?.getRegistrations().then((regs) => {
|
|
26307
26237
|
for (const reg of regs) {
|
|
@@ -26532,6 +26462,16 @@ function generateCodeFrame(source, start = 0, end) {
|
|
|
26532
26462
|
}
|
|
26533
26463
|
return res.join("\n");
|
|
26534
26464
|
}
|
|
26465
|
+
function parseId(originalId) {
|
|
26466
|
+
const [pathId, query] = originalId.split("?");
|
|
26467
|
+
const queryStr = query || "";
|
|
26468
|
+
return {
|
|
26469
|
+
originalId,
|
|
26470
|
+
pathId,
|
|
26471
|
+
query: queryStr ? `?${query}` : "",
|
|
26472
|
+
params: new URLSearchParams(queryStr)
|
|
26473
|
+
};
|
|
26474
|
+
}
|
|
26535
26475
|
|
|
26536
26476
|
// packages/qwik-router/src/buildtime/vite/format-error.ts
|
|
26537
26477
|
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
@@ -26714,21 +26654,27 @@ function ssrDevMiddleware(ctx, server) {
|
|
|
26714
26654
|
if (requestHandlers.length > 0) {
|
|
26715
26655
|
const serverRequestEv = await fromNodeHttp(url, req, res, "dev");
|
|
26716
26656
|
Object.assign(serverRequestEv.platform, ctx.opts.platform);
|
|
26717
|
-
const manifest = {
|
|
26718
|
-
manifestHash: "",
|
|
26719
|
-
symbols: {},
|
|
26720
|
-
mapping: {},
|
|
26721
|
-
bundles: {},
|
|
26722
|
-
injections: [],
|
|
26723
|
-
version: "1"
|
|
26724
|
-
};
|
|
26725
26657
|
const { _deserialize, _serialize, _verifySerializable } = await server.ssrLoadModule("@qwik-serializer");
|
|
26726
26658
|
const qwikSerializer = { _deserialize, _serialize, _verifySerializable };
|
|
26659
|
+
const rebuildRouteInfo = async (url2) => {
|
|
26660
|
+
const { serverPlugins: serverPlugins2, loadedRoute: loadedRoute2 } = await resolveRoute2(routeModulePaths, url2);
|
|
26661
|
+
const requestHandlers2 = resolveRequestHandlers(
|
|
26662
|
+
serverPlugins2,
|
|
26663
|
+
loadedRoute2,
|
|
26664
|
+
req.method ?? "GET",
|
|
26665
|
+
false,
|
|
26666
|
+
renderFn
|
|
26667
|
+
);
|
|
26668
|
+
return {
|
|
26669
|
+
loadedRoute: loadedRoute2,
|
|
26670
|
+
requestHandlers: requestHandlers2
|
|
26671
|
+
};
|
|
26672
|
+
};
|
|
26727
26673
|
const { completion, requestEv } = runQwikRouter(
|
|
26728
26674
|
serverRequestEv,
|
|
26729
26675
|
loadedRoute,
|
|
26730
26676
|
requestHandlers,
|
|
26731
|
-
|
|
26677
|
+
rebuildRouteInfo,
|
|
26732
26678
|
ctx.opts.trailingSlash,
|
|
26733
26679
|
ctx.opts.basePathname,
|
|
26734
26680
|
qwikSerializer
|
|
@@ -26891,7 +26837,7 @@ function staticDistMiddleware({ config }) {
|
|
|
26891
26837
|
import_node_fs6.default.createReadStream(filePath).pipe(res);
|
|
26892
26838
|
return;
|
|
26893
26839
|
}
|
|
26894
|
-
} catch
|
|
26840
|
+
} catch {
|
|
26895
26841
|
}
|
|
26896
26842
|
}
|
|
26897
26843
|
next();
|
|
@@ -26923,7 +26869,7 @@ function formatDevSerializeError(err, routeModulePaths) {
|
|
|
26923
26869
|
if (line > -1) {
|
|
26924
26870
|
err.loc.line = line + 1;
|
|
26925
26871
|
}
|
|
26926
|
-
} catch
|
|
26872
|
+
} catch {
|
|
26927
26873
|
}
|
|
26928
26874
|
}
|
|
26929
26875
|
}
|
|
@@ -26987,29 +26933,55 @@ self.addEventListener('install', () => self.skipWaiting());
|
|
|
26987
26933
|
self.addEventListener('activate', (ev) => ev.waitUntil(self.clients.claim()));
|
|
26988
26934
|
`;
|
|
26989
26935
|
|
|
26936
|
+
// packages/qwik-router/src/buildtime/vite/get-route-imports.ts
|
|
26937
|
+
function getRouteImports(routes, manifest) {
|
|
26938
|
+
var _a, _b;
|
|
26939
|
+
const result = {};
|
|
26940
|
+
routes.forEach((route) => {
|
|
26941
|
+
const routePath = removeExtension(route.filePath);
|
|
26942
|
+
const layoutPaths = route.layouts ? route.layouts.map((layout) => removeExtension(layout.filePath)) : [];
|
|
26943
|
+
const routeAndLayoutPaths = [routePath, ...layoutPaths];
|
|
26944
|
+
const bundles = [];
|
|
26945
|
+
for (const [bundleName, bundle] of Object.entries(manifest.bundles)) {
|
|
26946
|
+
if (isBundlePartOfRoute(bundle, routeAndLayoutPaths)) {
|
|
26947
|
+
bundles.push(bundleName);
|
|
26948
|
+
}
|
|
26949
|
+
}
|
|
26950
|
+
if (bundles.length > 0) {
|
|
26951
|
+
result[route.routeName] = { dynamicImports: bundles };
|
|
26952
|
+
}
|
|
26953
|
+
});
|
|
26954
|
+
for (const bundleName of Object.keys(manifest.bundles)) {
|
|
26955
|
+
const bundle = manifest.bundles[bundleName];
|
|
26956
|
+
if ((_a = bundle.origins) == null ? void 0 : _a.some((s2) => s2.endsWith(QWIK_ROUTER_CONFIG_ID))) {
|
|
26957
|
+
result[bundleName] = {
|
|
26958
|
+
...bundle,
|
|
26959
|
+
dynamicImports: (_b = bundle.dynamicImports) == null ? void 0 : _b.filter(
|
|
26960
|
+
(d) => {
|
|
26961
|
+
var _a2;
|
|
26962
|
+
return (_a2 = manifest.bundles[d].origins) == null ? void 0 : _a2.some((s2) => s2.endsWith("menu.md"));
|
|
26963
|
+
}
|
|
26964
|
+
)
|
|
26965
|
+
};
|
|
26966
|
+
break;
|
|
26967
|
+
}
|
|
26968
|
+
}
|
|
26969
|
+
return result;
|
|
26970
|
+
}
|
|
26971
|
+
function isBundlePartOfRoute(bundle, routeAndLayoutPaths) {
|
|
26972
|
+
if (!bundle.origins) {
|
|
26973
|
+
return false;
|
|
26974
|
+
}
|
|
26975
|
+
for (const bundleOrigin of bundle.origins) {
|
|
26976
|
+
const originPath = removeExtension(bundleOrigin);
|
|
26977
|
+
return routeAndLayoutPaths.some((path3) => path3.endsWith(originPath));
|
|
26978
|
+
}
|
|
26979
|
+
}
|
|
26980
|
+
|
|
26990
26981
|
// packages/qwik-router/src/buildtime/vite/image-jsx.ts
|
|
26991
26982
|
var import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
26992
26983
|
var import_node_path9 = __toESM(require("node:path"), 1);
|
|
26993
26984
|
var import_svgo = require("svgo");
|
|
26994
|
-
|
|
26995
|
-
// packages/qwik/src/optimizer/src/versions.ts
|
|
26996
|
-
var versions = {
|
|
26997
|
-
qwik: globalThis.QWIK_VERSION
|
|
26998
|
-
};
|
|
26999
|
-
|
|
27000
|
-
// packages/qwik/src/optimizer/src/plugins/plugin.ts
|
|
27001
|
-
function parseId(originalId) {
|
|
27002
|
-
const [pathId, query] = originalId.split("?");
|
|
27003
|
-
const queryStr = query || "";
|
|
27004
|
-
return {
|
|
27005
|
-
originalId,
|
|
27006
|
-
pathId,
|
|
27007
|
-
query: queryStr ? `?${query}` : "",
|
|
27008
|
-
params: new URLSearchParams(queryStr)
|
|
27009
|
-
};
|
|
27010
|
-
}
|
|
27011
|
-
|
|
27012
|
-
// packages/qwik-router/src/buildtime/vite/image-jsx.ts
|
|
27013
26985
|
function imagePlugin(userOpts) {
|
|
27014
26986
|
const supportedExtensions = [".jpg", ".jpeg", ".png", ".webp", ".gif", ".avif", ".tiff"];
|
|
27015
26987
|
return [
|
|
@@ -27042,7 +27014,7 @@ function imagePlugin(userOpts) {
|
|
|
27042
27014
|
defaultDirectives: (url) => {
|
|
27043
27015
|
var _a;
|
|
27044
27016
|
if (url.searchParams.has("jsx")) {
|
|
27045
|
-
const { jsx:
|
|
27017
|
+
const { jsx: _2, ...params } = Object.fromEntries(url.searchParams.entries());
|
|
27046
27018
|
return new URLSearchParams({
|
|
27047
27019
|
format: "webp",
|
|
27048
27020
|
quality: "75",
|
|
@@ -27266,7 +27238,7 @@ function qwikRouterPlugin(userOpts) {
|
|
|
27266
27238
|
return updatedViteConfig;
|
|
27267
27239
|
},
|
|
27268
27240
|
async configResolved(config) {
|
|
27269
|
-
var _a, _b, _c;
|
|
27241
|
+
var _a, _b, _c, _d, _e;
|
|
27270
27242
|
Object.assign(process.env, (0, import_vite2.loadEnv)(config.mode, process.cwd(), ""));
|
|
27271
27243
|
rootDir = (0, import_node_path11.resolve)(config.root);
|
|
27272
27244
|
const target = ((_a = config.build) == null ? void 0 : _a.ssr) || config.mode === "ssr" ? "ssr" : "client";
|
|
@@ -27279,10 +27251,13 @@ function qwikRouterPlugin(userOpts) {
|
|
|
27279
27251
|
if (!qwikPlugin) {
|
|
27280
27252
|
throw new Error("Missing vite-plugin-qwik");
|
|
27281
27253
|
}
|
|
27282
|
-
|
|
27254
|
+
(_c = (_b = qwikPlugin.api).registerBundleGraphAdder) == null ? void 0 : _c.call(_b, (manifest) => {
|
|
27255
|
+
return getRouteImports(ctx.routes, manifest);
|
|
27256
|
+
});
|
|
27257
|
+
if (((_d = config.ssr) == null ? void 0 : _d.format) === "cjs") {
|
|
27283
27258
|
ssrFormat = "cjs";
|
|
27284
27259
|
}
|
|
27285
|
-
outDir = (
|
|
27260
|
+
outDir = (_e = config.build) == null ? void 0 : _e.outDir;
|
|
27286
27261
|
},
|
|
27287
27262
|
configureServer(server) {
|
|
27288
27263
|
return () => {
|
|
@@ -27424,34 +27399,7 @@ function qwikRouterPlugin(userOpts) {
|
|
|
27424
27399
|
sequential: true,
|
|
27425
27400
|
async handler() {
|
|
27426
27401
|
if ((ctx == null ? void 0 : ctx.target) === "ssr" && !(ctx == null ? void 0 : ctx.isDevServer)) {
|
|
27427
|
-
const manifest = qwikPlugin.api.getManifest();
|
|
27428
27402
|
const clientOutDir = qwikPlugin.api.getClientOutDir();
|
|
27429
|
-
if (manifest && clientOutDir) {
|
|
27430
|
-
const basePathRelDir = api.getBasePathname().replace(/^\/|\/$/, "");
|
|
27431
|
-
const clientOutBaseDir = (0, import_node_path11.join)(clientOutDir, basePathRelDir);
|
|
27432
|
-
const insightsManifest = await qwikPlugin.api.getInsightsManifest(clientOutDir);
|
|
27433
|
-
for (const swEntry of ctx.serviceWorkers) {
|
|
27434
|
-
try {
|
|
27435
|
-
const swClientDistPath = (0, import_node_path11.join)(clientOutBaseDir, swEntry.chunkFileName);
|
|
27436
|
-
const swCode = await import_node_fs9.default.promises.readFile(swClientDistPath, "utf-8");
|
|
27437
|
-
try {
|
|
27438
|
-
const swCodeUpdate = prependManifestToServiceWorker(
|
|
27439
|
-
ctx,
|
|
27440
|
-
manifest,
|
|
27441
|
-
(insightsManifest == null ? void 0 : insightsManifest.prefetch) || null,
|
|
27442
|
-
swCode
|
|
27443
|
-
);
|
|
27444
|
-
if (swCodeUpdate) {
|
|
27445
|
-
await import_node_fs9.default.promises.mkdir(clientOutDir, { recursive: true });
|
|
27446
|
-
await import_node_fs9.default.promises.writeFile(swClientDistPath, swCodeUpdate);
|
|
27447
|
-
}
|
|
27448
|
-
} catch (e2) {
|
|
27449
|
-
console.error(e2);
|
|
27450
|
-
}
|
|
27451
|
-
} catch (e) {
|
|
27452
|
-
}
|
|
27453
|
-
}
|
|
27454
|
-
}
|
|
27455
27403
|
if (outDir && clientOutDir) {
|
|
27456
27404
|
const assetsDir = qwikPlugin.api.getAssetsDir();
|
|
27457
27405
|
const { staticPathsCode, notFoundPathsCode } = await postBuild(
|