feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

78
node_modules/webpack/lib/util/fs.js generated vendored
View File

@@ -80,23 +80,28 @@ const path = require("path");
/** @typedef {function(NodeJS.ErrnoException | null, number=): void} NumberCallback */
/** @typedef {function(NodeJS.ErrnoException | Error | null, JsonObject=): void} ReadJsonCallback */
/** @typedef {Map<string, FileSystemInfoEntry | "ignore">} TimeInfoEntries */
/**
* @typedef {object} WatcherInfo
* @property {Set<string>} changes get current aggregated changes that have not yet send to callback
* @property {Set<string>} removals get current aggregated removals that have not yet send to callback
* @property {Map<string, FileSystemInfoEntry | "ignore">} fileTimeInfoEntries get info about files
* @property {Map<string, FileSystemInfoEntry | "ignore">} contextTimeInfoEntries get info about directories
* @property {Set<string> | null} changes get current aggregated changes that have not yet send to callback
* @property {Set<string> | null} removals get current aggregated removals that have not yet send to callback
* @property {TimeInfoEntries} fileTimeInfoEntries get info about files
* @property {TimeInfoEntries} contextTimeInfoEntries get info about directories
*/
/** @typedef {Set<string>} Changes */
/** @typedef {Set<string>} Removals */
// TODO webpack 6 deprecate missing getInfo
/**
* @typedef {object} Watcher
* @property {function(): void} close closes the watcher and all underlying file watchers
* @property {function(): void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
* @property {function(): Set<string>=} getAggregatedChanges get current aggregated changes that have not yet send to callback
* @property {function(): Set<string>=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
* @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getFileTimeInfoEntries get info about files
* @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getContextTimeInfoEntries get info about directories
* @property {(function(): Changes | null)=} getAggregatedChanges get current aggregated changes that have not yet send to callback
* @property {(function(): Removals | null)=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
* @property {function(): TimeInfoEntries} getFileTimeInfoEntries get info about files
* @property {function(): TimeInfoEntries} getContextTimeInfoEntries get info about directories
* @property {function(): WatcherInfo=} getInfo get info about timestamps and changes
*/
@@ -107,7 +112,7 @@ const path = require("path");
* @param {Iterable<string>} missing watched existence entries
* @param {number} startTime timestamp of start time
* @param {WatchOptions} options options object
* @param {function(Error | null, Map<string, FileSystemInfoEntry | "ignore">, Map<string, FileSystemInfoEntry | "ignore">, Set<string>, Set<string>): void} callback aggregated callback
* @param {function(Error | null, TimeInfoEntries=, TimeInfoEntries=, Changes=, Removals=): void} callback aggregated callback
* @param {function(string, number): void} callbackUndelayed callback when the first change was detected
* @returns {Watcher} a watcher
*/
@@ -367,7 +372,7 @@ const path = require("path");
* @typedef {object} StreamOptions
* @property {(string | undefined)=} flags
* @property {(BufferEncoding | undefined)} encoding
* @property {(number | any | undefined)=} fd
* @property {(number | EXPECTED_ANY | undefined)=} fd
* @property {(number | undefined)=} mode
* @property {(boolean | undefined)=} autoClose
* @property {(boolean | undefined)=} emitClose
@@ -377,12 +382,12 @@ const path = require("path");
/**
* @typedef {object} FSImplementation
* @property {((...args: any[]) => any)=} open
* @property {((...args: any[]) => any)=} close
* @property {((...args: EXPECTED_ANY[]) => EXPECTED_ANY)=} open
* @property {((...args: EXPECTED_ANY[]) => EXPECTED_ANY)=} close
*/
/**
* @typedef {FSImplementation & { write: (...args: any[]) => any; close?: (...args: any[]) => any }} CreateWriteStreamFSImplementation
* @typedef {FSImplementation & { write: (...args: EXPECTED_ANY[]) => EXPECTED_ANY; close?: (...args: EXPECTED_ANY[]) => EXPECTED_ANY }} CreateWriteStreamFSImplementation
*/
/**
@@ -451,7 +456,6 @@ const path = require("path");
/** @typedef {InputFileSystem & OutputFileSystem & IntermediateFileSystemExtras} IntermediateFileSystem */
/**
*
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
* @param {string} rootPath the root path
* @param {string} targetPath the target path
@@ -464,13 +468,12 @@ const relative = (fs, rootPath, targetPath) => {
return path.posix.relative(rootPath, targetPath);
} else if (path.win32.isAbsolute(rootPath)) {
return path.win32.relative(rootPath, targetPath);
} else {
throw new Error(
`${rootPath} is neither a posix nor a windows path, and there is no 'relative' method defined in the file system`
);
}
throw new Error(
`${rootPath} is neither a posix nor a windows path, and there is no 'relative' method defined in the file system`
);
};
exports.relative = relative;
module.exports.relative = relative;
/**
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
@@ -485,13 +488,12 @@ const join = (fs, rootPath, filename) => {
return path.posix.join(rootPath, filename);
} else if (path.win32.isAbsolute(rootPath)) {
return path.win32.join(rootPath, filename);
} else {
throw new Error(
`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`
);
}
throw new Error(
`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`
);
};
exports.join = join;
module.exports.join = join;
/**
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
@@ -505,13 +507,12 @@ const dirname = (fs, absPath) => {
return path.posix.dirname(absPath);
} else if (path.win32.isAbsolute(absPath)) {
return path.win32.dirname(absPath);
} else {
throw new Error(
`${absPath} is neither a posix nor a windows path, and there is no 'dirname' method defined in the file system`
);
}
throw new Error(
`${absPath} is neither a posix nor a windows path, and there is no 'dirname' method defined in the file system`
);
};
exports.dirname = dirname;
module.exports.dirname = dirname;
/**
* @param {OutputFileSystem} fs a file system
@@ -556,7 +557,7 @@ const mkdirp = (fs, p, callback) => {
callback();
});
};
exports.mkdirp = mkdirp;
module.exports.mkdirp = mkdirp;
/**
* @param {IntermediateFileSystem} fs a file system
@@ -583,7 +584,7 @@ const mkdirpSync = (fs, p) => {
}
}
};
exports.mkdirpSync = mkdirpSync;
module.exports.mkdirpSync = mkdirpSync;
/**
* @param {InputFileSystem} fs a file system
@@ -601,13 +602,13 @@ const readJson = (fs, p, callback) => {
let data;
try {
data = JSON.parse(/** @type {Buffer} */ (buf).toString("utf-8"));
} catch (e) {
return callback(/** @type {Error} */ (e));
} catch (err1) {
return callback(/** @type {Error} */ (err1));
}
return callback(null, data);
});
};
exports.readJson = readJson;
module.exports.readJson = readJson;
/**
* @param {InputFileSystem} fs a file system
@@ -624,8 +625,8 @@ const lstatReadlinkAbsolute = (fs, p, callback) => {
// we retry 2 times to catch this case before throwing the error
return doStat();
}
if (err || !target) return doStat();
const value = target.toString();
if (err) return callback(err);
const value = /** @type {string} */ (target).toString();
callback(null, join(fs, dirname(fs, p), value));
});
};
@@ -641,11 +642,10 @@ const lstatReadlinkAbsolute = (fs, p, callback) => {
callback(null, stats);
}
);
} else {
return fs.stat(p, callback);
}
return fs.stat(p, callback);
};
if ("lstat" in fs) return doStat();
doReadLink();
};
exports.lstatReadlinkAbsolute = lstatReadlinkAbsolute;
module.exports.lstatReadlinkAbsolute = lstatReadlinkAbsolute;