@expo/config-plugins 4.0.13 → 4.0.14
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/android/Manifest.d.ts +1 -0
- package/build/android/Manifest.js +3 -1
- package/build/android/Manifest.js.map +1 -1
- package/build/ios/Maps.d.ts +3 -5
- package/build/ios/Maps.js +10 -13
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Name.d.ts +7 -2
- package/build/ios/Name.js +58 -1
- package/build/ios/Name.js.map +1 -1
- package/package.json +1 -1
|
@@ -113,6 +113,7 @@ export declare type AndroidManifest = {
|
|
|
113
113
|
};
|
|
114
114
|
export declare function writeAndroidManifestAsync(manifestPath: string, androidManifest: AndroidManifest): Promise<void>;
|
|
115
115
|
export declare function readAndroidManifestAsync(manifestPath: string): Promise<AndroidManifest>;
|
|
116
|
+
/** Returns the `manifest.application` tag ending in `.MainApplication` */
|
|
116
117
|
export declare function getMainApplication(androidManifest: AndroidManifest): ManifestApplication | null;
|
|
117
118
|
export declare function getMainApplicationOrThrow(androidManifest: AndroidManifest): ManifestApplication;
|
|
118
119
|
export declare function getMainActivityOrThrow(androidManifest: AndroidManifest): ManifestActivity;
|
|
@@ -87,6 +87,8 @@ function isManifest(xml) {
|
|
|
87
87
|
// TODO: Maybe more validation
|
|
88
88
|
return !!xml.manifest;
|
|
89
89
|
}
|
|
90
|
+
/** Returns the `manifest.application` tag ending in `.MainApplication` */
|
|
91
|
+
|
|
90
92
|
|
|
91
93
|
function getMainApplication(androidManifest) {
|
|
92
94
|
var _androidManifest$mani, _androidManifest$mani2, _androidManifest$mani3;
|
|
@@ -94,7 +96,7 @@ function getMainApplication(androidManifest) {
|
|
|
94
96
|
return (_androidManifest$mani = androidManifest === null || androidManifest === void 0 ? void 0 : (_androidManifest$mani2 = androidManifest.manifest) === null || _androidManifest$mani2 === void 0 ? void 0 : (_androidManifest$mani3 = _androidManifest$mani2.application) === null || _androidManifest$mani3 === void 0 ? void 0 : _androidManifest$mani3.filter(e => {
|
|
95
97
|
var _e$$;
|
|
96
98
|
|
|
97
|
-
return
|
|
99
|
+
return e === null || e === void 0 ? void 0 : (_e$$ = e.$) === null || _e$$ === void 0 ? void 0 : _e$$['android:name'].endsWith('.MainApplication');
|
|
98
100
|
})[0]) !== null && _androidManifest$mani !== void 0 ? _androidManifest$mani : null;
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/android/Manifest.ts"],"names":["writeAndroidManifestAsync","manifestPath","androidManifest","manifestXml","XML","format","fs","ensureDir","path","dirname","writeFile","readAndroidManifestAsync","xml","readXMLAsync","isManifest","Error","manifest","getMainApplication","application","filter","e","$","getMainApplicationOrThrow","mainApplication","getMainActivityOrThrow","mainActivity","getMainActivity","getRunnableActivity","enabledActivities","activity","Array","isArray","intentFilter","action","find","category","addMetaDataItemToMainApplication","itemName","itemValue","itemType","existingMetaDataItem","newItem","prefixAndroidKeys","name","length","push","removeMetaDataItemFromMainApplication","index","findMetaDataItem","splice","findApplicationSubItem","parent","findIndex","findUsesLibraryItem","getMainApplicationMetaDataValue","hasOwnProperty","item","addUsesLibraryItemToMainApplication","removeUsesLibraryItemFromMainApplication","head","Object","entries","reduce","prev","key","curr"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;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;;;;;;;;AAoJO,eAAeA,yBAAf,CACLC,YADK,EAELC,eAFK,EAGU;AACf,QAAMC,WAAW,GAAGC,GAAG,GAACC,MAAJ,CAAWH,eAAX,CAApB;AACA,QAAMI,mBAAGC,SAAH,CAAaC,gBAAKC,OAAL,CAAaR,YAAb,CAAb,CAAN;AACA,QAAMK,mBAAGI,SAAH,CAAa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CAAnB,EAAqC;AACnCiB,IAAAA,oBAAoB,GAAGjB,eAAe,CAAC,cAAD,CAAf,CAAgCJ,MAAhC,CACrBC,CAAC,IAAIA,CAAC,CAACC,CAAF,CAAI,cAAJ,MAAwBmC,IAAI,CAACb,IADb,CAAvB;;AAGA,QAAIH,oBAAoB,CAACI,MAAzB,EAAiC;AAC/BJ,MAAAA,oBAAoB,CAAC,CAAD,CAApB,CAAwBnB,CAAxB,GAA4BoB,OAAO,CAACpB,CAApC;AACD,KAFD,MAEO;AACLE,MAAAA,eAAe,CAAC,cAAD,CAAf,CAAgCsB,IAAhC,CAAqCJ,OAArC;AACD;AACF,GATD,MASO;AACLlB,IAAAA,eAAe,CAAC,cAAD,CAAf,GAAkC,CAACkB,OAAD,CAAlC;AACD;;AACD,SAAOlB,eAAP;AACD;;AAEM,SAASmC,wCAAT,CACLnC,eADK,EAELc,QAFK,EAGL;AACA,QAAMU,KAAK,GAAGM,mBAAmB,CAAC9B,eAAD,EAAkBc,QAAlB,CAAjC;;AACA,MAAId,eAAe,SAAf,IAAAA,eAAe,WAAf,IAAAA,eAAe,CAAG,cAAH,CAAf,IAAqCwB,KAAK,GAAG,CAAC,CAAlD,EAAqD;AACnDxB,IAAAA,eAAe,CAAC,cAAD,CAAf,CAAgC0B,MAAhC,CAAuCF,KAAvC,EAA8C,CAA9C;AACD;;AACD,SAAOxB,eAAP;AACD;;AAEM,SAASmB,iBAAT,CACLiB,IADK,EAEgB;AACrB;AACA,SAAOC,MAAM,CAACC,OAAP,CAAeF,IAAf,EAAqBG,MAArB,CACL,CAACC,IAAD,EAAO,CAACC,GAAD,EAAMC,IAAN,CAAP,MAAwB,EAAE,GAAGF,IAAL;AAAW,KAAE,WAAUC,GAAI,EAAhB,GAAoBC;AAA/B,GAAxB,CADK,EAEL,EAFK,CAAP;AAID","sourcesContent":["import assert from 'assert';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport * as XML from '../utils/XML';\n\nexport type StringBoolean = 'true' | 'false';\n\ntype ManifestMetaDataAttributes = AndroidManifestAttributes & {\n 'android:value'?: string;\n 'android:resource'?: string;\n};\n\ntype AndroidManifestAttributes = {\n 'android:name': string | 'android.intent.action.VIEW';\n 'tools:node'?: string | 'remove';\n};\n\ntype ManifestAction = {\n $: AndroidManifestAttributes;\n};\n\ntype ManifestCategory = {\n $: AndroidManifestAttributes;\n};\n\ntype ManifestData = {\n $: {\n [key: string]: string | undefined;\n 'android:host'?: string;\n 'android:pathPrefix'?: string;\n 'android:scheme'?: string;\n };\n};\n\ntype ManifestReceiver = {\n $: AndroidManifestAttributes & {\n 'android:exported'?: StringBoolean;\n 'android:enabled'?: StringBoolean;\n };\n 'intent-filter'?: ManifestIntentFilter[];\n};\n\nexport type ManifestIntentFilter = {\n $?: {\n 'android:autoVerify'?: StringBoolean;\n 'data-generated'?: StringBoolean;\n };\n action?: ManifestAction[];\n data?: ManifestData[];\n category?: ManifestCategory[];\n};\n\nexport type ManifestMetaData = {\n $: ManifestMetaDataAttributes;\n};\n\ntype ManifestServiceAttributes = AndroidManifestAttributes & {\n 'android:enabled'?: StringBoolean;\n 'android:exported'?: StringBoolean;\n 'android:permission'?: string;\n // ...\n};\n\ntype ManifestService = {\n $: ManifestServiceAttributes;\n 'intent-filter'?: ManifestIntentFilter[];\n};\n\ntype ManifestApplicationAttributes = {\n 'android:name': string | '.MainApplication';\n 'android:icon'?: string;\n 'android:label'?: string;\n 'android:allowBackup'?: StringBoolean;\n 'android:largeHeap'?: StringBoolean;\n 'android:requestLegacyExternalStorage'?: StringBoolean;\n 'android:usesCleartextTraffic'?: StringBoolean;\n [key: string]: string | undefined;\n};\n\nexport type ManifestActivity = {\n $: ManifestApplicationAttributes & {\n 'android:exported'?: StringBoolean;\n 'android:launchMode'?: string;\n 'android:theme'?: string;\n 'android:windowSoftInputMode'?:\n | string\n | 'stateUnspecified'\n | 'stateUnchanged'\n | 'stateHidden'\n | 'stateAlwaysHidden'\n | 'stateVisible'\n | 'stateAlwaysVisible'\n | 'adjustUnspecified'\n | 'adjustResize'\n | 'adjustPan';\n [key: string]: string | undefined;\n };\n 'intent-filter'?: ManifestIntentFilter[];\n // ...\n};\n\nexport type ManifestUsesLibrary = {\n $: AndroidManifestAttributes & {\n 'android:required'?: StringBoolean;\n };\n};\n\nexport type ManifestApplication = {\n $: ManifestApplicationAttributes;\n activity?: ManifestActivity[];\n service?: ManifestService[];\n receiver?: ManifestReceiver[];\n 'meta-data'?: ManifestMetaData[];\n 'uses-library'?: ManifestUsesLibrary[];\n // ...\n};\n\ntype ManifestPermission = {\n $: AndroidManifestAttributes & {\n 'android:protectionLevel'?: string | 'signature';\n };\n};\n\nexport type ManifestUsesPermission = {\n $: AndroidManifestAttributes;\n};\n\ntype ManifestUsesFeature = {\n $: AndroidManifestAttributes & {\n 'android:glEsVersion'?: string;\n 'android:required': StringBoolean;\n };\n};\n\nexport type AndroidManifest = {\n manifest: {\n // Probably more, but this is currently all we'd need for most cases in Expo.\n $: {\n 'xmlns:android': string;\n 'xmlns:tools'?: string;\n package?: string;\n [key: string]: string | undefined;\n };\n permission?: ManifestPermission[];\n 'uses-permission'?: ManifestUsesPermission[];\n 'uses-permission-sdk-23'?: ManifestUsesPermission[];\n 'uses-feature'?: ManifestUsesFeature[];\n application?: ManifestApplication[];\n };\n};\n\nexport async function writeAndroidManifestAsync(\n manifestPath: string,\n androidManifest: AndroidManifest\n): Promise<void> {\n const manifestXml = XML.format(androidManifest);\n await fs.ensureDir(path.dirname(manifestPath));\n await fs.writeFile(manifestPath, manifestXml);\n}\n\nexport async function readAndroidManifestAsync(manifestPath: string): Promise<AndroidManifest> {\n const xml = await XML.readXMLAsync({ path: manifestPath });\n if (!isManifest(xml)) {\n throw new Error('Invalid manifest found at: ' + manifestPath);\n }\n return xml;\n}\n\nfunction isManifest(xml: XML.XMLObject): xml is AndroidManifest {\n // TODO: Maybe more validation\n return !!xml.manifest;\n}\n\nexport function getMainApplication(androidManifest: AndroidManifest): ManifestApplication | null {\n return (\n androidManifest?.manifest?.application?.filter(\n e => e?.$?.['android:name'] === '.MainApplication'\n )[0] ?? null\n );\n}\n\nexport function getMainApplicationOrThrow(androidManifest: AndroidManifest): ManifestApplication {\n const mainApplication = getMainApplication(androidManifest);\n assert(mainApplication, 'AndroidManifest.xml is missing the required MainApplication element');\n return mainApplication;\n}\n\nexport function getMainActivityOrThrow(androidManifest: AndroidManifest): ManifestActivity {\n const mainActivity = getMainActivity(androidManifest);\n assert(mainActivity, 'AndroidManifest.xml is missing the required MainActivity element');\n return mainActivity;\n}\n\nexport function getRunnableActivity(androidManifest: AndroidManifest): ManifestActivity | null {\n // Get enabled activities\n const enabledActivities = androidManifest?.manifest?.application?.[0]?.activity?.filter?.(\n (e: any) => e.$['android:enabled'] !== 'false' && e.$['android:enabled'] !== false\n );\n\n if (!enabledActivities) {\n return null;\n }\n\n // Get the activity that has a runnable intent-filter\n for (const activity of enabledActivities) {\n if (Array.isArray(activity['intent-filter'])) {\n for (const intentFilter of activity['intent-filter']) {\n if (\n intentFilter.action?.find(\n action => action.$['android:name'] === 'android.intent.action.MAIN'\n ) &&\n intentFilter.category?.find(\n category => category.$['android:name'] === 'android.intent.category.LAUNCHER'\n )\n ) {\n return activity;\n }\n }\n }\n }\n\n return null;\n}\n\nexport function getMainActivity(androidManifest: AndroidManifest): ManifestActivity | null {\n const mainActivity = androidManifest?.manifest?.application?.[0]?.activity?.filter?.(\n (e: any) => e.$['android:name'] === '.MainActivity'\n );\n return mainActivity?.[0] ?? null;\n}\n\nexport function addMetaDataItemToMainApplication(\n mainApplication: ManifestApplication,\n itemName: string,\n itemValue: string,\n itemType: 'resource' | 'value' = 'value'\n): ManifestApplication {\n let existingMetaDataItem;\n const newItem = {\n $: prefixAndroidKeys({ name: itemName, [itemType]: itemValue }),\n } as ManifestMetaData;\n if (mainApplication['meta-data']) {\n existingMetaDataItem = mainApplication['meta-data'].filter(\n (e: any) => e.$['android:name'] === itemName\n );\n if (existingMetaDataItem.length) {\n existingMetaDataItem[0].$[\n `android:${itemType}` as keyof ManifestMetaDataAttributes\n ] = itemValue;\n } else {\n mainApplication['meta-data'].push(newItem);\n }\n } else {\n mainApplication['meta-data'] = [newItem];\n }\n return mainApplication;\n}\n\nexport function removeMetaDataItemFromMainApplication(mainApplication: any, itemName: string) {\n const index = findMetaDataItem(mainApplication, itemName);\n if (mainApplication?.['meta-data'] && index > -1) {\n mainApplication['meta-data'].splice(index, 1);\n }\n return mainApplication;\n}\n\nfunction findApplicationSubItem(\n mainApplication: ManifestApplication,\n category: keyof ManifestApplication,\n itemName: string\n): number {\n const parent = mainApplication[category];\n if (Array.isArray(parent)) {\n const index = parent.findIndex((e: any) => e.$['android:name'] === itemName);\n\n return index;\n }\n return -1;\n}\n\nexport function findMetaDataItem(mainApplication: any, itemName: string): number {\n return findApplicationSubItem(mainApplication, 'meta-data', itemName);\n}\n\nexport function findUsesLibraryItem(mainApplication: any, itemName: string): number {\n return findApplicationSubItem(mainApplication, 'uses-library', itemName);\n}\n\nexport function getMainApplicationMetaDataValue(\n androidManifest: AndroidManifest,\n name: string\n): string | null {\n const mainApplication = getMainApplication(androidManifest);\n\n if (mainApplication?.hasOwnProperty('meta-data')) {\n const item = mainApplication?.['meta-data']?.find((e: any) => e.$['android:name'] === name);\n return item?.$['android:value'] ?? null;\n }\n\n return null;\n}\n\nexport function addUsesLibraryItemToMainApplication(\n mainApplication: ManifestApplication,\n item: { name: string; required?: boolean }\n): ManifestApplication {\n let existingMetaDataItem;\n const newItem = {\n $: prefixAndroidKeys(item),\n } as ManifestUsesLibrary;\n\n if (mainApplication['uses-library']) {\n existingMetaDataItem = mainApplication['uses-library'].filter(\n e => e.$['android:name'] === item.name\n );\n if (existingMetaDataItem.length) {\n existingMetaDataItem[0].$ = newItem.$;\n } else {\n mainApplication['uses-library'].push(newItem);\n }\n } else {\n mainApplication['uses-library'] = [newItem];\n }\n return mainApplication;\n}\n\nexport function removeUsesLibraryItemFromMainApplication(\n mainApplication: ManifestApplication,\n itemName: string\n) {\n const index = findUsesLibraryItem(mainApplication, itemName);\n if (mainApplication?.['uses-library'] && index > -1) {\n mainApplication['uses-library'].splice(index, 1);\n }\n return mainApplication;\n}\n\nexport function prefixAndroidKeys<T extends Record<string, any> = Record<string, string>>(\n head: T\n): Record<string, any> {\n // prefix all keys with `android:`\n return Object.entries(head).reduce(\n (prev, [key, curr]) => ({ ...prev, [`android:${key}`]: curr }),\n {} as T\n );\n}\n"],"file":"Manifest.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/android/Manifest.ts"],"names":["writeAndroidManifestAsync","manifestPath","androidManifest","manifestXml","XML","format","fs","ensureDir","path","dirname","writeFile","readAndroidManifestAsync","xml","readXMLAsync","isManifest","Error","manifest","getMainApplication","application","filter","e","$","endsWith","getMainApplicationOrThrow","mainApplication","getMainActivityOrThrow","mainActivity","getMainActivity","getRunnableActivity","enabledActivities","activity","Array","isArray","intentFilter","action","find","category","addMetaDataItemToMainApplication","itemName","itemValue","itemType","existingMetaDataItem","newItem","prefixAndroidKeys","name","length","push","removeMetaDataItemFromMainApplication","index","findMetaDataItem","splice","findApplicationSubItem","parent","findIndex","findUsesLibraryItem","getMainApplicationMetaDataValue","hasOwnProperty","item","addUsesLibraryItemToMainApplication","removeUsesLibraryItemFromMainApplication","head","Object","entries","reduce","prev","key","curr"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;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;;;;;;;;AAoJO,eAAeA,yBAAf,CACLC,YADK,EAELC,eAFK,EAGU;AACf,QAAMC,WAAW,GAAGC,GAAG,GAACC,MAAJ,CAAWH,eAAX,CAApB;AACA,QAAMI,mBAAGC,SAAH,CAAaC,gBAAKC,OAAL,CAAaR,YAAb,CAAb,CAAN;AACA,QAAMK,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nimport * as XML from '../utils/XML';\n\nexport type StringBoolean = 'true' | 'false';\n\ntype ManifestMetaDataAttributes = AndroidManifestAttributes & {\n 'android:value'?: string;\n 'android:resource'?: string;\n};\n\ntype AndroidManifestAttributes = {\n 'android:name': string | 'android.intent.action.VIEW';\n 'tools:node'?: string | 'remove';\n};\n\ntype ManifestAction = {\n $: AndroidManifestAttributes;\n};\n\ntype ManifestCategory = {\n $: AndroidManifestAttributes;\n};\n\ntype ManifestData = {\n $: {\n [key: string]: string | undefined;\n 'android:host'?: string;\n 'android:pathPrefix'?: string;\n 'android:scheme'?: string;\n };\n};\n\ntype ManifestReceiver = {\n $: AndroidManifestAttributes & {\n 'android:exported'?: StringBoolean;\n 'android:enabled'?: StringBoolean;\n };\n 'intent-filter'?: ManifestIntentFilter[];\n};\n\nexport type ManifestIntentFilter = {\n $?: {\n 'android:autoVerify'?: StringBoolean;\n 'data-generated'?: StringBoolean;\n };\n action?: ManifestAction[];\n data?: ManifestData[];\n category?: ManifestCategory[];\n};\n\nexport type ManifestMetaData = {\n $: ManifestMetaDataAttributes;\n};\n\ntype ManifestServiceAttributes = AndroidManifestAttributes & {\n 'android:enabled'?: StringBoolean;\n 'android:exported'?: StringBoolean;\n 'android:permission'?: string;\n // ...\n};\n\ntype ManifestService = {\n $: ManifestServiceAttributes;\n 'intent-filter'?: ManifestIntentFilter[];\n};\n\ntype ManifestApplicationAttributes = {\n 'android:name': string | '.MainApplication';\n 'android:icon'?: string;\n 'android:label'?: string;\n 'android:allowBackup'?: StringBoolean;\n 'android:largeHeap'?: StringBoolean;\n 'android:requestLegacyExternalStorage'?: StringBoolean;\n 'android:usesCleartextTraffic'?: StringBoolean;\n [key: string]: string | undefined;\n};\n\nexport type ManifestActivity = {\n $: ManifestApplicationAttributes & {\n 'android:exported'?: StringBoolean;\n 'android:launchMode'?: string;\n 'android:theme'?: string;\n 'android:windowSoftInputMode'?:\n | string\n | 'stateUnspecified'\n | 'stateUnchanged'\n | 'stateHidden'\n | 'stateAlwaysHidden'\n | 'stateVisible'\n | 'stateAlwaysVisible'\n | 'adjustUnspecified'\n | 'adjustResize'\n | 'adjustPan';\n [key: string]: string | undefined;\n };\n 'intent-filter'?: ManifestIntentFilter[];\n // ...\n};\n\nexport type ManifestUsesLibrary = {\n $: AndroidManifestAttributes & {\n 'android:required'?: StringBoolean;\n };\n};\n\nexport type ManifestApplication = {\n $: ManifestApplicationAttributes;\n activity?: ManifestActivity[];\n service?: ManifestService[];\n receiver?: ManifestReceiver[];\n 'meta-data'?: ManifestMetaData[];\n 'uses-library'?: ManifestUsesLibrary[];\n // ...\n};\n\ntype ManifestPermission = {\n $: AndroidManifestAttributes & {\n 'android:protectionLevel'?: string | 'signature';\n };\n};\n\nexport type ManifestUsesPermission = {\n $: AndroidManifestAttributes;\n};\n\ntype ManifestUsesFeature = {\n $: AndroidManifestAttributes & {\n 'android:glEsVersion'?: string;\n 'android:required': StringBoolean;\n };\n};\n\nexport type AndroidManifest = {\n manifest: {\n // Probably more, but this is currently all we'd need for most cases in Expo.\n $: {\n 'xmlns:android': string;\n 'xmlns:tools'?: string;\n package?: string;\n [key: string]: string | undefined;\n };\n permission?: ManifestPermission[];\n 'uses-permission'?: ManifestUsesPermission[];\n 'uses-permission-sdk-23'?: ManifestUsesPermission[];\n 'uses-feature'?: ManifestUsesFeature[];\n application?: ManifestApplication[];\n };\n};\n\nexport async function writeAndroidManifestAsync(\n manifestPath: string,\n androidManifest: AndroidManifest\n): Promise<void> {\n const manifestXml = XML.format(androidManifest);\n await fs.ensureDir(path.dirname(manifestPath));\n await fs.writeFile(manifestPath, manifestXml);\n}\n\nexport async function readAndroidManifestAsync(manifestPath: string): Promise<AndroidManifest> {\n const xml = await XML.readXMLAsync({ path: manifestPath });\n if (!isManifest(xml)) {\n throw new Error('Invalid manifest found at: ' + manifestPath);\n }\n return xml;\n}\n\nfunction isManifest(xml: XML.XMLObject): xml is AndroidManifest {\n // TODO: Maybe more validation\n return !!xml.manifest;\n}\n\n/** Returns the `manifest.application` tag ending in `.MainApplication` */\nexport function getMainApplication(androidManifest: AndroidManifest): ManifestApplication | null {\n return (\n androidManifest?.manifest?.application?.filter(e =>\n e?.$?.['android:name'].endsWith('.MainApplication')\n )[0] ?? null\n );\n}\n\nexport function getMainApplicationOrThrow(androidManifest: AndroidManifest): ManifestApplication {\n const mainApplication = getMainApplication(androidManifest);\n assert(mainApplication, 'AndroidManifest.xml is missing the required MainApplication element');\n return mainApplication;\n}\n\nexport function getMainActivityOrThrow(androidManifest: AndroidManifest): ManifestActivity {\n const mainActivity = getMainActivity(androidManifest);\n assert(mainActivity, 'AndroidManifest.xml is missing the required MainActivity element');\n return mainActivity;\n}\n\nexport function getRunnableActivity(androidManifest: AndroidManifest): ManifestActivity | null {\n // Get enabled activities\n const enabledActivities = androidManifest?.manifest?.application?.[0]?.activity?.filter?.(\n (e: any) => e.$['android:enabled'] !== 'false' && e.$['android:enabled'] !== false\n );\n\n if (!enabledActivities) {\n return null;\n }\n\n // Get the activity that has a runnable intent-filter\n for (const activity of enabledActivities) {\n if (Array.isArray(activity['intent-filter'])) {\n for (const intentFilter of activity['intent-filter']) {\n if (\n intentFilter.action?.find(\n action => action.$['android:name'] === 'android.intent.action.MAIN'\n ) &&\n intentFilter.category?.find(\n category => category.$['android:name'] === 'android.intent.category.LAUNCHER'\n )\n ) {\n return activity;\n }\n }\n }\n }\n\n return null;\n}\n\nexport function getMainActivity(androidManifest: AndroidManifest): ManifestActivity | null {\n const mainActivity = androidManifest?.manifest?.application?.[0]?.activity?.filter?.(\n (e: any) => e.$['android:name'] === '.MainActivity'\n );\n return mainActivity?.[0] ?? null;\n}\n\nexport function addMetaDataItemToMainApplication(\n mainApplication: ManifestApplication,\n itemName: string,\n itemValue: string,\n itemType: 'resource' | 'value' = 'value'\n): ManifestApplication {\n let existingMetaDataItem;\n const newItem = {\n $: prefixAndroidKeys({ name: itemName, [itemType]: itemValue }),\n } as ManifestMetaData;\n if (mainApplication['meta-data']) {\n existingMetaDataItem = mainApplication['meta-data'].filter(\n (e: any) => e.$['android:name'] === itemName\n );\n if (existingMetaDataItem.length) {\n existingMetaDataItem[0].$[\n `android:${itemType}` as keyof ManifestMetaDataAttributes\n ] = itemValue;\n } else {\n mainApplication['meta-data'].push(newItem);\n }\n } else {\n mainApplication['meta-data'] = [newItem];\n }\n return mainApplication;\n}\n\nexport function removeMetaDataItemFromMainApplication(mainApplication: any, itemName: string) {\n const index = findMetaDataItem(mainApplication, itemName);\n if (mainApplication?.['meta-data'] && index > -1) {\n mainApplication['meta-data'].splice(index, 1);\n }\n return mainApplication;\n}\n\nfunction findApplicationSubItem(\n mainApplication: ManifestApplication,\n category: keyof ManifestApplication,\n itemName: string\n): number {\n const parent = mainApplication[category];\n if (Array.isArray(parent)) {\n const index = parent.findIndex((e: any) => e.$['android:name'] === itemName);\n\n return index;\n }\n return -1;\n}\n\nexport function findMetaDataItem(mainApplication: any, itemName: string): number {\n return findApplicationSubItem(mainApplication, 'meta-data', itemName);\n}\n\nexport function findUsesLibraryItem(mainApplication: any, itemName: string): number {\n return findApplicationSubItem(mainApplication, 'uses-library', itemName);\n}\n\nexport function getMainApplicationMetaDataValue(\n androidManifest: AndroidManifest,\n name: string\n): string | null {\n const mainApplication = getMainApplication(androidManifest);\n\n if (mainApplication?.hasOwnProperty('meta-data')) {\n const item = mainApplication?.['meta-data']?.find((e: any) => e.$['android:name'] === name);\n return item?.$['android:value'] ?? null;\n }\n\n return null;\n}\n\nexport function addUsesLibraryItemToMainApplication(\n mainApplication: ManifestApplication,\n item: { name: string; required?: boolean }\n): ManifestApplication {\n let existingMetaDataItem;\n const newItem = {\n $: prefixAndroidKeys(item),\n } as ManifestUsesLibrary;\n\n if (mainApplication['uses-library']) {\n existingMetaDataItem = mainApplication['uses-library'].filter(\n e => e.$['android:name'] === item.name\n );\n if (existingMetaDataItem.length) {\n existingMetaDataItem[0].$ = newItem.$;\n } else {\n mainApplication['uses-library'].push(newItem);\n }\n } else {\n mainApplication['uses-library'] = [newItem];\n }\n return mainApplication;\n}\n\nexport function removeUsesLibraryItemFromMainApplication(\n mainApplication: ManifestApplication,\n itemName: string\n) {\n const index = findUsesLibraryItem(mainApplication, itemName);\n if (mainApplication?.['uses-library'] && index > -1) {\n mainApplication['uses-library'].splice(index, 1);\n }\n return mainApplication;\n}\n\nexport function prefixAndroidKeys<T extends Record<string, any> = Record<string, string>>(\n head: T\n): Record<string, any> {\n // prefix all keys with `android:`\n return Object.entries(head).reduce(\n (prev, [key, curr]) => ({ ...prev, [`android:${key}`]: curr }),\n {} as T\n );\n}\n"],"file":"Manifest.js"}
|
package/build/ios/Maps.d.ts
CHANGED
|
@@ -10,10 +10,8 @@ export declare function removeGoogleMapsAppDelegateImport(src: string): MergeRes
|
|
|
10
10
|
export declare function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults;
|
|
11
11
|
export declare function removeGoogleMapsAppDelegateInit(src: string): MergeResults;
|
|
12
12
|
/**
|
|
13
|
-
* @param src
|
|
14
|
-
* @
|
|
15
|
-
* @param googleMapsPath '../node_modules/react-native-maps'
|
|
16
|
-
* @returns
|
|
13
|
+
* @param src The contents of the Podfile.
|
|
14
|
+
* @returns Podfile with Google Maps added.
|
|
17
15
|
*/
|
|
18
|
-
export declare function addMapsCocoaPods(src: string
|
|
16
|
+
export declare function addMapsCocoaPods(src: string): MergeResults;
|
|
19
17
|
export declare function removeMapsCocoaPods(src: string): MergeResults;
|
package/build/ios/Maps.js
CHANGED
|
@@ -161,18 +161,16 @@ function removeGoogleMapsAppDelegateInit(src) {
|
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
|
-
* @param src
|
|
165
|
-
* @
|
|
166
|
-
* @param googleMapsPath '../node_modules/react-native-maps'
|
|
167
|
-
* @returns
|
|
164
|
+
* @param src The contents of the Podfile.
|
|
165
|
+
* @returns Podfile with Google Maps added.
|
|
168
166
|
*/
|
|
169
167
|
|
|
170
168
|
|
|
171
|
-
function addMapsCocoaPods(src
|
|
169
|
+
function addMapsCocoaPods(src) {
|
|
172
170
|
return (0, _generateCode().mergeContents)({
|
|
173
171
|
tag: 'react-native-maps',
|
|
174
172
|
src,
|
|
175
|
-
newSrc: ` pod 'react-native-google-maps', path: '
|
|
173
|
+
newSrc: ` pod 'react-native-google-maps', path: File.dirname(\`node --print "require.resolve('react-native-maps/package.json')"\`)`,
|
|
176
174
|
anchor: /use_native_modules/,
|
|
177
175
|
offset: 0,
|
|
178
176
|
comment: '#'
|
|
@@ -193,13 +191,15 @@ function isReactNativeMapsInstalled(projectRoot) {
|
|
|
193
191
|
}
|
|
194
192
|
|
|
195
193
|
function isReactNativeMapsAutolinked(config) {
|
|
196
|
-
var _config$_internal;
|
|
197
|
-
|
|
198
194
|
// Only add the native code changes if we know that the package is going to be linked natively.
|
|
199
195
|
// This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)
|
|
200
196
|
// but another app will not have it installed in the package.json, causing it to not be linked natively.
|
|
201
197
|
// This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.
|
|
202
|
-
|
|
198
|
+
// TODO: `react-native-maps` doesn't use Expo autolinking so we cannot safely disable the module.
|
|
199
|
+
return true; // return (
|
|
200
|
+
// !config._internal?.autolinkedModules ||
|
|
201
|
+
// config._internal.autolinkedModules.includes('react-native-maps')
|
|
202
|
+
// );
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
const withMapsCocoaPods = (config, {
|
|
@@ -218,11 +218,8 @@ const withMapsCocoaPods = (config, {
|
|
|
218
218
|
debug('react-native-maps path:', googleMapsPath);
|
|
219
219
|
|
|
220
220
|
if (isLinked && googleMapsPath && useGoogleMaps) {
|
|
221
|
-
// Make the pod path relative to the ios folder.
|
|
222
|
-
const googleMapsPodPath = _path().default.relative(config.modRequest.platformProjectRoot, googleMapsPath);
|
|
223
|
-
|
|
224
221
|
try {
|
|
225
|
-
results = addMapsCocoaPods(contents
|
|
222
|
+
results = addMapsCocoaPods(contents);
|
|
226
223
|
} catch (error) {
|
|
227
224
|
if (error.code === 'ERR_NO_MATCH') {
|
|
228
225
|
throw new Error(`Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`);
|
package/build/ios/Maps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","require","MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","googleMapsPath","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","_internal","autolinkedModules","includes","filePath","modRequest","platformProjectRoot","contents","fs","readFile","results","isLinked","googleMapsPodPath","relative","error","code","Error","didMerge","didClear","writeFile","modResults","language"],"mappings":";;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAD,CAAP,CAAiB,8BAAjB,CAAd,C,CAEA;;;AACO,MAAMC,UAAU,GAAG,2MAAnB;;AAEP,MAAMC,iBAAiB,GAAG,yCAAsBC,mBAAtB,EAA2C,mBAA3C,CAA1B;;AAEO,MAAMC,QAAsB,GAAGC,MAAM,IAAI;AAC9CA,EAAAA,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H,yIADG,CAAN;AAGD;;AACD,gBAAMF,KAAN;AACD;AACF,OArBD,MAqBO;AACL9C,QAAAA,MAAM,CAACoD,UAAP,CAAkBb,QAAlB,GAA6BpB,iCAAiC,CAC5DnB,MAAM,CAACoD,UAAP,CAAkBb,QAD0C,CAAjC,CAE3BA,QAFF;AAGAvC,QAAAA,MAAM,CAACoD,UAAP,CAAkBb,QAAlB,GAA6BlB,+BAA+B,CAC1DrB,MAAM,CAACoD,UAAP,CAAkBb,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA9BD,MA8BO;AACL,YAAM,IAAIS,KAAJ,CAAU,qEAAV,CAAN;AACD;;AACD,WAAOhD,MAAP;AACD,GAnCM,CAAP;AAoCD,CArCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\n\nconst debug = require('debug')('expo:config-plugins:ios:maps') as typeof console.log;\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])|(\\[self\\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src\n * @param useGoogleMaps\n * @param googleMapsPath '../node_modules/react-native-maps'\n * @returns\n */\nexport function addMapsCocoaPods(src: string, googleMapsPath: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: '${googleMapsPath}'`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n const resolved = resolveFrom.silent(projectRoot, 'react-native-maps/package.json');\n return resolved ? path.dirname(resolved) : null;\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): string | null {\n // Only add the native code changes if we know that the package is going to be linked natively.\n // This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)\n // but another app will not have it installed in the package.json, causing it to not be linked natively.\n // This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.\n return (\n !config._internal?.autolinkedModules ||\n config._internal.autolinkedModules.includes('react-native-maps')\n );\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && googleMapsPath && useGoogleMaps) {\n // Make the pod path relative to the ios folder.\n const googleMapsPodPath = path.relative(\n config.modRequest.platformProjectRoot,\n googleMapsPath\n );\n try {\n results = addMapsCocoaPods(contents, googleMapsPodPath);\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (config.modResults.language === 'objc') {\n if (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error('Cannot setup Google Maps because the AppDelegate is not Objective C');\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Maps.ts"],"names":["debug","require","MATCH_INIT","withGoogleMapsKey","setGoogleMapsApiKey","withMaps","config","apiKey","getGoogleMapsApiKey","withMapsCocoaPods","useGoogleMaps","withGoogleMapsAppDelegate","ios","googleMapsApiKey","GMSApiKey","infoPlist","addGoogleMapsAppDelegateImport","src","newSrc","push","tag","join","anchor","offset","comment","removeGoogleMapsAppDelegateImport","addGoogleMapsAppDelegateInit","removeGoogleMapsAppDelegateInit","addMapsCocoaPods","removeMapsCocoaPods","isReactNativeMapsInstalled","projectRoot","resolved","resolveFrom","silent","path","dirname","isReactNativeMapsAutolinked","filePath","modRequest","platformProjectRoot","contents","fs","readFile","results","googleMapsPath","isLinked","error","code","Error","didMerge","didClear","writeFile","modResults","language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F;AAGAnC,UAAAA,MAAM,CAAC+C,UAAP,CAAkBZ,QAAlB,GAA6Bf,4BAA4B,CACvDpB,MAAM,CAAC+C,UAAP,CAAkBZ,QADqC,EAEvDlC,MAFuD,CAA5B,CAG3BkC,QAHF;AAID,SARD,CAQE,OAAOM,KAAP,EAAc;AACd,cAAIA,KAAK,CAACC,IAAN,KAAe,cAAnB,EAAmC;AACjC,kBAAM,IAAIC,KAAJ,CACH,yIADG,CAAN;AAGD;;AACD,gBAAMF,KAAN;AACD;AACF,OArBD,MAqBO;AACLzC,QAAAA,MAAM,CAAC+C,UAAP,CAAkBZ,QAAlB,GAA6BhB,iCAAiC,CAC5DnB,MAAM,CAAC+C,UAAP,CAAkBZ,QAD0C,CAAjC,CAE3BA,QAFF;AAGAnC,QAAAA,MAAM,CAAC+C,UAAP,CAAkBZ,QAAlB,GAA6Bd,+BAA+B,CAC1DrB,MAAM,CAAC+C,UAAP,CAAkBZ,QADwC,CAA/B,CAE3BA,QAFF;AAGD;AACF,KA9BD,MA8BO;AACL,YAAM,IAAIQ,KAAJ,CAAU,qEAAV,CAAN;AACD;;AACD,WAAO3C,MAAP;AACD,GAnCM,CAAP;AAoCD,CArCD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { ConfigPlugin, InfoPlist } from '../Plugin.types';\nimport { createInfoPlistPlugin, withAppDelegate } from '../plugins/ios-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { mergeContents, MergeResults, removeContents } from '../utils/generateCode';\n\nconst debug = require('debug')('expo:config-plugins:ios:maps') as typeof console.log;\n\n// Match against `UMModuleRegistryAdapter` (unimodules), and React Native without unimodules (Expo Modules), and SDK +44 React AppDelegate subscriber.\nexport const MATCH_INIT = /(?:(self\\.|_)(\\w+)\\s?=\\s?\\[\\[UMModuleRegistryAdapter alloc\\])|(?:RCTBridge\\s?\\*\\s?(\\w+)\\s?=\\s?\\[\\[RCTBridge alloc\\])|(\\[self\\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\\])/g;\n\nconst withGoogleMapsKey = createInfoPlistPlugin(setGoogleMapsApiKey, 'withGoogleMapsKey');\n\nexport const withMaps: ConfigPlugin = config => {\n config = withGoogleMapsKey(config);\n\n const apiKey = getGoogleMapsApiKey(config);\n // Technically adds react-native-maps (Apple maps) and google maps.\n\n debug('Google Maps API Key:', apiKey);\n config = withMapsCocoaPods(config, { useGoogleMaps: !!apiKey });\n\n // Adds/Removes AppDelegate setup for Google Maps API on iOS\n config = withGoogleMapsAppDelegate(config, { apiKey });\n\n return config;\n};\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'ios'>) {\n return config.ios?.config?.googleMapsApiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'ios'>,\n { GMSApiKey, ...infoPlist }: InfoPlist\n): InfoPlist {\n const apiKey = getGoogleMapsApiKey(config);\n\n if (apiKey === null) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n GMSApiKey: apiKey,\n };\n}\n\nexport function addGoogleMapsAppDelegateImport(src: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n '#import <GoogleMaps/GoogleMaps.h>',\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-import',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: /#import \"AppDelegate\\.h\"/,\n offset: 1,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateImport(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-import',\n src,\n });\n}\n\nexport function addGoogleMapsAppDelegateInit(src: string, apiKey: string): MergeResults {\n const newSrc = [];\n newSrc.push(\n '#if __has_include(<GoogleMaps/GoogleMaps.h>)',\n ` [GMSServices provideAPIKey:@\"${apiKey}\"];`,\n '#endif'\n );\n\n return mergeContents({\n tag: 'react-native-maps-init',\n src,\n newSrc: newSrc.join('\\n'),\n anchor: MATCH_INIT,\n offset: 0,\n comment: '//',\n });\n}\n\nexport function removeGoogleMapsAppDelegateInit(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps-init',\n src,\n });\n}\n\n/**\n * @param src The contents of the Podfile.\n * @returns Podfile with Google Maps added.\n */\nexport function addMapsCocoaPods(src: string): MergeResults {\n return mergeContents({\n tag: 'react-native-maps',\n src,\n newSrc: ` pod 'react-native-google-maps', path: File.dirname(\\`node --print \"require.resolve('react-native-maps/package.json')\"\\`)`,\n anchor: /use_native_modules/,\n offset: 0,\n comment: '#',\n });\n}\n\nexport function removeMapsCocoaPods(src: string): MergeResults {\n return removeContents({\n tag: 'react-native-maps',\n src,\n });\n}\n\nfunction isReactNativeMapsInstalled(projectRoot: string): string | null {\n const resolved = resolveFrom.silent(projectRoot, 'react-native-maps/package.json');\n return resolved ? path.dirname(resolved) : null;\n}\n\nfunction isReactNativeMapsAutolinked(config: Pick<ExpoConfig, '_internal'>): boolean {\n // Only add the native code changes if we know that the package is going to be linked natively.\n // This is specifically for monorepo support where one app might have react-native-maps (adding it to the node_modules)\n // but another app will not have it installed in the package.json, causing it to not be linked natively.\n // This workaround only exists because react-native-maps doesn't have a config plugin vendored in the package.\n\n // TODO: `react-native-maps` doesn't use Expo autolinking so we cannot safely disable the module.\n return true;\n\n // return (\n // !config._internal?.autolinkedModules ||\n // config._internal.autolinkedModules.includes('react-native-maps')\n // );\n}\n\nconst withMapsCocoaPods: ConfigPlugin<{ useGoogleMaps: boolean }> = (config, { useGoogleMaps }) => {\n return withDangerousMod(config, [\n 'ios',\n async config => {\n const filePath = path.join(config.modRequest.platformProjectRoot, 'Podfile');\n const contents = await fs.readFile(filePath, 'utf-8');\n let results: MergeResults;\n // Only add the block if react-native-maps is installed in the project (best effort).\n // Generally prebuild runs after a yarn install so this should always work as expected.\n const googleMapsPath = isReactNativeMapsInstalled(config.modRequest.projectRoot);\n const isLinked = isReactNativeMapsAutolinked(config);\n debug('Is Expo Autolinked:', isLinked);\n debug('react-native-maps path:', googleMapsPath);\n if (isLinked && googleMapsPath && useGoogleMaps) {\n try {\n results = addMapsCocoaPods(contents);\n } catch (error: any) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add react-native-maps to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.`\n );\n }\n throw error;\n }\n } else {\n // If the package is no longer installed, then remove the block.\n results = removeMapsCocoaPods(contents);\n }\n if (results.didMerge || results.didClear) {\n await fs.writeFile(filePath, results.contents);\n }\n return config;\n },\n ]);\n};\n\nconst withGoogleMapsAppDelegate: ConfigPlugin<{ apiKey: string | null }> = (config, { apiKey }) => {\n return withAppDelegate(config, config => {\n if (config.modResults.language === 'objc') {\n if (\n apiKey &&\n isReactNativeMapsAutolinked(config) &&\n isReactNativeMapsInstalled(config.modRequest.projectRoot)\n ) {\n try {\n config.modResults.contents = addGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = addGoogleMapsAppDelegateInit(\n config.modResults.contents,\n apiKey\n ).contents;\n } catch (error) {\n if (error.code === 'ERR_NO_MATCH') {\n throw new Error(\n `Cannot add Google Maps to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`\n );\n }\n throw error;\n }\n } else {\n config.modResults.contents = removeGoogleMapsAppDelegateImport(\n config.modResults.contents\n ).contents;\n config.modResults.contents = removeGoogleMapsAppDelegateInit(\n config.modResults.contents\n ).contents;\n }\n } else {\n throw new Error('Cannot setup Google Maps because the AppDelegate is not Objective C');\n }\n return config;\n });\n};\n"],"file":"Maps.js"}
|
package/build/ios/Name.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ExpoConfig } from '@expo/config-types';
|
|
2
|
+
import { XcodeProject } from 'xcode';
|
|
3
|
+
import { ConfigPlugin } from '../Plugin.types';
|
|
2
4
|
import { InfoPlist } from './IosConfig.types';
|
|
3
|
-
export declare const withDisplayName:
|
|
4
|
-
export declare const withName:
|
|
5
|
+
export declare const withDisplayName: ConfigPlugin<void>;
|
|
6
|
+
export declare const withName: ConfigPlugin<void>;
|
|
7
|
+
/** Set the PRODUCT_NAME variable in the xcproj file based on the app.json name property. */
|
|
8
|
+
export declare const withProductName: ConfigPlugin;
|
|
5
9
|
export declare function getName(config: Pick<ExpoConfig, 'name'>): string | null;
|
|
6
10
|
/**
|
|
7
11
|
* CFBundleDisplayName is used for most things: the name on the home screen, in
|
|
@@ -13,3 +17,4 @@ export declare function setDisplayName(configOrName: Pick<ExpoConfig, 'name'> |
|
|
|
13
17
|
* sometimes on the App Store
|
|
14
18
|
*/
|
|
15
19
|
export declare function setName(config: Pick<ExpoConfig, 'name'>, { CFBundleName, ...infoPlist }: InfoPlist): InfoPlist;
|
|
20
|
+
export declare function setProductName(config: Pick<ExpoConfig, 'name'>, project: XcodeProject): XcodeProject;
|
package/build/ios/Name.js
CHANGED
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getName = getName;
|
|
7
7
|
exports.setDisplayName = setDisplayName;
|
|
8
8
|
exports.setName = setName;
|
|
9
|
-
exports.
|
|
9
|
+
exports.setProductName = setProductName;
|
|
10
|
+
exports.withProductName = exports.withName = exports.withDisplayName = void 0;
|
|
10
11
|
|
|
11
12
|
function _iosPlugins() {
|
|
12
13
|
const data = require("../plugins/ios-plugins");
|
|
@@ -18,11 +19,42 @@ function _iosPlugins() {
|
|
|
18
19
|
return data;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
function _Target() {
|
|
23
|
+
const data = require("./Target");
|
|
24
|
+
|
|
25
|
+
_Target = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function _Xcodeproj() {
|
|
33
|
+
const data = require("./utils/Xcodeproj");
|
|
34
|
+
|
|
35
|
+
_Xcodeproj = function () {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
const withDisplayName = (0, _iosPlugins().createInfoPlistPlugin)(setDisplayName, 'withDisplayName');
|
|
22
43
|
exports.withDisplayName = withDisplayName;
|
|
23
44
|
const withName = (0, _iosPlugins().createInfoPlistPlugin)(setName, 'withName');
|
|
45
|
+
/** Set the PRODUCT_NAME variable in the xcproj file based on the app.json name property. */
|
|
46
|
+
|
|
24
47
|
exports.withName = withName;
|
|
25
48
|
|
|
49
|
+
const withProductName = config => {
|
|
50
|
+
return (0, _iosPlugins().withXcodeProject)(config, config => {
|
|
51
|
+
config.modResults = setProductName(config, config.modResults);
|
|
52
|
+
return config;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.withProductName = withProductName;
|
|
57
|
+
|
|
26
58
|
function getName(config) {
|
|
27
59
|
return typeof config.name === 'string' ? config.name : null;
|
|
28
60
|
}
|
|
@@ -72,4 +104,29 @@ function setName(config, {
|
|
|
72
104
|
CFBundleName: name
|
|
73
105
|
};
|
|
74
106
|
}
|
|
107
|
+
|
|
108
|
+
function setProductName(config, project) {
|
|
109
|
+
var _getName;
|
|
110
|
+
|
|
111
|
+
const name = (0, _Xcodeproj().sanitizedName)((_getName = getName(config)) !== null && _getName !== void 0 ? _getName : '');
|
|
112
|
+
|
|
113
|
+
if (!name) {
|
|
114
|
+
return project;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const quotedName = ensureQuotes(name);
|
|
118
|
+
const [, nativeTarget] = (0, _Target().findFirstNativeTarget)(project);
|
|
119
|
+
(0, _Xcodeproj().getBuildConfigurationsForListId)(project, nativeTarget.buildConfigurationList).forEach(([, item]) => {
|
|
120
|
+
item.buildSettings.PRODUCT_NAME = quotedName;
|
|
121
|
+
});
|
|
122
|
+
return project;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const ensureQuotes = value => {
|
|
126
|
+
if (!value.match(/^['"]/)) {
|
|
127
|
+
return `"${value}"`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return value;
|
|
131
|
+
};
|
|
75
132
|
//# sourceMappingURL=Name.js.map
|
package/build/ios/Name.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ios/Name.ts"],"names":["withDisplayName","setDisplayName","withName","setName","
|
|
1
|
+
{"version":3,"sources":["../../src/ios/Name.ts"],"names":["withDisplayName","setDisplayName","withName","setName","withProductName","config","modResults","setProductName","getName","name","configOrName","CFBundleDisplayName","infoPlist","CFBundleName","project","quotedName","ensureQuotes","nativeTarget","buildConfigurationList","forEach","item","buildSettings","PRODUCT_NAME","value","match"],"mappings":";;;;;;;;;;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMO,MAAMA,eAAe,GAAG,yCAAsBC,cAAtB,EAAsC,iBAAtC,CAAxB;;AAEA,MAAMC,QAAQ,GAAG,yCAAsBC,OAAtB,EAA+B,UAA/B,CAAjB;AAEP;;;;AACO,MAAMC,eAA6B,GAAGC,MAAM,IAAI;AACrD,SAAO,oCAAiBA,MAAjB,EAAyBA,MAAM,IAAI;AACxCA,IAAAA,MAAM,CAACC,UAAP,GAAoBC,cAAc,CAACF,MAAD,EAASA,MAAM,CAACC,UAAhB,CAAlC;AACA,WAAOD,MAAP;AACD,GAHM,CAAP;AAID,CALM;;;;AAOA,SAASG,OAAT,CAAiBH,MAAjB,EAAmD;AACxD,SAAO,OAAOA,MAAM,CAACI,IAAd,KAAuB,QAAvB,GAAkCJ,MAAM,CAACI,IAAzC,GAAgD,IAAvD;AACD;AAED;AACA;AACA;AACA;;;AACO,SAASR,cAAT,CACLS,YADK,EAEL;AAAEC,EAAAA,mBAAF;AAAuB,KAAGC;AAA1B,CAFK,EAGM;AACX,MAAIH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ACD,SAAOA,KAAP;AACD,CALD","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport { XcodeProject } from 'xcode';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { createInfoPlistPlugin, withXcodeProject } from '../plugins/ios-plugins';\nimport { InfoPlist } from './IosConfig.types';\nimport { findFirstNativeTarget } from './Target';\nimport {\n ConfigurationSectionEntry,\n getBuildConfigurationsForListId,\n sanitizedName,\n} from './utils/Xcodeproj';\n\nexport const withDisplayName = createInfoPlistPlugin(setDisplayName, 'withDisplayName');\n\nexport const withName = createInfoPlistPlugin(setName, 'withName');\n\n/** Set the PRODUCT_NAME variable in the xcproj file based on the app.json name property. */\nexport const withProductName: ConfigPlugin = config => {\n return withXcodeProject(config, config => {\n config.modResults = setProductName(config, config.modResults);\n return config;\n });\n};\n\nexport function getName(config: Pick<ExpoConfig, 'name'>) {\n return typeof config.name === 'string' ? config.name : null;\n}\n\n/**\n * CFBundleDisplayName is used for most things: the name on the home screen, in\n * notifications, and others.\n */\nexport function setDisplayName(\n configOrName: Pick<ExpoConfig, 'name'> | string,\n { CFBundleDisplayName, ...infoPlist }: InfoPlist\n): InfoPlist {\n let name: string | null = null;\n if (typeof configOrName === 'string') {\n name = configOrName;\n } else {\n name = getName(configOrName);\n }\n\n if (!name) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n CFBundleDisplayName: name,\n };\n}\n\n/**\n * CFBundleName is recommended to be 16 chars or less and is used in lists, eg:\n * sometimes on the App Store\n */\nexport function setName(\n config: Pick<ExpoConfig, 'name'>,\n { CFBundleName, ...infoPlist }: InfoPlist\n): InfoPlist {\n const name = getName(config);\n\n if (!name) {\n return infoPlist;\n }\n\n return {\n ...infoPlist,\n CFBundleName: name,\n };\n}\n\nexport function setProductName(\n config: Pick<ExpoConfig, 'name'>,\n project: XcodeProject\n): XcodeProject {\n const name = sanitizedName(getName(config) ?? '');\n\n if (!name) {\n return project;\n }\n const quotedName = ensureQuotes(name);\n\n const [, nativeTarget] = findFirstNativeTarget(project);\n\n getBuildConfigurationsForListId(project, nativeTarget.buildConfigurationList).forEach(\n ([, item]: ConfigurationSectionEntry) => {\n item.buildSettings.PRODUCT_NAME = quotedName;\n }\n );\n\n return project;\n}\n\nconst ensureQuotes = (value: string) => {\n if (!value.match(/^['\"]/)) {\n return `\"${value}\"`;\n }\n return value;\n};\n"],"file":"Name.js"}
|