@expo/prebuild-config 8.1.3 → 8.2.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/getPrebuildConfig.js +1 -2
- package/build/getPrebuildConfig.js.map +1 -1
- package/build/plugins/icons/AssetContents.js +5 -7
- package/build/plugins/icons/AssetContents.js.map +1 -1
- package/build/plugins/icons/withAndroidIcons.js +14 -22
- package/build/plugins/icons/withAndroidIcons.js.map +1 -1
- package/build/plugins/icons/withIosIcons.js +7 -8
- package/build/plugins/icons/withIosIcons.js.map +1 -1
- package/build/plugins/unversioned/expo-notifications/withAndroidNotifications.d.ts +2 -2
- package/build/plugins/unversioned/expo-notifications/withAndroidNotifications.js +6 -10
- package/build/plugins/unversioned/expo-notifications/withAndroidNotifications.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashImages.js +12 -19
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashImages.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashAssets.js +7 -8
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashAssets.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashColors.js +9 -12
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashColors.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashXcodeProject.d.ts +1 -0
- package/build/plugins/withDefaultPlugins.d.ts +0 -1
- package/build/plugins/withDefaultPlugins.js +3 -17
- package/build/plugins/withDefaultPlugins.js.map +1 -1
- package/package.json +10 -9
- package/build/plugins/sdk52/ReactNative78CompatPlugin.d.ts +0 -2
- package/build/plugins/sdk52/ReactNative78CompatPlugin.js +0 -88
- package/build/plugins/sdk52/ReactNative78CompatPlugin.js.map +0 -1
- package/build/plugins/unversioned/react-native-edge-to-edge/helpers.d.ts +0 -5
- package/build/plugins/unversioned/react-native-edge-to-edge/helpers.js +0 -47
- package/build/plugins/unversioned/react-native-edge-to-edge/helpers.js.map +0 -1
- package/build/plugins/unversioned/react-native-edge-to-edge/withConfigureEdgeToEdgeEnforcement.d.ts +0 -6
- package/build/plugins/unversioned/react-native-edge-to-edge/withConfigureEdgeToEdgeEnforcement.js +0 -53
- package/build/plugins/unversioned/react-native-edge-to-edge/withConfigureEdgeToEdgeEnforcement.js.map +0 -1
- package/build/plugins/unversioned/react-native-edge-to-edge/withEdgeToEdge.d.ts +0 -15
- package/build/plugins/unversioned/react-native-edge-to-edge/withEdgeToEdge.js +0 -110
- package/build/plugins/unversioned/react-native-edge-to-edge/withEdgeToEdge.js.map +0 -1
- package/build/plugins/unversioned/react-native-edge-to-edge/withEdgeToEdgeEnabledGradleProperties.d.ts +0 -6
- package/build/plugins/unversioned/react-native-edge-to-edge/withEdgeToEdgeEnabledGradleProperties.js +0 -42
- package/build/plugins/unversioned/react-native-edge-to-edge/withEdgeToEdgeEnabledGradleProperties.js.map +0 -1
- package/build/plugins/unversioned/react-native-edge-to-edge/withRestoreDefaultTheme.d.ts +0 -4
- package/build/plugins/unversioned/react-native-edge-to-edge/withRestoreDefaultTheme.js +0 -46
- package/build/plugins/unversioned/react-native-edge-to-edge/withRestoreDefaultTheme.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrebuildConfig.js","names":["_config","data","require","_getAutolinkedPackages","_withDefaultPlugins","getPrebuildConfigAsync","projectRoot","props","autolinkedModules","getAutolinkedPackagesAsync","platforms","getPrebuildConfig","bundleIdentifier","packageName","exp","config","rest","getConfig","skipSDKVersionRequirement","isModdedConfig","_internal","withVersionedExpoSDKPlugins","withLegacyExpoPlugins","includes","ios","withIosExpoPlugins","android","package","withAndroidExpoPlugins"],"sources":["../src/getPrebuildConfig.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\n\nimport { getAutolinkedPackagesAsync } from './getAutolinkedPackages';\nimport {\n withAndroidExpoPlugins,\n withIosExpoPlugins,\n withLegacyExpoPlugins,\n withVersionedExpoSDKPlugins,\n} from './plugins/withDefaultPlugins';\n\nexport async function getPrebuildConfigAsync(\n projectRoot: string,\n props: {\n bundleIdentifier?: string;\n packageName?: string;\n platforms: ModPlatform[];\n }\n): Promise<ReturnType<typeof getConfig>> {\n const autolinkedModules = await getAutolinkedPackagesAsync(projectRoot, props.platforms);\n\n return getPrebuildConfig(projectRoot, {\n ...props,\n autolinkedModules,\n });\n}\n\nfunction getPrebuildConfig(\n projectRoot: string,\n {\n platforms,\n bundleIdentifier,\n packageName,\n autolinkedModules,\n }: {\n bundleIdentifier?: string;\n packageName?: string;\n platforms: ModPlatform[];\n autolinkedModules?: string[];\n }\n) {\n // let config: ExpoConfig;\n let { exp: config, ...rest } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n isModdedConfig: true,\n });\n\n if (autolinkedModules) {\n if (!config._internal) {\n config._internal = {};\n }\n config._internal.autolinkedModules = autolinkedModules;\n }\n\n // Add all built-in plugins first because they should take\n // priority over the unversioned plugins.\n config = withVersionedExpoSDKPlugins(config);\n config = withLegacyExpoPlugins(config);\n\n if (platforms.includes('ios')) {\n if (!config.ios) config.ios = {};\n config.ios.bundleIdentifier =\n bundleIdentifier ?? config.ios.bundleIdentifier ?? `com.placeholder.appid`;\n\n // Add all built-in plugins\n config = withIosExpoPlugins(config, {\n bundleIdentifier: config.ios.bundleIdentifier,\n });\n }\n\n if (platforms.includes('android')) {\n if (!config.android) config.android = {};\n config.android.package = packageName ?? config.android.package ?? `com.placeholder.appid`;\n\n // Add all built-in plugins\n config = withAndroidExpoPlugins(config, {\n package: config.android.package,\n
|
|
1
|
+
{"version":3,"file":"getPrebuildConfig.js","names":["_config","data","require","_getAutolinkedPackages","_withDefaultPlugins","getPrebuildConfigAsync","projectRoot","props","autolinkedModules","getAutolinkedPackagesAsync","platforms","getPrebuildConfig","bundleIdentifier","packageName","exp","config","rest","getConfig","skipSDKVersionRequirement","isModdedConfig","_internal","withVersionedExpoSDKPlugins","withLegacyExpoPlugins","includes","ios","withIosExpoPlugins","android","package","withAndroidExpoPlugins"],"sources":["../src/getPrebuildConfig.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\n\nimport { getAutolinkedPackagesAsync } from './getAutolinkedPackages';\nimport {\n withAndroidExpoPlugins,\n withIosExpoPlugins,\n withLegacyExpoPlugins,\n withVersionedExpoSDKPlugins,\n} from './plugins/withDefaultPlugins';\n\nexport async function getPrebuildConfigAsync(\n projectRoot: string,\n props: {\n bundleIdentifier?: string;\n packageName?: string;\n platforms: ModPlatform[];\n }\n): Promise<ReturnType<typeof getConfig>> {\n const autolinkedModules = await getAutolinkedPackagesAsync(projectRoot, props.platforms);\n\n return getPrebuildConfig(projectRoot, {\n ...props,\n autolinkedModules,\n });\n}\n\nfunction getPrebuildConfig(\n projectRoot: string,\n {\n platforms,\n bundleIdentifier,\n packageName,\n autolinkedModules,\n }: {\n bundleIdentifier?: string;\n packageName?: string;\n platforms: ModPlatform[];\n autolinkedModules?: string[];\n }\n) {\n // let config: ExpoConfig;\n let { exp: config, ...rest } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n isModdedConfig: true,\n });\n\n if (autolinkedModules) {\n if (!config._internal) {\n config._internal = {};\n }\n config._internal.autolinkedModules = autolinkedModules;\n }\n\n // Add all built-in plugins first because they should take\n // priority over the unversioned plugins.\n config = withVersionedExpoSDKPlugins(config);\n config = withLegacyExpoPlugins(config);\n\n if (platforms.includes('ios')) {\n if (!config.ios) config.ios = {};\n config.ios.bundleIdentifier =\n bundleIdentifier ?? config.ios.bundleIdentifier ?? `com.placeholder.appid`;\n\n // Add all built-in plugins\n config = withIosExpoPlugins(config, {\n bundleIdentifier: config.ios.bundleIdentifier,\n });\n }\n\n if (platforms.includes('android')) {\n if (!config.android) config.android = {};\n config.android.package = packageName ?? config.android.package ?? `com.placeholder.appid`;\n\n // Add all built-in plugins\n config = withAndroidExpoPlugins(config, {\n package: config.android.package,\n });\n }\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AAM,CAAC;EAEtC,IAAIL,SAAS,CAACa,QAAQ,CAAC,KAAK,CAAC,EAAE;IAC7B,IAAI,CAACR,MAAM,CAACS,GAAG,EAAET,MAAM,CAACS,GAAG,GAAG,CAAC,CAAC;IAChCT,MAAM,CAACS,GAAG,CAACZ,gBAAgB,GACzBA,gBAAgB,IAAIG,MAAM,CAACS,GAAG,CAACZ,gBAAgB,IAAI,uBAAuB;;IAE5E;IACAG,MAAM,GAAG,IAAAU,wCAAkB,EAACV,MAAM,EAAE;MAClCH,gBAAgB,EAAEG,MAAM,CAACS,GAAG,CAACZ;IAC/B,CAAC,CAAC;EACJ;EAEA,IAAIF,SAAS,CAACa,QAAQ,CAAC,SAAS,CAAC,EAAE;IACjC,IAAI,CAACR,MAAM,CAACW,OAAO,EAAEX,MAAM,CAACW,OAAO,GAAG,CAAC,CAAC;IACxCX,MAAM,CAACW,OAAO,CAACC,OAAO,GAAGd,WAAW,IAAIE,MAAM,CAACW,OAAO,CAACC,OAAO,IAAI,uBAAuB;;IAEzF;IACAZ,MAAM,GAAG,IAAAa,4CAAsB,EAACb,MAAM,EAAE;MACtCY,OAAO,EAAEZ,MAAM,CAACW,OAAO,CAACC;IAC1B,CAAC,CAAC;EACJ;EAEA,OAAO;IAAEb,GAAG,EAAEC,MAAM;IAAE,GAAGC;EAAK,CAAC;AACjC","ignoreList":[]}
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createContentsJsonItem = createContentsJsonItem;
|
|
7
7
|
exports.writeContentsJsonAsync = writeContentsJsonAsync;
|
|
8
|
-
function
|
|
9
|
-
const data = _interopRequireDefault(require("fs"));
|
|
10
|
-
|
|
8
|
+
function _fsExtra() {
|
|
9
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
10
|
+
_fsExtra = function () {
|
|
11
11
|
return data;
|
|
12
12
|
};
|
|
13
13
|
return data;
|
|
@@ -33,10 +33,8 @@ function createContentsJsonItem(item) {
|
|
|
33
33
|
async function writeContentsJsonAsync(directory, {
|
|
34
34
|
images
|
|
35
35
|
}) {
|
|
36
|
-
await
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
await _fs().default.promises.writeFile((0, _path().join)(directory, 'Contents.json'), JSON.stringify({
|
|
36
|
+
await _fsExtra().default.ensureDir(directory);
|
|
37
|
+
await _fsExtra().default.writeFile((0, _path().join)(directory, 'Contents.json'), JSON.stringify({
|
|
40
38
|
images,
|
|
41
39
|
info: {
|
|
42
40
|
version: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetContents.js","names":["
|
|
1
|
+
{"version":3,"file":"AssetContents.js","names":["_fsExtra","data","_interopRequireDefault","require","_path","e","__esModule","default","createContentsJsonItem","item","writeContentsJsonAsync","directory","images","fs","ensureDir","writeFile","join","JSON","stringify","info","version","author"],"sources":["../../../src/plugins/icons/AssetContents.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { join } from 'path';\n\nexport type ContentsJsonImageIdiom =\n | 'iphone'\n | 'ipad'\n | 'watchos'\n | 'ios'\n | 'ios-marketing'\n | 'universal';\n\nexport type ContentsJsonImageAppearanceLuminosityType = 'light' | 'dark' | 'tinted';\n\nexport type ContentsJsonAppearance = {\n appearance: 'luminosity';\n value: ContentsJsonImageAppearanceLuminosityType;\n};\n\nexport type ContentsJsonImageScale = '1x' | '2x' | '3x';\n\nexport interface ContentsJsonImage {\n appearances?: ContentsJsonAppearance[];\n idiom: ContentsJsonImageIdiom;\n size?: string;\n scale?: ContentsJsonImageScale;\n filename?: string;\n platform?: ContentsJsonImageIdiom;\n}\n\nexport interface ContentsJsonColor {\n appearances?: ContentsJsonAppearance[];\n idiom: ContentsJsonImageIdiom;\n color: {\n 'color-space': 'srgb';\n components: {\n alpha: string;\n blue: string;\n green: string;\n red: string;\n };\n };\n}\n\nexport interface ContentsJson {\n images: ContentsJsonImage[];\n colors: ContentsJsonColor[];\n info: {\n version: number;\n author: string;\n };\n}\n\nexport function createContentsJsonItem(item: ContentsJsonImage): ContentsJsonImage {\n return item;\n}\n\n/**\n * Writes the Config.json which is used to assign images to their respective platform, dpi, and idiom.\n *\n * @param directory path to add the Contents.json to.\n * @param contents image json data\n */\nexport async function writeContentsJsonAsync(\n directory: string,\n { images }: Pick<ContentsJson, 'images'>\n): Promise<void> {\n await fs.ensureDir(directory);\n\n await fs.writeFile(\n join(directory, 'Contents.json'),\n JSON.stringify(\n {\n images,\n info: {\n version: 1,\n // common practice is for the tool that generated the icons to be the \"author\"\n author: 'expo',\n },\n },\n null,\n 2\n )\n );\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4B,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAmDrB,SAASG,sBAAsBA,CAACC,IAAuB,EAAqB;EACjF,OAAOA,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,sBAAsBA,CAC1CC,SAAiB,EACjB;EAAEC;AAAqC,CAAC,EACzB;EACf,MAAMC,kBAAE,CAACC,SAAS,CAACH,SAAS,CAAC;EAE7B,MAAME,kBAAE,CAACE,SAAS,CAChB,IAAAC,YAAI,EAACL,SAAS,EAAE,eAAe,CAAC,EAChCM,IAAI,CAACC,SAAS,CACZ;IACEN,MAAM;IACNO,IAAI,EAAE;MACJC,OAAO,EAAE,CAAC;MACV;MACAC,MAAM,EAAE;IACV;EACF,CAAC,EACD,IAAI,EACJ,CACF,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -25,9 +25,9 @@ function _imageUtils() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const data = _interopRequireDefault(require("fs"));
|
|
30
|
-
|
|
28
|
+
function _fsExtra() {
|
|
29
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
30
|
+
_fsExtra = function () {
|
|
31
31
|
return data;
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
@@ -244,19 +244,17 @@ const createAdaptiveIconXmlString = (backgroundImage, monochromeImage) => {
|
|
|
244
244
|
exports.createAdaptiveIconXmlString = createAdaptiveIconXmlString;
|
|
245
245
|
async function createAdaptiveIconXmlFiles(projectRoot, icLauncherXmlString, add) {
|
|
246
246
|
const anyDpiV26Directory = _path().default.resolve(projectRoot, ANDROID_RES_PATH, MIPMAP_ANYDPI_V26);
|
|
247
|
-
await
|
|
248
|
-
recursive: true
|
|
249
|
-
});
|
|
247
|
+
await _fsExtra().default.ensureDir(anyDpiV26Directory);
|
|
250
248
|
const launcherPath = _path().default.resolve(anyDpiV26Directory, IC_LAUNCHER_XML);
|
|
251
249
|
const launcherRoundPath = _path().default.resolve(anyDpiV26Directory, IC_LAUNCHER_ROUND_XML);
|
|
252
250
|
if (add) {
|
|
253
|
-
await Promise.all([
|
|
251
|
+
await Promise.all([_fsExtra().default.writeFile(launcherPath, icLauncherXmlString), _fsExtra().default.writeFile(launcherRoundPath, icLauncherXmlString)]);
|
|
254
252
|
} else {
|
|
255
253
|
// Remove the xml if the icon switches from adaptive to standard.
|
|
256
254
|
await Promise.all([launcherPath, launcherRoundPath].map(async path => {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
255
|
+
if (_fsExtra().default.existsSync(path)) {
|
|
256
|
+
return _fsExtra().default.remove(path);
|
|
257
|
+
}
|
|
260
258
|
}));
|
|
261
259
|
}
|
|
262
260
|
}
|
|
@@ -294,7 +292,7 @@ async function generateMultiLayerImageAsync(projectRoot, {
|
|
|
294
292
|
isAdaptive
|
|
295
293
|
});
|
|
296
294
|
if (backgroundImageFileName) {
|
|
297
|
-
await
|
|
295
|
+
await _fsExtra().default.writeFile(_path().default.resolve(dpiFolder, backgroundImageFileName), backgroundLayer);
|
|
298
296
|
} else {
|
|
299
297
|
iconLayer = await (0, _imageUtils().compositeImagesAsync)({
|
|
300
298
|
foreground: iconLayer,
|
|
@@ -305,10 +303,8 @@ async function generateMultiLayerImageAsync(projectRoot, {
|
|
|
305
303
|
// Remove any instances of ic_launcher_background.png that are there from previous icons
|
|
306
304
|
await deleteIconNamedAsync(projectRoot, backgroundImageFileName);
|
|
307
305
|
}
|
|
308
|
-
await
|
|
309
|
-
|
|
310
|
-
});
|
|
311
|
-
await _fs().default.promises.writeFile(_path().default.resolve(dpiFolder, outputImageFileName), iconLayer);
|
|
306
|
+
await _fsExtra().default.ensureDir(dpiFolder);
|
|
307
|
+
await _fsExtra().default.writeFile(_path().default.resolve(dpiFolder, outputImageFileName), iconLayer);
|
|
312
308
|
});
|
|
313
309
|
}
|
|
314
310
|
async function generateMonochromeImageAsync(projectRoot, {
|
|
@@ -327,10 +323,8 @@ async function generateMonochromeImageAsync(projectRoot, {
|
|
|
327
323
|
backgroundColor: 'transparent',
|
|
328
324
|
isAdaptive: true
|
|
329
325
|
});
|
|
330
|
-
await
|
|
331
|
-
|
|
332
|
-
});
|
|
333
|
-
await _fs().default.promises.writeFile(_path().default.resolve(dpiFolder, outputImageFileName), monochromeIcon);
|
|
326
|
+
await _fsExtra().default.ensureDir(dpiFolder);
|
|
327
|
+
await _fsExtra().default.writeFile(_path().default.resolve(dpiFolder, outputImageFileName), monochromeIcon);
|
|
334
328
|
});
|
|
335
329
|
}
|
|
336
330
|
function iterateDpiValues(projectRoot, callback) {
|
|
@@ -343,9 +337,7 @@ async function deleteIconNamedAsync(projectRoot, name) {
|
|
|
343
337
|
return iterateDpiValues(projectRoot, ({
|
|
344
338
|
dpiFolder
|
|
345
339
|
}) => {
|
|
346
|
-
return
|
|
347
|
-
force: true
|
|
348
|
-
});
|
|
340
|
+
return _fsExtra().default.remove(_path().default.resolve(dpiFolder, name));
|
|
349
341
|
});
|
|
350
342
|
}
|
|
351
343
|
async function generateIconAsync(projectRoot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAndroidIcons.js","names":["_configPlugins","data","require","_imageUtils","_fs","_interopRequireDefault","_path","_withAndroidManifestIcons","e","__esModule","default","Colors","AndroidConfig","dpiValues","exports","mdpi","folderName","scale","hdpi","xhdpi","xxhdpi","xxxhdpi","LEGACY_BASELINE_PIXEL_SIZE","ADAPTIVE_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","promises","mkdir","recursive","launcherPath","launcherRoundPath","Promise","all","writeFile","map","rm","force","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';\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};\n\nconst LEGACY_BASELINE_PIXEL_SIZE = 48;\nconst ADAPTIVE_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(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_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 isAdaptive: false,\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_WEBP,\n });\n }\n await generateMultiLayerImageAsync(projectRoot, {\n backgroundColor: 'transparent',\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 isAdaptive: true,\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.promises.mkdir(anyDpiV26Directory, { recursive: true });\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.promises.writeFile(launcherPath, icLauncherXmlString, 'utf8'),\n fs.promises.writeFile(launcherRoundPath, icLauncherXmlString, 'utf8'),\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 return fs.promises.rm(path, { force: true });\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 isAdaptive,\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 isAdaptive?: boolean;\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 isAdaptive,\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 isAdaptive,\n });\n\n if (backgroundImageFileName) {\n await fs.promises.writeFile(\n path.resolve(dpiFolder, backgroundImageFileName),\n backgroundLayer\n );\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.promises.mkdir(dpiFolder, { recursive: true });\n await fs.promises.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 isAdaptive: true,\n });\n await fs.promises.mkdir(dpiFolder, { recursive: true });\n await fs.promises.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.promises.rm(path.resolve(dpiFolder, name), { force: true });\n });\n}\n\nasync function generateIconAsync(\n projectRoot: string,\n {\n cacheType,\n src,\n scale,\n backgroundColor,\n borderRadiusRatio,\n isAdaptive,\n }: {\n cacheType: string;\n src: string;\n scale: number;\n backgroundColor: string;\n borderRadiusRatio?: number;\n isAdaptive?: boolean;\n }\n) {\n const iconSizePx =\n (isAdaptive ? ADAPTIVE_BASELINE_PIXEL_SIZE : LEGACY_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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AEA,eAAeI,iBAAiBA,CAC9BtD,WAAmB,EACnB;EACEuD,SAAS;EACTC,GAAG;EACHvF,KAAK;EACLoB,eAAe;EACfgC,iBAAiB;EACjBpB;AAQF,CAAC,EACD;EACA,MAAM+D,UAAU,GACd,CAAC/D,UAAU,GAAG1B,4BAA4B,GAAGD,0BAA0B,IAAIL,KAAK;EAElF,OAAO,CACL,MAAM,IAAAgG,gCAAkB,EACtB;IAAEjE,WAAW;IAAEuD;EAAU,CAAC,EAC1B;IACEC,GAAG;IACHU,KAAK,EAAEF,UAAU;IACjBG,MAAM,EAAEH,UAAU;IAClBI,UAAU,EAAE,OAAO;IACnB/E,eAAe;IACfgF,YAAY,EAAEhD,iBAAiB,GAAG2C,UAAU,GAAG3C,iBAAiB,GAAGiD;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","LEGACY_BASELINE_PIXEL_SIZE","ADAPTIVE_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","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};\n\nconst LEGACY_BASELINE_PIXEL_SIZE = 48;\nconst ADAPTIVE_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(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_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 isAdaptive: false,\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_WEBP,\n });\n }\n await generateMultiLayerImageAsync(projectRoot, {\n backgroundColor: 'transparent',\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 isAdaptive: true,\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 isAdaptive,\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 isAdaptive?: boolean;\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 isAdaptive,\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 isAdaptive,\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 isAdaptive: true,\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 isAdaptive,\n }: {\n cacheType: string;\n src: string;\n scale: number;\n backgroundColor: string;\n borderRadiusRatio?: number;\n isAdaptive?: boolean;\n }\n) {\n const iconSizePx =\n (isAdaptive ? ADAPTIVE_BASELINE_PIXEL_SIZE : LEGACY_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;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,0BAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,yBAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAsE,SAAAI,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtE,MAAM;EAAEG;AAAO,CAAC,GAAGC,8BAAa;AAKzB,MAAMC,SAAiB,GAAAC,OAAA,CAAAD,SAAA,GAAG;EAC/BE,IAAI,EAAE;IAAEC,UAAU,EAAE,aAAa;IAAEC,KAAK,EAA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AACJ;AAEA,eAAesB,iBAAiBA,CAC9BpD,WAAmB,EACnB;EACEqD,SAAS;EACTC,GAAG;EACHrF,KAAK;EACLoB,eAAe;EACfgC,iBAAiB;EACjBpB;AAQF,CAAC,EACD;EACA,MAAM6D,UAAU,GACd,CAAC7D,UAAU,GAAG1B,4BAA4B,GAAGD,0BAA0B,IAAIL,KAAK;EAElF,OAAO,CACL,MAAM,IAAA8F,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":[]}
|
|
@@ -21,9 +21,9 @@ function _imageUtils() {
|
|
|
21
21
|
};
|
|
22
22
|
return data;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const data =
|
|
26
|
-
|
|
24
|
+
function fs() {
|
|
25
|
+
const data = _interopRequireWildcard(require("fs-extra"));
|
|
26
|
+
fs = function () {
|
|
27
27
|
return data;
|
|
28
28
|
};
|
|
29
29
|
return data;
|
|
@@ -42,7 +42,8 @@ function _AssetContents() {
|
|
|
42
42
|
};
|
|
43
43
|
return data;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
46
47
|
const {
|
|
47
48
|
getProjectName
|
|
48
49
|
} = _configPlugins().IOSConfig.XcodeUtils;
|
|
@@ -84,9 +85,7 @@ async function setIconsAsync(config, projectRoot) {
|
|
|
84
85
|
const iosNamedProjectRoot = getIosNamedProjectPath(projectRoot);
|
|
85
86
|
|
|
86
87
|
// Ensure the Images.xcassets/AppIcon.appiconset path exists
|
|
87
|
-
await
|
|
88
|
-
recursive: true
|
|
89
|
-
});
|
|
88
|
+
await fs().ensureDir((0, _path().join)(iosNamedProjectRoot, IMAGESET_PATH));
|
|
90
89
|
const imagesJson = [];
|
|
91
90
|
const baseIconPath = typeof icon === 'object' ? icon?.light || icon?.dark || icon?.tinted : icon;
|
|
92
91
|
|
|
@@ -181,7 +180,7 @@ async function generateUniversalIconAsync(projectRoot, {
|
|
|
181
180
|
}
|
|
182
181
|
// Write image buffer to the file system.
|
|
183
182
|
const assetPath = (0, _path().join)(iosNamedProjectRoot, IMAGESET_PATH, filename);
|
|
184
|
-
await
|
|
183
|
+
await fs().writeFile(assetPath, source);
|
|
185
184
|
return {
|
|
186
185
|
filename,
|
|
187
186
|
idiom: 'universal',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withIosIcons.js","names":["_configPlugins","data","require","_imageUtils","_fs","_interopRequireDefault","_path","_AssetContents","e","__esModule","default","getProjectName","IOSConfig","XcodeUtils","IMAGE_CACHE_NAME","IMAGESET_PATH","withIosIcons","config","withDangerousMod","setIconsAsync","modRequest","projectRoot","exports","getIcons","iosSpecificIcons","ios","icon","light","dark","tinted","WarningAggregator","addWarningIOS","iosNamedProjectRoot","getIosNamedProjectPath","fs","promises","mkdir","join","recursive","imagesJson","baseIconPath","baseIcon","generateUniversalIconAsync","cacheKey","platform","push","darkIcon","appearance","tintedIcon","writeContentsJsonAsync","images","projectName","getAppleIconName","size","scale","name","filename","source","generateImageAsync","cacheType","src","width","height","removeTransparency","resizeMode","backgroundColor","undefined","createSquareAsync","assetPath","writeFile","idiom","appearances","value"],"sources":["../../../src/plugins/icons/withIosIcons.ts"],"sourcesContent":["import { ConfigPlugin, IOSConfig, WarningAggregator, withDangerousMod } from '@expo/config-plugins';\nimport { ExpoConfig, IOSIcons } from '@expo/config-types';\nimport { createSquareAsync, generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs';\nimport { join } from 'path';\n\nimport { ContentsJson, ContentsJsonImage, writeContentsJsonAsync } from './AssetContents';\n\nconst { getProjectName } = IOSConfig.XcodeUtils;\n\nconst IMAGE_CACHE_NAME = 'icons';\nconst IMAGESET_PATH = 'Images.xcassets/AppIcon.appiconset';\n\nexport const withIosIcons: ConfigPlugin = (config) => {\n return withDangerousMod(config, [\n 'ios',\n async (config) => {\n await setIconsAsync(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport function getIcons(config: Pick<ExpoConfig, 'icon' | 'ios'>): IOSIcons | string | null {\n const iosSpecificIcons = config.ios?.icon;\n\n if (iosSpecificIcons) {\n // For backwards compatibility, the icon can be a string\n if (typeof iosSpecificIcons === 'string') {\n return iosSpecificIcons || config.icon || null;\n }\n\n // in iOS 18 introduced the ability to specify dark and tinted icons, which users can specify as an object\n if (!iosSpecificIcons.light && !iosSpecificIcons.dark && !iosSpecificIcons.tinted) {\n return config.icon || null;\n }\n\n return iosSpecificIcons;\n }\n\n if (config.icon) {\n return config.icon;\n }\n\n return null;\n}\n\nexport async function setIconsAsync(config: ExpoConfig, projectRoot: string) {\n const icon = getIcons(config);\n\n if (\n !icon ||\n (typeof icon === 'string' && !icon) ||\n (typeof icon === 'object' && !icon?.light && !icon?.dark && !icon?.tinted)\n ) {\n WarningAggregator.addWarningIOS('icon', 'No icon is defined in the Expo config.');\n }\n\n // Something like projectRoot/ios/MyApp/\n const iosNamedProjectRoot = getIosNamedProjectPath(projectRoot);\n\n // Ensure the Images.xcassets/AppIcon.appiconset path exists\n await fs.promises.mkdir(join(iosNamedProjectRoot, IMAGESET_PATH), { recursive: true });\n\n const imagesJson: ContentsJson['images'] = [];\n\n const baseIconPath = typeof icon === 'object' ? icon?.light || icon?.dark || icon?.tinted : icon;\n\n // Store the image JSON data for assigning via the Contents.json\n const baseIcon = await generateUniversalIconAsync(projectRoot, {\n icon: baseIconPath,\n cacheKey: 'universal-icon',\n iosNamedProjectRoot,\n platform: 'ios',\n });\n\n imagesJson.push(baseIcon);\n\n if (typeof icon === 'object') {\n if (icon?.dark) {\n const darkIcon = await generateUniversalIconAsync(projectRoot, {\n icon: icon.dark,\n cacheKey: 'universal-icon-dark',\n iosNamedProjectRoot,\n platform: 'ios',\n appearance: 'dark',\n });\n\n imagesJson.push(darkIcon);\n }\n\n if (icon?.tinted) {\n const tintedIcon = await generateUniversalIconAsync(projectRoot, {\n icon: icon.tinted,\n cacheKey: 'universal-icon-tinted',\n iosNamedProjectRoot,\n platform: 'ios',\n appearance: 'tinted',\n });\n\n imagesJson.push(tintedIcon);\n }\n }\n\n // Finally, write the Contents.json\n await writeContentsJsonAsync(join(iosNamedProjectRoot, IMAGESET_PATH), { images: imagesJson });\n}\n\n/**\n * Return the project's named iOS path: ios/MyProject/\n *\n * @param projectRoot Expo project root path.\n */\nfunction getIosNamedProjectPath(projectRoot: string): string {\n const projectName = getProjectName(projectRoot);\n return join(projectRoot, 'ios', projectName);\n}\n\nfunction getAppleIconName(size: number, scale: number, appearance?: 'dark' | 'tinted'): string {\n let name = 'App-Icon';\n\n if (appearance) {\n name = `${name}-${appearance}`;\n }\n\n name = `${name}-${size}x${size}@${scale}x.png`;\n\n return name;\n}\n\nexport async function generateUniversalIconAsync(\n projectRoot: string,\n {\n icon,\n cacheKey,\n iosNamedProjectRoot,\n platform,\n appearance,\n }: {\n platform: 'watchos' | 'ios';\n icon?: string | null;\n appearance?: 'dark' | 'tinted';\n iosNamedProjectRoot: string;\n cacheKey: string;\n }\n): Promise<ContentsJsonImage> {\n const size = 1024;\n const filename = getAppleIconName(size, 1, appearance);\n\n let source: Buffer;\n\n if (icon) {\n // Using this method will cache the images in `.expo` based on the properties used to generate them.\n // this method also supports remote URLs and using the global sharp instance.\n source = (\n await generateImageAsync(\n { projectRoot, cacheType: IMAGE_CACHE_NAME + cacheKey },\n {\n src: icon,\n name: filename,\n width: size,\n height: size,\n // Transparency needs to be preserved in dark variant, but can safely be removed in \"light\" and \"tinted\" variants.\n removeTransparency: appearance !== 'dark',\n // The icon should be square, but if it's not then it will be cropped.\n resizeMode: 'cover',\n // Force the background color to solid white to prevent any transparency. (for \"any\" and \"tinted\" variants)\n // TODO: Maybe use a more adaptive option based on the icon color?\n backgroundColor: appearance !== 'dark' ? '#ffffff' : undefined,\n }\n )\n ).source;\n } else {\n // Create a white square image if no icon exists to mitigate the chance of a submission failure to the app store.\n source = await createSquareAsync({ size });\n }\n // Write image buffer to the file system.\n const assetPath = join(iosNamedProjectRoot, IMAGESET_PATH, filename);\n await fs.promises.writeFile(assetPath, source);\n\n return {\n filename,\n idiom: 'universal',\n platform,\n size: `${size}x${size}`,\n ...(appearance ? { appearances: [{ appearance: 'luminosity', value: appearance }] } : {}),\n };\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,IAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,GAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA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,GAAG,IAAI;EACjB,MAAMG,QAAQ,GAAGJ,gBAAgB,CAACC,IAAI,EAAE,CAAC,EAAEN,UAAU,CAAC;EAEtD,IAAIU,MAAc;EAElB,IAAI/B,IAAI,EAAE;IACR;IACA;IACA+B,MAAM,GAAG,CACP,MAAM,IAAAC,gCAAkB,EACtB;MAAErC,WAAW;MAAEsC,SAAS,EAAE7C,gBAAgB,GAAG6B;IAAS,CAAC,EACvD;MACEiB,GAAG,EAAElC,IAAI;MACT6B,IAAI,EAAEC,QAAQ;MACdK,KAAK,EAAER,IAAI;MACXS,MAAM,EAAET,IAAI;MACZ;MACAU,kBAAkB,EAAEhB,UAAU,KAAK,MAAM;MACzC;MACAiB,UAAU,EAAE,OAAO;MACnB;MACA;MACAC,eAAe,EAAElB,UAAU,KAAK,MAAM,GAAG,SAAS,GAAGmB;IACvD,CACF,CAAC,EACDT,MAAM;EACV,CAAC,MAAM;IACL;IACAA,MAAM,GAAG,MAAM,IAAAU,+BAAiB,EAAC;MAAEd;IAAK,CAAC,CAAC;EAC5C;EACA;EACA,MAAMe,SAAS,GAAG,IAAA/B,YAAI,EAACL,mBAAmB,EAAEjB,aAAa,EAAEyC,QAAQ,CAAC;EACpE,MAAMtB,aAAE,CAACC,QAAQ,CAACkC,SAAS,CAACD,SAAS,EAAEX,MAAM,CAAC;EAE9C,OAAO;IACLD,QAAQ;IACRc,KAAK,EAAE,WAAW;IAClB1B,QAAQ;IACRS,IAAI,EAAE,GAAGA,IAAI,IAAIA,IAAI,EAAE;IACvB,IAAIN,UAAU,GAAG;MAAEwB,WAAW,EAAE,CAAC;QAAExB,UAAU,EAAE,YAAY;QAAEyB,KAAK,EAAEzB;MAAW,CAAC;IAAE,CAAC,GAAG,CAAC,CAAC;EAC1F,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"withIosIcons.js","names":["_configPlugins","data","require","_imageUtils","fs","_interopRequireWildcard","_path","_AssetContents","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getProjectName","IOSConfig","XcodeUtils","IMAGE_CACHE_NAME","IMAGESET_PATH","withIosIcons","config","withDangerousMod","setIconsAsync","modRequest","projectRoot","exports","getIcons","iosSpecificIcons","ios","icon","light","dark","tinted","WarningAggregator","addWarningIOS","iosNamedProjectRoot","getIosNamedProjectPath","ensureDir","join","imagesJson","baseIconPath","baseIcon","generateUniversalIconAsync","cacheKey","platform","push","darkIcon","appearance","tintedIcon","writeContentsJsonAsync","images","projectName","getAppleIconName","size","scale","name","filename","source","generateImageAsync","cacheType","src","width","height","removeTransparency","resizeMode","backgroundColor","undefined","createSquareAsync","assetPath","writeFile","idiom","appearances","value"],"sources":["../../../src/plugins/icons/withIosIcons.ts"],"sourcesContent":["import { ConfigPlugin, IOSConfig, WarningAggregator, withDangerousMod } from '@expo/config-plugins';\nimport { ExpoConfig, IOSIcons } from '@expo/config-types';\nimport { createSquareAsync, generateImageAsync } from '@expo/image-utils';\nimport * as fs from 'fs-extra';\nimport { join } from 'path';\n\nimport { ContentsJson, ContentsJsonImage, writeContentsJsonAsync } from './AssetContents';\n\nconst { getProjectName } = IOSConfig.XcodeUtils;\n\nconst IMAGE_CACHE_NAME = 'icons';\nconst IMAGESET_PATH = 'Images.xcassets/AppIcon.appiconset';\n\nexport const withIosIcons: ConfigPlugin = (config) => {\n return withDangerousMod(config, [\n 'ios',\n async (config) => {\n await setIconsAsync(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport function getIcons(config: Pick<ExpoConfig, 'icon' | 'ios'>): IOSIcons | string | null {\n const iosSpecificIcons = config.ios?.icon;\n\n if (iosSpecificIcons) {\n // For backwards compatibility, the icon can be a string\n if (typeof iosSpecificIcons === 'string') {\n return iosSpecificIcons || config.icon || null;\n }\n\n // in iOS 18 introduced the ability to specify dark and tinted icons, which users can specify as an object\n if (!iosSpecificIcons.light && !iosSpecificIcons.dark && !iosSpecificIcons.tinted) {\n return config.icon || null;\n }\n\n return iosSpecificIcons;\n }\n\n if (config.icon) {\n return config.icon;\n }\n\n return null;\n}\n\nexport async function setIconsAsync(config: ExpoConfig, projectRoot: string) {\n const icon = getIcons(config);\n\n if (\n !icon ||\n (typeof icon === 'string' && !icon) ||\n (typeof icon === 'object' && !icon?.light && !icon?.dark && !icon?.tinted)\n ) {\n WarningAggregator.addWarningIOS('icon', 'No icon is defined in the Expo config.');\n }\n\n // Something like projectRoot/ios/MyApp/\n const iosNamedProjectRoot = getIosNamedProjectPath(projectRoot);\n\n // Ensure the Images.xcassets/AppIcon.appiconset path exists\n await fs.ensureDir(join(iosNamedProjectRoot, IMAGESET_PATH));\n\n const imagesJson: ContentsJson['images'] = [];\n\n const baseIconPath = typeof icon === 'object' ? icon?.light || icon?.dark || icon?.tinted : icon;\n\n // Store the image JSON data for assigning via the Contents.json\n const baseIcon = await generateUniversalIconAsync(projectRoot, {\n icon: baseIconPath,\n cacheKey: 'universal-icon',\n iosNamedProjectRoot,\n platform: 'ios',\n });\n\n imagesJson.push(baseIcon);\n\n if (typeof icon === 'object') {\n if (icon?.dark) {\n const darkIcon = await generateUniversalIconAsync(projectRoot, {\n icon: icon.dark,\n cacheKey: 'universal-icon-dark',\n iosNamedProjectRoot,\n platform: 'ios',\n appearance: 'dark',\n });\n\n imagesJson.push(darkIcon);\n }\n\n if (icon?.tinted) {\n const tintedIcon = await generateUniversalIconAsync(projectRoot, {\n icon: icon.tinted,\n cacheKey: 'universal-icon-tinted',\n iosNamedProjectRoot,\n platform: 'ios',\n appearance: 'tinted',\n });\n\n imagesJson.push(tintedIcon);\n }\n }\n\n // Finally, write the Contents.json\n await writeContentsJsonAsync(join(iosNamedProjectRoot, IMAGESET_PATH), { images: imagesJson });\n}\n\n/**\n * Return the project's named iOS path: ios/MyProject/\n *\n * @param projectRoot Expo project root path.\n */\nfunction getIosNamedProjectPath(projectRoot: string): string {\n const projectName = getProjectName(projectRoot);\n return join(projectRoot, 'ios', projectName);\n}\n\nfunction getAppleIconName(size: number, scale: number, appearance?: 'dark' | 'tinted'): string {\n let name = 'App-Icon';\n\n if (appearance) {\n name = `${name}-${appearance}`;\n }\n\n name = `${name}-${size}x${size}@${scale}x.png`;\n\n return name;\n}\n\nexport async function generateUniversalIconAsync(\n projectRoot: string,\n {\n icon,\n cacheKey,\n iosNamedProjectRoot,\n platform,\n appearance,\n }: {\n platform: 'watchos' | 'ios';\n icon?: string | null;\n appearance?: 'dark' | 'tinted';\n iosNamedProjectRoot: string;\n cacheKey: string;\n }\n): Promise<ContentsJsonImage> {\n const size = 1024;\n const filename = getAppleIconName(size, 1, appearance);\n\n let source: Buffer;\n\n if (icon) {\n // Using this method will cache the images in `.expo` based on the properties used to generate them.\n // this method also supports remote URLs and using the global sharp instance.\n source = (\n await generateImageAsync(\n { projectRoot, cacheType: IMAGE_CACHE_NAME + cacheKey },\n {\n src: icon,\n name: filename,\n width: size,\n height: size,\n // Transparency needs to be preserved in dark variant, but can safely be removed in \"light\" and \"tinted\" variants.\n removeTransparency: appearance !== 'dark',\n // The icon should be square, but if it's not then it will be cropped.\n resizeMode: 'cover',\n // Force the background color to solid white to prevent any transparency. (for \"any\" and \"tinted\" variants)\n // TODO: Maybe use a more adaptive option based on the icon color?\n backgroundColor: appearance !== 'dark' ? '#ffffff' : undefined,\n }\n )\n ).source;\n } else {\n // Create a white square image if no icon exists to mitigate the chance of a submission failure to the app store.\n source = await createSquareAsync({ size });\n }\n // Write image buffer to the file system.\n const assetPath = join(iosNamedProjectRoot, IMAGESET_PATH, filename);\n await fs.writeFile(assetPath, source);\n\n return {\n filename,\n idiom: 'universal',\n platform,\n size: `${size}x${size}`,\n ...(appearance ? { appearances: [{ appearance: 'luminosity', value: appearance }] } : {}),\n };\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAA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_DATA_NOTIFICATION_ICON = "expo.modules.notifications.default_notification_icon";
|
|
5
5
|
export declare const META_DATA_NOTIFICATION_ICON_COLOR = "expo.modules.notifications.default_notification_color";
|
|
6
6
|
export declare const NOTIFICATION_ICON = "notification_icon";
|
|
7
|
-
export declare const NOTIFICATION_ICON_RESOURCE
|
|
7
|
+
export declare const NOTIFICATION_ICON_RESOURCE: string;
|
|
8
8
|
export declare const NOTIFICATION_ICON_COLOR = "notification_icon_color";
|
|
9
|
-
export declare const NOTIFICATION_ICON_COLOR_RESOURCE
|
|
9
|
+
export declare const NOTIFICATION_ICON_COLOR_RESOURCE: string;
|
|
10
10
|
export declare const withNotificationIcons: ConfigPlugin;
|
|
11
11
|
export declare const withNotificationIconColor: ConfigPlugin;
|
|
12
12
|
export declare const withNotificationManifest: ConfigPlugin;
|
|
@@ -24,9 +24,9 @@ function _imageUtils() {
|
|
|
24
24
|
};
|
|
25
25
|
return data;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const data = _interopRequireDefault(require("fs"));
|
|
29
|
-
|
|
27
|
+
function _fsExtra() {
|
|
28
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
29
|
+
_fsExtra = function () {
|
|
30
30
|
return data;
|
|
31
31
|
};
|
|
32
32
|
return data;
|
|
@@ -130,9 +130,7 @@ async function writeNotificationIconImageFilesAsync(icon, projectRoot) {
|
|
|
130
130
|
}) => {
|
|
131
131
|
const drawableFolderName = folderName.replace('mipmap', 'drawable');
|
|
132
132
|
const dpiFolderPath = _path().default.resolve(projectRoot, _withAndroidIcons().ANDROID_RES_PATH, drawableFolderName);
|
|
133
|
-
await
|
|
134
|
-
recursive: true
|
|
135
|
-
});
|
|
133
|
+
await _fsExtra().default.ensureDir(dpiFolderPath);
|
|
136
134
|
const iconSizePx = BASELINE_PIXEL_SIZE * scale;
|
|
137
135
|
try {
|
|
138
136
|
const resizedIcon = (await (0, _imageUtils().generateImageAsync)({
|
|
@@ -145,7 +143,7 @@ async function writeNotificationIconImageFilesAsync(icon, projectRoot) {
|
|
|
145
143
|
resizeMode: 'cover',
|
|
146
144
|
backgroundColor: 'transparent'
|
|
147
145
|
})).source;
|
|
148
|
-
await
|
|
146
|
+
await _fsExtra().default.writeFile(_path().default.resolve(dpiFolderPath, NOTIFICATION_ICON + '.png'), resizedIcon);
|
|
149
147
|
} catch (e) {
|
|
150
148
|
throw new Error('Encountered an issue resizing Android notification icon: ' + e);
|
|
151
149
|
}
|
|
@@ -157,9 +155,7 @@ async function removeNotificationIconImageFilesAsync(projectRoot) {
|
|
|
157
155
|
}) => {
|
|
158
156
|
const drawableFolderName = folderName.replace('mipmap', 'drawable');
|
|
159
157
|
const dpiFolderPath = _path().default.resolve(projectRoot, _withAndroidIcons().ANDROID_RES_PATH, drawableFolderName);
|
|
160
|
-
await
|
|
161
|
-
force: true
|
|
162
|
-
});
|
|
158
|
+
await _fsExtra().default.remove(_path().default.resolve(dpiFolderPath, NOTIFICATION_ICON + '.png'));
|
|
163
159
|
}));
|
|
164
160
|
}
|
|
165
161
|
//# sourceMappingURL=withAndroidNotifications.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withAndroidNotifications.js","names":["_configPlugins","data","require","_imageUtils","_fs","_interopRequireDefault","_path","_withAndroidIcons","e","__esModule","default","Colors","AndroidConfig","addMetaDataItemToMainApplication","getMainApplicationOrThrow","removeMetaDataItemFromMainApplication","Manifest","BASELINE_PIXEL_SIZE","META_DATA_NOTIFICATION_ICON","exports","META_DATA_NOTIFICATION_ICON_COLOR","NOTIFICATION_ICON","NOTIFICATION_ICON_RESOURCE","NOTIFICATION_ICON_COLOR","NOTIFICATION_ICON_COLOR_RESOURCE","withNotificationIcons","config","withDangerousMod","setNotificationIconAsync","modRequest","projectRoot","withNotificationIconColor","withAndroidColors","modResults","setNotificationIconColor","withNotificationManifest","withAndroidManifest","setNotificationConfig","getNotificationIcon","notification","icon","getNotificationColor","color","writeNotificationIconImageFilesAsync","removeNotificationIconImageFilesAsync","manifest","mainApplication","colors","assignColorValue","name","value","Promise","all","Object","values","dpiValues","map","folderName","scale","drawableFolderName","replace","dpiFolderPath","path","resolve","ANDROID_RES_PATH","fs","promises","mkdir","recursive","iconSizePx","resizedIcon","generateImageAsync","cacheType","src","width","height","resizeMode","backgroundColor","source","writeFile","Error","rm","force"],"sources":["../../../../src/plugins/unversioned/expo-notifications/withAndroidNotifications.ts"],"sourcesContent":["import {\n AndroidConfig,\n ConfigPlugin,\n withAndroidColors,\n withAndroidManifest,\n withDangerousMod,\n} from '@expo/config-plugins';\nimport { ExpoConfig } from '@expo/config-types';\nimport { generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { ANDROID_RES_PATH, dpiValues } from '../../icons/withAndroidIcons';\n\nconst { Colors } = AndroidConfig;\nconst {\n addMetaDataItemToMainApplication,\n getMainApplicationOrThrow,\n removeMetaDataItemFromMainApplication,\n} = AndroidConfig.Manifest;\n\ntype AndroidManifest = AndroidConfig.Manifest.AndroidManifest;\nconst BASELINE_PIXEL_SIZE = 24;\nexport const META_DATA_NOTIFICATION_ICON = 'expo.modules.notifications.default_notification_icon';\nexport const META_DATA_NOTIFICATION_ICON_COLOR =\n 'expo.modules.notifications.default_notification_color';\nexport const NOTIFICATION_ICON = 'notification_icon';\nexport const NOTIFICATION_ICON_RESOURCE = `@drawable/${NOTIFICATION_ICON}`;\nexport const NOTIFICATION_ICON_COLOR = 'notification_icon_color';\nexport const NOTIFICATION_ICON_COLOR_RESOURCE = `@color/${NOTIFICATION_ICON_COLOR}`;\n\nexport const withNotificationIcons: ConfigPlugin = (config) => {\n return withDangerousMod(config, [\n 'android',\n async (config) => {\n await setNotificationIconAsync(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport const withNotificationIconColor: ConfigPlugin = (config) => {\n return withAndroidColors(config, (config) => {\n config.modResults = setNotificationIconColor(config, config.modResults);\n return config;\n });\n};\n\nexport const withNotificationManifest: ConfigPlugin = (config) => {\n return withAndroidManifest(config, (config) => {\n config.modResults = setNotificationConfig(config, config.modResults);\n return config;\n });\n};\n\nexport function getNotificationIcon(config: ExpoConfig) {\n return config.notification?.icon || null;\n}\n\nexport function getNotificationColor(config: ExpoConfig) {\n return config.notification?.color || null;\n}\n\n/**\n * Applies configuration for expo-notifications, including\n * the notification icon and notification color.\n */\nexport async function setNotificationIconAsync(config: ExpoConfig, projectRoot: string) {\n const icon = getNotificationIcon(config);\n if (icon) {\n await writeNotificationIconImageFilesAsync(icon, projectRoot);\n } else {\n await removeNotificationIconImageFilesAsync(projectRoot);\n }\n}\n\nexport function setNotificationConfig(config: ExpoConfig, manifest: AndroidManifest) {\n const icon = getNotificationIcon(config);\n const color = getNotificationColor(config);\n const mainApplication = getMainApplicationOrThrow(manifest);\n if (icon) {\n addMetaDataItemToMainApplication(\n mainApplication,\n META_DATA_NOTIFICATION_ICON,\n NOTIFICATION_ICON_RESOURCE,\n 'resource'\n );\n } else {\n removeMetaDataItemFromMainApplication(mainApplication, META_DATA_NOTIFICATION_ICON);\n }\n if (color) {\n addMetaDataItemToMainApplication(\n mainApplication,\n META_DATA_NOTIFICATION_ICON_COLOR,\n NOTIFICATION_ICON_COLOR_RESOURCE,\n 'resource'\n );\n } else {\n removeMetaDataItemFromMainApplication(mainApplication, META_DATA_NOTIFICATION_ICON_COLOR);\n }\n return manifest;\n}\n\nexport function setNotificationIconColor(\n config: ExpoConfig,\n colors: AndroidConfig.Resources.ResourceXML\n) {\n return Colors.assignColorValue(colors, {\n name: NOTIFICATION_ICON_COLOR,\n value: getNotificationColor(config),\n });\n}\n\nasync function writeNotificationIconImageFilesAsync(icon: string, projectRoot: string) {\n await Promise.all(\n Object.values(dpiValues).map(async ({ folderName, scale }) => {\n const drawableFolderName = folderName.replace('mipmap', 'drawable');\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, drawableFolderName);\n await fs.promises.mkdir(dpiFolderPath, { recursive: true });\n const iconSizePx = BASELINE_PIXEL_SIZE * scale;\n\n try {\n const resizedIcon = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-notification' },\n {\n src: icon,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n }\n )\n ).source;\n await fs.promises.writeFile(\n path.resolve(dpiFolderPath, NOTIFICATION_ICON + '.png'),\n resizedIcon\n );\n } catch (e) {\n throw new Error('Encountered an issue resizing Android notification icon: ' + e);\n }\n })\n );\n}\n\nasync function removeNotificationIconImageFilesAsync(projectRoot: string) {\n await Promise.all(\n Object.values(dpiValues).map(async ({ folderName }) => {\n const drawableFolderName = folderName.replace('mipmap', 'drawable');\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, drawableFolderName);\n await fs.promises.rm(path.resolve(dpiFolderPath, NOTIFICATION_ICON + '.png'), {\n force: true,\n });\n })\n );\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,IAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,GAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,kBAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,iBAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,I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S,CACzBjB,eAAI,CAACC,OAAO,CAACF,aAAa,EAAExC,iBAAiB,GAAG,MAAM,CAAC,EACvDiD,WACF,CAAC;IACH,CAAC,CAAC,OAAO9D,CAAC,EAAE;MACV,MAAM,IAAIwE,KAAK,CAAC,2DAA2D,GAAGxE,CAAC,CAAC;IAClF;EACF,CAAC,CACH,CAAC;AACH;AAEA,eAAeoC,qCAAqCA,CAACd,WAAmB,EAAE;EACxE,MAAMqB,OAAO,CAACC,GAAG,CACfC,MAAM,CAACC,MAAM,CAACC,6BAAS,CAAC,CAACC,GAAG,CAAC,OAAO;IAAEC;EAAW,CAAC,KAAK;IACrD,MAAME,kBAAkB,GAAGF,UAAU,CAACG,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC;IACnE,MAAMC,aAAa,GAAGC,eAAI,CAACC,OAAO,CAACjC,WAAW,EAAEkC,oCAAgB,EAAEL,kBAAkB,CAAC;IACrF,MAAMM,aAAE,CAACC,QAAQ,CAACe,EAAE,CAACnB,eAAI,CAACC,OAAO,CAACF,aAAa,EAAExC,iBAAiB,GAAG,MAAM,CAAC,EAAE;MAC5E6D,KAAK,EAAE;IACT,CAAC,CAAC;EACJ,CAAC,CACH,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"withAndroidNotifications.js","names":["_configPlugins","data","require","_imageUtils","_fsExtra","_interopRequireDefault","_path","_withAndroidIcons","e","__esModule","default","Colors","AndroidConfig","addMetaDataItemToMainApplication","getMainApplicationOrThrow","removeMetaDataItemFromMainApplication","Manifest","BASELINE_PIXEL_SIZE","META_DATA_NOTIFICATION_ICON","exports","META_DATA_NOTIFICATION_ICON_COLOR","NOTIFICATION_ICON","NOTIFICATION_ICON_RESOURCE","NOTIFICATION_ICON_COLOR","NOTIFICATION_ICON_COLOR_RESOURCE","withNotificationIcons","config","withDangerousMod","setNotificationIconAsync","modRequest","projectRoot","withNotificationIconColor","withAndroidColors","modResults","setNotificationIconColor","withNotificationManifest","withAndroidManifest","setNotificationConfig","getNotificationIcon","notification","icon","getNotificationColor","color","writeNotificationIconImageFilesAsync","removeNotificationIconImageFilesAsync","manifest","mainApplication","colors","assignColorValue","name","value","Promise","all","Object","values","dpiValues","map","folderName","scale","drawableFolderName","replace","dpiFolderPath","path","resolve","ANDROID_RES_PATH","fs","ensureDir","iconSizePx","resizedIcon","generateImageAsync","cacheType","src","width","height","resizeMode","backgroundColor","source","writeFile","Error","remove"],"sources":["../../../../src/plugins/unversioned/expo-notifications/withAndroidNotifications.ts"],"sourcesContent":["import {\n AndroidConfig,\n ConfigPlugin,\n withAndroidColors,\n withAndroidManifest,\n withDangerousMod,\n} from '@expo/config-plugins';\nimport { ExpoConfig } from '@expo/config-types';\nimport { generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { ANDROID_RES_PATH, dpiValues } from '../../icons/withAndroidIcons';\n\nconst { Colors } = AndroidConfig;\nconst {\n addMetaDataItemToMainApplication,\n getMainApplicationOrThrow,\n removeMetaDataItemFromMainApplication,\n} = AndroidConfig.Manifest;\n\ntype AndroidManifest = AndroidConfig.Manifest.AndroidManifest;\nconst BASELINE_PIXEL_SIZE = 24;\nexport const META_DATA_NOTIFICATION_ICON = 'expo.modules.notifications.default_notification_icon';\nexport const META_DATA_NOTIFICATION_ICON_COLOR =\n 'expo.modules.notifications.default_notification_color';\nexport const NOTIFICATION_ICON = 'notification_icon';\nexport const NOTIFICATION_ICON_RESOURCE = `@drawable/${NOTIFICATION_ICON}`;\nexport const NOTIFICATION_ICON_COLOR = 'notification_icon_color';\nexport const NOTIFICATION_ICON_COLOR_RESOURCE = `@color/${NOTIFICATION_ICON_COLOR}`;\n\nexport const withNotificationIcons: ConfigPlugin = (config) => {\n return withDangerousMod(config, [\n 'android',\n async (config) => {\n await setNotificationIconAsync(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport const withNotificationIconColor: ConfigPlugin = (config) => {\n return withAndroidColors(config, (config) => {\n config.modResults = setNotificationIconColor(config, config.modResults);\n return config;\n });\n};\n\nexport const withNotificationManifest: ConfigPlugin = (config) => {\n return withAndroidManifest(config, (config) => {\n config.modResults = setNotificationConfig(config, config.modResults);\n return config;\n });\n};\n\nexport function getNotificationIcon(config: ExpoConfig) {\n return config.notification?.icon || null;\n}\n\nexport function getNotificationColor(config: ExpoConfig) {\n return config.notification?.color || null;\n}\n\n/**\n * Applies configuration for expo-notifications, including\n * the notification icon and notification color.\n */\nexport async function setNotificationIconAsync(config: ExpoConfig, projectRoot: string) {\n const icon = getNotificationIcon(config);\n if (icon) {\n await writeNotificationIconImageFilesAsync(icon, projectRoot);\n } else {\n await removeNotificationIconImageFilesAsync(projectRoot);\n }\n}\n\nexport function setNotificationConfig(config: ExpoConfig, manifest: AndroidManifest) {\n const icon = getNotificationIcon(config);\n const color = getNotificationColor(config);\n const mainApplication = getMainApplicationOrThrow(manifest);\n if (icon) {\n addMetaDataItemToMainApplication(\n mainApplication,\n META_DATA_NOTIFICATION_ICON,\n NOTIFICATION_ICON_RESOURCE,\n 'resource'\n );\n } else {\n removeMetaDataItemFromMainApplication(mainApplication, META_DATA_NOTIFICATION_ICON);\n }\n if (color) {\n addMetaDataItemToMainApplication(\n mainApplication,\n META_DATA_NOTIFICATION_ICON_COLOR,\n NOTIFICATION_ICON_COLOR_RESOURCE,\n 'resource'\n );\n } else {\n removeMetaDataItemFromMainApplication(mainApplication, META_DATA_NOTIFICATION_ICON_COLOR);\n }\n return manifest;\n}\n\nexport function setNotificationIconColor(\n config: ExpoConfig,\n colors: AndroidConfig.Resources.ResourceXML\n) {\n return Colors.assignColorValue(colors, {\n name: NOTIFICATION_ICON_COLOR,\n value: getNotificationColor(config),\n });\n}\n\nasync function writeNotificationIconImageFilesAsync(icon: string, projectRoot: string) {\n await Promise.all(\n Object.values(dpiValues).map(async ({ folderName, scale }) => {\n const drawableFolderName = folderName.replace('mipmap', 'drawable');\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, drawableFolderName);\n await fs.ensureDir(dpiFolderPath);\n const iconSizePx = BASELINE_PIXEL_SIZE * scale;\n\n try {\n const resizedIcon = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-notification' },\n {\n src: icon,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n }\n )\n ).source;\n await fs.writeFile(path.resolve(dpiFolderPath, NOTIFICATION_ICON + '.png'), resizedIcon);\n } catch (e) {\n throw new Error('Encountered an issue resizing Android notification icon: ' + e);\n }\n })\n );\n}\n\nasync function removeNotificationIconImageFilesAsync(projectRoot: string) {\n await Promise.all(\n Object.values(dpiValues).map(async ({ folderName }) => {\n const drawableFolderName = folderName.replace('mipmap', 'drawable');\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, drawableFolderName);\n await fs.remove(path.resolve(dpiFolderPath, NOTIFICATION_ICON + '.png'));\n })\n );\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAAA,eAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,cAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,kBAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,iBAAA,YAAAA,CAAA;IAAA,OAAAN,IAA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AAExC,iBAAiB,GAAG,MAAM,CAAC,EAAE+C,WAAW,CAAC;IAC1F,CAAC,CAAC,OAAO5D,CAAC,EAAE;MACV,MAAM,IAAIsE,KAAK,CAAC,2DAA2D,GAAGtE,CAAC,CAAC;IAClF;EACF,CAAC,CACH,CAAC;AACH;AAEA,eAAeoC,qCAAqCA,CAACd,WAAmB,EAAE;EACxE,MAAMqB,OAAO,CAACC,GAAG,CACfC,MAAM,CAACC,MAAM,CAACC,6BAAS,CAAC,CAACC,GAAG,CAAC,OAAO;IAAEC;EAAW,CAAC,KAAK;IACrD,MAAME,kBAAkB,GAAGF,UAAU,CAACG,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC;IACnE,MAAMC,aAAa,GAAGC,eAAI,CAACC,OAAO,CAACjC,WAAW,EAAEkC,oCAAgB,EAAEL,kBAAkB,CAAC;IACrF,MAAMM,kBAAE,CAACc,MAAM,CAACjB,eAAI,CAACC,OAAO,CAACF,aAAa,EAAExC,iBAAiB,GAAG,MAAM,CAAC,CAAC;EAC1E,CAAC,CACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -20,9 +20,9 @@ function _imageUtils() {
|
|
|
20
20
|
};
|
|
21
21
|
return data;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const data = _interopRequireDefault(require("fs"));
|
|
25
|
-
|
|
23
|
+
function _fsExtra() {
|
|
24
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
25
|
+
_fsExtra = function () {
|
|
26
26
|
return data;
|
|
27
27
|
};
|
|
28
28
|
return data;
|
|
@@ -144,10 +144,9 @@ async function clearAllExistingSplashImagesAsync(projectRoot) {
|
|
|
144
144
|
await Promise.all(Object.values(modes).map(async ({
|
|
145
145
|
path: filePath
|
|
146
146
|
}) => {
|
|
147
|
-
await
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
});
|
|
147
|
+
if (await _fsExtra().default.pathExists(_path().default.resolve(androidMainPath, filePath))) {
|
|
148
|
+
await _fsExtra().default.remove(_path().default.resolve(androidMainPath, filePath));
|
|
149
|
+
}
|
|
151
150
|
}));
|
|
152
151
|
}));
|
|
153
152
|
}
|
|
@@ -194,10 +193,8 @@ async function setSplashImageDrawablesForThemeAsync(config, theme, projectRoot,
|
|
|
194
193
|
const outputPath = _path().default.join(androidMainPath, DRAWABLES_CONFIGS[imageKey].modes[theme].path);
|
|
195
194
|
const folder = _path().default.dirname(outputPath);
|
|
196
195
|
// Ensure directory exists.
|
|
197
|
-
await
|
|
198
|
-
|
|
199
|
-
});
|
|
200
|
-
await _fs().default.promises.writeFile(outputPath, composedImage);
|
|
196
|
+
await _fsExtra().default.ensureDir(folder);
|
|
197
|
+
await _fsExtra().default.writeFile(outputPath, composedImage);
|
|
201
198
|
}
|
|
202
199
|
return null;
|
|
203
200
|
}));
|
|
@@ -209,16 +206,12 @@ async function writeSplashScreenDrawablesAsync(drawablePath, projectRoot, drawab
|
|
|
209
206
|
const lightDrawablePath = _path().default.join(drawablePath, DRAWABLES_CONFIGS.default.modes.light.path);
|
|
210
207
|
const darkDrawablePath = _path().default.join(drawablePath, DRAWABLES_CONFIGS.default.modes.dark.path);
|
|
211
208
|
const lightFolder = _path().default.dirname(lightDrawablePath);
|
|
212
|
-
await
|
|
213
|
-
|
|
214
|
-
});
|
|
215
|
-
await _fs().default.promises.copyFile(_path().default.join(projectRoot, drawable.icon), lightDrawablePath);
|
|
209
|
+
await _fsExtra().default.ensureDir(lightFolder);
|
|
210
|
+
await _fsExtra().default.copyFile(_path().default.join(projectRoot, drawable.icon), lightDrawablePath);
|
|
216
211
|
if (drawable.darkIcon) {
|
|
217
212
|
const darkFolder = _path().default.dirname(darkDrawablePath);
|
|
218
|
-
await
|
|
219
|
-
|
|
220
|
-
});
|
|
221
|
-
await _fs().default.promises.copyFile(_path().default.join(projectRoot, drawable.darkIcon), darkDrawablePath);
|
|
213
|
+
await _fsExtra().default.ensureDir(darkFolder);
|
|
214
|
+
await _fsExtra().default.copyFile(_path().default.join(projectRoot, drawable.darkIcon), darkDrawablePath);
|
|
222
215
|
}
|
|
223
216
|
}
|
|
224
217
|
//# sourceMappingURL=withAndroidSplashImages.js.map
|