added fonts
This commit is contained in:
1 parent
4134e3a234
commit
142d2986b6
9079 files changed
+1498421
-2
No files matched your search
Generated
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
import { isAppPageRoute } from '../../lib/is-app-page-route';
|
||||
import { APP_PATHS_MANIFEST } from '../../shared/lib/constants';
|
||||
import { AppNormalizers } from '../normalizers/built/app';
|
||||
import { RouteKind } from '../route-kind';
|
||||
import { AppPageRouteMatcher } from '../route-matchers/app-page-route-matcher';
|
||||
import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider';
|
||||
export class AppPageRouteMatcherProvider extends ManifestRouteMatcherProvider {
|
||||
constructor(distDir, manifestLoader){
|
||||
super(APP_PATHS_MANIFEST, manifestLoader);
|
||||
this.normalizers = new AppNormalizers(distDir);
|
||||
}
|
||||
async transform(manifest) {
|
||||
// This matcher only matches app pages.
|
||||
const pages = Object.keys(manifest).filter((page)=>isAppPageRoute(page));
|
||||
// Collect all the app paths for each page. This could include any parallel
|
||||
// routes.
|
||||
const allAppPaths = {};
|
||||
for (const page of pages){
|
||||
const pathname = this.normalizers.pathname.normalize(page);
|
||||
if (pathname in allAppPaths) allAppPaths[pathname].push(page);
|
||||
else allAppPaths[pathname] = [
|
||||
page
|
||||
];
|
||||
}
|
||||
// Format the routes.
|
||||
const matchers = [];
|
||||
for (const [pathname, appPaths] of Object.entries(allAppPaths)){
|
||||
// TODO-APP: (wyattjoh) this is a hack right now, should be more deterministic
|
||||
const page = appPaths[0];
|
||||
const filename = this.normalizers.filename.normalize(manifest[page]);
|
||||
const bundlePath = this.normalizers.bundlePath.normalize(page);
|
||||
matchers.push(new AppPageRouteMatcher({
|
||||
kind: RouteKind.APP_PAGE,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename,
|
||||
appPaths
|
||||
}));
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=app-page-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/route-matcher-providers/app-page-route-matcher-provider.ts"],"sourcesContent":["import { isAppPageRoute } from '../../lib/is-app-page-route'\n\nimport { APP_PATHS_MANIFEST } from '../../shared/lib/constants'\nimport { AppNormalizers } from '../normalizers/built/app'\nimport { RouteKind } from '../route-kind'\nimport { AppPageRouteMatcher } from '../route-matchers/app-page-route-matcher'\nimport type {\n Manifest,\n ManifestLoader,\n} from './helpers/manifest-loaders/manifest-loader'\nimport { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider'\n\nexport class AppPageRouteMatcherProvider extends ManifestRouteMatcherProvider<AppPageRouteMatcher> {\n private readonly normalizers: AppNormalizers\n\n constructor(distDir: string, manifestLoader: ManifestLoader) {\n super(APP_PATHS_MANIFEST, manifestLoader)\n\n this.normalizers = new AppNormalizers(distDir)\n }\n\n protected async transform(\n manifest: Manifest\n ): Promise<ReadonlyArray<AppPageRouteMatcher>> {\n // This matcher only matches app pages.\n const pages = Object.keys(manifest).filter((page) => isAppPageRoute(page))\n\n // Collect all the app paths for each page. This could include any parallel\n // routes.\n const allAppPaths: Record<string, string[]> = {}\n for (const page of pages) {\n const pathname = this.normalizers.pathname.normalize(page)\n if (pathname in allAppPaths) allAppPaths[pathname].push(page)\n else allAppPaths[pathname] = [page]\n }\n\n // Format the routes.\n const matchers: Array<AppPageRouteMatcher> = []\n for (const [pathname, appPaths] of Object.entries(allAppPaths)) {\n // TODO-APP: (wyattjoh) this is a hack right now, should be more deterministic\n const page = appPaths[0]\n\n const filename = this.normalizers.filename.normalize(manifest[page])\n const bundlePath = this.normalizers.bundlePath.normalize(page)\n\n matchers.push(\n new AppPageRouteMatcher({\n kind: RouteKind.APP_PAGE,\n pathname,\n page,\n bundlePath,\n filename,\n appPaths,\n })\n )\n }\n\n return matchers\n }\n}\n"],"names":["isAppPageRoute","APP_PATHS_MANIFEST","AppNormalizers","RouteKind","AppPageRouteMatcher","ManifestRouteMatcherProvider","AppPageRouteMatcherProvider","constructor","distDir","manifestLoader","normalizers","transform","manifest","pages","Object","keys","filter","page","allAppPaths","pathname","normalize","push","matchers","appPaths","entries","filename","bundlePath","kind","APP_PAGE"],"mappings":"AAAA,SAASA,cAAc,QAAQ,8BAA6B;AAE5D,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,SAAS,QAAQ,gBAAe;AACzC,SAASC,mBAAmB,QAAQ,2CAA0C;AAK9E,SAASC,4BAA4B,QAAQ,oCAAmC;AAEhF,OAAO,MAAMC,oCAAoCD;IAG/CE,YAAYC,OAAe,EAAEC,cAA8B,CAAE;QAC3D,KAAK,CAACR,oBAAoBQ;QAE1B,IAAI,CAACC,WAAW,GAAG,IAAIR,eAAeM;IACxC;IAEA,MAAgBG,UACdC,QAAkB,EAC2B;QAC7C,uCAAuC;QACvC,MAAMC,QAAQC,OAAOC,IAAI,CAACH,UAAUI,MAAM,CAAC,CAACC,OAASjB,eAAeiB;QAEpE,2EAA2E;QAC3E,UAAU;QACV,MAAMC,cAAwC,CAAC;QAC/C,KAAK,MAAMD,QAAQJ,MAAO;YACxB,MAAMM,WAAW,IAAI,CAACT,WAAW,CAACS,QAAQ,CAACC,SAAS,CAACH;YACrD,IAAIE,YAAYD,aAAaA,WAAW,CAACC,SAAS,CAACE,IAAI,CAACJ;iBACnDC,WAAW,CAACC,SAAS,GAAG;gBAACF;aAAK;QACrC;QAEA,qBAAqB;QACrB,MAAMK,WAAuC,EAAE;QAC/C,KAAK,MAAM,CAACH,UAAUI,SAAS,IAAIT,OAAOU,OAAO,CAACN,aAAc;YAC9D,8EAA8E;YAC9E,MAAMD,OAAOM,QAAQ,CAAC,EAAE;YAExB,MAAME,WAAW,IAAI,CAACf,WAAW,CAACe,QAAQ,CAACL,SAAS,CAACR,QAAQ,CAACK,KAAK;YACnE,MAAMS,aAAa,IAAI,CAAChB,WAAW,CAACgB,UAAU,CAACN,SAAS,CAACH;YAEzDK,SAASD,IAAI,CACX,IAAIjB,oBAAoB;gBACtBuB,MAAMxB,UAAUyB,QAAQ;gBACxBT;gBACAF;gBACAS;gBACAD;gBACAF;YACF;QAEJ;QAEA,OAAOD;IACT;AACF"}
|
||||
Generated
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
import { isAppRouteRoute } from '../../lib/is-app-route-route';
|
||||
import { APP_PATHS_MANIFEST } from '../../shared/lib/constants';
|
||||
import { RouteKind } from '../route-kind';
|
||||
import { AppRouteRouteMatcher } from '../route-matchers/app-route-route-matcher';
|
||||
import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider';
|
||||
import { AppNormalizers } from '../normalizers/built/app';
|
||||
export class AppRouteRouteMatcherProvider extends ManifestRouteMatcherProvider {
|
||||
constructor(distDir, manifestLoader){
|
||||
super(APP_PATHS_MANIFEST, manifestLoader);
|
||||
this.normalizers = new AppNormalizers(distDir);
|
||||
}
|
||||
async transform(manifest) {
|
||||
// This matcher only matches app routes.
|
||||
const pages = Object.keys(manifest).filter((page)=>isAppRouteRoute(page));
|
||||
// Format the routes.
|
||||
const matchers = [];
|
||||
for (const page of pages){
|
||||
const filename = this.normalizers.filename.normalize(manifest[page]);
|
||||
const pathname = this.normalizers.pathname.normalize(page);
|
||||
const bundlePath = this.normalizers.bundlePath.normalize(page);
|
||||
matchers.push(new AppRouteRouteMatcher({
|
||||
kind: RouteKind.APP_ROUTE,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename
|
||||
}));
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=app-route-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/route-matcher-providers/app-route-route-matcher-provider.ts"],"sourcesContent":["import { isAppRouteRoute } from '../../lib/is-app-route-route'\nimport { APP_PATHS_MANIFEST } from '../../shared/lib/constants'\nimport { RouteKind } from '../route-kind'\nimport { AppRouteRouteMatcher } from '../route-matchers/app-route-route-matcher'\nimport type {\n Manifest,\n ManifestLoader,\n} from './helpers/manifest-loaders/manifest-loader'\nimport { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider'\nimport { AppNormalizers } from '../normalizers/built/app'\n\nexport class AppRouteRouteMatcherProvider extends ManifestRouteMatcherProvider<AppRouteRouteMatcher> {\n private readonly normalizers: AppNormalizers\n\n constructor(distDir: string, manifestLoader: ManifestLoader) {\n super(APP_PATHS_MANIFEST, manifestLoader)\n\n this.normalizers = new AppNormalizers(distDir)\n }\n\n protected async transform(\n manifest: Manifest\n ): Promise<ReadonlyArray<AppRouteRouteMatcher>> {\n // This matcher only matches app routes.\n const pages = Object.keys(manifest).filter((page) => isAppRouteRoute(page))\n\n // Format the routes.\n const matchers: Array<AppRouteRouteMatcher> = []\n for (const page of pages) {\n const filename = this.normalizers.filename.normalize(manifest[page])\n const pathname = this.normalizers.pathname.normalize(page)\n const bundlePath = this.normalizers.bundlePath.normalize(page)\n\n matchers.push(\n new AppRouteRouteMatcher({\n kind: RouteKind.APP_ROUTE,\n pathname,\n page,\n bundlePath,\n filename,\n })\n )\n }\n\n return matchers\n }\n}\n"],"names":["isAppRouteRoute","APP_PATHS_MANIFEST","RouteKind","AppRouteRouteMatcher","ManifestRouteMatcherProvider","AppNormalizers","AppRouteRouteMatcherProvider","constructor","distDir","manifestLoader","normalizers","transform","manifest","pages","Object","keys","filter","page","matchers","filename","normalize","pathname","bundlePath","push","kind","APP_ROUTE"],"mappings":"AAAA,SAASA,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,SAAS,QAAQ,gBAAe;AACzC,SAASC,oBAAoB,QAAQ,4CAA2C;AAKhF,SAASC,4BAA4B,QAAQ,oCAAmC;AAChF,SAASC,cAAc,QAAQ,2BAA0B;AAEzD,OAAO,MAAMC,qCAAqCF;IAGhDG,YAAYC,OAAe,EAAEC,cAA8B,CAAE;QAC3D,KAAK,CAACR,oBAAoBQ;QAE1B,IAAI,CAACC,WAAW,GAAG,IAAIL,eAAeG;IACxC;IAEA,MAAgBG,UACdC,QAAkB,EAC4B;QAC9C,wCAAwC;QACxC,MAAMC,QAAQC,OAAOC,IAAI,CAACH,UAAUI,MAAM,CAAC,CAACC,OAASjB,gBAAgBiB;QAErE,qBAAqB;QACrB,MAAMC,WAAwC,EAAE;QAChD,KAAK,MAAMD,QAAQJ,MAAO;YACxB,MAAMM,WAAW,IAAI,CAACT,WAAW,CAACS,QAAQ,CAACC,SAAS,CAACR,QAAQ,CAACK,KAAK;YACnE,MAAMI,WAAW,IAAI,CAACX,WAAW,CAACW,QAAQ,CAACD,SAAS,CAACH;YACrD,MAAMK,aAAa,IAAI,CAACZ,WAAW,CAACY,UAAU,CAACF,SAAS,CAACH;YAEzDC,SAASK,IAAI,CACX,IAAIpB,qBAAqB;gBACvBqB,MAAMtB,UAAUuB,SAAS;gBACzBJ;gBACAJ;gBACAK;gBACAH;YACF;QAEJ;QAEA,OAAOD;IACT;AACF"}
|
||||
node_modules/next/dist/esm/server/route-matcher-providers/dev/dev-app-page-route-matcher-provider.js
Generated
Vendored
+72
@@ -0,0 +1,72 @@
|
||||
import { AppPageRouteMatcher } from '../../route-matchers/app-page-route-matcher';
|
||||
import { RouteKind } from '../../route-kind';
|
||||
import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider';
|
||||
import { DevAppNormalizers } from '../../normalizers/built/app';
|
||||
import { normalizeCatchAllRoutes } from '../../../build/normalize-catchall-routes';
|
||||
export class DevAppPageRouteMatcherProvider extends FileCacheRouteMatcherProvider {
|
||||
constructor(appDir, extensions, reader){
|
||||
super(appDir, reader);
|
||||
this.normalizers = new DevAppNormalizers(appDir, extensions);
|
||||
// Match any page file that ends with `/page.${extension}` or `/default.${extension}` under the app
|
||||
// directory.
|
||||
this.expression = new RegExp(`[/\\\\](page|default)\\.(?:${extensions.join('|')})$`);
|
||||
}
|
||||
async transform(files) {
|
||||
// Collect all the app paths for each page. This could include any parallel
|
||||
// routes.
|
||||
const cache = new Map();
|
||||
const routeFilenames = new Array();
|
||||
let appPaths = {};
|
||||
for (const filename of files){
|
||||
// If the file isn't a match for this matcher, then skip it.
|
||||
if (!this.expression.test(filename)) continue;
|
||||
const page = this.normalizers.page.normalize(filename);
|
||||
// Validate that this is not an ignored page.
|
||||
if (page.includes('/_')) continue;
|
||||
// This is a valid file that we want to create a matcher for.
|
||||
routeFilenames.push(filename);
|
||||
const pathname = this.normalizers.pathname.normalize(filename);
|
||||
const bundlePath = this.normalizers.bundlePath.normalize(filename);
|
||||
// Save the normalization results.
|
||||
cache.set(filename, {
|
||||
page,
|
||||
pathname,
|
||||
bundlePath
|
||||
});
|
||||
if (pathname in appPaths) appPaths[pathname].push(page);
|
||||
else appPaths[pathname] = [
|
||||
page
|
||||
];
|
||||
}
|
||||
normalizeCatchAllRoutes(appPaths);
|
||||
// Make sure to sort parallel routes to make the result deterministic.
|
||||
appPaths = Object.fromEntries(Object.entries(appPaths).map(([k, v])=>[
|
||||
k,
|
||||
v.sort()
|
||||
]));
|
||||
const matchers = [];
|
||||
for (const filename of routeFilenames){
|
||||
// Grab the cached values (and the appPaths).
|
||||
const cached = cache.get(filename);
|
||||
if (!cached) {
|
||||
throw Object.defineProperty(new Error('Invariant: expected filename to exist in cache'), "__NEXT_ERROR_CODE", {
|
||||
value: "E190",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const { pathname, page, bundlePath } = cached;
|
||||
matchers.push(new AppPageRouteMatcher({
|
||||
kind: RouteKind.APP_PAGE,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename,
|
||||
appPaths: appPaths[pathname]
|
||||
}));
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dev-app-page-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/route-matcher-providers/dev/dev-app-page-route-matcher-provider.ts"],"sourcesContent":["import type { FileReader } from './helpers/file-reader/file-reader'\nimport { AppPageRouteMatcher } from '../../route-matchers/app-page-route-matcher'\nimport { RouteKind } from '../../route-kind'\nimport { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider'\n\nimport { DevAppNormalizers } from '../../normalizers/built/app'\nimport { normalizeCatchAllRoutes } from '../../../build/normalize-catchall-routes'\n\nexport class DevAppPageRouteMatcherProvider extends FileCacheRouteMatcherProvider<AppPageRouteMatcher> {\n private readonly expression: RegExp\n private readonly normalizers: DevAppNormalizers\n\n constructor(\n appDir: string,\n extensions: ReadonlyArray<string>,\n reader: FileReader\n ) {\n super(appDir, reader)\n\n this.normalizers = new DevAppNormalizers(appDir, extensions)\n\n // Match any page file that ends with `/page.${extension}` or `/default.${extension}` under the app\n // directory.\n this.expression = new RegExp(\n `[/\\\\\\\\](page|default)\\\\.(?:${extensions.join('|')})$`\n )\n }\n\n protected async transform(\n files: ReadonlyArray<string>\n ): Promise<ReadonlyArray<AppPageRouteMatcher>> {\n // Collect all the app paths for each page. This could include any parallel\n // routes.\n const cache = new Map<\n string,\n { page: string; pathname: string; bundlePath: string }\n >()\n const routeFilenames = new Array<string>()\n let appPaths: Record<string, string[]> = {}\n for (const filename of files) {\n // If the file isn't a match for this matcher, then skip it.\n if (!this.expression.test(filename)) continue\n\n const page = this.normalizers.page.normalize(filename)\n\n // Validate that this is not an ignored page.\n if (page.includes('/_')) continue\n\n // This is a valid file that we want to create a matcher for.\n routeFilenames.push(filename)\n\n const pathname = this.normalizers.pathname.normalize(filename)\n const bundlePath = this.normalizers.bundlePath.normalize(filename)\n\n // Save the normalization results.\n cache.set(filename, { page, pathname, bundlePath })\n\n if (pathname in appPaths) appPaths[pathname].push(page)\n else appPaths[pathname] = [page]\n }\n\n normalizeCatchAllRoutes(appPaths)\n\n // Make sure to sort parallel routes to make the result deterministic.\n appPaths = Object.fromEntries(\n Object.entries(appPaths).map(([k, v]) => [k, v.sort()])\n )\n\n const matchers: Array<AppPageRouteMatcher> = []\n for (const filename of routeFilenames) {\n // Grab the cached values (and the appPaths).\n const cached = cache.get(filename)\n if (!cached) {\n throw new Error('Invariant: expected filename to exist in cache')\n }\n const { pathname, page, bundlePath } = cached\n\n matchers.push(\n new AppPageRouteMatcher({\n kind: RouteKind.APP_PAGE,\n pathname,\n page,\n bundlePath,\n filename,\n appPaths: appPaths[pathname],\n })\n )\n }\n return matchers\n }\n}\n"],"names":["AppPageRouteMatcher","RouteKind","FileCacheRouteMatcherProvider","DevAppNormalizers","normalizeCatchAllRoutes","DevAppPageRouteMatcherProvider","constructor","appDir","extensions","reader","normalizers","expression","RegExp","join","transform","files","cache","Map","routeFilenames","Array","appPaths","filename","test","page","normalize","includes","push","pathname","bundlePath","set","Object","fromEntries","entries","map","k","v","sort","matchers","cached","get","Error","kind","APP_PAGE"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,8CAA6C;AACjF,SAASC,SAAS,QAAQ,mBAAkB;AAC5C,SAASC,6BAA6B,QAAQ,sCAAqC;AAEnF,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,SAASC,uBAAuB,QAAQ,2CAA0C;AAElF,OAAO,MAAMC,uCAAuCH;IAIlDI,YACEC,MAAc,EACdC,UAAiC,EACjCC,MAAkB,CAClB;QACA,KAAK,CAACF,QAAQE;QAEd,IAAI,CAACC,WAAW,GAAG,IAAIP,kBAAkBI,QAAQC;QAEjD,mGAAmG;QACnG,aAAa;QACb,IAAI,CAACG,UAAU,GAAG,IAAIC,OACpB,CAAC,2BAA2B,EAAEJ,WAAWK,IAAI,CAAC,KAAK,EAAE,CAAC;IAE1D;IAEA,MAAgBC,UACdC,KAA4B,EACiB;QAC7C,2EAA2E;QAC3E,UAAU;QACV,MAAMC,QAAQ,IAAIC;QAIlB,MAAMC,iBAAiB,IAAIC;QAC3B,IAAIC,WAAqC,CAAC;QAC1C,KAAK,MAAMC,YAAYN,MAAO;YAC5B,4DAA4D;YAC5D,IAAI,CAAC,IAAI,CAACJ,UAAU,CAACW,IAAI,CAACD,WAAW;YAErC,MAAME,OAAO,IAAI,CAACb,WAAW,CAACa,IAAI,CAACC,SAAS,CAACH;YAE7C,6CAA6C;YAC7C,IAAIE,KAAKE,QAAQ,CAAC,OAAO;YAEzB,6DAA6D;YAC7DP,eAAeQ,IAAI,CAACL;YAEpB,MAAMM,WAAW,IAAI,CAACjB,WAAW,CAACiB,QAAQ,CAACH,SAAS,CAACH;YACrD,MAAMO,aAAa,IAAI,CAAClB,WAAW,CAACkB,UAAU,CAACJ,SAAS,CAACH;YAEzD,kCAAkC;YAClCL,MAAMa,GAAG,CAACR,UAAU;gBAAEE;gBAAMI;gBAAUC;YAAW;YAEjD,IAAID,YAAYP,UAAUA,QAAQ,CAACO,SAAS,CAACD,IAAI,CAACH;iBAC7CH,QAAQ,CAACO,SAAS,GAAG;gBAACJ;aAAK;QAClC;QAEAnB,wBAAwBgB;QAExB,sEAAsE;QACtEA,WAAWU,OAAOC,WAAW,CAC3BD,OAAOE,OAAO,CAACZ,UAAUa,GAAG,CAAC,CAAC,CAACC,GAAGC,EAAE,GAAK;gBAACLine truncated
|
||||
Generated
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
import { AppRouteRouteMatcher } from '../../route-matchers/app-route-route-matcher';
|
||||
import { RouteKind } from '../../route-kind';
|
||||
import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider';
|
||||
import { isAppRouteRoute } from '../../../lib/is-app-route-route';
|
||||
import { DevAppNormalizers } from '../../normalizers/built/app';
|
||||
import { isMetadataRouteFile, isStaticMetadataRoute } from '../../../lib/metadata/is-metadata-route';
|
||||
import { normalizeMetadataPageToRoute } from '../../../lib/metadata/get-metadata-route';
|
||||
import path from '../../../shared/lib/isomorphic/path';
|
||||
export class DevAppRouteRouteMatcherProvider extends FileCacheRouteMatcherProvider {
|
||||
constructor(appDir, extensions, reader){
|
||||
super(appDir, reader);
|
||||
this.appDir = appDir;
|
||||
this.normalizers = new DevAppNormalizers(appDir, extensions);
|
||||
}
|
||||
async transform(files) {
|
||||
const matchers = [];
|
||||
for (const filename of files){
|
||||
const page = this.normalizers.page.normalize(filename);
|
||||
// If the file isn't a match for this matcher, then skip it.
|
||||
if (!isAppRouteRoute(page)) continue;
|
||||
// Validate that this is not an ignored page.
|
||||
if (page.includes('/_')) continue;
|
||||
const pathname = this.normalizers.pathname.normalize(filename);
|
||||
const bundlePath = this.normalizers.bundlePath.normalize(filename);
|
||||
const ext = path.extname(filename).slice(1);
|
||||
const isEntryMetadataRouteFile = isMetadataRouteFile(filename.replace(this.appDir, ''), [
|
||||
ext
|
||||
], true);
|
||||
if (isEntryMetadataRouteFile && !isStaticMetadataRoute(page)) {
|
||||
// Matching dynamic metadata routes.
|
||||
// Add 2 possibilities for both single and multiple routes:
|
||||
{
|
||||
// single:
|
||||
// /sitemap.ts -> /sitemap.xml/route
|
||||
// /icon.ts -> /icon/route
|
||||
// We'll map the filename before normalization:
|
||||
// sitemap.ts -> sitemap.xml/route.ts
|
||||
// icon.ts -> icon/route.ts
|
||||
const metadataPage = normalizeMetadataPageToRoute(page, false);
|
||||
const metadataPathname = normalizeMetadataPageToRoute(pathname, false);
|
||||
const metadataBundlePath = normalizeMetadataPageToRoute(bundlePath, false);
|
||||
const matcher = new AppRouteRouteMatcher({
|
||||
kind: RouteKind.APP_ROUTE,
|
||||
page: metadataPage,
|
||||
pathname: metadataPathname,
|
||||
bundlePath: metadataBundlePath,
|
||||
filename
|
||||
});
|
||||
matchers.push(matcher);
|
||||
}
|
||||
{
|
||||
// multiple:
|
||||
// /sitemap.ts -> /sitemap/[__metadata_id__]/route
|
||||
// /icon.ts -> /icon/[__metadata_id__]/route
|
||||
// We'll map the filename before normalization:
|
||||
// sitemap.ts -> sitemap.xml/[__metadata_id__].ts
|
||||
// icon.ts -> icon/[__metadata_id__].ts
|
||||
const metadataPage = normalizeMetadataPageToRoute(page, true);
|
||||
const metadataPathname = normalizeMetadataPageToRoute(pathname, true);
|
||||
const metadataBundlePath = normalizeMetadataPageToRoute(bundlePath, true);
|
||||
const matcher = new AppRouteRouteMatcher({
|
||||
kind: RouteKind.APP_ROUTE,
|
||||
page: metadataPage,
|
||||
pathname: metadataPathname,
|
||||
bundlePath: metadataBundlePath,
|
||||
filename
|
||||
});
|
||||
matchers.push(matcher);
|
||||
}
|
||||
} else {
|
||||
// Normal app routes and static metadata routes.
|
||||
matchers.push(new AppRouteRouteMatcher({
|
||||
kind: RouteKind.APP_ROUTE,
|
||||
page,
|
||||
pathname,
|
||||
bundlePath,
|
||||
filename
|
||||
}));
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dev-app-route-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/route-matcher-providers/dev/dev-app-route-route-matcher-provider.ts"],"sourcesContent":["import type { FileReader } from './helpers/file-reader/file-reader'\nimport type { Normalizer } from '../../normalizers/normalizer'\nimport { AppRouteRouteMatcher } from '../../route-matchers/app-route-route-matcher'\nimport { RouteKind } from '../../route-kind'\nimport { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider'\nimport { isAppRouteRoute } from '../../../lib/is-app-route-route'\nimport { DevAppNormalizers } from '../../normalizers/built/app'\nimport {\n isMetadataRouteFile,\n isStaticMetadataRoute,\n} from '../../../lib/metadata/is-metadata-route'\nimport { normalizeMetadataPageToRoute } from '../../../lib/metadata/get-metadata-route'\nimport path from '../../../shared/lib/isomorphic/path'\n\nexport class DevAppRouteRouteMatcherProvider extends FileCacheRouteMatcherProvider<AppRouteRouteMatcher> {\n private readonly normalizers: {\n page: Normalizer\n pathname: Normalizer\n bundlePath: Normalizer\n }\n private readonly appDir: string\n\n constructor(\n appDir: string,\n extensions: ReadonlyArray<string>,\n reader: FileReader\n ) {\n super(appDir, reader)\n\n this.appDir = appDir\n this.normalizers = new DevAppNormalizers(appDir, extensions)\n }\n\n protected async transform(\n files: ReadonlyArray<string>\n ): Promise<ReadonlyArray<AppRouteRouteMatcher>> {\n const matchers: Array<AppRouteRouteMatcher> = []\n for (const filename of files) {\n const page = this.normalizers.page.normalize(filename)\n\n // If the file isn't a match for this matcher, then skip it.\n if (!isAppRouteRoute(page)) continue\n\n // Validate that this is not an ignored page.\n if (page.includes('/_')) continue\n\n const pathname = this.normalizers.pathname.normalize(filename)\n const bundlePath = this.normalizers.bundlePath.normalize(filename)\n const ext = path.extname(filename).slice(1)\n const isEntryMetadataRouteFile = isMetadataRouteFile(\n filename.replace(this.appDir, ''),\n [ext],\n true\n )\n\n if (isEntryMetadataRouteFile && !isStaticMetadataRoute(page)) {\n // Matching dynamic metadata routes.\n // Add 2 possibilities for both single and multiple routes:\n {\n // single:\n // /sitemap.ts -> /sitemap.xml/route\n // /icon.ts -> /icon/route\n // We'll map the filename before normalization:\n // sitemap.ts -> sitemap.xml/route.ts\n // icon.ts -> icon/route.ts\n const metadataPage = normalizeMetadataPageToRoute(page, false)\n const metadataPathname = normalizeMetadataPageToRoute(pathname, false)\n const metadataBundlePath = normalizeMetadataPageToRoute(\n bundlePath,\n false\n )\n\n const matcher = new AppRouteRouteMatcher({\n kind: RouteKind.APP_ROUTE,\n page: metadataPage,\n pathname: metadataPathname,\n bundlePath: metadataBundlePath,\n filename,\n })\n matchers.push(matcher)\n }\n {\n // multiple:\n // /sitemap.ts -> /sitemap/[__metadata_id__]/route\n // /icon.ts -> /icon/[__metadata_id__]/route\n // We'll map the filename before normalization:\n // sitemap.ts -> sitemap.xml/[__metadata_id__].ts\n // icon.ts -> icon/[__metadata_id__].ts\n const metadataPage = normalizeMetadataPageToRoute(page, true)\n const metadataPathname = normalizeMetadataPageToRoute(pathname, true)\n const metadataBundlePath = normalizeMetadataPageToRoute(\n bundlePath,\n true\n )\n\n const matcher = new AppRouteRouteMatcher({\n kind: RouteKind.APP_ROUTE,\n page: metadataPage,\n pathname: metadataPathname,\n bundlePath: metadataBundlePath,\n filename,\n })\n matchers.push(matcher)\n }\n } else {\n // Normal app routes and static metadata routes.\n matchers.push(\n new AppRouteRouteMatcher({\n kind: RouteKind.APP_ROUTE,\n page,\n pathname,\n bundlePath,\n filename,\n })\n )\n }\n }\n\n return matchers\n }\n}\n"],"names":["AppRouteRouteMatcher","RouteKind","FileCacheRouteMatcherProvider","isAppRouteRoute","DevAppNormalizers","isMetadataRouteFile","isStaticMetadataRoute","normalizeMetadataPageToRoute","path","DevAppRouteRouteMatcherProvider","constructor","appDir","extensions","reader","normalizers","transform","files","matchers","filename","page","normalize","includes","pathname","bundlePath","ext","extname","slice","isEntryMetadataRouteFile","replace","metadataPage","metadataPathname","metadataBundlePath","matcher","kind","APP_ROUTE","pLine truncated
|
||||
Generated
Vendored
+62
@@ -0,0 +1,62 @@
|
||||
import { PagesAPILocaleRouteMatcher, PagesAPIRouteMatcher } from '../../route-matchers/pages-api-route-matcher';
|
||||
import { RouteKind } from '../../route-kind';
|
||||
import path from 'path';
|
||||
import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider';
|
||||
import { DevPagesNormalizers } from '../../normalizers/built/pages';
|
||||
export class DevPagesAPIRouteMatcherProvider extends FileCacheRouteMatcherProvider {
|
||||
constructor(pagesDir, extensions, reader, localeNormalizer){
|
||||
super(pagesDir, reader), this.pagesDir = pagesDir, this.extensions = extensions, this.localeNormalizer = localeNormalizer;
|
||||
// Match any route file that ends with `/${filename}.${extension}` under the
|
||||
// pages directory.
|
||||
this.expression = new RegExp(`\\.(?:${extensions.join('|')})$`);
|
||||
this.normalizers = new DevPagesNormalizers(pagesDir, extensions);
|
||||
}
|
||||
test(filename) {
|
||||
// If the file does not end in the correct extension it's not a match.
|
||||
if (!this.expression.test(filename)) return false;
|
||||
// Pages API routes must exist in the pages directory with the `/api/`
|
||||
// prefix. The pathnames being tested here though are the full filenames,
|
||||
// so we need to include the pages directory.
|
||||
// TODO: could path separator normalization be needed here?
|
||||
if (filename.startsWith(path.join(this.pagesDir, '/api/'))) return true;
|
||||
for (const extension of this.extensions){
|
||||
// We can also match if we have `pages/api.${extension}`, so check to
|
||||
// see if it's a match.
|
||||
if (filename === path.join(this.pagesDir, `api.${extension}`)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
async transform(files) {
|
||||
const matchers = [];
|
||||
for (const filename of files){
|
||||
// If the file isn't a match for this matcher, then skip it.
|
||||
if (!this.test(filename)) continue;
|
||||
const pathname = this.normalizers.pathname.normalize(filename);
|
||||
const page = this.normalizers.page.normalize(filename);
|
||||
const bundlePath = this.normalizers.bundlePath.normalize(filename);
|
||||
if (this.localeNormalizer) {
|
||||
matchers.push(new PagesAPILocaleRouteMatcher({
|
||||
kind: RouteKind.PAGES_API,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename,
|
||||
i18n: {}
|
||||
}));
|
||||
} else {
|
||||
matchers.push(new PagesAPIRouteMatcher({
|
||||
kind: RouteKind.PAGES_API,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename
|
||||
}));
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dev-pages-api-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.ts"],"sourcesContent":["import type { FileReader } from './helpers/file-reader/file-reader'\nimport {\n PagesAPILocaleRouteMatcher,\n PagesAPIRouteMatcher,\n} from '../../route-matchers/pages-api-route-matcher'\nimport { RouteKind } from '../../route-kind'\nimport path from 'path'\nimport type { LocaleRouteNormalizer } from '../../normalizers/locale-route-normalizer'\nimport { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider'\nimport { DevPagesNormalizers } from '../../normalizers/built/pages'\n\nexport class DevPagesAPIRouteMatcherProvider extends FileCacheRouteMatcherProvider<PagesAPIRouteMatcher> {\n private readonly expression: RegExp\n private readonly normalizers: DevPagesNormalizers\n\n constructor(\n private readonly pagesDir: string,\n private readonly extensions: ReadonlyArray<string>,\n reader: FileReader,\n private readonly localeNormalizer?: LocaleRouteNormalizer\n ) {\n super(pagesDir, reader)\n\n // Match any route file that ends with `/${filename}.${extension}` under the\n // pages directory.\n this.expression = new RegExp(`\\\\.(?:${extensions.join('|')})$`)\n\n this.normalizers = new DevPagesNormalizers(pagesDir, extensions)\n }\n\n private test(filename: string): boolean {\n // If the file does not end in the correct extension it's not a match.\n if (!this.expression.test(filename)) return false\n\n // Pages API routes must exist in the pages directory with the `/api/`\n // prefix. The pathnames being tested here though are the full filenames,\n // so we need to include the pages directory.\n\n // TODO: could path separator normalization be needed here?\n if (filename.startsWith(path.join(this.pagesDir, '/api/'))) return true\n\n for (const extension of this.extensions) {\n // We can also match if we have `pages/api.${extension}`, so check to\n // see if it's a match.\n if (filename === path.join(this.pagesDir, `api.${extension}`)) {\n return true\n }\n }\n\n return false\n }\n\n protected async transform(\n files: ReadonlyArray<string>\n ): Promise<ReadonlyArray<PagesAPIRouteMatcher>> {\n const matchers: Array<PagesAPIRouteMatcher> = []\n for (const filename of files) {\n // If the file isn't a match for this matcher, then skip it.\n if (!this.test(filename)) continue\n\n const pathname = this.normalizers.pathname.normalize(filename)\n const page = this.normalizers.page.normalize(filename)\n const bundlePath = this.normalizers.bundlePath.normalize(filename)\n\n if (this.localeNormalizer) {\n matchers.push(\n new PagesAPILocaleRouteMatcher({\n kind: RouteKind.PAGES_API,\n pathname,\n page,\n bundlePath,\n filename,\n i18n: {},\n })\n )\n } else {\n matchers.push(\n new PagesAPIRouteMatcher({\n kind: RouteKind.PAGES_API,\n pathname,\n page,\n bundlePath,\n filename,\n })\n )\n }\n }\n\n return matchers\n }\n}\n"],"names":["PagesAPILocaleRouteMatcher","PagesAPIRouteMatcher","RouteKind","path","FileCacheRouteMatcherProvider","DevPagesNormalizers","DevPagesAPIRouteMatcherProvider","constructor","pagesDir","extensions","reader","localeNormalizer","expression","RegExp","join","normalizers","test","filename","startsWith","extension","transform","files","matchers","pathname","normalize","page","bundlePath","push","kind","PAGES_API","i18n"],"mappings":"AACA,SACEA,0BAA0B,EAC1BC,oBAAoB,QACf,+CAA8C;AACrD,SAASC,SAAS,QAAQ,mBAAkB;AAC5C,OAAOC,UAAU,OAAM;AAEvB,SAASC,6BAA6B,QAAQ,sCAAqC;AACnF,SAASC,mBAAmB,QAAQ,gCAA+B;AAEnE,OAAO,MAAMC,wCAAwCF;IAInDG,YACE,AAAiBC,QAAgB,EACjC,AAAiBC,UAAiC,EAClDC,MAAkB,EAClB,AAAiBC,gBAAwC,CACzD;QACA,KAAK,CAACH,UAAUE,cALCF,WAAAA,eACAC,aAAAA,iBAEAE,mBAAAA;QAIjB,4EAA4E;QAC5E,mBAAmB;QACnB,IAAI,CAACC,UAAU,GAAG,IAAIC,OAAO,CAAC,MAAM,EAAEJ,WAAWK,IAAI,CAAC,KAAK,EAAE,CAAC;QAE9D,IAAI,CAACC,WAAW,GAAG,IAAIV,oBAAoBG,UAAUC;IACvD;IAEQO,KAAKC,QAAgB,EAAW;QACtC,sEAAsE;QACtE,IAAI,CAAC,IAAI,CAACL,UAAU,CAACI,IAAI,CAACC,WAAW,OAAO;QAE5C,sEAAsE;QACtE,yEAAyE;QACzE,6CAA6C;QAE7C,2DAA2D;QAC3D,IAAIA,SAASC,UAAU,CAACf,KAAKW,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE,WAAW,OAAO;QAEnE,KAAK,MAAMW,aAAa,IAAI,CAACV,UAAU,CAAE;YACvC,qEAAqE;YACrE,uBAAuB;YACvB,IAAIQ,aAAad,KAAKW,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE,CAAC,IAAI,EAAEW,WAAW,GAAG;gBAC7D,OAAO;YACT;QACF;QAEA,OAAO;IACT;IAEA,MAAgBC,UACdC,KAA4B,EACkB;QAC9C,MAAMC,WAAwC,EAAE;QAChD,KAAK,MAAML,YAAYI,MAAO;YAC5B,4DAA4D;YAC5D,IAAI,CAAC,IAAI,CAACL,IAAI,CAACC,WAAW;YAE1B,MAAMM,WAAW,IAAI,CAACR,WAAW,CAACQ,QAAQ,CAACC,SAAS,CAACP;YACrD,MAAMQ,OAAO,IAAI,CAACV,WAAW,CAACU,IAAI,CAACD,SAAS,CAACP;YAC7C,MAAMS,aAAa,IAAI,CAACX,WAAW,CAACW,UAAU,CAACF,SAAS,CAACP;YAEzD,IAAI,IAAI,CAACN,gBAAgB,EAAE;gBACzBW,SAASK,IAAI,CACX,IAAI3B,2BAA2B;oBAC7B4B,MAAMLine truncated
|
||||
Generated
Vendored
+62
@@ -0,0 +1,62 @@
|
||||
import { PagesRouteMatcher, PagesLocaleRouteMatcher } from '../../route-matchers/pages-route-matcher';
|
||||
import { RouteKind } from '../../route-kind';
|
||||
import path from 'path';
|
||||
import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider';
|
||||
import { DevPagesNormalizers } from '../../normalizers/built/pages';
|
||||
export class DevPagesRouteMatcherProvider extends FileCacheRouteMatcherProvider {
|
||||
constructor(pagesDir, extensions, reader, localeNormalizer){
|
||||
super(pagesDir, reader), this.pagesDir = pagesDir, this.extensions = extensions, this.localeNormalizer = localeNormalizer;
|
||||
// Match any route file that ends with `/${filename}.${extension}` under the
|
||||
// pages directory.
|
||||
this.expression = new RegExp(`\\.(?:${extensions.join('|')})$`);
|
||||
this.normalizers = new DevPagesNormalizers(pagesDir, extensions);
|
||||
}
|
||||
test(filename) {
|
||||
// If the file does not end in the correct extension it's not a match.
|
||||
if (!this.expression.test(filename)) return false;
|
||||
// Pages routes must exist in the pages directory without the `/api/`
|
||||
// prefix. The pathnames being tested here though are the full filenames,
|
||||
// so we need to include the pages directory.
|
||||
// TODO: could path separator normalization be needed here?
|
||||
if (filename.startsWith(path.join(this.pagesDir, '/api/'))) return false;
|
||||
for (const extension of this.extensions){
|
||||
// We can also match if we have `pages/api.${extension}`, so check to
|
||||
// see if it's a match.
|
||||
if (filename === path.join(this.pagesDir, `api.${extension}`)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
async transform(files) {
|
||||
const matchers = [];
|
||||
for (const filename of files){
|
||||
// If the file isn't a match for this matcher, then skip it.
|
||||
if (!this.test(filename)) continue;
|
||||
const pathname = this.normalizers.pathname.normalize(filename);
|
||||
const page = this.normalizers.page.normalize(filename);
|
||||
const bundlePath = this.normalizers.bundlePath.normalize(filename);
|
||||
if (this.localeNormalizer) {
|
||||
matchers.push(new PagesLocaleRouteMatcher({
|
||||
kind: RouteKind.PAGES,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename,
|
||||
i18n: {}
|
||||
}));
|
||||
} else {
|
||||
matchers.push(new PagesRouteMatcher({
|
||||
kind: RouteKind.PAGES,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename
|
||||
}));
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dev-pages-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/route-matcher-providers/dev/dev-pages-route-matcher-provider.ts"],"sourcesContent":["import type { FileReader } from './helpers/file-reader/file-reader'\nimport {\n PagesRouteMatcher,\n PagesLocaleRouteMatcher,\n} from '../../route-matchers/pages-route-matcher'\nimport { RouteKind } from '../../route-kind'\nimport path from 'path'\nimport type { LocaleRouteNormalizer } from '../../normalizers/locale-route-normalizer'\nimport { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider'\nimport { DevPagesNormalizers } from '../../normalizers/built/pages'\n\nexport class DevPagesRouteMatcherProvider extends FileCacheRouteMatcherProvider<PagesRouteMatcher> {\n private readonly expression: RegExp\n private readonly normalizers: DevPagesNormalizers\n\n constructor(\n private readonly pagesDir: string,\n private readonly extensions: ReadonlyArray<string>,\n reader: FileReader,\n private readonly localeNormalizer?: LocaleRouteNormalizer\n ) {\n super(pagesDir, reader)\n\n // Match any route file that ends with `/${filename}.${extension}` under the\n // pages directory.\n this.expression = new RegExp(`\\\\.(?:${extensions.join('|')})$`)\n\n this.normalizers = new DevPagesNormalizers(pagesDir, extensions)\n }\n\n private test(filename: string): boolean {\n // If the file does not end in the correct extension it's not a match.\n if (!this.expression.test(filename)) return false\n\n // Pages routes must exist in the pages directory without the `/api/`\n // prefix. The pathnames being tested here though are the full filenames,\n // so we need to include the pages directory.\n\n // TODO: could path separator normalization be needed here?\n if (filename.startsWith(path.join(this.pagesDir, '/api/'))) return false\n\n for (const extension of this.extensions) {\n // We can also match if we have `pages/api.${extension}`, so check to\n // see if it's a match.\n if (filename === path.join(this.pagesDir, `api.${extension}`)) {\n return false\n }\n }\n\n return true\n }\n\n protected async transform(\n files: ReadonlyArray<string>\n ): Promise<ReadonlyArray<PagesRouteMatcher>> {\n const matchers: Array<PagesRouteMatcher> = []\n for (const filename of files) {\n // If the file isn't a match for this matcher, then skip it.\n if (!this.test(filename)) continue\n\n const pathname = this.normalizers.pathname.normalize(filename)\n const page = this.normalizers.page.normalize(filename)\n const bundlePath = this.normalizers.bundlePath.normalize(filename)\n\n if (this.localeNormalizer) {\n matchers.push(\n new PagesLocaleRouteMatcher({\n kind: RouteKind.PAGES,\n pathname,\n page,\n bundlePath,\n filename,\n i18n: {},\n })\n )\n } else {\n matchers.push(\n new PagesRouteMatcher({\n kind: RouteKind.PAGES,\n pathname,\n page,\n bundlePath,\n filename,\n })\n )\n }\n }\n\n return matchers\n }\n}\n"],"names":["PagesRouteMatcher","PagesLocaleRouteMatcher","RouteKind","path","FileCacheRouteMatcherProvider","DevPagesNormalizers","DevPagesRouteMatcherProvider","constructor","pagesDir","extensions","reader","localeNormalizer","expression","RegExp","join","normalizers","test","filename","startsWith","extension","transform","files","matchers","pathname","normalize","page","bundlePath","push","kind","PAGES","i18n"],"mappings":"AACA,SACEA,iBAAiB,EACjBC,uBAAuB,QAClB,2CAA0C;AACjD,SAASC,SAAS,QAAQ,mBAAkB;AAC5C,OAAOC,UAAU,OAAM;AAEvB,SAASC,6BAA6B,QAAQ,sCAAqC;AACnF,SAASC,mBAAmB,QAAQ,gCAA+B;AAEnE,OAAO,MAAMC,qCAAqCF;IAIhDG,YACE,AAAiBC,QAAgB,EACjC,AAAiBC,UAAiC,EAClDC,MAAkB,EAClB,AAAiBC,gBAAwC,CACzD;QACA,KAAK,CAACH,UAAUE,cALCF,WAAAA,eACAC,aAAAA,iBAEAE,mBAAAA;QAIjB,4EAA4E;QAC5E,mBAAmB;QACnB,IAAI,CAACC,UAAU,GAAG,IAAIC,OAAO,CAAC,MAAM,EAAEJ,WAAWK,IAAI,CAAC,KAAK,EAAE,CAAC;QAE9D,IAAI,CAACC,WAAW,GAAG,IAAIV,oBAAoBG,UAAUC;IACvD;IAEQO,KAAKC,QAAgB,EAAW;QACtC,sEAAsE;QACtE,IAAI,CAAC,IAAI,CAACL,UAAU,CAACI,IAAI,CAACC,WAAW,OAAO;QAE5C,qEAAqE;QACrE,yEAAyE;QACzE,6CAA6C;QAE7C,2DAA2D;QAC3D,IAAIA,SAASC,UAAU,CAACf,KAAKW,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE,WAAW,OAAO;QAEnE,KAAK,MAAMW,aAAa,IAAI,CAACV,UAAU,CAAE;YACvC,qEAAqE;YACrE,uBAAuB;YACvB,IAAIQ,aAAad,KAAKW,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE,CAAC,IAAI,EAAEW,WAAW,GAAG;gBAC7D,OAAO;YACT;QACF;QAEA,OAAO;IACT;IAEA,MAAgBC,UACdC,KAA4B,EACe;QAC3C,MAAMC,WAAqC,EAAE;QAC7C,KAAK,MAAML,YAAYI,MAAO;YAC5B,4DAA4D;YAC5D,IAAI,CAAC,IAAI,CAACL,IAAI,CAACC,WAAW;YAE1B,MAAMM,WAAW,IAAI,CAACR,WAAW,CAACQ,QAAQ,CAACC,SAAS,CAACP;YACrD,MAAMQ,OAAO,IAAI,CAACV,WAAW,CAACU,IAAI,CAACD,SAAS,CAACP;YAC7C,MAAMS,aAAa,IAAI,CAACX,WAAW,CAACW,UAAU,CAACF,SAAS,CAACP;YAEzD,IAAI,IAAI,CAACN,gBAAgB,EAAE;gBACzBW,SAASK,IAAI,CACX,IAAI1B,wBAAwB;oBAC1B2B,MAAM1B,UAAU2B,KAAK;oBACrBN;oBACAE;oBACAC;oBACAT;oBACAa,MALine truncated
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
import { CachedRouteMatcherProvider } from '../helpers/cached-route-matcher-provider';
|
||||
/**
|
||||
* This will memoize the matchers when the file contents are the same.
|
||||
*/ export class FileCacheRouteMatcherProvider extends CachedRouteMatcherProvider {
|
||||
constructor(dir, reader){
|
||||
super({
|
||||
load: async ()=>reader.read(dir),
|
||||
compare: (left, right)=>{
|
||||
if (left.length !== right.length) return false;
|
||||
// Assuming the file traversal order is deterministic...
|
||||
for(let i = 0; i < left.length; i++){
|
||||
if (left[i] !== right[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=file-cache-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/route-matcher-providers/dev/file-cache-route-matcher-provider.ts"],"sourcesContent":["import type { RouteMatcher } from '../../route-matchers/route-matcher'\nimport { CachedRouteMatcherProvider } from '../helpers/cached-route-matcher-provider'\nimport type { FileReader } from './helpers/file-reader/file-reader'\n\n/**\n * This will memoize the matchers when the file contents are the same.\n */\nexport abstract class FileCacheRouteMatcherProvider<\n M extends RouteMatcher = RouteMatcher,\n> extends CachedRouteMatcherProvider<M, ReadonlyArray<string>> {\n constructor(dir: string, reader: FileReader) {\n super({\n load: async () => reader.read(dir),\n compare: (left, right) => {\n if (left.length !== right.length) return false\n\n // Assuming the file traversal order is deterministic...\n for (let i = 0; i < left.length; i++) {\n if (left[i] !== right[i]) return false\n }\n\n return true\n },\n })\n }\n}\n"],"names":["CachedRouteMatcherProvider","FileCacheRouteMatcherProvider","constructor","dir","reader","load","read","compare","left","right","length","i"],"mappings":"AACA,SAASA,0BAA0B,QAAQ,2CAA0C;AAGrF;;CAEC,GACD,OAAO,MAAeC,sCAEZD;IACRE,YAAYC,GAAW,EAAEC,MAAkB,CAAE;QAC3C,KAAK,CAAC;YACJC,MAAM,UAAYD,OAAOE,IAAI,CAACH;YAC9BI,SAAS,CAACC,MAAMC;gBACd,IAAID,KAAKE,MAAM,KAAKD,MAAMC,MAAM,EAAE,OAAO;gBAEzC,wDAAwD;gBACxD,IAAK,IAAIC,IAAI,GAAGA,IAAIH,KAAKE,MAAM,EAAEC,IAAK;oBACpC,IAAIH,IAAI,CAACG,EAAE,KAAKF,KAAK,CAACE,EAAE,EAAE,OAAO;gBACnC;gBAEA,OAAO;YACT;QACF;IACF;AACF"}
|
||||
Generated
Vendored
+99
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* CachedFileReader will deduplicate requests made to the same folder structure
|
||||
* to scan for files.
|
||||
*/ export class BatchedFileReader {
|
||||
constructor(reader){
|
||||
this.reader = reader;
|
||||
}
|
||||
schedule(callback) {
|
||||
if (!this.schedulePromise) {
|
||||
this.schedulePromise = Promise.resolve();
|
||||
}
|
||||
this.schedulePromise.then(()=>{
|
||||
process.nextTick(callback);
|
||||
});
|
||||
}
|
||||
getOrCreateBatch() {
|
||||
// If there is an existing batch and it's not completed, then reuse it.
|
||||
if (this.batch && !this.batch.completed) {
|
||||
return this.batch;
|
||||
}
|
||||
const batch = {
|
||||
completed: false,
|
||||
directories: [],
|
||||
callbacks: []
|
||||
};
|
||||
this.batch = batch;
|
||||
this.schedule(async ()=>{
|
||||
batch.completed = true;
|
||||
if (batch.directories.length === 0) return;
|
||||
// Collect all the results for each of the directories. If any error
|
||||
// occurs, send the results back to the loaders.
|
||||
let values;
|
||||
try {
|
||||
values = await this.load(batch.directories);
|
||||
} catch (err) {
|
||||
// Reject all the callbacks.
|
||||
for (const { reject } of batch.callbacks){
|
||||
reject(err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Loop over all the callbacks and send them their results.
|
||||
for(let i = 0; i < batch.callbacks.length; i++){
|
||||
const value = values[i];
|
||||
if (value instanceof Error) {
|
||||
batch.callbacks[i].reject(value);
|
||||
} else {
|
||||
batch.callbacks[i].resolve(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
return batch;
|
||||
}
|
||||
async load(directories) {
|
||||
// Make a unique array of directories. This is what lets us de-duplicate
|
||||
// loads for the same directory.
|
||||
const unique = [
|
||||
...new Set(directories)
|
||||
];
|
||||
const results = await Promise.all(unique.map(async (directory)=>{
|
||||
let files;
|
||||
let error;
|
||||
try {
|
||||
files = await this.reader.read(directory);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) error = err;
|
||||
}
|
||||
return {
|
||||
directory,
|
||||
files,
|
||||
error
|
||||
};
|
||||
}));
|
||||
return directories.map((directory)=>{
|
||||
const found = results.find((result)=>result.directory === directory);
|
||||
if (!found) return [];
|
||||
if (found.files) return found.files;
|
||||
if (found.error) return found.error;
|
||||
return [];
|
||||
});
|
||||
}
|
||||
async read(dir) {
|
||||
// Get or create a new file reading batch.
|
||||
const batch = this.getOrCreateBatch();
|
||||
// Push this directory into the batch to resolve.
|
||||
batch.directories.push(dir);
|
||||
// Push the promise handles into the batch (under the same index) so it can
|
||||
// be resolved later when it's scheduled.
|
||||
const promise = new Promise((resolve, reject)=>{
|
||||
batch.callbacks.push({
|
||||
resolve,
|
||||
reject
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=batched-file-reader.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.ts"],"sourcesContent":["import type { FileReader } from './file-reader'\n\ninterface FileReaderBatch {\n completed: boolean\n directories: Array<string>\n callbacks: Array<{\n resolve: (value: ReadonlyArray<string>) => void\n reject: (err: any) => void\n }>\n}\n\n/**\n * CachedFileReader will deduplicate requests made to the same folder structure\n * to scan for files.\n */\nexport class BatchedFileReader implements FileReader {\n private batch?: FileReaderBatch\n\n constructor(private readonly reader: FileReader) {}\n\n // This allows us to schedule the batches after all the promises associated\n // with loading files.\n private schedulePromise?: Promise<void>\n private schedule(callback: Function) {\n if (!this.schedulePromise) {\n this.schedulePromise = Promise.resolve()\n }\n this.schedulePromise.then(() => {\n process.nextTick(callback)\n })\n }\n\n private getOrCreateBatch(): FileReaderBatch {\n // If there is an existing batch and it's not completed, then reuse it.\n if (this.batch && !this.batch.completed) {\n return this.batch\n }\n\n const batch: FileReaderBatch = {\n completed: false,\n directories: [],\n callbacks: [],\n }\n\n this.batch = batch\n\n this.schedule(async () => {\n batch.completed = true\n if (batch.directories.length === 0) return\n\n // Collect all the results for each of the directories. If any error\n // occurs, send the results back to the loaders.\n let values: ReadonlyArray<ReadonlyArray<string> | Error>\n try {\n values = await this.load(batch.directories)\n } catch (err) {\n // Reject all the callbacks.\n for (const { reject } of batch.callbacks) {\n reject(err)\n }\n return\n }\n\n // Loop over all the callbacks and send them their results.\n for (let i = 0; i < batch.callbacks.length; i++) {\n const value = values[i]\n if (value instanceof Error) {\n batch.callbacks[i].reject(value)\n } else {\n batch.callbacks[i].resolve(value)\n }\n }\n })\n\n return batch\n }\n\n private async load(\n directories: ReadonlyArray<string>\n ): Promise<ReadonlyArray<ReadonlyArray<string> | Error>> {\n // Make a unique array of directories. This is what lets us de-duplicate\n // loads for the same directory.\n const unique = [...new Set(directories)]\n\n const results = await Promise.all(\n unique.map(async (directory) => {\n let files: ReadonlyArray<string> | undefined\n let error: Error | undefined\n try {\n files = await this.reader.read(directory)\n } catch (err) {\n if (err instanceof Error) error = err\n }\n\n return { directory, files, error }\n })\n )\n\n return directories.map((directory) => {\n const found = results.find((result) => result.directory === directory)\n if (!found) return []\n\n if (found.files) return found.files\n if (found.error) return found.error\n\n return []\n })\n }\n\n public async read(dir: string): Promise<ReadonlyArray<string>> {\n // Get or create a new file reading batch.\n const batch = this.getOrCreateBatch()\n\n // Push this directory into the batch to resolve.\n batch.directories.push(dir)\n\n // Push the promise handles into the batch (under the same index) so it can\n // be resolved later when it's scheduled.\n const promise = new Promise<ReadonlyArray<string>>((resolve, reject) => {\n batch.callbacks.push({ resolve, reject })\n })\n\n return promise\n }\n}\n"],"names":["BatchedFileReader","constructor","reader","schedule","callback","schedulePromise","Promise","resolve","then","process","nextTick","getOrCreateBatch","batch","completed","directories","callbacks","length","values","load","err","reject","i","value","Error","unique","Set","results","all","map","directory","files","error","read","found","find","result","dir","push","promise"],"mappings":"AAWA;;;CAGC,GACD,OAAO,MAAMA;IAGXC,YAAY,AAAiBC,MAAkB,CAAE;aAApBA,SAAAA;IAAqB;IAK1CC,SAASC,QAAkB,EAAE;QACnC,IAAI,CAAC,IAAI,CAACC,eAAe,EAAE;YACzB,IAAI,CAACA,eAAe,GAAGC,QAAQC,OAAO;QACxC;QACA,IAAI,CAACF,eAAe,CAACG,IAAI,CAAC;YACxBC,QAAQC,QAAQ,CAACN;QACnB;IACF;IAEQO,mBAAoC;QAC1C,uEAAuE;QACvE,IAAI,IAAI,CAACC,KAAK,IAAI,CAAC,IAAI,CAACA,KAAK,CAACC,SAAS,EAAE;YACvC,OAAO,IAAI,CAACD,KAAK;QACnB;QAEA,MAAMA,QAAyB;YAC7BC,WAAW;YACXC,aAAa,EAAE;YACfC,WAAW,EAAE;QACf;QAEA,IAAI,CAACH,KAAK,GAAGA;QAEb,IAAI,CAACT,QAAQ,CAAC;YACZS,MAAMC,SAAS,GAAG;YAClB,IAAID,MAAME,WAAW,CAACE,MAAM,KAAK,GAAG;YAEpC,oEAAoE;YACpE,gDAAgD;YAChD,IAAIC;YACJ,IAAI;gBACFA,SAAS,MAAM,IAAI,CAACC,IAAI,CAACN,MAAME,WAAW;YAC5C,EAAE,OAAOK,KAAK;gBACZ,4BAA4B;gBAC5B,KAAK,MAAM,EAAEC,MAAM,EAAE,IAAIR,MAAMG,SAAS,CAAE;oBACxCK,OAAOD;gBACT;gBACA;YACF;YAEA,2DAA2D;YAC3D,IAAK,ILine truncated
|
||||
Generated
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
import { recursiveReadDir } from '../../../../../lib/recursive-readdir';
|
||||
/**
|
||||
* Reads all the files in the directory and its subdirectories following any
|
||||
* symbolic links.
|
||||
*/ export class DefaultFileReader {
|
||||
/**
|
||||
* Creates a new file reader.
|
||||
*
|
||||
* @param pathnameFilter filter to ignore files with absolute pathnames, false to ignore
|
||||
* @param ignoreFilter filter to ignore files and directories with absolute pathnames, false to ignore
|
||||
* @param ignorePartFilter filter to ignore files and directories with the pathname part, false to ignore
|
||||
*/ constructor(options){
|
||||
this.options = options;
|
||||
}
|
||||
/**
|
||||
* Reads all the files in the directory and its subdirectories following any
|
||||
* symbolic links.
|
||||
*
|
||||
* @param dir the directory to read
|
||||
* @returns a promise that resolves to the list of files
|
||||
*/ async read(dir) {
|
||||
return recursiveReadDir(dir, {
|
||||
pathnameFilter: this.options.pathnameFilter,
|
||||
ignoreFilter: this.options.ignoreFilter,
|
||||
ignorePartFilter: this.options.ignorePartFilter,
|
||||
// We don't need to sort the results because we're not depending on the
|
||||
// order of the results.
|
||||
sortPathnames: false,
|
||||
// We want absolute pathnames because we're going to be comparing them
|
||||
// with other absolute pathnames.
|
||||
relativePathnames: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=default-file-reader.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-matcher-providers/dev/helpers/file-reader/default-file-reader.ts"],"sourcesContent":["import type { FileReader } from './file-reader'\nimport type { RecursiveReadDirOptions } from '../../../../../lib/recursive-readdir'\nimport { recursiveReadDir } from '../../../../../lib/recursive-readdir'\n\nexport type DefaultFileReaderOptions = Pick<\n RecursiveReadDirOptions,\n 'pathnameFilter' | 'ignoreFilter' | 'ignorePartFilter'\n>\n\n/**\n * Reads all the files in the directory and its subdirectories following any\n * symbolic links.\n */\nexport class DefaultFileReader implements FileReader {\n /**\n * Filter to ignore files with absolute pathnames. If undefined, no files are\n * ignored.\n */\n private readonly options: Readonly<DefaultFileReaderOptions>\n\n /**\n * Creates a new file reader.\n *\n * @param pathnameFilter filter to ignore files with absolute pathnames, false to ignore\n * @param ignoreFilter filter to ignore files and directories with absolute pathnames, false to ignore\n * @param ignorePartFilter filter to ignore files and directories with the pathname part, false to ignore\n */\n constructor(options: Readonly<DefaultFileReaderOptions>) {\n this.options = options\n }\n\n /**\n * Reads all the files in the directory and its subdirectories following any\n * symbolic links.\n *\n * @param dir the directory to read\n * @returns a promise that resolves to the list of files\n */\n public async read(dir: string): Promise<ReadonlyArray<string>> {\n return recursiveReadDir(dir, {\n pathnameFilter: this.options.pathnameFilter,\n ignoreFilter: this.options.ignoreFilter,\n ignorePartFilter: this.options.ignorePartFilter,\n\n // We don't need to sort the results because we're not depending on the\n // order of the results.\n sortPathnames: false,\n\n // We want absolute pathnames because we're going to be comparing them\n // with other absolute pathnames.\n relativePathnames: false,\n })\n }\n}\n"],"names":["recursiveReadDir","DefaultFileReader","constructor","options","read","dir","pathnameFilter","ignoreFilter","ignorePartFilter","sortPathnames","relativePathnames"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,uCAAsC;AAOvE;;;CAGC,GACD,OAAO,MAAMC;IAOX;;;;;;GAMC,GACDC,YAAYC,OAA2C,CAAE;QACvD,IAAI,CAACA,OAAO,GAAGA;IACjB;IAEA;;;;;;GAMC,GACD,MAAaC,KAAKC,GAAW,EAAkC;QAC7D,OAAOL,iBAAiBK,KAAK;YAC3BC,gBAAgB,IAAI,CAACH,OAAO,CAACG,cAAc;YAC3CC,cAAc,IAAI,CAACJ,OAAO,CAACI,YAAY;YACvCC,kBAAkB,IAAI,CAACL,OAAO,CAACK,gBAAgB;YAE/C,uEAAuE;YACvE,wBAAwB;YACxBC,eAAe;YAEf,sEAAsE;YACtE,iCAAiC;YACjCC,mBAAmB;QACrB;IACF;AACF"}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export { };
|
||||
|
||||
//# sourceMappingURL=file-reader.js.map
|
||||
node_modules/next/dist/esm/server/route-matcher-providers/dev/helpers/file-reader/file-reader.js.map
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-matcher-providers/dev/helpers/file-reader/file-reader.ts"],"sourcesContent":["export interface FileReader {\n /**\n * Reads the directory contents recursively.\n *\n * @param dir directory to read recursively from\n */\n read(dir: string): Promise<ReadonlyArray<string>> | ReadonlyArray<string>\n}\n"],"names":[],"mappings":"AAAA,WAOC"}
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* This will memoize the matchers if the loaded data is comparable.
|
||||
*/ export class CachedRouteMatcherProvider {
|
||||
constructor(loader){
|
||||
this.loader = loader;
|
||||
this.cached = [];
|
||||
}
|
||||
async matchers() {
|
||||
const data = await this.loader.load();
|
||||
if (!data) return [];
|
||||
// Return the cached matchers if the data has not changed.
|
||||
if (this.data && this.loader.compare(this.data, data)) return this.cached;
|
||||
this.data = data;
|
||||
// Transform the manifest into matchers.
|
||||
const matchers = await this.transform(data);
|
||||
// Cache the matchers.
|
||||
this.cached = matchers;
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=cached-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/route-matcher-providers/helpers/cached-route-matcher-provider.ts"],"sourcesContent":["import type { RouteMatcherProvider } from '../route-matcher-provider'\nimport type { RouteMatcher } from '../../route-matchers/route-matcher'\n\ninterface LoaderComparable<D> {\n load(): Promise<D>\n compare(left: D, right: D): boolean\n}\n\n/**\n * This will memoize the matchers if the loaded data is comparable.\n */\nexport abstract class CachedRouteMatcherProvider<\n M extends RouteMatcher = RouteMatcher,\n D = any,\n> implements RouteMatcherProvider<M>\n{\n private data?: D\n private cached: ReadonlyArray<M> = []\n\n constructor(private readonly loader: LoaderComparable<D>) {}\n\n protected abstract transform(data: D): Promise<ReadonlyArray<M>>\n\n public async matchers(): Promise<readonly M[]> {\n const data = await this.loader.load()\n if (!data) return []\n\n // Return the cached matchers if the data has not changed.\n if (this.data && this.loader.compare(this.data, data)) return this.cached\n this.data = data\n\n // Transform the manifest into matchers.\n const matchers = await this.transform(data)\n\n // Cache the matchers.\n this.cached = matchers\n\n return matchers\n }\n}\n"],"names":["CachedRouteMatcherProvider","constructor","loader","cached","matchers","data","load","compare","transform"],"mappings":"AAQA;;CAEC,GACD,OAAO,MAAeA;IAQpBC,YAAY,AAAiBC,MAA2B,CAAE;aAA7BA,SAAAA;aAFrBC,SAA2B,EAAE;IAEsB;IAI3D,MAAaC,WAAkC;QAC7C,MAAMC,OAAO,MAAM,IAAI,CAACH,MAAM,CAACI,IAAI;QACnC,IAAI,CAACD,MAAM,OAAO,EAAE;QAEpB,0DAA0D;QAC1D,IAAI,IAAI,CAACA,IAAI,IAAI,IAAI,CAACH,MAAM,CAACK,OAAO,CAAC,IAAI,CAACF,IAAI,EAAEA,OAAO,OAAO,IAAI,CAACF,MAAM;QACzE,IAAI,CAACE,IAAI,GAAGA;QAEZ,wCAAwC;QACxC,MAAMD,WAAW,MAAM,IAAI,CAACI,SAAS,CAACH;QAEtC,sBAAsB;QACtB,IAAI,CAACF,MAAM,GAAGC;QAEd,OAAOA;IACT;AACF"}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export { };
|
||||
|
||||
//# sourceMappingURL=manifest-loader.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-matcher-providers/helpers/manifest-loaders/manifest-loader.ts"],"sourcesContent":["export type Manifest = Record<string, string>\n\nexport interface ManifestLoader {\n load(name: string): Manifest | null\n}\n"],"names":[],"mappings":"AAEA,WAEC"}
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import { SERVER_DIRECTORY } from '../../../../shared/lib/constants';
|
||||
import path from '../../../../shared/lib/isomorphic/path';
|
||||
export class NodeManifestLoader {
|
||||
constructor(distDir){
|
||||
this.distDir = distDir;
|
||||
}
|
||||
static require(id) {
|
||||
try {
|
||||
return require(id);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
load(name) {
|
||||
return NodeManifestLoader.require(path.join(this.distDir, SERVER_DIRECTORY, name));
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=node-manifest-loader.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-matcher-providers/helpers/manifest-loaders/node-manifest-loader.ts"],"sourcesContent":["import { SERVER_DIRECTORY } from '../../../../shared/lib/constants'\nimport path from '../../../../shared/lib/isomorphic/path'\nimport type { Manifest, ManifestLoader } from './manifest-loader'\n\nexport class NodeManifestLoader implements ManifestLoader {\n constructor(private readonly distDir: string) {}\n\n static require(id: string) {\n try {\n return require(id)\n } catch {\n return null\n }\n }\n\n public load(name: string): Manifest | null {\n return NodeManifestLoader.require(\n path.join(this.distDir, SERVER_DIRECTORY, name)\n )\n }\n}\n"],"names":["SERVER_DIRECTORY","path","NodeManifestLoader","constructor","distDir","require","id","load","name","join"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,mCAAkC;AACnE,OAAOC,UAAU,yCAAwC;AAGzD,OAAO,MAAMC;IACXC,YAAY,AAAiBC,OAAe,CAAE;aAAjBA,UAAAA;IAAkB;IAE/C,OAAOC,QAAQC,EAAU,EAAE;QACzB,IAAI;YACF,OAAOD,QAAQC;QACjB,EAAE,OAAM;YACN,OAAO;QACT;IACF;IAEOC,KAAKC,IAAY,EAAmB;QACzC,OAAON,mBAAmBG,OAAO,CAC/BJ,KAAKQ,IAAI,CAAC,IAAI,CAACL,OAAO,EAAEJ,kBAAkBQ;IAE9C;AACF"}
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
export class ServerManifestLoader {
|
||||
constructor(getter){
|
||||
this.getter = getter;
|
||||
}
|
||||
load(name) {
|
||||
return this.getter(name);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=server-manifest-loader.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-matcher-providers/helpers/manifest-loaders/server-manifest-loader.ts"],"sourcesContent":["import type { Manifest, ManifestLoader } from './manifest-loader'\n\nexport class ServerManifestLoader implements ManifestLoader {\n constructor(private readonly getter: (name: string) => Manifest | null) {}\n\n public load(name: string): Manifest | null {\n return this.getter(name)\n }\n}\n"],"names":["ServerManifestLoader","constructor","getter","load","name"],"mappings":"AAEA,OAAO,MAAMA;IACXC,YAAY,AAAiBC,MAAyC,CAAE;aAA3CA,SAAAA;IAA4C;IAElEC,KAAKC,IAAY,EAAmB;QACzC,OAAO,IAAI,CAACF,MAAM,CAACE;IACrB;AACF"}
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { CachedRouteMatcherProvider } from './helpers/cached-route-matcher-provider';
|
||||
export class ManifestRouteMatcherProvider extends CachedRouteMatcherProvider {
|
||||
constructor(manifestName, manifestLoader){
|
||||
super({
|
||||
load: async ()=>manifestLoader.load(manifestName),
|
||||
compare: (left, right)=>left === right
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=manifest-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/route-matcher-providers/manifest-route-matcher-provider.ts"],"sourcesContent":["import type { RouteMatcher } from '../route-matchers/route-matcher'\nimport type {\n Manifest,\n ManifestLoader,\n} from './helpers/manifest-loaders/manifest-loader'\nimport { CachedRouteMatcherProvider } from './helpers/cached-route-matcher-provider'\n\nexport abstract class ManifestRouteMatcherProvider<\n M extends RouteMatcher = RouteMatcher,\n> extends CachedRouteMatcherProvider<M, Manifest | null> {\n constructor(manifestName: string, manifestLoader: ManifestLoader) {\n super({\n load: async () => manifestLoader.load(manifestName),\n compare: (left, right) => left === right,\n })\n }\n}\n"],"names":["CachedRouteMatcherProvider","ManifestRouteMatcherProvider","constructor","manifestName","manifestLoader","load","compare","left","right"],"mappings":"AAKA,SAASA,0BAA0B,QAAQ,0CAAyC;AAEpF,OAAO,MAAeC,qCAEZD;IACRE,YAAYC,YAAoB,EAAEC,cAA8B,CAAE;QAChE,KAAK,CAAC;YACJC,MAAM,UAAYD,eAAeC,IAAI,CAACF;YACtCG,SAAS,CAACC,MAAMC,QAAUD,SAASC;QACrC;IACF;AACF"}
|
||||
Generated
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
import { isAPIRoute } from '../../lib/is-api-route';
|
||||
import { PAGES_MANIFEST } from '../../shared/lib/constants';
|
||||
import { RouteKind } from '../route-kind';
|
||||
import { PagesAPILocaleRouteMatcher, PagesAPIRouteMatcher } from '../route-matchers/pages-api-route-matcher';
|
||||
import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider';
|
||||
import { PagesNormalizers } from '../normalizers/built/pages';
|
||||
export class PagesAPIRouteMatcherProvider extends ManifestRouteMatcherProvider {
|
||||
constructor(distDir, manifestLoader, i18nProvider){
|
||||
super(PAGES_MANIFEST, manifestLoader), this.i18nProvider = i18nProvider;
|
||||
this.normalizers = new PagesNormalizers(distDir);
|
||||
}
|
||||
async transform(manifest) {
|
||||
// This matcher is only for Pages API routes.
|
||||
const pathnames = Object.keys(manifest).filter((pathname)=>isAPIRoute(pathname));
|
||||
const matchers = [];
|
||||
for (const page of pathnames){
|
||||
if (this.i18nProvider) {
|
||||
// Match the locale on the page name, or default to the default locale.
|
||||
const { detectedLocale, pathname } = this.i18nProvider.analyze(page);
|
||||
matchers.push(new PagesAPILocaleRouteMatcher({
|
||||
kind: RouteKind.PAGES_API,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath: this.normalizers.bundlePath.normalize(page),
|
||||
filename: this.normalizers.filename.normalize(manifest[page]),
|
||||
i18n: {
|
||||
locale: detectedLocale
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
matchers.push(new PagesAPIRouteMatcher({
|
||||
kind: RouteKind.PAGES_API,
|
||||
// In `pages/`, the page is the same as the pathname.
|
||||
pathname: page,
|
||||
page,
|
||||
bundlePath: this.normalizers.bundlePath.normalize(page),
|
||||
filename: this.normalizers.filename.normalize(manifest[page])
|
||||
}));
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=pages-api-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/route-matcher-providers/pages-api-route-matcher-provider.ts"],"sourcesContent":["import { isAPIRoute } from '../../lib/is-api-route'\nimport { PAGES_MANIFEST } from '../../shared/lib/constants'\nimport { RouteKind } from '../route-kind'\nimport {\n PagesAPILocaleRouteMatcher,\n PagesAPIRouteMatcher,\n} from '../route-matchers/pages-api-route-matcher'\nimport type {\n Manifest,\n ManifestLoader,\n} from './helpers/manifest-loaders/manifest-loader'\nimport { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider'\nimport type { I18NProvider } from '../lib/i18n-provider'\nimport { PagesNormalizers } from '../normalizers/built/pages'\n\nexport class PagesAPIRouteMatcherProvider extends ManifestRouteMatcherProvider<PagesAPIRouteMatcher> {\n private readonly normalizers: PagesNormalizers\n\n constructor(\n distDir: string,\n manifestLoader: ManifestLoader,\n private readonly i18nProvider?: I18NProvider\n ) {\n super(PAGES_MANIFEST, manifestLoader)\n\n this.normalizers = new PagesNormalizers(distDir)\n }\n\n protected async transform(\n manifest: Manifest\n ): Promise<ReadonlyArray<PagesAPIRouteMatcher>> {\n // This matcher is only for Pages API routes.\n const pathnames = Object.keys(manifest).filter((pathname) =>\n isAPIRoute(pathname)\n )\n\n const matchers: Array<PagesAPIRouteMatcher> = []\n\n for (const page of pathnames) {\n if (this.i18nProvider) {\n // Match the locale on the page name, or default to the default locale.\n const { detectedLocale, pathname } = this.i18nProvider.analyze(page)\n\n matchers.push(\n new PagesAPILocaleRouteMatcher({\n kind: RouteKind.PAGES_API,\n pathname,\n page,\n bundlePath: this.normalizers.bundlePath.normalize(page),\n filename: this.normalizers.filename.normalize(manifest[page]),\n i18n: {\n locale: detectedLocale,\n },\n })\n )\n } else {\n matchers.push(\n new PagesAPIRouteMatcher({\n kind: RouteKind.PAGES_API,\n // In `pages/`, the page is the same as the pathname.\n pathname: page,\n page,\n bundlePath: this.normalizers.bundlePath.normalize(page),\n filename: this.normalizers.filename.normalize(manifest[page]),\n })\n )\n }\n }\n\n return matchers\n }\n}\n"],"names":["isAPIRoute","PAGES_MANIFEST","RouteKind","PagesAPILocaleRouteMatcher","PagesAPIRouteMatcher","ManifestRouteMatcherProvider","PagesNormalizers","PagesAPIRouteMatcherProvider","constructor","distDir","manifestLoader","i18nProvider","normalizers","transform","manifest","pathnames","Object","keys","filter","pathname","matchers","page","detectedLocale","analyze","push","kind","PAGES_API","bundlePath","normalize","filename","i18n","locale"],"mappings":"AAAA,SAASA,UAAU,QAAQ,yBAAwB;AACnD,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,SAAS,QAAQ,gBAAe;AACzC,SACEC,0BAA0B,EAC1BC,oBAAoB,QACf,4CAA2C;AAKlD,SAASC,4BAA4B,QAAQ,oCAAmC;AAEhF,SAASC,gBAAgB,QAAQ,6BAA4B;AAE7D,OAAO,MAAMC,qCAAqCF;IAGhDG,YACEC,OAAe,EACfC,cAA8B,EAC9B,AAAiBC,YAA2B,CAC5C;QACA,KAAK,CAACV,gBAAgBS,sBAFLC,eAAAA;QAIjB,IAAI,CAACC,WAAW,GAAG,IAAIN,iBAAiBG;IAC1C;IAEA,MAAgBI,UACdC,QAAkB,EAC4B;QAC9C,6CAA6C;QAC7C,MAAMC,YAAYC,OAAOC,IAAI,CAACH,UAAUI,MAAM,CAAC,CAACC,WAC9CnB,WAAWmB;QAGb,MAAMC,WAAwC,EAAE;QAEhD,KAAK,MAAMC,QAAQN,UAAW;YAC5B,IAAI,IAAI,CAACJ,YAAY,EAAE;gBACrB,uEAAuE;gBACvE,MAAM,EAAEW,cAAc,EAAEH,QAAQ,EAAE,GAAG,IAAI,CAACR,YAAY,CAACY,OAAO,CAACF;gBAE/DD,SAASI,IAAI,CACX,IAAIrB,2BAA2B;oBAC7BsB,MAAMvB,UAAUwB,SAAS;oBACzBP;oBACAE;oBACAM,YAAY,IAAI,CAACf,WAAW,CAACe,UAAU,CAACC,SAAS,CAACP;oBAClDQ,UAAU,IAAI,CAACjB,WAAW,CAACiB,QAAQ,CAACD,SAAS,CAACd,QAAQ,CAACO,KAAK;oBAC5DS,MAAM;wBACJC,QAAQT;oBACV;gBACF;YAEJ,OAAO;gBACLF,SAASI,IAAI,CACX,IAAIpB,qBAAqB;oBACvBqB,MAAMvB,UAAUwB,SAAS;oBACzB,qDAAqD;oBACrDP,UAAUE;oBACVA;oBACAM,YAAY,IAAI,CAACf,WAAW,CAACe,UAAU,CAACC,SAAS,CAACP;oBAClDQ,UAAU,IAAI,CAACjB,WAAW,CAACiB,QAAQ,CAACD,SAAS,CAACd,QAAQ,CAACO,KAAK;gBAC9D;YAEJ;QACF;QAEA,OAAOD;IACT;AACF"}
|
||||
Generated
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
import { isAPIRoute } from '../../lib/is-api-route';
|
||||
import { BLOCKED_PAGES, PAGES_MANIFEST } from '../../shared/lib/constants';
|
||||
import { RouteKind } from '../route-kind';
|
||||
import { PagesLocaleRouteMatcher, PagesRouteMatcher } from '../route-matchers/pages-route-matcher';
|
||||
import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider';
|
||||
import { PagesNormalizers } from '../normalizers/built/pages';
|
||||
export class PagesRouteMatcherProvider extends ManifestRouteMatcherProvider {
|
||||
constructor(distDir, manifestLoader, i18nProvider){
|
||||
super(PAGES_MANIFEST, manifestLoader), this.i18nProvider = i18nProvider;
|
||||
this.normalizers = new PagesNormalizers(distDir);
|
||||
}
|
||||
async transform(manifest) {
|
||||
// This matcher is only for Pages routes, not Pages API routes which are
|
||||
// included in this manifest.
|
||||
const pathnames = Object.keys(manifest).filter((pathname)=>!isAPIRoute(pathname))// Remove any blocked pages (page that can't be routed to, like error or
|
||||
// internal pages).
|
||||
.filter((pathname)=>{
|
||||
var _this_i18nProvider;
|
||||
const normalized = ((_this_i18nProvider = this.i18nProvider) == null ? void 0 : _this_i18nProvider.analyze(pathname).pathname) ?? pathname;
|
||||
// Skip any blocked pages.
|
||||
if (BLOCKED_PAGES.includes(normalized)) return false;
|
||||
return true;
|
||||
});
|
||||
const matchers = [];
|
||||
for (const page of pathnames){
|
||||
if (this.i18nProvider) {
|
||||
// Match the locale on the page name, or default to the default locale.
|
||||
const { detectedLocale, pathname } = this.i18nProvider.analyze(page);
|
||||
matchers.push(new PagesLocaleRouteMatcher({
|
||||
kind: RouteKind.PAGES,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath: this.normalizers.bundlePath.normalize(page),
|
||||
filename: this.normalizers.filename.normalize(manifest[page]),
|
||||
i18n: {
|
||||
locale: detectedLocale
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
matchers.push(new PagesRouteMatcher({
|
||||
kind: RouteKind.PAGES,
|
||||
// In `pages/`, the page is the same as the pathname.
|
||||
pathname: page,
|
||||
page,
|
||||
bundlePath: this.normalizers.bundlePath.normalize(page),
|
||||
filename: this.normalizers.filename.normalize(manifest[page])
|
||||
}));
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=pages-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/route-matcher-providers/pages-route-matcher-provider.ts"],"sourcesContent":["import { isAPIRoute } from '../../lib/is-api-route'\nimport { BLOCKED_PAGES, PAGES_MANIFEST } from '../../shared/lib/constants'\nimport { RouteKind } from '../route-kind'\nimport {\n PagesLocaleRouteMatcher,\n PagesRouteMatcher,\n} from '../route-matchers/pages-route-matcher'\nimport type {\n Manifest,\n ManifestLoader,\n} from './helpers/manifest-loaders/manifest-loader'\nimport { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider'\nimport type { I18NProvider } from '../lib/i18n-provider'\nimport { PagesNormalizers } from '../normalizers/built/pages'\n\nexport class PagesRouteMatcherProvider extends ManifestRouteMatcherProvider<PagesRouteMatcher> {\n private readonly normalizers: PagesNormalizers\n\n constructor(\n distDir: string,\n manifestLoader: ManifestLoader,\n private readonly i18nProvider?: I18NProvider\n ) {\n super(PAGES_MANIFEST, manifestLoader)\n\n this.normalizers = new PagesNormalizers(distDir)\n }\n\n protected async transform(\n manifest: Manifest\n ): Promise<ReadonlyArray<PagesRouteMatcher>> {\n // This matcher is only for Pages routes, not Pages API routes which are\n // included in this manifest.\n const pathnames = Object.keys(manifest)\n .filter((pathname) => !isAPIRoute(pathname))\n // Remove any blocked pages (page that can't be routed to, like error or\n // internal pages).\n .filter((pathname) => {\n const normalized =\n this.i18nProvider?.analyze(pathname).pathname ?? pathname\n\n // Skip any blocked pages.\n if (BLOCKED_PAGES.includes(normalized)) return false\n\n return true\n })\n\n const matchers: Array<PagesRouteMatcher> = []\n for (const page of pathnames) {\n if (this.i18nProvider) {\n // Match the locale on the page name, or default to the default locale.\n const { detectedLocale, pathname } = this.i18nProvider.analyze(page)\n\n matchers.push(\n new PagesLocaleRouteMatcher({\n kind: RouteKind.PAGES,\n pathname,\n page,\n bundlePath: this.normalizers.bundlePath.normalize(page),\n filename: this.normalizers.filename.normalize(manifest[page]),\n i18n: {\n locale: detectedLocale,\n },\n })\n )\n } else {\n matchers.push(\n new PagesRouteMatcher({\n kind: RouteKind.PAGES,\n // In `pages/`, the page is the same as the pathname.\n pathname: page,\n page,\n bundlePath: this.normalizers.bundlePath.normalize(page),\n filename: this.normalizers.filename.normalize(manifest[page]),\n })\n )\n }\n }\n\n return matchers\n }\n}\n"],"names":["isAPIRoute","BLOCKED_PAGES","PAGES_MANIFEST","RouteKind","PagesLocaleRouteMatcher","PagesRouteMatcher","ManifestRouteMatcherProvider","PagesNormalizers","PagesRouteMatcherProvider","constructor","distDir","manifestLoader","i18nProvider","normalizers","transform","manifest","pathnames","Object","keys","filter","pathname","normalized","analyze","includes","matchers","page","detectedLocale","push","kind","PAGES","bundlePath","normalize","filename","i18n","locale"],"mappings":"AAAA,SAASA,UAAU,QAAQ,yBAAwB;AACnD,SAASC,aAAa,EAAEC,cAAc,QAAQ,6BAA4B;AAC1E,SAASC,SAAS,QAAQ,gBAAe;AACzC,SACEC,uBAAuB,EACvBC,iBAAiB,QACZ,wCAAuC;AAK9C,SAASC,4BAA4B,QAAQ,oCAAmC;AAEhF,SAASC,gBAAgB,QAAQ,6BAA4B;AAE7D,OAAO,MAAMC,kCAAkCF;IAG7CG,YACEC,OAAe,EACfC,cAA8B,EAC9B,AAAiBC,YAA2B,CAC5C;QACA,KAAK,CAACV,gBAAgBS,sBAFLC,eAAAA;QAIjB,IAAI,CAACC,WAAW,GAAG,IAAIN,iBAAiBG;IAC1C;IAEA,MAAgBI,UACdC,QAAkB,EACyB;QAC3C,wEAAwE;QACxE,6BAA6B;QAC7B,MAAMC,YAAYC,OAAOC,IAAI,CAACH,UAC3BI,MAAM,CAAC,CAACC,WAAa,CAACpB,WAAWoB,UAClC,wEAAwE;QACxE,mBAAmB;SAClBD,MAAM,CAAC,CAACC;gBAEL;YADF,MAAMC,aACJ,EAAA,qBAAA,IAAI,CAACT,YAAY,qBAAjB,mBAAmBU,OAAO,CAACF,UAAUA,QAAQ,KAAIA;YAEnD,0BAA0B;YAC1B,IAAInB,cAAcsB,QAAQ,CAACF,aAAa,OAAO;YAE/C,OAAO;QACT;QAEF,MAAMG,WAAqC,EAAE;QAC7C,KAAK,MAAMC,QAAQT,UAAW;YAC5B,IAAI,IAAI,CAACJ,YAAY,EAAE;gBACrB,uEAAuE;gBACvE,MAAM,EAAEc,cAAc,EAAEN,QAAQ,EAAE,GAAG,IAAI,CAACR,YAAY,CAACU,OAAO,CAACG;gBAE/DD,SAASG,IAAI,CACX,IAAIvB,wBAAwB;oBAC1BwB,MAAMzB,UAAU0B,KAAK;oBACrBT;oBACAK;oBACAK,YAAY,IAAI,CAACjB,WAAW,CAACiB,UAAU,CAACC,SAAS,CAACN;oBAClDO,UAAU,IAAI,CAACnB,WAAW,CAACmB,QAAQ,CAACD,SAAS,CAAChB,QAAQ,CAACU,KAAK;oBAC5DQ,MAAM;wBACJC,QAAQR;oBACV;gBACF;YAEJ,OAAO;gBACLF,SAASG,IAAI,CACX,IAAItB,kBAAkB;oBACpBuB,MAAMzB,UAAU0B,KAAK;oBACrB,qDAAqD;oBACrDT,UAAUK;oBACVA;oBACAK,YAAY,IAAI,CAACjB,WAAW,CAACiB,UAAU,CAACC,SAAS,CAACN;oBAClDO,UAAU,IAAI,CAACnB,WAAW,CAACmB,QAAQ,CAACD,SAAS,CAAChB,QAAQ,CAACU,KAAK;gBAC9D;YAEJ;QACF;QAEA,OAAOD;IACT;AACF"}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export { };
|
||||
|
||||
//# sourceMappingURL=route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/route-matcher-providers/route-matcher-provider.ts"],"sourcesContent":["import type { RouteMatcher } from '../route-matchers/route-matcher'\n\nexport interface RouteMatcherProvider<M extends RouteMatcher = RouteMatcher> {\n matchers(): Promise<ReadonlyArray<M>>\n}\n"],"names":[],"mappings":"AAEA,WAEC"}
|
||||
Reference in new issue
Block a user