enhanced-resolve
Advanced tools
Comparing version 5.15.1 to 5.16.0
@@ -11,4 +11,6 @@ /* | ||
/** @typedef {import("./Resolver").FileSystem} FileSystem */ | ||
/** @typedef {import("./Resolver").PathLike} PathLike */ | ||
/** @typedef {import("./Resolver").PathOrFileDescriptor} PathOrFileDescriptor */ | ||
/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */ | ||
/** @typedef {any} BaseFileSystem */ | ||
/** @typedef {FileSystem & SyncFileSystem} BaseFileSystem */ | ||
@@ -39,3 +41,3 @@ /** | ||
* @param {FileSystemCallback<T>[]} callbacks callbacks | ||
* @param {Error | undefined} err error | ||
* @param {Error | null} err error | ||
* @param {T} result result | ||
@@ -63,4 +65,4 @@ */ | ||
/** | ||
* @param {function} provider async method in filesystem | ||
* @param {function} syncProvider sync method in filesystem | ||
* @param {Function | undefined} provider async method in filesystem | ||
* @param {Function | undefined} syncProvider sync method in filesystem | ||
* @param {BaseFileSystem} providerContext call context for the provider methods | ||
@@ -76,5 +78,5 @@ */ | ||
? /** | ||
* @param {string} path path | ||
* @param {any} options options | ||
* @param {function} callback callback | ||
* @param {PathLike | PathOrFileDescriptor} path path | ||
* @param {object | FileSystemCallback<any> | undefined} options options | ||
* @param {FileSystemCallback<any>=} callback callback | ||
* @returns {any} result | ||
@@ -84,7 +86,19 @@ */ | ||
if (typeof options === "function") { | ||
callback = options; | ||
callback = /** @type {FileSystemCallback<any>} */ (options); | ||
options = undefined; | ||
} | ||
if ( | ||
typeof path !== "string" && | ||
!Buffer.isBuffer(path) && | ||
!(path instanceof URL) && | ||
typeof path !== "number" | ||
) { | ||
/** @type {Function} */ | ||
(callback)( | ||
new TypeError("path must be a string, Buffer, URL or number") | ||
); | ||
return; | ||
} | ||
if (options) { | ||
return this._provider.call( | ||
return /** @type {Function} */ (this._provider).call( | ||
this._providerContext, | ||
@@ -96,6 +110,2 @@ path, | ||
} | ||
if (typeof path !== "string") { | ||
callback(new TypeError("path must be a string")); | ||
return; | ||
} | ||
let callbacks = this._activeAsyncOperations.get(path); | ||
@@ -107,3 +117,4 @@ if (callbacks) { | ||
this._activeAsyncOperations.set(path, (callbacks = [callback])); | ||
provider( | ||
/** @type {Function} */ | ||
(provider)( | ||
path, | ||
@@ -123,8 +134,12 @@ /** | ||
? /** | ||
* @param {string} path path | ||
* @param {any} options options | ||
* @param {PathLike | PathOrFileDescriptor} path path | ||
* @param {object=} options options | ||
* @returns {any} result | ||
*/ | ||
(path, options) => { | ||
return this._syncProvider.call(this._providerContext, path, options); | ||
return /** @type {Function} */ (this._syncProvider).call( | ||
this._providerContext, | ||
path, | ||
options | ||
); | ||
} | ||
@@ -162,7 +177,15 @@ : null; | ||
/** | ||
* @callback Provide | ||
* @param {PathLike | PathOrFileDescriptor} path path | ||
* @param {any} options options | ||
* @param {FileSystemCallback<any>} callback callback | ||
* @returns {void} | ||
*/ | ||
class CacheBackend { | ||
/** | ||
* @param {number} duration max cache duration of items | ||
* @param {function} provider async method | ||
* @param {function} syncProvider sync method | ||
* @param {function | undefined} provider async method | ||
* @param {function | undefined} syncProvider sync method | ||
* @param {BaseFileSystem} providerContext call context for the provider methods | ||
@@ -177,3 +200,3 @@ */ | ||
this._activeAsyncOperations = new Map(); | ||
/** @type {Map<string, { err?: Error, result?: any, level: Set<string> }>} */ | ||
/** @type {Map<string, { err: Error | null, result?: any, level: Set<string> }>} */ | ||
this._data = new Map(); | ||
@@ -201,3 +224,3 @@ /** @type {Set<string>[]} */ | ||
/** | ||
* @param {string} path path | ||
* @param {PathLike | PathOrFileDescriptor} path path | ||
* @param {any} options options | ||
@@ -212,8 +235,14 @@ * @param {FileSystemCallback<any>} callback callback | ||
} | ||
if (typeof path !== "string") { | ||
callback(new TypeError("path must be a string")); | ||
if ( | ||
typeof path !== "string" && | ||
!Buffer.isBuffer(path) && | ||
!(path instanceof URL) && | ||
typeof path !== "number" | ||
) { | ||
callback(new TypeError("path must be a string, Buffer, URL or number")); | ||
return; | ||
} | ||
const strPath = typeof path !== "string" ? path.toString() : path; | ||
if (options) { | ||
return this._provider.call( | ||
return /** @type {Function} */ (this._provider).call( | ||
this._providerContext, | ||
@@ -232,3 +261,3 @@ path, | ||
// Check in cache | ||
let cacheEntry = this._data.get(path); | ||
let cacheEntry = this._data.get(strPath); | ||
if (cacheEntry !== undefined) { | ||
@@ -240,3 +269,3 @@ if (cacheEntry.err) return nextTick(callback, cacheEntry.err); | ||
// Check if there is already the same operation running | ||
let callbacks = this._activeAsyncOperations.get(path); | ||
let callbacks = this._activeAsyncOperations.get(strPath); | ||
if (callbacks !== undefined) { | ||
@@ -246,15 +275,16 @@ callbacks.push(callback); | ||
} | ||
this._activeAsyncOperations.set(path, (callbacks = [callback])); | ||
this._activeAsyncOperations.set(strPath, (callbacks = [callback])); | ||
// Run the operation | ||
this._provider.call( | ||
/** @type {Function} */ | ||
(this._provider).call( | ||
this._providerContext, | ||
path, | ||
/** | ||
* @param {Error} [err] error | ||
* @param {Error | null} err error | ||
* @param {any} [result] result | ||
*/ | ||
(err, result) => { | ||
this._activeAsyncOperations.delete(path); | ||
this._storeResult(path, err, result); | ||
this._activeAsyncOperations.delete(strPath); | ||
this._storeResult(strPath, err, result); | ||
@@ -274,3 +304,3 @@ // Enter async mode if not yet done | ||
/** | ||
* @param {string} path path | ||
* @param {PathLike | PathOrFileDescriptor} path path | ||
* @param {any} options options | ||
@@ -280,7 +310,17 @@ * @returns {any} result | ||
provideSync(path, options) { | ||
if (typeof path !== "string") { | ||
if ( | ||
typeof path !== "string" && | ||
!Buffer.isBuffer(path) && | ||
!(path instanceof URL) && | ||
typeof path !== "number" | ||
) { | ||
throw new TypeError("path must be a string"); | ||
} | ||
const strPath = typeof path !== "string" ? path.toString() : path; | ||
if (options) { | ||
return this._syncProvider.call(this._providerContext, path, options); | ||
return /** @type {Function} */ (this._syncProvider).call( | ||
this._providerContext, | ||
path, | ||
options | ||
); | ||
} | ||
@@ -294,3 +334,3 @@ | ||
// Check in cache | ||
let cacheEntry = this._data.get(path); | ||
let cacheEntry = this._data.get(strPath); | ||
if (cacheEntry !== undefined) { | ||
@@ -303,4 +343,4 @@ if (cacheEntry.err) throw cacheEntry.err; | ||
// This sync operation will also complete them | ||
const callbacks = this._activeAsyncOperations.get(path); | ||
this._activeAsyncOperations.delete(path); | ||
const callbacks = this._activeAsyncOperations.get(strPath); | ||
this._activeAsyncOperations.delete(strPath); | ||
@@ -311,5 +351,8 @@ // Run the operation | ||
try { | ||
result = this._syncProvider.call(this._providerContext, path); | ||
result = /** @type {Function} */ (this._syncProvider).call( | ||
this._providerContext, | ||
path | ||
); | ||
} catch (err) { | ||
this._storeResult(path, /** @type {Error} */ (err), undefined); | ||
this._storeResult(strPath, /** @type {Error} */ (err), undefined); | ||
this._enterSyncModeWhenIdle(); | ||
@@ -321,6 +364,6 @@ if (callbacks) { | ||
} | ||
this._storeResult(path, undefined, result); | ||
this._storeResult(strPath, null, result); | ||
this._enterSyncModeWhenIdle(); | ||
if (callbacks) { | ||
runCallbacks(callbacks, undefined, result); | ||
runCallbacks(callbacks, null, result); | ||
} | ||
@@ -331,3 +374,3 @@ return result; | ||
/** | ||
* @param {string|string[]|Set<string>} [what] what to purge | ||
* @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge | ||
*/ | ||
@@ -343,5 +386,11 @@ purge(what) { | ||
} | ||
} else if (typeof what === "string") { | ||
} else if ( | ||
typeof what === "string" || | ||
Buffer.isBuffer(what) || | ||
what instanceof URL || | ||
typeof what === "number" | ||
) { | ||
const strWhat = typeof what !== "string" ? what.toString() : what; | ||
for (let [key, data] of this._data) { | ||
if (key.startsWith(what)) { | ||
if (key.startsWith(strWhat)) { | ||
this._data.delete(key); | ||
@@ -357,3 +406,4 @@ data.level.delete(key); | ||
for (const item of what) { | ||
if (key.startsWith(item)) { | ||
const strItem = typeof item !== "string" ? item.toString() : item; | ||
if (key.startsWith(strItem)) { | ||
this._data.delete(key); | ||
@@ -372,3 +422,3 @@ data.level.delete(key); | ||
/** | ||
* @param {string|string[]|Set<string>} [what] what to purge | ||
* @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge | ||
*/ | ||
@@ -378,8 +428,15 @@ purgeParent(what) { | ||
this.purge(); | ||
} else if (typeof what === "string") { | ||
this.purge(dirname(what)); | ||
} else if ( | ||
typeof what === "string" || | ||
Buffer.isBuffer(what) || | ||
what instanceof URL || | ||
typeof what === "number" | ||
) { | ||
const strWhat = typeof what !== "string" ? what.toString() : what; | ||
this.purge(dirname(strWhat)); | ||
} else { | ||
const set = new Set(); | ||
for (const item of what) { | ||
set.add(dirname(item)); | ||
const strItem = typeof item !== "string" ? item.toString() : item; | ||
set.add(dirname(strItem)); | ||
} | ||
@@ -392,3 +449,3 @@ this.purge(set); | ||
* @param {string} path path | ||
* @param {undefined | Error} err error | ||
* @param {Error | null} err error | ||
* @param {any} result result | ||
@@ -479,5 +536,5 @@ */ | ||
* @param {number} duration duration in ms files are cached | ||
* @param {Provider} provider provider | ||
* @param {AsyncProvider} syncProvider sync provider | ||
* @param {FileSystem} providerContext provider context | ||
* @param {Provider | undefined} provider provider | ||
* @param {AsyncProvider | undefined} syncProvider sync provider | ||
* @param {BaseFileSystem} providerContext provider context | ||
* @returns {OperationMergerBackend | CacheBackend} backend | ||
@@ -608,6 +665,19 @@ */ | ||
); | ||
this._realpathBackend = createBackend( | ||
duration, | ||
this.fileSystem.realpath, | ||
this.fileSystem.realpathSync, | ||
this.fileSystem | ||
); | ||
const realpath = this._realpathBackend.provide; | ||
this.realpath = /** @type {FileSystem["realpath"]} */ (realpath); | ||
const realpathSync = this._realpathBackend.provideSync; | ||
this.realpathSync = /** @type {SyncFileSystem["realpathSync"]} */ ( | ||
realpathSync | ||
); | ||
} | ||
/** | ||
* @param {string|string[]|Set<string>} [what] what to purge | ||
* @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge | ||
*/ | ||
@@ -621,3 +691,4 @@ purge(what) { | ||
this._readJsonBackend.purge(what); | ||
this._realpathBackend.purge(what); | ||
} | ||
}; |
@@ -69,3 +69,6 @@ /* | ||
if (err) { | ||
if (typeof err.code !== "undefined") { | ||
if ( | ||
typeof (/** @type {NodeJS.ErrnoException} */ (err).code) !== | ||
"undefined" | ||
) { | ||
if (resolveContext.missingDependencies) { | ||
@@ -84,3 +87,3 @@ resolveContext.missingDependencies.add(descriptionFilePath); | ||
} | ||
onJson(null, /** @type {JsonObject} */ (content)); | ||
onJson(null, content); | ||
}); | ||
@@ -87,0 +90,0 @@ } else { |
@@ -20,20 +20,7 @@ /* | ||
/** @typedef {Error & {details?: string}} ErrorWithDetail */ | ||
/** @typedef {Error & { details?: string }} ErrorWithDetail */ | ||
/** @typedef {(err: ErrorWithDetail|null, res?: string|false, req?: ResolveRequest) => void} ResolveCallback */ | ||
/** @typedef {(err: ErrorWithDetail | null, res?: string | false, req?: ResolveRequest) => void} ResolveCallback */ | ||
/** | ||
* @typedef {Object} FileSystemStats | ||
* @property {function(): boolean} isDirectory | ||
* @property {function(): boolean} isFile | ||
*/ | ||
/** | ||
* @typedef {Object} FileSystemDirent | ||
* @property {Buffer | string} name | ||
* @property {function(): boolean} isDirectory | ||
* @property {function(): boolean} isFile | ||
*/ | ||
/** | ||
* @typedef {Object} PossibleFileSystemError | ||
@@ -49,22 +36,229 @@ * @property {string=} code | ||
* @callback FileSystemCallback | ||
* @param {PossibleFileSystemError & Error | null | undefined} err | ||
* @param {PossibleFileSystemError & Error | null} err | ||
* @param {T=} result | ||
*/ | ||
/** @typedef {function((NodeJS.ErrnoException | null)=, (string | Buffer)[] | import("fs").Dirent[]=): void} DirentArrayCallback */ | ||
/** | ||
* @typedef {string | Buffer | URL} PathLike | ||
*/ | ||
/** | ||
* @typedef {Object} ReaddirOptions | ||
* @property {BufferEncoding | null | 'buffer'} [encoding] | ||
* @property {boolean | undefined} [withFileTypes=false] | ||
* @typedef {PathLike | number} PathOrFileDescriptor | ||
*/ | ||
/** | ||
* @typedef {Object} ObjectEncodingOptions | ||
* @property {BufferEncoding | null | undefined} [encoding] | ||
*/ | ||
/** @typedef {function(NodeJS.ErrnoException | null, string=): void} StringCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, Buffer=): void} BufferCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, (string | Buffer)=): void} StringOrBufferCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, IStats=): void} StatsCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, IBigIntStats=): void} BigIntStatsCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, (IStats | IBigIntStats)=): void} StatsOrBigIntStatsCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | Error | null, JsonObject=): void} ReadJsonCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, string[]=): void} ReaddirStringCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, Buffer[]=): void} ReaddirBufferCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, (string[] | Buffer[])=): void} ReaddirStringOrBufferCallback */ | ||
/** @typedef {function(NodeJS.ErrnoException | null, Dirent[]=): void} ReaddirDirentCallback */ | ||
/** | ||
* @template T | ||
* @typedef {Object} IStatsBase | ||
* @property {() => boolean} isFile | ||
* @property {() => boolean} isDirectory | ||
* @property {() => boolean} isBlockDevice | ||
* @property {() => boolean} isCharacterDevice | ||
* @property {() => boolean} isSymbolicLink | ||
* @property {() => boolean} isFIFO | ||
* @property {() => boolean} isSocket | ||
* @property {T} dev | ||
* @property {T} ino | ||
* @property {T} mode | ||
* @property {T} nlink | ||
* @property {T} uid | ||
* @property {T} gid | ||
* @property {T} rdev | ||
* @property {T} size | ||
* @property {T} blksize | ||
* @property {T} blocks | ||
* @property {T} atimeMs | ||
* @property {T} mtimeMs | ||
* @property {T} ctimeMs | ||
* @property {T} birthtimeMs | ||
* @property {Date} atime | ||
* @property {Date} mtime | ||
* @property {Date} ctime | ||
* @property {Date} birthtime | ||
*/ | ||
/** | ||
* @typedef {IStatsBase<number>} IStats | ||
*/ | ||
/** | ||
* @typedef {IStatsBase<bigint> & { atimeNs: bigint, mtimeNs: bigint, ctimeNs: bigint, birthtimeNs: bigint }} IBigIntStats | ||
*/ | ||
/** | ||
* @typedef {Object} Dirent | ||
* @property {() => boolean} isFile | ||
* @property {() => boolean} isDirectory | ||
* @property {() => boolean} isBlockDevice | ||
* @property {() => boolean} isCharacterDevice | ||
* @property {() => boolean} isSymbolicLink | ||
* @property {() => boolean} isFIFO | ||
* @property {() => boolean} isSocket | ||
* @property {string} name | ||
* @property {string} path | ||
*/ | ||
/** | ||
* @typedef {Object} StatOptions | ||
* @property {(boolean | undefined)=} bigint | ||
*/ | ||
/** | ||
* @typedef {Object} StatSyncOptions | ||
* @property {(boolean | undefined)=} bigint | ||
* @property {(boolean | undefined)=} throwIfNoEntry | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathOrFileDescriptor, options: ({ encoding?: null | undefined, flag?: string | undefined } & import("events").Abortable) | undefined | null, callback: BufferCallback): void; | ||
* (path: PathOrFileDescriptor, options: ({ encoding: BufferEncoding, flag?: string | undefined } & import("events").Abortable) | BufferEncoding, callback: StringCallback): void; | ||
* (path: PathOrFileDescriptor, options: (ObjectEncodingOptions & { flag?: string | undefined } & import("events").Abortable) | BufferEncoding | undefined | null, callback: StringOrBufferCallback): void; | ||
* (path: PathOrFileDescriptor, callback: BufferCallback): void; | ||
* }} ReadFile | ||
*/ | ||
/** | ||
* @typedef {ObjectEncodingOptions | BufferEncoding | undefined | null} EncodingOption | ||
*/ | ||
/** | ||
* @typedef {'buffer'| { encoding: 'buffer' }} BufferEncodingOption | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathOrFileDescriptor, options?: { encoding?: null | undefined, flag?: string | undefined } | null): Buffer; | ||
* (path: PathOrFileDescriptor, options: { encoding: BufferEncoding, flag?: string | undefined } | BufferEncoding): string; | ||
* (path: PathOrFileDescriptor, options?: (ObjectEncodingOptions & { flag?: string | undefined }) | BufferEncoding | null): string | Buffer; | ||
* }} ReadFileSync | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, options: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | undefined | null, callback: ReaddirStringCallback): void; | ||
* (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer', callback: ReaddirBufferCallback): void; | ||
* (path: PathLike, callback: ReaddirStringCallback): void; | ||
* (path: PathLike, options: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | undefined | null, callback: ReaddirStringOrBufferCallback): void; | ||
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }, callback: ReaddirDirentCallback): void; | ||
* }} Readdir | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | null): string[]; | ||
* (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer'): Buffer[]; | ||
* (path: PathLike, options?: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | null): string[] | Buffer[]; | ||
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }): Dirent[]; | ||
* }} ReaddirSync | ||
/** | ||
* @typedef {function(PathOrFileDescriptor, ReadJsonCallback): void} ReadJson | ||
*/ | ||
/** | ||
* @typedef {function(PathOrFileDescriptor): JsonObject} ReadJsonSync | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, options: EncodingOption, callback: StringCallback): void; | ||
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void; | ||
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void; | ||
* (path: PathLike, callback: StringCallback): void; | ||
* }} Readlink | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, options?: EncodingOption): string; | ||
* (path: PathLike, options: BufferEncodingOption): Buffer; | ||
* (path: PathLike, options?: EncodingOption): string | Buffer; | ||
* }} ReadlinkSync | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, callback: StatsCallback): void; | ||
* (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void; | ||
* (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void; | ||
* (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void; | ||
* }} LStat | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, options?: undefined): IStats; | ||
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined; | ||
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined; | ||
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats; | ||
* (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats; | ||
* (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats; | ||
* (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined; | ||
* }} LStatSync | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, callback: StatsCallback): void; | ||
* (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void; | ||
* (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void; | ||
* (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void; | ||
* }} Stat | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, options?: undefined): IStats; | ||
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined; | ||
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined; | ||
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats; | ||
* (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats; | ||
* (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats; | ||
* (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined; | ||
* }} StatSync | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, options: EncodingOption, callback: StringCallback): void; | ||
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void; | ||
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void; | ||
* (path: PathLike, callback: StringCallback): void; | ||
* }} RealPath | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* (path: PathLike, options?: EncodingOption): string; | ||
* (path: PathLike, options: BufferEncodingOption): Buffer; | ||
* (path: PathLike, options?: EncodingOption): string | Buffer; | ||
* }} RealPathSync | ||
*/ | ||
/** | ||
* @typedef {Object} FileSystem | ||
* @property {(function(string, FileSystemCallback<Buffer | string>): void) & function(string, object, FileSystemCallback<Buffer | string>): void} readFile | ||
* @property {function(string, (ReaddirOptions | BufferEncoding | null | undefined | 'buffer' | DirentArrayCallback)=, DirentArrayCallback=): void} readdir | ||
* @property {((function(string, FileSystemCallback<object>): void) & function(string, object, FileSystemCallback<object>): void)=} readJson | ||
* @property {(function(string, FileSystemCallback<Buffer | string>): void) & function(string, object, FileSystemCallback<Buffer | string>): void} readlink | ||
* @property {(function(string, FileSystemCallback<FileSystemStats>): void) & function(string, object, FileSystemCallback<Buffer | string>): void=} lstat | ||
* @property {(function(string, FileSystemCallback<FileSystemStats>): void) & function(string, object, FileSystemCallback<Buffer | string>): void} stat | ||
* @property {ReadFile} readFile | ||
* @property {Readdir} readdir | ||
* @property {ReadJson=} readJson | ||
* @property {Readlink} readlink | ||
* @property {LStat=} lstat | ||
* @property {Stat} stat | ||
* @property {RealPath=} realpath | ||
*/ | ||
@@ -74,8 +268,9 @@ | ||
* @typedef {Object} SyncFileSystem | ||
* @property {function(string, object=): Buffer | string} readFileSync | ||
* @property {function(string, object=): (Buffer | string)[] | FileSystemDirent[]} readdirSync | ||
* @property {(function(string, object=): object)=} readJsonSync | ||
* @property {function(string, object=): Buffer | string} readlinkSync | ||
* @property {function(string, object=): FileSystemStats=} lstatSync | ||
* @property {function(string, object=): FileSystemStats} statSync | ||
* @property {ReadFileSync} readFileSync | ||
* @property {ReaddirSync} readdirSync | ||
* @property {ReadJsonSync=} readJsonSync | ||
* @property {ReadlinkSync} readlinkSync | ||
* @property {LStatSync=} lstatSync | ||
* @property {StatSync} statSync | ||
* @property {RealPathSync=} realpathSync | ||
*/ | ||
@@ -82,0 +277,0 @@ |
@@ -9,2 +9,4 @@ /* | ||
/** @typedef {import("./Resolver").FileSystem} FileSystem */ | ||
/** @typedef {import("./Resolver").ReaddirStringCallback} ReaddirStringCallback */ | ||
/** @typedef {import("./Resolver").StringCallback} StringCallback */ | ||
/** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */ | ||
@@ -19,88 +21,202 @@ | ||
/** @type {FileSystem["lstat"] | undefined} */ | ||
this.lstat = undefined; | ||
/** @type {SyncFileSystem["lstatSync"] | undefined} */ | ||
this.lstatSync = undefined; | ||
const lstatSync = fs.lstatSync; | ||
if (lstatSync) { | ||
this.lstat = (arg, options, callback) => { | ||
let result; | ||
try { | ||
result = lstatSync.call(fs, arg); | ||
} catch (e) { | ||
// @ts-ignore | ||
return (callback || options)(e); | ||
this.lstat = | ||
/** @type {FileSystem["lstat"]} */ | ||
( | ||
(arg, options, callback) => { | ||
let result; | ||
try { | ||
result = /** @type {Function | undefined} */ (callback) | ||
? lstatSync.call(fs, arg, options) | ||
: lstatSync.call(fs, arg); | ||
} catch (e) { | ||
return (callback || options)( | ||
/** @type {NodeJS.ErrnoException | null} */ (e) | ||
); | ||
} | ||
(callback || options)(null, /** @type {any} */ (result)); | ||
} | ||
); | ||
this.lstatSync = | ||
/** @type {SyncFileSystem["lstatSync"]} */ | ||
((arg, options) => lstatSync.call(fs, arg, options)); | ||
} | ||
this.stat = | ||
/** @type {FileSystem["stat"]} */ | ||
( | ||
(arg, options, callback) => { | ||
let result; | ||
try { | ||
result = /** @type {Function | undefined} */ (callback) | ||
? fs.statSync(arg, options) | ||
: fs.statSync(arg); | ||
} catch (e) { | ||
return (callback || options)( | ||
/** @type {NodeJS.ErrnoException | null} */ (e) | ||
); | ||
} | ||
(callback || options)(null, /** @type {any} */ (result)); | ||
} | ||
// @ts-ignore | ||
(callback || options)(null, result); | ||
}; | ||
this.lstatSync = (arg, options) => lstatSync.call(fs, arg, options); | ||
} | ||
// @ts-ignore | ||
this.stat = (arg, options, callback) => { | ||
let result; | ||
try { | ||
result = callback ? fs.statSync(arg, options) : fs.statSync(arg); | ||
} catch (e) { | ||
return (callback || options)(e); | ||
} | ||
(callback || options)(null, result); | ||
}; | ||
/** @type {SyncFileSystem["statSync"]} */ | ||
this.statSync = (arg, options) => fs.statSync(arg, options); | ||
// @ts-ignore | ||
this.readdir = (arg, options, callback) => { | ||
let result; | ||
try { | ||
result = fs.readdirSync(arg); | ||
} catch (e) { | ||
return (callback || options)(e); | ||
} | ||
(callback || options)(null, result); | ||
}; | ||
/** @type {SyncFileSystem["readdirSync"]} */ | ||
this.readdirSync = (arg, options) => fs.readdirSync(arg, options); | ||
// @ts-ignore | ||
this.readFile = (arg, options, callback) => { | ||
let result; | ||
try { | ||
result = fs.readFileSync(arg); | ||
} catch (e) { | ||
return (callback || options)(e); | ||
} | ||
(callback || options)(null, result); | ||
}; | ||
/** @type {SyncFileSystem["readFileSync"]} */ | ||
this.readFileSync = (arg, options) => fs.readFileSync(arg, options); | ||
// @ts-ignore | ||
this.readlink = (arg, options, callback) => { | ||
let result; | ||
try { | ||
result = fs.readlinkSync(arg); | ||
} catch (e) { | ||
return (callback || options)(e); | ||
} | ||
(callback || options)(null, result); | ||
}; | ||
/** @type {SyncFileSystem["readlinkSync"]} */ | ||
this.readlinkSync = (arg, options) => fs.readlinkSync(arg, options); | ||
/** @type {FileSystem["readJson"] | undefined} */ | ||
); | ||
this.statSync = | ||
/** @type {SyncFileSystem["statSync"]} */ | ||
((arg, options) => fs.statSync(arg, options)); | ||
this.readdir = | ||
/** @type {FileSystem["readdir"]} */ | ||
( | ||
(arg, options, callback) => { | ||
let result; | ||
try { | ||
result = /** @type {Function | undefined} */ (callback) | ||
? fs.readdirSync( | ||
arg, | ||
/** @type {Exclude<Parameters<FileSystem["readdir"]>[1], ReaddirStringCallback>} */ | ||
(options) | ||
) | ||
: fs.readdirSync(arg); | ||
} catch (e) { | ||
return (callback || options)( | ||
/** @type {NodeJS.ErrnoException | null} */ (e) | ||
); | ||
} | ||
(callback || options)(null, /** @type {any} */ (result)); | ||
} | ||
); | ||
this.readdirSync = | ||
/** @type {SyncFileSystem["readdirSync"]} */ | ||
( | ||
(arg, options) => | ||
fs.readdirSync( | ||
arg, | ||
/** @type {Parameters<SyncFileSystem["readdirSync"]>[1]} */ (options) | ||
) | ||
); | ||
this.readFile = | ||
/** @type {FileSystem["readFile"]} */ | ||
( | ||
(arg, options, callback) => { | ||
let result; | ||
try { | ||
result = /** @type {Function | undefined} */ (callback) | ||
? fs.readFileSync(arg, options) | ||
: fs.readFileSync(arg); | ||
} catch (e) { | ||
return (callback || options)( | ||
/** @type {NodeJS.ErrnoException | null} */ (e) | ||
); | ||
} | ||
(callback || options)(null, /** @type {any} */ (result)); | ||
} | ||
); | ||
this.readFileSync = | ||
/** @type {SyncFileSystem["readFileSync"]} */ | ||
((arg, options) => fs.readFileSync(arg, options)); | ||
this.readlink = | ||
/** @type {FileSystem["readlink"]} */ | ||
( | ||
(arg, options, callback) => { | ||
let result; | ||
try { | ||
result = /** @type {Function | undefined} */ (callback) | ||
? fs.readlinkSync( | ||
arg, | ||
/** @type {Exclude<Parameters<FileSystem["readlink"]>[1], StringCallback>} */ | ||
(options) | ||
) | ||
: fs.readlinkSync(arg); | ||
} catch (e) { | ||
return (callback || options)( | ||
/** @type {NodeJS.ErrnoException | null} */ (e) | ||
); | ||
} | ||
(callback || options)(null, /** @type {any} */ (result)); | ||
} | ||
); | ||
this.readlinkSync = | ||
/** @type {SyncFileSystem["readlinkSync"]} */ | ||
( | ||
(arg, options) => | ||
fs.readlinkSync( | ||
arg, | ||
/** @type {Parameters<SyncFileSystem["readlinkSync"]>[1]} */ (options) | ||
) | ||
); | ||
this.readJson = undefined; | ||
/** @type {SyncFileSystem["readJsonSync"] | undefined} */ | ||
this.readJsonSync = undefined; | ||
const readJsonSync = fs.readJsonSync; | ||
if (readJsonSync) { | ||
this.readJson = (arg, options, callback) => { | ||
let result; | ||
try { | ||
result = readJsonSync.call(fs, arg); | ||
} catch (e) { | ||
// @ts-ignore | ||
return (callback || options)(e); | ||
} | ||
(callback || options)(null, result); | ||
}; | ||
this.readJsonSync = (arg, options) => readJsonSync.call(fs, arg, options); | ||
this.readJson = | ||
/** @type {FileSystem["readJson"]} */ | ||
( | ||
(arg, callback) => { | ||
let result; | ||
try { | ||
result = readJsonSync.call(fs, arg); | ||
} catch (e) { | ||
return callback( | ||
/** @type {NodeJS.ErrnoException | Error | null} */ (e) | ||
); | ||
} | ||
callback(null, result); | ||
} | ||
); | ||
this.readJsonSync = | ||
/** @type {SyncFileSystem["readJsonSync"]} */ | ||
(arg => readJsonSync.call(fs, arg)); | ||
} | ||
this.realpath = undefined; | ||
this.realpathSync = undefined; | ||
const realpathSync = fs.realpathSync; | ||
if (realpathSync) { | ||
this.realpath = | ||
/** @type {FileSystem["realpath"]} */ | ||
( | ||
(arg, options, callback) => { | ||
let result; | ||
try { | ||
result = /** @type {Function | undefined} */ (callback) | ||
? realpathSync.call( | ||
fs, | ||
arg, | ||
/** @type {Exclude<Parameters<NonNullable<FileSystem["realpath"]>>[1], StringCallback>} */ | ||
(options) | ||
) | ||
: realpathSync.call(fs, arg); | ||
} catch (e) { | ||
return (callback || options)( | ||
/** @type {NodeJS.ErrnoException | null} */ (e) | ||
); | ||
} | ||
(callback || options)(null, /** @type {any} */ (result)); | ||
} | ||
); | ||
this.realpathSync = | ||
/** @type {SyncFileSystem["realpathSync"]} */ | ||
( | ||
(arg, options) => | ||
realpathSync.call( | ||
fs, | ||
arg, | ||
/** @type {Parameters<NonNullable<SyncFileSystem["realpathSync"]>>[1]} */ | ||
(options) | ||
) | ||
); | ||
} | ||
} | ||
module.exports = SyncAsyncFileSystemDecorator; |
{ | ||
"name": "enhanced-resolve", | ||
"version": "5.15.1", | ||
"version": "5.16.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -23,3 +23,3 @@ "description": "Offers a async require.resolve function. It's highly configurable.", | ||
"@types/jest": "^27.5.1", | ||
"@types/node": "^14.11.1", | ||
"@types/node": "20.9.5", | ||
"cspell": "4.2.8", | ||
@@ -36,4 +36,4 @@ "eslint": "^7.9.0", | ||
"prettier": "^2.1.2", | ||
"tooling": "webpack/tooling#v1.14.0", | ||
"typescript": "^5.0.4" | ||
"tooling": "webpack/tooling#v1.23.1", | ||
"typescript": "^5.3.3" | ||
}, | ||
@@ -40,0 +40,0 @@ "engines": { |
883
types.d.ts
@@ -7,5 +7,12 @@ /* | ||
import { Dirent } from "fs"; | ||
import { Buffer } from "buffer"; | ||
import { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } from "tapable"; | ||
import { URL as URL_Import } from "url"; | ||
declare interface Abortable { | ||
/** | ||
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action. | ||
*/ | ||
signal?: AbortSignal; | ||
} | ||
type Alias = string | false | string[]; | ||
@@ -21,2 +28,3 @@ declare interface AliasOption { | ||
} | ||
type BaseFileSystem = FileSystem & SyncFileSystem; | ||
declare interface BaseResolveRequest { | ||
@@ -35,77 +43,48 @@ path: string | false; | ||
} | ||
type BufferEncoding = | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex"; | ||
type BufferEncodingOption = "buffer" | { encoding: "buffer" }; | ||
declare class CachedInputFileSystem { | ||
constructor(fileSystem: any, duration: number); | ||
fileSystem: any; | ||
lstat?: { | ||
(arg0: string, arg1: FileSystemCallback<FileSystemStats>): void; | ||
( | ||
arg0: string, | ||
arg1: object, | ||
arg2: FileSystemCallback<string | Buffer> | ||
): void; | ||
}; | ||
lstatSync?: (arg0: string, arg1?: object) => FileSystemStats; | ||
stat: { | ||
(arg0: string, arg1: FileSystemCallback<FileSystemStats>): void; | ||
( | ||
arg0: string, | ||
arg1: object, | ||
arg2: FileSystemCallback<string | Buffer> | ||
): void; | ||
}; | ||
statSync: (arg0: string, arg1?: object) => FileSystemStats; | ||
readdir: ( | ||
arg0: string, | ||
arg1?: | ||
| null | ||
| (( | ||
arg0?: null | NodeJS.ErrnoException, | ||
arg1?: (string | Buffer)[] | Dirent[] | ||
) => void) | ||
| ReaddirOptions | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| "buffer", | ||
arg2?: ( | ||
arg0?: null | NodeJS.ErrnoException, | ||
arg1?: (string | Buffer)[] | Dirent[] | ||
constructor(fileSystem: BaseFileSystem, duration: number); | ||
fileSystem: BaseFileSystem; | ||
lstat?: LStat; | ||
lstatSync?: LStatSync; | ||
stat: Stat; | ||
statSync: StatSync; | ||
readdir: Readdir; | ||
readdirSync: ReaddirSync; | ||
readFile: ReadFile; | ||
readFileSync: ReadFileSync; | ||
readJson?: ( | ||
arg0: PathOrFileDescriptor, | ||
arg1: ( | ||
arg0: null | Error | NodeJS.ErrnoException, | ||
arg1?: JsonObject | ||
) => void | ||
) => void; | ||
readdirSync: ( | ||
arg0: string, | ||
arg1?: object | ||
) => (string | Buffer)[] | FileSystemDirent[]; | ||
readFile: { | ||
(arg0: string, arg1: FileSystemCallback<string | Buffer>): void; | ||
( | ||
arg0: string, | ||
arg1: object, | ||
arg2: FileSystemCallback<string | Buffer> | ||
): void; | ||
}; | ||
readFileSync: (arg0: string, arg1?: object) => string | Buffer; | ||
readJson?: { | ||
(arg0: string, arg1: FileSystemCallback<object>): void; | ||
(arg0: string, arg1: object, arg2: FileSystemCallback<object>): void; | ||
}; | ||
readJsonSync?: (arg0: string, arg1?: object) => object; | ||
readlink: { | ||
(arg0: string, arg1: FileSystemCallback<string | Buffer>): void; | ||
( | ||
arg0: string, | ||
arg1: object, | ||
arg2: FileSystemCallback<string | Buffer> | ||
): void; | ||
}; | ||
readlinkSync: (arg0: string, arg1?: object) => string | Buffer; | ||
purge(what?: string | Set<string> | string[]): void; | ||
readJsonSync?: (arg0: PathOrFileDescriptor) => JsonObject; | ||
readlink: Readlink; | ||
readlinkSync: ReadlinkSync; | ||
realpath?: RealPath; | ||
realpathSync?: RealPathSync; | ||
purge( | ||
what?: | ||
| string | ||
| number | ||
| Buffer | ||
| URL_url | ||
| (string | number | Buffer | URL_url)[] | ||
| Set<string | number | Buffer | URL_url> | ||
): void; | ||
} | ||
@@ -141,2 +120,29 @@ declare class CloneBasenamePlugin { | ||
} | ||
declare interface Dirent { | ||
isFile: () => boolean; | ||
isDirectory: () => boolean; | ||
isBlockDevice: () => boolean; | ||
isCharacterDevice: () => boolean; | ||
isSymbolicLink: () => boolean; | ||
isFIFO: () => boolean; | ||
isSocket: () => boolean; | ||
name: string; | ||
path: string; | ||
} | ||
type EncodingOption = | ||
| undefined | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| ObjectEncodingOptions; | ||
type ErrorWithDetail = Error & { details?: string }; | ||
@@ -151,76 +157,75 @@ declare interface ExtensionAliasOption { | ||
declare interface FileSystem { | ||
readFile: { | ||
(arg0: string, arg1: FileSystemCallback<string | Buffer>): void; | ||
( | ||
arg0: string, | ||
arg1: object, | ||
arg2: FileSystemCallback<string | Buffer> | ||
): void; | ||
}; | ||
readdir: ( | ||
arg0: string, | ||
arg1?: | ||
| null | ||
| (( | ||
arg0?: null | NodeJS.ErrnoException, | ||
arg1?: (string | Buffer)[] | Dirent[] | ||
) => void) | ||
| ReaddirOptions | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| "buffer", | ||
arg2?: ( | ||
arg0?: null | NodeJS.ErrnoException, | ||
arg1?: (string | Buffer)[] | Dirent[] | ||
readFile: ReadFile; | ||
readdir: Readdir; | ||
readJson?: ( | ||
arg0: PathOrFileDescriptor, | ||
arg1: ( | ||
arg0: null | Error | NodeJS.ErrnoException, | ||
arg1?: JsonObject | ||
) => void | ||
) => void; | ||
readJson?: { | ||
(arg0: string, arg1: FileSystemCallback<object>): void; | ||
(arg0: string, arg1: object, arg2: FileSystemCallback<object>): void; | ||
}; | ||
readlink: { | ||
(arg0: string, arg1: FileSystemCallback<string | Buffer>): void; | ||
( | ||
arg0: string, | ||
arg1: object, | ||
arg2: FileSystemCallback<string | Buffer> | ||
): void; | ||
}; | ||
lstat?: { | ||
(arg0: string, arg1: FileSystemCallback<FileSystemStats>): void; | ||
( | ||
arg0: string, | ||
arg1: object, | ||
arg2: FileSystemCallback<string | Buffer> | ||
): void; | ||
}; | ||
stat: { | ||
(arg0: string, arg1: FileSystemCallback<FileSystemStats>): void; | ||
( | ||
arg0: string, | ||
arg1: object, | ||
arg2: FileSystemCallback<string | Buffer> | ||
): void; | ||
}; | ||
readlink: Readlink; | ||
lstat?: LStat; | ||
stat: Stat; | ||
realpath?: RealPath; | ||
} | ||
declare interface FileSystemCallback<T> { | ||
(err?: null | (PossibleFileSystemError & Error), result?: T): any; | ||
type IBigIntStats = IStatsBase<bigint> & { | ||
atimeNs: bigint; | ||
mtimeNs: bigint; | ||
ctimeNs: bigint; | ||
birthtimeNs: bigint; | ||
}; | ||
declare interface IStats { | ||
isFile: () => boolean; | ||
isDirectory: () => boolean; | ||
isBlockDevice: () => boolean; | ||
isCharacterDevice: () => boolean; | ||
isSymbolicLink: () => boolean; | ||
isFIFO: () => boolean; | ||
isSocket: () => boolean; | ||
dev: number; | ||
ino: number; | ||
mode: number; | ||
nlink: number; | ||
uid: number; | ||
gid: number; | ||
rdev: number; | ||
size: number; | ||
blksize: number; | ||
blocks: number; | ||
atimeMs: number; | ||
mtimeMs: number; | ||
ctimeMs: number; | ||
birthtimeMs: number; | ||
atime: Date; | ||
mtime: Date; | ||
ctime: Date; | ||
birthtime: Date; | ||
} | ||
declare interface FileSystemDirent { | ||
name: string | Buffer; | ||
isDirectory: () => boolean; | ||
declare interface IStatsBase<T> { | ||
isFile: () => boolean; | ||
} | ||
declare interface FileSystemStats { | ||
isDirectory: () => boolean; | ||
isFile: () => boolean; | ||
isBlockDevice: () => boolean; | ||
isCharacterDevice: () => boolean; | ||
isSymbolicLink: () => boolean; | ||
isFIFO: () => boolean; | ||
isSocket: () => boolean; | ||
dev: T; | ||
ino: T; | ||
mode: T; | ||
nlink: T; | ||
uid: T; | ||
gid: T; | ||
rdev: T; | ||
size: T; | ||
blksize: T; | ||
blocks: T; | ||
atimeMs: T; | ||
mtimeMs: T; | ||
ctimeMs: T; | ||
birthtimeMs: T; | ||
atime: Date; | ||
mtime: Date; | ||
ctime: Date; | ||
birthtime: Date; | ||
} | ||
@@ -262,2 +267,47 @@ declare interface Iterator<T, Z> { | ||
} | ||
declare interface LStat { | ||
( | ||
path: PathLike, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: IStats) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: undefined | (StatOptions & { bigint?: false }), | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: IStats) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: StatOptions & { bigint: true }, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: IBigIntStats) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: undefined | StatOptions, | ||
callback: ( | ||
arg0: null | NodeJS.ErrnoException, | ||
arg1?: IStats | IBigIntStats | ||
) => void | ||
): void; | ||
} | ||
declare interface LStatSync { | ||
(path: PathLike, options?: undefined): IStats; | ||
( | ||
path: PathLike, | ||
options?: StatSyncOptions & { bigint?: false; throwIfNoEntry: false } | ||
): undefined | IStats; | ||
( | ||
path: PathLike, | ||
options: StatSyncOptions & { bigint: true; throwIfNoEntry: false } | ||
): undefined | IBigIntStats; | ||
(path: PathLike, options?: StatSyncOptions & { bigint?: false }): IStats; | ||
(path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats; | ||
( | ||
path: PathLike, | ||
options: StatSyncOptions & { bigint: boolean; throwIfNoEntry?: false } | ||
): IStats | IBigIntStats; | ||
(path: PathLike, options?: StatSyncOptions): | ||
| undefined | ||
| IStats | ||
| IBigIntStats; | ||
} | ||
declare class LogInfoPlugin { | ||
@@ -280,2 +330,18 @@ constructor( | ||
} | ||
declare interface ObjectEncodingOptions { | ||
encoding?: | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex"; | ||
} | ||
declare interface ParsedIdentifier { | ||
@@ -290,2 +356,4 @@ request: string; | ||
} | ||
type PathLike = string | Buffer | URL_url; | ||
type PathOrFileDescriptor = string | number | Buffer | URL_url; | ||
type Plugin = | ||
@@ -299,3 +367,3 @@ | undefined | ||
| ((this: Resolver, arg1: Resolver) => void); | ||
declare interface PnpApiImpl { | ||
declare interface PnpApi { | ||
resolveToUnqualified: ( | ||
@@ -307,29 +375,308 @@ arg0: string, | ||
} | ||
declare interface PossibleFileSystemError { | ||
code?: string; | ||
errno?: number; | ||
path?: string; | ||
syscall?: string; | ||
declare interface ReadFile { | ||
( | ||
path: PathOrFileDescriptor, | ||
options: | ||
| undefined | ||
| null | ||
| ({ encoding?: null; flag?: string } & Abortable), | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer) => void | ||
): void; | ||
( | ||
path: PathOrFileDescriptor, | ||
options: | ||
| ({ encoding: BufferEncoding; flag?: string } & Abortable) | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex", | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void | ||
): void; | ||
( | ||
path: PathOrFileDescriptor, | ||
options: | ||
| undefined | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| (ObjectEncodingOptions & { flag?: string } & Abortable), | ||
callback: ( | ||
arg0: null | NodeJS.ErrnoException, | ||
arg1?: string | Buffer | ||
) => void | ||
): void; | ||
( | ||
path: PathOrFileDescriptor, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer) => void | ||
): void; | ||
} | ||
declare interface ReaddirOptions { | ||
encoding?: | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| "buffer"; | ||
withFileTypes?: boolean; | ||
declare interface ReadFileSync { | ||
( | ||
path: PathOrFileDescriptor, | ||
options?: null | { encoding?: null; flag?: string } | ||
): Buffer; | ||
( | ||
path: PathOrFileDescriptor, | ||
options: | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| { encoding: BufferEncoding; flag?: string } | ||
): string; | ||
( | ||
path: PathOrFileDescriptor, | ||
options?: | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| (ObjectEncodingOptions & { flag?: string }) | ||
): string | Buffer; | ||
} | ||
/** | ||
* Resolve context | ||
*/ | ||
declare interface Readdir { | ||
( | ||
path: PathLike, | ||
options: | ||
| undefined | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| { | ||
encoding: | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex"; | ||
withFileTypes?: false; | ||
recursive?: boolean; | ||
}, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: string[]) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: | ||
| { encoding: "buffer"; withFileTypes?: false; recursive?: boolean } | ||
| "buffer", | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer[]) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: string[]) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: | ||
| undefined | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| (ObjectEncodingOptions & { | ||
withFileTypes?: false; | ||
recursive?: boolean; | ||
}), | ||
callback: ( | ||
arg0: null | NodeJS.ErrnoException, | ||
arg1?: string[] | Buffer[] | ||
) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: ObjectEncodingOptions & { | ||
withFileTypes: true; | ||
recursive?: boolean; | ||
}, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: Dirent[]) => void | ||
): void; | ||
} | ||
declare interface ReaddirSync { | ||
( | ||
path: PathLike, | ||
options?: | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| { | ||
encoding: | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex"; | ||
withFileTypes?: false; | ||
recursive?: boolean; | ||
} | ||
): string[]; | ||
( | ||
path: PathLike, | ||
options: | ||
| "buffer" | ||
| { encoding: "buffer"; withFileTypes?: false; recursive?: boolean } | ||
): Buffer[]; | ||
( | ||
path: PathLike, | ||
options?: | ||
| null | ||
| "ascii" | ||
| "utf8" | ||
| "utf-8" | ||
| "utf16le" | ||
| "utf-16le" | ||
| "ucs2" | ||
| "ucs-2" | ||
| "base64" | ||
| "base64url" | ||
| "latin1" | ||
| "binary" | ||
| "hex" | ||
| (ObjectEncodingOptions & { withFileTypes?: false; recursive?: boolean }) | ||
): string[] | Buffer[]; | ||
( | ||
path: PathLike, | ||
options: ObjectEncodingOptions & { | ||
withFileTypes: true; | ||
recursive?: boolean; | ||
} | ||
): Dirent[]; | ||
} | ||
declare interface Readlink { | ||
( | ||
path: PathLike, | ||
options: EncodingOption, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: BufferEncodingOption, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: EncodingOption, | ||
callback: ( | ||
arg0: null | NodeJS.ErrnoException, | ||
arg1?: string | Buffer | ||
) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void | ||
): void; | ||
} | ||
declare interface ReadlinkSync { | ||
(path: PathLike, options?: EncodingOption): string; | ||
(path: PathLike, options: BufferEncodingOption): Buffer; | ||
(path: PathLike, options?: EncodingOption): string | Buffer; | ||
} | ||
declare interface RealPath { | ||
( | ||
path: PathLike, | ||
options: EncodingOption, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: BufferEncodingOption, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: Buffer) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: EncodingOption, | ||
callback: ( | ||
arg0: null | NodeJS.ErrnoException, | ||
arg1?: string | Buffer | ||
) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void | ||
): void; | ||
} | ||
declare interface RealPathSync { | ||
(path: PathLike, options?: EncodingOption): string; | ||
(path: PathLike, options: BufferEncodingOption): Buffer; | ||
(path: PathLike, options?: EncodingOption): string | Buffer; | ||
} | ||
declare interface ResolveContext { | ||
@@ -409,3 +756,8 @@ contextDependencies?: WriteOnlySet<string>; | ||
} | ||
declare interface ResolveOptions { | ||
type ResolveOptionsOptionalFS = Omit< | ||
ResolveOptionsResolverFactoryObject_2, | ||
"fileSystem" | ||
> & | ||
Partial<Pick<ResolveOptionsResolverFactoryObject_2, "fileSystem">>; | ||
declare interface ResolveOptionsResolverFactoryObject_1 { | ||
alias: AliasOption[]; | ||
@@ -435,3 +787,3 @@ fallback: AliasOption[]; | ||
plugins: Plugin[]; | ||
pnpApi: null | PnpApiImpl; | ||
pnpApi: null | PnpApi; | ||
roots: Set<string>; | ||
@@ -444,61 +796,3 @@ fullySpecified: boolean; | ||
} | ||
type ResolveOptionsOptionalFS = Omit<UserResolveOptions, "fileSystem"> & | ||
Partial<Pick<UserResolveOptions, "fileSystem">>; | ||
type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>; | ||
declare abstract class Resolver { | ||
fileSystem: FileSystem; | ||
options: ResolveOptions; | ||
hooks: KnownHooks; | ||
ensureHook( | ||
name: | ||
| string | ||
| AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
> | ||
): AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
>; | ||
getHook( | ||
name: | ||
| string | ||
| AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
> | ||
): AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
>; | ||
resolveSync(context: object, path: string, request: string): string | false; | ||
resolve( | ||
context: object, | ||
path: string, | ||
request: string, | ||
resolveContext: ResolveContext, | ||
callback: ( | ||
err: null | ErrorWithDetail, | ||
res?: string | false, | ||
req?: ResolveRequest | ||
) => void | ||
): void; | ||
doResolve( | ||
hook: AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
>, | ||
request: ResolveRequest, | ||
message: null | string, | ||
resolveContext: ResolveContext, | ||
callback: (err?: null | Error, result?: ResolveRequest) => void | ||
): void; | ||
parse(identifier: string): ParsedIdentifier; | ||
isModule(path: string): boolean; | ||
isPrivate(path: string): boolean; | ||
isDirectory(path: string): boolean; | ||
join(path: string, request: string): string; | ||
normalize(path: string): string; | ||
} | ||
declare interface UserResolveOptions { | ||
declare interface ResolveOptionsResolverFactoryObject_2 { | ||
/** | ||
@@ -611,3 +905,3 @@ * A list of module alias configurations or an object which maps key to value | ||
*/ | ||
pnpApi?: null | PnpApiImpl; | ||
pnpApi?: null | PnpApi; | ||
@@ -649,2 +943,125 @@ /** | ||
} | ||
type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>; | ||
declare abstract class Resolver { | ||
fileSystem: FileSystem; | ||
options: ResolveOptionsResolverFactoryObject_1; | ||
hooks: KnownHooks; | ||
ensureHook( | ||
name: | ||
| string | ||
| AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
> | ||
): AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
>; | ||
getHook( | ||
name: | ||
| string | ||
| AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
> | ||
): AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
>; | ||
resolveSync(context: object, path: string, request: string): string | false; | ||
resolve( | ||
context: object, | ||
path: string, | ||
request: string, | ||
resolveContext: ResolveContext, | ||
callback: ( | ||
err: null | ErrorWithDetail, | ||
res?: string | false, | ||
req?: ResolveRequest | ||
) => void | ||
): void; | ||
doResolve( | ||
hook: AsyncSeriesBailHook< | ||
[ResolveRequest, ResolveContext], | ||
null | ResolveRequest | ||
>, | ||
request: ResolveRequest, | ||
message: null | string, | ||
resolveContext: ResolveContext, | ||
callback: (err?: null | Error, result?: ResolveRequest) => void | ||
): void; | ||
parse(identifier: string): ParsedIdentifier; | ||
isModule(path: string): boolean; | ||
isPrivate(path: string): boolean; | ||
isDirectory(path: string): boolean; | ||
join(path: string, request: string): string; | ||
normalize(path: string): string; | ||
} | ||
declare interface Stat { | ||
( | ||
path: PathLike, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: IStats) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: undefined | (StatOptions & { bigint?: false }), | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: IStats) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: StatOptions & { bigint: true }, | ||
callback: (arg0: null | NodeJS.ErrnoException, arg1?: IBigIntStats) => void | ||
): void; | ||
( | ||
path: PathLike, | ||
options: undefined | StatOptions, | ||
callback: ( | ||
arg0: null | NodeJS.ErrnoException, | ||
arg1?: IStats | IBigIntStats | ||
) => void | ||
): void; | ||
} | ||
declare interface StatOptions { | ||
bigint?: boolean; | ||
} | ||
declare interface StatSync { | ||
(path: PathLike, options?: undefined): IStats; | ||
( | ||
path: PathLike, | ||
options?: StatSyncOptions & { bigint?: false; throwIfNoEntry: false } | ||
): undefined | IStats; | ||
( | ||
path: PathLike, | ||
options: StatSyncOptions & { bigint: true; throwIfNoEntry: false } | ||
): undefined | IBigIntStats; | ||
(path: PathLike, options?: StatSyncOptions & { bigint?: false }): IStats; | ||
(path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats; | ||
( | ||
path: PathLike, | ||
options: StatSyncOptions & { bigint: boolean; throwIfNoEntry?: false } | ||
): IStats | IBigIntStats; | ||
(path: PathLike, options?: StatSyncOptions): | ||
| undefined | ||
| IStats | ||
| IBigIntStats; | ||
} | ||
declare interface StatSyncOptions { | ||
bigint?: boolean; | ||
throwIfNoEntry?: boolean; | ||
} | ||
declare interface SyncFileSystem { | ||
readFileSync: ReadFileSync; | ||
readdirSync: ReaddirSync; | ||
readJsonSync?: (arg0: PathOrFileDescriptor) => JsonObject; | ||
readlinkSync: ReadlinkSync; | ||
lstatSync?: LStatSync; | ||
statSync: StatSync; | ||
realpathSync?: RealPathSync; | ||
} | ||
/** | ||
* `URL` class is a global reference for `require('url').URL` | ||
* https://nodejs.org/api/url.html#the-whatwg-url-api | ||
*/ | ||
declare interface URL_url extends URL_Import {} | ||
declare interface WriteOnlySet<T> { | ||
@@ -702,3 +1119,5 @@ add: (item: T) => void; | ||
export namespace ResolverFactory { | ||
export let createResolver: (options: UserResolveOptions) => Resolver; | ||
export let createResolver: ( | ||
options: ResolveOptionsResolverFactoryObject_2 | ||
) => Resolver; | ||
} | ||
@@ -720,3 +1139,3 @@ export const forEachBail: <T, Z>( | ||
ResolveOptionsOptionalFS, | ||
PnpApiImpl as PnpApi, | ||
PnpApi, | ||
Resolver, | ||
@@ -727,3 +1146,3 @@ FileSystem, | ||
Plugin, | ||
UserResolveOptions as ResolveOptions, | ||
ResolveOptionsResolverFactoryObject_2 as ResolveOptions, | ||
ResolveFunctionAsync, | ||
@@ -730,0 +1149,0 @@ ResolveFunction |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
210424
6746
0