@expo/cli 0.17.1 → 0.17.3

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 (26) hide show
  1. package/build/bin/cli +2 -2
  2. package/build/src/export/metroAssetLocalPath.js +2 -1
  3. package/build/src/export/metroAssetLocalPath.js.map +1 -1
  4. package/build/src/prebuild/resolveTemplate.js +26 -9
  5. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  6. package/build/src/start/interface/interactiveActions.js +13 -9
  7. package/build/src/start/interface/interactiveActions.js.map +1 -1
  8. package/build/src/start/interface/startInterface.js +1 -1
  9. package/build/src/start/interface/startInterface.js.map +1 -1
  10. package/build/src/start/server/getStaticRenderFunctions.js +65 -15
  11. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  12. package/build/src/start/server/metro/MetroBundlerDevServer.js +1 -1
  13. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  14. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  15. package/build/src/start/server/metro/createServerRouteMiddleware.js +3 -2
  16. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  17. package/build/src/start/server/metro/metroErrorInterface.js +8 -2
  18. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  19. package/build/src/start/server/middleware/metroOptions.js +6 -3
  20. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  21. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  22. package/build/src/utils/createFileTransform.js +12 -0
  23. package/build/src/utils/createFileTransform.js.map +1 -1
  24. package/build/src/utils/npm.js +2 -1
  25. package/build/src/utils/npm.js.map +1 -1
  26. package/package.json +6 -3
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.17.1");
140
+ console.log("0.17.3");
141
141
  process.exit(0);
142
142
  }
143
143
  if (args["--non-interactive"]) {
@@ -272,7 +272,7 @@ commands[command]().then((exec)=>{
272
272
  logEventAsync("action", {
273
273
  action: `expo ${command}`,
274
274
  source: "expo/cli",
275
- source_version: "0.17.1"
275
+ source_version: "0.17.3"
276
276
  });
277
277
  }
278
278
  });
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.getAssetLocalPath = getAssetLocalPath;
6
6
  exports.stripAssetPrefix = stripAssetPrefix;
7
+ exports.drawableFileTypes = void 0;
7
8
  var _path = _interopRequireDefault(require("path"));
8
9
  function _interopRequireDefault(obj) {
9
10
  return obj && obj.__esModule ? obj : {
@@ -65,7 +66,6 @@ function stripAssetPrefix(path, baseUrl) {
65
66
  return null;
66
67
  }
67
68
  }
68
- // See https://developer.android.com/guide/topics/resources/drawable-resource.html
69
69
  const drawableFileTypes = new Set([
70
70
  "gif",
71
71
  "jpeg",
@@ -74,6 +74,7 @@ const drawableFileTypes = new Set([
74
74
  "webp",
75
75
  "xml"
76
76
  ]);
77
+ exports.drawableFileTypes = drawableFileTypes;
77
78
  function getAndroidResourceFolderName(asset, scale) {
78
79
  if (!drawableFileTypes.has(asset.type)) {
79
80
  return "raw";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/metroAssetLocalPath.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\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 *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nexport function getAssetLocalPath(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale, platform }: { baseUrl?: string; scale: number; platform: string }\n): string {\n if (platform === 'android') {\n return getAssetLocalPathAndroid(asset, { baseUrl, scale });\n }\n return getAssetLocalPathDefault(asset, { baseUrl, scale });\n}\n\nfunction getAssetLocalPathAndroid(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n {\n baseUrl,\n scale,\n }: {\n // TODO: baseUrl support\n baseUrl?: string;\n scale: number;\n }\n): string {\n const androidFolder = getAndroidResourceFolderName(asset, scale);\n const fileName = getResourceIdentifier(asset);\n return path.join(androidFolder, `${fileName}.${asset.type}`);\n}\n\nfunction getAssetLocalPathDefault(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale }: { baseUrl?: string; scale: number }\n): string {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n const fileName = `${asset.name}${suffix}.${asset.type}`;\n\n const adjustedHttpServerLocation = stripAssetPrefix(asset.httpServerLocation, baseUrl);\n\n return path.join(\n // Assets can have relative paths outside of the project root.\n // Replace `../` with `_` to make sure they don't end up outside of\n // the expected assets directory.\n adjustedHttpServerLocation.replace(/^\\/+/g, '').replace(/\\.\\.\\//g, '_'),\n fileName\n );\n}\n\nexport function stripAssetPrefix(path: string, baseUrl?: string) {\n path = path.replace(/\\/assets\\?export_path=(.*)/, '$1');\n\n // TODO: Windows?\n if (baseUrl) {\n return path.replace(/^\\/+/g, '').replace(\n new RegExp(\n `^${baseUrl\n .replace(/^\\/+/g, '')\n .replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&')\n .replace(/-/g, '\\\\x2d')}`,\n 'g'\n ),\n ''\n );\n }\n return path;\n}\n\n/**\n * FIXME: using number to represent discrete scale numbers is fragile in essence because of\n * floating point numbers imprecision.\n */\nfunction getAndroidAssetSuffix(scale: number): string | null {\n switch (scale) {\n case 0.75:\n return 'ldpi';\n case 1:\n return 'mdpi';\n case 1.5:\n return 'hdpi';\n case 2:\n return 'xhdpi';\n case 3:\n return 'xxhdpi';\n case 4:\n return 'xxxhdpi';\n default:\n return null;\n }\n}\n\n// See https://developer.android.com/guide/topics/resources/drawable-resource.html\nconst drawableFileTypes = new Set<string>(['gif', 'jpeg', 'jpg', 'png', 'webp', 'xml']);\n\nfunction getAndroidResourceFolderName(asset: Pick<AssetData, 'type'>, scale: number): string {\n if (!drawableFileTypes.has(asset.type)) {\n return 'raw';\n }\n const suffix = getAndroidAssetSuffix(scale);\n if (!suffix) {\n throw new Error(\n `Asset \"${JSON.stringify(asset)}\" does not use a supported Android resolution suffix`\n );\n }\n return `drawable-${suffix}`;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["getAssetLocalPath","stripAssetPrefix","asset","baseUrl","scale","platform","getAssetLocalPathAndroid","getAssetLocalPathDefault","androidFolder","getAndroidResourceFolderName","fileName","getResourceIdentifier","path","join","type","suffix","name","adjustedHttpServerLocation","httpServerLocation","replace","RegExp","getAndroidAssetSuffix","drawableFileTypes","Set","has","Error","JSON","stringify","folderPath","getBaseUrl","toLowerCase","substring"],"mappings":"AAUA;;;;QAGgBA,iBAAiB,GAAjBA,iBAAiB;QA4CjBC,gBAAgB,GAAhBA,gBAAgB;AA9Cf,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAEhB,SAASD,iBAAiB,CAC/BE,KAA8D,EAC9D,EAAEC,OAAO,CAAA,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAyD,EAC3E;IACR,IAAIA,QAAQ,KAAK,SAAS,EAAE;QAC1B,OAAOC,wBAAwB,CAACJ,KAAK,EAAE;YAAEC,OAAO;YAAEC,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EAAEa,MAAM,CAAC,CAAC,CAAC;CAC7B;AAED,SAASJ,qBAAqB,CAACT,KAAqD,EAAU;IAC5F,MAAM0B,UAAU,GAAGC,UAAU,CAAC3B,KAAK,CAAC,AAAC;IACrC,OAAO,CAAC,EAAE0B,UAAU,CAAC,CAAC,EAAE1B,KAAK,CAACc,IAAI,CAAC,CAAC,CACjCc,WAAW,EAAE,CACbX,OAAO,QAAQ,GAAG,CAAC,CAAC,uCAAuC;KAC3DA,OAAO,kBAAkB,EAAE,CAAC,CAAC,uBAAuB;KACpDA,OAAO,aAAa,EAAE,CAAC,CAAC,CAAC,0BAA0B;CACvD;AAED,SAASU,UAAU,CAAC3B,KAA4C,EAAU;IACxE,IAAIC,OAAO,GAAGD,KAAK,CAACgB,kBAAkB,AAAC;IACvC,IAAIf,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtBA,OAAO,GAAGA,OAAO,CAAC4B,SAAS,CAAC,CAAC,CAAC,CAAC;KAChC;IACD,OAAO5B,OAAO,CAAC;CAChB"}
1
+ {"version":3,"sources":["../../../src/export/metroAssetLocalPath.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\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 *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nexport function getAssetLocalPath(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale, platform }: { baseUrl?: string; scale: number; platform: string }\n): string {\n if (platform === 'android') {\n return getAssetLocalPathAndroid(asset, { baseUrl, scale });\n }\n return getAssetLocalPathDefault(asset, { baseUrl, scale });\n}\n\nfunction getAssetLocalPathAndroid(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n {\n baseUrl,\n scale,\n }: {\n // TODO: baseUrl support\n baseUrl?: string;\n scale: number;\n }\n): string {\n const androidFolder = getAndroidResourceFolderName(asset, scale);\n const fileName = getResourceIdentifier(asset);\n return path.join(androidFolder, `${fileName}.${asset.type}`);\n}\n\nfunction getAssetLocalPathDefault(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale }: { baseUrl?: string; scale: number }\n): string {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n const fileName = `${asset.name}${suffix}.${asset.type}`;\n\n const adjustedHttpServerLocation = stripAssetPrefix(asset.httpServerLocation, baseUrl);\n\n return path.join(\n // Assets can have relative paths outside of the project root.\n // Replace `../` with `_` to make sure they don't end up outside of\n // the expected assets directory.\n adjustedHttpServerLocation.replace(/^\\/+/g, '').replace(/\\.\\.\\//g, '_'),\n fileName\n );\n}\n\nexport function stripAssetPrefix(path: string, baseUrl?: string) {\n path = path.replace(/\\/assets\\?export_path=(.*)/, '$1');\n\n // TODO: Windows?\n if (baseUrl) {\n return path.replace(/^\\/+/g, '').replace(\n new RegExp(\n `^${baseUrl\n .replace(/^\\/+/g, '')\n .replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&')\n .replace(/-/g, '\\\\x2d')}`,\n 'g'\n ),\n ''\n );\n }\n return path;\n}\n\n/**\n * FIXME: using number to represent discrete scale numbers is fragile in essence because of\n * floating point numbers imprecision.\n */\nfunction getAndroidAssetSuffix(scale: number): string | null {\n switch (scale) {\n case 0.75:\n return 'ldpi';\n case 1:\n return 'mdpi';\n case 1.5:\n return 'hdpi';\n case 2:\n return 'xhdpi';\n case 3:\n return 'xxhdpi';\n case 4:\n return 'xxxhdpi';\n default:\n return null;\n }\n}\n\n// See https://developer.android.com/guide/topics/resources/drawable-resource.html\nexport const drawableFileTypes = new Set<string>(['gif', 'jpeg', 'jpg', 'png', 'webp', 'xml']);\n\nfunction getAndroidResourceFolderName(asset: Pick<AssetData, 'type'>, scale: number): string {\n if (!drawableFileTypes.has(asset.type)) {\n return 'raw';\n }\n const suffix = getAndroidAssetSuffix(scale);\n if (!suffix) {\n throw new Error(\n `Asset \"${JSON.stringify(asset)}\" does not use a supported Android resolution suffix`\n );\n }\n return `drawable-${suffix}`;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["getAssetLocalPath","stripAssetPrefix","asset","baseUrl","scale","platform","getAssetLocalPathAndroid","getAssetLocalPathDefault","androidFolder","getAndroidResourceFolderName","fileName","getResourceIdentifier","path","join","type","suffix","name","adjustedHttpServerLocation","httpServerLocation","replace","RegExp","getAndroidAssetSuffix","drawableFileTypes","Set","has","Error","JSON","stringify","folderPath","getBaseUrl","toLowerCase","substring"],"mappings":"AAUA;;;;QAGgBA,iBAAiB,GAAjBA,iBAAiB;QA4CjBC,gBAAgB,GAAhBA,gBAAgB;;AA9Cf,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAEhB,SAASD,iBAAiB,CAC/BE,KAA8D,EAC9D,EAAEC,OAAO,CAAA,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAyD,EAC3E;IACR,IAAIA,QAAQ,KAAK,SAAS,EAAE;QAC1B,OAAOC,wBAAwB,CAACJ,KAAK,EAAE;YAAEC,OAAO;YAAEC,KAAK;SAAE,CAAC,CAAC;KAC5D;IACD,OAAOG,wBAAwB,CAACL,KAAK,EAAE;QAAEC,OAAO;QAAEC,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qD,EAAU;IAC5F,MAAM0B,UAAU,GAAGC,UAAU,CAAC3B,KAAK,CAAC,AAAC;IACrC,OAAO,CAAC,EAAE0B,UAAU,CAAC,CAAC,EAAE1B,KAAK,CAACc,IAAI,CAAC,CAAC,CACjCc,WAAW,EAAE,CACbX,OAAO,QAAQ,GAAG,CAAC,CAAC,uCAAuC;KAC3DA,OAAO,kBAAkB,EAAE,CAAC,CAAC,uBAAuB;KACpDA,OAAO,aAAa,EAAE,CAAC,CAAC,CAAC,0BAA0B;CACvD;AAED,SAASU,UAAU,CAAC3B,KAA4C,EAAU;IACxE,IAAIC,OAAO,GAAGD,KAAK,CAACgB,kBAAkB,AAAC;IACvC,IAAIf,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtBA,OAAO,GAAGA,OAAO,CAAC4B,SAAS,CAAC,CAAC,CAAC,CAAC;KAChC;IACD,OAAO5B,OAAO,CAAC;CAChB"}
@@ -11,6 +11,7 @@ var _path = _interopRequireDefault(require("path"));
11
11
  var _semver = _interopRequireDefault(require("semver"));
12
12
  var _client = require("../api/rest/client");
13
13
  var Log = _interopRequireWildcard(require("../log"));
14
+ var _createFileTransform = require("../utils/createFileTransform");
14
15
  var _errors = require("../utils/errors");
15
16
  var _npm = require("../utils/npm");
16
17
  var _url = require("../utils/url");
@@ -95,18 +96,31 @@ function hasRepo({ username , name , branch , filePath }) {
95
96
  const packagePath = `${filePath ? `/${filePath}` : ""}/package.json`;
96
97
  return (0, _url).isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);
97
98
  }
98
- async function downloadAndExtractRepoAsync(root, { username , name , branch , filePath }) {
99
- const projectName = _path.default.basename(root);
100
- const strip = filePath ? filePath.split("/").length + 1 : 1;
99
+ async function downloadAndExtractRepoAsync({ username , name , branch , filePath }, props) {
101
100
  const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;
102
101
  debug("Downloading tarball from:", url);
102
+ // Extract the (sub)directory into non-empty path segments
103
+ const directory = filePath.replace(/^\//, "").split("/").filter(Boolean);
104
+ // Remove the (sub)directory paths, and the root folder added by GitHub
105
+ const strip = directory.length + 1;
106
+ // Only extract the relevant (sub)directories, ignoring irrelevant files
107
+ // The filder auto-ignores dotfiles, unless explicitly included
108
+ const filter = (0, _createFileTransform).createGlobFilter(!directory.length ? [
109
+ "*/**",
110
+ "*/ios/.xcode.env"
111
+ ] : [
112
+ `*/${directory.join("/")}/**`,
113
+ `*/${directory.join("/")}/ios/.xcode.env`
114
+ ], {
115
+ // Always ignore the `.xcworkspace` folder
116
+ ignore: [
117
+ "**/ios/*.xcworkspace/**"
118
+ ]
119
+ });
103
120
  return await (0, _npm).extractNpmTarballFromUrlAsync(url, {
104
- cwd: root,
105
- name: projectName,
121
+ ...props,
106
122
  strip,
107
- fileList: [
108
- `${name}-${branch}${filePath ? `/${filePath}` : ""}`
109
- ]
123
+ filter
110
124
  });
111
125
  }
112
126
  async function resolveTemplateArgAsync(templateDirectory, oraInstance, appName, template, templatePath) {
@@ -150,7 +164,10 @@ async function resolveTemplateArgAsync(templateDirectory, oraInstance, appName,
150
164
  throw new _errors.AbortCommandError();
151
165
  }
152
166
  oraInstance.text = _chalk.default.bold(`Downloading files from repo ${_chalk.default.cyan(template)}. This might take a moment.`);
153
- return await downloadAndExtractRepoAsync(templateDirectory, repoInfo);
167
+ return await downloadAndExtractRepoAsync(repoInfo, {
168
+ cwd: templateDirectory,
169
+ name: appName
170
+ });
154
171
  }
155
172
 
156
173
  //# sourceMappingURL=resolveTemplate.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}): Promise<string> {\n if (template) {\n return await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n return await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n root: string,\n { username, name, branch, filePath }: RepoInfo\n): Promise<string> {\n const projectName = path.basename(root);\n\n const strip = filePath ? filePath.split('/').length + 1 : 1;\n\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n debug('Downloading tarball from:', url);\n return await extractNpmTarballFromUrlAsync(url, {\n cwd: root,\n name: projectName,\n strip,\n fileList: [`${name}-${branch}${filePath ? `/${filePath}` : ''}`],\n });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n): Promise<string> {\n assert(template, 'template is required');\n\n let repoUrl: URL | undefined;\n\n try {\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n // On Windows, we can actually create a URL from a local path\n // Double-check if the created URL is not a path to avoid mixing up URLs and paths\n if (process.platform === 'win32' && repoUrl && path.isAbsolute(repoUrl.toString())) {\n repoUrl = undefined;\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n return await extractLocalNpmTarballAsync(templatePath, {\n cwd: templateDirectory,\n name: appName,\n });\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n return await downloadAndExtractRepoAsync(templateDirectory, repoInfo);\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","root","projectName","path","basename","strip","length","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","assert","repoUrl","URL","error","code","fail","process","platform","isAbsolute","toString","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red","AbortCommandError","repoInfo","found","text","bold","cyan"],"mappings":"AAAA;;;;QA2BsBA,kBAAkB,GAAlBA,kBAAkB;QAmFlBC,uBAAuB,GAAvBA,uBAAuB;AA7G1B,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACJ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEA,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACnCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACiC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAK1D,IAAA,IAAc,WAAd,cAAc,CAAA;AACG,IAAA,IAAc,WAAd,cAAc,CAAA;;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;QACF,MAAM,IAAIkE,OAAiB,kBAAA,EAAE,CAAC;KAC/B;IAED,MAAMC,QAAQ,GAAG,MAAMvD,WAAW,CAACqC,OAAO,EAAEF,YAAY,CAAC,AAAC;IAE1D,IAAI,CAACoB,QAAQ,EAAE;QACbtB,WAAW,CAACQ,IAAI,CACd,CAAC,0BAA0B,EAAEW,MAAK,QAAA,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEjE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAC7F,CAAC;QACF,MAAM,IAAIkE,OAAiB,kBAAA,EAAE,CAAC;KAC/B;IAED,MAAME,KAAK,GAAG,MAAMpC,OAAO,CAACmC,QAAQ,CAAC,AAAC;IAEtC,IAAI,CAACC,KAAK,EAAE;QACVvB,WAAW,CAACQ,IAAI,CACd,CAAC,oCAAoC,EAAEW,MAAK,QAAA,CAACC,GAAG,CAC9C,CAAC,CAAC,EAAEjE,QAAQ,CAAC,CAAC,CAAC,CAChB,CAAC,wDAAwD,CAAC,CAC5D,CAAC;QACF,MAAM,IAAIkE,OAAiB,kBAAA,EAAE,CAAC;KAC/B;IAEDrB,WAAW,CAACwB,IAAI,GAAGL,MAAK,QAAA,CAACM,IAAI,CAC3B,CAAC,4BAA4B,EAAEN,MAAK,QAAA,CAACO,IAAI,CAACvE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;IAEF,OAAO,MAAMoC,2BAA2B,CAACrC,iBAAiB,EAAEoE,QAAQ,CAAC,CAAC;CACvE"}
1
+ {"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { createGlobFilter } from '../utils/createFileTransform';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n ExtractProps,\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}): Promise<string> {\n if (template) {\n return await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n return await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n { username, name, branch, filePath }: RepoInfo,\n props: ExtractProps\n): Promise<string> {\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n\n debug('Downloading tarball from:', url);\n\n // Extract the (sub)directory into non-empty path segments\n const directory = filePath.replace(/^\\//, '').split('/').filter(Boolean);\n // Remove the (sub)directory paths, and the root folder added by GitHub\n const strip = directory.length + 1;\n // Only extract the relevant (sub)directories, ignoring irrelevant files\n // The filder auto-ignores dotfiles, unless explicitly included\n const filter = createGlobFilter(\n !directory.length\n ? ['*/**', '*/ios/.xcode.env']\n : [`*/${directory.join('/')}/**`, `*/${directory.join('/')}/ios/.xcode.env`],\n {\n // Always ignore the `.xcworkspace` folder\n ignore: ['**/ios/*.xcworkspace/**'],\n }\n );\n\n return await extractNpmTarballFromUrlAsync(url, { ...props, strip, filter });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n): Promise<string> {\n assert(template, 'template is required');\n\n let repoUrl: URL | undefined;\n\n try {\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n // On Windows, we can actually create a URL from a local path\n // Double-check if the created URL is not a path to avoid mixing up URLs and paths\n if (process.platform === 'win32' && repoUrl && path.isAbsolute(repoUrl.toString())) {\n repoUrl = undefined;\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n return await extractLocalNpmTarballAsync(templatePath, {\n cwd: templateDirectory,\n name: appName,\n });\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n return await downloadAndExtractRepoAsync(repoInfo, {\n cwd: templateDirectory,\n name: appName,\n });\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","props","directory","filter","Boolean","strip","length","createGlobFilter","ignore","extractNpmTarballFromUrlAsync","oraInstance","appName","templatePath","assert","repoUrl","URL","error","code","fail","process","platform","path","isAbsolute","toString","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red","AbortCommandError","repoInfo","found","text","bold","cyan"],"mappings":"AAAA;;;;QA6BsBA,kBAAkB,GAAlBA,kBAAkB;QA4FlBC,uBAAuB,GAAvBA,uBAAuB;AAxH1B,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,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AC,CAChB,CAAC,wDAAwD,CAAC,CAC5D,CAAC;QACF,MAAM,IAAIoE,OAAiB,kBAAA,EAAE,CAAC;KAC/B;IAEDtB,WAAW,CAACyB,IAAI,GAAGL,MAAK,QAAA,CAACM,IAAI,CAC3B,CAAC,4BAA4B,EAAEN,MAAK,QAAA,CAACO,IAAI,CAACzE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;IAEF,OAAO,MAAMoC,2BAA2B,CAACiC,QAAQ,EAAE;QACjD7D,GAAG,EAAET,iBAAiB;QACtBI,IAAI,EAAE4C,OAAO;KACd,CAAC,CAAC;CACJ"}
@@ -39,10 +39,12 @@ function _interopRequireWildcard(obj) {
39
39
  }
40
40
  const debug = require("debug")("expo:start:interface:interactiveActions");
41
41
  class DevServerManagerActions {
42
- constructor(devServerManager){
42
+ constructor(devServerManager, options){
43
43
  this.devServerManager = devServerManager;
44
+ this.options = options;
44
45
  }
45
46
  printDevServerInfo(options) {
47
+ var ref;
46
48
  // If native dev server is running, print its URL.
47
49
  if (this.devServerManager.getNativeDevServerPort()) {
48
50
  const devServer = this.devServerManager.getDefaultDevServer();
@@ -72,13 +74,15 @@ class DevServerManagerActions {
72
74
  }
73
75
  }
74
76
  }
75
- const webDevServer = this.devServerManager.getWebDevServer();
76
- const webUrl = webDevServer == null ? void 0 : webDevServer.getDevServerUrl({
77
- hostType: "localhost"
78
- });
79
- if (webUrl) {
80
- Log.log();
81
- Log.log((0, _commandsTable).printItem(_chalk.default`Web is waiting on {underline ${webUrl}}`));
77
+ if ((ref = this.options.platforms) == null ? void 0 : ref.includes("web")) {
78
+ const webDevServer = this.devServerManager.getWebDevServer();
79
+ const webUrl = webDevServer == null ? void 0 : webDevServer.getDevServerUrl({
80
+ hostType: "localhost"
81
+ });
82
+ if (webUrl) {
83
+ Log.log();
84
+ Log.log((0, _commandsTable).printItem(_chalk.default`Web is waiting on {underline ${webUrl}}`));
85
+ }
82
86
  }
83
87
  (0, _commandsTable).printUsage(options, {
84
88
  verbose: false
@@ -149,7 +153,7 @@ class DevServerManagerActions {
149
153
  {
150
154
  title: "Open React devtools",
151
155
  value: "openReactDevTools",
152
- action: this.openReactDevToolsAsync
156
+ action: this.openReactDevToolsAsync.bind(this)
153
157
  }
154
158
  ];
155
159
  const pluginMenuItems = (await this.devServerManager.devtoolsPluginManager.queryPluginsAsync()).map((plugin)=>({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/interface/interactiveActions.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { BLT, printHelp, printItem, printQRCode, printUsage, StartOptions } from './commandsTable';\nimport * as Log from '../../log';\nimport { delayAsync } from '../../utils/delay';\nimport { learnMore } from '../../utils/link';\nimport { openBrowserAsync } from '../../utils/open';\nimport { ExpoChoice, selectAsync } from '../../utils/prompts';\nimport { DevServerManager } from '../server/DevServerManager';\nimport {\n addReactDevToolsReloadListener,\n startReactDevToolsProxyAsync,\n} from '../server/ReactDevToolsProxy';\nimport {\n MetroInspectorProxyApp,\n openJsInspector,\n queryAllInspectorAppsAsync,\n} from '../server/middleware/inspector/JsInspector';\n\nconst debug = require('debug')('expo:start:interface:interactiveActions') as typeof console.log;\n\ninterface MoreToolMenuItem extends ExpoChoice<string> {\n action?: () => unknown;\n}\n\n/** Wraps the DevServerManager and adds an interface for user actions. */\nexport class DevServerManagerActions {\n constructor(private devServerManager: DevServerManager) {}\n\n printDevServerInfo(\n options: Pick<StartOptions, 'devClient' | 'isWebSocketsEnabled' | 'platforms'>\n ) {\n // If native dev server is running, print its URL.\n if (this.devServerManager.getNativeDevServerPort()) {\n const devServer = this.devServerManager.getDefaultDevServer();\n try {\n const nativeRuntimeUrl = devServer.getNativeRuntimeUrl()!;\n const interstitialPageUrl = devServer.getRedirectUrl();\n\n printQRCode(interstitialPageUrl ?? nativeRuntimeUrl);\n\n if (interstitialPageUrl) {\n Log.log(\n printItem(\n chalk`Choose an app to open your project at {underline ${interstitialPageUrl}}`\n )\n );\n }\n Log.log(printItem(chalk`Metro waiting on {underline ${nativeRuntimeUrl}}`));\n if (options.devClient === false) {\n // TODO: if development build, change this message!\n Log.log(\n printItem('Scan the QR code above with Expo Go (Android) or the Camera app (iOS)')\n );\n } else {\n Log.log(\n printItem(\n 'Scan the QR code above to open the project in a development build. ' +\n learnMore('https://expo.fyi/start')\n )\n );\n }\n } catch (error) {\n console.log('err', error);\n // @ts-ignore: If there is no development build scheme, then skip the QR code.\n if (error.code !== 'NO_DEV_CLIENT_SCHEME') {\n throw error;\n } else {\n const serverUrl = devServer.getDevServerUrl();\n Log.log(printItem(chalk`Metro waiting on {underline ${serverUrl}}`));\n Log.log(printItem(`Linking is disabled because the client scheme cannot be resolved.`));\n }\n }\n }\n\n const webDevServer = this.devServerManager.getWebDevServer();\n const webUrl = webDevServer?.getDevServerUrl({ hostType: 'localhost' });\n if (webUrl) {\n Log.log();\n Log.log(printItem(chalk`Web is waiting on {underline ${webUrl}}`));\n }\n\n printUsage(options, { verbose: false });\n printHelp();\n Log.log();\n }\n\n async openJsInspectorAsync() {\n const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n let app: MetroInspectorProxyApp | null = null;\n\n if (!apps.length) {\n return Log.warn(\n chalk`{bold Debug:} No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine. ${learnMore(\n 'https://docs.expo.dev/guides/using-hermes/'\n )}`\n );\n }\n\n if (apps.length === 1) {\n app = apps[0];\n } else {\n const choices = apps.map((app) => ({\n title: app.deviceName ?? 'Unknown device',\n value: app.id,\n app,\n }));\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n const menuItem = choices.find((item) => item.value === value);\n if (!menuItem) {\n return Log.error(chalk`{bold Debug:} No device available for \"${value}\"`);\n }\n\n app = menuItem.app;\n }\n\n if (!app) {\n return Log.error(chalk`{bold Debug:} No device selected`);\n }\n\n try {\n await openJsInspector(metroServerOrigin, app);\n } catch (error: any) {\n Log.error('Failed to open JavaScript inspector. This is often an issue with Google Chrome.');\n Log.exception(error);\n }\n }\n\n reloadApp() {\n Log.log(`${BLT} Reloading apps`);\n // Send reload requests over the dev servers\n this.devServerManager.broadcastMessage('reload');\n }\n\n async openMoreToolsAsync() {\n // Options match: Chrome > View > Developer\n try {\n const defaultMenuItems: MoreToolMenuItem[] = [\n { title: 'Inspect elements', value: 'toggleElementInspector' },\n { title: 'Toggle performance monitor', value: 'togglePerformanceMonitor' },\n { title: 'Toggle developer menu', value: 'toggleDevMenu' },\n { title: 'Reload app', value: 'reload' },\n {\n title: 'Open React devtools',\n value: 'openReactDevTools',\n action: this.openReactDevToolsAsync,\n },\n // TODO: Maybe a \"View Source\" option to open code.\n ];\n const pluginMenuItems = (\n await this.devServerManager.devtoolsPluginManager.queryPluginsAsync()\n ).map((plugin) => ({\n title: chalk`Open devtools plugin - {bold ${plugin.packageName}}`,\n value: `devtoolsPlugin:${plugin.packageName}`,\n action: async () => {\n const url = new URL(\n plugin.webpageEndpoint,\n this.devServerManager\n .getDefaultDevServer()\n .getUrlCreator()\n .constructUrl({ scheme: 'http' })\n );\n await openBrowserAsync(url.toString());\n },\n }));\n const menuItems = [...defaultMenuItems, ...pluginMenuItems];\n const value = await selectAsync(chalk`Dev tools {dim (native only)}`, menuItems);\n const menuItem = menuItems.find((item) => item.value === value);\n if (menuItem?.action) {\n menuItem.action();\n } else if (menuItem?.value) {\n this.devServerManager.broadcastMessage('sendDevCommand', { name: menuItem.value });\n }\n } catch (error: any) {\n debug(error);\n // do nothing\n } finally {\n printHelp();\n }\n }\n\n async openReactDevToolsAsync() {\n await startReactDevToolsProxyAsync();\n const url = this.devServerManager.getDefaultDevServer().getReactDevToolsUrl();\n await openBrowserAsync(url);\n addReactDevToolsReloadListener(() => {\n this.reconnectReactDevTools();\n });\n this.reconnectReactDevTools();\n }\n\n async reconnectReactDevTools() {\n // Wait a little time for react-devtools to be initialized in browser\n await delayAsync(3000);\n this.devServerManager.broadcastMessage('sendDevCommand', { name: 'reconnectReactDevTools' });\n }\n\n toggleDevMenu() {\n Log.log(`${BLT} Toggling dev menu`);\n this.devServerManager.broadcastMessage('devMenu');\n }\n}\n"],"names":["Log","debug","require","DevServerManagerActions","constructor","devServerManager","printDevServerInfo","options","getNativeDevServerPort","devServer","getDefaultDevServer","nativeRuntimeUrl","getNativeRuntimeUrl","interstitialPageUrl","getRedirectUrl","printQRCode","log","printItem","chalk","devClient","learnMore","error","console","code","serverUrl","getDevServerUrl","webDevServer","getWebDevServer","webUrl","hostType","printUsage","verbose","printHelp","openJsInspectorAsync","metroServerOrigin","getJsInspectorBaseUrl","apps","queryAllInspectorAppsAsync","app","length","warn","choices","map","title","deviceName","value","id","selectAsync","menuItem","find","item","openJsInspector","exception","reloadApp","BLT","broadcastMessage","openMoreToolsAsync","defaultMenuItems","action","openReactDevToolsAsync","pluginMenuItems","devtoolsPluginManager","queryPluginsAsync","plugin","packageName","url","URL","webpageEndpoint","getUrlCreator","constructUrl","scheme","openBrowserAsync","toString","menuItems","name","startReactDevToolsProxyAsync","getReactDevToolsUrl","addReactDevToolsReloadListener","reconnectReactDevTools","delayAsync","toggleDevMenu"],"mappings":"AAAA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEwD,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACtFA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACY,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AACpB,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACX,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACX,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AAKtD,IAAA,mBAA8B,WAA9B,8BAA8B,CAAA;AAK9B,IAAA,YAA4C,WAA5C,4CAA4C,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yCAAyC,CAAC,AAAsB,AAAC;AAO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,CAACH,KAAK;iBAAE,CAAC,CAAC;aACpF;SACF,CAAC,OAAOxB,KAAK,EAAO;YACnBpB,KAAK,CAACoB,KAAK,CAAC,CAAC;QACb,aAAa;SACd,QAAS;YACRW,CAAAA,GAAAA,cAAS,AAAE,CAAA,UAAF,EAAE,CAAC;SACb;KACF;IAED,MAAM2B,sBAAsB,GAAG;QAC7B,MAAMgB,CAAAA,GAAAA,mBAA4B,AAAE,CAAA,6BAAF,EAAE,CAAC;QACrC,MAAMV,GAAG,GAAG,IAAI,CAAC5D,gBAAgB,CAACK,mBAAmB,EAAE,CAACkE,mBAAmB,EAAE,AAAC;QAC9E,MAAML,CAAAA,GAAAA,KAAgB,AAAK,CAAA,iBAAL,CAACN,GAAG,CAAC,CAAC;QAC5BY,CAAAA,GAAAA,mBAA8B,AAE5B,CAAA,+BAF4B,CAAC,IAAM;YACnC,IAAI,CAACC,sBAAsB,EAAE,CAAC;SAC/B,CAAC,CAAC;QACH,IAAI,CAACA,sBAAsB,EAAE,CAAC;KAC/B;IAED,MAAMA,sBAAsB,GAAG;QAC7B,qEAAqE;QACrE,MAAMC,CAAAA,GAAAA,MAAU,AAAM,CAAA,WAAN,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC1E,gBAAgB,CAACkD,gBAAgB,CAAC,gBAAgB,EAAE;YAAEmB,IAAI,EAAE,wBAAwB;SAAE,CAAC,CAAC;KAC9F;IAEDM,aAAa,GAAG;QACdhF,GAAG,CAACgB,GAAG,CAAC,CAAC,EAAEsC,cAAG,IAAA,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpC,IAAI,CAACjD,gBAAgB,CAACkD,gBAAgB,CAAC,SAAS,CAAC,CAAC;KACnD;CACF;QAjLYpD,uBAAuB,GAAvBA,uBAAuB"}
1
+ {"version":3,"sources":["../../../../src/start/interface/interactiveActions.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { BLT, printHelp, printItem, printQRCode, printUsage, StartOptions } from './commandsTable';\nimport * as Log from '../../log';\nimport { delayAsync } from '../../utils/delay';\nimport { learnMore } from '../../utils/link';\nimport { openBrowserAsync } from '../../utils/open';\nimport { ExpoChoice, selectAsync } from '../../utils/prompts';\nimport { DevServerManager } from '../server/DevServerManager';\nimport {\n addReactDevToolsReloadListener,\n startReactDevToolsProxyAsync,\n} from '../server/ReactDevToolsProxy';\nimport {\n MetroInspectorProxyApp,\n openJsInspector,\n queryAllInspectorAppsAsync,\n} from '../server/middleware/inspector/JsInspector';\n\nconst debug = require('debug')('expo:start:interface:interactiveActions') as typeof console.log;\n\ninterface MoreToolMenuItem extends ExpoChoice<string> {\n action?: () => unknown;\n}\n\n/** Wraps the DevServerManager and adds an interface for user actions. */\nexport class DevServerManagerActions {\n constructor(\n private devServerManager: DevServerManager,\n private options: Pick<StartOptions, 'devClient' | 'platforms'>\n ) {}\n\n printDevServerInfo(\n options: Pick<StartOptions, 'devClient' | 'isWebSocketsEnabled' | 'platforms'>\n ) {\n // If native dev server is running, print its URL.\n if (this.devServerManager.getNativeDevServerPort()) {\n const devServer = this.devServerManager.getDefaultDevServer();\n try {\n const nativeRuntimeUrl = devServer.getNativeRuntimeUrl()!;\n const interstitialPageUrl = devServer.getRedirectUrl();\n\n printQRCode(interstitialPageUrl ?? nativeRuntimeUrl);\n\n if (interstitialPageUrl) {\n Log.log(\n printItem(\n chalk`Choose an app to open your project at {underline ${interstitialPageUrl}}`\n )\n );\n }\n Log.log(printItem(chalk`Metro waiting on {underline ${nativeRuntimeUrl}}`));\n if (options.devClient === false) {\n // TODO: if development build, change this message!\n Log.log(\n printItem('Scan the QR code above with Expo Go (Android) or the Camera app (iOS)')\n );\n } else {\n Log.log(\n printItem(\n 'Scan the QR code above to open the project in a development build. ' +\n learnMore('https://expo.fyi/start')\n )\n );\n }\n } catch (error) {\n console.log('err', error);\n // @ts-ignore: If there is no development build scheme, then skip the QR code.\n if (error.code !== 'NO_DEV_CLIENT_SCHEME') {\n throw error;\n } else {\n const serverUrl = devServer.getDevServerUrl();\n Log.log(printItem(chalk`Metro waiting on {underline ${serverUrl}}`));\n Log.log(printItem(`Linking is disabled because the client scheme cannot be resolved.`));\n }\n }\n }\n\n if (this.options.platforms?.includes('web')) {\n const webDevServer = this.devServerManager.getWebDevServer();\n const webUrl = webDevServer?.getDevServerUrl({ hostType: 'localhost' });\n if (webUrl) {\n Log.log();\n Log.log(printItem(chalk`Web is waiting on {underline ${webUrl}}`));\n }\n }\n\n printUsage(options, { verbose: false });\n printHelp();\n Log.log();\n }\n\n async openJsInspectorAsync() {\n const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n let app: MetroInspectorProxyApp | null = null;\n\n if (!apps.length) {\n return Log.warn(\n chalk`{bold Debug:} No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine. ${learnMore(\n 'https://docs.expo.dev/guides/using-hermes/'\n )}`\n );\n }\n\n if (apps.length === 1) {\n app = apps[0];\n } else {\n const choices = apps.map((app) => ({\n title: app.deviceName ?? 'Unknown device',\n value: app.id,\n app,\n }));\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n const menuItem = choices.find((item) => item.value === value);\n if (!menuItem) {\n return Log.error(chalk`{bold Debug:} No device available for \"${value}\"`);\n }\n\n app = menuItem.app;\n }\n\n if (!app) {\n return Log.error(chalk`{bold Debug:} No device selected`);\n }\n\n try {\n await openJsInspector(metroServerOrigin, app);\n } catch (error: any) {\n Log.error('Failed to open JavaScript inspector. This is often an issue with Google Chrome.');\n Log.exception(error);\n }\n }\n\n reloadApp() {\n Log.log(`${BLT} Reloading apps`);\n // Send reload requests over the dev servers\n this.devServerManager.broadcastMessage('reload');\n }\n\n async openMoreToolsAsync() {\n // Options match: Chrome > View > Developer\n try {\n const defaultMenuItems: MoreToolMenuItem[] = [\n { title: 'Inspect elements', value: 'toggleElementInspector' },\n { title: 'Toggle performance monitor', value: 'togglePerformanceMonitor' },\n { title: 'Toggle developer menu', value: 'toggleDevMenu' },\n { title: 'Reload app', value: 'reload' },\n {\n title: 'Open React devtools',\n value: 'openReactDevTools',\n action: this.openReactDevToolsAsync.bind(this),\n },\n // TODO: Maybe a \"View Source\" option to open code.\n ];\n const pluginMenuItems = (\n await this.devServerManager.devtoolsPluginManager.queryPluginsAsync()\n ).map((plugin) => ({\n title: chalk`Open devtools plugin - {bold ${plugin.packageName}}`,\n value: `devtoolsPlugin:${plugin.packageName}`,\n action: async () => {\n const url = new URL(\n plugin.webpageEndpoint,\n this.devServerManager\n .getDefaultDevServer()\n .getUrlCreator()\n .constructUrl({ scheme: 'http' })\n );\n await openBrowserAsync(url.toString());\n },\n }));\n const menuItems = [...defaultMenuItems, ...pluginMenuItems];\n const value = await selectAsync(chalk`Dev tools {dim (native only)}`, menuItems);\n const menuItem = menuItems.find((item) => item.value === value);\n if (menuItem?.action) {\n menuItem.action();\n } else if (menuItem?.value) {\n this.devServerManager.broadcastMessage('sendDevCommand', { name: menuItem.value });\n }\n } catch (error: any) {\n debug(error);\n // do nothing\n } finally {\n printHelp();\n }\n }\n\n async openReactDevToolsAsync() {\n await startReactDevToolsProxyAsync();\n const url = this.devServerManager.getDefaultDevServer().getReactDevToolsUrl();\n await openBrowserAsync(url);\n addReactDevToolsReloadListener(() => {\n this.reconnectReactDevTools();\n });\n this.reconnectReactDevTools();\n }\n\n async reconnectReactDevTools() {\n // Wait a little time for react-devtools to be initialized in browser\n await delayAsync(3000);\n this.devServerManager.broadcastMessage('sendDevCommand', { name: 'reconnectReactDevTools' });\n }\n\n toggleDevMenu() {\n Log.log(`${BLT} Toggling dev menu`);\n this.devServerManager.broadcastMessage('devMenu');\n }\n}\n"],"names":["Log","debug","require","DevServerManagerActions","constructor","devServerManager","options","printDevServerInfo","getNativeDevServerPort","devServer","getDefaultDevServer","nativeRuntimeUrl","getNativeRuntimeUrl","interstitialPageUrl","getRedirectUrl","printQRCode","log","printItem","chalk","devClient","learnMore","error","console","code","serverUrl","getDevServerUrl","platforms","includes","webDevServer","getWebDevServer","webUrl","hostType","printUsage","verbose","printHelp","openJsInspectorAsync","metroServerOrigin","getJsInspectorBaseUrl","apps","queryAllInspectorAppsAsync","app","length","warn","choices","map","title","deviceName","value","id","selectAsync","menuItem","find","item","openJsInspector","exception","reloadApp","BLT","broadcastMessage","openMoreToolsAsync","defaultMenuItems","action","openReactDevToolsAsync","bind","pluginMenuItems","devtoolsPluginManager","queryPluginsAsync","plugin","packageName","url","URL","webpageEndpoint","getUrlCreator","constructUrl","scheme","openBrowserAsync","toString","menuItems","name","startReactDevToolsProxyAsync","getReactDevToolsUrl","addReactDevToolsReloadListener","reconnectReactDevTools","delayAsync","toggleDevMenu"],"mappings":"AAAA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEwD,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACtFA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACY,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AACpB,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACX,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACX,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AAKtD,IAAA,mBAA8B,WAA9B,8BAA8B,CAAA;AAK9B,IAAA,YAA4C,WAA5C,4CAA4C,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yCAAyC,CAAC,AAAsB,AAAC;AAOzF,MAAMC,uBAAuB;IAClCC,YACUC,gBAAkC,EAClCC,OAAsD,CAC9D;aAFQD,gBAAkC,GAAlCA,gBAAkC;aAClCC,OAAsD,GAAtDA,OAAsD;KAC5D;IAEJC,kBAAkB,CAChBD,OAA8E,EAC9E;YA4CI,GAAsB;QA3C1B,kDAAkD;QAClD,IAAI,IAAI,CAACD,gBAAgB,CAACG,sBAAsB,EAAE,EAAE;YAClD,MAAMC,SAAS,GAAG,IAAI,CAACJ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AAC,OAAO1B,KAAK,EAAO;YACnBpB,KAAK,CAACoB,KAAK,CAAC,CAAC;QACb,aAAa;SACd,QAAS;YACRa,CAAAA,GAAAA,cAAS,AAAE,CAAA,UAAF,EAAE,CAAC;SACb;KACF;IAED,MAAM2B,sBAAsB,GAAG;QAC7B,MAAMiB,CAAAA,GAAAA,mBAA4B,AAAE,CAAA,6BAAF,EAAE,CAAC;QACrC,MAAMV,GAAG,GAAG,IAAI,CAAC/D,gBAAgB,CAACK,mBAAmB,EAAE,CAACqE,mBAAmB,EAAE,AAAC;QAC9E,MAAML,CAAAA,GAAAA,KAAgB,AAAK,CAAA,iBAAL,CAACN,GAAG,CAAC,CAAC;QAC5BY,CAAAA,GAAAA,mBAA8B,AAE5B,CAAA,+BAF4B,CAAC,IAAM;YACnC,IAAI,CAACC,sBAAsB,EAAE,CAAC;SAC/B,CAAC,CAAC;QACH,IAAI,CAACA,sBAAsB,EAAE,CAAC;KAC/B;IAED,MAAMA,sBAAsB,GAAG;QAC7B,qEAAqE;QACrE,MAAMC,CAAAA,GAAAA,MAAU,AAAM,CAAA,WAAN,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC7E,gBAAgB,CAACoD,gBAAgB,CAAC,gBAAgB,EAAE;YAAEoB,IAAI,EAAE,wBAAwB;SAAE,CAAC,CAAC;KAC9F;IAEDM,aAAa,GAAG;QACdnF,GAAG,CAACgB,GAAG,CAAC,CAAC,EAAEwC,cAAG,IAAA,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpC,IAAI,CAACnD,gBAAgB,CAACoD,gBAAgB,CAAC,SAAS,CAAC,CAAC;KACnD;CACF;QAtLYtD,uBAAuB,GAAvBA,uBAAuB"}
@@ -58,7 +58,7 @@ const PLATFORM_SETTINGS = {
58
58
  };
59
59
  async function startInterfaceAsync(devServerManager, options) {
60
60
  var ref2;
61
- const actions = new _interactiveActions.DevServerManagerActions(devServerManager);
61
+ const actions = new _interactiveActions.DevServerManagerActions(devServerManager, options);
62
62
  const isWebSocketsEnabled = (ref2 = devServerManager.getDefaultDevServer()) == null ? void 0 : ref2.isTargetingNative();
63
63
  const usageOptions = {
64
64
  isWebSocketsEnabled,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/interface/startInterface.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { KeyPressHandler } from './KeyPressHandler';\nimport { BLT, printHelp, printUsage, StartOptions } from './commandsTable';\nimport { DevServerManagerActions } from './interactiveActions';\nimport * as Log from '../../log';\nimport { openInEditorAsync } from '../../utils/editor';\nimport { AbortCommandError } from '../../utils/errors';\nimport { getAllSpinners, ora } from '../../utils/ora';\nimport { getProgressBar, setProgressBar } from '../../utils/progress';\nimport { addInteractionListener, pauseInteractions } from '../../utils/prompts';\nimport { WebSupportProjectPrerequisite } from '../doctor/web/WebSupportProjectPrerequisite';\nimport { DevServerManager } from '../server/DevServerManager';\n\nconst debug = require('debug')('expo:start:interface:startInterface') as typeof console.log;\n\nconst CTRL_C = '\\u0003';\nconst CTRL_D = '\\u0004';\nconst CTRL_L = '\\u000C';\n\nconst PLATFORM_SETTINGS: Record<\n string,\n { name: string; key: 'android' | 'ios'; launchTarget: 'emulator' | 'simulator' }\n> = {\n android: {\n name: 'Android',\n key: 'android',\n launchTarget: 'emulator',\n },\n ios: {\n name: 'iOS',\n key: 'ios',\n launchTarget: 'simulator',\n },\n};\n\nexport async function startInterfaceAsync(\n devServerManager: DevServerManager,\n options: Pick<StartOptions, 'devClient' | 'platforms'>\n) {\n const actions = new DevServerManagerActions(devServerManager);\n\n const isWebSocketsEnabled = devServerManager.getDefaultDevServer()?.isTargetingNative();\n\n const usageOptions = {\n isWebSocketsEnabled,\n devClient: devServerManager.options.devClient,\n ...options,\n };\n\n actions.printDevServerInfo(usageOptions);\n\n const onPressAsync = async (key: string) => {\n // Auxillary commands all escape.\n switch (key) {\n case CTRL_C:\n case CTRL_D: {\n // Prevent terminal UI from accepting commands while the process is closing.\n // Without this, fast typers will close the server then start typing their\n // next command and have a bunch of unrelated things pop up.\n pauseInteractions();\n\n const spinners = getAllSpinners();\n spinners.forEach((spinner) => {\n spinner.fail();\n });\n\n const currentProgress = getProgressBar();\n if (currentProgress) {\n currentProgress.terminate();\n setProgressBar(null);\n }\n const spinner = ora({ text: 'Stopping server', color: 'white' }).start();\n try {\n await devServerManager.stopAsync();\n spinner.stopAndPersist({ text: 'Stopped server', symbol: `\\u203A` });\n // @ts-ignore: Argument of type '\"SIGINT\"' is not assignable to parameter of type '\"disconnect\"'.\n process.emit('SIGINT');\n\n // TODO: Is this the right place to do this?\n process.exit();\n } catch (error) {\n spinner.fail('Failed to stop server');\n throw error;\n }\n break;\n }\n case CTRL_L:\n return Log.clear();\n case '?':\n return printUsage(usageOptions, { verbose: true });\n }\n\n // Optionally enabled\n\n if (isWebSocketsEnabled) {\n switch (key) {\n case 'm':\n return actions.toggleDevMenu();\n case 'M':\n return actions.openMoreToolsAsync();\n }\n }\n\n const { platforms = ['ios', 'android', 'web'] } = options;\n\n if (['i', 'a'].includes(key.toLowerCase())) {\n const platform = key.toLowerCase() === 'i' ? 'ios' : 'android';\n\n const shouldPrompt = ['I', 'A'].includes(key);\n if (shouldPrompt) {\n Log.clear();\n }\n\n const server = devServerManager.getDefaultDevServer();\n const settings = PLATFORM_SETTINGS[platform];\n\n Log.log(`${BLT} Opening on ${settings.name}...`);\n\n if (server.isTargetingNative() && !platforms.includes(settings.key)) {\n Log.warn(\n chalk`${settings.name} is disabled, enable it by adding {bold ${settings.key}} to the platforms array in your app.json or app.config.js`\n );\n } else {\n try {\n await server.openPlatformAsync(settings.launchTarget, { shouldPrompt });\n printHelp();\n } catch (error: any) {\n if (!(error instanceof AbortCommandError)) {\n Log.exception(error);\n }\n }\n }\n // Break out early.\n return;\n }\n\n switch (key) {\n case 's': {\n Log.clear();\n if (await devServerManager.toggleRuntimeMode()) {\n usageOptions.devClient = devServerManager.options.devClient;\n return actions.printDevServerInfo(usageOptions);\n }\n break;\n }\n case 'w': {\n try {\n await devServerManager.ensureProjectPrerequisiteAsync(WebSupportProjectPrerequisite);\n if (!platforms.includes('web')) {\n platforms.push('web');\n options.platforms?.push('web');\n }\n } catch (e: any) {\n Log.warn(e.message);\n break;\n }\n\n const isDisabled = !platforms.includes('web');\n if (isDisabled) {\n debug('Web is disabled');\n // Use warnings from the web support setup.\n break;\n }\n\n // Ensure the Webpack dev server is running first\n if (!devServerManager.getWebDevServer()) {\n debug('Starting up webpack dev server');\n await devServerManager.ensureWebDevServerRunningAsync();\n // When this is the first time webpack is started, reprint the connection info.\n actions.printDevServerInfo(usageOptions);\n }\n\n Log.log(`${BLT} Open in the web browser...`);\n try {\n await devServerManager.getWebDevServer()?.openPlatformAsync('desktop');\n printHelp();\n } catch (error: any) {\n if (!(error instanceof AbortCommandError)) {\n Log.exception(error);\n }\n }\n break;\n }\n case 'c':\n Log.clear();\n return actions.printDevServerInfo(usageOptions);\n case 'j':\n return actions.openJsInspectorAsync();\n case 'r':\n return actions.reloadApp();\n case 'o':\n Log.log(`${BLT} Opening the editor...`);\n return openInEditorAsync(devServerManager.projectRoot);\n }\n };\n\n const keyPressHandler = new KeyPressHandler(onPressAsync);\n\n const listener = keyPressHandler.createInteractionListener();\n\n addInteractionListener(listener);\n\n // Start observing...\n keyPressHandler.startInterceptingKeyStrokes();\n}\n"],"names":["startInterfaceAsync","Log","debug","require","CTRL_C","CTRL_D","CTRL_L","PLATFORM_SETTINGS","android","name","key","launchTarget","ios","devServerManager","options","actions","DevServerManagerActions","isWebSocketsEnabled","getDefaultDevServer","isTargetingNative","usageOptions","devClient","printDevServerInfo","onPressAsync","pauseInteractions","spinners","getAllSpinners","forEach","spinner","fail","currentProgress","getProgressBar","terminate","setProgressBar","ora","text","color","start","stopAsync","stopAndPersist","symbol","process","emit","exit","error","clear","printUsage","verbose","toggleDevMenu","openMoreToolsAsync","platforms","includes","toLowerCase","platform","shouldPrompt","server","settings","log","BLT","warn","chalk","openPlatformAsync","printHelp","AbortCommandError","exception","toggleRuntimeMode","ensureProjectPrerequisiteAsync","WebSupportProjectPrerequisite","push","e","message","isDisabled","getWebDevServer","ensureWebDevServerRunningAsync","openJsInspectorAsync","reloadApp","openInEditorAsync","projectRoot","keyPressHandler","KeyPressHandler","listener","createInteractionListener","addInteractionListener","startInterceptingKeyStrokes"],"mappings":"AAAA;;;;QAoCsBA,mBAAmB,GAAnBA,mBAAmB;AApCvB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEO,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AACM,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AAClC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAClDC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACmB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACpB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAClB,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACN,IAAA,SAAsB,WAAtB,sBAAsB,CAAA;AACX,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AACjC,IAAA,8BAA6C,WAA7C,6CAA6C,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG3F,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,qCAAqC,CAAC,AAAsB,AAAC;AAE5F,MAAMC,MAAM,GAAG,MAAQ,AAAC;AACxB,MAAMC,MAAM,GAAG,MAAQ,AAAC;AACxB,MAAMC,MAAM,GAAG,IAAQ,AAAC;AAExB,MAAMC,iBAAiB,GAGnB;IACFC,OAAO,EAAE;QACPC,IAAI,EAAE,SAAS;QACfC,GAAG,EAAE,SAAS;QACdC,YAAY,EAAE,UAAU;KACzB;IACDC,GAAG,EAAE;QACHH,IAAI,EAAE,KAAK;QACXC,GAAG,EAAE,KAAK;QACVC,YAAY,EAAE,WAAW;KAC1B;CACF,AAAC;AAEK,eAAeX,mBAAmB,CACvCa,gBAAkC,EAClCC,OAAsD,EACtD;QAG4BD,IAAsC;IAFl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AkC,CAAEgD,iBAAiB,CAAC,SAAS,CAAC,CAAA,CAAC;wBACvEC,CAAAA,GAAAA,cAAS,AAAE,CAAA,UAAF,EAAE,CAAC;qBACb,CAAC,OAAOlB,KAAK,EAAO;wBACnB,IAAI,CAAC,CAACA,KAAK,YAAYmB,OAAiB,kBAAA,CAAC,EAAE;4BACzC9D,GAAG,CAAC+D,SAAS,CAACpB,KAAK,CAAC,CAAC;yBACtB;qBACF;oBACD,MAAM;iBACP;YACD,KAAK,GAAG;gBACN3C,GAAG,CAAC4C,KAAK,EAAE,CAAC;gBACZ,OAAO9B,OAAO,CAACO,kBAAkB,CAACF,YAAY,CAAC,CAAC;YAClD,KAAK,GAAG;gBACN,OAAOL,OAAO,CAAC2D,oBAAoB,EAAE,CAAC;YACxC,KAAK,GAAG;gBACN,OAAO3D,OAAO,CAAC4D,SAAS,EAAE,CAAC;YAC7B,KAAK,GAAG;gBACN1E,GAAG,CAACwD,GAAG,CAAC,CAAC,EAAEC,cAAG,IAAA,CAAC,sBAAsB,CAAC,CAAC,CAAC;gBACxC,OAAOkB,CAAAA,GAAAA,OAAiB,AAA8B,CAAA,kBAA9B,CAAC/D,gBAAgB,CAACgE,WAAW,CAAC,CAAC;SAC1D;KACF,AAAC;IAEF,MAAMC,eAAe,GAAG,IAAIC,gBAAe,gBAAA,CAACxD,YAAY,CAAC,AAAC;IAE1D,MAAMyD,QAAQ,GAAGF,eAAe,CAACG,yBAAyB,EAAE,AAAC;IAE7DC,CAAAA,GAAAA,QAAsB,AAAU,CAAA,uBAAV,CAACF,QAAQ,CAAC,CAAC;IAEjC,qBAAqB;IACrBF,eAAe,CAACK,2BAA2B,EAAE,CAAC;CAC/C"}
1
+ {"version":3,"sources":["../../../../src/start/interface/startInterface.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { KeyPressHandler } from './KeyPressHandler';\nimport { BLT, printHelp, printUsage, StartOptions } from './commandsTable';\nimport { DevServerManagerActions } from './interactiveActions';\nimport * as Log from '../../log';\nimport { openInEditorAsync } from '../../utils/editor';\nimport { AbortCommandError } from '../../utils/errors';\nimport { getAllSpinners, ora } from '../../utils/ora';\nimport { getProgressBar, setProgressBar } from '../../utils/progress';\nimport { addInteractionListener, pauseInteractions } from '../../utils/prompts';\nimport { WebSupportProjectPrerequisite } from '../doctor/web/WebSupportProjectPrerequisite';\nimport { DevServerManager } from '../server/DevServerManager';\n\nconst debug = require('debug')('expo:start:interface:startInterface') as typeof console.log;\n\nconst CTRL_C = '\\u0003';\nconst CTRL_D = '\\u0004';\nconst CTRL_L = '\\u000C';\n\nconst PLATFORM_SETTINGS: Record<\n string,\n { name: string; key: 'android' | 'ios'; launchTarget: 'emulator' | 'simulator' }\n> = {\n android: {\n name: 'Android',\n key: 'android',\n launchTarget: 'emulator',\n },\n ios: {\n name: 'iOS',\n key: 'ios',\n launchTarget: 'simulator',\n },\n};\n\nexport async function startInterfaceAsync(\n devServerManager: DevServerManager,\n options: Pick<StartOptions, 'devClient' | 'platforms'>\n) {\n const actions = new DevServerManagerActions(devServerManager, options);\n\n const isWebSocketsEnabled = devServerManager.getDefaultDevServer()?.isTargetingNative();\n\n const usageOptions = {\n isWebSocketsEnabled,\n devClient: devServerManager.options.devClient,\n ...options,\n };\n\n actions.printDevServerInfo(usageOptions);\n\n const onPressAsync = async (key: string) => {\n // Auxillary commands all escape.\n switch (key) {\n case CTRL_C:\n case CTRL_D: {\n // Prevent terminal UI from accepting commands while the process is closing.\n // Without this, fast typers will close the server then start typing their\n // next command and have a bunch of unrelated things pop up.\n pauseInteractions();\n\n const spinners = getAllSpinners();\n spinners.forEach((spinner) => {\n spinner.fail();\n });\n\n const currentProgress = getProgressBar();\n if (currentProgress) {\n currentProgress.terminate();\n setProgressBar(null);\n }\n const spinner = ora({ text: 'Stopping server', color: 'white' }).start();\n try {\n await devServerManager.stopAsync();\n spinner.stopAndPersist({ text: 'Stopped server', symbol: `\\u203A` });\n // @ts-ignore: Argument of type '\"SIGINT\"' is not assignable to parameter of type '\"disconnect\"'.\n process.emit('SIGINT');\n\n // TODO: Is this the right place to do this?\n process.exit();\n } catch (error) {\n spinner.fail('Failed to stop server');\n throw error;\n }\n break;\n }\n case CTRL_L:\n return Log.clear();\n case '?':\n return printUsage(usageOptions, { verbose: true });\n }\n\n // Optionally enabled\n\n if (isWebSocketsEnabled) {\n switch (key) {\n case 'm':\n return actions.toggleDevMenu();\n case 'M':\n return actions.openMoreToolsAsync();\n }\n }\n\n const { platforms = ['ios', 'android', 'web'] } = options;\n\n if (['i', 'a'].includes(key.toLowerCase())) {\n const platform = key.toLowerCase() === 'i' ? 'ios' : 'android';\n\n const shouldPrompt = ['I', 'A'].includes(key);\n if (shouldPrompt) {\n Log.clear();\n }\n\n const server = devServerManager.getDefaultDevServer();\n const settings = PLATFORM_SETTINGS[platform];\n\n Log.log(`${BLT} Opening on ${settings.name}...`);\n\n if (server.isTargetingNative() && !platforms.includes(settings.key)) {\n Log.warn(\n chalk`${settings.name} is disabled, enable it by adding {bold ${settings.key}} to the platforms array in your app.json or app.config.js`\n );\n } else {\n try {\n await server.openPlatformAsync(settings.launchTarget, { shouldPrompt });\n printHelp();\n } catch (error: any) {\n if (!(error instanceof AbortCommandError)) {\n Log.exception(error);\n }\n }\n }\n // Break out early.\n return;\n }\n\n switch (key) {\n case 's': {\n Log.clear();\n if (await devServerManager.toggleRuntimeMode()) {\n usageOptions.devClient = devServerManager.options.devClient;\n return actions.printDevServerInfo(usageOptions);\n }\n break;\n }\n case 'w': {\n try {\n await devServerManager.ensureProjectPrerequisiteAsync(WebSupportProjectPrerequisite);\n if (!platforms.includes('web')) {\n platforms.push('web');\n options.platforms?.push('web');\n }\n } catch (e: any) {\n Log.warn(e.message);\n break;\n }\n\n const isDisabled = !platforms.includes('web');\n if (isDisabled) {\n debug('Web is disabled');\n // Use warnings from the web support setup.\n break;\n }\n\n // Ensure the Webpack dev server is running first\n if (!devServerManager.getWebDevServer()) {\n debug('Starting up webpack dev server');\n await devServerManager.ensureWebDevServerRunningAsync();\n // When this is the first time webpack is started, reprint the connection info.\n actions.printDevServerInfo(usageOptions);\n }\n\n Log.log(`${BLT} Open in the web browser...`);\n try {\n await devServerManager.getWebDevServer()?.openPlatformAsync('desktop');\n printHelp();\n } catch (error: any) {\n if (!(error instanceof AbortCommandError)) {\n Log.exception(error);\n }\n }\n break;\n }\n case 'c':\n Log.clear();\n return actions.printDevServerInfo(usageOptions);\n case 'j':\n return actions.openJsInspectorAsync();\n case 'r':\n return actions.reloadApp();\n case 'o':\n Log.log(`${BLT} Opening the editor...`);\n return openInEditorAsync(devServerManager.projectRoot);\n }\n };\n\n const keyPressHandler = new KeyPressHandler(onPressAsync);\n\n const listener = keyPressHandler.createInteractionListener();\n\n addInteractionListener(listener);\n\n // Start observing...\n keyPressHandler.startInterceptingKeyStrokes();\n}\n"],"names":["startInterfaceAsync","Log","debug","require","CTRL_C","CTRL_D","CTRL_L","PLATFORM_SETTINGS","android","name","key","launchTarget","ios","devServerManager","options","actions","DevServerManagerActions","isWebSocketsEnabled","getDefaultDevServer","isTargetingNative","usageOptions","devClient","printDevServerInfo","onPressAsync","pauseInteractions","spinners","getAllSpinners","forEach","spinner","fail","currentProgress","getProgressBar","terminate","setProgressBar","ora","text","color","start","stopAsync","stopAndPersist","symbol","process","emit","exit","error","clear","printUsage","verbose","toggleDevMenu","openMoreToolsAsync","platforms","includes","toLowerCase","platform","shouldPrompt","server","settings","log","BLT","warn","chalk","openPlatformAsync","printHelp","AbortCommandError","exception","toggleRuntimeMode","ensureProjectPrerequisiteAsync","WebSupportProjectPrerequisite","push","e","message","isDisabled","getWebDevServer","ensureWebDevServerRunningAsync","openJsInspectorAsync","reloadApp","openInEditorAsync","projectRoot","keyPressHandler","KeyPressHandler","listener","createInteractionListener","addInteractionListener","startInterceptingKeyStrokes"],"mappings":"AAAA;;;;QAoCsBA,mBAAmB,GAAnBA,mBAAmB;AApCvB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEO,IAAA,gBAAmB,WAAnB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;YACD,KAAK,GAAG;gBACN3C,GAAG,CAAC4C,KAAK,EAAE,CAAC;gBACZ,OAAO9B,OAAO,CAACO,kBAAkB,CAACF,YAAY,CAAC,CAAC;YAClD,KAAK,GAAG;gBACN,OAAOL,OAAO,CAAC2D,oBAAoB,EAAE,CAAC;YACxC,KAAK,GAAG;gBACN,OAAO3D,OAAO,CAAC4D,SAAS,EAAE,CAAC;YAC7B,KAAK,GAAG;gBACN1E,GAAG,CAACwD,GAAG,CAAC,CAAC,EAAEC,cAAG,IAAA,CAAC,sBAAsB,CAAC,CAAC,CAAC;gBACxC,OAAOkB,CAAAA,GAAAA,OAAiB,AAA8B,CAAA,kBAA9B,CAAC/D,gBAAgB,CAACgE,WAAW,CAAC,CAAC;SAC1D;KACF,AAAC;IAEF,MAAMC,eAAe,GAAG,IAAIC,gBAAe,gBAAA,CAACxD,YAAY,CAAC,AAAC;IAE1D,MAAMyD,QAAQ,GAAGF,eAAe,CAACG,yBAAyB,EAAE,AAAC;IAE7DC,CAAAA,GAAAA,QAAsB,AAAU,CAAA,uBAAV,CAACF,QAAQ,CAAC,CAAC;IAEjC,qBAAqB;IACrBF,eAAe,CAACK,2BAA2B,EAAE,CAAC;CAC/C"}
@@ -23,7 +23,23 @@ function _interopRequireDefault(obj) {
23
23
  default: obj
24
24
  };
25
25
  }
26
+ class MetroNodeError extends Error {
27
+ constructor(message, rawObject){
28
+ super(message);
29
+ this.rawObject = rawObject;
30
+ }
31
+ }
26
32
  const debug = require("debug")("expo:start:server:node-renderer");
33
+ const cachedSourceMaps = new Map();
34
+ // Support unhandled rejections
35
+ require("source-map-support").install({
36
+ retrieveSourceMap (source) {
37
+ if (cachedSourceMaps.has(source)) {
38
+ return cachedSourceMaps.get(source);
39
+ }
40
+ return null;
41
+ }
42
+ });
27
43
  function wrapBundle(str) {
28
44
  // Skip the metro runtime so debugging is a bit easier.
29
45
  // Replace the __r() call with an export statement.
@@ -101,18 +117,18 @@ async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFileP
101
117
  baseUrl,
102
118
  isExporting: true,
103
119
  asyncRoutes: false,
104
- routerRoot
120
+ routerRoot,
121
+ inlineSourceMap: false
105
122
  });
106
- const url = new URL(urlFragment.replace(/^\//, ""), devServerUrl).toString();
123
+ let url;
124
+ if (devServerUrl) {
125
+ url = new URL(urlFragment.replace(/^\//, ""), devServerUrl).toString();
126
+ } else {
127
+ url = "/" + urlFragment.replace(/^\/+/, "");
128
+ }
107
129
  debug("fetching from Metro:", root, serverPath, url);
108
130
  return url;
109
131
  }
110
- class MetroNodeError extends Error {
111
- constructor(message, rawObject){
112
- super(message);
113
- this.rawObject = rawObject;
114
- }
115
- }
116
132
  async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteFilePath, props) {
117
133
  const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);
118
134
  const res = await (0, _nodeFetch).default(url);
@@ -130,14 +146,23 @@ async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteF
130
146
  throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);
131
147
  }
132
148
  const content = await res.text();
133
- return wrapBundle(content);
149
+ const map = await (0, _nodeFetch).default(url.replace(".bundle?", ".map?")).then((r)=>r.json()
150
+ );
151
+ cachedSourceMaps.set(url, {
152
+ url: projectRoot,
153
+ map
154
+ });
155
+ return {
156
+ src: wrapBundle(content),
157
+ filename: url
158
+ };
134
159
  }
135
160
  async function getStaticRenderFunctions(projectRoot, devServerUrl, options) {
136
- const scriptContents = await getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, options);
137
- return evalMetroAndWrapFunctions(projectRoot, scriptContents);
161
+ const { src: scriptContents , filename } = await getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, options);
162
+ return evalMetroAndWrapFunctions(projectRoot, scriptContents, filename);
138
163
  }
139
- function evalMetroAndWrapFunctions(projectRoot, script) {
140
- const contents = evalMetro(script);
164
+ function evalMetroAndWrapFunctions(projectRoot, script, filename) {
165
+ const contents = evalMetro(projectRoot, script, filename);
141
166
  // wrap each function with a try/catch that uses Metro's error formatter
142
167
  return Object.keys(contents).reduce((acc, key)=>{
143
168
  const fn = contents[key];
@@ -160,8 +185,33 @@ function evalMetroAndWrapFunctions(projectRoot, script) {
160
185
  return acc;
161
186
  }, {});
162
187
  }
163
- function evalMetro(src) {
164
- return (0, _profile).profile(_requireFromString.default, "eval-metro-bundle")(src);
188
+ function evalMetro(projectRoot, src, filename) {
189
+ const originalConsole = {
190
+ log: console.log,
191
+ warn: console.warn,
192
+ error: console.error
193
+ };
194
+ try {
195
+ return (0, _profile).profile(_requireFromString.default, "eval-metro-bundle")(src, filename);
196
+ } catch (error) {
197
+ // Format any errors that were thrown in the global scope of the evaluation.
198
+ if (error instanceof Error) {
199
+ (0, _metroErrorInterface).logMetroErrorAsync({
200
+ projectRoot,
201
+ error
202
+ }).catch((internalError)=>{
203
+ debug("Failed to log metro error:", internalError);
204
+ throw error;
205
+ });
206
+ } else {
207
+ throw error;
208
+ }
209
+ } finally{
210
+ // Restore the original console in case it was modified.
211
+ console.log = originalConsole.log;
212
+ console.warn = originalConsole.warn;
213
+ console.error = originalConsole.error;
214
+ }
165
215
  }
166
216
 
167
217
  //# sourceMappingURL=getStaticRenderFunctions.js.map