@vltpkg/graph 0.0.0-9 → 1.0.0-rc.10

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 (203) hide show
  1. package/README.md +136 -1
  2. package/dist/esm/actual/load.d.ts +49 -3
  3. package/dist/esm/actual/load.d.ts.map +1 -1
  4. package/dist/esm/actual/load.js +146 -74
  5. package/dist/esm/actual/load.js.map +1 -1
  6. package/dist/esm/browser.d.ts +8 -4
  7. package/dist/esm/browser.d.ts.map +1 -1
  8. package/dist/esm/browser.js +6 -2
  9. package/dist/esm/browser.js.map +1 -1
  10. package/dist/esm/build.d.ts +29 -0
  11. package/dist/esm/build.d.ts.map +1 -0
  12. package/dist/esm/build.js +79 -0
  13. package/dist/esm/build.js.map +1 -0
  14. package/dist/esm/dependencies.d.ts +10 -3
  15. package/dist/esm/dependencies.d.ts.map +1 -1
  16. package/dist/esm/dependencies.js +63 -0
  17. package/dist/esm/dependencies.js.map +1 -1
  18. package/dist/esm/diff.d.ts +69 -0
  19. package/dist/esm/diff.d.ts.map +1 -1
  20. package/dist/esm/diff.js +25 -0
  21. package/dist/esm/diff.js.map +1 -1
  22. package/dist/esm/edge.d.ts +8 -2
  23. package/dist/esm/edge.d.ts.map +1 -1
  24. package/dist/esm/edge.js +12 -0
  25. package/dist/esm/edge.js.map +1 -1
  26. package/dist/esm/fixup-added-names.d.ts +16 -0
  27. package/dist/esm/fixup-added-names.d.ts.map +1 -0
  28. package/dist/esm/fixup-added-names.js +31 -0
  29. package/dist/esm/fixup-added-names.js.map +1 -0
  30. package/dist/esm/graph.d.ts +34 -10
  31. package/dist/esm/graph.d.ts.map +1 -1
  32. package/dist/esm/graph.js +150 -24
  33. package/dist/esm/graph.js.map +1 -1
  34. package/dist/esm/ideal/append-nodes.d.ts +12 -1
  35. package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
  36. package/dist/esm/ideal/append-nodes.js +303 -53
  37. package/dist/esm/ideal/append-nodes.js.map +1 -1
  38. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +4 -4
  39. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
  40. package/dist/esm/ideal/build-ideal-from-starting-graph.js +35 -16
  41. package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
  42. package/dist/esm/ideal/build.d.ts +9 -0
  43. package/dist/esm/ideal/build.d.ts.map +1 -1
  44. package/dist/esm/ideal/build.js +31 -1
  45. package/dist/esm/ideal/build.js.map +1 -1
  46. package/dist/esm/ideal/get-importer-specs.d.ts +11 -3
  47. package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
  48. package/dist/esm/ideal/get-importer-specs.js +86 -9
  49. package/dist/esm/ideal/get-importer-specs.js.map +1 -1
  50. package/dist/esm/ideal/get-ordered-dependencies.d.ts +10 -0
  51. package/dist/esm/ideal/get-ordered-dependencies.d.ts.map +1 -0
  52. package/dist/esm/ideal/get-ordered-dependencies.js +42 -0
  53. package/dist/esm/ideal/get-ordered-dependencies.js.map +1 -0
  54. package/dist/esm/ideal/peers.d.ts +71 -0
  55. package/dist/esm/ideal/peers.d.ts.map +1 -0
  56. package/dist/esm/ideal/peers.js +318 -0
  57. package/dist/esm/ideal/peers.js.map +1 -0
  58. package/dist/esm/ideal/refresh-ideal-graph.d.ts +48 -0
  59. package/dist/esm/ideal/refresh-ideal-graph.d.ts.map +1 -0
  60. package/dist/esm/ideal/refresh-ideal-graph.js +79 -0
  61. package/dist/esm/ideal/refresh-ideal-graph.js.map +1 -0
  62. package/dist/esm/ideal/types.d.ts +78 -1
  63. package/dist/esm/ideal/types.d.ts.map +1 -1
  64. package/dist/esm/ideal/types.js.map +1 -1
  65. package/dist/esm/index.d.ts +9 -4
  66. package/dist/esm/index.d.ts.map +1 -1
  67. package/dist/esm/index.js +5 -1
  68. package/dist/esm/index.js.map +1 -1
  69. package/dist/esm/install.d.ts +10 -4
  70. package/dist/esm/install.d.ts.map +1 -1
  71. package/dist/esm/install.js +191 -20
  72. package/dist/esm/install.js.map +1 -1
  73. package/dist/esm/lockfile/load-edges.d.ts +8 -1
  74. package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
  75. package/dist/esm/lockfile/load-edges.js +80 -15
  76. package/dist/esm/lockfile/load-edges.js.map +1 -1
  77. package/dist/esm/lockfile/load-nodes.d.ts +3 -2
  78. package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
  79. package/dist/esm/lockfile/load-nodes.js +85 -13
  80. package/dist/esm/lockfile/load-nodes.js.map +1 -1
  81. package/dist/esm/lockfile/load.d.ts +18 -5
  82. package/dist/esm/lockfile/load.d.ts.map +1 -1
  83. package/dist/esm/lockfile/load.js +28 -20
  84. package/dist/esm/lockfile/load.js.map +1 -1
  85. package/dist/esm/lockfile/save.d.ts +16 -3
  86. package/dist/esm/lockfile/save.d.ts.map +1 -1
  87. package/dist/esm/lockfile/save.js +64 -17
  88. package/dist/esm/lockfile/save.js.map +1 -1
  89. package/dist/esm/lockfile/types.d.ts +34 -4
  90. package/dist/esm/lockfile/types.d.ts.map +1 -1
  91. package/dist/esm/lockfile/types.js +31 -0
  92. package/dist/esm/lockfile/types.js.map +1 -1
  93. package/dist/esm/modifiers.d.ts +189 -0
  94. package/dist/esm/modifiers.d.ts.map +1 -0
  95. package/dist/esm/modifiers.js +330 -0
  96. package/dist/esm/modifiers.js.map +1 -0
  97. package/dist/esm/node.d.ts +91 -6
  98. package/dist/esm/node.d.ts.map +1 -1
  99. package/dist/esm/node.js +119 -5
  100. package/dist/esm/node.js.map +1 -1
  101. package/dist/esm/reify/add-edge.d.ts +1 -2
  102. package/dist/esm/reify/add-edge.d.ts.map +1 -1
  103. package/dist/esm/reify/add-edge.js +29 -18
  104. package/dist/esm/reify/add-edge.js.map +1 -1
  105. package/dist/esm/reify/add-edges.d.ts +1 -2
  106. package/dist/esm/reify/add-edges.d.ts.map +1 -1
  107. package/dist/esm/reify/add-edges.js +3 -3
  108. package/dist/esm/reify/add-edges.js.map +1 -1
  109. package/dist/esm/reify/add-nodes.d.ts.map +1 -1
  110. package/dist/esm/reify/add-nodes.js +4 -27
  111. package/dist/esm/reify/add-nodes.js.map +1 -1
  112. package/dist/esm/reify/bin-chmod.d.ts +11 -0
  113. package/dist/esm/reify/bin-chmod.d.ts.map +1 -0
  114. package/dist/esm/reify/bin-chmod.js +39 -0
  115. package/dist/esm/reify/bin-chmod.js.map +1 -0
  116. package/dist/esm/reify/build.d.ts +10 -1
  117. package/dist/esm/reify/build.d.ts.map +1 -1
  118. package/dist/esm/reify/build.js +36 -23
  119. package/dist/esm/reify/build.js.map +1 -1
  120. package/dist/esm/reify/calculate-save-value.d.ts +3 -0
  121. package/dist/esm/reify/calculate-save-value.d.ts.map +1 -0
  122. package/dist/esm/reify/calculate-save-value.js +45 -0
  123. package/dist/esm/reify/calculate-save-value.js.map +1 -0
  124. package/dist/esm/reify/check-needed-build.d.ts +25 -0
  125. package/dist/esm/reify/check-needed-build.d.ts.map +1 -0
  126. package/dist/esm/reify/check-needed-build.js +50 -0
  127. package/dist/esm/reify/check-needed-build.js.map +1 -0
  128. package/dist/esm/reify/delete-edge.d.ts.map +1 -1
  129. package/dist/esm/reify/delete-edge.js +3 -4
  130. package/dist/esm/reify/delete-edge.js.map +1 -1
  131. package/dist/esm/reify/extract-node.d.ts +24 -0
  132. package/dist/esm/reify/extract-node.d.ts.map +1 -0
  133. package/dist/esm/reify/extract-node.js +84 -0
  134. package/dist/esm/reify/extract-node.js.map +1 -0
  135. package/dist/esm/reify/index.d.ts +18 -1
  136. package/dist/esm/reify/index.d.ts.map +1 -1
  137. package/dist/esm/reify/index.js +85 -15
  138. package/dist/esm/reify/index.js.map +1 -1
  139. package/dist/esm/reify/internal-hoist.d.ts +9 -0
  140. package/dist/esm/reify/internal-hoist.d.ts.map +1 -0
  141. package/dist/esm/reify/internal-hoist.js +134 -0
  142. package/dist/esm/reify/internal-hoist.js.map +1 -0
  143. package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
  144. package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
  145. package/dist/esm/reify/update-importers-package-json.js +33 -24
  146. package/dist/esm/reify/update-importers-package-json.js.map +1 -1
  147. package/dist/esm/remove-optional-subgraph.js +1 -1
  148. package/dist/esm/remove-optional-subgraph.js.map +1 -1
  149. package/dist/esm/resolve-save-type.d.ts +1 -2
  150. package/dist/esm/resolve-save-type.d.ts.map +1 -1
  151. package/dist/esm/resolve-save-type.js.map +1 -1
  152. package/dist/esm/stringify-node.d.ts +1 -1
  153. package/dist/esm/stringify-node.d.ts.map +1 -1
  154. package/dist/esm/stringify-node.js +10 -1
  155. package/dist/esm/stringify-node.js.map +1 -1
  156. package/dist/esm/transfer-data/load.d.ts +44 -0
  157. package/dist/esm/transfer-data/load.d.ts.map +1 -0
  158. package/dist/esm/transfer-data/load.js +176 -0
  159. package/dist/esm/transfer-data/load.js.map +1 -0
  160. package/dist/esm/uninstall.d.ts +5 -4
  161. package/dist/esm/uninstall.d.ts.map +1 -1
  162. package/dist/esm/uninstall.js +61 -19
  163. package/dist/esm/uninstall.js.map +1 -1
  164. package/dist/esm/update.d.ts +13 -0
  165. package/dist/esm/update.d.ts.map +1 -0
  166. package/dist/esm/update.js +73 -0
  167. package/dist/esm/update.js.map +1 -0
  168. package/dist/esm/virtual-root.d.ts +16 -0
  169. package/dist/esm/virtual-root.d.ts.map +1 -0
  170. package/dist/esm/virtual-root.js +79 -0
  171. package/dist/esm/virtual-root.js.map +1 -0
  172. package/dist/esm/visualization/human-readable-output.d.ts +4 -5
  173. package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
  174. package/dist/esm/visualization/human-readable-output.js +47 -19
  175. package/dist/esm/visualization/human-readable-output.js.map +1 -1
  176. package/dist/esm/visualization/json-output.d.ts +7 -2
  177. package/dist/esm/visualization/json-output.d.ts.map +1 -1
  178. package/dist/esm/visualization/json-output.js +35 -12
  179. package/dist/esm/visualization/json-output.js.map +1 -1
  180. package/dist/esm/visualization/mermaid-output.d.ts +7 -1
  181. package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
  182. package/dist/esm/visualization/mermaid-output.js +110 -14
  183. package/dist/esm/visualization/mermaid-output.js.map +1 -1
  184. package/dist/esm/visualization/object-like-output.d.ts +1 -1
  185. package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
  186. package/dist/esm/visualization/object-like-output.js.map +1 -1
  187. package/package.json +35 -29
  188. package/dist/esm/ideal/add-nodes.d.ts +0 -19
  189. package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
  190. package/dist/esm/ideal/add-nodes.js +0 -32
  191. package/dist/esm/ideal/add-nodes.js.map +0 -1
  192. package/dist/esm/ideal/remove-nodes.d.ts +0 -7
  193. package/dist/esm/ideal/remove-nodes.d.ts.map +0 -1
  194. package/dist/esm/ideal/remove-nodes.js +0 -19
  195. package/dist/esm/ideal/remove-nodes.js.map +0 -1
  196. package/dist/esm/reify/bin-paths.d.ts +0 -4
  197. package/dist/esm/reify/bin-paths.d.ts.map +0 -1
  198. package/dist/esm/reify/bin-paths.js +0 -23
  199. package/dist/esm/reify/bin-paths.js.map +0 -1
  200. package/dist/esm/types.d.ts +0 -42
  201. package/dist/esm/types.d.ts.map +0 -1
  202. package/dist/esm/types.js +0 -2
  203. package/dist/esm/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAInC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,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I,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO,YAAY,CAAC;YAClB,GAAG,IAAI,CAAC,QAAQ;YAChB,KAAK,EAAE,IAAI;YACX,aAAa,EAAE,IAAI;SACpB,CAAC,CAAA;IACJ,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QAC1B,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAA;IAChE,CAAC;CACF","sourcesContent":["import { getId, joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { satisfies } from '@vltpkg/satisfies'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { Manifest, DependencySaveType } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport { lockfileData } from './lockfile/save.ts'\nimport { Node } from './node.ts'\nimport type { NodeOptions } from './node.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\nimport { resolveSaveType } from './resolve-save-type.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n// this is always the same, but we don't hard code it as a string,\n// in case the DepID module needs to change its delimiter again ever.\nconst mainDepID = joinDepIDTuple(['file', '.'])\n\nexport type ManifestInventory = Map<DepID, Manifest>\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type GraphOptions = SpecOptions & {\n /**\n * The main importer manifest info.\n */\n mainManifest: Manifest\n /**\n * An inventory of seen manifests.\n */\n manifests?: ManifestInventory\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * Root of the project this graph represents\n */\n projectRoot: string\n}\n\nexport class Graph implements GraphLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Graph'\n }\n\n #options: GraphOptions\n\n #nodeOptions: NodeOptions\n\n /**\n * A {@link Monorepo} instance, used for managing workspaces.\n */\n monorepo?: Monorepo\n\n /**\n * An inventory with all manifests related to an install.\n */\n manifests: ManifestInventory\n\n /**\n * A set of all edges in this graph.\n */\n edges = new Set<Edge>()\n\n /**\n * Map registered dep ids to the node that represent them in the graph.\n */\n nodes = new Map<DepID, Node>()\n\n /**\n * Map of nodes by their name\n */\n nodesByName = new Map<string, Set<Node>>()\n\n /**\n * Cached resolutions for spec lookups\n */\n resolutions = new Map<string, Node>()\n\n /**\n * Reverse map of resolutions\n */\n resolutionsReverse = new Map<Node, Set<string>>()\n\n /**\n * A set of importer nodes in this graph.\n */\n importers = new Set<Node>()\n\n /**\n * The {@link Node} that represents the project root `package.json`.\n */\n mainImporter: Node\n\n /**\n * A set of extraneous dependencies found when building the graph.\n */\n extraneousDependencies = new Set<Edge>()\n\n /**\n * The root of the project this graph represents\n */\n projectRoot: string\n\n constructor(options: GraphOptions) {\n const { mainManifest, monorepo } = options\n this.#options = options\n this.manifests = getMap(options.manifests)\n this.projectRoot = options.projectRoot\n this.#nodeOptions = {\n ...this.#options,\n graph: this,\n }\n\n // add the project root node\n const mainImporterLocation = '.'\n const mainImporterSpec = Spec.parse(\n mainManifest.name || '(root)',\n mainImporterLocation,\n )\n const mainImporter = this.addNode(\n mainDepID,\n mainManifest,\n mainImporterSpec,\n )\n mainImporter.setImporterLocation(mainImporterLocation)\n mainImporter.mainImporter = true\n this.mainImporter = mainImporter\n this.importers.add(mainImporter)\n this.manifests.set(mainImporter.id, mainManifest)\n\n // uses the monorepo instance in order to retrieve info on\n // workspaces and create importer nodes for each of them\n this.monorepo = monorepo\n if (this.monorepo) {\n for (const ws of this.monorepo) {\n const wsNode = this.addNode(\n ws.id,\n ws.manifest,\n undefined,\n ws.name,\n )\n wsNode.setImporterLocation(`./${ws.path}`)\n if (wsNode.manifest) {\n this.manifests.set(wsNode.id, wsNode.manifest)\n }\n this.importers.add(wsNode)\n }\n }\n }\n\n /**\n * Delete all nodes that are unreachable from the importers.\n * The collection of deleted nodes is returned.\n *\n * NOTE: This can be extremely slow for large graphs, and is almost always\n * unnecessary! Only call when it is known that some unreachable nodes may\n * have been created, for example when deleting the unneeded subgraph when an\n * optional node fails to resolve/install.\n */\n gc() {\n const { nodes } = this\n this.nodes = new Map()\n const marked = new Set(this.importers)\n for (const imp of marked) {\n // don't delete the importer!\n nodes.delete(imp.id)\n this.nodes.set(imp.id, imp)\n for (const { to } of imp.edgesOut.values()) {\n if (!to || marked.has(to)) continue\n marked.add(to)\n nodes.delete(to.id)\n this.nodes.set(to.id, to)\n }\n }\n for (const node of nodes.values()) {\n this.removeNode(node)\n }\n return nodes\n }\n\n /**\n * Create a new edge between two nodes of the graph in case both exist,\n * in case the destination node does not exists, then a dangling edge,\n * pointing to nothing will be created to represent that missing dependency.\n */\n addEdge(\n type: DependencySaveType,\n spec: Spec,\n from: NodeLike,\n to?: NodeLike,\n ) {\n // fix any nameless spec\n if (spec.name === '(unknown)') {\n if (to) {\n spec.name = to.name /* c8 ignore next */ || '(unknown)'\n spec.spec = `${to.name}@${spec.bareSpec}`\n } else {\n throw error(\n 'Impossible to place a missing, nameless dependency',\n { spec },\n )\n }\n }\n const existing = from.edgesOut.get(spec.name)\n if (existing) {\n const edge = existing as Edge\n if (\n edge.type === type &&\n edge.spec.bareSpec === spec.bareSpec\n ) {\n if (to && to !== edge.to) {\n edge.to = to as Node\n edge.to.edgesIn.add(edge)\n }\n return edge\n }\n this.edges.delete(edge)\n }\n const f = from as Node\n const edgeOut = f.addEdgesTo(\n resolveSaveType(from, spec.name, type),\n spec,\n to as Node | undefined,\n )\n this.edges.add(edgeOut)\n return edgeOut\n }\n\n /**\n * Find an existing node to satisfy a dependency\n */\n findResolution(spec: Spec, fromNode: Node) {\n const f = spec.final\n // if it's a file: dep, then the fromNode location matters\n const fromPref =\n f.type === 'file' ? fromNode.location + ' : ' : ''\n const sf = fromPref + String(f)\n const cached = this.resolutions.get(sf)\n if (cached) return cached\n const nbn = this.nodesByName.get(f.name)\n if (!nbn) return undefined\n for (const node of nbn) {\n if (\n satisfies(\n node.id,\n f,\n fromNode.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n this.resolutions.set(sf, node)\n // always set by now, because the node was added at some point\n this.resolutionsReverse.get(node)?.add(sf)\n return node\n }\n }\n }\n\n /**\n * Create a new node in the graph.\n */\n addNode(\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n const node = new Node(\n this.#nodeOptions,\n id,\n manifest,\n spec,\n name,\n version,\n )\n this.nodes.set(node.id, node)\n const nbn = this.nodesByName.get(node.name) ?? new Set()\n nbn.add(node)\n this.nodesByName.set(node.name, nbn)\n if (spec) {\n const f = String(spec.final)\n // if it's a file: type, then that is fromNode-specific,\n // so we can't shortcut add it here.\n if (spec.final.type !== 'file') {\n this.resolutions.set(f, node)\n const rrev = this.resolutionsReverse.get(node) ?? new Set()\n rrev.add(f)\n this.resolutionsReverse.set(node, rrev)\n }\n }\n if (manifest) {\n this.manifests.set(node.id, manifest)\n }\n return node\n }\n\n /**\n * Place a new package into the graph representation, creating the new\n * edges and possibly new nodes that are to be expected when traversing\n * the graph in a top-down direction, e.g: from importers to leafs.\n *\n * For different uses that are not a direct top-down traversal of the graph\n * consider using `addNode()` and `addEdge()` instead.\n */\n placePackage(\n fromNode: Node,\n depType: DependencySaveType,\n spec: Spec,\n manifest?: Manifest,\n id?: DepID,\n ) {\n // if no manifest is available, then create an edge that has no\n // reference to any other node, representing a missing dependency\n if (!manifest && !id) {\n this.addEdge(depType, spec, fromNode)\n return\n }\n\n // flags set on the node we're about to create or find.\n const flags = {\n dev: fromNode.dev || depType === 'dev',\n optional:\n fromNode.optional ||\n depType === 'optional' ||\n depType === 'peerOptional',\n }\n\n const depId = id || (manifest && getId(spec, manifest))\n\n /* c8 ignore start - should not be possible */\n if (!depId) {\n throw error('Could not find dep id when placing package', {\n spec,\n manifest,\n })\n }\n /* c8 ignore stop */\n\n // if a node for this package is already represented by a node\n // in the graph, then just creates a new edge to that node\n const toFoundNode = this.nodes.get(depId)\n if (toFoundNode) {\n this.addEdge(depType, spec, fromNode, toFoundNode)\n // the current only stays dev/optional if this dep lets it remain so\n // if it's not already, we don't make it dev or optional.\n toFoundNode.dev &&= flags.dev\n toFoundNode.optional &&= flags.optional\n return toFoundNode\n }\n\n // creates a new node and edges to its parent\n const toNode = this.addNode(depId, manifest)\n toNode.registry = spec.registry\n toNode.dev = flags.dev\n toNode.optional = flags.optional\n this.addEdge(depType, spec, fromNode, toNode)\n return toNode\n }\n\n /**\n * Removes a node and its relevant edges from the graph.\n *\n * If a replacement is provided, then any edges that were previously\n * pointing to the removed node will be directed to the replacement,\n * if it is valid to do so.\n */\n removeNode(node: Node, replacement?: Node) {\n this.nodes.delete(node.id)\n const nbn = this.nodesByName.get(node.name)\n // if it's the last one, just remove the set\n if (nbn?.size === 1) this.nodesByName.delete(node.name)\n else nbn?.delete(node)\n for (const r of this.resolutionsReverse.get(node) ?? new Set()) {\n this.resolutions.delete(r)\n }\n this.resolutionsReverse.delete(node)\n this.manifests.delete(node.id)\n for (const edge of node.edgesOut.values()) {\n this.edges.delete(edge)\n }\n for (const edge of node.edgesIn) {\n if (\n replacement &&\n satisfies(\n replacement.id,\n edge.spec,\n edge.from.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n edge.to = replacement\n } else {\n edge.from.edgesOut.delete(edge.spec.name)\n this.edges.delete(edge)\n }\n }\n }\n\n toJSON() {\n return lockfileData({\n ...this.#options,\n graph: this,\n saveManifests: true,\n })\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const data = this.toJSON()\n return `${this[Symbol.toStringTag]} ${insp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IAAI,CAAC,QAAQ;gBAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;YAEvC,oCAAoC;YACpC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;YACrB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO,YAAY,CAAC;YAClB,GAAG,IAAI,CAAC,QAAQ;YAChB,KAAK,EAAE,IAAI;YACX,aAAa,EAAE,IAAI;SACpB,CAAC,CAAA;IACJ,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QAC1B,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAA;IAChE,CAAC;CACF","sourcesContent":["import { getId, joinDepIDTuple, splitExtra } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { satisfies } from '@vltpkg/satisfies'\nimport { getOptions, Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type {\n GraphLike,\n NodeLike,\n NormalizedManifest,\n DependencySaveType,\n} from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport { lockfileData } from './lockfile/save.ts'\nimport { Edge } from './edge.ts'\nimport { Node } from './node.ts'\nimport type { NodeOptions } from './node.ts'\nimport { resolveSaveType } from './resolve-save-type.ts'\nimport type { PeerContext } from './ideal/types.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nconst cacheKeySeparator = '│'\n\n// this is always the same, but we don't hard code it as a string,\n// in case the DepID module needs to change its delimiter again ever.\nconst mainDepID = joinDepIDTuple(['file', '.'])\n\nexport type ManifestInventory = Map<DepID, NormalizedManifest>\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\n/**\n * Get a cache key for a resolution based on the\n * spec, location and query modifier.\n */\nconst getResolutionCacheKey = (\n spec: Spec,\n location: string,\n extra: string,\n): string => {\n const f = spec.final\n // if it's a file: dep, then the fromNode location matters\n const fromPrefix = f.type === 'file' ? location + ' : ' : ''\n // the unique key should also precise what is the type of the spec,\n // and in the case of a registry, what registry it is from.\n const typePrecisionKey =\n f.registry ?\n `${cacheKeySeparator}registry` +\n `${cacheKeySeparator}${f.registry}`\n : f.gitRemote ?\n `${cacheKeySeparator}git` + `${cacheKeySeparator}${f.gitRemote}`\n : `${cacheKeySeparator}${f.type}`\n const modifierSuffix = `${cacheKeySeparator}${extra}`\n return fromPrefix + String(f) + typePrecisionKey + modifierSuffix\n}\n\nexport type GraphOptions = SpecOptions & {\n /**\n * The main importer manifest info.\n */\n mainManifest: NormalizedManifest\n /**\n * An inventory of seen manifests.\n */\n manifests?: ManifestInventory\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * Root of the project this graph represents\n */\n projectRoot: string\n}\n\nexport class Graph implements GraphLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Graph'\n }\n\n #options: GraphOptions\n\n #nodeOptions: NodeOptions\n\n /**\n * A {@link Monorepo} instance, used for managing workspaces.\n */\n monorepo?: Monorepo\n\n /**\n * An inventory with all manifests related to an install.\n */\n manifests: ManifestInventory\n\n /**\n * A set of all edges in this graph.\n */\n edges = new Set<Edge>()\n\n /**\n * Map registered dep ids to the node that represent them in the graph.\n */\n nodes = new Map<DepID, Node>()\n\n /**\n * Map of nodes by their name\n */\n nodesByName = new Map<string, Set<Node>>()\n\n /**\n * Cached resolutions for spec lookups\n */\n resolutions = new Map<string, Node>()\n\n /**\n * Reverse map of resolutions\n */\n resolutionsReverse = new Map<Node, Set<string>>()\n\n /**\n * A set of importer nodes in this graph.\n */\n importers = new Set<Node>()\n\n /**\n * The {@link Node} that represents the project root `package.json`.\n */\n mainImporter: Node\n\n /**\n * A set of extraneous dependencies found when building the graph.\n */\n extraneousDependencies = new Set<Edge>()\n\n /**\n * The root of the project this graph represents\n */\n projectRoot: string\n\n /**\n * The peer context sets used to resolve peer dependencies within this graph.\n */\n peerContexts: PeerContext[]\n\n /**\n * Tracks the current peer context index.\n */\n currentPeerContextIndex = 0\n\n constructor(options: GraphOptions) {\n const { mainManifest, monorepo } = options\n this.#options = options\n // hydrate spec options to their full contents, including defaults\n const specOptions = getOptions({\n registry: options.registry,\n registries: options.registries,\n 'git-hosts': options['git-hosts'],\n 'git-host-archives': options['git-host-archives'],\n 'scope-registries': options['scope-registries'],\n 'jsr-registries': options['jsr-registries'],\n catalog: options.catalog,\n catalogs: options.catalogs,\n })\n this.manifests = getMap(options.manifests)\n this.projectRoot = options.projectRoot\n this.#nodeOptions = {\n ...this.#options,\n ...specOptions,\n graph: this,\n }\n\n // add the project root node\n const mainImporterLocation = '.'\n const mainImporterSpec = Spec.parse(\n mainManifest.name || '(root)',\n mainImporterLocation,\n )\n const mainImporter = this.addNode(\n mainDepID,\n mainManifest,\n mainImporterSpec,\n )\n mainImporter.setImporterLocation(mainImporterLocation)\n mainImporter.mainImporter = true\n this.mainImporter = mainImporter\n this.mainImporter.workspaces = new Map()\n this.importers.add(mainImporter)\n this.manifests.set(mainImporter.id, mainManifest)\n\n // uses the monorepo instance in order to retrieve info on\n // workspaces and create importer nodes for each of them\n this.monorepo = monorepo\n if (this.monorepo) {\n for (const ws of this.monorepo) {\n const wsNode = this.addNode(\n ws.id,\n ws.manifest,\n undefined,\n ws.name,\n )\n wsNode.setImporterLocation(`./${ws.path}`)\n if (wsNode.manifest) {\n this.manifests.set(wsNode.id, wsNode.manifest)\n }\n this.importers.add(wsNode)\n // creates a virtual edge to connect the workspaces to the root node\n const edge = new Edge(\n 'prod',\n Spec.parse(wsNode.name, 'workspace:*', this.#options),\n this.mainImporter,\n wsNode,\n )\n this.mainImporter.workspaces.set(wsNode.name, edge)\n }\n }\n\n // initializes the peer context set collection\n const initialPeerContext: PeerContext = new Map()\n initialPeerContext.index = this.currentPeerContextIndex\n this.peerContexts = [initialPeerContext]\n }\n\n /**\n * Get the next peer context index.\n */\n nextPeerContextIndex() {\n return ++this.currentPeerContextIndex\n }\n\n /**\n * Delete all nodes and edges that are unreachable from the importers.\n * The collection of deleted nodes is returned.\n *\n * NOTE: This can be extremely slow for large graphs, and is almost always\n * unnecessary! Only call when it is known that some unreachable nodes may\n * have been created, for example when deleting the unneeded subgraph when an\n * optional node fails to resolve/install.\n */\n gc() {\n const { nodes } = this\n this.edges.clear()\n this.nodes = new Map()\n const marked = new Set(this.importers)\n for (const imp of marked) {\n // don't delete the importer!\n nodes.delete(imp.id)\n this.nodes.set(imp.id, imp)\n for (const edge of imp.edgesOut.values()) {\n this.edges.add(edge)\n const { to } = edge\n if (!to || marked.has(to)) continue\n marked.add(to)\n nodes.delete(to.id)\n this.nodes.set(to.id, to)\n }\n }\n for (const node of nodes.values()) {\n this.removeNode(node)\n }\n return nodes\n }\n\n /**\n * Create a new edge between two nodes of the graph in case both exist,\n * in case the destination node does not exists, then a dangling edge,\n * pointing to nothing will be created to represent that missing dependency.\n */\n addEdge(\n type: DependencySaveType,\n spec: Spec,\n from: NodeLike,\n to?: NodeLike,\n ) {\n // fix any nameless spec\n if (spec.name === '(unknown)') {\n if (to) {\n spec.name = to.name /* c8 ignore next */ || '(unknown)'\n spec.spec = `${to.name}@${spec.bareSpec}`\n } else {\n throw error(\n 'Impossible to place a missing, nameless dependency',\n { spec },\n )\n }\n }\n const existing = from.edgesOut.get(spec.name)\n if (existing) {\n const edge = existing as Edge\n if (\n edge.type === type &&\n edge.spec.bareSpec === spec.bareSpec\n ) {\n if (to && to !== edge.to) {\n // removes this edge from its destination edgesIn ref\n edge.to?.edgesIn.delete(edge)\n // now swap the destination to the new one\n edge.to = to as Node\n edge.to.edgesIn.add(edge)\n }\n return edge\n }\n this.edges.delete(edge)\n }\n const f = from as Node\n const edgeOut = f.addEdgesTo(\n resolveSaveType(from, spec.name, type),\n spec,\n to as Node | undefined,\n )\n this.edges.add(edgeOut)\n return edgeOut\n }\n\n /**\n * Find an existing node to satisfy a dependency\n */\n findResolution(spec: Spec, fromNode: Node, extra = '') {\n const f = spec.final\n const sf = getResolutionCacheKey(f, fromNode.location, extra)\n const cached = this.resolutions.get(sf)\n if (cached) return cached\n const nbn = this.nodesByName.get(f.name)\n if (!nbn) return undefined\n for (const node of nbn) {\n if (\n satisfies(\n node.id,\n f,\n fromNode.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n this.resolutions.set(sf, node)\n // always set by now, because the node was added at some point\n this.resolutionsReverse.get(node)?.add(sf)\n return node\n }\n }\n }\n\n /**\n * Create a new node in the graph.\n */\n addNode(\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n const node = new Node(\n this.#nodeOptions,\n id,\n manifest,\n spec,\n name,\n version,\n )\n this.nodes.set(node.id, node)\n const nbn = this.nodesByName.get(node.name) ?? new Set()\n nbn.add(node)\n\n // ensure the nodes by name set is always sorted, this will help\n // keeping a deterministic graph resolution when reusing nodes\n const newByNameSet = new Set(\n [...nbn].sort((a, b) => a.id.localeCompare(b.id)),\n )\n this.nodesByName.set(node.name, newByNameSet)\n\n if (manifest) {\n this.manifests.set(node.id, manifest)\n }\n return node\n }\n\n /**\n * Place a new package into the graph representation, creating the new\n * edges and possibly new nodes that are to be expected when traversing\n * the graph in a top-down direction, e.g: from importers to leafs.\n *\n * For different uses that are not a direct top-down traversal of the graph\n * consider using `addNode()` and `addEdge()` instead.\n */\n placePackage(\n fromNode: Node,\n depType: DependencySaveType,\n spec: Spec,\n manifest?: NormalizedManifest,\n id?: DepID,\n extra?: string,\n ): Node | undefined {\n // if no manifest is available, then create an edge that has no\n // reference to any other node, representing a missing dependency\n if (!manifest && !id) {\n this.addEdge(depType, spec, fromNode)\n return\n }\n\n // flags set on the node we're about to create or find.\n const flags = {\n dev: fromNode.dev || depType === 'dev',\n optional:\n fromNode.optional ||\n depType === 'optional' ||\n depType === 'peerOptional',\n }\n\n const depId = id || (manifest && getId(spec, manifest, extra))\n\n /* c8 ignore start - should not be possible */\n if (!depId) {\n throw error('Could not find dep id when placing package', {\n spec,\n manifest,\n })\n }\n /* c8 ignore stop */\n\n // if a node for this package is already represented by a node\n // in the graph, then just creates a new edge to that node\n const toFoundNode = this.nodes.get(depId)\n if (toFoundNode) {\n this.addEdge(depType, spec, fromNode, toFoundNode)\n // the current only stays dev/optional if this dep lets it remain so\n // if it's not already, we don't make it dev or optional.\n toFoundNode.detached = false\n toFoundNode.dev &&= flags.dev\n toFoundNode.optional &&= flags.optional\n return toFoundNode\n }\n\n // creates a new node and edges to its parent\n const toNode = this.addNode(depId, manifest, spec)\n toNode.registry = spec.registry\n toNode.dev = flags.dev\n toNode.optional = flags.optional\n // split extra into modifier and peerSetHash\n if (extra) {\n const { modifier, peerSetHash } = splitExtra(extra)\n toNode.modifier = modifier\n toNode.peerSetHash = peerSetHash\n }\n\n // add extra manifest info if available\n if (manifest) {\n const { bin, engines, os, cpu } = manifest\n // add platform info if available\n if (engines || os || cpu) {\n const platform: NodeLike['platform'] = {}\n if (engines) platform.engines = engines\n if (os) platform.os = os\n if (cpu) platform.cpu = cpu\n toNode.platform = platform\n }\n // add bin info if available\n if (bin) {\n toNode.bins = bin\n }\n }\n toNode.maybeSetConfusedManifest(spec, manifest)\n\n this.addEdge(depType, spec, fromNode, toNode)\n\n // populate resolution cache if applicable\n const f = getResolutionCacheKey(\n spec.final,\n fromNode.location,\n extra || '',\n )\n this.resolutions.set(f, toNode)\n const rrev = this.resolutionsReverse.get(toNode) ?? new Set()\n rrev.add(f)\n this.resolutionsReverse.set(toNode, rrev)\n\n return toNode\n }\n\n /**\n * Removes a node and its relevant edges from the graph.\n *\n * Use the `keepEdges` option to keep the edges that were pointing to\n * this node and only removes their `to` property value.\n *\n * If a replacement is provided, then any edges that were previously\n * pointing to the removed node will be directed to the replacement,\n * if it is valid to do so.\n */\n removeNode(node: Node, replacement?: Node, keepEdges?: boolean) {\n this.nodes.delete(node.id)\n const nbn = this.nodesByName.get(node.name)\n // if it's the last one, just remove the set\n if (nbn?.size === 1) this.nodesByName.delete(node.name)\n else nbn?.delete(node)\n for (const r of this.resolutionsReverse.get(node) ?? new Set()) {\n this.resolutions.delete(r)\n }\n this.resolutionsReverse.delete(node)\n this.manifests.delete(node.id)\n for (const edge of node.edgesOut.values()) {\n this.edges.delete(edge)\n }\n for (const edge of node.edgesIn) {\n if (\n replacement &&\n satisfies(\n replacement.id,\n edge.spec,\n edge.from.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n edge.to = replacement\n } else if (keepEdges) {\n edge.to = undefined\n } else {\n edge.from.edgesOut.delete(edge.spec.name)\n this.edges.delete(edge)\n }\n }\n }\n\n /**\n * Removes the resolved node of a given edge.\n */\n removeEdgeResolution(edge: Edge, extra = '') {\n const node = edge.to\n const resolutionKey = getResolutionCacheKey(\n edge.spec,\n edge.from.location,\n extra,\n )\n if (node) {\n edge.to = undefined\n this.resolutions.delete(resolutionKey)\n this.resolutionsReverse.get(node)?.delete(resolutionKey)\n this.nodesByName.delete(node.name)\n node.edgesIn.delete(edge)\n if (node.edgesIn.size === 0) {\n this.nodes.delete(node.id)\n }\n }\n }\n\n /**\n * Remove all edges from the graph while preserving nodes and resolution caches.\n * This allows the graph to be reconstructed efficiently using the existing nodes.\n */\n resetEdges() {\n // Clear the global edges set\n this.edges.clear()\n\n // Clear all node edge relationships\n for (const node of this.nodes.values()) {\n // marking nodes as detached needs to be restricted to only those\n // that had a manifest, otherwise we'd be skipping fetching manifest\n // for nodes we don't have a manifest during the ideal build phase\n if (node.manifest) node.detached = true\n\n // detaches all edges from this node\n node.edgesOut.clear()\n node.edgesIn.clear()\n }\n }\n\n toJSON() {\n return lockfileData({\n ...this.#options,\n graph: this,\n saveManifests: true,\n })\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const data = this.toJSON()\n return `${this[Symbol.toStringTag]} ${inspect(data, options)}`\n }\n}\n"]}
@@ -5,5 +5,16 @@ import type { PathScurry } from 'path-scurry';
5
5
  import type { Dependency } from '../dependencies.ts';
6
6
  import type { Graph } from '../graph.ts';
7
7
  import type { Node } from '../node.ts';
8
- export declare const appendNodes: (add: Map<string, Dependency>, packageInfo: PackageInfoClient, graph: Graph, fromNode: Node, deps: Dependency[], scurry: PathScurry, options: SpecOptions, seen: Set<DepID>) => Promise<void>;
8
+ import type { GraphModifier, ModifierActiveEntry } from '../modifiers.ts';
9
+ import type { ExtractResult } from '../reify/extract-node.ts';
10
+ import type { RollbackRemove } from '@vltpkg/rollback-remove';
11
+ import type { TransientAddMap, TransientRemoveMap } from './types.ts';
12
+ /**
13
+ * Append new nodes in the given `graph` for dependencies specified at `add`
14
+ * and missing dependencies from the `deps` parameter.
15
+ *
16
+ * It also applies any modifiers that applies to a given node as it processes
17
+ * and builds the graph.
18
+ */
19
+ export declare const appendNodes: (packageInfo: PackageInfoClient, graph: Graph, fromNode: Node, deps: Dependency[], scurry: PathScurry, options: SpecOptions, seen: Set<DepID>, add?: Map<string, Dependency>, modifiers?: GraphModifier, modifierRefs?: Map<string, ModifierActiveEntry>, extractPromises?: Promise<ExtractResult>[], actual?: Graph, seenExtracted?: Set<DepID>, remover?: RollbackRemove, transientAdd?: TransientAddMap, transientRemove?: TransientRemoveMap) => Promise<void>;
9
20
  //# sourceMappingURL=append-nodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"append-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAG/C,OAA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U,WACT,WAAW,QACd,GAAG,CAAC,KAAK,CAAC,QACV,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,cACjB,aAAa,iBACV,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,oBAC7B,OAAO,CAAC,aAAa,CAAC,EAAE,WACjC,KAAK,kBACE,GAAG,CAAC,KAAK,CAAC,YAChB,cAAc,iBACT,eAAe,oBACZ,kBAAkB,kBAyGrC,CAAA"}
@@ -1,9 +1,12 @@
1
- import { joinDepIDTuple } from '@vltpkg/dep-id';
1
+ import { joinDepIDTuple, joinExtra } from '@vltpkg/dep-id';
2
2
  import { error } from '@vltpkg/error-cause';
3
3
  import { Spec } from '@vltpkg/spec';
4
- import { longDependencyTypes } from '@vltpkg/types';
5
- import { asDependency, shorten } from "../dependencies.js";
4
+ import { longDependencyTypes, normalizeManifest } from '@vltpkg/types';
5
+ import { fixupAddedNames } from "../fixup-added-names.js";
6
+ import { shorten } from "../dependencies.js";
6
7
  import { removeOptionalSubgraph } from "../remove-optional-subgraph.js";
8
+ import { extractNode } from "../reify/extract-node.js";
9
+ import { endPeerPlacement, postPlacementPeerCheck, startPeerPlacement, } from "./peers.js";
7
10
  /**
8
11
  * Only install devDeps for git dependencies and importers
9
12
  * Everything else always gets installed
@@ -36,59 +39,145 @@ const getFileTypeInfo = (spec, fromNode, scurry) => {
36
39
  };
37
40
  };
38
41
  const isStringArray = (a) => Array.isArray(a) && !a.some(b => typeof b !== 'string');
39
- export const appendNodes = async (add, packageInfo, graph, fromNode, deps, scurry, options, seen) => {
40
- /* c8 ignore next */
41
- if (seen.has(fromNode.id))
42
- return;
43
- seen.add(fromNode.id);
44
- await Promise.all(deps.map(async ({ spec, type }) => {
45
- // see if there's a satisfying node in the graph currently
42
+ /**
43
+ * Fetch manifests for dependencies and create placement tasks.
44
+ */
45
+ const fetchManifestsForDeps = async (packageInfo, graph, fromNode, deps, scurry, peerContext, modifierRefs, depth = 0) => {
46
+ // Create fetch tasks for all dependencies at this level
47
+ const fetchTasks = [];
48
+ const placementTasks = [];
49
+ for (const { spec: originalSpec, type } of deps) {
50
+ let spec = originalSpec;
46
51
  const fileTypeInfo = getFileTypeInfo(spec, fromNode, scurry);
47
- const existingNode = graph.findResolution(spec, fromNode);
48
- if (existingNode) {
52
+ const activeModifier = modifierRefs?.get(spec.name);
53
+ // here is the place we swap specs if a edge modifier was defined
54
+ const queryModifier = activeModifier?.modifier.query;
55
+ const completeModifier = activeModifier &&
56
+ activeModifier.interactiveBreadcrumb.current ===
57
+ activeModifier.modifier.breadcrumb.last;
58
+ if (queryModifier &&
59
+ completeModifier &&
60
+ 'spec' in activeModifier.modifier) {
61
+ spec = activeModifier.modifier.spec;
62
+ if (spec.bareSpec === '-') {
63
+ continue;
64
+ }
65
+ }
66
+ const peer = type === 'peer' || type === 'peerOptional';
67
+ // skip reusing nodes for peer deps since their reusability
68
+ // is handled ahead-of-time during its parent's placement
69
+ const existingNode = graph.findResolution(spec, fromNode, queryModifier);
70
+ // defines what nodes are eligible to be reused
71
+ const validExistingNode = existingNode &&
72
+ !existingNode.detached &&
73
+ // Regular deps can always reuse
74
+ /* c8 ignore start */
75
+ (!peer ||
76
+ // otherwise reusing peer deps only in case of a peerSetHash matche
77
+ existingNode.peerSetHash === fromNode.peerSetHash);
78
+ /* c8 ignore stop */
79
+ if (validExistingNode ||
80
+ // importers are handled at the ./add-nodes.ts top-level
81
+ // so we should just skip whenever we find one
82
+ existingNode?.importer) {
49
83
  graph.addEdge(type, spec, fromNode, existingNode);
50
- return;
84
+ continue;
51
85
  }
86
+ // is the current edge pointint go an optional dependency?
52
87
  const edgeOptional = type === 'optional' || type === 'peerOptional';
53
- const mani = await packageInfo
54
- .manifest(spec, { from: scurry.resolve(fromNode.location) })
55
- .catch((er) => {
56
- // optional deps ignored if inaccessible
57
- if (edgeOptional || fromNode.optional) {
58
- return undefined;
59
- }
60
- throw er;
88
+ // Start manifest fetch immediately for parallel processing
89
+ const manifestPromise =
90
+ // the "detached" node state means that it has already been load as
91
+ // part of a graph (either lockfile or actual) and it has valid manifest
92
+ // data so we shortcut the package info manifest fetch here
93
+ existingNode?.detached ?
94
+ Promise.resolve(existingNode.manifest)
95
+ // this is the entry point to fetch calls to retrieve manifests
96
+ // from the build ideal graph point of view
97
+ : packageInfo
98
+ .manifest(spec, { from: scurry.resolve(fromNode.location) })
99
+ .then(manifest => manifest)
100
+ .catch((er) => {
101
+ // optional deps ignored if inaccessible
102
+ if (edgeOptional || fromNode.optional) {
103
+ return undefined;
104
+ }
105
+ throw er;
106
+ });
107
+ const fetchTask = {
108
+ spec,
109
+ type,
110
+ fromNode,
111
+ fileTypeInfo,
112
+ activeModifier,
113
+ queryModifier,
114
+ edgeOptional,
115
+ manifestPromise,
116
+ depth,
117
+ peerContext,
118
+ };
119
+ fetchTasks.push(fetchTask);
120
+ }
121
+ // Create placement tasks from fetch tasks
122
+ for (const fetchTask of fetchTasks) {
123
+ const manifest = await fetchTask.manifestPromise;
124
+ placementTasks.push({
125
+ fetchTask,
126
+ manifest,
61
127
  });
62
- // when an user is adding a nameless dependency, e.g: `github:foo/bar`,
63
- // `file:./foo/bar`, we need to update the `add` option value to set the
64
- // correct name once we have it, so that it can properly be stored in
65
- // the `package.json` file at the end of reify.
66
- if (mani?.name && spec.name === '(unknown)') {
67
- const s = add.get(String(spec));
68
- if (s) {
69
- // removes the previous, placeholder entry key
70
- add.delete(String(spec));
71
- // replaces spec with a version with the correct name
72
- spec = Spec.parse(mani.name, spec.bareSpec, options);
73
- // updates the add map with the fixed up spec
74
- const n = asDependency({
75
- ...s,
76
- spec,
77
- });
78
- add.set(mani.name, n);
79
- }
128
+ }
129
+ // sort placement tasks: non-peer dependencies first, then peer dependencies
130
+ // so that peer dependencies can easily reuse already placed regular
131
+ // dependencies as part of peer context set resolution also makes sure to
132
+ // sort by the manifest name for deterministic order.
133
+ placementTasks.sort((a, b) => {
134
+ const aIsPeer = (a.manifest?.peerDependencies &&
135
+ Object.keys(a.manifest.peerDependencies).length > 0) ?
136
+ 1
137
+ : 0;
138
+ const bIsPeer = (b.manifest?.peerDependencies &&
139
+ Object.keys(b.manifest.peerDependencies).length > 0) ?
140
+ 1
141
+ : 0;
142
+ // regular dependencies first, peer dependencies last
143
+ if (aIsPeer !== bIsPeer) {
144
+ return aIsPeer - bIsPeer;
80
145
  }
81
- if (!mani) {
146
+ // if both are in the same group,
147
+ // sort alphabetically by manifest name (fallback to spec.name)
148
+ const aName = a.manifest?.name /* c8 ignore next */ || a.fetchTask.spec.name;
149
+ const bName = b.manifest?.name || b.fetchTask.spec.name;
150
+ return aName.localeCompare(bName, 'en');
151
+ });
152
+ return placementTasks;
153
+ };
154
+ /**
155
+ * Process placement tasks and collect child dependencies, this is the
156
+ * second step of the appendNodes operation after manifest fetching in
157
+ * which the final graph data structure is actually built.
158
+ */
159
+ const processPlacementTasks = async (graph, options, placementTasks, add, modifiers, scurry, packageInfo, extractPromises, actual, seenExtracted, remover, transientAdd, transientRemove) => {
160
+ const childDepsToProcess = [];
161
+ for (const placementTask of placementTasks) {
162
+ const { fetchTask, manifest } = placementTask;
163
+ let { activeModifier, edgeOptional, fileTypeInfo, fromNode, peerContext, queryModifier, spec, type, } = fetchTask;
164
+ // fix the name in the `add` map when needed. This allows the upcoming
165
+ // reify step to properly update the package.json file dependencies
166
+ // using the correct names retrieved from the manifest data
167
+ const additiveMap = fromNode.importer ? add : transientAdd?.get(fromNode.id);
168
+ spec = fixupAddedNames(additiveMap, manifest, options, spec);
169
+ // handles missing manifest resolution
170
+ if (!manifest) {
82
171
  if (!edgeOptional && fromNode.isOptional()) {
83
172
  // failed resolution of a non-optional dep of an optional node
84
173
  // have to clean up the dependents
85
174
  removeOptionalSubgraph(graph, fromNode);
86
- return;
175
+ continue;
87
176
  }
88
177
  else if (edgeOptional) {
89
178
  // failed resolution of an optional dep, just ignore it,
90
179
  // nothing to prune because we never added it in the first place.
91
- return;
180
+ continue;
92
181
  }
93
182
  else {
94
183
  throw error('failed to resolve dependency', {
@@ -97,7 +186,14 @@ export const appendNodes = async (add, packageInfo, graph, fromNode, deps, scurr
97
186
  });
98
187
  }
99
188
  }
100
- const node = graph.placePackage(fromNode, type, spec, mani, fileTypeInfo?.id);
189
+ // start peer deps placement process, populating the peer context with
190
+ // dependency data; adding the parent node deps and this manifest's
191
+ // peer deps references to the current peer context set
192
+ const peerPlacement = startPeerPlacement(peerContext, manifest, fromNode, options);
193
+ const peerSetHash = peerPlacement.peerSetHash;
194
+ const queuedEntries = peerPlacement.queuedEntries;
195
+ // places a new node in the graph representing a newly seen dependency
196
+ const node = graph.placePackage(fromNode, type, spec, normalizeManifest(manifest), fileTypeInfo?.id, joinExtra({ peerSetHash, modifier: queryModifier }));
101
197
  /* c8 ignore start - not possible, already ensured manifest */
102
198
  if (!node) {
103
199
  throw error('failed to place package', {
@@ -106,38 +202,192 @@ export const appendNodes = async (add, packageInfo, graph, fromNode, deps, scurr
106
202
  });
107
203
  }
108
204
  /* c8 ignore stop */
205
+ // update the node modifier tracker
206
+ if (activeModifier) {
207
+ modifiers?.updateActiveEntry(node, activeModifier);
208
+ }
209
+ const eligibleForExtraction = type !== 'peer' &&
210
+ type !== 'peerOptional' &&
211
+ remover &&
212
+ extractPromises &&
213
+ actual &&
214
+ scurry &&
215
+ packageInfo &&
216
+ node.inVltStore() &&
217
+ !node.isOptional() &&
218
+ // this fixes an issue with installing `file:pathname` specs
219
+ /* c8 ignore next */ !fileTypeInfo?.isDirectory &&
220
+ !node.importer;
221
+ // extract the node if it meets the criteria for early extraction
222
+ if (eligibleForExtraction) {
223
+ /* c8 ignore start */
224
+ if (seenExtracted?.has(node.id)) {
225
+ continue;
226
+ }
227
+ /* c8 ignore stop */
228
+ seenExtracted?.add(node.id);
229
+ const actualNode = actual.nodes.get(node.id);
230
+ if (!actualNode?.equals(node)) {
231
+ // extract the node without awaiting - push the promise to the array
232
+ const extractPromise = extractNode(node, scurry, remover, options, packageInfo);
233
+ extractPromises.push(extractPromise);
234
+ }
235
+ }
236
+ // updates graph node information
109
237
  if (fileTypeInfo?.path && fileTypeInfo.isDirectory) {
110
238
  node.location = fileTypeInfo.path;
111
239
  }
112
240
  node.setResolved();
113
- const nestedAppends = [];
114
- const bundleDeps = node.manifest?.bundleDependencies;
241
+ // collect child dependencies for processing in the next level
242
+ const nextPeerDeps = new Map();
243
+ // compute deps normally
244
+ const bundleDeps = manifest.bundleDependencies;
115
245
  const bundled = new Set((node.id.startsWith('git') ||
116
246
  node.importer ||
117
247
  !isStringArray(bundleDeps)) ?
118
248
  []
119
249
  : bundleDeps);
250
+ // setup next level to process all child dependencies in the manifest
120
251
  const nextDeps = [];
252
+ // traverse actual dependency declarations in the manifest
253
+ // creating dependency entries for them
121
254
  for (const depTypeName of longDependencyTypes) {
122
- const depRecord = mani[depTypeName];
255
+ const depRecord = manifest[depTypeName];
123
256
  if (depRecord && shouldInstallDepType(node, depTypeName)) {
124
257
  for (const [name, bareSpec] of Object.entries(depRecord)) {
258
+ // might need to skip already placed peer deps here
125
259
  if (bundled.has(name))
126
260
  continue;
127
- nextDeps.push({
128
- type: shorten(depTypeName, name, mani),
261
+ const dep = {
262
+ type: shorten(depTypeName, name, manifest),
129
263
  spec: Spec.parse(name, bareSpec, {
130
264
  ...options,
131
265
  registry: spec.registry,
132
266
  }),
133
- });
267
+ };
268
+ if (depTypeName === 'peerDependencies') {
269
+ nextPeerDeps.set(name, dep);
270
+ }
271
+ else {
272
+ nextDeps.push(dep);
273
+ }
274
+ }
275
+ }
276
+ }
277
+ // Inject transient dependencies for non-importer nodes (nested folders)
278
+ // These are deps that were added from a nested folder context using
279
+ // relative file: specs that should resolve relative to that folder
280
+ const transientDeps = transientAdd?.get(node.id);
281
+ if (transientDeps) {
282
+ for (const [, dep] of transientDeps) {
283
+ if (dep.type === 'peer' || dep.type === 'peerOptional') {
284
+ nextPeerDeps.set(dep.spec.name, dep);
285
+ continue;
286
+ }
287
+ // remove the dependency from nextDeps if it already exists
288
+ const index = nextDeps.findIndex(d => d.spec.name === dep.spec.name);
289
+ if (index !== -1) {
290
+ nextDeps.splice(index, 1);
291
+ }
292
+ nextDeps.push(dep);
293
+ }
294
+ }
295
+ // Remove transient removals when needed
296
+ const transientRemovals = transientRemove?.get(node.id);
297
+ if (transientRemovals) {
298
+ for (const depName of transientRemovals) {
299
+ const index = nextDeps.findIndex(dep => dep.spec.name === depName);
300
+ if (index !== -1) {
301
+ nextDeps.splice(index, 1);
302
+ continue;
303
+ }
304
+ if (nextPeerDeps.has(depName)) {
305
+ nextPeerDeps.delete(depName);
134
306
  }
135
307
  }
136
308
  }
137
- if (nextDeps.length) {
138
- nestedAppends.push(appendNodes(add, packageInfo, graph, node, nextDeps, scurry, options, seen));
309
+ // finish peer placement for this node, resolving satisfied peers
310
+ // to seen nodes from the peer context and adding unsatisfied peers
311
+ // to `nextDeps` so they get processed along regular dependencies
312
+ const updateContext = endPeerPlacement(peerContext, nextDeps, nextPeerDeps, graph, spec, fromNode, node, type, queuedEntries);
313
+ childDepsToProcess.push({
314
+ node,
315
+ deps: nextDeps,
316
+ modifierRefs: modifiers?.tryDependencies(node, nextDeps),
317
+ peerContext,
318
+ updateContext,
319
+ });
320
+ }
321
+ return childDepsToProcess;
322
+ };
323
+ /**
324
+ * Append new nodes in the given `graph` for dependencies specified at `add`
325
+ * and missing dependencies from the `deps` parameter.
326
+ *
327
+ * It also applies any modifiers that applies to a given node as it processes
328
+ * and builds the graph.
329
+ */
330
+ export const appendNodes = async (packageInfo, graph, fromNode, deps, scurry, options, seen, add, modifiers, modifierRefs, extractPromises, actual, seenExtracted, remover, transientAdd, transientRemove) => {
331
+ /* c8 ignore next */
332
+ if (seen.has(fromNode.id))
333
+ return;
334
+ seen.add(fromNode.id);
335
+ // Get the initial peer context from the graph
336
+ const [initialPeerContext] = graph.peerContexts;
337
+ /* c8 ignore start - impossible */
338
+ if (!initialPeerContext) {
339
+ throw error('no initial peer context found in graph');
340
+ }
341
+ /* c8 ignore stop */
342
+ // Use a queue for breadth-first processing
343
+ let currentLevelDeps = [
344
+ {
345
+ node: fromNode,
346
+ deps,
347
+ modifierRefs,
348
+ depth: 0,
349
+ peerContext: initialPeerContext,
350
+ /* c8 ignore start */
351
+ updateContext: {
352
+ putEntries: () => undefined,
353
+ resolvePeerDeps: () => { },
354
+ },
355
+ /* c8 ignore stop */
356
+ },
357
+ ];
358
+ while (currentLevelDeps.length > 0) {
359
+ const nextLevelDeps = [];
360
+ // Process all nodes at the current level in parallel
361
+ const levelResults = await Promise.all(currentLevelDeps.map(async ({ node, deps: nodeDeps, modifierRefs: nodeModifierRefs, peerContext, depth, }) => {
362
+ // Mark node as seen when we start processing its dependencies
363
+ seen.add(node.id);
364
+ // Fetch manifests for this node's dependencies
365
+ const placementTasks = await fetchManifestsForDeps(packageInfo, graph, node,
366
+ // Sort dependencies by spec.name for deterministic ordering
367
+ nodeDeps.sort((a, b) => a.spec.name.localeCompare(b.spec.name, 'en')), scurry, peerContext, nodeModifierRefs, depth);
368
+ // Process the placement tasks and get child dependencies
369
+ return await processPlacementTasks(graph, options, placementTasks, add, modifiers, scurry, packageInfo, extractPromises, actual, seenExtracted, remover, transientAdd, transientRemove);
370
+ }));
371
+ // Traverse the queued up children dependencies, adding and tracking
372
+ // dependencies on the peer context set, forking the context as needed
373
+ // and resolving any peer dependency that is able to be resolved using
374
+ // the current peer context set
375
+ postPlacementPeerCheck(graph, levelResults);
376
+ // Collect all child dependencies for the next level
377
+ for (const childDepsToProcess of levelResults) {
378
+ for (const childDep of childDepsToProcess) {
379
+ if (!seen.has(childDep.node.id)) {
380
+ /* c8 ignore next */
381
+ const currentDepth = currentLevelDeps[0]?.depth ?? 0;
382
+ nextLevelDeps.push({
383
+ ...childDep,
384
+ depth: currentDepth + 1,
385
+ });
386
+ }
387
+ }
139
388
  }
140
- await Promise.all(nestedAppends);
141
- }));
389
+ // Move to the next level
390
+ currentLevelDeps = nextLevelDeps;
391
+ }
142
392
  };
143
393
  //# sourceMappingURL=append-nodes.js.map