@expo/prebuild-config 8.0.4 → 8.0.6
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/plugins/icons/withAndroidIcons.d.ts +1 -1
- package/build/plugins/icons/withAndroidIcons.js +46 -27
- package/build/plugins/icons/withAndroidIcons.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/InterfaceBuilder.d.ts +23 -5
- package/build/plugins/unversioned/expo-splash-screen/InterfaceBuilder.js +47 -10
- package/build/plugins/unversioned/expo-splash-screen/InterfaceBuilder.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/getAndroidSplashConfig.d.ts +21 -7
- package/build/plugins/unversioned/expo-splash-screen/getAndroidSplashConfig.js +29 -3
- package/build/plugins/unversioned/expo-splash-screen/getAndroidSplashConfig.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/getIosSplashConfig.d.ts +1 -0
- package/build/plugins/unversioned/expo-splash-screen/getIosSplashConfig.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashDrawables.js +2 -2
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashDrawables.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashImages.d.ts +4 -4
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashImages.js +33 -19
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashImages.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashLegacyMainActivity.d.ts +3 -2
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashLegacyMainActivity.js +5 -5
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashLegacyMainActivity.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashMainActivity.d.ts +3 -0
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashMainActivity.js +58 -0
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashMainActivity.js.map +1 -0
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashScreen.d.ts +2 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashScreen.js +6 -41
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashScreen.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashStrings.d.ts +2 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashStrings.js +2 -2
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashStrings.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashStyles.d.ts +4 -3
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashStyles.js +45 -10
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashStyles.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashAssets.js +46 -67
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashAssets.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreen.js +11 -8
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreen.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreenStoryboard.js +32 -64
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreenStoryboard.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/{wtihIosSplashScreenStoryboardImage.js → withIosSplashScreenStoryboardImage.js} +7 -5
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreenStoryboardImage.js.map +1 -0
- package/build/plugins/withDefaultPlugins.js +1 -1
- package/build/plugins/withDefaultPlugins.js.map +1 -1
- package/package.json +3 -3
- package/build/plugins/unversioned/expo-splash-screen/wtihIosSplashScreenStoryboardImage.js.map +0 -1
- /package/build/plugins/unversioned/expo-splash-screen/{wtihIosSplashScreenStoryboardImage.d.ts → withIosSplashScreenStoryboardImage.d.ts} +0 -0
|
@@ -34,6 +34,6 @@ export declare function setIconAsync(projectRoot: string, { icon, backgroundColo
|
|
|
34
34
|
* - A backgroundImage is provided, or
|
|
35
35
|
* - A backgroundColor was specified
|
|
36
36
|
*/
|
|
37
|
-
export declare function configureAdaptiveIconAsync(projectRoot: string, foregroundImage: string, backgroundImage: string | null, monochromeImage: string | null, isAdaptive: boolean): Promise<void>;
|
|
37
|
+
export declare function configureAdaptiveIconAsync(projectRoot: string, foregroundImage: string, backgroundImage: string | null, backgroundColor: string | null, monochromeImage: string | null, isAdaptive: boolean): Promise<void>;
|
|
38
38
|
export declare const createAdaptiveIconXmlString: (backgroundImage: string | null, monochromeImage: string | null) => string;
|
|
39
39
|
export {};
|
|
@@ -72,15 +72,16 @@ const dpiValues = exports.dpiValues = {
|
|
|
72
72
|
scale: 4
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
const
|
|
75
|
+
const ICON_BASELINE_PIXEL_SIZE = 48;
|
|
76
|
+
const FOREGROUND_BASELINE_PIXEL_SIZE = 108;
|
|
76
77
|
const ANDROID_RES_PATH = exports.ANDROID_RES_PATH = 'android/app/src/main/res/';
|
|
77
78
|
const MIPMAP_ANYDPI_V26 = 'mipmap-anydpi-v26';
|
|
78
79
|
const ICON_BACKGROUND = 'iconBackground';
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
80
|
+
const IC_LAUNCHER_WEBP = 'ic_launcher.webp';
|
|
81
|
+
const IC_LAUNCHER_ROUND_WEBP = 'ic_launcher_round.webp';
|
|
82
|
+
const IC_LAUNCHER_BACKGROUND_WEBP = 'ic_launcher_background.webp';
|
|
83
|
+
const IC_LAUNCHER_FOREGROUND_WEBP = 'ic_launcher_foreground.webp';
|
|
84
|
+
const IC_LAUNCHER_MONOCHROME_WEBP = 'ic_launcher_monochrome.webp';
|
|
84
85
|
const IC_LAUNCHER_XML = 'ic_launcher.xml';
|
|
85
86
|
const IC_LAUNCHER_ROUND_XML = 'ic_launcher_round.xml';
|
|
86
87
|
const withAndroidIcons = config => {
|
|
@@ -156,9 +157,9 @@ async function setIconAsync(projectRoot, {
|
|
|
156
157
|
if (isAdaptive) {
|
|
157
158
|
await generateRoundIconAsync(projectRoot, icon, backgroundImage, backgroundColor);
|
|
158
159
|
} else {
|
|
159
|
-
await deleteIconNamedAsync(projectRoot,
|
|
160
|
+
await deleteIconNamedAsync(projectRoot, IC_LAUNCHER_ROUND_WEBP);
|
|
160
161
|
}
|
|
161
|
-
await configureAdaptiveIconAsync(projectRoot, icon, backgroundImage, monochromeImage, isAdaptive);
|
|
162
|
+
await configureAdaptiveIconAsync(projectRoot, icon, backgroundImage, backgroundColor, monochromeImage, isAdaptive);
|
|
162
163
|
return true;
|
|
163
164
|
}
|
|
164
165
|
|
|
@@ -173,7 +174,7 @@ async function configureLegacyIconAsync(projectRoot, icon, backgroundImage, back
|
|
|
173
174
|
icon,
|
|
174
175
|
backgroundImage,
|
|
175
176
|
backgroundColor,
|
|
176
|
-
outputImageFileName:
|
|
177
|
+
outputImageFileName: IC_LAUNCHER_WEBP,
|
|
177
178
|
imageCacheFolder: 'android-standard-square',
|
|
178
179
|
backgroundImageCacheFolder: 'android-standard-square-background'
|
|
179
180
|
});
|
|
@@ -182,7 +183,7 @@ async function generateRoundIconAsync(projectRoot, icon, backgroundImage, backgr
|
|
|
182
183
|
return generateMultiLayerImageAsync(projectRoot, {
|
|
183
184
|
icon,
|
|
184
185
|
borderRadiusRatio: 0.5,
|
|
185
|
-
outputImageFileName:
|
|
186
|
+
outputImageFileName: IC_LAUNCHER_ROUND_WEBP,
|
|
186
187
|
backgroundImage,
|
|
187
188
|
backgroundColor,
|
|
188
189
|
imageCacheFolder: 'android-standard-circle',
|
|
@@ -196,22 +197,22 @@ async function generateRoundIconAsync(projectRoot, icon, backgroundImage, backgr
|
|
|
196
197
|
* - A backgroundImage is provided, or
|
|
197
198
|
* - A backgroundColor was specified
|
|
198
199
|
*/
|
|
199
|
-
async function configureAdaptiveIconAsync(projectRoot, foregroundImage, backgroundImage, monochromeImage, isAdaptive) {
|
|
200
|
+
async function configureAdaptiveIconAsync(projectRoot, foregroundImage, backgroundImage, backgroundColor, monochromeImage, isAdaptive) {
|
|
200
201
|
if (monochromeImage) {
|
|
201
202
|
await generateMonochromeImageAsync(projectRoot, {
|
|
202
203
|
icon: monochromeImage,
|
|
203
204
|
imageCacheFolder: 'android-adaptive-monochrome',
|
|
204
|
-
outputImageFileName:
|
|
205
|
+
outputImageFileName: IC_LAUNCHER_MONOCHROME_WEBP
|
|
205
206
|
});
|
|
206
207
|
}
|
|
207
208
|
await generateMultiLayerImageAsync(projectRoot, {
|
|
208
|
-
backgroundColor
|
|
209
|
+
backgroundColor,
|
|
209
210
|
backgroundImage,
|
|
210
211
|
backgroundImageCacheFolder: 'android-adaptive-background',
|
|
211
|
-
outputImageFileName:
|
|
212
|
+
outputImageFileName: IC_LAUNCHER_FOREGROUND_WEBP,
|
|
212
213
|
icon: foregroundImage,
|
|
213
214
|
imageCacheFolder: 'android-adaptive-foreground',
|
|
214
|
-
backgroundImageFileName:
|
|
215
|
+
backgroundImageFileName: IC_LAUNCHER_BACKGROUND_WEBP
|
|
215
216
|
});
|
|
216
217
|
|
|
217
218
|
// create ic_launcher.xml and ic_launcher_round.xml
|
|
@@ -228,7 +229,7 @@ function setBackgroundColor(backgroundColor, colors) {
|
|
|
228
229
|
});
|
|
229
230
|
}
|
|
230
231
|
const createAdaptiveIconXmlString = (backgroundImage, monochromeImage) => {
|
|
231
|
-
const background = backgroundImage ? `@
|
|
232
|
+
const background = backgroundImage ? `@drawable/ic_launcher_background` : `@color/iconBackground`;
|
|
232
233
|
const iconElements = [`<background android:drawable="${background}"/>`, '<foreground android:drawable="@mipmap/ic_launcher_foreground"/>'];
|
|
233
234
|
if (monochromeImage) {
|
|
234
235
|
iconElements.push('<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>');
|
|
@@ -273,16 +274,16 @@ async function generateMultiLayerImageAsync(projectRoot, {
|
|
|
273
274
|
cacheType: imageCacheFolder,
|
|
274
275
|
src: icon,
|
|
275
276
|
scale,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
backgroundColor: backgroundColor ?? 'transparent',
|
|
278
|
+
borderRadiusRatio,
|
|
279
|
+
isForeground: outputImageFileName === IC_LAUNCHER_FOREGROUND_WEBP
|
|
279
280
|
});
|
|
280
281
|
if (backgroundImage) {
|
|
281
282
|
const backgroundLayer = await generateIconAsync(projectRoot, {
|
|
282
283
|
cacheType: backgroundImageCacheFolder,
|
|
283
284
|
src: backgroundImage,
|
|
284
285
|
scale,
|
|
285
|
-
backgroundColor: 'transparent',
|
|
286
|
+
backgroundColor: backgroundColor ?? 'transparent',
|
|
286
287
|
borderRadiusRatio
|
|
287
288
|
});
|
|
288
289
|
if (backgroundImageFileName) {
|
|
@@ -338,19 +339,37 @@ async function generateIconAsync(projectRoot, {
|
|
|
338
339
|
src,
|
|
339
340
|
scale,
|
|
340
341
|
backgroundColor,
|
|
341
|
-
borderRadiusRatio
|
|
342
|
+
borderRadiusRatio,
|
|
343
|
+
isForeground
|
|
342
344
|
}) {
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
+
const baseline = isForeground ? FOREGROUND_BASELINE_PIXEL_SIZE : ICON_BASELINE_PIXEL_SIZE;
|
|
346
|
+
const bgIconSizePx = baseline * scale;
|
|
347
|
+
const iconSizePx = bgIconSizePx * (isForeground ? 0.4 : 0.65);
|
|
348
|
+
const {
|
|
349
|
+
source: foreground
|
|
350
|
+
} = await (0, _imageUtils().generateImageAsync)({
|
|
345
351
|
projectRoot,
|
|
346
352
|
cacheType
|
|
347
353
|
}, {
|
|
348
354
|
src,
|
|
355
|
+
resizeMode: 'contain',
|
|
349
356
|
width: iconSizePx,
|
|
350
|
-
height: iconSizePx
|
|
357
|
+
height: iconSizePx
|
|
358
|
+
});
|
|
359
|
+
const background = await (0, _imageUtils().generateImageBackgroundAsync)({
|
|
360
|
+
width: bgIconSizePx,
|
|
361
|
+
height: bgIconSizePx,
|
|
362
|
+
backgroundColor: isForeground ? 'transparent' : backgroundColor,
|
|
351
363
|
resizeMode: 'cover',
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
364
|
+
borderRadius: borderRadiusRatio ? bgIconSizePx * borderRadiusRatio : undefined
|
|
365
|
+
});
|
|
366
|
+
const x = (bgIconSizePx - iconSizePx) / 2;
|
|
367
|
+
const y = x;
|
|
368
|
+
return (0, _imageUtils().compositeImagesAsync)({
|
|
369
|
+
background,
|
|
370
|
+
foreground,
|
|
371
|
+
x,
|
|
372
|
+
y
|
|
373
|
+
});
|
|
355
374
|
}
|
|
356
375
|
//# sourceMappingURL=withAndroidIcons.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAndroidIcons.js","names":["_configPlugins","data","require","_imageUtils","_fsExtra","_interopRequireDefault","_path","_withAndroidManifestIcons","e","__esModule","default","Colors","AndroidConfig","dpiValues","exports","mdpi","folderName","scale","hdpi","xhdpi","xxhdpi","xxxhdpi","BASELINE_PIXEL_SIZE","ANDROID_RES_PATH","MIPMAP_ANYDPI_V26","ICON_BACKGROUND","IC_LAUNCHER_PNG","IC_LAUNCHER_ROUND_PNG","IC_LAUNCHER_BACKGROUND_PNG","IC_LAUNCHER_FOREGROUND_PNG","IC_LAUNCHER_MONOCHROME_PNG","IC_LAUNCHER_XML","IC_LAUNCHER_ROUND_XML","withAndroidIcons","config","foregroundImage","backgroundColor","backgroundImage","monochromeImage","getAdaptiveIcon","icon","getIcon","withAndroidManifestIcons","withAndroidAdaptiveIconColors","withDangerousMod","setIconAsync","modRequest","projectRoot","isAdaptive","android","adaptiveIcon","setRoundIconManifest","manifest","application","Manifest","getMainApplicationOrThrow","$","withAndroidColors","modResults","setBackgroundColor","configureLegacyIconAsync","generateRoundIconAsync","deleteIconNamedAsync","configureAdaptiveIconAsync","generateMultiLayerImageAsync","outputImageFileName","imageCacheFolder","backgroundImageCacheFolder","borderRadiusRatio","generateMonochromeImageAsync","backgroundImageFileName","icLauncherXmlString","createAdaptiveIconXmlString","createAdaptiveIconXmlFiles","colors","assignColorValue","value","name","background","iconElements","push","join","add","anyDpiV26Directory","path","resolve","fs","ensureDir","launcherPath","launcherRoundPath","Promise","all","writeFile","map","existsSync","remove","iterateDpiValues","dpiFolder","iconLayer","generateIconAsync","cacheType","src","backgroundLayer","compositeImagesAsync","foreground","monochromeIcon","callback","Object","values","iconSizePx","generateImageAsync","width","height","resizeMode","borderRadius","undefined","source"],"sources":["../../../src/plugins/icons/withAndroidIcons.ts"],"sourcesContent":["import {\n AndroidConfig,\n ConfigPlugin,\n withAndroidColors,\n withDangerousMod,\n} from '@expo/config-plugins';\nimport { ResourceXML } from '@expo/config-plugins/build/android/Resources';\nimport { ExpoConfig } from '@expo/config-types';\nimport { compositeImagesAsync, generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { withAndroidManifestIcons } from './withAndroidManifestIcons';\n\nconst { Colors } = AndroidConfig;\n\ntype DPIString = 'mdpi' | 'hdpi' | 'xhdpi' | 'xxhdpi' | 'xxxhdpi';\ntype dpiMap = Record<DPIString, { folderName: string; scale: number }>;\n\nexport const dpiValues: dpiMap = {\n mdpi: { folderName: 'mipmap-mdpi', scale: 1 },\n hdpi: { folderName: 'mipmap-hdpi', scale: 1.5 },\n xhdpi: { folderName: 'mipmap-xhdpi', scale: 2 },\n xxhdpi: { folderName: 'mipmap-xxhdpi', scale: 3 },\n xxxhdpi: { folderName: 'mipmap-xxxhdpi', scale: 4 },\n};\nconst BASELINE_PIXEL_SIZE = 108;\nexport const ANDROID_RES_PATH = 'android/app/src/main/res/';\nconst MIPMAP_ANYDPI_V26 = 'mipmap-anydpi-v26';\nconst ICON_BACKGROUND = 'iconBackground';\nconst IC_LAUNCHER_PNG = 'ic_launcher.png';\nconst IC_LAUNCHER_ROUND_PNG = 'ic_launcher_round.png';\nconst IC_LAUNCHER_BACKGROUND_PNG = 'ic_launcher_background.png';\nconst IC_LAUNCHER_FOREGROUND_PNG = 'ic_launcher_foreground.png';\nconst IC_LAUNCHER_MONOCHROME_PNG = 'ic_launcher_monochrome.png';\nconst IC_LAUNCHER_XML = 'ic_launcher.xml';\nconst IC_LAUNCHER_ROUND_XML = 'ic_launcher_round.xml';\n\nexport const withAndroidIcons: ConfigPlugin = (config) => {\n const { foregroundImage, backgroundColor, backgroundImage, monochromeImage } =\n getAdaptiveIcon(config);\n const icon = foregroundImage ?? getIcon(config);\n\n if (!icon) {\n return config;\n }\n\n config = withAndroidManifestIcons(config);\n // Apply colors.xml changes\n config = withAndroidAdaptiveIconColors(config, backgroundColor);\n return withDangerousMod(config, [\n 'android',\n async (config) => {\n await setIconAsync(config.modRequest.projectRoot, {\n icon,\n backgroundColor,\n backgroundImage,\n monochromeImage,\n isAdaptive: !!config.android?.adaptiveIcon,\n });\n return config;\n },\n ]);\n};\n\nexport function setRoundIconManifest(\n config: Pick<ExpoConfig, 'android'>,\n manifest: AndroidConfig.Manifest.AndroidManifest\n): AndroidConfig.Manifest.AndroidManifest {\n const isAdaptive = !!config.android?.adaptiveIcon;\n const application = AndroidConfig.Manifest.getMainApplicationOrThrow(manifest);\n\n if (isAdaptive) {\n application.$['android:roundIcon'] = '@mipmap/ic_launcher_round';\n } else {\n delete application.$['android:roundIcon'];\n }\n return manifest;\n}\n\nconst withAndroidAdaptiveIconColors: ConfigPlugin<string | null> = (config, backgroundColor) => {\n return withAndroidColors(config, (config) => {\n config.modResults = setBackgroundColor(backgroundColor ?? '#FFFFFF', config.modResults);\n return config;\n });\n};\n\nexport function getIcon(config: ExpoConfig) {\n return config.android?.icon || config.icon || null;\n}\n\nexport function getAdaptiveIcon(config: ExpoConfig) {\n return {\n foregroundImage: config.android?.adaptiveIcon?.foregroundImage ?? null,\n backgroundColor: config.android?.adaptiveIcon?.backgroundColor ?? null,\n backgroundImage: config.android?.adaptiveIcon?.backgroundImage ?? null,\n monochromeImage: config.android?.adaptiveIcon?.monochromeImage ?? null,\n };\n}\n\n/**\n * Resizes the user-provided icon to create a set of legacy icon files in\n * their respective \"mipmap\" directories for <= Android 7, and creates a set of adaptive\n * icon files for > Android 7 from the adaptive icon files (if provided).\n */\nexport async function setIconAsync(\n projectRoot: string,\n {\n icon,\n backgroundColor,\n backgroundImage,\n monochromeImage,\n isAdaptive,\n }: {\n icon: string | null;\n backgroundColor: string | null;\n backgroundImage: string | null;\n monochromeImage: string | null;\n isAdaptive: boolean;\n }\n) {\n if (!icon) {\n return null;\n }\n\n await configureLegacyIconAsync(projectRoot, icon, backgroundImage, backgroundColor);\n if (isAdaptive) {\n await generateRoundIconAsync(projectRoot, icon, backgroundImage, backgroundColor);\n } else {\n await deleteIconNamedAsync(projectRoot, IC_LAUNCHER_ROUND_PNG);\n }\n await configureAdaptiveIconAsync(projectRoot, icon, backgroundImage, monochromeImage, isAdaptive);\n\n return true;\n}\n\n/**\n * Configures legacy icon files to be used on Android 7 and earlier. If adaptive icon configuration\n * was provided, we create a pseudo-adaptive icon by layering the provided files (or background\n * color if no backgroundImage is provided. If no backgroundImage and no backgroundColor are provided,\n * the background is set to transparent.)\n */\nasync function configureLegacyIconAsync(\n projectRoot: string,\n icon: string,\n backgroundImage: string | null,\n backgroundColor: string | null\n) {\n return generateMultiLayerImageAsync(projectRoot, {\n icon,\n backgroundImage,\n backgroundColor,\n outputImageFileName: IC_LAUNCHER_PNG,\n imageCacheFolder: 'android-standard-square',\n backgroundImageCacheFolder: 'android-standard-square-background',\n });\n}\n\nasync function generateRoundIconAsync(\n projectRoot: string,\n icon: string,\n backgroundImage: string | null,\n backgroundColor: string | null\n) {\n return generateMultiLayerImageAsync(projectRoot, {\n icon,\n borderRadiusRatio: 0.5,\n outputImageFileName: IC_LAUNCHER_ROUND_PNG,\n backgroundImage,\n backgroundColor,\n imageCacheFolder: 'android-standard-circle',\n backgroundImageCacheFolder: 'android-standard-round-background',\n });\n}\n\n/**\n * Configures adaptive icon files to be used on Android 8 and up. A foreground image must be provided,\n * and will have a transparent background unless:\n * - A backgroundImage is provided, or\n * - A backgroundColor was specified\n */\nexport async function configureAdaptiveIconAsync(\n projectRoot: string,\n foregroundImage: string,\n backgroundImage: string | null,\n monochromeImage: string | null,\n isAdaptive: boolean\n) {\n if (monochromeImage) {\n await generateMonochromeImageAsync(projectRoot, {\n icon: monochromeImage,\n imageCacheFolder: 'android-adaptive-monochrome',\n outputImageFileName: IC_LAUNCHER_MONOCHROME_PNG,\n });\n }\n await generateMultiLayerImageAsync(projectRoot, {\n backgroundColor: 'transparent',\n backgroundImage,\n backgroundImageCacheFolder: 'android-adaptive-background',\n outputImageFileName: IC_LAUNCHER_FOREGROUND_PNG,\n icon: foregroundImage,\n imageCacheFolder: 'android-adaptive-foreground',\n backgroundImageFileName: IC_LAUNCHER_BACKGROUND_PNG,\n });\n\n // create ic_launcher.xml and ic_launcher_round.xml\n const icLauncherXmlString = createAdaptiveIconXmlString(backgroundImage, monochromeImage);\n await createAdaptiveIconXmlFiles(\n projectRoot,\n icLauncherXmlString,\n // If the user only defined icon and not android.adaptiveIcon, then skip enabling the layering system\n // this will scale the image down and present it uncropped.\n isAdaptive\n );\n}\n\nfunction setBackgroundColor(backgroundColor: string | null, colors: ResourceXML) {\n return Colors.assignColorValue(colors, {\n value: backgroundColor,\n name: ICON_BACKGROUND,\n });\n}\n\nexport const createAdaptiveIconXmlString = (\n backgroundImage: string | null,\n monochromeImage: string | null\n) => {\n const background = backgroundImage ? `@mipmap/ic_launcher_background` : `@color/iconBackground`;\n\n const iconElements: string[] = [\n `<background android:drawable=\"${background}\"/>`,\n '<foreground android:drawable=\"@mipmap/ic_launcher_foreground\"/>',\n ];\n\n if (monochromeImage) {\n iconElements.push('<monochrome android:drawable=\"@mipmap/ic_launcher_monochrome\"/>');\n }\n\n return `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n ${iconElements.join('\\n ')}\n</adaptive-icon>`;\n};\n\nasync function createAdaptiveIconXmlFiles(\n projectRoot: string,\n icLauncherXmlString: string,\n add: boolean\n) {\n const anyDpiV26Directory = path.resolve(projectRoot, ANDROID_RES_PATH, MIPMAP_ANYDPI_V26);\n await fs.ensureDir(anyDpiV26Directory);\n const launcherPath = path.resolve(anyDpiV26Directory, IC_LAUNCHER_XML);\n const launcherRoundPath = path.resolve(anyDpiV26Directory, IC_LAUNCHER_ROUND_XML);\n if (add) {\n await Promise.all([\n fs.writeFile(launcherPath, icLauncherXmlString),\n fs.writeFile(launcherRoundPath, icLauncherXmlString),\n ]);\n } else {\n // Remove the xml if the icon switches from adaptive to standard.\n await Promise.all(\n [launcherPath, launcherRoundPath].map(async (path) => {\n if (fs.existsSync(path)) {\n return fs.remove(path);\n }\n })\n );\n }\n}\n\nasync function generateMultiLayerImageAsync(\n projectRoot: string,\n {\n icon,\n backgroundColor,\n backgroundImage,\n imageCacheFolder,\n backgroundImageCacheFolder,\n borderRadiusRatio,\n outputImageFileName,\n backgroundImageFileName,\n }: {\n icon: string;\n backgroundImage: string | null;\n backgroundColor: string | null;\n imageCacheFolder: string;\n backgroundImageCacheFolder: string;\n backgroundImageFileName?: string;\n borderRadiusRatio?: number;\n outputImageFileName: string;\n }\n) {\n await iterateDpiValues(projectRoot, async ({ dpiFolder, scale }) => {\n let iconLayer = await generateIconAsync(projectRoot, {\n cacheType: imageCacheFolder,\n src: icon,\n scale,\n // backgroundImage overrides backgroundColor\n backgroundColor: backgroundImage ? 'transparent' : (backgroundColor ?? 'transparent'),\n borderRadiusRatio,\n });\n\n if (backgroundImage) {\n const backgroundLayer = await generateIconAsync(projectRoot, {\n cacheType: backgroundImageCacheFolder,\n src: backgroundImage,\n scale,\n backgroundColor: 'transparent',\n borderRadiusRatio,\n });\n\n if (backgroundImageFileName) {\n await fs.writeFile(path.resolve(dpiFolder, backgroundImageFileName), backgroundLayer);\n } else {\n iconLayer = await compositeImagesAsync({\n foreground: iconLayer,\n background: backgroundLayer,\n });\n }\n } else if (backgroundImageFileName) {\n // Remove any instances of ic_launcher_background.png that are there from previous icons\n await deleteIconNamedAsync(projectRoot, backgroundImageFileName);\n }\n\n await fs.ensureDir(dpiFolder);\n await fs.writeFile(path.resolve(dpiFolder, outputImageFileName), iconLayer);\n });\n}\n\nasync function generateMonochromeImageAsync(\n projectRoot: string,\n {\n icon,\n imageCacheFolder,\n outputImageFileName,\n }: { icon: string; imageCacheFolder: string; outputImageFileName: string }\n) {\n await iterateDpiValues(projectRoot, async ({ dpiFolder, scale }) => {\n const monochromeIcon = await generateIconAsync(projectRoot, {\n cacheType: imageCacheFolder,\n src: icon,\n scale,\n backgroundColor: 'transparent',\n });\n await fs.ensureDir(dpiFolder);\n await fs.writeFile(path.resolve(dpiFolder, outputImageFileName), monochromeIcon);\n });\n}\n\nfunction iterateDpiValues(\n projectRoot: string,\n callback: (value: { dpiFolder: string; folderName: string; scale: number }) => Promise<void>\n) {\n return Promise.all(\n Object.values(dpiValues).map((value) =>\n callback({\n dpiFolder: path.resolve(projectRoot, ANDROID_RES_PATH, value.folderName),\n ...value,\n })\n )\n );\n}\n\nasync function deleteIconNamedAsync(projectRoot: string, name: string) {\n return iterateDpiValues(projectRoot, ({ dpiFolder }) => {\n return fs.remove(path.resolve(dpiFolder, name));\n });\n}\n\nasync function generateIconAsync(\n projectRoot: string,\n {\n cacheType,\n src,\n scale,\n backgroundColor,\n borderRadiusRatio,\n }: {\n cacheType: string;\n src: string;\n scale: number;\n backgroundColor: string;\n borderRadiusRatio?: number;\n }\n) {\n const iconSizePx = BASELINE_PIXEL_SIZE * scale;\n\n return (\n await generateImageAsync(\n { projectRoot, cacheType },\n {\n src,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor,\n borderRadius: borderRadiusRatio ? iconSizePx * borderRadiusRatio : undefined,\n }\n )\n ).source;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EA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,eAAI,CAACC,OAAO,CAACY,SAAS,EAAEhC,mBAAmB,CAAC,EAAEwC,cAAc,CAAC;EAClF,CAAC,CAAC;AACJ;AAEA,SAAST,gBAAgBA,CACvBjD,WAAmB,EACnB2D,QAA4F,EAC5F;EACA,OAAOhB,OAAO,CAACC,GAAG,CAChBgB,MAAM,CAACC,MAAM,CAAC/F,SAAS,CAAC,CAACgF,GAAG,CAAEjB,KAAK,IACjC8B,QAAQ,CAAC;IACPT,SAAS,EAAEb,eAAI,CAACC,OAAO,CAACtC,WAAW,EAAExB,gBAAgB,EAAEqD,KAAK,CAAC5D,UAAU,CAAC;IACxE,GAAG4D;EACL,CAAC,CACH,CACF,CAAC;AACH;AAEA,eAAed,oBAAoBA,CAACf,WAAmB,EAAE8B,IAAY,EAAE;EACrE,OAAOmB,gBAAgB,CAACjD,WAAW,EAAE,CAAC;IAAEkD;EAAU,CAAC,KAAK;IACtD,OAAOX,kBAAE,CAACS,MAAM,CAACX,eAAI,CAACC,OAAO,CAACY,SAAS,EAAEpB,IAAI,CAAC,CAAC;EACjD,CAAC,CAAC;AACJ;AAEA,eAAesB,iBAAiBA,CAC9BpD,WAAmB,EACnB;EACEqD,SAAS;EACTC,GAAG;EACHpF,KAAK;EACLmB,eAAe;EACfgC;AAOF,CAAC,EACD;EACA,MAAMyC,UAAU,GAAGvF,mBAAmB,GAAGL,KAAK;EAE9C,OAAO,CACL,MAAM,IAAA6F,gCAAkB,EACtB;IAAE/D,WAAW;IAAEqD;EAAU,CAAC,EAC1B;IACEC,GAAG;IACHU,KAAK,EAAEF,UAAU;IACjBG,MAAM,EAAEH,UAAU;IAClBI,UAAU,EAAE,OAAO;IACnB7E,eAAe;IACf8E,YAAY,EAAE9C,iBAAiB,GAAGyC,UAAU,GAAGzC,iBAAiB,GAAG+C;EACrE,CACF,CAAC,EACDC,MAAM;AACV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"withAndroidIcons.js","names":["_configPlugins","data","require","_imageUtils","_fsExtra","_interopRequireDefault","_path","_withAndroidManifestIcons","e","__esModule","default","Colors","AndroidConfig","dpiValues","exports","mdpi","folderName","scale","hdpi","xhdpi","xxhdpi","xxxhdpi","ICON_BASELINE_PIXEL_SIZE","FOREGROUND_BASELINE_PIXEL_SIZE","ANDROID_RES_PATH","MIPMAP_ANYDPI_V26","ICON_BACKGROUND","IC_LAUNCHER_WEBP","IC_LAUNCHER_ROUND_WEBP","IC_LAUNCHER_BACKGROUND_WEBP","IC_LAUNCHER_FOREGROUND_WEBP","IC_LAUNCHER_MONOCHROME_WEBP","IC_LAUNCHER_XML","IC_LAUNCHER_ROUND_XML","withAndroidIcons","config","foregroundImage","backgroundColor","backgroundImage","monochromeImage","getAdaptiveIcon","icon","getIcon","withAndroidManifestIcons","withAndroidAdaptiveIconColors","withDangerousMod","setIconAsync","modRequest","projectRoot","isAdaptive","android","adaptiveIcon","setRoundIconManifest","manifest","application","Manifest","getMainApplicationOrThrow","$","withAndroidColors","modResults","setBackgroundColor","configureLegacyIconAsync","generateRoundIconAsync","deleteIconNamedAsync","configureAdaptiveIconAsync","generateMultiLayerImageAsync","outputImageFileName","imageCacheFolder","backgroundImageCacheFolder","borderRadiusRatio","generateMonochromeImageAsync","backgroundImageFileName","icLauncherXmlString","createAdaptiveIconXmlString","createAdaptiveIconXmlFiles","colors","assignColorValue","value","name","background","iconElements","push","join","add","anyDpiV26Directory","path","resolve","fs","ensureDir","launcherPath","launcherRoundPath","Promise","all","writeFile","map","existsSync","remove","iterateDpiValues","dpiFolder","iconLayer","generateIconAsync","cacheType","src","isForeground","backgroundLayer","compositeImagesAsync","foreground","monochromeIcon","callback","Object","values","baseline","bgIconSizePx","iconSizePx","source","generateImageAsync","resizeMode","width","height","generateImageBackgroundAsync","borderRadius","undefined","x","y"],"sources":["../../../src/plugins/icons/withAndroidIcons.ts"],"sourcesContent":["import {\n AndroidConfig,\n ConfigPlugin,\n withAndroidColors,\n withDangerousMod,\n} from '@expo/config-plugins';\nimport { ResourceXML } from '@expo/config-plugins/build/android/Resources';\nimport { ExpoConfig } from '@expo/config-types';\nimport {\n generateImageAsync,\n compositeImagesAsync,\n generateImageBackgroundAsync,\n} from '@expo/image-utils';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { withAndroidManifestIcons } from './withAndroidManifestIcons';\n\nconst { Colors } = AndroidConfig;\n\ntype DPIString = 'mdpi' | 'hdpi' | 'xhdpi' | 'xxhdpi' | 'xxxhdpi';\ntype dpiMap = Record<DPIString, { folderName: string; scale: number }>;\n\nexport const dpiValues: dpiMap = {\n mdpi: { folderName: 'mipmap-mdpi', scale: 1 },\n hdpi: { folderName: 'mipmap-hdpi', scale: 1.5 },\n xhdpi: { folderName: 'mipmap-xhdpi', scale: 2 },\n xxhdpi: { folderName: 'mipmap-xxhdpi', scale: 3 },\n xxxhdpi: { folderName: 'mipmap-xxxhdpi', scale: 4 },\n};\nconst ICON_BASELINE_PIXEL_SIZE = 48;\nconst FOREGROUND_BASELINE_PIXEL_SIZE = 108;\n\nexport const ANDROID_RES_PATH = 'android/app/src/main/res/';\nconst MIPMAP_ANYDPI_V26 = 'mipmap-anydpi-v26';\nconst ICON_BACKGROUND = 'iconBackground';\nconst IC_LAUNCHER_WEBP = 'ic_launcher.webp';\nconst IC_LAUNCHER_ROUND_WEBP = 'ic_launcher_round.webp';\nconst IC_LAUNCHER_BACKGROUND_WEBP = 'ic_launcher_background.webp';\nconst IC_LAUNCHER_FOREGROUND_WEBP = 'ic_launcher_foreground.webp';\nconst IC_LAUNCHER_MONOCHROME_WEBP = 'ic_launcher_monochrome.webp';\nconst IC_LAUNCHER_XML = 'ic_launcher.xml';\nconst IC_LAUNCHER_ROUND_XML = 'ic_launcher_round.xml';\n\nexport const withAndroidIcons: ConfigPlugin = (config) => {\n const { foregroundImage, backgroundColor, backgroundImage, monochromeImage } =\n getAdaptiveIcon(config);\n const icon = foregroundImage ?? getIcon(config);\n\n if (!icon) {\n return config;\n }\n\n config = withAndroidManifestIcons(config);\n // Apply colors.xml changes\n config = withAndroidAdaptiveIconColors(config, backgroundColor);\n return withDangerousMod(config, [\n 'android',\n async (config) => {\n await setIconAsync(config.modRequest.projectRoot, {\n icon,\n backgroundColor,\n backgroundImage,\n monochromeImage,\n isAdaptive: !!config.android?.adaptiveIcon,\n });\n return config;\n },\n ]);\n};\n\nexport function setRoundIconManifest(\n config: Pick<ExpoConfig, 'android'>,\n manifest: AndroidConfig.Manifest.AndroidManifest\n): AndroidConfig.Manifest.AndroidManifest {\n const isAdaptive = !!config.android?.adaptiveIcon;\n const application = AndroidConfig.Manifest.getMainApplicationOrThrow(manifest);\n\n if (isAdaptive) {\n application.$['android:roundIcon'] = '@mipmap/ic_launcher_round';\n } else {\n delete application.$['android:roundIcon'];\n }\n return manifest;\n}\n\nconst withAndroidAdaptiveIconColors: ConfigPlugin<string | null> = (config, backgroundColor) => {\n return withAndroidColors(config, (config) => {\n config.modResults = setBackgroundColor(backgroundColor ?? '#FFFFFF', config.modResults);\n return config;\n });\n};\n\nexport function getIcon(config: ExpoConfig) {\n return config.android?.icon || config.icon || null;\n}\n\nexport function getAdaptiveIcon(config: ExpoConfig) {\n return {\n foregroundImage: config.android?.adaptiveIcon?.foregroundImage ?? null,\n backgroundColor: config.android?.adaptiveIcon?.backgroundColor ?? null,\n backgroundImage: config.android?.adaptiveIcon?.backgroundImage ?? null,\n monochromeImage: config.android?.adaptiveIcon?.monochromeImage ?? null,\n };\n}\n\n/**\n * Resizes the user-provided icon to create a set of legacy icon files in\n * their respective \"mipmap\" directories for <= Android 7, and creates a set of adaptive\n * icon files for > Android 7 from the adaptive icon files (if provided).\n */\nexport async function setIconAsync(\n projectRoot: string,\n {\n icon,\n backgroundColor,\n backgroundImage,\n monochromeImage,\n isAdaptive,\n }: {\n icon: string | null;\n backgroundColor: string | null;\n backgroundImage: string | null;\n monochromeImage: string | null;\n isAdaptive: boolean;\n }\n) {\n if (!icon) {\n return null;\n }\n\n await configureLegacyIconAsync(projectRoot, icon, backgroundImage, backgroundColor);\n if (isAdaptive) {\n await generateRoundIconAsync(projectRoot, icon, backgroundImage, backgroundColor);\n } else {\n await deleteIconNamedAsync(projectRoot, IC_LAUNCHER_ROUND_WEBP);\n }\n await configureAdaptiveIconAsync(\n projectRoot,\n icon,\n backgroundImage,\n backgroundColor,\n monochromeImage,\n isAdaptive\n );\n\n return true;\n}\n\n/**\n * Configures legacy icon files to be used on Android 7 and earlier. If adaptive icon configuration\n * was provided, we create a pseudo-adaptive icon by layering the provided files (or background\n * color if no backgroundImage is provided. If no backgroundImage and no backgroundColor are provided,\n * the background is set to transparent.)\n */\nasync function configureLegacyIconAsync(\n projectRoot: string,\n icon: string,\n backgroundImage: string | null,\n backgroundColor: string | null\n) {\n return generateMultiLayerImageAsync(projectRoot, {\n icon,\n backgroundImage,\n backgroundColor,\n outputImageFileName: IC_LAUNCHER_WEBP,\n imageCacheFolder: 'android-standard-square',\n backgroundImageCacheFolder: 'android-standard-square-background',\n });\n}\n\nasync function generateRoundIconAsync(\n projectRoot: string,\n icon: string,\n backgroundImage: string | null,\n backgroundColor: string | null\n) {\n return generateMultiLayerImageAsync(projectRoot, {\n icon,\n borderRadiusRatio: 0.5,\n outputImageFileName: IC_LAUNCHER_ROUND_WEBP,\n backgroundImage,\n backgroundColor,\n imageCacheFolder: 'android-standard-circle',\n backgroundImageCacheFolder: 'android-standard-round-background',\n });\n}\n\n/**\n * Configures adaptive icon files to be used on Android 8 and up. A foreground image must be provided,\n * and will have a transparent background unless:\n * - A backgroundImage is provided, or\n * - A backgroundColor was specified\n */\nexport async function configureAdaptiveIconAsync(\n projectRoot: string,\n foregroundImage: string,\n backgroundImage: string | null,\n backgroundColor: string | null,\n monochromeImage: string | null,\n isAdaptive: boolean\n) {\n if (monochromeImage) {\n await generateMonochromeImageAsync(projectRoot, {\n icon: monochromeImage,\n imageCacheFolder: 'android-adaptive-monochrome',\n outputImageFileName: IC_LAUNCHER_MONOCHROME_WEBP,\n });\n }\n await generateMultiLayerImageAsync(projectRoot, {\n backgroundColor,\n backgroundImage,\n backgroundImageCacheFolder: 'android-adaptive-background',\n outputImageFileName: IC_LAUNCHER_FOREGROUND_WEBP,\n icon: foregroundImage,\n imageCacheFolder: 'android-adaptive-foreground',\n backgroundImageFileName: IC_LAUNCHER_BACKGROUND_WEBP,\n });\n\n // create ic_launcher.xml and ic_launcher_round.xml\n const icLauncherXmlString = createAdaptiveIconXmlString(backgroundImage, monochromeImage);\n await createAdaptiveIconXmlFiles(\n projectRoot,\n icLauncherXmlString,\n // If the user only defined icon and not android.adaptiveIcon, then skip enabling the layering system\n // this will scale the image down and present it uncropped.\n isAdaptive\n );\n}\n\nfunction setBackgroundColor(backgroundColor: string | null, colors: ResourceXML) {\n return Colors.assignColorValue(colors, {\n value: backgroundColor,\n name: ICON_BACKGROUND,\n });\n}\n\nexport const createAdaptiveIconXmlString = (\n backgroundImage: string | null,\n monochromeImage: string | null\n) => {\n const background = backgroundImage ? `@drawable/ic_launcher_background` : `@color/iconBackground`;\n\n const iconElements: string[] = [\n `<background android:drawable=\"${background}\"/>`,\n '<foreground android:drawable=\"@mipmap/ic_launcher_foreground\"/>',\n ];\n\n if (monochromeImage) {\n iconElements.push('<monochrome android:drawable=\"@mipmap/ic_launcher_monochrome\"/>');\n }\n\n return `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n ${iconElements.join('\\n ')}\n</adaptive-icon>`;\n};\n\nasync function createAdaptiveIconXmlFiles(\n projectRoot: string,\n icLauncherXmlString: string,\n add: boolean\n) {\n const anyDpiV26Directory = path.resolve(projectRoot, ANDROID_RES_PATH, MIPMAP_ANYDPI_V26);\n await fs.ensureDir(anyDpiV26Directory);\n const launcherPath = path.resolve(anyDpiV26Directory, IC_LAUNCHER_XML);\n const launcherRoundPath = path.resolve(anyDpiV26Directory, IC_LAUNCHER_ROUND_XML);\n if (add) {\n await Promise.all([\n fs.writeFile(launcherPath, icLauncherXmlString),\n fs.writeFile(launcherRoundPath, icLauncherXmlString),\n ]);\n } else {\n // Remove the xml if the icon switches from adaptive to standard.\n await Promise.all(\n [launcherPath, launcherRoundPath].map(async (path) => {\n if (fs.existsSync(path)) {\n return fs.remove(path);\n }\n })\n );\n }\n}\n\nasync function generateMultiLayerImageAsync(\n projectRoot: string,\n {\n icon,\n backgroundColor,\n backgroundImage,\n imageCacheFolder,\n backgroundImageCacheFolder,\n borderRadiusRatio,\n outputImageFileName,\n backgroundImageFileName,\n }: {\n icon: string;\n backgroundImage: string | null;\n backgroundColor: string | null;\n imageCacheFolder: string;\n backgroundImageCacheFolder: string;\n backgroundImageFileName?: string;\n borderRadiusRatio?: number;\n outputImageFileName: string;\n }\n) {\n await iterateDpiValues(projectRoot, async ({ dpiFolder, scale }) => {\n let iconLayer = await generateIconAsync(projectRoot, {\n cacheType: imageCacheFolder,\n src: icon,\n scale,\n backgroundColor: backgroundColor ?? 'transparent',\n borderRadiusRatio,\n isForeground: outputImageFileName === IC_LAUNCHER_FOREGROUND_WEBP,\n });\n\n if (backgroundImage) {\n const backgroundLayer = await generateIconAsync(projectRoot, {\n cacheType: backgroundImageCacheFolder,\n src: backgroundImage,\n scale,\n backgroundColor: backgroundColor ?? 'transparent',\n borderRadiusRatio,\n });\n\n if (backgroundImageFileName) {\n await fs.writeFile(path.resolve(dpiFolder, backgroundImageFileName), backgroundLayer);\n } else {\n iconLayer = await compositeImagesAsync({\n foreground: iconLayer,\n background: backgroundLayer,\n });\n }\n } else if (backgroundImageFileName) {\n // Remove any instances of ic_launcher_background.png that are there from previous icons\n await deleteIconNamedAsync(projectRoot, backgroundImageFileName);\n }\n\n await fs.ensureDir(dpiFolder);\n await fs.writeFile(path.resolve(dpiFolder, outputImageFileName), iconLayer);\n });\n}\n\nasync function generateMonochromeImageAsync(\n projectRoot: string,\n {\n icon,\n imageCacheFolder,\n outputImageFileName,\n }: { icon: string; imageCacheFolder: string; outputImageFileName: string }\n) {\n await iterateDpiValues(projectRoot, async ({ dpiFolder, scale }) => {\n const monochromeIcon = await generateIconAsync(projectRoot, {\n cacheType: imageCacheFolder,\n src: icon,\n scale,\n backgroundColor: 'transparent',\n });\n await fs.ensureDir(dpiFolder);\n await fs.writeFile(path.resolve(dpiFolder, outputImageFileName), monochromeIcon);\n });\n}\n\nfunction iterateDpiValues(\n projectRoot: string,\n callback: (value: { dpiFolder: string; folderName: string; scale: number }) => Promise<void>\n) {\n return Promise.all(\n Object.values(dpiValues).map((value) =>\n callback({\n dpiFolder: path.resolve(projectRoot, ANDROID_RES_PATH, value.folderName),\n ...value,\n })\n )\n );\n}\n\nasync function deleteIconNamedAsync(projectRoot: string, name: string) {\n return iterateDpiValues(projectRoot, ({ dpiFolder }) => {\n return fs.remove(path.resolve(dpiFolder, name));\n });\n}\n\nasync function generateIconAsync(\n projectRoot: string,\n {\n cacheType,\n src,\n scale,\n backgroundColor,\n borderRadiusRatio,\n isForeground,\n }: {\n cacheType: string;\n src: string;\n scale: number;\n backgroundColor: string;\n borderRadiusRatio?: number;\n isForeground?: boolean;\n }\n) {\n const baseline = isForeground ? FOREGROUND_BASELINE_PIXEL_SIZE : ICON_BASELINE_PIXEL_SIZE;\n const bgIconSizePx = baseline * scale;\n const iconSizePx = bgIconSizePx * (isForeground ? 0.4 : 0.65);\n\n const { source: foreground } = await generateImageAsync(\n { projectRoot, cacheType },\n {\n src,\n resizeMode: 'contain',\n width: iconSizePx,\n height: iconSizePx,\n }\n );\n\n const background = await generateImageBackgroundAsync({\n width: bgIconSizePx,\n height: bgIconSizePx,\n backgroundColor: isForeground ? 'transparent' : backgroundColor,\n resizeMode: 'cover',\n borderRadius: borderRadiusRatio ? bgIconSizePx * borderRadiusRatio : undefined,\n });\n\n const x = (bgIconSizePx - iconSizePx) / 2;\n const y = x;\n\n return compositeImagesAsync({ background, foreground, x, y });\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,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C,EAC1B;IACEC,GAAG;IACHc,UAAU,EAAE,SAAS;IACrBC,KAAK,EAAEJ,UAAU;IACjBK,MAAM,EAAEL;EACV,CACF,CAAC;EAED,MAAMlC,UAAU,GAAG,MAAM,IAAAwC,0CAA4B,EAAC;IACpDF,KAAK,EAAEL,YAAY;IACnBM,MAAM,EAAEN,YAAY;IACpB3E,eAAe,EAAEkE,YAAY,GAAG,aAAa,GAAGlE,eAAe;IAC/D+E,UAAU,EAAE,OAAO;IACnBI,YAAY,EAAEnD,iBAAiB,GAAG2C,YAAY,GAAG3C,iBAAiB,GAAGoD;EACvE,CAAC,CAAC;EAEF,MAAMC,CAAC,GAAG,CAACV,YAAY,GAAGC,UAAU,IAAI,CAAC;EACzC,MAAMU,CAAC,GAAGD,CAAC;EAEX,OAAO,IAAAjB,kCAAoB,EAAC;IAAE1B,UAAU;IAAE2B,UAAU;IAAEgB,CAAC;IAAEC;EAAE,CAAC,CAAC;AAC/D","ignoreList":[]}
|
|
@@ -50,7 +50,7 @@ export type IBFontDescription = IBItem<{
|
|
|
50
50
|
type?: 'system' | 'boldSystem' | 'UICTFontTextStyleCallout' | 'UICTFontTextStyleBody' | string;
|
|
51
51
|
}>;
|
|
52
52
|
export type ImageContentMode = 'scaleAspectFit' | 'scaleAspectFill';
|
|
53
|
-
export type ConstraintAttribute = 'top' | 'bottom' | 'trailing' | 'leading';
|
|
53
|
+
export type ConstraintAttribute = 'top' | 'bottom' | 'trailing' | 'leading' | 'centerX' | 'centerY';
|
|
54
54
|
export type IBImageView = IBItem<{
|
|
55
55
|
id: string;
|
|
56
56
|
userLabel: string;
|
|
@@ -58,8 +58,8 @@ export type IBImageView = IBItem<{
|
|
|
58
58
|
clipsSubviews?: IBBoolean;
|
|
59
59
|
userInteractionEnabled: IBBoolean;
|
|
60
60
|
contentMode: IBContentMode;
|
|
61
|
-
horizontalHuggingPriority
|
|
62
|
-
verticalHuggingPriority
|
|
61
|
+
horizontalHuggingPriority?: number;
|
|
62
|
+
verticalHuggingPriority?: number;
|
|
63
63
|
insetsLayoutMarginsFromSafeArea?: IBBoolean;
|
|
64
64
|
translatesAutoresizingMaskIntoConstraints?: IBBoolean;
|
|
65
65
|
}, {
|
|
@@ -130,7 +130,13 @@ export type IBViewController = IBItem<{
|
|
|
130
130
|
}>[];
|
|
131
131
|
color: IBItem<{
|
|
132
132
|
key: string | 'backgroundColor';
|
|
133
|
-
systemColor
|
|
133
|
+
systemColor?: string | 'systemBackgroundColor';
|
|
134
|
+
red?: string;
|
|
135
|
+
green?: string;
|
|
136
|
+
blue?: string;
|
|
137
|
+
alpha?: string;
|
|
138
|
+
colorSpace?: string;
|
|
139
|
+
customColorSpace?: string;
|
|
134
140
|
}>[];
|
|
135
141
|
constraints: IBItem<object, {
|
|
136
142
|
constraint: IBConstraint[];
|
|
@@ -199,9 +205,11 @@ export declare function createConstraintId(...attributes: string[]): string;
|
|
|
199
205
|
export declare function removeImageFromSplashScreen(xml: IBSplashScreenDocument, { imageName }: {
|
|
200
206
|
imageName: string;
|
|
201
207
|
}): IBSplashScreenDocument;
|
|
202
|
-
export declare function applyImageToSplashScreenXML(xml: IBSplashScreenDocument, { imageName, contentMode, }: {
|
|
208
|
+
export declare function applyImageToSplashScreenXML(xml: IBSplashScreenDocument, { imageName, contentMode, backgroundColor, logoWidth, }: {
|
|
203
209
|
imageName: string;
|
|
204
210
|
contentMode: ImageContentMode;
|
|
211
|
+
backgroundColor: string;
|
|
212
|
+
logoWidth?: number;
|
|
205
213
|
}): IBSplashScreenDocument;
|
|
206
214
|
/**
|
|
207
215
|
* IB does not allow two items to have the same ID.
|
|
@@ -220,3 +228,13 @@ export declare function removeExisting<TItem extends {
|
|
|
220
228
|
export declare function toString(xml: any): string;
|
|
221
229
|
/** Parse string contents into an object. */
|
|
222
230
|
export declare function toObjectAsync(contents: string): Promise<any>;
|
|
231
|
+
export declare const parseColor: (value: string) => Color;
|
|
232
|
+
type Color = {
|
|
233
|
+
hex: string;
|
|
234
|
+
rgb: {
|
|
235
|
+
red: string;
|
|
236
|
+
green: string;
|
|
237
|
+
blue: string;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
export {};
|
|
@@ -7,6 +7,7 @@ exports.applyImageToSplashScreenXML = applyImageToSplashScreenXML;
|
|
|
7
7
|
exports.createConstraint = createConstraint;
|
|
8
8
|
exports.createConstraintId = createConstraintId;
|
|
9
9
|
exports.ensureUniquePush = ensureUniquePush;
|
|
10
|
+
exports.parseColor = void 0;
|
|
10
11
|
exports.removeExisting = removeExisting;
|
|
11
12
|
exports.removeImageFromSplashScreen = removeImageFromSplashScreen;
|
|
12
13
|
exports.toObjectAsync = toObjectAsync;
|
|
@@ -71,22 +72,25 @@ function removeImageFromSplashScreen(xml, {
|
|
|
71
72
|
return xml;
|
|
72
73
|
}
|
|
73
74
|
function getAbsoluteConstraints(childId, parentId) {
|
|
74
|
-
return [createConstraint([childId, '
|
|
75
|
+
return [createConstraint([childId, 'centerX'], [parentId, 'centerX']), createConstraint([childId, 'centerY'], [parentId, 'centerY'])];
|
|
75
76
|
}
|
|
76
77
|
function applyImageToSplashScreenXML(xml, {
|
|
77
78
|
imageName,
|
|
78
|
-
contentMode
|
|
79
|
+
contentMode,
|
|
80
|
+
backgroundColor,
|
|
81
|
+
logoWidth = 100
|
|
79
82
|
}) {
|
|
80
|
-
const
|
|
81
|
-
const
|
|
83
|
+
const mainView = xml.document.scenes[0].scene[0].objects[0].viewController[0].view[0];
|
|
84
|
+
const width = logoWidth;
|
|
85
|
+
const height = logoWidth;
|
|
86
|
+
const x = (mainView.rect[0].$.width - width) / 2;
|
|
87
|
+
const y = (mainView.rect[0].$.height - height) / 2;
|
|
82
88
|
const imageView = {
|
|
83
89
|
$: {
|
|
84
90
|
id: IMAGE_ID,
|
|
85
91
|
userLabel: imageName,
|
|
86
92
|
image: imageName,
|
|
87
93
|
contentMode,
|
|
88
|
-
horizontalHuggingPriority: 251,
|
|
89
|
-
verticalHuggingPriority: 251,
|
|
90
94
|
clipsSubviews: true,
|
|
91
95
|
userInteractionEnabled: false,
|
|
92
96
|
translatesAutoresizingMaskIntoConstraints: false
|
|
@@ -94,17 +98,17 @@ function applyImageToSplashScreenXML(xml, {
|
|
|
94
98
|
rect: [{
|
|
95
99
|
$: {
|
|
96
100
|
key: 'frame',
|
|
97
|
-
x
|
|
98
|
-
y
|
|
101
|
+
x,
|
|
102
|
+
y,
|
|
99
103
|
width,
|
|
100
104
|
height
|
|
101
105
|
}
|
|
102
106
|
}]
|
|
103
107
|
};
|
|
104
|
-
const mainView = xml.document.scenes[0].scene[0].objects[0].viewController[0].view[0];
|
|
105
108
|
|
|
106
109
|
// Add ImageView
|
|
107
110
|
ensureUniquePush(mainView.subviews[0].imageView, imageView);
|
|
111
|
+
mainView.constraints[0].constraint = [];
|
|
108
112
|
|
|
109
113
|
// Add Constraints
|
|
110
114
|
getAbsoluteConstraints(IMAGE_ID, CONTAINER_ID).forEach(constraint => {
|
|
@@ -121,13 +125,26 @@ function applyImageToSplashScreenXML(xml, {
|
|
|
121
125
|
imageSection.splice(existingImageIndex, 1);
|
|
122
126
|
}
|
|
123
127
|
imageSection.push({
|
|
124
|
-
// <image name="SplashScreen" width="414" height="736"/>
|
|
125
128
|
$: {
|
|
126
129
|
name: imageName,
|
|
127
130
|
width,
|
|
128
131
|
height
|
|
129
132
|
}
|
|
130
133
|
});
|
|
134
|
+
|
|
135
|
+
// Add background color
|
|
136
|
+
mainView.color = mainView.color ?? [];
|
|
137
|
+
const colorSection = mainView.color;
|
|
138
|
+
const color = parseColor(backgroundColor);
|
|
139
|
+
colorSection.push({
|
|
140
|
+
$: {
|
|
141
|
+
key: 'backgroundColor',
|
|
142
|
+
...color.rgb,
|
|
143
|
+
alpha: '1',
|
|
144
|
+
colorSpace: 'custom',
|
|
145
|
+
customColorSpace: 'sRGB'
|
|
146
|
+
}
|
|
147
|
+
});
|
|
131
148
|
return xml;
|
|
132
149
|
}
|
|
133
150
|
|
|
@@ -172,4 +189,24 @@ function toString(xml) {
|
|
|
172
189
|
function toObjectAsync(contents) {
|
|
173
190
|
return new (_xml2js().Parser)().parseStringPromise(contents);
|
|
174
191
|
}
|
|
192
|
+
|
|
193
|
+
// Function taken from react-native-bootsplash
|
|
194
|
+
const parseColor = value => {
|
|
195
|
+
const color = value.toUpperCase().replace(/[^0-9A-F]/g, '');
|
|
196
|
+
if (color.length !== 3 && color.length !== 6) {
|
|
197
|
+
console.error(`"${value}" value is not a valid hexadecimal color.`);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
const hex = color.length === 3 ? '#' + color[0] + color[0] + color[1] + color[1] + color[2] + color[2] : '#' + color;
|
|
201
|
+
const rgb = {
|
|
202
|
+
red: (parseInt('' + hex[1] + hex[2], 16) / 255).toPrecision(15),
|
|
203
|
+
green: (parseInt('' + hex[3] + hex[4], 16) / 255).toPrecision(15),
|
|
204
|
+
blue: (parseInt('' + hex[5] + hex[6], 16) / 255).toPrecision(15)
|
|
205
|
+
};
|
|
206
|
+
return {
|
|
207
|
+
hex,
|
|
208
|
+
rgb
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
exports.parseColor = parseColor;
|
|
175
212
|
//# sourceMappingURL=InterfaceBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceBuilder.js","names":["_crypto","data","_interopRequireDefault","require","_xml2js","e","__esModule","default","debug","createConstraint","firstItem","firstAttribute","secondItem","secondAttribute","constant","$","id","createConstraintId","attributes","crypto","createHash","update","join","digest","IMAGE_ID","CONTAINER_ID","removeImageFromSplashScreen","xml","imageName","mainView","document","scenes","scene","objects","viewController","view","removeExisting","subviews","imageView","getAbsoluteConstraints","forEach","constraint","constrainsArray","constraints","imageSection","resources","image","existingImageIndex","findIndex","name","splice","childId","parentId","applyImageToSplashScreenXML","contentMode","width","height","userLabel","horizontalHuggingPriority","verticalHuggingPriority","clipsSubviews","userInteractionEnabled","translatesAutoresizingMaskIntoConstraints","rect","key","x","y","ensureUniquePush","push","array","item","existingItem","toString","builder","Builder","preserveChildrenOrder","xmldec","version","encoding","renderOpts","pretty","indent","buildObject","toObjectAsync","contents","Parser","parseStringPromise"],"sources":["../../../../src/plugins/unversioned/expo-splash-screen/InterfaceBuilder.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { Builder, Parser } from 'xml2js';\n\nconst debug = require('debug')(\n 'expo:prebuild-config:expo-splash-screen:ios:InterfaceBuilder'\n) as typeof console.log;\n\nexport type IBBoolean = 'YES' | 'NO' | boolean;\n\nexport type IBItem<\n H extends Record<string, any>,\n B extends Record<string, any[]> = { [key: string]: any },\n> = {\n $: H;\n} & B;\n\nexport type Rect = {\n key: string;\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\nexport type IBRect = IBItem<Rect>;\n\nexport type IBAutoresizingMask = IBItem<{\n /** @example `autoresizingMask` */\n key: string;\n flexibleMaxX: IBBoolean;\n flexibleMaxY: IBBoolean;\n}>;\n\n/** @example `<color key=\"textColor\" systemColor=\"linkColor\"/>` */\nexport type IBColor = IBItem<\n {\n /** @example `textColor` */\n key: string;\n } & (\n | /** Custom color */\n {\n /** @example `0.86584504117670746` */\n red: number;\n /** @example `0.26445041990630447` */\n green: number;\n /** @example `0.3248577810203549` */\n blue: number;\n /** @example `1` */\n alpha: number;\n colorSpace: 'custom' | string;\n customColorSpace: 'displayP3' | 'sRGB' | string;\n }\n /** Built-in color */\n | {\n systemColor: 'linkColor' | string;\n }\n )\n>;\n\nexport type IBFontDescription = IBItem<{\n /** @example `fontDescription` */\n key: string;\n /** Font size */\n pointSize: number;\n\n /** Custom font */\n name?: 'HelveticaNeue' | string;\n family?: 'Helvetica Neue' | string;\n\n /** Built-in font */\n type?: 'system' | 'boldSystem' | 'UICTFontTextStyleCallout' | 'UICTFontTextStyleBody' | string;\n}>;\n\nexport type ImageContentMode = 'scaleAspectFit' | 'scaleAspectFill';\n\nexport type ConstraintAttribute = 'top' | 'bottom' | 'trailing' | 'leading';\n\nexport type IBImageView = IBItem<\n {\n id: string;\n userLabel: string;\n image: string;\n clipsSubviews?: IBBoolean;\n userInteractionEnabled: IBBoolean;\n contentMode: IBContentMode;\n horizontalHuggingPriority: number;\n verticalHuggingPriority: number;\n insetsLayoutMarginsFromSafeArea?: IBBoolean;\n translatesAutoresizingMaskIntoConstraints?: IBBoolean;\n },\n {\n rect: IBRect[];\n }\n>;\n\nexport type IBLabel = IBItem<\n {\n id: string;\n /** The main value. */\n text: string;\n\n opaque: IBBoolean;\n fixedFrame: IBBoolean;\n textAlignment?: IBTextAlignment;\n lineBreakMode:\n | 'clip'\n | 'characterWrap'\n | 'wordWrap'\n | 'headTruncation'\n | 'middleTruncation'\n | 'tailTruncation';\n baselineAdjustment?: 'none' | 'alignBaselines';\n adjustsFontSizeToFit: IBBoolean;\n userInteractionEnabled: IBBoolean;\n contentMode: IBContentMode;\n horizontalHuggingPriority: number;\n verticalHuggingPriority: number;\n translatesAutoresizingMaskIntoConstraints?: IBBoolean;\n },\n {\n /** @example `<rect key=\"frame\" x=\"175\" y=\"670\" width=\"35\" height=\"17\"/>` */\n rect: IBRect[];\n /** @example `<autoresizingMask key=\"autoresizingMask\" flexibleMaxX=\"YES\" flexibleMaxY=\"YES\"/>` */\n autoresizingMask?: IBAutoresizingMask[];\n /** @example `<fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"19\"/>` */\n fontDescription?: IBFontDescription[];\n /** @example `<color key=\"textColor\" red=\"0.0\" green=\"0.0\" blue=\"0.0\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>` */\n color?: IBColor[];\n nil?: IBItem<{\n /** @example `textColor` `highlightedColor` */\n key: string;\n }>[];\n }\n>;\n\nexport type IBTextAlignment = 'left' | 'center' | 'right' | 'justified' | 'natural';\n\nexport type IBContentMode = string | 'left' | 'scaleAspectFill';\n\nexport type IBConstraint = IBItem<{\n firstItem: string;\n firstAttribute: ConstraintAttribute;\n secondItem: string;\n secondAttribute: ConstraintAttribute;\n constant?: number;\n id: string;\n}>;\n\nexport type IBViewController = IBItem<\n {\n id: string;\n placeholderIdentifier?: string;\n userLabel: string;\n sceneMemberID: string;\n },\n {\n view: IBItem<\n {\n id: string;\n key: string;\n userInteractionEnabled: IBBoolean;\n contentMode: string | 'scaleToFill';\n insetsLayoutMarginsFromSafeArea: IBBoolean;\n userLabel: string;\n },\n {\n rect: IBRect[];\n autoresizingMask: IBItem<{\n key: string;\n flexibleMaxX: IBBoolean;\n flexibleMaxY: IBBoolean;\n }>[];\n\n subviews: IBItem<\n object,\n {\n imageView: IBImageView[];\n label: IBLabel[];\n }\n >[];\n color: IBItem<{\n key: string | 'backgroundColor';\n systemColor: string | 'systemBackgroundColor';\n }>[];\n constraints: IBItem<\n object,\n {\n constraint: IBConstraint[];\n }\n >[];\n viewLayoutGuide: IBItem<{\n id: string;\n key: string | 'safeArea';\n }>[];\n }\n >[];\n }\n>;\n\nexport type IBPoint = IBItem<{\n key: string | 'canvasLocation';\n x: number;\n y: number;\n}>;\n\nexport type IBScene = IBItem<\n { sceneID: string },\n {\n objects: {\n viewController: IBViewController[];\n placeholder: IBItem<{\n id: string;\n placeholderIdentifier?: string;\n userLabel: string;\n sceneMemberID: string;\n }>[];\n }[];\n point: IBPoint[];\n }\n>;\n\nexport type IBResourceImage = IBItem<{\n name: string;\n width: number;\n height: number;\n}>;\n\nexport type IBDevice = IBItem<{\n id: string;\n orientation: string | 'portrait';\n appearance: string | 'light';\n}>;\n\nexport type IBSplashScreenDocument = {\n document: IBItem<\n {\n type: 'com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB' | string;\n version: '3.0' | string;\n toolsVersion: number;\n targetRuntime: 'iOS.CocoaTouch' | string;\n propertyAccessControl: 'none' | string;\n useAutolayout: IBBoolean;\n launchScreen: IBBoolean;\n useTraitCollections: IBBoolean;\n useSafeAreas: IBBoolean;\n colorMatched: IBBoolean;\n initialViewController: string;\n },\n {\n device: IBDevice[];\n dependencies: unknown[];\n scenes: {\n scene: IBScene[];\n }[];\n resources: {\n image: IBResourceImage[];\n }[];\n }\n >;\n};\n\nexport function createConstraint(\n [firstItem, firstAttribute]: [string, ConstraintAttribute],\n [secondItem, secondAttribute]: [string, ConstraintAttribute],\n constant?: number\n): IBConstraint {\n return {\n $: {\n firstItem,\n firstAttribute,\n secondItem,\n secondAttribute,\n constant,\n // Prevent updating between runs\n id: createConstraintId(firstItem, firstAttribute, secondItem, secondAttribute),\n },\n };\n}\n\nexport function createConstraintId(...attributes: string[]) {\n return crypto.createHash('sha1').update(attributes.join('-')).digest('hex');\n}\n\nconst IMAGE_ID = 'EXPO-SplashScreen';\nconst CONTAINER_ID = 'EXPO-ContainerView';\n\nexport function removeImageFromSplashScreen(\n xml: IBSplashScreenDocument,\n { imageName }: { imageName: string }\n) {\n const mainView = xml.document.scenes[0].scene[0].objects[0].viewController[0].view[0];\n\n debug(`Remove all splash screen image elements`);\n\n removeExisting(mainView.subviews[0].imageView, IMAGE_ID);\n\n // Add Constraints\n getAbsoluteConstraints(IMAGE_ID, CONTAINER_ID).forEach((constraint) => {\n // <constraint firstItem=\"EXPO-SplashScreen\" firstAttribute=\"top\" secondItem=\"EXPO-ContainerView\" secondAttribute=\"top\" id=\"2VS-Uz-0LU\"/>\n const constrainsArray = mainView.constraints[0].constraint;\n removeExisting(constrainsArray, constraint);\n });\n\n // Add resource\n const imageSection = xml.document.resources[0].image;\n\n const existingImageIndex = imageSection.findIndex((image) => image.$.name === imageName);\n if (existingImageIndex > -1) {\n imageSection.splice(existingImageIndex, 1);\n }\n return xml;\n}\n\nfunction getAbsoluteConstraints(childId: string, parentId: string) {\n return [\n createConstraint([childId, 'top'], [parentId, 'top']),\n createConstraint([childId, 'leading'], [parentId, 'leading']),\n createConstraint([childId, 'trailing'], [parentId, 'trailing']),\n createConstraint([childId, 'bottom'], [parentId, 'bottom']),\n ];\n}\n\nexport function applyImageToSplashScreenXML(\n xml: IBSplashScreenDocument,\n {\n imageName,\n contentMode,\n }: {\n imageName: string;\n contentMode: ImageContentMode;\n }\n): IBSplashScreenDocument {\n const width = 414;\n const height = 736;\n\n const imageView: IBImageView = {\n $: {\n id: IMAGE_ID,\n userLabel: imageName,\n image: imageName,\n contentMode,\n horizontalHuggingPriority: 251,\n verticalHuggingPriority: 251,\n clipsSubviews: true,\n userInteractionEnabled: false,\n translatesAutoresizingMaskIntoConstraints: false,\n },\n rect: [\n {\n $: {\n key: 'frame',\n x: 0.0,\n y: 0.0,\n width,\n height,\n },\n },\n ],\n };\n\n const mainView = xml.document.scenes[0].scene[0].objects[0].viewController[0].view[0];\n\n // Add ImageView\n ensureUniquePush(mainView.subviews[0].imageView, imageView);\n\n // Add Constraints\n getAbsoluteConstraints(IMAGE_ID, CONTAINER_ID).forEach((constraint) => {\n // <constraint firstItem=\"EXPO-SplashScreen\" firstAttribute=\"top\" secondItem=\"EXPO-ContainerView\" secondAttribute=\"top\" id=\"2VS-Uz-0LU\"/>\n const constrainsArray = mainView.constraints[0].constraint;\n ensureUniquePush(constrainsArray, constraint);\n });\n\n // Add resource\n const imageSection = xml.document.resources[0].image;\n\n const existingImageIndex = imageSection.findIndex((image) => image.$.name === imageName);\n if (existingImageIndex > -1) {\n debug(`Removing existing IB image asset at index ${existingImageIndex}`);\n imageSection.splice(existingImageIndex, 1);\n }\n imageSection.push({\n // <image name=\"SplashScreen\" width=\"414\" height=\"736\"/>\n $: {\n name: imageName,\n width,\n height,\n },\n });\n\n return xml;\n}\n\n/**\n * IB does not allow two items to have the same ID.\n * This method will add an item by first removing any existing item with the same `$.id`.\n */\nexport function ensureUniquePush<TItem extends { $: { id: string } }>(array: TItem[], item: TItem) {\n if (!array) return array;\n removeExisting(array, item);\n array.push(item);\n return array;\n}\n\nexport function removeExisting<TItem extends { $: { id: string } }>(\n array: TItem[],\n item: TItem | string\n) {\n const id = typeof item === 'string' ? item : item.$?.id;\n const existingItem = array?.findIndex((existingItem) => existingItem.$.id === id);\n if (existingItem > -1) {\n debug(`Removing existing IB item with id ${id}, from: %O`, array);\n array.splice(existingItem, 1);\n }\n return array;\n}\n\n// Attempt to copy Xcode formatting.\nexport function toString(xml: any): string {\n const builder = new Builder({\n // @ts-expect-error: untyped\n preserveChildrenOrder: true,\n xmldec: {\n version: '1.0',\n encoding: 'UTF-8',\n },\n renderOpts: {\n pretty: true,\n indent: ' ',\n },\n });\n return builder.buildObject(xml);\n}\n\n/** Parse string contents into an object. */\nexport function toObjectAsync(contents: string) {\n return new Parser().parseStringPromise(contents);\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAyC,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEzC,MAAMG,KAAK,GAAGL,OAAO,CAAC,OAAO,CAAC,CAC5B,8DACF,CAAuB;;AA4BvB;;AAoOO,SAASM,gBAAgBA,CAC9B,CAACC,SAAS,EAAEC,cAAc,CAAgC,EAC1D,CAACC,UAAU,EAAEC,eAAe,CAAgC,EAC5DC,QAAiB,EACH;EACd,OAAO;IACLC,CAAC,EAAE;MACDL,SAAS;MACTC,cAAc;MACdC,UAAU;MACVC,eAAe;MACfC,QAAQ;MACR;MACAE,EAAE,EAAEC,kBAAkB,CAACP,SAAS,EAAEC,cAAc,EAAEC,UAAU,EAAEC,eAAe;IAC/E;EACF,CAAC;AACH;AAEO,SAASI,kBAAkBA,CAAC,GAAGC,UAAoB,EAAE;EAC1D,OAAOC,iBAAM,CAACC,UAAU,CAAC,MAAM,CAAC,CAACC,MAAM,CAACH,UAAU,CAACI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AAS,CAAEuB,YAAY,IAAKA,YAAY,CAACxD,CAAC,CAACC,EAAE,KAAKA,EAAE,CAAC;EACjF,IAAIuD,YAAY,GAAG,CAAC,CAAC,EAAE;IACrB/D,KAAK,CAAC,qCAAqCQ,EAAE,YAAY,EAAEqD,KAAK,CAAC;IACjEA,KAAK,CAACnB,MAAM,CAACqB,YAAY,EAAE,CAAC,CAAC;EAC/B;EACA,OAAOF,KAAK;AACd;;AAEA;AACO,SAASG,QAAQA,CAAC7C,GAAQ,EAAU;EACzC,MAAM8C,OAAO,GAAG,KAAIC,iBAAO,EAAC;IAC1B;IACAC,qBAAqB,EAAE,IAAI;IAC3BC,MAAM,EAAE;MACNC,OAAO,EAAE,KAAK;MACdC,QAAQ,EAAE;IACZ,CAAC;IACDC,UAAU,EAAE;MACVC,MAAM,EAAE,IAAI;MACZC,MAAM,EAAE;IACV;EACF,CAAC,CAAC;EACF,OAAOR,OAAO,CAACS,WAAW,CAACvD,GAAG,CAAC;AACjC;;AAEA;AACO,SAASwD,aAAaA,CAACC,QAAgB,EAAE;EAC9C,OAAO,KAAIC,gBAAM,EAAC,CAAC,CAACC,kBAAkB,CAACF,QAAQ,CAAC;AAClD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"InterfaceBuilder.js","names":["_crypto","data","_interopRequireDefault","require","_xml2js","e","__esModule","default","debug","createConstraint","firstItem","firstAttribute","secondItem","secondAttribute","constant","$","id","createConstraintId","attributes","crypto","createHash","update","join","digest","IMAGE_ID","CONTAINER_ID","removeImageFromSplashScreen","xml","imageName","mainView","document","scenes","scene","objects","viewController","view","removeExisting","subviews","imageView","getAbsoluteConstraints","forEach","constraint","constrainsArray","constraints","imageSection","resources","image","existingImageIndex","findIndex","name","splice","childId","parentId","applyImageToSplashScreenXML","contentMode","backgroundColor","logoWidth","width","height","x","rect","y","userLabel","clipsSubviews","userInteractionEnabled","translatesAutoresizingMaskIntoConstraints","key","ensureUniquePush","push","color","colorSection","parseColor","rgb","alpha","colorSpace","customColorSpace","array","item","existingItem","toString","builder","Builder","preserveChildrenOrder","xmldec","version","encoding","renderOpts","pretty","indent","buildObject","toObjectAsync","contents","Parser","parseStringPromise","value","toUpperCase","replace","length","console","error","process","exit","hex","red","parseInt","toPrecision","green","blue","exports"],"sources":["../../../../src/plugins/unversioned/expo-splash-screen/InterfaceBuilder.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { Builder, Parser } from 'xml2js';\n\nconst debug = require('debug')(\n 'expo:prebuild-config:expo-splash-screen:ios:InterfaceBuilder'\n) as typeof console.log;\n\nexport type IBBoolean = 'YES' | 'NO' | boolean;\n\nexport type IBItem<\n H extends Record<string, any>,\n B extends Record<string, any[]> = { [key: string]: any },\n> = {\n $: H;\n} & B;\n\nexport type Rect = {\n key: string;\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\nexport type IBRect = IBItem<Rect>;\n\nexport type IBAutoresizingMask = IBItem<{\n /** @example `autoresizingMask` */\n key: string;\n flexibleMaxX: IBBoolean;\n flexibleMaxY: IBBoolean;\n}>;\n\n/** @example `<color key=\"textColor\" systemColor=\"linkColor\"/>` */\nexport type IBColor = IBItem<\n {\n /** @example `textColor` */\n key: string;\n } & (\n | /** Custom color */\n {\n /** @example `0.86584504117670746` */\n red: number;\n /** @example `0.26445041990630447` */\n green: number;\n /** @example `0.3248577810203549` */\n blue: number;\n /** @example `1` */\n alpha: number;\n colorSpace: 'custom' | string;\n customColorSpace: 'displayP3' | 'sRGB' | string;\n }\n /** Built-in color */\n | {\n systemColor: 'linkColor' | string;\n }\n )\n>;\n\nexport type IBFontDescription = IBItem<{\n /** @example `fontDescription` */\n key: string;\n /** Font size */\n pointSize: number;\n\n /** Custom font */\n name?: 'HelveticaNeue' | string;\n family?: 'Helvetica Neue' | string;\n\n /** Built-in font */\n type?: 'system' | 'boldSystem' | 'UICTFontTextStyleCallout' | 'UICTFontTextStyleBody' | string;\n}>;\n\nexport type ImageContentMode = 'scaleAspectFit' | 'scaleAspectFill';\n\nexport type ConstraintAttribute = 'top' | 'bottom' | 'trailing' | 'leading' | 'centerX' | 'centerY';\n\nexport type IBImageView = IBItem<\n {\n id: string;\n userLabel: string;\n image: string;\n clipsSubviews?: IBBoolean;\n userInteractionEnabled: IBBoolean;\n contentMode: IBContentMode;\n horizontalHuggingPriority?: number;\n verticalHuggingPriority?: number;\n insetsLayoutMarginsFromSafeArea?: IBBoolean;\n translatesAutoresizingMaskIntoConstraints?: IBBoolean;\n },\n {\n rect: IBRect[];\n }\n>;\n\nexport type IBLabel = IBItem<\n {\n id: string;\n /** The main value. */\n text: string;\n\n opaque: IBBoolean;\n fixedFrame: IBBoolean;\n textAlignment?: IBTextAlignment;\n lineBreakMode:\n | 'clip'\n | 'characterWrap'\n | 'wordWrap'\n | 'headTruncation'\n | 'middleTruncation'\n | 'tailTruncation';\n baselineAdjustment?: 'none' | 'alignBaselines';\n adjustsFontSizeToFit: IBBoolean;\n userInteractionEnabled: IBBoolean;\n contentMode: IBContentMode;\n horizontalHuggingPriority: number;\n verticalHuggingPriority: number;\n translatesAutoresizingMaskIntoConstraints?: IBBoolean;\n },\n {\n /** @example `<rect key=\"frame\" x=\"175\" y=\"670\" width=\"35\" height=\"17\"/>` */\n rect: IBRect[];\n /** @example `<autoresizingMask key=\"autoresizingMask\" flexibleMaxX=\"YES\" flexibleMaxY=\"YES\"/>` */\n autoresizingMask?: IBAutoresizingMask[];\n /** @example `<fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"19\"/>` */\n fontDescription?: IBFontDescription[];\n /** @example `<color key=\"textColor\" red=\"0.0\" green=\"0.0\" blue=\"0.0\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>` */\n color?: IBColor[];\n nil?: IBItem<{\n /** @example `textColor` `highlightedColor` */\n key: string;\n }>[];\n }\n>;\n\nexport type IBTextAlignment = 'left' | 'center' | 'right' | 'justified' | 'natural';\n\nexport type IBContentMode = string | 'left' | 'scaleAspectFill';\n\nexport type IBConstraint = IBItem<{\n firstItem: string;\n firstAttribute: ConstraintAttribute;\n secondItem: string;\n secondAttribute: ConstraintAttribute;\n constant?: number;\n id: string;\n}>;\n\nexport type IBViewController = IBItem<\n {\n id: string;\n placeholderIdentifier?: string;\n userLabel: string;\n sceneMemberID: string;\n },\n {\n view: IBItem<\n {\n id: string;\n key: string;\n userInteractionEnabled: IBBoolean;\n contentMode: string | 'scaleToFill';\n insetsLayoutMarginsFromSafeArea: IBBoolean;\n userLabel: string;\n },\n {\n rect: IBRect[];\n autoresizingMask: IBItem<{\n key: string;\n flexibleMaxX: IBBoolean;\n flexibleMaxY: IBBoolean;\n }>[];\n\n subviews: IBItem<\n object,\n {\n imageView: IBImageView[];\n label: IBLabel[];\n }\n >[];\n color: IBItem<{\n key: string | 'backgroundColor';\n systemColor?: string | 'systemBackgroundColor';\n red?: string;\n green?: string;\n blue?: string;\n alpha?: string;\n colorSpace?: string;\n customColorSpace?: string;\n }>[];\n constraints: IBItem<\n object,\n {\n constraint: IBConstraint[];\n }\n >[];\n viewLayoutGuide: IBItem<{\n id: string;\n key: string | 'safeArea';\n }>[];\n }\n >[];\n }\n>;\n\nexport type IBPoint = IBItem<{\n key: string | 'canvasLocation';\n x: number;\n y: number;\n}>;\n\nexport type IBScene = IBItem<\n { sceneID: string },\n {\n objects: {\n viewController: IBViewController[];\n placeholder: IBItem<{\n id: string;\n placeholderIdentifier?: string;\n userLabel: string;\n sceneMemberID: string;\n }>[];\n }[];\n point: IBPoint[];\n }\n>;\n\nexport type IBResourceImage = IBItem<{\n name: string;\n width: number;\n height: number;\n}>;\n\nexport type IBDevice = IBItem<{\n id: string;\n orientation: string | 'portrait';\n appearance: string | 'light';\n}>;\n\nexport type IBSplashScreenDocument = {\n document: IBItem<\n {\n type: 'com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB' | string;\n version: '3.0' | string;\n toolsVersion: number;\n targetRuntime: 'iOS.CocoaTouch' | string;\n propertyAccessControl: 'none' | string;\n useAutolayout: IBBoolean;\n launchScreen: IBBoolean;\n useTraitCollections: IBBoolean;\n useSafeAreas: IBBoolean;\n colorMatched: IBBoolean;\n initialViewController: string;\n },\n {\n device: IBDevice[];\n dependencies: unknown[];\n scenes: {\n scene: IBScene[];\n }[];\n resources: {\n image: IBResourceImage[];\n }[];\n }\n >;\n};\n\nexport function createConstraint(\n [firstItem, firstAttribute]: [string, ConstraintAttribute],\n [secondItem, secondAttribute]: [string, ConstraintAttribute],\n constant?: number\n): IBConstraint {\n return {\n $: {\n firstItem,\n firstAttribute,\n secondItem,\n secondAttribute,\n constant,\n // Prevent updating between runs\n id: createConstraintId(firstItem, firstAttribute, secondItem, secondAttribute),\n },\n };\n}\n\nexport function createConstraintId(...attributes: string[]) {\n return crypto.createHash('sha1').update(attributes.join('-')).digest('hex');\n}\n\nconst IMAGE_ID = 'EXPO-SplashScreen';\nconst CONTAINER_ID = 'EXPO-ContainerView';\n\nexport function removeImageFromSplashScreen(\n xml: IBSplashScreenDocument,\n { imageName }: { imageName: string }\n) {\n const mainView = xml.document.scenes[0].scene[0].objects[0].viewController[0].view[0];\n\n debug(`Remove all splash screen image elements`);\n\n removeExisting(mainView.subviews[0].imageView, IMAGE_ID);\n\n // Add Constraints\n getAbsoluteConstraints(IMAGE_ID, CONTAINER_ID).forEach((constraint) => {\n // <constraint firstItem=\"EXPO-SplashScreen\" firstAttribute=\"top\" secondItem=\"EXPO-ContainerView\" secondAttribute=\"top\" id=\"2VS-Uz-0LU\"/>\n const constrainsArray = mainView.constraints[0].constraint;\n removeExisting(constrainsArray, constraint);\n });\n\n // Add resource\n const imageSection = xml.document.resources[0].image;\n\n const existingImageIndex = imageSection.findIndex((image) => image.$.name === imageName);\n if (existingImageIndex > -1) {\n imageSection.splice(existingImageIndex, 1);\n }\n return xml;\n}\n\nfunction getAbsoluteConstraints(childId: string, parentId: string) {\n return [\n createConstraint([childId, 'centerX'], [parentId, 'centerX']),\n createConstraint([childId, 'centerY'], [parentId, 'centerY']),\n ];\n}\n\nexport function applyImageToSplashScreenXML(\n xml: IBSplashScreenDocument,\n {\n imageName,\n contentMode,\n backgroundColor,\n logoWidth = 100,\n }: {\n imageName: string;\n contentMode: ImageContentMode;\n backgroundColor: string;\n logoWidth?: number;\n }\n): IBSplashScreenDocument {\n const mainView = xml.document.scenes[0].scene[0].objects[0].viewController[0].view[0];\n const width = logoWidth;\n const height = logoWidth;\n const x = (mainView.rect[0].$.width - width) / 2;\n const y = (mainView.rect[0].$.height - height) / 2;\n\n const imageView: IBImageView = {\n $: {\n id: IMAGE_ID,\n userLabel: imageName,\n image: imageName,\n contentMode,\n clipsSubviews: true,\n userInteractionEnabled: false,\n translatesAutoresizingMaskIntoConstraints: false,\n },\n rect: [\n {\n $: {\n key: 'frame',\n x,\n y,\n width,\n height,\n },\n },\n ],\n };\n\n // Add ImageView\n ensureUniquePush(mainView.subviews[0].imageView, imageView);\n\n mainView.constraints[0].constraint = [];\n\n // Add Constraints\n getAbsoluteConstraints(IMAGE_ID, CONTAINER_ID).forEach((constraint) => {\n // <constraint firstItem=\"EXPO-SplashScreen\" firstAttribute=\"top\" secondItem=\"EXPO-ContainerView\" secondAttribute=\"top\" id=\"2VS-Uz-0LU\"/>\n const constrainsArray = mainView.constraints[0].constraint;\n ensureUniquePush(constrainsArray, constraint);\n });\n\n // Add resource\n const imageSection = xml.document.resources[0].image;\n\n const existingImageIndex = imageSection.findIndex((image) => image.$.name === imageName);\n if (existingImageIndex > -1) {\n debug(`Removing existing IB image asset at index ${existingImageIndex}`);\n imageSection.splice(existingImageIndex, 1);\n }\n imageSection.push({\n $: {\n name: imageName,\n width,\n height,\n },\n });\n\n // Add background color\n mainView.color = mainView.color ?? [];\n const colorSection = mainView.color;\n const color = parseColor(backgroundColor);\n\n colorSection.push({\n $: {\n key: 'backgroundColor',\n ...color.rgb,\n alpha: '1',\n colorSpace: 'custom',\n customColorSpace: 'sRGB',\n },\n });\n\n return xml;\n}\n\n/**\n * IB does not allow two items to have the same ID.\n * This method will add an item by first removing any existing item with the same `$.id`.\n */\nexport function ensureUniquePush<TItem extends { $: { id: string } }>(array: TItem[], item: TItem) {\n if (!array) return array;\n removeExisting(array, item);\n array.push(item);\n return array;\n}\n\nexport function removeExisting<TItem extends { $: { id: string } }>(\n array: TItem[],\n item: TItem | string\n) {\n const id = typeof item === 'string' ? item : item.$?.id;\n const existingItem = array?.findIndex((existingItem) => existingItem.$.id === id);\n if (existingItem > -1) {\n debug(`Removing existing IB item with id ${id}, from: %O`, array);\n array.splice(existingItem, 1);\n }\n return array;\n}\n\n// Attempt to copy Xcode formatting.\nexport function toString(xml: any): string {\n const builder = new Builder({\n // @ts-expect-error: untyped\n preserveChildrenOrder: true,\n xmldec: {\n version: '1.0',\n encoding: 'UTF-8',\n },\n renderOpts: {\n pretty: true,\n indent: ' ',\n },\n });\n return builder.buildObject(xml);\n}\n\n/** Parse string contents into an object. */\nexport function toObjectAsync(contents: string) {\n return new Parser().parseStringPromise(contents);\n}\n\n// Function taken from react-native-bootsplash\nexport const parseColor = (value: string): Color => {\n const color = value.toUpperCase().replace(/[^0-9A-F]/g, '');\n\n if (color.length !== 3 && color.length !== 6) {\n console.error(`\"${value}\" value is not a valid hexadecimal color.`);\n process.exit(1);\n }\n\n const hex =\n color.length === 3\n ? '#' + color[0] + color[0] + color[1] + color[1] + color[2] + color[2]\n : '#' + color;\n\n const rgb: Color['rgb'] = {\n red: (parseInt('' + hex[1] + hex[2], 16) / 255).toPrecision(15),\n green: (parseInt('' + hex[3] + hex[4], 16) / 255).toPrecision(15),\n blue: (parseInt('' + hex[5] + hex[6], 16) / 255).toPrecision(15),\n };\n\n return { hex, rgb };\n};\n\ntype Color = {\n hex: string;\n rgb: {\n red: string;\n green: string;\n blue: string;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;A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GA,KAAK,CAAC,CAAC,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,GACrE,GAAG,GAAGA,KAAK;EAEjB,MAAMG,GAAiB,GAAG;IACxB+B,GAAG,EAAE,CAACC,QAAQ,CAAC,EAAE,GAAGF,GAAG,CAAC,CAAC,CAAC,GAAGA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,EAAEG,WAAW,CAAC,EAAE,CAAC;IAC/DC,KAAK,EAAE,CAACF,QAAQ,CAAC,EAAE,GAAGF,GAAG,CAAC,CAAC,CAAC,GAAGA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,EAAEG,WAAW,CAAC,EAAE,CAAC;IACjEE,IAAI,EAAE,CAACH,QAAQ,CAAC,EAAE,GAAGF,GAAG,CAAC,CAAC,CAAC,GAAGA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,EAAEG,WAAW,CAAC,EAAE;EACjE,CAAC;EAED,OAAO;IAAEH,GAAG;IAAE9B;EAAI,CAAC;AACrB,CAAC;AAACoC,OAAA,CAAArC,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { ExpoConfig } from '@expo/config-types';
|
|
2
2
|
export type SplashScreenConfig = {
|
|
3
|
-
xxxhdpi
|
|
4
|
-
xxhdpi
|
|
5
|
-
xhdpi
|
|
6
|
-
hdpi
|
|
7
|
-
mdpi
|
|
3
|
+
xxxhdpi?: string | null;
|
|
4
|
+
xxhdpi?: string | null;
|
|
5
|
+
xhdpi?: string | null;
|
|
6
|
+
hdpi?: string | null;
|
|
7
|
+
mdpi?: string | null;
|
|
8
|
+
image?: string | null;
|
|
8
9
|
backgroundColor: string | null;
|
|
9
10
|
resizeMode: 'contain' | 'cover' | 'native';
|
|
11
|
+
dark?: {
|
|
12
|
+
backgroundColor?: string;
|
|
13
|
+
xxxhdpi?: string;
|
|
14
|
+
xxhdpi?: string;
|
|
15
|
+
xhdpi?: string;
|
|
16
|
+
hdpi?: string;
|
|
17
|
+
mdpi?: string;
|
|
18
|
+
image?: string;
|
|
19
|
+
resizeMode?: 'contain' | 'cover' | 'native';
|
|
20
|
+
};
|
|
10
21
|
};
|
|
11
|
-
export
|
|
12
|
-
|
|
22
|
+
export type AndroidSplashConfig = {
|
|
23
|
+
logoWidth?: number;
|
|
24
|
+
} & SplashScreenConfig;
|
|
25
|
+
export declare function getAndroidSplashConfig(config: Pick<ExpoConfig, 'splash' | 'android'>, props?: AndroidSplashConfig | null): SplashScreenConfig | null;
|
|
26
|
+
export declare function getAndroidDarkSplashConfig(config: Pick<ExpoConfig, 'splash' | 'android'>, props: AndroidSplashConfig | null): SplashScreenConfig | null;
|