@antongolub/lockfile 0.0.0-snapshot.51 → 0.0.0-snapshot.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1329,6 +1329,14 @@ function resolutionPinUnresolvedDiagnostic(prefix, subject, depName, range) {
1329
1329
  message: `dependency ${depName}=${range} from ${subject} has no exact or semver-satisfying entry \u2014 likely a resolutions pin to a non-satisfying descriptor; pass ParseOptions.manifests so the override map can bridge it`
1330
1330
  };
1331
1331
  }
1332
+ function patchPreferredDiagnostic(prefix, subject, depName, range, patchId) {
1333
+ return {
1334
+ code: `${prefix}_PATCH_PREFERRED`,
1335
+ severity: "info",
1336
+ subject,
1337
+ message: `dependency ${depName}=${range} from ${subject} redirected to sibling patch node ${patchId} (lock-borne patchedDependencies preference); base left GC-able`
1338
+ };
1339
+ }
1332
1340
  function emitDropped(nodeId, feature, reason, onDiagnostic) {
1333
1341
  if (onDiagnostic === void 0) return;
1334
1342
  onDiagnostic({
@@ -1380,6 +1388,16 @@ function semverResolve(range, candidates) {
1380
1388
  if (top.length === 1) return { kind: "bound", id: top[0] };
1381
1389
  return { kind: "ambiguous", candidateIds: top };
1382
1390
  }
1391
+ function distTagResolve(range, candidates) {
1392
+ const tag = registryRangeOf(range);
1393
+ if (tag === void 0) return { kind: "none" };
1394
+ if (semver.validRange(tag) !== null) return { kind: "none" };
1395
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1396
+ if (eligible.length === 0) return { kind: "none" };
1397
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1398
+ const ids = eligible.map((c) => c.id).sort(cmpStr2);
1399
+ return { kind: "ambiguous", candidateIds: ids };
1400
+ }
1383
1401
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1384
1402
  let best;
1385
1403
  let bestScore = -1;
@@ -1412,6 +1430,15 @@ function parentPathMatches(parentPath, consumerPath) {
1412
1430
  }
1413
1431
  return true;
1414
1432
  }
1433
+ function patchPreferenceFor(_name, _version, patchSiblings, consumerLocator) {
1434
+ if (patchSiblings.length === 0) return void 0;
1435
+ if (patchSiblings.length === 1) return patchSiblings[0].id;
1436
+ if (consumerLocator !== void 0) {
1437
+ const matches = patchSiblings.filter((s) => s.locatorQualifier === consumerLocator);
1438
+ if (matches.length === 1) return matches[0].id;
1439
+ }
1440
+ return void 0;
1441
+ }
1415
1442
  var cmpStr2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
1416
1443
  function readInstalledManifest(workspaceRoot, parentName, consumerNodeId) {
1417
1444
  return readInstalledManifestFrom([workspaceRoot], parentName);
@@ -1552,6 +1579,7 @@ function parseFamily(input, options, config) {
1552
1579
  const specIndex = /* @__PURE__ */ new Map();
1553
1580
  const patchDescriptorIndex = /* @__PURE__ */ new Map();
1554
1581
  const semverCandidatesByName = /* @__PURE__ */ new Map();
1582
+ const patchSiblingsByBase = /* @__PURE__ */ new Map();
1555
1583
  const seenIds = /* @__PURE__ */ new Set();
1556
1584
  const entryIds = /* @__PURE__ */ new Map();
1557
1585
  for (const { key, value, specs } of entries) {
@@ -1617,6 +1645,13 @@ function parseFamily(input, options, config) {
1617
1645
  const candidateList = semverCandidatesByName.get(authoritativeName);
1618
1646
  if (candidateList === void 0) semverCandidatesByName.set(authoritativeName, [semverCandidate]);
1619
1647
  else candidateList.push(semverCandidate);
1648
+ if (effectivePatch !== void 0 && resolution !== void 0 && isNpmBasePatchResolution(resolution, authoritativeName)) {
1649
+ const sibling = { id, locatorQualifier: locatorQualifierOfPatchResolution(resolution) };
1650
+ const baseKey = `${authoritativeName}@${version}`;
1651
+ const siblings = patchSiblingsByBase.get(baseKey);
1652
+ if (siblings === void 0) patchSiblingsByBase.set(baseKey, [sibling]);
1653
+ else siblings.push(sibling);
1654
+ }
1620
1655
  const peerDependencies = stringRecordOfBlock(asMap(value["peerDependencies"]));
1621
1656
  if (peerDependencies !== void 0) {
1622
1657
  rawPeerDependencies.set(id, peerDependencies);
@@ -1680,6 +1715,7 @@ function parseFamily(input, options, config) {
1680
1715
  }
1681
1716
  const ladderCtx = {
1682
1717
  candidatesByName: semverCandidatesByName,
1718
+ patchSiblingsByBase,
1683
1719
  overrides: options.overrides ?? [],
1684
1720
  codePrefix: config.codePrefix,
1685
1721
  manifestsProvided: options.overrides !== void 0
@@ -1774,6 +1810,7 @@ ${stringify(root)}`;
1774
1810
  output = unquoteMetadataScalar(output, "compressionLevel", compressionLevel);
1775
1811
  }
1776
1812
  output = unquoteConditionsScalars(output);
1813
+ output = unquoteMetaBooleanScalars(output);
1777
1814
  if (options.lineEnding === "crlf") {
1778
1815
  output = output.replace(/\n/g, "\r\n");
1779
1816
  }
@@ -2617,6 +2654,7 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2617
2654
  const normalizedRange = normalizedEdgeRange(kind, depRange);
2618
2655
  const lookup = `${depName}@${normalizedRange}`;
2619
2656
  let dstId = index.get(lookup);
2657
+ let boundViaOverride = false;
2620
2658
  if (dstId === void 0) {
2621
2659
  dstId = resolvePatchAndLinkFallbacks(
2622
2660
  lookup,
@@ -2646,7 +2684,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2646
2684
  );
2647
2685
  if (viaOverride === null) continue;
2648
2686
  }
2649
- if (viaOverride !== void 0) dstId = viaOverride;
2687
+ if (viaOverride !== void 0) {
2688
+ dstId = viaOverride;
2689
+ boundViaOverride = true;
2690
+ }
2650
2691
  }
2651
2692
  }
2652
2693
  if (dstId === void 0) {
@@ -2658,6 +2699,30 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2658
2699
  continue;
2659
2700
  }
2660
2701
  }
2702
+ if (dstId === void 0) {
2703
+ const result = distTagResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2704
+ if (result.kind === "bound") {
2705
+ dstId = result.id;
2706
+ } else if (result.kind === "ambiguous") {
2707
+ diagnostics.push(ambiguousResolutionDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, result.candidateIds));
2708
+ if (!ladder.manifestsProvided) {
2709
+ diagnostics.push(resolutionPinUnresolvedDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange));
2710
+ }
2711
+ continue;
2712
+ }
2713
+ }
2714
+ if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2715
+ const bound = nodeNameVersion(dstId);
2716
+ const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
2717
+ if (siblings !== void 0 && siblings.length > 0) {
2718
+ const consumerLocator = srcResolution !== void 0 ? encodeURIComponent(srcResolution) : void 0;
2719
+ const patchId = patchPreferenceFor(depName, normalizedRange, siblings, consumerLocator);
2720
+ if (patchId !== void 0 && patchId !== dstId) {
2721
+ dstId = patchId;
2722
+ diagnostics.push(patchPreferredDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, patchId));
2723
+ }
2724
+ }
2725
+ }
2661
2726
  if (!dstId) {
2662
2727
  diagnostics.push({
2663
2728
  code: "YARN_BERRY_UNRESOLVED_DEP",
@@ -2680,6 +2745,16 @@ function normalizedEdgeRange(kind, range) {
2680
2745
  if (kind === "peer") return range;
2681
2746
  return hasExplicitProtocol(range) ? range : `npm:${range}`;
2682
2747
  }
2748
+ function nodeNameVersion(id) {
2749
+ const name = nameOf(id);
2750
+ if (name.length >= id.length) return void 0;
2751
+ let rest = id.slice(name.length + 1);
2752
+ const parenIdx = rest.indexOf("(");
2753
+ if (parenIdx >= 0) rest = rest.slice(0, parenIdx);
2754
+ const plusIdx = rest.indexOf("+");
2755
+ if (plusIdx >= 0) rest = rest.slice(0, plusIdx);
2756
+ return rest.length > 0 ? `${name}@${rest}` : void 0;
2757
+ }
2683
2758
  function hasExplicitProtocol(range) {
2684
2759
  const colonIdx = range.indexOf(":");
2685
2760
  if (colonIdx <= 0) return false;
@@ -2709,6 +2784,17 @@ function locatorQualifierOfPatchSpec(spec) {
2709
2784
  }
2710
2785
  return void 0;
2711
2786
  }
2787
+ function isNpmBasePatchResolution(resolution, name) {
2788
+ const locator = patchLocatorOfResolution(resolution);
2789
+ if (locator === void 0) return false;
2790
+ const base = baseSpecOfPatchLocator(locator);
2791
+ return base !== void 0 && base.startsWith(`${name}@npm:`);
2792
+ }
2793
+ function locatorQualifierOfPatchResolution(resolution) {
2794
+ const locator = patchLocatorOfResolution(resolution);
2795
+ if (locator === void 0 || !locator.startsWith("patch:")) return void 0;
2796
+ return locatorQualifierOfPatchSpec(locator.slice("patch:".length));
2797
+ }
2712
2798
  function resolvePatchDescriptor(candidates, srcResolution, srcId, lookup, diagnostics) {
2713
2799
  if (candidates === void 0 || candidates.length === 0) return void 0;
2714
2800
  if (candidates.length === 1) return candidates[0].id;
@@ -2818,6 +2904,12 @@ function unquoteConditionsScalars(output) {
2818
2904
  (_m, key, body) => `${key}: ${body}`
2819
2905
  );
2820
2906
  }
2907
+ function unquoteMetaBooleanScalars(output) {
2908
+ return output.replace(
2909
+ /^( (?:optional|built|unplugged)): "(true|false)"$/gm,
2910
+ (_m, key, body) => `${key}: ${body}`
2911
+ );
2912
+ }
2821
2913
 
2822
2914
  // src/main/ts/formats/yarn-berry-v10.ts
2823
2915
  var CONFIG = {
@@ -1329,6 +1329,14 @@ function resolutionPinUnresolvedDiagnostic(prefix, subject, depName, range) {
1329
1329
  message: `dependency ${depName}=${range} from ${subject} has no exact or semver-satisfying entry \u2014 likely a resolutions pin to a non-satisfying descriptor; pass ParseOptions.manifests so the override map can bridge it`
1330
1330
  };
1331
1331
  }
1332
+ function patchPreferredDiagnostic(prefix, subject, depName, range, patchId) {
1333
+ return {
1334
+ code: `${prefix}_PATCH_PREFERRED`,
1335
+ severity: "info",
1336
+ subject,
1337
+ message: `dependency ${depName}=${range} from ${subject} redirected to sibling patch node ${patchId} (lock-borne patchedDependencies preference); base left GC-able`
1338
+ };
1339
+ }
1332
1340
  function emitDropped(nodeId, feature, reason, onDiagnostic) {
1333
1341
  if (onDiagnostic === void 0) return;
1334
1342
  onDiagnostic({
@@ -1380,6 +1388,16 @@ function semverResolve(range, candidates) {
1380
1388
  if (top.length === 1) return { kind: "bound", id: top[0] };
1381
1389
  return { kind: "ambiguous", candidateIds: top };
1382
1390
  }
1391
+ function distTagResolve(range, candidates) {
1392
+ const tag = registryRangeOf(range);
1393
+ if (tag === void 0) return { kind: "none" };
1394
+ if (semver.validRange(tag) !== null) return { kind: "none" };
1395
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1396
+ if (eligible.length === 0) return { kind: "none" };
1397
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1398
+ const ids = eligible.map((c) => c.id).sort(cmpStr2);
1399
+ return { kind: "ambiguous", candidateIds: ids };
1400
+ }
1383
1401
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1384
1402
  let best;
1385
1403
  let bestScore = -1;
@@ -1412,6 +1430,15 @@ function parentPathMatches(parentPath, consumerPath) {
1412
1430
  }
1413
1431
  return true;
1414
1432
  }
1433
+ function patchPreferenceFor(_name, _version, patchSiblings, consumerLocator) {
1434
+ if (patchSiblings.length === 0) return void 0;
1435
+ if (patchSiblings.length === 1) return patchSiblings[0].id;
1436
+ if (consumerLocator !== void 0) {
1437
+ const matches = patchSiblings.filter((s) => s.locatorQualifier === consumerLocator);
1438
+ if (matches.length === 1) return matches[0].id;
1439
+ }
1440
+ return void 0;
1441
+ }
1415
1442
  var cmpStr2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
1416
1443
  function readInstalledManifest(workspaceRoot, parentName, consumerNodeId) {
1417
1444
  return readInstalledManifestFrom([workspaceRoot], parentName);
@@ -1552,6 +1579,7 @@ function parseFamily(input, options, config) {
1552
1579
  const specIndex = /* @__PURE__ */ new Map();
1553
1580
  const patchDescriptorIndex = /* @__PURE__ */ new Map();
1554
1581
  const semverCandidatesByName = /* @__PURE__ */ new Map();
1582
+ const patchSiblingsByBase = /* @__PURE__ */ new Map();
1555
1583
  const seenIds = /* @__PURE__ */ new Set();
1556
1584
  const entryIds = /* @__PURE__ */ new Map();
1557
1585
  for (const { key, value, specs } of entries) {
@@ -1617,6 +1645,13 @@ function parseFamily(input, options, config) {
1617
1645
  const candidateList = semverCandidatesByName.get(authoritativeName);
1618
1646
  if (candidateList === void 0) semverCandidatesByName.set(authoritativeName, [semverCandidate]);
1619
1647
  else candidateList.push(semverCandidate);
1648
+ if (effectivePatch !== void 0 && resolution !== void 0 && isNpmBasePatchResolution(resolution, authoritativeName)) {
1649
+ const sibling = { id, locatorQualifier: locatorQualifierOfPatchResolution(resolution) };
1650
+ const baseKey = `${authoritativeName}@${version}`;
1651
+ const siblings = patchSiblingsByBase.get(baseKey);
1652
+ if (siblings === void 0) patchSiblingsByBase.set(baseKey, [sibling]);
1653
+ else siblings.push(sibling);
1654
+ }
1620
1655
  const peerDependencies = stringRecordOfBlock(asMap(value["peerDependencies"]));
1621
1656
  if (peerDependencies !== void 0) {
1622
1657
  rawPeerDependencies.set(id, peerDependencies);
@@ -1680,6 +1715,7 @@ function parseFamily(input, options, config) {
1680
1715
  }
1681
1716
  const ladderCtx = {
1682
1717
  candidatesByName: semverCandidatesByName,
1718
+ patchSiblingsByBase,
1683
1719
  overrides: options.overrides ?? [],
1684
1720
  codePrefix: config.codePrefix,
1685
1721
  manifestsProvided: options.overrides !== void 0
@@ -1774,6 +1810,7 @@ ${stringify(root)}`;
1774
1810
  output = unquoteMetadataScalar(output, "compressionLevel", compressionLevel);
1775
1811
  }
1776
1812
  output = unquoteConditionsScalars(output);
1813
+ output = unquoteMetaBooleanScalars(output);
1777
1814
  if (options.lineEnding === "crlf") {
1778
1815
  output = output.replace(/\n/g, "\r\n");
1779
1816
  }
@@ -2621,6 +2658,7 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2621
2658
  const normalizedRange = normalizedEdgeRange(kind, depRange);
2622
2659
  const lookup = `${depName}@${normalizedRange}`;
2623
2660
  let dstId = index.get(lookup);
2661
+ let boundViaOverride = false;
2624
2662
  if (dstId === void 0) {
2625
2663
  dstId = resolvePatchAndLinkFallbacks(
2626
2664
  lookup,
@@ -2650,7 +2688,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2650
2688
  );
2651
2689
  if (viaOverride === null) continue;
2652
2690
  }
2653
- if (viaOverride !== void 0) dstId = viaOverride;
2691
+ if (viaOverride !== void 0) {
2692
+ dstId = viaOverride;
2693
+ boundViaOverride = true;
2694
+ }
2654
2695
  }
2655
2696
  }
2656
2697
  if (dstId === void 0) {
@@ -2662,6 +2703,30 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2662
2703
  continue;
2663
2704
  }
2664
2705
  }
2706
+ if (dstId === void 0) {
2707
+ const result = distTagResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2708
+ if (result.kind === "bound") {
2709
+ dstId = result.id;
2710
+ } else if (result.kind === "ambiguous") {
2711
+ diagnostics.push(ambiguousResolutionDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, result.candidateIds));
2712
+ if (!ladder.manifestsProvided) {
2713
+ diagnostics.push(resolutionPinUnresolvedDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange));
2714
+ }
2715
+ continue;
2716
+ }
2717
+ }
2718
+ if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2719
+ const bound = nodeNameVersion(dstId);
2720
+ const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
2721
+ if (siblings !== void 0 && siblings.length > 0) {
2722
+ const consumerLocator = srcResolution !== void 0 ? encodeURIComponent(srcResolution) : void 0;
2723
+ const patchId = patchPreferenceFor(depName, normalizedRange, siblings, consumerLocator);
2724
+ if (patchId !== void 0 && patchId !== dstId) {
2725
+ dstId = patchId;
2726
+ diagnostics.push(patchPreferredDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, patchId));
2727
+ }
2728
+ }
2729
+ }
2665
2730
  if (!dstId) {
2666
2731
  diagnostics.push({
2667
2732
  code: "YARN_BERRY_UNRESOLVED_DEP",
@@ -2684,6 +2749,16 @@ function normalizedEdgeRange(kind, range) {
2684
2749
  if (kind === "peer") return range;
2685
2750
  return hasExplicitProtocol(range) ? range : `npm:${range}`;
2686
2751
  }
2752
+ function nodeNameVersion(id) {
2753
+ const name = nameOf(id);
2754
+ if (name.length >= id.length) return void 0;
2755
+ let rest = id.slice(name.length + 1);
2756
+ const parenIdx = rest.indexOf("(");
2757
+ if (parenIdx >= 0) rest = rest.slice(0, parenIdx);
2758
+ const plusIdx = rest.indexOf("+");
2759
+ if (plusIdx >= 0) rest = rest.slice(0, plusIdx);
2760
+ return rest.length > 0 ? `${name}@${rest}` : void 0;
2761
+ }
2687
2762
  function hasExplicitProtocol(range) {
2688
2763
  const colonIdx = range.indexOf(":");
2689
2764
  if (colonIdx <= 0) return false;
@@ -2713,6 +2788,17 @@ function locatorQualifierOfPatchSpec(spec) {
2713
2788
  }
2714
2789
  return void 0;
2715
2790
  }
2791
+ function isNpmBasePatchResolution(resolution, name) {
2792
+ const locator = patchLocatorOfResolution(resolution);
2793
+ if (locator === void 0) return false;
2794
+ const base = baseSpecOfPatchLocator(locator);
2795
+ return base !== void 0 && base.startsWith(`${name}@npm:`);
2796
+ }
2797
+ function locatorQualifierOfPatchResolution(resolution) {
2798
+ const locator = patchLocatorOfResolution(resolution);
2799
+ if (locator === void 0 || !locator.startsWith("patch:")) return void 0;
2800
+ return locatorQualifierOfPatchSpec(locator.slice("patch:".length));
2801
+ }
2716
2802
  function resolvePatchDescriptor(candidates, srcResolution, srcId, lookup, diagnostics) {
2717
2803
  if (candidates === void 0 || candidates.length === 0) return void 0;
2718
2804
  if (candidates.length === 1) return candidates[0].id;
@@ -2822,6 +2908,12 @@ function unquoteConditionsScalars(output) {
2822
2908
  (_m, key, body) => `${key}: ${body}`
2823
2909
  );
2824
2910
  }
2911
+ function unquoteMetaBooleanScalars(output) {
2912
+ return output.replace(
2913
+ /^( (?:optional|built|unplugged)): "(true|false)"$/gm,
2914
+ (_m, key, body) => `${key}: ${body}`
2915
+ );
2916
+ }
2825
2917
 
2826
2918
  // src/main/ts/formats/yarn-berry-v4.ts
2827
2919
  var CONFIG = {
@@ -1329,6 +1329,14 @@ function resolutionPinUnresolvedDiagnostic(prefix, subject, depName, range) {
1329
1329
  message: `dependency ${depName}=${range} from ${subject} has no exact or semver-satisfying entry \u2014 likely a resolutions pin to a non-satisfying descriptor; pass ParseOptions.manifests so the override map can bridge it`
1330
1330
  };
1331
1331
  }
1332
+ function patchPreferredDiagnostic(prefix, subject, depName, range, patchId) {
1333
+ return {
1334
+ code: `${prefix}_PATCH_PREFERRED`,
1335
+ severity: "info",
1336
+ subject,
1337
+ message: `dependency ${depName}=${range} from ${subject} redirected to sibling patch node ${patchId} (lock-borne patchedDependencies preference); base left GC-able`
1338
+ };
1339
+ }
1332
1340
  function emitDropped(nodeId, feature, reason, onDiagnostic) {
1333
1341
  if (onDiagnostic === void 0) return;
1334
1342
  onDiagnostic({
@@ -1380,6 +1388,16 @@ function semverResolve(range, candidates) {
1380
1388
  if (top.length === 1) return { kind: "bound", id: top[0] };
1381
1389
  return { kind: "ambiguous", candidateIds: top };
1382
1390
  }
1391
+ function distTagResolve(range, candidates) {
1392
+ const tag = registryRangeOf(range);
1393
+ if (tag === void 0) return { kind: "none" };
1394
+ if (semver.validRange(tag) !== null) return { kind: "none" };
1395
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1396
+ if (eligible.length === 0) return { kind: "none" };
1397
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1398
+ const ids = eligible.map((c) => c.id).sort(cmpStr2);
1399
+ return { kind: "ambiguous", candidateIds: ids };
1400
+ }
1383
1401
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1384
1402
  let best;
1385
1403
  let bestScore = -1;
@@ -1412,6 +1430,15 @@ function parentPathMatches(parentPath, consumerPath) {
1412
1430
  }
1413
1431
  return true;
1414
1432
  }
1433
+ function patchPreferenceFor(_name, _version, patchSiblings, consumerLocator) {
1434
+ if (patchSiblings.length === 0) return void 0;
1435
+ if (patchSiblings.length === 1) return patchSiblings[0].id;
1436
+ if (consumerLocator !== void 0) {
1437
+ const matches = patchSiblings.filter((s) => s.locatorQualifier === consumerLocator);
1438
+ if (matches.length === 1) return matches[0].id;
1439
+ }
1440
+ return void 0;
1441
+ }
1415
1442
  var cmpStr2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
1416
1443
  function readInstalledManifest(workspaceRoot, parentName, consumerNodeId) {
1417
1444
  return readInstalledManifestFrom([workspaceRoot], parentName);
@@ -1552,6 +1579,7 @@ function parseFamily(input, options, config) {
1552
1579
  const specIndex = /* @__PURE__ */ new Map();
1553
1580
  const patchDescriptorIndex = /* @__PURE__ */ new Map();
1554
1581
  const semverCandidatesByName = /* @__PURE__ */ new Map();
1582
+ const patchSiblingsByBase = /* @__PURE__ */ new Map();
1555
1583
  const seenIds = /* @__PURE__ */ new Set();
1556
1584
  const entryIds = /* @__PURE__ */ new Map();
1557
1585
  for (const { key, value, specs } of entries) {
@@ -1617,6 +1645,13 @@ function parseFamily(input, options, config) {
1617
1645
  const candidateList = semverCandidatesByName.get(authoritativeName);
1618
1646
  if (candidateList === void 0) semverCandidatesByName.set(authoritativeName, [semverCandidate]);
1619
1647
  else candidateList.push(semverCandidate);
1648
+ if (effectivePatch !== void 0 && resolution !== void 0 && isNpmBasePatchResolution(resolution, authoritativeName)) {
1649
+ const sibling = { id, locatorQualifier: locatorQualifierOfPatchResolution(resolution) };
1650
+ const baseKey = `${authoritativeName}@${version}`;
1651
+ const siblings = patchSiblingsByBase.get(baseKey);
1652
+ if (siblings === void 0) patchSiblingsByBase.set(baseKey, [sibling]);
1653
+ else siblings.push(sibling);
1654
+ }
1620
1655
  const peerDependencies = stringRecordOfBlock(asMap(value["peerDependencies"]));
1621
1656
  if (peerDependencies !== void 0) {
1622
1657
  rawPeerDependencies.set(id, peerDependencies);
@@ -1680,6 +1715,7 @@ function parseFamily(input, options, config) {
1680
1715
  }
1681
1716
  const ladderCtx = {
1682
1717
  candidatesByName: semverCandidatesByName,
1718
+ patchSiblingsByBase,
1683
1719
  overrides: options.overrides ?? [],
1684
1720
  codePrefix: config.codePrefix,
1685
1721
  manifestsProvided: options.overrides !== void 0
@@ -1774,6 +1810,7 @@ ${stringify(root)}`;
1774
1810
  output = unquoteMetadataScalar(output, "compressionLevel", compressionLevel);
1775
1811
  }
1776
1812
  output = unquoteConditionsScalars(output);
1813
+ output = unquoteMetaBooleanScalars(output);
1777
1814
  if (options.lineEnding === "crlf") {
1778
1815
  output = output.replace(/\n/g, "\r\n");
1779
1816
  }
@@ -2616,6 +2653,7 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2616
2653
  const normalizedRange = normalizedEdgeRange(kind, depRange);
2617
2654
  const lookup = `${depName}@${normalizedRange}`;
2618
2655
  let dstId = index.get(lookup);
2656
+ let boundViaOverride = false;
2619
2657
  if (dstId === void 0) {
2620
2658
  dstId = resolvePatchAndLinkFallbacks(
2621
2659
  lookup,
@@ -2645,7 +2683,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2645
2683
  );
2646
2684
  if (viaOverride === null) continue;
2647
2685
  }
2648
- if (viaOverride !== void 0) dstId = viaOverride;
2686
+ if (viaOverride !== void 0) {
2687
+ dstId = viaOverride;
2688
+ boundViaOverride = true;
2689
+ }
2649
2690
  }
2650
2691
  }
2651
2692
  if (dstId === void 0) {
@@ -2657,6 +2698,30 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2657
2698
  continue;
2658
2699
  }
2659
2700
  }
2701
+ if (dstId === void 0) {
2702
+ const result = distTagResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2703
+ if (result.kind === "bound") {
2704
+ dstId = result.id;
2705
+ } else if (result.kind === "ambiguous") {
2706
+ diagnostics.push(ambiguousResolutionDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, result.candidateIds));
2707
+ if (!ladder.manifestsProvided) {
2708
+ diagnostics.push(resolutionPinUnresolvedDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange));
2709
+ }
2710
+ continue;
2711
+ }
2712
+ }
2713
+ if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2714
+ const bound = nodeNameVersion(dstId);
2715
+ const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
2716
+ if (siblings !== void 0 && siblings.length > 0) {
2717
+ const consumerLocator = srcResolution !== void 0 ? encodeURIComponent(srcResolution) : void 0;
2718
+ const patchId = patchPreferenceFor(depName, normalizedRange, siblings, consumerLocator);
2719
+ if (patchId !== void 0 && patchId !== dstId) {
2720
+ dstId = patchId;
2721
+ diagnostics.push(patchPreferredDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, patchId));
2722
+ }
2723
+ }
2724
+ }
2660
2725
  if (!dstId) {
2661
2726
  diagnostics.push({
2662
2727
  code: "YARN_BERRY_UNRESOLVED_DEP",
@@ -2679,6 +2744,16 @@ function normalizedEdgeRange(kind, range) {
2679
2744
  if (kind === "peer") return range;
2680
2745
  return hasExplicitProtocol(range) ? range : `npm:${range}`;
2681
2746
  }
2747
+ function nodeNameVersion(id) {
2748
+ const name = nameOf(id);
2749
+ if (name.length >= id.length) return void 0;
2750
+ let rest = id.slice(name.length + 1);
2751
+ const parenIdx = rest.indexOf("(");
2752
+ if (parenIdx >= 0) rest = rest.slice(0, parenIdx);
2753
+ const plusIdx = rest.indexOf("+");
2754
+ if (plusIdx >= 0) rest = rest.slice(0, plusIdx);
2755
+ return rest.length > 0 ? `${name}@${rest}` : void 0;
2756
+ }
2682
2757
  function hasExplicitProtocol(range) {
2683
2758
  const colonIdx = range.indexOf(":");
2684
2759
  if (colonIdx <= 0) return false;
@@ -2708,6 +2783,17 @@ function locatorQualifierOfPatchSpec(spec) {
2708
2783
  }
2709
2784
  return void 0;
2710
2785
  }
2786
+ function isNpmBasePatchResolution(resolution, name) {
2787
+ const locator = patchLocatorOfResolution(resolution);
2788
+ if (locator === void 0) return false;
2789
+ const base = baseSpecOfPatchLocator(locator);
2790
+ return base !== void 0 && base.startsWith(`${name}@npm:`);
2791
+ }
2792
+ function locatorQualifierOfPatchResolution(resolution) {
2793
+ const locator = patchLocatorOfResolution(resolution);
2794
+ if (locator === void 0 || !locator.startsWith("patch:")) return void 0;
2795
+ return locatorQualifierOfPatchSpec(locator.slice("patch:".length));
2796
+ }
2711
2797
  function resolvePatchDescriptor(candidates, srcResolution, srcId, lookup, diagnostics) {
2712
2798
  if (candidates === void 0 || candidates.length === 0) return void 0;
2713
2799
  if (candidates.length === 1) return candidates[0].id;
@@ -2817,6 +2903,12 @@ function unquoteConditionsScalars(output) {
2817
2903
  (_m, key, body) => `${key}: ${body}`
2818
2904
  );
2819
2905
  }
2906
+ function unquoteMetaBooleanScalars(output) {
2907
+ return output.replace(
2908
+ /^( (?:optional|built|unplugged)): "(true|false)"$/gm,
2909
+ (_m, key, body) => `${key}: ${body}`
2910
+ );
2911
+ }
2820
2912
 
2821
2913
  // src/main/ts/formats/yarn-berry-v5.ts
2822
2914
  var CONFIG = {