fix(mobile): bound framework conventions to path segments (#1506)
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -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";
|
||||
};
|
||||
|
||||
@@ -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.",
|
||||
]),
|
||||
);
|
||||
|
||||
@@ -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.",
|
||||
];
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user