@expo/cli 54.0.23 → 54.0.25

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.
Files changed (67) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/api/rest/client.js +27 -12
  3. package/build/src/api/rest/client.js.map +1 -1
  4. package/build/src/api/user/UserSettings.js +4 -2
  5. package/build/src/api/user/UserSettings.js.map +1 -1
  6. package/build/src/export/embed/exportEmbedAsync.js +3 -3
  7. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  8. package/build/src/export/embed/exportServer.js +1 -1
  9. package/build/src/export/embed/exportServer.js.map +1 -1
  10. package/build/src/export/exportApp.js +1 -1
  11. package/build/src/export/exportApp.js.map +1 -1
  12. package/build/src/export/exportAssets.js +10 -9
  13. package/build/src/export/exportAssets.js.map +1 -1
  14. package/build/src/export/publicFolder.js +19 -1
  15. package/build/src/export/publicFolder.js.map +1 -1
  16. package/build/src/prebuild/resolveTemplate.js +10 -5
  17. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  18. package/build/src/run/android/resolveLaunchProps.js +11 -6
  19. package/build/src/run/android/resolveLaunchProps.js.map +1 -1
  20. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  21. package/build/src/run/ios/appleDevice/client/LockdowndClient.js +1 -1
  22. package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -1
  23. package/build/src/run/ios/launchApp.js +1 -1
  24. package/build/src/run/ios/launchApp.js.map +1 -1
  25. package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +39 -2
  26. package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
  27. package/build/src/start/platforms/android/AndroidPlatformManager.js.map +1 -1
  28. package/build/src/start/platforms/android/adb.js +16 -15
  29. package/build/src/start/platforms/android/adb.js.map +1 -1
  30. package/build/src/start/platforms/ios/ApplePlatformManager.js.map +1 -1
  31. package/build/src/start/server/BundlerDevServer.js +18 -4
  32. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  33. package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
  34. package/build/src/start/server/getStaticRenderFunctions.js +2 -1
  35. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  36. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +6 -5
  37. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
  38. package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js +17 -1
  39. package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js.map +1 -1
  40. package/build/src/start/server/metro/dev-server/createMessageSocket.js +13 -2
  41. package/build/src/start/server/metro/dev-server/createMessageSocket.js.map +1 -1
  42. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +85 -15
  43. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
  44. package/build/src/start/server/metro/instantiateMetro.js +7 -3
  45. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  46. package/build/src/start/server/metro/metroErrorInterface.js +5 -2
  47. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  48. package/build/src/start/server/metro/router.js +10 -1
  49. package/build/src/start/server/metro/router.js.map +1 -1
  50. package/build/src/start/server/middleware/InterstitialPageMiddleware.js +7 -4
  51. package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
  52. package/build/src/start/server/middleware/ServeStaticMiddleware.js +2 -9
  53. package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -1
  54. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +14 -24
  55. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +1 -1
  56. package/build/src/start/server/webTemplate.js +3 -5
  57. package/build/src/start/server/webTemplate.js.map +1 -1
  58. package/build/src/utils/codesigning.js +6 -0
  59. package/build/src/utils/codesigning.js.map +1 -1
  60. package/build/src/utils/net.js +13 -0
  61. package/build/src/utils/net.js.map +1 -1
  62. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  63. package/build/src/utils/telemetry/utils/context.js +1 -1
  64. package/build/src/utils/url.js +0 -12
  65. package/build/src/utils/url.js.map +1 -1
  66. package/package.json +9 -9
  67. package/static/loading-page/index.html +10 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/run/ios/launchApp.ts"],"sourcesContent":["import chalk from 'chalk';\nimport path from 'path';\n\nimport * as XcodeBuild from './XcodeBuild';\nimport { BuildProps } from './XcodeBuild.types';\nimport { getAppDeltaDirectory, installOnDeviceAsync } from './appleDevice/installOnDeviceAsync';\nimport { Log } from '../../log';\nimport { AppleDeviceManager } from '../../start/platforms/ios/AppleDeviceManager';\nimport { launchBinaryOnMacAsync } from '../../start/platforms/ios/devicectl';\nimport { SimulatorLogStreamer } from '../../start/platforms/ios/simctlLogging';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { parsePlistAsync } from '../../utils/plist';\nimport { profile } from '../../utils/profile';\n\ntype BinaryLaunchInfo = {\n bundleId: string;\n schemes: string[];\n};\n\n/** Install and launch the app binary on a device. */\nexport async function launchAppAsync(\n binaryPath: string,\n manager: DevServerManager,\n props: Pick<BuildProps, 'isSimulator' | 'device' | 'shouldStartBundler'>,\n appId?: string\n) {\n appId ??= (await profile(getLaunchInfoForBinaryAsync)(binaryPath)).bundleId;\n\n Log.log(chalk.gray`\\u203A Installing ${binaryPath}`);\n if (!props.isSimulator) {\n if (props.device.osType === 'macOS') {\n await launchBinaryOnMacAsync(appId, binaryPath);\n } else {\n await profile(installOnDeviceAsync)({\n bundleIdentifier: appId,\n bundle: binaryPath,\n appDeltaDirectory: getAppDeltaDirectory(appId),\n udid: props.device.udid,\n deviceName: props.device.name,\n });\n }\n\n return;\n }\n\n XcodeBuild.logPrettyItem(chalk`{bold Installing} on ${props.device.name}`);\n\n const device = await AppleDeviceManager.resolveAsync({ device: props.device });\n await device.installAppAsync(binaryPath);\n\n XcodeBuild.logPrettyItem(chalk`{bold Opening} on ${device.name} {dim (${appId})}`);\n\n if (props.shouldStartBundler) {\n await SimulatorLogStreamer.getStreamer(device.device, {\n appId,\n }).attachAsync();\n }\n\n await manager.getDefaultDevServer().openCustomRuntimeAsync(\n 'simulator',\n {\n applicationId: appId,\n },\n { device }\n );\n}\n\nexport async function getLaunchInfoForBinaryAsync(binaryPath: string): Promise<BinaryLaunchInfo> {\n const builtInfoPlistPath = path.join(binaryPath, 'Info.plist');\n const { CFBundleIdentifier, CFBundleURLTypes } = await parsePlistAsync(builtInfoPlistPath);\n\n let schemes: string[] = [];\n\n if (Array.isArray(CFBundleURLTypes)) {\n schemes =\n CFBundleURLTypes.reduce<string[]>((acc, urlType: unknown) => {\n if (\n urlType &&\n typeof urlType === 'object' &&\n 'CFBundleURLSchemes' in urlType &&\n Array.isArray(urlType.CFBundleURLSchemes)\n ) {\n return [...acc, ...urlType.CFBundleURLSchemes];\n }\n return acc;\n }, []) ?? [];\n }\n\n return { bundleId: CFBundleIdentifier, schemes };\n}\n"],"names":["getLaunchInfoForBinaryAsync","launchAppAsync","binaryPath","manager","props","appId","profile","bundleId","Log","log","chalk","gray","isSimulator","device","osType","launchBinaryOnMacAsync","installOnDeviceAsync","bundleIdentifier","bundle","appDeltaDirectory","getAppDeltaDirectory","udid","deviceName","name","XcodeBuild","logPrettyItem","AppleDeviceManager","resolveAsync","installAppAsync","shouldStartBundler","SimulatorLogStreamer","getStreamer","attachAsync","getDefaultDevServer","openCustomRuntimeAsync","applicationId","builtInfoPlistPath","path","join","CFBundleIdentifier","CFBundleURLTypes","parsePlistAsync","schemes","Array","isArray","reduce","acc","urlType","CFBundleURLSchemes"],"mappings":";;;;;;;;;;;IAmEsBA,2BAA2B;eAA3BA;;IA/CAC,cAAc;eAAdA;;;;gEApBJ;;;;;;;gEACD;;;;;;oEAEW;sCAE+B;qBACvC;oCACe;2BACI;+BACF;uBAEL;yBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQjB,eAAeA,eACpBC,UAAkB,EAClBC,OAA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CAACpC,YAAY;IACjD,MAAM,EAAEqC,kBAAkB,EAAEC,gBAAgB,EAAE,GAAG,MAAMC,IAAAA,sBAAe,EAACL;IAEvE,IAAIM,UAAoB,EAAE;IAE1B,IAAIC,MAAMC,OAAO,CAACJ,mBAAmB;QACnCE,UACEF,iBAAiBK,MAAM,CAAW,CAACC,KAAKC;YACtC,IACEA,WACA,OAAOA,YAAY,YACnB,wBAAwBA,WACxBJ,MAAMC,OAAO,CAACG,QAAQC,kBAAkB,GACxC;gBACA,OAAO;uBAAIF;uBAAQC,QAAQC,kBAAkB;iBAAC;YAChD;YACA,OAAOF;QACT,GAAG,EAAE,KAAK,EAAE;IAChB;IAEA,OAAO;QAAEvC,UAAUgC;QAAoBG;IAAQ;AACjD"}
1
+ {"version":3,"sources":["../../../../src/run/ios/launchApp.ts"],"sourcesContent":["import chalk from 'chalk';\nimport path from 'path';\n\nimport * as XcodeBuild from './XcodeBuild';\nimport { BuildProps } from './XcodeBuild.types';\nimport { getAppDeltaDirectory, installOnDeviceAsync } from './appleDevice/installOnDeviceAsync';\nimport { Log } from '../../log';\nimport { AppleDeviceManager } from '../../start/platforms/ios/AppleDeviceManager';\nimport { launchBinaryOnMacAsync } from '../../start/platforms/ios/devicectl';\nimport { SimulatorLogStreamer } from '../../start/platforms/ios/simctlLogging';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { parsePlistAsync } from '../../utils/plist';\nimport { profile } from '../../utils/profile';\n\ntype BinaryLaunchInfo = {\n bundleId: string;\n schemes: string[];\n};\n\n/** Install and launch the app binary on a device. */\nexport async function launchAppAsync(\n binaryPath: string,\n manager: DevServerManager,\n props: Pick<BuildProps, 'isSimulator' | 'device' | 'shouldStartBundler'>,\n appId?: string\n) {\n appId ??= (await profile(getLaunchInfoForBinaryAsync)(binaryPath)).bundleId;\n\n Log.log(chalk.gray`\\u203A Installing ${binaryPath}`);\n if (!props.isSimulator) {\n if (props.device.osType === 'macOS') {\n await launchBinaryOnMacAsync(appId, binaryPath);\n } else {\n await profile(installOnDeviceAsync)({\n bundleIdentifier: appId,\n bundle: binaryPath,\n appDeltaDirectory: getAppDeltaDirectory(appId),\n udid: props.device.udid,\n deviceName: props.device.name,\n });\n }\n\n return;\n }\n\n XcodeBuild.logPrettyItem(chalk`{bold Installing} on ${props.device.name}`);\n\n const device = await AppleDeviceManager.resolveAsync({ device: props.device });\n await device.installAppAsync(binaryPath);\n\n XcodeBuild.logPrettyItem(chalk`{bold Opening} on ${device.name} {dim (${appId})}`);\n\n if (props.shouldStartBundler) {\n await SimulatorLogStreamer.getStreamer(device.device, {\n appId,\n }).attachAsync();\n }\n\n await manager.getDefaultDevServer().openCustomRuntimeAsync(\n 'simulator',\n {\n applicationId: appId,\n },\n { device: device.device }\n );\n}\n\nexport async function getLaunchInfoForBinaryAsync(binaryPath: string): Promise<BinaryLaunchInfo> {\n const builtInfoPlistPath = path.join(binaryPath, 'Info.plist');\n const { CFBundleIdentifier, CFBundleURLTypes } = await parsePlistAsync(builtInfoPlistPath);\n\n let schemes: string[] = [];\n\n if (Array.isArray(CFBundleURLTypes)) {\n schemes =\n CFBundleURLTypes.reduce<string[]>((acc, urlType: unknown) => {\n if (\n urlType &&\n typeof urlType === 'object' &&\n 'CFBundleURLSchemes' in urlType &&\n Array.isArray(urlType.CFBundleURLSchemes)\n ) {\n return [...acc, ...urlType.CFBundleURLSchemes];\n }\n return acc;\n }, []) ?? [];\n }\n\n return { bundleId: CFBundleIdentifier, schemes };\n}\n"],"names":["getLaunchInfoForBinaryAsync","launchAppAsync","binaryPath","manager","props","appId","profile","bundleId","Log","log","chalk","gray","isSimulator","device","osType","launchBinaryOnMacAsync","installOnDeviceAsync","bundleIdentifier","bundle","appDeltaDirectory","getAppDeltaDirectory","udid","deviceName","name","XcodeBuild","logPrettyItem","AppleDeviceManager","resolveAsync","installAppAsync","shouldStartBundler","SimulatorLogStreamer","getStreamer","attachAsync","getDefaultDevServer","openCustomRuntimeAsync","applicationId","builtInfoPlistPath","path","join","CFBundleIdentifier","CFBundleURLTypes","parsePlistAsync","schemes","Array","isArray","reduce","acc","urlType","CFBundleURLSchemes"],"mappings":";;;;;;;;;;;IAmEsBA,2BAA2B;eAA3BA;;IA/CAC,cAAc;eAAdA;;;;gEApBJ;;;;;;;gEACD;;;;;;oEAEW;sCAE+B;qBACvC;oCACe;2BACI;+BACF;uBAEL;yBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQjB,eAAeA,eACpBC,UAAkB,EAClBC,OAAyB,EACzBC,KAAwE,EACxEC,KAAc;IAEdA,UAAU,AAAC,CAAA,MAAMC,IAAAA,gBAAO,EAACN,6BAA6BE,WAAU,EAAGK,QAAQ;IAE3EC,QAAG,CAACC,GAAG,CAACC,gBAAK,CAACC,IAAI,CAAC,kBAAkB,EAAET,WAAW,CAAC;IACnD,IAAI,CAACE,MAAMQ,WAAW,EAAE;QACtB,IAAIR,MAAMS,MAAM,CAACC,MAAM,KAAK,SAAS;YACnC,MAAMC,IAAAA,iCAAsB,EAACV,OAAOH;QACtC,OAAO;YACL,MAAMI,IAAAA,gBAAO,EAACU,0CAAoB,EAAE;gBAClCC,kBAAkBZ;gBAClBa,QAAQhB;gBACRiB,mBAAmBC,IAAAA,0CAAoB,EAACf;gBACxCgB,MAAMjB,MAAMS,MAAM,CAACQ,IAAI;gBACvBC,YAAYlB,MAAMS,MAAM,CAACU,IAAI;YAC/B;QACF;QAEA;IACF;IAEAC,YAAWC,aAAa,CAACf,IAAAA,gBAAK,CAAA,CAAC,qBAAqB,EAAEN,MAAMS,MAAM,CAACU,IAAI,CAAC,CAAC;IAEzE,MAAMV,SAAS,MAAMa,sCAAkB,CAACC,YAAY,CAAC;QAAEd,QAAQT,MAAMS,MAAM;IAAC;IAC5E,MAAMA,OAAOe,eAAe,CAAC1B;IAE7BsB,YAAWC,aAAa,CAACf,IAAAA,gBAAK,CAAA,CAAC,kBAAkB,EAAEG,OAAOU,IAAI,CAAC,OAAO,EAAElB,MAAM,EAAE,CAAC;IAEjF,IAAID,MAAMyB,kBAAkB,EAAE;QAC5B,MAAMC,mCAAoB,CAACC,WAAW,CAAClB,OAAOA,MAAM,EAAE;YACpDR;QACF,GAAG2B,WAAW;IAChB;IAEA,MAAM7B,QAAQ8B,mBAAmB,GAAGC,sBAAsB,CACxD,aACA;QACEC,eAAe9B;IACjB,GACA;QAAEQ,QAAQA,OAAOA,MAAM;IAAC;AAE5B;AAEO,eAAeb,4BAA4BE,UAAkB;IAClE,MAAMkC,qBAAqBC,eAAI,CAACC,IAAI,CAACpC,YAAY;IACjD,MAAM,EAAEqC,kBAAkB,EAAEC,gBAAgB,EAAE,GAAG,MAAMC,IAAAA,sBAAe,EAACL;IAEvE,IAAIM,UAAoB,EAAE;IAE1B,IAAIC,MAAMC,OAAO,CAACJ,mBAAmB;QACnCE,UACEF,iBAAiBK,MAAM,CAAW,CAACC,KAAKC;YACtC,IACEA,WACA,OAAOA,YAAY,YACnB,wBAAwBA,WACxBJ,MAAMC,OAAO,CAACG,QAAQC,kBAAkB,GACxC;gBACA,OAAO;uBAAIF;uBAAQC,QAAQC,kBAAkB;iBAAC;YAChD;YACA,OAAOF;QACT,GAAG,EAAE,KAAK,EAAE;IAChB;IAEA,OAAO;QAAEvC,UAAUgC;QAAoBG;IAAQ;AACjD"}
@@ -22,6 +22,13 @@ function _spawnasync() {
22
22
  };
23
23
  return data;
24
24
  }
25
+ function _path() {
26
+ const data = /*#__PURE__*/ _interop_require_default(require("path"));
27
+ _path = function() {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
25
32
  const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../../log"));
26
33
  const _Prerequisite = require("../Prerequisite");
27
34
  function _interop_require_default(obj) {
@@ -71,14 +78,44 @@ function _interop_require_wildcard(obj, nodeInterop) {
71
78
  return newObj;
72
79
  }
73
80
  const debug = require('debug')('expo:doctor:apple:simulatorApp');
74
- async function getSimulatorAppIdAsync() {
81
+ /**
82
+ * Get the bundle ID of the Simulator.app via AppleScript / LaunchServices.
83
+ * May return null if the Simulator.app is not registered in LaunchServices
84
+ * (e.g. when Xcode lives on an external or renamed volume).
85
+ */ async function getSimulatorAppIdViaAppleScriptAsync() {
75
86
  try {
76
87
  return (await (0, _osascript().execAsync)('id of app "Simulator"')).trim();
77
88
  } catch {
78
- // This error may occur in CI where the users intends to install just the simulators but no Xcode.
89
+ // This error may occur in CI where the user intends to install just the simulators but no
90
+ // Xcode, or when Simulator.app is not registered in LaunchServices (e.g. Xcode on an
91
+ // external or renamed volume).
92
+ }
93
+ return null;
94
+ }
95
+ /**
96
+ * Fallback: locate Simulator.app via the active Xcode developer directory and read its
97
+ * CFBundleIdentifier directly from the app bundle's Info.plist.
98
+ * This works even when LaunchServices hasn't indexed Simulator.app.
99
+ */ async function getSimulatorAppIdFromBundleAsync() {
100
+ try {
101
+ const { stdout: developerDir } = await (0, _spawnasync().default)('xcode-select', [
102
+ '--print-path'
103
+ ]);
104
+ const simulatorInfoPlist = _path().default.join(developerDir.trim(), 'Applications', 'Simulator.app', 'Contents', 'Info.plist');
105
+ const { stdout: bundleId } = await (0, _spawnasync().default)('defaults', [
106
+ 'read',
107
+ simulatorInfoPlist,
108
+ 'CFBundleIdentifier'
109
+ ]);
110
+ return bundleId.trim() || null;
111
+ } catch {
112
+ // Simulator.app not found at the expected path or xcode-select is unavailable.
79
113
  }
80
114
  return null;
81
115
  }
116
+ async function getSimulatorAppIdAsync() {
117
+ return await getSimulatorAppIdViaAppleScriptAsync() ?? await getSimulatorAppIdFromBundleAsync();
118
+ }
82
119
  class SimulatorAppPrerequisite extends _Prerequisite.Prerequisite {
83
120
  static #_ = this.instance = new SimulatorAppPrerequisite();
84
121
  async assertImplementation() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/doctor/apple/SimulatorAppPrerequisite.ts"],"sourcesContent":["import { execAsync } from '@expo/osascript';\nimport spawnAsync from '@expo/spawn-async';\n\nimport * as Log from '../../../log';\nimport { Prerequisite, PrerequisiteCommandError } from '../Prerequisite';\n\nconst debug = require('debug')('expo:doctor:apple:simulatorApp') as typeof console.log;\n\nasync function getSimulatorAppIdAsync(): Promise<string | null> {\n try {\n return (await execAsync('id of app \"Simulator\"')).trim();\n } catch {\n // This error may occur in CI where the users intends to install just the simulators but no Xcode.\n }\n return null;\n}\n\nexport class SimulatorAppPrerequisite extends Prerequisite {\n static instance = new SimulatorAppPrerequisite();\n\n async assertImplementation(): Promise<void> {\n const result = await getSimulatorAppIdAsync();\n if (!result) {\n // This error may occur in CI where the users intends to install just the simulators but no Xcode.\n throw new PrerequisiteCommandError(\n 'SIMULATOR_APP',\n \"Can't determine id of Simulator app; the Simulator is most likely not installed on this machine. Run `sudo xcode-select -s /Applications/Xcode.app`\"\n );\n }\n if (\n result !== 'com.apple.iphonesimulator' &&\n result !== 'com.apple.CoreSimulator.SimulatorTrampoline'\n ) {\n throw new PrerequisiteCommandError(\n 'SIMULATOR_APP',\n \"Simulator is installed but is identified as '\" + result + \"'; don't know what that is.\"\n );\n }\n debug(`Simulator app id: ${result}`);\n\n try {\n // make sure we can run simctl\n await spawnAsync('xcrun', ['simctl', 'help']);\n } catch (error: any) {\n Log.warn(`Unable to run simctl:\\n${error.toString()}`);\n throw new PrerequisiteCommandError(\n 'SIMCTL',\n 'xcrun is not configured correctly. Ensure `sudo xcode-select --reset` works before running this command again.'\n );\n }\n }\n}\n"],"names":["SimulatorAppPrerequisite","debug","require","getSimulatorAppIdAsync","execAsync","trim","Prerequisite","instance","assertImplementation","result","PrerequisiteCommandError","spawnAsync","error","Log","warn","toString"],"mappings":";;;;+BAiBaA;;;eAAAA;;;;yBAjBa;;;;;;;gEACH;;;;;;6DAEF;8BACkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvD,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,eAAeC;IACb,IAAI;QACF,OAAO,AAAC,CAAA,MAAMC,IAAAA,sBAAS,EAAC,wBAAuB,EAAGC,IAAI;IACxD,EAAE,OAAM;IACN,kGAAkG;IACpG;IACA,OAAO;AACT;AAEO,MAAML,iCAAiCM,0BAAY;qBACjDC,WAAW,IAAIP;IAEtB,MAAMQ,uBAAsC;QAC1C,MAAMC,SAAS,MAAMN;QACrB,IAAI,CAACM,QAAQ;YACX,kGAAkG;YAClG,MAAM,IAAIC,sCAAwB,CAChC,iBACA;QAEJ;QACA,IACED,WAAW,+BACXA,WAAW,+CACX;YACA,MAAM,IAAIC,sCAAwB,CAChC,iBACA,kDAAkDD,SAAS;QAE/D;QACAR,MAAM,CAAC,kBAAkB,EAAEQ,QAAQ;QAEnC,IAAI;YACF,8BAA8B;YAC9B,MAAME,IAAAA,qBAAU,EAAC,SAAS;gBAAC;gBAAU;aAAO;QAC9C,EAAE,OAAOC,OAAY;YACnBC,KAAIC,IAAI,CAAC,CAAC,uBAAuB,EAAEF,MAAMG,QAAQ,IAAI;YACrD,MAAM,IAAIL,sCAAwB,CAChC,UACA;QAEJ;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../src/start/doctor/apple/SimulatorAppPrerequisite.ts"],"sourcesContent":["import { execAsync } from '@expo/osascript';\nimport spawnAsync from '@expo/spawn-async';\nimport path from 'path';\n\nimport * as Log from '../../../log';\nimport { Prerequisite, PrerequisiteCommandError } from '../Prerequisite';\n\nconst debug = require('debug')('expo:doctor:apple:simulatorApp') as typeof console.log;\n\n/**\n * Get the bundle ID of the Simulator.app via AppleScript / LaunchServices.\n * May return null if the Simulator.app is not registered in LaunchServices\n * (e.g. when Xcode lives on an external or renamed volume).\n */\nasync function getSimulatorAppIdViaAppleScriptAsync(): Promise<string | null> {\n try {\n return (await execAsync('id of app \"Simulator\"')).trim();\n } catch {\n // This error may occur in CI where the user intends to install just the simulators but no\n // Xcode, or when Simulator.app is not registered in LaunchServices (e.g. Xcode on an\n // external or renamed volume).\n }\n return null;\n}\n\n/**\n * Fallback: locate Simulator.app via the active Xcode developer directory and read its\n * CFBundleIdentifier directly from the app bundle's Info.plist.\n * This works even when LaunchServices hasn't indexed Simulator.app.\n */\nasync function getSimulatorAppIdFromBundleAsync(): Promise<string | null> {\n try {\n const { stdout: developerDir } = await spawnAsync('xcode-select', ['--print-path']);\n const simulatorInfoPlist = path.join(\n developerDir.trim(),\n 'Applications',\n 'Simulator.app',\n 'Contents',\n 'Info.plist'\n );\n const { stdout: bundleId } = await spawnAsync('defaults', [\n 'read',\n simulatorInfoPlist,\n 'CFBundleIdentifier',\n ]);\n return bundleId.trim() || null;\n } catch {\n // Simulator.app not found at the expected path or xcode-select is unavailable.\n }\n return null;\n}\n\nasync function getSimulatorAppIdAsync(): Promise<string | null> {\n return (\n (await getSimulatorAppIdViaAppleScriptAsync()) ?? (await getSimulatorAppIdFromBundleAsync())\n );\n}\n\nexport class SimulatorAppPrerequisite extends Prerequisite {\n static instance = new SimulatorAppPrerequisite();\n\n async assertImplementation(): Promise<void> {\n const result = await getSimulatorAppIdAsync();\n if (!result) {\n // This error may occur in CI where the users intends to install just the simulators but no Xcode.\n throw new PrerequisiteCommandError(\n 'SIMULATOR_APP',\n \"Can't determine id of Simulator app; the Simulator is most likely not installed on this machine. Run `sudo xcode-select -s /Applications/Xcode.app`\"\n );\n }\n if (\n result !== 'com.apple.iphonesimulator' &&\n result !== 'com.apple.CoreSimulator.SimulatorTrampoline'\n ) {\n throw new PrerequisiteCommandError(\n 'SIMULATOR_APP',\n \"Simulator is installed but is identified as '\" + result + \"'; don't know what that is.\"\n );\n }\n debug(`Simulator app id: ${result}`);\n\n try {\n // make sure we can run simctl\n await spawnAsync('xcrun', ['simctl', 'help']);\n } catch (error: any) {\n Log.warn(`Unable to run simctl:\\n${error.toString()}`);\n throw new PrerequisiteCommandError(\n 'SIMCTL',\n 'xcrun is not configured correctly. Ensure `sudo xcode-select --reset` works before running this command again.'\n );\n }\n }\n}\n"],"names":["SimulatorAppPrerequisite","debug","require","getSimulatorAppIdViaAppleScriptAsync","execAsync","trim","getSimulatorAppIdFromBundleAsync","stdout","developerDir","spawnAsync","simulatorInfoPlist","path","join","bundleId","getSimulatorAppIdAsync","Prerequisite","instance","assertImplementation","result","PrerequisiteCommandError","error","Log","warn","toString"],"mappings":";;;;+BA0DaA;;;eAAAA;;;;yBA1Da;;;;;;;gEACH;;;;;;;gEACN;;;;;;6DAEI;8BACkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvD,MAAMC,QAAQC,QAAQ,SAAS;AAE/B;;;;CAIC,GACD,eAAeC;IACb,IAAI;QACF,OAAO,AAAC,CAAA,MAAMC,IAAAA,sBAAS,EAAC,wBAAuB,EAAGC,IAAI;IACxD,EAAE,OAAM;IACN,0FAA0F;IAC1F,qFAAqF;IACrF,+BAA+B;IACjC;IACA,OAAO;AACT;AAEA;;;;CAIC,GACD,eAAeC;IACb,IAAI;QACF,MAAM,EAAEC,QAAQC,YAAY,EAAE,GAAG,MAAMC,IAAAA,qBAAU,EAAC,gBAAgB;YAAC;SAAe;QAClF,MAAMC,qBAAqBC,eAAI,CAACC,IAAI,CAClCJ,aAAaH,IAAI,IACjB,gBACA,iBACA,YACA;QAEF,MAAM,EAAEE,QAAQM,QAAQ,EAAE,GAAG,MAAMJ,IAAAA,qBAAU,EAAC,YAAY;YACxD;YACAC;YACA;SACD;QACD,OAAOG,SAASR,IAAI,MAAM;IAC5B,EAAE,OAAM;IACN,+EAA+E;IACjF;IACA,OAAO;AACT;AAEA,eAAeS;IACb,OACE,AAAC,MAAMX,0CAA4C,MAAMG;AAE7D;AAEO,MAAMN,iCAAiCe,0BAAY;qBACjDC,WAAW,IAAIhB;IAEtB,MAAMiB,uBAAsC;QAC1C,MAAMC,SAAS,MAAMJ;QACrB,IAAI,CAACI,QAAQ;YACX,kGAAkG;YAClG,MAAM,IAAIC,sCAAwB,CAChC,iBACA;QAEJ;QACA,IACED,WAAW,+BACXA,WAAW,+CACX;YACA,MAAM,IAAIC,sCAAwB,CAChC,iBACA,kDAAkDD,SAAS;QAE/D;QACAjB,MAAM,CAAC,kBAAkB,EAAEiB,QAAQ;QAEnC,IAAI;YACF,8BAA8B;YAC9B,MAAMT,IAAAA,qBAAU,EAAC,SAAS;gBAAC;gBAAU;aAAO;QAC9C,EAAE,OAAOW,OAAY;YACnBC,KAAIC,IAAI,CAAC,CAAC,uBAAuB,EAAEF,MAAMG,QAAQ,IAAI;YACrD,MAAM,IAAIJ,sCAAwB,CAChC,UACA;QAEJ;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/android/AndroidPlatformManager.ts"],"sourcesContent":["import { AndroidAppIdResolver } from './AndroidAppIdResolver';\nimport { AndroidDeviceManager } from './AndroidDeviceManager';\nimport { Device } from './adb';\nimport { startAdbReverseAsync } from './adbReverse';\nimport { CommandError } from '../../../utils/errors';\nimport { memoize } from '../../../utils/fn';\nimport { learnMore } from '../../../utils/link';\nimport { hasDirectDevClientDependency } from '../../detectDevClient';\nimport { AppIdResolver } from '../AppIdResolver';\nimport { BaseOpenInCustomProps, BaseResolveDeviceProps, PlatformManager } from '../PlatformManager';\n\nconst debug = require('debug')(\n 'expo:start:platforms:platformManager:android'\n) as typeof console.log;\n\nexport interface AndroidOpenInCustomProps extends BaseOpenInCustomProps {\n /**\n * The Android app intent to launch through `adb shell am start -n <launchActivity>`.\n */\n launchActivity?: string;\n /**\n * The custom app id to launch, provided through `--app-id`.\n * By default, the app id is identical to the package name.\n * When using product flavors, the app id might be customized.\n */\n customAppId?: string;\n}\n\nexport class AndroidPlatformManager extends PlatformManager<Device, AndroidOpenInCustomProps> {\n /** The last used custom launch props, should be reused whenever launching custom runtime without launch props */\n private lastCustomRuntimeLaunchProps?: AndroidOpenInCustomProps;\n /** Memoized method to detect if dev client is installed */\n private hasDevClientInstalled: () => boolean;\n\n constructor(\n protected projectRoot: string,\n protected port: number,\n options: {\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL */\n getExpoGoUrl: () => string;\n /** Get redirect URL for native disambiguation. */\n getRedirectUrl: () => string | null;\n /** Dev Client URL. */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n }\n ) {\n super(projectRoot, {\n platform: 'android',\n ...options,\n resolveDeviceAsync: AndroidDeviceManager.resolveAsync,\n });\n\n this.hasDevClientInstalled = memoize(hasDirectDevClientDependency.bind(this, projectRoot));\n }\n\n async openAsync(\n options:\n | { runtime: 'expo' | 'web' }\n | { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> },\n resolveSettings?: Partial<BaseResolveDeviceProps<Device>>\n ): Promise<{ url: string }> {\n await startAdbReverseAsync([this.port]);\n\n if (options.runtime === 'custom') {\n // Store the resolved launch properties for future \"openAsync\" request.\n // This reuses the same launch properties when opening through the CLI interface (pressing `a`).\n if (options.props) {\n this.lastCustomRuntimeLaunchProps = options.props;\n } else if (!options.props && this.lastCustomRuntimeLaunchProps) {\n options.props = this.lastCustomRuntimeLaunchProps;\n }\n\n // Handle projects that need to launch with a custom app id and launch activity\n return this.openProjectInCustomRuntimeWithCustomAppIdAsync(options, resolveSettings);\n }\n\n return super.openAsync(options, resolveSettings);\n }\n\n /**\n * Launch the custom runtime project, using the provided custom app id and launch activity.\n * Instead of \"open url\", this will launch the activity directly.\n * If dev client is installed, it will also pass the dev client URL to the activity.\n */\n async openProjectInCustomRuntimeWithCustomAppIdAsync(\n options: { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> },\n resolveSettings?: Partial<BaseResolveDeviceProps<Device>>\n ) {\n // Fall back to default dev client URL open behavior if no custom app id or launch activity is provided\n if (!options.props?.customAppId || !options.props?.launchActivity) {\n return super.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n }\n\n const { customAppId, launchActivity } = options.props;\n const url = this.hasDevClientInstalled()\n ? (this.props.getCustomRuntimeUrl({ scheme: options.props.scheme }) ?? undefined)\n : undefined;\n\n debug(`Opening custom runtime using launch activity: ${launchActivity} --`, options.props);\n\n const deviceManager = (await this.props.resolveDeviceAsync(\n resolveSettings\n )) as AndroidDeviceManager;\n\n if (!(await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(customAppId))) {\n throw new CommandError(\n `No development build (${customAppId}) for this project is installed. ` +\n `Install a development build on the target device and try again.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n deviceManager.logOpeningUrl(url ?? launchActivity);\n await deviceManager.activateWindowAsync();\n await deviceManager.launchActivityAsync(launchActivity, url);\n\n return { url: url ?? launchActivity };\n }\n\n _getAppIdResolver(): AppIdResolver {\n return new AndroidAppIdResolver(this.projectRoot);\n }\n\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props?: Partial<AndroidOpenInCustomProps>\n ): string {\n return props?.launchActivity ?? `${applicationId}/.MainActivity`;\n }\n}\n"],"names":["AndroidPlatformManager","debug","require","PlatformManager","constructor","projectRoot","port","options","platform","resolveDeviceAsync","AndroidDeviceManager","resolveAsync","hasDevClientInstalled","memoize","hasDirectDevClientDependency","bind","openAsync","resolveSettings","startAdbReverseAsync","runtime","props","lastCustomRuntimeLaunchProps","openProjectInCustomRuntimeWithCustomAppIdAsync","customAppId","launchActivity","openProjectInCustomRuntimeAsync","url","getCustomRuntimeUrl","scheme","undefined","deviceManager","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","CommandError","learnMore","logOpeningUrl","activateWindowAsync","launchActivityAsync","_getAppIdResolver","AndroidAppIdResolver","_resolveAlternativeLaunchUrl","applicationId"],"mappings":";;;;+BA4BaA;;;eAAAA;;;sCA5BwB;sCACA;4BAEA;wBACR;oBACL;sBACE;iCACmB;iCAEkC;AAE/E,MAAMC,QAAQC,QAAQ,SACpB;AAgBK,MAAMF,+BAA+BG,gCAAe;IAMzDC,YACE,AAAUC,WAAmB,EAC7B,AAAUC,IAAY,EACtBC,OASC,CACD;QACA,KAAK,CAACF,aAAa;YACjBG,UAAU;YACV,GAAGD,OAAO;YACVE,oBAAoBC,0CAAoB,CAACC,YAAY;Q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AiB,MAAM,IAAI,CAACV,KAAK,CAACX,kBAAkB,CACxDQ;QAGF,IAAI,CAAE,MAAMa,cAAcC,mDAAmD,CAACR,cAAe;YAC3F,MAAM,IAAIS,oBAAY,CACpB,CAAC,sBAAsB,EAAET,YAAY,iCAAiC,CAAC,GACrE,CAAC,iEAAiE,EAAEU,IAAAA,eAAS,EAC3E,6CACC;QAET;QAEAH,cAAcI,aAAa,CAACR,OAAOF;QACnC,MAAMM,cAAcK,mBAAmB;QACvC,MAAML,cAAcM,mBAAmB,CAACZ,gBAAgBE;QAExD,OAAO;YAAEA,KAAKA,OAAOF;QAAe;IACtC;IAEAa,oBAAmC;QACjC,OAAO,IAAIC,0CAAoB,CAAC,IAAI,CAACjC,WAAW;IAClD;IAEAkC,6BACEC,aAAqB,EACrBpB,KAAyC,EACjC;QACR,OAAOA,CAAAA,yBAAAA,MAAOI,cAAc,KAAI,GAAGgB,cAAc,cAAc,CAAC;IAClE;AACF"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/android/AndroidPlatformManager.ts"],"sourcesContent":["import { AndroidAppIdResolver } from './AndroidAppIdResolver';\nimport { AndroidDeviceManager } from './AndroidDeviceManager';\nimport { Device } from './adb';\nimport { startAdbReverseAsync } from './adbReverse';\nimport { CommandError } from '../../../utils/errors';\nimport { memoize } from '../../../utils/fn';\nimport { learnMore } from '../../../utils/link';\nimport { hasDirectDevClientDependency } from '../../detectDevClient';\nimport { AppIdResolver } from '../AppIdResolver';\nimport { BaseOpenInCustomProps, BaseResolveDeviceProps, PlatformManager } from '../PlatformManager';\n\nconst debug = require('debug')(\n 'expo:start:platforms:platformManager:android'\n) as typeof console.log;\n\nexport interface AndroidOpenInCustomProps extends BaseOpenInCustomProps {\n /**\n * The Android app intent to launch through `adb shell am start -n <launchActivity>`.\n */\n launchActivity?: string;\n /**\n * The custom app id to launch, provided through `--app-id`.\n * By default, the app id is identical to the package name.\n * When using product flavors, the app id might be customized.\n */\n customAppId?: string;\n}\n\nexport class AndroidPlatformManager extends PlatformManager<Device, AndroidOpenInCustomProps> {\n /** The last used custom launch props, should be reused whenever launching custom runtime without launch props */\n private lastCustomRuntimeLaunchProps?: AndroidOpenInCustomProps;\n /** Memoized method to detect if dev client is installed */\n private hasDevClientInstalled: () => boolean;\n\n constructor(\n protected projectRoot: string,\n protected port: number,\n options: {\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL */\n getExpoGoUrl: () => string;\n /** Get redirect URL for native disambiguation. */\n getRedirectUrl: () => string | null;\n /** Dev Client URL. */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n }\n ) {\n super(projectRoot, {\n platform: 'android',\n ...options,\n resolveDeviceAsync: AndroidDeviceManager.resolveAsync,\n });\n\n this.hasDevClientInstalled = memoize(hasDirectDevClientDependency.bind(this, projectRoot));\n }\n\n async openAsync(\n options:\n | { runtime: 'expo' | 'web' }\n | { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> },\n resolveSettings?: BaseResolveDeviceProps<Device>\n ): Promise<{ url: string }> {\n await startAdbReverseAsync([this.port]);\n\n if (options.runtime === 'custom') {\n // Store the resolved launch properties for future \"openAsync\" request.\n // This reuses the same launch properties when opening through the CLI interface (pressing `a`).\n if (options.props) {\n this.lastCustomRuntimeLaunchProps = options.props;\n } else if (!options.props && this.lastCustomRuntimeLaunchProps) {\n options.props = this.lastCustomRuntimeLaunchProps;\n }\n\n // Handle projects that need to launch with a custom app id and launch activity\n return this.openProjectInCustomRuntimeWithCustomAppIdAsync(options, resolveSettings);\n }\n\n return super.openAsync(options, resolveSettings);\n }\n\n /**\n * Launch the custom runtime project, using the provided custom app id and launch activity.\n * Instead of \"open url\", this will launch the activity directly.\n * If dev client is installed, it will also pass the dev client URL to the activity.\n */\n async openProjectInCustomRuntimeWithCustomAppIdAsync(\n options: { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> },\n resolveSettings?: Partial<BaseResolveDeviceProps<Device>>\n ) {\n // Fall back to default dev client URL open behavior if no custom app id or launch activity is provided\n if (!options.props?.customAppId || !options.props?.launchActivity) {\n return super.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n }\n\n const { customAppId, launchActivity } = options.props;\n const url = this.hasDevClientInstalled()\n ? (this.props.getCustomRuntimeUrl({ scheme: options.props.scheme }) ?? undefined)\n : undefined;\n\n debug(`Opening custom runtime using launch activity: ${launchActivity} --`, options.props);\n\n const deviceManager = (await this.props.resolveDeviceAsync(\n resolveSettings\n )) as AndroidDeviceManager;\n\n if (!(await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(customAppId))) {\n throw new CommandError(\n `No development build (${customAppId}) for this project is installed. ` +\n `Install a development build on the target device and try again.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n deviceManager.logOpeningUrl(url ?? launchActivity);\n await deviceManager.activateWindowAsync();\n await deviceManager.launchActivityAsync(launchActivity, url);\n\n return { url: url ?? launchActivity };\n }\n\n _getAppIdResolver(): AppIdResolver {\n return new AndroidAppIdResolver(this.projectRoot);\n }\n\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props?: Partial<AndroidOpenInCustomProps>\n ): string {\n return props?.launchActivity ?? `${applicationId}/.MainActivity`;\n }\n}\n"],"names":["AndroidPlatformManager","debug","require","PlatformManager","constructor","projectRoot","port","options","platform","resolveDeviceAsync","AndroidDeviceManager","resolveAsync","hasDevClientInstalled","memoize","hasDirectDevClientDependency","bind","openAsync","resolveSettings","startAdbReverseAsync","runtime","props","lastCustomRuntimeLaunchProps","openProjectInCustomRuntimeWithCustomAppIdAsync","customAppId","launchActivity","openProjectInCustomRuntimeAsync","url","getCustomRuntimeUrl","scheme","undefined","deviceManager","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","CommandError","learnMore","logOpeningUrl","activateWindowAsync","launchActivityAsync","_getAppIdResolver","AndroidAppIdResolver","_resolveAlternativeLaunchUrl","applicationId"],"mappings":";;;;+BA4BaA;;;eAAA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AEC,cAAc,EAAE,GAAGjB,QAAQa,KAAK;QACrD,MAAMM,MAAM,IAAI,CAACd,qBAAqB,KACjC,IAAI,CAACQ,KAAK,CAACO,mBAAmB,CAAC;YAAEC,QAAQrB,QAAQa,KAAK,CAACQ,MAAM;QAAC,MAAMC,YACrEA;QAEJ5B,MAAM,CAAC,8CAA8C,EAAEuB,eAAe,GAAG,CAAC,EAAEjB,QAAQa,KAAK;QAEzF,MAAMU,gBAAiB,MAAM,IAAI,CAACV,KAAK,CAACX,kBAAkB,CACxDQ;QAGF,IAAI,CAAE,MAAMa,cAAcC,mDAAmD,CAACR,cAAe;YAC3F,MAAM,IAAIS,oBAAY,CACpB,CAAC,sBAAsB,EAAET,YAAY,iCAAiC,CAAC,GACrE,CAAC,iEAAiE,EAAEU,IAAAA,eAAS,EAC3E,6CACC;QAET;QAEAH,cAAcI,aAAa,CAACR,OAAOF;QACnC,MAAMM,cAAcK,mBAAmB;QACvC,MAAML,cAAcM,mBAAmB,CAACZ,gBAAgBE;QAExD,OAAO;YAAEA,KAAKA,OAAOF;QAAe;IACtC;IAEAa,oBAAmC;QACjC,OAAO,IAAIC,0CAAoB,CAAC,IAAI,CAACjC,WAAW;IAClD;IAEAkC,6BACEC,aAAqB,EACrBpB,KAAyC,EACjC;QACR,OAAOA,CAAAA,yBAAAA,MAAOI,cAAc,KAAI,GAAGgB,cAAc,cAAc,CAAC;IAClE;AACF"}
@@ -15,6 +15,9 @@ _export(exports, {
15
15
  adbArgs: function() {
16
16
  return adbArgs;
17
17
  },
18
+ adbShellArgs: function() {
19
+ return adbShellArgs;
20
+ },
18
21
  getAdbNameForDeviceIdAsync: function() {
19
22
  return getAdbNameForDeviceIdAsync;
20
23
  },
@@ -162,7 +165,7 @@ function logUnauthorized(device) {
162
165
  _log.warn(`\nThis computer is not authorized for developing on ${_chalk().default.bold(device.name)}. ${_chalk().default.dim((0, _link.learnMore)('https://expo.fyi/authorize-android-device'))}`);
163
166
  }
164
167
  async function isPackageInstalledAsync(device, androidPackage) {
165
- const packages = await getServer().runAsync(adbArgs(device.pid, 'shell', 'pm', 'list', 'packages', '--user', _env.env.EXPO_ADB_USER, androidPackage));
168
+ const packages = await getServer().runAsync(adbShellArgs(device.pid, 'pm', 'list', 'packages', '--user', _env.env.EXPO_ADB_USER, androidPackage));
166
169
  const lines = packages.split(/\r?\n/);
167
170
  for(let i = 0; i < lines.length; i++){
168
171
  const line = lines[i].trim();
@@ -173,8 +176,7 @@ async function isPackageInstalledAsync(device, androidPackage) {
173
176
  return false;
174
177
  }
175
178
  async function launchActivityAsync(device, { launchActivity, url }) {
176
- const args = [
177
- 'shell',
179
+ const command = [
178
180
  'am',
179
181
  'start',
180
182
  // FLAG_ACTIVITY_SINGLE_TOP -- If set, the activity will not be launched if it is already running at the top of the history stack.
@@ -185,16 +187,15 @@ async function launchActivityAsync(device, { launchActivity, url }) {
185
187
  launchActivity
186
188
  ];
187
189
  if (url) {
188
- args.push('-d', url);
190
+ command.push('-d', url);
189
191
  }
190
- return openAsync(adbArgs(device.pid, ...args));
192
+ return openAsync(adbShellArgs(device.pid, ...command));
191
193
  }
192
194
  async function openAppIdAsync(device, { applicationId }) {
193
195
  return openAsync(adbArgs(device.pid, 'shell', 'monkey', '-p', applicationId, '-c', 'android.intent.category.LAUNCHER', '1'));
194
196
  }
195
197
  async function openUrlAsync(device, { url }) {
196
- return openAsync(adbArgs(device.pid, 'shell', 'am', 'start', '-a', 'android.intent.action.VIEW', '-d', // ADB requires ampersands to be escaped.
197
- url.replace(/&/g, String.raw`\&`)));
198
+ return openAsync(adbShellArgs(device.pid, 'am', 'start', '-a', 'android.intent.action.VIEW', '-d', url));
198
199
  }
199
200
  /** Runs a generic command watches for common errors in order to throw with an expected code. */ async function openAsync(args) {
200
201
  const results = await getServer().runAsync(args);
@@ -207,7 +208,7 @@ async function uninstallAsync(device, { appId }) {
207
208
  return await getServer().runAsync(adbArgs(device.pid, 'uninstall', '--user', _env.env.EXPO_ADB_USER, appId));
208
209
  }
209
210
  async function getPackageInfoAsync(device, { appId }) {
210
- return await getServer().runAsync(adbArgs(device.pid, 'shell', 'dumpsys', 'package', appId));
211
+ return await getServer().runAsync(adbShellArgs(device.pid, 'dumpsys', 'package', appId));
211
212
  }
212
213
  async function installAsync(device, { filePath }) {
213
214
  // TODO: Handle the `INSTALL_FAILED_INSUFFICIENT_STORAGE` error.
@@ -220,6 +221,12 @@ function adbArgs(pid, ...options) {
220
221
  }
221
222
  return args.concat(options);
222
223
  }
224
+ function adbShellArgs(pid, ...command) {
225
+ return adbArgs(pid, 'shell', ...command.map(shellQuote));
226
+ }
227
+ function shellQuote(value) {
228
+ return `'${value.replace(/'/g, `'\\''`)}'`;
229
+ }
223
230
  async function getAttachedDevicesAsync() {
224
231
  const output = await getServer().runAsync([
225
232
  'devices',
@@ -331,13 +338,7 @@ async function getDeviceABIsAsync(device) {
331
338
  ];
332
339
  }
333
340
  async function getPropertyDataForDeviceAsync(device, prop) {
334
- // @ts-ignore
335
- const propCommand = adbArgs(...[
336
- device.pid,
337
- 'shell',
338
- 'getprop',
339
- prop
340
- ].filter(Boolean));
341
+ const propCommand = prop ? adbShellArgs(device.pid, 'getprop', prop) : adbShellArgs(device.pid, 'getprop');
341
342
  try {
342
343
  // Prevent reading as UTF8.
343
344
  const results = await getServer().getFileOutputAsync(propCommand);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/android/adb.ts"],"sourcesContent":["import chalk from 'chalk';\nimport os from 'os';\n\nimport { ADBServer } from './ADBServer';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { learnMore } from '../../../utils/link';\n\nconst debug = require('debug')('expo:start:platforms:android:adb') as typeof console.log;\n\nexport enum DeviceABI {\n // The arch specific android target platforms are soft-deprecated.\n // Instead of using TargetPlatform as a combination arch + platform\n // the code will be updated to carry arch information in [DarwinArch]\n // and [AndroidArch].\n arm = 'arm',\n arm64 = 'arm64',\n x64 = 'x64',\n x86 = 'x86',\n x8664 = 'x86_64',\n arm64v8a = 'arm64-v8a',\n armeabiV7a = 'armeabi-v7a',\n armeabi = 'armeabi',\n universal = 'universal',\n}\n\n/** Represents a connected Android device. */\nexport type Device = {\n /** Process ID. */\n pid?: string;\n /** Name of the device, also used as the ID for opening devices. */\n name: string;\n /** Is emulator or connected device. */\n type: 'emulator' | 'device';\n /** Is the device booted (emulator). */\n isBooted: boolean;\n /** Is device authorized for developing. https://expo.fyi/authorize-android-device */\n isAuthorized: boolean;\n /** The connection type to ADB, only available when `type: device` */\n connectionType?: 'USB' | 'Network';\n};\n\ntype DeviceContext = Pick<Device, 'pid'>;\n\ntype DeviceProperties = Record<string, string>;\n\nconst CANT_START_ACTIVITY_ERROR = 'Activity not started, unable to resolve Intent';\n// http://developer.android.com/ndk/guides/abis.html\nconst PROP_CPU_NAME = 'ro.product.cpu.abi';\n\nconst PROP_CPU_ABI_LIST_NAME = 'ro.product.cpu.abilist';\n\n// Can sometimes be null\n// http://developer.android.com/ndk/guides/abis.html\nconst PROP_BOOT_ANIMATION_STATE = 'init.svc.bootanim';\n\nlet _server: ADBServer | null;\n\n/** Return the lazily loaded ADB server instance. */\nexport function getServer() {\n _server ??= new ADBServer();\n return _server;\n}\n\n/** Logs an FYI message about authorizing your device. */\nexport function logUnauthorized(device: Device) {\n Log.warn(\n `\\nThis computer is not authorized for developing on ${chalk.bold(device.name)}. ${chalk.dim(\n learnMore('https://expo.fyi/authorize-android-device')\n )}`\n );\n}\n\n/** Returns true if the provided package name is installed on the provided Android device. */\nexport async function isPackageInstalledAsync(\n device: DeviceContext,\n androidPackage: string\n): Promise<boolean> {\n const packages = await getServer().runAsync(\n adbArgs(\n device.pid,\n 'shell',\n 'pm',\n 'list',\n 'packages',\n '--user',\n env.EXPO_ADB_USER,\n androidPackage\n )\n );\n\n const lines = packages.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trim();\n if (line === `package:${androidPackage}`) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * @param device.pid Process ID of the Android device to launch.\n * @param props.launchActivity Activity to launch `[application identifier]/.[main activity name]`, ex: `com.bacon.app/.MainActivity`\n * @param props.url Optional (dev client) URL to launch\n */\nexport async function launchActivityAsync(\n device: DeviceContext,\n {\n launchActivity,\n url,\n }: {\n launchActivity: string;\n url?: string;\n }\n) {\n const args: string[] = [\n 'shell',\n 'am',\n 'start',\n // FLAG_ACTIVITY_SINGLE_TOP -- If set, the activity will not be launched if it is already running at the top of the history stack.\n '-f',\n '0x20000000',\n // Activity to open first: com.bacon.app/.MainActivity\n '-n',\n launchActivity,\n ];\n\n if (url) {\n args.push('-d', url);\n }\n\n return openAsync(adbArgs(device.pid, ...args));\n}\n\n/**\n * @param device.pid Process ID of the Android device to launch.\n * @param props.applicationId package name to launch.\n */\nexport async function openAppIdAsync(\n device: DeviceContext,\n {\n applicationId,\n }: {\n applicationId: string;\n }\n) {\n return openAsync(\n adbArgs(\n device.pid,\n 'shell',\n 'monkey',\n '-p',\n applicationId,\n '-c',\n 'android.intent.category.LAUNCHER',\n '1'\n )\n );\n}\n\n/**\n * @param device.pid Process ID of the Android device to launch.\n * @param props.url URL to launch.\n */\nexport async function openUrlAsync(\n device: DeviceContext,\n {\n url,\n }: {\n url: string;\n }\n) {\n return openAsync(\n adbArgs(\n device.pid,\n 'shell',\n 'am',\n 'start',\n '-a',\n 'android.intent.action.VIEW',\n '-d',\n // ADB requires ampersands to be escaped.\n url.replace(/&/g, String.raw`\\&`)\n )\n );\n}\n\n/** Runs a generic command watches for common errors in order to throw with an expected code. */\nasync function openAsync(args: string[]): Promise<string> {\n const results = await getServer().runAsync(args);\n if (\n results.includes(CANT_START_ACTIVITY_ERROR) ||\n results.match(/Error: Activity class .* does not exist\\./g)\n ) {\n throw new CommandError('APP_NOT_INSTALLED', results.substring(results.indexOf('Error: ')));\n }\n return results;\n}\n\n/** Uninstall an app given its Android package name. */\nexport async function uninstallAsync(\n device: DeviceContext,\n { appId }: { appId: string }\n): Promise<string> {\n return await getServer().runAsync(\n adbArgs(device.pid, 'uninstall', '--user', env.EXPO_ADB_USER, appId)\n );\n}\n\n/** Get package info from an app based on its Android package name. */\nexport async function getPackageInfoAsync(\n device: DeviceContext,\n { appId }: { appId: string }\n): Promise<string> {\n return await getServer().runAsync(adbArgs(device.pid, 'shell', 'dumpsys', 'package', appId));\n}\n\n/** Install an app on a connected device. */\nexport async function installAsync(device: DeviceContext, { filePath }: { filePath: string }) {\n // TODO: Handle the `INSTALL_FAILED_INSUFFICIENT_STORAGE` error.\n return await getServer().runAsync(\n adbArgs(device.pid, 'install', '-r', '-d', '--user', env.EXPO_ADB_USER, filePath)\n );\n}\n\n/** Format ADB args with process ID. */\nexport function adbArgs(pid: Device['pid'], ...options: string[]): string[] {\n const args = [];\n if (pid) {\n args.push('-s', pid);\n }\n\n return args.concat(options);\n}\n\n// TODO: This is very expensive for some operations.\nexport async function getAttachedDevicesAsync(): Promise<Device[]> {\n const output = await getServer().runAsync(['devices', '-l']);\n\n const splitItems = output\n .trim()\n .replace(/\\n$/, '')\n .split(os.EOL)\n // Filter ADB trace logs from the output, e.g.\n // adb D 03-06 15:25:53 63677 4018815 adb_client.cpp:393] adb_query: host:devices-l\n // 03-04 12:29:44.557 16415 16415 D adb : commandline.cpp:1646 Using server socket: tcp:172.27.192.1:5037\n // 03-04 12:29:44.557 16415 16415 D adb : adb_client.cpp:160 _adb_connect: host:version\n .filter((line) => !line.match(/\\.cpp:[0-9]+/));\n\n // First line is `\"List of devices attached\"`, remove it\n // @ts-ignore: todo\n const attachedDevices: {\n props: string[];\n type: Device['type'];\n isAuthorized: Device['isAuthorized'];\n isBooted: Device['isBooted'];\n connectionType?: Device['connectionType'];\n }[] = splitItems\n .slice(1, splitItems.length)\n .map((line) => {\n // unauthorized: ['FA8251A00719', 'unauthorized', 'usb:338690048X', 'transport_id:5']\n // authorized: ['FA8251A00719', 'device', 'usb:336592896X', 'product:walleye', 'model:Pixel_2', 'device:walleye', 'transport_id:4']\n // emulator: ['emulator-5554', 'offline', 'transport_id:1']\n const props = line.split(' ').filter(Boolean);\n const type = line.includes('emulator') ? 'emulator' : 'device';\n\n let connectionType;\n if (type === 'device' && line.includes('usb:')) {\n connectionType = 'USB';\n } else if (type === 'device' && line.includes('_adb-tls-connect.')) {\n connectionType = 'Network';\n }\n\n const isBooted = type === 'emulator' || props[1] !== 'offline';\n const isAuthorized =\n connectionType === 'Network'\n ? line.includes('model:') // Network connected devices show `model:<name>` when authorized\n : props[1] !== 'unauthorized';\n\n return { props, type, isAuthorized, isBooted, connectionType };\n })\n .filter(({ props: [pid] }) => !!pid);\n\n const devicePromises = attachedDevices.map<Promise<Device>>(async (props) => {\n const {\n type,\n props: [pid, ...deviceInfo],\n isAuthorized,\n isBooted,\n } = props;\n\n let name: string | null = null;\n\n if (type === 'device') {\n if (isAuthorized) {\n // Possibly formatted like `model:Pixel_2`\n // Transform to `Pixel_2`\n const modelItem = deviceInfo.find((info) => info.includes('model:'));\n if (modelItem) {\n name = modelItem.replace('model:', '');\n }\n }\n // unauthorized devices don't have a name available to read\n if (!name) {\n // Device FA8251A00719\n name = `Device ${pid}`;\n }\n } else {\n // Given an emulator pid, get the emulator name which can be used to start the emulator later.\n name = (await getAdbNameForDeviceIdAsync({ pid })) ?? '';\n }\n\n return props.connectionType\n ? { pid, name, type, isAuthorized, isBooted, connectionType: props.connectionType }\n : { pid, name, type, isAuthorized, isBooted };\n });\n\n return Promise.all(devicePromises);\n}\n\n/**\n * Return the Emulator name for an emulator ID, this can be used to determine if an emulator is booted.\n *\n * @param device.pid a value like `emulator-5554` from `abd devices`\n */\nexport async function getAdbNameForDeviceIdAsync(device: DeviceContext): Promise<string | null> {\n const results = await getServer().runAsync(adbArgs(device.pid, 'emu', 'avd', 'name'));\n\n if (results.match(/could not connect to TCP port .*: Connection refused/)) {\n // Can also occur when the emulator does not exist.\n throw new CommandError('EMULATOR_NOT_FOUND', results);\n }\n\n return sanitizeAdbDeviceName(results) ?? null;\n}\n\nexport async function isDeviceBootedAsync({\n name,\n}: { name?: string } = {}): Promise<Device | null> {\n const devices = await getAttachedDevicesAsync();\n\n if (!name) {\n return devices[0] ?? null;\n }\n\n return devices.find((device) => device.name === name) ?? null;\n}\n\n/**\n * Returns true when a device's splash screen animation has stopped.\n * This can be used to detect when a device is fully booted and ready to use.\n *\n * @param pid\n */\nexport async function isBootAnimationCompleteAsync(pid?: string): Promise<boolean> {\n try {\n const props = await getPropertyDataForDeviceAsync({ pid }, PROP_BOOT_ANIMATION_STATE);\n return !!props[PROP_BOOT_ANIMATION_STATE].match(/stopped/);\n } catch {\n return false;\n }\n}\n\n/** Get a list of ABIs for the provided device. */\nexport async function getDeviceABIsAsync(\n device: Pick<Device, 'name' | 'pid'>\n): Promise<DeviceABI[]> {\n const cpuAbiList = (await getPropertyDataForDeviceAsync(device, PROP_CPU_ABI_LIST_NAME))[\n PROP_CPU_ABI_LIST_NAME\n ];\n\n if (cpuAbiList) {\n return cpuAbiList.trim().split(',') as DeviceABI[];\n }\n\n const abi = (await getPropertyDataForDeviceAsync(device, PROP_CPU_NAME))[\n PROP_CPU_NAME\n ] as DeviceABI;\n return [abi];\n}\n\nexport async function getPropertyDataForDeviceAsync(\n device: DeviceContext,\n prop?: string\n): Promise<DeviceProperties> {\n // @ts-ignore\n const propCommand = adbArgs(...[device.pid, 'shell', 'getprop', prop].filter(Boolean));\n try {\n // Prevent reading as UTF8.\n const results = await getServer().getFileOutputAsync(propCommand);\n // Like:\n // [wifi.direct.interface]: [p2p-dev-wlan0]\n // [wifi.interface]: [wlan0]\n\n if (prop) {\n debug(`Property data: (device pid: ${device.pid}, prop: ${prop}, data: ${results})`);\n return {\n [prop]: results,\n };\n }\n const props = parseAdbDeviceProperties(results);\n\n debug(`Parsed data:`, props);\n\n return props;\n } catch (error: any) {\n // TODO: Ensure error has message and not stderr\n throw new CommandError(`Failed to get properties for device (${device.pid}): ${error.message}`);\n }\n}\n\nfunction parseAdbDeviceProperties(devicePropertiesString: string) {\n const properties: DeviceProperties = {};\n const propertyExp = /\\[(.*?)\\]: \\[(.*?)\\]/gm;\n for (const match of devicePropertiesString.matchAll(propertyExp)) {\n properties[match[1]] = match[2];\n }\n return properties;\n}\n\n/**\n * Sanitize the ADB device name to only get the actual device name.\n * On Windows, we need to do \\r, \\n, and \\r\\n filtering to get the name.\n */\nexport function sanitizeAdbDeviceName(deviceName: string) {\n return deviceName\n .trim()\n .split(/[\\r\\n]+/)\n .shift();\n}\n"],"names":["DeviceABI","adbArgs","getAdbNameForDeviceIdAsync","getAttachedDevicesAsync","getDeviceABIsAsync","getPackageInfoAsync","getPropertyDataForDeviceAsync","getServer","installAsync","isBootAnimationCompleteAsync","isDeviceBootedAsync","isPackageInstalledAsync","launchActivityAsync","logUnauthorized","openAppIdAsync","openUrlAsync","sanitizeAdbDeviceName","uninstallAsync","debug","require","CANT_START_ACTIVITY_ERROR","PROP_CPU_NAME","PROP_CPU_ABI_LIST_NAME","PROP_BOOT_ANIMATION_STATE","_server","ADBServer","device","Log","warn","chalk","bold","name","dim","learnMore","androidPackage","packages","runAsync","pid","env","EXPO_ADB_USER","lines","split","i","length","line","trim","launchActivity","url","args","push","openAsync","applicationId","replace","String","raw","results","includes","match","CommandError","substring","indexOf","appId","filePath","options","concat","output","splitItems","os","EOL","filter","attachedDevices","slice","map","props","Boolean","type","connectionType","isBooted","isAuthorized","devicePromises","deviceInfo","modelItem","find","info","Promise","all","devices","cpuAbiList","abi","prop","propCommand","getFileOutputAsync","parseAdbDeviceProperties","error","message","devicePropertiesString","properties","propertyExp","matchAll","deviceName","shift"],"mappings":";;;;;;;;;;;IAWYA,SAAS;eAATA;;IAyNIC,OAAO;eAAPA;;IAmGMC,0BAA0B;eAA1BA;;IAzFAC,uBAAuB;eAAvBA;;IAgIAC,kBAAkB;eAAlBA;;IA1JAC,mBAAmB;eAAnBA;;IA2KAC,6BAA6B;eAA7BA;;IAnUNC,SAAS;eAATA;;IAgKMC,YAAY;eAA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C,QAAQ,CAAC,CAAC;YACnF,OAAO;gBACL,CAACkC,KAAK,EAAElC;YACV;QACF;QACA,MAAMkB,QAAQmB,yBAAyBrC;QAEvCrC,MAAM,CAAC,YAAY,CAAC,EAAEuD;QAEtB,OAAOA;IACT,EAAE,OAAOoB,OAAY;QACnB,gDAAgD;QAChD,MAAM,IAAInC,oBAAY,CAAC,CAAC,qCAAqC,EAAEhC,OAAOW,GAAG,CAAC,GAAG,EAAEwD,MAAMC,OAAO,EAAE;IAChG;AACF;AAEA,SAASF,yBAAyBG,sBAA8B;IAC9D,MAAMC,aAA+B,CAAC;IACtC,MAAMC,cAAc;IACpB,KAAK,MAAMxC,SAASsC,uBAAuBG,QAAQ,CAACD,aAAc;QAChED,UAAU,CAACvC,KAAK,CAAC,EAAE,CAAC,GAAGA,KAAK,CAAC,EAAE;IACjC;IACA,OAAOuC;AACT;AAMO,SAAShF,sBAAsBmF,UAAkB;IACtD,OAAOA,WACJtD,IAAI,GACJJ,KAAK,CAAC,WACN2D,KAAK;AACV"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/android/adb.ts"],"sourcesContent":["import chalk from 'chalk';\nimport os from 'os';\n\nimport { ADBServer } from './ADBServer';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { learnMore } from '../../../utils/link';\n\nconst debug = require('debug')('expo:start:platforms:android:adb') as typeof console.log;\n\nexport enum DeviceABI {\n // The arch specific android target platforms are soft-deprecated.\n // Instead of using TargetPlatform as a combination arch + platform\n // the code will be updated to carry arch information in [DarwinArch]\n // and [AndroidArch].\n arm = 'arm',\n arm64 = 'arm64',\n x64 = 'x64',\n x86 = 'x86',\n x8664 = 'x86_64',\n arm64v8a = 'arm64-v8a',\n armeabiV7a = 'armeabi-v7a',\n armeabi = 'armeabi',\n universal = 'universal',\n}\n\n/** Represents a connected Android device. */\nexport type Device = {\n /** Process ID. */\n pid?: string;\n /** Name of the device, also used as the ID for opening devices. */\n name: string;\n /** Is emulator or connected device. */\n type: 'emulator' | 'device';\n /** Is the device booted (emulator). */\n isBooted: boolean;\n /** Is device authorized for developing. https://expo.fyi/authorize-android-device */\n isAuthorized: boolean;\n /** The connection type to ADB, only available when `type: device` */\n connectionType?: 'USB' | 'Network';\n};\n\ntype DeviceContext = Pick<Device, 'pid'>;\n\ntype DeviceProperties = Record<string, string>;\n\nconst CANT_START_ACTIVITY_ERROR = 'Activity not started, unable to resolve Intent';\n// http://developer.android.com/ndk/guides/abis.html\nconst PROP_CPU_NAME = 'ro.product.cpu.abi';\n\nconst PROP_CPU_ABI_LIST_NAME = 'ro.product.cpu.abilist';\n\n// Can sometimes be null\n// http://developer.android.com/ndk/guides/abis.html\nconst PROP_BOOT_ANIMATION_STATE = 'init.svc.bootanim';\n\nlet _server: ADBServer | null;\n\n/** Return the lazily loaded ADB server instance. */\nexport function getServer() {\n _server ??= new ADBServer();\n return _server;\n}\n\n/** Logs an FYI message about authorizing your device. */\nexport function logUnauthorized(device: Device) {\n Log.warn(\n `\\nThis computer is not authorized for developing on ${chalk.bold(device.name)}. ${chalk.dim(\n learnMore('https://expo.fyi/authorize-android-device')\n )}`\n );\n}\n\n/** Returns true if the provided package name is installed on the provided Android device. */\nexport async function isPackageInstalledAsync(\n device: DeviceContext,\n androidPackage: string\n): Promise<boolean> {\n const packages = await getServer().runAsync(\n adbShellArgs(device.pid, 'pm', 'list', 'packages', '--user', env.EXPO_ADB_USER, androidPackage)\n );\n\n const lines = packages.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trim();\n if (line === `package:${androidPackage}`) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * @param device.pid Process ID of the Android device to launch.\n * @param props.launchActivity Activity to launch `[application identifier]/.[main activity name]`, ex: `com.bacon.app/.MainActivity`\n * @param props.url Optional (dev client) URL to launch\n */\nexport async function launchActivityAsync(\n device: DeviceContext,\n {\n launchActivity,\n url,\n }: {\n launchActivity: string;\n url?: string;\n }\n) {\n const command: string[] = [\n 'am',\n 'start',\n // FLAG_ACTIVITY_SINGLE_TOP -- If set, the activity will not be launched if it is already running at the top of the history stack.\n '-f',\n '0x20000000',\n // Activity to open first: com.bacon.app/.MainActivity\n '-n',\n launchActivity,\n ];\n\n if (url) {\n command.push('-d', url);\n }\n\n return openAsync(adbShellArgs(device.pid, ...command));\n}\n\n/**\n * @param device.pid Process ID of the Android device to launch.\n * @param props.applicationId package name to launch.\n */\nexport async function openAppIdAsync(\n device: DeviceContext,\n {\n applicationId,\n }: {\n applicationId: string;\n }\n) {\n return openAsync(\n adbArgs(\n device.pid,\n 'shell',\n 'monkey',\n '-p',\n applicationId,\n '-c',\n 'android.intent.category.LAUNCHER',\n '1'\n )\n );\n}\n\n/**\n * @param device.pid Process ID of the Android device to launch.\n * @param props.url URL to launch.\n */\nexport async function openUrlAsync(\n device: DeviceContext,\n {\n url,\n }: {\n url: string;\n }\n) {\n return openAsync(\n adbShellArgs(device.pid, 'am', 'start', '-a', 'android.intent.action.VIEW', '-d', url)\n );\n}\n\n/** Runs a generic command watches for common errors in order to throw with an expected code. */\nasync function openAsync(args: string[]): Promise<string> {\n const results = await getServer().runAsync(args);\n if (\n results.includes(CANT_START_ACTIVITY_ERROR) ||\n results.match(/Error: Activity class .* does not exist\\./g)\n ) {\n throw new CommandError('APP_NOT_INSTALLED', results.substring(results.indexOf('Error: ')));\n }\n return results;\n}\n\n/** Uninstall an app given its Android package name. */\nexport async function uninstallAsync(\n device: DeviceContext,\n { appId }: { appId: string }\n): Promise<string> {\n return await getServer().runAsync(\n adbArgs(device.pid, 'uninstall', '--user', env.EXPO_ADB_USER, appId)\n );\n}\n\n/** Get package info from an app based on its Android package name. */\nexport async function getPackageInfoAsync(\n device: DeviceContext,\n { appId }: { appId: string }\n): Promise<string> {\n return await getServer().runAsync(adbShellArgs(device.pid, 'dumpsys', 'package', appId));\n}\n\n/** Install an app on a connected device. */\nexport async function installAsync(device: DeviceContext, { filePath }: { filePath: string }) {\n // TODO: Handle the `INSTALL_FAILED_INSUFFICIENT_STORAGE` error.\n return await getServer().runAsync(\n adbArgs(device.pid, 'install', '-r', '-d', '--user', env.EXPO_ADB_USER, filePath)\n );\n}\n\n/** Format ADB args with process ID. */\nexport function adbArgs(pid: Device['pid'], ...options: string[]): string[] {\n const args = [];\n if (pid) {\n args.push('-s', pid);\n }\n\n return args.concat(options);\n}\n\n/**\n * `adb shell` concatenates trailing args and runs the result through `sh -c` on\n * the device, so unquoted metacharacters in tainted tokens execute on-device.\n */\nexport function adbShellArgs(pid: Device['pid'], ...command: string[]): string[] {\n return adbArgs(pid, 'shell', ...command.map(shellQuote));\n}\n\nfunction shellQuote(value: string): string {\n return `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\n// TODO: This is very expensive for some operations.\nexport async function getAttachedDevicesAsync(): Promise<Device[]> {\n const output = await getServer().runAsync(['devices', '-l']);\n\n const splitItems = output\n .trim()\n .replace(/\\n$/, '')\n .split(os.EOL)\n // Filter ADB trace logs from the output, e.g.\n // adb D 03-06 15:25:53 63677 4018815 adb_client.cpp:393] adb_query: host:devices-l\n // 03-04 12:29:44.557 16415 16415 D adb : commandline.cpp:1646 Using server socket: tcp:172.27.192.1:5037\n // 03-04 12:29:44.557 16415 16415 D adb : adb_client.cpp:160 _adb_connect: host:version\n .filter((line) => !line.match(/\\.cpp:[0-9]+/));\n\n // First line is `\"List of devices attached\"`, remove it\n // @ts-ignore: todo\n const attachedDevices: {\n props: string[];\n type: Device['type'];\n isAuthorized: Device['isAuthorized'];\n isBooted: Device['isBooted'];\n connectionType?: Device['connectionType'];\n }[] = splitItems\n .slice(1, splitItems.length)\n .map((line) => {\n // unauthorized: ['FA8251A00719', 'unauthorized', 'usb:338690048X', 'transport_id:5']\n // authorized: ['FA8251A00719', 'device', 'usb:336592896X', 'product:walleye', 'model:Pixel_2', 'device:walleye', 'transport_id:4']\n // emulator: ['emulator-5554', 'offline', 'transport_id:1']\n const props = line.split(' ').filter(Boolean);\n const type = line.includes('emulator') ? 'emulator' : 'device';\n\n let connectionType;\n if (type === 'device' && line.includes('usb:')) {\n connectionType = 'USB';\n } else if (type === 'device' && line.includes('_adb-tls-connect.')) {\n connectionType = 'Network';\n }\n\n const isBooted = type === 'emulator' || props[1] !== 'offline';\n const isAuthorized =\n connectionType === 'Network'\n ? line.includes('model:') // Network connected devices show `model:<name>` when authorized\n : props[1] !== 'unauthorized';\n\n return { props, type, isAuthorized, isBooted, connectionType };\n })\n .filter(({ props: [pid] }) => !!pid);\n\n const devicePromises = attachedDevices.map<Promise<Device>>(async (props) => {\n const {\n type,\n props: [pid, ...deviceInfo],\n isAuthorized,\n isBooted,\n } = props;\n\n let name: string | null = null;\n\n if (type === 'device') {\n if (isAuthorized) {\n // Possibly formatted like `model:Pixel_2`\n // Transform to `Pixel_2`\n const modelItem = deviceInfo.find((info) => info.includes('model:'));\n if (modelItem) {\n name = modelItem.replace('model:', '');\n }\n }\n // unauthorized devices don't have a name available to read\n if (!name) {\n // Device FA8251A00719\n name = `Device ${pid}`;\n }\n } else {\n // Given an emulator pid, get the emulator name which can be used to start the emulator later.\n name = (await getAdbNameForDeviceIdAsync({ pid })) ?? '';\n }\n\n return props.connectionType\n ? { pid, name, type, isAuthorized, isBooted, connectionType: props.connectionType }\n : { pid, name, type, isAuthorized, isBooted };\n });\n\n return Promise.all(devicePromises);\n}\n\n/**\n * Return the Emulator name for an emulator ID, this can be used to determine if an emulator is booted.\n *\n * @param device.pid a value like `emulator-5554` from `abd devices`\n */\nexport async function getAdbNameForDeviceIdAsync(device: DeviceContext): Promise<string | null> {\n const results = await getServer().runAsync(adbArgs(device.pid, 'emu', 'avd', 'name'));\n\n if (results.match(/could not connect to TCP port .*: Connection refused/)) {\n // Can also occur when the emulator does not exist.\n throw new CommandError('EMULATOR_NOT_FOUND', results);\n }\n\n return sanitizeAdbDeviceName(results) ?? null;\n}\n\nexport async function isDeviceBootedAsync({\n name,\n}: { name?: string } = {}): Promise<Device | null> {\n const devices = await getAttachedDevicesAsync();\n\n if (!name) {\n return devices[0] ?? null;\n }\n\n return devices.find((device) => device.name === name) ?? null;\n}\n\n/**\n * Returns true when a device's splash screen animation has stopped.\n * This can be used to detect when a device is fully booted and ready to use.\n *\n * @param pid\n */\nexport async function isBootAnimationCompleteAsync(pid?: string): Promise<boolean> {\n try {\n const props = await getPropertyDataForDeviceAsync({ pid }, PROP_BOOT_ANIMATION_STATE);\n return !!props[PROP_BOOT_ANIMATION_STATE].match(/stopped/);\n } catch {\n return false;\n }\n}\n\n/** Get a list of ABIs for the provided device. */\nexport async function getDeviceABIsAsync(\n device: Pick<Device, 'name' | 'pid'>\n): Promise<DeviceABI[]> {\n const cpuAbiList = (await getPropertyDataForDeviceAsync(device, PROP_CPU_ABI_LIST_NAME))[\n PROP_CPU_ABI_LIST_NAME\n ];\n\n if (cpuAbiList) {\n return cpuAbiList.trim().split(',') as DeviceABI[];\n }\n\n const abi = (await getPropertyDataForDeviceAsync(device, PROP_CPU_NAME))[\n PROP_CPU_NAME\n ] as DeviceABI;\n return [abi];\n}\n\nexport async function getPropertyDataForDeviceAsync(\n device: DeviceContext,\n prop?: string\n): Promise<DeviceProperties> {\n const propCommand = prop\n ? adbShellArgs(device.pid, 'getprop', prop)\n : adbShellArgs(device.pid, 'getprop');\n try {\n // Prevent reading as UTF8.\n const results = await getServer().getFileOutputAsync(propCommand);\n // Like:\n // [wifi.direct.interface]: [p2p-dev-wlan0]\n // [wifi.interface]: [wlan0]\n\n if (prop) {\n debug(`Property data: (device pid: ${device.pid}, prop: ${prop}, data: ${results})`);\n return {\n [prop]: results,\n };\n }\n const props = parseAdbDeviceProperties(results);\n\n debug(`Parsed data:`, props);\n\n return props;\n } catch (error: any) {\n // TODO: Ensure error has message and not stderr\n throw new CommandError(`Failed to get properties for device (${device.pid}): ${error.message}`);\n }\n}\n\nfunction parseAdbDeviceProperties(devicePropertiesString: string) {\n const properties: DeviceProperties = {};\n const propertyExp = /\\[(.*?)\\]: \\[(.*?)\\]/gm;\n for (const match of devicePropertiesString.matchAll(propertyExp)) {\n properties[match[1]] = match[2];\n }\n return properties;\n}\n\n/**\n * Sanitize the ADB device name to only get the actual device name.\n * On Windows, we need to do \\r, \\n, and \\r\\n filtering to get the name.\n */\nexport function sanitizeAdbDeviceName(deviceName: string) {\n return deviceName\n .trim()\n .split(/[\\r\\n]+/)\n .shift();\n}\n"],"names":["DeviceABI","adbArgs","adbShellArgs","getAdbNameForDeviceIdAsync","getAttachedDevicesAsync","getDeviceABIsAsync","getPackageInfoAsync","getPropertyDataForDeviceAsync","getServer","installAsync","isBootAnimationCompleteAsync","isDeviceBootedAsync","isPackageInstalledAsync","launchActivityAsync","logUnauthorized","openAppIdAsync","openUrlAsync","sanitizeAdbDeviceName","uninstallAsync","debug","require","CANT_START_ACTIVITY_ERROR","PROP_CPU_NAME","PROP_CPU_ABI_LIST_NAME","PROP_BOOT_ANIMATION_STATE","_server","ADBServer","device","Log","warn","chalk","bold","name","dim","learnMore","androidPackage","packages","runAsync","pid","env","EXPO_ADB_USER","lines","split","i","length","line","trim","launchActivity","url","command","push","openAsync","applicationId","args","results","includes","match","CommandError","substring","indexOf","appId","filePath","options","concat","map","shellQuote","value","replace","output","splitItems","os","EOL","filter","attachedDevices","slice","props","Boolean","type","connectionType","isBooted","isAuthorized","devicePromises","deviceInfo","modelItem","find","info","Promise","all","devices","cpuAbiList","abi","prop","propCommand","getFileOutputAsync","parseAdbDeviceProperties","error","message","devicePropertiesString","properties","propertyExp","matchAll","deviceName","shift"],"mappings":";;;;;;;;;;;IAWYA,SAAS;eAATA;;IAqMIC,OAAO;eAAPA;;IAaAC,YAAY;eAAZA;;IAkGMC,0BAA0B;eAA1BA;;IAzFAC,uBAAuB;eAAvBA;;IAgIAC,kBAAkB;eAAlBA;;IAtKAC,mBAAmB;eAAnBA;;IAuLAC,6BAA6B;eAA7BA;;IA3TNC,SAAS;eAATA;;IA4IMC,YAAY;eAAZA;;IAoJAC,4BAA4B;eAA5BA;;IAl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;QAC3C,4BAA4B;QAE5B,IAAID,MAAM;YACRxE,MAAM,CAAC,4BAA4B,EAAEQ,OAAOW,GAAG,CAAC,QAAQ,EAAEqD,KAAK,QAAQ,EAAErC,QAAQ,CAAC,CAAC;YACnF,OAAO;gBACL,CAACqC,KAAK,EAAErC;YACV;QACF;QACA,MAAMqB,QAAQmB,yBAAyBxC;QAEvCnC,MAAM,CAAC,YAAY,CAAC,EAAEwD;QAEtB,OAAOA;IACT,EAAE,OAAOoB,OAAY;QACnB,gDAAgD;QAChD,MAAM,IAAItC,oBAAY,CAAC,CAAC,qCAAqC,EAAE9B,OAAOW,GAAG,CAAC,GAAG,EAAEyD,MAAMC,OAAO,EAAE;IAChG;AACF;AAEA,SAASF,yBAAyBG,sBAA8B;IAC9D,MAAMC,aAA+B,CAAC;IACtC,MAAMC,cAAc;IACpB,KAAK,MAAM3C,SAASyC,uBAAuBG,QAAQ,CAACD,aAAc;QAChED,UAAU,CAAC1C,KAAK,CAAC,EAAE,CAAC,GAAGA,KAAK,CAAC,EAAE;IACjC;IACA,OAAO0C;AACT;AAMO,SAASjF,sBAAsBoF,UAAkB;IACtD,OAAOA,WACJvD,IAAI,GACJJ,KAAK,CAAC,WACN4D,KAAK;AACV"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/ios/ApplePlatformManager.ts"],"sourcesContent":["import { AppleAppIdResolver } from './AppleAppIdResolver';\nimport { AppleDeviceManager } from './AppleDeviceManager';\nimport { Device } from './simctl';\nimport { AppIdResolver } from '../AppIdResolver';\nimport { BaseOpenInCustomProps, PlatformManager } from '../PlatformManager';\n\n/** Manages launching apps on Apple simulators. */\nexport class ApplePlatformManager extends PlatformManager<Device> {\n constructor(\n protected projectRoot: string,\n protected port: number,\n options: {\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL. */\n getExpoGoUrl: () => string;\n /** Get redirect URL for native disambiguation. */\n getRedirectUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n }\n ) {\n super(projectRoot, {\n platform: 'ios',\n ...options,\n resolveDeviceAsync: AppleDeviceManager.resolveAsync,\n });\n }\n\n async openAsync(\n options:\n | { runtime: 'expo' | 'web' }\n | { runtime: 'custom'; props?: Partial<BaseOpenInCustomProps> },\n resolveSettings?: Partial<{ shouldPrompt?: boolean; device?: Device }>\n ): Promise<{ url: string }> {\n await AppleDeviceManager.assertSystemRequirementsAsync();\n return super.openAsync(options, resolveSettings);\n }\n\n _getAppIdResolver(): AppIdResolver {\n return new AppleAppIdResolver(this.projectRoot);\n }\n\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props?: Partial<BaseOpenInCustomProps>\n ): string {\n return applicationId;\n }\n}\n"],"names":["ApplePlatformManager","PlatformManager","constructor","projectRoot","port","options","platform","resolveDeviceAsync","AppleDeviceManager","resolveAsync","openAsync","resolveSettings","assertSystemRequirementsAsync","_getAppIdResolver","AppleAppIdResolver","_resolveAlternativeLaunchUrl","applicationId","props"],"mappings":";;;;+BAOaA;;;eAAAA;;;oCAPsB;oCACA;iCAGoB;AAGhD,MAAMA,6BAA6BC,gCAAe;IACvDC,YACE,AAAUC,WAAmB,EAC7B,AAAUC,IAAY,EACtBC,OASC,CACD;QACA,KAAK,CAACF,aAAa;YACjBG,UAAU;YACV,GAAGD,OAAO;YACVE,oBAAoBC,sCAAkB,CAACC,YAAY;QACrD,SAjBUN,cAAAA,kBACAC,OAAAA;IAiBZ;IAEA,MAAMM,UACJL,OAEiE,EACjEM,eAAsE,EAC5C;QAC1B,MAAMH,sCAAkB,CAACI,6BAA6B;QACtD,OAAO,KAAK,CAACF,UAAUL,SAASM;IAClC;IAEAE,oBAAmC;QACjC,OAAO,IAAIC,sCAAkB,CAAC,IAAI,CAACX,WAAW;IAChD;IAEAY,6BACEC,aAAqB,EACrBC,KAAsC,EAC9B;QACR,OAAOD;IACT;AACF"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/ApplePlatformManager.ts"],"sourcesContent":["import { AppleAppIdResolver } from './AppleAppIdResolver';\nimport { AppleDeviceManager } from './AppleDeviceManager';\nimport { Device } from './simctl';\nimport { AppIdResolver } from '../AppIdResolver';\nimport { BaseOpenInCustomProps, BaseResolveDeviceProps, PlatformManager } from '../PlatformManager';\n\n/** Manages launching apps on Apple simulators. */\nexport class ApplePlatformManager extends PlatformManager<Device> {\n constructor(\n protected projectRoot: string,\n protected port: number,\n options: {\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL. */\n getExpoGoUrl: () => string;\n /** Get redirect URL for native disambiguation. */\n getRedirectUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n }\n ) {\n super(projectRoot, {\n platform: 'ios',\n ...options,\n resolveDeviceAsync: AppleDeviceManager.resolveAsync,\n });\n }\n\n async openAsync(\n options:\n | { runtime: 'expo' | 'web' }\n | { runtime: 'custom'; props?: Partial<BaseOpenInCustomProps> },\n resolveSettings?: BaseResolveDeviceProps<Device>\n ): Promise<{ url: string }> {\n await AppleDeviceManager.assertSystemRequirementsAsync();\n return super.openAsync(options, resolveSettings);\n }\n\n _getAppIdResolver(): AppIdResolver {\n return new AppleAppIdResolver(this.projectRoot);\n }\n\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props?: Partial<BaseOpenInCustomProps>\n ): string {\n return applicationId;\n }\n}\n"],"names":["ApplePlatformManager","PlatformManager","constructor","projectRoot","port","options","platform","resolveDeviceAsync","AppleDeviceManager","resolveAsync","openAsync","resolveSettings","assertSystemRequirementsAsync","_getAppIdResolver","AppleAppIdResolver","_resolveAlternativeLaunchUrl","applicationId","props"],"mappings":";;;;+BAOaA;;;eAAAA;;;oCAPsB;oCACA;iCAG4C;AAGxE,MAAMA,6BAA6BC,gCAAe;IACvDC,YACE,AAAUC,WAAmB,EAC7B,AAAUC,IAAY,EACtBC,OASC,CACD;QACA,KAAK,CAACF,aAAa;YACjBG,UAAU;YACV,GAAGD,OAAO;YACVE,oBAAoBC,sCAAkB,CAACC,YAAY;QACrD,SAjBUN,cAAAA,kBACAC,OAAAA;IAiBZ;IAEA,MAAMM,UACJL,OAEiE,EACjEM,eAAgD,EACtB;QAC1B,MAAMH,sCAAkB,CAACI,6BAA6B;QACtD,OAAO,KAAK,CAACF,UAAUL,SAASM;IAClC;IAEAE,oBAAmC;QACjC,OAAO,IAAIC,sCAAkB,CAAC,IAAI,CAACX,WAAW;IAChD;IAEAY,6BACEC,aAAqB,EACrBC,KAAsC,EAC9B;QACR,OAAOD;IACT;AACF"}
@@ -360,23 +360,37 @@ class BundlerDevServer {
360
360
  }
361
361
  return this.getUrlCreator().constructLoadingUrl({}, platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null) ?? null;
362
362
  }
363
- async getPlatformManagerAsync(platform) {
363
+ async getPlatformManagerAsync(ofPlatform) {
364
+ const platform = ofPlatform;
364
365
  if (!this.platformManagers[platform]) {
365
366
  var _this_getInstance;
366
- const Manager = PLATFORM_MANAGERS[platform]();
367
367
  const port = (_this_getInstance = this.getInstance()) == null ? void 0 : _this_getInstance.location.port;
368
368
  if (!port || !this.urlCreator) {
369
369
  throw new _errors.CommandError('DEV_SERVER', 'Cannot interact with native platforms until dev server has started');
370
370
  }
371
371
  debug(`Creating platform manager (platform: ${platform}, port: ${port})`);
372
- this.platformManagers[platform] = new Manager(this.projectRoot, port, {
372
+ const managerParams = {
373
373
  getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),
374
374
  getExpoGoUrl: this.getExpoGoUrl.bind(this),
375
375
  getRedirectUrl: this.getRedirectUrl.bind(this, platform),
376
376
  getDevServerUrl: this.getDevServerUrl.bind(this, {
377
377
  hostType: 'localhost'
378
378
  })
379
- });
379
+ };
380
+ switch(platform){
381
+ case 'simulator':
382
+ {
383
+ const Manager = PLATFORM_MANAGERS[platform]();
384
+ this.platformManagers[platform] = new Manager(this.projectRoot, port, managerParams);
385
+ break;
386
+ }
387
+ case 'emulator':
388
+ {
389
+ const Manager = PLATFORM_MANAGERS[platform]();
390
+ this.platformManagers[platform] = new Manager(this.projectRoot, port, managerParams);
391
+ break;
392
+ }
393
+ }
380
394
  }
381
395
  return this.platformManagers[platform];
382
396
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import assert from 'assert';\nimport resolveFrom from 'resolve-from';\n\nimport { AsyncNgrok } from './AsyncNgrok';\nimport { AsyncWsTunnel } from './AsyncWsTunnel';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env, envIsWebcontainer } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n addListener?(event: string, listener: (...args: any[]) => void): unknown;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n /** Will the bundler be used for exporting. NOTE: This is an odd option to pass to the dev server. */\n isExporting?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Tunnel instance for managing tunnel connections. */\n protected tunnel: AsyncNgrok | AsyncWsTunnel | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n protected readonly devToolsPluginManager: DevToolsPluginManager;\n public isDevClient: boolean;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n /** Advanced options */\n options?: {\n /**\n * The instance of DevToolsPluginManager\n * @default new DevToolsPluginManager(projectRoot)\n */\n devToolsPluginManager?: DevToolsPluginManager;\n // TODO: Replace with custom scheme maybe...\n isDevClient?: boolean;\n }\n ) {\n this.devToolsPluginManager =\n options?.devToolsPluginManager ?? new DevToolsPluginManager(projectRoot);\n this.isDevClient = options?.isDevClient ?? false;\n }\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}\n ) {\n const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware;\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n return false;\n }\n\n public abstract startTypeScriptServices(): Promise<void>;\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: (callback: () => void) => {\n this.instance = null;\n callback?.();\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !env.EXPO_OFFLINE &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n } else if (envIsWebcontainer()) {\n await this._startTunnelAsync();\n }\n\n if (!options.isExporting) {\n await this.startDevSessionAsync();\n this.watchConfig();\n }\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | AsyncWsTunnel | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[tunnel] connect to port: ' + port);\n this.tunnel = envIsWebcontainer()\n ? new AsyncWsTunnel(this.projectRoot, port)\n : new AsyncNgrok(this.projectRoot, port);\n await this.tunnel.startAsync();\n return this.tunnel;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' })\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop tunnel if running.\n await this.tunnel?.stopAsync().catch((e) => {\n Log.error(`Error stopping tunnel:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n // Check if server is even running.\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n if ('code' in error && error.code === 'ERR_SERVER_NOT_RUNNING') {\n resolve();\n } else {\n reject(error);\n }\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n public getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? (this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl())\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n\n // If we have an active WS tunnel instance, we always need to return the tunnel location.\n if (this.tunnel && this.tunnel instanceof AsyncWsTunnel) {\n return this.getUrlCreator().constructUrl();\n }\n\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n\n return location.url ?? null;\n }\n\n public getDevServerUrlOrAssert(options: { hostType?: 'localhost' } = {}): string {\n const instance = this.getDevServerUrl(options);\n if (!instance) {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the dev server URL before the server has started - bundler[${this.name}]`\n );\n }\n\n return instance;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from the tunnel. */\n public getTunnelUrl(): string | null {\n return this.tunnel?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? (this.getTunnelUrl() ?? serverUrl) : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync<T extends BaseOpenInCustomProps = BaseOpenInCustomProps>(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<T> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["BundlerDevServer","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","constructor","projectRoot","platformBundlers","options","tunnel","devSession","instance","platformManagers","urlCreator","notifier","devToolsPluginManager","DevToolsPluginManager","isDevClient","setInstance","getManifestMiddlewareAsync","Middleware","ExpoGoManifestHandlerMiddleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","watchEnvironmentVariables","port","CommandError","server","close","callback","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","env","EXPO_OFFLINE","_startTunnelAsync","envIsWebcontainer","isExporting","startDevSessionAsync","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncWsTunnel","AsyncNgrok","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","runtime","isTargetingWeb","web","broadcastMessage","method","params","closeAsync","catch","e","Log","error","exception","resolveWithTimeout","Promise","resolve","reject","code","timeout","errorMessage","assert","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getDevServerUrlOrAssert","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","Manager","getCustomRuntimeUrl"],"mappings":";;;;+BAyFsBA;;;eAAAA;;;;gEAzFH;;;;;;;gEACK;;;;;;4BAEG;+BACG;8EACI;oC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AME,UAAUrH,iBAAiB,CAACmH,SAAS;YAC3C,MAAM3E,QAAO,oBAAA,IAAI,CAACwB,WAAW,uBAAhB,kBAAoBlB,QAAQ,CAACN,IAAI;YAC9C,IAAI,CAACA,QAAQ,CAAC,IAAI,CAAC3B,UAAU,EAAE;gBAC7B,MAAM,IAAI4B,oBAAY,CACpB,cACA;YAEJ;YACA3C,MAAM,CAAC,qCAAqC,EAAEqH,SAAS,QAAQ,EAAE3E,KAAK,CAAC,CAAC;YACxE,IAAI,CAAC5B,gBAAgB,CAACuG,SAAS,GAAG,IAAIE,QAAQ,IAAI,CAAC/G,WAAW,EAAEkC,MAAM;gBACpE8E,qBAAqB,IAAI,CAACzG,UAAU,CAACgF,qBAAqB,CAACpE,IAAI,CAAC,IAAI,CAACZ,UAAU;gBAC/EgG,cAAc,IAAI,CAACA,YAAY,CAACpF,IAAI,CAAC,IAAI;gBACzCyF,gBAAgB,IAAI,CAACA,cAAc,CAACzF,IAAI,CAAC,IAAI,EAAE0F;gBAC/C9C,iBAAiB,IAAI,CAACA,eAAe,CAAC5C,IAAI,CAAC,IAAI,EAAE;oBAAE2B,UAAU;gBAAY;YAC3E;QACF;QACA,OAAO,IAAI,CAACxC,gBAAgB,CAACuG,SAAS;IACxC;AACF"}
1
+ {"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import assert from 'assert';\nimport resolveFrom from 'resolve-from';\n\nimport { AsyncNgrok } from './AsyncNgrok';\nimport { AsyncWsTunnel } from './AsyncWsTunnel';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env, envIsWebcontainer } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n addListener?(event: string, listener: (...args: any[]) => void): unknown;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n /** Will the bundler be used for exporting. NOTE: This is an odd option to pass to the dev server. */\n isExporting?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\ntype PlatformManagers = {\n [K in keyof typeof PLATFORM_MANAGERS]: InstanceType<ReturnType<(typeof PLATFORM_MANAGERS)[K]>>;\n};\n\ntype PlatformDevice<Platform extends keyof PlatformManagers> =\n PlatformManagers[Platform] extends PlatformManager<infer Device, any> ? Device : never;\n\ntype PlatformLaunchProps<Platform extends keyof PlatformManagers> =\n PlatformManagers[Platform] extends PlatformManager<any, infer LaunchProps> ? LaunchProps : never;\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Tunnel instance for managing tunnel connections. */\n protected tunnel: AsyncNgrok | AsyncWsTunnel | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: { [K in keyof PlatformManagers]?: PlatformManagers[K] | undefined } =\n {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n protected readonly devToolsPluginManager: DevToolsPluginManager;\n public isDevClient: boolean;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n /** Advanced options */\n options?: {\n /**\n * The instance of DevToolsPluginManager\n * @default new DevToolsPluginManager(projectRoot)\n */\n devToolsPluginManager?: DevToolsPluginManager;\n // TODO: Replace with custom scheme maybe...\n isDevClient?: boolean;\n }\n ) {\n this.devToolsPluginManager =\n options?.devToolsPluginManager ?? new DevToolsPluginManager(projectRoot);\n this.isDevClient = options?.isDevClient ?? false;\n }\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}\n ) {\n const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware;\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n return false;\n }\n\n public abstract startTypeScriptServices(): Promise<void>;\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: (callback: () => void) => {\n this.instance = null;\n callback?.();\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !env.EXPO_OFFLINE &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n } else if (envIsWebcontainer()) {\n await this._startTunnelAsync();\n }\n\n if (!options.isExporting) {\n await this.startDevSessionAsync();\n this.watchConfig();\n }\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | AsyncWsTunnel | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[tunnel] connect to port: ' + port);\n this.tunnel = envIsWebcontainer()\n ? new AsyncWsTunnel(this.projectRoot, port)\n : new AsyncNgrok(this.projectRoot, port);\n await this.tunnel.startAsync();\n return this.tunnel;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' })\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop tunnel if running.\n await this.tunnel?.stopAsync().catch((e) => {\n Log.error(`Error stopping tunnel:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n // Check if server is even running.\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n if ('code' in error && error.code === 'ERR_SERVER_NOT_RUNNING') {\n resolve();\n } else {\n reject(error);\n }\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n public getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? (this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl())\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n\n // If we have an active WS tunnel instance, we always need to return the tunnel location.\n if (this.tunnel && this.tunnel instanceof AsyncWsTunnel) {\n return this.getUrlCreator().constructUrl();\n }\n\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n\n return location.url ?? null;\n }\n\n public getDevServerUrlOrAssert(options: { hostType?: 'localhost' } = {}): string {\n const instance = this.getDevServerUrl(options);\n if (!instance) {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the dev server URL before the server has started - bundler[${this.name}]`\n );\n }\n\n return instance;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from the tunnel. */\n public getTunnelUrl(): string | null {\n return this.tunnel?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof PlatformManagers | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? (this.getTunnelUrl() ?? serverUrl) : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync<Platform extends keyof PlatformManagers>(\n launchTarget: Platform,\n launchProps: Partial<PlatformLaunchProps<Platform>> = {},\n resolver: BaseResolveDeviceProps<PlatformDevice<Platform>> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync(\n { runtime: 'custom', props: launchProps },\n resolver as BaseResolveDeviceProps<any>\n );\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof PlatformManagers | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n protected async getPlatformManagerAsync<Platform extends keyof PlatformManagers>(\n ofPlatform: Platform\n ): Promise<PlatformManagers[Platform]> {\n const platform: keyof PlatformManagers = ofPlatform;\n if (!this.platformManagers[platform]) {\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n const managerParams = {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n };\n switch (platform) {\n case 'simulator': {\n const Manager = PLATFORM_MANAGERS[platform]();\n this.platformManagers[platform] = new Manager(this.projectRoot, port, managerParams);\n break;\n }\n case 'emulator': {\n const Manager = PLATFORM_MANAGERS[platform]();\n this.platformManagers[platform] = new Manager(this.projectRoot, port, managerParams);\n break;\n }\n }\n }\n return this.platformManagers[platform] as PlatformManagers[Platform];\n }\n}\n"],"names":["BundlerDevServer","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","constructor","projectRoot","platformBundlers","options","tunnel","devSession","instance","platformManagers","urlCreator","notifier","devToolsPluginManager","DevToolsPluginManager","isDevClient","setInstance","getManifestMiddlewareAsync","Middleware","ExpoGoManifestHandlerMiddleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","watchEnvironmentVariables","port","CommandError","server","close","callback","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","env","EXPO_OFFLINE","_startTunnelAsync","envIsWebcontainer","isExporting","startDevSessionAsync","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncWsTunnel","AsyncNgrok","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","runtime","isTargetingWeb","web","broadcastMessage","method","params","closeAsync","catch","e","Log","error","exception","resolveWithTimeout","Promise","resolve","reject","code","timeout","errorMessage","assert","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getDevServerUrlOrAssert","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","ofPlatform","managerParams","getCustomRuntimeUrl","Manager"],"mappings":";;;;+BAmGsBA;;;eAAAA;;;;gEAnGH;;;;;;;gEACK;;;;;;4BAEG;+BACG;8EACI;oCACC;4BACU;6DAExB;8BACQ;uBACM;qBACI;wBACV;sBACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOjC,MAAMC,QAAQC,QA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,CAAC3B,UAAU,EAAE;gBAC7B,MAAM,IAAI4B,oBAAY,CACpB,cACA;YAEJ;YACA3C,MAAM,CAAC,qCAAqC,EAAEqH,SAAS,QAAQ,EAAE3E,KAAK,CAAC,CAAC;YACxE,MAAM8E,gBAAgB;gBACpBC,qBAAqB,IAAI,CAAC1G,UAAU,CAACgF,qBAAqB,CAACpE,IAAI,CAAC,IAAI,CAACZ,UAAU;gBAC/EgG,cAAc,IAAI,CAACA,YAAY,CAACpF,IAAI,CAAC,IAAI;gBACzCyF,gBAAgB,IAAI,CAACA,cAAc,CAACzF,IAAI,CAAC,IAAI,EAAE0F;gBAC/C9C,iBAAiB,IAAI,CAACA,eAAe,CAAC5C,IAAI,CAAC,IAAI,EAAE;oBAAE2B,UAAU;gBAAY;YAC3E;YACA,OAAQ+D;gBACN,KAAK;oBAAa;wBAChB,MAAMK,UAAUxH,iBAAiB,CAACmH,SAAS;wBAC3C,IAAI,CAACvG,gBAAgB,CAACuG,SAAS,GAAG,IAAIK,QAAQ,IAAI,CAAClH,WAAW,EAAEkC,MAAM8E;wBACtE;oBACF;gBACA,KAAK;oBAAY;wBACf,MAAME,UAAUxH,iBAAiB,CAACmH,SAAS;wBAC3C,IAAI,CAACvG,gBAAgB,CAACuG,SAAS,GAAG,IAAIK,QAAQ,IAAI,CAAClH,WAAW,EAAEkC,MAAM8E;wBACtE;oBACF;YACF;QACF;QACA,OAAO,IAAI,CAAC1G,gBAAgB,CAACuG,SAAS;IACxC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevToolsPluginManager.ts"],"sourcesContent":["import type { ModuleDescriptorDevTools } from 'expo-modules-autolinking/exports';\n\nconst debug = require('debug')('expo:start:server:devtools');\n\nexport const DevToolsPluginEndpoint = '/_expo/plugins';\n\ninterface AutolinkingPlugin {\n packageName: string;\n packageRoot: string;\n webpageRoot: string;\n}\n\nexport interface DevToolsPlugin extends AutolinkingPlugin {\n webpageEndpoint: string;\n}\n\nexport default class DevToolsPluginManager {\n private plugins: DevToolsPlugin[] | null = null;\n\n constructor(private projectRoot: string) {}\n\n public async queryPluginsAsync(): Promise<DevToolsPlugin[]> {\n if (this.plugins) {\n return this.plugins;\n }\n const plugins = (await this.queryAutolinkedPluginsAsync(this.projectRoot)).map((plugin) => ({\n ...plugin,\n webpageEndpoint: `${DevToolsPluginEndpoint}/${plugin.packageName}`,\n }));\n this.plugins = plugins;\n return this.plugins;\n }\n\n public async queryPluginWebpageRootAsync(pluginName: string): Promise<string | null> {\n const plugins = await this.queryPluginsAsync();\n const plugin = plugins.find((p) => p.packageName === pluginName);\n return plugin?.webpageRoot ?? null;\n }\n\n private async queryAutolinkedPluginsAsync(projectRoot: string): Promise<AutolinkingPlugin[]> {\n const autolinking: typeof import('expo/internal/unstable-autolinking-exports') = require('expo/internal/unstable-autolinking-exports');\n const linker = autolinking.makeCachedDependenciesLinker({ projectRoot });\n const revisions = await autolinking.scanExpoModuleResolutionsForPlatform(linker, 'devtools');\n const { resolveModuleAsync } = autolinking.getLinkingImplementationForPlatform('devtools');\n const plugins: ModuleDescriptorDevTools[] = (\n await Promise.all(\n Object.values(revisions).map((revision) => resolveModuleAsync(revision.name, revision))\n )\n ).filter((maybePlugin) => maybePlugin != null);\n debug('Found autolinked plugins', plugins);\n return plugins;\n }\n}\n"],"names":["DevToolsPluginEndpoint","DevToolsPluginManager","debug","require","constructor","projectRoot","plugins","queryPluginsAsync","queryAutolinkedPluginsAsync","map","plugin","webpageEndpoint","packageName","queryPluginWebpageRootAsync","pluginName","find","p","webpageRoot","autolinking","linker","makeCachedDependenciesLinker","revisions","scanExpoModuleResolutionsForPlatform","resolveModuleAsync","getLinkingImplementationForPlatform","Promise","all","Object","values","revision","name","filter","maybePlugin"],"mappings":";;;;;;;;;;;IAIaA,sBAAsB;eAAtBA;;IAYb,OAoCC;eApCoBC;;;AAdrB,MAAMC,QAAQC,QAAQ,SAAS;AAExB,MAAMH,yBAAyB;AAYvB,MAAMC;IAGnBG,YAAY,AAAQC,WAAmB,CAAE;aAArBA,cAAAA;aAFZC,UAAmC;IAED;IAE1C,MAAaC,oBAA+C;QAC1D,IAAI,IAAI,CAACD,OAAO,EAAE;YAChB,OAAO,IAAI,CAACA,OAAO;QACrB;QACA,MAAMA,UAAU,AAAC,CAAA,MAAM,IAAI,CAACE,2BAA2B,CAAC,IAAI,CAACH,WAAW,CAAA,EAAGI,GAAG,CAAC,CAACC,SAAY,CAAA;gBAC1F,GAAGA,MAAM;gBACTC,iBAAiB,GAAGX,uBAAuB,CAAC,EAAEU,OAAOE,WAAW,EAAE;YACpE,CAAA;QACA,IAAI,CAACN,OAAO,GAAGA;QACf,OAAO,IAAI,CAACA,OAAO;IACrB;IAEA,MAAaO,4BAA4BC,UAAkB,EAA0B;QACnF,MAAMR,UAAU,MAAM,IAAI,CAACC,iBAAiB;QAC5C,MAAMG,SAASJ,QAAQS,IAAI,CAAC,CAACC,IAAMA,EAAEJ,WAAW,KAAKE;QACrD,OAAOJ,CAAAA,0BAAAA,OAAQO,WAAW,KAAI;IAChC;IAEA,MAAcT,4BAA4BH,WAAmB,EAAgC;QAC3F,MAAMa,cAA2Ef,QAAQ;QACzF,MAAMgB,SAASD,YAAYE,4BAA4B,CAAC;YAAEf;QAAY;QACtE,MAAMgB,YAAY,MAAMH,YAAYI,oCAAoC,CAACH,QAAQ;QACjF,MAAM,EAAEI,kBAAkB,EAAE,GAAGL,YAAYM,mCAAmC,CAAC;QAC/E,MAAMlB,UAAsC,AAC1C,CAAA,MAAMmB,QAAQC,GAAG,CACfC,OAAOC,MAAM,CAACP,WAAWZ,GAAG,CAAC,CAACoB,WAAaN,mBAAmBM,SAASC,IAAI,EAAED,WAC/E,EACAE,MAAM,CAAC,CAACC,cAAgBA,eAAe;QACzC9B,MAAM,4BAA4BI;QAClC,OAAOA;IACT;AACF"}
1
+ {"version":3,"sources":["../../../../src/start/server/DevToolsPluginManager.ts"],"sourcesContent":["import type { ModuleDescriptorDevTools } from 'expo-modules-autolinking/exports';\n\nconst debug = require('debug')('expo:start:server:devtools');\n\nexport const DevToolsPluginEndpoint = '/_expo/plugins';\n\ninterface AutolinkingPlugin {\n packageName: string;\n packageRoot: string;\n webpageRoot: string | undefined;\n}\n\nexport interface DevToolsPlugin extends AutolinkingPlugin {\n webpageEndpoint: string;\n}\n\nexport default class DevToolsPluginManager {\n private plugins: DevToolsPlugin[] | null = null;\n\n constructor(private projectRoot: string) {}\n\n public async queryPluginsAsync(): Promise<DevToolsPlugin[]> {\n if (this.plugins) {\n return this.plugins;\n }\n const plugins = (await this.queryAutolinkedPluginsAsync(this.projectRoot)).map((plugin) => ({\n ...plugin,\n webpageEndpoint: `${DevToolsPluginEndpoint}/${plugin.packageName}`,\n }));\n this.plugins = plugins;\n return this.plugins;\n }\n\n public async queryPluginWebpageRootAsync(pluginName: string): Promise<string | null> {\n const plugins = await this.queryPluginsAsync();\n const plugin = plugins.find((p) => p.packageName === pluginName);\n return plugin?.webpageRoot ?? null;\n }\n\n private async queryAutolinkedPluginsAsync(projectRoot: string): Promise<AutolinkingPlugin[]> {\n const autolinking: typeof import('expo/internal/unstable-autolinking-exports') = require('expo/internal/unstable-autolinking-exports');\n const linker = autolinking.makeCachedDependenciesLinker({ projectRoot });\n const revisions = await autolinking.scanExpoModuleResolutionsForPlatform(linker, 'devtools');\n const { resolveModuleAsync } = autolinking.getLinkingImplementationForPlatform('devtools');\n const plugins: ModuleDescriptorDevTools[] = (\n await Promise.all(\n Object.values(revisions).map((revision) => resolveModuleAsync(revision.name, revision))\n )\n ).filter((maybePlugin) => maybePlugin != null);\n debug('Found autolinked plugins', plugins);\n return plugins;\n }\n}\n"],"names":["DevToolsPluginEndpoint","DevToolsPluginManager","debug","require","constructor","projectRoot","plugins","queryPluginsAsync","queryAutolinkedPluginsAsync","map","plugin","webpageEndpoint","packageName","queryPluginWebpageRootAsync","pluginName","find","p","webpageRoot","autolinking","linker","makeCachedDependenciesLinker","revisions","scanExpoModuleResolutionsForPlatform","resolveModuleAsync","getLinkingImplementationForPlatform","Promise","all","Object","values","revision","name","filter","maybePlugin"],"mappings":";;;;;;;;;;;IAIaA,sBAAsB;eAAtBA;;IAYb,OAoCC;eApCoBC;;;AAdrB,MAAMC,QAAQC,QAAQ,SAAS;AAExB,MAAMH,yBAAyB;AAYvB,MAAMC;IAGnBG,YAAY,AAAQC,WAAmB,CAAE;aAArBA,cAAAA;aAFZC,UAAmC;IAED;IAE1C,MAAaC,oBAA+C;QAC1D,IAAI,IAAI,CAACD,OAAO,EAAE;YAChB,OAAO,IAAI,CAACA,OAAO;QACrB;QACA,MAAMA,UAAU,AAAC,CAAA,MAAM,IAAI,CAACE,2BAA2B,CAAC,IAAI,CAACH,WAAW,CAAA,EAAGI,GAAG,CAAC,CAACC,SAAY,CAAA;gBAC1F,GAAGA,MAAM;gBACTC,iBAAiB,GAAGX,uBAAuB,CAAC,EAAEU,OAAOE,WAAW,EAAE;YACpE,CAAA;QACA,IAAI,CAACN,OAAO,GAAGA;QACf,OAAO,IAAI,CAACA,OAAO;IACrB;IAEA,MAAaO,4BAA4BC,UAAkB,EAA0B;QACnF,MAAMR,UAAU,MAAM,IAAI,CAACC,iBAAiB;QAC5C,MAAMG,SAASJ,QAAQS,IAAI,CAAC,CAACC,IAAMA,EAAEJ,WAAW,KAAKE;QACrD,OAAOJ,CAAAA,0BAAAA,OAAQO,WAAW,KAAI;IAChC;IAEA,MAAcT,4BAA4BH,WAAmB,EAAgC;QAC3F,MAAMa,cAA2Ef,QAAQ;QACzF,MAAMgB,SAASD,YAAYE,4BAA4B,CAAC;YAAEf;QAAY;QACtE,MAAMgB,YAAY,MAAMH,YAAYI,oCAAoC,CAACH,QAAQ;QACjF,MAAM,EAAEI,kBAAkB,EAAE,GAAGL,YAAYM,mCAAmC,CAAC;QAC/E,MAAMlB,UAAsC,AAC1C,CAAA,MAAMmB,QAAQC,GAAG,CACfC,OAAOC,MAAM,CAACP,WAAWZ,GAAG,CAAC,CAACoB,WAAaN,mBAAmBM,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