@antongolub/lockfile 0.0.0-snapshot.71 → 0.0.0-snapshot.73

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.
@@ -1487,6 +1487,13 @@ function distTagResolve(range, candidates) {
1487
1487
  const ids = eligible.map((c) => c.id).sort(cmpStr2);
1488
1488
  return { kind: "ambiguous", candidateIds: ids };
1489
1489
  }
1490
+ function catalogResolve(range, candidates) {
1491
+ if (!range.startsWith("catalog:")) return { kind: "none" };
1492
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1493
+ if (eligible.length === 0) return { kind: "none" };
1494
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1495
+ return { kind: "ambiguous", candidateIds: eligible.map((c) => c.id).sort(cmpStr2) };
1496
+ }
1490
1497
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1491
1498
  let best;
1492
1499
  let bestScore = -1;
@@ -2941,6 +2948,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2941
2948
  continue;
2942
2949
  }
2943
2950
  }
2951
+ if (dstId === void 0) {
2952
+ const result = catalogResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2953
+ if (result.kind === "bound") dstId = result.id;
2954
+ }
2944
2955
  if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2945
2956
  const bound = nodeNameVersion(dstId);
2946
2957
  const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
@@ -1487,6 +1487,13 @@ function distTagResolve(range, candidates) {
1487
1487
  const ids = eligible.map((c) => c.id).sort(cmpStr2);
1488
1488
  return { kind: "ambiguous", candidateIds: ids };
1489
1489
  }
1490
+ function catalogResolve(range, candidates) {
1491
+ if (!range.startsWith("catalog:")) return { kind: "none" };
1492
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1493
+ if (eligible.length === 0) return { kind: "none" };
1494
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1495
+ return { kind: "ambiguous", candidateIds: eligible.map((c) => c.id).sort(cmpStr2) };
1496
+ }
1490
1497
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1491
1498
  let best;
1492
1499
  let bestScore = -1;
@@ -2945,6 +2952,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2945
2952
  continue;
2946
2953
  }
2947
2954
  }
2955
+ if (dstId === void 0) {
2956
+ const result = catalogResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2957
+ if (result.kind === "bound") dstId = result.id;
2958
+ }
2948
2959
  if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2949
2960
  const bound = nodeNameVersion(dstId);
2950
2961
  const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
@@ -1487,6 +1487,13 @@ function distTagResolve(range, candidates) {
1487
1487
  const ids = eligible.map((c) => c.id).sort(cmpStr2);
1488
1488
  return { kind: "ambiguous", candidateIds: ids };
1489
1489
  }
1490
+ function catalogResolve(range, candidates) {
1491
+ if (!range.startsWith("catalog:")) return { kind: "none" };
1492
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1493
+ if (eligible.length === 0) return { kind: "none" };
1494
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1495
+ return { kind: "ambiguous", candidateIds: eligible.map((c) => c.id).sort(cmpStr2) };
1496
+ }
1490
1497
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1491
1498
  let best;
1492
1499
  let bestScore = -1;
@@ -2940,6 +2947,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2940
2947
  continue;
2941
2948
  }
2942
2949
  }
2950
+ if (dstId === void 0) {
2951
+ const result = catalogResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2952
+ if (result.kind === "bound") dstId = result.id;
2953
+ }
2943
2954
  if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2944
2955
  const bound = nodeNameVersion(dstId);
2945
2956
  const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
@@ -1487,6 +1487,13 @@ function distTagResolve(range, candidates) {
1487
1487
  const ids = eligible.map((c) => c.id).sort(cmpStr2);
1488
1488
  return { kind: "ambiguous", candidateIds: ids };
1489
1489
  }
1490
+ function catalogResolve(range, candidates) {
1491
+ if (!range.startsWith("catalog:")) return { kind: "none" };
1492
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1493
+ if (eligible.length === 0) return { kind: "none" };
1494
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1495
+ return { kind: "ambiguous", candidateIds: eligible.map((c) => c.id).sort(cmpStr2) };
1496
+ }
1490
1497
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1491
1498
  let best;
1492
1499
  let bestScore = -1;
@@ -2940,6 +2947,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2940
2947
  continue;
2941
2948
  }
2942
2949
  }
2950
+ if (dstId === void 0) {
2951
+ const result = catalogResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2952
+ if (result.kind === "bound") dstId = result.id;
2953
+ }
2943
2954
  if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2944
2955
  const bound = nodeNameVersion(dstId);
2945
2956
  const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
@@ -1487,6 +1487,13 @@ function distTagResolve(range, candidates) {
1487
1487
  const ids = eligible.map((c) => c.id).sort(cmpStr2);
1488
1488
  return { kind: "ambiguous", candidateIds: ids };
1489
1489
  }
1490
+ function catalogResolve(range, candidates) {
1491
+ if (!range.startsWith("catalog:")) return { kind: "none" };
1492
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1493
+ if (eligible.length === 0) return { kind: "none" };
1494
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1495
+ return { kind: "ambiguous", candidateIds: eligible.map((c) => c.id).sort(cmpStr2) };
1496
+ }
1490
1497
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1491
1498
  let best;
1492
1499
  let bestScore = -1;
@@ -2940,6 +2947,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2940
2947
  continue;
2941
2948
  }
2942
2949
  }
2950
+ if (dstId === void 0) {
2951
+ const result = catalogResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2952
+ if (result.kind === "bound") dstId = result.id;
2953
+ }
2943
2954
  if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2944
2955
  const bound = nodeNameVersion(dstId);
2945
2956
  const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
@@ -1487,6 +1487,13 @@ function distTagResolve(range, candidates) {
1487
1487
  const ids = eligible.map((c) => c.id).sort(cmpStr2);
1488
1488
  return { kind: "ambiguous", candidateIds: ids };
1489
1489
  }
1490
+ function catalogResolve(range, candidates) {
1491
+ if (!range.startsWith("catalog:")) return { kind: "none" };
1492
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1493
+ if (eligible.length === 0) return { kind: "none" };
1494
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1495
+ return { kind: "ambiguous", candidateIds: eligible.map((c) => c.id).sort(cmpStr2) };
1496
+ }
1490
1497
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1491
1498
  let best;
1492
1499
  let bestScore = -1;
@@ -2941,6 +2948,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2941
2948
  continue;
2942
2949
  }
2943
2950
  }
2951
+ if (dstId === void 0) {
2952
+ const result = catalogResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2953
+ if (result.kind === "bound") dstId = result.id;
2954
+ }
2944
2955
  if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2945
2956
  const bound = nodeNameVersion(dstId);
2946
2957
  const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
@@ -1487,6 +1487,13 @@ function distTagResolve(range, candidates) {
1487
1487
  const ids = eligible.map((c) => c.id).sort(cmpStr2);
1488
1488
  return { kind: "ambiguous", candidateIds: ids };
1489
1489
  }
1490
+ function catalogResolve(range, candidates) {
1491
+ if (!range.startsWith("catalog:")) return { kind: "none" };
1492
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
1493
+ if (eligible.length === 0) return { kind: "none" };
1494
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
1495
+ return { kind: "ambiguous", candidateIds: eligible.map((c) => c.id).sort(cmpStr2) };
1496
+ }
1490
1497
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
1491
1498
  let best;
1492
1499
  let bestScore = -1;
@@ -2941,6 +2948,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
2941
2948
  continue;
2942
2949
  }
2943
2950
  }
2951
+ if (dstId === void 0) {
2952
+ const result = catalogResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
2953
+ if (result.kind === "bound") dstId = result.id;
2954
+ }
2944
2955
  if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
2945
2956
  const bound = nodeNameVersion(dstId);
2946
2957
  const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
package/dist/index.js CHANGED
@@ -6382,6 +6382,13 @@ function distTagResolve(range, candidates) {
6382
6382
  const ids = eligible.map((c) => c.id).sort(cmpStr4);
6383
6383
  return { kind: "ambiguous", candidateIds: ids };
6384
6384
  }
6385
+ function catalogResolve(range, candidates) {
6386
+ if (!range.startsWith("catalog:")) return { kind: "none" };
6387
+ const eligible = candidates.filter((c) => c.sourceType === "tarball");
6388
+ if (eligible.length === 0) return { kind: "none" };
6389
+ if (eligible.length === 1) return { kind: "bound", id: eligible[0].id };
6390
+ return { kind: "ambiguous", candidateIds: eligible.map((c) => c.id).sort(cmpStr4) };
6391
+ }
6385
6392
  function overrideTargetFor(depName, declaredRange, consumerPath, overrides) {
6386
6393
  let best;
6387
6394
  let bestScore = -1;
@@ -7451,6 +7458,10 @@ function addEdgesFromBlock(builder, srcId, block, kind, index, patchDescriptorIn
7451
7458
  continue;
7452
7459
  }
7453
7460
  }
7461
+ if (dstId === void 0) {
7462
+ const result = catalogResolve(normalizedRange, ladder.candidatesByName.get(depName) ?? []);
7463
+ if (result.kind === "bound") dstId = result.id;
7464
+ }
7454
7465
  if (typeof dstId === "string" && !boundViaOverride && isRegistryRange(normalizedRange)) {
7455
7466
  const bound = nodeNameVersion(dstId);
7456
7467
  const siblings = bound === void 0 ? void 0 : ladder.patchSiblingsByBase.get(bound);
@@ -10945,6 +10956,12 @@ function optimize(graph, options = {}) {
10945
10956
  }
10946
10957
  }
10947
10958
  }
10959
+ for (const node of graph.nodes()) {
10960
+ if (!live.has(node.id)) continue;
10961
+ if (node.patch === void 0 && node.source === void 0) continue;
10962
+ const baseId = serializeNodeId(node.name, node.version, node.peerContext, void 0, void 0);
10963
+ if (baseId !== node.id && graph.getNode(baseId) !== void 0) live.add(baseId);
10964
+ }
10948
10965
  const removed = [];
10949
10966
  const unresolved = [];
10950
10967
  let next = graph;
package/dist/optimize.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'crypto';
2
2
  import 'buffer';
3
3
 
4
- // src/main/ts/recipe/patch.ts
4
+ // src/main/ts/errors.ts
5
5
 
6
6
  // src/main/ts/graph.ts
7
7
  function nameOf(id) {
@@ -15,6 +15,16 @@ function nameOf(id) {
15
15
  }
16
16
  return lastAt < 0 ? id : id.slice(0, lastAt);
17
17
  }
18
+ function serializeNodeId(name, version, peerContext, patch, source) {
19
+ const base = toTarballKey({ name, version});
20
+ if (peerContext.length === 0) return base;
21
+ return base + peerContext.map((p) => `(${p})`).join("");
22
+ }
23
+ function toTarballKey(inputs) {
24
+ const slots = [];
25
+ return slots.length === 0 ? `${inputs.name}@${inputs.version}` : `${inputs.name}@${inputs.version}+${slots.sort(cmpStr).join("+")}`;
26
+ }
27
+ var cmpStr = (a, b) => a < b ? -1 : a > b ? 1 : 0;
18
28
 
19
29
  // src/main/ts/optimize/diagnostics.ts
20
30
  function optimizeNodeRemoved(nodeId) {
@@ -136,6 +146,12 @@ function optimize(graph, options = {}) {
136
146
  }
137
147
  }
138
148
  }
149
+ for (const node of graph.nodes()) {
150
+ if (!live.has(node.id)) continue;
151
+ if (node.patch === void 0 && node.source === void 0) continue;
152
+ const baseId = serializeNodeId(node.name, node.version, node.peerContext);
153
+ if (baseId !== node.id && graph.getNode(baseId) !== void 0) live.add(baseId);
154
+ }
139
155
  const removed = [];
140
156
  const unresolved = [];
141
157
  let next = graph;
@@ -209,7 +225,9 @@ function pruneOrphans(graph, options = {}) {
209
225
  if (node === void 0) return false;
210
226
  if (node.workspacePath !== void 0) return false;
211
227
  if (preserve.has(id)) return false;
212
- return current.in(id).length === 0;
228
+ if (current.in(id).length > 0) return false;
229
+ if (hasLivePatchedVariant(current, node)) return false;
230
+ return true;
213
231
  };
214
232
  const queue = [];
215
233
  if (options.seed !== void 0) {
@@ -244,6 +262,18 @@ function pruneOrphans(graph, options = {}) {
244
262
  }
245
263
  return { graph: current, removed, unresolved };
246
264
  }
265
+ function hasLivePatchedVariant(graph, node) {
266
+ if (node.patch !== void 0 || node.source !== void 0) return false;
267
+ for (const id of graph.byName(node.name)) {
268
+ if (id === node.id) continue;
269
+ const other = graph.getNode(id);
270
+ if (other === void 0) continue;
271
+ if (other.patch === void 0 && other.source === void 0) continue;
272
+ if (other.version !== node.version) continue;
273
+ if (serializeNodeId(other.name, other.version, other.peerContext) === node.id) return true;
274
+ }
275
+ return false;
276
+ }
247
277
  function tarballSharedByOther(graph, removingId, key) {
248
278
  for (const id of graph.byName(key.name)) {
249
279
  if (id === removingId) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antongolub/lockfile",
3
- "version": "0.0.0-snapshot.71",
3
+ "version": "0.0.0-snapshot.73",
4
4
  "private": false,
5
5
  "description": "Universal lockfile model and converter for npm, yarn, pnpm, bun",
6
6
  "type": "module",