added fonts

This commit is contained in:
guus committed 2025-07-02 11:28:41 +02:00
1 parent 4134e3a234
commit 142d2986b6
9079 files changed
+1498421 -2

No files matched your search

@@ -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>>;
}
@@ -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
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/server/route-matcher-providers/dev/helpers/file-reader/batched-file-reader.ts"],"sourcesContent":["import type { FileReader } from './file-reader'\n\ninterface FileReaderBatch {\n completed: boolean\n directories: Array<string>\n callbacks: Array<{\n resolve: (value: ReadonlyArray<string>) => void\n reject: (err: any) => void\n }>\n}\n\n/**\n * CachedFileReader will deduplicate requests made to the same folder structure\n * to scan for files.\n */\nexport class BatchedFileReader implements FileReader {\n private batch?: FileReaderBatch\n\n constructor(private readonly reader: FileReader) {}\n\n // This allows us to schedule the batches after all the promises associated\n // with loading files.\n private schedulePromise?: Promise<void>\n private schedule(callback: Function) {\n if (!this.schedulePromise) {\n this.schedulePromise = Promise.resolve()\n }\n this.schedulePromise.then(() => {\n process.nextTick(callback)\n })\n }\n\n private getOrCreateBatch(): FileReaderBatch {\n // If there is an existing batch and it's not completed, then reuse it.\n if (this.batch && !this.batch.completed) {\n return this.batch\n }\n\n const batch: FileReaderBatch = {\n completed: false,\n directories: [],\n callbacks: [],\n }\n\n this.batch = batch\n\n this.schedule(async () => {\n batch.completed = true\n if (batch.directories.length === 0) return\n\n // Collect all the results for each of the directories. If any error\n // occurs, send the results back to the loaders.\n let values: ReadonlyArray<ReadonlyArray<string> | Error>\n try {\n values = await this.load(batch.directories)\n } catch (err) {\n // Reject all the callbacks.\n for (const { reject } of batch.callbacks) {\n reject(err)\n }\n return\n }\n\n // Loop over all the callbacks and send them their results.\n for (let i = 0; i < batch.callbacks.length; i++) {\n const value = values[i]\n if (value instanceof Error) {\n batch.callbacks[i].reject(value)\n } else {\n batch.callbacks[i].resolve(value)\n }\n }\n })\n\n return batch\n }\n\n private async load(\n directories: ReadonlyArray<string>\n ): Promise<ReadonlyArray<ReadonlyArray<string> | Error>> {\n // Make a unique array of directories. This is what lets us de-duplicate\n // loads for the same directory.\n const unique = [...new Set(directories)]\n\n const results = await Promise.all(\n unique.map(async (directory) => {\n let files: ReadonlyArray<string> | undefined\n let error: Error | undefined\n try {\n files = await this.reader.read(directory)\n } catch (err) {\n if (err instanceof Error) error = err\n }\n\n return { directory, files, error }\n })\n )\n\n return directories.map((directory) => {\n const found = results.find((result) => result.directory === directory)\n if (!found) return []\n\n if (found.files) return found.files\n if (found.error) return found.error\n\n return []\n })\n }\n\n public async read(dir: string): Promise<ReadonlyArray<string>> {\n // Get or create a new file reading batch.\n const batch = this.getOrCreateBatch()\n\n // Push this directory into the batch to resolve.\n batch.directories.push(dir)\n\n // Push the promise handles into the batch (under the same index) so it can\n // be resolved later when it's scheduled.\n const promise = new Promise<ReadonlyArray<string>>((resolve, reject) => {\n batch.callbacks.push({ resolve, reject })\n })\n\n return promise\n }\n}\n"],"names":["BatchedFileReader","constructor","reader","schedule","callback","schedulePromise","Promise","resolve","then","process","nextTick","getOrCreateBatch","batch","completed","directories","callbacks","length","values","load","err","reject","i","value","Error","unique","Set","results","all","map","directory","files","error","read","found","find","result","dir","push","promise"],"mappings":";;;;+BAeaA;;;eAAAA;;;AAAN,MAAMA;IAGXC,YAAY,AAAiBC,MAAkB,CAAE;aAApBA,SAAAA;IAAqB;IAK1CC,SAASC,QAAkB,EAAE;QACnC,IAAI,CAAC,IAAI,CAACC,eAAe,EAAE;YACzB,IAAI,CAACA,eAAe,GAAGC,QAAQC,OAAO;QACxC;QACA,IAAI,CAACF,eAAe,CAACG,IAAI,CAAC;YACxBC,QAAQC,QAAQ,CAACN;QACnB;IACF;IAEQO,mBAAoC;QAC1C,uEAAuE;QACvE,IAAI,IAAI,CAACC,KAAK,IAAI,CAAC,IAAI,CAACA,KAAK,CAACC,SAAS,EAAE;YACvC,OAAO,IAAI,CAACD,KAAK;QACnB;QAEA,MAAMA,QAAyB;YAC7BC,WAAW;YACXC,aAAa,EAAE;YACfC,WAAW,EAAE;QACf;QAEA,IAAI,CAACH,KAAK,GAAGA;QAEb,IAAI,CAACT,QAAQ,CAAC;YACZS,MAAMC,SAAS,GAAG;YAClB,IAAID,MAAME,WAAW,CAACE,MAAM,KAAK,GAAG;YAEpC,oEAAoE;YACpE,gDAAgD;YAChD,IAAIC;YACJ,IAAI;gBACFA,SAAS,MAAM,IAAI,CAACC,IAAI,CAACN,MAAME,WAAW;YAC5C,EAAE,OAAOK,KAAK;gBACZ,4BAA4B;gBAC5B,KAAK,MAAM,EAAEC,MAAM,EAAE,IAAIR,MAAMG,SAAS,CAAE;oBACxCK,OAAOD;gBACT;gBACA;YACF;YAEA,2DAA2D;YAC3D,IALine truncated
@@ -0,0 +1,30 @@
import type { FileReader } from './file-reader';
import type { 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>>;
}
@@ -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
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/server/route-matcher-providers/dev/helpers/file-reader/default-file-reader.ts"],"sourcesContent":["import type { FileReader } from './file-reader'\nimport type { RecursiveReadDirOptions } from '../../../../../lib/recursive-readdir'\nimport { recursiveReadDir } from '../../../../../lib/recursive-readdir'\n\nexport type DefaultFileReaderOptions = Pick<\n RecursiveReadDirOptions,\n 'pathnameFilter' | 'ignoreFilter' | 'ignorePartFilter'\n>\n\n/**\n * Reads all the files in the directory and its subdirectories following any\n * symbolic links.\n */\nexport class DefaultFileReader implements FileReader {\n /**\n * Filter to ignore files with absolute pathnames. If undefined, no files are\n * ignored.\n */\n private readonly options: Readonly<DefaultFileReaderOptions>\n\n /**\n * Creates a new file reader.\n *\n * @param pathnameFilter filter to ignore files with absolute pathnames, false to ignore\n * @param ignoreFilter filter to ignore files and directories with absolute pathnames, false to ignore\n * @param ignorePartFilter filter to ignore files and directories with the pathname part, false to ignore\n */\n constructor(options: Readonly<DefaultFileReaderOptions>) {\n this.options = options\n }\n\n /**\n * Reads all the files in the directory and its subdirectories following any\n * symbolic links.\n *\n * @param dir the directory to read\n * @returns a promise that resolves to the list of files\n */\n public async read(dir: string): Promise<ReadonlyArray<string>> {\n return recursiveReadDir(dir, {\n pathnameFilter: this.options.pathnameFilter,\n ignoreFilter: this.options.ignoreFilter,\n ignorePartFilter: this.options.ignorePartFilter,\n\n // We don't need to sort the results because we're not depending on the\n // order of the results.\n sortPathnames: false,\n\n // We want absolute pathnames because we're going to be comparing them\n // with other absolute pathnames.\n relativePathnames: false,\n })\n }\n}\n"],"names":["DefaultFileReader","constructor","options","read","dir","recursiveReadDir","pathnameFilter","ignoreFilter","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,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"}
@@ -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>;
}
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=file-reader.js.map
@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}