@callstack/react-native-brownfield 3.7.0 → 3.8.1

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/ReactBrownfield.podspec +1 -0
  3. package/ios/ExpoHostRuntime.swift +23 -5
  4. package/ios/ReactNativeBrownfield.swift +17 -0
  5. package/ios/ReactNativeHostRuntime.swift +10 -0
  6. package/ios/ReactNativeViewController.swift +58 -6
  7. package/lib/commonjs/expo-config-plugin/android/utils/androidManifest.js +2 -0
  8. package/lib/commonjs/expo-config-plugin/android/utils/androidManifest.js.map +1 -0
  9. package/lib/commonjs/expo-config-plugin/android/utils/constants.js +1 -1
  10. package/lib/commonjs/expo-config-plugin/android/utils/expo-updates.js +2 -0
  11. package/lib/commonjs/expo-config-plugin/android/utils/expo-updates.js.map +1 -0
  12. package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js +1 -1
  13. package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -1
  14. package/lib/commonjs/expo-config-plugin/android/withBrownfieldAndroid.js +1 -1
  15. package/lib/commonjs/expo-config-plugin/android/withBrownfieldAndroid.js.map +1 -1
  16. package/lib/commonjs/expo-config-plugin/expoUtils.js +1 -1
  17. package/lib/commonjs/expo-config-plugin/expoUtils.js.map +1 -1
  18. package/lib/commonjs/expo-config-plugin/ios/utils/expo-updates.js +2 -0
  19. package/lib/commonjs/expo-config-plugin/ios/utils/expo-updates.js.map +1 -0
  20. package/lib/commonjs/expo-config-plugin/ios/withBrownfieldIos.js +1 -1
  21. package/lib/commonjs/expo-config-plugin/ios/withBrownfieldIos.js.map +1 -1
  22. package/lib/commonjs/expo-config-plugin/ios/xcodeHelpers.js +1 -1
  23. package/lib/commonjs/expo-config-plugin/ios/xcodeHelpers.js.map +1 -1
  24. package/lib/commonjs/expo-config-plugin/template/android/AndroidManifest.xml +1 -1
  25. package/lib/commonjs/expo-config-plugin/template/android/ReactNativeHostManager.pre55.kt +6 -1
  26. package/lib/commonjs/expo-config-plugin/template/android/strings.xml +4 -0
  27. package/lib/commonjs/expo-config-plugin/template/ios/patchExpoPre55.sh +2 -0
  28. package/lib/module/expo-config-plugin/android/utils/androidManifest.js +2 -0
  29. package/lib/module/expo-config-plugin/android/utils/androidManifest.js.map +1 -0
  30. package/lib/module/expo-config-plugin/android/utils/constants.js +1 -1
  31. package/lib/module/expo-config-plugin/android/utils/expo-updates.js +2 -0
  32. package/lib/module/expo-config-plugin/android/utils/expo-updates.js.map +1 -0
  33. package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js +1 -1
  34. package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -1
  35. package/lib/module/expo-config-plugin/android/withBrownfieldAndroid.js +1 -1
  36. package/lib/module/expo-config-plugin/android/withBrownfieldAndroid.js.map +1 -1
  37. package/lib/module/expo-config-plugin/expoUtils.js +1 -1
  38. package/lib/module/expo-config-plugin/expoUtils.js.map +1 -1
  39. package/lib/module/expo-config-plugin/ios/utils/expo-updates.js +2 -0
  40. package/lib/module/expo-config-plugin/ios/utils/expo-updates.js.map +1 -0
  41. package/lib/module/expo-config-plugin/ios/withBrownfieldIos.js +1 -1
  42. package/lib/module/expo-config-plugin/ios/withBrownfieldIos.js.map +1 -1
  43. package/lib/module/expo-config-plugin/ios/xcodeHelpers.js +1 -1
  44. package/lib/module/expo-config-plugin/ios/xcodeHelpers.js.map +1 -1
  45. package/lib/module/expo-config-plugin/template/android/AndroidManifest.xml +1 -1
  46. package/lib/module/expo-config-plugin/template/android/ReactNativeHostManager.pre55.kt +6 -1
  47. package/lib/module/expo-config-plugin/template/android/strings.xml +4 -0
  48. package/lib/module/expo-config-plugin/template/ios/patchExpoPre55.sh +2 -0
  49. package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/androidManifest.d.ts +13 -0
  50. package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/androidManifest.d.ts.map +1 -0
  51. package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
  52. package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/expo-updates.d.ts +12 -0
  53. package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/expo-updates.d.ts.map +1 -0
  54. package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts +20 -1
  55. package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
  56. package/lib/typescript/commonjs/src/expo-config-plugin/android/withBrownfieldAndroid.d.ts.map +1 -1
  57. package/lib/typescript/commonjs/src/expo-config-plugin/expoUtils.d.ts +1 -0
  58. package/lib/typescript/commonjs/src/expo-config-plugin/expoUtils.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/src/expo-config-plugin/ios/utils/expo-updates.d.ts +30 -0
  60. package/lib/typescript/commonjs/src/expo-config-plugin/ios/utils/expo-updates.d.ts.map +1 -0
  61. package/lib/typescript/commonjs/src/expo-config-plugin/ios/withBrownfieldIos.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/src/expo-config-plugin/ios/xcodeHelpers.d.ts +29 -0
  63. package/lib/typescript/commonjs/src/expo-config-plugin/ios/xcodeHelpers.d.ts.map +1 -1
  64. package/lib/typescript/module/src/expo-config-plugin/android/utils/androidManifest.d.ts +13 -0
  65. package/lib/typescript/module/src/expo-config-plugin/android/utils/androidManifest.d.ts.map +1 -0
  66. package/lib/typescript/module/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
  67. package/lib/typescript/module/src/expo-config-plugin/android/utils/expo-updates.d.ts +12 -0
  68. package/lib/typescript/module/src/expo-config-plugin/android/utils/expo-updates.d.ts.map +1 -0
  69. package/lib/typescript/module/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts +20 -1
  70. package/lib/typescript/module/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
  71. package/lib/typescript/module/src/expo-config-plugin/android/withBrownfieldAndroid.d.ts.map +1 -1
  72. package/lib/typescript/module/src/expo-config-plugin/expoUtils.d.ts +1 -0
  73. package/lib/typescript/module/src/expo-config-plugin/expoUtils.d.ts.map +1 -1
  74. package/lib/typescript/module/src/expo-config-plugin/ios/utils/expo-updates.d.ts +30 -0
  75. package/lib/typescript/module/src/expo-config-plugin/ios/utils/expo-updates.d.ts.map +1 -0
  76. package/lib/typescript/module/src/expo-config-plugin/ios/withBrownfieldIos.d.ts.map +1 -1
  77. package/lib/typescript/module/src/expo-config-plugin/ios/xcodeHelpers.d.ts +29 -0
  78. package/lib/typescript/module/src/expo-config-plugin/ios/xcodeHelpers.d.ts.map +1 -1
  79. package/package.json +2 -2
  80. package/src/expo-config-plugin/android/utils/androidManifest.ts +131 -0
  81. package/src/expo-config-plugin/android/utils/constants.ts +1 -1
  82. package/src/expo-config-plugin/android/utils/expo-updates.ts +106 -0
  83. package/src/expo-config-plugin/android/withAndroidModuleFiles.ts +122 -8
  84. package/src/expo-config-plugin/android/withBrownfieldAndroid.ts +18 -1
  85. package/src/expo-config-plugin/expoUtils.ts +14 -0
  86. package/src/expo-config-plugin/ios/utils/expo-updates.ts +168 -0
  87. package/src/expo-config-plugin/ios/withBrownfieldIos.ts +13 -1
  88. package/src/expo-config-plugin/ios/xcodeHelpers.ts +217 -4
  89. package/src/expo-config-plugin/template/android/AndroidManifest.xml +1 -1
  90. package/src/expo-config-plugin/template/android/ReactNativeHostManager.pre55.kt +6 -1
  91. package/src/expo-config-plugin/template/android/strings.xml +4 -0
  92. package/src/expo-config-plugin/template/ios/patchExpoPre55.sh +2 -0
@@ -0,0 +1,30 @@
1
+ import type { XcodeProject } from '@expo/config-plugins';
2
+ type PbxFileReference = {
3
+ [key: string]: unknown;
4
+ name?: string;
5
+ path?: string;
6
+ };
7
+ type PbxGroupLike = {
8
+ [key: string]: unknown;
9
+ name?: string;
10
+ path?: string;
11
+ children?: Array<{
12
+ value?: string;
13
+ comment?: string;
14
+ } | string>;
15
+ };
16
+ /**
17
+ * Selects an existing PBXFileReference for the app-level Expo plist.
18
+ *
19
+ * Matches either:
20
+ * - a file reference whose own path is `Supporting/Expo.plist`
21
+ * - or an `Expo.plist` file reference that lives under a `Supporting` PBXGroup
22
+ */
23
+ export declare function selectExpoPlistFileReference(fileReferences: Record<string, PbxFileReference | string>, groups?: Record<string, PbxGroupLike | string>): string | null;
24
+ /**
25
+ * Ensures the framework target contains the app-level `Supporting/Expo.plist`
26
+ * in a `PBXResourcesBuildPhase`. This is idempotent and safe to call repeatedly.
27
+ */
28
+ export declare function ensureFrameworkHasExpoPlistResource(project: XcodeProject, frameworkTargetUUID: string): void;
29
+ export {};
30
+ //# sourceMappingURL=expo-updates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expo-updates.d.ts","sourceRoot":"","sources":["../../../../../../../src/expo-config-plugin/ios/utils/expo-updates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMzD,KAAK,gBAAgB,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,CAAC;CACjE,CAAC;AA0EF;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC,EACzD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,GAC7C,MAAM,GAAG,IAAI,CAYf;AAwBD;;;GAGG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,YAAY,EACrB,mBAAmB,EAAE,MAAM,GAC1B,IAAI,CAuBN"}
@@ -1 +1 @@
1
- {"version":3,"file":"withBrownfieldIos.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/ios/withBrownfieldIos.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAU9B,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,UAAU,CAAC;AAItE;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAC1C,qCAAqC,CA+DtC,CAAC"}
1
+ {"version":3,"file":"withBrownfieldIos.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/ios/withBrownfieldIos.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,UAAU,CAAC;AAItE;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAC1C,qCAAqC,CA0EtC,CAAC"}
@@ -11,6 +11,34 @@ export declare function addFrameworkTarget(project: XcodeProject, modRequest: Mo
11
11
  targetAlreadyExists: boolean;
12
12
  };
13
13
  export declare function addSourceFilesBuildPhase(project: XcodeProject, frameworkTargetUUID: string, options: ResolvedBrownfieldPluginIosConfig): void;
14
+ export type PbxReferenceLike = {
15
+ value?: string;
16
+ comment?: string;
17
+ } | string;
18
+ export type PbxNativeTarget = {
19
+ buildPhases?: PbxReferenceLike[];
20
+ name?: string;
21
+ };
22
+ export type PbxResourcesBuildPhase = {
23
+ isa: 'PBXResourcesBuildPhase';
24
+ buildActionMask: number;
25
+ files?: PbxReferenceLike[];
26
+ runOnlyForDeploymentPostprocessing: number;
27
+ };
28
+ export type PbxBuildFile = {
29
+ isa: 'PBXBuildFile';
30
+ fileRef: string;
31
+ };
32
+ export type PbxCommentedReference = {
33
+ value: string;
34
+ comment: string;
35
+ };
36
+ export declare function createPbxCommentedReference(value: string, comment: string): PbxCommentedReference;
37
+ type ResourcesBuildPhaseOptions = {
38
+ resourcesBuildPhaseComment: string;
39
+ buildFileComment: string;
40
+ };
41
+ export declare function ensureTargetHasFileReferenceInResourcesBuildPhase(project: XcodeProject, frameworkTargetUUID: string, fileRefUuid: string, { resourcesBuildPhaseComment, buildFileComment }: ResourcesBuildPhaseOptions): boolean;
14
42
  /**
15
43
  * Finds the "Bundle React Native code and images" build phase from the main app target
16
44
  * and adds it to the framework target's build phases
@@ -30,4 +58,5 @@ export declare function addExpoPre55ShellPatchScriptPhase(modRequest: ModProps<X
30
58
  * @returns True if the build phases were modified, false otherwise
31
59
  */
32
60
  export declare function ensureExpoPre55ShellPatchScriptPhaseIsOrdered(project: XcodeProject, frameworkTargetUUID: string): boolean;
61
+ export {};
33
62
  //# sourceMappingURL=xcodeHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xcodeHelpers.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/ios/xcodeHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,YAAY,EAElB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAKlE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC,EAClC,OAAO,EAAE,iCAAiC,GACzC;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAoIA;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,YAAY,EACrB,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,iCAAiC,QAkB3C;AA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
+ name: string;
3
+ value: string;
4
+ };
5
+ export type AndroidStringResourceEntry = {
6
+ name: string;
7
+ value: string;
8
+ };
9
+ export declare function extractApplicationMetaData(manifestContent: string): AndroidManifestMetaDataEntry[];
10
+ export declare function extractStringResourcesFromXml(stringsContent: string, resourceNames: string[]): AndroidStringResourceEntry[];
11
+ export declare function renderLibraryManifestApplication(metaDataEntries: AndroidManifestMetaDataEntry[]): string;
12
+ export declare function renderLibraryStringResources(stringResources: AndroidStringResourceEntry[]): string;
13
+ //# sourceMappingURL=androidManifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"androidManifest.d.ts","sourceRoot":"","sources":["../../../../../../../src/expo-config-plugin/android/utils/androidManifest.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAOF,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,GACtB,4BAA4B,EAAE,CAahC;AAED,wBAAgB,6BAA6B,CAC3C,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EAAE,GACtB,0BAA0B,EAAE,CAW9B;AAED,wBAAgB,gCAAgC,CAC9C,eAAe,EAAE,4BAA4B,EAAE,GAC9C,MAAM,CAaR;AAED,wBAAgB,4BAA4B,CAC1C,eAAe,EAAE,0BAA0B,EAAE,GAC5C,MAAM,CAQR"}
@@ -1,3 +1,3 @@
1
- export declare const BROWNFIELD_PLUGIN_VERSION = "1.0.2";
2
- export declare const brownfieldGradlePluginDependency = "classpath(\"com.callstack.react:brownfield-gradle-plugin:1.0.2\")";
1
+ export declare const BROWNFIELD_PLUGIN_VERSION = "1.1.0";
2
+ export declare const brownfieldGradlePluginDependency = "classpath(\"com.callstack.react:brownfield-gradle-plugin:1.1.0\")";
3
3
  //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { type AndroidManifestMetaDataEntry, type AndroidStringResourceEntry } from './androidManifest';
2
+ /**
3
+ * This copies values from the app's finalized Android files while running
4
+ * inside `withDangerousMod` / `withFinalizedMod`. In that phase, the stable
5
+ * cross-plugin input is the on-disk XML after Expo and other config plugins have
6
+ * finished mutating it, so extraction intentionally uses raw file
7
+ * contents as the source of truth.
8
+ */
9
+ export declare function readExpoUpdatesApplicationMetaData(androidDir: string, appModuleName: string): AndroidManifestMetaDataEntry[];
10
+ export declare function extractExpoUpdatesApplicationMetaData(manifestContent: string): AndroidManifestMetaDataEntry[];
11
+ export declare function readExpoUpdatesStringResources(androidDir: string, appModuleName: string, metaDataEntries: AndroidManifestMetaDataEntry[]): AndroidStringResourceEntry[];
12
+ //# sourceMappingURL=expo-updates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expo-updates.d.ts","sourceRoot":"","sources":["../../../../../../../src/expo-config-plugin/android/utils/expo-updates.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAGhC,MAAM,mBAAmB,CAAC;AAa3B;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,4BAA4B,EAAE,CAiBhC;AAED,wBAAgB,qCAAqC,CACnD,eAAe,EAAE,MAAM,GACtB,4BAA4B,EAAE,CAIhC;AAED,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,4BAA4B,EAAE,GAC9C,0BAA0B,EAAE,CAwB9B"}
@@ -1,9 +1,14 @@
1
1
  import { type ConfigPlugin } from '@expo/config-plugins';
2
2
  import type { ResolvedBrownfieldPluginConfigWithAndroid } from '../types';
3
+ import { type AndroidManifestMetaDataEntry, type AndroidStringResourceEntry } from './utils/androidManifest';
3
4
  /**
4
5
  * Creates the Android library module directory structure and files
5
6
  */
6
- export declare function createAndroidModule({ androidDir, config, rnVersion, isExpoPre55, }: {
7
+ export declare function createAndroidModule({ androidDir, config, rnVersion, isExpoPre55, projectRoot, }: {
8
+ /**
9
+ * Expo app root (used to detect optional dependencies such as expo-updates)
10
+ */
11
+ projectRoot?: string;
7
12
  /**
8
13
  * Whether the Expo project is pre-55
9
14
  */
@@ -21,6 +26,20 @@ export declare function createAndroidModule({ androidDir, config, rnVersion, isE
21
26
  */
22
27
  config: ResolvedBrownfieldPluginConfigWithAndroid;
23
28
  }): void;
29
+ export declare function syncAndroidModuleManifest({ androidDir, config, expoUpdatesMetaData, }: {
30
+ androidDir: string;
31
+ config: ResolvedBrownfieldPluginConfigWithAndroid;
32
+ expoUpdatesMetaData: AndroidManifestMetaDataEntry[];
33
+ }): void;
34
+ export declare function syncAndroidModuleStringResources({ androidDir, config, expoUpdatesStringResources, }: {
35
+ androidDir: string;
36
+ config: ResolvedBrownfieldPluginConfigWithAndroid;
37
+ expoUpdatesStringResources: AndroidStringResourceEntry[];
38
+ }): void;
39
+ export declare function syncAndroidModuleExpoUpdatesFromAppFiles({ androidDir, config, }: {
40
+ androidDir: string;
41
+ config: ResolvedBrownfieldPluginConfigWithAndroid;
42
+ }): void;
24
43
  /**
25
44
  * Dangerous mod that creates the Android module directory and files
26
45
  */
@@ -1 +1 @@
1
- {"version":3,"file":"withAndroidModuleFiles.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/android/withAndroidModuleFiles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,KAAK,EAEV,yCAAyC,EAC1C,MAAM,UAAU,CAAC;AAMlB;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,MAAM,EACN,SAAS,EACT,WAAW,GACZ,EAAE;IACD;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,yCAAyC,CAAC;CACnD,GAAG,IAAI,CA0EP;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAAY,CAC/C,yCAAyC,CAuC1C,CAAC"}
1
+ {"version":3,"file":"withAndroidModuleFiles.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/android/withAndroidModuleFiles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,KAAK,EAEV,yCAAyC,EAC1C,MAAM,UAAU,CAAC;AAIlB,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAGhC,MAAM,yBAAyB,CAAC;AAOjC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,MAAM,EACN,SAAS,EACT,WAAW,EACX,WAAW,GACZ,EAAE;IACD;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,EAAE,yCAAyC,CAAC;CACnD,GAAG,IAAI,CAsFP;AAED,wBAAgB,yBAAyB,CAAC,EACxC,UAAU,EACV,MAAM,EACN,mBAAmB,GACpB,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,yCAAyC,CAAC;IAClD,mBAAmB,EAAE,4BAA4B,EAAE,CAAC;CACrD,GAAG,IAAI,CASP;AAED,wBAAgB,gCAAgC,CAAC,EAC/C,UAAU,EACV,MAAM,EACN,0BAA0B,GAC3B,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,yCAAyC,CAAC;IAClD,0BAA0B,EAAE,0BAA0B,EAAE,CAAC;CAC1D,GAAG,IAAI,CAUP;AAkBD,wBAAgB,wCAAwC,CAAC,EACvD,UAAU,EACV,MAAM,GACP,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,yCAAyC,CAAC;CACnD,GAAG,IAAI,CAsBP;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAAY,CAC/C,yCAAyC,CAwC1C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"withBrownfieldAndroid.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/android/withBrownfieldAndroid.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,UAAU,CAAC;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAAY,CAC9C,yCAAyC,CA2B1C,CAAC"}
1
+ {"version":3,"file":"withBrownfieldAndroid.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/android/withBrownfieldAndroid.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAU9B,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,UAAU,CAAC;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAAY,CAC9C,yCAAyC,CAwC1C,CAAC"}
@@ -3,4 +3,5 @@ export declare function getExpoInfo(config: ExpoConfig): {
3
3
  expoMajor: number;
4
4
  isExpoPre55: boolean;
5
5
  };
6
+ export declare function hasExpoUpdatesInstalled(projectRoot: string | undefined): boolean;
6
7
  //# sourceMappingURL=expoUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"expoUtils.d.ts","sourceRoot":"","sources":["../../../../../src/expo-config-plugin/expoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU;;;EAS7C"}
1
+ {"version":3,"file":"expoUtils.d.ts","sourceRoot":"","sources":["../../../../../src/expo-config-plugin/expoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU;;;EAS7C;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,OAAO,CAUT"}
@@ -0,0 +1,30 @@
1
+ import type { XcodeProject } from '@expo/config-plugins';
2
+ type PbxFileReference = {
3
+ [key: string]: unknown;
4
+ name?: string;
5
+ path?: string;
6
+ };
7
+ type PbxGroupLike = {
8
+ [key: string]: unknown;
9
+ name?: string;
10
+ path?: string;
11
+ children?: Array<{
12
+ value?: string;
13
+ comment?: string;
14
+ } | string>;
15
+ };
16
+ /**
17
+ * Selects an existing PBXFileReference for the app-level Expo plist.
18
+ *
19
+ * Matches either:
20
+ * - a file reference whose own path is `Supporting/Expo.plist`
21
+ * - or an `Expo.plist` file reference that lives under a `Supporting` PBXGroup
22
+ */
23
+ export declare function selectExpoPlistFileReference(fileReferences: Record<string, PbxFileReference | string>, groups?: Record<string, PbxGroupLike | string>): string | null;
24
+ /**
25
+ * Ensures the framework target contains the app-level `Supporting/Expo.plist`
26
+ * in a `PBXResourcesBuildPhase`. This is idempotent and safe to call repeatedly.
27
+ */
28
+ export declare function ensureFrameworkHasExpoPlistResource(project: XcodeProject, frameworkTargetUUID: string): void;
29
+ export {};
30
+ //# sourceMappingURL=expo-updates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expo-updates.d.ts","sourceRoot":"","sources":["../../../../../../../src/expo-config-plugin/ios/utils/expo-updates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMzD,KAAK,gBAAgB,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,CAAC;CACjE,CAAC;AA0EF;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC,EACzD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,GAC7C,MAAM,GAAG,IAAI,CAYf;AAwBD;;;GAGG;AACH,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,YAAY,EACrB,mBAAmB,EAAE,MAAM,GAC1B,IAAI,CAuBN"}
@@ -1 +1 @@
1
- {"version":3,"file":"withBrownfieldIos.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/ios/withBrownfieldIos.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAU9B,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,UAAU,CAAC;AAItE;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAC1C,qCAAqC,CA+DtC,CAAC"}
1
+ {"version":3,"file":"withBrownfieldIos.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/ios/withBrownfieldIos.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,UAAU,CAAC;AAItE;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAC1C,qCAAqC,CA0EtC,CAAC"}
@@ -11,6 +11,34 @@ export declare function addFrameworkTarget(project: XcodeProject, modRequest: Mo
11
11
  targetAlreadyExists: boolean;
12
12
  };
13
13
  export declare function addSourceFilesBuildPhase(project: XcodeProject, frameworkTargetUUID: string, options: ResolvedBrownfieldPluginIosConfig): void;
14
+ export type PbxReferenceLike = {
15
+ value?: string;
16
+ comment?: string;
17
+ } | string;
18
+ export type PbxNativeTarget = {
19
+ buildPhases?: PbxReferenceLike[];
20
+ name?: string;
21
+ };
22
+ export type PbxResourcesBuildPhase = {
23
+ isa: 'PBXResourcesBuildPhase';
24
+ buildActionMask: number;
25
+ files?: PbxReferenceLike[];
26
+ runOnlyForDeploymentPostprocessing: number;
27
+ };
28
+ export type PbxBuildFile = {
29
+ isa: 'PBXBuildFile';
30
+ fileRef: string;
31
+ };
32
+ export type PbxCommentedReference = {
33
+ value: string;
34
+ comment: string;
35
+ };
36
+ export declare function createPbxCommentedReference(value: string, comment: string): PbxCommentedReference;
37
+ type ResourcesBuildPhaseOptions = {
38
+ resourcesBuildPhaseComment: string;
39
+ buildFileComment: string;
40
+ };
41
+ export declare function ensureTargetHasFileReferenceInResourcesBuildPhase(project: XcodeProject, frameworkTargetUUID: string, fileRefUuid: string, { resourcesBuildPhaseComment, buildFileComment }: ResourcesBuildPhaseOptions): boolean;
14
42
  /**
15
43
  * Finds the "Bundle React Native code and images" build phase from the main app target
16
44
  * and adds it to the framework target's build phases
@@ -30,4 +58,5 @@ export declare function addExpoPre55ShellPatchScriptPhase(modRequest: ModProps<X
30
58
  * @returns True if the build phases were modified, false otherwise
31
59
  */
32
60
  export declare function ensureExpoPre55ShellPatchScriptPhaseIsOrdered(project: XcodeProject, frameworkTargetUUID: string): boolean;
61
+ export {};
33
62
  //# sourceMappingURL=xcodeHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xcodeHelpers.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/ios/xcodeHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,YAAY,EAElB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAKlE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC,EAClC,OAAO,EAAE,iCAAiC,GACzC;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAoIA;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,YAAY,EACrB,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,iCAAiC,QAkB3C;AAgDD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,GACjB,IAAI,CAmDN;AA4DD,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC,EAClC,OAAO,EAAE,YAAY,EACrB,EACE,aAAa,EACb,mBAAmB,GACpB,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,QA2BF;AAED;;;;;;GAMG;AACH,wBAAgB,6CAA6C,CAC3D,OAAO,EAAE,YAAY,EACrB,mBAAmB,EAAE,MAAM,WAmC5B"}
1
+ {"version":3,"file":"xcodeHelpers.d.ts","sourceRoot":"","sources":["../../../../../../src/expo-config-plugin/ios/xcodeHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,YAAY,EAElB,MAAM,sBAAsB,CAAC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EF,wBAAgB,iDAAiD,CAC/D,OAAO,EAAE,YAAY,EACrB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,MAAM,EACnB,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,EAAE,0BAA0B,GAC3E,OAAO,CAwBT;AAgDD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,MAAM,GACjB,IAAI,CAkDN;AA4DD,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC,EAClC,OAAO,EAAE,YAAY,EACrB,EACE,aAAa,EACb,mBAAmB,GACpB,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,QA2BF;AAED;;;;;;GAMG;AACH,wBAAgB,6CAA6C,CAC3D,OAAO,EAAE,YAAY,EACrB,mBAAmB,EAAE,MAAM,WAmC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@callstack/react-native-brownfield",
3
- "version": "3.7.0",
3
+ "version": "3.8.1",
4
4
  "license": "MIT",
5
5
  "author": "Michal Chudziak <mike.chudziak@callstack.com>",
6
6
  "bin": {
@@ -86,7 +86,7 @@
86
86
  "@expo/config-plugins": "^54.0.4"
87
87
  },
88
88
  "dependencies": {
89
- "@callstack/brownfield-cli": "^3.7.0"
89
+ "@callstack/brownfield-cli": "^3.8.1"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@babel/core": "^7.25.2",
@@ -0,0 +1,131 @@
1
+ export type AndroidManifestMetaDataEntry = {
2
+ name: string;
3
+ value: string;
4
+ };
5
+
6
+ export type AndroidStringResourceEntry = {
7
+ name: string;
8
+ value: string;
9
+ };
10
+
11
+ const APPLICATION_BLOCK_REGEX = /<application\b[\s\S]*?<\/application>/;
12
+ const META_DATA_TAG_REGEX =
13
+ /<meta-data\b[\s\S]*?(?:\/>|>[\s\S]*?<\/meta-data>)/g;
14
+ const STRING_TAG_REGEX = /<string\b[\s\S]*?>[\s\S]*?<\/string>/g;
15
+
16
+ export function extractApplicationMetaData(
17
+ manifestContent: string
18
+ ): AndroidManifestMetaDataEntry[] {
19
+ const applicationBlock = manifestContent.match(APPLICATION_BLOCK_REGEX)?.[0];
20
+
21
+ if (!applicationBlock) {
22
+ return [];
23
+ }
24
+
25
+ return (applicationBlock.match(META_DATA_TAG_REGEX) ?? [])
26
+ .map(parseMetaDataTag)
27
+ .filter(
28
+ (metaDataEntry): metaDataEntry is AndroidManifestMetaDataEntry =>
29
+ metaDataEntry !== null
30
+ );
31
+ }
32
+
33
+ export function extractStringResourcesFromXml(
34
+ stringsContent: string,
35
+ resourceNames: string[]
36
+ ): AndroidStringResourceEntry[] {
37
+ if (resourceNames.length === 0) {
38
+ return [];
39
+ }
40
+
41
+ return resourceNames
42
+ .map((name) => extractStringResource(stringsContent, name))
43
+ .filter(
44
+ (stringResource): stringResource is AndroidStringResourceEntry =>
45
+ stringResource !== null
46
+ );
47
+ }
48
+
49
+ export function renderLibraryManifestApplication(
50
+ metaDataEntries: AndroidManifestMetaDataEntry[]
51
+ ): string {
52
+ if (metaDataEntries.length === 0) {
53
+ return '';
54
+ }
55
+
56
+ const renderedMetaDataEntries = metaDataEntries
57
+ .map(
58
+ ({ name, value }) =>
59
+ ` <meta-data android:name="${name}" android:value="${value}" />`
60
+ )
61
+ .join('\n');
62
+
63
+ return ` <application>\n${renderedMetaDataEntries}\n </application>`;
64
+ }
65
+
66
+ export function renderLibraryStringResources(
67
+ stringResources: AndroidStringResourceEntry[]
68
+ ): string {
69
+ if (stringResources.length === 0) {
70
+ return '';
71
+ }
72
+
73
+ return stringResources
74
+ .map(({ name, value }) => ` <string name="${name}">${value}</string>`)
75
+ .join('\n');
76
+ }
77
+
78
+ function parseMetaDataTag(
79
+ metaDataTag: string
80
+ ): AndroidManifestMetaDataEntry | null {
81
+ const name = getAndroidAttribute(metaDataTag, 'name');
82
+ const value = getAndroidAttribute(metaDataTag, 'value');
83
+
84
+ return parseMetaDataAttributes(name, value);
85
+ }
86
+
87
+ function parseMetaDataAttributes(
88
+ name: string | undefined,
89
+ value: string | undefined
90
+ ): AndroidManifestMetaDataEntry | null {
91
+ if (name === undefined || value === undefined) {
92
+ return null;
93
+ }
94
+ return { name, value };
95
+ }
96
+
97
+ function extractStringResource(
98
+ stringsContent: string,
99
+ resourceName: string
100
+ ): AndroidStringResourceEntry | null {
101
+ const stringTag = (stringsContent.match(STRING_TAG_REGEX) ?? []).find(
102
+ (tag) => getAttribute(tag, 'name') === resourceName
103
+ );
104
+
105
+ if (!stringTag) {
106
+ return null;
107
+ }
108
+
109
+ const value = stringTag.match(/>([\s\S]*?)<\/string>/)?.[1];
110
+
111
+ if (value === undefined) {
112
+ return null;
113
+ }
114
+
115
+ return { name: resourceName, value };
116
+ }
117
+
118
+ function getAndroidAttribute(
119
+ metaDataTag: string,
120
+ attributeName: string
121
+ ): string | undefined {
122
+ return getAttribute(metaDataTag, `android:${attributeName}`);
123
+ }
124
+
125
+ function getAttribute(tag: string, attributeName: string): string | undefined {
126
+ const attributeRegex = new RegExp(
127
+ `\\b${attributeName}\\s*=\\s*(['"])([\\s\\S]*?)\\1`
128
+ );
129
+
130
+ return tag.match(attributeRegex)?.[2];
131
+ }
@@ -1,2 +1,2 @@
1
- export const BROWNFIELD_PLUGIN_VERSION = '1.0.2';
1
+ export const BROWNFIELD_PLUGIN_VERSION = '1.1.0';
2
2
  export const brownfieldGradlePluginDependency = `classpath("com.callstack.react:brownfield-gradle-plugin:${BROWNFIELD_PLUGIN_VERSION}")`;
@@ -0,0 +1,106 @@
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
3
+
4
+ import { Logger } from '../../logging';
5
+ import {
6
+ type AndroidManifestMetaDataEntry,
7
+ type AndroidStringResourceEntry,
8
+ extractApplicationMetaData,
9
+ extractStringResourcesFromXml,
10
+ } from './androidManifest';
11
+
12
+ const APP_MANIFEST_PATH_SEGMENTS = ['src', 'main', 'AndroidManifest.xml'];
13
+ const APP_STRINGS_PATH_SEGMENTS = [
14
+ 'src',
15
+ 'main',
16
+ 'res',
17
+ 'values',
18
+ 'strings.xml',
19
+ ];
20
+ const STRING_REFERENCE_REGEX = /^@string\/([A-Za-z0-9_.]+)$/;
21
+ const EXPO_UPDATES_META_DATA_PREFIX = 'expo.modules.updates.';
22
+
23
+ /**
24
+ * This copies values from the app's finalized Android files while running
25
+ * inside `withDangerousMod` / `withFinalizedMod`. In that phase, the stable
26
+ * cross-plugin input is the on-disk XML after Expo and other config plugins have
27
+ * finished mutating it, so extraction intentionally uses raw file
28
+ * contents as the source of truth.
29
+ */
30
+ export function readExpoUpdatesApplicationMetaData(
31
+ androidDir: string,
32
+ appModuleName: string
33
+ ): AndroidManifestMetaDataEntry[] {
34
+ const manifestPath = path.join(
35
+ androidDir,
36
+ appModuleName,
37
+ ...APP_MANIFEST_PATH_SEGMENTS
38
+ );
39
+
40
+ if (!fs.existsSync(manifestPath)) {
41
+ Logger.logDebug(
42
+ `App manifest not found, skipping metadata copy: ${manifestPath}`
43
+ );
44
+ return [];
45
+ }
46
+
47
+ return extractExpoUpdatesApplicationMetaData(
48
+ fs.readFileSync(manifestPath, 'utf8')
49
+ );
50
+ }
51
+
52
+ export function extractExpoUpdatesApplicationMetaData(
53
+ manifestContent: string
54
+ ): AndroidManifestMetaDataEntry[] {
55
+ return extractApplicationMetaData(manifestContent).filter(
56
+ isExpoUpdatesMetaDataEntry
57
+ );
58
+ }
59
+
60
+ export function readExpoUpdatesStringResources(
61
+ androidDir: string,
62
+ appModuleName: string,
63
+ metaDataEntries: AndroidManifestMetaDataEntry[]
64
+ ): AndroidStringResourceEntry[] {
65
+ const stringResourceNames = getReferencedStringResourceNames(metaDataEntries);
66
+
67
+ if (stringResourceNames.length === 0) {
68
+ return [];
69
+ }
70
+
71
+ const stringsPath = path.join(
72
+ androidDir,
73
+ appModuleName,
74
+ ...APP_STRINGS_PATH_SEGMENTS
75
+ );
76
+
77
+ if (!fs.existsSync(stringsPath)) {
78
+ Logger.logDebug(
79
+ `App strings not found, skipping string resource copy: ${stringsPath}`
80
+ );
81
+ return [];
82
+ }
83
+
84
+ return extractStringResourcesFromXml(
85
+ fs.readFileSync(stringsPath, 'utf8'),
86
+ stringResourceNames
87
+ );
88
+ }
89
+
90
+ function isExpoUpdatesMetaDataEntry(
91
+ metaDataEntry: AndroidManifestMetaDataEntry
92
+ ): boolean {
93
+ return metaDataEntry.name.startsWith(EXPO_UPDATES_META_DATA_PREFIX);
94
+ }
95
+
96
+ function getReferencedStringResourceNames(
97
+ metaDataEntries: AndroidManifestMetaDataEntry[]
98
+ ): string[] {
99
+ return [
100
+ ...new Set(
101
+ metaDataEntries
102
+ .map(({ value }) => value.match(STRING_REFERENCE_REGEX)?.[1])
103
+ .filter((name): name is string => name !== undefined)
104
+ ),
105
+ ];
106
+ }