MCPcopy
hub / github.com/webpack/webpack / _resolveContextTsh

Method _resolveContextTsh

lib/FileSystemInfo.js:4310–4369  ·  lib/FileSystemInfo.js::FileSystemInfo._resolveContextTsh

* Resolve context tsh. * @private * @param {ContextTimestampAndHash} entry entry * @param {ProcessorCallback<ResolvedContextTimestampAndHash>} callback callback * @returns {void}

(entry, callback)

Source from the content-addressed store, hash-verified

4308 * @returns {void}
4309 */
4310 _resolveContextTsh(entry, callback) {
4311 /** @type {string[]} */
4312 const hashes = [];
4313 /** @type {string[]} */
4314 const tsHashes = [];
4315 let safeTime = 0;
4316 class="cm">// Skip already-visited symlink targets so cyclic pnpm/peer-variant graphs terminate (#21084).
4317 const seen = new Set(entry.symlinks);
4318 processAsyncTree(
4319 /** @type {NonNullable<ContextHash[class="st">"symlinks"]>} */ (entry.symlinks),
4320 10,
4321 (target, push, callback) => {
4322 this._getUnresolvedContextTsh(target, (err, entry) => {
4323 if (err) return callback(err);
4324 if (entry) {
4325 hashes.push(entry.hash);
4326 if (entry.timestampHash) tsHashes.push(entry.timestampHash);
4327 if (entry.safeTime) {
4328 safeTime = Math.max(safeTime, entry.safeTime);
4329 }
4330 if (entry.symlinks !== undefined) {
4331 for (const target of entry.symlinks) {
4332 if (!seen.has(target)) {
4333 seen.add(target);
4334 push(target);
4335 }
4336 }
4337 }
4338 }
4339 callback();
4340 });
4341 },
4342 (err) => {
4343 if (err) return callback(/** @type {WebpackError} */ (err));
4344 const hash = createHash(this._hashFunction);
4345 const tsHash = createHash(this._hashFunction);
4346 hash.update(entry.hash);
4347 if (entry.timestampHash) tsHash.update(entry.timestampHash);
4348 if (entry.safeTime) {
4349 safeTime = Math.max(safeTime, entry.safeTime);
4350 }
4351 hashes.sort();
4352 for (const h of hashes) {
4353 hash.update(h);
4354 }
4355 tsHashes.sort();
4356 for (const h of tsHashes) {
4357 tsHash.update(h);
4358 }
4359 callback(
4360 null,
4361 (entry.resolved = {
4362 safeTime,
4363 timestampHash: tsHash.digest(class="st">"hex"),
4364 hash: hash.digest(class="st">"hex")
4365 })
4366 );
4367 }

Callers 2

getContextTshMethod · 0.95

Calls 11

processAsyncTreeFunction · 0.85
createHashFunction · 0.85
sortMethod · 0.80
callbackFunction · 0.50
pushFunction · 0.50
pushMethod · 0.45
hasMethod · 0.45
addMethod · 0.45
updateMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected