@depxray/core 1.3.0

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 (57) hide show
  1. package/dist/buildGraph.d.ts +11 -0
  2. package/dist/buildGraph.d.ts.map +1 -0
  3. package/dist/buildGraph.js +111 -0
  4. package/dist/buildGraph.js.map +1 -0
  5. package/dist/buildStructureGraph.d.ts +3 -0
  6. package/dist/buildStructureGraph.d.ts.map +1 -0
  7. package/dist/buildStructureGraph.js +45 -0
  8. package/dist/buildStructureGraph.js.map +1 -0
  9. package/dist/configLoader.d.ts +18 -0
  10. package/dist/configLoader.d.ts.map +1 -0
  11. package/dist/configLoader.js +188 -0
  12. package/dist/configLoader.js.map +1 -0
  13. package/dist/detectCircularDeps.d.ts +21 -0
  14. package/dist/detectCircularDeps.d.ts.map +1 -0
  15. package/dist/detectCircularDeps.js +159 -0
  16. package/dist/detectCircularDeps.js.map +1 -0
  17. package/dist/detectOrphanFiles.d.ts +4 -0
  18. package/dist/detectOrphanFiles.d.ts.map +1 -0
  19. package/dist/detectOrphanFiles.js +58 -0
  20. package/dist/detectOrphanFiles.js.map +1 -0
  21. package/dist/exportGraph.d.ts +16 -0
  22. package/dist/exportGraph.d.ts.map +1 -0
  23. package/dist/exportGraph.js +50 -0
  24. package/dist/exportGraph.js.map +1 -0
  25. package/dist/fileDiscovery.d.ts +21 -0
  26. package/dist/fileDiscovery.d.ts.map +1 -0
  27. package/dist/fileDiscovery.js +119 -0
  28. package/dist/fileDiscovery.js.map +1 -0
  29. package/dist/filterTreeByDepth.d.ts +3 -0
  30. package/dist/filterTreeByDepth.d.ts.map +1 -0
  31. package/dist/filterTreeByDepth.js +22 -0
  32. package/dist/filterTreeByDepth.js.map +1 -0
  33. package/dist/index.d.ts +15 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +43 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/parseImports.d.ts +30 -0
  38. package/dist/parseImports.d.ts.map +1 -0
  39. package/dist/parseImports.js +196 -0
  40. package/dist/parseImports.js.map +1 -0
  41. package/dist/resolveImports.d.ts +25 -0
  42. package/dist/resolveImports.d.ts.map +1 -0
  43. package/dist/resolveImports.js +189 -0
  44. package/dist/resolveImports.js.map +1 -0
  45. package/dist/scanFileTree.d.ts +3 -0
  46. package/dist/scanFileTree.d.ts.map +1 -0
  47. package/dist/scanFileTree.js +118 -0
  48. package/dist/scanFileTree.js.map +1 -0
  49. package/dist/scanProject.d.ts +39 -0
  50. package/dist/scanProject.d.ts.map +1 -0
  51. package/dist/scanProject.js +224 -0
  52. package/dist/scanProject.js.map +1 -0
  53. package/dist/types.d.ts +316 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/dist/types.js +45 -0
  56. package/dist/types.js.map +1 -0
  57. package/package.json +44 -0
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // detectOrphanFiles - Find dependency graph nodes with no incoming imports
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.matchesAnyPattern = matchesAnyPattern;
7
+ exports.detectOrphanFiles = detectOrphanFiles;
8
+ const types_js_1 = require("./types.js");
9
+ function escapeRegExpChar(char) {
10
+ return /[\\^$+?.()|[\]{}]/.test(char) ? `\\${char}` : char;
11
+ }
12
+ function globToRegExp(pattern) {
13
+ const normalizedPattern = pattern.replaceAll('\\', '/');
14
+ let source = '^';
15
+ let index = 0;
16
+ while (index < normalizedPattern.length) {
17
+ const char = normalizedPattern[index];
18
+ const next = normalizedPattern[index + 1];
19
+ const afterNext = normalizedPattern[index + 2];
20
+ if (char === '*' && next === '*' && afterNext === '/') {
21
+ source += '(?:.*/)?';
22
+ index += 3;
23
+ continue;
24
+ }
25
+ if (char === '*' && next === '*') {
26
+ source += '.*';
27
+ index += 2;
28
+ continue;
29
+ }
30
+ if (char === '*') {
31
+ source += '[^/]*';
32
+ index += 1;
33
+ continue;
34
+ }
35
+ if (char === '?') {
36
+ source += '[^/]';
37
+ index += 1;
38
+ continue;
39
+ }
40
+ source += escapeRegExpChar(char);
41
+ index += 1;
42
+ }
43
+ source += '$';
44
+ return new RegExp(source);
45
+ }
46
+ function matchesAnyPattern(relativePath, patterns) {
47
+ const normalizedPath = relativePath.replaceAll('\\', '/');
48
+ return patterns.some((pattern) => globToRegExp(pattern).test(normalizedPath));
49
+ }
50
+ function detectOrphanFiles(graph, options = {}) {
51
+ const entryPointPatterns = options.entryPointPatterns ?? types_js_1.DEFAULT_ENTRY_POINT_PATTERNS;
52
+ return graph.nodes
53
+ .filter((node) => node.inDegree === 0)
54
+ .filter((node) => !matchesAnyPattern(node.relativePath, entryPointPatterns))
55
+ .map((node) => node.relativePath)
56
+ .sort((a, b) => a.localeCompare(b));
57
+ }
58
+ //# sourceMappingURL=detectOrphanFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detectOrphanFiles.js","sourceRoot":"","sources":["../src/detectOrphanFiles.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;;AAsD/E,8CAMC;AAED,8CAWC;AAnED,yCAA0D;AAE1D,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7D,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxD,IAAI,MAAM,GAAG,GAAG,CAAC;IACjB,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C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K;SACf,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC;SACrC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;SAC3E,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;SAChC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { DependencyGraph } from './types.js';
2
+ /**
3
+ * Serialize a DependencyGraph to a formatted JSON string.
4
+ *
5
+ * The output includes all nodes, edges, circular dependencies, and metadata.
6
+ * This format is designed to be:
7
+ * - Human-readable (indented JSON)
8
+ * - Machine-parseable (for AI agents like Claude, Codex, Antigravity)
9
+ * - Portable (uses relative paths for nodes/edges)
10
+ *
11
+ * @param graph - The dependency graph to serialize
12
+ * @param pretty - Whether to format with indentation (default: true)
13
+ * @returns JSON string representation of the graph
14
+ */
15
+ export declare function exportGraphJSON(graph: DependencyGraph, pretty?: boolean): string;
16
+ //# sourceMappingURL=exportGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportGraph.d.ts","sourceRoot":"","sources":["../src/exportGraph.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,MAAM,GAAE,OAAc,GACrB,MAAM,CA8BR"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // exportGraph — Serialize a DependencyGraph to JSON
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.exportGraphJSON = exportGraphJSON;
7
+ /**
8
+ * Serialize a DependencyGraph to a formatted JSON string.
9
+ *
10
+ * The output includes all nodes, edges, circular dependencies, and metadata.
11
+ * This format is designed to be:
12
+ * - Human-readable (indented JSON)
13
+ * - Machine-parseable (for AI agents like Claude, Codex, Antigravity)
14
+ * - Portable (uses relative paths for nodes/edges)
15
+ *
16
+ * @param graph - The dependency graph to serialize
17
+ * @param pretty - Whether to format with indentation (default: true)
18
+ * @returns JSON string representation of the graph
19
+ */
20
+ function exportGraphJSON(graph, pretty = true) {
21
+ // Create a clean export object with relative paths for portability
22
+ const exportData = {
23
+ version: '1.0.0',
24
+ metadata: graph.metadata,
25
+ nodes: graph.nodes.map((node) => ({
26
+ id: node.relativePath,
27
+ relativePath: node.relativePath,
28
+ extension: node.extension,
29
+ inDegree: node.inDegree,
30
+ outDegree: node.outDegree,
31
+ isCircular: node.isCircular,
32
+ ...(node.componentName ? { componentName: node.componentName } : {}),
33
+ })),
34
+ edges: graph.edges.map((edge) => ({
35
+ source: edge.source.includes(graph.rootDir)
36
+ ? edge.source.replace(graph.rootDir + '/', '')
37
+ : edge.source,
38
+ target: edge.target.includes(graph.rootDir)
39
+ ? edge.target.replace(graph.rootDir + '/', '')
40
+ : edge.target,
41
+ importSpecifier: edge.importSpecifier,
42
+ importedNames: edge.importedNames,
43
+ isTypeOnly: edge.isTypeOnly,
44
+ isDynamic: edge.isDynamic,
45
+ })),
46
+ circularDependencies: graph.circularDependencies,
47
+ };
48
+ return JSON.stringify(exportData, null, pretty ? 2 : undefined);
49
+ }
50
+ //# sourceMappingURL=exportGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportGraph.js","sourceRoot":"","sources":["../src/exportGraph.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,oDAAoD;AACpD,+EAA+E;;AAiB/E,0CAiCC;AA9CD;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAC7B,KAAsB,EACtB,SAAkB,IAAI;IAEtB,mEAAmE;IACnE,M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H,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;KACjD,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Recursively discover all scannable files in a directory.
3
+ *
4
+ * @param rootDir - The project root directory
5
+ * @param extensions - File extensions to include
6
+ * @param ignorePatterns - Directory names to skip entirely
7
+ * @param maxDepth - Maximum recursion depth (default: Infinity)
8
+ * @returns Array of absolute file paths
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const files = await discoverFiles('/path/to/project');
13
+ * // [
14
+ * // '/path/to/project/src/App.tsx',
15
+ * // '/path/to/project/src/components/Button.tsx',
16
+ * // ...
17
+ * // ]
18
+ * ```
19
+ */
20
+ export declare function discoverFiles(rootDir: string, extensions?: string[], ignorePatterns?: string[], maxDepth?: number): Promise<string[]>;
21
+ //# sourceMappingURL=fileDiscovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileDiscovery.d.ts","sourceRoot":"","sources":["../src/fileDiscovery.ts"],"names":[],"mappings":"AAqCA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,UAAU,GAAE,MAAM,EAAuB,EACzC,cAAc,GAAE,MAAM,EAA4B,EAClD,QAAQ,GAAE,MAAiB,GAC1B,OAAO,CAAC,MAAM,EAAE,CAAC,CAyCnB"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // fileDiscovery — Walk the filesystem and find scannable files
4
+ // ============================================================================
5
+ // Recursively traverses a project directory, collects files matching the
6
+ // target extensions, and prunes directories that should be ignored
7
+ // (node_modules, dist, .git, etc.).
8
+ //
9
+ // Uses async I/O to avoid blocking Node.js on large projects.
10
+ // ============================================================================
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.discoverFiles = discoverFiles;
46
+ const path = __importStar(require("path"));
47
+ const fs = __importStar(require("fs/promises"));
48
+ const types_js_1 = require("./types.js");
49
+ /**
50
+ * Check if a directory name should be ignored during traversal.
51
+ */
52
+ function shouldIgnoreDir(dirName, ignorePatterns) {
53
+ return ignorePatterns.some((pattern) => {
54
+ // Simple name matching (no glob support yet — keep it straightforward)
55
+ return dirName === pattern || dirName.startsWith(pattern);
56
+ });
57
+ }
58
+ /**
59
+ * Check if a file matches the target extensions.
60
+ */
61
+ function hasTargetExtension(filePath, extensions) {
62
+ return extensions.some((ext) => filePath.endsWith(ext));
63
+ }
64
+ /**
65
+ * Recursively discover all scannable files in a directory.
66
+ *
67
+ * @param rootDir - The project root directory
68
+ * @param extensions - File extensions to include
69
+ * @param ignorePatterns - Directory names to skip entirely
70
+ * @param maxDepth - Maximum recursion depth (default: Infinity)
71
+ * @returns Array of absolute file paths
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const files = await discoverFiles('/path/to/project');
76
+ * // [
77
+ * // '/path/to/project/src/App.tsx',
78
+ * // '/path/to/project/src/components/Button.tsx',
79
+ * // ...
80
+ * // ]
81
+ * ```
82
+ */
83
+ async function discoverFiles(rootDir, extensions = types_js_1.DEFAULT_EXTENSIONS, ignorePatterns = types_js_1.DEFAULT_IGNORE_PATTERNS, maxDepth = Infinity) {
84
+ const results = [];
85
+ async function walk(dir, currentDepth) {
86
+ if (currentDepth > maxDepth) {
87
+ return;
88
+ }
89
+ let entries;
90
+ try {
91
+ entries = await fs.readdir(dir, { withFileTypes: true });
92
+ }
93
+ catch {
94
+ // Permission denied or other access error — skip silently
95
+ return;
96
+ }
97
+ // Process entries in parallel for performance
98
+ const tasks = [];
99
+ for (const entry of entries) {
100
+ const fullPath = path.join(dir, entry.name);
101
+ if (entry.isDirectory()) {
102
+ // Skip ignored directories entirely (prune the subtree)
103
+ if (!shouldIgnoreDir(entry.name, ignorePatterns)) {
104
+ tasks.push(walk(fullPath, currentDepth + 1));
105
+ }
106
+ }
107
+ else if (entry.isFile()) {
108
+ if (hasTargetExtension(entry.name, extensions)) {
109
+ results.push(fullPath);
110
+ }
111
+ }
112
+ }
113
+ await Promise.all(tasks);
114
+ }
115
+ await walk(rootDir, 0);
116
+ // Sort for deterministic output (helps with testing and diffing)
117
+ return results.sort();
118
+ }
119
+ //# sourceMappingURL=fileDiscovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileDiscovery.js","sourceRoot":"","sources":["../src/fileDiscovery.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,+DAA+D;AAC/D,+EAA+E;AAC/E,yEAAyE;A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I,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAE5C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,wDAAwD;gBACxD,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC;oBACjD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC1B,IAAI,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC;oBAC/C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACzB,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAEvB,iEAAiE;IACjE,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FileTreeNode } from './types.js';
2
+ export declare function filterTreeByDepth(rootNode: FileTreeNode, maxDepth: number): FileTreeNode;
3
+ //# sourceMappingURL=filterTreeByDepth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterTreeByDepth.d.ts","sourceRoot":"","sources":["../src/filterTreeByDepth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,MAAM,GACf,YAAY,CAoBd"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterTreeByDepth = filterTreeByDepth;
4
+ function filterTreeByDepth(rootNode, maxDepth) {
5
+ if (!Number.isFinite(maxDepth)) {
6
+ return structuredClone(rootNode);
7
+ }
8
+ function truncate(node) {
9
+ if (node.kind === 'directory' && node.depth >= maxDepth) {
10
+ return {
11
+ ...node,
12
+ children: [],
13
+ };
14
+ }
15
+ return {
16
+ ...node,
17
+ children: node.children.map(truncate),
18
+ };
19
+ }
20
+ return truncate(rootNode);
21
+ }
22
+ //# sourceMappingURL=filterTreeByDepth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterTreeByDepth.js","sourceRoot":"","sources":["../src/filterTreeByDepth.ts"],"names":[],"mappings":";;AAEA,8CAuBC;AAvBD,SAAgB,iBAAiB,CAC/B,QAAsB,EACtB,QAAgB;IAEhB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,SAAS,QAAQ,CAAC,IAAkB;QAClC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,IAAI,QAAQ,EAAE,CAAC;YACxD,OAAO;gBACL,GAAG,IAAI;gBACP,QAAQ,EAAE,EAAE;aACb,CAAC;QACJ,CAAC;QAED,OAAO;YACL,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;SACtC,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,15 @@
1
+ export { scanProject } from './scanProject.js';
2
+ export { exportGraphJSON } from './exportGraph.js';
3
+ export { scanFileTree } from './scanFileTree.js';
4
+ export { filterTreeByDepth } from './filterTreeByDepth.js';
5
+ export { buildStructureGraph } from './buildStructureGraph.js';
6
+ export { parseImports } from './parseImports.js';
7
+ export { resolveImport, resolveImports } from './resolveImports.js';
8
+ export { buildGraph } from './buildGraph.js';
9
+ export { detectCircularDeps } from './detectCircularDeps.js';
10
+ export { detectOrphanFiles, matchesAnyPattern } from './detectOrphanFiles.js';
11
+ export { discoverFiles } from './fileDiscovery.js';
12
+ export { loadAliases } from './configLoader.js';
13
+ export type { FileTreeNode, GraphNode, GraphEdge, StructureGraphNode, StructureGraphEdge, StructureGraph, CircularChain, DependencyGraph, ScanOptions, OrphanDetectionOptions, ScanFileTreeOptions, ScanResult, ScanError, ScanMetadata, RawImportInfo, ResolvedImport, AliasMapping, } from './types.js';
14
+ export { DEFAULT_EXTENSIONS, DEFAULT_ENTRY_POINT_PATTERNS, DEFAULT_IGNORE_PATTERNS, } from './types.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,YAAY,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,eAAe,EACf,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // @depxray/core — Public API
4
+ // ============================================================================
5
+ // Barrel export file. Everything exported here is the public API of the
6
+ // core scanner package. Keep this minimal and intentional.
7
+ // ============================================================================
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DEFAULT_IGNORE_PATTERNS = exports.DEFAULT_ENTRY_POINT_PATTERNS = exports.DEFAULT_EXTENSIONS = exports.loadAliases = exports.discoverFiles = exports.matchesAnyPattern = exports.detectOrphanFiles = exports.detectCircularDeps = exports.buildGraph = exports.resolveImports = exports.resolveImport = exports.parseImports = exports.buildStructureGraph = exports.filterTreeByDepth = exports.scanFileTree = exports.exportGraphJSON = exports.scanProject = void 0;
10
+ // ─── Main API ──────────────────────────────────────────────────────────────
11
+ var scanProject_js_1 = require("./scanProject.js");
12
+ Object.defineProperty(exports, "scanProject", { enumerable: true, get: function () { return scanProject_js_1.scanProject; } });
13
+ var exportGraph_js_1 = require("./exportGraph.js");
14
+ Object.defineProperty(exports, "exportGraphJSON", { enumerable: true, get: function () { return exportGraph_js_1.exportGraphJSON; } });
15
+ var scanFileTree_js_1 = require("./scanFileTree.js");
16
+ Object.defineProperty(exports, "scanFileTree", { enumerable: true, get: function () { return scanFileTree_js_1.scanFileTree; } });
17
+ var filterTreeByDepth_js_1 = require("./filterTreeByDepth.js");
18
+ Object.defineProperty(exports, "filterTreeByDepth", { enumerable: true, get: function () { return filterTreeByDepth_js_1.filterTreeByDepth; } });
19
+ var buildStructureGraph_js_1 = require("./buildStructureGraph.js");
20
+ Object.defineProperty(exports, "buildStructureGraph", { enumerable: true, get: function () { return buildStructureGraph_js_1.buildStructureGraph; } });
21
+ // ─── Individual modules (for advanced usage) ──────────────────────────────
22
+ var parseImports_js_1 = require("./parseImports.js");
23
+ Object.defineProperty(exports, "parseImports", { enumerable: true, get: function () { return parseImports_js_1.parseImports; } });
24
+ var resolveImports_js_1 = require("./resolveImports.js");
25
+ Object.defineProperty(exports, "resolveImport", { enumerable: true, get: function () { return resolveImports_js_1.resolveImport; } });
26
+ Object.defineProperty(exports, "resolveImports", { enumerable: true, get: function () { return resolveImports_js_1.resolveImports; } });
27
+ var buildGraph_js_1 = require("./buildGraph.js");
28
+ Object.defineProperty(exports, "buildGraph", { enumerable: true, get: function () { return buildGraph_js_1.buildGraph; } });
29
+ var detectCircularDeps_js_1 = require("./detectCircularDeps.js");
30
+ Object.defineProperty(exports, "detectCircularDeps", { enumerable: true, get: function () { return detectCircularDeps_js_1.detectCircularDeps; } });
31
+ var detectOrphanFiles_js_1 = require("./detectOrphanFiles.js");
32
+ Object.defineProperty(exports, "detectOrphanFiles", { enumerable: true, get: function () { return detectOrphanFiles_js_1.detectOrphanFiles; } });
33
+ Object.defineProperty(exports, "matchesAnyPattern", { enumerable: true, get: function () { return detectOrphanFiles_js_1.matchesAnyPattern; } });
34
+ var fileDiscovery_js_1 = require("./fileDiscovery.js");
35
+ Object.defineProperty(exports, "discoverFiles", { enumerable: true, get: function () { return fileDiscovery_js_1.discoverFiles; } });
36
+ var configLoader_js_1 = require("./configLoader.js");
37
+ Object.defineProperty(exports, "loadAliases", { enumerable: true, get: function () { return configLoader_js_1.loadAliases; } });
38
+ // ─── Constants ─────────────────────────────────────────────────────────────
39
+ var types_js_1 = require("./types.js");
40
+ Object.defineProperty(exports, "DEFAULT_EXTENSIONS", { enumerable: true, get: function () { return types_js_1.DEFAULT_EXTENSIONS; } });
41
+ Object.defineProperty(exports, "DEFAULT_ENTRY_POINT_PATTERNS", { enumerable: true, get: function () { return types_js_1.DEFAULT_ENTRY_POINT_PATTERNS; } });
42
+ Object.defineProperty(exports, "DEFAULT_IGNORE_PATTERNS", { enumerable: true, get: function () { return types_js_1.DEFAULT_IGNORE_PATTERNS; } });
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAC/E,wEAAwE;AACxE,2DAA2D;AAC3D,+EAA+E;;;AAE/E,8EAA8E;AAC9E,mDAA+C;AAAtC,6GAAA,WAAW,OAAA;AACpB,mDAAmD;AAA1C,iHAAA,eAAe,OAAA;AACxB,qDAAiD;AAAxC,+GAAA,YAAY,OAAA;AACrB,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,mEAA+D;AAAtD,6HAAA,mBAAmB,OAAA;AAE5B,6EAA6E;AAC7E,qDAAiD;AAAxC,+GAAA,YAAY,OAAA;AACrB,yDAAoE;AAA3D,kHAAA,aAAa,OAAA;AAAE,mHAAA,cAAc,OAAA;AACtC,iDAA6C;AAApC,2GAAA,UAAU,OAAA;AACnB,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAC3B,+DAA8E;AAArE,yHAAA,iBAAiB,OAAA;AAAE,yHAAA,iBAAiB,OAAA;AAC7C,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qDAAgD;AAAvC,8GAAA,WAAW,OAAA;AAuBpB,8EAA8E;AAC9E,uCAIoB;AAHlB,8GAAA,kBAAkB,OAAA;AAClB,wHAAA,4BAA4B,OAAA;AAC5B,mHAAA,uBAAuB,OAAA"}
@@ -0,0 +1,30 @@
1
+ import type { RawImportInfo } from './types.js';
2
+ /**
3
+ * Parse a source file and extract all import information.
4
+ *
5
+ * This function does NOT resolve paths — it only extracts the raw import
6
+ * specifiers as they appear in the source code. Path resolution is handled
7
+ * separately by `resolveImports.ts`.
8
+ *
9
+ * @param sourceCode - The full text content of the file
10
+ * @param filePath - Absolute path to the file (used to determine parser plugins)
11
+ * @returns Array of raw import information, one entry per import statement
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const code = `
16
+ * import React from 'react';
17
+ * import { Button } from './components/Button';
18
+ * import type { Props } from './types';
19
+ * `;
20
+ * const imports = parseImports(code, '/project/src/App.tsx');
21
+ * // Returns:
22
+ * // [
23
+ * // { source: 'react', specifiers: ['React'], isTypeOnly: false, isDynamic: false, line: 2 },
24
+ * // { source: './components/Button', specifiers: ['Button'], isTypeOnly: false, isDynamic: false, line: 3 },
25
+ * // { source: './types', specifiers: ['Props'], isTypeOnly: true, isDynamic: false, line: 4 },
26
+ * // ]
27
+ * ```
28
+ */
29
+ export declare function parseImports(sourceCode: string, filePath: string): RawImportInfo[];
30
+ //# sourceMappingURL=parseImports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseImports.d.ts","sourceRoot":"","sources":["../src/parseImports.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAoChD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,aAAa,EAAE,CA+HjB"}
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // parseImports — Extract import statements from a file's AST
4
+ // ============================================================================
5
+ // Uses @babel/parser to parse JavaScript/TypeScript files into an AST,
6
+ // then @babel/traverse to walk the tree and extract all import statements.
7
+ //
8
+ // Handles:
9
+ // - Static imports: import X from './Y'
10
+ // - Named imports: import { A, B } from './Y'
11
+ // - Namespace imports: import * as X from './Y'
12
+ // - Type-only imports: import type { X } from './Y'
13
+ // - Re-exports: export { X } from './Y'
14
+ // - Barrel re-exports: export * from './Y'
15
+ // - Dynamic imports: const X = await import('./Y')
16
+ // - CommonJS require: const X = require('./Y')
17
+ // ============================================================================
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.parseImports = parseImports;
23
+ const parser_1 = require("@babel/parser");
24
+ const traverse_1 = __importDefault(require("@babel/traverse"));
25
+ /**
26
+ * Determine which Babel parser plugins to enable based on file extension.
27
+ *
28
+ * - `.ts` / `.tsx` files get the `typescript` plugin
29
+ * - `.jsx` / `.tsx` files get the `jsx` plugin
30
+ * - TypeScript files cannot use both `typescript` and `flow` plugins
31
+ */
32
+ function getParserPlugins(filePath) {
33
+ const isTypeScript = filePath.endsWith('.ts') || filePath.endsWith('.tsx');
34
+ const isJSX = filePath.endsWith('.tsx') || filePath.endsWith('.jsx');
35
+ const plugins = [
36
+ 'decorators-legacy',
37
+ 'dynamicImport',
38
+ 'classProperties',
39
+ 'classPrivateProperties',
40
+ 'classPrivateMethods',
41
+ 'optionalChaining',
42
+ 'nullishCoalescingOperator',
43
+ 'exportDefaultFrom',
44
+ 'exportNamespaceFrom',
45
+ ];
46
+ if (isTypeScript) {
47
+ plugins.push('typescript');
48
+ }
49
+ if (isJSX) {
50
+ plugins.push('jsx');
51
+ }
52
+ return plugins;
53
+ }
54
+ /**
55
+ * Parse a source file and extract all import information.
56
+ *
57
+ * This function does NOT resolve paths — it only extracts the raw import
58
+ * specifiers as they appear in the source code. Path resolution is handled
59
+ * separately by `resolveImports.ts`.
60
+ *
61
+ * @param sourceCode - The full text content of the file
62
+ * @param filePath - Absolute path to the file (used to determine parser plugins)
63
+ * @returns Array of raw import information, one entry per import statement
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const code = `
68
+ * import React from 'react';
69
+ * import { Button } from './components/Button';
70
+ * import type { Props } from './types';
71
+ * `;
72
+ * const imports = parseImports(code, '/project/src/App.tsx');
73
+ * // Returns:
74
+ * // [
75
+ * // { source: 'react', specifiers: ['React'], isTypeOnly: false, isDynamic: false, line: 2 },
76
+ * // { source: './components/Button', specifiers: ['Button'], isTypeOnly: false, isDynamic: false, line: 3 },
77
+ * // { source: './types', specifiers: ['Props'], isTypeOnly: true, isDynamic: false, line: 4 },
78
+ * // ]
79
+ * ```
80
+ */
81
+ function parseImports(sourceCode, filePath) {
82
+ const plugins = getParserPlugins(filePath);
83
+ // Parse the source code into an AST.
84
+ // We wrap this in try/catch because some files may have syntax errors.
85
+ let ast;
86
+ try {
87
+ ast = (0, parser_1.parse)(sourceCode, {
88
+ sourceType: 'module',
89
+ // Allow both import/export and require() in the same file
90
+ allowImportExportEverywhere: true,
91
+ plugins,
92
+ });
93
+ }
94
+ catch {
95
+ // If parsing fails, return an empty array.
96
+ // The caller (scanProject) will record this as a ScanError.
97
+ throw new Error(`Failed to parse ${filePath}`);
98
+ }
99
+ const imports = [];
100
+ // Walk the AST and collect all import-like statements.
101
+ (0, traverse_1.default)(ast, {
102
+ // ─── Static imports ──────────────────────────────────────────────
103
+ // Matches: import X from './Y'
104
+ // import { A, B } from './Y'
105
+ // import * as X from './Y'
106
+ // import type { X } from './Y'
107
+ // import './side-effect'
108
+ ImportDeclaration(path) {
109
+ const specifiers = path.node.specifiers.map((s) => {
110
+ if (s.type === 'ImportDefaultSpecifier') {
111
+ return s.local.name;
112
+ }
113
+ if (s.type === 'ImportNamespaceSpecifier') {
114
+ return `* as ${s.local.name}`;
115
+ }
116
+ // ImportSpecifier
117
+ return s.local.name;
118
+ });
119
+ imports.push({
120
+ source: path.node.source.value,
121
+ specifiers,
122
+ isTypeOnly: path.node.importKind === 'type',
123
+ isDynamic: false,
124
+ line: path.node.loc?.start.line ?? 0,
125
+ });
126
+ },
127
+ // ─── Re-exports ──────────────────────────────────────────────────
128
+ // Matches: export { X } from './Y'
129
+ // export { default as X } from './Y'
130
+ // export type { X } from './Y'
131
+ ExportNamedDeclaration(path) {
132
+ if (path.node.source) {
133
+ const specifiers = path.node.specifiers.map((s) => {
134
+ if (s.type === 'ExportSpecifier') {
135
+ const exported = s.exported;
136
+ return exported.type === 'Identifier'
137
+ ? exported.name
138
+ : exported.value;
139
+ }
140
+ return '';
141
+ });
142
+ imports.push({
143
+ source: path.node.source.value,
144
+ specifiers: specifiers.filter(Boolean),
145
+ isTypeOnly: path.node.exportKind === 'type',
146
+ isDynamic: false,
147
+ line: path.node.loc?.start.line ?? 0,
148
+ });
149
+ }
150
+ },
151
+ // ─── Barrel re-exports ───────────────────────────────────────────
152
+ // Matches: export * from './Y'
153
+ ExportAllDeclaration(path) {
154
+ imports.push({
155
+ source: path.node.source.value,
156
+ specifiers: ['*'],
157
+ isTypeOnly: false,
158
+ isDynamic: false,
159
+ line: path.node.loc?.start.line ?? 0,
160
+ });
161
+ },
162
+ // ─── Dynamic imports and require() ───────────────────────────────
163
+ // Matches: import('./Y') — dynamic import
164
+ // const X = require('./Y') — CommonJS require
165
+ CallExpression(path) {
166
+ // Dynamic import: import('./Y')
167
+ if (path.node.callee.type === 'Import' &&
168
+ path.node.arguments.length > 0 &&
169
+ path.node.arguments[0].type === 'StringLiteral') {
170
+ imports.push({
171
+ source: path.node.arguments[0].value,
172
+ specifiers: [],
173
+ isTypeOnly: false,
174
+ isDynamic: true,
175
+ line: path.node.loc?.start.line ?? 0,
176
+ });
177
+ return;
178
+ }
179
+ // CommonJS require: require('./Y')
180
+ if (path.node.callee.type === 'Identifier' &&
181
+ path.node.callee.name === 'require' &&
182
+ path.node.arguments.length > 0 &&
183
+ path.node.arguments[0].type === 'StringLiteral') {
184
+ imports.push({
185
+ source: path.node.arguments[0].value,
186
+ specifiers: [],
187
+ isTypeOnly: false,
188
+ isDynamic: false,
189
+ line: path.node.loc?.start.line ?? 0,
190
+ });
191
+ }
192
+ },
193
+ });
194
+ return imports;
195
+ }
196
+ //# sourceMappingURL=parseImports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseImports.js","sourceRoot":"","sources":["../src/parseImports.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,6DAA6D;AAC7D,+EAA+E;AAC/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