@expo/prebuild-config 4.0.3 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/getAutolinkedPackages.js +6 -5
- package/build/getAutolinkedPackages.js.map +1 -1
- package/build/getPrebuildConfig.js.map +1 -1
- package/build/importExpoModulesAutolinking.d.ts +16 -0
- package/build/importExpoModulesAutolinking.js +38 -0
- package/build/importExpoModulesAutolinking.js.map +1 -0
- package/build/index.js.map +1 -1
- package/build/plugins/icons/AssetContents.js.map +1 -1
- package/build/plugins/icons/withAndroidIcons.d.ts +2 -1
- package/build/plugins/icons/withAndroidIcons.js +144 -132
- package/build/plugins/icons/withAndroidIcons.js.map +1 -1
- package/build/plugins/icons/withAndroidManifestIcons.js.map +1 -1
- package/build/plugins/icons/withIosIcons.js.map +1 -1
- package/build/plugins/unversioned/createLegacyPlugin.js.map +1 -1
- package/build/plugins/unversioned/expo-ads-admob/expo-ads-admob.js.map +1 -1
- package/build/plugins/unversioned/expo-ads-admob/withAndroidAdMob.js.map +1 -1
- package/build/plugins/unversioned/expo-ads-admob/withIosAdMob.js.map +1 -1
- package/build/plugins/unversioned/expo-apple-authentication.js.map +1 -1
- package/build/plugins/unversioned/expo-branch/expo-branch.js.map +1 -1
- package/build/plugins/unversioned/expo-branch/withAndroidBranch.js.map +1 -1
- package/build/plugins/unversioned/expo-branch/withIosBranch.js.map +1 -1
- package/build/plugins/unversioned/expo-contacts.js.map +1 -1
- package/build/plugins/unversioned/expo-document-picker.js.map +1 -1
- package/build/plugins/unversioned/expo-facebook/expo-facebook.js.map +1 -1
- package/build/plugins/unversioned/expo-facebook/withAndroidFacebook.js.map +1 -1
- package/build/plugins/unversioned/expo-facebook/withIosFacebook.js.map +1 -1
- package/build/plugins/unversioned/expo-facebook/withSKAdNetworkIdentifiers.js.map +1 -1
- package/build/plugins/unversioned/expo-navigation-bar/expo-navigation-bar.js.map +1 -1
- package/build/plugins/unversioned/expo-navigation-bar/withAndroidNavigationBar.js.map +1 -1
- package/build/plugins/unversioned/expo-notifications/expo-notifications.js.map +1 -1
- package/build/plugins/unversioned/expo-notifications/withAndroidNotifications.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/InterfaceBuilder.d.ts +94 -5
- package/build/plugins/unversioned/expo-splash-screen/InterfaceBuilder.js +89 -86
- package/build/plugins/unversioned/expo-splash-screen/InterfaceBuilder.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/expo-splash-screen.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/getAndroidSplashConfig.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/getIosSplashConfig.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashDrawables.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashImages.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashLegacyMainActivity.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashScreen.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashStrings.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withAndroidSplashStyles.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashAssets.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashInfoPlist.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreen.js +25 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreen.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreenStoryboard.d.ts +14 -0
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreenStoryboard.js +212 -0
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashScreenStoryboard.js.map +1 -0
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashXcodeProject.d.ts +5 -7
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashXcodeProject.js +11 -87
- package/build/plugins/unversioned/expo-splash-screen/withIosSplashXcodeProject.js.map +1 -1
- package/build/plugins/unversioned/expo-splash-screen/wtihIosSplashScreenStoryboardImage.d.ts +5 -0
- package/build/plugins/unversioned/expo-splash-screen/wtihIosSplashScreenStoryboardImage.js +68 -0
- package/build/plugins/unversioned/expo-splash-screen/wtihIosSplashScreenStoryboardImage.js.map +1 -0
- package/build/plugins/unversioned/expo-system-ui/expo-system-ui.js.map +1 -1
- package/build/plugins/unversioned/expo-system-ui/withAndroidRootViewBackgroundColor.js.map +1 -1
- package/build/plugins/unversioned/expo-system-ui/withAndroidUserInterfaceStyle.js.map +1 -1
- package/build/plugins/unversioned/expo-system-ui/withIosRootViewBackgroundColor.js.map +1 -1
- package/build/plugins/unversioned/expo-system-ui/withIosUserInterfaceStyle.d.ts +2 -2
- package/build/plugins/unversioned/expo-system-ui/withIosUserInterfaceStyle.js +8 -10
- package/build/plugins/unversioned/expo-system-ui/withIosUserInterfaceStyle.js.map +1 -1
- package/build/plugins/unversioned/expo-updates.js.map +1 -1
- package/build/plugins/unversioned/react-native-maps.js.map +1 -1
- package/build/plugins/withDefaultPlugins.js.map +1 -1
- package/package.json +14 -11
|
@@ -7,10 +7,10 @@ exports.getAutolinkedPackagesAsync = getAutolinkedPackagesAsync;
|
|
|
7
7
|
exports.resolvePackagesList = resolvePackagesList;
|
|
8
8
|
exports.shouldSkipAutoPlugin = shouldSkipAutoPlugin;
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
const data = require("
|
|
10
|
+
function _importExpoModulesAutolinking() {
|
|
11
|
+
const data = require("./importExpoModulesAutolinking");
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
_importExpoModulesAutolinking = function () {
|
|
14
14
|
return data;
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -25,8 +25,9 @@ function _autolinking() {
|
|
|
25
25
|
* @returns list of packages ex: `['expo-camera', 'react-native-screens']`
|
|
26
26
|
*/
|
|
27
27
|
async function getAutolinkedPackagesAsync(projectRoot, platforms = ['ios', 'android']) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
28
|
+
const autolinking = (0, _importExpoModulesAutolinking().importExpoModulesAutolinking)(projectRoot);
|
|
29
|
+
const searchPaths = await autolinking.resolveSearchPathsAsync(null, projectRoot);
|
|
30
|
+
const platformPaths = await Promise.all(platforms.map(platform => autolinking.findModulesAsync({
|
|
30
31
|
platform,
|
|
31
32
|
searchPaths,
|
|
32
33
|
silent: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"getAutolinkedPackages.js","names":["getAutolinkedPackagesAsync","projectRoot","platforms","autolinking","importExpoModulesAutolinking","searchPaths","resolveSearchPathsAsync","platformPaths","Promise","all","map","platform","findModulesAsync","silent","resolvePackagesList","allPlatformPaths","paths","Object","keys","flat","uniquePaths","Set","sort","shouldSkipAutoPlugin","config","plugin","Array","isArray","_internal","autolinkedModules","pluginId","isIncluded","includes"],"sources":["../src/getAutolinkedPackages.ts"],"sourcesContent":["import { ModPlatform, StaticPlugin } from '@expo/config-plugins';\nimport { ExpoConfig } from '@expo/config-types';\n\nimport { importExpoModulesAutolinking } from './importExpoModulesAutolinking';\n\n/**\n * Returns a list of packages that are autolinked to a project.\n *\n * @param projectRoot\n * @param platforms platforms to check for\n * @returns list of packages ex: `['expo-camera', 'react-native-screens']`\n */\nexport async function getAutolinkedPackagesAsync(\n projectRoot: string,\n platforms: ModPlatform[] = ['ios', 'android']\n) {\n const autolinking = importExpoModulesAutolinking(projectRoot);\n const searchPaths = await autolinking.resolveSearchPathsAsync(null, projectRoot);\n\n const platformPaths = await Promise.all(\n platforms.map((platform) =>\n autolinking.findModulesAsync({\n platform,\n searchPaths,\n silent: true,\n })\n )\n );\n\n return resolvePackagesList(platformPaths);\n}\n\nexport function resolvePackagesList(platformPaths: Record<string, any>[]) {\n const allPlatformPaths = platformPaths.map((paths) => Object.keys(paths)).flat();\n\n const uniquePaths = [...new Set(allPlatformPaths)];\n\n return uniquePaths.sort();\n}\n\nexport function shouldSkipAutoPlugin(\n config: Pick<ExpoConfig, '_internal'>,\n plugin: StaticPlugin | string\n) {\n // Hack workaround because expo-dev-client doesn't use expo modules.\n if (plugin === 'expo-dev-client') {\n return false;\n }\n\n // Only perform the check if `autolinkedModules` is defined, otherwise we assume\n // this is a legacy runner which doesn't support autolinking.\n if (Array.isArray(config._internal?.autolinkedModules)) {\n // Resolve the pluginId as a string.\n const pluginId = Array.isArray(plugin) ? plugin[0] : plugin;\n if (typeof pluginId === 'string') {\n // Determine if the autolinked modules list includes our moduleId\n const isIncluded = config._internal!.autolinkedModules.includes(pluginId);\n if (!isIncluded) {\n // If it doesn't then we know that any potential plugin shouldn't be applied automatically.\n return true;\n }\n }\n }\n return false;\n}\n"],"mappings":";;;;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,0BAAf,CACLC,WADK,EAELC,SAAwB,GAAG,CAAC,KAAD,EAAQ,SAAR,CAFtB,EAGL;EACA,MAAMC,WAAW,GAAG,IAAAC,4DAAA,EAA6BH,WAA7B,CAApB;EACA,MAAMI,WAAW,GAAG,MAAMF,WAAW,CAACG,uBAAZ,CAAoC,IAApC,EAA0CL,WAA1C,CAA1B;EAEA,MAAMM,aAAa,GAAG,MAAMC,OAAO,CAACC,GAAR,CAC1BP,SAAS,CAACQ,GAAV,CAAeC,QAAD,IACZR,WAAW,CAACS,gBAAZ,CAA6B;IAC3BD,QAD2B;IAE3BN,WAF2B;IAG3BQ,MAAM,EAAE;EAHmB,CAA7B,CADF,CAD0B,CAA5B;EAUA,OAAOC,mBAAmB,CAACP,aAAD,CAA1B;AACD;;AAEM,SAASO,mBAAT,CAA6BP,aAA7B,EAAmE;EACxE,MAAMQ,gBAAgB,GAAGR,aAAa,CAACG,GAAd,CAAmBM,KAAD,IAAWC,MAAM,CAACC,IAAP,CAAYF,KAAZ,CAA7B,EAAiDG,IAAjD,EAAzB;EAEA,MAAMC,WAAW,GAAG,CAAC,GAAG,IAAIC,GAAJ,CAAQN,gBAAR,CAAJ,CAApB;EAEA,OAAOK,WAAW,CAACE,IAAZ,EAAP;AACD;;AAEM,SAASC,oBAAT,CACLC,MADK,EAELC,MAFK,EAGL;EAAA;;EACA;EACA,IAAIA,MAAM,KAAK,iBAAf,EAAkC;IAChC,OAAO,KAAP;EACD,CAJD,CAMA;EACA;;;EACA,IAAIC,KAAK,CAACC,OAAN,sBAAcH,MAAM,CAACI,SAArB,sDAAc,kBAAkBC,iBAAhC,CAAJ,EAAwD;IACtD;IACA,MAAMC,QAAQ,GAAGJ,KAAK,CAACC,OAAN,CAAcF,MAAd,IAAwBA,MAAM,CAAC,CAAD,CAA9B,GAAoCA,MAArD;;IACA,IAAI,OAAOK,QAAP,KAAoB,QAAxB,EAAkC;MAChC;MACA,MAAMC,UAAU,GAAGP,MAAM,CAACI,SAAP,CAAkBC,iBAAlB,CAAoCG,QAApC,CAA6CF,QAA7C,CAAnB;;MACA,IAAI,CAACC,UAAL,EAAiB;QACf;QACA,OAAO,IAAP;MACD;IACF;EACF;;EACD,OAAO,KAAP;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"getPrebuildConfig.js","names":["getPrebuildConfigAsync","projectRoot","props","autolinkedModules","getAutolinkedPackagesAsync","platforms","getPrebuildConfig","bundleIdentifier","packageName","expoUsername","exp","config","rest","getConfig","skipSDKVersionRequirement","isModdedConfig","_internal","resolvedExpoUsername","getAccountUsername","withVersionedExpoSDKPlugins","withLegacyExpoPlugins","includes","ios","withIosExpoPlugins","android","package","withAndroidExpoPlugins"],"sources":["../src/getPrebuildConfig.ts"],"sourcesContent":["import { getAccountUsername, getConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport { ExpoConfig } from '@expo/config-types';\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 expoUsername?: string | ((config: ExpoConfig) => string | null);\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 expoUsername,\n }: {\n bundleIdentifier?: string;\n packageName?: string;\n platforms: ModPlatform[];\n autolinkedModules?: string[];\n expoUsername?: string | ((config: ExpoConfig) => string | null);\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 const resolvedExpoUsername =\n typeof expoUsername === 'function'\n ? expoUsername(config)\n : // If the user didn't pass a username then fallback on the static cached username.\n expoUsername ?? getAccountUsername(config);\n\n // Add all built-in plugins first because they should take\n // priority over the unversioned plugins.\n config = withVersionedExpoSDKPlugins(config, {\n expoUsername: resolvedExpoUsername,\n });\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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AAS,2CAAA,EAAsBT,MAAtB,CAAT;;EAEA,IAAIN,SAAS,CAACgB,QAAV,CAAmB,KAAnB,CAAJ,EAA+B;IAAA;;IAC7B,IAAI,CAACV,MAAM,CAACW,GAAZ,EAAiBX,MAAM,CAACW,GAAP,GAAa,EAAb;IACjBX,MAAM,CAACW,GAAP,CAAWf,gBAAX,WACEA,gBADF,aACEA,gBADF,cACEA,gBADF,GACsBI,MAAM,CAACW,GAAP,CAAWf,gBADjC,uCACsD,uBADtD,CAF6B,CAK7B;;IACAI,MAAM,GAAG,IAAAY,wCAAA,EAAmBZ,MAAnB,EAA2B;MAClCJ,gBAAgB,EAAEI,MAAM,CAACW,GAAP,CAAWf;IADK,CAA3B,CAAT;EAGD;;EAED,IAAIF,SAAS,CAACgB,QAAV,CAAmB,SAAnB,CAAJ,EAAmC;IAAA;;IACjC,IAAI,CAACV,MAAM,CAACa,OAAZ,EAAqBb,MAAM,CAACa,OAAP,GAAiB,EAAjB;IACrBb,MAAM,CAACa,OAAP,CAAeC,OAAf,YAAyBjB,WAAzB,aAAyBA,WAAzB,cAAyBA,WAAzB,GAAwCG,MAAM,CAACa,OAAP,CAAeC,OAAvD,yCAAmE,uBAAnE,CAFiC,CAIjC;;IACAd,MAAM,GAAG,IAAAe,4CAAA,EAAuBf,MAAvB,EAA+B;MACtCc,OAAO,EAAEd,MAAM,CAACa,OAAP,CAAeC;IADc,CAA/B,CAAT;EAGD;;EAED,OAAO;IAAEf,GAAG,EAAEC,MAAP;IAAe,GAAGC;EAAlB,CAAP;AACD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare type SearchResults = {
|
|
2
|
+
[moduleName: string]: object;
|
|
3
|
+
};
|
|
4
|
+
export declare type SearchOptions = {
|
|
5
|
+
searchPaths: string[];
|
|
6
|
+
platform: 'ios' | 'android' | 'web';
|
|
7
|
+
silent?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare type AutolinkingModule = {
|
|
10
|
+
resolveSearchPathsAsync(searchPaths: string[] | null, cwd: string): Promise<string[]>;
|
|
11
|
+
findModulesAsync(providedOptions: SearchOptions): Promise<SearchResults>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Imports the `expo-modules-autolinking` package installed in the project at the given path.
|
|
15
|
+
*/
|
|
16
|
+
export declare function importExpoModulesAutolinking(projectRoot: string): AutolinkingModule;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.importExpoModulesAutolinking = importExpoModulesAutolinking;
|
|
7
|
+
|
|
8
|
+
// NOTE: Keep these types in-sync with expo-modules-autolinking
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Imports the `expo-modules-autolinking` package installed in the project at the given path.
|
|
12
|
+
*/
|
|
13
|
+
function importExpoModulesAutolinking(projectRoot) {
|
|
14
|
+
const autolinking = tryRequireExpoModulesAutolinking(projectRoot);
|
|
15
|
+
assertAutolinkingCompatibility(autolinking);
|
|
16
|
+
return autolinking;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function tryRequireExpoModulesAutolinking(projectRoot) {
|
|
20
|
+
try {
|
|
21
|
+
const resolvedAutolinkingPath = require.resolve('expo-modules-autolinking/build/autolinking', {
|
|
22
|
+
paths: [projectRoot]
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return require(resolvedAutolinkingPath);
|
|
26
|
+
} catch {
|
|
27
|
+
throw new Error("Cannot find 'expo-modules-autolinking' package in your project, make sure that you have 'expo' package installed");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function assertAutolinkingCompatibility(autolinking) {
|
|
32
|
+
if ('resolveSearchPathsAsync' in autolinking && 'findModulesAsync' in autolinking) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw new Error("The 'expo-modules-autolinking' package has been found, but it seems to be incompatible with '@expo/prebuild-config'");
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=importExpoModulesAutolinking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importExpoModulesAutolinking.js","names":["importExpoModulesAutolinking","projectRoot","autolinking","tryRequireExpoModulesAutolinking","assertAutolinkingCompatibility","resolvedAutolinkingPath","require","resolve","paths","Error"],"sources":["../src/importExpoModulesAutolinking.ts"],"sourcesContent":["// NOTE: Keep these types in-sync with expo-modules-autolinking\n\nexport type SearchResults = {\n [moduleName: string]: object;\n};\n\nexport type SearchOptions = {\n searchPaths: string[];\n platform: 'ios' | 'android' | 'web';\n silent?: boolean;\n};\n\nexport type AutolinkingModule = {\n resolveSearchPathsAsync(searchPaths: string[] | null, cwd: string): Promise<string[]>;\n findModulesAsync(providedOptions: SearchOptions): Promise<SearchResults>;\n};\n\n/**\n * Imports the `expo-modules-autolinking` package installed in the project at the given path.\n */\nexport function importExpoModulesAutolinking(projectRoot: string): AutolinkingModule {\n const autolinking = tryRequireExpoModulesAutolinking(projectRoot);\n assertAutolinkingCompatibility(autolinking);\n return autolinking;\n}\n\nfunction tryRequireExpoModulesAutolinking(projectRoot: string): AutolinkingModule {\n try {\n const resolvedAutolinkingPath = require.resolve('expo-modules-autolinking/build/autolinking', {\n paths: [projectRoot],\n });\n return require(resolvedAutolinkingPath);\n } catch {\n throw new Error(\n \"Cannot find 'expo-modules-autolinking' package in your project, make sure that you have 'expo' package installed\"\n );\n }\n}\n\nfunction assertAutolinkingCompatibility(autolinking: AutolinkingModule): void {\n if ('resolveSearchPathsAsync' in autolinking && 'findModulesAsync' in autolinking) {\n return;\n }\n throw new Error(\n \"The 'expo-modules-autolinking' package has been found, but it seems to be incompatible with '@expo/prebuild-config'\"\n );\n}\n"],"mappings":";;;;;;;AAAA;;AAiBA;AACA;AACA;AACO,SAASA,4BAAT,CAAsCC,WAAtC,EAA8E;EACnF,MAAMC,WAAW,GAAGC,gCAAgC,CAACF,WAAD,CAApD;EACAG,8BAA8B,CAACF,WAAD,CAA9B;EACA,OAAOA,WAAP;AACD;;AAED,SAASC,gCAAT,CAA0CF,WAA1C,EAAkF;EAChF,IAAI;IACF,MAAMI,uBAAuB,GAAGC,OAAO,CAACC,OAAR,CAAgB,4CAAhB,EAA8D;MAC5FC,KAAK,EAAE,CAACP,WAAD;IADqF,CAA9D,CAAhC;;IAGA,OAAOK,OAAO,CAACD,uBAAD,CAAd;EACD,CALD,CAKE,MAAM;IACN,MAAM,IAAII,KAAJ,CACJ,kHADI,CAAN;EAGD;AACF;;AAED,SAASL,8BAAT,CAAwCF,WAAxC,EAA8E;EAC5E,IAAI,6BAA6BA,WAA7B,IAA4C,sBAAsBA,WAAtE,EAAmF;IACjF;EACD;;EACD,MAAM,IAAIO,KAAJ,CACJ,qHADI,CAAN;AAGD"}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable import/export */\n\nexport { getPrebuildConfigAsync } from './getPrebuildConfig';\nexport * from './plugins/withDefaultPlugins';\n"],"mappings":";;;;;;;;;;;;;;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"AssetContents.js","names":["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 = 'iphone' | 'ipad' | 'ios-marketing' | 'universal';\n\nexport type ContentsJsonImageAppearance = {\n appearance: 'luminosity';\n value: 'dark';\n};\n\nexport type ContentsJsonImageScale = '1x' | '2x' | '3x';\n\nexport interface ContentsJsonImage {\n appearances?: ContentsJsonImageAppearance[];\n idiom: ContentsJsonImageIdiom;\n size?: string;\n scale: ContentsJsonImageScale;\n filename?: string;\n}\n\nexport interface ContentsJson {\n images: ContentsJsonImage[];\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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AA2BO,SAASA,sBAAT,CAAgCC,IAAhC,EAA4E;EACjF,OAAOA,IAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,eAAeC,sBAAf,CACLC,SADK,EAEL;EAAEC;AAAF,CAFK,EAGU;EACf,MAAMC,kBAAA,CAAGC,SAAH,CAAaH,SAAb,CAAN;EAEA,MAAME,kBAAA,CAAGE,SAAH,CACJ,IAAAC,YAAA,EAAKL,SAAL,EAAgB,eAAhB,CADI,EAEJM,IAAI,CAACC,SAAL,CACE;IACEN,MADF;IAEEO,IAAI,EAAE;MACJC,OAAO,EAAE,CADL;MAEJ;MACAC,MAAM,EAAE;IAHJ;EAFR,CADF,EASE,IATF,EAUE,CAVF,CAFI,CAAN;AAeD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import { AndroidConfig, ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import { ExpoConfig } from '@expo/config-types';
|
|
3
3
|
declare type DPIString = 'mdpi' | 'hdpi' | 'xhdpi' | 'xxhdpi' | 'xxxhdpi';
|
|
4
4
|
declare type dpiMap = Record<DPIString, {
|
|
@@ -8,6 +8,7 @@ declare type dpiMap = Record<DPIString, {
|
|
|
8
8
|
export declare const dpiValues: dpiMap;
|
|
9
9
|
export declare const ANDROID_RES_PATH = "android/app/src/main/res/";
|
|
10
10
|
export declare const withAndroidIcons: ConfigPlugin;
|
|
11
|
+
export declare function setRoundIconManifest(config: Pick<ExpoConfig, 'android'>, manifest: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest;
|
|
11
12
|
export declare function getIcon(config: ExpoConfig): string | null;
|
|
12
13
|
export declare function getAdaptiveIcon(config: ExpoConfig): {
|
|
13
14
|
foregroundImage: string | null;
|
|
@@ -9,6 +9,7 @@ exports.dpiValues = exports.createAdaptiveIconXmlString = void 0;
|
|
|
9
9
|
exports.getAdaptiveIcon = getAdaptiveIcon;
|
|
10
10
|
exports.getIcon = getIcon;
|
|
11
11
|
exports.setIconAsync = setIconAsync;
|
|
12
|
+
exports.setRoundIconManifest = setRoundIconManifest;
|
|
12
13
|
exports.withAndroidIcons = void 0;
|
|
13
14
|
|
|
14
15
|
function _configPlugins() {
|
|
@@ -132,6 +133,22 @@ const withAndroidIcons = config => {
|
|
|
132
133
|
|
|
133
134
|
exports.withAndroidIcons = withAndroidIcons;
|
|
134
135
|
|
|
136
|
+
function setRoundIconManifest(config, manifest) {
|
|
137
|
+
var _config$android2;
|
|
138
|
+
|
|
139
|
+
const isAdaptive = !!((_config$android2 = config.android) !== null && _config$android2 !== void 0 && _config$android2.adaptiveIcon);
|
|
140
|
+
|
|
141
|
+
const application = _configPlugins().AndroidConfig.Manifest.getMainApplicationOrThrow(manifest);
|
|
142
|
+
|
|
143
|
+
if (isAdaptive) {
|
|
144
|
+
application.$['android:roundIcon'] = '@mipmap/ic_launcher_round';
|
|
145
|
+
} else {
|
|
146
|
+
delete application.$['android:roundIcon'];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return manifest;
|
|
150
|
+
}
|
|
151
|
+
|
|
135
152
|
const withAndroidAdaptiveIconColors = (config, backgroundColor) => {
|
|
136
153
|
return (0, _configPlugins().withAndroidColors)(config, config => {
|
|
137
154
|
config.modResults = setBackgroundColor(backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : '#FFFFFF', config.modResults);
|
|
@@ -140,18 +157,18 @@ const withAndroidAdaptiveIconColors = (config, backgroundColor) => {
|
|
|
140
157
|
};
|
|
141
158
|
|
|
142
159
|
function getIcon(config) {
|
|
143
|
-
var _config$
|
|
160
|
+
var _config$android3;
|
|
144
161
|
|
|
145
|
-
return ((_config$
|
|
162
|
+
return ((_config$android3 = config.android) === null || _config$android3 === void 0 ? void 0 : _config$android3.icon) || config.icon || null;
|
|
146
163
|
}
|
|
147
164
|
|
|
148
165
|
function getAdaptiveIcon(config) {
|
|
149
|
-
var _config$android$adapt, _config$
|
|
166
|
+
var _config$android$adapt, _config$android4, _config$android4$adap, _config$android$adapt2, _config$android5, _config$android5$adap, _config$android$adapt3, _config$android6, _config$android6$adap;
|
|
150
167
|
|
|
151
168
|
return {
|
|
152
|
-
foregroundImage: (_config$android$adapt = (_config$
|
|
153
|
-
backgroundColor: (_config$android$adapt2 = (_config$
|
|
154
|
-
backgroundImage: (_config$android$adapt3 = (_config$
|
|
169
|
+
foregroundImage: (_config$android$adapt = (_config$android4 = config.android) === null || _config$android4 === void 0 ? void 0 : (_config$android4$adap = _config$android4.adaptiveIcon) === null || _config$android4$adap === void 0 ? void 0 : _config$android4$adap.foregroundImage) !== null && _config$android$adapt !== void 0 ? _config$android$adapt : null,
|
|
170
|
+
backgroundColor: (_config$android$adapt2 = (_config$android5 = config.android) === null || _config$android5 === void 0 ? void 0 : (_config$android5$adap = _config$android5.adaptiveIcon) === null || _config$android5$adap === void 0 ? void 0 : _config$android5$adap.backgroundColor) !== null && _config$android$adapt2 !== void 0 ? _config$android$adapt2 : null,
|
|
171
|
+
backgroundImage: (_config$android$adapt3 = (_config$android6 = config.android) === null || _config$android6 === void 0 ? void 0 : (_config$android6$adap = _config$android6.adaptiveIcon) === null || _config$android6$adap === void 0 ? void 0 : _config$android6$adap.backgroundImage) !== null && _config$android$adapt3 !== void 0 ? _config$android$adapt3 : null
|
|
155
172
|
};
|
|
156
173
|
}
|
|
157
174
|
/**
|
|
@@ -172,6 +189,13 @@ async function setIconAsync(projectRoot, {
|
|
|
172
189
|
}
|
|
173
190
|
|
|
174
191
|
await configureLegacyIconAsync(projectRoot, icon, backgroundImage, backgroundColor);
|
|
192
|
+
|
|
193
|
+
if (isAdaptive) {
|
|
194
|
+
await generateRoundIconAsync(projectRoot, icon, backgroundImage, backgroundColor);
|
|
195
|
+
} else {
|
|
196
|
+
await deleteIconNamedAsync(projectRoot, IC_LAUNCHER_ROUND_PNG);
|
|
197
|
+
}
|
|
198
|
+
|
|
175
199
|
await configureAdaptiveIconAsync(projectRoot, icon, backgroundImage, isAdaptive);
|
|
176
200
|
return true;
|
|
177
201
|
}
|
|
@@ -184,76 +208,26 @@ async function setIconAsync(projectRoot, {
|
|
|
184
208
|
|
|
185
209
|
|
|
186
210
|
async function configureLegacyIconAsync(projectRoot, icon, backgroundImage, backgroundColor) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
backgroundColor = backgroundImage ? 'transparent' : (_backgroundColor = backgroundColor) !== null && _backgroundColor !== void 0 ? _backgroundColor : 'transparent';
|
|
198
|
-
let squareIconImage = (await (0, _imageUtils().generateImageAsync)({
|
|
199
|
-
projectRoot,
|
|
200
|
-
cacheType: 'android-standard-square'
|
|
201
|
-
}, {
|
|
202
|
-
src: icon,
|
|
203
|
-
width: iconSizePx,
|
|
204
|
-
height: iconSizePx,
|
|
205
|
-
resizeMode: 'cover',
|
|
206
|
-
backgroundColor
|
|
207
|
-
})).source;
|
|
208
|
-
let roundIconImage = (await (0, _imageUtils().generateImageAsync)({
|
|
209
|
-
projectRoot,
|
|
210
|
-
cacheType: 'android-standard-circle'
|
|
211
|
-
}, {
|
|
212
|
-
src: icon,
|
|
213
|
-
width: iconSizePx,
|
|
214
|
-
height: iconSizePx,
|
|
215
|
-
resizeMode: 'cover',
|
|
216
|
-
backgroundColor,
|
|
217
|
-
borderRadius: iconSizePx / 2
|
|
218
|
-
})).source;
|
|
219
|
-
|
|
220
|
-
if (backgroundImage) {
|
|
221
|
-
// Layer the buffers we just created on top of the background image that's provided
|
|
222
|
-
const squareBackgroundLayer = (await (0, _imageUtils().generateImageAsync)({
|
|
223
|
-
projectRoot,
|
|
224
|
-
cacheType: 'android-standard-square-background'
|
|
225
|
-
}, {
|
|
226
|
-
src: backgroundImage,
|
|
227
|
-
width: iconSizePx,
|
|
228
|
-
height: iconSizePx,
|
|
229
|
-
resizeMode: 'cover',
|
|
230
|
-
backgroundColor: 'transparent'
|
|
231
|
-
})).source;
|
|
232
|
-
const roundBackgroundLayer = (await (0, _imageUtils().generateImageAsync)({
|
|
233
|
-
projectRoot,
|
|
234
|
-
cacheType: 'android-standard-round-background'
|
|
235
|
-
}, {
|
|
236
|
-
src: backgroundImage,
|
|
237
|
-
width: iconSizePx,
|
|
238
|
-
height: iconSizePx,
|
|
239
|
-
resizeMode: 'cover',
|
|
240
|
-
backgroundColor: 'transparent',
|
|
241
|
-
borderRadius: iconSizePx / 2
|
|
242
|
-
})).source;
|
|
243
|
-
squareIconImage = await (0, _imageUtils().compositeImagesAsync)({
|
|
244
|
-
foreground: squareIconImage,
|
|
245
|
-
background: squareBackgroundLayer
|
|
246
|
-
});
|
|
247
|
-
roundIconImage = await (0, _imageUtils().compositeImagesAsync)({
|
|
248
|
-
foreground: roundIconImage,
|
|
249
|
-
background: roundBackgroundLayer
|
|
250
|
-
});
|
|
251
|
-
}
|
|
211
|
+
return generateMultiLayerImageAsync(projectRoot, {
|
|
212
|
+
icon,
|
|
213
|
+
backgroundImage,
|
|
214
|
+
backgroundColor,
|
|
215
|
+
outputImageFileName: IC_LAUNCHER_PNG,
|
|
216
|
+
imageCacheFolder: 'android-standard-square',
|
|
217
|
+
backgroundImageCacheFolder: 'android-standard-square-background'
|
|
218
|
+
});
|
|
219
|
+
}
|
|
252
220
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
221
|
+
async function generateRoundIconAsync(projectRoot, icon, backgroundImage, backgroundColor) {
|
|
222
|
+
return generateMultiLayerImageAsync(projectRoot, {
|
|
223
|
+
icon,
|
|
224
|
+
borderRadiusRatio: 0.5,
|
|
225
|
+
outputImageFileName: IC_LAUNCHER_ROUND_PNG,
|
|
226
|
+
backgroundImage,
|
|
227
|
+
backgroundColor,
|
|
228
|
+
imageCacheFolder: 'android-standard-circle',
|
|
229
|
+
backgroundImageCacheFolder: 'android-standard-round-background'
|
|
230
|
+
});
|
|
257
231
|
}
|
|
258
232
|
/**
|
|
259
233
|
* Configures adaptive icon files to be used on Android 8 and up. A foreground image must be provided,
|
|
@@ -264,47 +238,15 @@ async function configureLegacyIconAsync(projectRoot, icon, backgroundImage, back
|
|
|
264
238
|
|
|
265
239
|
|
|
266
240
|
async function configureAdaptiveIconAsync(projectRoot, foregroundImage, backgroundImage, isAdaptive) {
|
|
267
|
-
await
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const adpativeIconForeground = (await (0, _imageUtils().generateImageAsync)({
|
|
277
|
-
projectRoot,
|
|
278
|
-
cacheType: 'android-adaptive-foreground'
|
|
279
|
-
}, {
|
|
280
|
-
src: foregroundImage,
|
|
281
|
-
width: iconSizePx,
|
|
282
|
-
height: iconSizePx,
|
|
283
|
-
resizeMode: 'cover',
|
|
284
|
-
backgroundColor: 'transparent'
|
|
285
|
-
})).source;
|
|
286
|
-
await _fsExtra().default.writeFile(_path().default.resolve(dpiFolderPath, IC_LAUNCHER_FOREGROUND_PNG), adpativeIconForeground);
|
|
287
|
-
|
|
288
|
-
if (backgroundImage) {
|
|
289
|
-
const adpativeIconBackground = (await (0, _imageUtils().generateImageAsync)({
|
|
290
|
-
projectRoot,
|
|
291
|
-
cacheType: 'android-adaptive-background'
|
|
292
|
-
}, {
|
|
293
|
-
src: backgroundImage,
|
|
294
|
-
width: iconSizePx,
|
|
295
|
-
height: iconSizePx,
|
|
296
|
-
resizeMode: 'cover',
|
|
297
|
-
backgroundColor: 'transparent'
|
|
298
|
-
})).source;
|
|
299
|
-
await _fsExtra().default.writeFile(_path().default.resolve(dpiFolderPath, IC_LAUNCHER_BACKGROUND_PNG), adpativeIconBackground);
|
|
300
|
-
} else {
|
|
301
|
-
// Remove any instances of ic_launcher_background.png that are there from previous icons
|
|
302
|
-
await removeBackgroundImageFilesAsync(projectRoot);
|
|
303
|
-
}
|
|
304
|
-
} catch (e) {
|
|
305
|
-
throw new Error('Encountered an issue resizing adaptive app icon: ' + e);
|
|
306
|
-
}
|
|
307
|
-
})); // create ic_launcher.xml and ic_launcher_round.xml
|
|
241
|
+
await generateMultiLayerImageAsync(projectRoot, {
|
|
242
|
+
backgroundColor: 'transparent',
|
|
243
|
+
backgroundImage,
|
|
244
|
+
backgroundImageCacheFolder: 'android-adaptive-background',
|
|
245
|
+
outputImageFileName: IC_LAUNCHER_FOREGROUND_PNG,
|
|
246
|
+
icon: foregroundImage,
|
|
247
|
+
imageCacheFolder: 'android-adaptive-foreground',
|
|
248
|
+
backgroundImageFileName: IC_LAUNCHER_BACKGROUND_PNG
|
|
249
|
+
}); // create ic_launcher.xml and ic_launcher_round.xml
|
|
308
250
|
|
|
309
251
|
const icLauncherXmlString = createAdaptiveIconXmlString(backgroundImage);
|
|
310
252
|
await createAdaptiveIconXmlFiles(projectRoot, icLauncherXmlString, // If the user only defined icon and not android.adaptiveIcon, then skip enabling the layering system
|
|
@@ -320,15 +262,10 @@ function setBackgroundColor(backgroundColor, colors) {
|
|
|
320
262
|
}
|
|
321
263
|
|
|
322
264
|
const createAdaptiveIconXmlString = backgroundImage => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (backgroundImage) {
|
|
326
|
-
background = `<background android:drawable="@mipmap/ic_launcher_background"/>`;
|
|
327
|
-
}
|
|
328
|
-
|
|
265
|
+
const background = backgroundImage ? `@mipmap/ic_launcher_background` : `@color/iconBackground`;
|
|
329
266
|
return `<?xml version="1.0" encoding="utf-8"?>
|
|
330
267
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
|
331
|
-
${background}
|
|
268
|
+
<background android:drawable="${background}"/>
|
|
332
269
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
|
333
270
|
</adaptive-icon>`;
|
|
334
271
|
};
|
|
@@ -345,25 +282,100 @@ async function createAdaptiveIconXmlFiles(projectRoot, icLauncherXmlString, add)
|
|
|
345
282
|
const launcherRoundPath = _path().default.resolve(anyDpiV26Directory, IC_LAUNCHER_ROUND_XML);
|
|
346
283
|
|
|
347
284
|
if (add) {
|
|
348
|
-
await _fsExtra().default.writeFile(launcherPath, icLauncherXmlString);
|
|
349
|
-
await _fsExtra().default.writeFile(launcherRoundPath, icLauncherXmlString);
|
|
285
|
+
await Promise.all([_fsExtra().default.writeFile(launcherPath, icLauncherXmlString), _fsExtra().default.writeFile(launcherRoundPath, icLauncherXmlString)]);
|
|
350
286
|
} else {
|
|
351
287
|
// Remove the xml if the icon switches from adaptive to standard.
|
|
352
288
|
await Promise.all([launcherPath, launcherRoundPath].map(async path => {
|
|
353
289
|
if (_fsExtra().default.existsSync(path)) {
|
|
354
|
-
return
|
|
290
|
+
return _fsExtra().default.remove(path);
|
|
355
291
|
}
|
|
356
292
|
}));
|
|
357
293
|
}
|
|
358
294
|
}
|
|
359
295
|
|
|
360
|
-
async function
|
|
361
|
-
|
|
362
|
-
|
|
296
|
+
async function generateMultiLayerImageAsync(projectRoot, {
|
|
297
|
+
icon,
|
|
298
|
+
backgroundColor,
|
|
299
|
+
backgroundImage,
|
|
300
|
+
imageCacheFolder,
|
|
301
|
+
backgroundImageCacheFolder,
|
|
302
|
+
borderRadiusRatio,
|
|
303
|
+
outputImageFileName,
|
|
304
|
+
backgroundImageFileName
|
|
305
|
+
}) {
|
|
306
|
+
await iterateDpiValues(projectRoot, async ({
|
|
307
|
+
dpiFolder,
|
|
308
|
+
scale
|
|
363
309
|
}) => {
|
|
364
|
-
|
|
310
|
+
let iconLayer = await generateIconAsync(projectRoot, {
|
|
311
|
+
cacheType: imageCacheFolder,
|
|
312
|
+
src: icon,
|
|
313
|
+
scale,
|
|
314
|
+
// backgroundImage overrides backgroundColor
|
|
315
|
+
backgroundColor: backgroundImage ? 'transparent' : backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : 'transparent',
|
|
316
|
+
borderRadiusRatio
|
|
317
|
+
});
|
|
365
318
|
|
|
366
|
-
|
|
367
|
-
|
|
319
|
+
if (backgroundImage) {
|
|
320
|
+
const backgroundLayer = await generateIconAsync(projectRoot, {
|
|
321
|
+
cacheType: backgroundImageCacheFolder,
|
|
322
|
+
src: backgroundImage,
|
|
323
|
+
scale,
|
|
324
|
+
backgroundColor: 'transparent',
|
|
325
|
+
borderRadiusRatio
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
if (backgroundImageFileName) {
|
|
329
|
+
await _fsExtra().default.writeFile(_path().default.resolve(dpiFolder, backgroundImageFileName), backgroundLayer);
|
|
330
|
+
} else {
|
|
331
|
+
iconLayer = await (0, _imageUtils().compositeImagesAsync)({
|
|
332
|
+
foreground: iconLayer,
|
|
333
|
+
background: backgroundLayer
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
} else if (backgroundImageFileName) {
|
|
337
|
+
// Remove any instances of ic_launcher_background.png that are there from previous icons
|
|
338
|
+
await deleteIconNamedAsync(projectRoot, backgroundImageFileName);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
await _fsExtra().default.ensureDir(dpiFolder);
|
|
342
|
+
await _fsExtra().default.writeFile(_path().default.resolve(dpiFolder, outputImageFileName), iconLayer);
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function iterateDpiValues(projectRoot, callback) {
|
|
347
|
+
return Promise.all(Object.values(dpiValues).map(value => callback({
|
|
348
|
+
dpiFolder: _path().default.resolve(projectRoot, ANDROID_RES_PATH, value.folderName),
|
|
349
|
+
...value
|
|
350
|
+
})));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
async function deleteIconNamedAsync(projectRoot, name) {
|
|
354
|
+
return iterateDpiValues(projectRoot, ({
|
|
355
|
+
dpiFolder
|
|
356
|
+
}) => {
|
|
357
|
+
return _fsExtra().default.remove(_path().default.resolve(dpiFolder, name));
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async function generateIconAsync(projectRoot, {
|
|
362
|
+
cacheType,
|
|
363
|
+
src,
|
|
364
|
+
scale,
|
|
365
|
+
backgroundColor,
|
|
366
|
+
borderRadiusRatio
|
|
367
|
+
}) {
|
|
368
|
+
const iconSizePx = BASELINE_PIXEL_SIZE * scale;
|
|
369
|
+
return (await (0, _imageUtils().generateImageAsync)({
|
|
370
|
+
projectRoot,
|
|
371
|
+
cacheType
|
|
372
|
+
}, {
|
|
373
|
+
src,
|
|
374
|
+
width: iconSizePx,
|
|
375
|
+
height: iconSizePx,
|
|
376
|
+
resizeMode: 'cover',
|
|
377
|
+
backgroundColor,
|
|
378
|
+
borderRadius: borderRadiusRatio ? iconSizePx * borderRadiusRatio : undefined
|
|
379
|
+
})).source;
|
|
368
380
|
}
|
|
369
381
|
//# sourceMappingURL=withAndroidIcons.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/icons/withAndroidIcons.ts"],"names":["Colors","AndroidConfig","dpiValues","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_XML","IC_LAUNCHER_ROUND_XML","withAndroidIcons","config","foregroundImage","backgroundColor","backgroundImage","getAdaptiveIcon","icon","getIcon","withAndroidAdaptiveIconColors","setIconAsync","modRequest","projectRoot","isAdaptive","android","adaptiveIcon","modResults","setBackgroundColor","configureLegacyIconAsync","configureAdaptiveIconAsync","Promise","all","Object","values","map","dpiFolderPath","path","resolve","iconSizePx","squareIconImage","cacheType","src","width","height","resizeMode","source","roundIconImage","borderRadius","squareBackgroundLayer","roundBackgroundLayer","foreground","background","fs","ensureDir","writeFile","adpativeIconForeground","adpativeIconBackground","removeBackgroundImageFilesAsync","e","Error","icLauncherXmlString","createAdaptiveIconXmlString","createAdaptiveIconXmlFiles","colors","assignColorValue","value","name","add","anyDpiV26Directory","launcherPath","launcherRoundPath","existsSync","remove"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAQA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAaC,8BAAnB;;AAKO,MAAMC,SAAiB,GAAG;AAC/BC,EAAAA,IAAI,EAAE;AAAEC,IAAAA,UAAU,EAAE,aAAd;AAA6BC,IAAAA,KAAK,EAAE;AAApC,GADyB;AAE/BC,EAAAA,IAAI,EAAE;AAA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EAA0BpB,gBAA1B,EAA4CC,iBAA5C,CAA3B;;AACA,QAAMiD,mBAAGC,SAAH,CAAae,kBAAb,CAAN;;AACA,QAAMC,YAAY,GAAGjC,gBAAKC,OAAL,CAAa+B,kBAAb,EAAiC3D,eAAjC,CAArB;;AACA,QAAM6D,iBAAiB,GAAGlC,gBAAKC,OAAL,CAAa+B,kBAAb,EAAiC1D,qBAAjC,CAA1B;;AACA,MAAIyD,GAAJ,EAAS;AACP,UAAMf,mBAAGE,SAAH,CAAae,YAAb,EAA2BT,mBAA3B,CAAN;AACA,UAAMR,mBAAGE,SAAH,CAAagB,iBAAb,EAAgCV,mBAAhC,CAAN;AACD,GAHD,MAGO;AACL;AACA,UAAM9B,OAAO,CAACC,GAAR,CACJ,CAACsC,YAAD,EAAeC,iBAAf,EAAkCpC,GAAlC,CAAsC,MAAME,IAAN,IAAc;AAClD,UAAIgB,mBAAGmB,UAAH,CAAcnC,IAAd,CAAJ,EAAyB;AACvB,eAAO,MAAMgB,mBAAGoB,MAAH,CAAUpC,IAAV,CAAb;AACD;AACF,KAJD,CADI,CAAN;AAOD;AACF;;AAED,eAAeqB,+BAAf,CAA+CnC,WAA/C,EAAoE;AAClE,SAAO,MAAMQ,OAAO,CAACC,GAAR,CACXC,MAAM,CAACC,MAAP,CAAcxC,SAAd,EAAyByC,GAAzB,CAA6B,OAAO;AAAEvC,IAAAA;AAAF,GAAP,KAA0B;AACrD,UAAMwC,aAAa,GAAGC,gBAAKC,OAAL,CAAaf,WAAb,EAA0BpB,gBAA1B,EAA4CP,UAA5C,CAAtB;;AACA,UAAMyD,mBAAGoB,MAAH,CAAUpC,gBAAKC,OAAL,CAAaF,aAAb,EAA4B5B,0BAA5B,CAAV,CAAN;AACD,GAHD,CADW,CAAb;AAMD","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 = 48;\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_XML = 'ic_launcher.xml';\nconst IC_LAUNCHER_ROUND_XML = 'ic_launcher_round.xml';\n\nexport const withAndroidIcons: ConfigPlugin = config => {\n const { foregroundImage, backgroundColor, backgroundImage } = 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 isAdaptive: !!config.android?.adaptiveIcon,\n });\n return config;\n },\n ]);\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 };\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 isAdaptive,\n }: {\n icon: string | null;\n backgroundColor: string | null;\n backgroundImage: string | null;\n isAdaptive: boolean;\n }\n) {\n if (!icon) {\n return null;\n }\n\n await configureLegacyIconAsync(projectRoot, icon, backgroundImage, backgroundColor);\n\n await configureAdaptiveIconAsync(projectRoot, icon, backgroundImage, 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 await Promise.all(\n Object.values(dpiValues).map(async ({ folderName, scale }) => {\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, folderName);\n const iconSizePx = BASELINE_PIXEL_SIZE * scale;\n\n // backgroundImage overrides backgroundColor\n backgroundColor = backgroundImage ? 'transparent' : backgroundColor ?? 'transparent';\n\n let squareIconImage: Buffer = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-standard-square' },\n {\n src: icon,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor,\n }\n )\n ).source;\n let roundIconImage: Buffer = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-standard-circle' },\n {\n src: icon,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor,\n borderRadius: iconSizePx / 2,\n }\n )\n ).source;\n\n if (backgroundImage) {\n // Layer the buffers we just created on top of the background image that's provided\n const squareBackgroundLayer = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-standard-square-background' },\n {\n src: backgroundImage,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n }\n )\n ).source;\n const roundBackgroundLayer = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-standard-round-background' },\n {\n src: backgroundImage,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n borderRadius: iconSizePx / 2,\n }\n )\n ).source;\n squareIconImage = await compositeImagesAsync({\n foreground: squareIconImage,\n background: squareBackgroundLayer,\n });\n roundIconImage = await compositeImagesAsync({\n foreground: roundIconImage,\n background: roundBackgroundLayer,\n });\n }\n\n await fs.ensureDir(dpiFolderPath);\n await fs.writeFile(path.resolve(dpiFolderPath, IC_LAUNCHER_PNG), squareIconImage);\n await fs.writeFile(path.resolve(dpiFolderPath, IC_LAUNCHER_ROUND_PNG), roundIconImage);\n })\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 isAdaptive: boolean\n) {\n await Promise.all(\n Object.values(dpiValues).map(async ({ folderName, scale }) => {\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, folderName);\n const iconSizePx = BASELINE_PIXEL_SIZE * scale;\n\n try {\n const adpativeIconForeground = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-adaptive-foreground' },\n {\n src: foregroundImage,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n }\n )\n ).source;\n await fs.writeFile(\n path.resolve(dpiFolderPath, IC_LAUNCHER_FOREGROUND_PNG),\n adpativeIconForeground\n );\n\n if (backgroundImage) {\n const adpativeIconBackground = (\n await generateImageAsync(\n { projectRoot, cacheType: 'android-adaptive-background' },\n {\n src: backgroundImage,\n width: iconSizePx,\n height: iconSizePx,\n resizeMode: 'cover',\n backgroundColor: 'transparent',\n }\n )\n ).source;\n await fs.writeFile(\n path.resolve(dpiFolderPath, IC_LAUNCHER_BACKGROUND_PNG),\n adpativeIconBackground\n );\n } else {\n // Remove any instances of ic_launcher_background.png that are there from previous icons\n await removeBackgroundImageFilesAsync(projectRoot);\n }\n } catch (e) {\n throw new Error('Encountered an issue resizing adaptive app icon: ' + e);\n }\n })\n );\n\n // create ic_launcher.xml and ic_launcher_round.xml\n const icLauncherXmlString = createAdaptiveIconXmlString(backgroundImage);\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 = (backgroundImage: string | null) => {\n let background = `<background android:drawable=\"@color/iconBackground\"/>`;\n if (backgroundImage) {\n background = `<background android:drawable=\"@mipmap/ic_launcher_background\"/>`;\n }\n\n return `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n ${background}\n <foreground android:drawable=\"@mipmap/ic_launcher_foreground\"/>\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 fs.writeFile(launcherPath, icLauncherXmlString);\n await fs.writeFile(launcherRoundPath, icLauncherXmlString);\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 await fs.remove(path);\n }\n })\n );\n }\n}\n\nasync function removeBackgroundImageFilesAsync(projectRoot: string) {\n return await Promise.all(\n Object.values(dpiValues).map(async ({ folderName }) => {\n const dpiFolderPath = path.resolve(projectRoot, ANDROID_RES_PATH, folderName);\n await fs.remove(path.resolve(dpiFolderPath, IC_LAUNCHER_BACKGROUND_PNG));\n })\n );\n}\n"],"file":"withAndroidIcons.js"}
|
|
1
|
+
{"version":3,"file":"withAndroidIcons.js","names":["Colors","AndroidConfig","dpiValues","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_XML","IC_LAUNCHER_ROUND_XML","withAndroidIcons","config","foregroundImage","backgroundColor","backgroundImage","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","backgroundImageFileName","icLauncherXmlString","createAdaptiveIconXmlString","createAdaptiveIconXmlFiles","colors","assignColorValue","value","name","background","add","anyDpiV26Directory","path","resolve","fs","ensureDir","launcherPath","launcherRoundPath","Promise","all","writeFile","map","existsSync","remove","iterateDpiValues","dpiFolder","iconLayer","generateIconAsync","cacheType","src","backgroundLayer","compositeImagesAsync","foreground","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 = 48;\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_XML = 'ic_launcher.xml';\nconst IC_LAUNCHER_ROUND_XML = 'ic_launcher_round.xml';\n\nexport const withAndroidIcons: ConfigPlugin = (config) => {\n const { foregroundImage, backgroundColor, backgroundImage } = 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 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 };\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 isAdaptive,\n }: {\n icon: string | null;\n backgroundColor: string | null;\n backgroundImage: 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, 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 isAdaptive: boolean\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);\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 = (backgroundImage: string | null) => {\n const background = backgroundImage ? `@mipmap/ic_launcher_background` : `@color/iconBackground`;\n\n return `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <background android:drawable=\"${background}\"/>\n <foreground android:drawable=\"@mipmap/ic_launcher_foreground\"/>\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\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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAQA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;AAEA,MAAM;EAAEA;AAAF,IAAaC,8BAAnB;;AAKO,MAAMC,SAAiB,GAAG;EAC/BC,IAAI,EAAE;IAAEC,UAAU,EAAE,aAAd;IAA6BC,KAAK,EAAE;EAApC,CADyB;EAE/BC,IAAI,EAAE;IAAEF,UAAU,EAAE,aAAd;IAA6BC,KAAK,EAAE;EAApC,CAFyB;EAG/BE,KAAK,EAAE;IAAEH,UAAU,EAAE,cAAd;IAA8BC,KAAK,EAAE;EAArC,CAHwB;EAI/BG,MAAM,EAAE;IAAEJ,UAAU,EAAE,eAAd;IAA+BC,KAAK,EAAE;EAAtC,CAJuB;EAK/BI,OAAO,EAAE;IAAEL,UAAU,EAAE,gBAAd;IAAgCC,KAAK,EAAE;EAAvC;AALsB,CAA1B;;AAOP,MAAMK,mBAAmB,GAAG,EAA5B;AACO,MAAMC,gBAAg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