@colbymchenry/codegraph-darwin-arm64 1.1.5 → 1.2.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 (48) hide show
  1. package/lib/dist/bin/codegraph.js +11 -10
  2. package/lib/dist/bin/codegraph.js.map +1 -1
  3. package/lib/dist/bin/command-supervision.d.ts.map +1 -1
  4. package/lib/dist/bin/command-supervision.js +10 -0
  5. package/lib/dist/bin/command-supervision.js.map +1 -1
  6. package/lib/dist/db/index.d.ts +20 -0
  7. package/lib/dist/db/index.d.ts.map +1 -1
  8. package/lib/dist/db/index.js +39 -0
  9. package/lib/dist/db/index.js.map +1 -1
  10. package/lib/dist/extraction/languages/c-cpp.d.ts +17 -0
  11. package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  12. package/lib/dist/extraction/languages/c-cpp.js +134 -3
  13. package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
  14. package/lib/dist/extraction/tree-sitter-types.d.ts +17 -0
  15. package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  16. package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
  17. package/lib/dist/extraction/tree-sitter.js +92 -6
  18. package/lib/dist/extraction/tree-sitter.js.map +1 -1
  19. package/lib/dist/graph/traversal.d.ts.map +1 -1
  20. package/lib/dist/graph/traversal.js +76 -17
  21. package/lib/dist/graph/traversal.js.map +1 -1
  22. package/lib/dist/index.d.ts +17 -0
  23. package/lib/dist/index.d.ts.map +1 -1
  24. package/lib/dist/index.js +46 -4
  25. package/lib/dist/index.js.map +1 -1
  26. package/lib/dist/reasoning/login.js +1 -1
  27. package/lib/dist/reasoning/login.js.map +1 -1
  28. package/lib/dist/resolution/callback-synthesizer.d.ts +1 -1
  29. package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  30. package/lib/dist/resolution/callback-synthesizer.js +71 -11
  31. package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
  32. package/lib/dist/resolution/cooperative-yield.d.ts +32 -0
  33. package/lib/dist/resolution/cooperative-yield.d.ts.map +1 -0
  34. package/lib/dist/resolution/cooperative-yield.js +42 -0
  35. package/lib/dist/resolution/cooperative-yield.js.map +1 -0
  36. package/lib/dist/resolution/index.d.ts +11 -2
  37. package/lib/dist/resolution/index.d.ts.map +1 -1
  38. package/lib/dist/resolution/index.js +72 -4
  39. package/lib/dist/resolution/index.js.map +1 -1
  40. package/lib/dist/resolution/name-matcher.d.ts +22 -0
  41. package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
  42. package/lib/dist/resolution/name-matcher.js +273 -20
  43. package/lib/dist/resolution/name-matcher.js.map +1 -1
  44. package/lib/dist/upgrade/index.js +1 -1
  45. package/lib/dist/upgrade/index.js.map +1 -1
  46. package/lib/node_modules/.package-lock.json +1 -1
  47. package/lib/package.json +1 -1
  48. package/package.json +1 -1
@@ -5,6 +5,7 @@ const generated_detection_1 = require("../extraction/generated-detection");
5
5
  const strip_comments_1 = require("./strip-comments");
6
6
  const c_fnptr_synthesizer_1 = require("./c-fnptr-synthesizer");
7
7
  const goframe_synthesizer_1 = require("./goframe-synthesizer");
8
+ const cooperative_yield_1 = require("./cooperative-yield");
8
9
  const REGISTRAR_NAME = /^(on[A-Z]\w*|subscribe|addListener|addEventListener|register|watch|listen|addCallback)$/;
9
10
  const DISPATCHER_NAME = /(emit|trigger|notify|dispatch|fire|publish|flush)/i;
10
11
  const MAX_CALLBACKS_PER_CHANNEL = 40;
@@ -113,10 +114,13 @@ function* methodAndFunctionNodes(queries) {
113
114
  yield* queries.iterateNodesByKind('function');
114
115
  }
115
116
  /** Phase 1: field-backed observer channels (registrar/dispatcher share a store). */
116
- function fieldChannelEdges(queries, ctx) {
117
+ async function fieldChannelEdges(queries, ctx, onYield) {
117
118
  const registrars = [];
118
119
  const dispatchers = [];
120
+ let scanned = 0;
119
121
  for (const m of methodAndFunctionNodes(queries)) {
122
+ if ((++scanned & 255) === 0)
123
+ await onYield(); // #1091: yield mid-scan on huge graphs
120
124
  const isReg = REGISTRAR_NAME.test(m.name);
121
125
  const isDisp = DISPATCHER_NAME.test(m.name);
122
126
  if (!isReg && !isDisp)
@@ -197,7 +201,7 @@ function fieldChannelEdges(queries, ctx) {
197
201
  * subclass `DataRequest.validate`), bounded by a fan-out cap so a generic field
198
202
  * name shared across unrelated classes can't fan out into noise.
199
203
  */
200
- function closureCollectionEdges(queries, ctx) {
204
+ async function closureCollectionEdges(queries, ctx, onYield) {
201
205
  const dispatchers = new Map(); // field → dispatcher methods + forEach line
202
206
  const registrars = new Map(); // field → registrar methods + append line
203
207
  const addReg = (field, node, absLine) => {
@@ -208,7 +212,13 @@ function closureCollectionEdges(queries, ctx) {
208
212
  arr.push({ node, line: absLine });
209
213
  registrars.set(field, arr);
210
214
  };
215
+ // Slices EVERY method/function's source (no cheap name-gate), so on a repo
216
+ // with a huge file this is the heaviest synthesis pass — yield mid-scan so it
217
+ // can't wedge the #850 watchdog on its own (#1091).
218
+ let scanned = 0;
211
219
  for (const m of methodAndFunctionNodes(queries)) {
220
+ if ((++scanned & 127) === 0)
221
+ await onYield();
212
222
  const content = ctx.readFile(m.filePath);
213
223
  const src = content && sliceLines(content, m.startLine, m.endLine);
214
224
  if (!src)
@@ -265,10 +275,13 @@ function closureCollectionEdges(queries, ctx) {
265
275
  return edges;
266
276
  }
267
277
  /** Phase 2: string-keyed EventEmitter channels (on('e', fn) ↔ emit('e')). */
268
- function eventEmitterEdges(ctx) {
278
+ async function eventEmitterEdges(ctx, onYield) {
269
279
  const emitsByEvent = new Map(); // event → dispatcher node ids
270
280
  const handlersByEvent = new Map(); // event → handler id → registration site (file:line)
281
+ let scanned = 0;
271
282
  for (const file of ctx.getAllFiles()) {
283
+ if ((++scanned & 255) === 0)
284
+ await onYield(); // #1091: yield mid-scan on huge graphs
272
285
  const content = ctx.readFile(file);
273
286
  if (!content)
274
287
  continue;
@@ -872,11 +885,14 @@ function goGrpcStubImplEdges(queries) {
872
885
  * component/function/class node — TS generics like `Array<Foo>` resolve to a type
873
886
  * (or nothing) and are dropped.
874
887
  */
875
- function reactJsxChildEdges(ctx) {
888
+ async function reactJsxChildEdges(ctx, onYield) {
876
889
  const edges = [];
877
890
  const seen = new Set();
878
891
  const PARENT_KINDS = new Set(['method', 'function', 'component']);
892
+ let scanned = 0;
879
893
  for (const file of ctx.getAllFiles()) {
894
+ if ((++scanned & 255) === 0)
895
+ await onYield(); // #1091: yield mid-scan on huge graphs
880
896
  const content = ctx.readFile(file);
881
897
  if (!content || (!content.includes('</') && !content.includes('/>')))
882
898
  continue; // JSX-file gate
@@ -1893,10 +1909,13 @@ function resolveRegistryHandler(ctx, name, chained) {
1893
1909
  // entry resolving to the global URL constant).
1894
1910
  return cands.find((n) => n.kind === 'method') ?? null;
1895
1911
  }
1896
- function objectRegistryEdges(ctx) {
1912
+ async function objectRegistryEdges(ctx, onYield) {
1897
1913
  const edges = [];
1898
1914
  const seen = new Set();
1915
+ let scanned = 0;
1899
1916
  for (const file of ctx.getAllFiles()) {
1917
+ if ((++scanned & 255) === 0)
1918
+ await onYield(); // #1091: yield mid-scan on huge graphs
1900
1919
  if (!REGISTRY_JS_EXT.test(file))
1901
1920
  continue;
1902
1921
  const content = ctx.readFile(file);
@@ -2831,7 +2850,15 @@ function laravelEventEdges(ctx) {
2831
2850
  * Sidekiq Worker.perform_async → #perform + Laravel event(new X) → listener handle).
2832
2851
  * Returns the count added. Never throws into indexing — callers wrap in try/catch.
2833
2852
  */
2834
- function synthesizeCallbackEdges(queries, ctx) {
2853
+ async function synthesizeCallbackEdges(queries, ctx) {
2854
+ // Each sub-pass below is a whole-graph scan, and there are ~30 of them, all
2855
+ // running synchronously on the indexer's main thread. Their AGGREGATE can run
2856
+ // for well over a minute on a large repo — long enough for the #850 liveness
2857
+ // watchdog to SIGKILL the process mid-index (#1091), since its heartbeat lives
2858
+ // on this same thread. Yield between passes so the heartbeat can fire; a pass
2859
+ // that itself hangs (a real wedge) never reaches the next yield, so the
2860
+ // watchdog still catches that. See ./cooperative-yield.
2861
+ const yieldToLoop = (0, cooperative_yield_1.createYielder)();
2835
2862
  // Cross-file Go method→type `contains` edges must be synthesized AND persisted
2836
2863
  // FIRST: a method declared in a different file from its receiver type is
2837
2864
  // otherwise orphaned from the struct, and goImplementsEdges (next) derives a
@@ -2840,6 +2867,7 @@ function synthesizeCallbackEdges(queries, ctx) {
2840
2867
  const goMethodContains = goCrossFileMethodContainsEdges(queries);
2841
2868
  if (goMethodContains.length > 0)
2842
2869
  queries.insertEdges(goMethodContains);
2870
+ await yieldToLoop();
2843
2871
  // Go implicit `implements` edges must be synthesized AND persisted next: the
2844
2872
  // interface-dispatch bridge below reads `implements` edges from the DB, and
2845
2873
  // Go has none statically. (Other languages already have static implements
@@ -2847,37 +2875,69 @@ function synthesizeCallbackEdges(queries, ctx) {
2847
2875
  const goImpl = goImplementsEdges(queries);
2848
2876
  if (goImpl.length > 0)
2849
2877
  queries.insertEdges(goImpl);
2850
- const fieldEdges = fieldChannelEdges(queries, ctx);
2851
- const closureCollEdges = closureCollectionEdges(queries, ctx);
2852
- const emitterEdges = eventEmitterEdges(ctx);
2878
+ await yieldToLoop();
2879
+ const fieldEdges = await fieldChannelEdges(queries, ctx, yieldToLoop);
2880
+ await yieldToLoop();
2881
+ const closureCollEdges = await closureCollectionEdges(queries, ctx, yieldToLoop);
2882
+ await yieldToLoop();
2883
+ const emitterEdges = await eventEmitterEdges(ctx, yieldToLoop);
2884
+ await yieldToLoop();
2853
2885
  const renderEdges = reactRenderEdges(queries, ctx);
2854
- const jsxEdges = reactJsxChildEdges(ctx);
2886
+ await yieldToLoop();
2887
+ const jsxEdges = await reactJsxChildEdges(ctx, yieldToLoop);
2888
+ await yieldToLoop();
2855
2889
  const vueEdges = vueTemplateEdges(ctx);
2890
+ await yieldToLoop();
2856
2891
  const svelteKitEdges = svelteKitLoadEdges(ctx);
2892
+ await yieldToLoop();
2857
2893
  const pascalEdges = pascalFormEdges(ctx);
2894
+ await yieldToLoop();
2858
2895
  const flutterEdges = flutterBuildEdges(queries, ctx);
2896
+ await yieldToLoop();
2859
2897
  const cppEdges = cppOverrideEdges(queries);
2898
+ await yieldToLoop();
2860
2899
  const ifaceEdges = interfaceOverrideEdges(queries);
2900
+ await yieldToLoop();
2861
2901
  const kotlinExpectActual = kotlinExpectActualEdges(queries);
2902
+ await yieldToLoop();
2862
2903
  const goGrpcEdges = goGrpcStubImplEdges(queries);
2904
+ await yieldToLoop();
2863
2905
  const rnEventEdgesList = rnEventEdges(ctx);
2906
+ await yieldToLoop();
2864
2907
  const fabricNativeEdges = fabricNativeImplEdges(ctx);
2908
+ await yieldToLoop();
2865
2909
  const expoXPlatEdges = expoCrossPlatformEdges(queries);
2910
+ await yieldToLoop();
2866
2911
  const rnXPlatEdges = rnCrossPlatformEdges(queries);
2912
+ await yieldToLoop();
2867
2913
  const mybatisEdges = mybatisJavaXmlEdges(queries);
2914
+ await yieldToLoop();
2868
2915
  const ginEdges = ginMiddlewareChainEdges(queries, ctx);
2916
+ await yieldToLoop();
2869
2917
  const thunkEdges = reduxThunkEdges(queries, ctx);
2870
- const registryEdges = objectRegistryEdges(ctx);
2918
+ await yieldToLoop();
2919
+ const registryEdges = await objectRegistryEdges(ctx, yieldToLoop);
2920
+ await yieldToLoop();
2871
2921
  const rtkEdges = rtkQueryEdges(queries, ctx);
2922
+ await yieldToLoop();
2872
2923
  const piniaEdges = piniaStoreEdges(ctx);
2924
+ await yieldToLoop();
2873
2925
  const vuexEdges = vuexDispatchEdges(ctx);
2926
+ await yieldToLoop();
2874
2927
  const celeryEdges = celeryDispatchEdges(ctx);
2928
+ await yieldToLoop();
2875
2929
  const springEdges = springEventEdges(ctx);
2930
+ await yieldToLoop();
2876
2931
  const mediatrEdges = mediatrDispatchEdges(ctx);
2932
+ await yieldToLoop();
2877
2933
  const sidekiqEdges = sidekiqDispatchEdges(ctx);
2934
+ await yieldToLoop();
2878
2935
  const laravelEdges = laravelEventEdges(ctx);
2936
+ await yieldToLoop();
2879
2937
  const cFnPtrEdges = (0, c_fnptr_synthesizer_1.cFnPointerDispatchEdges)(queries, ctx);
2938
+ await yieldToLoop();
2880
2939
  const goframeEdges = (0, goframe_synthesizer_1.goframeRouteEdges)(ctx);
2940
+ await yieldToLoop();
2881
2941
  const merged = [];
2882
2942
  const seen = new Set();
2883
2943
  for (const e of [