1 line
3.5 KiB
Plaintext
1 line
3.5 KiB
Plaintext
![]() |
{"version":3,"file":"Drawable.xml.js","sourceRoot":"","sources":["../../src/android/Drawable.xml.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAGxB,4CAA4F;AAC5F,0DAM6B;AAE7B,MAAM,sBAAsB,GAAG,iCAAiC,CAAC;AAEjE,SAAS,iBAAiB,CAAC,GAAY,EAAE,UAA4C;IACnF,MAAM,QAAQ,GAAyB;QACrC,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,CAAC;gBACN,OAAO,EAAE,uHAAuH;aACjI;YACD;gBACE,IAAI,EAAE,YAAY;gBAClB,UAAU,EAAE;oBACV,eAAe,EAAE,4CAA4C;iBAC9D;gBACD,QAAQ,EAAE;oBACR,QAAQ,EAAG;wBACT;4BACE,IAAI,EAAE,MAAM;4BACZ,UAAU,EAAE;gCACV,kBAAkB,EAAE,gCAAgC;6BACrD;yBACF;qBACwB,CAAC,MAAM,CAChC,UAAU,KAAK,uCAA2B,CAAC,MAAM;wBAC/C,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC;4BACE;gCACE,IAAI,EAAE,MAAM;gCACZ,QAAQ,EAAE;oCACR;wCACE,IAAI,EAAE,QAAQ;wCACd,UAAU,EAAE;4CACV,iBAAiB,EAAE,QAAQ;4CAC3B,aAAa,EAAE,8BAA8B;yCAC9C;qCACF;iCACF;6BACF;yBACF,CACN;iBACF;aACF;SACF;KACF,CAAC;IACF,MAAM,MAAM,GAAG,mCAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACY,KAAK,UAAU,oBAAoB,CAChD,eAAuB,EACvB,SAEI,EAAE;IAEN,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG,MAAM,8BAAW,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,UAAU,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;IACnF,MAAM,+BAAY,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;AACrD,CAAC;AAVD,uCAUC","sourcesContent":["import path from 'path';\nimport { Element } from 'xml-js';\n\nimport { SplashScreenImageResizeMode, SplashScreenImageResizeModeType } from '../constants';\nimport {\n mergeXmlElements,\n readXmlFile,\n writeXmlFile,\n ExpectedElementsType,\n ExpectedElementType,\n} from '../xml-manipulation';\n\nconst DRAWABLE_XML_FILE_PATH = './res/drawable/splashscreen.xml';\n\nfunction configureDrawable(xml: Element, resizeMode?: SplashScreenImageResizeModeType): Element {\n const expected: ExpectedElementsType = {\n elements: [\n {\n idx: 0,\n comment: `\\n This file was created by '@expo/configure-splash-screen' and some of it's content shouldn't be modified by hand\\n`,\n },\n {\n name: 'layer-list',\n attributes: {\n 'xmlns:android': 'http://schemas.android.com/apk/res/android',\n },\n elements: {\n newValue: ([\n {\n name: 'item',\n attributes: {\n 'android:drawable': '@color/splashscreen_background',\n },\n },\n ] as ExpectedElementType[]).concat(\n resizeMode !== SplashScreenImageResizeMode.NATIVE\n ? []\n : [\n {\n name: 'item',\n elements: [\n {\n name: 'bitmap',\n attributes: {\n 'android:gravity': 'center',\n 'android:src': '@drawable/splashscreen_image',\n },\n },\n ],\n },\n ]\n ),\n },\n },\n ],\n };\n const result = mergeXmlElements(xml, expected);\n return result;\n}\n\n/**\n * @param androidMainPath Path to the main directory containing code and resources in Android project. In general that would be `android/app/src/main`.\n */\nexport default async function configureDrawableXml(\n androidMainPath: string,\n config: {\n imageResizeMode?: SplashScreenImageResizeModeType;\n } = {}\n) {\n const filePath = path.resolve(androidMainPath, DRAWABLE_XML_FILE_PATH);\n const xmlContent = await readXmlFile(filePath);\n const configuredXmlContent = configureDrawable(xmlContent, config.imageResizeMode);\n await writeXmlFile(filePath, configuredXmlContent);\n}\n"]}
|