MCPcopy Create free account
hub / github.com/benjitaylor/agentation / findNearestComponentSource

Function findNearestComponentSource

package/src/utils/source-location.ts:780–803  ·  view source on GitHub ↗
(
  element: HTMLElement,
  maxAncestors = 10
)

Source from the content-addressed store, hash-verified

778 * @returns Source location result
779 */
780export function findNearestComponentSource(
781 element: HTMLElement,
782 maxAncestors = 10
783): SourceLocationResult {
784 let current: HTMLElement | null = element;
785 let depth = 0;
786
787 while (current && depth < maxAncestors) {
788 const result = getSourceLocation(current);
789
790 // Return first successful result
791 if (result.found) {
792 return result;
793 }
794
795 // If we found fiber but no source, keep looking up DOM
796 // (might find a parent component with source info)
797 current = current.parentElement;
798 depth++;
799 }
800
801 // Return result for original element (will explain why not found)
802 return getSourceLocation(element);
803}
804
805/**
806 * Gets all component sources in the ancestor chain

Callers 1

detectSourceFileFunction · 0.90

Calls 1

getSourceLocationFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…