| | |
| | | /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ |
| | | /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ |
| | | /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */ |
| | | /** @typedef {import("./util/fs").JsonObject} JsonObject */ |
| | | /** @typedef {import("./util/fs").IStats} IStats */ |
| | | /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ |
| | | /** |
| | | * Defines the processor callback type used by this module. |
| | | * @template T |
| | | * @typedef {import("./util/AsyncQueue").Callback<T>} ProcessorCallback |
| | | */ |
| | | /** |
| | | * Defines the processor type used by this module. |
| | | * @template T, R |
| | | * @typedef {import("./util/AsyncQueue").Processor<T, R>} Processor |
| | | */ |
| | |
| | | |
| | | let FS_ACCURACY = 2000; |
| | | |
| | | /** @type {Set<string>} */ |
| | | const EMPTY_SET = new Set(); |
| | | |
| | | const RBDT_RESOLVE_INITIAL = 0; |
| | |
| | | |
| | | const INVALID = Symbol("invalid"); |
| | | |
| | | // eslint-disable-next-line jsdoc/ts-no-empty-object-type |
| | | /** @typedef {{ }} ExistenceOnlyTimeEntry */ |
| | | |
| | | /** |
| | | * Defines the file system info entry type used by this module. |
| | | * @typedef {object} FileSystemInfoEntry |
| | | * @property {number} safeTime |
| | | * @property {number=} timestamp |
| | | */ |
| | | |
| | | /** |
| | | * Defines the resolved context file system info entry type used by this module. |
| | | * @typedef {object} ResolvedContextFileSystemInfoEntry |
| | | * @property {number} safeTime |
| | | * @property {string=} timestampHash |
| | |
| | | /** @typedef {Set<string>} Symlinks */ |
| | | |
| | | /** |
| | | * Defines the context file system info entry type used by this module. |
| | | * @typedef {object} ContextFileSystemInfoEntry |
| | | * @property {number} safeTime |
| | | * @property {string=} timestampHash |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the timestamp and hash type used by this module. |
| | | * @typedef {object} TimestampAndHash |
| | | * @property {number} safeTime |
| | | * @property {number=} timestamp |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the resolved context timestamp and hash type used by this module. |
| | | * @typedef {object} ResolvedContextTimestampAndHash |
| | | * @property {number} safeTime |
| | | * @property {string=} timestampHash |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the context timestamp and hash type used by this module. |
| | | * @typedef {object} ContextTimestampAndHash |
| | | * @property {number} safeTime |
| | | * @property {string=} timestampHash |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the context hash type used by this module. |
| | | * @typedef {object} ContextHash |
| | | * @property {string} hash |
| | | * @property {string=} resolved |
| | |
| | | /** @typedef {Set<string>} SnapshotContent */ |
| | | |
| | | /** |
| | | * Defines the snapshot optimization entry type used by this module. |
| | | * @typedef {object} SnapshotOptimizationEntry |
| | | * @property {Snapshot} snapshot |
| | | * @property {number} shared |
| | |
| | | /** @typedef {Set<string>} Missing */ |
| | | |
| | | /** |
| | | * Defines the resolve dependencies type used by this module. |
| | | * @typedef {object} ResolveDependencies |
| | | * @property {Files} files list of files |
| | | * @property {Directories} directories list of directories |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the resolve build dependencies result type used by this module. |
| | | * @typedef {object} ResolveBuildDependenciesResult |
| | | * @property {Files} files list of files |
| | | * @property {Directories} directories list of directories |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the snapshot options type used by this module. |
| | | * @typedef {object} SnapshotOptions |
| | | * @property {boolean=} hash should use hash to snapshot |
| | | * @property {boolean=} timestamp should use timestamp to snapshot |
| | |
| | | |
| | | class SnapshotIterator { |
| | | /** |
| | | * Creates an instance of SnapshotIterator. |
| | | * @param {() => IteratorResult<string>} next next |
| | | */ |
| | | constructor(next) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Defines the get maps function type used by this module. |
| | | * @template T |
| | | * @typedef {(snapshot: Snapshot) => T[]} GetMapsFunction |
| | | */ |
| | | |
| | | /** |
| | | * Represents SnapshotIterable. |
| | | * @template T |
| | | */ |
| | | class SnapshotIterable { |
| | | /** |
| | | * Creates an instance of SnapshotIterable. |
| | | * @param {Snapshot} snapshot snapshot |
| | | * @param {GetMapsFunction<T>} getMaps get maps function |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates start time using the provided value. |
| | | * @param {number} value start value |
| | | */ |
| | | setStartTime(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets merged start time. |
| | | * @param {number | undefined} value value |
| | | * @param {Snapshot} snapshot snapshot |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets file timestamps. |
| | | * @param {FileTimestamps} value file timestamps |
| | | */ |
| | | setFileTimestamps(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates file hashes using the provided value. |
| | | * @param {FileHashes} value file hashes |
| | | */ |
| | | setFileHashes(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates file tshs using the provided value. |
| | | * @param {FileTshs} value file tshs |
| | | */ |
| | | setFileTshs(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets context timestamps. |
| | | * @param {ContextTimestamps} value context timestamps |
| | | */ |
| | | setContextTimestamps(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets context hashes. |
| | | * @param {ContextHashes} value context hashes |
| | | */ |
| | | setContextHashes(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates context tshs using the provided value. |
| | | * @param {ContextTshs} value context tshs |
| | | */ |
| | | setContextTshs(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets missing existence. |
| | | * @param {MissingExistence} value context tshs |
| | | */ |
| | | setMissingExistence(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets managed item info. |
| | | * @param {ManagedItemInfo} value managed item info |
| | | */ |
| | | setManagedItemInfo(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets managed files. |
| | | * @param {ManagedFiles} value managed files |
| | | */ |
| | | setManagedFiles(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets managed contexts. |
| | | * @param {ManagedContexts} value managed contexts |
| | | */ |
| | | setManagedContexts(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets managed missing. |
| | | * @param {ManagedMissing} value managed missing |
| | | */ |
| | | setManagedMissing(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates children using the provided value. |
| | | * @param {Children} value children |
| | | */ |
| | | setChildren(value) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds the provided child to the snapshot. |
| | | * @param {Snapshot} child children |
| | | */ |
| | | addChild(child) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Serializes this instance into the provided serializer context. |
| | | * @param {ObjectSerializerContext} context context |
| | | */ |
| | | serialize({ write }) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | */ |
| | | deserialize({ read }) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates an iterable from the provided get map. |
| | | * @template T |
| | | * @param {GetMapsFunction<T>} getMaps first |
| | | * @returns {SnapshotIterable<T>} iterable |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets file iterable. |
| | | * @returns {Iterable<string>} iterable |
| | | */ |
| | | getFileIterable() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets context iterable. |
| | | * @returns {Iterable<string>} iterable |
| | | */ |
| | | getContextIterable() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets missing iterable. |
| | | * @returns {Iterable<string>} iterable |
| | | */ |
| | | getMissingIterable() { |
| | |
| | | const MIN_COMMON_SNAPSHOT_SIZE = 3; |
| | | |
| | | /** |
| | | * Defines the snapshot optimization value type used by this module. |
| | | * @template U, T |
| | | * @typedef {U extends true ? Set<string> : Map<string, T>} SnapshotOptimizationValue |
| | | */ |
| | | |
| | | /** |
| | | * Represents SnapshotOptimization. |
| | | * @template T |
| | | * @template {boolean} [U=false] |
| | | */ |
| | | class SnapshotOptimization { |
| | | /** |
| | | * Creates an instance of SnapshotOptimization. |
| | | * @param {(snapshot: Snapshot) => boolean} has has value |
| | | * @param {(snapshot: Snapshot) => SnapshotOptimizationValue<U, T> | undefined} get get value |
| | | * @param {(snapshot: Snapshot, value: SnapshotOptimizationValue<U, T>) => void} set set value |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided new snapshot. |
| | | * @param {Snapshot} newSnapshot snapshot |
| | | * @param {Set<string>} capturedFiles files to snapshot/share |
| | | * @returns {void} |
| | |
| | | return; |
| | | } |
| | | /** |
| | | * Increase shared and store optimization entry. |
| | | * @param {SnapshotOptimizationEntry} entry optimization entry |
| | | * @returns {void} |
| | | */ |
| | |
| | | storeOptimizationEntry(entry); |
| | | }; |
| | | /** |
| | | * Stores optimization entry. |
| | | * @param {SnapshotOptimizationEntry} entry optimization entry |
| | | * @returns {void} |
| | | */ |
| | |
| | | continue; |
| | | } |
| | | // Extract common timestamps from both snapshots |
| | | /** @type {Set<string> | Map<string, T>} */ |
| | | let commonMap; |
| | | if (this._isSet) { |
| | | commonMap = new Set(); |
| | |
| | | // Incomplete snapshot, that can't be used |
| | | continue; |
| | | } |
| | | /** @type {Set<string> | Map<string, T>} */ |
| | | let commonMap; |
| | | if (this._isSet) { |
| | | commonMap = new Set(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns result. |
| | | * @param {string} str input |
| | | * @returns {string} result |
| | | */ |
| | |
| | | |
| | | /* istanbul ignore next */ |
| | | /** |
| | | * Processes the provided mtime. |
| | | * @param {number} mtime mtime |
| | | */ |
| | | const applyMtime = (mtime) => { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Merges the provided values into a single result. |
| | | * @template T |
| | | * @template K |
| | | * @param {Map<T, K> | undefined} a source map |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Merges the provided values into a single result. |
| | | * @template T |
| | | * @param {Set<T> | undefined} a source map |
| | | * @param {Set<T> | undefined} b joining map |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Gets resolved timestamp. |
| | | * @template {ContextFileSystemInfoEntry | ContextTimestampAndHash} T |
| | | * @param {T | null} entry entry |
| | | * @returns {T["resolved"] | null | undefined} the resolved entry |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Gets resolved hash. |
| | | * @param {ContextHash | null} entry entry |
| | | * @returns {string | null | undefined} the resolved entry |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Adds the provided source to the snapshot optimization. |
| | | * @template T |
| | | * @param {Set<T>} source source |
| | | * @param {Set<T>} target target |
| | |
| | | */ |
| | | class FileSystemInfo { |
| | | /** |
| | | * Creates an instance of FileSystemInfo. |
| | | * @param {InputFileSystem} fs file system |
| | | * @param {object} options options |
| | | * @param {Iterable<string | RegExp>=} options.unmanagedPaths paths that are not managed by a package manager and the contents are subject to change |
| | |
| | | logStatistics() { |
| | | const logger = /** @type {Logger} */ (this.logger); |
| | | /** |
| | | * Processes the provided header. |
| | | * @param {string} header header |
| | | * @param {string | undefined} message message |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided path. |
| | | * @private |
| | | * @param {string} path path |
| | | * @param {string} reason reason |
| | |
| | | } |
| | | |
| | | /** |
| | | * @param {ReadonlyMap<string, FileTimestamp>} map timestamps |
| | | * Adds file timestamps. |
| | | * @param {ReadonlyMap<string, FileSystemInfoEntry | ExistenceOnlyTimeEntry | "ignore" | null>} map timestamps |
| | | * @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it |
| | | * @returns {void} |
| | | */ |
| | | addFileTimestamps(map, immutable) { |
| | | this._fileTimestamps.addAll(map, immutable); |
| | | this._fileTimestamps.addAll( |
| | | /** @type {ReadonlyMap<string, FileTimestamp>} */ |
| | | (map), |
| | | immutable |
| | | ); |
| | | this._cachedDeprecatedFileTimestamps = undefined; |
| | | } |
| | | |
| | | /** |
| | | * @param {ReadonlyMap<string, ContextTimestamp>} map timestamps |
| | | * Adds context timestamps. |
| | | * @param {ReadonlyMap<string, ContextFileSystemInfoEntry | ExistenceOnlyTimeEntry | "ignore" | null>} map timestamps |
| | | * @param {boolean=} immutable if 'map' is immutable and FileSystemInfo can keep referencing it |
| | | * @returns {void} |
| | | */ |
| | | addContextTimestamps(map, immutable) { |
| | | this._contextTimestamps.addAll(map, immutable); |
| | | this._contextTimestamps.addAll( |
| | | /** @type {ReadonlyMap<string, ContextTimestamp>} */ |
| | | (map), |
| | | immutable |
| | | ); |
| | | this._cachedDeprecatedContextTimestamps = undefined; |
| | | } |
| | | |
| | | /** |
| | | * Gets file timestamp. |
| | | * @param {string} path file path |
| | | * @param {(err?: WebpackError | null, fileTimestamp?: FileTimestamp) => void} callback callback function |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets context timestamp. |
| | | * @param {string} path context path |
| | | * @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback function |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get unresolved context timestamp. |
| | | * @private |
| | | * @param {string} path context path |
| | | * @param {(err?: WebpackError | null, contextTimestamp?: ContextTimestamp) => void} callback callback function |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns file hash. |
| | | * @param {string} path file path |
| | | * @param {(err?: WebpackError | null, hash?: string | null) => void} callback callback function |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns context hash. |
| | | * @param {string} path context path |
| | | * @param {(err?: WebpackError | null, contextHash?: string) => void} callback callback function |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get unresolved context hash. |
| | | * @private |
| | | * @param {string} path context path |
| | | * @param {(err?: WebpackError | null, contextHash?: ContextHash | null) => void} callback callback function |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns context tsh. |
| | | * @param {string} path context path |
| | | * @param {(err?: WebpackError | null, resolvedContextTimestampAndHash?: ResolvedContextTimestampAndHash | null) => void} callback callback function |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get unresolved context tsh. |
| | | * @private |
| | | * @param {string} path context path |
| | | * @param {(err?: WebpackError | null, contextTimestampAndHash?: ContextTimestampAndHash | null) => void} callback callback function |
| | |
| | | } |
| | | |
| | | /** |
| | | * Resolves build dependencies. |
| | | * @param {string} context context directory |
| | | * @param {Iterable<string>} deps dependencies |
| | | * @param {(err?: Error | null, resolveBuildDependenciesResult?: ResolveBuildDependenciesResult) => void} callback callback function |
| | |
| | | missingDependencies: resolveMissing |
| | | }; |
| | | /** |
| | | * Expected to string. |
| | | * @param {undefined | boolean | string} expected expected result |
| | | * @returns {string} expected result |
| | | */ |
| | |
| | | /** @typedef {{ type: JobType, context: string | undefined, path: string, issuer: Job | undefined, expected: undefined | boolean | string }} Job */ |
| | | |
| | | /** |
| | | * Returns result. |
| | | * @param {Job} job job |
| | | * @returns {string} result |
| | | */ |
| | |
| | | return `unknown ${job.type} ${job.path}`; |
| | | }; |
| | | /** |
| | | * Returns string value. |
| | | * @param {Job} job job |
| | | * @returns {string} string value |
| | | */ |
| | |
| | | (job, push, callback) => { |
| | | const { type, context, path, expected } = job; |
| | | /** |
| | | * Resolves directory. |
| | | * @param {string} path path |
| | | * @returns {void} |
| | | */ |
| | |
| | | ); |
| | | }; |
| | | /** |
| | | * Processes the provided path. |
| | | * @param {string} path path |
| | | * @param {("f" | "c" | "e")=} symbol symbol |
| | | * @param {(ResolveFunctionAsync)=} resolve resolve fn |
| | |
| | | break; |
| | | } |
| | | case RBDT_RESOLVE_DIRECTORY: { |
| | | resolveDirectory(RBDT_RESOLVE_INITIAL ? path.slice(0, -1) : path); |
| | | resolveDirectory( |
| | | type === RBDT_RESOLVE_INITIAL ? path.slice(0, -1) : path |
| | | ); |
| | | break; |
| | | } |
| | | case RBDT_RESOLVE_CJS_FILE: { |
| | |
| | | for (const modulePath of module.paths) { |
| | | if (childPath.startsWith(modulePath)) { |
| | | const subPath = childPath.slice(modulePath.length + 1); |
| | | const packageMatch = /^(@[^\\/]+[\\/])[^\\/]+/.exec( |
| | | const packageMatch = /^@[^\\/]+[\\/][^\\/]+/.exec( |
| | | subPath |
| | | ); |
| | | if (packageMatch) { |
| | |
| | | const context = dirname(this.fs, path); |
| | | const source = /** @type {Buffer} */ (content).toString(); |
| | | const [imports] = lexer.parse(source); |
| | | /** @type {Set<string>} */ |
| | | const added = new Set(); |
| | | for (const imp of imports) { |
| | | try { |
| | | /** @type {string} */ |
| | | let dependency; |
| | | if (imp.d === -1) { |
| | | // import ... from "..." |
| | |
| | | return callback(err); |
| | | } |
| | | resolveFiles.add(packageJson); |
| | | /** @type {JsonObject} */ |
| | | let packageData; |
| | | try { |
| | | packageData = JSON.parse( |
| | |
| | | } |
| | | const depsObject = packageData.dependencies; |
| | | const optionalDepsObject = packageData.optionalDependencies; |
| | | /** @type {Set<string>} */ |
| | | const allDeps = new Set(); |
| | | /** @type {Set<string>} */ |
| | | const optionalDeps = new Set(); |
| | | if (typeof depsObject === "object" && depsObject) { |
| | | for (const dep of Object.keys(depsObject)) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks resolve results valid. |
| | | * @param {ResolveResults} resolveResults results from resolving |
| | | * @param {(err?: Error | null, result?: boolean) => void} callback callback with true when resolveResults resolve the same way |
| | | * @returns {void} |
| | |
| | | } |
| | | }, |
| | | /** |
| | | * Processes the provided err. |
| | | * @param {Error | typeof INVALID=} err error or invalid flag |
| | | * @returns {void} |
| | | */ |
| | | /** @type {import("neo-async").ErrorCallback<Error | typeof INVALID>} */ ( |
| | | (err) => { |
| | | if (err === INVALID) { |
| | | return callback(null, false); |
| | |
| | | } |
| | | return callback(null, true); |
| | | } |
| | | ) |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * Creates a snapshot. |
| | | * @param {number | null | undefined} startTime when processing the files has started |
| | | * @param {Iterable<string> | null | undefined} files all files |
| | | * @param {Iterable<string> | null | undefined} directories all directories |
| | |
| | | } |
| | | }; |
| | | /** |
| | | * Checks true when managed. |
| | | * @param {string} path path |
| | | * @param {ManagedFiles} managedSet managed set |
| | | * @returns {boolean} true when managed |
| | |
| | | return false; |
| | | }; |
| | | /** |
| | | * Capture non managed. |
| | | * @param {Iterable<string>} items items |
| | | * @param {Set<string>} managedSet managed set |
| | | * @returns {Set<string>} result |
| | |
| | | return capturedItems; |
| | | }; |
| | | /** |
| | | * Process captured files. |
| | | * @param {ManagedFiles} capturedFiles captured files |
| | | */ |
| | | const processCapturedFiles = (capturedFiles) => { |
| | |
| | | processCapturedFiles(captureNonManaged(files, managedFiles)); |
| | | } |
| | | /** |
| | | * Process captured directories. |
| | | * @param {ManagedContexts} capturedDirectories captured directories |
| | | */ |
| | | const processCapturedDirectories = (capturedDirectories) => { |
| | |
| | | } else { |
| | | jobs++; |
| | | /** |
| | | * Processes the provided err. |
| | | * @param {(WebpackError | null)=} err error |
| | | * @param {(ResolvedContextTimestampAndHash | null)=} entry entry |
| | | * @returns {void} |
| | |
| | | ); |
| | | for (const path of capturedDirectories) { |
| | | const cache = this._contextHashes.get(path); |
| | | /** @type {undefined | null | string} */ |
| | | let resolved; |
| | | if ( |
| | | cache !== undefined && |
| | |
| | | } else { |
| | | jobs++; |
| | | /** |
| | | * Processes the provided err. |
| | | * @param {(WebpackError | null)=} err err |
| | | * @param {string=} entry entry |
| | | */ |
| | |
| | | for (const path of capturedDirectories) { |
| | | const cache = this._contextTimestamps.get(path); |
| | | if (cache === "ignore") continue; |
| | | /** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */ |
| | | let resolved; |
| | | if ( |
| | | cache !== undefined && |
| | |
| | | } else { |
| | | jobs++; |
| | | /** |
| | | * Processes the provided err. |
| | | * @param {(Error | null)=} err error |
| | | * @param {FileTimestamp=} entry entry |
| | | * @returns {void} |
| | |
| | | ); |
| | | } |
| | | /** |
| | | * Process captured missing. |
| | | * @param {ManagedMissing} capturedMissing captured missing |
| | | */ |
| | | const processCapturedMissing = (capturedMissing) => { |
| | |
| | | } else { |
| | | // Fallback to normal snapshotting |
| | | /** |
| | | * Processes the provided set. |
| | | * @param {Set<string>} set set |
| | | * @param {(set: Set<string>) => void} fn fn |
| | | */ |
| | | const process = (set, fn) => { |
| | | if (set.size === 0) return; |
| | | /** @type {Set<string>} */ |
| | | const captured = new Set(); |
| | | for (const file of set) { |
| | | if (file.startsWith(path)) captured.add(file); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Merges the provided values into a single result. |
| | | * @param {Snapshot} snapshot1 a snapshot |
| | | * @param {Snapshot} snapshot2 a snapshot |
| | | * @returns {Snapshot} merged snapshot |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks snapshot valid. |
| | | * @param {Snapshot} snapshot the snapshot made |
| | | * @param {CheckSnapshotValidCallback} callback callback function |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Check snapshot valid no cache. |
| | | * @private |
| | | * @param {Snapshot} snapshot the snapshot made |
| | | * @param {CheckSnapshotValidCallback} callback callback function |
| | |
| | | } |
| | | }; |
| | | /** |
| | | * Invalid with error. |
| | | * @param {string} path path |
| | | * @param {WebpackError} err err |
| | | */ |
| | |
| | | invalid(); |
| | | }; |
| | | /** |
| | | * Checks true, if ok. |
| | | * @param {string} path file path |
| | | * @param {string | null} current current hash |
| | | * @param {string | null} snap snapshot hash |
| | |
| | | return true; |
| | | }; |
| | | /** |
| | | * Checks true, if ok. |
| | | * @param {string} path file path |
| | | * @param {boolean} current current entry |
| | | * @param {boolean} snap entry from snapshot |
| | |
| | | return true; |
| | | }; |
| | | /** |
| | | * Checks true, if ok. |
| | | * @param {string} path file path |
| | | * @param {FileSystemInfoEntry | null} c current entry |
| | | * @param {FileSystemInfoEntry | null} s entry from snapshot |
| | |
| | | return true; |
| | | }; |
| | | /** |
| | | * Checks true, if ok. |
| | | * @param {string} path file path |
| | | * @param {ResolvedContextFileSystemInfoEntry | null} c current entry |
| | | * @param {ResolvedContextFileSystemInfoEntry | null} s entry from snapshot |
| | |
| | | }; |
| | | if (snapshot.hasChildren()) { |
| | | /** |
| | | * Processes the provided err. |
| | | * @param {(WebpackError | null)=} err err |
| | | * @param {boolean=} result result |
| | | * @returns {void} |
| | |
| | | } |
| | | } |
| | | /** |
| | | * Process file hash snapshot. |
| | | * @param {string} path file path |
| | | * @param {string | null} hash hash |
| | | */ |
| | |
| | | for (const [path, ts] of contextTimestamps) { |
| | | const cache = this._contextTimestamps.get(path); |
| | | if (cache === "ignore") continue; |
| | | /** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */ |
| | | let resolved; |
| | | if ( |
| | | cache !== undefined && |
| | |
| | | } else { |
| | | jobs++; |
| | | /** |
| | | * Processes the provided err. |
| | | * @param {(WebpackError | null)=} err error |
| | | * @param {ResolvedContextTimestamp=} entry entry |
| | | * @returns {void} |
| | |
| | | } |
| | | } |
| | | /** |
| | | * Process context hash snapshot. |
| | | * @param {string} path path |
| | | * @param {string | null} hash hash |
| | | */ |
| | | const processContextHashSnapshot = (path, hash) => { |
| | | const cache = this._contextHashes.get(path); |
| | | /** @type {undefined | null | string} */ |
| | | let resolved; |
| | | if ( |
| | | cache !== undefined && |
| | |
| | | } else { |
| | | jobs++; |
| | | /** |
| | | * Processes the provided err. |
| | | * @param {(WebpackError | null)=} err err |
| | | * @param {string=} entry entry |
| | | * @returns {void} |
| | |
| | | } else { |
| | | const cache = this._contextTimestamps.get(path); |
| | | if (cache === "ignore") continue; |
| | | /** @type {undefined | null | ResolvedContextFileSystemInfoEntry} */ |
| | | let resolved; |
| | | if ( |
| | | cache !== undefined && |
| | | (resolved = getResolvedTimestamp(cache)) !== undefined |
| | | ) { |
| | | if ( |
| | | !checkContext( |
| | | path, |
| | | /** @type {ResolvedContextFileSystemInfoEntry | null} */ |
| | | (resolved), |
| | | tsh, |
| | | false |
| | | ) |
| | | ) { |
| | | if (!checkContext(path, resolved, tsh, false)) { |
| | | processContextHashSnapshot(path, tsh && tsh.hash); |
| | | } |
| | | } else { |
| | | jobs++; |
| | | /** |
| | | * Processes the provided err. |
| | | * @param {(WebpackError | null)=} err error |
| | | * @param {ResolvedContextTimestamp=} entry entry |
| | | * @returns {void} |
| | |
| | | return callback(/** @type {WebpackError} */ (err)); |
| | | } |
| | | const stat = /** @type {IStats} */ (_stat); |
| | | /** @type {FileSystemInfoEntry} */ |
| | | let ts; |
| | | if (stat.isDirectory()) { |
| | | ts = { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get file timestamp and hash. |
| | | * @private |
| | | * @param {string} path path |
| | | * @param {(err: WebpackError | null, timestampAndHash?: TimestampAndHash | string) => void} callback callback |
| | | */ |
| | | _getFileTimestampAndHash(path, callback) { |
| | | /** |
| | | * Continue with hash. |
| | | * @param {string} hash hash |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided object. |
| | | * @private |
| | | * @template T |
| | | * @template ItemType |
| | |
| | | }); |
| | | }, |
| | | reduce: (files, tsEntries) => { |
| | | /** @type {undefined | Symlinks} */ |
| | | let symlinks; |
| | | |
| | | const hash = createHash(this._hashFunction); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Resolve context timestamp. |
| | | * @private |
| | | * @param {ContextFileSystemInfoEntry} entry entry |
| | | * @param {(err?: WebpackError | null, resolvedContextTimestamp?: ResolvedContextTimestamp) => void} callback callback |
| | |
| | | }); |
| | | }, |
| | | /** |
| | | * Returns reduced hash. |
| | | * @param {string[]} files files |
| | | * @param {(string | ContextHash)[]} fileHashes hashes |
| | | * @returns {ContextHash} reduced hash |
| | | */ |
| | | reduce: (files, fileHashes) => { |
| | | /** @type {undefined | Symlinks} */ |
| | | let symlinks; |
| | | const hash = createHash(this._hashFunction); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Resolve context hash. |
| | | * @private |
| | | * @param {ContextHash} entry context hash |
| | | * @param {(err: WebpackError | null, contextHash?: string) => void} callback callback |
| | |
| | | */ |
| | | _readContextTimestampAndHash(path, callback) { |
| | | /** |
| | | * Processes the provided timestamp. |
| | | * @param {ContextTimestamp} timestamp timestamp |
| | | * @param {ContextHash} hash hash |
| | | */ |
| | |
| | | }); |
| | | }, |
| | | /** |
| | | * Returns tsh. |
| | | * @param {string[]} files files |
| | | * @param {(Partial<TimestampAndHash> & Partial<ContextTimestampAndHash> | string | null)[]} results results |
| | | * @returns {ContextTimestampAndHash} tsh |
| | | */ |
| | | reduce: (files, results) => { |
| | | /** @type {undefined | Symlinks} */ |
| | | let symlinks; |
| | | |
| | | const tsHash = createHash(this._hashFunction); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Resolve context tsh. |
| | | * @private |
| | | * @param {ContextTimestampAndHash} entry entry |
| | | * @param {ProcessorCallback<ResolvedContextTimestampAndHash>} callback callback |
| | |
| | | return callback(/** @type {WebpackError} */ (err)); |
| | | } |
| | | const set = new Set( |
| | | /** @type {string[]} */ (elements).map((element) => |
| | | join(this.fs, path, element) |
| | | ) |
| | | /** @type {string[]} */ |
| | | (elements).map((element) => join(this.fs, path, element)) |
| | | ); |
| | | callback(null, set); |
| | | }); |
| | |
| | | } |
| | | return callback(/** @type {WebpackError} */ (err)); |
| | | } |
| | | /** @type {JsonObject} */ |
| | | let data; |
| | | try { |
| | | data = JSON.parse(/** @type {Buffer} */ (content).toString("utf8")); |