@antongolub/lockfile 0.0.0-snapshot.45 → 0.0.0-snapshot.46

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.
Files changed (46) hide show
  1. package/SCHEMAS.md +1 -0
  2. package/dist/{_npm-flat-types-5XRp-_Te.d.ts → _npm-flat-types-C3oOIC0o.d.ts} +1 -1
  3. package/dist/{_pnpm-flat-core-DtT-PfX-.d.ts → _pnpm-flat-core-C5VUToQP.d.ts} +1 -1
  4. package/dist/{_yarn-berry-core-nexIf1L1.d.ts → _yarn-berry-core-sjtp6At6.d.ts} +1 -1
  5. package/dist/complete.d.ts +1 -1
  6. package/dist/formats/bun-text.d.ts +1 -1
  7. package/dist/formats/bun-text.js +48 -12
  8. package/dist/formats/npm-1.d.ts +1 -1
  9. package/dist/formats/npm-1.js +48 -12
  10. package/dist/formats/npm-2.d.ts +2 -2
  11. package/dist/formats/npm-2.js +72 -17
  12. package/dist/formats/npm-3.d.ts +2 -2
  13. package/dist/formats/npm-3.js +72 -17
  14. package/dist/formats/pnpm-v5.d.ts +1 -1
  15. package/dist/formats/pnpm-v5.js +90 -16
  16. package/dist/formats/pnpm-v6.d.ts +2 -2
  17. package/dist/formats/pnpm-v6.js +85 -16
  18. package/dist/formats/pnpm-v9.d.ts +2 -2
  19. package/dist/formats/pnpm-v9.js +85 -16
  20. package/dist/formats/yarn-berry-v10.d.ts +24 -0
  21. package/dist/formats/yarn-berry-v10.js +2380 -0
  22. package/dist/formats/yarn-berry-v4.d.ts +2 -2
  23. package/dist/formats/yarn-berry-v4.js +113 -26
  24. package/dist/formats/yarn-berry-v5.d.ts +2 -2
  25. package/dist/formats/yarn-berry-v5.js +113 -26
  26. package/dist/formats/yarn-berry-v6.d.ts +2 -2
  27. package/dist/formats/yarn-berry-v6.js +113 -26
  28. package/dist/formats/yarn-berry-v7.d.ts +2 -2
  29. package/dist/formats/yarn-berry-v7.js +113 -26
  30. package/dist/formats/yarn-berry-v8.d.ts +2 -2
  31. package/dist/formats/yarn-berry-v8.js +113 -26
  32. package/dist/formats/yarn-berry-v9.d.ts +2 -2
  33. package/dist/formats/yarn-berry-v9.js +113 -26
  34. package/dist/formats/yarn-classic.d.ts +1 -1
  35. package/dist/formats/yarn-classic.js +48 -12
  36. package/dist/{graph-DbCmOfBk.d.ts → graph-XpDkFSjz.d.ts} +1 -0
  37. package/dist/index.d.ts +4 -3
  38. package/dist/index.js +361 -54
  39. package/dist/{modify-Qsze2kCh.d.ts → modify-C4BdPHYO.d.ts} +1 -1
  40. package/dist/modify.d.ts +2 -2
  41. package/dist/modify.js +4 -4
  42. package/dist/optimize-Du6S8Ld1.d.ts +33 -0
  43. package/dist/optimize.d.ts +24 -0
  44. package/dist/optimize.js +132 -0
  45. package/dist/registry.d.ts +1 -1
  46. package/package.json +10 -1
package/SCHEMAS.md CHANGED
@@ -33,6 +33,7 @@ berry's `__metadata`.
33
33
  | `yarn-berry-v6` | `__metadata.version: 6` | yarn `>=3.2 <4` | yarn `>=3.2` |
34
34
  | `yarn-berry-v8` | `__metadata.version: 8` | yarn `>=4.0 <4.14` | yarn `>=4` |
35
35
  | `yarn-berry-v9` | `__metadata.version: 9` | yarn `>=4.14` | yarn `>=4.14` |
36
+ | `yarn-berry-v10` | `__metadata.version: 10` | yarn 5 (dev branch) | yarn 5+ (preview — reverse-engineered from yarnpkg/berry master) |
36
37
 
37
38
  **Schema numbers that don't exist:**
38
39
  - `__metadata.version: 1` and `2` were never used by berry.
@@ -1,4 +1,4 @@
1
- import { D as Diagnostic } from './graph-DbCmOfBk.js';
1
+ import { D as Diagnostic } from './graph-XpDkFSjz.js';
2
2
 
3
3
  interface NpmFamilyParseOptions {
4
4
  }
@@ -1,4 +1,4 @@
1
- import { D as Diagnostic } from './graph-DbCmOfBk.js';
1
+ import { D as Diagnostic } from './graph-XpDkFSjz.js';
2
2
 
3
3
  interface PnpmFamilyParseOptions {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { D as Diagnostic } from './graph-DbCmOfBk.js';
1
+ import { D as Diagnostic } from './graph-XpDkFSjz.js';
2
2
 
3
3
  interface YarnBerryFamilyParseOptions {
4
4
  workspaceRoot?: string;
@@ -1,4 +1,4 @@
1
- import { N as NodeId, D as Diagnostic, G as Graph, E as EdgeTriple, a as Node, b as EdgeKind } from './graph-DbCmOfBk.js';
1
+ import { N as NodeId, D as Diagnostic, G as Graph, E as EdgeTriple, a as Node, b as EdgeKind } from './graph-XpDkFSjz.js';
2
2
  import { R as RegistryAdapter } from './types-Ci06KZkZ.js';
3
3
 
4
4
  interface CompletionSeed {
@@ -1,4 +1,4 @@
1
- import { D as Diagnostic, G as Graph } from '../graph-DbCmOfBk.js';
1
+ import { D as Diagnostic, G as Graph } from '../graph-XpDkFSjz.js';
2
2
 
3
3
  interface BunTextParseOptions {
4
4
  }
@@ -98,9 +98,13 @@ function tarballKeyInputsOfNode(node) {
98
98
  };
99
99
  }
100
100
  var cmpStr = (a, b) => a < b ? -1 : a > b ? 1 : 0;
101
+ var cmpAlias = (a, b) => a === b ? 0 : a === void 0 ? -1 : b === void 0 ? 1 : cmpStr(a, b);
101
102
  var cmpEdgeBy = (end) => (a, b) => {
102
103
  const c = cmpStr(end === "dst" ? a.dst : a.src, end === "dst" ? b.dst : b.src);
103
- return c !== 0 ? c : cmpStr(a.kind, b.kind);
104
+ if (c !== 0) return c;
105
+ const k = cmpStr(a.kind, b.kind);
106
+ if (k !== 0) return k;
107
+ return cmpAlias(a.attrs?.alias, b.attrs?.alias);
104
108
  };
105
109
  function emptyState() {
106
110
  return {
@@ -136,7 +140,7 @@ function removeMatching(arr, pred) {
136
140
  arr.splice(i, 1);
137
141
  return true;
138
142
  }
139
- var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}`;
143
+ var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}\0${e.attrs?.alias ?? ""}`;
140
144
  function rebindNodeId(s, oldId, newId, newNode) {
141
145
  s.nodes.set(newId, newNode);
142
146
  s.nodes.delete(oldId);
@@ -146,7 +150,9 @@ function rebindNodeId(s, oldId, newId, newNode) {
146
150
  for (const e of outs) {
147
151
  const peerInc = s.incoming.get(e.dst);
148
152
  if (peerInc) {
149
- const idx = peerInc.findIndex((x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst);
153
+ const idx = peerInc.findIndex(
154
+ (x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst && x.attrs?.alias === e.attrs?.alias
155
+ );
150
156
  if (idx >= 0) peerInc[idx] = e;
151
157
  }
152
158
  }
@@ -156,11 +162,25 @@ function rebindNodeId(s, oldId, newId, newNode) {
156
162
  for (const e of ins) {
157
163
  const peerOut = s.outgoing.get(e.src);
158
164
  if (peerOut) {
159
- const idx = peerOut.findIndex((x) => x.src === e.src && x.kind === e.kind && x.dst === oldId);
165
+ const idx = peerOut.findIndex(
166
+ (x) => x.src === e.src && x.kind === e.kind && x.dst === oldId && x.attrs?.alias === e.attrs?.alias
167
+ );
160
168
  if (idx >= 0) peerOut[idx] = e;
161
169
  }
162
170
  }
163
171
  }
172
+ function protocolOf(range) {
173
+ const colonIdx = range.indexOf(":");
174
+ if (colonIdx <= 0) return void 0;
175
+ const prefix = range.slice(0, colonIdx);
176
+ return /^[a-z][a-z0-9+.-]*$/i.test(prefix) ? prefix : void 0;
177
+ }
178
+ function isPublishedSelfLink(edge) {
179
+ const range = edge.attrs?.range;
180
+ if (range === void 0) return false;
181
+ const proto = protocolOf(range);
182
+ return proto === void 0 || proto === "npm";
183
+ }
164
184
  function validate(s) {
165
185
  for (const d of s.diagnostics) {
166
186
  if (d.severity === "error") {
@@ -178,16 +198,26 @@ function validate(s) {
178
198
  }
179
199
  const k = tripleKey(e);
180
200
  if (seen.has(k)) {
181
- throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}`);
201
+ const aliasSuffix = e.attrs?.alias !== void 0 ? ` (alias=${e.attrs.alias})` : "";
202
+ throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}${aliasSuffix}`);
182
203
  }
183
204
  seen.add(k);
184
205
  }
185
206
  }
186
207
  for (const [id, node] of s.nodes) {
187
208
  if (node.workspacePath !== void 0) {
188
- const inc = s.incoming.get(id);
189
- const hasNonWorkspaceIncoming = inc?.some((edge) => s.nodes.get(edge.src)?.workspacePath === void 0) ?? false;
190
- if (hasNonWorkspaceIncoming) {
209
+ const inc = s.incoming.get(id) ?? [];
210
+ for (const edge of inc) {
211
+ if (s.nodes.get(edge.src)?.workspacePath !== void 0) continue;
212
+ if (isPublishedSelfLink(edge)) {
213
+ s.diagnostics.push({
214
+ code: "SEAL_PUBLISHED_SELF_LINK",
215
+ subject: id,
216
+ severity: "info",
217
+ message: `published self-link: ${edge.src} \u2192${edge.kind} ${id} (range ${edge.attrs?.range}) \u2014 published dependency resolved to co-located workspace`
218
+ });
219
+ continue;
220
+ }
191
221
  throw new GraphError("INVARIANT_VIOLATION", `workspace node has incoming edges: ${id}`);
192
222
  }
193
223
  }
@@ -468,8 +498,10 @@ var GraphImpl = class _GraphImpl {
468
498
  if (!next.nodes.has(src)) throw new GraphError("PATCH_REJECTED", `addEdge: src ${src} missing`);
469
499
  if (!next.nodes.has(dst)) throw new GraphError("PATCH_REJECTED", `addEdge: dst ${dst} missing`);
470
500
  const existing = next.outgoing.get(src) ?? [];
471
- if (existing.some((e2) => e2.dst === dst && e2.kind === kind)) {
472
- throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}`);
501
+ const newAlias = attrs?.alias;
502
+ if (existing.some((e2) => e2.dst === dst && e2.kind === kind && e2.attrs?.alias === newAlias)) {
503
+ const aliasSuffix = newAlias !== void 0 ? ` (alias=${newAlias})` : "";
504
+ throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}${aliasSuffix}`);
473
505
  }
474
506
  const e = attrs ? { src, dst, kind, attrs } : { src, dst, kind };
475
507
  pushTo(next.outgoing, src, e);
@@ -478,11 +510,15 @@ var GraphImpl = class _GraphImpl {
478
510
  },
479
511
  removeEdge(src, dst, kind) {
480
512
  const outs = next.outgoing.get(src);
481
- if (!outs || !removeMatching(outs, (e) => e.dst === dst && e.kind === kind)) {
513
+ let removedAlias;
514
+ const found = outs?.findIndex((e) => e.dst === dst && e.kind === kind) ?? -1;
515
+ if (!outs || found < 0) {
482
516
  throw new GraphError("PATCH_REJECTED", `removeEdge: ${src} \u2192${kind} ${dst} missing`);
483
517
  }
518
+ removedAlias = outs[found]?.attrs?.alias;
519
+ outs.splice(found, 1);
484
520
  const ins = next.incoming.get(dst);
485
- if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind);
521
+ if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind && e.attrs?.alias === removedAlias);
486
522
  applied.push({ kind: "edge-removed", subject: { src, dst, kind } });
487
523
  },
488
524
  replacePeerContext(id, peers) {
@@ -1,4 +1,4 @@
1
- import { D as Diagnostic, G as Graph } from '../graph-DbCmOfBk.js';
1
+ import { D as Diagnostic, G as Graph } from '../graph-XpDkFSjz.js';
2
2
 
3
3
  interface Npm1ParseOptions {
4
4
  }
@@ -99,9 +99,13 @@ function tarballKeyInputsOfNode(node) {
99
99
  };
100
100
  }
101
101
  var cmpStr = (a, b) => a < b ? -1 : a > b ? 1 : 0;
102
+ var cmpAlias = (a, b) => a === b ? 0 : a === void 0 ? -1 : b === void 0 ? 1 : cmpStr(a, b);
102
103
  var cmpEdgeBy = (end) => (a, b) => {
103
104
  const c = cmpStr(end === "dst" ? a.dst : a.src, end === "dst" ? b.dst : b.src);
104
- return c !== 0 ? c : cmpStr(a.kind, b.kind);
105
+ if (c !== 0) return c;
106
+ const k = cmpStr(a.kind, b.kind);
107
+ if (k !== 0) return k;
108
+ return cmpAlias(a.attrs?.alias, b.attrs?.alias);
105
109
  };
106
110
  function emptyState() {
107
111
  return {
@@ -137,7 +141,7 @@ function removeMatching(arr, pred) {
137
141
  arr.splice(i, 1);
138
142
  return true;
139
143
  }
140
- var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}`;
144
+ var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}\0${e.attrs?.alias ?? ""}`;
141
145
  function rebindNodeId(s, oldId, newId, newNode) {
142
146
  s.nodes.set(newId, newNode);
143
147
  s.nodes.delete(oldId);
@@ -147,7 +151,9 @@ function rebindNodeId(s, oldId, newId, newNode) {
147
151
  for (const e of outs) {
148
152
  const peerInc = s.incoming.get(e.dst);
149
153
  if (peerInc) {
150
- const idx = peerInc.findIndex((x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst);
154
+ const idx = peerInc.findIndex(
155
+ (x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst && x.attrs?.alias === e.attrs?.alias
156
+ );
151
157
  if (idx >= 0) peerInc[idx] = e;
152
158
  }
153
159
  }
@@ -157,11 +163,25 @@ function rebindNodeId(s, oldId, newId, newNode) {
157
163
  for (const e of ins) {
158
164
  const peerOut = s.outgoing.get(e.src);
159
165
  if (peerOut) {
160
- const idx = peerOut.findIndex((x) => x.src === e.src && x.kind === e.kind && x.dst === oldId);
166
+ const idx = peerOut.findIndex(
167
+ (x) => x.src === e.src && x.kind === e.kind && x.dst === oldId && x.attrs?.alias === e.attrs?.alias
168
+ );
161
169
  if (idx >= 0) peerOut[idx] = e;
162
170
  }
163
171
  }
164
172
  }
173
+ function protocolOf(range) {
174
+ const colonIdx = range.indexOf(":");
175
+ if (colonIdx <= 0) return void 0;
176
+ const prefix = range.slice(0, colonIdx);
177
+ return /^[a-z][a-z0-9+.-]*$/i.test(prefix) ? prefix : void 0;
178
+ }
179
+ function isPublishedSelfLink(edge) {
180
+ const range = edge.attrs?.range;
181
+ if (range === void 0) return false;
182
+ const proto = protocolOf(range);
183
+ return proto === void 0 || proto === "npm";
184
+ }
165
185
  function validate(s) {
166
186
  for (const d of s.diagnostics) {
167
187
  if (d.severity === "error") {
@@ -179,16 +199,26 @@ function validate(s) {
179
199
  }
180
200
  const k = tripleKey(e);
181
201
  if (seen.has(k)) {
182
- throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}`);
202
+ const aliasSuffix = e.attrs?.alias !== void 0 ? ` (alias=${e.attrs.alias})` : "";
203
+ throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}${aliasSuffix}`);
183
204
  }
184
205
  seen.add(k);
185
206
  }
186
207
  }
187
208
  for (const [id, node] of s.nodes) {
188
209
  if (node.workspacePath !== void 0) {
189
- const inc = s.incoming.get(id);
190
- const hasNonWorkspaceIncoming = inc?.some((edge) => s.nodes.get(edge.src)?.workspacePath === void 0) ?? false;
191
- if (hasNonWorkspaceIncoming) {
210
+ const inc = s.incoming.get(id) ?? [];
211
+ for (const edge of inc) {
212
+ if (s.nodes.get(edge.src)?.workspacePath !== void 0) continue;
213
+ if (isPublishedSelfLink(edge)) {
214
+ s.diagnostics.push({
215
+ code: "SEAL_PUBLISHED_SELF_LINK",
216
+ subject: id,
217
+ severity: "info",
218
+ message: `published self-link: ${edge.src} \u2192${edge.kind} ${id} (range ${edge.attrs?.range}) \u2014 published dependency resolved to co-located workspace`
219
+ });
220
+ continue;
221
+ }
192
222
  throw new GraphError("INVARIANT_VIOLATION", `workspace node has incoming edges: ${id}`);
193
223
  }
194
224
  }
@@ -469,8 +499,10 @@ var GraphImpl = class _GraphImpl {
469
499
  if (!next.nodes.has(src)) throw new GraphError("PATCH_REJECTED", `addEdge: src ${src} missing`);
470
500
  if (!next.nodes.has(dst)) throw new GraphError("PATCH_REJECTED", `addEdge: dst ${dst} missing`);
471
501
  const existing = next.outgoing.get(src) ?? [];
472
- if (existing.some((e2) => e2.dst === dst && e2.kind === kind)) {
473
- throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}`);
502
+ const newAlias = attrs?.alias;
503
+ if (existing.some((e2) => e2.dst === dst && e2.kind === kind && e2.attrs?.alias === newAlias)) {
504
+ const aliasSuffix = newAlias !== void 0 ? ` (alias=${newAlias})` : "";
505
+ throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}${aliasSuffix}`);
474
506
  }
475
507
  const e = attrs ? { src, dst, kind, attrs } : { src, dst, kind };
476
508
  pushTo(next.outgoing, src, e);
@@ -479,11 +511,15 @@ var GraphImpl = class _GraphImpl {
479
511
  },
480
512
  removeEdge(src, dst, kind) {
481
513
  const outs = next.outgoing.get(src);
482
- if (!outs || !removeMatching(outs, (e) => e.dst === dst && e.kind === kind)) {
514
+ let removedAlias;
515
+ const found = outs?.findIndex((e) => e.dst === dst && e.kind === kind) ?? -1;
516
+ if (!outs || found < 0) {
483
517
  throw new GraphError("PATCH_REJECTED", `removeEdge: ${src} \u2192${kind} ${dst} missing`);
484
518
  }
519
+ removedAlias = outs[found]?.attrs?.alias;
520
+ outs.splice(found, 1);
485
521
  const ins = next.incoming.get(dst);
486
- if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind);
522
+ if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind && e.attrs?.alias === removedAlias);
487
523
  applied.push({ kind: "edge-removed", subject: { src, dst, kind } });
488
524
  },
489
525
  replacePeerContext(id, peers) {
@@ -1,5 +1,5 @@
1
- import { G as Graph, D as Diagnostic } from '../graph-DbCmOfBk.js';
2
- import { N as NpmFamilyEnrichOptions, a as NpmFamilyOptimizeOptions, b as NpmFamilyParseOptions, c as NpmFamilyStringifyOptions } from '../_npm-flat-types-5XRp-_Te.js';
1
+ import { G as Graph, D as Diagnostic } from '../graph-XpDkFSjz.js';
2
+ import { N as NpmFamilyEnrichOptions, a as NpmFamilyOptimizeOptions, b as NpmFamilyParseOptions, c as NpmFamilyStringifyOptions } from '../_npm-flat-types-C3oOIC0o.js';
3
3
 
4
4
  interface Npm2ParseOptions extends NpmFamilyParseOptions {
5
5
  }
@@ -31,6 +31,17 @@ var GraphError = class extends Error {
31
31
  this.code = code;
32
32
  }
33
33
  };
34
+ function nameOf(id) {
35
+ let depth = 0;
36
+ let lastAt = -1;
37
+ for (let i = 0; i < id.length; i++) {
38
+ const c = id[i];
39
+ if (c === "(") depth++;
40
+ else if (c === ")") depth--;
41
+ else if (c === "@" && depth === 0 && i > 0) lastAt = i;
42
+ }
43
+ return lastAt < 0 ? id : id.slice(0, lastAt);
44
+ }
34
45
  function serializeNodeId(name, version, peerContext, patch) {
35
46
  const base = toTarballKey({ name, version, patch });
36
47
  if (peerContext.length === 0) return base;
@@ -101,9 +112,13 @@ function tarballKeyInputsOfNode(node) {
101
112
  };
102
113
  }
103
114
  var cmpStr = (a, b) => a < b ? -1 : a > b ? 1 : 0;
115
+ var cmpAlias = (a, b) => a === b ? 0 : a === void 0 ? -1 : b === void 0 ? 1 : cmpStr(a, b);
104
116
  var cmpEdgeBy = (end) => (a, b) => {
105
117
  const c = cmpStr(end === "dst" ? a.dst : a.src, end === "dst" ? b.dst : b.src);
106
- return c !== 0 ? c : cmpStr(a.kind, b.kind);
118
+ if (c !== 0) return c;
119
+ const k = cmpStr(a.kind, b.kind);
120
+ if (k !== 0) return k;
121
+ return cmpAlias(a.attrs?.alias, b.attrs?.alias);
107
122
  };
108
123
  function emptyState() {
109
124
  return {
@@ -139,7 +154,7 @@ function removeMatching(arr, pred) {
139
154
  arr.splice(i, 1);
140
155
  return true;
141
156
  }
142
- var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}`;
157
+ var tripleKey = (e) => `${e.src}\0${e.kind}\0${e.dst}\0${e.attrs?.alias ?? ""}`;
143
158
  function rebindNodeId(s, oldId, newId, newNode) {
144
159
  s.nodes.set(newId, newNode);
145
160
  s.nodes.delete(oldId);
@@ -149,7 +164,9 @@ function rebindNodeId(s, oldId, newId, newNode) {
149
164
  for (const e of outs) {
150
165
  const peerInc = s.incoming.get(e.dst);
151
166
  if (peerInc) {
152
- const idx = peerInc.findIndex((x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst);
167
+ const idx = peerInc.findIndex(
168
+ (x) => x.src === oldId && x.kind === e.kind && x.dst === e.dst && x.attrs?.alias === e.attrs?.alias
169
+ );
153
170
  if (idx >= 0) peerInc[idx] = e;
154
171
  }
155
172
  }
@@ -159,11 +176,25 @@ function rebindNodeId(s, oldId, newId, newNode) {
159
176
  for (const e of ins) {
160
177
  const peerOut = s.outgoing.get(e.src);
161
178
  if (peerOut) {
162
- const idx = peerOut.findIndex((x) => x.src === e.src && x.kind === e.kind && x.dst === oldId);
179
+ const idx = peerOut.findIndex(
180
+ (x) => x.src === e.src && x.kind === e.kind && x.dst === oldId && x.attrs?.alias === e.attrs?.alias
181
+ );
163
182
  if (idx >= 0) peerOut[idx] = e;
164
183
  }
165
184
  }
166
185
  }
186
+ function protocolOf(range) {
187
+ const colonIdx = range.indexOf(":");
188
+ if (colonIdx <= 0) return void 0;
189
+ const prefix = range.slice(0, colonIdx);
190
+ return /^[a-z][a-z0-9+.-]*$/i.test(prefix) ? prefix : void 0;
191
+ }
192
+ function isPublishedSelfLink(edge) {
193
+ const range = edge.attrs?.range;
194
+ if (range === void 0) return false;
195
+ const proto = protocolOf(range);
196
+ return proto === void 0 || proto === "npm";
197
+ }
167
198
  function validate(s) {
168
199
  for (const d of s.diagnostics) {
169
200
  if (d.severity === "error") {
@@ -181,16 +212,26 @@ function validate(s) {
181
212
  }
182
213
  const k = tripleKey(e);
183
214
  if (seen.has(k)) {
184
- throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}`);
215
+ const aliasSuffix = e.attrs?.alias !== void 0 ? ` (alias=${e.attrs.alias})` : "";
216
+ throw new GraphError("INVARIANT_VIOLATION", `duplicate edge: ${e.src} \u2192${e.kind} ${e.dst}${aliasSuffix}`);
185
217
  }
186
218
  seen.add(k);
187
219
  }
188
220
  }
189
221
  for (const [id, node] of s.nodes) {
190
222
  if (node.workspacePath !== void 0) {
191
- const inc = s.incoming.get(id);
192
- const hasNonWorkspaceIncoming = inc?.some((edge) => s.nodes.get(edge.src)?.workspacePath === void 0) ?? false;
193
- if (hasNonWorkspaceIncoming) {
223
+ const inc = s.incoming.get(id) ?? [];
224
+ for (const edge of inc) {
225
+ if (s.nodes.get(edge.src)?.workspacePath !== void 0) continue;
226
+ if (isPublishedSelfLink(edge)) {
227
+ s.diagnostics.push({
228
+ code: "SEAL_PUBLISHED_SELF_LINK",
229
+ subject: id,
230
+ severity: "info",
231
+ message: `published self-link: ${edge.src} \u2192${edge.kind} ${id} (range ${edge.attrs?.range}) \u2014 published dependency resolved to co-located workspace`
232
+ });
233
+ continue;
234
+ }
194
235
  throw new GraphError("INVARIANT_VIOLATION", `workspace node has incoming edges: ${id}`);
195
236
  }
196
237
  }
@@ -471,8 +512,10 @@ var GraphImpl = class _GraphImpl {
471
512
  if (!next.nodes.has(src)) throw new GraphError("PATCH_REJECTED", `addEdge: src ${src} missing`);
472
513
  if (!next.nodes.has(dst)) throw new GraphError("PATCH_REJECTED", `addEdge: dst ${dst} missing`);
473
514
  const existing = next.outgoing.get(src) ?? [];
474
- if (existing.some((e2) => e2.dst === dst && e2.kind === kind)) {
475
- throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}`);
515
+ const newAlias = attrs?.alias;
516
+ if (existing.some((e2) => e2.dst === dst && e2.kind === kind && e2.attrs?.alias === newAlias)) {
517
+ const aliasSuffix = newAlias !== void 0 ? ` (alias=${newAlias})` : "";
518
+ throw new GraphError("PATCH_REJECTED", `addEdge: duplicate ${src} \u2192${kind} ${dst}${aliasSuffix}`);
476
519
  }
477
520
  const e = attrs ? { src, dst, kind, attrs } : { src, dst, kind };
478
521
  pushTo(next.outgoing, src, e);
@@ -481,11 +524,15 @@ var GraphImpl = class _GraphImpl {
481
524
  },
482
525
  removeEdge(src, dst, kind) {
483
526
  const outs = next.outgoing.get(src);
484
- if (!outs || !removeMatching(outs, (e) => e.dst === dst && e.kind === kind)) {
527
+ let removedAlias;
528
+ const found = outs?.findIndex((e) => e.dst === dst && e.kind === kind) ?? -1;
529
+ if (!outs || found < 0) {
485
530
  throw new GraphError("PATCH_REJECTED", `removeEdge: ${src} \u2192${kind} ${dst} missing`);
486
531
  }
532
+ removedAlias = outs[found]?.attrs?.alias;
533
+ outs.splice(found, 1);
487
534
  const ins = next.incoming.get(dst);
488
- if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind);
535
+ if (ins) removeMatching(ins, (e) => e.src === src && e.kind === kind && e.attrs?.alias === removedAlias);
489
536
  applied.push({ kind: "edge-removed", subject: { src, dst, kind } });
490
537
  },
491
538
  replacePeerContext(id, peers) {
@@ -1384,12 +1431,20 @@ function addDepEdges(builder, edgeRanges, edgeDeclaredNames, srcPath, srcId, dep
1384
1431
  });
1385
1432
  continue;
1386
1433
  }
1434
+ const aliasSlot = name === nameOf(dstId) ? void 0 : name;
1387
1435
  const edgeKey = edgeTripleKey(srcId, kind, dstId);
1388
- if (edgeRanges.has(edgeKey)) continue;
1389
- edgeRanges.set(edgeKey, range);
1390
- edgeDeclaredNames.set(edgeKey, name);
1436
+ if (edgeRanges.has(edgeKey) && aliasSlot === void 0) continue;
1437
+ if (aliasSlot === void 0) {
1438
+ edgeRanges.set(edgeKey, range);
1439
+ edgeDeclaredNames.set(edgeKey, name);
1440
+ } else if (!edgeRanges.has(edgeKey)) {
1441
+ edgeRanges.set(edgeKey, range);
1442
+ edgeDeclaredNames.set(edgeKey, name);
1443
+ }
1391
1444
  try {
1392
- builder.addEdge(srcId, dstId, kind, { range });
1445
+ const attrs = { range };
1446
+ if (aliasSlot !== void 0) attrs.alias = aliasSlot;
1447
+ builder.addEdge(srcId, dstId, kind, attrs);
1393
1448
  } catch (error) {
1394
1449
  if (error instanceof GraphError && error.code === "INVARIANT_VIOLATION") {
1395
1450
  continue;
@@ -1612,7 +1667,7 @@ function collectManifestBlocks(graph, srcId, sidecar, emitDiagnostic = () => voi
1612
1667
  const target = edge.kind === "dep" ? dep : edge.kind === "dev" ? dev : edge.kind === "peer" ? peer : edge.kind === "optional" ? optional : void 0;
1613
1668
  if (target === void 0) continue;
1614
1669
  const edgeKey = edgeTripleKey(edge.src, edge.kind, edge.dst);
1615
- const declaredName = sidecar?.edgeDeclaredNames.get(edgeKey) ?? dst.name;
1670
+ const declaredName = edge.attrs?.alias ?? sidecar?.edgeDeclaredNames.get(edgeKey) ?? dst.name;
1616
1671
  if (isWorkspaceEdge(edge)) {
1617
1672
  const ws = workspaceRangeOfEdge(edge, dst);
1618
1673
  if (ws !== void 0) {
@@ -1,5 +1,5 @@
1
- import { G as Graph, D as Diagnostic } from '../graph-DbCmOfBk.js';
2
- import { N as NpmFamilyEnrichOptions, a as NpmFamilyOptimizeOptions, b as NpmFamilyParseOptions, c as NpmFamilyStringifyOptions } from '../_npm-flat-types-5XRp-_Te.js';
1
+ import { G as Graph, D as Diagnostic } from '../graph-XpDkFSjz.js';
2
+ import { N as NpmFamilyEnrichOptions, a as NpmFamilyOptimizeOptions, b as NpmFamilyParseOptions, c as NpmFamilyStringifyOptions } from '../_npm-flat-types-C3oOIC0o.js';
3
3
 
4
4
  interface Npm3ParseOptions extends NpmFamilyParseOptions {
5
5
  }