@antongolub/lockfile 0.0.0-snapshot.63 → 0.0.0-snapshot.65

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.
@@ -126,11 +126,12 @@ function tarballKeyInputsOfNode(node) {
126
126
  var cmpStr = (a, b) => a < b ? -1 : a > b ? 1 : 0;
127
127
  var cmpAlias = (a, b) => a === b ? 0 : a === void 0 ? -1 : b === void 0 ? 1 : cmpStr(a, b);
128
128
  var cmpEdgeBy = (end) => (a, b) => {
129
+ var _a, _b;
129
130
  const c = cmpStr(end === "dst" ? a.dst : a.src, end === "dst" ? b.dst : b.src);
130
131
  if (c !== 0) return c;
131
132
  const k = cmpStr(a.kind, b.kind);
132
133
  if (k !== 0) return k;
133
- return cmpAlias(a.attrs?.alias, b.attrs?.alias);
134
+ return cmpAlias((_a = a.attrs) == null ? void 0 : _a.alias, (_b = b.attrs) == null ? void 0 : _b.alias);
134
135
  };
135
136
  function emptyState() {
136
137
  return {
@@ -166,7 +167,10 @@ function removeMatching(arr, pred) {
166
167
  arr.splice(i, 1);
167
168
  return true;
168
169
  }
169
- var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}\0${e.attrs?.alias ?? ""}`;
170
+ var tripleKey = (e) => {
171
+ var _a;
172
+ return `${e.src}\0${e.kind}\0${e.dst}\0${((_a = e.attrs) == null ? void 0 : _a.alias) ?? ""}`;
173
+ };
170
174
  function rebindNodeId(s, oldId, newId, newNode) {
171
175
  s.nodes.set(newId, newNode);
172
176
  s.nodes.delete(oldId);
@@ -177,7 +181,10 @@ function rebindNodeId(s, oldId, newId, newNode) {
177
181
  const peerInc = s.incoming.get(e.dst);
178
182
  if (peerInc) {
179
183
  const idx = peerInc.findIndex(
180
- (x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst && x.attrs?.alias === e.attrs?.alias
184
+ (x) => {
185
+ var _a, _b;
186
+ return x.src === oldId && x.kind === e.kind && x.dst === e.dst && ((_a = x.attrs) == null ? void 0 : _a.alias) === ((_b = e.attrs) == null ? void 0 : _b.alias);
187
+ }
181
188
  );
182
189
  if (idx >= 0) peerInc[idx] = e;
183
190
  }
@@ -189,7 +196,10 @@ function rebindNodeId(s, oldId, newId, newNode) {
189
196
  const peerOut = s.outgoing.get(e.src);
190
197
  if (peerOut) {
191
198
  const idx = peerOut.findIndex(
192
- (x) => x.src === e.src && x.kind === e.kind && x.dst === oldId && x.attrs?.alias === e.attrs?.alias
199
+ (x) => {
200
+ var _a, _b;
201
+ return x.src === e.src && x.kind === e.kind && x.dst === oldId && ((_a = x.attrs) == null ? void 0 : _a.alias) === ((_b = e.attrs) == null ? void 0 : _b.alias);
202
+ }
193
203
  );
194
204
  if (idx >= 0) peerOut[idx] = e;
195
205
  }
@@ -202,12 +212,14 @@ function protocolOf(range) {
202
212
  return /^[a-z][a-z0-9+.-]*$/i.test(prefix) ? prefix : void 0;
203
213
  }
204
214
  function isPublishedSelfLink(edge) {
205
- const range = edge.attrs?.range;
215
+ var _a;
216
+ const range = (_a = edge.attrs) == null ? void 0 : _a.range;
206
217
  if (range === void 0) return false;
207
218
  const proto = protocolOf(range);
208
219
  return proto === void 0 || proto === "npm";
209
220
  }
210
221
  function validate(s) {
222
+ var _a, _b, _c, _d, _e;
211
223
  for (const d of s.diagnostics) {
212
224
  if (d.severity === "error") {
213
225
  throw new GraphError("INVARIANT_VIOLATION", `unresolved error diagnostic: ${d.code} \u2014 ${d.message}`);
@@ -224,7 +236,7 @@ function validate(s) {
224
236
  }
225
237
  const k = tripleKey(e);
226
238
  if (seen.has(k)) {
227
- const aliasSuffix = e.attrs?.alias !== void 0 ? ` (alias=${e.attrs.alias})` : "";
239
+ const aliasSuffix = ((_a = e.attrs) == null ? void 0 : _a.alias) !== void 0 ? ` (alias=${e.attrs.alias})` : "";
228
240
  throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}${aliasSuffix}`);
229
241
  }
230
242
  seen.add(k);
@@ -234,14 +246,14 @@ function validate(s) {
234
246
  if (node.workspacePath !== void 0) {
235
247
  const inc = s.incoming.get(id) ?? [];
236
248
  for (const edge of inc) {
237
- if (s.nodes.get(edge.src)?.workspacePath !== void 0) continue;
238
- if (s.tarballs.get(stripPeerContextFromNodeId(edge.src))?.resolution?.type === "directory") continue;
249
+ if (((_b = s.nodes.get(edge.src)) == null ? void 0 : _b.workspacePath) !== void 0) continue;
250
+ if (((_d = (_c = s.tarballs.get(stripPeerContextFromNodeId(edge.src))) == null ? void 0 : _c.resolution) == null ? void 0 : _d.type) === "directory") continue;
239
251
  if (isPublishedSelfLink(edge)) {
240
252
  s.diagnostics.push({
241
253
  code: "SEAL_PUBLISHED_SELF_LINK",
242
254
  subject: id,
243
255
  severity: "info",
244
- message: `published self-link: ${edge.src} \u2192${edge.kind} ${id} (range ${edge.attrs?.range}) \u2014 published dependency resolved to co-located workspace`
256
+ message: `published self-link: ${edge.src} \u2192${edge.kind} ${id} (range ${(_e = edge.attrs) == null ? void 0 : _e.range}) \u2014 published dependency resolved to co-located workspace`
245
257
  });
246
258
  continue;
247
259
  }
@@ -315,9 +327,9 @@ var GraphImpl = class _GraphImpl {
315
327
  }
316
328
  }
317
329
  *walk(seeds, opts) {
318
- const direction = opts?.direction ?? "out";
319
- const kinds = opts?.kinds;
320
- const maxDepth = opts?.maxDepth ?? Infinity;
330
+ const direction = (opts == null ? void 0 : opts.direction) ?? "out";
331
+ const kinds = opts == null ? void 0 : opts.kinds;
332
+ const maxDepth = (opts == null ? void 0 : opts.maxDepth) ?? Infinity;
321
333
  const visited = /* @__PURE__ */ new Set();
322
334
  const initial = Array.isArray(seeds) ? seeds : [seeds];
323
335
  const stack = [];
@@ -525,8 +537,11 @@ var GraphImpl = class _GraphImpl {
525
537
  if (!next.nodes.has(src)) throw new GraphError("PATCH_REJECTED", `addEdge: src ${src} missing`);
526
538
  if (!next.nodes.has(dst)) throw new GraphError("PATCH_REJECTED", `addEdge: dst ${dst} missing`);
527
539
  const existing = next.outgoing.get(src) ?? [];
528
- const newAlias = attrs?.alias;
529
- if (existing.some((e2) => e2.dst === dst && e2.kind === kind && e2.attrs?.alias === newAlias)) {
540
+ const newAlias = attrs == null ? void 0 : attrs.alias;
541
+ if (existing.some((e2) => {
542
+ var _a;
543
+ return e2.dst === dst && e2.kind === kind && ((_a = e2.attrs) == null ? void 0 : _a.alias) === newAlias;
544
+ })) {
530
545
  const aliasSuffix = newAlias !== void 0 ? ` (alias=${newAlias})` : "";
531
546
  throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}${aliasSuffix}`);
532
547
  }
@@ -536,16 +551,20 @@ var GraphImpl = class _GraphImpl {
536
551
  applied.push({ kind: "edge-added", subject: { src, dst, kind } });
537
552
  },
538
553
  removeEdge(src, dst, kind) {
554
+ var _a, _b;
539
555
  const outs = next.outgoing.get(src);
540
556
  let removedAlias;
541
- const found = outs?.findIndex((e) => e.dst === dst && e.kind === kind) ?? -1;
557
+ const found = (outs == null ? void 0 : outs.findIndex((e) => e.dst === dst && e.kind === kind)) ?? -1;
542
558
  if (!outs || found < 0) {
543
559
  throw new GraphError("PATCH_REJECTED", `removeEdge: ${src} \u2192${kind} ${dst} missing`);
544
560
  }
545
- removedAlias = outs[found]?.attrs?.alias;
561
+ removedAlias = (_b = (_a = outs[found]) == null ? void 0 : _a.attrs) == null ? void 0 : _b.alias;
546
562
  outs.splice(found, 1);
547
563
  const ins = next.incoming.get(dst);
548
- if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind && e.attrs?.alias === removedAlias);
564
+ if (ins) removeMatching(ins, (e) => {
565
+ var _a2;
566
+ return e.src === src && e.kind === kind && ((_a2 = e.attrs) == null ? void 0 : _a2.alias) === removedAlias;
567
+ });
549
568
  applied.push({ kind: "edge-removed", subject: { src, dst, kind } });
550
569
  },
551
570
  replacePeerContext(id, peers) {
@@ -740,12 +759,14 @@ function bunTextWouldCollapse(specifier) {
740
759
  return isWorkspaceSpecifier(specifier);
741
760
  }
742
761
  function isWorkspaceEdge(edge) {
743
- return edge.attrs?.workspace === true;
762
+ var _a;
763
+ return ((_a = edge.attrs) == null ? void 0 : _a.workspace) === true;
744
764
  }
745
765
  function workspaceRangeOfEdge(edge, dst) {
766
+ var _a, _b;
746
767
  if (!isWorkspaceEdge(edge)) return void 0;
747
- if (edge.attrs?.workspaceRange !== void 0) return edge.attrs.workspaceRange;
748
- const specifier = edge.attrs?.range ?? "";
768
+ if (((_a = edge.attrs) == null ? void 0 : _a.workspaceRange) !== void 0) return edge.attrs.workspaceRange;
769
+ const specifier = ((_b = edge.attrs) == null ? void 0 : _b.range) ?? "";
749
770
  const sourceLooksProtocol = isWorkspaceSpecifier(specifier);
750
771
  const canonicalSpecifier = sourceLooksProtocol ? specifier : "";
751
772
  if (dst.version === void 0 || dst.version === "") return { specifier: canonicalSpecifier };
@@ -938,7 +959,8 @@ function rememberSidecar(graph, sidecar) {
938
959
  sidecarByGraph.set(graph, sidecar);
939
960
  }
940
961
  function getBunOverridesCanonical(graph) {
941
- return sidecarByGraph.get(graph)?.canonicalOverrides;
962
+ var _a;
963
+ return (_a = sidecarByGraph.get(graph)) == null ? void 0 : _a.canonicalOverrides;
942
964
  }
943
965
  function check(input) {
944
966
  if (!/"lockfileVersion"\s*:\s*1\b/.test(input)) return false;
@@ -1026,7 +1048,7 @@ function parse(input, _options = {}) {
1026
1048
  continue;
1027
1049
  }
1028
1050
  const wsManifest = workspaces[parsed2.path];
1029
- const wsVersion = wsManifest?.version ?? "0.0.0";
1051
+ const wsVersion = (wsManifest == null ? void 0 : wsManifest.version) ?? "0.0.0";
1030
1052
  const wsId = `${parsed2.name}@${wsVersion}`;
1031
1053
  if (!seenNodeIds.has(wsId)) {
1032
1054
  seenNodeIds.add(wsId);
@@ -1155,24 +1177,28 @@ function parse(input, _options = {}) {
1155
1177
  }
1156
1178
  }
1157
1179
  function stringify(graph, options = {}) {
1180
+ var _a, _b, _c;
1158
1181
  const sidecar = sidecarByGraph.get(graph);
1159
- const emitDiagnostic = (diagnostic) => options.onDiagnostic?.(diagnostic);
1182
+ const emitDiagnostic = (diagnostic) => {
1183
+ var _a2;
1184
+ return (_a2 = options.onDiagnostic) == null ? void 0 : _a2.call(options, diagnostic);
1185
+ };
1160
1186
  const warnedPatches = /* @__PURE__ */ new Set();
1161
1187
  const warnedPeerVirt = /* @__PURE__ */ new Set();
1162
1188
  const rootNode = locateRootNode(graph, sidecar);
1163
1189
  const memberNodes = Array.from(graph.nodes()).filter((n) => n.workspacePath !== void 0 && n.workspacePath !== "").sort((a, b) => cmpStr2(a.workspacePath, b.workspacePath));
1164
1190
  const workspacesBlock = {
1165
- "": buildWorkspaceManifest(graph, rootNode, sidecar?.workspaces.get("")?.manifest, emitDiagnostic)
1191
+ "": buildWorkspaceManifest(graph, rootNode, (_a = sidecar == null ? void 0 : sidecar.workspaces.get("")) == null ? void 0 : _a.manifest, emitDiagnostic)
1166
1192
  };
1167
1193
  for (const member of memberNodes) {
1168
1194
  const path = member.workspacePath;
1169
- workspacesBlock[path] = buildWorkspaceManifest(graph, member, sidecar?.workspaces.get(path)?.manifest, emitDiagnostic);
1195
+ workspacesBlock[path] = buildWorkspaceManifest(graph, member, (_b = sidecar == null ? void 0 : sidecar.workspaces.get(path)) == null ? void 0 : _b.manifest, emitDiagnostic);
1170
1196
  }
1171
1197
  const packagesBlock = {};
1172
1198
  for (const member of [...memberNodes].sort((a, b) => cmpStr2(a.name, b.name))) {
1173
1199
  packagesBlock[member.name] = [`${member.name}@workspace:${member.workspacePath}`];
1174
1200
  }
1175
- const regularNodes = Array.from(graph.nodes()).filter((n) => n.id !== rootNode?.id && n.workspacePath === void 0).sort(
1201
+ const regularNodes = Array.from(graph.nodes()).filter((n) => n.id !== (rootNode == null ? void 0 : rootNode.id) && n.workspacePath === void 0).sort(
1176
1202
  (a, b) => cmpStr2(a.name, b.name) || cmpStr2(a.version, b.version) || (a.patch === void 0 ? 0 : 1) - (b.patch === void 0 ? 0 : 1)
1177
1203
  );
1178
1204
  const warnedResolutions = /* @__PURE__ */ new Set();
@@ -1187,7 +1213,7 @@ function stringify(graph, options = {}) {
1187
1213
  }
1188
1214
  emittedNameVersion.add(nameVersion);
1189
1215
  const inner = buildInnerBlock(graph, node, sidecar);
1190
- const integritySrc = graph.tarballOf(node.id)?.integrity;
1216
+ const integritySrc = (_c = graph.tarballOf(node.id)) == null ? void 0 : _c.integrity;
1191
1217
  const integrity = (integritySrc && emitSri(integritySrc)) ?? "";
1192
1218
  const key = chooseNodeEmitKey(node, sidecar, packagesBlock);
1193
1219
  packagesBlock[key] = [`${node.name}@${node.version}`, "", inner, integrity];
@@ -1201,10 +1227,10 @@ function stringify(graph, options = {}) {
1201
1227
  out.overrides = overridesBlock;
1202
1228
  }
1203
1229
  out.packages = packagesBlock;
1204
- if (sidecar?.patchedDependencies !== void 0 && Object.keys(sidecar.patchedDependencies).length > 0) {
1230
+ if ((sidecar == null ? void 0 : sidecar.patchedDependencies) !== void 0 && Object.keys(sidecar.patchedDependencies).length > 0) {
1205
1231
  out.patchedDependencies = sortRecord(sidecar.patchedDependencies);
1206
1232
  }
1207
- if (sidecar?.trustedDependencies !== void 0 && sidecar.trustedDependencies.length > 0) {
1233
+ if ((sidecar == null ? void 0 : sidecar.trustedDependencies) !== void 0 && sidecar.trustedDependencies.length > 0) {
1208
1234
  out.trustedDependencies = [...sidecar.trustedDependencies].sort(cmpStr2);
1209
1235
  }
1210
1236
  const json = renderJsonc(out);
@@ -1214,8 +1240,8 @@ function resolveOverridesBlock(callerOverrides, sidecar, emitDiagnostic) {
1214
1240
  if (callerOverrides !== void 0) {
1215
1241
  return callerOverrides.length > 0 ? projectOverrides(callerOverrides, "npm", emitDiagnostic) : void 0;
1216
1242
  }
1217
- if (sidecar?.nativeOverrides !== void 0) return sidecar.nativeOverrides;
1218
- if (sidecar?.canonicalOverrides !== void 0 && sidecar.canonicalOverrides.length > 0) {
1243
+ if ((sidecar == null ? void 0 : sidecar.nativeOverrides) !== void 0) return sidecar.nativeOverrides;
1244
+ if ((sidecar == null ? void 0 : sidecar.canonicalOverrides) !== void 0 && sidecar.canonicalOverrides.length > 0) {
1219
1245
  return projectOverrides(sidecar.canonicalOverrides, "npm", emitDiagnostic);
1220
1246
  }
1221
1247
  return void 0;
@@ -1539,7 +1565,7 @@ function isWorkspaceProtocolRange(range) {
1539
1565
  return range.startsWith("workspace:");
1540
1566
  }
1541
1567
  function locateRootNode(graph, sidecar) {
1542
- if (sidecar?.rootId !== void 0) {
1568
+ if ((sidecar == null ? void 0 : sidecar.rootId) !== void 0) {
1543
1569
  const node = graph.getNode(sidecar.rootId);
1544
1570
  if (node !== void 0) return node;
1545
1571
  }
@@ -1554,6 +1580,7 @@ function locateRootNode(graph, sidecar) {
1554
1580
  return void 0;
1555
1581
  }
1556
1582
  function buildWorkspaceManifest(graph, workspaceNode, sidecarManifest, emitDiagnostic = () => void 0) {
1583
+ var _a;
1557
1584
  const out = {};
1558
1585
  if (workspaceNode !== void 0) {
1559
1586
  out.name = workspaceNode.name;
@@ -1572,7 +1599,7 @@ function buildWorkspaceManifest(graph, workspaceNode, sidecarManifest, emitDiagn
1572
1599
  for (const edge of graph.out(workspaceNode.id)) {
1573
1600
  const dst = graph.getNode(edge.dst);
1574
1601
  if (dst === void 0) continue;
1575
- const range = edge.attrs?.range;
1602
+ const range = (_a = edge.attrs) == null ? void 0 : _a.range;
1576
1603
  if (typeof range !== "string") continue;
1577
1604
  const target = edge.kind === "dep" ? dependencies : edge.kind === "dev" ? devDependencies : edge.kind === "optional" ? optionalDependencies : edge.kind === "peer" ? peerDependencies : void 0;
1578
1605
  if (target === void 0) continue;
@@ -1601,18 +1628,19 @@ function buildWorkspaceManifest(graph, workspaceNode, sidecarManifest, emitDiagn
1601
1628
  return out;
1602
1629
  }
1603
1630
  function buildInnerBlock(graph, node, sidecar) {
1631
+ var _a, _b, _c;
1604
1632
  const dependencies = {};
1605
1633
  const optionalDependencies = {};
1606
1634
  const peerDependencies = {};
1607
1635
  for (const edge of graph.out(node.id)) {
1608
1636
  const dst = graph.getNode(edge.dst);
1609
1637
  if (dst === void 0) continue;
1610
- const range = edge.attrs?.range;
1638
+ const range = (_a = edge.attrs) == null ? void 0 : _a.range;
1611
1639
  if (typeof range !== "string") continue;
1612
1640
  const target = edge.kind === "dep" || edge.kind === "dev" ? dependencies : edge.kind === "optional" ? optionalDependencies : edge.kind === "peer" ? peerDependencies : void 0;
1613
1641
  if (target !== void 0) target[dst.name] = range;
1614
1642
  }
1615
- for (const [key, range] of sidecar?.peerDeclarations ?? []) {
1643
+ for (const [key, range] of (sidecar == null ? void 0 : sidecar.peerDeclarations) ?? []) {
1616
1644
  const sep = key.indexOf("|");
1617
1645
  if (sep < 0 || key.slice(0, sep) !== node.id) continue;
1618
1646
  const peerName = key.slice(sep + 1);
@@ -1622,12 +1650,13 @@ function buildInnerBlock(graph, node, sidecar) {
1622
1650
  if (Object.keys(dependencies).length > 0) inner.dependencies = sortRecord(dependencies);
1623
1651
  if (Object.keys(optionalDependencies).length > 0) inner.optionalDependencies = sortRecord(optionalDependencies);
1624
1652
  if (Object.keys(peerDependencies).length > 0) inner.peerDependencies = sortRecord(peerDependencies);
1625
- const stashedBin = sidecar?.nodes.get(node.id)?.inner?.bin;
1653
+ const stashedBin = (_c = (_b = sidecar == null ? void 0 : sidecar.nodes.get(node.id)) == null ? void 0 : _b.inner) == null ? void 0 : _c.bin;
1626
1654
  if (stashedBin !== void 0) inner.bin = stashedBin;
1627
1655
  return inner;
1628
1656
  }
1629
1657
  function chooseNodeEmitKey(node, sidecar, alreadyEmitted) {
1630
- const stored = sidecar?.nodes.get(node.id)?.packagesKey;
1658
+ var _a;
1659
+ const stored = (_a = sidecar == null ? void 0 : sidecar.nodes.get(node.id)) == null ? void 0 : _a.packagesKey;
1631
1660
  if (stored !== void 0 && alreadyEmitted[stored] === void 0) {
1632
1661
  return stored;
1633
1662
  }
@@ -1645,8 +1674,9 @@ function warnPatchDrop(node, warned, emitDiagnostic) {
1645
1674
  );
1646
1675
  }
1647
1676
  function warnResolutionDrop(graph, node, warned, emitDiagnostic) {
1677
+ var _a;
1648
1678
  if (warned.has(node.id)) return;
1649
- const canonical = graph.tarballOf(node.id)?.resolution;
1679
+ const canonical = (_a = graph.tarballOf(node.id)) == null ? void 0 : _a.resolution;
1650
1680
  if (canonical === void 0) return;
1651
1681
  if (canonical.type === "tarball") return;
1652
1682
  if (canonical.type === "unknown" && node.patch !== void 0) return;