vinext 0.0.14 → 0.0.16
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 +6 -0
- package/dist/cli.js +21 -11
- package/dist/cli.js.map +1 -1
- package/dist/config/config-matchers.d.ts +4 -1
- package/dist/config/config-matchers.d.ts.map +1 -1
- package/dist/config/config-matchers.js +11 -1
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +2 -0
- package/dist/config/next-config.d.ts.map +1 -1
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +2 -0
- package/dist/deploy.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -59
- package/dist/index.js.map +1 -1
- package/dist/server/app-dev-server.d.ts.map +1 -1
- package/dist/server/app-dev-server.js +29 -13
- package/dist/server/app-dev-server.js.map +1 -1
- package/dist/server/middleware.d.ts +23 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +44 -10
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/prod-server.d.ts.map +1 -1
- package/dist/server/prod-server.js +30 -4
- package/dist/server/prod-server.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts.map +1 -1
- package/dist/shims/fetch-cache.js +73 -41
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +68 -0
- package/dist/shims/font-google-base.d.ts.map +1 -0
- package/dist/shims/font-google-base.js +365 -0
- package/dist/shims/font-google-base.js.map +1 -0
- package/dist/shims/font-google.d.ts +2 -121
- package/dist/shims/font-google.d.ts.map +1 -1
- package/dist/shims/font-google.generated.d.ts +1925 -0
- package/dist/shims/font-google.generated.d.ts.map +1 -0
- package/dist/shims/font-google.generated.js +1928 -0
- package/dist/shims/font-google.generated.js.map +1 -0
- package/dist/shims/font-google.js +2 -386
- package/dist/shims/font-google.js.map +1 -1
- package/dist/shims/form.d.ts.map +1 -1
- package/dist/shims/form.js +32 -0
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/link.d.ts.map +1 -1
- package/dist/shims/link.js +11 -0
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/url-safety.d.ts +8 -0
- package/dist/shims/url-safety.d.ts.map +1 -0
- package/dist/shims/url-safety.js +16 -0
- package/dist/shims/url-safety.js.map +1 -0
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +4 -0
- package/dist/utils/project.js.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-dev-server.d.ts","sourceRoot":"","sources":["../../src/server/app-dev-server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"app-dev-server.d.ts","sourceRoot":"","sources":["../../src/server/app-dev-server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAKtF;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE;QACT,WAAW,EAAE,WAAW,EAAE,CAAC;QAC3B,UAAU,EAAE,WAAW,EAAE,CAAC;QAC1B,QAAQ,EAAE,WAAW,EAAE,CAAC;KACzB,CAAC;IACF,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,4GAA4G;IAC5G,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,uGAAuG;IACvG,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,QAAQ,EAAE,EAClB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,EAC9B,cAAc,CAAC,EAAE,iBAAiB,EAAE,EACpC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,EAC/B,QAAQ,CAAC,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,MAAM,CAAC,EAAE,eAAe,GACvB,MAAM,CA+nER;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CA4XzC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CA4S7C"}
|
|
@@ -10,6 +10,7 @@ import fs from "node:fs";
|
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
import { generateDevOriginCheckCode } from "./dev-origin-check.js";
|
|
12
12
|
import { generateSafeRegExpCode, generateMiddlewareMatcherCode, generateNormalizePathCode } from "./middleware-codegen.js";
|
|
13
|
+
import { isProxyFile } from "./middleware.js";
|
|
13
14
|
/**
|
|
14
15
|
* Generate the virtual RSC entry module.
|
|
15
16
|
*
|
|
@@ -1135,7 +1136,7 @@ async function __proxyExternalRequest(request, externalUrl) {
|
|
|
1135
1136
|
return new Response(upstream.body, { status: upstream.status, statusText: upstream.statusText, headers: respHeaders });
|
|
1136
1137
|
}
|
|
1137
1138
|
|
|
1138
|
-
function __applyConfigHeaders(pathname) {
|
|
1139
|
+
function __applyConfigHeaders(pathname, ctx) {
|
|
1139
1140
|
const result = [];
|
|
1140
1141
|
for (const rule of __configHeaders) {
|
|
1141
1142
|
const groups = [];
|
|
@@ -1151,7 +1152,12 @@ function __applyConfigHeaders(pathname) {
|
|
|
1151
1152
|
.replace(/:[\\w-]+/g, "[^/]+")
|
|
1152
1153
|
.replace(/___GROUP_(\\d+)___/g, (_, idx) => "(" + groups[Number(idx)] + ")");
|
|
1153
1154
|
const sourceRegex = __safeRegExp("^" + escaped + "$");
|
|
1154
|
-
if (sourceRegex && sourceRegex.test(pathname))
|
|
1155
|
+
if (sourceRegex && sourceRegex.test(pathname)) {
|
|
1156
|
+
if (ctx && (rule.has || rule.missing)) {
|
|
1157
|
+
if (!__checkHasConditions(rule.has, rule.missing, ctx)) continue;
|
|
1158
|
+
}
|
|
1159
|
+
result.push(...rule.headers);
|
|
1160
|
+
}
|
|
1155
1161
|
}
|
|
1156
1162
|
return result;
|
|
1157
1163
|
}
|
|
@@ -1168,7 +1174,8 @@ export default async function handler(request) {
|
|
|
1168
1174
|
_runWithCacheState(() =>
|
|
1169
1175
|
_runWithPrivateCache(() =>
|
|
1170
1176
|
runWithFetchCache(async () => {
|
|
1171
|
-
const
|
|
1177
|
+
const __reqCtx = __buildRequestContext(request);
|
|
1178
|
+
const response = await _handleRequest(request, __reqCtx);
|
|
1172
1179
|
// Apply custom headers from next.config.js to non-redirect responses.
|
|
1173
1180
|
// Skip redirects (3xx) because Response.redirect() creates immutable headers,
|
|
1174
1181
|
// and Next.js doesn't apply custom headers to redirects anyway.
|
|
@@ -1177,7 +1184,7 @@ export default async function handler(request) {
|
|
|
1177
1184
|
let pathname;
|
|
1178
1185
|
try { pathname = __normalizePath(decodeURIComponent(url.pathname)); } catch { pathname = url.pathname; }
|
|
1179
1186
|
${bp ? `if (pathname.startsWith(${JSON.stringify(bp)})) pathname = pathname.slice(${JSON.stringify(bp)}.length) || "/";` : ""}
|
|
1180
|
-
const extraHeaders = __applyConfigHeaders(pathname);
|
|
1187
|
+
const extraHeaders = __applyConfigHeaders(pathname, __reqCtx);
|
|
1181
1188
|
for (const h of extraHeaders) {
|
|
1182
1189
|
response.headers.set(h.key, h.value);
|
|
1183
1190
|
}
|
|
@@ -1190,7 +1197,7 @@ export default async function handler(request) {
|
|
|
1190
1197
|
);
|
|
1191
1198
|
}
|
|
1192
1199
|
|
|
1193
|
-
async function _handleRequest(request) {
|
|
1200
|
+
async function _handleRequest(request, __reqCtx) {
|
|
1194
1201
|
const url = new URL(request.url);
|
|
1195
1202
|
|
|
1196
1203
|
// ── Cross-origin request protection ─────────────────────────────────
|
|
@@ -1236,7 +1243,6 @@ async function _handleRequest(request) {
|
|
|
1236
1243
|
}
|
|
1237
1244
|
|
|
1238
1245
|
// ── Apply redirects from next.config.js ───────────────────────────────
|
|
1239
|
-
const __reqCtx = __buildRequestContext(request);
|
|
1240
1246
|
if (__configRedirects.length) {
|
|
1241
1247
|
const __redir = __applyConfigRedirects(pathname, __reqCtx);
|
|
1242
1248
|
if (__redir) {
|
|
@@ -1274,10 +1280,20 @@ async function _handleRequest(request) {
|
|
|
1274
1280
|
let _middlewareRewriteStatus = null;
|
|
1275
1281
|
|
|
1276
1282
|
${middlewarePath ? `
|
|
1277
|
-
|
|
1278
|
-
|
|
1283
|
+
// Run proxy/middleware if present and path matches.
|
|
1284
|
+
// Validate exports match the file type (proxy.ts vs middleware.ts), matching Next.js behavior.
|
|
1285
|
+
// https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/proxy-missing-export/proxy-missing-export.test.ts
|
|
1286
|
+
const _isProxy = ${JSON.stringify(isProxyFile(middlewarePath))};
|
|
1287
|
+
const middlewareFn = _isProxy
|
|
1288
|
+
? (middlewareModule.proxy ?? middlewareModule.default)
|
|
1289
|
+
: (middlewareModule.middleware ?? middlewareModule.default);
|
|
1290
|
+
if (typeof middlewareFn !== "function") {
|
|
1291
|
+
const _fileType = _isProxy ? "Proxy" : "Middleware";
|
|
1292
|
+
const _expectedExport = _isProxy ? "proxy" : "middleware";
|
|
1293
|
+
throw new Error("The " + _fileType + " file must export a function named \`" + _expectedExport + "\` or a \`default\` function.");
|
|
1294
|
+
}
|
|
1279
1295
|
const middlewareMatcher = middlewareModule.config?.matcher;
|
|
1280
|
-
if (
|
|
1296
|
+
if (matchesMiddleware(cleanPathname, middlewareMatcher)) {
|
|
1281
1297
|
try {
|
|
1282
1298
|
// Wrap in NextRequest so middleware gets .nextUrl, .cookies, .geo, .ip, etc.
|
|
1283
1299
|
// Always construct a new Request with the fully decoded + normalized pathname
|
|
@@ -1295,10 +1311,10 @@ async function _handleRequest(request) {
|
|
|
1295
1311
|
// headers are kept so applyMiddlewareRequestHeaders() can unpack them;
|
|
1296
1312
|
// the blanket strip loop after that call removes every remaining
|
|
1297
1313
|
// x-middleware-* header before the set is merged into the response.
|
|
1298
|
-
|
|
1314
|
+
_middlewareResponseHeaders = new Headers();
|
|
1299
1315
|
for (const [key, value] of mwResponse.headers) {
|
|
1300
1316
|
if (key !== "x-middleware-next" && key !== "x-middleware-rewrite") {
|
|
1301
|
-
_middlewareResponseHeaders.
|
|
1317
|
+
_middlewareResponseHeaders.append(key, value);
|
|
1302
1318
|
}
|
|
1303
1319
|
}
|
|
1304
1320
|
} else {
|
|
@@ -1319,7 +1335,7 @@ async function _handleRequest(request) {
|
|
|
1319
1335
|
_middlewareResponseHeaders = new Headers();
|
|
1320
1336
|
for (const [key, value] of mwResponse.headers) {
|
|
1321
1337
|
if (key !== "x-middleware-next" && key !== "x-middleware-rewrite") {
|
|
1322
|
-
_middlewareResponseHeaders.
|
|
1338
|
+
_middlewareResponseHeaders.append(key, value);
|
|
1323
1339
|
}
|
|
1324
1340
|
}
|
|
1325
1341
|
} else {
|
|
@@ -2107,7 +2123,7 @@ async function _handleRequest(request) {
|
|
|
2107
2123
|
// Merge middleware response headers into the final response
|
|
2108
2124
|
if (_middlewareResponseHeaders) {
|
|
2109
2125
|
for (const [key, value] of _middlewareResponseHeaders) {
|
|
2110
|
-
response.headers.
|
|
2126
|
+
response.headers.append(key, value);
|
|
2111
2127
|
}
|
|
2112
2128
|
}
|
|
2113
2129
|
// Apply custom status code from middleware rewrite
|