@antongolub/lockfile 0.0.0-snapshot.53 → 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 = "";
@@ -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 = "";
@@ -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 = "";
@@ -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 = "";
@@ -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 = "";
@@ -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 = "";
@@ -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 = "";
@@ -1074,7 +1074,40 @@ function check(input) {
1074
1074
  const normalized = stripBom(normalizeLineEndings(input));
1075
1075
  if (normalized.startsWith(HEADER)) return true;
1076
1076
  const lines = normalized.split("\n");
1077
- return lines[0] === HEADER_LINE_1 && lines[1] === HEADER_LINE_2;
1077
+ if (lines[0] === HEADER_LINE_1 && lines[1] === HEADER_LINE_2) return true;
1078
+ return hasClassicStructuralBody(normalized, lines);
1079
+ }
1080
+ function hasClassicStructuralBody(normalized, lines) {
1081
+ if (BERRY_HEADER_RE.test(normalized)) return false;
1082
+ for (let i = 0; i < lines.length; i++) {
1083
+ const line = lines[i] ?? "";
1084
+ if (line.length === 0 || line[0] === " " || line[0] === " " || line[0] === "#") continue;
1085
+ if (!line.endsWith(":")) continue;
1086
+ if (!isClassicEntryKeyLine(line.slice(0, -1))) continue;
1087
+ for (let j = i + 1; j < lines.length; j++) {
1088
+ const body = lines[j] ?? "";
1089
+ if (body.length === 0) return false;
1090
+ if (body.startsWith(" #")) continue;
1091
+ return CLASSIC_VERSION_FIELD_RE.test(body);
1092
+ }
1093
+ return false;
1094
+ }
1095
+ return false;
1096
+ }
1097
+ var CLASSIC_VERSION_FIELD_RE = /^ {2}version "(?:\\.|[^"])*"\s*$/;
1098
+ function isClassicEntryKeyLine(key) {
1099
+ let specs;
1100
+ try {
1101
+ specs = splitEntryKey(parseEntryKeyToken(key));
1102
+ } catch {
1103
+ return false;
1104
+ }
1105
+ if (specs.length === 0) return false;
1106
+ for (const spec of specs) {
1107
+ const idx = spec.indexOf("@", spec.startsWith("@") ? 1 : 0);
1108
+ if (idx <= 0 || idx === spec.length - 1) return false;
1109
+ }
1110
+ return true;
1078
1111
  }
1079
1112
  function parse2(input, options = {}) {
1080
1113
  const normalized = stripBom(normalizeLineEndings(input));
@@ -1097,15 +1130,15 @@ function parse2(input, options = {}) {
1097
1130
  if (entry.version === void 0) {
1098
1131
  throw parseFailed(`entry ${JSON.stringify(entry.key)} missing version`);
1099
1132
  }
1100
- const specsByName = /* @__PURE__ */ new Map();
1133
+ const specsByResolvedName = /* @__PURE__ */ new Map();
1101
1134
  for (const spec of specs) {
1102
- const part = parseSpec(spec);
1103
- const current = specsByName.get(part.name);
1104
- if (current === void 0) specsByName.set(part.name, [part.spec]);
1105
- else current.push(part.spec);
1135
+ const identity = specIdentity(parseSpec(spec));
1136
+ const current = specsByResolvedName.get(identity.resolvedName);
1137
+ if (current === void 0) specsByResolvedName.set(identity.resolvedName, [identity.descriptorKey]);
1138
+ else current.push(identity.descriptorKey);
1106
1139
  }
1107
- for (const [name, rawRanges] of specsByName) {
1108
- const ranges = Array.from(new Set(rawRanges)).sort(cmpUtf16);
1140
+ for (const [name, rawDescriptors] of specsByResolvedName) {
1141
+ const descriptors = Array.from(new Set(rawDescriptors)).sort(cmpUtf16);
1109
1142
  const id = `${name}@${entry.version}`;
1110
1143
  const prior = seenEntries.get(id);
1111
1144
  if (prior !== void 0) {
@@ -1116,8 +1149,7 @@ function parse2(input, options = {}) {
1116
1149
  });
1117
1150
  }
1118
1151
  const merged = sidecar.get(id) ?? [];
1119
- for (const range of ranges) {
1120
- const spec = `${name}@${range}`;
1152
+ for (const spec of descriptors) {
1121
1153
  if (!merged.includes(spec)) merged.push(spec);
1122
1154
  specIndex.set(spec, id);
1123
1155
  }
@@ -1159,14 +1191,14 @@ function parse2(input, options = {}) {
1159
1191
  } else if (canonicalResolution !== void 0) {
1160
1192
  builder.setTarball({ name, version: entry.version }, { resolution: canonicalResolution });
1161
1193
  }
1162
- sidecar.set(id, ranges.map((range) => `${name}@${range}`));
1194
+ sidecar.set(id, descriptors.slice());
1163
1195
  if (entry.extras !== void 0 && entry.extras.length > 0) {
1164
1196
  entryExtras.set(id, entry.extras);
1165
1197
  for (const raw of entry.extras) unknownFields.add(raw.split(" ", 1)[0] ?? raw);
1166
1198
  }
1167
1199
  entryNodes.push({ node, entry });
1168
- for (const range of ranges) {
1169
- specIndex.set(`${name}@${range}`, id);
1200
+ for (const spec of descriptors) {
1201
+ specIndex.set(spec, id);
1170
1202
  }
1171
1203
  }
1172
1204
  }
@@ -1246,7 +1278,7 @@ function stringify(graph, options = {}) {
1246
1278
  }
1247
1279
  const integrity = payload?.integrity && emitSri(payload.integrity);
1248
1280
  if (integrity !== void 0 && integrity !== "") {
1249
- lines.push(` integrity ${integrity}`);
1281
+ lines.push(` integrity ${integrity.includes(" ") ? `"${integrity}"` : integrity}`);
1250
1282
  }
1251
1283
  const extras = emitSidecar?.entryExtras?.get(node.id);
1252
1284
  if (extras !== void 0) {
@@ -1470,7 +1502,8 @@ function parseEntries(input) {
1470
1502
  continue;
1471
1503
  }
1472
1504
  if (line.startsWith(" integrity ")) {
1473
- current.integrity = line.slice(" integrity ".length);
1505
+ const value = line.slice(" integrity ".length);
1506
+ current.integrity = value.startsWith('"') ? parseQuotedToken(value) : value;
1474
1507
  continue;
1475
1508
  }
1476
1509
  current.extras ??= [];
@@ -1585,6 +1618,19 @@ function parseSpec(spec) {
1585
1618
  spec: spec.slice(idx + 1)
1586
1619
  };
1587
1620
  }
1621
+ function specIdentity(part) {
1622
+ const descriptorKey = `${part.name}@${part.spec}`;
1623
+ if (part.spec.startsWith("npm:")) {
1624
+ const target = part.spec.slice("npm:".length);
1625
+ const at = target.indexOf("@", target.startsWith("@") ? 1 : 0);
1626
+ const targetName = at > 0 ? target.slice(0, at) : void 0;
1627
+ if (targetName !== void 0 && targetName.length > 0 && targetName !== part.name) {
1628
+ return { resolvedName: targetName, aliasName: part.name, descriptorKey };
1629
+ }
1630
+ return { resolvedName: part.name, descriptorKey };
1631
+ }
1632
+ return { resolvedName: part.name, descriptorKey };
1633
+ }
1588
1634
  function isClassicRegistryRange(range) {
1589
1635
  if (range.startsWith("npm:")) return true;
1590
1636
  const colonIdx = range.indexOf(":");
@@ -1634,7 +1680,10 @@ function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, lad
1634
1680
  }
1635
1681
  continue;
1636
1682
  }
1637
- builder.addEdge(srcId, dstId, kind, { range });
1683
+ const dstName = nameOf(dstId);
1684
+ const attrs = { range };
1685
+ if (name !== dstName) attrs.alias = name;
1686
+ builder.addEdge(srcId, dstId, kind, attrs);
1638
1687
  }
1639
1688
  }
1640
1689
  function specIndexOfGraph(graph, sidecar) {
@@ -1771,7 +1820,7 @@ function isWorkspaceProtocolRange(range) {
1771
1820
  return range.startsWith("workspace:");
1772
1821
  }
1773
1822
  function entrySpecsOfNode(graph, node) {
1774
- const liveSpecs = Array.from(graph.in(node.id)).filter((edge) => edge.kind === "dep" || edge.kind === "optional").map((edge) => edge.attrs?.range).filter((range) => range !== void 0).map((range) => `${node.name}@${range}`);
1823
+ const liveSpecs = Array.from(graph.in(node.id)).filter((edge) => edge.kind === "dep" || edge.kind === "optional").filter((edge) => edge.attrs?.range !== void 0).map((edge) => `${edge.attrs.alias ?? node.name}@${edge.attrs.range}`);
1775
1824
  if (liveSpecs.length > 0) {
1776
1825
  return Array.from(new Set(liveSpecs)).sort(cmpUtf16);
1777
1826
  }
@@ -1836,7 +1885,7 @@ function collectBlockEntries(graph, edges, emitDiagnostic) {
1836
1885
  return [dst.name, resolved];
1837
1886
  }
1838
1887
  }
1839
- return [dst.name, edge.attrs.range];
1888
+ return [edge.attrs.alias ?? dst.name, edge.attrs.range];
1840
1889
  }).filter((entry) => entry !== void 0).sort((a, b) => cmpUtf16(a[0], b[0]));
1841
1890
  }
1842
1891
  function warnDroppedPeerEdges(graph, srcId, warned, emitDiagnostic) {
package/dist/index.js CHANGED
@@ -5949,10 +5949,7 @@ function stringify7(graph, options = {}) {
5949
5949
  }
5950
5950
 
5951
5951
  // src/main/ts/formats/_yarn-syml.ts
5952
- var YAML_NUMBER_RE = /^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/;
5953
- var YAML_BOOLEAN_RE = /^(true|false|yes|no|on|off)$/i;
5954
- var YAML_NULL_RE = /^(null|~)$/;
5955
- var YAML_SPECIAL_RE = /[ \t:,[\]{}#&*!|>'"%@`]/;
5952
+ var SYML_SIMPLE_STRING_RE = /^(?![-?:,\][{}#&*!|>'"%@` \t\r\n]).([ \t]*(?![,\][{}:# \t\r\n]).)*$/;
5956
5953
  var SymlParseError = class extends Error {
5957
5954
  line;
5958
5955
  constructor(message, line) {
@@ -6117,16 +6114,7 @@ function parse9(input) {
6117
6114
  return root;
6118
6115
  }
6119
6116
  function needsQuotes(raw) {
6120
- if (raw === "") return true;
6121
- if (YAML_SPECIAL_RE.test(raw)) return true;
6122
- if (raw[0] === "-" || raw[0] === "?") return true;
6123
- if (YAML_NUMBER_RE.test(raw)) return true;
6124
- if (YAML_BOOLEAN_RE.test(raw)) return true;
6125
- if (YAML_NULL_RE.test(raw)) return true;
6126
- for (let i = 0; i < raw.length; i++) {
6127
- if (raw.charCodeAt(i) > 127) return true;
6128
- }
6129
- return false;
6117
+ return !SYML_SIMPLE_STRING_RE.test(raw);
6130
6118
  }
6131
6119
  function escapeQuoted(raw) {
6132
6120
  let out = "";
@@ -7442,7 +7430,40 @@ function check15(input) {
7442
7430
  const normalized = stripBom(normalizeLineEndings3(input));
7443
7431
  if (normalized.startsWith(HEADER)) return true;
7444
7432
  const lines = normalized.split("\n");
7445
- return lines[0] === HEADER_LINE_1 && lines[1] === HEADER_LINE_2;
7433
+ if (lines[0] === HEADER_LINE_1 && lines[1] === HEADER_LINE_2) return true;
7434
+ return hasClassicStructuralBody(normalized, lines);
7435
+ }
7436
+ function hasClassicStructuralBody(normalized, lines) {
7437
+ if (BERRY_HEADER_RE.test(normalized)) return false;
7438
+ for (let i = 0; i < lines.length; i++) {
7439
+ const line = lines[i] ?? "";
7440
+ if (line.length === 0 || line[0] === " " || line[0] === " " || line[0] === "#") continue;
7441
+ if (!line.endsWith(":")) continue;
7442
+ if (!isClassicEntryKeyLine(line.slice(0, -1))) continue;
7443
+ for (let j = i + 1; j < lines.length; j++) {
7444
+ const body = lines[j] ?? "";
7445
+ if (body.length === 0) return false;
7446
+ if (body.startsWith(" #")) continue;
7447
+ return CLASSIC_VERSION_FIELD_RE.test(body);
7448
+ }
7449
+ return false;
7450
+ }
7451
+ return false;
7452
+ }
7453
+ var CLASSIC_VERSION_FIELD_RE = /^ {2}version "(?:\\.|[^"])*"\s*$/;
7454
+ function isClassicEntryKeyLine(key) {
7455
+ let specs;
7456
+ try {
7457
+ specs = splitEntryKey(parseEntryKeyToken(key));
7458
+ } catch {
7459
+ return false;
7460
+ }
7461
+ if (specs.length === 0) return false;
7462
+ for (const spec of specs) {
7463
+ const idx = spec.indexOf("@", spec.startsWith("@") ? 1 : 0);
7464
+ if (idx <= 0 || idx === spec.length - 1) return false;
7465
+ }
7466
+ return true;
7446
7467
  }
7447
7468
  function parse17(input, options = {}) {
7448
7469
  const normalized = stripBom(normalizeLineEndings3(input));
@@ -7465,15 +7486,15 @@ function parse17(input, options = {}) {
7465
7486
  if (entry.version === void 0) {
7466
7487
  throw parseFailed2(`entry ${JSON.stringify(entry.key)} missing version`);
7467
7488
  }
7468
- const specsByName = /* @__PURE__ */ new Map();
7489
+ const specsByResolvedName = /* @__PURE__ */ new Map();
7469
7490
  for (const spec of specs) {
7470
- const part = parseSpec2(spec);
7471
- const current = specsByName.get(part.name);
7472
- if (current === void 0) specsByName.set(part.name, [part.spec]);
7473
- else current.push(part.spec);
7491
+ const identity = specIdentity(parseSpec2(spec));
7492
+ const current = specsByResolvedName.get(identity.resolvedName);
7493
+ if (current === void 0) specsByResolvedName.set(identity.resolvedName, [identity.descriptorKey]);
7494
+ else current.push(identity.descriptorKey);
7474
7495
  }
7475
- for (const [name, rawRanges] of specsByName) {
7476
- const ranges = Array.from(new Set(rawRanges)).sort(cmpUtf16);
7496
+ for (const [name, rawDescriptors] of specsByResolvedName) {
7497
+ const descriptors = Array.from(new Set(rawDescriptors)).sort(cmpUtf16);
7477
7498
  const id = `${name}@${entry.version}`;
7478
7499
  const prior = seenEntries.get(id);
7479
7500
  if (prior !== void 0) {
@@ -7484,8 +7505,7 @@ function parse17(input, options = {}) {
7484
7505
  });
7485
7506
  }
7486
7507
  const merged = sidecar.get(id) ?? [];
7487
- for (const range of ranges) {
7488
- const spec = `${name}@${range}`;
7508
+ for (const spec of descriptors) {
7489
7509
  if (!merged.includes(spec)) merged.push(spec);
7490
7510
  specIndex.set(spec, id);
7491
7511
  }
@@ -7527,14 +7547,14 @@ function parse17(input, options = {}) {
7527
7547
  } else if (canonicalResolution !== void 0) {
7528
7548
  builder.setTarball({ name, version: entry.version }, { resolution: canonicalResolution });
7529
7549
  }
7530
- sidecar.set(id, ranges.map((range) => `${name}@${range}`));
7550
+ sidecar.set(id, descriptors.slice());
7531
7551
  if (entry.extras !== void 0 && entry.extras.length > 0) {
7532
7552
  entryExtras.set(id, entry.extras);
7533
7553
  for (const raw of entry.extras) unknownFields.add(raw.split(" ", 1)[0] ?? raw);
7534
7554
  }
7535
7555
  entryNodes.push({ node, entry });
7536
- for (const range of ranges) {
7537
- specIndex.set(`${name}@${range}`, id);
7556
+ for (const spec of descriptors) {
7557
+ specIndex.set(spec, id);
7538
7558
  }
7539
7559
  }
7540
7560
  }
@@ -7614,7 +7634,7 @@ function stringify16(graph, options = {}) {
7614
7634
  }
7615
7635
  const integrity = payload?.integrity && emitSri(payload.integrity);
7616
7636
  if (integrity !== void 0 && integrity !== "") {
7617
- lines.push(` integrity ${integrity}`);
7637
+ lines.push(` integrity ${integrity.includes(" ") ? `"${integrity}"` : integrity}`);
7618
7638
  }
7619
7639
  const extras = emitSidecar?.entryExtras?.get(node.id);
7620
7640
  if (extras !== void 0) {
@@ -7733,7 +7753,8 @@ function parseEntries(input) {
7733
7753
  continue;
7734
7754
  }
7735
7755
  if (line.startsWith(" integrity ")) {
7736
- current.integrity = line.slice(" integrity ".length);
7756
+ const value = line.slice(" integrity ".length);
7757
+ current.integrity = value.startsWith('"') ? parseQuotedToken(value) : value;
7737
7758
  continue;
7738
7759
  }
7739
7760
  current.extras ??= [];
@@ -7848,6 +7869,19 @@ function parseSpec2(spec) {
7848
7869
  spec: spec.slice(idx + 1)
7849
7870
  };
7850
7871
  }
7872
+ function specIdentity(part) {
7873
+ const descriptorKey = `${part.name}@${part.spec}`;
7874
+ if (part.spec.startsWith("npm:")) {
7875
+ const target = part.spec.slice("npm:".length);
7876
+ const at = target.indexOf("@", target.startsWith("@") ? 1 : 0);
7877
+ const targetName = at > 0 ? target.slice(0, at) : void 0;
7878
+ if (targetName !== void 0 && targetName.length > 0 && targetName !== part.name) {
7879
+ return { resolvedName: targetName, aliasName: part.name, descriptorKey };
7880
+ }
7881
+ return { resolvedName: part.name, descriptorKey };
7882
+ }
7883
+ return { resolvedName: part.name, descriptorKey };
7884
+ }
7851
7885
  function isClassicRegistryRange(range) {
7852
7886
  if (range.startsWith("npm:")) return true;
7853
7887
  const colonIdx = range.indexOf(":");
@@ -7897,11 +7931,14 @@ function addEdgesFromMap(builder, diagnostics, srcId, deps, kind, specIndex, lad
7897
7931
  }
7898
7932
  continue;
7899
7933
  }
7900
- builder.addEdge(srcId, dstId, kind, { range });
7934
+ const dstName = nameOf(dstId);
7935
+ const attrs = { range };
7936
+ if (name !== dstName) attrs.alias = name;
7937
+ builder.addEdge(srcId, dstId, kind, attrs);
7901
7938
  }
7902
7939
  }
7903
7940
  function entrySpecsOfNode(graph, node) {
7904
- const liveSpecs = Array.from(graph.in(node.id)).filter((edge) => edge.kind === "dep" || edge.kind === "optional").map((edge) => edge.attrs?.range).filter((range) => range !== void 0).map((range) => `${node.name}@${range}`);
7941
+ const liveSpecs = Array.from(graph.in(node.id)).filter((edge) => edge.kind === "dep" || edge.kind === "optional").filter((edge) => edge.attrs?.range !== void 0).map((edge) => `${edge.attrs.alias ?? node.name}@${edge.attrs.range}`);
7905
7942
  if (liveSpecs.length > 0) {
7906
7943
  return Array.from(new Set(liveSpecs)).sort(cmpUtf16);
7907
7944
  }
@@ -7966,7 +8003,7 @@ function collectBlockEntries(graph, edges, emitDiagnostic) {
7966
8003
  return [dst.name, resolved];
7967
8004
  }
7968
8005
  }
7969
- return [dst.name, edge.attrs.range];
8006
+ return [edge.attrs.alias ?? dst.name, edge.attrs.range];
7970
8007
  }).filter((entry) => entry !== void 0).sort((a, b) => cmpUtf16(a[0], b[0]));
7971
8008
  }
7972
8009
  function warnDroppedPeerEdges(graph, srcId, warned, emitDiagnostic) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antongolub/lockfile",
3
- "version": "0.0.0-snapshot.53",
3
+ "version": "0.0.0-snapshot.55",
4
4
  "private": false,
5
5
  "description": "Universal lockfile model and converter for npm, yarn, pnpm, bun",
6
6
  "type": "module",