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

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.
package/dist/index.js CHANGED
@@ -10945,6 +10945,12 @@ function optimize(graph, options = {}) {
10945
10945
  }
10946
10946
  }
10947
10947
  }
10948
+ for (const node of graph.nodes()) {
10949
+ if (!live.has(node.id)) continue;
10950
+ if (node.patch === void 0 && node.source === void 0) continue;
10951
+ const baseId = serializeNodeId(node.name, node.version, node.peerContext, void 0, void 0);
10952
+ if (baseId !== node.id && graph.getNode(baseId) !== void 0) live.add(baseId);
10953
+ }
10948
10954
  const removed = [];
10949
10955
  const unresolved = [];
10950
10956
  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.72",
4
4
  "private": false,
5
5
  "description": "Universal lockfile model and converter for npm, yarn, pnpm, bun",
6
6
  "type": "module",