.
This commit is contained in:
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { AppPageRouteMatcher } from '../route-matchers/app-page-route-matcher';
|
||||
import type { Manifest, ManifestLoader } from './helpers/manifest-loaders/manifest-loader';
|
||||
import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider';
|
||||
export declare class AppPageRouteMatcherProvider extends ManifestRouteMatcherProvider<AppPageRouteMatcher> {
|
||||
private readonly normalizers;
|
||||
constructor(distDir: string, manifestLoader: ManifestLoader);
|
||||
protected transform(manifest: Manifest): Promise<ReadonlyArray<AppPageRouteMatcher>>;
|
||||
}
|
||||
Generated
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "AppPageRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return AppPageRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _isapppageroute = require("../../lib/is-app-page-route");
|
||||
const _constants = require("../../shared/lib/constants");
|
||||
const _app = require("../normalizers/built/app");
|
||||
const _routekind = require("../route-kind");
|
||||
const _apppageroutematcher = require("../route-matchers/app-page-route-matcher");
|
||||
const _manifestroutematcherprovider = require("./manifest-route-matcher-provider");
|
||||
class AppPageRouteMatcherProvider extends _manifestroutematcherprovider.ManifestRouteMatcherProvider {
|
||||
constructor(distDir, manifestLoader){
|
||||
super(_constants.APP_PATHS_MANIFEST, manifestLoader);
|
||||
this.normalizers = new _app.AppNormalizers(distDir);
|
||||
}
|
||||
async transform(manifest) {
|
||||
// This matcher only matches app pages.
|
||||
const pages = Object.keys(manifest).filter((page)=>(0, _isapppageroute.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.AppPageRouteMatcher({
|
||||
kind: _routekind.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":["AppPageRouteMatcherProvider","ManifestRouteMatcherProvider","constructor","distDir","manifestLoader","APP_PATHS_MANIFEST","normalizers","AppNormalizers","transform","manifest","pages","Object","keys","filter","page","isAppPageRoute","allAppPaths","pathname","normalize","push","matchers","appPaths","entries","filename","bundlePath","AppPageRouteMatcher","kind","RouteKind","APP_PAGE"],"mappings":";;;;+BAYaA;;;eAAAA;;;gCAZkB;2BAEI;qBACJ;2BACL;qCACU;8CAKS;AAEtC,MAAMA,oCAAoCC,0DAA4B;IAG3EC,YAAYC,OAAe,EAAEC,cAA8B,CAAE;QAC3D,KAAK,CAACC,6BAAkB,EAAED;QAE1B,IAAI,CAACE,WAAW,GAAG,IAAIC,mBAAc,CAACJ;IACxC;IAEA,MAAgBK,UACdC,QAAkB,EAC2B;QAC7C,uCAAuC;QACvC,MAAMC,QAAQC,OAAOC,IAAI,CAACH,UAAUI,MAAM,CAAC,CAACC,OAASC,IAAAA,8BAAc,EAACD;QAEpE,2EAA2E;QAC3E,UAAU;QACV,MAAME,cAAwC,CAAC;QAC/C,KAAK,MAAMF,QAAQJ,MAAO;YACxB,MAAMO,WAAW,IAAI,CAACX,WAAW,CAACW,QAAQ,CAACC,SAAS,CAACJ;YACrD,IAAIG,YAAYD,aAAaA,WAAW,CAACC,SAAS,CAACE,IAAI,CAACL;iBACnDE,WAAW,CAACC,SAAS,GAAG;gBAACH;aAAK;QACrC;QAEA,qBAAqB;QACrB,MAAMM,WAAuC,EAAE;QAC/C,KAAK,MAAM,CAACH,UAAUI,SAAS,IAAIV,OAAOW,OAAO,CAACN,aAAc;YAC9D,8EAA8E;YAC9E,MAAMF,OAAOO,QAAQ,CAAC,EAAE;YAExB,MAAME,WAAW,IAAI,CAACjB,WAAW,CAACiB,QAAQ,CAACL,SAAS,CAACT,QAAQ,CAACK,KAAK;YACnE,MAAMU,aAAa,IAAI,CAAClB,WAAW,CAACkB,UAAU,CAACN,SAAS,CAACJ;YAEzDM,SAASD,IAAI,CACX,IAAIM,wCAAmB,CAAC;gBACtBC,MAAMC,oBAAS,CAACC,QAAQ;gBACxBX;gBACAH;gBACAU;gBACAD;gBACAF;YACF;QAEJ;QAEA,OAAOD;IACT;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { AppRouteRouteMatcher } from '../route-matchers/app-route-route-matcher';
|
||||
import type { Manifest, ManifestLoader } from './helpers/manifest-loaders/manifest-loader';
|
||||
import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider';
|
||||
export declare class AppRouteRouteMatcherProvider extends ManifestRouteMatcherProvider<AppRouteRouteMatcher> {
|
||||
private readonly normalizers;
|
||||
constructor(distDir: string, manifestLoader: ManifestLoader);
|
||||
protected transform(manifest: Manifest): Promise<ReadonlyArray<AppRouteRouteMatcher>>;
|
||||
}
|
||||
Generated
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "AppRouteRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return AppRouteRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _isapprouteroute = require("../../lib/is-app-route-route");
|
||||
const _constants = require("../../shared/lib/constants");
|
||||
const _routekind = require("../route-kind");
|
||||
const _approuteroutematcher = require("../route-matchers/app-route-route-matcher");
|
||||
const _manifestroutematcherprovider = require("./manifest-route-matcher-provider");
|
||||
const _app = require("../normalizers/built/app");
|
||||
class AppRouteRouteMatcherProvider extends _manifestroutematcherprovider.ManifestRouteMatcherProvider {
|
||||
constructor(distDir, manifestLoader){
|
||||
super(_constants.APP_PATHS_MANIFEST, manifestLoader);
|
||||
this.normalizers = new _app.AppNormalizers(distDir);
|
||||
}
|
||||
async transform(manifest) {
|
||||
// This matcher only matches app routes.
|
||||
const pages = Object.keys(manifest).filter((page)=>(0, _isapprouteroute.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.AppRouteRouteMatcher({
|
||||
kind: _routekind.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":["AppRouteRouteMatcherProvider","ManifestRouteMatcherProvider","constructor","distDir","manifestLoader","APP_PATHS_MANIFEST","normalizers","AppNormalizers","transform","manifest","pages","Object","keys","filter","page","isAppRouteRoute","matchers","filename","normalize","pathname","bundlePath","push","AppRouteRouteMatcher","kind","RouteKind","APP_ROUTE"],"mappings":";;;;+BAWaA;;;eAAAA;;;iCAXmB;2BACG;2BACT;sCACW;8CAKQ;qBACd;AAExB,MAAMA,qCAAqCC,0DAA4B;IAG5EC,YAAYC,OAAe,EAAEC,cAA8B,CAAE;QAC3D,KAAK,CAACC,6BAAkB,EAAED;QAE1B,IAAI,CAACE,WAAW,GAAG,IAAIC,mBAAc,CAACJ;IACxC;IAEA,MAAgBK,UACdC,QAAkB,EAC4B;QAC9C,wCAAwC;QACxC,MAAMC,QAAQC,OAAOC,IAAI,CAACH,UAAUI,MAAM,CAAC,CAACC,OAASC,IAAAA,gCAAe,EAACD;QAErE,qBAAqB;QACrB,MAAME,WAAwC,EAAE;QAChD,KAAK,MAAMF,QAAQJ,MAAO;YACxB,MAAMO,WAAW,IAAI,CAACX,WAAW,CAACW,QAAQ,CAACC,SAAS,CAACT,QAAQ,CAACK,KAAK;YACnE,MAAMK,WAAW,IAAI,CAACb,WAAW,CAACa,QAAQ,CAACD,SAAS,CAACJ;YACrD,MAAMM,aAAa,IAAI,CAACd,WAAW,CAACc,UAAU,CAACF,SAAS,CAACJ;YAEzDE,SAASK,IAAI,CACX,IAAIC,0CAAoB,CAAC;gBACvBC,MAAMC,oBAAS,CAACC,SAAS;gBACzBN;gBACAL;gBACAM;gBACAH;YACF;QAEJ;QAEA,OAAOD;IACT;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import type { FileReader } from './helpers/file-reader/file-reader';
|
||||
import { AppPageRouteMatcher } from '../../route-matchers/app-page-route-matcher';
|
||||
import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider';
|
||||
export declare class DevAppPageRouteMatcherProvider extends FileCacheRouteMatcherProvider<AppPageRouteMatcher> {
|
||||
private readonly expression;
|
||||
private readonly normalizers;
|
||||
private readonly isTurbopack;
|
||||
constructor(appDir: string, extensions: ReadonlyArray<string>, reader: FileReader, isTurbopack: boolean);
|
||||
protected transform(files: ReadonlyArray<string>): Promise<ReadonlyArray<AppPageRouteMatcher>>;
|
||||
}
|
||||
Generated
Vendored
+91
@@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "DevAppPageRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return DevAppPageRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _apppageroutematcher = require("../../route-matchers/app-page-route-matcher");
|
||||
const _routekind = require("../../route-kind");
|
||||
const _filecacheroutematcherprovider = require("./file-cache-route-matcher-provider");
|
||||
const _app = require("../../normalizers/built/app");
|
||||
const _normalizecatchallroutes = require("../../../build/normalize-catchall-routes");
|
||||
const _apppaths = require("../../../shared/lib/router/utils/app-paths");
|
||||
class DevAppPageRouteMatcherProvider extends _filecacheroutematcherprovider.FileCacheRouteMatcherProvider {
|
||||
constructor(appDir, extensions, reader, isTurbopack){
|
||||
super(appDir, reader);
|
||||
this.normalizers = new _app.DevAppNormalizers(appDir, extensions, isTurbopack);
|
||||
// Match any page file that ends with `/page.${extension}` or `/default.${extension}` under the app
|
||||
// directory.
|
||||
this.expression = new RegExp(`[/\\\\](page|default)\\.(?:${extensions.join('|')})$`);
|
||||
this.isTurbopack = isTurbopack;
|
||||
}
|
||||
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;
|
||||
let page = this.normalizers.page.normalize(filename);
|
||||
// Validate that this is not an ignored page.
|
||||
if (page.includes('/_')) continue;
|
||||
// Turbopack uses the correct page name with the underscore normalized.
|
||||
// TODO: Move implementation to packages/next/src/server/normalizers/built/app/app-page-normalizer.ts.
|
||||
// The `includes('/_')` check above needs to be moved for that to work as otherwise `%5Fsegmentname`
|
||||
// will result in `_segmentname` which hits that includes check and be skipped.
|
||||
if (this.isTurbopack) {
|
||||
page = page.replace(/%5F/g, '_');
|
||||
}
|
||||
// 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
|
||||
];
|
||||
}
|
||||
(0, _normalizecatchallroutes.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(_apppaths.compareAppPaths)
|
||||
]));
|
||||
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.AppPageRouteMatcher({
|
||||
kind: _routekind.RouteKind.APP_PAGE,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename,
|
||||
appPaths: appPaths[pathname]
|
||||
}));
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dev-app-page-route-matcher-provider.js.map
|
||||
node_modules/next/dist/server/route-matcher-providers/dev/dev-app-page-route-matcher-provider.js.map
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import type { FileReader } from './helpers/file-reader/file-reader';
|
||||
import { AppRouteRouteMatcher } from '../../route-matchers/app-route-route-matcher';
|
||||
import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider';
|
||||
export declare class DevAppRouteRouteMatcherProvider extends FileCacheRouteMatcherProvider<AppRouteRouteMatcher> {
|
||||
private readonly normalizers;
|
||||
private readonly appDir;
|
||||
private readonly isTurbopack;
|
||||
constructor(appDir: string, extensions: ReadonlyArray<string>, reader: FileReader, isTurbopack: boolean);
|
||||
protected transform(files: ReadonlyArray<string>): Promise<ReadonlyArray<AppRouteRouteMatcher>>;
|
||||
}
|
||||
Generated
Vendored
+112
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "DevAppRouteRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return DevAppRouteRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _approuteroutematcher = require("../../route-matchers/app-route-route-matcher");
|
||||
const _routekind = require("../../route-kind");
|
||||
const _filecacheroutematcherprovider = require("./file-cache-route-matcher-provider");
|
||||
const _isapprouteroute = require("../../../lib/is-app-route-route");
|
||||
const _app = require("../../normalizers/built/app");
|
||||
const _ismetadataroute = require("../../../lib/metadata/is-metadata-route");
|
||||
const _getmetadataroute = require("../../../lib/metadata/get-metadata-route");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("../../../shared/lib/isomorphic/path"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
class DevAppRouteRouteMatcherProvider extends _filecacheroutematcherprovider.FileCacheRouteMatcherProvider {
|
||||
constructor(appDir, extensions, reader, isTurbopack){
|
||||
super(appDir, reader);
|
||||
this.appDir = appDir;
|
||||
this.isTurbopack = isTurbopack;
|
||||
this.normalizers = new _app.DevAppNormalizers(appDir, extensions, isTurbopack);
|
||||
}
|
||||
async transform(files) {
|
||||
const matchers = [];
|
||||
for (const filename of files){
|
||||
// Skip static metadata files as they are served from filesystem.
|
||||
if ((0, _ismetadataroute.isStaticMetadataFile)(filename.replace(this.appDir, ''))) {
|
||||
continue;
|
||||
}
|
||||
let page = this.normalizers.page.normalize(filename);
|
||||
// If the file isn't a match for this matcher, then skip it.
|
||||
if (!(0, _isapprouteroute.isAppRouteRoute)(page)) continue;
|
||||
// Validate that this is not an ignored page.
|
||||
if (page.includes('/_')) continue;
|
||||
// Turbopack uses the correct page name with the underscore normalized.
|
||||
// TODO: Move implementation to packages/next/src/server/normalizers/built/app/app-page-normalizer.ts.
|
||||
// The `includes('/_')` check above needs to be moved for that to work as otherwise `%5Fsegmentname`
|
||||
// will result in `_segmentname` which hits that includes check and be skipped.
|
||||
if (this.isTurbopack) {
|
||||
page = page.replace(/%5F/g, '_');
|
||||
}
|
||||
const pathname = this.normalizers.pathname.normalize(filename);
|
||||
const bundlePath = this.normalizers.bundlePath.normalize(filename);
|
||||
const ext = _path.default.extname(filename).slice(1);
|
||||
const isEntryMetadataRouteFile = (0, _ismetadataroute.isMetadataRouteFile)(filename.replace(this.appDir, ''), [
|
||||
ext
|
||||
], true);
|
||||
if (isEntryMetadataRouteFile && !(0, _ismetadataroute.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 = (0, _getmetadataroute.normalizeMetadataPageToRoute)(page, false);
|
||||
const metadataPathname = (0, _getmetadataroute.normalizeMetadataPageToRoute)(pathname, false);
|
||||
const metadataBundlePath = (0, _getmetadataroute.normalizeMetadataPageToRoute)(bundlePath, false);
|
||||
const matcher = new _approuteroutematcher.AppRouteRouteMatcher({
|
||||
kind: _routekind.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 = (0, _getmetadataroute.normalizeMetadataPageToRoute)(page, true);
|
||||
const metadataPathname = (0, _getmetadataroute.normalizeMetadataPageToRoute)(pathname, true);
|
||||
const metadataBundlePath = (0, _getmetadataroute.normalizeMetadataPageToRoute)(bundlePath, true);
|
||||
const matcher = new _approuteroutematcher.AppRouteRouteMatcher({
|
||||
kind: _routekind.RouteKind.APP_ROUTE,
|
||||
page: metadataPage,
|
||||
pathname: metadataPathname,
|
||||
bundlePath: metadataBundlePath,
|
||||
filename
|
||||
});
|
||||
matchers.push(matcher);
|
||||
}
|
||||
} else {
|
||||
// Normal app routes.
|
||||
matchers.push(new _approuteroutematcher.AppRouteRouteMatcher({
|
||||
kind: _routekind.RouteKind.APP_ROUTE,
|
||||
page,
|
||||
pathname,
|
||||
bundlePath,
|
||||
filename
|
||||
}));
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dev-app-route-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import type { FileReader } from './helpers/file-reader/file-reader';
|
||||
import { PagesAPIRouteMatcher } from '../../route-matchers/pages-api-route-matcher';
|
||||
import type { LocaleRouteNormalizer } from '../../normalizers/locale-route-normalizer';
|
||||
import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider';
|
||||
export declare class DevPagesAPIRouteMatcherProvider extends FileCacheRouteMatcherProvider<PagesAPIRouteMatcher> {
|
||||
private readonly pagesDir;
|
||||
private readonly extensions;
|
||||
private readonly localeNormalizer?;
|
||||
private readonly expression;
|
||||
private readonly normalizers;
|
||||
constructor(pagesDir: string, extensions: ReadonlyArray<string>, reader: FileReader, localeNormalizer?: LocaleRouteNormalizer | undefined);
|
||||
private test;
|
||||
protected transform(files: ReadonlyArray<string>): Promise<ReadonlyArray<PagesAPIRouteMatcher>>;
|
||||
}
|
||||
Generated
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "DevPagesAPIRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return DevPagesAPIRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _pagesapiroutematcher = require("../../route-matchers/pages-api-route-matcher");
|
||||
const _routekind = require("../../route-kind");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _filecacheroutematcherprovider = require("./file-cache-route-matcher-provider");
|
||||
const _pages = require("../../normalizers/built/pages");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
class DevPagesAPIRouteMatcherProvider extends _filecacheroutematcherprovider.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 _pages.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.default.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.default.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 _pagesapiroutematcher.PagesAPILocaleRouteMatcher({
|
||||
kind: _routekind.RouteKind.PAGES_API,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename,
|
||||
i18n: {}
|
||||
}));
|
||||
} else {
|
||||
matchers.push(new _pagesapiroutematcher.PagesAPIRouteMatcher({
|
||||
kind: _routekind.RouteKind.PAGES_API,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename
|
||||
}));
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dev-pages-api-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import type { FileReader } from './helpers/file-reader/file-reader';
|
||||
import { PagesRouteMatcher } from '../../route-matchers/pages-route-matcher';
|
||||
import type { LocaleRouteNormalizer } from '../../normalizers/locale-route-normalizer';
|
||||
import { FileCacheRouteMatcherProvider } from './file-cache-route-matcher-provider';
|
||||
export declare class DevPagesRouteMatcherProvider extends FileCacheRouteMatcherProvider<PagesRouteMatcher> {
|
||||
private readonly pagesDir;
|
||||
private readonly extensions;
|
||||
private readonly localeNormalizer?;
|
||||
private readonly expression;
|
||||
private readonly normalizers;
|
||||
constructor(pagesDir: string, extensions: ReadonlyArray<string>, reader: FileReader, localeNormalizer?: LocaleRouteNormalizer | undefined);
|
||||
private test;
|
||||
protected transform(files: ReadonlyArray<string>): Promise<ReadonlyArray<PagesRouteMatcher>>;
|
||||
}
|
||||
Generated
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "DevPagesRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return DevPagesRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _pagesroutematcher = require("../../route-matchers/pages-route-matcher");
|
||||
const _routekind = require("../../route-kind");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
||||
const _filecacheroutematcherprovider = require("./file-cache-route-matcher-provider");
|
||||
const _pages = require("../../normalizers/built/pages");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
class DevPagesRouteMatcherProvider extends _filecacheroutematcherprovider.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 _pages.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.default.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.default.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 _pagesroutematcher.PagesLocaleRouteMatcher({
|
||||
kind: _routekind.RouteKind.PAGES,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename,
|
||||
i18n: {}
|
||||
}));
|
||||
} else {
|
||||
matchers.push(new _pagesroutematcher.PagesRouteMatcher({
|
||||
kind: _routekind.RouteKind.PAGES,
|
||||
pathname,
|
||||
page,
|
||||
bundlePath,
|
||||
filename
|
||||
}));
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dev-pages-route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import type { RouteMatcher } from '../../route-matchers/route-matcher';
|
||||
import { CachedRouteMatcherProvider } from '../helpers/cached-route-matcher-provider';
|
||||
import type { FileReader } from './helpers/file-reader/file-reader';
|
||||
/**
|
||||
* This will memoize the matchers when the file contents are the same.
|
||||
*/
|
||||
export declare abstract class FileCacheRouteMatcherProvider<M extends RouteMatcher = RouteMatcher> extends CachedRouteMatcherProvider<M, ReadonlyArray<string>> {
|
||||
constructor(dir: string, reader: FileReader);
|
||||
}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "FileCacheRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return FileCacheRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _cachedroutematcherprovider = require("../helpers/cached-route-matcher-provider");
|
||||
class FileCacheRouteMatcherProvider extends _cachedroutematcherprovider.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":["FileCacheRouteMatcherProvider","CachedRouteMatcherProvider","constructor","dir","reader","load","read","compare","left","right","length","i"],"mappings":";;;;+BAOsBA;;;eAAAA;;;4CANqB;AAMpC,MAAeA,sCAEZC,sDAA0B;IAClCC,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","ignoreList":[0]}
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import type { FileReader } from './file-reader';
|
||||
/**
|
||||
* CachedFileReader will deduplicate requests made to the same folder structure
|
||||
* to scan for files.
|
||||
*/
|
||||
export declare class BatchedFileReader implements FileReader {
|
||||
private readonly reader;
|
||||
private batch?;
|
||||
constructor(reader: FileReader);
|
||||
private schedulePromise?;
|
||||
private schedule;
|
||||
private getOrCreateBatch;
|
||||
private load;
|
||||
read(dir: string): Promise<ReadonlyArray<string>>;
|
||||
}
|
||||
node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.js
Generated
Vendored
+106
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "BatchedFileReader", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return BatchedFileReader;
|
||||
}
|
||||
});
|
||||
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
File diff suppressed because one or more lines are too long
Generated
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
import type { FileReader } from './file-reader';
|
||||
import type { RecursiveReadDirOptions } from '../../../../../lib/recursive-readdir';
|
||||
export type DefaultFileReaderOptions = Pick<RecursiveReadDirOptions, 'pathnameFilter' | 'ignorePartFilter'>;
|
||||
/**
|
||||
* Reads all the files in the directory and its subdirectories following any
|
||||
* symbolic links.
|
||||
*/
|
||||
export declare class DefaultFileReader implements FileReader {
|
||||
/**
|
||||
* Filter to ignore files with absolute pathnames. If undefined, no files are
|
||||
* ignored.
|
||||
*/
|
||||
private readonly options;
|
||||
/**
|
||||
* 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: Readonly<DefaultFileReaderOptions>);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
read(dir: string): Promise<ReadonlyArray<string>>;
|
||||
}
|
||||
node_modules/next/dist/server/route-matcher-providers/dev/helpers/file-reader/default-file-reader.js
Generated
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "DefaultFileReader", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return DefaultFileReader;
|
||||
}
|
||||
});
|
||||
const _recursivereaddir = require("../../../../../lib/recursive-readdir");
|
||||
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 (0, _recursivereaddir.recursiveReadDir)(dir, {
|
||||
pathnameFilter: this.options.pathnameFilter,
|
||||
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' | '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 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":["DefaultFileReader","constructor","options","read","dir","recursiveReadDir","pathnameFilter","ignorePartFilter","sortPathnames","relativePathnames"],"mappings":";;;;+BAaaA;;;eAAAA;;;kCAXoB;AAW1B,MAAMA;IAOX;;;;;;GAMC,GACDC,YAAYC,OAA2C,CAAE;QACvD,IAAI,CAACA,OAAO,GAAGA;IACjB;IAEA;;;;;;GAMC,GACD,MAAaC,KAAKC,GAAW,EAAkC;QAC7D,OAAOC,IAAAA,kCAAgB,EAACD,KAAK;YAC3BE,gBAAgB,IAAI,CAACJ,OAAO,CAACI,cAAc;YAC3CC,kBAAkB,IAAI,CAACL,OAAO,CAACK,gBAAgB;YAE/C,uEAAuE;YACvE,wBAAwB;YACxBC,eAAe;YAEf,sEAAsE;YACtE,iCAAiC;YACjCC,mBAAmB;QACrB;IACF;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
export interface FileReader {
|
||||
/**
|
||||
* Reads the directory contents recursively.
|
||||
*
|
||||
* @param dir directory to read recursively from
|
||||
*/
|
||||
read(dir: string): Promise<ReadonlyArray<string>> | ReadonlyArray<string>;
|
||||
}
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
//# sourceMappingURL=file-reader.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":[],"names":[],"mappings":"","ignoreList":[]}
|
||||
Generated
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
import type { RouteMatcherProvider } from '../route-matcher-provider';
|
||||
import type { RouteMatcher } from '../../route-matchers/route-matcher';
|
||||
interface LoaderComparable<D> {
|
||||
load(): Promise<D>;
|
||||
compare(left: D, right: D): boolean;
|
||||
}
|
||||
/**
|
||||
* This will memoize the matchers if the loaded data is comparable.
|
||||
*/
|
||||
export declare abstract class CachedRouteMatcherProvider<M extends RouteMatcher = RouteMatcher, D = any> implements RouteMatcherProvider<M> {
|
||||
private readonly loader;
|
||||
private data?;
|
||||
private cached;
|
||||
constructor(loader: LoaderComparable<D>);
|
||||
protected abstract transform(data: D): Promise<ReadonlyArray<M>>;
|
||||
matchers(): Promise<readonly M[]>;
|
||||
}
|
||||
export {};
|
||||
Generated
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "CachedRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return CachedRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
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":";;;;+BAWsBA;;;eAAAA;;;AAAf,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","ignoreList":[0]}
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export type Manifest = Record<string, string>;
|
||||
export interface ManifestLoader {
|
||||
load(name: string): Manifest | null;
|
||||
}
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
//# sourceMappingURL=manifest-loader.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":[],"names":[],"mappings":"","ignoreList":[]}
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import type { Manifest, ManifestLoader } from './manifest-loader';
|
||||
export declare class NodeManifestLoader implements ManifestLoader {
|
||||
private readonly distDir;
|
||||
constructor(distDir: string);
|
||||
static require(id: string): any;
|
||||
load(name: string): Manifest | null;
|
||||
}
|
||||
Generated
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "NodeManifestLoader", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return NodeManifestLoader;
|
||||
}
|
||||
});
|
||||
const _constants = require("../../../../shared/lib/constants");
|
||||
const _path = /*#__PURE__*/ _interop_require_default(require("../../../../shared/lib/isomorphic/path"));
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
class NodeManifestLoader {
|
||||
constructor(distDir){
|
||||
this.distDir = distDir;
|
||||
}
|
||||
static require(id) {
|
||||
try {
|
||||
return require(id);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
load(name) {
|
||||
return NodeManifestLoader.require(_path.default.join(this.distDir, _constants.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":["NodeManifestLoader","constructor","distDir","require","id","load","name","path","join","SERVER_DIRECTORY"],"mappings":";;;;+BAIaA;;;eAAAA;;;2BAJoB;6DAChB;;;;;;AAGV,MAAMA;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/BI,aAAI,CAACC,IAAI,CAAC,IAAI,CAACN,OAAO,EAAEO,2BAAgB,EAAEH;IAE9C;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import type { Manifest, ManifestLoader } from './manifest-loader';
|
||||
export declare class ServerManifestLoader implements ManifestLoader {
|
||||
private readonly getter;
|
||||
constructor(getter: (name: string) => Manifest | null);
|
||||
load(name: string): Manifest | null;
|
||||
}
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "ServerManifestLoader", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ServerManifestLoader;
|
||||
}
|
||||
});
|
||||
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":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA;IACXC,YAAY,AAAiBC,MAAyC,CAAE;aAA3CA,SAAAA;IAA4C;IAElEC,KAAKC,IAAY,EAAmB;QACzC,OAAO,IAAI,CAACF,MAAM,CAACE;IACrB;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import type { RouteMatcher } from '../route-matchers/route-matcher';
|
||||
import type { Manifest, ManifestLoader } from './helpers/manifest-loaders/manifest-loader';
|
||||
import { CachedRouteMatcherProvider } from './helpers/cached-route-matcher-provider';
|
||||
export declare abstract class ManifestRouteMatcherProvider<M extends RouteMatcher = RouteMatcher> extends CachedRouteMatcherProvider<M, Manifest | null> {
|
||||
constructor(manifestName: string, manifestLoader: ManifestLoader);
|
||||
}
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "ManifestRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ManifestRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _cachedroutematcherprovider = require("./helpers/cached-route-matcher-provider");
|
||||
class ManifestRouteMatcherProvider extends _cachedroutematcherprovider.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":["ManifestRouteMatcherProvider","CachedRouteMatcherProvider","constructor","manifestName","manifestLoader","load","compare","left","right"],"mappings":";;;;+BAOsBA;;;eAAAA;;;4CAFqB;AAEpC,MAAeA,qCAEZC,sDAA0B;IAClCC,YAAYC,YAAoB,EAAEC,cAA8B,CAAE;QAChE,KAAK,CAAC;YACJC,MAAM,UAAYD,eAAeC,IAAI,CAACF;YACtCG,SAAS,CAACC,MAAMC,QAAUD,SAASC;QACrC;IACF;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import { PagesAPIRouteMatcher } from '../route-matchers/pages-api-route-matcher';
|
||||
import type { Manifest, ManifestLoader } from './helpers/manifest-loaders/manifest-loader';
|
||||
import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider';
|
||||
import type { I18NProvider } from '../lib/i18n-provider';
|
||||
export declare class PagesAPIRouteMatcherProvider extends ManifestRouteMatcherProvider<PagesAPIRouteMatcher> {
|
||||
private readonly i18nProvider?;
|
||||
private readonly normalizers;
|
||||
constructor(distDir: string, manifestLoader: ManifestLoader, i18nProvider?: I18NProvider | undefined);
|
||||
protected transform(manifest: Manifest): Promise<ReadonlyArray<PagesAPIRouteMatcher>>;
|
||||
}
|
||||
Generated
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "PagesAPIRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return PagesAPIRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _isapiroute = require("../../lib/is-api-route");
|
||||
const _constants = require("../../shared/lib/constants");
|
||||
const _routekind = require("../route-kind");
|
||||
const _pagesapiroutematcher = require("../route-matchers/pages-api-route-matcher");
|
||||
const _manifestroutematcherprovider = require("./manifest-route-matcher-provider");
|
||||
const _pages = require("../normalizers/built/pages");
|
||||
class PagesAPIRouteMatcherProvider extends _manifestroutematcherprovider.ManifestRouteMatcherProvider {
|
||||
constructor(distDir, manifestLoader, i18nProvider){
|
||||
super(_constants.PAGES_MANIFEST, manifestLoader), this.i18nProvider = i18nProvider;
|
||||
this.normalizers = new _pages.PagesNormalizers(distDir);
|
||||
}
|
||||
async transform(manifest) {
|
||||
// This matcher is only for Pages API routes.
|
||||
const pathnames = Object.keys(manifest).filter((pathname)=>(0, _isapiroute.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 _pagesapiroutematcher.PagesAPILocaleRouteMatcher({
|
||||
kind: _routekind.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.PagesAPIRouteMatcher({
|
||||
kind: _routekind.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":["PagesAPIRouteMatcherProvider","ManifestRouteMatcherProvider","constructor","distDir","manifestLoader","i18nProvider","PAGES_MANIFEST","normalizers","PagesNormalizers","transform","manifest","pathnames","Object","keys","filter","pathname","isAPIRoute","matchers","page","detectedLocale","analyze","push","PagesAPILocaleRouteMatcher","kind","RouteKind","PAGES_API","bundlePath","normalize","filename","i18n","locale","PagesAPIRouteMatcher"],"mappings":";;;;+BAeaA;;;eAAAA;;;4BAfc;2BACI;2BACL;sCAInB;8CAKsC;uBAEZ;AAE1B,MAAMA,qCAAqCC,0DAA4B;IAG5EC,YACEC,OAAe,EACfC,cAA8B,EAC9B,AAAiBC,YAA2B,CAC5C;QACA,KAAK,CAACC,yBAAc,EAAEF,sBAFLC,eAAAA;QAIjB,IAAI,CAACE,WAAW,GAAG,IAAIC,uBAAgB,CAACL;IAC1C;IAEA,MAAgBM,UACdC,QAAkB,EAC4B;QAC9C,6CAA6C;QAC7C,MAAMC,YAAYC,OAAOC,IAAI,CAACH,UAAUI,MAAM,CAAC,CAACC,WAC9CC,IAAAA,sBAAU,EAACD;QAGb,MAAME,WAAwC,EAAE;QAEhD,KAAK,MAAMC,QAAQP,UAAW;YAC5B,IAAI,IAAI,CAACN,YAAY,EAAE;gBACrB,uEAAuE;gBACvE,MAAM,EAAEc,cAAc,EAAEJ,QAAQ,EAAE,GAAG,IAAI,CAACV,YAAY,CAACe,OAAO,CAACF;gBAE/DD,SAASI,IAAI,CACX,IAAIC,gDAA0B,CAAC;oBAC7BC,MAAMC,oBAAS,CAACC,SAAS;oBACzBV;oBACAG;oBACAQ,YAAY,IAAI,CAACnB,WAAW,CAACmB,UAAU,CAACC,SAAS,CAACT;oBAClDU,UAAU,IAAI,CAACrB,WAAW,CAACqB,QAAQ,CAACD,SAAS,CAACjB,QAAQ,CAACQ,KAAK;oBAC5DW,MAAM;wBACJC,QAAQX;oBACV;gBACF;YAEJ,OAAO;gBACLF,SAASI,IAAI,CACX,IAAIU,0CAAoB,CAAC;oBACvBR,MAAMC,oBAAS,CAACC,SAAS;oBACzB,qDAAqD;oBACrDV,UAAUG;oBACVA;oBACAQ,YAAY,IAAI,CAACnB,WAAW,CAACmB,UAAU,CAACC,SAAS,CAACT;oBAClDU,UAAU,IAAI,CAACrB,WAAW,CAACqB,QAAQ,CAACD,SAAS,CAACjB,QAAQ,CAACQ,KAAK;gBAC9D;YAEJ;QACF;QAEA,OAAOD;IACT;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
import { PagesRouteMatcher } from '../route-matchers/pages-route-matcher';
|
||||
import type { Manifest, ManifestLoader } from './helpers/manifest-loaders/manifest-loader';
|
||||
import { ManifestRouteMatcherProvider } from './manifest-route-matcher-provider';
|
||||
import type { I18NProvider } from '../lib/i18n-provider';
|
||||
export declare class PagesRouteMatcherProvider extends ManifestRouteMatcherProvider<PagesRouteMatcher> {
|
||||
private readonly i18nProvider?;
|
||||
private readonly normalizers;
|
||||
constructor(distDir: string, manifestLoader: ManifestLoader, i18nProvider?: I18NProvider | undefined);
|
||||
protected transform(manifest: Manifest): Promise<ReadonlyArray<PagesRouteMatcher>>;
|
||||
}
|
||||
Generated
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "PagesRouteMatcherProvider", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return PagesRouteMatcherProvider;
|
||||
}
|
||||
});
|
||||
const _isapiroute = require("../../lib/is-api-route");
|
||||
const _constants = require("../../shared/lib/constants");
|
||||
const _routekind = require("../route-kind");
|
||||
const _pagesroutematcher = require("../route-matchers/pages-route-matcher");
|
||||
const _manifestroutematcherprovider = require("./manifest-route-matcher-provider");
|
||||
const _pages = require("../normalizers/built/pages");
|
||||
class PagesRouteMatcherProvider extends _manifestroutematcherprovider.ManifestRouteMatcherProvider {
|
||||
constructor(distDir, manifestLoader, i18nProvider){
|
||||
super(_constants.PAGES_MANIFEST, manifestLoader), this.i18nProvider = i18nProvider;
|
||||
this.normalizers = new _pages.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)=>!(0, _isapiroute.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 (_constants.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 _pagesroutematcher.PagesLocaleRouteMatcher({
|
||||
kind: _routekind.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.PagesRouteMatcher({
|
||||
kind: _routekind.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":["PagesRouteMatcherProvider","ManifestRouteMatcherProvider","constructor","distDir","manifestLoader","i18nProvider","PAGES_MANIFEST","normalizers","PagesNormalizers","transform","manifest","pathnames","Object","keys","filter","pathname","isAPIRoute","normalized","analyze","BLOCKED_PAGES","includes","matchers","page","detectedLocale","push","PagesLocaleRouteMatcher","kind","RouteKind","PAGES","bundlePath","normalize","filename","i18n","locale","PagesRouteMatcher"],"mappings":";;;;+BAeaA;;;eAAAA;;;4BAfc;2BACmB;2BACpB;mCAInB;8CAKsC;uBAEZ;AAE1B,MAAMA,kCAAkCC,0DAA4B;IAGzEC,YACEC,OAAe,EACfC,cAA8B,EAC9B,AAAiBC,YAA2B,CAC5C;QACA,KAAK,CAACC,yBAAc,EAAEF,sBAFLC,eAAAA;QAIjB,IAAI,CAACE,WAAW,GAAG,IAAIC,uBAAgB,CAACL;IAC1C;IAEA,MAAgBM,UACdC,QAAkB,EACyB;QAC3C,wEAAwE;QACxE,6BAA6B;QAC7B,MAAMC,YAAYC,OAAOC,IAAI,CAACH,UAC3BI,MAAM,CAAC,CAACC,WAAa,CAACC,IAAAA,sBAAU,EAACD,UAClC,wEAAwE;QACxE,mBAAmB;SAClBD,MAAM,CAAC,CAACC;gBAEL;YADF,MAAME,aACJ,EAAA,qBAAA,IAAI,CAACZ,YAAY,qBAAjB,mBAAmBa,OAAO,CAACH,UAAUA,QAAQ,KAAIA;YAEnD,0BAA0B;YAC1B,IAAII,wBAAa,CAACC,QAAQ,CAACH,aAAa,OAAO;YAE/C,OAAO;QACT;QAEF,MAAMI,WAAqC,EAAE;QAC7C,KAAK,MAAMC,QAAQX,UAAW;YAC5B,IAAI,IAAI,CAACN,YAAY,EAAE;gBACrB,uEAAuE;gBACvE,MAAM,EAAEkB,cAAc,EAAER,QAAQ,EAAE,GAAG,IAAI,CAACV,YAAY,CAACa,OAAO,CAACI;gBAE/DD,SAASG,IAAI,CACX,IAAIC,0CAAuB,CAAC;oBAC1BC,MAAMC,oBAAS,CAACC,KAAK;oBACrBb;oBACAO;oBACAO,YAAY,IAAI,CAACtB,WAAW,CAACsB,UAAU,CAACC,SAAS,CAACR;oBAClDS,UAAU,IAAI,CAACxB,WAAW,CAACwB,QAAQ,CAACD,SAAS,CAACpB,QAAQ,CAACY,KAAK;oBAC5DU,MAAM;wBACJC,QAAQV;oBACV;gBACF;YAEJ,OAAO;gBACLF,SAASG,IAAI,CACX,IAAIU,oCAAiB,CAAC;oBACpBR,MAAMC,oBAAS,CAACC,KAAK;oBACrB,qDAAqD;oBACrDb,UAAUO;oBACVA;oBACAO,YAAY,IAAI,CAACtB,WAAW,CAACsB,UAAU,CAACC,SAAS,CAACR;oBAClDS,UAAU,IAAI,CAACxB,WAAW,CAACwB,QAAQ,CAACD,SAAS,CAACpB,QAAQ,CAACY,KAAK;gBAC9D;YAEJ;QACF;QAEA,OAAOD;IACT;AACF","ignoreList":[0]}
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import type { RouteMatcher } from '../route-matchers/route-matcher';
|
||||
export interface RouteMatcherProvider<M extends RouteMatcher = RouteMatcher> {
|
||||
matchers(): Promise<ReadonlyArray<M>>;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
//# sourceMappingURL=route-matcher-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":[],"names":[],"mappings":"","ignoreList":[]}
|
||||
Reference in New Issue
Block a user