fix(mobile): bound framework conventions to path segments (#1506)

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
Thang Luu
2026-10-10 21:42:03 +08:00
committed by GitHub
co-authored by morluto
parent 8c47a9ce4b
commit a929c9f714
7 changed files with 163 additions and 7 deletions
+1 -1
View File
@@ -222,7 +222,7 @@ const bridgeBasis = (
if (convention === "react-native") return "react-native-convention";
if (convention === "flutter") return "flutter-convention";
if (convention === "unity") return "unity-convention";
if (/lib\/[^/]+\/lib[^/]+\.so$/u.test(path.toLowerCase()))
if (/(?:^|\/)lib\/[^/]+\/lib[^/]+\.so$/iu.test(path))
return "jni-library-convention";
return "managed-and-native-content";
};
+1 -1
View File
@@ -624,7 +624,7 @@ describe("Apple path conventions", () => {
).toBe(true);
expect(result.limitations).toEqual(
expect.arrayContaining([
"Runtime families are inferred from inventory formats and paths.",
"Runtime families are inferred from inventory formats and bounded framework path conventions, not observed runtime loading.",
"A bridge basis is inferred from the native path and is repeated for every managed component.",
]),
);
+2 -1
View File
@@ -431,7 +431,8 @@ const projectionLimitations = (facts: {
: []),
"Bundle roles follow path conventions. Read each info_plist_path with inspect_plist for CFBundleExecutable, identifiers, and declared services.",
"Bundle identifiers and signing claims require dedicated plist and CMS parsing; this projection reports only exact paths and hashes.",
"Runtime families are inferred from inventory formats and paths.",
"Runtime families are inferred from inventory formats and bounded framework path conventions, not observed runtime loading.",
"Generic framework and dylib paths do not establish Swift or Objective-C; this inventory projection does not decode language metadata.",
"Bridge candidates are path-based hypotheses, not observed runtime calls.",
"A bridge basis is inferred from the native path and is repeated for every managed component.",
];
+6 -3
View File
@@ -7,6 +7,10 @@ const foldSegment = (segment: string): string =>
const REACT_NATIVE_SEGMENTS = new Set([
"react.framework",
"reactnative.framework",
"libreactnative.so",
"libreactnativejni.so",
"libhermes_executor.so",
"libhermes.so",
"hermes.framework",
]);
@@ -15,15 +19,14 @@ const UNITY_SEGMENTS = new Set(["libunity.so", "unityframework.framework"]);
/**
* A runtime family named by one filename or directory segment.
* `reactnative` may occur inside a segment (`libreactnativejni.so`).
* The other names match the whole segment.
* Only recognized complete library and framework names establish a convention.
*/
export const nativeRuntimeConvention = (
path: string,
): NativeRuntimeConvention | null => {
for (const segment of path.split("/")) {
const folded = foldSegment(segment);
if (folded.includes("reactnative") || REACT_NATIVE_SEGMENTS.has(folded))
if (REACT_NATIVE_SEGMENTS.has(folded))
return "react-native";
if (FLUTTER_SEGMENTS.has(folded)) return "flutter";
if (UNITY_SEGMENTS.has(folded)) return "unity";