GT2/GT2-iOS/node_modules/xdl/build/__sourcemaps__/Android.js.map

1 line
19 KiB
Plaintext

{"version":3,"sources":["Android.js"],"names":["async","args","await","Binaries","addToPathAsync","let","result","spawnAsync","stdout","e","errorMessage","_","trim","stderr","startsWith","BEGINNING_OF_ADB_ERROR_MESSAGE","substring","length","Error","_getAdbOutputAsync","devices","lines","split","_isDeviceAttachedAsync","shift","listOfDevicesWithoutFirstLine","join","includes","_isDeviceAuthorizedAsync","packages","i","line","_isExpoInstalledAsync","info","regex","regexMatch","exec","_expoVersionAsync","versions","Api","versionsAsync","installedVersion","semver","lt","androidVersion","Logger","notifications","warn","code","NotificationCode","OLD_ANDROID_APP_VERSION","_checkExpoUpToDateAsync","apkPath","path","_apkCacheDirectory","existsAsync","downloadAsync","androidUrl","_downloadApkAsync","global","START_LOADING","STOP_LOADING","_installExpoAsync","_uninstallExpoAsync","_assertDeviceReadyAsync","installResult","status","_lastUrl","error","message","upgradeExpoAsync","genymotionMessage","url","output","CANT_START_ACTIVITY_ERROR","indexOf","_openUrlAsync","isDetached","installedExpo","Analytics","logEvent","platform","openUrlAsync","projectRoot","startAdbReverseAsync","projectUrl","UrlUtils","constructManifestUrlAsync","exp","ProjectUtils","readConfigJsonAsync","success","openProjectAsync","packagerInfo","ProjectSettings","readPackagerInfoAsync","expRc","readExpRcAsync","userDefinedAdbReversePorts","extraAdbReversePorts","adbReversePorts","packagerPort","expoServerPort","port","adbReverse","adbReverseRemove","stopAdbReverseAsync","debug","isPlatformSupported","process","dotExpoHomeDirectory","UserSettings","dir","mkdirp","sync"],"mappings":";;;;;;;;+BA+BAA,WAAkCC,IAAlCD,EAAwC;AACtCE,UAAMC,gCAASC,cAATD,CAAwB,KAAxBA,CAAND;;AAEA,QAAI;AACFG,UAAIC,SAASJ,MAAMK,iDAAW,KAAXA,EAAkBN,IAAlBM,CAAnBF;AACA,aAAOC,OAAOE,MAAd;AACF,KAHA,CAGE,OAAOC,CAAP,EAAU;AACVJ,UAAIK,eAA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B,KAAqB,OADxF;AAGF;;AA6EA,SAASvD,kBAAT,GAA8B;AAC5BjD,MAAIyG,uBAAuBC,gDAAaD,oBAAbC,EAA3B1G;AACAA,MAAI2G,MAAM3D,cAAK3B,IAAL2B,CAAUyD,oBAAVzD,EAAgC,mBAAhCA,CAAVhD;AACA4G,sCAAOC,IAAPD,CAAYD,GAAZC;AACA,SAAOD,GAAP;AACF","file":"../Android.js","sourcesContent":["/**\n * @flow\n */\n\nimport _ from 'lodash';\nimport spawnAsync from '@expo/spawn-async';\nimport existsAsync from 'exists-async';\nimport mkdirp from 'mkdirp';\nimport path from 'path';\nimport semver from 'semver';\n\nimport * as Analytics from './Analytics';\nimport * as Binaries from './Binaries';\nimport Api from './Api';\nimport Logger from './Logger';\nimport NotificationCode from './NotificationCode';\nimport * as ProjectUtils from './project/ProjectUtils';\nimport * as ProjectSettings from './ProjectSettings';\nimport UserSettings from './UserSettings';\nimport * as UrlUtils from './UrlUtils';\n\nlet _lastUrl = null;\nconst BEGINNING_OF_ADB_ERROR_MESSAGE = 'error: ';\nconst CANT_START_ACTIVITY_ERROR = 'Activity not started, unable to resolve Intent';\n\nexport function isPlatformSupported() {\n return (\n process.platform === 'darwin' || process.platform === 'win32' || process.platform === 'linux'\n );\n}\n\nasync function _getAdbOutputAsync(args) {\n await Binaries.addToPathAsync('adb');\n\n try {\n let result = await spawnAsync('adb', args);\n return result.stdout;\n } catch (e) {\n let errorMessage = _.trim(e.stderr);\n if (errorMessage.startsWith(BEGINNING_OF_ADB_ERROR_MESSAGE)) {\n errorMessage = errorMessage.substring(BEGINNING_OF_ADB_ERROR_MESSAGE.length);\n }\n throw new Error(errorMessage);\n }\n}\n\n// Device attached\nasync function _isDeviceAttachedAsync() {\n let devices = await _getAdbOutputAsync(['devices']);\n let lines = _.trim(devices).split(/\\r?\\n/);\n // First line is \"List of devices\".\n return lines.length > 1;\n}\n\nasync function _isDeviceAuthorizedAsync() {\n let devices = await _getAdbOutputAsync(['devices']);\n let lines = _.trim(devices).split(/\\r?\\n/);\n lines.shift();\n let listOfDevicesWithoutFirstLine = lines.join('\\n');\n // result looks like \"072c4cf200e333c7\tdevice\" when authorized\n // and \"072c4cf200e333c7\tunauthorized\" when not.\n return listOfDevicesWithoutFirstLine.includes('device');\n}\n\n// Expo installed\nasync function _isExpoInstalledAsync() {\n let packages = await _getAdbOutputAsync(['shell', 'pm', 'list', 'packages', '-f']);\n let lines = packages.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i];\n if (line.includes('host.exp.exponent.test')) {\n continue;\n }\n\n if (line.includes('host.exp.exponent')) {\n return true;\n }\n }\n\n return false;\n}\n\nasync function _expoVersionAsync() {\n let info = await _getAdbOutputAsync(['shell', 'dumpsys', 'package', 'host.exp.exponent']);\n\n let regex = /versionName\\=([0-9\\.]+)/;\n let regexMatch = regex.exec(info);\n if (regexMatch.length < 2) {\n return null;\n }\n\n return regexMatch[1];\n}\n\nasync function _checkExpoUpToDateAsync() {\n let versions = await Api.versionsAsync();\n let installedVersion = await _expoVersionAsync();\n\n if (!installedVersion || semver.lt(installedVersion, versions.androidVersion)) {\n Logger.notifications.warn(\n { code: NotificationCode.OLD_ANDROID_APP_VERSION },\n 'This version of the Expo app is out of date. Uninstall the app and run again to upgrade.'\n );\n }\n}\n\nfunction _apkCacheDirectory() {\n let dotExpoHomeDirectory = UserSettings.dotExpoHomeDirectory();\n let dir = path.join(dotExpoHomeDirectory, 'android-apk-cache');\n mkdirp.sync(dir);\n return dir;\n}\n\nasync function _downloadApkAsync() {\n let versions = await Api.versionsAsync();\n let apkPath = path.join(_apkCacheDirectory(), `Exponent-${versions.androidVersion}.apk`);\n\n if (await existsAsync(apkPath)) {\n return apkPath;\n }\n\n await Api.downloadAsync(\n versions.androidUrl,\n path.join(_apkCacheDirectory(), `Exponent-${versions.androidVersion}.apk`)\n );\n return apkPath;\n}\n\nasync function _installExpoAsync() {\n Logger.global.info(`Downloading latest version of Expo`);\n Logger.notifications.info({ code: NotificationCode.START_LOADING });\n let path = await _downloadApkAsync();\n Logger.notifications.info({ code: NotificationCode.STOP_LOADING });\n Logger.global.info(`Installing Expo on device`);\n Logger.notifications.info({ code: NotificationCode.START_LOADING });\n let result = await _getAdbOutputAsync(['install', path]);\n Logger.notifications.info({ code: NotificationCode.STOP_LOADING });\n return result;\n}\n\nasync function _uninstallExpoAsync() {\n Logger.global.info('Uninstalling Expo from Android device.');\n return await _getAdbOutputAsync(['uninstall', 'host.exp.exponent']);\n}\n\nexport async function upgradeExpoAsync(): Promise<boolean> {\n try {\n await _assertDeviceReadyAsync();\n\n await _uninstallExpoAsync();\n let installResult = await _installExpoAsync();\n if (installResult.status !== 0) {\n return false;\n }\n\n if (_lastUrl) {\n Logger.global.info(`Opening ${_lastUrl} in Expo.`);\n await _getAdbOutputAsync([\n 'shell',\n 'am',\n 'start',\n '-a',\n 'android.intent.action.VIEW',\n '-d',\n _lastUrl,\n ]);\n _lastUrl = null;\n }\n\n return true;\n } catch (e) {\n Logger.global.error(e.message);\n return false;\n }\n}\n\n// Open Url\nasync function _assertDeviceReadyAsync() {\n const genymotionMessage = `https://developer.android.com/studio/run/device.html#developer-device-options. If you are using Genymotion go to Settings -> ADB, select \"Use custom Android SDK tools\", and point it at your Android SDK directory.`;\n\n if (!await _isDeviceAttachedAsync()) {\n throw new Error(\n `No Android device found. Please connect a device and follow the instructions here to enable USB debugging:\\n${genymotionMessage}`\n );\n }\n\n if (!await _isDeviceAuthorizedAsync()) {\n throw new Error(\n `This computer is not authorized to debug the device. Please follow the instructions here to enable USB debugging:\\n${genymotionMessage}`\n );\n }\n}\n\nasync function _openUrlAsync(url: string) {\n let output = await _getAdbOutputAsync([\n 'shell',\n 'am',\n 'start',\n '-a',\n 'android.intent.action.VIEW',\n '-d',\n url,\n ]);\n if (output.includes(CANT_START_ACTIVITY_ERROR)) {\n throw new Error(output.substring(output.indexOf('Error: ')));\n }\n\n return output;\n}\n\nasync function openUrlAsync(url: string, isDetached: boolean = false) {\n try {\n await _assertDeviceReadyAsync();\n\n let installedExpo = false;\n if (!isDetached && !await _isExpoInstalledAsync()) {\n await _installExpoAsync();\n installedExpo = true;\n }\n\n if (!isDetached) {\n _lastUrl = url;\n _checkExpoUpToDateAsync(); // let this run in background\n }\n\n Logger.global.info(`Opening on Android device`);\n try {\n await _openUrlAsync(url);\n } catch (e) {\n if (isDetached) {\n e.message = `Error running app. Have you installed the app already using Android Studio? Since you are detached you must build manually. ${e.message}`;\n } else {\n e.message = `Error running app. ${e.message}`;\n }\n\n throw e;\n }\n\n Analytics.logEvent('Open Url on Device', {\n platform: 'android',\n installedExpo,\n });\n } catch (e) {\n e.message = `Error running adb: ${e.message}`;\n throw e;\n }\n}\n\nexport async function openProjectAsync(projectRoot: string) {\n try {\n await startAdbReverseAsync(projectRoot);\n\n let projectUrl = await UrlUtils.constructManifestUrlAsync(projectRoot);\n let { exp } = await ProjectUtils.readConfigJsonAsync(projectRoot);\n\n await openUrlAsync(projectUrl, !!exp.isDetached);\n return { success: true, error: null };\n } catch (e) {\n Logger.global.error(`Couldn't start project on Android: ${e.message}`);\n return { success: false, error: e };\n }\n}\n\n// Adb reverse\nexport async function startAdbReverseAsync(projectRoot: string) {\n const packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);\n const expRc = await ProjectUtils.readExpRcAsync(projectRoot);\n const userDefinedAdbReversePorts = expRc.extraAdbReversePorts || [];\n\n let adbReversePorts = [\n packagerInfo.packagerPort,\n packagerInfo.expoServerPort,\n ...userDefinedAdbReversePorts,\n ];\n\n for (let port of adbReversePorts) {\n if (!await adbReverse(port)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport async function stopAdbReverseAsync(projectRoot: string) {\n const packagerInfo = await ProjectSettings.readPackagerInfoAsync(projectRoot);\n const expRc = await ProjectUtils.readExpRcAsync(projectRoot);\n const userDefinedAdbReversePorts = expRc.extraAdbReversePorts || [];\n\n let adbReversePorts = [\n packagerInfo.packagerPort,\n packagerInfo.expoServerPort,\n ...userDefinedAdbReversePorts,\n ];\n\n for (let port of adbReversePorts) {\n await adbReverseRemove(port);\n }\n}\n\nasync function adbReverse(port: number) {\n if (!await _isDeviceAuthorizedAsync()) {\n return false;\n }\n\n try {\n await _getAdbOutputAsync(['reverse', `tcp:${port}`, `tcp:${port}`]);\n return true;\n } catch (e) {\n Logger.global.warn(`Couldn't adb reverse: ${e.message}`);\n return false;\n }\n}\n\nasync function adbReverseRemove(port: number) {\n if (!await _isDeviceAuthorizedAsync()) {\n return false;\n }\n\n try {\n await _getAdbOutputAsync(['reverse', '--remove', `tcp:${port}`]);\n return true;\n } catch (e) {\n // Don't send this to warn because we call this preemptively sometimes\n Logger.global.debug(`Couldn't adb reverse remove: ${e.message}`);\n return false;\n }\n}\n"],"sourceRoot":"/xdl/src"}