Unverified Commit bbfcbe96 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Rename MiddlewareMatcher to ProxyMatcher (#85005)

Follow up on https://github.com/vercel/next.js/pull/84710, `adapterPath`
docs had `MiddlewareMatcher` type, used in `ProxyConfig` type. As it's a
user-facing type, update it.
parent bae8bf46
...@@ -23,9 +23,8 @@ use next_core::{ ...@@ -23,9 +23,8 @@ use next_core::{
next_dynamic::NextDynamicTransition, next_dynamic::NextDynamicTransition,
next_edge::route_regex::get_named_middleware_regex, next_edge::route_regex::get_named_middleware_regex,
next_manifests::{ next_manifests::{
AppPathsManifest, BuildManifest, EdgeFunctionDefinition, MiddlewareMatcher, AppPathsManifest, BuildManifest, EdgeFunctionDefinition, MiddlewaresManifestV2,
MiddlewaresManifestV2, PagesManifest, Regions, PagesManifest, ProxyMatcher, Regions, client_reference_manifest::ClientReferenceManifest,
client_reference_manifest::ClientReferenceManifest,
}, },
next_server::{ next_server::{
ServerContextType, get_server_module_options_context, get_server_resolve_options_context, ServerContextType, get_server_module_options_context, get_server_resolve_options_context,
...@@ -1561,7 +1560,7 @@ impl AppEndpoint { ...@@ -1561,7 +1560,7 @@ impl AppEndpoint {
if emit_manifests != EmitManifests::None { if emit_manifests != EmitManifests::None {
// create middleware manifest // create middleware manifest
let named_regex = get_named_middleware_regex(&app_entry.pathname); let named_regex = get_named_middleware_regex(&app_entry.pathname);
let matchers = MiddlewareMatcher { let matchers = ProxyMatcher {
regexp: Some(named_regex.into()), regexp: Some(named_regex.into()),
original_source: app_entry.pathname.clone(), original_source: app_entry.pathname.clone(),
..Default::default() ..Default::default()
......
...@@ -5,7 +5,7 @@ use next_core::{ ...@@ -5,7 +5,7 @@ use next_core::{
all_assets_from_entries, all_assets_from_entries,
middleware::get_middleware_module, middleware::get_middleware_module,
next_edge::entry::wrap_edge_entry, next_edge::entry::wrap_edge_entry,
next_manifests::{EdgeFunctionDefinition, MiddlewareMatcher, MiddlewaresManifestV2, Regions}, next_manifests::{EdgeFunctionDefinition, MiddlewaresManifestV2, ProxyMatcher, Regions},
parse_segment_config_from_source, parse_segment_config_from_source,
segment_config::ParseSegmentMode, segment_config::ParseSegmentMode,
util::{MiddlewareMatcherKind, NextRuntime}, util::{MiddlewareMatcherKind, NextRuntime},
...@@ -171,7 +171,7 @@ impl MiddlewareEndpoint { ...@@ -171,7 +171,7 @@ impl MiddlewareEndpoint {
.iter() .iter()
.map(|matcher| { .map(|matcher| {
let mut matcher = match matcher { let mut matcher = match matcher {
MiddlewareMatcherKind::Str(matcher) => MiddlewareMatcher { MiddlewareMatcherKind::Str(matcher) => ProxyMatcher {
original_source: matcher.as_str().into(), original_source: matcher.as_str().into(),
..Default::default() ..Default::default()
}, },
...@@ -216,7 +216,7 @@ impl MiddlewareEndpoint { ...@@ -216,7 +216,7 @@ impl MiddlewareEndpoint {
}) })
.collect() .collect()
} else { } else {
vec![MiddlewareMatcher { vec![ProxyMatcher {
regexp: Some(rcstr!("^/.*$")), regexp: Some(rcstr!("^/.*$")),
original_source: rcstr!("/:path*"), original_source: rcstr!("/:path*"),
..Default::default() ..Default::default()
......
...@@ -12,8 +12,8 @@ use next_core::{ ...@@ -12,8 +12,8 @@ use next_core::{
next_dynamic::NextDynamicTransition, next_dynamic::NextDynamicTransition,
next_edge::route_regex::get_named_middleware_regex, next_edge::route_regex::get_named_middleware_regex,
next_manifests::{ next_manifests::{
BuildManifest, ClientBuildManifest, EdgeFunctionDefinition, MiddlewareMatcher, BuildManifest, ClientBuildManifest, EdgeFunctionDefinition, MiddlewaresManifestV2,
MiddlewaresManifestV2, PagesManifest, Regions, PagesManifest, ProxyMatcher, Regions,
}, },
next_pages::create_page_ssr_entry_module, next_pages::create_page_ssr_entry_module,
next_server::{ next_server::{
...@@ -1500,7 +1500,7 @@ impl PageEndpoint { ...@@ -1500,7 +1500,7 @@ impl PageEndpoint {
}; };
let named_regex = get_named_middleware_regex(&this.pathname).into(); let named_regex = get_named_middleware_regex(&this.pathname).into();
let matchers = MiddlewareMatcher { let matchers = ProxyMatcher {
regexp: Some(named_regex), regexp: Some(named_regex),
original_source: this.pathname.clone(), original_source: this.pathname.clone(),
..Default::default() ..Default::default()
......
...@@ -238,7 +238,7 @@ impl Default for MiddlewaresManifest { ...@@ -238,7 +238,7 @@ impl Default for MiddlewaresManifest {
NonLocalValue, NonLocalValue,
)] )]
#[serde(rename_all = "camelCase", default)] #[serde(rename_all = "camelCase", default)]
pub struct MiddlewareMatcher { pub struct ProxyMatcher {
// When skipped next.js with fill that during merging. // When skipped next.js with fill that during merging.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub regexp: Option<RcStr>, pub regexp: Option<RcStr>,
...@@ -251,7 +251,7 @@ pub struct MiddlewareMatcher { ...@@ -251,7 +251,7 @@ pub struct MiddlewareMatcher {
pub original_source: RcStr, pub original_source: RcStr,
} }
impl Default for MiddlewareMatcher { impl Default for ProxyMatcher {
fn default() -> Self { fn default() -> Self {
Self { Self {
regexp: None, regexp: None,
...@@ -272,7 +272,7 @@ pub struct EdgeFunctionDefinition { ...@@ -272,7 +272,7 @@ pub struct EdgeFunctionDefinition {
pub files: Vec<RcStr>, pub files: Vec<RcStr>,
pub name: RcStr, pub name: RcStr,
pub page: RcStr, pub page: RcStr,
pub matchers: Vec<MiddlewareMatcher>, pub matchers: Vec<ProxyMatcher>,
pub wasm: Vec<AssetBinding>, pub wasm: Vec<AssetBinding>,
pub assets: Vec<AssetBinding>, pub assets: Vec<AssetBinding>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
...@@ -446,14 +446,14 @@ mod tests { ...@@ -446,14 +446,14 @@ mod tests {
#[test] #[test]
fn test_middleware_matcher_serialization() { fn test_middleware_matcher_serialization() {
let matchers = vec![ let matchers = vec![
MiddlewareMatcher { ProxyMatcher {
regexp: None, regexp: None,
locale: false, locale: false,
has: None, has: None,
missing: None, missing: None,
original_source: rcstr!(""), original_source: rcstr!(""),
}, },
MiddlewareMatcher { ProxyMatcher {
regexp: Some(rcstr!(".*")), regexp: Some(rcstr!(".*")),
locale: true, locale: true,
has: Some(vec![RouteHas::Query { has: Some(vec![RouteHas::Query {
...@@ -469,7 +469,7 @@ mod tests { ...@@ -469,7 +469,7 @@ mod tests {
]; ];
let serialized = serde_json::to_string(&matchers).unwrap(); let serialized = serde_json::to_string(&matchers).unwrap();
let deserialized: Vec<MiddlewareMatcher> = serde_json::from_str(&serialized).unwrap(); let deserialized: Vec<ProxyMatcher> = serde_json::from_str(&serialized).unwrap();
assert_eq!(matchers, deserialized); assert_eq!(matchers, deserialized);
} }
......
...@@ -37,7 +37,7 @@ use turbopack_ecmascript::{ ...@@ -37,7 +37,7 @@ use turbopack_ecmascript::{
use crate::{ use crate::{
app_structure::AppPageLoaderTree, app_structure::AppPageLoaderTree,
next_config::RouteHas, next_config::RouteHas,
next_manifests::MiddlewareMatcher, next_manifests::ProxyMatcher,
util::{MiddlewareMatcherKind, NextRuntime}, util::{MiddlewareMatcherKind, NextRuntime},
}; };
...@@ -1121,7 +1121,7 @@ async fn parse_route_matcher_from_js_value( ...@@ -1121,7 +1121,7 @@ async fn parse_route_matcher_from_js_value(
if let Some(matcher) = item.as_str() { if let Some(matcher) = item.as_str() {
matchers.push(MiddlewareMatcherKind::Str(matcher.to_string())); matchers.push(MiddlewareMatcherKind::Str(matcher.to_string()));
} else if let JsValue::Object { parts, .. } = item { } else if let JsValue::Object { parts, .. } = item {
let mut matcher = MiddlewareMatcher::default(); let mut matcher = ProxyMatcher::default();
let mut had_source = false; let mut had_source = false;
for matcher_part in parts { for matcher_part in parts {
if let ObjectPart::KeyValue(key, value) = matcher_part { if let ObjectPart::KeyValue(key, value) = matcher_part {
......
...@@ -20,7 +20,7 @@ use turbopack_core::{ ...@@ -20,7 +20,7 @@ use turbopack_core::{
use crate::{ use crate::{
embed_js::next_js_fs, next_config::NextConfig, next_import_map::get_next_package, embed_js::next_js_fs, next_config::NextConfig, next_import_map::get_next_package,
next_manifests::MiddlewareMatcher, next_shared::webpack_rules::WebpackLoaderBuiltinCondition, next_manifests::ProxyMatcher, next_shared::webpack_rules::WebpackLoaderBuiltinCondition,
}; };
const NEXT_TEMPLATE_PATH: &str = "dist/esm/build/templates"; const NEXT_TEMPLATE_PATH: &str = "dist/esm/build/templates";
...@@ -232,7 +232,7 @@ impl NextRuntime { ...@@ -232,7 +232,7 @@ impl NextRuntime {
#[derive(PartialEq, Eq, Clone, Debug, TraceRawVcs, Serialize, Deserialize, NonLocalValue)] #[derive(PartialEq, Eq, Clone, Debug, TraceRawVcs, Serialize, Deserialize, NonLocalValue)]
pub enum MiddlewareMatcherKind { pub enum MiddlewareMatcherKind {
Str(String), Str(String),
Matcher(MiddlewareMatcher), Matcher(ProxyMatcher),
} }
/// Loads a next.js template, replaces `replacements` and `injections` and makes /// Loads a next.js template, replaces `replacements` and `injections` and makes
......
...@@ -264,7 +264,7 @@ Middleware function (if present): ...@@ -264,7 +264,7 @@ Middleware function (if present):
config: { config: {
maxDuration?: number maxDuration?: number
preferredRegion?: string | string[] preferredRegion?: string | string[]
matchers?: MiddlewareMatcher[] matchers?: ProxyMatcher[]
} }
} }
``` ```
......
...@@ -10,7 +10,7 @@ import { recursiveReadDir } from '../../lib/recursive-readdir' ...@@ -10,7 +10,7 @@ import { recursiveReadDir } from '../../lib/recursive-readdir'
import { isDynamicRoute } from '../../shared/lib/router/utils' import { isDynamicRoute } from '../../shared/lib/router/utils'
import type { Revalidate } from '../../server/lib/cache-control' import type { Revalidate } from '../../server/lib/cache-control'
import type { NextConfigComplete } from '../../server/config-shared' import type { NextConfigComplete } from '../../server/config-shared'
import type { MiddlewareMatcher } from '../analysis/get-page-static-info' import type { ProxyMatcher } from '../analysis/get-page-static-info'
import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths' import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'
import { AdapterOutputType, type PHASE_TYPE } from '../../shared/lib/constants' import { AdapterOutputType, type PHASE_TYPE } from '../../shared/lib/constants'
import { normalizePagePath } from '../../shared/lib/page-path/normalize-page-path' import { normalizePagePath } from '../../shared/lib/page-path/normalize-page-path'
...@@ -212,7 +212,7 @@ export interface AdapterOutput { ...@@ -212,7 +212,7 @@ export interface AdapterOutput {
/** /**
* matchers are the configured matchers for middleware * matchers are the configured matchers for middleware
*/ */
matchers?: MiddlewareMatcher[] matchers?: ProxyMatcher[]
/** /**
* bypassToken is the generated token that signals a prerender cache * bypassToken is the generated token that signals a prerender cache
...@@ -246,7 +246,7 @@ export interface AdapterOutput { ...@@ -246,7 +246,7 @@ export interface AdapterOutput {
/** /**
* matchers are the configured matchers for middleware * matchers are the configured matchers for middleware
*/ */
matchers?: MiddlewareMatcher[] matchers?: ProxyMatcher[]
} }
} }
} }
......
...@@ -44,7 +44,7 @@ import { normalizePagePath } from '../../shared/lib/page-path/normalize-page-pat ...@@ -44,7 +44,7 @@ import { normalizePagePath } from '../../shared/lib/page-path/normalize-page-pat
const PARSE_PATTERN = const PARSE_PATTERN =
/(?<!(_jsx|jsx-))runtime|preferredRegion|getStaticProps|getServerSideProps|generateStaticParams|export const|generateImageMetadata|generateSitemaps|middleware|proxy/ /(?<!(_jsx|jsx-))runtime|preferredRegion|getStaticProps|getServerSideProps|generateStaticParams|export const|generateImageMetadata|generateSitemaps|middleware|proxy/
export type MiddlewareMatcher = { export type ProxyMatcher = {
regexp: string regexp: string
locale?: false locale?: false
has?: RouteHas[] has?: RouteHas[]
...@@ -54,13 +54,13 @@ export type MiddlewareMatcher = { ...@@ -54,13 +54,13 @@ export type MiddlewareMatcher = {
export type ProxyConfig = { export type ProxyConfig = {
/** /**
* The matcher for the middleware. Read more: [Next.js Docs: Middleware `matcher`](https://nextjs.org/docs/app/api-reference/file-conventions/proxy#matcher), * The matcher for the proxy. Read more: [Next.js Docs: Proxy `matcher`](https://nextjs.org/docs/app/api-reference/file-conventions/proxy#matcher),
* [Next.js Docs: Middleware matching paths](https://nextjs.org/docs/app/building-your-application/routing/middleware#matching-paths) * [Next.js Docs: Proxy matching paths](https://nextjs.org/docs/app/building-your-application/routing/proxy#matching-paths)
*/ */
matchers?: MiddlewareMatcher[] matchers?: ProxyMatcher[]
/** /**
* The regions that the middleware should run in. * The regions that the proxy should run in.
*/ */
regions?: string | string[] regions?: string | string[]
...@@ -422,7 +422,7 @@ async function tryToReadFile(filePath: string, shouldThrow: boolean) { ...@@ -422,7 +422,7 @@ async function tryToReadFile(filePath: string, shouldThrow: boolean) {
export function getMiddlewareMatchers( export function getMiddlewareMatchers(
matcherOrMatchers: MiddlewareConfigMatcherInput, matcherOrMatchers: MiddlewareConfigMatcherInput,
nextConfig: Pick<NextConfig, 'basePath' | 'i18n'> nextConfig: Pick<NextConfig, 'basePath' | 'i18n'>
): MiddlewareMatcher[] { ): ProxyMatcher[] {
const matchers = Array.isArray(matcherOrMatchers) const matchers = Array.isArray(matcherOrMatchers)
? matcherOrMatchers ? matcherOrMatchers
: [matcherOrMatchers] : [matcherOrMatchers]
......
...@@ -3,7 +3,7 @@ import type { ...@@ -3,7 +3,7 @@ import type {
I18NDomains, I18NDomains,
NextConfigComplete, NextConfigComplete,
} from '../server/config-shared' } from '../server/config-shared'
import type { MiddlewareMatcher } from './analysis/get-page-static-info' import type { ProxyMatcher } from './analysis/get-page-static-info'
import type { Rewrite } from '../lib/load-custom-routes' import type { Rewrite } from '../lib/load-custom-routes'
import path from 'node:path' import path from 'node:path'
import { needsExperimentalReact } from '../lib/needs-experimental-react' import { needsExperimentalReact } from '../lib/needs-experimental-react'
...@@ -32,7 +32,7 @@ export interface DefineEnvOptions { ...@@ -32,7 +32,7 @@ export interface DefineEnvOptions {
isClient: boolean isClient: boolean
isEdgeServer: boolean isEdgeServer: boolean
isNodeServer: boolean isNodeServer: boolean
middlewareMatchers: MiddlewareMatcher[] | undefined middlewareMatchers: ProxyMatcher[] | undefined
omitNonDeterministic?: boolean omitNonDeterministic?: boolean
rewrites: { rewrites: {
beforeFiles: Rewrite[] beforeFiles: Rewrite[]
...@@ -46,7 +46,7 @@ interface DefineEnv { ...@@ -46,7 +46,7 @@ interface DefineEnv {
| string | string
| string[] | string[]
| boolean | boolean
| MiddlewareMatcher[] | ProxyMatcher[]
| BloomFilter | BloomFilter
| Partial<NextConfigComplete['images']> | Partial<NextConfigComplete['images']>
| I18NDomains | I18NDomains
......
...@@ -6,7 +6,7 @@ import type { NextConfigComplete } from '../server/config-shared' ...@@ -6,7 +6,7 @@ import type { NextConfigComplete } from '../server/config-shared'
import type { webpack } from 'next/dist/compiled/webpack/webpack' import type { webpack } from 'next/dist/compiled/webpack/webpack'
import type { import type {
ProxyConfig, ProxyConfig,
MiddlewareMatcher, ProxyMatcher,
PageStaticInfo, PageStaticInfo,
} from './analysis/get-page-static-info' } from './analysis/get-page-static-info'
import type { LoadedEnvFiles } from '@next/env' import type { LoadedEnvFiles } from '@next/env'
...@@ -832,7 +832,7 @@ export async function createEntrypoints( ...@@ -832,7 +832,7 @@ export async function createEntrypoints(
const edgeServer: webpack.EntryObject = {} const edgeServer: webpack.EntryObject = {}
const server: webpack.EntryObject = {} const server: webpack.EntryObject = {}
const client: webpack.EntryObject = {} const client: webpack.EntryObject = {}
let middlewareMatchers: MiddlewareMatcher[] | undefined = undefined let middlewareMatchers: ProxyMatcher[] | undefined = undefined
let appPathsPerRoute: Record<string, string[]> = {} let appPathsPerRoute: Record<string, string[]> = {}
if (appDir && appPaths) { if (appDir && appPaths) {
......
...@@ -56,7 +56,7 @@ import type { ...@@ -56,7 +56,7 @@ import type {
SWC_TARGET_TRIPLE, SWC_TARGET_TRIPLE,
} from './webpack/plugins/telemetry-plugin/telemetry-plugin' } from './webpack/plugins/telemetry-plugin/telemetry-plugin'
import type { Span } from '../trace' import type { Span } from '../trace'
import type { MiddlewareMatcher } from './analysis/get-page-static-info' import type { ProxyMatcher } from './analysis/get-page-static-info'
import loadJsConfig, { import loadJsConfig, {
type JsConfig, type JsConfig,
type ResolvedBaseUrl, type ResolvedBaseUrl,
...@@ -346,7 +346,7 @@ export default async function getBaseWebpackConfig( ...@@ -346,7 +346,7 @@ export default async function getBaseWebpackConfig(
originalRedirects: CustomRoutes['redirects'] | undefined originalRedirects: CustomRoutes['redirects'] | undefined
runWebpackSpan: Span runWebpackSpan: Span
appDir: string | undefined appDir: string | undefined
middlewareMatchers?: MiddlewareMatcher[] middlewareMatchers?: ProxyMatcher[]
noMangling?: boolean noMangling?: boolean
jsConfig: any jsConfig: any
jsConfigPath?: string jsConfigPath?: string
......
import type { import type {
ProxyConfig, ProxyConfig,
MiddlewareMatcher, ProxyMatcher,
RSCModuleType, RSCModuleType,
} from '../../analysis/get-page-static-info' } from '../../analysis/get-page-static-info'
import type { webpack } from 'next/dist/compiled/webpack/webpack' import type { webpack } from 'next/dist/compiled/webpack/webpack'
...@@ -47,7 +47,7 @@ export interface RouteMeta { ...@@ -47,7 +47,7 @@ export interface RouteMeta {
export interface EdgeMiddlewareMeta { export interface EdgeMiddlewareMeta {
page: string page: string
matchers?: MiddlewareMatcher[] matchers?: ProxyMatcher[]
} }
export interface EdgeSSRMeta { export interface EdgeSSRMeta {
......
import type { import type {
ProxyConfig, ProxyConfig,
MiddlewareMatcher, ProxyMatcher,
} from '../../analysis/get-page-static-info' } from '../../analysis/get-page-static-info'
import { getModuleBuildInfo } from './get-module-build-info' import { getModuleBuildInfo } from './get-module-build-info'
import { import {
...@@ -20,14 +20,14 @@ export type MiddlewareLoaderOptions = { ...@@ -20,14 +20,14 @@ export type MiddlewareLoaderOptions = {
// matchers can have special characters that break the loader params // matchers can have special characters that break the loader params
// parsing so we base64 encode/decode the string // parsing so we base64 encode/decode the string
export function encodeMatchers(matchers: MiddlewareMatcher[]) { export function encodeMatchers(matchers: ProxyMatcher[]) {
return Buffer.from(JSON.stringify(matchers)).toString('base64') return Buffer.from(JSON.stringify(matchers)).toString('base64')
} }
export function decodeMatchers(encodedMatchers: string) { export function decodeMatchers(encodedMatchers: string) {
return JSON.parse( return JSON.parse(
Buffer.from(encodedMatchers, 'base64').toString() Buffer.from(encodedMatchers, 'base64').toString()
) as MiddlewareMatcher[] ) as ProxyMatcher[]
} }
export default async function middlewareLoader(this: any) { export default async function middlewareLoader(this: any) {
......
...@@ -3,7 +3,7 @@ import type { ...@@ -3,7 +3,7 @@ import type {
EdgeMiddlewareMeta, EdgeMiddlewareMeta,
} from '../loaders/get-module-build-info' } from '../loaders/get-module-build-info'
import type { EdgeSSRMeta } from '../loaders/get-module-build-info' import type { EdgeSSRMeta } from '../loaders/get-module-build-info'
import type { MiddlewareMatcher } from '../../analysis/get-page-static-info' import type { ProxyMatcher } from '../../analysis/get-page-static-info'
import { getNamedMiddlewareRegex } from '../../../shared/lib/router/utils/route-regex' import { getNamedMiddlewareRegex } from '../../../shared/lib/router/utils/route-regex'
import { getModuleBuildInfo } from '../loaders/get-module-build-info' import { getModuleBuildInfo } from '../loaders/get-module-build-info'
import { getSortedRoutes } from '../../../shared/lib/router/utils' import { getSortedRoutes } from '../../../shared/lib/router/utils'
...@@ -44,7 +44,7 @@ export interface EdgeFunctionDefinition { ...@@ -44,7 +44,7 @@ export interface EdgeFunctionDefinition {
files: string[] files: string[]
name: string name: string
page: string page: string
matchers: MiddlewareMatcher[] matchers: ProxyMatcher[]
env: Record<string, string> env: Record<string, string>
wasm?: AssetBinding[] wasm?: AssetBinding[]
assets?: AssetBinding[] assets?: AssetBinding[]
......
import type { ComponentType } from 'react' import type { ComponentType } from 'react'
import type { RouteLoader } from './route-loader' import type { RouteLoader } from './route-loader'
import type { MiddlewareMatcher } from '../build/analysis/get-page-static-info' import type { ProxyMatcher } from '../build/analysis/get-page-static-info'
import { addBasePath } from './add-base-path' import { addBasePath } from './add-base-path'
import { interpolateAs } from '../shared/lib/router/utils/interpolate-as' import { interpolateAs } from '../shared/lib/router/utils/interpolate-as'
import getAssetPathFromRoute from '../shared/lib/router/utils/get-asset-path-from-route' import getAssetPathFromRoute from '../shared/lib/router/utils/get-asset-path-from-route'
...@@ -17,7 +17,7 @@ import { ...@@ -17,7 +17,7 @@ import {
declare global { declare global {
interface Window { interface Window {
__DEV_MIDDLEWARE_MATCHERS?: MiddlewareMatcher[] __DEV_MIDDLEWARE_MATCHERS?: ProxyMatcher[]
__DEV_PAGES_MANIFEST?: { pages: string[] } __DEV_PAGES_MANIFEST?: { pages: string[] }
__SSG_MANIFEST_CB?: () => void __SSG_MANIFEST_CB?: () => void
__SSG_MANIFEST?: Set<string> __SSG_MANIFEST?: Set<string>
...@@ -36,7 +36,7 @@ export default class PageLoader { ...@@ -36,7 +36,7 @@ export default class PageLoader {
private assetPrefix: string private assetPrefix: string
private promisedSsgManifest: Promise<Set<string>> private promisedSsgManifest: Promise<Set<string>>
private promisedDevPagesManifest?: Promise<string[]> private promisedDevPagesManifest?: Promise<string[]>
private promisedMiddlewareMatchers?: Promise<MiddlewareMatcher[]> private promisedMiddlewareMatchers?: Promise<ProxyMatcher[]>
public routeLoader: RouteLoader public routeLoader: RouteLoader
...@@ -93,7 +93,7 @@ export default class PageLoader { ...@@ -93,7 +93,7 @@ export default class PageLoader {
) { ) {
const middlewareMatchers = process.env.__NEXT_MIDDLEWARE_MATCHERS const middlewareMatchers = process.env.__NEXT_MIDDLEWARE_MATCHERS
window.__MIDDLEWARE_MATCHERS = middlewareMatchers window.__MIDDLEWARE_MATCHERS = middlewareMatchers
? (middlewareMatchers as any as MiddlewareMatcher[]) ? (middlewareMatchers as any as ProxyMatcher[])
: undefined : undefined
return window.__MIDDLEWARE_MATCHERS return window.__MIDDLEWARE_MATCHERS
// Turbopack production // Turbopack production
...@@ -109,7 +109,7 @@ export default class PageLoader { ...@@ -109,7 +109,7 @@ export default class PageLoader {
{ credentials: 'same-origin' } { credentials: 'same-origin' }
) )
.then((res) => res.json()) .then((res) => res.json())
.then((matchers: MiddlewareMatcher[]) => { .then((matchers: ProxyMatcher[]) => {
window.__MIDDLEWARE_MATCHERS = matchers window.__MIDDLEWARE_MATCHERS = matchers
return matchers return matchers
}) })
...@@ -133,7 +133,7 @@ export default class PageLoader { ...@@ -133,7 +133,7 @@ export default class PageLoader {
{ credentials: 'same-origin' } { credentials: 'same-origin' }
) )
.then((res) => res.json()) .then((res) => res.json())
.then((matchers: MiddlewareMatcher[]) => { .then((matchers: ProxyMatcher[]) => {
window.__DEV_MIDDLEWARE_MATCHERS = matchers window.__DEV_MIDDLEWARE_MATCHERS = matchers
return matchers return matchers
}) })
......
import type { ComponentType } from 'react' import type { ComponentType } from 'react'
import type { MiddlewareMatcher } from '../build/analysis/get-page-static-info' import type { ProxyMatcher } from '../build/analysis/get-page-static-info'
import getAssetPathFromRoute from '../shared/lib/router/utils/get-asset-path-from-route' import getAssetPathFromRoute from '../shared/lib/router/utils/get-asset-path-from-route'
import { __unsafeCreateTrustedScriptURL } from './trusted-types' import { __unsafeCreateTrustedScriptURL } from './trusted-types'
import { requestIdleCallback } from './request-idle-callback' import { requestIdleCallback } from './request-idle-callback'
...@@ -16,7 +16,7 @@ declare global { ...@@ -16,7 +16,7 @@ declare global {
interface Window { interface Window {
__BUILD_MANIFEST?: Record<string, string[]> __BUILD_MANIFEST?: Record<string, string[]>
__BUILD_MANIFEST_CB?: Function __BUILD_MANIFEST_CB?: Function
__MIDDLEWARE_MATCHERS?: MiddlewareMatcher[] __MIDDLEWARE_MATCHERS?: ProxyMatcher[]
__MIDDLEWARE_MANIFEST_CB?: Function __MIDDLEWARE_MANIFEST_CB?: Function
__REACT_LOADABLE_MANIFEST?: any __REACT_LOADABLE_MANIFEST?: any
__DYNAMIC_CSS_MANIFEST?: any __DYNAMIC_CSS_MANIFEST?: any
......
...@@ -40,7 +40,7 @@ import type { ...@@ -40,7 +40,7 @@ import type {
IncomingMessage, IncomingMessage,
ServerResponse as HTTPServerResponse, ServerResponse as HTTPServerResponse,
} from 'http' } from 'http'
import type { MiddlewareMatcher } from '../build/analysis/get-page-static-info' import type { ProxyMatcher } from '../build/analysis/get-page-static-info'
import type { TLSSocket } from 'tls' import type { TLSSocket } from 'tls'
import type { PathnameNormalizer } from './normalizers/request/pathname-normalizer' import type { PathnameNormalizer } from './normalizers/request/pathname-normalizer'
import type { InstrumentationModule } from './instrumentation/types' import type { InstrumentationModule } from './instrumentation/types'
...@@ -157,7 +157,7 @@ export type FindComponentsResult = { ...@@ -157,7 +157,7 @@ export type FindComponentsResult = {
export interface MiddlewareRoutingItem { export interface MiddlewareRoutingItem {
page: string page: string
match: MiddlewareRouteMatch match: MiddlewareRouteMatch
matchers?: MiddlewareMatcher[] matchers?: ProxyMatcher[]
} }
export type RouteHandler< export type RouteHandler<
......
import type { NextConfigComplete } from '../../config-shared' import type { NextConfigComplete } from '../../config-shared'
import type { FilesystemDynamicRoute } from './filesystem' import type { FilesystemDynamicRoute } from './filesystem'
import type { UnwrapPromise } from '../../../lib/coalesced-function' import type { UnwrapPromise } from '../../../lib/coalesced-function'
import type { MiddlewareMatcher } from '../../../build/analysis/get-page-static-info' import type { ProxyMatcher } from '../../../build/analysis/get-page-static-info'
import type { RoutesManifest } from '../../../build' import type { RoutesManifest } from '../../../build'
import type { MiddlewareRouteMatch } from '../../../shared/lib/router/utils/middleware-route-matcher' import type { MiddlewareRouteMatch } from '../../../shared/lib/router/utils/middleware-route-matcher'
import type { PropagateToWorkersField } from './types' import type { PropagateToWorkersField } from './types'
...@@ -124,7 +124,7 @@ export type ServerFields = { ...@@ -124,7 +124,7 @@ export type ServerFields = {
| { | {
page: string page: string
match: MiddlewareRouteMatch match: MiddlewareRouteMatch
matchers?: MiddlewareMatcher[] matchers?: ProxyMatcher[]
} }
| undefined | undefined
hasAppNotFound?: boolean hasAppNotFound?: boolean
...@@ -359,7 +359,7 @@ async function startWatcher( ...@@ -359,7 +359,7 @@ async function startWatcher(
wp.on('aggregated', async () => { wp.on('aggregated', async () => {
let writeEnvDefinitions = false let writeEnvDefinitions = false
let typescriptStatusFromLastAggregation = enabledTypeScript let typescriptStatusFromLastAggregation = enabledTypeScript
let middlewareMatchers: MiddlewareMatcher[] | undefined let middlewareMatchers: ProxyMatcher[] | undefined
const routedPages: string[] = [] const routedPages: string[] = []
const knownFiles = wp.getTimeInfoEntries() const knownFiles = wp.getTimeInfoEntries()
const appPaths: Record<string, string[]> = {} const appPaths: Record<string, string[]> = {}
......
import type { BaseNextRequest } from '../../../../server/base-http' import type { BaseNextRequest } from '../../../../server/base-http'
import type { MiddlewareMatcher } from '../../../../build/analysis/get-page-static-info' import type { ProxyMatcher } from '../../../../build/analysis/get-page-static-info'
import type { Params } from '../../../../server/request/params' import type { Params } from '../../../../server/request/params'
import { matchHas } from './prepare-destination' import { matchHas } from './prepare-destination'
...@@ -12,7 +12,7 @@ export interface MiddlewareRouteMatch { ...@@ -12,7 +12,7 @@ export interface MiddlewareRouteMatch {
} }
export function getMiddlewareRouteMatcher( export function getMiddlewareRouteMatcher(
matchers: MiddlewareMatcher[] matchers: ProxyMatcher[]
): MiddlewareRouteMatch { ): MiddlewareRouteMatch {
return ( return (
pathname: string | null | undefined, pathname: string | null | undefined,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment