@qwik.dev/router 2.0.0-beta.13 → 2.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapters/azure-swa/vite/index.mjs +7 -7
- package/lib/adapters/bun-server/vite/index.mjs +7 -7
- package/lib/adapters/cloud-run/vite/index.mjs +7 -7
- package/lib/adapters/cloudflare-pages/vite/index.mjs +8 -8
- package/lib/adapters/deno-server/vite/index.mjs +7 -7
- package/lib/adapters/netlify-edge/vite/index.mjs +7 -7
- package/lib/adapters/node-server/vite/index.mjs +7 -7
- package/lib/adapters/shared/vite/index.mjs +8 -8
- package/lib/adapters/ssg/vite/index.mjs +7 -8
- package/lib/adapters/vercel-edge/vite/index.mjs +7 -7
- package/lib/chunks/error-handler.mjs +2 -4
- package/lib/chunks/format-error.mjs +6 -6
- package/lib/chunks/fs.mjs +6 -27
- package/lib/chunks/index.mjs +39 -31
- package/lib/chunks/mime-types.mjs +2 -3
- package/lib/chunks/routing.qwik.mjs +23 -47
- package/lib/chunks/types.qwik.mjs +2 -5
- package/lib/index.d.ts +2 -1
- package/lib/index.qwik.mjs +48 -68
- package/lib/middleware/aws-lambda/index.mjs +4 -5
- package/lib/middleware/azure-swa/index.mjs +6 -7
- package/lib/middleware/bun/index.mjs +8 -9
- package/lib/middleware/cloudflare-pages/index.mjs +5 -6
- package/lib/middleware/deno/index.mjs +7 -8
- package/lib/middleware/firebase/index.mjs +4 -5
- package/lib/middleware/netlify-edge/index.mjs +5 -6
- package/lib/middleware/node/index.mjs +15 -11
- package/lib/middleware/request-handler/index.d.ts +2 -2
- package/lib/middleware/request-handler/index.mjs +64 -79
- package/lib/middleware/vercel-edge/index.mjs +5 -6
- package/lib/service-worker/index.mjs +2 -3
- package/lib/ssg/index.mjs +3 -4
- package/lib/vite/index.d.ts +7 -1
- package/lib/vite/index.mjs +91 -68
- package/package.json +21 -39
- package/lib/adapters/azure-swa/vite/index.cjs +0 -61
- package/lib/adapters/bun-server/vite/index.cjs +0 -27
- package/lib/adapters/cloud-run/vite/index.cjs +0 -24
- package/lib/adapters/cloudflare-pages/vite/index.cjs +0 -65
- package/lib/adapters/deno-server/vite/index.cjs +0 -39
- package/lib/adapters/netlify-edge/vite/index.cjs +0 -88
- package/lib/adapters/node-server/vite/index.cjs +0 -27
- package/lib/adapters/shared/vite/index.cjs +0 -306
- package/lib/adapters/ssg/vite/index.cjs +0 -19
- package/lib/adapters/vercel-edge/vite/index.cjs +0 -81
- package/lib/chunks/error-handler.cjs +0 -58
- package/lib/chunks/format-error.cjs +0 -136
- package/lib/chunks/fs.cjs +0 -274
- package/lib/chunks/index.cjs +0 -877
- package/lib/chunks/mime-types.cjs +0 -52
- package/lib/chunks/routing.qwik.cjs +0 -452
- package/lib/chunks/types.qwik.cjs +0 -24
- package/lib/index.qwik.cjs +0 -1662
- package/lib/middleware/aws-lambda/index.cjs +0 -52
- package/lib/middleware/azure-swa/index.cjs +0 -92
- package/lib/middleware/bun/index.cjs +0 -143
- package/lib/middleware/cloudflare-pages/index.cjs +0 -96
- package/lib/middleware/deno/index.cjs +0 -130
- package/lib/middleware/firebase/index.cjs +0 -33
- package/lib/middleware/netlify-edge/index.cjs +0 -71
- package/lib/middleware/node/index.cjs +0 -219
- package/lib/middleware/request-handler/index.cjs +0 -1488
- package/lib/middleware/vercel-edge/index.cjs +0 -98
- package/lib/service-worker/index.cjs +0 -5
- package/lib/ssg/index.cjs +0 -15
- package/lib/vite/index.cjs +0 -2021
|
@@ -599,14 +599,14 @@ declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Reco
|
|
|
599
599
|
|
|
600
600
|
/** @public */
|
|
601
601
|
export declare interface ResolveSyncValue {
|
|
602
|
+
<T, INPUT, OPTIONAL extends boolean>(action: Action<T, INPUT, OPTIONAL>): Awaited<T> | undefined;
|
|
602
603
|
<T>(loader: Loader_2<T>): Awaited<T> extends () => any ? never : Awaited<T>;
|
|
603
|
-
<T>(action: Action<T>): Awaited<T> | undefined;
|
|
604
604
|
}
|
|
605
605
|
|
|
606
606
|
/** @public */
|
|
607
607
|
export declare interface ResolveValue {
|
|
608
|
+
<T, INPUT, OPTIONAL extends boolean>(action: Action<T, INPUT, OPTIONAL>): Promise<T | undefined>;
|
|
608
609
|
<T>(loader: Loader_2<T>): Awaited<T> extends () => any ? never : Promise<T>;
|
|
609
|
-
<T>(action: Action<T>): Promise<T | undefined>;
|
|
610
610
|
}
|
|
611
611
|
|
|
612
612
|
/** @public */
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
-
var _a, _b, _c, _pendingHighSurrogate, _handle, _transform;
|
|
12
|
-
import { isServer } from "@qwik.dev/core/build";
|
|
13
|
-
import { i as isPromise, k as QDATA_KEY, Q as Q_ROUTE, h as QFN_KEY, m as QLOADER_KEY, j as QACTION_KEY, d as loadRoute } from "../../chunks/routing.qwik.mjs";
|
|
14
|
-
import { inlinedQrl } from "@qwik.dev/core";
|
|
15
|
-
import { _serialize, _UNINITIALIZED, _deserialize, _verifySerializable } from "@qwik.dev/core/internal";
|
|
16
|
-
import { L as LoadedRouteProp } from "../../chunks/types.qwik.mjs";
|
|
17
|
-
import { _asyncRequestStore as _asyncRequestStore$1, ServerError as ServerError$1, RedirectMessage as RedirectMessage$1, RewriteMessage as RewriteMessage$1, AbortMessage as AbortMessage$1 } from "@qwik.dev/router/middleware/request-handler";
|
|
18
|
-
import { g as getErrorHtml, m as minimalHtmlResponse } from "../../chunks/error-handler.mjs";
|
|
19
|
-
import "@qwik.dev/core/preloader";
|
|
1
|
+
import { isServer } from '@qwik.dev/core/build';
|
|
2
|
+
import { i as isPromise, k as QDATA_KEY, Q as Q_ROUTE, h as QFN_KEY, m as QLOADER_KEY, j as QACTION_KEY, d as loadRoute } from '../../chunks/routing.qwik.mjs';
|
|
3
|
+
import { inlinedQrl } from '@qwik.dev/core';
|
|
4
|
+
import { _serialize, _UNINITIALIZED, _deserialize, _verifySerializable } from '@qwik.dev/core/internal';
|
|
5
|
+
import { L as LoadedRouteProp } from '../../chunks/types.qwik.mjs';
|
|
6
|
+
import { _asyncRequestStore as _asyncRequestStore$1, ServerError as ServerError$1, RedirectMessage as RedirectMessage$1, RewriteMessage as RewriteMessage$1, AbortMessage as AbortMessage$1 } from '@qwik.dev/router/middleware/request-handler';
|
|
7
|
+
import { g as getErrorHtml, m as minimalHtmlResponse } from '../../chunks/error-handler.mjs';
|
|
8
|
+
import '@qwik.dev/core/preloader';
|
|
9
|
+
|
|
20
10
|
var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
|
|
21
11
|
HttpStatus2[HttpStatus2["Continue"] = 100] = "Continue";
|
|
22
12
|
HttpStatus2[HttpStatus2["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
@@ -81,6 +71,7 @@ var HttpStatus = /* @__PURE__ */ ((HttpStatus2) => {
|
|
|
81
71
|
HttpStatus2[HttpStatus2["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
82
72
|
return HttpStatus2;
|
|
83
73
|
})(HttpStatus || {});
|
|
74
|
+
|
|
84
75
|
function createCacheControl(cacheControl) {
|
|
85
76
|
const controls = [];
|
|
86
77
|
if (cacheControl === "day") {
|
|
@@ -142,6 +133,7 @@ function createCacheControl(cacheControl) {
|
|
|
142
133
|
}
|
|
143
134
|
return controls.join(", ");
|
|
144
135
|
}
|
|
136
|
+
|
|
145
137
|
const SAMESITE = {
|
|
146
138
|
lax: "Lax",
|
|
147
139
|
Lax: "Lax",
|
|
@@ -221,13 +213,12 @@ function resolveSameSite(sameSite) {
|
|
|
221
213
|
const REQ_COOKIE = Symbol("request-cookies");
|
|
222
214
|
const RES_COOKIE = Symbol("response-cookies");
|
|
223
215
|
const LIVE_COOKIE = Symbol("live-cookies");
|
|
224
|
-
_c = REQ_COOKIE, _b = RES_COOKIE, _a = LIVE_COOKIE;
|
|
225
216
|
class Cookie {
|
|
217
|
+
[REQ_COOKIE];
|
|
218
|
+
[RES_COOKIE] = {};
|
|
219
|
+
[LIVE_COOKIE] = {};
|
|
220
|
+
appendCounter = 0;
|
|
226
221
|
constructor(cookieString) {
|
|
227
|
-
__publicField(this, _c);
|
|
228
|
-
__publicField(this, _b, {});
|
|
229
|
-
__publicField(this, _a, {});
|
|
230
|
-
__publicField(this, "appendCounter", 0);
|
|
231
222
|
this[REQ_COOKIE] = parseCookieString(cookieString);
|
|
232
223
|
this[LIVE_COOKIE] = { ...this[REQ_COOKIE] };
|
|
233
224
|
}
|
|
@@ -291,6 +282,7 @@ const mergeHeadersCookies = (headers, cookies) => {
|
|
|
291
282
|
}
|
|
292
283
|
return headers;
|
|
293
284
|
};
|
|
285
|
+
|
|
294
286
|
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo, basePathname = "/") {
|
|
295
287
|
let resolve;
|
|
296
288
|
const responsePromise = new Promise((r) => resolve = r);
|
|
@@ -392,6 +384,7 @@ function getRouteMatchPathname(pathname) {
|
|
|
392
384
|
}
|
|
393
385
|
const IsQData = "@isQData";
|
|
394
386
|
const QDATA_JSON = "/q-data.json";
|
|
387
|
+
|
|
395
388
|
const RequestEvLoaders = Symbol("RequestEvLoaders");
|
|
396
389
|
const RequestEvMode = Symbol("RequestEvMode");
|
|
397
390
|
const RequestEvRoute = Symbol("RequestEvRoute");
|
|
@@ -696,6 +689,7 @@ const formToObj = (formData) => {
|
|
|
696
689
|
}, {});
|
|
697
690
|
return values;
|
|
698
691
|
};
|
|
692
|
+
|
|
699
693
|
function getQwikRouterServerData(requestEv) {
|
|
700
694
|
const { params, request, status, locale, originalUrl } = requestEv;
|
|
701
695
|
const requestHeaders = {};
|
|
@@ -740,6 +734,7 @@ function getQwikRouterServerData(requestEv) {
|
|
|
740
734
|
}
|
|
741
735
|
};
|
|
742
736
|
}
|
|
737
|
+
|
|
743
738
|
const resolveRequestHandlers = (serverPlugins, route, method, checkOrigin, renderHandler, isInternal) => {
|
|
744
739
|
const routeLoaders = [];
|
|
745
740
|
const routeActions = [];
|
|
@@ -1262,9 +1257,10 @@ function isContentType(headers, ...types) {
|
|
|
1262
1257
|
const type = headers.get("content-type")?.split(/;/, 1)[0].trim() ?? "";
|
|
1263
1258
|
return types.includes(type);
|
|
1264
1259
|
}
|
|
1260
|
+
|
|
1265
1261
|
let _asyncRequestStore;
|
|
1266
1262
|
if (isServer) {
|
|
1267
|
-
import(
|
|
1263
|
+
import('node:async_hooks').then((module) => {
|
|
1268
1264
|
_asyncRequestStore = new module.AsyncLocalStorage();
|
|
1269
1265
|
}).catch((err) => {
|
|
1270
1266
|
console.warn(
|
|
@@ -1279,7 +1275,7 @@ async function requestHandler(serverRequestEv, opts) {
|
|
|
1279
1275
|
let { qwikRouterConfig } = opts;
|
|
1280
1276
|
if (!qwikRouterConfig) {
|
|
1281
1277
|
if (!qwikRouterConfigActual) {
|
|
1282
|
-
qwikRouterConfigActual = await import(
|
|
1278
|
+
qwikRouterConfigActual = await import('@qwik-router-config');
|
|
1283
1279
|
}
|
|
1284
1280
|
qwikRouterConfig = qwikRouterConfigActual;
|
|
1285
1281
|
}
|
|
@@ -1340,6 +1336,7 @@ async function loadRequestHandlers(qwikRouterConfig, pathname, method, checkOrig
|
|
|
1340
1336
|
}
|
|
1341
1337
|
return null;
|
|
1342
1338
|
}
|
|
1339
|
+
|
|
1343
1340
|
const notFounds = [
|
|
1344
1341
|
// Will be replaced in post-build with the 404s generated by SSG
|
|
1345
1342
|
"__QWIK_ROUTER_NOT_FOUND_ARRAY__"
|
|
@@ -1352,6 +1349,7 @@ function getNotFound(prefix) {
|
|
|
1352
1349
|
}
|
|
1353
1350
|
return minimalHtmlResponse(404, "Resource Not Found");
|
|
1354
1351
|
}
|
|
1352
|
+
|
|
1355
1353
|
const staticPaths = /* @__PURE__ */ new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]);
|
|
1356
1354
|
function isStaticPath(method, url) {
|
|
1357
1355
|
if (method.toUpperCase() !== "GET") {
|
|
@@ -1378,6 +1376,7 @@ function isStaticPath(method, url) {
|
|
|
1378
1376
|
}
|
|
1379
1377
|
return false;
|
|
1380
1378
|
}
|
|
1379
|
+
|
|
1381
1380
|
class ServerError extends Error {
|
|
1382
1381
|
constructor(status, data) {
|
|
1383
1382
|
super(typeof data === "string" ? data : void 0);
|
|
@@ -1385,84 +1384,70 @@ class ServerError extends Error {
|
|
|
1385
1384
|
this.data = data;
|
|
1386
1385
|
}
|
|
1387
1386
|
}
|
|
1387
|
+
|
|
1388
1388
|
class AbortMessage {
|
|
1389
1389
|
}
|
|
1390
1390
|
class RedirectMessage extends AbortMessage {
|
|
1391
1391
|
}
|
|
1392
|
+
|
|
1392
1393
|
class RewriteMessage extends AbortMessage {
|
|
1393
1394
|
constructor(pathname) {
|
|
1394
1395
|
super();
|
|
1395
1396
|
this.pathname = pathname;
|
|
1396
1397
|
}
|
|
1397
1398
|
}
|
|
1399
|
+
|
|
1398
1400
|
class _TextEncoderStream_polyfill {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
__privateSet(this, _pendingHighSurrogate, null);
|
|
1412
|
-
if (56320 <= codeUnit && codeUnit <= 57343) {
|
|
1413
|
-
finalChunk += highSurrogate + item;
|
|
1414
|
-
continue;
|
|
1415
|
-
}
|
|
1416
|
-
finalChunk += "�";
|
|
1417
|
-
}
|
|
1418
|
-
if (55296 <= codeUnit && codeUnit <= 56319) {
|
|
1419
|
-
__privateSet(this, _pendingHighSurrogate, item);
|
|
1420
|
-
continue;
|
|
1421
|
-
}
|
|
1401
|
+
#pendingHighSurrogate = null;
|
|
1402
|
+
#handle = new TextEncoder();
|
|
1403
|
+
#transform = new TransformStream({
|
|
1404
|
+
transform: (chunk, controller) => {
|
|
1405
|
+
chunk = String(chunk);
|
|
1406
|
+
let finalChunk = "";
|
|
1407
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
1408
|
+
const item = chunk[i];
|
|
1409
|
+
const codeUnit = item.charCodeAt(0);
|
|
1410
|
+
if (this.#pendingHighSurrogate !== null) {
|
|
1411
|
+
const highSurrogate = this.#pendingHighSurrogate;
|
|
1412
|
+
this.#pendingHighSurrogate = null;
|
|
1422
1413
|
if (56320 <= codeUnit && codeUnit <= 57343) {
|
|
1423
|
-
finalChunk +=
|
|
1414
|
+
finalChunk += highSurrogate + item;
|
|
1424
1415
|
continue;
|
|
1425
1416
|
}
|
|
1426
|
-
finalChunk +=
|
|
1417
|
+
finalChunk += "�";
|
|
1427
1418
|
}
|
|
1428
|
-
if (
|
|
1429
|
-
|
|
1419
|
+
if (55296 <= codeUnit && codeUnit <= 56319) {
|
|
1420
|
+
this.#pendingHighSurrogate = item;
|
|
1421
|
+
continue;
|
|
1430
1422
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
controller.enqueue(new Uint8Array([239, 191, 189]));
|
|
1423
|
+
if (56320 <= codeUnit && codeUnit <= 57343) {
|
|
1424
|
+
finalChunk += "�";
|
|
1425
|
+
continue;
|
|
1435
1426
|
}
|
|
1427
|
+
finalChunk += item;
|
|
1436
1428
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1429
|
+
if (finalChunk) {
|
|
1430
|
+
controller.enqueue(this.#handle.encode(finalChunk));
|
|
1431
|
+
}
|
|
1432
|
+
},
|
|
1433
|
+
flush: (controller) => {
|
|
1434
|
+
if (this.#pendingHighSurrogate !== null) {
|
|
1435
|
+
controller.enqueue(new Uint8Array([239, 191, 189]));
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
1439
|
get encoding() {
|
|
1440
|
-
return
|
|
1440
|
+
return this.#handle.encoding;
|
|
1441
1441
|
}
|
|
1442
1442
|
get readable() {
|
|
1443
|
-
return
|
|
1443
|
+
return this.#transform.readable;
|
|
1444
1444
|
}
|
|
1445
1445
|
get writable() {
|
|
1446
|
-
return
|
|
1446
|
+
return this.#transform.writable;
|
|
1447
1447
|
}
|
|
1448
1448
|
get [Symbol.toStringTag]() {
|
|
1449
1449
|
return "TextEncoderStream";
|
|
1450
1450
|
}
|
|
1451
1451
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
_transform = new WeakMap();
|
|
1455
|
-
export {
|
|
1456
|
-
AbortMessage,
|
|
1457
|
-
RedirectMessage,
|
|
1458
|
-
RequestEvShareQData,
|
|
1459
|
-
RewriteMessage,
|
|
1460
|
-
ServerError,
|
|
1461
|
-
_TextEncoderStream_polyfill,
|
|
1462
|
-
_asyncRequestStore,
|
|
1463
|
-
getErrorHtml,
|
|
1464
|
-
getNotFound,
|
|
1465
|
-
isStaticPath,
|
|
1466
|
-
mergeHeadersCookies,
|
|
1467
|
-
requestHandler
|
|
1468
|
-
};
|
|
1452
|
+
|
|
1453
|
+
export { AbortMessage, RedirectMessage, RequestEvShareQData, RewriteMessage, ServerError, _TextEncoderStream_polyfill, _asyncRequestStore, getErrorHtml, getNotFound, isStaticPath, mergeHeadersCookies, requestHandler };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { setServerPlatform } from
|
|
2
|
-
import { isStaticPath, mergeHeadersCookies, requestHandler, getNotFound } from
|
|
1
|
+
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
|
+
import { isStaticPath, mergeHeadersCookies, requestHandler, getNotFound } from '@qwik.dev/router/middleware/request-handler';
|
|
3
|
+
|
|
3
4
|
const COUNTRY_HEADER_NAME = "x-vercel-ip-country";
|
|
4
5
|
const IP_HEADER_NAME = "x-real-ip";
|
|
5
6
|
const VERCEL_COOKIE = "__vdpl";
|
|
@@ -92,7 +93,5 @@ function createQwikRouter(opts) {
|
|
|
92
93
|
return onVercelEdgeRequest;
|
|
93
94
|
}
|
|
94
95
|
const createQwikCity = createQwikRouter;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
createQwikRouter
|
|
98
|
-
};
|
|
96
|
+
|
|
97
|
+
export { createQwikCity, createQwikRouter };
|
package/lib/ssg/index.mjs
CHANGED
|
@@ -5,11 +5,10 @@ async function generate(opts) {
|
|
|
5
5
|
}
|
|
6
6
|
async function getEntryModule() {
|
|
7
7
|
try {
|
|
8
|
-
return await import(
|
|
8
|
+
return await import('../chunks/index.mjs');
|
|
9
9
|
} catch (e) {
|
|
10
10
|
throw new Error(`Unsupported platform`, { cause: e });
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
13
|
+
|
|
14
|
+
export { generate };
|
package/lib/vite/index.d.ts
CHANGED
|
@@ -99,7 +99,13 @@ declare interface PluginOptions {
|
|
|
99
99
|
mdxPlugins?: MdxPlugins;
|
|
100
100
|
/** MDX Options https://mdxjs.com/ */
|
|
101
101
|
mdx?: any;
|
|
102
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Extend the `platform` object in RequestEvent, which can be used to e.g. mock Cloudflare
|
|
104
|
+
* bindings.
|
|
105
|
+
*
|
|
106
|
+
* This only works in **dev mode** and only when using the in-process Vite dev server middleware
|
|
107
|
+
* (the default).
|
|
108
|
+
*/
|
|
103
109
|
platform?: Record<string, unknown>;
|
|
104
110
|
/** Configuration to rewrite url paths */
|
|
105
111
|
rewriteRoutes?: RewriteRouteOption[];
|