expo-modules-autolinking 2.1.1 → 2.1.3
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/CHANGELOG.md +11 -0
- package/android/expo-gradle-plugin/expo-autolinking-settings-plugin/src/main/kotlin/expo/modules/plugin/SettingsManager.kt +1 -1
- package/build/ExpoModuleConfig.js +2 -2
- package/build/ExpoModuleConfig.js.map +1 -1
- package/build/autolinking/findModules.js +1 -2
- package/build/autolinking/findModules.js.map +1 -1
- package/build/autolinking/generatePackageList.js +2 -3
- package/build/autolinking/generatePackageList.js.map +1 -1
- package/build/autolinking/getConfiguration.js +1 -2
- package/build/autolinking/getConfiguration.js.map +1 -1
- package/build/autolinking/index.js +3 -3
- package/build/autolinking/index.js.map +1 -1
- package/build/autolinking/mergeLinkingOptions.js +4 -5
- package/build/autolinking/mergeLinkingOptions.js.map +1 -1
- package/build/autolinking/resolveModules.js +2 -3
- package/build/autolinking/resolveModules.js.map +1 -1
- package/build/autolinking/utils.js +2 -3
- package/build/autolinking/utils.js.map +1 -1
- package/build/autolinking/verifySearchResults.js +1 -2
- package/build/autolinking/verifySearchResults.js.map +1 -1
- package/build/fileUtils.d.ts +0 -1
- package/build/fileUtils.js +3 -4
- package/build/fileUtils.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/platforms/android.d.ts +1 -0
- package/build/platforms/android.js +22 -13
- package/build/platforms/android.js.map +1 -1
- package/build/platforms/apple.js +5 -6
- package/build/platforms/apple.js.map +1 -1
- package/build/platforms/devtools.js +2 -3
- package/build/platforms/devtools.js.map +1 -1
- package/build/reactNativeConfig/androidResolver.d.ts +0 -1
- package/build/reactNativeConfig/androidResolver.js +7 -8
- package/build/reactNativeConfig/androidResolver.js.map +1 -1
- package/build/reactNativeConfig/config.js +1 -2
- package/build/reactNativeConfig/config.js.map +1 -1
- package/build/reactNativeConfig/iosResolver.js +1 -2
- package/build/reactNativeConfig/iosResolver.js.map +1 -1
- package/build/reactNativeConfig/reactNativeConfig.d.ts +1 -0
- package/build/reactNativeConfig/reactNativeConfig.js +36 -5
- package/build/reactNativeConfig/reactNativeConfig.js.map +1 -1
- package/package.json +3 -3
- package/src/platforms/android.ts +19 -4
- package/src/reactNativeConfig/reactNativeConfig.ts +45 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/reactNativeConfig/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/reactNativeConfig/config.ts"],"names":[],"mappings":";;;;;AAeA,0CAmCC;AAlDD,2DAA6B;AAC7B,gDAAwB;AACxB,8EAAoD;AACpD,gEAAuC;AAGvC,4CAA+C;AAE/C,IAAI,MAAM,GAAmD,SAAS,CAAC;AAEvE,MAAM,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC;AAElF;;GAEG;AACI,KAAK,UAAU,eAAe,CACnC,WAAmB;IAEnB,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;IACtE,IAAI,MAAM,IAAA,2BAAe,EAAC,YAAY,CAAC,EAAE,CAAC;QACxC,OAAO,aAAa,CAAC,YAAY,EAAE,MAAM,kBAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;IACtE,IAAI,MAAM,IAAA,2BAAe,EAAC,YAAY,CAAC,EAAE,CAAC;QACxC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,sBAAW,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YAC7D,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;aAAM,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,kBAAkB,GAAG,MAAM,EAAE,eAAe,CAAC,cAAc,EAAE;YACjE,eAAe,EAAE;gBACf,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ;gBAClC,gBAAgB,EAAE,MAAM,CAAC,oBAAoB,CAAC,QAAQ;gBACtD,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM;aACnC;SACF,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,kBAAkB,EAAE,UAAU,CAAC;QAElD,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,aAAa,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,QAAgB,EAAE,cAAsB;IAC7D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,6BAAiB,EAAC,cAAc,EAAE,QAAQ,EAAE;YACzD,YAAY,EAAE,CAAC,mBAAmB,CAAC;SACpC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,OAAO,IAAI,MAAM,IAAI,IAAI,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\nimport requireFromString from 'require-from-string';\nimport resolveFrom from 'resolve-from';\n\nimport type { RNConfigReactNativeConfig } from './reactNativeConfig.types';\nimport { fileExistsAsync } from '../fileUtils';\n\nlet tsMain: typeof import('typescript') | null | undefined = undefined;\n\nconst mockedNativeModules = path.join(__dirname, '..', '..', 'node_modules_mock');\n\n/**\n * Load the `react-native.config.js` or `react-native.config.ts` from the package.\n */\nexport async function loadConfigAsync<T extends RNConfigReactNativeConfig>(\n packageRoot: string\n): Promise<T | null> {\n const configJsPath = path.join(packageRoot, 'react-native.config.js');\n if (await fileExistsAsync(configJsPath)) {\n return requireConfig(configJsPath, await fs.readFile(configJsPath, 'utf8'));\n }\n\n const configTsPath = path.join(packageRoot, 'react-native.config.ts');\n if (await fileExistsAsync(configTsPath)) {\n if (tsMain === undefined) {\n const tsPath = resolveFrom.silent(packageRoot, 'typescript');\n if (tsPath) {\n tsMain = require(tsPath);\n }\n } else if (tsMain == null) {\n return null;\n }\n\n const configContents = await fs.readFile(configTsPath, 'utf8');\n const transpiledContents = tsMain?.transpileModule(configContents, {\n compilerOptions: {\n module: tsMain.ModuleKind.NodeNext,\n moduleResolution: tsMain.ModuleResolutionKind.NodeNext,\n target: tsMain.ScriptTarget.ESNext,\n },\n });\n const outputText = transpiledContents?.outputText;\n\n if (outputText) {\n return requireConfig(configTsPath, outputText);\n }\n }\n\n return null;\n}\n\n/**\n * Temporarily, we need to mock the community CLI, because\n * some packages are checking the version of the CLI in the `react-native.config.js` file.\n * We can remove this once we remove this check from packages.\n */\nfunction requireConfig(filepath: string, configContents: string) {\n try {\n const config = requireFromString(configContents, filepath, {\n prependPaths: [mockedNativeModules],\n });\n return config.default ?? config ?? null;\n } catch {\n return null;\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveDependencyConfigImplIosAsync =
|
|
6
|
+
exports.resolveDependencyConfigImplIosAsync = resolveDependencyConfigImplIosAsync;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const glob_1 = require("glob");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -27,5 +27,4 @@ async function resolveDependencyConfigImplIosAsync(packageRoot, reactNativeConfi
|
|
|
27
27
|
scriptPhases: reactNativeConfig?.scriptPhases || [],
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
exports.resolveDependencyConfigImplIosAsync = resolveDependencyConfigImplIosAsync;
|
|
31
30
|
//# sourceMappingURL=iosResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iosResolver.js","sourceRoot":"","sources":["../../src/reactNativeConfig/iosResolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"iosResolver.js","sourceRoot":"","sources":["../../src/reactNativeConfig/iosResolver.ts"],"names":[],"mappings":";;;;;AASA,kFAyBC;AAlCD,2DAA6B;AAC7B,+BAA4B;AAC5B,gDAAwB;AAOjB,KAAK,UAAU,mCAAmC,CACvD,WAAmB,EACnB,iBAA2E;IAE3E,IAAI,iBAAiB,KAAK,IAAI,EAAE,CAAC;QAC/B,qCAAqC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,IAAA,WAAI,EAAC,WAAW,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IAC/D,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,kBAAkB,GAAG,cAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,UAAU,CAAC;IACnE,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC7F,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAExD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,kBAAE,CAAC,QAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAElG,OAAO;QACL,WAAW;QACX,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,cAAc,EAAE,iBAAiB,EAAE,cAAc,IAAI,EAAE;QACvD,YAAY,EAAE,iBAAiB,EAAE,YAAY,IAAI,EAAE;KACpD,CAAC;AACJ,CAAC","sourcesContent":["import fs from 'fs/promises';\nimport { glob } from 'glob';\nimport path from 'path';\n\nimport type {\n RNConfigDependencyIos,\n RNConfigReactNativePlatformsConfigIos,\n} from './reactNativeConfig.types';\n\nexport async function resolveDependencyConfigImplIosAsync(\n packageRoot: string,\n reactNativeConfig: RNConfigReactNativePlatformsConfigIos | null | undefined\n): Promise<RNConfigDependencyIos | null> {\n if (reactNativeConfig === null) {\n // Skip autolinking for this package.\n return null;\n }\n\n const podspecs = await glob('*.podspec', { cwd: packageRoot });\n if (!podspecs?.length) {\n return null;\n }\n const mainPackagePodspec = path.basename(packageRoot) + '.podspec';\n const podspecFile = podspecs.includes(mainPackagePodspec) ? mainPackagePodspec : podspecs[0];\n const podspecPath = path.join(packageRoot, podspecFile);\n\n const packageJson = JSON.parse(await fs.readFile(path.join(packageRoot, 'package.json'), 'utf8'));\n\n return {\n podspecPath,\n version: packageJson.version,\n configurations: reactNativeConfig?.configurations || [],\n scriptPhases: reactNativeConfig?.scriptPhases || [],\n };\n}\n"]}
|
|
@@ -9,4 +9,5 @@ export declare function createReactNativeConfigAsync({ platform, projectRoot, se
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function findDependencyRootsAsync(projectRoot: string, searchPaths: string[]): Promise<Record<string, string>>;
|
|
11
11
|
export declare function resolveDependencyConfigAsync(platform: SupportedPlatform, name: string, packageRoot: string, projectConfig: RNConfigReactNativeProjectConfig | null): Promise<RNConfigDependency | null>;
|
|
12
|
+
export declare function resolveEdgeToEdgeDependencyRoot(projectRoot: string): string | null;
|
|
12
13
|
export declare function resolveAppProjectConfigAsync(projectRoot: string, platform: SupportedPlatform): Promise<RNConfigReactNativeAppProjectConfig>;
|
|
@@ -3,14 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createReactNativeConfigAsync = createReactNativeConfigAsync;
|
|
7
|
+
exports.findDependencyRootsAsync = findDependencyRootsAsync;
|
|
8
|
+
exports.resolveDependencyConfigAsync = resolveDependencyConfigAsync;
|
|
9
|
+
exports.resolveEdgeToEdgeDependencyRoot = resolveEdgeToEdgeDependencyRoot;
|
|
10
|
+
exports.resolveAppProjectConfigAsync = resolveAppProjectConfigAsync;
|
|
7
11
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
12
|
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
9
14
|
const utils_1 = require("../autolinking/utils");
|
|
10
15
|
const fileUtils_1 = require("../fileUtils");
|
|
11
16
|
const androidResolver_1 = require("./androidResolver");
|
|
12
17
|
const config_1 = require("./config");
|
|
13
18
|
const iosResolver_1 = require("./iosResolver");
|
|
19
|
+
const android_1 = require("../platforms/android");
|
|
20
|
+
const EDGE_TO_EDGE_ENABLED_GRADLE_PROPERTY_KEY = 'expo.edgeToEdgeEnabled';
|
|
14
21
|
/**
|
|
15
22
|
* Create config for react-native core autolinking.
|
|
16
23
|
*/
|
|
@@ -20,6 +27,20 @@ async function createReactNativeConfigAsync({ platform, projectRoot, searchPaths
|
|
|
20
27
|
...(await findDependencyRootsAsync(projectRoot, searchPaths)),
|
|
21
28
|
...findProjectLocalDependencyRoots(projectConfig),
|
|
22
29
|
};
|
|
30
|
+
// For Expo SDK 53 onwards, `react-native-edge-to-edge` is a transitive dependency of every expo project. Unless the user
|
|
31
|
+
// has also included it as a project dependency, we have to autolink it manually (transitive non-expo module dependencies are not autolinked).
|
|
32
|
+
// There are two reasons why we don't want to autolink `edge-to-edge` when `edgeToEdge` property is set to `false`:
|
|
33
|
+
// 1. `react-native-is-edge-to-edge` tries to check if the `edge-to-edge` turbomodule is present to determine whether edge-to-edge is enabled.
|
|
34
|
+
// 2. `react-native-edge-to-edge` applies edge-to-edge in `onHostResume` and has no property to disable this behavior.
|
|
35
|
+
const shouldAutolinkEdgeToEdge = platform === 'android' &&
|
|
36
|
+
(await resolveGradleEdgeToEdgeEnabled(projectRoot)) &&
|
|
37
|
+
!('react-native-edge-to-edge' in dependencyRoots);
|
|
38
|
+
if (shouldAutolinkEdgeToEdge) {
|
|
39
|
+
const edgeToEdgeRoot = resolveEdgeToEdgeDependencyRoot(projectRoot);
|
|
40
|
+
if (edgeToEdgeRoot) {
|
|
41
|
+
dependencyRoots['react-native-edge-to-edge'] = edgeToEdgeRoot;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
23
44
|
// NOTE(@kitten): If this isn't resolved to be the realpath and is a symlink,
|
|
24
45
|
// the Cocoapods resolution will detect path mismatches and generate nonsensical
|
|
25
46
|
// relative paths that won't resolve
|
|
@@ -43,7 +64,6 @@ async function createReactNativeConfigAsync({ platform, projectRoot, searchPaths
|
|
|
43
64
|
project: projectData,
|
|
44
65
|
};
|
|
45
66
|
}
|
|
46
|
-
exports.createReactNativeConfigAsync = createReactNativeConfigAsync;
|
|
47
67
|
/**
|
|
48
68
|
* Find all dependencies and their directories from the project.
|
|
49
69
|
*/
|
|
@@ -72,7 +92,6 @@ async function findDependencyRootsAsync(projectRoot, searchPaths) {
|
|
|
72
92
|
}
|
|
73
93
|
return results;
|
|
74
94
|
}
|
|
75
|
-
exports.findDependencyRootsAsync = findDependencyRootsAsync;
|
|
76
95
|
/**
|
|
77
96
|
* Find local dependencies that specified in the `react-native.config.js` file.
|
|
78
97
|
*/
|
|
@@ -123,7 +142,14 @@ async function resolveDependencyConfigAsync(platform, name, packageRoot, project
|
|
|
123
142
|
},
|
|
124
143
|
};
|
|
125
144
|
}
|
|
126
|
-
|
|
145
|
+
function resolveEdgeToEdgeDependencyRoot(projectRoot) {
|
|
146
|
+
const expoPackageRoot = resolve_from_1.default.silent(projectRoot, 'expo/package.json');
|
|
147
|
+
const edgeToEdgePath = resolve_from_1.default.silent(expoPackageRoot ?? projectRoot, 'react-native-edge-to-edge/package.json');
|
|
148
|
+
if (edgeToEdgePath) {
|
|
149
|
+
return path_1.default.dirname(edgeToEdgePath);
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
127
153
|
async function resolveAppProjectConfigAsync(projectRoot, platform) {
|
|
128
154
|
if (platform === 'android') {
|
|
129
155
|
const androidDir = path_1.default.join(projectRoot, 'android');
|
|
@@ -148,5 +174,10 @@ async function resolveAppProjectConfigAsync(projectRoot, platform) {
|
|
|
148
174
|
}
|
|
149
175
|
return {};
|
|
150
176
|
}
|
|
151
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Resolve the `expo.edgeToEdgeEnabled` property from the `gradle.properties` file.
|
|
179
|
+
*/
|
|
180
|
+
async function resolveGradleEdgeToEdgeEnabled(projectRoot) {
|
|
181
|
+
return ((await (0, android_1.resolveGradlePropertyAsync)(path_1.default.join(projectRoot, 'android'), EDGE_TO_EDGE_ENABLED_GRADLE_PROPERTY_KEY)) === 'true');
|
|
182
|
+
}
|
|
152
183
|
//# sourceMappingURL=reactNativeConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNativeConfig.js","sourceRoot":"","sources":["../../src/reactNativeConfig/reactNativeConfig.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAC7B,gDAAwB;AAExB,gDAA8D;AAC9D,4CAA+C;AAE/C,uDAI2B;AAC3B,qCAA2C;AAC3C,+CAAoE;AAUpE;;GAEG;AACI,KAAK,UAAU,4BAA4B,CAAC,EACjD,QAAQ,EACR,WAAW,EACX,WAAW,GACY;IACvB,MAAM,aAAa,GAAG,MA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AS,EAAE;YACT,CAAC,QAAQ,CAAC,EAAE,YAAY;SACzB;KACF,CAAC;AACJ,CAAC;AA9CD,oEA8CC;AAEM,KAAK,UAAU,4BAA4B,CAChD,WAAmB,EACnB,QAA2B;IAE3B,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACrD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,4CAA0B,EAAC,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAChG,IAAI,MAAM,IAAI,IAAI,IAAI,QAAQ,IAAI,IAAI,EAAE;YACtC,OAAO,EAAE,CAAC;SACX;QACD,MAAM,WAAW,GAAG,MAAM,IAAA,uCAAqB,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE9E,OAAO;YACL,OAAO,EAAE;gBACP,WAAW,EAAE,WAAW,IAAI,EAAE;gBAC9B,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;aAC7C;SACF,CAAC;KACH;IAED,IAAI,QAAQ,KAAK,KAAK,EAAE;QACtB,OAAO;YACL,GAAG,EAAE;gBACH,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;aACzC;SACF,CAAC;KACH;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AA7BD,oEA6BC","sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\n\nimport { getIsolatedModulesPath } from '../autolinking/utils';\nimport { fileExistsAsync } from '../fileUtils';\nimport type { SupportedPlatform } from '../types';\nimport {\n findGradleAndManifestAsync,\n parsePackageNameAsync,\n resolveDependencyConfigImplAndroidAsync,\n} from './androidResolver';\nimport { loadConfigAsync } from './config';\nimport { resolveDependencyConfigImplIosAsync } from './iosResolver';\nimport type {\n RNConfigCommandOptions,\n RNConfigDependency,\n RNConfigReactNativeAppProjectConfig,\n RNConfigReactNativeLibraryConfig,\n RNConfigReactNativeProjectConfig,\n RNConfigResult,\n} from './reactNativeConfig.types';\n\n/**\n * Create config for react-native core autolinking.\n */\nexport async function createReactNativeConfigAsync({\n platform,\n projectRoot,\n searchPaths,\n}: RNConfigCommandOptions): Promise<RNConfigResult> {\n const projectConfig = await loadConfigAsync<RNConfigReactNativeProjectConfig>(projectRoot);\n const dependencyRoots = {\n ...(await findDependencyRootsAsync(projectRoot, searchPaths)),\n ...findProjectLocalDependencyRoots(projectConfig),\n };\n\n // NOTE(@kitten): If this isn't resolved to be the realpath and is a symlink,\n // the Cocoapods resolution will detect path mismatches and generate nonsensical\n // relative paths that won't resolve\n let reactNativePath: string;\n try {\n reactNativePath = await fs.realpath(dependencyRoots['react-native']);\n } catch {\n reactNativePath = dependencyRoots['react-native'];\n }\n\n const dependencyConfigs = await Promise.all(\n Object.entries(dependencyRoots).map(async ([name, packageRoot]) => {\n const config = await resolveDependencyConfigAsync(platform, name, packageRoot, projectConfig);\n return [name, config];\n })\n );\n const dependencyResults = Object.fromEntries<RNConfigDependency>(\n dependencyConfigs.filter(([, config]) => config != null) as Iterable<\n [string, RNConfigDependency]\n >\n );\n const projectData = await resolveAppProjectConfigAsync(projectRoot, platform);\n return {\n root: projectRoot,\n reactNativePath,\n dependencies: dependencyResults,\n project: projectData,\n };\n}\n\n/**\n * Find all dependencies and their directories from the project.\n */\nexport async function findDependencyRootsAsync(\n projectRoot: string,\n searchPaths: string[]\n): Promise<Record<string, string>> {\n const packageJson = JSON.parse(await fs.readFile(path.join(projectRoot, 'package.json'), 'utf8'));\n const dependencies = [\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.devDependencies ?? {}),\n ];\n\n const results: Record<string, string> = {};\n // `searchPathSet` can be mutated to discover all \"isolated modules groups\", when using isolated modules\n const searchPathSet = new Set(searchPaths);\n\n for (const name of dependencies) {\n for (const searchPath of searchPathSet) {\n const packageConfigPath = path.resolve(searchPath, name, 'package.json');\n if (await fileExistsAsync(packageConfigPath)) {\n const packageRoot = path.dirname(packageConfigPath);\n results[name] = packageRoot;\n\n const maybeIsolatedModulesPath = getIsolatedModulesPath(packageRoot, name);\n if (maybeIsolatedModulesPath) {\n searchPathSet.add(maybeIsolatedModulesPath);\n }\n break;\n }\n }\n }\n\n return results;\n}\n\n/**\n * Find local dependencies that specified in the `react-native.config.js` file.\n */\nfunction findProjectLocalDependencyRoots(\n projectConfig: RNConfigReactNativeProjectConfig | null\n): Record<string, string> {\n if (!projectConfig?.dependencies) {\n return {};\n }\n const results: Record<string, string> = {};\n for (const [name, config] of Object.entries(projectConfig.dependencies)) {\n if (typeof config.root === 'string') {\n results[name] = config.root;\n }\n }\n return results;\n}\n\nexport async function resolveDependencyConfigAsync(\n platform: SupportedPlatform,\n name: string,\n packageRoot: string,\n projectConfig: RNConfigReactNativeProjectConfig | null\n): Promise<RNConfigDependency | null> {\n const libraryConfig = await loadConfigAsync<RNConfigReactNativeLibraryConfig>(packageRoot);\n const reactNativeConfig = {\n ...libraryConfig?.dependency,\n ...projectConfig?.dependencies?.[name],\n };\n\n if (Object.keys(libraryConfig?.platforms ?? {}).length > 0) {\n // Package defines platforms would be a platform host package.\n // The rnc-cli will skip this package.\n return null;\n }\n if (name === 'react-native' || name === 'react-native-macos') {\n // Starting from version 0.76, the `react-native` package only defines platforms\n // when @react-native-community/cli-platform-android/ios is installed.\n // Therefore, we need to manually filter it out.\n return null;\n }\n\n let platformData = null;\n if (platform === 'android') {\n platformData = await resolveDependencyConfigImplAndroidAsync(\n packageRoot,\n reactNativeConfig.platforms?.android\n );\n } else if (platform === 'ios') {\n platformData = await resolveDependencyConfigImplIosAsync(\n packageRoot,\n reactNativeConfig.platforms?.ios\n );\n }\n if (!platformData) {\n return null;\n }\n return {\n root: packageRoot,\n name,\n platforms: {\n [platform]: platformData,\n },\n };\n}\n\nexport async function resolveAppProjectConfigAsync(\n projectRoot: string,\n platform: SupportedPlatform\n): Promise<RNConfigReactNativeAppProjectConfig> {\n if (platform === 'android') {\n const androidDir = path.join(projectRoot, 'android');\n const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false });\n if (gradle == null || manifest == null) {\n return {};\n }\n const packageName = await parsePackageNameAsync(androidDir, manifest, gradle);\n\n return {\n android: {\n packageName: packageName ?? '',\n sourceDir: path.join(projectRoot, 'android'),\n },\n };\n }\n\n if (platform === 'ios') {\n return {\n ios: {\n sourceDir: path.join(projectRoot, 'ios'),\n },\n };\n }\n\n return {};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reactNativeConfig.js","sourceRoot":"","sources":["../../src/reactNativeConfig/reactNativeConfig.ts"],"names":[],"mappings":";;;;;AA6BA,oEAwDC;AAKD,4DA+BC;AAoBD,oEA8CC;AAED,0EAUC;AAED,oEA6BC;AAtOD,2DAA6B;AAC7B,gDAAwB;AACxB,gEAAuC;AAEvC,gDAA8D;AAC9D,4CAA+C;AAE/C,uDAI2B;AAC3B,qCAA2C;AAC3C,+CAAoE;AASpE,kDAAkE;AAElE,MAAM,wCAAwC,GAAG,wBAAwB,CAAC;AAE1E;;GAEG;AACI,KAAK,UAAU,4BAA4B,CAAC,EACjD,QAAQ,EACR,WAAW,EACX,WAAW,GACY;IACvB,MAAM,aAAa,GAAG,MAAM,IAAA,wBAAe,EAAmC,WAAW,CAAC,CAAC;IAC3F,MAAM,eAAe,GAAG;QACtB,GAAG,CAAC,MAAM,wBAAwB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC7D,GAAG,+BAA+B,CAAC,aAAa,CAAC;KAClD,CAAC;IAEF,yHAAyH;IACzH,8IAA8I;IAC9I,mHAAmH;IACnH,8IAA8I;IAC9I,sHAAsH;IACtH,MAAM,wBAAwB,GAC5B,QAAQ,KAAK,SAAS;QACtB,CAAC,MAAM,8BAA8B,CAAC,WAAW,CAAC,CAAC;QACnD,CAAC,CAAC,2BAA2B,IAAI,eAAe,CAAC,CAAC;IA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AAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO;YACL,GAAG,EAAE;gBACH,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;aACzC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,8BAA8B,CAAC,WAAmB;IAC/D,OAAO,CACL,CAAC,MAAM,IAAA,oCAA0B,EAC/B,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,EACjC,wCAAwC,CACzC,CAAC,KAAK,MAAM,CACd,CAAC;AACJ,CAAC","sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { getIsolatedModulesPath } from '../autolinking/utils';\nimport { fileExistsAsync } from '../fileUtils';\nimport type { SupportedPlatform } from '../types';\nimport {\n findGradleAndManifestAsync,\n parsePackageNameAsync,\n resolveDependencyConfigImplAndroidAsync,\n} from './androidResolver';\nimport { loadConfigAsync } from './config';\nimport { resolveDependencyConfigImplIosAsync } from './iosResolver';\nimport type {\n RNConfigCommandOptions,\n RNConfigDependency,\n RNConfigReactNativeAppProjectConfig,\n RNConfigReactNativeLibraryConfig,\n RNConfigReactNativeProjectConfig,\n RNConfigResult,\n} from './reactNativeConfig.types';\nimport { resolveGradlePropertyAsync } from '../platforms/android';\n\nconst EDGE_TO_EDGE_ENABLED_GRADLE_PROPERTY_KEY = 'expo.edgeToEdgeEnabled';\n\n/**\n * Create config for react-native core autolinking.\n */\nexport async function createReactNativeConfigAsync({\n platform,\n projectRoot,\n searchPaths,\n}: RNConfigCommandOptions): Promise<RNConfigResult> {\n const projectConfig = await loadConfigAsync<RNConfigReactNativeProjectConfig>(projectRoot);\n const dependencyRoots = {\n ...(await findDependencyRootsAsync(projectRoot, searchPaths)),\n ...findProjectLocalDependencyRoots(projectConfig),\n };\n\n // For Expo SDK 53 onwards, `react-native-edge-to-edge` is a transitive dependency of every expo project. Unless the user\n // has also included it as a project dependency, we have to autolink it manually (transitive non-expo module dependencies are not autolinked).\n // There are two reasons why we don't want to autolink `edge-to-edge` when `edgeToEdge` property is set to `false`:\n // 1. `react-native-is-edge-to-edge` tries to check if the `edge-to-edge` turbomodule is present to determine whether edge-to-edge is enabled.\n // 2. `react-native-edge-to-edge` applies edge-to-edge in `onHostResume` and has no property to disable this behavior.\n const shouldAutolinkEdgeToEdge =\n platform === 'android' &&\n (await resolveGradleEdgeToEdgeEnabled(projectRoot)) &&\n !('react-native-edge-to-edge' in dependencyRoots);\n\n if (shouldAutolinkEdgeToEdge) {\n const edgeToEdgeRoot = resolveEdgeToEdgeDependencyRoot(projectRoot);\n if (edgeToEdgeRoot) {\n dependencyRoots['react-native-edge-to-edge'] = edgeToEdgeRoot;\n }\n }\n\n // NOTE(@kitten): If this isn't resolved to be the realpath and is a symlink,\n // the Cocoapods resolution will detect path mismatches and generate nonsensical\n // relative paths that won't resolve\n let reactNativePath: string;\n try {\n reactNativePath = await fs.realpath(dependencyRoots['react-native']);\n } catch {\n reactNativePath = dependencyRoots['react-native'];\n }\n\n const dependencyConfigs = await Promise.all(\n Object.entries(dependencyRoots).map(async ([name, packageRoot]) => {\n const config = await resolveDependencyConfigAsync(platform, name, packageRoot, projectConfig);\n return [name, config];\n })\n );\n const dependencyResults = Object.fromEntries<RNConfigDependency>(\n dependencyConfigs.filter(([, config]) => config != null) as Iterable<\n [string, RNConfigDependency]\n >\n );\n const projectData = await resolveAppProjectConfigAsync(projectRoot, platform);\n return {\n root: projectRoot,\n reactNativePath,\n dependencies: dependencyResults,\n project: projectData,\n };\n}\n\n/**\n * Find all dependencies and their directories from the project.\n */\nexport async function findDependencyRootsAsync(\n projectRoot: string,\n searchPaths: string[]\n): Promise<Record<string, string>> {\n const packageJson = JSON.parse(await fs.readFile(path.join(projectRoot, 'package.json'), 'utf8'));\n const dependencies = [\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.devDependencies ?? {}),\n ];\n\n const results: Record<string, string> = {};\n // `searchPathSet` can be mutated to discover all \"isolated modules groups\", when using isolated modules\n const searchPathSet = new Set(searchPaths);\n\n for (const name of dependencies) {\n for (const searchPath of searchPathSet) {\n const packageConfigPath = path.resolve(searchPath, name, 'package.json');\n if (await fileExistsAsync(packageConfigPath)) {\n const packageRoot = path.dirname(packageConfigPath);\n results[name] = packageRoot;\n\n const maybeIsolatedModulesPath = getIsolatedModulesPath(packageRoot, name);\n if (maybeIsolatedModulesPath) {\n searchPathSet.add(maybeIsolatedModulesPath);\n }\n break;\n }\n }\n }\n\n return results;\n}\n\n/**\n * Find local dependencies that specified in the `react-native.config.js` file.\n */\nfunction findProjectLocalDependencyRoots(\n projectConfig: RNConfigReactNativeProjectConfig | null\n): Record<string, string> {\n if (!projectConfig?.dependencies) {\n return {};\n }\n const results: Record<string, string> = {};\n for (const [name, config] of Object.entries(projectConfig.dependencies)) {\n if (typeof config.root === 'string') {\n results[name] = config.root;\n }\n }\n return results;\n}\n\nexport async function resolveDependencyConfigAsync(\n platform: SupportedPlatform,\n name: string,\n packageRoot: string,\n projectConfig: RNConfigReactNativeProjectConfig | null\n): Promise<RNConfigDependency | null> {\n const libraryConfig = await loadConfigAsync<RNConfigReactNativeLibraryConfig>(packageRoot);\n const reactNativeConfig = {\n ...libraryConfig?.dependency,\n ...projectConfig?.dependencies?.[name],\n };\n\n if (Object.keys(libraryConfig?.platforms ?? {}).length > 0) {\n // Package defines platforms would be a platform host package.\n // The rnc-cli will skip this package.\n return null;\n }\n if (name === 'react-native' || name === 'react-native-macos') {\n // Starting from version 0.76, the `react-native` package only defines platforms\n // when @react-native-community/cli-platform-android/ios is installed.\n // Therefore, we need to manually filter it out.\n return null;\n }\n\n let platformData = null;\n if (platform === 'android') {\n platformData = await resolveDependencyConfigImplAndroidAsync(\n packageRoot,\n reactNativeConfig.platforms?.android\n );\n } else if (platform === 'ios') {\n platformData = await resolveDependencyConfigImplIosAsync(\n packageRoot,\n reactNativeConfig.platforms?.ios\n );\n }\n if (!platformData) {\n return null;\n }\n return {\n root: packageRoot,\n name,\n platforms: {\n [platform]: platformData,\n },\n };\n}\n\nexport function resolveEdgeToEdgeDependencyRoot(projectRoot: string): string | null {\n const expoPackageRoot = resolveFrom.silent(projectRoot, 'expo/package.json');\n const edgeToEdgePath = resolveFrom.silent(\n expoPackageRoot ?? projectRoot,\n 'react-native-edge-to-edge/package.json'\n );\n if (edgeToEdgePath) {\n return path.dirname(edgeToEdgePath);\n }\n return null;\n}\n\nexport async function resolveAppProjectConfigAsync(\n projectRoot: string,\n platform: SupportedPlatform\n): Promise<RNConfigReactNativeAppProjectConfig> {\n if (platform === 'android') {\n const androidDir = path.join(projectRoot, 'android');\n const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false });\n if (gradle == null || manifest == null) {\n return {};\n }\n const packageName = await parsePackageNameAsync(androidDir, manifest, gradle);\n\n return {\n android: {\n packageName: packageName ?? '',\n sourceDir: path.join(projectRoot, 'android'),\n },\n };\n }\n\n if (platform === 'ios') {\n return {\n ios: {\n sourceDir: path.join(projectRoot, 'ios'),\n },\n };\n }\n\n return {};\n}\n\n/**\n * Resolve the `expo.edgeToEdgeEnabled` property from the `gradle.properties` file.\n */\nasync function resolveGradleEdgeToEdgeEnabled(projectRoot: string): Promise<boolean> {\n return (\n (await resolveGradlePropertyAsync(\n path.join(projectRoot, 'android'),\n EDGE_TO_EDGE_ENABLED_GRADLE_PROPERTY_KEY\n )) === 'true'\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-autolinking",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Scripts that autolink Expo modules.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"homepage": "https://github.com/expo/expo/tree/main/packages/expo-modules-autolinking#readme",
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"expo-module-scripts": "~4.1.
|
|
37
|
+
"expo-module-scripts": "~4.1.1",
|
|
38
38
|
"minimatch": "^9.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"require-from-string": "^2.0.2",
|
|
47
47
|
"resolve-from": "^5.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "c81263062bf24ad09e51e019f1d7dc29fa651c55"
|
|
50
50
|
}
|
package/src/platforms/android.ts
CHANGED
|
@@ -124,13 +124,28 @@ export async function resolveModuleAsync(
|
|
|
124
124
|
export async function resolveExtraBuildDependenciesAsync(
|
|
125
125
|
projectNativeRoot: string
|
|
126
126
|
): Promise<ExtraDependencies | null> {
|
|
127
|
+
const extraMavenReposString = await resolveGradlePropertyAsync(
|
|
128
|
+
projectNativeRoot,
|
|
129
|
+
ANDROID_EXTRA_BUILD_DEPS_KEY
|
|
130
|
+
);
|
|
131
|
+
if (extraMavenReposString) {
|
|
132
|
+
try {
|
|
133
|
+
return JSON.parse(extraMavenReposString);
|
|
134
|
+
} catch {}
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export async function resolveGradlePropertyAsync(
|
|
140
|
+
projectNativeRoot: string,
|
|
141
|
+
propertyKey: string
|
|
142
|
+
): Promise<string | null> {
|
|
127
143
|
const propsFile = path.join(projectNativeRoot, ANDROID_PROPERTIES_FILE);
|
|
128
144
|
try {
|
|
129
145
|
const contents = await fs.promises.readFile(propsFile, 'utf8');
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
return extraMavenRepos;
|
|
146
|
+
const propertyValue = searchGradlePropertyFirst(contents, propertyKey);
|
|
147
|
+
if (propertyValue) {
|
|
148
|
+
return propertyValue;
|
|
134
149
|
}
|
|
135
150
|
} catch {}
|
|
136
151
|
return null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import resolveFrom from 'resolve-from';
|
|
3
4
|
|
|
4
5
|
import { getIsolatedModulesPath } from '../autolinking/utils';
|
|
5
6
|
import { fileExistsAsync } from '../fileUtils';
|
|
@@ -19,6 +20,9 @@ import type {
|
|
|
19
20
|
RNConfigReactNativeProjectConfig,
|
|
20
21
|
RNConfigResult,
|
|
21
22
|
} from './reactNativeConfig.types';
|
|
23
|
+
import { resolveGradlePropertyAsync } from '../platforms/android';
|
|
24
|
+
|
|
25
|
+
const EDGE_TO_EDGE_ENABLED_GRADLE_PROPERTY_KEY = 'expo.edgeToEdgeEnabled';
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
28
|
* Create config for react-native core autolinking.
|
|
@@ -34,6 +38,23 @@ export async function createReactNativeConfigAsync({
|
|
|
34
38
|
...findProjectLocalDependencyRoots(projectConfig),
|
|
35
39
|
};
|
|
36
40
|
|
|
41
|
+
// For Expo SDK 53 onwards, `react-native-edge-to-edge` is a transitive dependency of every expo project. Unless the user
|
|
42
|
+
// has also included it as a project dependency, we have to autolink it manually (transitive non-expo module dependencies are not autolinked).
|
|
43
|
+
// There are two reasons why we don't want to autolink `edge-to-edge` when `edgeToEdge` property is set to `false`:
|
|
44
|
+
// 1. `react-native-is-edge-to-edge` tries to check if the `edge-to-edge` turbomodule is present to determine whether edge-to-edge is enabled.
|
|
45
|
+
// 2. `react-native-edge-to-edge` applies edge-to-edge in `onHostResume` and has no property to disable this behavior.
|
|
46
|
+
const shouldAutolinkEdgeToEdge =
|
|
47
|
+
platform === 'android' &&
|
|
48
|
+
(await resolveGradleEdgeToEdgeEnabled(projectRoot)) &&
|
|
49
|
+
!('react-native-edge-to-edge' in dependencyRoots);
|
|
50
|
+
|
|
51
|
+
if (shouldAutolinkEdgeToEdge) {
|
|
52
|
+
const edgeToEdgeRoot = resolveEdgeToEdgeDependencyRoot(projectRoot);
|
|
53
|
+
if (edgeToEdgeRoot) {
|
|
54
|
+
dependencyRoots['react-native-edge-to-edge'] = edgeToEdgeRoot;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
// NOTE(@kitten): If this isn't resolved to be the realpath and is a symlink,
|
|
38
59
|
// the Cocoapods resolution will detect path mismatches and generate nonsensical
|
|
39
60
|
// relative paths that won't resolve
|
|
@@ -166,6 +187,18 @@ export async function resolveDependencyConfigAsync(
|
|
|
166
187
|
};
|
|
167
188
|
}
|
|
168
189
|
|
|
190
|
+
export function resolveEdgeToEdgeDependencyRoot(projectRoot: string): string | null {
|
|
191
|
+
const expoPackageRoot = resolveFrom.silent(projectRoot, 'expo/package.json');
|
|
192
|
+
const edgeToEdgePath = resolveFrom.silent(
|
|
193
|
+
expoPackageRoot ?? projectRoot,
|
|
194
|
+
'react-native-edge-to-edge/package.json'
|
|
195
|
+
);
|
|
196
|
+
if (edgeToEdgePath) {
|
|
197
|
+
return path.dirname(edgeToEdgePath);
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
|
|
169
202
|
export async function resolveAppProjectConfigAsync(
|
|
170
203
|
projectRoot: string,
|
|
171
204
|
platform: SupportedPlatform
|
|
@@ -196,3 +229,15 @@ export async function resolveAppProjectConfigAsync(
|
|
|
196
229
|
|
|
197
230
|
return {};
|
|
198
231
|
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Resolve the `expo.edgeToEdgeEnabled` property from the `gradle.properties` file.
|
|
235
|
+
*/
|
|
236
|
+
async function resolveGradleEdgeToEdgeEnabled(projectRoot: string): Promise<boolean> {
|
|
237
|
+
return (
|
|
238
|
+
(await resolveGradlePropertyAsync(
|
|
239
|
+
path.join(projectRoot, 'android'),
|
|
240
|
+
EDGE_TO_EDGE_ENABLED_GRADLE_PROPERTY_KEY
|
|
241
|
+
)) === 'true'
|
|
242
|
+
);
|
|
243
|
+
}
|