main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
import { 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;
constructor(appDir: string, extensions: ReadonlyArray<string>, reader: FileReader);
protected transform(files: ReadonlyArray<string>): Promise<ReadonlyArray<AppPageRouteMatcher>>;
}

View File

@@ -0,0 +1,71 @@
"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");
class DevAppPageRouteMatcherProvider extends _filecacheroutematcherprovider.FileCacheRouteMatcherProvider {
constructor(appDir, extensions, reader){
super(appDir, reader);
this.normalizers = new _app.DevAppNormalizers(appDir, extensions);
// Match any page file that ends with `/page.${extension}` under the app
// directory.
this.expression = new RegExp(`[/\\\\]page\\.(?:${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();
const 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
];
}
const matchers = [];
for (const filename of routeFilenames){
// Grab the cached values (and the appPaths).
const cached = cache.get(filename);
if (!cached) {
throw new Error("Invariant: expected filename to exist in cache");
}
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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/route-matcher-providers/dev/dev-app-page-route-matcher-provider.ts"],"names":["DevAppPageRouteMatcherProvider","FileCacheRouteMatcherProvider","constructor","appDir","extensions","reader","normalizers","DevAppNormalizers","expression","RegExp","join","transform","files","cache","Map","routeFilenames","Array","appPaths","filename","test","page","normalize","includes","push","pathname","bundlePath","set","matchers","cached","get","Error","AppPageRouteMatcher","kind","RouteKind","APP_PAGE"],"mappings":";;;;+BAOaA;;;eAAAA;;;qCANuB;2BACV;+CACoB;qBAEZ;AAE3B,MAAMA,uCAAuCC,4DAA6B;IAI/EC,YACEC,MAAc,EACdC,UAAiC,EACjCC,MAAkB,CAClB;QACA,KAAK,CAACF,QAAQE;QAEd,IAAI,CAACC,WAAW,GAAG,IAAIC,sBAAiB,CAACJ,QAAQC;QAEjD,wEAAwE;QACxE,aAAa;QACb,IAAI,CAACI,UAAU,GAAG,IAAIC,OAAO,CAAC,iBAAiB,EAAEL,WAAWM,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3E;IAEA,MAAgBC,UACdC,KAA4B,EACiB;QAC7C,2EAA2E;QAC3E,UAAU;QACV,MAAMC,QAAQ,IAAIC;QAIlB,MAAMC,iBAAiB,IAAIC;QAC3B,MAAMC,WAAqC,CAAC;QAC5C,KAAK,MAAMC,YAAYN,MAAO;YAC5B,4DAA4D;YAC5D,IAAI,CAAC,IAAI,CAACJ,UAAU,CAACW,IAAI,CAACD,WAAW;YAErC,MAAME,OAAO,IAAI,CAACd,WAAW,CAACc,IAAI,CAACC,SAAS,CAACH;YAE7C,6CAA6C;YAC7C,IAAIE,KAAKE,QAAQ,CAAC,OAAO;YAEzB,6DAA6D;YAC7DP,eAAeQ,IAAI,CAACL;YAEpB,MAAMM,WAAW,IAAI,CAAClB,WAAW,CAACkB,QAAQ,CAACH,SAAS,CAACH;YACrD,MAAMO,aAAa,IAAI,CAACnB,WAAW,CAACmB,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;QAEA,MAAMO,WAAuC,EAAE;QAC/C,KAAK,MAAMT,YAAYH,eAAgB;YACrC,6CAA6C;YAC7C,MAAMa,SAASf,MAAMgB,GAAG,CAACX;YACzB,IAAI,CAACU,QAAQ;gBACX,MAAM,IAAIE,MAAM;YAClB;YACA,MAAM,EAAEN,QAAQ,EAAEJ,IAAI,EAAEK,UAAU,EAAE,GAAGG;YAEvCD,SAASJ,IAAI,CACX,IAAIQ,wCAAmB,CAAC;gBACtBC,MAAMC,oBAAS,CAACC,QAAQ;gBACxBV;gBACAJ;gBACAK;gBACAP;gBACAD,UAAUA,QAAQ,CAACO,SAAS;YAC9B;QAEJ;QACA,OAAOG;IACT;AACF"}

View File

@@ -0,0 +1,8 @@
import { 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;
constructor(appDir: string, extensions: ReadonlyArray<string>, reader: FileReader);
protected transform(files: ReadonlyArray<string>): Promise<ReadonlyArray<AppRouteRouteMatcher>>;
}

View File

@@ -0,0 +1,43 @@
"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");
class DevAppRouteRouteMatcherProvider extends _filecacheroutematcherprovider.FileCacheRouteMatcherProvider {
constructor(appDir, extensions, reader){
super(appDir, reader);
this.normalizers = new _app.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 (!(0, _isapprouteroute.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);
matchers.push(new _approuteroutematcher.AppRouteRouteMatcher({
kind: _routekind.RouteKind.APP_ROUTE,
pathname,
page,
bundlePath,
filename
}));
}
return matchers;
}
}
//# sourceMappingURL=dev-app-route-route-matcher-provider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/route-matcher-providers/dev/dev-app-route-route-matcher-provider.ts"],"names":["DevAppRouteRouteMatcherProvider","FileCacheRouteMatcherProvider","constructor","appDir","extensions","reader","normalizers","DevAppNormalizers","transform","files","matchers","filename","page","normalize","isAppRouteRoute","includes","pathname","bundlePath","push","AppRouteRouteMatcher","kind","RouteKind","APP_ROUTE"],"mappings":";;;;+BAQaA;;;eAAAA;;;sCAPwB;2BAEX;+CACoB;iCACd;qBACE;AAE3B,MAAMA,wCAAwCC,4DAA6B;IAOhFC,YACEC,MAAc,EACdC,UAAiC,EACjCC,MAAkB,CAClB;QACA,KAAK,CAACF,QAAQE;QAEd,IAAI,CAACC,WAAW,GAAG,IAAIC,sBAAiB,CAACJ,QAAQC;IACnD;IAEA,MAAgBI,UACdC,KAA4B,EACkB;QAC9C,MAAMC,WAAwC,EAAE;QAChD,KAAK,MAAMC,YAAYF,MAAO;YAC5B,MAAMG,OAAO,IAAI,CAACN,WAAW,CAACM,IAAI,CAACC,SAAS,CAACF;YAE7C,4DAA4D;YAC5D,IAAI,CAACG,IAAAA,gCAAe,EAACF,OAAO;YAE5B,6CAA6C;YAC7C,IAAIA,KAAKG,QAAQ,CAAC,OAAO;YAEzB,MAAMC,WAAW,IAAI,CAACV,WAAW,CAACU,QAAQ,CAACH,SAAS,CAACF;YACrD,MAAMM,aAAa,IAAI,CAACX,WAAW,CAACW,UAAU,CAACJ,SAAS,CAACF;YAEzDD,SAASQ,IAAI,CACX,IAAIC,0CAAoB,CAAC;gBACvBC,MAAMC,oBAAS,CAACC,SAAS;gBACzBN;gBACAJ;gBACAK;gBACAN;YACF;QAEJ;QAEA,OAAOD;IACT;AACF"}

View File

@@ -0,0 +1,14 @@
import { FileReader } from './helpers/file-reader/file-reader';
import { PagesAPIRouteMatcher } from '../../route-matchers/pages-api-route-matcher';
import { 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>>;
}

View File

@@ -0,0 +1,80 @@
"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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/route-matcher-providers/dev/dev-pages-api-route-matcher-provider.ts"],"names":["DevPagesAPIRouteMatcherProvider","FileCacheRouteMatcherProvider","constructor","pagesDir","extensions","reader","localeNormalizer","expression","RegExp","join","normalizers","DevPagesNormalizers","test","filename","startsWith","path","extension","transform","files","matchers","pathname","normalize","page","bundlePath","push","PagesAPILocaleRouteMatcher","kind","RouteKind","PAGES_API","i18n","PagesAPIRouteMatcher"],"mappings":";;;;+BAWaA;;;eAAAA;;;sCAPN;2BACmB;6DACT;+CAE6B;uBACV;;;;;;AAE7B,MAAMA,wCAAwCC,4DAA6B;IAIhFC,YACmBC,UACAC,YACjBC,MAAkB,EACDC,iBACjB;QACA,KAAK,CAACH,UAAUE;wBALCF;0BACAC;gCAEAE;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,IAAIC,0BAAmB,CAACR,UAAUC;IACvD;IAEQQ,KAAKC,QAAgB,EAAW;QACtC,sEAAsE;QACtE,IAAI,CAAC,IAAI,CAACN,UAAU,CAACK,IAAI,CAACC,WAAW,OAAO;QAE5C,sEAAsE;QACtE,yEAAyE;QACzE,6CAA6C;QAE7C,2DAA2D;QAC3D,IAAIA,SAASC,UAAU,CAACC,aAAI,CAACN,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE,WAAW,OAAO;QAEnE,KAAK,MAAMa,aAAa,IAAI,CAACZ,UAAU,CAAE;YACvC,qEAAqE;YACrE,uBAAuB;YACvB,IAAIS,aAAaE,aAAI,CAACN,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE,CAAC,IAAI,EAAEa,UAAU,CAAC,GAAG;gBAC7D,OAAO;YACT;QACF;QAEA,OAAO;IACT;IAEA,MAAgBC,UACdC,KAA4B,EACkB;QAC9C,MAAMC,WAAwC,EAAE;QAChD,KAAK,MAAMN,YAAYK,MAAO;YAC5B,4DAA4D;YAC5D,IAAI,CAAC,IAAI,CAACN,IAAI,CAACC,WAAW;YAE1B,MAAMO,WAAW,IAAI,CAACV,WAAW,CAACU,QAAQ,CAACC,SAAS,CAACR;YACrD,MAAMS,OAAO,IAAI,CAACZ,WAAW,CAACY,IAAI,CAACD,SAAS,CAACR;YAC7C,MAAMU,aAAa,IAAI,CAACb,WAAW,CAACa,UAAU,CAACF,SAAS,CAACR;YAEzD,IAAI,IAAI,CAACP,gBAAgB,EAAE;gBACzBa,SAASK,IAAI,CACX,IAAIC,gDAA0B,CAAC;oBAC7BC,MAAMC,oBAAS,CAACC,SAAS;oBACzBR;oBACAE;oBACAC;oBACAV;oBACAgB,MAAM,CAAC;gBACT;YAEJ,OAAO;gBACLV,SAASK,IAAI,CACX,IAAIM,0CAAoB,CAAC;oBACvBJ,MAAMC,oBAAS,CAACC,SAAS;oBACzBR;oBACAE;oBACAC;oBACAV;gBACF;YAEJ;QACF;QAEA,OAAOM;IACT;AACF"}

View File

@@ -0,0 +1,14 @@
import { FileReader } from './helpers/file-reader/file-reader';
import { PagesRouteMatcher } from '../../route-matchers/pages-route-matcher';
import { 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>>;
}

View File

@@ -0,0 +1,80 @@
"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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/route-matcher-providers/dev/dev-pages-route-matcher-provider.ts"],"names":["DevPagesRouteMatcherProvider","FileCacheRouteMatcherProvider","constructor","pagesDir","extensions","reader","localeNormalizer","expression","RegExp","join","normalizers","DevPagesNormalizers","test","filename","startsWith","path","extension","transform","files","matchers","pathname","normalize","page","bundlePath","push","PagesLocaleRouteMatcher","kind","RouteKind","PAGES","i18n","PagesRouteMatcher"],"mappings":";;;;+BAWaA;;;eAAAA;;;mCAPN;2BACmB;6DACT;+CAE6B;uBACV;;;;;;AAE7B,MAAMA,qCAAqCC,4DAA6B;IAI7EC,YACmBC,UACAC,YACjBC,MAAkB,EACDC,iBACjB;QACA,KAAK,CAACH,UAAUE;wBALCF;0BACAC;gCAEAE;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,IAAIC,0BAAmB,CAACR,UAAUC;IACvD;IAEQQ,KAAKC,QAAgB,EAAW;QACtC,sEAAsE;QACtE,IAAI,CAAC,IAAI,CAACN,UAAU,CAACK,IAAI,CAACC,WAAW,OAAO;QAE5C,qEAAqE;QACrE,yEAAyE;QACzE,6CAA6C;QAE7C,2DAA2D;QAC3D,IAAIA,SAASC,UAAU,CAACC,aAAI,CAACN,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE,WAAW,OAAO;QAEnE,KAAK,MAAMa,aAAa,IAAI,CAACZ,UAAU,CAAE;YACvC,qEAAqE;YACrE,uBAAuB;YACvB,IAAIS,aAAaE,aAAI,CAACN,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE,CAAC,IAAI,EAAEa,UAAU,CAAC,GAAG;gBAC7D,OAAO;YACT;QACF;QAEA,OAAO;IACT;IAEA,MAAgBC,UACdC,KAA4B,EACe;QAC3C,MAAMC,WAAqC,EAAE;QAC7C,KAAK,MAAMN,YAAYK,MAAO;YAC5B,4DAA4D;YAC5D,IAAI,CAAC,IAAI,CAACN,IAAI,CAACC,WAAW;YAE1B,MAAMO,WAAW,IAAI,CAACV,WAAW,CAACU,QAAQ,CAACC,SAAS,CAACR;YACrD,MAAMS,OAAO,IAAI,CAACZ,WAAW,CAACY,IAAI,CAACD,SAAS,CAACR;YAC7C,MAAMU,aAAa,IAAI,CAACb,WAAW,CAACa,UAAU,CAACF,SAAS,CAACR;YAEzD,IAAI,IAAI,CAACP,gBAAgB,EAAE;gBACzBa,SAASK,IAAI,CACX,IAAIC,0CAAuB,CAAC;oBAC1BC,MAAMC,oBAAS,CAACC,KAAK;oBACrBR;oBACAE;oBACAC;oBACAV;oBACAgB,MAAM,CAAC;gBACT;YAEJ,OAAO;gBACLV,SAASK,IAAI,CACX,IAAIM,oCAAiB,CAAC;oBACpBJ,MAAMC,oBAAS,CAACC,KAAK;oBACrBR;oBACAE;oBACAC;oBACAV;gBACF;YAEJ;QACF;QAEA,OAAOM;IACT;AACF"}

View File

@@ -0,0 +1,9 @@
import { RouteMatcher } from '../../route-matchers/route-matcher';
import { CachedRouteMatcherProvider } from '../helpers/cached-route-matcher-provider';
import { 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);
}

View File

@@ -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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/route-matcher-providers/dev/file-cache-route-matcher-provider.ts"],"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"}

View File

@@ -0,0 +1,15 @@
import { 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>>;
}

View File

@@ -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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/server/future/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.ts"],"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":";;;;+BAeaA;;;eAAAA;;;AAAN,MAAMA;IAGXC,YAA6BC,OAAoB;sBAApBA;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,IAAIE,IAAI,GAAGA,IAAIT,MAAMG,SAAS,CAACC,MAAM,EAAEK,IAAK;gBAC/C,MAAMC,QAAQL,MAAM,CAACI,EAAE;gBACvB,IAAIC,iBAAiBC,OAAO;oBAC1BX,MAAMG,SAAS,CAACM,EAAE,CAACD,MAAM,CAACE;gBAC5B,OAAO;oBACLV,MAAMG,SAAS,CAACM,EAAE,CAACd,OAAO,CAACe;gBAC7B;YACF;QACF;QAEA,OAAOV;IACT;IAEA,MAAcM,KACZJ,WAAkC,EACqB;QACvD,wEAAwE;QACxE,gCAAgC;QAChC,MAAMU,SAAS;eAAI,IAAIC,IAAIX;SAAa;QAExC,MAAMY,UAAU,MAAMpB,QAAQqB,GAAG,CAC/BH,OAAOI,GAAG,CAAC,OAAOC;YAChB,IAAIC;YACJ,IAAIC;YACJ,IAAI;gBACFD,QAAQ,MAAM,IAAI,CAAC5B,MAAM,CAAC8B,IAAI,CAACH;YACjC,EAAE,OAAOV,KAAK;gBACZ,IAAIA,eAAeI,OAAOQ,QAAQZ;YACpC;YAEA,OAAO;gBAAEU;gBAAWC;gBAAOC;YAAM;QACnC;QAGF,OAAOjB,YAAYc,GAAG,CAAC,CAACC;YACtB,MAAMI,QAAQP,QAAQQ,IAAI,CAAC,CAACC,SAAWA,OAAON,SAAS,KAAKA;YAC5D,IAAI,CAACI,OAAO,OAAO,EAAE;YAErB,IAAIA,MAAMH,KAAK,EAAE,OAAOG,MAAMH,KAAK;YACnC,IAAIG,MAAMF,KAAK,EAAE,OAAOE,MAAMF,KAAK;YAEnC,OAAO,EAAE;QACX;IACF;IAEA,MAAaC,KAAKI,GAAW,EAAkC;QAC7D,0CAA0C;QAC1C,MAAMxB,QAAQ,IAAI,CAACD,gBAAgB;QAEnC,iDAAiD;QACjDC,MAAME,WAAW,CAACuB,IAAI,CAACD;QAEvB,2EAA2E;QAC3E,yCAAyC;QACzC,MAAME,UAAU,IAAIhC,QAA+B,CAACC,SAASa;YAC3DR,MAAMG,SAAS,CAACsB,IAAI,CAAC;gBAAE9B;gBAASa;YAAO;QACzC;QAEA,OAAOkB;IACT;AACF"}

View File

@@ -0,0 +1,30 @@
import type { FileReader } from './file-reader';
import { RecursiveReadDirOptions } from '../../../../../../lib/recursive-readdir';
export type DefaultFileReaderOptions = Pick<RecursiveReadDirOptions, 'pathnameFilter' | 'ignoreFilter' | '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>>;
}

View File

@@ -0,0 +1,43 @@
"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,
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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/server/future/route-matcher-providers/dev/helpers/file-reader/default-file-reader.ts"],"names":["DefaultFileReader","constructor","options","read","dir","recursiveReadDir","pathnameFilter","ignoreFilter","ignorePartFilter","sortPathnames","relativePathnames"],"mappings":";;;;+BAgBaA;;;eAAAA;;;kCAXN;AAWA,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,cAAc,IAAI,CAACL,OAAO,CAACK,YAAY;YACvCC,kBAAkB,IAAI,CAACN,OAAO,CAACM,gBAAgB;YAE/C,uEAAuE;YACvE,wBAAwB;YACxBC,eAAe;YAEf,sEAAsE;YACtE,iCAAiC;YACjCC,mBAAmB;QACrB;IACF;AACF"}

View File

@@ -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>;
}

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=file-reader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}