@expo/config-plugins 5.0.4 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Plugin.types.d.ts +7 -7
- package/build/Plugin.types.js +0 -9
- package/build/Plugin.types.js.map +1 -1
- package/build/android/AllowBackup.js +0 -15
- package/build/android/AllowBackup.js.map +1 -1
- package/build/android/BuildProperties.js +2 -16
- package/build/android/BuildProperties.js.map +1 -1
- package/build/android/Colors.js +3 -25
- package/build/android/Colors.js.map +1 -1
- package/build/android/EasBuild.js +2 -22
- package/build/android/EasBuild.js.map +1 -1
- package/build/android/EasBuildGradleScript.js.map +1 -1
- package/build/android/GoogleMapsApiKey.js +0 -12
- package/build/android/GoogleMapsApiKey.js.map +1 -1
- package/build/android/GoogleServices.js +10 -48
- package/build/android/GoogleServices.js.map +1 -1
- package/build/android/IntentFilters.d.ts +1 -1
- package/build/android/IntentFilters.js +8 -24
- package/build/android/IntentFilters.js.map +1 -1
- package/build/android/Manifest.d.ts +19 -19
- package/build/android/Manifest.js +7 -66
- package/build/android/Manifest.js.map +1 -1
- package/build/android/Name.js +6 -27
- package/build/android/Name.js.map +1 -1
- package/build/android/Orientation.js +2 -12
- package/build/android/Orientation.js.map +1 -1
- package/build/android/Package.js +26 -111
- package/build/android/Package.js.map +1 -1
- package/build/android/Paths.d.ts +2 -2
- package/build/android/Paths.js +0 -47
- package/build/android/Paths.js.map +1 -1
- package/build/android/Permissions.js +8 -52
- package/build/android/Permissions.js.map +1 -1
- package/build/android/PrimaryColor.js +0 -18
- package/build/android/PrimaryColor.js.map +1 -1
- package/build/android/Properties.d.ts +1 -1
- package/build/android/Properties.js +0 -9
- package/build/android/Properties.js.map +1 -1
- package/build/android/Resources.d.ts +4 -4
- package/build/android/Resources.js +9 -29
- package/build/android/Resources.js.map +1 -1
- package/build/android/Scheme.d.ts +1 -1
- package/build/android/Scheme.js +13 -66
- package/build/android/Scheme.js.map +1 -1
- package/build/android/StatusBar.js +5 -33
- package/build/android/StatusBar.js.map +1 -1
- package/build/android/Strings.js +0 -14
- package/build/android/Strings.js.map +1 -1
- package/build/android/Styles.js +7 -34
- package/build/android/Styles.js.map +1 -1
- package/build/android/Updates.d.ts +2 -0
- package/build/android/Updates.js +50 -47
- package/build/android/Updates.js.map +1 -1
- package/build/android/Version.js +3 -29
- package/build/android/Version.js.map +1 -1
- package/build/android/WindowSoftInputMode.js +0 -14
- package/build/android/WindowSoftInputMode.js.map +1 -1
- package/build/android/codeMod.js +6 -22
- package/build/android/codeMod.js.map +1 -1
- package/build/android/index.js +0 -94
- package/build/android/index.js.map +1 -1
- package/build/index.js +2 -65
- package/build/index.js.map +1 -1
- package/build/ios/Bitcode.d.ts +1 -1
- package/build/ios/Bitcode.js +8 -28
- package/build/ios/Bitcode.js.map +1 -1
- package/build/ios/BuildProperties.js +2 -14
- package/build/ios/BuildProperties.js.map +1 -1
- package/build/ios/BuildScheme.js +2 -34
- package/build/ios/BuildScheme.js.map +1 -1
- package/build/ios/BundleIdentifier.js +13 -72
- package/build/ios/BundleIdentifier.js.map +1 -1
- package/build/ios/DeviceFamily.js +6 -24
- package/build/ios/DeviceFamily.js.map +1 -1
- package/build/ios/Entitlements.js +4 -45
- package/build/ios/Entitlements.js.map +1 -1
- package/build/ios/Google.d.ts +2 -2
- package/build/ios/Google.js +11 -66
- package/build/ios/Google.js.map +1 -1
- package/build/ios/IosConfig.types.d.ts +6 -11
- package/build/ios/IosConfig.types.js.map +1 -1
- package/build/ios/Locales.d.ts +3 -3
- package/build/ios/Locales.js +12 -43
- package/build/ios/Locales.js.map +1 -1
- package/build/ios/Maps.js +15 -53
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Name.js +7 -31
- package/build/ios/Name.js.map +1 -1
- package/build/ios/Orientation.js +2 -10
- package/build/ios/Orientation.js.map +1 -1
- package/build/ios/Paths.d.ts +2 -2
- package/build/ios/Paths.js +8 -73
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/Permissions.js +1 -16
- package/build/ios/Permissions.js.map +1 -1
- package/build/ios/ProvisioningProfile.d.ts +1 -1
- package/build/ios/ProvisioningProfile.js +0 -18
- package/build/ios/ProvisioningProfile.js.map +1 -1
- package/build/ios/RequiresFullScreen.js +19 -31
- package/build/ios/RequiresFullScreen.js.map +1 -1
- package/build/ios/Scheme.js +10 -32
- package/build/ios/Scheme.js.map +1 -1
- package/build/ios/Swift.js +16 -50
- package/build/ios/Swift.js.map +1 -1
- package/build/ios/Target.js +0 -30
- package/build/ios/Target.js.map +1 -1
- package/build/ios/Updates.js +10 -49
- package/build/ios/Updates.js.map +1 -1
- package/build/ios/UsesNonExemptEncryption.js +4 -10
- package/build/ios/UsesNonExemptEncryption.js.map +1 -1
- package/build/ios/Version.js +4 -11
- package/build/ios/Version.js.map +1 -1
- package/build/ios/XcodeProjectFile.js +5 -23
- package/build/ios/XcodeProjectFile.js.map +1 -1
- package/build/ios/codeMod.js +19 -60
- package/build/ios/codeMod.js.map +1 -1
- package/build/ios/index.js +0 -97
- package/build/ios/index.js.map +1 -1
- package/build/ios/utils/Xcodeproj.d.ts +6 -6
- package/build/ios/utils/Xcodeproj.js +15 -101
- package/build/ios/utils/Xcodeproj.js.map +1 -1
- package/build/ios/utils/getInfoPlistPath.js +2 -15
- package/build/ios/utils/getInfoPlistPath.js.map +1 -1
- package/build/ios/utils/string.js +0 -1
- package/build/ios/utils/string.js.map +1 -1
- package/build/plugins/android-plugins.d.ts +2 -2
- package/build/plugins/android-plugins.js +11 -42
- package/build/plugins/android-plugins.js.map +1 -1
- package/build/plugins/createBaseMod.d.ts +3 -3
- package/build/plugins/createBaseMod.js +8 -25
- package/build/plugins/createBaseMod.js.map +1 -1
- package/build/plugins/ios-plugins.d.ts +2 -2
- package/build/plugins/ios-plugins.js +8 -48
- package/build/plugins/ios-plugins.js.map +1 -1
- package/build/plugins/mod-compiler.js +21 -72
- package/build/plugins/mod-compiler.js.map +1 -1
- package/build/plugins/withAndroidBaseMods.d.ts +1 -1
- package/build/plugins/withAndroidBaseMods.js +4 -89
- package/build/plugins/withAndroidBaseMods.js.map +1 -1
- package/build/plugins/withDangerousMod.js +0 -5
- package/build/plugins/withDangerousMod.js.map +1 -1
- package/build/plugins/withIosBaseMods.d.ts +1 -1
- package/build/plugins/withIosBaseMods.js +26 -118
- package/build/plugins/withIosBaseMods.js.map +1 -1
- package/build/plugins/withMod.d.ts +1 -1
- package/build/plugins/withMod.js +24 -59
- package/build/plugins/withMod.js.map +1 -1
- package/build/plugins/withPlugins.js +0 -9
- package/build/plugins/withPlugins.js.map +1 -1
- package/build/plugins/withRunOnce.js +3 -9
- package/build/plugins/withRunOnce.js.map +1 -1
- package/build/plugins/withStaticPlugin.js +21 -43
- package/build/plugins/withStaticPlugin.js.map +1 -1
- package/build/utils/BuildProperties.types.d.ts +2 -2
- package/build/utils/BuildProperties.types.js.map +1 -1
- package/build/utils/Updates.d.ts +3 -1
- package/build/utils/Updates.js +18 -77
- package/build/utils/Updates.js.map +1 -1
- package/build/utils/XML.d.ts +1 -1
- package/build/utils/XML.js +7 -44
- package/build/utils/XML.js.map +1 -1
- package/build/utils/commonCodeMod.js +2 -10
- package/build/utils/commonCodeMod.js.map +1 -1
- package/build/utils/errors.d.ts +1 -1
- package/build/utils/errors.js +3 -11
- package/build/utils/errors.js.map +1 -1
- package/build/utils/fs.js +1 -12
- package/build/utils/fs.js.map +1 -1
- package/build/utils/generateCode.d.ts +1 -1
- package/build/utils/generateCode.js +8 -25
- package/build/utils/generateCode.js.map +1 -1
- package/build/utils/history.d.ts +1 -1
- package/build/utils/history.js +0 -6
- package/build/utils/history.js.map +1 -1
- package/build/utils/matchBrackets.d.ts +3 -3
- package/build/utils/matchBrackets.js +2 -17
- package/build/utils/matchBrackets.js.map +1 -1
- package/build/utils/modules.js +0 -10
- package/build/utils/modules.js.map +1 -1
- package/build/utils/obj.js +0 -4
- package/build/utils/obj.js.map +1 -1
- package/build/utils/plugin-resolver.js +25 -69
- package/build/utils/plugin-resolver.js.map +1 -1
- package/build/utils/sortObject.js +4 -10
- package/build/utils/sortObject.js.map +1 -1
- package/build/utils/versions.js +0 -10
- package/build/utils/versions.js.map +1 -1
- package/build/utils/warnings.js +1 -9
- package/build/utils/warnings.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleMapsApiKey.js","names":["META_API_KEY","LIB_HTTP","withGoogleMapsApiKey","createAndroidManifestPlugin","setGoogleMapsApiKey","getGoogleMapsApiKey","config","android","googleMaps","apiKey","androidManifest","mainApplication","getMainApplicationOrThrow","addMetaDataItemToMainApplication","addUsesLibraryItemToMainApplication","name","required","removeMetaDataItemFromMainApplication","removeUsesLibraryItemFromMainApplication"],"sources":["../../src/android/GoogleMapsApiKey.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\n\nimport { createAndroidManifestPlugin } from '../plugins/android-plugins';\nimport {\n addMetaDataItemToMainApplication,\n addUsesLibraryItemToMainApplication,\n AndroidManifest,\n getMainApplicationOrThrow,\n removeMetaDataItemFromMainApplication,\n removeUsesLibraryItemFromMainApplication,\n} from './Manifest';\n\nconst META_API_KEY = 'com.google.android.geo.API_KEY';\nconst LIB_HTTP = 'org.apache.http.legacy';\n\nexport const withGoogleMapsApiKey = createAndroidManifestPlugin(\n setGoogleMapsApiKey,\n 'withGoogleMapsApiKey'\n);\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'android'>) {\n return config.android?.config?.googleMaps?.apiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'android'>,\n androidManifest: AndroidManifest\n) {\n const apiKey = getGoogleMapsApiKey(config);\n const mainApplication = getMainApplicationOrThrow(androidManifest);\n\n if (apiKey) {\n // If the item exists, add it back\n addMetaDataItemToMainApplication(mainApplication, META_API_KEY, apiKey);\n addUsesLibraryItemToMainApplication(mainApplication, {\n name: LIB_HTTP,\n required: false,\n });\n } else {\n // Remove any existing item\n removeMetaDataItemFromMainApplication(mainApplication, META_API_KEY);\n removeUsesLibraryItemFromMainApplication(mainApplication, LIB_HTTP);\n }\n\n return androidManifest;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"GoogleMapsApiKey.js","names":["META_API_KEY","LIB_HTTP","withGoogleMapsApiKey","createAndroidManifestPlugin","setGoogleMapsApiKey","getGoogleMapsApiKey","config","android","googleMaps","apiKey","androidManifest","mainApplication","getMainApplicationOrThrow","addMetaDataItemToMainApplication","addUsesLibraryItemToMainApplication","name","required","removeMetaDataItemFromMainApplication","removeUsesLibraryItemFromMainApplication"],"sources":["../../src/android/GoogleMapsApiKey.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\n\nimport { createAndroidManifestPlugin } from '../plugins/android-plugins';\nimport {\n addMetaDataItemToMainApplication,\n addUsesLibraryItemToMainApplication,\n AndroidManifest,\n getMainApplicationOrThrow,\n removeMetaDataItemFromMainApplication,\n removeUsesLibraryItemFromMainApplication,\n} from './Manifest';\n\nconst META_API_KEY = 'com.google.android.geo.API_KEY';\nconst LIB_HTTP = 'org.apache.http.legacy';\n\nexport const withGoogleMapsApiKey = createAndroidManifestPlugin(\n setGoogleMapsApiKey,\n 'withGoogleMapsApiKey'\n);\n\nexport function getGoogleMapsApiKey(config: Pick<ExpoConfig, 'android'>) {\n return config.android?.config?.googleMaps?.apiKey ?? null;\n}\n\nexport function setGoogleMapsApiKey(\n config: Pick<ExpoConfig, 'android'>,\n androidManifest: AndroidManifest\n) {\n const apiKey = getGoogleMapsApiKey(config);\n const mainApplication = getMainApplicationOrThrow(androidManifest);\n\n if (apiKey) {\n // If the item exists, add it back\n addMetaDataItemToMainApplication(mainApplication, META_API_KEY, apiKey);\n addUsesLibraryItemToMainApplication(mainApplication, {\n name: LIB_HTTP,\n required: false,\n });\n } else {\n // Remove any existing item\n removeMetaDataItemFromMainApplication(mainApplication, META_API_KEY);\n removeUsesLibraryItemFromMainApplication(mainApplication, LIB_HTTP);\n }\n\n return androidManifest;\n}\n"],"mappings":";;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AASA,MAAMA,YAAY,GAAG,gCAAgC;AACrD,MAAMC,QAAQ,GAAG,wBAAwB;AAElC,MAAMC,oBAAoB,GAAG,IAAAC,6CAA2B,EAC7DC,mBAAmB,EACnB,sBAAsB,CACvB;AAAC;AAEK,SAASC,mBAAmB,CAACC,MAAmC,EAAE;EAAA;EACvE,mDAAOA,MAAM,CAACC,OAAO,8EAAd,gBAAgBD,MAAM,qFAAtB,uBAAwBE,UAAU,2DAAlC,uBAAoCC,MAAM,yEAAI,IAAI;AAC3D;AAEO,SAASL,mBAAmB,CACjCE,MAAmC,EACnCI,eAAgC,EAChC;EACA,MAAMD,MAAM,GAAGJ,mBAAmB,CAACC,MAAM,CAAC;EAC1C,MAAMK,eAAe,GAAG,IAAAC,qCAAyB,EAACF,eAAe,CAAC;EAElE,IAAID,MAAM,EAAE;IACV;IACA,IAAAI,4CAAgC,EAACF,eAAe,EAAEX,YAAY,EAAES,MAAM,CAAC;IACvE,IAAAK,+CAAmC,EAACH,eAAe,EAAE;MACnDI,IAAI,EAAEd,QAAQ;MACde,QAAQ,EAAE;IACZ,CAAC,CAAC;EACJ,CAAC,MAAM;IACL;IACA,IAAAC,iDAAqC,EAACN,eAAe,EAAEX,YAAY,CAAC;IACpE,IAAAkB,oDAAwC,EAACP,eAAe,EAAEV,QAAQ,CAAC;EACrE;EAEA,OAAOS,eAAe;AACxB"}
|
|
@@ -8,65 +8,48 @@ exports.getGoogleServicesFilePath = getGoogleServicesFilePath;
|
|
|
8
8
|
exports.setClassPath = setClassPath;
|
|
9
9
|
exports.setGoogleServicesFile = setGoogleServicesFile;
|
|
10
10
|
exports.withGoogleServicesFile = exports.withClassPath = exports.withApplyPlugin = void 0;
|
|
11
|
-
|
|
12
11
|
function _path() {
|
|
13
12
|
const data = _interopRequireDefault(require("path"));
|
|
14
|
-
|
|
15
13
|
_path = function () {
|
|
16
14
|
return data;
|
|
17
15
|
};
|
|
18
|
-
|
|
19
16
|
return data;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
function _androidPlugins() {
|
|
23
19
|
const data = require("../plugins/android-plugins");
|
|
24
|
-
|
|
25
20
|
_androidPlugins = function () {
|
|
26
21
|
return data;
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
return data;
|
|
30
24
|
}
|
|
31
|
-
|
|
32
25
|
function _withDangerousMod() {
|
|
33
26
|
const data = require("../plugins/withDangerousMod");
|
|
34
|
-
|
|
35
27
|
_withDangerousMod = function () {
|
|
36
28
|
return data;
|
|
37
29
|
};
|
|
38
|
-
|
|
39
30
|
return data;
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
function _fs() {
|
|
43
33
|
const data = require("../utils/fs");
|
|
44
|
-
|
|
45
34
|
_fs = function () {
|
|
46
35
|
return data;
|
|
47
36
|
};
|
|
48
|
-
|
|
49
37
|
return data;
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
function _warnings() {
|
|
53
40
|
const data = require("../utils/warnings");
|
|
54
|
-
|
|
55
41
|
_warnings = function () {
|
|
56
42
|
return data;
|
|
57
43
|
};
|
|
58
|
-
|
|
59
44
|
return data;
|
|
60
45
|
}
|
|
61
|
-
|
|
62
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
63
|
-
|
|
64
47
|
const DEFAULT_TARGET_PATH = './android/app/google-services.json';
|
|
65
48
|
const googleServicesClassPath = 'com.google.gms:google-services';
|
|
66
|
-
const googleServicesPlugin = 'com.google.gms.google-services';
|
|
49
|
+
const googleServicesPlugin = 'com.google.gms.google-services';
|
|
67
50
|
|
|
51
|
+
// NOTE(brentvatne): This may be annoying to keep up to date...
|
|
68
52
|
const googleServicesVersion = '4.3.3';
|
|
69
|
-
|
|
70
53
|
const withClassPath = config => {
|
|
71
54
|
return (0, _androidPlugins().withProjectBuildGradle)(config, config => {
|
|
72
55
|
if (config.modResults.language === 'groovy') {
|
|
@@ -74,13 +57,10 @@ const withClassPath = config => {
|
|
|
74
57
|
} else {
|
|
75
58
|
(0, _warnings().addWarningAndroid)('android.googleServicesFile', `Cannot automatically configure project build.gradle if it's not groovy`);
|
|
76
59
|
}
|
|
77
|
-
|
|
78
60
|
return config;
|
|
79
61
|
});
|
|
80
62
|
};
|
|
81
|
-
|
|
82
63
|
exports.withClassPath = withClassPath;
|
|
83
|
-
|
|
84
64
|
const withApplyPlugin = config => {
|
|
85
65
|
return (0, _androidPlugins().withAppBuildGradle)(config, config => {
|
|
86
66
|
if (config.modResults.language === 'groovy') {
|
|
@@ -88,90 +68,72 @@ const withApplyPlugin = config => {
|
|
|
88
68
|
} else {
|
|
89
69
|
(0, _warnings().addWarningAndroid)('android.googleServicesFile', `Cannot automatically configure app build.gradle if it's not groovy`);
|
|
90
70
|
}
|
|
91
|
-
|
|
92
71
|
return config;
|
|
93
72
|
});
|
|
94
73
|
};
|
|
74
|
+
|
|
95
75
|
/**
|
|
96
76
|
* Add `google-services.json` to project
|
|
97
77
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
78
|
exports.withApplyPlugin = withApplyPlugin;
|
|
101
|
-
|
|
102
79
|
const withGoogleServicesFile = config => {
|
|
103
80
|
return (0, _withDangerousMod().withDangerousMod)(config, ['android', async config => {
|
|
104
81
|
await setGoogleServicesFile(config, config.modRequest.projectRoot);
|
|
105
82
|
return config;
|
|
106
83
|
}]);
|
|
107
84
|
};
|
|
108
|
-
|
|
109
85
|
exports.withGoogleServicesFile = withGoogleServicesFile;
|
|
110
|
-
|
|
111
86
|
function getGoogleServicesFilePath(config) {
|
|
112
87
|
var _config$android$googl, _config$android;
|
|
113
|
-
|
|
114
88
|
return (_config$android$googl = (_config$android = config.android) === null || _config$android === void 0 ? void 0 : _config$android.googleServicesFile) !== null && _config$android$googl !== void 0 ? _config$android$googl : null;
|
|
115
89
|
}
|
|
116
|
-
|
|
117
90
|
async function setGoogleServicesFile(config, projectRoot, targetPath = DEFAULT_TARGET_PATH) {
|
|
118
91
|
const partialSourcePath = getGoogleServicesFilePath(config);
|
|
119
|
-
|
|
120
92
|
if (!partialSourcePath) {
|
|
121
93
|
return false;
|
|
122
94
|
}
|
|
123
|
-
|
|
124
95
|
const completeSourcePath = _path().default.resolve(projectRoot, partialSourcePath);
|
|
125
|
-
|
|
126
96
|
const destinationPath = _path().default.resolve(projectRoot, targetPath);
|
|
127
|
-
|
|
128
97
|
try {
|
|
129
98
|
await (0, _fs().copyFilePathToPathAsync)(completeSourcePath, destinationPath);
|
|
130
99
|
} catch (e) {
|
|
131
100
|
console.log(e);
|
|
132
101
|
throw new Error(`Cannot copy google-services.json from ${completeSourcePath} to ${destinationPath}. Please make sure the source and destination paths exist.`);
|
|
133
102
|
}
|
|
134
|
-
|
|
135
103
|
return true;
|
|
136
104
|
}
|
|
105
|
+
|
|
137
106
|
/**
|
|
138
107
|
* Adding the Google Services plugin
|
|
139
108
|
* NOTE(brentvatne): string replacement is a fragile approach! we need a
|
|
140
109
|
* better solution than this.
|
|
141
110
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
111
|
function setClassPath(config, buildGradle) {
|
|
145
112
|
const googleServicesFile = getGoogleServicesFilePath(config);
|
|
146
|
-
|
|
147
113
|
if (!googleServicesFile) {
|
|
148
114
|
return buildGradle;
|
|
149
115
|
}
|
|
150
|
-
|
|
151
116
|
if (buildGradle.includes(googleServicesClassPath)) {
|
|
152
117
|
return buildGradle;
|
|
153
|
-
}
|
|
154
|
-
|
|
118
|
+
}
|
|
155
119
|
|
|
120
|
+
//
|
|
156
121
|
return buildGradle.replace(/dependencies\s?{/, `dependencies {
|
|
157
122
|
classpath '${googleServicesClassPath}:${googleServicesVersion}'`);
|
|
158
123
|
}
|
|
159
|
-
|
|
160
124
|
function applyPlugin(config, appBuildGradle) {
|
|
161
125
|
const googleServicesFile = getGoogleServicesFilePath(config);
|
|
162
|
-
|
|
163
126
|
if (!googleServicesFile) {
|
|
164
127
|
return appBuildGradle;
|
|
165
|
-
}
|
|
166
|
-
|
|
128
|
+
}
|
|
167
129
|
|
|
130
|
+
// Make sure the project does not have the plugin already
|
|
168
131
|
const pattern = new RegExp(`apply\\s+plugin:\\s+['"]${googleServicesPlugin}['"]`);
|
|
169
|
-
|
|
170
132
|
if (appBuildGradle.match(pattern)) {
|
|
171
133
|
return appBuildGradle;
|
|
172
|
-
}
|
|
173
|
-
|
|
134
|
+
}
|
|
174
135
|
|
|
136
|
+
// Add it to the end of the file
|
|
175
137
|
return appBuildGradle + `\napply plugin: '${googleServicesPlugin}'`;
|
|
176
138
|
}
|
|
177
139
|
//# sourceMappingURL=GoogleServices.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleServices.js","names":["DEFAULT_TARGET_PATH","googleServicesClassPath","googleServicesPlugin","googleServicesVersion","withClassPath","config","withProjectBuildGradle","modResults","language","contents","setClassPath","addWarningAndroid","withApplyPlugin","withAppBuildGradle","applyPlugin","withGoogleServicesFile","withDangerousMod","setGoogleServicesFile","modRequest","projectRoot","getGoogleServicesFilePath","android","googleServicesFile","targetPath","partialSourcePath","completeSourcePath","path","resolve","destinationPath","copyFilePathToPathAsync","e","console","log","Error","buildGradle","includes","replace","appBuildGradle","pattern","RegExp","match"],"sources":["../../src/android/GoogleServices.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withAppBuildGradle, withProjectBuildGradle } from '../plugins/android-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { copyFilePathToPathAsync } from '../utils/fs';\nimport { addWarningAndroid } from '../utils/warnings';\n\nconst DEFAULT_TARGET_PATH = './android/app/google-services.json';\n\nconst googleServicesClassPath = 'com.google.gms:google-services';\nconst googleServicesPlugin = 'com.google.gms.google-services';\n\n// NOTE(brentvatne): This may be annoying to keep up to date...\nconst googleServicesVersion = '4.3.3';\n\nexport const withClassPath: ConfigPlugin = (config) => {\n return withProjectBuildGradle(config, (config) => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = setClassPath(config, config.modResults.contents);\n } else {\n addWarningAndroid(\n 'android.googleServicesFile',\n `Cannot automatically configure project build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\nexport const withApplyPlugin: ConfigPlugin = (config) => {\n return withAppBuildGradle(config, (config) => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = applyPlugin(config, config.modResults.contents);\n } else {\n addWarningAndroid(\n 'android.googleServicesFile',\n `Cannot automatically configure app build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\n/**\n * Add `google-services.json` to project\n */\nexport const withGoogleServicesFile: ConfigPlugin = (config) => {\n return withDangerousMod(config, [\n 'android',\n async (config) => {\n await setGoogleServicesFile(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport function getGoogleServicesFilePath(config: Pick<ExpoConfig, 'android'>) {\n return config.android?.googleServicesFile ?? null;\n}\n\nexport async function setGoogleServicesFile(\n config: Pick<ExpoConfig, 'android'>,\n projectRoot: string,\n targetPath: string = DEFAULT_TARGET_PATH\n) {\n const partialSourcePath = getGoogleServicesFilePath(config);\n if (!partialSourcePath) {\n return false;\n }\n\n const completeSourcePath = path.resolve(projectRoot, partialSourcePath);\n const destinationPath = path.resolve(projectRoot, targetPath);\n\n try {\n await copyFilePathToPathAsync(completeSourcePath, destinationPath);\n } catch (e) {\n console.log(e);\n throw new Error(\n `Cannot copy google-services.json from ${completeSourcePath} to ${destinationPath}. Please make sure the source and destination paths exist.`\n );\n }\n return true;\n}\n\n/**\n * Adding the Google Services plugin\n * NOTE(brentvatne): string replacement is a fragile approach! we need a\n * better solution than this.\n */\nexport function setClassPath(config: Pick<ExpoConfig, 'android'>, buildGradle: string) {\n const googleServicesFile = getGoogleServicesFilePath(config);\n if (!googleServicesFile) {\n return buildGradle;\n }\n\n if (buildGradle.includes(googleServicesClassPath)) {\n return buildGradle;\n }\n\n //\n return buildGradle.replace(\n /dependencies\\s?{/,\n `dependencies {\n classpath '${googleServicesClassPath}:${googleServicesVersion}'`\n );\n}\n\nexport function applyPlugin(config: Pick<ExpoConfig, 'android'>, appBuildGradle: string) {\n const googleServicesFile = getGoogleServicesFilePath(config);\n if (!googleServicesFile) {\n return appBuildGradle;\n }\n\n // Make sure the project does not have the plugin already\n const pattern = new RegExp(`apply\\\\s+plugin:\\\\s+['\"]${googleServicesPlugin}['\"]`);\n if (appBuildGradle.match(pattern)) {\n return appBuildGradle;\n }\n\n // Add it to the end of the file\n return appBuildGradle + `\\napply plugin: '${googleServicesPlugin}'`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"GoogleServices.js","names":["DEFAULT_TARGET_PATH","googleServicesClassPath","googleServicesPlugin","googleServicesVersion","withClassPath","config","withProjectBuildGradle","modResults","language","contents","setClassPath","addWarningAndroid","withApplyPlugin","withAppBuildGradle","applyPlugin","withGoogleServicesFile","withDangerousMod","setGoogleServicesFile","modRequest","projectRoot","getGoogleServicesFilePath","android","googleServicesFile","targetPath","partialSourcePath","completeSourcePath","path","resolve","destinationPath","copyFilePathToPathAsync","e","console","log","Error","buildGradle","includes","replace","appBuildGradle","pattern","RegExp","match"],"sources":["../../src/android/GoogleServices.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withAppBuildGradle, withProjectBuildGradle } from '../plugins/android-plugins';\nimport { withDangerousMod } from '../plugins/withDangerousMod';\nimport { copyFilePathToPathAsync } from '../utils/fs';\nimport { addWarningAndroid } from '../utils/warnings';\n\nconst DEFAULT_TARGET_PATH = './android/app/google-services.json';\n\nconst googleServicesClassPath = 'com.google.gms:google-services';\nconst googleServicesPlugin = 'com.google.gms.google-services';\n\n// NOTE(brentvatne): This may be annoying to keep up to date...\nconst googleServicesVersion = '4.3.3';\n\nexport const withClassPath: ConfigPlugin = (config) => {\n return withProjectBuildGradle(config, (config) => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = setClassPath(config, config.modResults.contents);\n } else {\n addWarningAndroid(\n 'android.googleServicesFile',\n `Cannot automatically configure project build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\nexport const withApplyPlugin: ConfigPlugin = (config) => {\n return withAppBuildGradle(config, (config) => {\n if (config.modResults.language === 'groovy') {\n config.modResults.contents = applyPlugin(config, config.modResults.contents);\n } else {\n addWarningAndroid(\n 'android.googleServicesFile',\n `Cannot automatically configure app build.gradle if it's not groovy`\n );\n }\n return config;\n });\n};\n\n/**\n * Add `google-services.json` to project\n */\nexport const withGoogleServicesFile: ConfigPlugin = (config) => {\n return withDangerousMod(config, [\n 'android',\n async (config) => {\n await setGoogleServicesFile(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport function getGoogleServicesFilePath(config: Pick<ExpoConfig, 'android'>) {\n return config.android?.googleServicesFile ?? null;\n}\n\nexport async function setGoogleServicesFile(\n config: Pick<ExpoConfig, 'android'>,\n projectRoot: string,\n targetPath: string = DEFAULT_TARGET_PATH\n) {\n const partialSourcePath = getGoogleServicesFilePath(config);\n if (!partialSourcePath) {\n return false;\n }\n\n const completeSourcePath = path.resolve(projectRoot, partialSourcePath);\n const destinationPath = path.resolve(projectRoot, targetPath);\n\n try {\n await copyFilePathToPathAsync(completeSourcePath, destinationPath);\n } catch (e) {\n console.log(e);\n throw new Error(\n `Cannot copy google-services.json from ${completeSourcePath} to ${destinationPath}. Please make sure the source and destination paths exist.`\n );\n }\n return true;\n}\n\n/**\n * Adding the Google Services plugin\n * NOTE(brentvatne): string replacement is a fragile approach! we need a\n * better solution than this.\n */\nexport function setClassPath(config: Pick<ExpoConfig, 'android'>, buildGradle: string) {\n const googleServicesFile = getGoogleServicesFilePath(config);\n if (!googleServicesFile) {\n return buildGradle;\n }\n\n if (buildGradle.includes(googleServicesClassPath)) {\n return buildGradle;\n }\n\n //\n return buildGradle.replace(\n /dependencies\\s?{/,\n `dependencies {\n classpath '${googleServicesClassPath}:${googleServicesVersion}'`\n );\n}\n\nexport function applyPlugin(config: Pick<ExpoConfig, 'android'>, appBuildGradle: string) {\n const googleServicesFile = getGoogleServicesFilePath(config);\n if (!googleServicesFile) {\n return appBuildGradle;\n }\n\n // Make sure the project does not have the plugin already\n const pattern = new RegExp(`apply\\\\s+plugin:\\\\s+['\"]${googleServicesPlugin}['\"]`);\n if (appBuildGradle.match(pattern)) {\n return appBuildGradle;\n }\n\n // Add it to the end of the file\n return appBuildGradle + `\\napply plugin: '${googleServicesPlugin}'`;\n}\n"],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Android, ExpoConfig } from '@expo/config-types';
|
|
2
2
|
import { AndroidManifest, ManifestIntentFilter } from './Manifest';
|
|
3
|
-
|
|
3
|
+
type AndroidIntentFilters = NonNullable<Android['intentFilters']>;
|
|
4
4
|
export declare const withAndroidIntentFilters: import("..").ConfigPlugin<void>;
|
|
5
5
|
export declare function getIntentFilters(config: Pick<ExpoConfig, 'android'>): AndroidIntentFilters;
|
|
6
6
|
export declare function setAndroidIntentFilters(config: Pick<ExpoConfig, 'android'>, androidManifest: AndroidManifest): AndroidManifest;
|
|
@@ -7,61 +7,45 @@ exports.default = renderIntentFilters;
|
|
|
7
7
|
exports.getIntentFilters = getIntentFilters;
|
|
8
8
|
exports.setAndroidIntentFilters = setAndroidIntentFilters;
|
|
9
9
|
exports.withAndroidIntentFilters = void 0;
|
|
10
|
-
|
|
11
10
|
function _androidPlugins() {
|
|
12
11
|
const data = require("../plugins/android-plugins");
|
|
13
|
-
|
|
14
12
|
_androidPlugins = function () {
|
|
15
13
|
return data;
|
|
16
14
|
};
|
|
17
|
-
|
|
18
15
|
return data;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
function _Manifest() {
|
|
22
18
|
const data = require("./Manifest");
|
|
23
|
-
|
|
24
19
|
_Manifest = function () {
|
|
25
20
|
return data;
|
|
26
21
|
};
|
|
27
|
-
|
|
28
22
|
return data;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
const GENERATED_TAG = 'data-generated';
|
|
32
25
|
const withAndroidIntentFilters = (0, _androidPlugins().createAndroidManifestPlugin)(setAndroidIntentFilters, 'withAndroidIntentFilters');
|
|
33
26
|
exports.withAndroidIntentFilters = withAndroidIntentFilters;
|
|
34
|
-
|
|
35
27
|
function getIntentFilters(config) {
|
|
36
28
|
var _config$android$inten, _config$android;
|
|
37
|
-
|
|
38
29
|
return (_config$android$inten = (_config$android = config.android) === null || _config$android === void 0 ? void 0 : _config$android.intentFilters) !== null && _config$android$inten !== void 0 ? _config$android$inten : [];
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
function setAndroidIntentFilters(config, androidManifest) {
|
|
42
32
|
var _mainActivity$intent, _mainActivity$intent2;
|
|
43
|
-
|
|
44
33
|
// Always ensure old tags are removed.
|
|
45
|
-
const mainActivity = (0, _Manifest().getMainActivityOrThrow)(androidManifest);
|
|
46
|
-
|
|
34
|
+
const mainActivity = (0, _Manifest().getMainActivityOrThrow)(androidManifest);
|
|
35
|
+
// Remove all generated tags from previous runs...
|
|
47
36
|
if ((_mainActivity$intent = mainActivity['intent-filter']) !== null && _mainActivity$intent !== void 0 && _mainActivity$intent.length) {
|
|
48
37
|
mainActivity['intent-filter'] = mainActivity['intent-filter'].filter(value => {
|
|
49
38
|
var _value$$;
|
|
50
|
-
|
|
51
39
|
return ((_value$$ = value.$) === null || _value$$ === void 0 ? void 0 : _value$$[GENERATED_TAG]) !== 'true';
|
|
52
40
|
});
|
|
53
41
|
}
|
|
54
|
-
|
|
55
42
|
const intentFilters = getIntentFilters(config);
|
|
56
|
-
|
|
57
43
|
if (!intentFilters.length) {
|
|
58
44
|
return androidManifest;
|
|
59
45
|
}
|
|
60
|
-
|
|
61
46
|
mainActivity['intent-filter'] = (_mainActivity$intent2 = mainActivity['intent-filter']) === null || _mainActivity$intent2 === void 0 ? void 0 : _mainActivity$intent2.concat(renderIntentFilters(intentFilters));
|
|
62
47
|
return androidManifest;
|
|
63
48
|
}
|
|
64
|
-
|
|
65
49
|
function renderIntentFilters(intentFilters) {
|
|
66
50
|
return intentFilters.map(intentFilter => {
|
|
67
51
|
// <intent-filter>
|
|
@@ -71,7 +55,8 @@ function renderIntentFilters(intentFilters) {
|
|
|
71
55
|
// Add a custom "generated" tag that we can query later to remove.
|
|
72
56
|
[GENERATED_TAG]: 'true'
|
|
73
57
|
},
|
|
74
|
-
action: [
|
|
58
|
+
action: [
|
|
59
|
+
// <action android:name="android.intent.action.VIEW"/>
|
|
75
60
|
{
|
|
76
61
|
$: {
|
|
77
62
|
'android:name': `android.intent.action.${intentFilter.action}`
|
|
@@ -82,19 +67,18 @@ function renderIntentFilters(intentFilters) {
|
|
|
82
67
|
};
|
|
83
68
|
});
|
|
84
69
|
}
|
|
85
|
-
/** Like `<data android:scheme="exp"/>` */
|
|
86
|
-
|
|
87
70
|
|
|
71
|
+
/** Like `<data android:scheme="exp"/>` */
|
|
88
72
|
function renderIntentFilterData(data) {
|
|
89
73
|
return (Array.isArray(data) ? data : [data]).filter(Boolean).map(datum => ({
|
|
90
|
-
$: Object.entries(datum !== null && datum !== void 0 ? datum : {}).reduce((prev, [key, value]) => ({
|
|
74
|
+
$: Object.entries(datum !== null && datum !== void 0 ? datum : {}).reduce((prev, [key, value]) => ({
|
|
75
|
+
...prev,
|
|
91
76
|
[`android:${key}`]: value
|
|
92
77
|
}), {})
|
|
93
78
|
}));
|
|
94
79
|
}
|
|
95
|
-
/** Like `<category android:name="android.intent.category.DEFAULT"/>` */
|
|
96
|
-
|
|
97
80
|
|
|
81
|
+
/** Like `<category android:name="android.intent.category.DEFAULT"/>` */
|
|
98
82
|
function renderIntentFilterCategory(category) {
|
|
99
83
|
return (Array.isArray(category) ? category : [category]).filter(Boolean).map(cat => ({
|
|
100
84
|
$: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntentFilters.js","names":["GENERATED_TAG","withAndroidIntentFilters","createAndroidManifestPlugin","setAndroidIntentFilters","getIntentFilters","config","android","intentFilters","androidManifest","mainActivity","getMainActivityOrThrow","length","filter","value","$","concat","renderIntentFilters","map","intentFilter","autoVerify","undefined","action","data","renderIntentFilterData","category","renderIntentFilterCategory","Array","isArray","Boolean","datum","Object","entries","reduce","prev","key","cat"],"sources":["../../src/android/IntentFilters.ts"],"sourcesContent":["import { Android, AndroidIntentFiltersData, ExpoConfig } from '@expo/config-types';\n\nimport { createAndroidManifestPlugin } from '../plugins/android-plugins';\nimport { AndroidManifest, getMainActivityOrThrow, ManifestIntentFilter } from './Manifest';\n\ntype AndroidIntentFilters = NonNullable<Android['intentFilters']>;\n\nconst GENERATED_TAG = 'data-generated';\n\nexport const withAndroidIntentFilters = createAndroidManifestPlugin(\n setAndroidIntentFilters,\n 'withAndroidIntentFilters'\n);\n\nexport function getIntentFilters(config: Pick<ExpoConfig, 'android'>): AndroidIntentFilters {\n return config.android?.intentFilters ?? [];\n}\n\nexport function setAndroidIntentFilters(\n config: Pick<ExpoConfig, 'android'>,\n androidManifest: AndroidManifest\n): AndroidManifest {\n // Always ensure old tags are removed.\n const mainActivity = getMainActivityOrThrow(androidManifest);\n // Remove all generated tags from previous runs...\n if (mainActivity['intent-filter']?.length) {\n mainActivity['intent-filter'] = mainActivity['intent-filter'].filter(\n (value) => value.$?.[GENERATED_TAG] !== 'true'\n );\n }\n\n const intentFilters = getIntentFilters(config);\n if (!intentFilters.length) {\n return androidManifest;\n }\n\n mainActivity['intent-filter'] = mainActivity['intent-filter']?.concat(\n renderIntentFilters(intentFilters)\n );\n\n return androidManifest;\n}\n\nexport default function renderIntentFilters(\n intentFilters: AndroidIntentFilters\n): ManifestIntentFilter[] {\n return intentFilters.map((intentFilter) => {\n // <intent-filter>\n return {\n $: {\n 'android:autoVerify': intentFilter.autoVerify ? 'true' : undefined,\n // Add a custom \"generated\" tag that we can query later to remove.\n [GENERATED_TAG]: 'true',\n },\n action: [\n // <action android:name=\"android.intent.action.VIEW\"/>\n {\n $: {\n 'android:name': `android.intent.action.${intentFilter.action}`,\n },\n },\n ],\n data: renderIntentFilterData(intentFilter.data),\n category: renderIntentFilterCategory(intentFilter.category),\n };\n });\n}\n\n/** Like `<data android:scheme=\"exp\"/>` */\nfunction renderIntentFilterData(data?: AndroidIntentFiltersData | AndroidIntentFiltersData[]) {\n return (Array.isArray(data) ? data : [data]).filter(Boolean).map((datum) => ({\n $: Object.entries(datum ?? {}).reduce(\n (prev, [key, value]) => ({ ...prev, [`android:${key}`]: value }),\n {}\n ),\n }));\n}\n\n/** Like `<category android:name=\"android.intent.category.DEFAULT\"/>` */\nfunction renderIntentFilterCategory(category?: string | string[]) {\n return (Array.isArray(category) ? category : [category]).filter(Boolean).map((cat) => ({\n $: {\n 'android:name': `android.intent.category.${cat}`,\n },\n }));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntentFilters.js","names":["GENERATED_TAG","withAndroidIntentFilters","createAndroidManifestPlugin","setAndroidIntentFilters","getIntentFilters","config","android","intentFilters","androidManifest","mainActivity","getMainActivityOrThrow","length","filter","value","$","concat","renderIntentFilters","map","intentFilter","autoVerify","undefined","action","data","renderIntentFilterData","category","renderIntentFilterCategory","Array","isArray","Boolean","datum","Object","entries","reduce","prev","key","cat"],"sources":["../../src/android/IntentFilters.ts"],"sourcesContent":["import { Android, AndroidIntentFiltersData, ExpoConfig } from '@expo/config-types';\n\nimport { createAndroidManifestPlugin } from '../plugins/android-plugins';\nimport { AndroidManifest, getMainActivityOrThrow, ManifestIntentFilter } from './Manifest';\n\ntype AndroidIntentFilters = NonNullable<Android['intentFilters']>;\n\nconst GENERATED_TAG = 'data-generated';\n\nexport const withAndroidIntentFilters = createAndroidManifestPlugin(\n setAndroidIntentFilters,\n 'withAndroidIntentFilters'\n);\n\nexport function getIntentFilters(config: Pick<ExpoConfig, 'android'>): AndroidIntentFilters {\n return config.android?.intentFilters ?? [];\n}\n\nexport function setAndroidIntentFilters(\n config: Pick<ExpoConfig, 'android'>,\n androidManifest: AndroidManifest\n): AndroidManifest {\n // Always ensure old tags are removed.\n const mainActivity = getMainActivityOrThrow(androidManifest);\n // Remove all generated tags from previous runs...\n if (mainActivity['intent-filter']?.length) {\n mainActivity['intent-filter'] = mainActivity['intent-filter'].filter(\n (value) => value.$?.[GENERATED_TAG] !== 'true'\n );\n }\n\n const intentFilters = getIntentFilters(config);\n if (!intentFilters.length) {\n return androidManifest;\n }\n\n mainActivity['intent-filter'] = mainActivity['intent-filter']?.concat(\n renderIntentFilters(intentFilters)\n );\n\n return androidManifest;\n}\n\nexport default function renderIntentFilters(\n intentFilters: AndroidIntentFilters\n): ManifestIntentFilter[] {\n return intentFilters.map((intentFilter) => {\n // <intent-filter>\n return {\n $: {\n 'android:autoVerify': intentFilter.autoVerify ? 'true' : undefined,\n // Add a custom \"generated\" tag that we can query later to remove.\n [GENERATED_TAG]: 'true',\n },\n action: [\n // <action android:name=\"android.intent.action.VIEW\"/>\n {\n $: {\n 'android:name': `android.intent.action.${intentFilter.action}`,\n },\n },\n ],\n data: renderIntentFilterData(intentFilter.data),\n category: renderIntentFilterCategory(intentFilter.category),\n };\n });\n}\n\n/** Like `<data android:scheme=\"exp\"/>` */\nfunction renderIntentFilterData(data?: AndroidIntentFiltersData | AndroidIntentFiltersData[]) {\n return (Array.isArray(data) ? data : [data]).filter(Boolean).map((datum) => ({\n $: Object.entries(datum ?? {}).reduce(\n (prev, [key, value]) => ({ ...prev, [`android:${key}`]: value }),\n {}\n ),\n }));\n}\n\n/** Like `<category android:name=\"android.intent.category.DEFAULT\"/>` */\nfunction renderIntentFilterCategory(category?: string | string[]) {\n return (Array.isArray(category) ? category : [category]).filter(Boolean).map((cat) => ({\n $: {\n 'android:name': `android.intent.category.${cat}`,\n },\n }));\n}\n"],"mappings":";;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA,MAAMA,aAAa,GAAG,gBAAgB;AAE/B,MAAMC,wBAAwB,GAAG,IAAAC,6CAA2B,EACjEC,uBAAuB,EACvB,0BAA0B,CAC3B;AAAC;AAEK,SAASC,gBAAgB,CAACC,MAAmC,EAAwB;EAAA;EAC1F,mDAAOA,MAAM,CAACC,OAAO,oDAAd,gBAAgBC,aAAa,yEAAI,EAAE;AAC5C;AAEO,SAASJ,uBAAuB,CACrCE,MAAmC,EACnCG,eAAgC,EACf;EAAA;EACjB;EACA,MAAMC,YAAY,GAAG,IAAAC,kCAAsB,EAACF,eAAe,CAAC;EAC5D;EACA,4BAAIC,YAAY,CAAC,eAAe,CAAC,iDAA7B,qBAA+BE,MAAM,EAAE;IACzCF,YAAY,CAAC,eAAe,CAAC,GAAGA,YAAY,CAAC,eAAe,CAAC,CAACG,MAAM,CACjEC,KAAK;MAAA;MAAA,OAAK,aAAAA,KAAK,CAACC,CAAC,6CAAP,SAAUd,aAAa,CAAC,MAAK,MAAM;IAAA,EAC/C;EACH;EAEA,MAAMO,aAAa,GAAGH,gBAAgB,CAACC,MAAM,CAAC;EAC9C,IAAI,CAACE,aAAa,CAACI,MAAM,EAAE;IACzB,OAAOH,eAAe;EACxB;EAEAC,YAAY,CAAC,eAAe,CAAC,4BAAGA,YAAY,CAAC,eAAe,CAAC,0DAA7B,sBAA+BM,MAAM,CACnEC,mBAAmB,CAACT,aAAa,CAAC,CACnC;EAED,OAAOC,eAAe;AACxB;AAEe,SAASQ,mBAAmB,CACzCT,aAAmC,EACX;EACxB,OAAOA,aAAa,CAACU,GAAG,CAAEC,YAAY,IAAK;IACzC;IACA,OAAO;MACLJ,CAAC,EAAE;QACD,oBAAoB,EAAEI,YAAY,CAACC,UAAU,GAAG,MAAM,GAAGC,SAAS;QAClE;QACA,CAACpB,aAAa,GAAG;MACnB,CAAC;MACDqB,MAAM,EAAE;MACN;MACA;QACEP,CAAC,EAAE;UACD,cAAc,EAAG,yBAAwBI,YAAY,CAACG,MAAO;QAC/D;MACF,CAAC,CACF;MACDC,IAAI,EAAEC,sBAAsB,CAACL,YAAY,CAACI,IAAI,CAAC;MAC/CE,QAAQ,EAAEC,0BAA0B,CAACP,YAAY,CAACM,QAAQ;IAC5D,CAAC;EACH,CAAC,CAAC;AACJ;;AAEA;AACA,SAASD,sBAAsB,CAACD,IAA4D,EAAE;EAC5F,OAAO,CAACI,KAAK,CAACC,OAAO,CAACL,IAAI,CAAC,GAAGA,IAAI,GAAG,CAACA,IAAI,CAAC,EAAEV,MAAM,CAACgB,OAAO,CAAC,CAACX,GAAG,CAAEY,KAAK,KAAM;IAC3Ef,CAAC,EAAEgB,MAAM,CAACC,OAAO,CAACF,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,CAAC,CAAC,CAACG,MAAM,CACnC,CAACC,IAAI,EAAE,CAACC,GAAG,EAAErB,KAAK,CAAC,MAAM;MAAE,GAAGoB,IAAI;MAAE,CAAE,WAAUC,GAAI,EAAC,GAAGrB;IAAM,CAAC,CAAC,EAChE,CAAC,CAAC;EAEN,CAAC,CAAC,CAAC;AACL;;AAEA;AACA,SAASY,0BAA0B,CAACD,QAA4B,EAAE;EAChE,OAAO,CAACE,KAAK,CAACC,OAAO,CAACH,QAAQ,CAAC,GAAGA,QAAQ,GAAG,CAACA,QAAQ,CAAC,EAAEZ,MAAM,CAACgB,OAAO,CAAC,CAACX,GAAG,CAAEkB,GAAG,KAAM;IACrFrB,CAAC,EAAE;MACD,cAAc,EAAG,2BAA0BqB,GAAI;IACjD;EACF,CAAC,CAAC,CAAC;AACL"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export type StringBoolean = 'true' | 'false';
|
|
2
|
+
type ManifestMetaDataAttributes = AndroidManifestAttributes & {
|
|
3
3
|
'android:value'?: string;
|
|
4
4
|
'android:resource'?: string;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
type AndroidManifestAttributes = {
|
|
7
7
|
'android:name': string | 'android.intent.action.VIEW';
|
|
8
8
|
'tools:node'?: string | 'remove';
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type ManifestAction = {
|
|
11
11
|
$: AndroidManifestAttributes;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type ManifestCategory = {
|
|
14
14
|
$: AndroidManifestAttributes;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
type ManifestData = {
|
|
17
17
|
$: {
|
|
18
18
|
[key: string]: string | undefined;
|
|
19
19
|
'android:host'?: string;
|
|
@@ -21,14 +21,14 @@ declare type ManifestData = {
|
|
|
21
21
|
'android:scheme'?: string;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
type ManifestReceiver = {
|
|
25
25
|
$: AndroidManifestAttributes & {
|
|
26
26
|
'android:exported'?: StringBoolean;
|
|
27
27
|
'android:enabled'?: StringBoolean;
|
|
28
28
|
};
|
|
29
29
|
'intent-filter'?: ManifestIntentFilter[];
|
|
30
30
|
};
|
|
31
|
-
export
|
|
31
|
+
export type ManifestIntentFilter = {
|
|
32
32
|
$?: {
|
|
33
33
|
'android:autoVerify'?: StringBoolean;
|
|
34
34
|
'data-generated'?: StringBoolean;
|
|
@@ -37,19 +37,19 @@ export declare type ManifestIntentFilter = {
|
|
|
37
37
|
data?: ManifestData[];
|
|
38
38
|
category?: ManifestCategory[];
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export type ManifestMetaData = {
|
|
41
41
|
$: ManifestMetaDataAttributes;
|
|
42
42
|
};
|
|
43
|
-
|
|
43
|
+
type ManifestServiceAttributes = AndroidManifestAttributes & {
|
|
44
44
|
'android:enabled'?: StringBoolean;
|
|
45
45
|
'android:exported'?: StringBoolean;
|
|
46
46
|
'android:permission'?: string;
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
type ManifestService = {
|
|
49
49
|
$: ManifestServiceAttributes;
|
|
50
50
|
'intent-filter'?: ManifestIntentFilter[];
|
|
51
51
|
};
|
|
52
|
-
|
|
52
|
+
type ManifestApplicationAttributes = {
|
|
53
53
|
'android:name': string | '.MainApplication';
|
|
54
54
|
'android:icon'?: string;
|
|
55
55
|
'android:roundIcon'?: string;
|
|
@@ -60,7 +60,7 @@ declare type ManifestApplicationAttributes = {
|
|
|
60
60
|
'android:usesCleartextTraffic'?: StringBoolean;
|
|
61
61
|
[key: string]: string | undefined;
|
|
62
62
|
};
|
|
63
|
-
export
|
|
63
|
+
export type ManifestActivity = {
|
|
64
64
|
$: ManifestApplicationAttributes & {
|
|
65
65
|
'android:exported'?: StringBoolean;
|
|
66
66
|
'android:launchMode'?: string;
|
|
@@ -70,12 +70,12 @@ export declare type ManifestActivity = {
|
|
|
70
70
|
};
|
|
71
71
|
'intent-filter'?: ManifestIntentFilter[];
|
|
72
72
|
};
|
|
73
|
-
export
|
|
73
|
+
export type ManifestUsesLibrary = {
|
|
74
74
|
$: AndroidManifestAttributes & {
|
|
75
75
|
'android:required'?: StringBoolean;
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
|
-
export
|
|
78
|
+
export type ManifestApplication = {
|
|
79
79
|
$: ManifestApplicationAttributes;
|
|
80
80
|
activity?: ManifestActivity[];
|
|
81
81
|
service?: ManifestService[];
|
|
@@ -83,21 +83,21 @@ export declare type ManifestApplication = {
|
|
|
83
83
|
'meta-data'?: ManifestMetaData[];
|
|
84
84
|
'uses-library'?: ManifestUsesLibrary[];
|
|
85
85
|
};
|
|
86
|
-
|
|
86
|
+
type ManifestPermission = {
|
|
87
87
|
$: AndroidManifestAttributes & {
|
|
88
88
|
'android:protectionLevel'?: string | 'signature';
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
|
-
export
|
|
91
|
+
export type ManifestUsesPermission = {
|
|
92
92
|
$: AndroidManifestAttributes;
|
|
93
93
|
};
|
|
94
|
-
|
|
94
|
+
type ManifestUsesFeature = {
|
|
95
95
|
$: AndroidManifestAttributes & {
|
|
96
96
|
'android:glEsVersion'?: string;
|
|
97
97
|
'android:required': StringBoolean;
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
-
export
|
|
100
|
+
export type AndroidManifest = {
|
|
101
101
|
manifest: {
|
|
102
102
|
$: {
|
|
103
103
|
'xmlns:android': string;
|