@ophan/core 0.0.2 → 0.0.3

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 (76) hide show
  1. package/dist/community-detectors/index.d.ts +20 -0
  2. package/dist/community-detectors/index.d.ts.map +1 -0
  3. package/dist/community-detectors/index.js +45 -0
  4. package/dist/community-detectors/label-prop.d.ts +20 -0
  5. package/dist/community-detectors/label-prop.d.ts.map +1 -0
  6. package/dist/community-detectors/label-prop.js +77 -0
  7. package/dist/community-detectors/leiden.d.ts +22 -0
  8. package/dist/community-detectors/leiden.d.ts.map +1 -0
  9. package/dist/community-detectors/leiden.js +312 -0
  10. package/dist/community-detectors/louvain.d.ts +13 -0
  11. package/dist/community-detectors/louvain.d.ts.map +1 -0
  12. package/dist/community-detectors/louvain.js +29 -0
  13. package/dist/community-detectors/types.d.ts +36 -0
  14. package/dist/community-detectors/types.d.ts.map +1 -0
  15. package/dist/{parsers/__fixtures__/no-functions.js → community-detectors/types.js} +0 -2
  16. package/dist/edge-resolvers/call.d.ts +13 -0
  17. package/dist/edge-resolvers/call.d.ts.map +1 -0
  18. package/dist/edge-resolvers/call.js +40 -0
  19. package/dist/edge-resolvers/co-location.d.ts +16 -0
  20. package/dist/edge-resolvers/co-location.d.ts.map +1 -0
  21. package/dist/edge-resolvers/co-location.js +129 -0
  22. package/dist/edge-resolvers/import.d.ts +16 -0
  23. package/dist/edge-resolvers/import.d.ts.map +1 -0
  24. package/dist/edge-resolvers/import.js +118 -0
  25. package/dist/edge-resolvers/index.d.ts +9 -0
  26. package/dist/edge-resolvers/index.d.ts.map +1 -0
  27. package/dist/edge-resolvers/index.js +29 -0
  28. package/dist/edge-resolvers/jsx-ref.d.ts +13 -0
  29. package/dist/edge-resolvers/jsx-ref.d.ts.map +1 -0
  30. package/dist/edge-resolvers/jsx-ref.js +40 -0
  31. package/dist/edge-resolvers/types.d.ts +40 -0
  32. package/dist/edge-resolvers/types.d.ts.map +1 -0
  33. package/dist/edge-resolvers/types.js +2 -0
  34. package/dist/graph.d.ts +293 -0
  35. package/dist/graph.d.ts.map +1 -0
  36. package/dist/graph.js +1295 -0
  37. package/dist/index.d.ts +37 -8
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +385 -183
  40. package/dist/migrations.d.ts +25 -0
  41. package/dist/migrations.d.ts.map +1 -0
  42. package/dist/migrations.js +323 -0
  43. package/dist/module-resolvers/index.d.ts +11 -0
  44. package/dist/module-resolvers/index.d.ts.map +1 -0
  45. package/dist/module-resolvers/index.js +67 -0
  46. package/dist/module-resolvers/javascript.d.ts +18 -0
  47. package/dist/module-resolvers/javascript.d.ts.map +1 -0
  48. package/dist/module-resolvers/javascript.js +130 -0
  49. package/dist/module-resolvers/types.d.ts +18 -0
  50. package/dist/module-resolvers/types.d.ts.map +1 -0
  51. package/dist/module-resolvers/types.js +2 -0
  52. package/dist/parsers/python.d.ts.map +1 -1
  53. package/dist/parsers/python.js +38 -4
  54. package/dist/parsers/typescript.d.ts.map +1 -1
  55. package/dist/parsers/typescript.js +133 -0
  56. package/dist/practices.d.ts +28 -0
  57. package/dist/practices.d.ts.map +1 -0
  58. package/dist/practices.js +95 -0
  59. package/dist/schemas.d.ts +251 -3
  60. package/dist/schemas.d.ts.map +1 -1
  61. package/dist/schemas.js +121 -6
  62. package/dist/shared.d.ts +8 -0
  63. package/dist/shared.d.ts.map +1 -1
  64. package/dist/summarize.d.ts +165 -0
  65. package/dist/summarize.d.ts.map +1 -0
  66. package/dist/summarize.js +1067 -0
  67. package/ophan_logo.png +0 -0
  68. package/package.json +9 -2
  69. package/dist/parsers/__fixtures__/arrow-functions.d.ts +0 -5
  70. package/dist/parsers/__fixtures__/arrow-functions.d.ts.map +0 -1
  71. package/dist/parsers/__fixtures__/arrow-functions.js +0 -16
  72. package/dist/parsers/__fixtures__/class-methods.d.ts +0 -6
  73. package/dist/parsers/__fixtures__/class-methods.d.ts.map +0 -1
  74. package/dist/parsers/__fixtures__/class-methods.js +0 -12
  75. package/dist/parsers/__fixtures__/no-functions.d.ts +0 -9
  76. package/dist/parsers/__fixtures__/no-functions.d.ts.map +0 -1
@@ -0,0 +1,16 @@
1
+ import type { EdgeResolver, EdgeResolverContext } from "./types";
2
+ import type { FunctionEdge } from "../graph";
3
+ /**
4
+ * Resolves co-location edges — proximity-based connections between functions
5
+ * in the same file or same directory.
6
+ *
7
+ * Same-file: all-pairs with weight decaying by positional distance (1/offset).
8
+ * Directory (cross-file): half the same-file weight, also decaying by offset.
9
+ *
10
+ * Owns a shared dedup Set to prevent duplicate edges across both phases.
11
+ */
12
+ export declare class CoLocationEdgeResolver implements EdgeResolver {
13
+ readonly edgeTypes: readonly ["co_location"];
14
+ resolve(ctx: EdgeResolverContext): FunctionEdge[];
15
+ }
16
+ //# sourceMappingURL=co-location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"co-location.d.ts","sourceRoot":"","sources":["../../src/edge-resolvers/co-location.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;;GAQG;AACH,qBAAa,sBAAuB,YAAW,YAAY;IACzD,QAAQ,CAAC,SAAS,2BAA4B;IAE9C,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,YAAY,EAAE;CAsFlD"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CoLocationEdgeResolver = void 0;
37
+ const path = __importStar(require("path"));
38
+ /**
39
+ * Resolves co-location edges — proximity-based connections between functions
40
+ * in the same file or same directory.
41
+ *
42
+ * Same-file: all-pairs with weight decaying by positional distance (1/offset).
43
+ * Directory (cross-file): half the same-file weight, also decaying by offset.
44
+ *
45
+ * Owns a shared dedup Set to prevent duplicate edges across both phases.
46
+ */
47
+ class CoLocationEdgeResolver {
48
+ constructor() {
49
+ this.edgeTypes = ["co_location"];
50
+ }
51
+ resolve(ctx) {
52
+ const edges = [];
53
+ const colocAdded = new Set();
54
+ // Phase 1: Same-file co-location
55
+ for (const fn of ctx.functions) {
56
+ if (ctx.affectedHashes && !ctx.affectedHashes.has(fn.contentHash))
57
+ continue;
58
+ const sortedSiblings = ctx.fileToSortedFns.get(fn.filePath);
59
+ if (!sortedSiblings || sortedSiblings.length <= 1)
60
+ continue;
61
+ const idx = sortedSiblings.indexOf(fn);
62
+ if (idx < 0)
63
+ continue;
64
+ for (let offset = 1; offset < sortedSiblings.length - idx; offset++) {
65
+ const neighbor = sortedSiblings[idx + offset];
66
+ if (!neighbor)
67
+ break;
68
+ const a = fn.contentHash < neighbor.contentHash
69
+ ? fn.contentHash
70
+ : neighbor.contentHash;
71
+ const b = fn.contentHash < neighbor.contentHash
72
+ ? neighbor.contentHash
73
+ : fn.contentHash;
74
+ const key = `${a}|${b}`;
75
+ if (!colocAdded.has(key)) {
76
+ colocAdded.add(key);
77
+ edges.push({
78
+ sourceHash: a,
79
+ targetHash: b,
80
+ edgeType: "co_location",
81
+ weight: ctx.config.edgeWeights.co_location / offset,
82
+ });
83
+ }
84
+ }
85
+ }
86
+ // Phase 2: Directory co-location (cross-file, same directory)
87
+ const dirToFns = new Map();
88
+ for (const fn of ctx.functions) {
89
+ const dir = path.dirname(fn.filePath);
90
+ const list = dirToFns.get(dir) || [];
91
+ list.push(fn);
92
+ dirToFns.set(dir, list);
93
+ }
94
+ const dirWeight = ctx.config.edgeWeights.co_location * 0.5;
95
+ for (const fns of dirToFns.values()) {
96
+ const files = new Set(fns.map((f) => f.filePath));
97
+ if (files.size < 2)
98
+ continue;
99
+ fns.sort((a, b) => a.filePath.localeCompare(b.filePath) || a.startLine - b.startLine);
100
+ for (let i = 0; i < fns.length; i++) {
101
+ if (ctx.affectedHashes && !ctx.affectedHashes.has(fns[i].contentHash))
102
+ continue;
103
+ for (let j = i + 1; j < fns.length; j++) {
104
+ if (fns[i].filePath === fns[j].filePath)
105
+ continue;
106
+ const a = fns[i].contentHash < fns[j].contentHash
107
+ ? fns[i].contentHash
108
+ : fns[j].contentHash;
109
+ const b = fns[i].contentHash < fns[j].contentHash
110
+ ? fns[j].contentHash
111
+ : fns[i].contentHash;
112
+ const key = `${a}|${b}`;
113
+ if (!colocAdded.has(key)) {
114
+ colocAdded.add(key);
115
+ const offset = j - i;
116
+ edges.push({
117
+ sourceHash: a,
118
+ targetHash: b,
119
+ edgeType: "co_location",
120
+ weight: dirWeight / offset,
121
+ });
122
+ }
123
+ }
124
+ }
125
+ }
126
+ return edges;
127
+ }
128
+ }
129
+ exports.CoLocationEdgeResolver = CoLocationEdgeResolver;
@@ -0,0 +1,16 @@
1
+ import type { EdgeResolver, EdgeResolverContext } from "./types";
2
+ import type { FunctionEdge } from "../graph";
3
+ /**
4
+ * Resolves import edges from import statements.
5
+ * Three resolution paths:
6
+ * 1. Direct: imported name found in the resolved target file
7
+ * 2. Barrel fallback: imported name found via package-scoped search (re-exports)
8
+ * 3. Namespace fallback: intersect fn.calls with target file's functions
9
+ *
10
+ * Owns importAdded Set for deduplication (import edges are undirected).
11
+ */
12
+ export declare class ImportEdgeResolver implements EdgeResolver {
13
+ readonly edgeTypes: readonly ["import"];
14
+ resolve(ctx: EdgeResolverContext): FunctionEdge[];
15
+ }
16
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/edge-resolvers/import.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,QAAQ,CAAC,SAAS,sBAAuB;IAEzC,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,YAAY,EAAE;CAqHlD"}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportEdgeResolver = void 0;
4
+ const module_resolvers_1 = require("../module-resolvers");
5
+ /**
6
+ * Resolves import edges from import statements.
7
+ * Three resolution paths:
8
+ * 1. Direct: imported name found in the resolved target file
9
+ * 2. Barrel fallback: imported name found via package-scoped search (re-exports)
10
+ * 3. Namespace fallback: intersect fn.calls with target file's functions
11
+ *
12
+ * Owns importAdded Set for deduplication (import edges are undirected).
13
+ */
14
+ class ImportEdgeResolver {
15
+ constructor() {
16
+ this.edgeTypes = ["import"];
17
+ }
18
+ resolve(ctx) {
19
+ const edges = [];
20
+ const importAdded = new Set();
21
+ for (const fn of ctx.functions) {
22
+ if (ctx.affectedHashes && !ctx.affectedHashes.has(fn.contentHash))
23
+ continue;
24
+ if (!fn.imports)
25
+ continue;
26
+ for (const imp of fn.imports) {
27
+ const langResolver = (0, module_resolvers_1.getModuleResolverForFile)(fn.filePath);
28
+ const targetFile = langResolver?.resolveModuleToFile(imp.module, fn.filePath, ctx.fileToHashes, ctx.resolver);
29
+ // Determine package scope for fallback through barrel file re-exports
30
+ let pkgScope;
31
+ if (ctx.resolver) {
32
+ for (const [pkgName] of ctx.resolver.workspacePackages) {
33
+ if (imp.module === pkgName ||
34
+ imp.module.startsWith(pkgName + "/")) {
35
+ pkgScope = ctx.pkgNameToHashes.get(pkgName);
36
+ break;
37
+ }
38
+ }
39
+ }
40
+ if (!targetFile && !pkgScope)
41
+ continue;
42
+ // Create edges to the specific functions named in the import
43
+ let matched = false;
44
+ for (const importedName of imp.names) {
45
+ // Direct lookup: function defined in the resolved target file
46
+ const directHash = targetFile
47
+ ? ctx.fileNameToHash.get(`${targetFile}::${importedName}`)
48
+ : undefined;
49
+ if (directHash && directHash !== fn.contentHash) {
50
+ matched = true;
51
+ const a = fn.contentHash < directHash ? fn.contentHash : directHash;
52
+ const b = fn.contentHash < directHash ? directHash : fn.contentHash;
53
+ const importKey = `${a}|${b}`;
54
+ if (!importAdded.has(importKey)) {
55
+ importAdded.add(importKey);
56
+ edges.push({
57
+ sourceHash: a,
58
+ targetHash: b,
59
+ edgeType: "import",
60
+ weight: ctx.config.edgeWeights.import,
61
+ });
62
+ }
63
+ }
64
+ else if (pkgScope) {
65
+ // Fallback: imported name is a re-export through a barrel file
66
+ const targetHashes = pkgScope.get(importedName);
67
+ if (targetHashes) {
68
+ for (const targetHash of targetHashes) {
69
+ if (targetHash === fn.contentHash)
70
+ continue;
71
+ matched = true;
72
+ const a = fn.contentHash < targetHash ? fn.contentHash : targetHash;
73
+ const b = fn.contentHash < targetHash ? targetHash : fn.contentHash;
74
+ const importKey = `${a}|${b}`;
75
+ if (!importAdded.has(importKey)) {
76
+ importAdded.add(importKey);
77
+ edges.push({
78
+ sourceHash: a,
79
+ targetHash: b,
80
+ edgeType: "import",
81
+ weight: ctx.config.edgeWeights.import,
82
+ });
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ // Fallback for namespace imports: intersect fn.calls with target file's functions
89
+ if (!matched && fn.calls && targetFile) {
90
+ const targetFnsInFile = ctx.fileToHashes.get(targetFile);
91
+ if (targetFnsInFile) {
92
+ for (const calledName of fn.calls) {
93
+ const targetHash = ctx.fileNameToHash.get(`${targetFile}::${calledName}`);
94
+ if (targetHash &&
95
+ targetHash !== fn.contentHash &&
96
+ targetFnsInFile.has(targetHash)) {
97
+ const a = fn.contentHash < targetHash ? fn.contentHash : targetHash;
98
+ const b = fn.contentHash < targetHash ? targetHash : fn.contentHash;
99
+ const importKey = `${a}|${b}`;
100
+ if (!importAdded.has(importKey)) {
101
+ importAdded.add(importKey);
102
+ edges.push({
103
+ sourceHash: a,
104
+ targetHash: b,
105
+ edgeType: "import",
106
+ weight: ctx.config.edgeWeights.import,
107
+ });
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ return edges;
116
+ }
117
+ }
118
+ exports.ImportEdgeResolver = ImportEdgeResolver;
@@ -0,0 +1,9 @@
1
+ export type { EdgeResolver, EdgeResolverContext } from "./types";
2
+ export { CallEdgeResolver } from "./call";
3
+ export { JsxRefEdgeResolver } from "./jsx-ref";
4
+ export { CoLocationEdgeResolver } from "./co-location";
5
+ export { ImportEdgeResolver } from "./import";
6
+ import type { EdgeResolver } from "./types";
7
+ export declare function registerEdgeResolver(resolver: EdgeResolver): void;
8
+ export declare function getEdgeResolvers(): readonly EdgeResolver[];
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/edge-resolvers/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQ5C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAEjE;AAED,wBAAgB,gBAAgB,IAAI,SAAS,YAAY,EAAE,CAE1D"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImportEdgeResolver = exports.CoLocationEdgeResolver = exports.JsxRefEdgeResolver = exports.CallEdgeResolver = void 0;
4
+ exports.registerEdgeResolver = registerEdgeResolver;
5
+ exports.getEdgeResolvers = getEdgeResolvers;
6
+ var call_1 = require("./call");
7
+ Object.defineProperty(exports, "CallEdgeResolver", { enumerable: true, get: function () { return call_1.CallEdgeResolver; } });
8
+ var jsx_ref_1 = require("./jsx-ref");
9
+ Object.defineProperty(exports, "JsxRefEdgeResolver", { enumerable: true, get: function () { return jsx_ref_1.JsxRefEdgeResolver; } });
10
+ var co_location_1 = require("./co-location");
11
+ Object.defineProperty(exports, "CoLocationEdgeResolver", { enumerable: true, get: function () { return co_location_1.CoLocationEdgeResolver; } });
12
+ var import_1 = require("./import");
13
+ Object.defineProperty(exports, "ImportEdgeResolver", { enumerable: true, get: function () { return import_1.ImportEdgeResolver; } });
14
+ const call_2 = require("./call");
15
+ const jsx_ref_2 = require("./jsx-ref");
16
+ const co_location_2 = require("./co-location");
17
+ const import_2 = require("./import");
18
+ const registry = [];
19
+ function registerEdgeResolver(resolver) {
20
+ registry.push(resolver);
21
+ }
22
+ function getEdgeResolvers() {
23
+ return registry;
24
+ }
25
+ // Register built-in resolvers
26
+ registerEdgeResolver(new call_2.CallEdgeResolver());
27
+ registerEdgeResolver(new jsx_ref_2.JsxRefEdgeResolver());
28
+ registerEdgeResolver(new co_location_2.CoLocationEdgeResolver());
29
+ registerEdgeResolver(new import_2.ImportEdgeResolver());
@@ -0,0 +1,13 @@
1
+ import type { EdgeResolver, EdgeResolverContext } from "./types";
2
+ import type { FunctionEdge } from "../graph";
3
+ /**
4
+ * Resolves JSX component reference edges.
5
+ * When a function renders <Component />, creates a weak edge to that component.
6
+ * Separated from call edges because UI composition is a weaker domain signal
7
+ * than direct function calls.
8
+ */
9
+ export declare class JsxRefEdgeResolver implements EdgeResolver {
10
+ readonly edgeTypes: readonly ["jsx_ref"];
11
+ resolve(ctx: EdgeResolverContext): FunctionEdge[];
12
+ }
13
+ //# sourceMappingURL=jsx-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-ref.d.ts","sourceRoot":"","sources":["../../src/edge-resolvers/jsx-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACrD,QAAQ,CAAC,SAAS,uBAAwB;IAE1C,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,YAAY,EAAE;CAqBlD"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JsxRefEdgeResolver = void 0;
4
+ /**
5
+ * Resolves JSX component reference edges.
6
+ * When a function renders <Component />, creates a weak edge to that component.
7
+ * Separated from call edges because UI composition is a weaker domain signal
8
+ * than direct function calls.
9
+ */
10
+ class JsxRefEdgeResolver {
11
+ constructor() {
12
+ this.edgeTypes = ["jsx_ref"];
13
+ }
14
+ resolve(ctx) {
15
+ const edges = [];
16
+ for (const fn of ctx.functions) {
17
+ if (ctx.affectedHashes && !ctx.affectedHashes.has(fn.contentHash))
18
+ continue;
19
+ if (!fn.jsxRefs)
20
+ continue;
21
+ for (const refName of fn.jsxRefs) {
22
+ const targetHashes = ctx.nameToHashes.get(refName);
23
+ if (!targetHashes)
24
+ continue;
25
+ for (const targetHash of targetHashes) {
26
+ if (targetHash === fn.contentHash)
27
+ continue;
28
+ edges.push({
29
+ sourceHash: fn.contentHash,
30
+ targetHash,
31
+ edgeType: "jsx_ref",
32
+ weight: ctx.config.edgeWeights.jsx_ref,
33
+ });
34
+ }
35
+ }
36
+ }
37
+ return edges;
38
+ }
39
+ }
40
+ exports.JsxRefEdgeResolver = JsxRefEdgeResolver;
@@ -0,0 +1,40 @@
1
+ import type { FunctionInfo } from "../shared";
2
+ import type { GraphConfig, FunctionEdge, ModuleResolver } from "../graph";
3
+ /**
4
+ * Shared context built once per resolveEdges() invocation.
5
+ * Contains pre-built lookup maps that edge resolvers need.
6
+ * The orchestrator builds this — resolvers consume it.
7
+ */
8
+ export interface EdgeResolverContext {
9
+ /** function_name → Set<content_hash> (handles name collisions across files) */
10
+ nameToHashes: Map<string, Set<string>>;
11
+ /** file_path → Set<content_hash> */
12
+ fileToHashes: Map<string, Set<string>>;
13
+ /** "file_path::function_name" → content_hash (targeted import lookup) */
14
+ fileNameToHash: Map<string, string>;
15
+ /** package_name → Map<function_name, Set<content_hash>> (barrel file fallback) */
16
+ pkgNameToHashes: Map<string, Map<string, Set<string>>>;
17
+ /** file_path → FunctionInfo[] sorted by startLine */
18
+ fileToSortedFns: Map<string, FunctionInfo[]>;
19
+ /** All extracted functions for this scan */
20
+ functions: FunctionInfo[];
21
+ /** Graph configuration (edge weights, etc.) */
22
+ config: GraphConfig;
23
+ /** Optional: limit resolution to these hashes (incremental mode) */
24
+ affectedHashes?: Set<string>;
25
+ /** Optional: workspace module resolver for import resolution */
26
+ resolver?: ModuleResolver;
27
+ }
28
+ /**
29
+ * Strategy interface for edge resolution.
30
+ * Each implementation handles one category of edges (calls, imports, co-location, etc.).
31
+ *
32
+ * Resolvers own their own deduplication — the orchestrator concatenates results.
33
+ */
34
+ export interface EdgeResolver {
35
+ /** Edge type identifier(s) this resolver produces */
36
+ readonly edgeTypes: readonly string[];
37
+ /** Resolve edges from the shared context */
38
+ resolve(ctx: EdgeResolverContext): FunctionEdge[];
39
+ }
40
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/edge-resolvers/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,oCAAoC;IACpC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,yEAAyE;IACzE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,kFAAkF;IAClF,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvD,qDAAqD;IACrD,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAC7C,4CAA4C;IAC5C,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,+CAA+C;IAC/C,MAAM,EAAE,WAAW,CAAC;IACpB,oEAAoE;IACpE,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,4CAA4C;IAC5C,OAAO,CAAC,GAAG,EAAE,mBAAmB,GAAG,YAAY,EAAE,CAAC;CACnD"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });