foresthouse 1.0.0-dev.21 → 1.0.0-dev.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as printReactUsageTree, c as printPackageDependencyTree, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, m as isSourceCodeFile, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree } from "./react-DWxB8qZ6.mjs";
2
+ import { a as printReactUsageTree, c as printPackageDependencyTree, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, m as isSourceCodeFile, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree } from "./react-CABHoyGj.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as printReactUsageTree, c as printPackageDependencyTree, d as getReactUsageRoots, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, l as getFilteredUsages, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree, u as getReactUsageEntries } from "./react-DWxB8qZ6.mjs";
1
+ import { a as printReactUsageTree, c as printPackageDependencyTree, d as getReactUsageRoots, f as analyzeReactUsage, g as analyzePackageDependencies, h as analyzePackageDependencyDiff, i as graphToSerializablePackageTree, l as getFilteredUsages, n as graphToSerializableTree, o as printDependencyTree, p as analyzeDependencies, r as diffGraphToSerializablePackageTree, s as printPackageDependencyDiffTree, t as graphToSerializableReactTree, u as getReactUsageEntries } from "./react-CABHoyGj.mjs";
2
2
  export { analyzeDependencies, analyzePackageDependencies, analyzePackageDependencyDiff, analyzeReactUsage, diffGraphToSerializablePackageTree, getFilteredUsages, getReactUsageEntries, getReactUsageRoots, graphToSerializablePackageTree, graphToSerializableReactTree, graphToSerializableTree, printDependencyTree, printPackageDependencyDiffTree, printPackageDependencyTree, printReactUsageTree };
@@ -2169,28 +2169,31 @@ function printDependencyTree(graph, options = {}) {
2169
2169
  const omitUnused = options.omitUnused ?? false;
2170
2170
  const rootLines = [toDisplayPath(graph.entryId, cwd)];
2171
2171
  const visited = new Set([graph.entryId]);
2172
+ const expanded = new Set([graph.entryId]);
2172
2173
  const entryNode = graph.nodes.get(graph.entryId);
2173
2174
  if (entryNode === void 0) return rootLines.join("\n");
2174
2175
  const rootDependencies = filterDependencies(entryNode.dependencies, includeExternals, omitUnused);
2175
2176
  rootDependencies.forEach((dependency, index) => {
2176
- rootLines.push(...renderDependency(dependency, graph, visited, "", index === rootDependencies.length - 1, includeExternals, omitUnused, color, cwd));
2177
+ rootLines.push(...renderDependency(dependency, graph, visited, expanded, "", index === rootDependencies.length - 1, includeExternals, omitUnused, color, cwd));
2177
2178
  });
2178
2179
  return rootLines.join("\n");
2179
2180
  }
2180
- function renderDependency(dependency, graph, visited, prefix, isLast, includeExternals, omitUnused, color, cwd) {
2181
+ function renderDependency(dependency, graph, visited, expanded, prefix, isLast, includeExternals, omitUnused, color, cwd) {
2181
2182
  const branch = `${prefix}${isLast ? "└─ " : "├─ "}`;
2182
2183
  const label = formatDependencyLabel(dependency, cwd, color);
2183
2184
  if (dependency.kind !== "source") return [`${branch}${label}`];
2184
2185
  if (visited.has(dependency.target)) return [`${branch}${label} (circular)`];
2185
2186
  const childNode = graph.nodes.get(dependency.target);
2186
2187
  if (childNode === void 0) return [`${branch}${label}`];
2188
+ if (expanded.has(dependency.target)) return [`${branch}${label} (shared)`];
2187
2189
  const nextPrefix = `${prefix}${isLast ? " " : "│ "}`;
2188
2190
  const nextVisited = new Set(visited);
2189
2191
  nextVisited.add(dependency.target);
2192
+ expanded.add(dependency.target);
2190
2193
  const childLines = [`${branch}${label}`];
2191
2194
  const childDependencies = filterDependencies(childNode.dependencies, includeExternals, omitUnused);
2192
2195
  childDependencies.forEach((childDependency, index) => {
2193
- childLines.push(...renderDependency(childDependency, graph, nextVisited, nextPrefix, index === childDependencies.length - 1, includeExternals, omitUnused, color, cwd));
2196
+ childLines.push(...renderDependency(childDependency, graph, nextVisited, expanded, nextPrefix, index === childDependencies.length - 1, includeExternals, omitUnused, color, cwd));
2194
2197
  });
2195
2198
  return childLines;
2196
2199
  }
@@ -2371,10 +2374,9 @@ function serializePackageDiffDependency(dependency) {
2371
2374
  //#endregion
2372
2375
  //#region src/output/json/import.ts
2373
2376
  function graphToSerializableTree(graph, options = {}) {
2374
- const visited = /* @__PURE__ */ new Set();
2375
- return serializeNode(graph.entryId, graph, visited, options.omitUnused ?? false);
2377
+ return serializeNode(graph.entryId, graph, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), options.omitUnused ?? false);
2376
2378
  }
2377
- function serializeNode(filePath, graph, visited, omitUnused) {
2379
+ function serializeNode(filePath, graph, visited, expanded, omitUnused) {
2378
2380
  const node = graph.nodes.get(filePath);
2379
2381
  const displayPath = toDisplayPath(filePath, graph.cwd);
2380
2382
  if (node === void 0) return {
@@ -2387,7 +2389,14 @@ function serializeNode(filePath, graph, visited, omitUnused) {
2387
2389
  kind: "circular",
2388
2390
  dependencies: []
2389
2391
  };
2390
- visited.add(filePath);
2392
+ if (expanded.has(filePath)) return {
2393
+ path: displayPath,
2394
+ kind: "shared",
2395
+ dependencies: []
2396
+ };
2397
+ const nextVisited = new Set(visited);
2398
+ nextVisited.add(filePath);
2399
+ expanded.add(filePath);
2391
2400
  const dependencies = node.dependencies.filter((dependency) => !omitUnused || !dependency.unused).map((dependency) => {
2392
2401
  if (dependency.kind !== "source") return {
2393
2402
  specifier: dependency.specifier,
@@ -2405,7 +2414,7 @@ function serializeNode(filePath, graph, visited, omitUnused) {
2405
2414
  unused: dependency.unused,
2406
2415
  kind: dependency.kind,
2407
2416
  target: toDisplayPath(dependency.target, graph.cwd),
2408
- node: serializeNode(dependency.target, graph, new Set(visited), omitUnused)
2417
+ node: serializeNode(dependency.target, graph, nextVisited, expanded, omitUnused)
2409
2418
  };
2410
2419
  });
2411
2420
  return {
@@ -2481,4 +2490,4 @@ function formatReactNodeFilePath(filePath, kind, cwd) {
2481
2490
  //#endregion
2482
2491
  export { printReactUsageTree as a, printPackageDependencyTree as c, getReactUsageRoots as d, analyzeReactUsage as f, analyzePackageDependencies as g, analyzePackageDependencyDiff as h, graphToSerializablePackageTree as i, getFilteredUsages as l, isSourceCodeFile as m, graphToSerializableTree as n, printDependencyTree as o, analyzeDependencies as p, diffGraphToSerializablePackageTree as r, printPackageDependencyDiffTree as s, graphToSerializableReactTree as t, getReactUsageEntries as u };
2483
2492
 
2484
- //# sourceMappingURL=react-DWxB8qZ6.mjs.map
2493
+ //# sourceMappingURL=react-CABHoyGj.mjs.map