@expo/config-plugins 5.0.4 → 6.0.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/build/Plugin.types.d.ts +7 -7
- package/build/Plugin.types.js +0 -9
- package/build/Plugin.types.js.map +1 -1
- package/build/android/AllowBackup.js +0 -15
- package/build/android/AllowBackup.js.map +1 -1
- package/build/android/BuildProperties.js +2 -16
- package/build/android/BuildProperties.js.map +1 -1
- package/build/android/Colors.js +3 -25
- package/build/android/Colors.js.map +1 -1
- package/build/android/EasBuild.js +2 -22
- package/build/android/EasBuild.js.map +1 -1
- package/build/android/EasBuildGradleScript.js.map +1 -1
- package/build/android/GoogleMapsApiKey.js +0 -12
- package/build/android/GoogleMapsApiKey.js.map +1 -1
- package/build/android/GoogleServices.js +10 -48
- package/build/android/GoogleServices.js.map +1 -1
- package/build/android/IntentFilters.d.ts +1 -1
- package/build/android/IntentFilters.js +8 -24
- package/build/android/IntentFilters.js.map +1 -1
- package/build/android/Manifest.d.ts +19 -19
- package/build/android/Manifest.js +7 -66
- package/build/android/Manifest.js.map +1 -1
- package/build/android/Name.js +6 -27
- package/build/android/Name.js.map +1 -1
- package/build/android/Orientation.js +2 -12
- package/build/android/Orientation.js.map +1 -1
- package/build/android/Package.js +26 -111
- package/build/android/Package.js.map +1 -1
- package/build/android/Paths.d.ts +2 -2
- package/build/android/Paths.js +0 -47
- package/build/android/Paths.js.map +1 -1
- package/build/android/Permissions.js +8 -52
- package/build/android/Permissions.js.map +1 -1
- package/build/android/PrimaryColor.js +0 -18
- package/build/android/PrimaryColor.js.map +1 -1
- package/build/android/Properties.d.ts +1 -1
- package/build/android/Properties.js +0 -9
- package/build/android/Properties.js.map +1 -1
- package/build/android/Resources.d.ts +4 -4
- package/build/android/Resources.js +9 -29
- package/build/android/Resources.js.map +1 -1
- package/build/android/Scheme.d.ts +1 -1
- package/build/android/Scheme.js +13 -66
- package/build/android/Scheme.js.map +1 -1
- package/build/android/StatusBar.js +5 -33
- package/build/android/StatusBar.js.map +1 -1
- package/build/android/Strings.js +0 -14
- package/build/android/Strings.js.map +1 -1
- package/build/android/Styles.js +7 -34
- package/build/android/Styles.js.map +1 -1
- package/build/android/Updates.d.ts +2 -0
- package/build/android/Updates.js +50 -47
- package/build/android/Updates.js.map +1 -1
- package/build/android/Version.js +3 -29
- package/build/android/Version.js.map +1 -1
- package/build/android/WindowSoftInputMode.js +0 -14
- package/build/android/WindowSoftInputMode.js.map +1 -1
- package/build/android/codeMod.js +6 -22
- package/build/android/codeMod.js.map +1 -1
- package/build/android/index.js +0 -94
- package/build/android/index.js.map +1 -1
- package/build/index.js +2 -65
- package/build/index.js.map +1 -1
- package/build/ios/Bitcode.d.ts +1 -1
- package/build/ios/Bitcode.js +8 -28
- package/build/ios/Bitcode.js.map +1 -1
- package/build/ios/BuildProperties.js +2 -14
- package/build/ios/BuildProperties.js.map +1 -1
- package/build/ios/BuildScheme.js +2 -34
- package/build/ios/BuildScheme.js.map +1 -1
- package/build/ios/BundleIdentifier.js +13 -72
- package/build/ios/BundleIdentifier.js.map +1 -1
- package/build/ios/DeviceFamily.js +6 -24
- package/build/ios/DeviceFamily.js.map +1 -1
- package/build/ios/Entitlements.js +4 -45
- package/build/ios/Entitlements.js.map +1 -1
- package/build/ios/Google.d.ts +2 -2
- package/build/ios/Google.js +11 -66
- package/build/ios/Google.js.map +1 -1
- package/build/ios/IosConfig.types.d.ts +6 -11
- package/build/ios/IosConfig.types.js.map +1 -1
- package/build/ios/Locales.d.ts +3 -3
- package/build/ios/Locales.js +12 -43
- package/build/ios/Locales.js.map +1 -1
- package/build/ios/Maps.js +15 -53
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Name.js +7 -31
- package/build/ios/Name.js.map +1 -1
- package/build/ios/Orientation.js +2 -10
- package/build/ios/Orientation.js.map +1 -1
- package/build/ios/Paths.d.ts +2 -2
- package/build/ios/Paths.js +8 -73
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/Permissions.js +1 -16
- package/build/ios/Permissions.js.map +1 -1
- package/build/ios/ProvisioningProfile.d.ts +1 -1
- package/build/ios/ProvisioningProfile.js +0 -18
- package/build/ios/ProvisioningProfile.js.map +1 -1
- package/build/ios/RequiresFullScreen.js +19 -31
- package/build/ios/RequiresFullScreen.js.map +1 -1
- package/build/ios/Scheme.js +10 -32
- package/build/ios/Scheme.js.map +1 -1
- package/build/ios/Swift.js +16 -50
- package/build/ios/Swift.js.map +1 -1
- package/build/ios/Target.js +0 -30
- package/build/ios/Target.js.map +1 -1
- package/build/ios/Updates.js +10 -49
- package/build/ios/Updates.js.map +1 -1
- package/build/ios/UsesNonExemptEncryption.js +4 -10
- package/build/ios/UsesNonExemptEncryption.js.map +1 -1
- package/build/ios/Version.js +4 -11
- package/build/ios/Version.js.map +1 -1
- package/build/ios/XcodeProjectFile.js +5 -23
- package/build/ios/XcodeProjectFile.js.map +1 -1
- package/build/ios/codeMod.js +19 -60
- package/build/ios/codeMod.js.map +1 -1
- package/build/ios/index.js +0 -97
- package/build/ios/index.js.map +1 -1
- package/build/ios/utils/Xcodeproj.d.ts +6 -6
- package/build/ios/utils/Xcodeproj.js +15 -101
- package/build/ios/utils/Xcodeproj.js.map +1 -1
- package/build/ios/utils/getInfoPlistPath.js +2 -15
- package/build/ios/utils/getInfoPlistPath.js.map +1 -1
- package/build/ios/utils/string.js +0 -1
- package/build/ios/utils/string.js.map +1 -1
- package/build/plugins/android-plugins.d.ts +2 -2
- package/build/plugins/android-plugins.js +11 -42
- package/build/plugins/android-plugins.js.map +1 -1
- package/build/plugins/createBaseMod.d.ts +3 -3
- package/build/plugins/createBaseMod.js +8 -25
- package/build/plugins/createBaseMod.js.map +1 -1
- package/build/plugins/ios-plugins.d.ts +2 -2
- package/build/plugins/ios-plugins.js +8 -48
- package/build/plugins/ios-plugins.js.map +1 -1
- package/build/plugins/mod-compiler.js +21 -72
- package/build/plugins/mod-compiler.js.map +1 -1
- package/build/plugins/withAndroidBaseMods.d.ts +1 -1
- package/build/plugins/withAndroidBaseMods.js +4 -89
- package/build/plugins/withAndroidBaseMods.js.map +1 -1
- package/build/plugins/withDangerousMod.js +0 -5
- package/build/plugins/withDangerousMod.js.map +1 -1
- package/build/plugins/withIosBaseMods.d.ts +1 -1
- package/build/plugins/withIosBaseMods.js +26 -118
- package/build/plugins/withIosBaseMods.js.map +1 -1
- package/build/plugins/withMod.d.ts +1 -1
- package/build/plugins/withMod.js +24 -59
- package/build/plugins/withMod.js.map +1 -1
- package/build/plugins/withPlugins.js +0 -9
- package/build/plugins/withPlugins.js.map +1 -1
- package/build/plugins/withRunOnce.js +3 -9
- package/build/plugins/withRunOnce.js.map +1 -1
- package/build/plugins/withStaticPlugin.js +21 -43
- package/build/plugins/withStaticPlugin.js.map +1 -1
- package/build/utils/BuildProperties.types.d.ts +2 -2
- package/build/utils/BuildProperties.types.js.map +1 -1
- package/build/utils/Updates.d.ts +3 -1
- package/build/utils/Updates.js +18 -77
- package/build/utils/Updates.js.map +1 -1
- package/build/utils/XML.d.ts +1 -1
- package/build/utils/XML.js +7 -44
- package/build/utils/XML.js.map +1 -1
- package/build/utils/commonCodeMod.js +2 -10
- package/build/utils/commonCodeMod.js.map +1 -1
- package/build/utils/errors.d.ts +1 -1
- package/build/utils/errors.js +3 -11
- package/build/utils/errors.js.map +1 -1
- package/build/utils/fs.js +1 -12
- package/build/utils/fs.js.map +1 -1
- package/build/utils/generateCode.d.ts +1 -1
- package/build/utils/generateCode.js +8 -25
- package/build/utils/generateCode.js.map +1 -1
- package/build/utils/history.d.ts +1 -1
- package/build/utils/history.js +0 -6
- package/build/utils/history.js.map +1 -1
- package/build/utils/matchBrackets.d.ts +3 -3
- package/build/utils/matchBrackets.js +2 -17
- package/build/utils/matchBrackets.js.map +1 -1
- package/build/utils/modules.js +0 -10
- package/build/utils/modules.js.map +1 -1
- package/build/utils/obj.js +0 -4
- package/build/utils/obj.js.map +1 -1
- package/build/utils/plugin-resolver.js +25 -69
- package/build/utils/plugin-resolver.js.map +1 -1
- package/build/utils/sortObject.js +4 -10
- package/build/utils/sortObject.js.map +1 -1
- package/build/utils/versions.js +0 -10
- package/build/utils/versions.js.map +1 -1
- package/build/utils/warnings.js +1 -9
- package/build/utils/warnings.js.map +1 -1
- package/package.json +5 -5
|
@@ -6,17 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createAndroidManifestPlugin = createAndroidManifestPlugin;
|
|
7
7
|
exports.createStringsXmlPlugin = createStringsXmlPlugin;
|
|
8
8
|
exports.withStringsXml = exports.withSettingsGradle = exports.withProjectBuildGradle = exports.withMainApplication = exports.withMainActivity = exports.withGradleProperties = exports.withAppBuildGradle = exports.withAndroidStyles = exports.withAndroidManifest = exports.withAndroidColorsNight = exports.withAndroidColors = void 0;
|
|
9
|
-
|
|
10
9
|
function _withMod() {
|
|
11
10
|
const data = require("./withMod");
|
|
12
|
-
|
|
13
11
|
_withMod = function () {
|
|
14
12
|
return data;
|
|
15
13
|
};
|
|
16
|
-
|
|
17
14
|
return data;
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
/**
|
|
21
17
|
* Helper method for creating mods from existing config functions.
|
|
22
18
|
*
|
|
@@ -27,38 +23,32 @@ function createAndroidManifestPlugin(action, name) {
|
|
|
27
23
|
config.modResults = await action(config, config.modResults);
|
|
28
24
|
return config;
|
|
29
25
|
});
|
|
30
|
-
|
|
31
26
|
if (name) {
|
|
32
27
|
Object.defineProperty(withUnknown, 'name', {
|
|
33
28
|
value: name
|
|
34
29
|
});
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
return withUnknown;
|
|
38
32
|
}
|
|
39
|
-
|
|
40
33
|
function createStringsXmlPlugin(action, name) {
|
|
41
34
|
const withUnknown = config => withStringsXml(config, async config => {
|
|
42
35
|
config.modResults = await action(config, config.modResults);
|
|
43
36
|
return config;
|
|
44
37
|
});
|
|
45
|
-
|
|
46
38
|
if (name) {
|
|
47
39
|
Object.defineProperty(withUnknown, 'name', {
|
|
48
40
|
value: name
|
|
49
41
|
});
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
return withUnknown;
|
|
53
44
|
}
|
|
45
|
+
|
|
54
46
|
/**
|
|
55
47
|
* Provides the AndroidManifest.xml for modification.
|
|
56
48
|
*
|
|
57
49
|
* @param config
|
|
58
50
|
* @param action
|
|
59
51
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
52
|
const withAndroidManifest = (config, action) => {
|
|
63
53
|
return (0, _withMod().withMod)(config, {
|
|
64
54
|
platform: 'android',
|
|
@@ -66,16 +56,14 @@ const withAndroidManifest = (config, action) => {
|
|
|
66
56
|
action
|
|
67
57
|
});
|
|
68
58
|
};
|
|
59
|
+
|
|
69
60
|
/**
|
|
70
61
|
* Provides the strings.xml for modification.
|
|
71
62
|
*
|
|
72
63
|
* @param config
|
|
73
64
|
* @param action
|
|
74
65
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
66
|
exports.withAndroidManifest = withAndroidManifest;
|
|
78
|
-
|
|
79
67
|
const withStringsXml = (config, action) => {
|
|
80
68
|
return (0, _withMod().withMod)(config, {
|
|
81
69
|
platform: 'android',
|
|
@@ -83,16 +71,14 @@ const withStringsXml = (config, action) => {
|
|
|
83
71
|
action
|
|
84
72
|
});
|
|
85
73
|
};
|
|
74
|
+
|
|
86
75
|
/**
|
|
87
76
|
* Provides the `android/app/src/main/res/values/colors.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).
|
|
88
77
|
*
|
|
89
78
|
* @param config
|
|
90
79
|
* @param action
|
|
91
80
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
81
|
exports.withStringsXml = withStringsXml;
|
|
95
|
-
|
|
96
82
|
const withAndroidColors = (config, action) => {
|
|
97
83
|
return (0, _withMod().withMod)(config, {
|
|
98
84
|
platform: 'android',
|
|
@@ -100,16 +86,14 @@ const withAndroidColors = (config, action) => {
|
|
|
100
86
|
action
|
|
101
87
|
});
|
|
102
88
|
};
|
|
89
|
+
|
|
103
90
|
/**
|
|
104
91
|
* Provides the `android/app/src/main/res/values-night/colors.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).
|
|
105
92
|
*
|
|
106
93
|
* @param config
|
|
107
94
|
* @param action
|
|
108
95
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
96
|
exports.withAndroidColors = withAndroidColors;
|
|
112
|
-
|
|
113
97
|
const withAndroidColorsNight = (config, action) => {
|
|
114
98
|
return (0, _withMod().withMod)(config, {
|
|
115
99
|
platform: 'android',
|
|
@@ -117,16 +101,14 @@ const withAndroidColorsNight = (config, action) => {
|
|
|
117
101
|
action
|
|
118
102
|
});
|
|
119
103
|
};
|
|
104
|
+
|
|
120
105
|
/**
|
|
121
106
|
* Provides the `android/app/src/main/res/values/styles.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).
|
|
122
107
|
*
|
|
123
108
|
* @param config
|
|
124
109
|
* @param action
|
|
125
110
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
111
|
exports.withAndroidColorsNight = withAndroidColorsNight;
|
|
129
|
-
|
|
130
112
|
const withAndroidStyles = (config, action) => {
|
|
131
113
|
return (0, _withMod().withMod)(config, {
|
|
132
114
|
platform: 'android',
|
|
@@ -134,16 +116,14 @@ const withAndroidStyles = (config, action) => {
|
|
|
134
116
|
action
|
|
135
117
|
});
|
|
136
118
|
};
|
|
119
|
+
|
|
137
120
|
/**
|
|
138
121
|
* Provides the project MainActivity for modification.
|
|
139
122
|
*
|
|
140
123
|
* @param config
|
|
141
124
|
* @param action
|
|
142
125
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
126
|
exports.withAndroidStyles = withAndroidStyles;
|
|
146
|
-
|
|
147
127
|
const withMainActivity = (config, action) => {
|
|
148
128
|
return (0, _withMod().withMod)(config, {
|
|
149
129
|
platform: 'android',
|
|
@@ -151,16 +131,14 @@ const withMainActivity = (config, action) => {
|
|
|
151
131
|
action
|
|
152
132
|
});
|
|
153
133
|
};
|
|
134
|
+
|
|
154
135
|
/**
|
|
155
136
|
* Provides the project MainApplication for modification.
|
|
156
137
|
*
|
|
157
138
|
* @param config
|
|
158
139
|
* @param action
|
|
159
140
|
*/
|
|
160
|
-
|
|
161
|
-
|
|
162
141
|
exports.withMainActivity = withMainActivity;
|
|
163
|
-
|
|
164
142
|
const withMainApplication = (config, action) => {
|
|
165
143
|
return (0, _withMod().withMod)(config, {
|
|
166
144
|
platform: 'android',
|
|
@@ -168,16 +146,14 @@ const withMainApplication = (config, action) => {
|
|
|
168
146
|
action
|
|
169
147
|
});
|
|
170
148
|
};
|
|
149
|
+
|
|
171
150
|
/**
|
|
172
151
|
* Provides the project /build.gradle for modification.
|
|
173
152
|
*
|
|
174
153
|
* @param config
|
|
175
154
|
* @param action
|
|
176
155
|
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
156
|
exports.withMainApplication = withMainApplication;
|
|
180
|
-
|
|
181
157
|
const withProjectBuildGradle = (config, action) => {
|
|
182
158
|
return (0, _withMod().withMod)(config, {
|
|
183
159
|
platform: 'android',
|
|
@@ -185,16 +161,14 @@ const withProjectBuildGradle = (config, action) => {
|
|
|
185
161
|
action
|
|
186
162
|
});
|
|
187
163
|
};
|
|
164
|
+
|
|
188
165
|
/**
|
|
189
166
|
* Provides the app/build.gradle for modification.
|
|
190
167
|
*
|
|
191
168
|
* @param config
|
|
192
169
|
* @param action
|
|
193
170
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
171
|
exports.withProjectBuildGradle = withProjectBuildGradle;
|
|
197
|
-
|
|
198
172
|
const withAppBuildGradle = (config, action) => {
|
|
199
173
|
return (0, _withMod().withMod)(config, {
|
|
200
174
|
platform: 'android',
|
|
@@ -202,16 +176,14 @@ const withAppBuildGradle = (config, action) => {
|
|
|
202
176
|
action
|
|
203
177
|
});
|
|
204
178
|
};
|
|
179
|
+
|
|
205
180
|
/**
|
|
206
181
|
* Provides the /settings.gradle for modification.
|
|
207
182
|
*
|
|
208
183
|
* @param config
|
|
209
184
|
* @param action
|
|
210
185
|
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
186
|
exports.withAppBuildGradle = withAppBuildGradle;
|
|
214
|
-
|
|
215
187
|
const withSettingsGradle = (config, action) => {
|
|
216
188
|
return (0, _withMod().withMod)(config, {
|
|
217
189
|
platform: 'android',
|
|
@@ -219,16 +191,14 @@ const withSettingsGradle = (config, action) => {
|
|
|
219
191
|
action
|
|
220
192
|
});
|
|
221
193
|
};
|
|
194
|
+
|
|
222
195
|
/**
|
|
223
196
|
* Provides the /gradle.properties for modification.
|
|
224
197
|
*
|
|
225
198
|
* @param config
|
|
226
199
|
* @param action
|
|
227
200
|
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
201
|
exports.withSettingsGradle = withSettingsGradle;
|
|
231
|
-
|
|
232
202
|
const withGradleProperties = (config, action) => {
|
|
233
203
|
return (0, _withMod().withMod)(config, {
|
|
234
204
|
platform: 'android',
|
|
@@ -236,6 +206,5 @@ const withGradleProperties = (config, action) => {
|
|
|
236
206
|
action
|
|
237
207
|
});
|
|
238
208
|
};
|
|
239
|
-
|
|
240
209
|
exports.withGradleProperties = withGradleProperties;
|
|
241
210
|
//# sourceMappingURL=android-plugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"android-plugins.js","names":["createAndroidManifestPlugin","action","name","withUnknown","config","withAndroidManifest","modResults","Object","defineProperty","value","createStringsXmlPlugin","withStringsXml","withMod","platform","mod","withAndroidColors","withAndroidColorsNight","withAndroidStyles","withMainActivity","withMainApplication","withProjectBuildGradle","withAppBuildGradle","withSettingsGradle","withGradleProperties"],"sources":["../../src/plugins/android-plugins.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\n\nimport { ConfigPlugin, Mod } from '../Plugin.types';\nimport { Manifest, Paths, Properties, Resources } from '../android';\nimport { withMod } from './withMod';\n\ntype OptionalPromise<T> = T | Promise<T>;\n\ntype MutateDataAction<T> = (expo: ExpoConfig, data: T) => OptionalPromise<T>;\n\n/**\n * Helper method for creating mods from existing config functions.\n *\n * @param action\n */\nexport function createAndroidManifestPlugin(\n action: MutateDataAction<Manifest.AndroidManifest>,\n name: string\n): ConfigPlugin {\n const withUnknown: ConfigPlugin = (config) =>\n withAndroidManifest(config, async (config) => {\n config.modResults = await action(config, config.modResults);\n return config;\n });\n if (name) {\n Object.defineProperty(withUnknown, 'name', {\n value: name,\n });\n }\n return withUnknown;\n}\n\nexport function createStringsXmlPlugin(\n action: MutateDataAction<Resources.ResourceXML>,\n name: string\n): ConfigPlugin {\n const withUnknown: ConfigPlugin = (config) =>\n withStringsXml(config, async (config) => {\n config.modResults = await action(config, config.modResults);\n return config;\n });\n if (name) {\n Object.defineProperty(withUnknown, 'name', {\n value: name,\n });\n }\n return withUnknown;\n}\n\n/**\n * Provides the AndroidManifest.xml for modification.\n *\n * @param config\n * @param action\n */\nexport const withAndroidManifest: ConfigPlugin<Mod<Manifest.AndroidManifest>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'manifest',\n action,\n });\n};\n\n/**\n * Provides the strings.xml for modification.\n *\n * @param config\n * @param action\n */\nexport const withStringsXml: ConfigPlugin<Mod<Resources.ResourceXML>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'strings',\n action,\n });\n};\n\n/**\n * Provides the `android/app/src/main/res/values/colors.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).\n *\n * @param config\n * @param action\n */\nexport const withAndroidColors: ConfigPlugin<Mod<Resources.ResourceXML>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'colors',\n action,\n });\n};\n\n/**\n * Provides the `android/app/src/main/res/values-night/colors.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).\n *\n * @param config\n * @param action\n */\nexport const withAndroidColorsNight: ConfigPlugin<Mod<Resources.ResourceXML>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'colorsNight',\n action,\n });\n};\n\n/**\n * Provides the `android/app/src/main/res/values/styles.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).\n *\n * @param config\n * @param action\n */\nexport const withAndroidStyles: ConfigPlugin<Mod<Resources.ResourceXML>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'styles',\n action,\n });\n};\n\n/**\n * Provides the project MainActivity for modification.\n *\n * @param config\n * @param action\n */\nexport const withMainActivity: ConfigPlugin<Mod<Paths.ApplicationProjectFile>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'mainActivity',\n action,\n });\n};\n\n/**\n * Provides the project MainApplication for modification.\n *\n * @param config\n * @param action\n */\nexport const withMainApplication: ConfigPlugin<Mod<Paths.ApplicationProjectFile>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'mainApplication',\n action,\n });\n};\n\n/**\n * Provides the project /build.gradle for modification.\n *\n * @param config\n * @param action\n */\nexport const withProjectBuildGradle: ConfigPlugin<Mod<Paths.GradleProjectFile>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'projectBuildGradle',\n action,\n });\n};\n\n/**\n * Provides the app/build.gradle for modification.\n *\n * @param config\n * @param action\n */\nexport const withAppBuildGradle: ConfigPlugin<Mod<Paths.GradleProjectFile>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'appBuildGradle',\n action,\n });\n};\n\n/**\n * Provides the /settings.gradle for modification.\n *\n * @param config\n * @param action\n */\nexport const withSettingsGradle: ConfigPlugin<Mod<Paths.GradleProjectFile>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'settingsGradle',\n action,\n });\n};\n\n/**\n * Provides the /gradle.properties for modification.\n *\n * @param config\n * @param action\n */\nexport const withGradleProperties: ConfigPlugin<Mod<Properties.PropertiesItem[]>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'gradleProperties',\n action,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"android-plugins.js","names":["createAndroidManifestPlugin","action","name","withUnknown","config","withAndroidManifest","modResults","Object","defineProperty","value","createStringsXmlPlugin","withStringsXml","withMod","platform","mod","withAndroidColors","withAndroidColorsNight","withAndroidStyles","withMainActivity","withMainApplication","withProjectBuildGradle","withAppBuildGradle","withSettingsGradle","withGradleProperties"],"sources":["../../src/plugins/android-plugins.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\n\nimport { ConfigPlugin, Mod } from '../Plugin.types';\nimport { Manifest, Paths, Properties, Resources } from '../android';\nimport { withMod } from './withMod';\n\ntype OptionalPromise<T> = T | Promise<T>;\n\ntype MutateDataAction<T> = (expo: ExpoConfig, data: T) => OptionalPromise<T>;\n\n/**\n * Helper method for creating mods from existing config functions.\n *\n * @param action\n */\nexport function createAndroidManifestPlugin(\n action: MutateDataAction<Manifest.AndroidManifest>,\n name: string\n): ConfigPlugin {\n const withUnknown: ConfigPlugin = (config) =>\n withAndroidManifest(config, async (config) => {\n config.modResults = await action(config, config.modResults);\n return config;\n });\n if (name) {\n Object.defineProperty(withUnknown, 'name', {\n value: name,\n });\n }\n return withUnknown;\n}\n\nexport function createStringsXmlPlugin(\n action: MutateDataAction<Resources.ResourceXML>,\n name: string\n): ConfigPlugin {\n const withUnknown: ConfigPlugin = (config) =>\n withStringsXml(config, async (config) => {\n config.modResults = await action(config, config.modResults);\n return config;\n });\n if (name) {\n Object.defineProperty(withUnknown, 'name', {\n value: name,\n });\n }\n return withUnknown;\n}\n\n/**\n * Provides the AndroidManifest.xml for modification.\n *\n * @param config\n * @param action\n */\nexport const withAndroidManifest: ConfigPlugin<Mod<Manifest.AndroidManifest>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'manifest',\n action,\n });\n};\n\n/**\n * Provides the strings.xml for modification.\n *\n * @param config\n * @param action\n */\nexport const withStringsXml: ConfigPlugin<Mod<Resources.ResourceXML>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'strings',\n action,\n });\n};\n\n/**\n * Provides the `android/app/src/main/res/values/colors.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).\n *\n * @param config\n * @param action\n */\nexport const withAndroidColors: ConfigPlugin<Mod<Resources.ResourceXML>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'colors',\n action,\n });\n};\n\n/**\n * Provides the `android/app/src/main/res/values-night/colors.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).\n *\n * @param config\n * @param action\n */\nexport const withAndroidColorsNight: ConfigPlugin<Mod<Resources.ResourceXML>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'colorsNight',\n action,\n });\n};\n\n/**\n * Provides the `android/app/src/main/res/values/styles.xml` as JSON (parsed with [`xml2js`](https://www.npmjs.com/package/xml2js)).\n *\n * @param config\n * @param action\n */\nexport const withAndroidStyles: ConfigPlugin<Mod<Resources.ResourceXML>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'styles',\n action,\n });\n};\n\n/**\n * Provides the project MainActivity for modification.\n *\n * @param config\n * @param action\n */\nexport const withMainActivity: ConfigPlugin<Mod<Paths.ApplicationProjectFile>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'mainActivity',\n action,\n });\n};\n\n/**\n * Provides the project MainApplication for modification.\n *\n * @param config\n * @param action\n */\nexport const withMainApplication: ConfigPlugin<Mod<Paths.ApplicationProjectFile>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'mainApplication',\n action,\n });\n};\n\n/**\n * Provides the project /build.gradle for modification.\n *\n * @param config\n * @param action\n */\nexport const withProjectBuildGradle: ConfigPlugin<Mod<Paths.GradleProjectFile>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'projectBuildGradle',\n action,\n });\n};\n\n/**\n * Provides the app/build.gradle for modification.\n *\n * @param config\n * @param action\n */\nexport const withAppBuildGradle: ConfigPlugin<Mod<Paths.GradleProjectFile>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'appBuildGradle',\n action,\n });\n};\n\n/**\n * Provides the /settings.gradle for modification.\n *\n * @param config\n * @param action\n */\nexport const withSettingsGradle: ConfigPlugin<Mod<Paths.GradleProjectFile>> = (config, action) => {\n return withMod(config, {\n platform: 'android',\n mod: 'settingsGradle',\n action,\n });\n};\n\n/**\n * Provides the /gradle.properties for modification.\n *\n * @param config\n * @param action\n */\nexport const withGradleProperties: ConfigPlugin<Mod<Properties.PropertiesItem[]>> = (\n config,\n action\n) => {\n return withMod(config, {\n platform: 'android',\n mod: 'gradleProperties',\n action,\n });\n};\n"],"mappings":";;;;;;;;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;AACA;AACA;AACA;AACA;AACO,SAASA,2BAA2B,CACzCC,MAAkD,EAClDC,IAAY,EACE;EACd,MAAMC,WAAyB,GAAIC,MAAM,IACvCC,mBAAmB,CAACD,MAAM,EAAE,MAAOA,MAAM,IAAK;IAC5CA,MAAM,CAACE,UAAU,GAAG,MAAML,MAAM,CAACG,MAAM,EAAEA,MAAM,CAACE,UAAU,CAAC;IAC3D,OAAOF,MAAM;EACf,CAAC,CAAC;EACJ,IAAIF,IAAI,EAAE;IACRK,MAAM,CAACC,cAAc,CAACL,WAAW,EAAE,MAAM,EAAE;MACzCM,KAAK,EAAEP;IACT,CAAC,CAAC;EACJ;EACA,OAAOC,WAAW;AACpB;AAEO,SAASO,sBAAsB,CACpCT,MAA+C,EAC/CC,IAAY,EACE;EACd,MAAMC,WAAyB,GAAIC,MAAM,IACvCO,cAAc,CAACP,MAAM,EAAE,MAAOA,MAAM,IAAK;IACvCA,MAAM,CAACE,UAAU,GAAG,MAAML,MAAM,CAACG,MAAM,EAAEA,MAAM,CAACE,UAAU,CAAC;IAC3D,OAAOF,MAAM;EACf,CAAC,CAAC;EACJ,IAAIF,IAAI,EAAE;IAC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AM,EACNH,MAAM,KACH;EACH,OAAO,IAAAW,kBAAO,EAACR,MAAM,EAAE;IACrBS,QAAQ,EAAE,SAAS;IACnBC,GAAG,EAAE,kBAAkB;IACvBb;EACF,CAAC,CAAC;AACJ,CAAC;AAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConfigPlugin, ExportedConfig, ExportedConfigWithProps, ModPlatform } from '../Plugin.types';
|
|
2
2
|
import { BaseModOptions } from './withMod';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type ForwardedBaseModOptions = Partial<Pick<BaseModOptions, 'saveToInternal' | 'skipEmptyMod'>>;
|
|
4
|
+
export type BaseModProviderMethods<ModType, Props extends ForwardedBaseModOptions = ForwardedBaseModOptions> = {
|
|
5
5
|
getFilePath: (config: ExportedConfigWithProps<ModType>, props: Props) => Promise<string> | string;
|
|
6
6
|
read: (filePath: string, config: ExportedConfigWithProps<ModType>, props: Props) => Promise<ModType> | ModType;
|
|
7
7
|
write: (filePath: string, config: ExportedConfigWithProps<ModType>, props: Props) => Promise<void> | void;
|
|
@@ -13,7 +13,7 @@ export declare type BaseModProviderMethods<ModType, Props extends ForwardedBaseM
|
|
|
13
13
|
*/
|
|
14
14
|
isIntrospective?: boolean;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type CreateBaseModProps<ModType, Props extends ForwardedBaseModOptions = ForwardedBaseModOptions> = {
|
|
17
17
|
methodName: string;
|
|
18
18
|
platform: ModPlatform;
|
|
19
19
|
modName: string;
|
|
@@ -8,31 +8,22 @@ exports.createBaseMod = createBaseMod;
|
|
|
8
8
|
exports.createPlatformBaseMod = createPlatformBaseMod;
|
|
9
9
|
exports.provider = provider;
|
|
10
10
|
exports.withGeneratedBaseMods = withGeneratedBaseMods;
|
|
11
|
-
|
|
12
11
|
function _debug() {
|
|
13
12
|
const data = _interopRequireDefault(require("debug"));
|
|
14
|
-
|
|
15
13
|
_debug = function () {
|
|
16
14
|
return data;
|
|
17
15
|
};
|
|
18
|
-
|
|
19
16
|
return data;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
function _withMod() {
|
|
23
19
|
const data = require("./withMod");
|
|
24
|
-
|
|
25
20
|
_withMod = function () {
|
|
26
21
|
return data;
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
return data;
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
26
|
const debug = (0, _debug().default)('expo:config-plugins:base-mods');
|
|
35
|
-
|
|
36
27
|
function createBaseMod({
|
|
37
28
|
methodName,
|
|
38
29
|
platform,
|
|
@@ -44,7 +35,6 @@ function createBaseMod({
|
|
|
44
35
|
}) {
|
|
45
36
|
const withUnknown = (config, _props) => {
|
|
46
37
|
var _props$skipEmptyMod, _props$saveToInternal;
|
|
47
|
-
|
|
48
38
|
const props = _props || {};
|
|
49
39
|
return (0, _withMod().withBaseMod)(config, {
|
|
50
40
|
platform,
|
|
@@ -53,7 +43,6 @@ function createBaseMod({
|
|
|
53
43
|
saveToInternal: (_props$saveToInternal = props.saveToInternal) !== null && _props$saveToInternal !== void 0 ? _props$saveToInternal : false,
|
|
54
44
|
isProvider: true,
|
|
55
45
|
isIntrospective,
|
|
56
|
-
|
|
57
46
|
async action({
|
|
58
47
|
modRequest: {
|
|
59
48
|
nextMod,
|
|
@@ -62,13 +51,15 @@ function createBaseMod({
|
|
|
62
51
|
...config
|
|
63
52
|
}) {
|
|
64
53
|
try {
|
|
65
|
-
let results = {
|
|
54
|
+
let results = {
|
|
55
|
+
...config,
|
|
66
56
|
modRequest
|
|
67
57
|
};
|
|
68
58
|
const filePath = await getFilePath(results, props);
|
|
69
59
|
debug(`mods.${platform}.${modName}: file path: ${filePath || '[skipped]'}`);
|
|
70
60
|
const modResults = await read(filePath, results, props);
|
|
71
|
-
results = await nextMod({
|
|
61
|
+
results = await nextMod({
|
|
62
|
+
...results,
|
|
72
63
|
modResults,
|
|
73
64
|
modRequest
|
|
74
65
|
});
|
|
@@ -80,35 +71,29 @@ function createBaseMod({
|
|
|
80
71
|
throw error;
|
|
81
72
|
}
|
|
82
73
|
}
|
|
83
|
-
|
|
84
74
|
});
|
|
85
75
|
};
|
|
86
|
-
|
|
87
76
|
if (methodName) {
|
|
88
77
|
Object.defineProperty(withUnknown, 'name', {
|
|
89
78
|
value: methodName
|
|
90
79
|
});
|
|
91
80
|
}
|
|
92
|
-
|
|
93
81
|
return withUnknown;
|
|
94
82
|
}
|
|
95
|
-
|
|
96
83
|
function assertModResults(results, platformName, modName) {
|
|
97
84
|
// If the results came from a mod, they'd be in the form of [config, data].
|
|
98
85
|
// Ensure the results are an array and omit the data since it should've been written by a data provider plugin.
|
|
99
|
-
const ensuredResults = results;
|
|
86
|
+
const ensuredResults = results;
|
|
100
87
|
|
|
88
|
+
// Sanity check to help locate non compliant mods.
|
|
101
89
|
if (!ensuredResults || typeof ensuredResults !== 'object' || !(ensuredResults !== null && ensuredResults !== void 0 && ensuredResults.mods)) {
|
|
102
90
|
throw new Error(`Mod \`mods.${platformName}.${modName}\` evaluated to an object that is not a valid project config. Instead got: ${JSON.stringify(ensuredResults)}`);
|
|
103
91
|
}
|
|
104
|
-
|
|
105
92
|
return ensuredResults;
|
|
106
93
|
}
|
|
107
|
-
|
|
108
94
|
function upperFirst(name) {
|
|
109
95
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
110
96
|
}
|
|
111
|
-
|
|
112
97
|
function createPlatformBaseMod({
|
|
113
98
|
modName,
|
|
114
99
|
...props
|
|
@@ -121,15 +106,13 @@ function createPlatformBaseMod({
|
|
|
121
106
|
...props
|
|
122
107
|
});
|
|
123
108
|
}
|
|
124
|
-
/** A TS wrapper for creating provides */
|
|
125
|
-
|
|
126
109
|
|
|
110
|
+
/** A TS wrapper for creating provides */
|
|
127
111
|
function provider(props) {
|
|
128
112
|
return props;
|
|
129
113
|
}
|
|
130
|
-
/** Plugin to create and append base mods from file providers */
|
|
131
|
-
|
|
132
114
|
|
|
115
|
+
/** Plugin to create and append base mods from file providers */
|
|
133
116
|
function withGeneratedBaseMods(config, {
|
|
134
117
|
platform,
|
|
135
118
|
providers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseMod.js","names":["debug","Debug","createBaseMod","methodName","platform","modName","getFilePath","read","write","isIntrospective","withUnknown","config","_props","props","withBaseMod","mod","skipEmptyMod","saveToInternal","isProvider","action","modRequest","nextMod","results","filePath","modResults","assertModResults","error","message","Object","defineProperty","value","platformName","ensuredResults","mods","Error","JSON","stringify","upperFirst","name","charAt","toUpperCase","slice","createPlatformBaseMod","provider","withGeneratedBaseMods","providers","entries","reduce","baseMod"],"sources":["../../src/plugins/createBaseMod.ts"],"sourcesContent":["import Debug from 'debug';\n\nimport {\n ConfigPlugin,\n ExportedConfig,\n ExportedConfigWithProps,\n ModPlatform,\n} from '../Plugin.types';\nimport { BaseModOptions, withBaseMod } from './withMod';\n\nconst debug = Debug('expo:config-plugins:base-mods');\n\nexport type ForwardedBaseModOptions = Partial<\n Pick<BaseModOptions, 'saveToInternal' | 'skipEmptyMod'>\n>;\n\nexport type BaseModProviderMethods<\n ModType,\n Props extends ForwardedBaseModOptions = ForwardedBaseModOptions\n> = {\n getFilePath: (config: ExportedConfigWithProps<ModType>, props: Props) => Promise<string> | string;\n read: (\n filePath: string,\n config: ExportedConfigWithProps<ModType>,\n props: Props\n ) => Promise<ModType> | ModType;\n write: (\n filePath: string,\n config: ExportedConfigWithProps<ModType>,\n props: Props\n ) => Promise<void> | void;\n /**\n * If the mod supports introspection, and avoids making any filesystem modifications during compilation.\n * By enabling, this mod, and all of its descendants will be run in introspection mode.\n * This should only be used for static files like JSON or XML, and not for application files that require regexes,\n * or complex static files that require other files to be generated like Xcode `.pbxproj`.\n */\n isIntrospective?: boolean;\n};\n\nexport type CreateBaseModProps<\n ModType,\n Props extends ForwardedBaseModOptions = ForwardedBaseModOptions\n> = {\n methodName: string;\n platform: ModPlatform;\n modName: string;\n} & BaseModProviderMethods<ModType, Props>;\n\nexport function createBaseMod<\n ModType,\n Props extends ForwardedBaseModOptions = ForwardedBaseModOptions\n>({\n methodName,\n platform,\n modName,\n getFilePath,\n read,\n write,\n isIntrospective,\n}: CreateBaseModProps<ModType, Props>): ConfigPlugin<Props | void> {\n const withUnknown: ConfigPlugin<Props | void> = (config, _props) => {\n const props = _props || ({} as Props);\n return withBaseMod<ModType>(config, {\n platform,\n mod: modName,\n skipEmptyMod: props.skipEmptyMod ?? true,\n saveToInternal: props.saveToInternal ?? false,\n isProvider: true,\n isIntrospective,\n async action({ modRequest: { nextMod, ...modRequest }, ...config }) {\n try {\n let results: ExportedConfigWithProps<ModType> = {\n ...config,\n modRequest,\n };\n\n const filePath = await getFilePath(results, props);\n debug(`mods.${platform}.${modName}: file path: ${filePath || '[skipped]'}`);\n const modResults = await read(filePath, results, props);\n\n results = await nextMod!({\n ...results,\n modResults,\n modRequest,\n });\n\n assertModResults(results, modRequest.platform, modRequest.modName);\n\n await write(filePath, results, props);\n return results;\n } catch (error: any) {\n error.message = `[${platform}.${modName}]: ${methodName}: ${error.message}`;\n throw error;\n }\n },\n });\n };\n\n if (methodName) {\n Object.defineProperty(withUnknown, 'name', {\n value: methodName,\n });\n }\n\n return withUnknown;\n}\n\nexport function assertModResults(results: any, platformName: string, modName: string) {\n // If the results came from a mod, they'd be in the form of [config, data].\n // Ensure the results are an array and omit the data since it should've been written by a data provider plugin.\n const ensuredResults = results;\n\n // Sanity check to help locate non compliant mods.\n if (!ensuredResults || typeof ensuredResults !== 'object' || !ensuredResults?.mods) {\n throw new Error(\n `Mod \\`mods.${platformName}.${modName}\\` evaluated to an object that is not a valid project config. Instead got: ${JSON.stringify(\n ensuredResults\n )}`\n );\n }\n return ensuredResults;\n}\n\nfunction upperFirst(name: string): string {\n return name.charAt(0).toUpperCase() + name.slice(1);\n}\n\nexport function createPlatformBaseMod<\n ModType,\n Props extends ForwardedBaseModOptions = ForwardedBaseModOptions\n>({ modName, ...props }: Omit<CreateBaseModProps<ModType, Props>, 'methodName'>) {\n // Generate the function name to ensure it's uniform and also to improve stack traces.\n const methodName = `with${upperFirst(props.platform)}${upperFirst(modName)}BaseMod`;\n return createBaseMod<ModType, Props>({\n methodName,\n modName,\n ...props,\n });\n}\n\n/** A TS wrapper for creating provides */\nexport function provider<ModType, Props extends ForwardedBaseModOptions = ForwardedBaseModOptions>(\n props: BaseModProviderMethods<ModType, Props>\n) {\n return props;\n}\n\n/** Plugin to create and append base mods from file providers */\nexport function withGeneratedBaseMods<ModName extends string>(\n config: ExportedConfig,\n {\n platform,\n providers,\n ...props\n }: ForwardedBaseModOptions & {\n platform: ModPlatform;\n providers: Partial<Record<ModName, BaseModProviderMethods<any, any>>>;\n }\n): ExportedConfig {\n return Object.entries(providers).reduce((config, [modName, value]) => {\n const baseMod = createPlatformBaseMod({ platform, modName, ...(value as any) });\n return baseMod(config, props);\n }, config);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createBaseMod.js","names":["debug","Debug","createBaseMod","methodName","platform","modName","getFilePath","read","write","isIntrospective","withUnknown","config","_props","props","withBaseMod","mod","skipEmptyMod","saveToInternal","isProvider","action","modRequest","nextMod","results","filePath","modResults","assertModResults","error","message","Object","defineProperty","value","platformName","ensuredResults","mods","Error","JSON","stringify","upperFirst","name","charAt","toUpperCase","slice","createPlatformBaseMod","provider","withGeneratedBaseMods","providers","entries","reduce","baseMod"],"sources":["../../src/plugins/createBaseMod.ts"],"sourcesContent":["import Debug from 'debug';\n\nimport {\n ConfigPlugin,\n ExportedConfig,\n ExportedConfigWithProps,\n ModPlatform,\n} from '../Plugin.types';\nimport { BaseModOptions, withBaseMod } from './withMod';\n\nconst debug = Debug('expo:config-plugins:base-mods');\n\nexport type ForwardedBaseModOptions = Partial<\n Pick<BaseModOptions, 'saveToInternal' | 'skipEmptyMod'>\n>;\n\nexport type BaseModProviderMethods<\n ModType,\n Props extends ForwardedBaseModOptions = ForwardedBaseModOptions\n> = {\n getFilePath: (config: ExportedConfigWithProps<ModType>, props: Props) => Promise<string> | string;\n read: (\n filePath: string,\n config: ExportedConfigWithProps<ModType>,\n props: Props\n ) => Promise<ModType> | ModType;\n write: (\n filePath: string,\n config: ExportedConfigWithProps<ModType>,\n props: Props\n ) => Promise<void> | void;\n /**\n * If the mod supports introspection, and avoids making any filesystem modifications during compilation.\n * By enabling, this mod, and all of its descendants will be run in introspection mode.\n * This should only be used for static files like JSON or XML, and not for application files that require regexes,\n * or complex static files that require other files to be generated like Xcode `.pbxproj`.\n */\n isIntrospective?: boolean;\n};\n\nexport type CreateBaseModProps<\n ModType,\n Props extends ForwardedBaseModOptions = ForwardedBaseModOptions\n> = {\n methodName: string;\n platform: ModPlatform;\n modName: string;\n} & BaseModProviderMethods<ModType, Props>;\n\nexport function createBaseMod<\n ModType,\n Props extends ForwardedBaseModOptions = ForwardedBaseModOptions\n>({\n methodName,\n platform,\n modName,\n getFilePath,\n read,\n write,\n isIntrospective,\n}: CreateBaseModProps<ModType, Props>): ConfigPlugin<Props | void> {\n const withUnknown: ConfigPlugin<Props | void> = (config, _props) => {\n const props = _props || ({} as Props);\n return withBaseMod<ModType>(config, {\n platform,\n mod: modName,\n skipEmptyMod: props.skipEmptyMod ?? true,\n saveToInternal: props.saveToInternal ?? false,\n isProvider: true,\n isIntrospective,\n async action({ modRequest: { nextMod, ...modRequest }, ...config }) {\n try {\n let results: ExportedConfigWithProps<ModType> = {\n ...config,\n modRequest,\n };\n\n const filePath = await getFilePath(results, props);\n debug(`mods.${platform}.${modName}: file path: ${filePath || '[skipped]'}`);\n const modResults = await read(filePath, results, props);\n\n results = await nextMod!({\n ...results,\n modResults,\n modRequest,\n });\n\n assertModResults(results, modRequest.platform, modRequest.modName);\n\n await write(filePath, results, props);\n return results;\n } catch (error: any) {\n error.message = `[${platform}.${modName}]: ${methodName}: ${error.message}`;\n throw error;\n }\n },\n });\n };\n\n if (methodName) {\n Object.defineProperty(withUnknown, 'name', {\n value: methodName,\n });\n }\n\n return withUnknown;\n}\n\nexport function assertModResults(results: any, platformName: string, modName: string) {\n // If the results came from a mod, they'd be in the form of [config, data].\n // Ensure the results are an array and omit the data since it should've been written by a data provider plugin.\n const ensuredResults = results;\n\n // Sanity check to help locate non compliant mods.\n if (!ensuredResults || typeof ensuredResults !== 'object' || !ensuredResults?.mods) {\n throw new Error(\n `Mod \\`mods.${platformName}.${modName}\\` evaluated to an object that is not a valid project config. Instead got: ${JSON.stringify(\n ensuredResults\n )}`\n );\n }\n return ensuredResults;\n}\n\nfunction upperFirst(name: string): string {\n return name.charAt(0).toUpperCase() + name.slice(1);\n}\n\nexport function createPlatformBaseMod<\n ModType,\n Props extends ForwardedBaseModOptions = ForwardedBaseModOptions\n>({ modName, ...props }: Omit<CreateBaseModProps<ModType, Props>, 'methodName'>) {\n // Generate the function name to ensure it's uniform and also to improve stack traces.\n const methodName = `with${upperFirst(props.platform)}${upperFirst(modName)}BaseMod`;\n return createBaseMod<ModType, Props>({\n methodName,\n modName,\n ...props,\n });\n}\n\n/** A TS wrapper for creating provides */\nexport function provider<ModType, Props extends ForwardedBaseModOptions = ForwardedBaseModOptions>(\n props: BaseModProviderMethods<ModType, Props>\n) {\n return props;\n}\n\n/** Plugin to create and append base mods from file providers */\nexport function withGeneratedBaseMods<ModName extends string>(\n config: ExportedConfig,\n {\n platform,\n providers,\n ...props\n }: ForwardedBaseModOptions & {\n platform: ModPlatform;\n providers: Partial<Record<ModName, BaseModProviderMethods<any, any>>>;\n }\n): ExportedConfig {\n return Object.entries(providers).reduce((config, [modName, value]) => {\n const baseMod = createPlatformBaseMod({ platform, modName, ...(value as any) });\n return baseMod(config, props);\n }, config);\n}\n"],"mappings":";;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwD;AAExD,MAAMA,KAAK,GAAG,IAAAC,gBAAK,EAAC,+BAA+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MAAsB,EACtB;EACEP,QAAQ;EACRyC,SAAS;EACT,GAAGhC;AAIL,CAAC,EACe;EAChB,OAAOe,MAAM,CAACkB,OAAO,CAACD,SAAS,CAAC,CAACE,MAAM,CAAC,CAACpC,MAAM,EAAE,CAACN,OAAO,EAAEyB,KAAK,CAAC,KAAK;IACpE,MAAMkB,OAAO,GAAGN,qBAAqB,CAAC;MAAEtC,QAAQ;MAAEC,OAAO;MAAE,GAAIyB;IAAc,CAAC,CAAC;IAC/E,OAAOkB,OAAO,CAACrC,MAAM,EAAEE,KAAK,CAAC;EAC/B,CAAC,EAAEF,MAAM,CAAC;AACZ"}
|
|
@@ -4,7 +4,7 @@ import type { XcodeProject } from 'xcode';
|
|
|
4
4
|
import type { ConfigPlugin, Mod } from '../Plugin.types';
|
|
5
5
|
import type { ExpoPlist, InfoPlist } from '../ios/IosConfig.types';
|
|
6
6
|
import type { AppDelegateProjectFile } from '../ios/Paths';
|
|
7
|
-
|
|
7
|
+
type MutateInfoPlistAction = (expo: ExpoConfig, infoPlist: InfoPlist) => Promise<InfoPlist> | InfoPlist;
|
|
8
8
|
/**
|
|
9
9
|
* Helper method for creating mods from existing config functions.
|
|
10
10
|
*
|
|
@@ -16,7 +16,7 @@ export declare function createInfoPlistPluginWithPropertyGuard(action: MutateInf
|
|
|
16
16
|
expoConfigProperty: string;
|
|
17
17
|
expoPropertyGetter?: (config: ExpoConfig) => string;
|
|
18
18
|
}, name?: string): ConfigPlugin;
|
|
19
|
-
|
|
19
|
+
type MutateEntitlementsPlistAction = (expo: ExpoConfig, entitlements: JSONObject) => JSONObject;
|
|
20
20
|
/**
|
|
21
21
|
* Helper method for creating mods from existing config functions.
|
|
22
22
|
*
|