MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / detect

Function detect

src/resolution/frameworks/react-native.ts:549–569  ·  view source on GitHub ↗

* Detect: package.json depends on `react-native`, OR any source file * uses the `RCT_EXPORT_MODULE` / `RCT_EXTERN_MODULE` / * `TurboModuleRegistry` markers. Either signal is enough — different * libraries split the JS package from the native code (`react-native-svg`'s * apple/ + android/

(context)

Source from the content-addressed store, hash-verified

547 * apple/ + android/ directories vs its src/), so we don't require both.
548 */
549 detect(context) {
550 const pkg = context.readFile('package.json');
551 if (pkg && /["']react-native["']\s*:/.test(pkg)) return true;
552 // Fallback: scan a small number of files for the macro markers — only
553 // looking at the first ones returned by getAllFiles to keep detect()
554 // fast on huge repos.
555 const files = context.getAllFiles();
556 for (let i = 0; i < Math.min(files.length, 200); i++) {
557 const f = files[i];
558 if (!f) continue;
559 if (f.endsWith('.mm') || f.endsWith('.m')) {
560 const src = context.readFile(f);
561 if (src && /RCT_EXPORT_MODULE\b|RCT_EXTERN_(?:REMAP_)?MODULE\b/.test(src)) return true;
562 }
563 if (f.endsWith('.ts') || f.endsWith('.tsx')) {
564 const src = context.readFile(f);
565 if (src && /TurboModuleRegistry\.(?:get|getEnforcing)\s*</.test(src)) return true;
566 }
567 }
568 return false;
569 },
570
571 claimsReference(_name) {
572 // JS-visible method names are ordinary identifiers and are typically

Callers

nothing calls this directly

Calls 2

readFileMethod · 0.65
getAllFilesMethod · 0.65

Tested by

no test coverage detected