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AACjB,CAAC;AAED,kBAAe,GAAG,EAAE,CAClB,IAAI,mBAAO,EAAE;KACV,WAAW,CACV,wNAAwN,CACzN;KACA,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;KAC3C,kBAAkB,CAAC,KAAK,CAAC;KACzB,mBAAmB,CAAC,KAAK,CAAC;KAC1B,MAAM,CACL,2BAA2B,EAC3B,qDAAqD,mBAAmB,CACtE,oBAAQ,CACT,eAAe,oBAAQ,CAAC,GAAG,KAAK,CAClC;KACA,MAAM,CACL,gCAAgC,EAChC,oNAAoN,CACrN;KACA,MAAM,CACL,yBAAyB,EACzB,uEAAuE,CACxE;KACA,MAAM,CACL,sCAAsC,EACtC,6HAA6H,mBAAmB,CAC9I,uCAA2B,CAC5B,yDACC,uCAA2B,CAAC,OAC9B,KAAK,CACN;KACA,MAAM,CACL,sCAAsC,EACtC,gMAAgM,CACjM;KACA,MAAM,CACL,+BAA+B,EAC/B,6JAA6J,CAC9J;KACA,MAAM,CACL,4BAA4B,EAC5B,mEAAmE,mBAAmB,CACpF,sCAA0B,CAC3B,eAAe,sCAA0B,CAAC,OAAO,KAAK,CACxD;KACA,MAAM,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;KACtD,MAAM,CACL,uCAAuC,EACvC,kJAAkJ,CACnJ;KACA,MAAM,CACL,0BAA0B,EAC1B,2GAA2G,CAC5G;KACA,MAAM,CACL,sCAAsC,EACtC,wLAAwL,CACzL;KACA,MAAM,CACL,iDAAiD,EACjD,uMAAuM,CACxM;KACA,MAAM,CAAC,KAAK,EAAE,OAAsB,EAAE,EAAE;IACvC,MAAM,aAAa,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC","sourcesContent":["import { Command } from 'commander';\n\nimport { AndroidSplashScreenConfigJSON, IosSplashScreenConfigJSON } from './SplashScreenConfig';\nimport configureAndroid from './android';\nimport {\n SplashScreenImageResizeMode,\n SplashScreenStatusBarStyle,\n Platform,\n PlatformType,\n} from './constants';\nimport configureIos from './ios';\nimport { validateEnumValue } from './validators';\n\ntype RawCLIOptions = Partial<{\n imageResizeMode: string;\n platform: string;\n backgroundColor: string;\n imagePath: string;\n darkModeBackgroundColor: string;\n darkModeImagePath: string;\n statusBarHidden: boolean;\n statusBarStyle: string;\n darkModeStatusBarStyle: string;\n statusBarTranslucent: boolean;\n statusBarBackgroundColor: string;\n darkModeStatusBarBackgroundColor: string;\n}>;\n\ninterface Configuration {\n platform: PlatformType;\n android: AndroidSplashScreenConfigJSON;\n ios: IosSplashScreenConfigJSON;\n}\n\nasync function action(configuration: Configuration) {\n const { platform, android, ios } = configuration;\n const rootDir = process.cwd();\n switch (platform) {\n case Platform.ANDROID:\n await configureAndroid(rootDir, android);\n break;\n case Platform.IOS:\n await configureIos(rootDir, ios);\n break;\n case Platform.ALL:\n default:\n await configureAndroid(rootDir, android);\n await configureIos(rootDir, ios);\n break;\n }\n}\n\nfunction configurationFromOptions({\n platform,\n imageResizeMode,\n backgroundColor,\n imagePath,\n statusBarHidden,\n statusBarStyle,\n statusBarTranslucent,\n statusBarBackgroundColor,\n darkModeBackgroundColor,\n darkModeImagePath,\n darkModeStatusBarStyle,\n darkModeStatusBarBackgroundColor,\n}: RawCLIOptions): Configuration {\n let resolvedPlatform: PlatformType = Platform.ALL;\n try {\n resolvedPlatform = (platform && validateEnumValue(platform, Platform)) || Platform.ALL;\n } catch (e) {\n throw new Error(`'platform': ${e.message}`);\n }\n\n if (!backgroundColor) {\n throw new Error(\n `'backgroundColor': Required option is not provided. Provide a valid color string.`\n );\n }\n\n const resolvedStatusBarHidden =\n statusBarHidden === undefined ? undefined : Boolean(statusBarHidden);\n const resolvedStatusBarTranslucent =\n statusBarTranslucent === undefined ? undefined : Boolean(statusBarTranslucent);\n\n const genericConfig = {\n imageResizeMode,\n backgroundColor,\n image: imagePath,\n };\n const genericStatusBarConfig = {\n hidden: resolvedStatusBarHidden,\n style: statusBarStyle,\n };\n const genericDarkModeConfig = {\n backgroundColor: darkModeBackgroundColor,\n image: darkModeImagePath,\n };\n\n const result: Configuration = {\n platform: resolvedPlatform,\n android: {\n ...genericConfig,\n statusBar: {\n ...genericStatusBarConfig,\n translucent: resolvedStatusBarTranslucent,\n backgroundColor: statusBarBackgroundColor,\n },\n darkMode: {\n ...genericDarkModeConfig,\n statusBar: {\n style: darkModeStatusBarStyle,\n backgroundColor: darkModeStatusBarBackgroundColor,\n },\n },\n },\n ios: {\n ...genericConfig,\n statusBar: genericStatusBarConfig,\n darkMode: genericDarkModeConfig,\n },\n };\n\n return result;\n}\n\nfunction getAvailableOptions(o: object) {\n return Object.values(o)\n .map(v => `\"${v}\"`)\n .join(' | ');\n}\n\nexport default () =>\n new Command()\n .description(\n 'Idempotent operation that configures native splash screens using provided backgroundColor and optional .png file. Supports light and dark modes configuration. Dark mode is supported only on iOS 13+ and Android 10+.'\n )\n .version(require('../package.json').version)\n .allowUnknownOption(false)\n .passCommandToAction(false)\n .option(\n '-p, --platform <platform>',\n `Selected platform to configure. Available values: ${getAvailableOptions(\n Platform\n )} (default: \"${Platform.ALL}\").`\n )\n .option(\n '-b, --background-color <color>',\n `(required) Valid css-formatted color (hex (#RRGGBB[AA]), rgb[a], hsl[a], named color (https://drafts.csswg.org/css-color/#named-colors)) that would be used as the background color for native splash screen view.`\n )\n .option(\n '-i, --image-path <path>',\n 'Path to valid .png image that will be displayed on the splash screen.'\n )\n .option(\n '-r, --image-resize-mode <resizeMode>',\n `Resize mode to be used for the splash screen image. Available only if 'image-path' is provided as well. Available values: ${getAvailableOptions(\n SplashScreenImageResizeMode\n )} (\"native\" is only available for Android)) (default: \"${\n SplashScreenImageResizeMode.CONTAIN\n }\").`\n )\n .option(\n '--dark-mode-background-color <color>',\n `Color (see 'background-color' supported formats) that would be used as the background color for the splash screen in dark mode. Providing this option enables other dark-mode related options.`\n )\n .option(\n '--dark-mode-image-path <path>',\n `Path to valid .png image that will be displayed on the splash screen in dark mode only. Available only if 'dark-mode-background-color' is provided as well.`\n )\n .option(\n '--status-bar-style <style>',\n `Customizes the color of the status bar icons. Available values: ${getAvailableOptions(\n SplashScreenStatusBarStyle\n )} (default: \"${SplashScreenStatusBarStyle.DEFAULT}\").`\n )\n .option('--status-bar-hidden', `Hides the status bar.`)\n .option(\n '--status-bar-background-color <color>',\n `(only for Android platform) Customizes the background color of the status bar. Accepts a valid color (see 'background-color' supported formats).`\n )\n .option(\n '--status-bar-translucent',\n `(only for Android platform) Makes the status bar translucent (enables drawing under the status bar area).`\n )\n .option(\n '--dark-mode-status-bar-style <style>',\n `(only for Android platform) The same as 'status-bar-style', but applied only in dark mode. Available only if 'dark-mode-background-color' and 'status-bar-style' are provided as well.`\n )\n .option(\n '--dark-mode-status-bar-background-color <color>',\n `(only for Android platform) The same as 'status-bar-background-color', but applied only in the dark mode. Available only if 'dark-mode-background-color' and 'status-bar-style' are provided as well.`\n )\n .action(async (options: RawCLIOptions) => {\n const configuration = configurationFromOptions(options);\n await action(configuration);\n });\n"]} |