@antongolub/lockfile 0.0.0-snapshot.52 → 0.0.0-snapshot.55

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.
@@ -848,10 +848,7 @@ function codeOf(error) {
848
848
  }
849
849
 
850
850
  // src/main/ts/formats/_yarn-syml.ts
851
- var YAML_NUMBER_RE = /^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/;
852
- var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
853
- var YAML_NULL_RE = /^(null|~)$/;
854
- var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
851
+ var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
855
852
  var SymlParseError = class extends Error {
856
853
  line;
857
854
  constructor(message, line) {
@@ -1016,16 +1013,7 @@ function parse(input) {
1016
1013
  return root;
1017
1014
  }
1018
1015
  function needsQuotes(raw) {
1019
- if (raw === "") return true;
1020
- if (YAML_SPECIAL_RE.test(raw)) return true;
1021
- if (raw[0] === "-" || raw[0] === "?") return true;
1022
- if (YAML_NUMBER_RE.test(raw)) return true;
1023
- if (YAML_BOOLEAN_RE.test(raw)) return true;
1024
- if (YAML_NULL_RE.test(raw)) return true;
1025
- for (let i = 0; i < raw.length; i++) {
1026
- if (raw.charCodeAt(i) > 127) return true;
1027
- }
1028
- return false;
1016
+ return !SYML_SIMPLE_STRING_RE.test(raw);
1029
1017
  }
1030
1018
  function escapeQuoted(raw) {
1031
1019
  let out = "";
@@ -1329,6 +1317,14 @@ function resolutionPinUnresolvedDiagnostic(prefix, subject, depName, range) {
1329
1317
  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
1318
  };
1331
1319
  }
1320
+ function patchPreferredDiagnostic(prefix, subject, depName, range, patchId) {
1321
+ return {
1322
+ code: `${prefix}_PATCH_PREFERRED`,
1323
+ severity: "info",
1324
+ subject,
1325
+ message: `dependency ${depName}=${range} from ${subject} redirected to sibling patch node ${patchId} (lock-borne patchedDependencies preference); base left GC-able`
1326
+ };
1327
+ }
1332
1328
  function emitDropped(nodeId, feature, reason, onDiagnostic) {
1333
1329
  if (onDiagnostic === void 0) return;
1334
1330
  onDiagnostic({
@@ -1380,6 +1376,16 @@ function semverResolve(range, candidates) {
1380
1376
  if (top.length === 1) return { kind: "bound", id: top[0] };
1381
1377
  return { kind: "ambiguous", candidateIds: top };
1382
1378
  }
1379
+ function distTagResolve(range, candidates) {
1380
+ const tag = registryRangeOf(range);
1381
+ if (tag === void 0) return { kind: "none" };
1382
+ if (semver.validRange(tag) !== null) return { kind: "none" };
1383
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1384
+ if (eligible.length === 0) return { kind: "none" };
1385
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1386
+ const ids = eligible.map((c) => c.id).sort(cmpStr2);
1387
+ return { kind: "ambiguous", candidateIds: ids };
1388
+ }
1383
1389
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1384
1390
  let best;
1385
1391
  let bestScore = -1;
@@ -1412,6 +1418,15 @@ function parentPathMatches(parentPath, consumerPath) {
1412
1418
  }
1413
1419
  return true;
1414
1420
  }
1421
+ function patchPreferenceFor(_name, _version, patchSiblings, consumerLocator) {
1422
+ if (patchSiblings.length === 0) return void 0;
1423
+ if (patchSiblings.length === 1) return patchSiblings[0].id;
1424
+ if (consumerLocator !== void 0) {
1425
+ const matches = patchSiblings.filter((s) => s.locatorQualifier === consumerLocator);
1426
+ if (matches.length === 1) return matches[0].id;
1427
+ }
1428
+ return void 0;
1429
+ }
1415
1430
  var cmpStr2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
1416
1431
  function readInstalledManifest(workspaceRoot, parentName, consumerNodeId) {
1417
1432
  return readInstalledManifestFrom([workspaceRoot], parentName);
@@ -1552,6 +1567,7 @@ function parseFamily(input, options, config) {
1552
1567
  const specIndex = /* @__PURE__ */ new Map();
1553
1568
  const patchDescriptorIndex = /* @__PURE__ */ new Map();
1554
1569
  const semverCandidatesByName = /* @__PURE__ */ new Map();
1570
+ const patchSiblingsByBase = /* @__PURE__ */ new Map();
1555
1571
  const seenIds = /* @__PURE__ */ new Set();
1556
1572
  const entryIds = /* @__PURE__ */ new Map();
1557
1573
  for (const { key, value, specs } of entries) {
@@ -1617,6 +1633,13 @@ function parseFamily(input, options, config) {
1617
1633
  const candidateList = semverCandidatesByName.get(authoritativeName);
1618
1634
  if (candidateList === void 0) semverCandidatesByName.set(authoritativeName, [semverCandidate]);
1619
1635
  else candidateList.push(semverCandidate);
1636
+ if (effectivePatch !== void 0 && resolution !== void 0 && isNpmBasePatchResolution(resolution, authoritativeName)) {
1637
+ const sibling = { id, locatorQualifier: locatorQualifierOfPatchResolution(resolution) };
1638
+ const baseKey = `${authoritativeName}@${version}`;
1639
+ const siblings = patchSiblingsByBase.get(baseKey);
1640
+ if (siblings === void 0) patchSiblingsByBase.set(baseKey, [sibling]);
1641
+ else siblings.push(sibling);
1642
+ }
1620
1643
  const peerDependencies = stringRecordOfBlock(asMap(value["peerDependencies"]));
1621
1644
  if (peerDependencies !== void 0) {
1622
1645
  rawPeerDependencies.set(id, peerDependencies);
@@ -1680,6 +1703,7 @@ function parseFamily(input, options, config) {
1680
1703
  }
1681
1704
  const ladderCtx = {
1682
1705
  candidatesByName: semverCandidatesByName,
1706
+ patchSiblingsByBase,
1683
1707
  overrides: options.overrides ?? [],
1684
1708
  codePrefix: config.codePrefix,
1685
1709
  manifestsProvided: options.overrides !== void 0
@@ -2618,6 +2642,7 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2618
2642
  const normalizedRange = normalizedEdgeRange(kind, depRange);
2619
2643
  const lookup = `${depName}@${normalizedRange}`;
2620
2644
  let dstId = index.get(lookup);
2645
+ let boundViaOverride = false;
2621
2646
  if (dstId === void 0) {
2622
2647
  dstId = resolvePatchAndLinkFallbacks(
2623
2648
  lookup,
@@ -2647,7 +2672,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2647
2672
  );
2648
2673
  if (viaOverride === null) continue;
2649
2674
  }
2650
- if (viaOverride !== void 0) dstId = viaOverride;
2675
+ if (viaOverride !== void 0) {
2676
+ dstId = viaOverride;
2677
+ boundViaOverride = true;
2678
+ }
2651
2679
  }
2652
2680
  }
2653
2681
  if (dstId === void 0) {
@@ -2659,6 +2687,30 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2659
2687
  continue;
2660
2688
  }
2661
2689
  }
2690
+ if (dstId === void 0) {
2691
+ const result = distTagResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2692
+ if (result.kind === "bound") {
2693
+ dstId = result.id;
2694
+ } else if (result.kind === "ambiguous") {
2695
+ diagnostics.push(ambiguousResolutionDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, result.candidateIds));
2696
+ if (!ladder.manifestsProvided) {
2697
+ diagnostics.push(resolutionPinUnresolvedDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange));
2698
+ }
2699
+ continue;
2700
+ }
2701
+ }
2702
+ if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2703
+ const bound = nodeNameVersion(dstId);
2704
+ const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
2705
+ if (siblings !== void 0 && siblings.length > 0) {
2706
+ const consumerLocator = srcResolution !== void 0 ? encodeURIComponent(srcResolution) : void 0;
2707
+ const patchId = patchPreferenceFor(depName, normalizedRange, siblings, consumerLocator);
2708
+ if (patchId !== void 0 && patchId !== dstId) {
2709
+ dstId = patchId;
2710
+ diagnostics.push(patchPreferredDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, patchId));
2711
+ }
2712
+ }
2713
+ }
2662
2714
  if (!dstId) {
2663
2715
  diagnostics.push({
2664
2716
  code: "YARN_BERRY_UNRESOLVED_DEP",
@@ -2681,6 +2733,16 @@ function normalizedEdgeRange(kind, range) {
2681
2733
  if (kind === "peer") return range;
2682
2734
  return hasExplicitProtocol(range) ? range : `npm:${range}`;
2683
2735
  }
2736
+ function nodeNameVersion(id) {
2737
+ const name = nameOf(id);
2738
+ if (name.length >= id.length) return void 0;
2739
+ let rest = id.slice(name.length + 1);
2740
+ const parenIdx = rest.indexOf("(");
2741
+ if (parenIdx >= 0) rest = rest.slice(0, parenIdx);
2742
+ const plusIdx = rest.indexOf("+");
2743
+ if (plusIdx >= 0) rest = rest.slice(0, plusIdx);
2744
+ return rest.length > 0 ? `${name}@${rest}` : void 0;
2745
+ }
2684
2746
  function hasExplicitProtocol(range) {
2685
2747
  const colonIdx = range.indexOf(":");
2686
2748
  if (colonIdx <= 0) return false;
@@ -2710,6 +2772,17 @@ function locatorQualifierOfPatchSpec(spec) {
2710
2772
  }
2711
2773
  return void 0;
2712
2774
  }
2775
+ function isNpmBasePatchResolution(resolution, name) {
2776
+ const locator = patchLocatorOfResolution(resolution);
2777
+ if (locator === void 0) return false;
2778
+ const base = baseSpecOfPatchLocator(locator);
2779
+ return base !== void 0 && base.startsWith(`${name}@npm:`);
2780
+ }
2781
+ function locatorQualifierOfPatchResolution(resolution) {
2782
+ const locator = patchLocatorOfResolution(resolution);
2783
+ if (locator === void 0 || !locator.startsWith("patch:")) return void 0;
2784
+ return locatorQualifierOfPatchSpec(locator.slice("patch:".length));
2785
+ }
2713
2786
  function resolvePatchDescriptor(candidates, srcResolution, srcId, lookup, diagnostics) {
2714
2787
  if (candidates === void 0 || candidates.length === 0) return void 0;
2715
2788
  if (candidates.length === 1) return candidates[0].id;
@@ -848,10 +848,7 @@ function codeOf(error) {
848
848
  }
849
849
 
850
850
  // src/main/ts/formats/_yarn-syml.ts
851
- var YAML_NUMBER_RE = /^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/;
852
- var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
853
- var YAML_NULL_RE = /^(null|~)$/;
854
- var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
851
+ var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
855
852
  var SymlParseError = class extends Error {
856
853
  line;
857
854
  constructor(message, line) {
@@ -1016,16 +1013,7 @@ function parse(input) {
1016
1013
  return root;
1017
1014
  }
1018
1015
  function needsQuotes(raw) {
1019
- if (raw === "") return true;
1020
- if (YAML_SPECIAL_RE.test(raw)) return true;
1021
- if (raw[0] === "-" || raw[0] === "?") return true;
1022
- if (YAML_NUMBER_RE.test(raw)) return true;
1023
- if (YAML_BOOLEAN_RE.test(raw)) return true;
1024
- if (YAML_NULL_RE.test(raw)) return true;
1025
- for (let i = 0; i < raw.length; i++) {
1026
- if (raw.charCodeAt(i) > 127) return true;
1027
- }
1028
- return false;
1016
+ return !SYML_SIMPLE_STRING_RE.test(raw);
1029
1017
  }
1030
1018
  function escapeQuoted(raw) {
1031
1019
  let out = "";
@@ -1329,6 +1317,14 @@ function resolutionPinUnresolvedDiagnostic(prefix, subject, depName, range) {
1329
1317
  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
1318
  };
1331
1319
  }
1320
+ function patchPreferredDiagnostic(prefix, subject, depName, range, patchId) {
1321
+ return {
1322
+ code: `${prefix}_PATCH_PREFERRED`,
1323
+ severity: "info",
1324
+ subject,
1325
+ message: `dependency ${depName}=${range} from ${subject} redirected to sibling patch node ${patchId} (lock-borne patchedDependencies preference); base left GC-able`
1326
+ };
1327
+ }
1332
1328
  function emitDropped(nodeId, feature, reason, onDiagnostic) {
1333
1329
  if (onDiagnostic === void 0) return;
1334
1330
  onDiagnostic({
@@ -1380,6 +1376,16 @@ function semverResolve(range, candidates) {
1380
1376
  if (top.length === 1) return { kind: "bound", id: top[0] };
1381
1377
  return { kind: "ambiguous", candidateIds: top };
1382
1378
  }
1379
+ function distTagResolve(range, candidates) {
1380
+ const tag = registryRangeOf(range);
1381
+ if (tag === void 0) return { kind: "none" };
1382
+ if (semver.validRange(tag) !== null) return { kind: "none" };
1383
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1384
+ if (eligible.length === 0) return { kind: "none" };
1385
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1386
+ const ids = eligible.map((c) => c.id).sort(cmpStr2);
1387
+ return { kind: "ambiguous", candidateIds: ids };
1388
+ }
1383
1389
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1384
1390
  let best;
1385
1391
  let bestScore = -1;
@@ -1412,6 +1418,15 @@ function parentPathMatches(parentPath, consumerPath) {
1412
1418
  }
1413
1419
  return true;
1414
1420
  }
1421
+ function patchPreferenceFor(_name, _version, patchSiblings, consumerLocator) {
1422
+ if (patchSiblings.length === 0) return void 0;
1423
+ if (patchSiblings.length === 1) return patchSiblings[0].id;
1424
+ if (consumerLocator !== void 0) {
1425
+ const matches = patchSiblings.filter((s) => s.locatorQualifier === consumerLocator);
1426
+ if (matches.length === 1) return matches[0].id;
1427
+ }
1428
+ return void 0;
1429
+ }
1415
1430
  var cmpStr2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
1416
1431
  function readInstalledManifest(workspaceRoot, parentName, consumerNodeId) {
1417
1432
  return readInstalledManifestFrom([workspaceRoot], parentName);
@@ -1552,6 +1567,7 @@ function parseFamily(input, options, config) {
1552
1567
  const specIndex = /* @__PURE__ */ new Map();
1553
1568
  const patchDescriptorIndex = /* @__PURE__ */ new Map();
1554
1569
  const semverCandidatesByName = /* @__PURE__ */ new Map();
1570
+ const patchSiblingsByBase = /* @__PURE__ */ new Map();
1555
1571
  const seenIds = /* @__PURE__ */ new Set();
1556
1572
  const entryIds = /* @__PURE__ */ new Map();
1557
1573
  for (const { key, value, specs } of entries) {
@@ -1617,6 +1633,13 @@ function parseFamily(input, options, config) {
1617
1633
  const candidateList = semverCandidatesByName.get(authoritativeName);
1618
1634
  if (candidateList === void 0) semverCandidatesByName.set(authoritativeName, [semverCandidate]);
1619
1635
  else candidateList.push(semverCandidate);
1636
+ if (effectivePatch !== void 0 && resolution !== void 0 && isNpmBasePatchResolution(resolution, authoritativeName)) {
1637
+ const sibling = { id, locatorQualifier: locatorQualifierOfPatchResolution(resolution) };
1638
+ const baseKey = `${authoritativeName}@${version}`;
1639
+ const siblings = patchSiblingsByBase.get(baseKey);
1640
+ if (siblings === void 0) patchSiblingsByBase.set(baseKey, [sibling]);
1641
+ else siblings.push(sibling);
1642
+ }
1620
1643
  const peerDependencies = stringRecordOfBlock(asMap(value["peerDependencies"]));
1621
1644
  if (peerDependencies !== void 0) {
1622
1645
  rawPeerDependencies.set(id, peerDependencies);
@@ -1680,6 +1703,7 @@ function parseFamily(input, options, config) {
1680
1703
  }
1681
1704
  const ladderCtx = {
1682
1705
  candidatesByName: semverCandidatesByName,
1706
+ patchSiblingsByBase,
1683
1707
  overrides: options.overrides ?? [],
1684
1708
  codePrefix: config.codePrefix,
1685
1709
  manifestsProvided: options.overrides !== void 0
@@ -2622,6 +2646,7 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2622
2646
  const normalizedRange = normalizedEdgeRange(kind, depRange);
2623
2647
  const lookup = `${depName}@${normalizedRange}`;
2624
2648
  let dstId = index.get(lookup);
2649
+ let boundViaOverride = false;
2625
2650
  if (dstId === void 0) {
2626
2651
  dstId = resolvePatchAndLinkFallbacks(
2627
2652
  lookup,
@@ -2651,7 +2676,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2651
2676
  );
2652
2677
  if (viaOverride === null) continue;
2653
2678
  }
2654
- if (viaOverride !== void 0) dstId = viaOverride;
2679
+ if (viaOverride !== void 0) {
2680
+ dstId = viaOverride;
2681
+ boundViaOverride = true;
2682
+ }
2655
2683
  }
2656
2684
  }
2657
2685
  if (dstId === void 0) {
@@ -2663,6 +2691,30 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2663
2691
  continue;
2664
2692
  }
2665
2693
  }
2694
+ if (dstId === void 0) {
2695
+ const result = distTagResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2696
+ if (result.kind === "bound") {
2697
+ dstId = result.id;
2698
+ } else if (result.kind === "ambiguous") {
2699
+ diagnostics.push(ambiguousResolutionDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, result.candidateIds));
2700
+ if (!ladder.manifestsProvided) {
2701
+ diagnostics.push(resolutionPinUnresolvedDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange));
2702
+ }
2703
+ continue;
2704
+ }
2705
+ }
2706
+ if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2707
+ const bound = nodeNameVersion(dstId);
2708
+ const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
2709
+ if (siblings !== void 0 && siblings.length > 0) {
2710
+ const consumerLocator = srcResolution !== void 0 ? encodeURIComponent(srcResolution) : void 0;
2711
+ const patchId = patchPreferenceFor(depName, normalizedRange, siblings, consumerLocator);
2712
+ if (patchId !== void 0 && patchId !== dstId) {
2713
+ dstId = patchId;
2714
+ diagnostics.push(patchPreferredDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, patchId));
2715
+ }
2716
+ }
2717
+ }
2666
2718
  if (!dstId) {
2667
2719
  diagnostics.push({
2668
2720
  code: "YARN_BERRY_UNRESOLVED_DEP",
@@ -2685,6 +2737,16 @@ function normalizedEdgeRange(kind, range) {
2685
2737
  if (kind === "peer") return range;
2686
2738
  return hasExplicitProtocol(range) ? range : `npm:${range}`;
2687
2739
  }
2740
+ function nodeNameVersion(id) {
2741
+ const name = nameOf(id);
2742
+ if (name.length >= id.length) return void 0;
2743
+ let rest = id.slice(name.length + 1);
2744
+ const parenIdx = rest.indexOf("(");
2745
+ if (parenIdx >= 0) rest = rest.slice(0, parenIdx);
2746
+ const plusIdx = rest.indexOf("+");
2747
+ if (plusIdx >= 0) rest = rest.slice(0, plusIdx);
2748
+ return rest.length > 0 ? `${name}@${rest}` : void 0;
2749
+ }
2688
2750
  function hasExplicitProtocol(range) {
2689
2751
  const colonIdx = range.indexOf(":");
2690
2752
  if (colonIdx <= 0) return false;
@@ -2714,6 +2776,17 @@ function locatorQualifierOfPatchSpec(spec) {
2714
2776
  }
2715
2777
  return void 0;
2716
2778
  }
2779
+ function isNpmBasePatchResolution(resolution, name) {
2780
+ const locator = patchLocatorOfResolution(resolution);
2781
+ if (locator === void 0) return false;
2782
+ const base = baseSpecOfPatchLocator(locator);
2783
+ return base !== void 0 && base.startsWith(`${name}@npm:`);
2784
+ }
2785
+ function locatorQualifierOfPatchResolution(resolution) {
2786
+ const locator = patchLocatorOfResolution(resolution);
2787
+ if (locator === void 0 || !locator.startsWith("patch:")) return void 0;
2788
+ return locatorQualifierOfPatchSpec(locator.slice("patch:".length));
2789
+ }
2717
2790
  function resolvePatchDescriptor(candidates, srcResolution, srcId, lookup, diagnostics) {
2718
2791
  if (candidates === void 0 || candidates.length === 0) return void 0;
2719
2792
  if (candidates.length === 1) return candidates[0].id;
@@ -848,10 +848,7 @@ function codeOf(error) {
848
848
  }
849
849
 
850
850
  // src/main/ts/formats/_yarn-syml.ts
851
- var YAML_NUMBER_RE = /^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/;
852
- var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
853
- var YAML_NULL_RE = /^(null|~)$/;
854
- var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
851
+ var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
855
852
  var SymlParseError = class extends Error {
856
853
  line;
857
854
  constructor(message, line) {
@@ -1016,16 +1013,7 @@ function parse(input) {
1016
1013
  return root;
1017
1014
  }
1018
1015
  function needsQuotes(raw) {
1019
- if (raw === "") return true;
1020
- if (YAML_SPECIAL_RE.test(raw)) return true;
1021
- if (raw[0] === "-" || raw[0] === "?") return true;
1022
- if (YAML_NUMBER_RE.test(raw)) return true;
1023
- if (YAML_BOOLEAN_RE.test(raw)) return true;
1024
- if (YAML_NULL_RE.test(raw)) return true;
1025
- for (let i = 0; i < raw.length; i++) {
1026
- if (raw.charCodeAt(i) > 127) return true;
1027
- }
1028
- return false;
1016
+ return !SYML_SIMPLE_STRING_RE.test(raw);
1029
1017
  }
1030
1018
  function escapeQuoted(raw) {
1031
1019
  let out = "";
@@ -1329,6 +1317,14 @@ function resolutionPinUnresolvedDiagnostic(prefix, subject, depName, range) {
1329
1317
  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
1318
  };
1331
1319
  }
1320
+ function patchPreferredDiagnostic(prefix, subject, depName, range, patchId) {
1321
+ return {
1322
+ code: `${prefix}_PATCH_PREFERRED`,
1323
+ severity: "info",
1324
+ subject,
1325
+ message: `dependency ${depName}=${range} from ${subject} redirected to sibling patch node ${patchId} (lock-borne patchedDependencies preference); base left GC-able`
1326
+ };
1327
+ }
1332
1328
  function emitDropped(nodeId, feature, reason, onDiagnostic) {
1333
1329
  if (onDiagnostic === void 0) return;
1334
1330
  onDiagnostic({
@@ -1380,6 +1376,16 @@ function semverResolve(range, candidates) {
1380
1376
  if (top.length === 1) return { kind: "bound", id: top[0] };
1381
1377
  return { kind: "ambiguous", candidateIds: top };
1382
1378
  }
1379
+ function distTagResolve(range, candidates) {
1380
+ const tag = registryRangeOf(range);
1381
+ if (tag === void 0) return { kind: "none" };
1382
+ if (semver.validRange(tag) !== null) return { kind: "none" };
1383
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1384
+ if (eligible.length === 0) return { kind: "none" };
1385
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1386
+ const ids = eligible.map((c) => c.id).sort(cmpStr2);
1387
+ return { kind: "ambiguous", candidateIds: ids };
1388
+ }
1383
1389
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1384
1390
  let best;
1385
1391
  let bestScore = -1;
@@ -1412,6 +1418,15 @@ function parentPathMatches(parentPath, consumerPath) {
1412
1418
  }
1413
1419
  return true;
1414
1420
  }
1421
+ function patchPreferenceFor(_name, _version, patchSiblings, consumerLocator) {
1422
+ if (patchSiblings.length === 0) return void 0;
1423
+ if (patchSiblings.length === 1) return patchSiblings[0].id;
1424
+ if (consumerLocator !== void 0) {
1425
+ const matches = patchSiblings.filter((s) => s.locatorQualifier === consumerLocator);
1426
+ if (matches.length === 1) return matches[0].id;
1427
+ }
1428
+ return void 0;
1429
+ }
1415
1430
  var cmpStr2 = (a, b) => a < b ? -1 : a > b ? 1 : 0;
1416
1431
  function readInstalledManifest(workspaceRoot, parentName, consumerNodeId) {
1417
1432
  return readInstalledManifestFrom([workspaceRoot], parentName);
@@ -1552,6 +1567,7 @@ function parseFamily(input, options, config) {
1552
1567
  const specIndex = /* @__PURE__ */ new Map();
1553
1568
  const patchDescriptorIndex = /* @__PURE__ */ new Map();
1554
1569
  const semverCandidatesByName = /* @__PURE__ */ new Map();
1570
+ const patchSiblingsByBase = /* @__PURE__ */ new Map();
1555
1571
  const seenIds = /* @__PURE__ */ new Set();
1556
1572
  const entryIds = /* @__PURE__ */ new Map();
1557
1573
  for (const { key, value, specs } of entries) {
@@ -1617,6 +1633,13 @@ function parseFamily(input, options, config) {
1617
1633
  const candidateList = semverCandidatesByName.get(authoritativeName);
1618
1634
  if (candidateList === void 0) semverCandidatesByName.set(authoritativeName, [semverCandidate]);
1619
1635
  else candidateList.push(semverCandidate);
1636
+ if (effectivePatch !== void 0 && resolution !== void 0 && isNpmBasePatchResolution(resolution, authoritativeName)) {
1637
+ const sibling = { id, locatorQualifier: locatorQualifierOfPatchResolution(resolution) };
1638
+ const baseKey = `${authoritativeName}@${version}`;
1639
+ const siblings = patchSiblingsByBase.get(baseKey);
1640
+ if (siblings === void 0) patchSiblingsByBase.set(baseKey, [sibling]);
1641
+ else siblings.push(sibling);
1642
+ }
1620
1643
  const peerDependencies = stringRecordOfBlock(asMap(value["peerDependencies"]));
1621
1644
  if (peerDependencies !== void 0) {
1622
1645
  rawPeerDependencies.set(id, peerDependencies);
@@ -1680,6 +1703,7 @@ function parseFamily(input, options, config) {
1680
1703
  }
1681
1704
  const ladderCtx = {
1682
1705
  candidatesByName: semverCandidatesByName,
1706
+ patchSiblingsByBase,
1683
1707
  overrides: options.overrides ?? [],
1684
1708
  codePrefix: config.codePrefix,
1685
1709
  manifestsProvided: options.overrides !== void 0
@@ -2617,6 +2641,7 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2617
2641
  const normalizedRange = normalizedEdgeRange(kind, depRange);
2618
2642
  const lookup = `${depName}@${normalizedRange}`;
2619
2643
  let dstId = index.get(lookup);
2644
+ let boundViaOverride = false;
2620
2645
  if (dstId === void 0) {
2621
2646
  dstId = resolvePatchAndLinkFallbacks(
2622
2647
  lookup,
@@ -2646,7 +2671,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2646
2671
  );
2647
2672
  if (viaOverride === null) continue;
2648
2673
  }
2649
- if (viaOverride !== void 0) dstId = viaOverride;
2674
+ if (viaOverride !== void 0) {
2675
+ dstId = viaOverride;
2676
+ boundViaOverride = true;
2677
+ }
2650
2678
  }
2651
2679
  }
2652
2680
  if (dstId === void 0) {
@@ -2658,6 +2686,30 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2658
2686
  continue;
2659
2687
  }
2660
2688
  }
2689
+ if (dstId === void 0) {
2690
+ const result = distTagResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2691
+ if (result.kind === "bound") {
2692
+ dstId = result.id;
2693
+ } else if (result.kind === "ambiguous") {
2694
+ diagnostics.push(ambiguousResolutionDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, result.candidateIds));
2695
+ if (!ladder.manifestsProvided) {
2696
+ diagnostics.push(resolutionPinUnresolvedDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange));
2697
+ }
2698
+ continue;
2699
+ }
2700
+ }
2701
+ if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2702
+ const bound = nodeNameVersion(dstId);
2703
+ const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
2704
+ if (siblings !== void 0 && siblings.length > 0) {
2705
+ const consumerLocator = srcResolution !== void 0 ? encodeURIComponent(srcResolution) : void 0;
2706
+ const patchId = patchPreferenceFor(depName, normalizedRange, siblings, consumerLocator);
2707
+ if (patchId !== void 0 && patchId !== dstId) {
2708
+ dstId = patchId;
2709
+ diagnostics.push(patchPreferredDiagnostic(ladder.codePrefix, srcId, depName, normalizedRange, patchId));
2710
+ }
2711
+ }
2712
+ }
2661
2713
  if (!dstId) {
2662
2714
  diagnostics.push({
2663
2715
  code: "YARN_BERRY_UNRESOLVED_DEP",
@@ -2680,6 +2732,16 @@ function normalizedEdgeRange(kind, range) {
2680
2732
  if (kind === "peer") return range;
2681
2733
  return hasExplicitProtocol(range) ? range : `npm:${range}`;
2682
2734
  }
2735
+ function nodeNameVersion(id) {
2736
+ const name = nameOf(id);
2737
+ if (name.length >= id.length) return void 0;
2738
+ let rest = id.slice(name.length + 1);
2739
+ const parenIdx = rest.indexOf("(");
2740
+ if (parenIdx >= 0) rest = rest.slice(0, parenIdx);
2741
+ const plusIdx = rest.indexOf("+");
2742
+ if (plusIdx >= 0) rest = rest.slice(0, plusIdx);
2743
+ return rest.length > 0 ? `${name}@${rest}` : void 0;
2744
+ }
2683
2745
  function hasExplicitProtocol(range) {
2684
2746
  const colonIdx = range.indexOf(":");
2685
2747
  if (colonIdx <= 0) return false;
@@ -2709,6 +2771,17 @@ function locatorQualifierOfPatchSpec(spec) {
2709
2771
  }
2710
2772
  return void 0;
2711
2773
  }
2774
+ function isNpmBasePatchResolution(resolution, name) {
2775
+ const locator = patchLocatorOfResolution(resolution);
2776
+ if (locator === void 0) return false;
2777
+ const base = baseSpecOfPatchLocator(locator);
2778
+ return base !== void 0 && base.startsWith(`${name}@npm:`);
2779
+ }
2780
+ function locatorQualifierOfPatchResolution(resolution) {
2781
+ const locator = patchLocatorOfResolution(resolution);
2782
+ if (locator === void 0 || !locator.startsWith("patch:")) return void 0;
2783
+ return locatorQualifierOfPatchSpec(locator.slice("patch:".length));
2784
+ }
2712
2785
  function resolvePatchDescriptor(candidates, srcResolution, srcId, lookup, diagnostics) {
2713
2786
  if (candidates === void 0 || candidates.length === 0) return void 0;
2714
2787
  if (candidates.length === 1) return candidates[0].id;