@expo/cli 0.16.6 → 0.16.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/bin/cli CHANGED
@@ -137,7 +137,7 @@ const args = (0, _arg).default({
137
137
  });
138
138
  if (args["--version"]) {
139
139
  // Version is added in the build script.
140
- console.log("0.16.6");
140
+ console.log("0.16.8");
141
141
  process.exit(0);
142
142
  }
143
143
  if (args["--non-interactive"]) {
@@ -271,7 +271,7 @@ commands[command]().then((exec)=>{
271
271
  logEventAsync("action", {
272
272
  action: `expo ${command}`,
273
273
  source: "expo/cli",
274
- source_version: "0.16.6"
274
+ source_version: "0.16.8"
275
275
  });
276
276
  }
277
277
  });
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.exportEmbedAsync = exportEmbedAsync;
6
+ exports.createMetroServerAndBundleRequestAsync = createMetroServerAndBundleRequestAsync;
7
+ exports.exportEmbedBundleAndAssetsAsync = exportEmbedBundleAndAssetsAsync;
6
8
  exports.exportEmbedBundleAsync = exportEmbedBundleAsync;
9
+ exports.exportEmbedAssetsAsync = exportEmbedAssetsAsync;
7
10
  var _config = require("@expo/config");
8
11
  var _fs = _interopRequireDefault(require("fs"));
9
12
  var _glob = require("glob");
@@ -56,7 +59,7 @@ async function exportEmbedAsync(projectRoot, options) {
56
59
  await (0, _dir).removeAsync(previousPath);
57
60
  }
58
61
  }
59
- const { bundle , assets } = await exportEmbedBundleAsync(projectRoot, options);
62
+ const { bundle , assets } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);
60
63
  _fs.default.mkdirSync(_path.default.dirname(options.bundleOutput), {
61
64
  recursive: true,
62
65
  mode: 493
@@ -73,7 +76,7 @@ async function exportEmbedAsync(projectRoot, options) {
73
76
  }) : null,
74
77
  ]);
75
78
  }
76
- async function exportEmbedBundleAsync(projectRoot, options) {
79
+ async function createMetroServerAndBundleRequestAsync(projectRoot, options) {
77
80
  const exp = (0, _config).getConfig(projectRoot, {
78
81
  skipSDKVersionRequirement: true
79
82
  }).exp;
@@ -107,20 +110,51 @@ async function exportEmbedBundleAsync(projectRoot, options) {
107
110
  const server = new _server.default(config, {
108
111
  watch: false
109
112
  });
113
+ return {
114
+ server,
115
+ bundleRequest
116
+ };
117
+ }
118
+ async function exportEmbedBundleAndAssetsAsync(projectRoot, options) {
119
+ const { server , bundleRequest } = await createMetroServerAndBundleRequestAsync(projectRoot, options);
120
+ try {
121
+ const bundle = await exportEmbedBundleAsync(server, bundleRequest, projectRoot, options);
122
+ const assets = await exportEmbedAssetsAsync(server, bundleRequest, projectRoot, options);
123
+ return {
124
+ bundle,
125
+ assets
126
+ };
127
+ } finally{
128
+ server.end();
129
+ }
130
+ }
131
+ async function exportEmbedBundleAsync(server, bundleRequest, projectRoot, options) {
110
132
  try {
111
- const bundle = await (0, _profile).profile(server.build.bind(server), "metro-bundle")({
133
+ return await (0, _profile).profile(server.build.bind(server), "metro-bundle")({
112
134
  ...bundleRequest,
113
135
  bundleType: "bundle"
114
136
  });
115
- // Save the assets of the bundle
116
- const outputAssets = await (0, _forkBundleAsync).getAssets(server, {
137
+ } catch (error) {
138
+ if (isError(error)) {
139
+ // Log using Xcode error format so the errors are picked up by xcodebuild.
140
+ // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script
141
+ if (options.platform === "ios") {
142
+ // If the error is about to be presented in Xcode, strip the ansi characters from the message.
143
+ if ("message" in error && (0, _xcodeCompilerLogger).isExecutingFromXcodebuild()) {
144
+ error.message = (0, _ansi).stripAnsi(error.message);
145
+ }
146
+ (0, _xcodeCompilerLogger).logMetroErrorInXcode(projectRoot, error);
147
+ }
148
+ }
149
+ throw error;
150
+ }
151
+ }
152
+ async function exportEmbedAssetsAsync(server, bundleRequest, projectRoot, options) {
153
+ try {
154
+ return await (0, _forkBundleAsync).getAssets(server, {
117
155
  ...bundleRequest,
118
156
  bundleType: "todo"
119
157
  });
120
- return {
121
- bundle,
122
- assets: outputAssets
123
- };
124
158
  } catch (error) {
125
159
  if (isError(error)) {
126
160
  // Log using Xcode error format so the errors are picked up by xcodebuild.
@@ -134,8 +168,6 @@ async function exportEmbedBundleAsync(projectRoot, options) {
134
168
  }
135
169
  }
136
170
  throw error;
137
- } finally{
138
- server.end();
139
171
  }
140
172
  }
141
173
  function isError(error) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport Server from 'metro/src/Server';\nimport output from 'metro/src/shared/output/bundle';\nimport type { BundleOptions } from 'metro/src/shared/types';\nimport path from 'path';\n\nimport { Options } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { removeAsync } from '../../utils/dir';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { profile } from '../../utils/profile';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { getAssets } from '../fork-bundleAsync';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (!bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//)) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(path.join(bundleParent, `*.app/${bundleName}`), {\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets } = await exportEmbedBundleAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAsync(projectRoot: string, options: Options) {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n maxWorkers: options.maxWorkers,\n resetCache: false, //options.resetCache,\n config: options.config,\n },\n {\n exp,\n isExporting: true,\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const bundleRequest = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n mainModuleName: options.entryFile,\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n }),\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n try {\n const bundle = await profile(\n server.build.bind(server),\n 'metro-bundle'\n )({\n ...bundleRequest,\n bundleType: 'bundle',\n });\n\n // Save the assets of the bundle\n const outputAssets = await getAssets(server, {\n ...bundleRequest,\n bundleType: 'todo',\n });\n\n return {\n bundle,\n assets: outputAssets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n server.end();\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n"],"names":["exportEmbedAsync","exportEmbedBundleAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","join","dot","projectRoot","options","setNodeEnv","dev","load","removeAsync","platform","previousPath","fs","existsSync","bundle","assets","mkdirSync","recursive","mode","Promise","all","output","save","Log","log","assetsDest","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","exp","getConfig","skipSDKVersionRequirement","config","loadMetroConfigAsync","maxWorkers","resetCache","isExporting","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","getMetroDirectBundleOptionsForExpoConfig","mainModuleName","entryFile","minify","engine","undefined","unstable_transformProfile","unstableTransformProfile","server","watch","profile","build","bind","bundleType","outputAssets","getAssets","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","end","Error"],"mappings":"AAMA;;;;QAuCsBA,gBAAgB,GAAhBA,gBAAgB;QAoChBC,sBAAsB,GAAtBA,sBAAsB;AA3ElB,IAAA,OAAc,WAAd,cAAc,CAAA;AACzB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACc,IAAA,KAAM,WAAN,MAAM,CAAA;AACpB,IAAA,OAAkB,kCAAlB,kBAAkB,EAAA;AAClB,IAAA,OAAgC,kCAAhC,gCAAgC,EAAA;AAElC,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGyC,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACnE,IAAA,IAAW,WAAX,WAAW,CAAA;AACM,IAAA,iBAA2C,WAA3C,2CAA2C,CAAA;AACvB,IAAA,aAA4C,WAA5C,4CAA4C,CAAA;AAC3E,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AAChB,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AAClB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AACxB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AACP,IAAA,aAAiB,WAAjB,iBAAiB,CAAA;AAC7B,IAAA,gBAAqB,WAArB,qBAAqB,CAAA;AACP,IAAA,mBAAuB,WAAvB,uBAAuB,CAAA;;;;;;AAE/D,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,AAAC;AAEpD,SAASC,0BAA0B,CAACC,YAAoB,EAAE;IACxD,+CAA+C;IAC/C,IAAI,CAACA,YAAY,CAACC,KAAK,+CAA+C,EAAE;QACtEJ,KAAK,CAAC,oCAAoC,EAAEG,YAAY,CAAC,CAAC;QAC1D,OAAO,KAAK,CAAC;KACd;IACD,MAAME,UAAU,GAAGC,KAAI,QAAA,CAACC,QAAQ,CAACJ,YAAY,CAAC,AAAC;IAC/C,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C,GAAGX,aAAa;YAChBgB,UAAU,EAAE,MAAM;SACnB,CAAC,AAAC;QAEH,OAAO;YACL7C,MAAM;YACNC,MAAM,EAAE6C,YAAY;SACrB,CAAC;KACH,CAAC,OAAOE,KAAK,EAAO;QACnB,IAAIC,OAAO,CAACD,KAAK,CAAC,EAAE;YAClB,0EAA0E;YAC1E,iIAAiI;YACjI,IAAIzD,OAAO,CAACK,QAAQ,KAAK,KAAK,EAAE;gBAC9B,8FAA8F;gBAC9F,IAAI,SAAS,IAAIoD,KAAK,IAAIE,CAAAA,GAAAA,oBAAyB,AAAE,CAAA,0BAAF,EAAE,EAAE;oBACrDF,KAAK,CAACG,OAAO,GAAGC,CAAAA,GAAAA,KAAS,AAAe,CAAA,UAAf,CAACJ,KAAK,CAACG,OAAO,CAAC,AAAU,CAAC;iBACpD;gBACDE,CAAAA,GAAAA,oBAAoB,AAAoB,CAAA,qBAApB,CAAC/D,WAAW,EAAE0D,KAAK,CAAC,CAAC;aAC1C;SACF;QACD,MAAMA,KAAK,CAAC;KACb,QAAS;QACRR,MAAM,CAACc,GAAG,EAAE,CAAC;KACd;CACF;AAED,SAASL,OAAO,CAACD,KAAU,EAAkB;IAC3C,OAAOA,KAAK,YAAYO,KAAK,CAAC;CAC/B"}
1
+ {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getConfig } from '@expo/config';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport Server from 'metro/src/Server';\nimport output from 'metro/src/shared/output/bundle';\nimport type { BundleOptions } from 'metro/src/shared/types';\nimport path from 'path';\n\nimport { Options } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { removeAsync } from '../../utils/dir';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { profile } from '../../utils/profile';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { getAssets } from '../fork-bundleAsync';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (!bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//)) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(path.join(bundleParent, `*.app/${bundleName}`), {\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n maxWorkers: options.maxWorkers,\n resetCache: false, //options.resetCache,\n config: options.config,\n },\n {\n exp,\n isExporting: true,\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const bundleRequest = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n mainModuleName: options.entryFile,\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n }),\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n return { server, bundleRequest };\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: Awaited<ReturnType<typeof getAssets>>;\n}> {\n const { server, bundleRequest } = await createMetroServerAndBundleRequestAsync(\n projectRoot,\n options\n );\n\n try {\n const bundle = await exportEmbedBundleAsync(server, bundleRequest, projectRoot, options);\n const assets = await exportEmbedAssetsAsync(server, bundleRequest, projectRoot, options);\n return { bundle, assets };\n } finally {\n server.end();\n }\n}\n\nexport async function exportEmbedBundleAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n return await profile(\n server.build.bind(server),\n 'metro-bundle'\n )({\n ...bundleRequest,\n bundleType: 'bundle',\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n return await getAssets(server, {\n ...bundleRequest,\n bundleType: 'todo',\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n"],"names":["exportEmbedAsync","createMetroServerAndBundleRequestAsync","exportEmbedBundleAndAssetsAsync","exportEmbedBundleAsync","exportEmbedAssetsAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","join","dot","projectRoot","options","setNodeEnv","dev","load","removeAsync","platform","previousPath","fs","existsSync","bundle","assets","mkdirSync","recursive","mode","Promise","all","output","save","Log","log","assetsDest","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","exp","getConfig","skipSDKVersionRequirement","config","loadMetroConfigAsync","maxWorkers","resetCache","isExporting","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","getMetroDirectBundleOptionsForExpoConfig","mainModuleName","entryFile","minify","engine","undefined","unstable_transformProfile","unstableTransformProfile","server","watch","end","profile","build","bind","bundleType","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","getAssets","Error"],"mappings":"AAMA;;;;QAuCsBA,gBAAgB,GAAhBA,gBAAgB;QAoChBC,sCAAsC,GAAtCA,sCAAsC;QA4DtCC,+BAA+B,GAA/BA,+BAA+B;QAqB/BC,sBAAsB,GAAtBA,sBAAsB;QA8BtBC,sBAAsB,GAAtBA,sBAAsB;AA1LlB,IAAA,OAAc,WAAd,cAAc,CAAA;AACzB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACc,IAAA,KAAM,WAAN,MAAM,CAAA;AACpB,IAAA,OAAkB,kCAAlB,kBAAkB,EAAA;AAClB,IAAA,OAAgC,kCAAhC,gCAAgC,EAAA;AAElC,IAAA,KAAM,kCAAN,MAAM,EAAA;AAGyC,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACnE,IAAA,IAAW,WAAX,WAAW,CAAA;AACM,IAAA,iBAA2C,WAA3C,2CAA2C,CAAA;AACvB,IAAA,aAA4C,WAA5C,4CAA4C,CAAA;AAC3E,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AAChB,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AAClB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AACxB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AACP,IAAA,aAAiB,WAAjB,iBAAiB,CAAA;AAC7B,IAAA,gBAAqB,WAArB,qBAAqB,CAAA;AACP,IAAA,mBAAuB,WAA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e,CAAA,UAAf,CAACJ,KAAK,CAACG,OAAO,CAAC,AAAU,CAAC;iBACpD;gBACDE,CAAAA,GAAAA,oBAAoB,AAAoB,CAAA,qBAApB,CAAC9D,WAAW,EAAEyD,KAAK,CAAC,CAAC;aAC1C;SACF;QACD,MAAMA,KAAK,CAAC;KACb;CACF;AAEM,eAAexE,sBAAsB,CAC1CiE,MAAc,EACdX,aAA4B,EAC5BvC,WAAmB,EACnBC,OAAkC,EAClC;IACA,IAAI;QACF,OAAO,MAAM8D,CAAAA,GAAAA,gBAAS,AAGpB,CAAA,UAHoB,CAACb,MAAM,EAAE;YAC7B,GAAGX,aAAa;YAChBiB,UAAU,EAAE,MAAM;SACnB,CAAC,CAAC;KACJ,CAAC,OAAOC,KAAK,EAAO;QACnB,IAAIC,OAAO,CAACD,KAAK,CAAC,EAAE;YAClB,0EAA0E;YAC1E,iIAAiI;YACjI,IAAIxD,OAAO,CAACK,QAAQ,KAAK,KAAK,EAAE;gBAC9B,8FAA8F;gBAC9F,IAAI,SAAS,IAAImD,KAAK,IAAIE,CAAAA,GAAAA,oBAAyB,AAAE,CAAA,0BAAF,EAAE,EAAE;oBACrDF,KAAK,CAACG,OAAO,GAAGC,CAAAA,GAAAA,KAAS,AAAe,CAAA,UAAf,CAACJ,KAAK,CAACG,OAAO,CAAC,AAAU,CAAC;iBACpD;gBACDE,CAAAA,GAAAA,oBAAoB,AAAoB,CAAA,qBAApB,CAAC9D,WAAW,EAAEyD,KAAK,CAAC,CAAC;aAC1C;SACF;QACD,MAAMA,KAAK,CAAC;KACb;CACF;AAED,SAASC,OAAO,CAACD,KAAU,EAAkB;IAC3C,OAAOA,KAAK,YAAYO,KAAK,CAAC;CAC/B"}
@@ -6,6 +6,7 @@ var _spawnAsync = _interopRequireDefault(require("@expo/spawn-async"));
6
6
  var _childProcess = require("child_process");
7
7
  var _androidSdk = require("./AndroidSdk");
8
8
  var _log = require("../../../log");
9
+ var _env = require("../../../utils/env");
9
10
  var _errors = require("../../../utils/errors");
10
11
  var _exit = require("../../../utils/exit");
11
12
  function _interopRequireDefault(obj) {
@@ -99,6 +100,12 @@ class ADBServer {
99
100
  if (error.signal === "SIGINT") {
100
101
  throw new _errors.AbortCommandError();
101
102
  }
103
+ if (error.status === 255 && error.stdout.includes("Bad user number")) {
104
+ var ref;
105
+ var ref1;
106
+ const userNumber = (ref1 = (ref = error.stdout.match(/Bad user number: (.+)/)) == null ? void 0 : ref[1]) != null ? ref1 : _env.env.EXPO_ADB_USER;
107
+ throw new _errors.CommandError("EXPO_ADB_USER", `Invalid ADB user number "${userNumber}" set with environment variable EXPO_ADB_USER. Run "adb shell pm list users" to see valid user numbers.`);
108
+ }
102
109
  // TODO: Support heap corruption for adb 29 (process exits with code -1073740940) (windows and linux)
103
110
  let errorMessage = (error.stderr || error.stdout || error.message).trim();
104
111
  if (errorMessage.startsWith(BEGINNING_OF_ADB_ERROR_MESSAGE)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/android/ADBServer.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { execFileSync } from 'child_process';\n\nimport { assertSdkRoot } from './AndroidSdk';\nimport { Log } from '../../../log';\nimport { AbortCommandError } from '../../../utils/errors';\nimport { installExitHooks } from '../../../utils/exit';\n\nconst debug = require('debug')('expo:start:platforms:android:adbServer') as typeof console.log;\n\nconst BEGINNING_OF_ADB_ERROR_MESSAGE = 'error: ';\n\n// This is a tricky class since it controls a system state (side-effects).\n// A more ideal solution would be to implement ADB in JS.\n// The main reason this is a class is to control the flow of testing.\n\nexport class ADBServer {\n isRunning: boolean = false;\n removeExitHook: () => void = () => {};\n\n /** Returns the command line reference to ADB. */\n getAdbExecutablePath(): string {\n try {\n const sdkRoot = assertSdkRoot();\n if (sdkRoot) {\n return `${sdkRoot}/platform-tools/adb`;\n }\n } catch (error: any) {\n Log.warn(error.message);\n }\n\n Log.debug('Failed to resolve the Android SDK path, falling back to global adb executable');\n return 'adb';\n }\n\n /** Start the ADB server. */\n async startAsync(): Promise<boolean> {\n if (this.isRunning) {\n return false;\n }\n // clean up\n this.removeExitHook = installExitHooks(() => {\n if (this.isRunning) {\n this.stopAsync();\n }\n });\n const adb = this.getAdbExecutablePath();\n const result = await this.resolveAdbPromise(spawnAsync(adb, ['start-server']));\n const lines = result.stderr.trim().split(/\\r?\\n/);\n const isStarted = lines.includes('* daemon started successfully');\n this.isRunning = isStarted;\n return isStarted;\n }\n\n /** Kill the ADB server. */\n async stopAsync(): Promise<boolean> {\n debug('Stopping ADB server');\n\n if (!this.isRunning) {\n debug('ADB server is not running');\n return false;\n }\n this.removeExitHook();\n try {\n await this.runAsync(['kill-server']);\n return true;\n } catch (error: any) {\n Log.error('Failed to stop ADB server: ' + error.message);\n return false;\n } finally {\n debug('Stopped ADB server');\n this.isRunning = false;\n }\n }\n\n /** Execute an ADB command with given args. */\n async runAsync(args: string[]): Promise<string> {\n // TODO: Add a global package that installs adb to the path.\n const adb = this.getAdbExecutablePath();\n\n await this.startAsync();\n\n debug([adb, ...args].join(' '));\n const result = await this.resolveAdbPromise(spawnAsync(adb, args));\n return result.output.join('\\n');\n }\n\n /** Get ADB file output. Useful for reading device state/settings. */\n async getFileOutputAsync(args: string[]): Promise<string> {\n // TODO: Add a global package that installs adb to the path.\n const adb = this.getAdbExecutablePath();\n\n await this.startAsync();\n\n const results = await this.resolveAdbPromise(\n execFileSync(adb, args, {\n encoding: 'latin1',\n stdio: 'pipe',\n })\n );\n debug('[ADB] File output:\\n', results);\n return results;\n }\n\n /** Formats error info. */\n async resolveAdbPromise<T>(promise: T | Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error: any) {\n // User pressed ctrl+c to cancel the process...\n if (error.signal === 'SIGINT') {\n throw new AbortCommandError();\n }\n // TODO: Support heap corruption for adb 29 (process exits with code -1073740940) (windows and linux)\n let errorMessage = (error.stderr || error.stdout || error.message).trim();\n if (errorMessage.startsWith(BEGINNING_OF_ADB_ERROR_MESSAGE)) {\n errorMessage = errorMessage.substring(BEGINNING_OF_ADB_ERROR_MESSAGE.length);\n }\n error.message = errorMessage;\n throw error;\n }\n }\n}\n"],"names":["debug","require","BEGINNING_OF_ADB_ERROR_MESSAGE","ADBServer","isRunning","removeExitHook","getAdbExecutablePath","sdkRoot","assertSdkRoot","error","Log","warn","message","startAsync","installExitHooks","stopAsync","adb","result","resolveAdbPromise","spawnAsync","lines","stderr","trim","split","isStarted","includes","runAsync","args","join","output","getFileOutputAsync","results","execFileSync","encoding","stdio","promise","signal","AbortCommandError","errorMessage","stdout","startsWith","substring","length"],"mappings":"AAAA;;;;AAAuB,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AACb,IAAA,aAAe,WAAf,eAAe,CAAA;AAEd,IAAA,WAAc,WAAd,cAAc,CAAA;AACxB,IAAA,IAAc,WAAd,cAAc,CAAA;AACA,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACxB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;;;;;;AAEtD,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,wCAAwC,CAAC,AAAsB,AAAC;AAE/F,MAAMC,8BAA8B,GAAG,SAAS,AAAC;AAM1C,MAAMC,SAAS;IACpBC,SAAS,GAAY,KAAK,CAAC;IAC3BC,cAAc,GAAe,IAAM,EAAE,CAAC;IAEtC,iDAAiD,CACjDC,oBAAoB,GAAW;QAC7B,IAAI;YACF,MAAMC,OAAO,GAAGC,CAAAA,GAAAA,WAAa,AAAE,CAAA,cAAF,EAAE,AAAC;YAChC,IAAID,OAAO,EAAE;gBACX,OAAO,CAAC,EAAEA,OAAO,CAAC,mBAAmB,CAAC,CAAC;aACxC;SACF,CAAC,OAAOE,KAAK,EAAO;YACnBC,IAAG,IAAA,CAACC,IAAI,CAACF,KAAK,CAACG,OAAO,CAAC,CAAC;SACzB;QAEDF,IAAG,IAAA,CAACV,KAAK,CAAC,+EAA+E,CAAC,CAAC;QAC3F,OAAO,KAAK,CAAC;KACd;IA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;gBAC7B,MAAM,IAAIC,OAAiB,kBAAA,EAAE,CAAC;aAC/B;YACD,qGAAqG;YACrG,IAAIC,YAAY,GAAG,CAAC7B,KAAK,CAACY,MAAM,IAAIZ,KAAK,CAAC8B,MAAM,IAAI9B,KAAK,CAACG,OAAO,CAAC,CAACU,IAAI,EAAE,AAAC;YAC1E,IAAIgB,YAAY,CAACE,UAAU,CAACtC,8BAA8B,CAAC,EAAE;gBAC3DoC,YAAY,GAAGA,YAAY,CAACG,SAAS,CAACvC,8BAA8B,CAACwC,MAAM,CAAC,CAAC;aAC9E;YACDjC,KAAK,CAACG,OAAO,GAAG0B,YAAY,CAAC;YAC7B,MAAM7B,KAAK,CAAC;SACb;KACF;CACF;QA1GYN,SAAS,GAATA,SAAS"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/android/ADBServer.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { execFileSync } from 'child_process';\n\nimport { assertSdkRoot } from './AndroidSdk';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { AbortCommandError, CommandError } from '../../../utils/errors';\nimport { installExitHooks } from '../../../utils/exit';\n\nconst debug = require('debug')('expo:start:platforms:android:adbServer') as typeof console.log;\n\nconst BEGINNING_OF_ADB_ERROR_MESSAGE = 'error: ';\n\n// This is a tricky class since it controls a system state (side-effects).\n// A more ideal solution would be to implement ADB in JS.\n// The main reason this is a class is to control the flow of testing.\n\nexport class ADBServer {\n isRunning: boolean = false;\n removeExitHook: () => void = () => {};\n\n /** Returns the command line reference to ADB. */\n getAdbExecutablePath(): string {\n try {\n const sdkRoot = assertSdkRoot();\n if (sdkRoot) {\n return `${sdkRoot}/platform-tools/adb`;\n }\n } catch (error: any) {\n Log.warn(error.message);\n }\n\n Log.debug('Failed to resolve the Android SDK path, falling back to global adb executable');\n return 'adb';\n }\n\n /** Start the ADB server. */\n async startAsync(): Promise<boolean> {\n if (this.isRunning) {\n return false;\n }\n // clean up\n this.removeExitHook = installExitHooks(() => {\n if (this.isRunning) {\n this.stopAsync();\n }\n });\n const adb = this.getAdbExecutablePath();\n const result = await this.resolveAdbPromise(spawnAsync(adb, ['start-server']));\n const lines = result.stderr.trim().split(/\\r?\\n/);\n const isStarted = lines.includes('* daemon started successfully');\n this.isRunning = isStarted;\n return isStarted;\n }\n\n /** Kill the ADB server. */\n async stopAsync(): Promise<boolean> {\n debug('Stopping ADB server');\n\n if (!this.isRunning) {\n debug('ADB server is not running');\n return false;\n }\n this.removeExitHook();\n try {\n await this.runAsync(['kill-server']);\n return true;\n } catch (error: any) {\n Log.error('Failed to stop ADB server: ' + error.message);\n return false;\n } finally {\n debug('Stopped ADB server');\n this.isRunning = false;\n }\n }\n\n /** Execute an ADB command with given args. */\n async runAsync(args: string[]): Promise<string> {\n // TODO: Add a global package that installs adb to the path.\n const adb = this.getAdbExecutablePath();\n\n await this.startAsync();\n\n debug([adb, ...args].join(' '));\n const result = await this.resolveAdbPromise(spawnAsync(adb, args));\n return result.output.join('\\n');\n }\n\n /** Get ADB file output. Useful for reading device state/settings. */\n async getFileOutputAsync(args: string[]): Promise<string> {\n // TODO: Add a global package that installs adb to the path.\n const adb = this.getAdbExecutablePath();\n\n await this.startAsync();\n\n const results = await this.resolveAdbPromise(\n execFileSync(adb, args, {\n encoding: 'latin1',\n stdio: 'pipe',\n })\n );\n debug('[ADB] File output:\\n', results);\n return results;\n }\n\n /** Formats error info. */\n async resolveAdbPromise<T>(promise: T | Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error: any) {\n // User pressed ctrl+c to cancel the process...\n if (error.signal === 'SIGINT') {\n throw new AbortCommandError();\n }\n if (error.status === 255 && error.stdout.includes('Bad user number')) {\n const userNumber = error.stdout.match(/Bad user number: (.+)/)?.[1] ?? env.EXPO_ADB_USER;\n throw new CommandError(\n 'EXPO_ADB_USER',\n `Invalid ADB user number \"${userNumber}\" set with environment variable EXPO_ADB_USER. Run \"adb shell pm list users\" to see valid user numbers.`\n );\n }\n // TODO: Support heap corruption for adb 29 (process exits with code -1073740940) (windows and linux)\n let errorMessage = (error.stderr || error.stdout || error.message).trim();\n if (errorMessage.startsWith(BEGINNING_OF_ADB_ERROR_MESSAGE)) {\n errorMessage = errorMessage.substring(BEGINNING_OF_ADB_ERROR_MESSAGE.length);\n }\n\n error.message = errorMessage;\n throw error;\n }\n }\n}\n"],"names":["debug","require","BEGINNING_OF_ADB_ERROR_MESSAGE","ADBServer","isRunning","removeExitHook","getAdbExecutablePath","sdkRoot","assertSdkRoot","error","Log","warn","message","startAsync","installExitHooks","stopAsync","adb","result","resolveAdbPromise","spawnAsync","lines","stderr","trim","split","isStarted","includes","runAsync","args","join","output","getFileOutputAsync","results","execFileSync","encoding","stdio","promise","signal","AbortCommandError","status","stdout","userNumber","match","env","EXPO_ADB_USER","CommandError","errorMessage","startsWith","substring","length"],"mappings":"AAAA;;;;AAAuB,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AACb,IAAA,aAAe,WAAf,eAAe,CAAA;AAEd,IAAA,WAAc,WAAd,cAAc,CAAA;AACxB,IAAA,IAAc,WAAd,cAAc,CAAA;AACd,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACQ,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACtC,IAAA,KAAqB,WAArB,qBAAqB,CAAA;;;;;;AAEtD,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,wCAAwC,CAAC,AAAsB,AAAC;AAE/F,MAAMC,8BAA8B,GAAG,SAAS,AAAC;AAM1C,MAAMC,SAAS;IACpBC,SAAS,GAAY,KAAK,CAAC;IAC3BC,cAAc,GAAe,IAAM,EAAE,CAAC;IAEtC,iDAAiD,CACjDC,oBAAoB,GAAW;QAC7B,IAAI;YACF,MAAMC,OAAO,GAAGC,CAAAA,GAAAA,WAAa,AAAE,CAAA,cAAF,EAAE,AAAC;YAChC,IAAID,OAAO,EAAE;gBACX,OAAO,CAAC,EAAEA,OAAO,CAAC,mBAAmB,CAAC,C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alk"));
24
24
  var _os = _interopRequireDefault(require("os"));
25
25
  var _adbserver = require("./ADBServer");
26
26
  var Log = _interopRequireWildcard(require("../../../log"));
27
+ var _env = require("../../../utils/env");
27
28
  var _errors = require("../../../utils/errors");
28
29
  var _link = require("../../../utils/link");
29
30
  function _interopRequireDefault(obj) {
@@ -84,7 +85,7 @@ function logUnauthorized(device) {
84
85
  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"))}`);
85
86
  }
86
87
  async function isPackageInstalledAsync(device, androidPackage) {
87
- const packages = await getServer().runAsync(adbArgs(device.pid, "shell", "pm", "list", "packages", androidPackage));
88
+ const packages = await getServer().runAsync(adbArgs(device.pid, "shell", "pm", "list", "packages", "--user", _env.env.EXPO_ADB_USER, androidPackage));
88
89
  const lines = packages.split(/\r?\n/);
89
90
  for(let i = 0; i < lines.length; i++){
90
91
  const line = lines[i].trim();
@@ -114,14 +115,14 @@ async function openUrlAsync(device, { url }) {
114
115
  return results;
115
116
  }
116
117
  async function uninstallAsync(device, { appId }) {
117
- return await getServer().runAsync(adbArgs(device.pid, "uninstall", appId));
118
+ return await getServer().runAsync(adbArgs(device.pid, "uninstall", "--user", _env.env.EXPO_ADB_USER, appId));
118
119
  }
119
120
  async function getPackageInfoAsync(device, { appId }) {
120
121
  return await getServer().runAsync(adbArgs(device.pid, "shell", "dumpsys", "package", appId));
121
122
  }
122
123
  async function installAsync(device, { filePath }) {
123
124
  // TODO: Handle the `INSTALL_FAILED_INSUFFICIENT_STORAGE` error.
124
- return await getServer().runAsync(adbArgs(device.pid, "install", "-r", "-d", filePath));
125
+ return await getServer().runAsync(adbArgs(device.pid, "install", "-r", "-d", "--user", _env.env.EXPO_ADB_USER, filePath));
125
126
  }
126
127
  function adbArgs(pid, ...options) {
127
128
  const args = [];
@@ -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 { 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 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};\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(device.pid, 'shell', 'pm', 'list', 'packages', 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 */\nexport async function launchActivityAsync(\n device: DeviceContext,\n {\n launchActivity,\n }: {\n launchActivity: string;\n }\n) {\n return openAsync(\n adbArgs(\n device.pid,\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}\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(adbArgs(device.pid, 'uninstall', appId));\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(adbArgs(device.pid, 'install', '-r', '-d', filePath));\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 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.trim().replace(/\\n$/, '').split(os.EOL);\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 }[] = 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\n const isAuthorized = props[1] !== 'unauthorized';\n const type = line.includes('emulator') ? 'emulator' : 'device';\n return { props, type, isAuthorized };\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 } = 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 {\n pid,\n name,\n type,\n isAuthorized,\n isBooted: true,\n };\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":["getServer","logUnauthorized","isPackageInstalledAsync","launchActivityAsync","openAppIdAsync","openUrlAsync","uninstallAsync","getPackageInfoAsync","installAsync","adbArgs","getAttachedDevicesAsync","getAdbNameForDeviceIdAsync","isDeviceBootedAsync","isBootAnimationCompleteAsync","getDeviceABIsAsync","getPropertyDataForDeviceAsync","sanitizeAdbDeviceName","Log","debug","require","DeviceABI","arm","arm64","x64","x86","armeabiV7a","armeabi","universal","CANT_START_ACTIVITY_ERROR","PROP_CPU_NAME","PROP_CPU_ABI_LIST_NAME","PROP_BOOT_ANIMATION_STATE","_server","ADBServer","device","warn","chalk","bold","name","dim","learnMore","androidPackage","packages","runAsync","pid","lines","split","i","length","line","trim","launchActivity","openAsync","applicationId","url","replace","String","raw","args","results","includes","match","CommandError","substring","indexOf","appId","filePath","options","push","concat","output","splitItems","os","EOL","attachedDevices","slice","map","props","filter","Boolean","isAuthorized","type","devicePromises","deviceInfo","modelItem","find","info","isBooted","Promise","all","devices","cpuAbiList","abi","prop","propCommand","getFileOutputAsync","parseAdbDeviceProperties","error","message","devicePropertiesString","properties","propertyExp","matchAll","deviceName","shift"],"mappings":"AAAA;;;;QAuDgBA,SAAS,GAATA,SAAS;QAMTC,eAAe,GAAfA,eAAe;QASTC,uBAAuB,GAAvBA,uBAAuB;QAsBvBC,mBAAmB,GAAnBA,mBAAmB;QA4BnBC,cAAc,GAAdA,cAAc;QA0BdC,YAAY,GAAZA,YAAY;QAoCZC,cAAc,GAAdA,cAAc;QAQdC,mBAAmB,GAAnBA,mBAAmB;QAQnBC,YAAY,GAAZA,YAAY;QAMlBC,OAAO,GAAPA,OAAO;QASDC,uBAAuB,GAAvBA,uBAAuB;QAqEvBC,0BAA0B,GAA1BA,0BAA0B;QAW1BC,mBAAmB,GAAnBA,mBAAmB;QAkBnBC,4BAA4B,GAA5BA,4BAA4B;QAU5BC,kBAAkB,GAAlBA,kBAAkB;QAiBlBC,6BAA6B,GAA7BA,6BAA6B;QA2CnCC,qBAAqB,GAArBA,qBAAqB;;AA7XnB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEO,IAAA,UAAa,WAAb,aAAa,CAAA;AAC3BC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,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;KACjG;CACF;AAED,SAASF,wBAAwB,CAACG,sBAA8B,EAAE;IAChE,MAAMC,UAAU,GAAqB,EAAE,AAAC;IACxC,MAAMC,WAAW,2BAA2B,AAAC;IAC7C,KAAK,MAAMxC,KAAK,IAAIsC,sBAAsB,CAACG,QAAQ,CAACD,WAAW,CAAC,CAAE;QAChED,UAAU,CAACvC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,CAAC;KACjC;IACD,OAAOuC,UAAU,CAAC;CACnB;AAMM,SAASpF,qBAAqB,CAACuF,UAAkB,EAAE;IACxD,OAAOA,UAAU,CACdrD,IAAI,EAAE,CACNJ,KAAK,WAAW,CAChB0D,KAAK,EAAE,CAAC;CACZ"}
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 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};\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 */\nexport async function launchActivityAsync(\n device: DeviceContext,\n {\n launchActivity,\n }: {\n launchActivity: string;\n }\n) {\n return openAsync(\n adbArgs(\n device.pid,\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}\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.trim().replace(/\\n$/, '').split(os.EOL);\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 }[] = 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\n const isAuthorized = props[1] !== 'unauthorized';\n const type = line.includes('emulator') ? 'emulator' : 'device';\n return { props, type, isAuthorized };\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 } = 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 {\n pid,\n name,\n type,\n isAuthorized,\n isBooted: true,\n };\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":["getServer","logUnauthorized","isPackageInstalledAsync","launchActivityAsync","openAppIdAsync","openUrlAsync","uninstallAsync","getPackageInfoAsync","installAsync","adbArgs","getAttachedDevicesAsync","getAdbNameForDeviceIdAsync","isDeviceBootedAsync","isBootAnimationCompleteAsync","getDeviceABIsAsync","getPropertyDataForDeviceAsync","sanitizeAdbDeviceName","Log","debug","require","DeviceABI","arm","arm64","x64","x86","armeabiV7a","armeabi","universal","CANT_START_ACTIVITY_ERROR","PROP_CPU_NAME","PROP_CPU_ABI_LIST_NAME","PROP_BOOT_ANIMATION_STATE","_server","ADBServer","device","warn","chalk","bold","name","dim","learnMore","androidPackage","packages","runAsync","pid","env","EXPO_ADB_USER","lines","split","i","length","line","trim","launchActivity","openAsync","applicationId","url","replace","String","raw","args","results","includes","match","CommandError","substring","indexOf","appId","filePath","options","push","concat","output","splitItems","os","EOL","attachedDevices","slice","map","props","filter","Boolean","isAuthorized","type","devicePromises","deviceInfo","modelItem","find","info","isBooted","Promise","all","devices","cpuAbiList","abi","prop","propCommand","getFileOutputAsync","parseAdbDeviceProperties","error","message","devicePropertiesString","properties","propertyExp","matchAll","deviceName","shift"],"mappings":"AAAA;;;;QAwDgBA,SAAS,GAATA,SAAS;QAMTC,eAAe,GAAfA,e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AI,EAAE,CACNJ,KAAK,WAAW,CAChB0D,KAAK,EAAE,CAAC;CACZ"}
@@ -322,8 +322,8 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
322
322
  var ref;
323
323
  return (ref = this.urlCreator) == null ? void 0 : ref.constructDevClientUrl();
324
324
  } else {
325
- var ref3;
326
- return (ref3 = this.urlCreator) == null ? void 0 : ref3.constructUrl({
325
+ var ref2;
326
+ return (ref2 = this.urlCreator) == null ? void 0 : ref2.constructUrl({
327
327
  scheme: "exp"
328
328
  });
329
329
  }
@@ -333,21 +333,21 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
333
333
  middleware.use(new _createFileMiddleware.CreateFileMiddleware(this.projectRoot).getHandler());
334
334
  // Append support for redirecting unhandled requests to the index.html page on web.
335
335
  if (this.isTargetingWeb()) {
336
- var ref4;
337
- const { exp } = (0, _config).getConfig(this.projectRoot, {
336
+ var ref3;
337
+ const config = (0, _config).getConfig(this.projectRoot, {
338
338
  skipSDKVersionRequirement: true
339
339
  });
340
+ const { exp } = config;
340
341
  var ref1;
341
342
  const useServerRendering = [
342
343
  "static",
343
344
  "server"
344
- ].includes((ref1 = (ref4 = exp.web) == null ? void 0 : ref4.output) != null ? ref1 : "");
345
+ ].includes((ref1 = (ref3 = exp.web) == null ? void 0 : ref3.output) != null ? ref1 : "");
345
346
  // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.
346
347
  middleware.use(new _serveStaticMiddleware.ServeStaticMiddleware(this.projectRoot).getHandler());
347
348
  // This should come after the static middleware so it doesn't serve the favicon from `public/favicon.ico`.
348
349
  middleware.use(new _faviconMiddleware.FaviconMiddleware(this.projectRoot).getHandler());
349
350
  if (useServerRendering) {
350
- var ref2;
351
351
  const baseUrl = (0, _metroOptions).getBaseUrlFromExpoConfig(exp);
352
352
  var _mode1;
353
353
  const asyncRoutes = (0, _metroOptions).getAsyncRoutesFromExpoConfig(exp, (_mode1 = options.mode) != null ? _mode1 : "development", "web");
@@ -358,6 +358,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
358
358
  appDir,
359
359
  baseUrl,
360
360
  routerRoot,
361
+ config,
361
362
  getWebBundleUrl: manifestMiddleware.getWebBundleUrl.bind(manifestMiddleware),
362
363
  getStaticPageAsync: (pathname)=>{
363
364
  var _mode;
@@ -371,19 +372,30 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
371
372
  });
372
373
  }
373
374
  }));
374
- if (((ref2 = exp.web) == null ? void 0 : ref2.output) === "server") {
375
- // NOTE(EvanBacon): We aren't sure what files the API routes are using so we'll just invalidate
376
- // aggressively to ensure we always have the latest. The only caching we really get here is for
377
- // cases where the user is making subsequent requests to the same API route without changing anything.
378
- // This is useful for testing but pretty suboptimal. Luckily our caching is pretty aggressive so it makes
379
- // up for a lot of the overhead.
380
- (0, _waitForMetroToObserveTypeScriptFile).observeAnyFileChanges({
381
- metro,
382
- server
383
- }, ()=>{
375
+ (0, _waitForMetroToObserveTypeScriptFile).observeAnyFileChanges({
376
+ metro,
377
+ server
378
+ }, (events)=>{
379
+ var ref;
380
+ if (((ref = exp.web) == null ? void 0 : ref.output) === "server") {
381
+ // NOTE(EvanBacon): We aren't sure what files the API routes are using so we'll just invalidate
382
+ // aggressively to ensure we always have the latest. The only caching we really get here is for
383
+ // cases where the user is making subsequent requests to the same API route without changing anything.
384
+ // This is useful for testing but pretty suboptimal. Luckily our caching is pretty aggressive so it makes
385
+ // up for a lot of the overhead.
384
386
  (0, _bundleApiRoutes).invalidateApiRouteCache();
385
- });
386
- }
387
+ } else if (!(0, _router).hasWarnedAboutApiRoutes()) {
388
+ for (const event of events){
389
+ var // If the user did not delete a file that matches the Expo Router API Route convention, then we should warn that
390
+ // API Routes are not enabled in the project.
391
+ ref4;
392
+ if (((ref4 = event.metadata) == null ? void 0 : ref4.type) !== "d" && // Ensure the file is in the project's routes directory to prevent false positives in monorepos.
393
+ event.filePath.startsWith(appDir) && (0, _router).isApiRouteConvention(event.filePath)) {
394
+ (0, _router).warnInvalidWebOutput();
395
+ }
396
+ }
397
+ }
398
+ });
387
399
  } else {
388
400
  // This MUST run last since it's the fallback.
389
401
  middleware.use(new _historyFallbackMiddleware.HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler());