vinext 0.0.12 → 0.0.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/README.md +8 -2
- package/dist/client/entry.js +1 -1
- package/dist/client/entry.js.map +1 -1
- package/dist/config/config-matchers.d.ts.map +1 -1
- package/dist/config/config-matchers.js +11 -10
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +218 -11
- package/dist/deploy.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -13
- package/dist/index.js.map +1 -1
- package/dist/routing/app-router.js +12 -12
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/pages-router.js +9 -9
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/server/app-dev-server.d.ts.map +1 -1
- package/dist/server/app-dev-server.js +35 -25
- package/dist/server/app-dev-server.js.map +1 -1
- package/dist/server/app-router-entry.d.ts.map +1 -1
- package/dist/server/app-router-entry.js +13 -15
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/middleware-codegen.js +1 -1
- package/dist/server/middleware-codegen.js.map +1 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +11 -2
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/prod-server.d.ts.map +1 -1
- package/dist/server/prod-server.js +6 -2
- package/dist/server/prod-server.js.map +1 -1
- package/dist/shims/cache-runtime.d.ts.map +1 -1
- package/dist/shims/cache-runtime.js +2 -1
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/link.d.ts.map +1 -1
- package/dist/shims/link.js +1 -0
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/navigation.d.ts.map +1 -1
- package/dist/shims/navigation.js +25 -15
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.js +2 -2
- package/dist/shims/router.js.map +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +2 -1
- package/dist/utils/project.js.map +1 -1
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -585,7 +585,15 @@ export async function runMiddleware(request) {
|
|
|
585
585
|
|
|
586
586
|
if (!matchesMiddleware(normalizedPathname, matcher)) return { continue: true };
|
|
587
587
|
|
|
588
|
-
|
|
588
|
+
// Construct a new Request with the decoded + normalized pathname so middleware
|
|
589
|
+
// always sees the same canonical path that the router uses.
|
|
590
|
+
var mwRequest = request;
|
|
591
|
+
if (normalizedPathname !== url.pathname) {
|
|
592
|
+
var mwUrl = new URL(url);
|
|
593
|
+
mwUrl.pathname = normalizedPathname;
|
|
594
|
+
mwRequest = new Request(mwUrl, request);
|
|
595
|
+
}
|
|
596
|
+
var nextRequest = mwRequest instanceof NextRequest ? mwRequest : new NextRequest(mwRequest);
|
|
589
597
|
var response;
|
|
590
598
|
try { response = await middlewareFn(nextRequest); }
|
|
591
599
|
catch (e) {
|
|
@@ -598,7 +606,9 @@ export async function runMiddleware(request) {
|
|
|
598
606
|
if (response.headers.get("x-middleware-next") === "1") {
|
|
599
607
|
var rHeaders = new Headers();
|
|
600
608
|
for (var [key, value] of response.headers) {
|
|
601
|
-
|
|
609
|
+
// Strip ALL x-middleware-* headers — they are internal routing signals
|
|
610
|
+
// and must never reach clients.
|
|
611
|
+
if (!key.startsWith("x-middleware-")) rHeaders.set(key, value);
|
|
602
612
|
}
|
|
603
613
|
return { continue: true, responseHeaders: rHeaders };
|
|
604
614
|
}
|
|
@@ -611,7 +621,7 @@ export async function runMiddleware(request) {
|
|
|
611
621
|
var rewriteUrl = response.headers.get("x-middleware-rewrite");
|
|
612
622
|
if (rewriteUrl) {
|
|
613
623
|
var rwHeaders = new Headers();
|
|
614
|
-
for (var [k, v] of response.headers) { if (k
|
|
624
|
+
for (var [k, v] of response.headers) { if (!k.startsWith("x-middleware-")) rwHeaders.set(k, v); }
|
|
615
625
|
var rewritePath;
|
|
616
626
|
try { var parsed = new URL(rewriteUrl, request.url); rewritePath = parsed.pathname + parsed.search; }
|
|
617
627
|
catch { rewritePath = rewriteUrl; }
|
|
@@ -692,7 +702,8 @@ ${apiRouteEntries.join(",\n")}
|
|
|
692
702
|
function matchRoute(url, routes) {
|
|
693
703
|
const pathname = url.split("?")[0];
|
|
694
704
|
let normalizedUrl = pathname === "/" ? "/" : pathname.replace(/\\/$/, "");
|
|
695
|
-
|
|
705
|
+
// NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at
|
|
706
|
+
// the entry point. Decoding again would create a double-decode vector.
|
|
696
707
|
for (const route of routes) {
|
|
697
708
|
const params = matchPattern(normalizedUrl, route.pattern);
|
|
698
709
|
if (params !== null) return { route, params };
|
|
@@ -1518,6 +1529,7 @@ hydrate();
|
|
|
1518
1529
|
});
|
|
1519
1530
|
});
|
|
1520
1531
|
}
|
|
1532
|
+
const imageImportDimCache = new Map();
|
|
1521
1533
|
const plugins = [
|
|
1522
1534
|
// Resolve tsconfig paths/baseUrl aliases so real-world Next.js repos
|
|
1523
1535
|
// that use @/*, #/*, or baseUrl imports work out of the box.
|
|
@@ -2379,7 +2391,7 @@ hydrate();
|
|
|
2379
2391
|
name: "vinext:image-imports",
|
|
2380
2392
|
enforce: "pre",
|
|
2381
2393
|
// Cache of image dimensions to avoid re-reading files
|
|
2382
|
-
_dimCache:
|
|
2394
|
+
_dimCache: imageImportDimCache,
|
|
2383
2395
|
resolveId: {
|
|
2384
2396
|
filter: { id: /\?vinext-meta$/ },
|
|
2385
2397
|
handler(source, _importer) {
|
|
@@ -2395,7 +2407,7 @@ hydrate();
|
|
|
2395
2407
|
return null;
|
|
2396
2408
|
const imagePath = id.replace("\0vinext-image-meta:", "");
|
|
2397
2409
|
// Read from cache first
|
|
2398
|
-
const cache =
|
|
2410
|
+
const cache = imageImportDimCache;
|
|
2399
2411
|
let dims = cache.get(imagePath);
|
|
2400
2412
|
if (!dims) {
|
|
2401
2413
|
try {
|
|
@@ -3047,20 +3059,21 @@ export function matchConfigPattern(pathname, pattern) {
|
|
|
3047
3059
|
// the whole segment (":path*.md") as a named parameter and matches everything.
|
|
3048
3060
|
if (pattern.includes("(") ||
|
|
3049
3061
|
pattern.includes("\\") ||
|
|
3050
|
-
|
|
3062
|
+
/:[\w-]+[*+][^/]/.test(pattern)) {
|
|
3051
3063
|
try {
|
|
3052
3064
|
// Extract named params and their constraints from the pattern.
|
|
3053
3065
|
// :param(constraint) -> use constraint as the regex group
|
|
3054
3066
|
// :param -> ([^/]+)
|
|
3055
3067
|
// :param* -> (.*)
|
|
3056
3068
|
// :param+ -> (.+)
|
|
3069
|
+
// Param names may contain hyphens (e.g. :auth-method, :sign-in).
|
|
3057
3070
|
const paramNames = [];
|
|
3058
3071
|
// Single-pass conversion with procedural suffix handling. The tokenizer
|
|
3059
3072
|
// matches only simple, non-overlapping tokens; quantifier/constraint
|
|
3060
3073
|
// suffixes after :param are consumed procedurally to avoid polynomial
|
|
3061
3074
|
// backtracking in the regex engine.
|
|
3062
3075
|
let regexStr = "";
|
|
3063
|
-
const tokenRe = /:(\w+)|[.]|[^:.]+/g; // lgtm[js/redos] — alternatives are non-overlapping (`:` and `.` excluded from `[^:.]+`)
|
|
3076
|
+
const tokenRe = /:([\w-]+)|[.]|[^:.]+/g; // lgtm[js/redos] — alternatives are non-overlapping (`:` and `.` excluded from `[^:.]+`)
|
|
3064
3077
|
let tok;
|
|
3065
3078
|
while ((tok = tokenRe.exec(pattern)) !== null) {
|
|
3066
3079
|
if (tok[1] !== undefined) {
|
|
@@ -3110,7 +3123,8 @@ export function matchConfigPattern(pathname, pattern) {
|
|
|
3110
3123
|
}
|
|
3111
3124
|
}
|
|
3112
3125
|
// Check for catch-all patterns (:param* or :param+) without regex groups
|
|
3113
|
-
|
|
3126
|
+
// Param names may contain hyphens (e.g. :sign-in*, :sign-up+).
|
|
3127
|
+
const catchAllMatch = pattern.match(/:([\w-]+)(\*|\+)$/);
|
|
3114
3128
|
if (catchAllMatch) {
|
|
3115
3129
|
const prefix = pattern.slice(0, pattern.lastIndexOf(":"));
|
|
3116
3130
|
const paramName = catchAllMatch[1];
|
|
@@ -3123,10 +3137,8 @@ export function matchConfigPattern(pathname, pattern) {
|
|
|
3123
3137
|
return null;
|
|
3124
3138
|
// For :path* zero segments is fine
|
|
3125
3139
|
let restValue = rest.startsWith("/") ? rest.slice(1) : rest;
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
}
|
|
3129
|
-
catch { /* malformed percent-encoding */ }
|
|
3140
|
+
// NOTE: Do NOT decodeURIComponent here. The pathname is already decoded at
|
|
3141
|
+
// the entry point. Decoding again would create a double-decode vector.
|
|
3130
3142
|
return { [paramName]: restValue };
|
|
3131
3143
|
}
|
|
3132
3144
|
// Simple segment-based matching for exact patterns and :param
|