kirograph 0.16.1 → 0.19.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.
- package/LICENSE +1 -1
- package/README.md +103 -1605
- package/dist/architecture/layers/dart.js +112 -0
- package/dist/architecture/layers/dart.js.map +7 -0
- package/dist/architecture/layers/index.js +3 -1
- package/dist/architecture/layers/index.js.map +2 -2
- package/dist/bin/banner.js +74 -6
- package/dist/bin/banner.js.map +2 -2
- package/dist/bin/commands/affected.js +40 -5
- package/dist/bin/commands/affected.js.map +2 -2
- package/dist/bin/commands/attack-surface.js +157 -0
- package/dist/bin/commands/attack-surface.js.map +7 -0
- package/dist/bin/commands/benchmark.js +206 -0
- package/dist/bin/commands/benchmark.js.map +7 -0
- package/dist/bin/commands/budget.js +70 -0
- package/dist/bin/commands/budget.js.map +7 -0
- package/dist/bin/commands/communities.js +77 -0
- package/dist/bin/commands/communities.js.map +7 -0
- package/dist/bin/commands/data.js +665 -0
- package/dist/bin/commands/data.js.map +7 -0
- package/dist/bin/commands/dep-confusion.js +119 -0
- package/dist/bin/commands/dep-confusion.js.map +7 -0
- package/dist/bin/commands/export.js +304 -10
- package/dist/bin/commands/export.js.map +2 -2
- package/dist/bin/commands/flows.js +97 -0
- package/dist/bin/commands/flows.js.map +7 -0
- package/dist/bin/commands/help.js +386 -100
- package/dist/bin/commands/help.js.map +2 -2
- package/dist/bin/commands/install.js +90 -8
- package/dist/bin/commands/install.js.map +2 -2
- package/dist/bin/commands/licenses.js +201 -0
- package/dist/bin/commands/licenses.js.map +7 -0
- package/dist/bin/commands/reachability.js +160 -0
- package/dist/bin/commands/reachability.js.map +7 -0
- package/dist/bin/commands/read.js +100 -0
- package/dist/bin/commands/read.js.map +7 -0
- package/dist/bin/commands/refactor.js +116 -0
- package/dist/bin/commands/refactor.js.map +7 -0
- package/dist/bin/commands/remediation.js +133 -0
- package/dist/bin/commands/remediation.js.map +7 -0
- package/dist/bin/commands/sbom.js +76 -0
- package/dist/bin/commands/sbom.js.map +7 -0
- package/dist/bin/commands/security-ci-report.js +267 -0
- package/dist/bin/commands/security-ci-report.js.map +7 -0
- package/dist/bin/commands/security-export.js +1349 -0
- package/dist/bin/commands/security-export.js.map +7 -0
- package/dist/bin/commands/security-flows.js +126 -0
- package/dist/bin/commands/security-flows.js.map +7 -0
- package/dist/bin/commands/security-secrets.js +170 -0
- package/dist/bin/commands/security-secrets.js.map +7 -0
- package/dist/bin/commands/security.js +193 -0
- package/dist/bin/commands/security.js.map +7 -0
- package/dist/bin/commands/staleness.js +144 -0
- package/dist/bin/commands/staleness.js.map +7 -0
- package/dist/bin/commands/status.js +102 -2
- package/dist/bin/commands/status.js.map +2 -2
- package/dist/bin/commands/supply-chain.js +138 -0
- package/dist/bin/commands/supply-chain.js.map +7 -0
- package/dist/bin/commands/uninit.js +109 -60
- package/dist/bin/commands/uninit.js.map +2 -2
- package/dist/bin/commands/vex.js +76 -0
- package/dist/bin/commands/vex.js.map +7 -0
- package/dist/bin/commands/vuln-suppress.js +95 -0
- package/dist/bin/commands/vuln-suppress.js.map +7 -0
- package/dist/bin/commands/vulns.js +382 -0
- package/dist/bin/commands/vulns.js.map +7 -0
- package/dist/bin/installer/auto-detect.js +125 -0
- package/dist/bin/installer/auto-detect.js.map +7 -0
- package/dist/bin/installer/cli-agent.js +28 -5
- package/dist/bin/installer/cli-agent.js.map +2 -2
- package/dist/bin/installer/common.js +47 -0
- package/dist/bin/installer/common.js.map +2 -2
- package/dist/bin/installer/config-prompt.js +39 -1
- package/dist/bin/installer/config-prompt.js.map +2 -2
- package/dist/bin/installer/detect.js +309 -0
- package/dist/bin/installer/detect.js.map +7 -0
- package/dist/bin/installer/index.js +36 -1
- package/dist/bin/installer/index.js.map +2 -2
- package/dist/bin/installer/instructions.js +195 -3
- package/dist/bin/installer/instructions.js.map +2 -2
- package/dist/bin/installer/steering.js +440 -0
- package/dist/bin/installer/steering.js.map +2 -2
- package/dist/bin/installer/targets/aider.js +3 -3
- package/dist/bin/installer/targets/aider.js.map +2 -2
- package/dist/bin/installer/targets/amp.js +3 -3
- package/dist/bin/installer/targets/amp.js.map +2 -2
- package/dist/bin/installer/targets/antigravity.js +35 -6
- package/dist/bin/installer/targets/antigravity.js.map +2 -2
- package/dist/bin/installer/targets/augment.js +3 -3
- package/dist/bin/installer/targets/augment.js.map +2 -2
- package/dist/bin/installer/targets/claude.js +49 -5
- package/dist/bin/installer/targets/claude.js.map +2 -2
- package/dist/bin/installer/targets/cline.js +32 -6
- package/dist/bin/installer/targets/cline.js.map +2 -2
- package/dist/bin/installer/targets/codex.js +64 -12
- package/dist/bin/installer/targets/codex.js.map +2 -2
- package/dist/bin/installer/targets/continue.js +2 -2
- package/dist/bin/installer/targets/continue.js.map +2 -2
- package/dist/bin/installer/targets/copilot-cli.js +101 -0
- package/dist/bin/installer/targets/copilot-cli.js.map +7 -0
- package/dist/bin/installer/targets/copilot.js +31 -5
- package/dist/bin/installer/targets/copilot.js.map +2 -2
- package/dist/bin/installer/targets/cursor.js +4 -4
- package/dist/bin/installer/targets/cursor.js.map +2 -2
- package/dist/bin/installer/targets/devin.js +2 -2
- package/dist/bin/installer/targets/devin.js.map +2 -2
- package/dist/bin/installer/targets/gemini-cli.js +2 -2
- package/dist/bin/installer/targets/gemini-cli.js.map +2 -2
- package/dist/bin/installer/targets/generic.js +2 -14
- package/dist/bin/installer/targets/generic.js.map +2 -2
- package/dist/bin/installer/targets/goose.js +3 -3
- package/dist/bin/installer/targets/goose.js.map +2 -2
- package/dist/bin/installer/targets/index.js +250 -0
- package/dist/bin/installer/targets/index.js.map +2 -2
- package/dist/bin/installer/targets/junie.js +2 -2
- package/dist/bin/installer/targets/junie.js.map +2 -2
- package/dist/bin/installer/targets/kilo.js +2 -2
- package/dist/bin/installer/targets/kilo.js.map +2 -2
- package/dist/bin/installer/targets/kiro.js +3 -3
- package/dist/bin/installer/targets/kiro.js.map +2 -2
- package/dist/bin/installer/targets/opencode.js +2 -2
- package/dist/bin/installer/targets/opencode.js.map +2 -2
- package/dist/bin/installer/targets/openhands.js +3 -3
- package/dist/bin/installer/targets/openhands.js.map +2 -2
- package/dist/bin/installer/targets/qoder.js +91 -0
- package/dist/bin/installer/targets/qoder.js.map +7 -0
- package/dist/bin/installer/targets/qwen.js +96 -0
- package/dist/bin/installer/targets/qwen.js.map +7 -0
- package/dist/bin/installer/targets/replit.js +3 -3
- package/dist/bin/installer/targets/replit.js.map +2 -2
- package/dist/bin/installer/targets/roo.js +2 -2
- package/dist/bin/installer/targets/roo.js.map +2 -2
- package/dist/bin/installer/targets/tabnine.js +3 -3
- package/dist/bin/installer/targets/tabnine.js.map +2 -2
- package/dist/bin/installer/targets/trae.js +5 -5
- package/dist/bin/installer/targets/trae.js.map +2 -2
- package/dist/bin/installer/targets/warp.js +2 -2
- package/dist/bin/installer/targets/warp.js.map +2 -2
- package/dist/bin/installer/targets/windsurf.js +35 -6
- package/dist/bin/installer/targets/windsurf.js.map +2 -2
- package/dist/bin/kirograph.js +74 -6
- package/dist/bin/kirograph.js.map +3 -3
- package/dist/bin/progress.js +30 -0
- package/dist/bin/progress.js.map +2 -2
- package/dist/compression/naive-cost.js +25 -0
- package/dist/compression/naive-cost.js.map +2 -2
- package/dist/compression/tracker.js +91 -2
- package/dist/compression/tracker.js.map +2 -2
- package/dist/compression/types.js.map +1 -1
- package/dist/config.js +126 -3
- package/dist/config.js.map +2 -2
- package/dist/core/pipeline.js +92 -4
- package/dist/core/pipeline.js.map +2 -2
- package/dist/data/filters.js +105 -0
- package/dist/data/filters.js.map +7 -0
- package/dist/data/indexer.js +225 -0
- package/dist/data/indexer.js.map +7 -0
- package/dist/data/linker.js +150 -0
- package/dist/data/linker.js.map +7 -0
- package/dist/data/lint.js +109 -0
- package/dist/data/lint.js.map +7 -0
- package/dist/data/parsers/csv.js +132 -0
- package/dist/data/parsers/csv.js.map +7 -0
- package/dist/data/parsers/excel.js +88 -0
- package/dist/data/parsers/excel.js.map +7 -0
- package/dist/data/parsers/index.js +79 -0
- package/dist/data/parsers/index.js.map +7 -0
- package/dist/data/parsers/json-array.js +89 -0
- package/dist/data/parsers/json-array.js.map +7 -0
- package/dist/data/parsers/jsonl.js +84 -0
- package/dist/data/parsers/jsonl.js.map +7 -0
- package/dist/data/parsers/parquet.js +95 -0
- package/dist/data/parsers/parquet.js.map +7 -0
- package/dist/data/profiler.js +182 -0
- package/dist/data/profiler.js.map +7 -0
- package/dist/data/queries.js +512 -0
- package/dist/data/queries.js.map +7 -0
- package/dist/data/types.js +17 -0
- package/dist/data/types.js.map +7 -0
- package/dist/db/data-schema.sql +61 -0
- package/dist/db/database.js +67 -5
- package/dist/db/database.js.map +2 -2
- package/dist/db/memory-schema.sql +5 -1
- package/dist/db/schema.sql +3 -1
- package/dist/db/security-schema.sql +72 -0
- package/dist/extraction/extractor.js +81 -0
- package/dist/extraction/extractor.js.map +2 -2
- package/dist/extraction/grammars.js +32 -8
- package/dist/extraction/grammars.js.map +2 -2
- package/dist/extraction/languages.js +43 -1
- package/dist/extraction/languages.js.map +2 -2
- package/dist/extraction/notebook.js +300 -0
- package/dist/extraction/notebook.js.map +7 -0
- package/dist/extraction/wasm/tree-sitter-astro.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-gdscript.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-julia.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-perl.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-powershell.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-sql.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-verilog.wasm +0 -0
- package/dist/frameworks/flutter.js +130 -0
- package/dist/frameworks/flutter.js.map +7 -0
- package/dist/frameworks/index.js +7 -1
- package/dist/frameworks/index.js.map +3 -3
- package/dist/graph/communities.js +317 -0
- package/dist/graph/communities.js.map +7 -0
- package/dist/graph/flows.js +138 -0
- package/dist/graph/flows.js.map +7 -0
- package/dist/graph/refactor.js +155 -0
- package/dist/graph/refactor.js.map +7 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/mcp/cache.js +172 -0
- package/dist/mcp/cache.js.map +7 -0
- package/dist/mcp/read-modes.js +295 -0
- package/dist/mcp/read-modes.js.map +7 -0
- package/dist/mcp/server.js +2 -1
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/tool-names.js +29 -1
- package/dist/mcp/tool-names.js.map +2 -2
- package/dist/mcp/tools.js +1588 -6
- package/dist/mcp/tools.js.map +3 -3
- package/dist/memory/database.js +32 -2
- package/dist/memory/database.js.map +2 -2
- package/dist/memory/types.js.map +1 -1
- package/dist/resolution/bridges/android-rn.js +298 -0
- package/dist/resolution/bridges/android-rn.js.map +7 -0
- package/dist/resolution/bridges/expo-modules.js +155 -0
- package/dist/resolution/bridges/expo-modules.js.map +7 -0
- package/dist/resolution/bridges/flutter-channel.js +385 -0
- package/dist/resolution/bridges/flutter-channel.js.map +7 -0
- package/dist/resolution/bridges/index.js +80 -0
- package/dist/resolution/bridges/index.js.map +7 -0
- package/dist/resolution/bridges/native-events.js +188 -0
- package/dist/resolution/bridges/native-events.js.map +7 -0
- package/dist/resolution/bridges/native-views.js +244 -0
- package/dist/resolution/bridges/native-views.js.map +7 -0
- package/dist/resolution/bridges/react-native.js +161 -0
- package/dist/resolution/bridges/react-native.js.map +7 -0
- package/dist/resolution/bridges/swift-objc.js +227 -0
- package/dist/resolution/bridges/swift-objc.js.map +7 -0
- package/dist/resolution/bridges/turbomodules.js +216 -0
- package/dist/resolution/bridges/turbomodules.js.map +7 -0
- package/dist/resolution/index.js +61 -2
- package/dist/resolution/index.js.map +2 -2
- package/dist/security/attack-surface.js +164 -0
- package/dist/security/attack-surface.js.map +7 -0
- package/dist/security/context-warnings.js +123 -0
- package/dist/security/context-warnings.js.map +7 -0
- package/dist/security/context-warnings.test.js +300 -0
- package/dist/security/context-warnings.test.js.map +7 -0
- package/dist/security/data-flows.js +228 -0
- package/dist/security/data-flows.js.map +7 -0
- package/dist/security/dep-confusion.js +255 -0
- package/dist/security/dep-confusion.js.map +7 -0
- package/dist/security/errors.js +51 -0
- package/dist/security/errors.js.map +7 -0
- package/dist/security/export/fix-suggestions.js +58 -0
- package/dist/security/export/fix-suggestions.js.map +7 -0
- package/dist/security/export/fix-suggestions.test.js +74 -0
- package/dist/security/export/fix-suggestions.test.js.map +7 -0
- package/dist/security/export/sbom.js +230 -0
- package/dist/security/export/sbom.js.map +7 -0
- package/dist/security/export/sbom.test.js +288 -0
- package/dist/security/export/sbom.test.js.map +7 -0
- package/dist/security/export/serialization.js +142 -0
- package/dist/security/export/serialization.js.map +7 -0
- package/dist/security/export/serialization.test.js +310 -0
- package/dist/security/export/serialization.test.js.map +7 -0
- package/dist/security/export/vex.js +220 -0
- package/dist/security/export/vex.js.map +7 -0
- package/dist/security/export/vex.test.js +278 -0
- package/dist/security/export/vex.test.js.map +7 -0
- package/dist/security/index.js +67 -0
- package/dist/security/index.js.map +7 -0
- package/dist/security/integrator-transitives.test.js +359 -0
- package/dist/security/integrator-transitives.test.js.map +7 -0
- package/dist/security/integrator.js +491 -0
- package/dist/security/integrator.js.map +7 -0
- package/dist/security/integrator.test.js +237 -0
- package/dist/security/integrator.test.js.map +7 -0
- package/dist/security/license.js +70 -0
- package/dist/security/license.js.map +7 -0
- package/dist/security/manifest/adapter.js +243 -0
- package/dist/security/manifest/adapter.js.map +7 -0
- package/dist/security/manifest/adapter.test.js +272 -0
- package/dist/security/manifest/adapter.test.js.map +7 -0
- package/dist/security/manifest/parser.js +376 -0
- package/dist/security/manifest/parser.js.map +7 -0
- package/dist/security/manifest/parser.test.js +110 -0
- package/dist/security/manifest/parser.test.js.map +7 -0
- package/dist/security/manifest/plugins/cargo.js +233 -0
- package/dist/security/manifest/plugins/cargo.js.map +7 -0
- package/dist/security/manifest/plugins/cargo.test.js +304 -0
- package/dist/security/manifest/plugins/cargo.test.js.map +7 -0
- package/dist/security/manifest/plugins/composer.js +152 -0
- package/dist/security/manifest/plugins/composer.js.map +7 -0
- package/dist/security/manifest/plugins/go.js +146 -0
- package/dist/security/manifest/plugins/go.js.map +7 -0
- package/dist/security/manifest/plugins/go.test.js +341 -0
- package/dist/security/manifest/plugins/go.test.js.map +7 -0
- package/dist/security/manifest/plugins/gradle.js +159 -0
- package/dist/security/manifest/plugins/gradle.js.map +7 -0
- package/dist/security/manifest/plugins/hex.js +159 -0
- package/dist/security/manifest/plugins/hex.js.map +7 -0
- package/dist/security/manifest/plugins/maven.js +128 -0
- package/dist/security/manifest/plugins/maven.js.map +7 -0
- package/dist/security/manifest/plugins/maven.test.js +389 -0
- package/dist/security/manifest/plugins/maven.test.js.map +7 -0
- package/dist/security/manifest/plugins/npm.js +284 -0
- package/dist/security/manifest/plugins/npm.js.map +7 -0
- package/dist/security/manifest/plugins/npm.test.js +298 -0
- package/dist/security/manifest/plugins/npm.test.js.map +7 -0
- package/dist/security/manifest/plugins/nuget.js +186 -0
- package/dist/security/manifest/plugins/nuget.js.map +7 -0
- package/dist/security/manifest/plugins/pip.js +123 -0
- package/dist/security/manifest/plugins/pip.js.map +7 -0
- package/dist/security/manifest/plugins/pip.test.js +208 -0
- package/dist/security/manifest/plugins/pip.test.js.map +7 -0
- package/dist/security/manifest/plugins/pubspec.js +212 -0
- package/dist/security/manifest/plugins/pubspec.js.map +7 -0
- package/dist/security/manifest/plugins/pyproject.js +261 -0
- package/dist/security/manifest/plugins/pyproject.js.map +7 -0
- package/dist/security/manifest/plugins/rubygems.js +185 -0
- package/dist/security/manifest/plugins/rubygems.js.map +7 -0
- package/dist/security/manifest/plugins/swift.js +200 -0
- package/dist/security/manifest/plugins/swift.js.map +7 -0
- package/dist/security/owasp.js +104 -0
- package/dist/security/owasp.js.map +7 -0
- package/dist/security/pipeline.js +125 -0
- package/dist/security/pipeline.js.map +7 -0
- package/dist/security/reachability.js +276 -0
- package/dist/security/reachability.js.map +7 -0
- package/dist/security/reachability.test.js +394 -0
- package/dist/security/reachability.test.js.map +7 -0
- package/dist/security/remediation.js +126 -0
- package/dist/security/remediation.js.map +7 -0
- package/dist/security/secrets.js +176 -0
- package/dist/security/secrets.js.map +7 -0
- package/dist/security/staleness.js +231 -0
- package/dist/security/staleness.js.map +7 -0
- package/dist/security/supply-chain.js +301 -0
- package/dist/security/supply-chain.js.map +7 -0
- package/dist/security/suppressions.js +106 -0
- package/dist/security/suppressions.js.map +7 -0
- package/dist/security/types.js +17 -0
- package/dist/security/types.js.map +7 -0
- package/dist/security/vuln/client.js +355 -0
- package/dist/security/vuln/client.js.map +7 -0
- package/dist/security/vuln/client.test.js +288 -0
- package/dist/security/vuln/client.test.js.map +7 -0
- package/dist/security/vuln/epss-client.js +95 -0
- package/dist/security/vuln/epss-client.js.map +7 -0
- package/dist/security/vuln/index.js +29 -0
- package/dist/security/vuln/index.js.map +7 -0
- package/dist/security/vuln/osv-adapter.js +321 -0
- package/dist/security/vuln/osv-adapter.js.map +7 -0
- package/dist/security/vuln/osv-adapter.test.js +391 -0
- package/dist/security/vuln/osv-adapter.test.js.map +7 -0
- package/dist/security/vuln/types.js +17 -0
- package/dist/security/vuln/types.js.map +7 -0
- package/dist/types.js.map +2 -2
- package/package.json +5 -2
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var react_native_exports = {};
|
|
20
|
+
__export(react_native_exports, {
|
|
21
|
+
reactNativeLegacyBridge: () => reactNativeLegacyBridge
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(react_native_exports);
|
|
24
|
+
function findNativeModuleCalls(context) {
|
|
25
|
+
const calls = [];
|
|
26
|
+
const files = context.getAllFiles();
|
|
27
|
+
for (const f of files) {
|
|
28
|
+
if (!f.endsWith(".ts") && !f.endsWith(".tsx") && !f.endsWith(".js") && !f.endsWith(".jsx")) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const content = context.readFile(f);
|
|
32
|
+
if (!content) continue;
|
|
33
|
+
const nativeModuleRegex = /NativeModules\.(\w+)\.(\w+)\s*\(/g;
|
|
34
|
+
let match;
|
|
35
|
+
const nodes = context.getNodesInFile(f);
|
|
36
|
+
while ((match = nativeModuleRegex.exec(content)) !== null) {
|
|
37
|
+
const moduleName = match[1];
|
|
38
|
+
const methodName = match[2];
|
|
39
|
+
const lineNum = content.slice(0, match.index).split("\n").length;
|
|
40
|
+
const enclosing = nodes.find(
|
|
41
|
+
(n) => (n.kind === "function" || n.kind === "method") && n.startLine <= lineNum && n.endLine >= lineNum
|
|
42
|
+
);
|
|
43
|
+
if (enclosing) {
|
|
44
|
+
calls.push({ moduleName, methodName, callerNodeId: enclosing.id });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return calls;
|
|
49
|
+
}
|
|
50
|
+
function findNativeMethodDecls(context) {
|
|
51
|
+
const decls = [];
|
|
52
|
+
const files = context.getAllFiles();
|
|
53
|
+
for (const f of files) {
|
|
54
|
+
if (f.endsWith(".m") || f.endsWith(".mm")) {
|
|
55
|
+
const content = context.readFile(f);
|
|
56
|
+
if (!content) continue;
|
|
57
|
+
const moduleMatch = content.match(/RCT_EXPORT_MODULE\((\w*)\)/);
|
|
58
|
+
const implMatch = content.match(/@implementation\s+(\w+)/);
|
|
59
|
+
let moduleName = moduleMatch?.[1] || "";
|
|
60
|
+
if (!moduleName && implMatch) {
|
|
61
|
+
moduleName = implMatch[1].replace(/^RCT/, "");
|
|
62
|
+
}
|
|
63
|
+
if (!moduleName) continue;
|
|
64
|
+
const methodRegex = /RCT_EXPORT_METHOD\((\w+)/g;
|
|
65
|
+
let methodMatch;
|
|
66
|
+
const nodes = context.getNodesInFile(f);
|
|
67
|
+
while ((methodMatch = methodRegex.exec(content)) !== null) {
|
|
68
|
+
const methodName = methodMatch[1];
|
|
69
|
+
const lineNum = content.slice(0, methodMatch.index).split("\n").length;
|
|
70
|
+
const methodNode = nodes.find(
|
|
71
|
+
(n) => (n.kind === "method" || n.kind === "function") && (n.name === methodName || n.name.startsWith(methodName)) && Math.abs(n.startLine - lineNum) < 5
|
|
72
|
+
);
|
|
73
|
+
if (methodNode) {
|
|
74
|
+
decls.push({ moduleName, methodName, nodeId: methodNode.id, language: "objc" });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const remapRegex = /RCT_REMAP_METHOD\((\w+)\s*,\s*(\w+)/g;
|
|
78
|
+
let remapMatch;
|
|
79
|
+
while ((remapMatch = remapRegex.exec(content)) !== null) {
|
|
80
|
+
const jsMethodName = remapMatch[1];
|
|
81
|
+
const lineNum = content.slice(0, remapMatch.index).split("\n").length;
|
|
82
|
+
const methodNode = nodes.find(
|
|
83
|
+
(n) => (n.kind === "method" || n.kind === "function") && Math.abs(n.startLine - lineNum) < 5
|
|
84
|
+
);
|
|
85
|
+
if (methodNode) {
|
|
86
|
+
decls.push({ moduleName, methodName: jsMethodName, nodeId: methodNode.id, language: "objc" });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (f.endsWith(".java") || f.endsWith(".kt")) {
|
|
91
|
+
const content = context.readFile(f);
|
|
92
|
+
if (!content) continue;
|
|
93
|
+
const getNameMatch = content.match(/getName\s*\(\s*\)\s*\{[^}]*return\s*"(\w+)"/);
|
|
94
|
+
const classMatch = content.match(/class\s+(\w+Module)\b/);
|
|
95
|
+
let moduleName = getNameMatch?.[1] || "";
|
|
96
|
+
if (!moduleName && classMatch) {
|
|
97
|
+
moduleName = classMatch[1].replace(/Module$/, "");
|
|
98
|
+
}
|
|
99
|
+
if (!moduleName) continue;
|
|
100
|
+
const reactMethodRegex = /@ReactMethod[\s\S]*?(?:fun|void|public)\s+(\w+)\s*\(/g;
|
|
101
|
+
let methodMatch;
|
|
102
|
+
const nodes = context.getNodesInFile(f);
|
|
103
|
+
while ((methodMatch = reactMethodRegex.exec(content)) !== null) {
|
|
104
|
+
const methodName = methodMatch[1];
|
|
105
|
+
const lineNum = content.slice(0, methodMatch.index).split("\n").length;
|
|
106
|
+
const methodNode = nodes.find(
|
|
107
|
+
(n) => (n.kind === "method" || n.kind === "function") && n.name === methodName && Math.abs(n.startLine - lineNum) < 5
|
|
108
|
+
);
|
|
109
|
+
if (methodNode) {
|
|
110
|
+
decls.push({ moduleName, methodName, nodeId: methodNode.id, language: "java" });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return decls;
|
|
116
|
+
}
|
|
117
|
+
const reactNativeLegacyBridge = {
|
|
118
|
+
name: "react-native-legacy-bridge",
|
|
119
|
+
detect(context) {
|
|
120
|
+
const packageJson = context.readFile("package.json");
|
|
121
|
+
if (!packageJson) return false;
|
|
122
|
+
try {
|
|
123
|
+
const pkg = JSON.parse(packageJson);
|
|
124
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
125
|
+
return "react-native" in deps;
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
resolve(context) {
|
|
131
|
+
const edges = [];
|
|
132
|
+
const calls = findNativeModuleCalls(context);
|
|
133
|
+
const decls = findNativeMethodDecls(context);
|
|
134
|
+
for (const call of calls) {
|
|
135
|
+
for (const decl of decls) {
|
|
136
|
+
if (call.moduleName === decl.moduleName && call.methodName === decl.methodName) {
|
|
137
|
+
edges.push({
|
|
138
|
+
source: call.callerNodeId,
|
|
139
|
+
target: decl.nodeId,
|
|
140
|
+
kind: "calls",
|
|
141
|
+
confidence: "inferred",
|
|
142
|
+
confidenceScore: 0.85,
|
|
143
|
+
metadata: {
|
|
144
|
+
synthesizedBy: "react-native-legacy-bridge",
|
|
145
|
+
provenance: "heuristic",
|
|
146
|
+
moduleName: call.moduleName,
|
|
147
|
+
methodName: call.methodName,
|
|
148
|
+
nativeLanguage: decl.language
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return edges;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
158
|
+
0 && (module.exports = {
|
|
159
|
+
reactNativeLegacyBridge
|
|
160
|
+
});
|
|
161
|
+
//# sourceMappingURL=react-native.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/resolution/bridges/react-native.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * React Native Legacy Bridge\n *\n * Synthesizes edges between JavaScript/TypeScript calls to NativeModules.X.method()\n * and native implementations declared via RCT_EXPORT_METHOD (ObjC) or @ReactMethod (Java/Kotlin).\n */\n\nimport type { Node } from '../../types';\nimport type { ResolutionContext } from '../../frameworks/types';\nimport type { BridgeResolver, SynthesizedEdge } from './index';\n\n// \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ninterface NativeModuleCall {\n moduleName: string;\n methodName: string;\n callerNodeId: string;\n}\n\ninterface NativeMethodDecl {\n moduleName: string;\n methodName: string;\n nodeId: string;\n language: 'objc' | 'java' | 'kotlin';\n}\n\n/**\n * Scan JS/TS files for NativeModules.X.method() call patterns.\n */\nfunction findNativeModuleCalls(context: ResolutionContext): NativeModuleCall[] {\n const calls: NativeModuleCall[] = [];\n const files = context.getAllFiles();\n\n for (const f of files) {\n if (!f.endsWith('.ts') && !f.endsWith('.tsx') && !f.endsWith('.js') && !f.endsWith('.jsx')) {\n continue;\n }\n\n const content = context.readFile(f);\n if (!content) continue;\n\n // Match NativeModules.ModuleName.methodName patterns\n const nativeModuleRegex = /NativeModules\\.(\\w+)\\.(\\w+)\\s*\\(/g;\n let match: RegExpExecArray | null;\n\n const nodes = context.getNodesInFile(f);\n\n while ((match = nativeModuleRegex.exec(content)) !== null) {\n const moduleName = match[1];\n const methodName = match[2];\n const lineNum = content.slice(0, match.index).split('\\n').length;\n\n // Find enclosing function/method\n const enclosing = nodes.find(\n n => (n.kind === 'function' || n.kind === 'method') &&\n n.startLine <= lineNum && n.endLine >= lineNum\n );\n\n if (enclosing) {\n calls.push({ moduleName, methodName, callerNodeId: enclosing.id });\n }\n }\n }\n\n return calls;\n}\n\n/**\n * Scan native files for RCT_EXPORT_METHOD / @ReactMethod declarations.\n */\nfunction findNativeMethodDecls(context: ResolutionContext): NativeMethodDecl[] {\n const decls: NativeMethodDecl[] = [];\n const files = context.getAllFiles();\n\n for (const f of files) {\n // ObjC files\n if (f.endsWith('.m') || f.endsWith('.mm')) {\n const content = context.readFile(f);\n if (!content) continue;\n\n // Extract module name from RCT_EXPORT_MODULE(Name)\n const moduleMatch = content.match(/RCT_EXPORT_MODULE\\((\\w*)\\)/);\n // Also try class name pattern: @implementation RCTModuleName\n const implMatch = content.match(/@implementation\\s+(\\w+)/);\n\n let moduleName = moduleMatch?.[1] || '';\n if (!moduleName && implMatch) {\n // Strip RCT prefix for module name\n moduleName = implMatch[1].replace(/^RCT/, '');\n }\n\n if (!moduleName) continue;\n\n // Find RCT_EXPORT_METHOD declarations\n const methodRegex = /RCT_EXPORT_METHOD\\((\\w+)/g;\n let methodMatch: RegExpExecArray | null;\n const nodes = context.getNodesInFile(f);\n\n while ((methodMatch = methodRegex.exec(content)) !== null) {\n const methodName = methodMatch[1];\n const lineNum = content.slice(0, methodMatch.index).split('\\n').length;\n\n // Find the node for this method\n const methodNode = nodes.find(\n n => (n.kind === 'method' || n.kind === 'function') &&\n (n.name === methodName || n.name.startsWith(methodName)) &&\n Math.abs(n.startLine - lineNum) < 5\n );\n\n if (methodNode) {\n decls.push({ moduleName, methodName, nodeId: methodNode.id, language: 'objc' });\n }\n }\n\n // Also check RCT_REMAP_METHOD\n const remapRegex = /RCT_REMAP_METHOD\\((\\w+)\\s*,\\s*(\\w+)/g;\n let remapMatch: RegExpExecArray | null;\n while ((remapMatch = remapRegex.exec(content)) !== null) {\n const jsMethodName = remapMatch[1];\n const lineNum = content.slice(0, remapMatch.index).split('\\n').length;\n\n const methodNode = nodes.find(\n n => (n.kind === 'method' || n.kind === 'function') &&\n Math.abs(n.startLine - lineNum) < 5\n );\n\n if (methodNode) {\n decls.push({ moduleName, methodName: jsMethodName, nodeId: methodNode.id, language: 'objc' });\n }\n }\n }\n\n // Java/Kotlin files\n if (f.endsWith('.java') || f.endsWith('.kt')) {\n const content = context.readFile(f);\n if (!content) continue;\n\n // Extract module name from getName() method\n const getNameMatch = content.match(/getName\\s*\\(\\s*\\)\\s*\\{[^}]*return\\s*\"(\\w+)\"/);\n // Also try class name\n const classMatch = content.match(/class\\s+(\\w+Module)\\b/);\n\n let moduleName = getNameMatch?.[1] || '';\n if (!moduleName && classMatch) {\n moduleName = classMatch[1].replace(/Module$/, '');\n }\n\n if (!moduleName) continue;\n\n // Find @ReactMethod annotated methods\n const reactMethodRegex = /@ReactMethod[\\s\\S]*?(?:fun|void|public)\\s+(\\w+)\\s*\\(/g;\n let methodMatch: RegExpExecArray | null;\n const nodes = context.getNodesInFile(f);\n\n while ((methodMatch = reactMethodRegex.exec(content)) !== null) {\n const methodName = methodMatch[1];\n const lineNum = content.slice(0, methodMatch.index).split('\\n').length;\n\n const methodNode = nodes.find(\n n => (n.kind === 'method' || n.kind === 'function') &&\n n.name === methodName &&\n Math.abs(n.startLine - lineNum) < 5\n );\n\n if (methodNode) {\n decls.push({ moduleName, methodName, nodeId: methodNode.id, language: 'java' });\n }\n }\n }\n }\n\n return decls;\n}\n\n// \u2500\u2500 Bridge Implementation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const reactNativeLegacyBridge: BridgeResolver = {\n name: 'react-native-legacy-bridge',\n\n detect(context: ResolutionContext): boolean {\n // Check for react-native in package.json\n const packageJson = context.readFile('package.json');\n if (!packageJson) return false;\n\n try {\n const pkg = JSON.parse(packageJson);\n const deps = { ...pkg.dependencies, ...pkg.devDependencies };\n return 'react-native' in deps;\n } catch {\n return false;\n }\n },\n\n resolve(context: ResolutionContext): SynthesizedEdge[] {\n const edges: SynthesizedEdge[] = [];\n\n const calls = findNativeModuleCalls(context);\n const decls = findNativeMethodDecls(context);\n\n // Match calls to declarations by module name + method name\n for (const call of calls) {\n for (const decl of decls) {\n if (call.moduleName === decl.moduleName && call.methodName === decl.methodName) {\n edges.push({\n source: call.callerNodeId,\n target: decl.nodeId,\n kind: 'calls',\n confidence: 'inferred',\n confidenceScore: 0.85,\n metadata: {\n synthesizedBy: 'react-native-legacy-bridge',\n provenance: 'heuristic',\n moduleName: call.moduleName,\n methodName: call.methodName,\n nativeLanguage: decl.language,\n },\n });\n }\n }\n }\n\n return edges;\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,SAAS,sBAAsB,SAAgD;AAC7E,QAAM,QAA4B,CAAC;AACnC,QAAM,QAAQ,QAAQ,YAAY;AAElC,aAAW,KAAK,OAAO;AACrB,QAAI,CAAC,EAAE,SAAS,KAAK,KAAK,CAAC,EAAE,SAAS,MAAM,KAAK,CAAC,EAAE,SAAS,KAAK,KAAK,CAAC,EAAE,SAAS,MAAM,GAAG;AAC1F;AAAA,IACF;AAEA,UAAM,UAAU,QAAQ,SAAS,CAAC;AAClC,QAAI,CAAC,QAAS;AAGd,UAAM,oBAAoB;AAC1B,QAAI;AAEJ,UAAM,QAAQ,QAAQ,eAAe,CAAC;AAEtC,YAAQ,QAAQ,kBAAkB,KAAK,OAAO,OAAO,MAAM;AACzD,YAAM,aAAa,MAAM,CAAC;AAC1B,YAAM,aAAa,MAAM,CAAC;AAC1B,YAAM,UAAU,QAAQ,MAAM,GAAG,MAAM,KAAK,EAAE,MAAM,IAAI,EAAE;AAG1D,YAAM,YAAY,MAAM;AAAA,QACtB,QAAM,EAAE,SAAS,cAAc,EAAE,SAAS,aACrC,EAAE,aAAa,WAAW,EAAE,WAAW;AAAA,MAC9C;AAEA,UAAI,WAAW;AACb,cAAM,KAAK,EAAE,YAAY,YAAY,cAAc,UAAU,GAAG,CAAC;AAAA,MACnE;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAKA,SAAS,sBAAsB,SAAgD;AAC7E,QAAM,Q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AAO,EAAE,GAAG,IAAI,cAAc,GAAG,IAAI,gBAAgB;AAC3D,aAAO,kBAAkB;AAAA,IAC3B,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EAEA,QAAQ,SAA+C;AACrD,UAAM,QAA2B,CAAC;AAElC,UAAM,QAAQ,sBAAsB,OAAO;AAC3C,UAAM,QAAQ,sBAAsB,OAAO;AAG3C,eAAW,QAAQ,OAAO;AACxB,iBAAW,QAAQ,OAAO;AACxB,YAAI,KAAK,eAAe,KAAK,cAAc,KAAK,eAAe,KAAK,YAAY;AAC9E,gBAAM,KAAK;AAAA,YACT,QAAQ,KAAK;AAAA,YACb,QAAQ,KAAK;AAAA,YACb,MAAM;AAAA,YACN,YAAY;AAAA,YACZ,iBAAiB;AAAA,YACjB,UAAU;AAAA,cACR,eAAe;AAAA,cACf,YAAY;AAAA,cACZ,YAAY,KAAK;AAAA,cACjB,YAAY,KAAK;AAAA,cACjB,gBAAgB,KAAK;AAAA,YACvB;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var swift_objc_exports = {};
|
|
20
|
+
__export(swift_objc_exports, {
|
|
21
|
+
swiftObjcBridge: () => swiftObjcBridge
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(swift_objc_exports);
|
|
24
|
+
function swiftToObjcSelector(funcName, signature) {
|
|
25
|
+
const selectors = [];
|
|
26
|
+
if (signature) {
|
|
27
|
+
const paramMatch = signature.match(/\(([^)]*)\)/);
|
|
28
|
+
if (paramMatch) {
|
|
29
|
+
const params = paramMatch[1].split(",").map((p) => p.trim()).filter(Boolean);
|
|
30
|
+
if (params.length === 0) {
|
|
31
|
+
selectors.push(funcName);
|
|
32
|
+
} else {
|
|
33
|
+
const labels = params.map((p) => {
|
|
34
|
+
const parts = p.split(":")[0].trim().split(/\s+/);
|
|
35
|
+
return parts[0];
|
|
36
|
+
});
|
|
37
|
+
if (labels.length > 0 && labels[0] !== "_") {
|
|
38
|
+
const firstLabel = labels[0];
|
|
39
|
+
const capitalizedFirst = firstLabel.charAt(0).toUpperCase() + firstLabel.slice(1);
|
|
40
|
+
let selector = `${funcName}With${capitalizedFirst}:`;
|
|
41
|
+
for (let i = 1; i < labels.length; i++) {
|
|
42
|
+
if (labels[i] !== "_") {
|
|
43
|
+
selector += `${labels[i]}:`;
|
|
44
|
+
} else {
|
|
45
|
+
selector += ":";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
selectors.push(selector);
|
|
49
|
+
}
|
|
50
|
+
let directSelector = `${funcName}:`;
|
|
51
|
+
for (let i = 1; i < labels.length; i++) {
|
|
52
|
+
if (labels[i] !== "_") {
|
|
53
|
+
directSelector += `${labels[i]}:`;
|
|
54
|
+
} else {
|
|
55
|
+
directSelector += ":";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
selectors.push(directSelector);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
selectors.push(funcName);
|
|
63
|
+
if (funcName === "init" && signature) {
|
|
64
|
+
const paramMatch = signature.match(/\(([^)]*)\)/);
|
|
65
|
+
if (paramMatch) {
|
|
66
|
+
const params = paramMatch[1].split(",").map((p) => p.trim()).filter(Boolean);
|
|
67
|
+
if (params.length > 0) {
|
|
68
|
+
const firstLabel = params[0].split(":")[0].trim().split(/\s+/)[0];
|
|
69
|
+
if (firstLabel !== "_") {
|
|
70
|
+
const cap = firstLabel.charAt(0).toUpperCase() + firstLabel.slice(1);
|
|
71
|
+
selectors.push(`initWith${cap}:`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return [...new Set(selectors)];
|
|
77
|
+
}
|
|
78
|
+
function swiftPropertyToObjcSelectors(propName) {
|
|
79
|
+
const capitalized = propName.charAt(0).toUpperCase() + propName.slice(1);
|
|
80
|
+
return [propName, `set${capitalized}:`];
|
|
81
|
+
}
|
|
82
|
+
const swiftObjcBridge = {
|
|
83
|
+
name: "swift-objc-bridge",
|
|
84
|
+
detect(context) {
|
|
85
|
+
const files = context.getAllFiles();
|
|
86
|
+
let hasSwift = false;
|
|
87
|
+
let hasObjc = false;
|
|
88
|
+
for (const f of files) {
|
|
89
|
+
if (f.endsWith(".swift")) hasSwift = true;
|
|
90
|
+
if (f.endsWith(".m") || f.endsWith(".mm") || f.endsWith(".h")) hasObjc = true;
|
|
91
|
+
if (hasSwift && hasObjc) return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
},
|
|
95
|
+
resolve(context) {
|
|
96
|
+
const edges = [];
|
|
97
|
+
const files = context.getAllFiles();
|
|
98
|
+
const swiftNodes = [];
|
|
99
|
+
for (const f of files) {
|
|
100
|
+
if (f.endsWith(".swift")) {
|
|
101
|
+
const nodes = context.getNodesInFile(f);
|
|
102
|
+
for (const node of nodes) {
|
|
103
|
+
if ((node.kind === "function" || node.kind === "method" || node.kind === "property") && node.decorators?.includes("objc")) {
|
|
104
|
+
swiftNodes.push(node);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (swiftNodes.length === 0) return edges;
|
|
110
|
+
const selectorToSwiftNode = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const node of swiftNodes) {
|
|
112
|
+
if (node.kind === "property") {
|
|
113
|
+
const selectors = swiftPropertyToObjcSelectors(node.name);
|
|
114
|
+
for (const sel of selectors) {
|
|
115
|
+
selectorToSwiftNode.set(sel, node);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
const selectors = swiftToObjcSelector(node.name, node.signature);
|
|
119
|
+
for (const sel of selectors) {
|
|
120
|
+
selectorToSwiftNode.set(sel, node);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (const f of files) {
|
|
125
|
+
if (!f.endsWith(".m") && !f.endsWith(".mm")) continue;
|
|
126
|
+
const content = context.readFile(f);
|
|
127
|
+
if (!content) continue;
|
|
128
|
+
const objcNodes = context.getNodesInFile(f);
|
|
129
|
+
for (const node of objcNodes) {
|
|
130
|
+
if (node.kind !== "method" && node.kind !== "function") continue;
|
|
131
|
+
const swiftTarget = selectorToSwiftNode.get(node.name);
|
|
132
|
+
if (swiftTarget) {
|
|
133
|
+
edges.push({
|
|
134
|
+
source: node.id,
|
|
135
|
+
target: swiftTarget.id,
|
|
136
|
+
kind: "calls",
|
|
137
|
+
confidence: "inferred",
|
|
138
|
+
confidenceScore: 0.85,
|
|
139
|
+
metadata: {
|
|
140
|
+
synthesizedBy: "swift-objc-bridge",
|
|
141
|
+
provenance: "heuristic",
|
|
142
|
+
direction: "objc-to-swift"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const msgSendRegex = /\[[\w\s.]+\s+(\w+(?::\w*)*)\s*\]/g;
|
|
148
|
+
let match;
|
|
149
|
+
while ((match = msgSendRegex.exec(content)) !== null) {
|
|
150
|
+
const selector = match[1];
|
|
151
|
+
const swiftTarget = selectorToSwiftNode.get(selector);
|
|
152
|
+
if (!swiftTarget) continue;
|
|
153
|
+
const lineNum = content.slice(0, match.index).split("\n").length;
|
|
154
|
+
const enclosingNode = objcNodes.find(
|
|
155
|
+
(n) => (n.kind === "method" || n.kind === "function") && n.startLine <= lineNum && n.endLine >= lineNum
|
|
156
|
+
);
|
|
157
|
+
if (enclosingNode) {
|
|
158
|
+
const exists = edges.some(
|
|
159
|
+
(e) => e.source === enclosingNode.id && e.target === swiftTarget.id
|
|
160
|
+
);
|
|
161
|
+
if (!exists) {
|
|
162
|
+
edges.push({
|
|
163
|
+
source: enclosingNode.id,
|
|
164
|
+
target: swiftTarget.id,
|
|
165
|
+
kind: "calls",
|
|
166
|
+
confidence: "inferred",
|
|
167
|
+
confidenceScore: 0.8,
|
|
168
|
+
metadata: {
|
|
169
|
+
synthesizedBy: "swift-objc-bridge",
|
|
170
|
+
provenance: "heuristic",
|
|
171
|
+
direction: "objc-to-swift",
|
|
172
|
+
selector
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
for (const f of files) {
|
|
180
|
+
if (!f.endsWith(".swift")) continue;
|
|
181
|
+
const content = context.readFile(f);
|
|
182
|
+
if (!content) continue;
|
|
183
|
+
const swiftFileNodes = context.getNodesInFile(f);
|
|
184
|
+
const objcMethods = [];
|
|
185
|
+
for (const of2 of files) {
|
|
186
|
+
if (!of2.endsWith(".m") && !of2.endsWith(".mm") && !of2.endsWith(".h")) continue;
|
|
187
|
+
const nodes = context.getNodesInFile(of2);
|
|
188
|
+
for (const n of nodes) {
|
|
189
|
+
if (n.kind === "method" || n.kind === "function") {
|
|
190
|
+
objcMethods.push(n);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
for (const swiftNode of swiftFileNodes) {
|
|
195
|
+
if (swiftNode.kind !== "method" && swiftNode.kind !== "function") continue;
|
|
196
|
+
for (const objcMethod of objcMethods) {
|
|
197
|
+
const nameMatch = swiftNode.name === objcMethod.name;
|
|
198
|
+
if (nameMatch) {
|
|
199
|
+
const exists = edges.some(
|
|
200
|
+
(e) => e.source === swiftNode.id && e.target === objcMethod.id
|
|
201
|
+
);
|
|
202
|
+
if (!exists) {
|
|
203
|
+
edges.push({
|
|
204
|
+
source: swiftNode.id,
|
|
205
|
+
target: objcMethod.id,
|
|
206
|
+
kind: "calls",
|
|
207
|
+
confidence: "inferred",
|
|
208
|
+
confidenceScore: 0.7,
|
|
209
|
+
metadata: {
|
|
210
|
+
synthesizedBy: "swift-objc-bridge",
|
|
211
|
+
provenance: "heuristic",
|
|
212
|
+
direction: "swift-to-objc"
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return edges;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
224
|
+
0 && (module.exports = {
|
|
225
|
+
swiftObjcBridge
|
|
226
|
+
});
|
|
227
|
+
//# sourceMappingURL=swift-objc.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/resolution/bridges/swift-objc.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Swift \u2194 ObjC Bridge\n *\n * Synthesizes edges between Swift functions with @objc attributes and\n * Objective-C message sends that match the mangled selector.\n *\n * Name mangling rules:\n * - func foo(bar: Int) \u2192 -fooWithBar:\n * - init(name:) \u2192 -initWithName:\n * - var x \u2192 -x / -setX:\n */\n\nimport type { Node } from '../../types';\nimport type { ResolutionContext } from '../../frameworks/types';\nimport type { BridgeResolver, SynthesizedEdge } from './index';\n\n// \u2500\u2500 Swift \u2192 ObjC name mangling \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * Convert a Swift function signature to its ObjC selector equivalent.\n * Examples:\n * foo(bar:baz:) \u2192 fooWithBar:baz:\n * init(name:) \u2192 initWithName:\n * doSomething() \u2192 doSomething\n */\nfunction swiftToObjcSelector(funcName: string, signature?: string): string[] {\n const selectors: string[] = [];\n\n // Extract parameter labels from signature if available\n // Signature format: func foo(bar: Int, baz: String)\n if (signature) {\n const paramMatch = signature.match(/\\(([^)]*)\\)/);\n if (paramMatch) {\n const params = paramMatch[1].split(',').map(p => p.trim()).filter(Boolean);\n if (params.length === 0) {\n // No params: selector is just the function name\n selectors.push(funcName);\n } else {\n // First param label gets \"With\" prefix (Cocoa convention)\n const labels = params.map(p => {\n const parts = p.split(':')[0].trim().split(/\\s+/);\n return parts[0]; // external label\n });\n\n if (labels.length > 0 && labels[0] !== '_') {\n const firstLabel = labels[0];\n const capitalizedFirst = firstLabel.charAt(0).toUpperCase() + firstLabel.slice(1);\n let selector = `${funcName}With${capitalizedFirst}:`;\n for (let i = 1; i < labels.length; i++) {\n if (labels[i] !== '_') {\n selector += `${labels[i]}:`;\n } else {\n selector += ':';\n }\n }\n selectors.push(selector);\n }\n\n // Also try direct selector without \"With\" prefix\n let directSelector = `${funcName}:`;\n for (let i = 1; i < labels.length; i++) {\n if (labels[i] !== '_') {\n directSelector += `${labels[i]}:`;\n } else {\n directSelector += ':';\n }\n }\n selectors.push(directSelector);\n }\n }\n }\n\n // Always include the bare name as a candidate\n selectors.push(funcName);\n\n // For init methods, add initWith variant\n if (funcName === 'init' && signature) {\n const paramMatch = signature.match(/\\(([^)]*)\\)/);\n if (paramMatch) {\n const params = paramMatch[1].split(',').map(p => p.trim()).filter(Boolean);\n if (params.length > 0) {\n const firstLabel = params[0].split(':')[0].trim().split(/\\s+/)[0];\n if (firstLabel !== '_') {\n const cap = firstLabel.charAt(0).toUpperCase() + firstLabel.slice(1);\n selectors.push(`initWith${cap}:`);\n }\n }\n }\n }\n\n return [...new Set(selectors)];\n}\n\n/**\n * Generate ObjC property accessor selectors for a Swift property.\n * var x \u2192 [x, setX:]\n */\nfunction swiftPropertyToObjcSelectors(propName: string): string[] {\n const capitalized = propName.charAt(0).toUpperCase() + propName.slice(1);\n return [propName, `set${capitalized}:`];\n}\n\n// \u2500\u2500 Bridge Implementation \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport const swiftObjcBridge: BridgeResolver = {\n name: 'swift-objc-bridge',\n\n detect(context: ResolutionContext): boolean {\n const files = context.getAllFiles();\n let hasSwift = false;\n let hasObjc = false;\n\n for (const f of files) {\n if (f.endsWith('.swift')) hasSwift = true;\n if (f.endsWith('.m') || f.endsWith('.mm') || f.endsWith('.h')) hasObjc = true;\n if (hasSwift && hasObjc) return true;\n }\n\n return false;\n },\n\n resolve(context: ResolutionContext): SynthesizedEdge[] {\n const edges: SynthesizedEdge[] = [];\n const files = context.getAllFiles();\n\n // Collect Swift @objc functions and properties\n const swiftNodes: Node[] = [];\n for (const f of files) {\n if (f.endsWith('.swift')) {\n const nodes = context.getNodesInFile(f);\n for (const node of nodes) {\n if (\n (node.kind === 'function' || node.kind === 'method' || node.kind === 'property') &&\n node.decorators?.includes('objc')\n ) {\n swiftNodes.push(node);\n }\n }\n }\n }\n\n if (swiftNodes.length === 0) return edges;\n\n // Build selector \u2192 Swift node map\n const selectorToSwiftNode = new Map<string, Node>();\n for (const node of swiftNodes) {\n if (node.kind === 'property') {\n const selectors = swiftPropertyToObjcSelectors(node.name);\n for (const sel of selectors) {\n selectorToSwiftNode.set(sel, node);\n }\n } else {\n const selectors = swiftToObjcSelector(node.name, node.signature);\n for (const sel of selectors) {\n selectorToSwiftNode.set(sel, node);\n }\n }\n }\n\n // Scan ObjC files for message sends matching selectors\n for (const f of files) {\n if (!f.endsWith('.m') && !f.endsWith('.mm')) continue;\n\n const content = context.readFile(f);\n if (!content) continue;\n\n const objcNodes = context.getNodesInFile(f);\n\n // Look for message send patterns: [obj selectorName...]\n // Also look for method declarations that call Swift methods\n for (const node of objcNodes) {\n if (node.kind !== 'method' && node.kind !== 'function') continue;\n\n // Check if this ObjC method name matches a Swift selector\n const swiftTarget = selectorToSwiftNode.get(node.name);\n if (swiftTarget) {\n edges.push({\n source: node.id,\n target: swiftTarget.id,\n kind: 'calls',\n confidence: 'inferred',\n confidenceScore: 0.85,\n metadata: {\n synthesizedBy: 'swift-objc-bridge',\n provenance: 'heuristic',\n direction: 'objc-to-swift',\n },\n });\n }\n }\n\n // Regex-based scan for message sends in ObjC source\n const msgSendRegex = /\\[[\\w\\s.]+\\s+(\\w+(?::\\w*)*)\\s*\\]/g;\n let match: RegExpExecArray | null;\n while ((match = msgSendRegex.exec(content)) !== null) {\n const selector = match[1];\n const swiftTarget = selectorToSwiftNode.get(selector);\n if (!swiftTarget) continue;\n\n // Find the enclosing ObjC function/method for this call site\n const lineNum = content.slice(0, match.index).split('\\n').length;\n const enclosingNode = objcNodes.find(\n n => (n.kind === 'method' || n.kind === 'function') &&\n n.startLine <= lineNum && n.endLine >= lineNum\n );\n\n if (enclosingNode) {\n // Avoid duplicate edges\n const exists = edges.some(\n e => e.source === enclosingNode.id && e.target === swiftTarget.id\n );\n if (!exists) {\n edges.push({\n source: enclosingNode.id,\n target: swiftTarget.id,\n kind: 'calls',\n confidence: 'inferred',\n confidenceScore: 0.8,\n metadata: {\n synthesizedBy: 'swift-objc-bridge',\n provenance: 'heuristic',\n direction: 'objc-to-swift',\n selector,\n },\n });\n }\n }\n }\n }\n\n // Reverse direction: Swift calling ObjC methods\n // Look for Swift files calling ObjC selectors\n for (const f of files) {\n if (!f.endsWith('.swift')) continue;\n\n const content = context.readFile(f);\n if (!content) continue;\n\n const swiftFileNodes = context.getNodesInFile(f);\n\n // Collect all ObjC method nodes for matching\n const objcMethods: Node[] = [];\n for (const of2 of files) {\n if (!of2.endsWith('.m') && !of2.endsWith('.mm') && !of2.endsWith('.h')) continue;\n const nodes = context.getNodesInFile(of2);\n for (const n of nodes) {\n if (n.kind === 'method' || n.kind === 'function') {\n objcMethods.push(n);\n }\n }\n }\n\n // Match Swift method calls to ObjC implementations\n for (const swiftNode of swiftFileNodes) {\n if (swiftNode.kind !== 'method' && swiftNode.kind !== 'function') continue;\n\n for (const objcMethod of objcMethods) {\n // Check if the Swift node references the ObjC method name\n const nameMatch = swiftNode.name === objcMethod.name;\n if (nameMatch) {\n const exists = edges.some(\n e => e.source === swiftNode.id && e.target === objcMethod.id\n );\n if (!exists) {\n edges.push({\n source: swiftNode.id,\n target: objcMethod.id,\n kind: 'calls',\n confidence: 'inferred',\n confidenceScore: 0.7,\n metadata: {\n synthesizedBy: 'swift-objc-bridge',\n provenance: 'heuristic',\n direction: 'swift-to-objc',\n },\n });\n }\n }\n }\n }\n }\n\n return edges;\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBA,SAAS,oBAAoB,UAAkB,WAA8B;AAC3E,QAAM,YAAsB,CAAC;AAI7B,MAAI,WAAW;AACb,UAAM,aAAa,UAAU,MAAM,aAAa;AAChD,QAAI,YAAY;AACd,YAAM,SAAS,WAAW,CAAC,EAAE,MAAM,GAAG,EAAE,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AAK,EAAE,WAAW,UAAU,MAAM,EAAE,WAAW,WAAW;AAAA,YAC5D;AACA,gBAAI,CAAC,QAAQ;AACX,oBAAM,KAAK;AAAA,gBACT,QAAQ,UAAU;AAAA,gBAClB,QAAQ,WAAW;AAAA,gBACnB,MAAM;AAAA,gBACN,YAAY;AAAA,gBACZ,iBAAiB;AAAA,gBACjB,UAAU;AAAA,kBACR,eAAe;AAAA,kBACf,YAAY;AAAA,kBACZ,WAAW;AAAA,gBACb;AAAA,cACF,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var turbomodules_exports = {};
|
|
20
|
+
__export(turbomodules_exports, {
|
|
21
|
+
turboModulesBridge: () => turboModulesBridge
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(turbomodules_exports);
|
|
24
|
+
function findTurboModuleSpecs(context) {
|
|
25
|
+
const specs = [];
|
|
26
|
+
const files = context.getAllFiles();
|
|
27
|
+
for (const f of files) {
|
|
28
|
+
const fileName = f.split("/").pop() ?? "";
|
|
29
|
+
if (!fileName.match(/^Native\w+\.(ts|tsx|js)$/)) continue;
|
|
30
|
+
const content = context.readFile(f);
|
|
31
|
+
if (!content) continue;
|
|
32
|
+
const specMatch = content.match(
|
|
33
|
+
/export\s+interface\s+Spec\s+extends\s+TurboModule\s*\{([^}]*)\}/s
|
|
34
|
+
);
|
|
35
|
+
if (!specMatch) continue;
|
|
36
|
+
const moduleName = fileName.replace(/^Native/, "").replace(/\.(ts|tsx|js)$/, "");
|
|
37
|
+
const methods = [];
|
|
38
|
+
const methodRegex = /(\w+)\s*\(/g;
|
|
39
|
+
let match;
|
|
40
|
+
while ((match = methodRegex.exec(specMatch[1])) !== null) {
|
|
41
|
+
methods.push(match[1]);
|
|
42
|
+
}
|
|
43
|
+
const nodes = context.getNodesInFile(f);
|
|
44
|
+
const specNode = nodes.find(
|
|
45
|
+
(n) => n.kind === "interface" && n.name === "Spec"
|
|
46
|
+
);
|
|
47
|
+
specs.push({
|
|
48
|
+
moduleName,
|
|
49
|
+
methods,
|
|
50
|
+
specFilePath: f,
|
|
51
|
+
specNodeId: specNode?.id
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return specs;
|
|
55
|
+
}
|
|
56
|
+
function findNativeImpls(context, moduleNames) {
|
|
57
|
+
const impls = [];
|
|
58
|
+
const files = context.getAllFiles();
|
|
59
|
+
for (const f of files) {
|
|
60
|
+
if (!f.endsWith(".m") && !f.endsWith(".mm") && !f.endsWith(".swift") && !f.endsWith(".java") && !f.endsWith(".kt")) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const content = context.readFile(f);
|
|
64
|
+
if (!content) continue;
|
|
65
|
+
let moduleName = null;
|
|
66
|
+
if (f.endsWith(".m") || f.endsWith(".mm")) {
|
|
67
|
+
const implMatch = content.match(/@implementation\s+(\w+)/);
|
|
68
|
+
if (implMatch) {
|
|
69
|
+
const className = implMatch[1];
|
|
70
|
+
for (const name of moduleNames) {
|
|
71
|
+
if (className === name || className === `RCT${name}` || className === `${name}Module` || className === `RCT${name}Module`) {
|
|
72
|
+
moduleName = name;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (f.endsWith(".swift")) {
|
|
79
|
+
const classMatch = content.match(/class\s+(\w+)\s*:/);
|
|
80
|
+
if (classMatch) {
|
|
81
|
+
const className = classMatch[1];
|
|
82
|
+
for (const name of moduleNames) {
|
|
83
|
+
if (className === name || className === `${name}Module`) {
|
|
84
|
+
moduleName = name;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (f.endsWith(".java") || f.endsWith(".kt")) {
|
|
91
|
+
const classMatch = content.match(/class\s+(\w+)\s+(?:extends|:)\s+\w*(?:TurboModule|ReactContextBaseJavaModule)/);
|
|
92
|
+
if (classMatch) {
|
|
93
|
+
const className = classMatch[1];
|
|
94
|
+
for (const name of moduleNames) {
|
|
95
|
+
if (className === name || className === `${name}Module`) {
|
|
96
|
+
moduleName = name;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const getNameMatch = content.match(/getName\s*\(\s*\)\s*(?::\s*String\s*)?\{[^}]*return\s*"(\w+)"/);
|
|
102
|
+
if (getNameMatch) {
|
|
103
|
+
const returnedName = getNameMatch[1];
|
|
104
|
+
if (moduleNames.has(returnedName)) {
|
|
105
|
+
moduleName = returnedName;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!moduleName) continue;
|
|
110
|
+
const nodes = context.getNodesInFile(f);
|
|
111
|
+
const methods = /* @__PURE__ */ new Map();
|
|
112
|
+
for (const node of nodes) {
|
|
113
|
+
if (node.kind === "method" || node.kind === "function") {
|
|
114
|
+
methods.set(node.name, node.id);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
impls.push({ moduleName, methods, filePath: f });
|
|
118
|
+
}
|
|
119
|
+
return impls;
|
|
120
|
+
}
|
|
121
|
+
const turboModulesBridge = {
|
|
122
|
+
name: "turbomodules-bridge",
|
|
123
|
+
detect(context) {
|
|
124
|
+
const files = context.getAllFiles();
|
|
125
|
+
for (const f of files) {
|
|
126
|
+
const fileName = f.split("/").pop() ?? "";
|
|
127
|
+
if (fileName.match(/^Native\w+\.(ts|tsx|js)$/)) {
|
|
128
|
+
const content = context.readFile(f);
|
|
129
|
+
if (content && content.includes("TurboModule")) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
},
|
|
136
|
+
resolve(context) {
|
|
137
|
+
const edges = [];
|
|
138
|
+
const specs = findTurboModuleSpecs(context);
|
|
139
|
+
if (specs.length === 0) return edges;
|
|
140
|
+
const moduleNames = new Set(specs.map((s) => s.moduleName));
|
|
141
|
+
const impls = findNativeImpls(context, moduleNames);
|
|
142
|
+
for (const spec of specs) {
|
|
143
|
+
const matchingImpls = impls.filter((i) => i.moduleName === spec.moduleName);
|
|
144
|
+
for (const impl of matchingImpls) {
|
|
145
|
+
for (const method of spec.methods) {
|
|
146
|
+
const nativeNodeId = impl.methods.get(method);
|
|
147
|
+
if (!nativeNodeId) continue;
|
|
148
|
+
const callSites = findCallSitesForModule(context, spec.moduleName, method);
|
|
149
|
+
for (const callSiteId of callSites) {
|
|
150
|
+
edges.push({
|
|
151
|
+
source: callSiteId,
|
|
152
|
+
target: nativeNodeId,
|
|
153
|
+
kind: "calls",
|
|
154
|
+
confidence: "inferred",
|
|
155
|
+
confidenceScore: 0.9,
|
|
156
|
+
metadata: {
|
|
157
|
+
synthesizedBy: "turbomodules-bridge",
|
|
158
|
+
provenance: "heuristic",
|
|
159
|
+
moduleName: spec.moduleName,
|
|
160
|
+
methodName: method,
|
|
161
|
+
specFile: spec.specFilePath
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (spec.specNodeId) {
|
|
166
|
+
edges.push({
|
|
167
|
+
source: spec.specNodeId,
|
|
168
|
+
target: nativeNodeId,
|
|
169
|
+
kind: "references",
|
|
170
|
+
confidence: "inferred",
|
|
171
|
+
confidenceScore: 0.9,
|
|
172
|
+
metadata: {
|
|
173
|
+
synthesizedBy: "turbomodules-bridge",
|
|
174
|
+
provenance: "heuristic",
|
|
175
|
+
moduleName: spec.moduleName,
|
|
176
|
+
methodName: method
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return edges;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
function findCallSitesForModule(context, moduleName, methodName) {
|
|
187
|
+
const callSiteIds = [];
|
|
188
|
+
const files = context.getAllFiles();
|
|
189
|
+
for (const f of files) {
|
|
190
|
+
if (!f.endsWith(".ts") && !f.endsWith(".tsx") && !f.endsWith(".js") && !f.endsWith(".jsx")) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const content = context.readFile(f);
|
|
194
|
+
if (!content) continue;
|
|
195
|
+
const importPattern = new RegExp(`import\\s+\\w+\\s+from\\s+['"]\\.*/Native${moduleName}['"]`);
|
|
196
|
+
if (!importPattern.test(content)) continue;
|
|
197
|
+
const callRegex = new RegExp(`\\w+\\.${methodName}\\s*\\(`, "g");
|
|
198
|
+
let match;
|
|
199
|
+
const nodes = context.getNodesInFile(f);
|
|
200
|
+
while ((match = callRegex.exec(content)) !== null) {
|
|
201
|
+
const lineNum = content.slice(0, match.index).split("\n").length;
|
|
202
|
+
const enclosing = nodes.find(
|
|
203
|
+
(n) => (n.kind === "function" || n.kind === "method") && n.startLine <= lineNum && n.endLine >= lineNum
|
|
204
|
+
);
|
|
205
|
+
if (enclosing && !callSiteIds.includes(enclosing.id)) {
|
|
206
|
+
callSiteIds.push(enclosing.id);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return callSiteIds;
|
|
211
|
+
}
|
|
212
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
213
|
+
0 && (module.exports = {
|
|
214
|
+
turboModulesBridge
|
|
215
|
+
});
|
|
216
|
+
//# sourceMappingURL=turbomodules.js.map
|