@expo/cli 0.2.5 → 0.2.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 +17 -6
- package/build/bin/cli.map +1 -1
- package/build/src/install/checkPackages.js +2 -2
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/prebuild/clearNativeFolder.js +5 -2
- package/build/src/prebuild/clearNativeFolder.js.map +1 -1
- package/build/src/register/registerAsync.js +2 -2
- package/build/src/register/registerAsync.js.map +1 -1
- package/build/src/run/hints.js +2 -2
- package/build/src/run/hints.js.map +1 -1
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +2 -2
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +2 -2
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -1
- package/build/src/run/startBundler.js +2 -2
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +2 -2
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +3 -3
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +1 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +11 -6
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +7 -2
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +2 -2
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/startAsync.js +8 -8
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +28 -14
- package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
- package/build/src/utils/env.js +16 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/git.js +2 -1
- package/build/src/utils/git.js.map +1 -1
- package/build/src/utils/interactive.js +11 -0
- package/build/src/utils/interactive.js.map +1 -0
- package/build/src/utils/ora.js +2 -1
- package/build/src/utils/ora.js.map +1 -1
- package/build/src/utils/prompts.js +2 -2
- package/build/src/utils/prompts.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/platforms/ExpoGoInstaller.ts"],"sourcesContent":["import semver from 'semver';\n\nimport { getVersionsAsync } from '../../api/getVersions';\nimport * as Log from '../../log';\nimport { downloadExpoGoAsync } from '../../utils/downloadExpoGoAsync';\nimport { logNewSection } from '../../utils/ora';\nimport { confirmAsync } from '../../utils/prompts';\nimport type { DeviceManager } from './DeviceManager';\n\nconst debug = require('debug')('expo:utils:ExpoGoInstaller') as typeof console.log;\n\n/** Given a platform, appId, and sdkVersion, this module will ensure that Expo Go is up-to-date on the provided device. */\nexport class ExpoGoInstaller<IDevice> {\n // Keep a list of [platform-deviceId] so we can prevent asking multiple times if a user wants to upgrade.\n // This can prevent annoying interactions when they don't want to upgrade for whatever reason.\n static cache: Record<string, boolean> = {};\n\n constructor(\n private platform: 'ios' | 'android',\n // Ultimately this should be inlined since we know the platform.\n private appId: string,\n private sdkVersion?: string\n ) {}\n\n /** Returns true if the installed app matching the previously provided `appId` is outdated. */\n async isClientOutdatedAsync(device: DeviceManager<IDevice>): Promise<boolean> {\n const installedVersion = await device.getAppVersionAsync(this.appId);\n if (!installedVersion) {\n return true;\n }\n const version = await this._getExpectedClientVersionAsync();\n debug(`Expected Expo Go version: ${version}, installed version: ${installedVersion}`);\n return version ? !semver.eq(installedVersion, version) : true;\n }\n\n /** Returns the expected version of Expo Go given the project SDK Version. Exposed for testing. */\n async _getExpectedClientVersionAsync(): Promise<string | null> {\n const versions = await getVersionsAsync();\n // Like `sdkVersions['44.0.0']['androidClientVersion'] = '1.0.0'`\n const specificVersion =\n versions?.sdkVersions?.[this.sdkVersion!]?.[`${this.platform}ClientVersion`];\n const latestVersion = versions[`${this.platform}Version`];\n return specificVersion ?? latestVersion ?? null;\n }\n\n /** Returns a boolean indicating if Expo Go should be installed. Returns `true` if the app was uninstalled. */\n async uninstallExpoGoIfOutdatedAsync(deviceManager: DeviceManager<IDevice>): Promise<boolean> {\n const cacheId = `${this.platform}-${deviceManager.identifier}`;\n\n if (ExpoGoInstaller.cache[cacheId]) {\n return false;\n }\n if (await this.isClientOutdatedAsync(deviceManager)) {\n // Only prompt once per device, per run.\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/platforms/ExpoGoInstaller.ts"],"sourcesContent":["import semver from 'semver';\n\nimport { getVersionsAsync } from '../../api/getVersions';\nimport * as Log from '../../log';\nimport { downloadExpoGoAsync } from '../../utils/downloadExpoGoAsync';\nimport { logNewSection } from '../../utils/ora';\nimport { confirmAsync } from '../../utils/prompts';\nimport type { DeviceManager } from './DeviceManager';\n\nconst debug = require('debug')('expo:utils:ExpoGoInstaller') as typeof console.log;\n\n/** Given a platform, appId, and sdkVersion, this module will ensure that Expo Go is up-to-date on the provided device. */\nexport class ExpoGoInstaller<IDevice> {\n // Keep a list of [platform-deviceId] so we can prevent asking multiple times if a user wants to upgrade.\n // This can prevent annoying interactions when they don't want to upgrade for whatever reason.\n static cache: Record<string, boolean> = {};\n\n constructor(\n private platform: 'ios' | 'android',\n // Ultimately this should be inlined since we know the platform.\n private appId: string,\n private sdkVersion?: string\n ) {}\n\n /** Returns true if the installed app matching the previously provided `appId` is outdated. */\n async isClientOutdatedAsync(device: DeviceManager<IDevice>): Promise<boolean> {\n const installedVersion = await device.getAppVersionAsync(this.appId);\n if (!installedVersion) {\n return true;\n }\n const version = await this._getExpectedClientVersionAsync();\n debug(`Expected Expo Go version: ${version}, installed version: ${installedVersion}`);\n return version ? !semver.eq(installedVersion, version) : true;\n }\n\n /** Returns the expected version of Expo Go given the project SDK Version. Exposed for testing. */\n async _getExpectedClientVersionAsync(): Promise<string | null> {\n const versions = await getVersionsAsync();\n // Like `sdkVersions['44.0.0']['androidClientVersion'] = '1.0.0'`\n const specificVersion =\n versions?.sdkVersions?.[this.sdkVersion!]?.[`${this.platform}ClientVersion`];\n const latestVersion = versions[`${this.platform}Version`];\n return specificVersion ?? latestVersion ?? null;\n }\n\n /** Returns a boolean indicating if Expo Go should be installed. Returns `true` if the app was uninstalled. */\n async uninstallExpoGoIfOutdatedAsync(deviceManager: DeviceManager<IDevice>): Promise<boolean> {\n const cacheId = `${this.platform}-${deviceManager.identifier}`;\n\n if (ExpoGoInstaller.cache[cacheId]) {\n debug('skipping subsequent upgrade check');\n return false;\n }\n ExpoGoInstaller.cache[cacheId] = true;\n if (await this.isClientOutdatedAsync(deviceManager)) {\n // Only prompt once per device, per run.\n const confirm = await confirmAsync({\n initial: true,\n message: `Expo Go on ${deviceManager.name} is outdated, would you like to upgrade?`,\n });\n if (confirm) {\n // Don't need to uninstall to update on iOS.\n if (this.platform !== 'ios') {\n Log.log(`Uninstalling Expo Go from ${this.platform} device ${deviceManager.name}.`);\n await deviceManager.uninstallAppAsync(this.appId);\n }\n return true;\n }\n }\n return false;\n }\n\n /** Check if a given device has Expo Go installed, if not then download and install it. */\n async ensureAsync(deviceManager: DeviceManager<IDevice>): Promise<boolean> {\n let shouldInstall = !(await deviceManager.isAppInstalledAsync(this.appId));\n\n if (!shouldInstall) {\n shouldInstall = await this.uninstallExpoGoIfOutdatedAsync(deviceManager);\n }\n\n if (shouldInstall) {\n // Download the Expo Go app from the Expo servers.\n const binaryPath = await downloadExpoGoAsync(this.platform, { sdkVersion: this.sdkVersion });\n // Install the app on the device.\n const ora = logNewSection(`Installing Expo Go on ${deviceManager.name}`);\n try {\n await deviceManager.installAppAsync(binaryPath);\n } finally {\n ora.stop();\n }\n return true;\n }\n return false;\n }\n}\n"],"names":["Log","debug","require","ExpoGoInstaller","cache","constructor","platform","appId","sdkVersion","isClientOutdatedAsync","device","installedVersion","getAppVersionAsync","version","_getExpectedClientVersionAsync","semver","eq","versions","getVersionsAsync","specificVersion","sdkVersions","latestVersion","uninstallExpoGoIfOutdatedAsync","deviceManager","cacheId","identifier","confirm","confirmAsync","initial","message","name","log","uninstallAppAsync","ensureAsync","shouldInstall","isAppInstalledAsync","binaryPath","downloadExpoGoAsync","ora","logNewSection","installAppAsync","stop"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEM,IAAA,YAAuB,WAAvB,uBAAuB,CAAA;AAC5CA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACqB,IAAA,oBAAiC,WAAjC,iCAAiC,CAAA;AACvC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AAClB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGlD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,4BAA4B,CAAC,AAAsB,AAAC;AAG5E,MAAMC,eAAe;IAC1B,yGAAyG;IACzG,8FAA8F;IAC9F,OAAOC,KAAK,GAA4B,EAAE,CAAC;IAE3CC,YACUC,QAA2B,EAE3BC,KAAa,EACbC,UAAmB,CAC3B;aAJQF,QAA2B,GAA3BA,QAA2B;aAE3BC,KAAa,GAAbA,KAAa;aACbC,UAAmB,GAAnBA,UAAmB;KACzB;IAEJ,8FAA8F,CAC9F,MAAMC,qBAAqB,CAACC,MAA8B,EAAoB;QAC5E,MAAMC,gBAAgB,GAAG,MAAMD,MAAM,CAACE,kBAAkB,CAAC,IAAI,CAACL,KAAK,CAAC,AAAC;QACrE,IAAI,CAACI,gBAAgB,EAAE;YACrB,OAAO,IAAI,CAAC;SACb;QACD,MAAME,OAAO,GAA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YACjC,MAAM8B,GAAG,GAAGC,CAAAA,GAAAA,IAAa,AAA+C,CAAA,cAA/C,CAAC,CAAC,sBAAsB,EAAEhB,aAAa,CAACO,IAAI,CAAC,CAAC,CAAC,AAAC;YACzE,IAAI;gBACF,MAAMP,aAAa,CAACiB,eAAe,CAACJ,UAAU,CAAC,CAAC;aACjD,QAAS;gBACRE,GAAG,CAACG,IAAI,EAAE,CAAC;aACZ;YACD,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;KACd;CACF;QAlFYtC,eAAe,GAAfA,eAAe"}
|
|
@@ -30,9 +30,9 @@ class PlatformManager {
|
|
|
30
30
|
// TODO: Expensive, we should only do this once.
|
|
31
31
|
const { exp } = (0, _config).getConfig(this.projectRoot);
|
|
32
32
|
const installedExpo = await deviceManager.ensureExpoGoAsync(exp.sdkVersion);
|
|
33
|
-
|
|
33
|
+
deviceManager.activateWindowAsync();
|
|
34
34
|
await deviceManager.openUrlAsync(url);
|
|
35
|
-
(0, _rudderstackClient).
|
|
35
|
+
await (0, _rudderstackClient).logEventAsync("Open Url on Device", {
|
|
36
36
|
platform: this.props.platform,
|
|
37
37
|
installedExpo
|
|
38
38
|
});
|
|
@@ -55,7 +55,7 @@ class PlatformManager {
|
|
|
55
55
|
throw new _errors.CommandError(`The development client (${applicationId}) for this project is not installed. ` + `Please build and install the client on the device first.\n${(0, _link).learnMore("https://docs.expo.dev/development/build/")}`);
|
|
56
56
|
}
|
|
57
57
|
// TODO: Rethink analytics
|
|
58
|
-
(0, _rudderstackClient).
|
|
58
|
+
await (0, _rudderstackClient).logEventAsync("Open Url on Device", {
|
|
59
59
|
platform: this.props.platform,
|
|
60
60
|
installedExpo: false
|
|
61
61
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/platforms/PlatformManager.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport assert from 'assert';\n\nimport { logEvent } from '../../utils/analytics/rudderstackClient';\nimport { CommandError, UnimplementedError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport { AppIdResolver } from './AppIdResolver';\nimport { DeviceManager } from './DeviceManager';\n\nconst debug = require('debug')('expo:start:platforms:platformManager') as typeof console.log;\n\nexport interface BaseOpenInCustomProps {\n scheme?: string;\n applicationId?: string | null;\n}\n\nexport interface BaseResolveDeviceProps<IDevice> {\n /** Should prompt the user to select a device. */\n shouldPrompt?: boolean;\n /** The target device to use. */\n device?: IDevice;\n}\n\n/** An abstract class for launching a URL on a device. */\nexport class PlatformManager<\n IDevice,\n IOpenInCustomProps extends BaseOpenInCustomProps = BaseOpenInCustomProps,\n IResolveDeviceProps extends BaseResolveDeviceProps<IDevice> = BaseResolveDeviceProps<IDevice>\n> {\n constructor(\n protected projectRoot: string,\n protected props: {\n platform: 'ios' | 'android';\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL */\n getExpoGoUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n /** Resolve a device, this function should automatically handle opening the device and asserting any system validations. */\n resolveDeviceAsync: (\n resolver?: Partial<IResolveDeviceProps>\n ) => Promise<DeviceManager<IDevice>>;\n }\n ) {}\n\n /** Returns the project application identifier or asserts that one is not defined. Exposed for testing. */\n _getAppIdResolver(): AppIdResolver {\n throw new UnimplementedError();\n }\n\n protected async openProjectInExpoGoAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n const url = this.props.getExpoGoUrl();\n // This should never happen, but just in case...\n assert(url, 'Could not get dev server URL');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n\n // TODO: Expensive, we should only do this once.\n const { exp } = getConfig(this.projectRoot);\n const installedExpo = await deviceManager.ensureExpoGoAsync(exp.sdkVersion);\n\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n logEvent('Open Url on Device', {\n platform: this.props.platform,\n installedExpo,\n });\n\n return { url };\n }\n\n private async openProjectInCustomRuntimeAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {},\n props: Partial<IOpenInCustomProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open custom (${Object.entries(props)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')})`\n );\n\n let url = this.props.getCustomRuntimeUrl({ scheme: props.scheme });\n debug(`Opening project in custom runtime: ${url} -- %O`, props);\n // TODO: It's unclear why we do application id validation when opening with a URL\n const applicationId = props.applicationId ?? (await this._getAppIdResolver().getAppIdAsync());\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n\n if (!(await deviceManager.isAppInstalledAsync(applicationId))) {\n throw new CommandError(\n `The development client (${applicationId}) for this project is not installed. ` +\n `Please build and install the client on the device first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n // TODO: Rethink analytics\n logEvent('Open Url on Device', {\n platform: this.props.platform,\n installedExpo: false,\n });\n\n if (!url) {\n url = this._resolveAlternativeLaunchUrl(applicationId, props);\n }\n\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return {\n url,\n };\n }\n\n /** Launch the project on a device given the input runtime. */\n async openAsync(\n options:\n | {\n runtime: 'expo' | 'web';\n }\n | {\n runtime: 'custom';\n props?: Partial<IOpenInCustomProps>;\n },\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open (runtime: ${options.runtime}, platform: ${this.props.platform}, device: %O, shouldPrompt: ${resolveSettings.shouldPrompt})`,\n resolveSettings.device\n );\n if (options.runtime === 'expo') {\n return this.openProjectInExpoGoAsync(resolveSettings);\n } else if (options.runtime === 'web') {\n return this.openWebProjectAsync(resolveSettings);\n } else if (options.runtime === 'custom') {\n return this.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n } else {\n throw new CommandError(`Invalid runtime target: ${options.runtime}`);\n }\n }\n\n /** Open the current web project (Webpack) in a device . */\n private async openWebProjectAsync(resolveSettings: Partial<IResolveDeviceProps> = {}): Promise<{\n url: string;\n }> {\n const url = this.props.getDevServerUrl();\n assert(url, 'Dev server is not running.');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return { url };\n }\n\n /** If the launch URL cannot be determined (`custom` runtimes) then an alternative string can be provided to open the device. Often a device ID or activity to launch. Exposed for testing. */\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props: Partial<IOpenInCustomProps> = {}\n ): string {\n throw new UnimplementedError();\n }\n}\n"],"names":["debug","require","PlatformManager","constructor","projectRoot","props","_getAppIdResolver","UnimplementedError","openProjectInExpoGoAsync","resolveSettings","url","getExpoGoUrl","assert","deviceManager","resolveDeviceAsync","logOpeningUrl","exp","getConfig","installedExpo","ensureExpoGoAsync","sdkVersion","activateWindowAsync","openUrlAsync","logEvent","platform","openProjectInCustomRuntimeAsync","Object","entries","map","k","v","join","getCustomRuntimeUrl","scheme","applicationId","getAppIdAsync","isAppInstalledAsync","CommandError","learnMore","_resolveAlternativeLaunchUrl","openAsync","options","runtime","shouldPrompt","device","openWebProjectAsync","getDevServerUrl"],"mappings":"AAAA;;;;AAA0B,IAAA,OAAc,WAAd,cAAc,CAAA;AACrB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEF,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AACjB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAC3C,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;;;;;;AAI5C,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAetF,MAAMC,eAAe;IAK1BC,YACYC,WAAmB,EACnBC,KAYT,CACD;aAdUD,WAAmB,GAAnBA,WAAmB;aACnBC,KAYT,GAZSA,KAYT;KACC;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AAC,AAAC;QAC3EI,aAAa,CAACE,aAAa,CAACL,GAAG,CAAC,CAAC;QACjC,MAAMG,aAAa,CAACQ,mBAAmB,EAAE,CAAC;QAC1C,MAAMR,aAAa,CAACS,YAAY,CAACZ,GAAG,CAAC,CAAC;QAEtC,OAAO;YAAEA,GAAG;SAAE,CAAC;KAChB;IAED,8LAA8L,CAC9L6B,4BAA4B,CAC1BL,aAAqB,EACrB7B,KAAkC,GAAG,EAAE,EAC/B;QACR,MAAM,IAAIE,OAAkB,mBAAA,EAAE,CAAC;KAChC;CACF;QAlJYL,eAAe,GAAfA,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/platforms/PlatformManager.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport assert from 'assert';\n\nimport { logEventAsync } from '../../utils/analytics/rudderstackClient';\nimport { CommandError, UnimplementedError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport { AppIdResolver } from './AppIdResolver';\nimport { DeviceManager } from './DeviceManager';\n\nconst debug = require('debug')('expo:start:platforms:platformManager') as typeof console.log;\n\nexport interface BaseOpenInCustomProps {\n scheme?: string;\n applicationId?: string | null;\n}\n\nexport interface BaseResolveDeviceProps<IDevice> {\n /** Should prompt the user to select a device. */\n shouldPrompt?: boolean;\n /** The target device to use. */\n device?: IDevice;\n}\n\n/** An abstract class for launching a URL on a device. */\nexport class PlatformManager<\n IDevice,\n IOpenInCustomProps extends BaseOpenInCustomProps = BaseOpenInCustomProps,\n IResolveDeviceProps extends BaseResolveDeviceProps<IDevice> = BaseResolveDeviceProps<IDevice>\n> {\n constructor(\n protected projectRoot: string,\n protected props: {\n platform: 'ios' | 'android';\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL */\n getExpoGoUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n /** Resolve a device, this function should automatically handle opening the device and asserting any system validations. */\n resolveDeviceAsync: (\n resolver?: Partial<IResolveDeviceProps>\n ) => Promise<DeviceManager<IDevice>>;\n }\n ) {}\n\n /** Returns the project application identifier or asserts that one is not defined. Exposed for testing. */\n _getAppIdResolver(): AppIdResolver {\n throw new UnimplementedError();\n }\n\n protected async openProjectInExpoGoAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n const url = this.props.getExpoGoUrl();\n // This should never happen, but just in case...\n assert(url, 'Could not get dev server URL');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n\n // TODO: Expensive, we should only do this once.\n const { exp } = getConfig(this.projectRoot);\n const installedExpo = await deviceManager.ensureExpoGoAsync(exp.sdkVersion);\n\n deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo,\n });\n\n return { url };\n }\n\n private async openProjectInCustomRuntimeAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {},\n props: Partial<IOpenInCustomProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open custom (${Object.entries(props)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')})`\n );\n\n let url = this.props.getCustomRuntimeUrl({ scheme: props.scheme });\n debug(`Opening project in custom runtime: ${url} -- %O`, props);\n // TODO: It's unclear why we do application id validation when opening with a URL\n const applicationId = props.applicationId ?? (await this._getAppIdResolver().getAppIdAsync());\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n\n if (!(await deviceManager.isAppInstalledAsync(applicationId))) {\n throw new CommandError(\n `The development client (${applicationId}) for this project is not installed. ` +\n `Please build and install the client on the device first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n // TODO: Rethink analytics\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo: false,\n });\n\n if (!url) {\n url = this._resolveAlternativeLaunchUrl(applicationId, props);\n }\n\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return {\n url,\n };\n }\n\n /** Launch the project on a device given the input runtime. */\n async openAsync(\n options:\n | {\n runtime: 'expo' | 'web';\n }\n | {\n runtime: 'custom';\n props?: Partial<IOpenInCustomProps>;\n },\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open (runtime: ${options.runtime}, platform: ${this.props.platform}, device: %O, shouldPrompt: ${resolveSettings.shouldPrompt})`,\n resolveSettings.device\n );\n if (options.runtime === 'expo') {\n return this.openProjectInExpoGoAsync(resolveSettings);\n } else if (options.runtime === 'web') {\n return this.openWebProjectAsync(resolveSettings);\n } else if (options.runtime === 'custom') {\n return this.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n } else {\n throw new CommandError(`Invalid runtime target: ${options.runtime}`);\n }\n }\n\n /** Open the current web project (Webpack) in a device . */\n private async openWebProjectAsync(resolveSettings: Partial<IResolveDeviceProps> = {}): Promise<{\n url: string;\n }> {\n const url = this.props.getDevServerUrl();\n assert(url, 'Dev server is not running.');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return { url };\n }\n\n /** If the launch URL cannot be determined (`custom` runtimes) then an alternative string can be provided to open the device. Often a device ID or activity to launch. Exposed for testing. */\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props: Partial<IOpenInCustomProps> = {}\n ): string {\n throw new UnimplementedError();\n }\n}\n"],"names":["debug","require","PlatformManager","constructor","projectRoot","props","_getAppIdResolver","UnimplementedError","openProjectInExpoGoAsync","resolveSettings","url","getExpoGoUrl","assert","deviceManager","resolveDeviceAsync","logOpeningUrl","exp","getConfig","installedExpo","ensureExpoGoAsync","sdkVersion","activateWindowAsync","openUrlAsync","logEventAsync","platform","openProjectInCustomRuntimeAsync","Object","entries","map","k","v","join","getCustomRuntimeUrl","scheme","applicationId","getAppIdAsync","isAppInstalledAsync","CommandError","learnMore","_resolveAlternativeLaunchUrl","openAsync","options","runtime","shouldPrompt","device","openWebProjectAsync","getDevServerUrl"],"mappings":"AAAA;;;;AAA0B,IAAA,OAAc,WAAd,cAAc,CAAA;AACrB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEG,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AACtB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAC3C,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;;;;;;AAI5C,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAetF,MAAMC,eAAe;IAK1BC,YACYC,WAAmB,EACnBC,KAYT,CACD;aAdUD,WAAmB,GAAnBA,WAAmB;aACnBC,KAYT,GAZSA,KAYT;KACC;IAEJ,0GAA0G,CAC1GC,iBAAiB,GAAkB;QACjC,MAAM,IAAIC,OAAkB,mBAAA,EAAE,CAAC;KAChC;IAED,MAAgBC,wBAAwB,CACtCC,eAA6C,GAAG,EAAE,EACxB;QAC1B,MAAMC,GAAG,GAAG,IAAI,CAACL,KAAK,CAACM,YAAY,EAAE,AAAC;QACtC,gDAAgD;QAChDC,CAAAA,GAAAA,OAAM,AAAqC,CAAA,QAArC,CAACF,GAAG,EAAE,8BAA8B,CAAC,CAAC;QAE5C,MAAMG,aAAa,GAAG,MAAM,IAAI,CAACR,KAAK,CAACS,kBAAkB,CAACL,eAAe,CAAC,AAAC;QAC3EI,aAAa,CAACE,aAAa,CAACL,GAAG,CAAC,CAAC;QAEjC,gDAAgD;QAChD,MAAM,EAAEM,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAAkB,CAAA,UAAlB,CAAC,IAAI,CAACb,WAAW,CAAC,AAAC;QAC5C,MAAMc,aAAa,GAAG,MAAML,aAAa,CAACM,iBAAiB,CAACH,GAAG,CAACI,UAAU,CAAC,AAAC;QAE5EP,aAAa,CAACQ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AO,KAAK,QAAQ,EAAE;YACvC,OAAO,IAAI,CAACjB,+BAA+B,CAAChB,eAAe,EAAEgC,OAAO,CAACpC,KAAK,CAAC,CAAC;SAC7E,MAAM;YACL,MAAM,IAAIgC,OAAY,aAAA,CAAC,CAAC,wBAAwB,EAAEI,OAAO,CAACC,OAAO,CAAC,CAAC,CAAC,CAAC;SACtE;KACF;IAED,2DAA2D,CAC3D,MAAcG,mBAAmB,CAACpC,eAA6C,GAAG,EAAE,EAEjF;QACD,MAAMC,GAAG,GAAG,IAAI,CAACL,KAAK,CAACyC,eAAe,EAAE,AAAC;QACzClC,CAAAA,GAAAA,OAAM,AAAmC,CAAA,QAAnC,CAACF,GAAG,EAAE,4BAA4B,CAAC,CAAC;QAE1C,MAAMG,aAAa,GAAG,MAAM,IAAI,CAACR,KAAK,CAACS,kBAAkB,CAACL,eAAe,CAAC,AAAC;QAC3EI,aAAa,CAACE,aAAa,CAACL,GAAG,CAAC,CAAC;QACjC,MAAMG,aAAa,CAACQ,mBAAmB,EAAE,CAAC;QAC1C,MAAMR,aAAa,CAACS,YAAY,CAACZ,GAAG,CAAC,CAAC;QAEtC,OAAO;YAAEA,GAAG;SAAE,CAAC;KAChB;IAED,8LAA8L,CAC9L6B,4BAA4B,CAC1BL,aAAqB,EACrB7B,KAAkC,GAAG,EAAE,EAC/B;QACR,MAAM,IAAIE,OAAkB,mBAAA,EAAE,CAAC;KAChC;CACF;QAlJYL,eAAe,GAAfA,eAAe"}
|
|
@@ -124,7 +124,7 @@ class DevServerManager {
|
|
|
124
124
|
/** Start all dev servers. */ async startAsync(startOptions) {
|
|
125
125
|
const { exp } = (0, _config).getConfig(this.projectRoot);
|
|
126
126
|
var _sdkVersion;
|
|
127
|
-
(0, _rudderstackClient).
|
|
127
|
+
await (0, _rudderstackClient).logEventAsync("Start Project", {
|
|
128
128
|
sdkVersion: (_sdkVersion = exp.sdkVersion) != null ? _sdkVersion : null
|
|
129
129
|
});
|
|
130
130
|
const platformBundlers = (0, _platformBundlers).getPlatformBundlers(exp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { logEvent } from '../../utils/analytics/rudderstackClient';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport { getPlatformBundlers } from './platformBundlers';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n private projectPrerequisites: ProjectPrerequisite[] = [];\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n this.watchBabelConfig();\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot);\n\n logEvent('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(\n this.projectRoot,\n platformBundlers,\n !!options?.devClient\n );\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["AndroidDebugBridge","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","DevServerManager","constructor","projectRoot","options","projectPrerequisites","watchBabelConfig","notifier","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","startAsync","type","startOptions","logEvent","sdkVersion","platformBundlers","BundlerDevServerClass","devClient","stopAsync","Promise","allSettled","map","getServer"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AACjC,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEI,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AAC9B,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AAEtDA,IAAAA,kBAAkB,mCAAM,0BAA0B,EAAhC;AAEM,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oCAAoC,CAAC,AAAsB,AAAC;AAO3F,MAAMC,UAAU,GAAuB,EAAE,AAAC;AAE1C,MAAMC,QAAQ,GAAG;IACfC,OAAO,EAAE,IACPH,OAAO,CAAC,mCAAmC,CAAC,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,SAAS,CAAA,CACrB,AAAC;YACF,MAAM3B,MAAM,CAACoB,UAAU,CAACtC,OAAO,WAAPA,OAAO,GAAI,IAAI,CAACA,OAAO,CAAC,CAAC;YACjDT,UAAU,CAACqB,IAAI,CAACM,MAAM,CAAC,CAAC;SACzB;QAED,OAAOa,GAAG,CAAC;KACZ;IAED,sCAAsC,CACtC,MAAMe,SAAS,GAAkB;QAC/B,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,uBAAuB;eACpBzD,UAAU,CAAC0D,GAAG,CAAC,CAAC/B,MAAM,GAAKA,MAAM,CAAC4B,SAAS,EAAE;YAAA,CAAC;YACjD,WAAW;YACX1D,kBAAkB,CAAC8D,SAAS,EAAE,CAACJ,SAAS,EAAE;SAC3C,CAAC,CAAC;KACJ;CACF;QAjIYjD,gBAAgB,GAAhBA,gBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { logEventAsync } from '../../utils/analytics/rudderstackClient';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport { getPlatformBundlers } from './platformBundlers';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n private projectPrerequisites: ProjectPrerequisite[] = [];\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n this.watchBabelConfig();\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot);\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(\n this.projectRoot,\n platformBundlers,\n !!options?.devClient\n );\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["AndroidDebugBridge","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","DevServerManager","constructor","projectRoot","options","projectPrerequisites","watchBabelConfig","notifier","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","startAsync","type","startOptions","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devClient","stopAsync","Promise","allSettled","map","getServer"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc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,UAAU,YAAdX,WAAc,GAAI,IAAI;SACnC,CAAC,CAAC;QAEH,MAAMY,gBAAgB,GAAGP,CAAAA,GAAAA,iBAAmB,AAAK,CAAA,oBAAL,CAACL,GAAG,CAAC,AAAC;QAElD,2BAA2B;QAC3B,KAAK,MAAM,EAAEQ,IAAI,CAAA,EAAEvC,OAAO,CAAA,EAAE,IAAIwC,YAAY,CAAE;YAC5C,MAAMI,qBAAqB,GAAG,MAAMpD,QAAQ,CAAC+C,IAAI,CAAC,EAAE,AAAC;YACrD,MAAMrB,MAAM,GAAG,IAAI0B,qBAAqB,CACtC,IAAI,CAAC7C,WAAW,EAChB4C,gBAAgB,EAChB,CAAC,CAAC3C,CAAAA,OAAO,QAAW,GAAlBA,KAAAA,CAAkB,GAAlBA,OAAO,CAAE6C,SAAS,CAAA,CACrB,AAAC;YACF,MAAM3B,MAAM,CAACoB,UAAU,CAACtC,OAAO,WAAPA,OAAO,GAAI,IAAI,CAACA,OAAO,CAAC,CAAC;YACjDT,UAAU,CAACqB,IAAI,CAACM,MAAM,CAAC,CAAC;SACzB;QAED,OAAOa,GAAG,CAAC;KACZ;IAED,sCAAsC,CACtC,MAAMe,SAAS,GAAkB;QAC/B,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,uBAAuB;eACpBzD,UAAU,CAAC0D,GAAG,CAAC,CAAC/B,MAAM,GAAKA,MAAM,CAAC4B,SAAS,EAAE;YAAA,CAAC;YACjD,WAAW;YACX1D,kBAAkB,CAAC8D,SAAS,EAAE,CAACJ,SAAS,EAAE;SAC3C,CAAC,CAAC;KACJ;CACF;QAjIYjD,gBAAgB,GAAhBA,gBAAgB"}
|
|
@@ -6,6 +6,7 @@ var _config = require("@expo/config");
|
|
|
6
6
|
var _settings = require("../../api/settings");
|
|
7
7
|
var _updateDevelopmentSession = require("../../api/updateDevelopmentSession");
|
|
8
8
|
var _user = require("../../api/user/user");
|
|
9
|
+
var _log = require("../../log");
|
|
9
10
|
var ProjectDevices = _interopRequireWildcard(require("../project/devices"));
|
|
10
11
|
function _interopRequireWildcard(obj) {
|
|
11
12
|
if (obj && obj.__esModule) {
|
|
@@ -64,12 +65,16 @@ class DevelopmentSession {
|
|
|
64
65
|
}
|
|
65
66
|
if (this.url) {
|
|
66
67
|
debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
try {
|
|
69
|
+
await (0, _updateDevelopmentSession).updateDevelopmentSessionAsync({
|
|
70
|
+
url: this.url,
|
|
71
|
+
runtime,
|
|
72
|
+
exp,
|
|
73
|
+
deviceIds
|
|
74
|
+
});
|
|
75
|
+
} catch (error) {
|
|
76
|
+
_log.Log.warn(`Non-fatal error updating development session API: ${error}`);
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
this.stopNotifying();
|
|
75
80
|
this.timeout = setTimeout(()=>this.startAsync({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport { APISettings } from '../../api/settings';\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n private timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n * @returns\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n if (APISettings.isOffline) {\n debug('Development session will not ping because the server is offline.');\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n await updateDevelopmentSessionAsync({\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport { APISettings } from '../../api/settings';\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport { Log } from '../../log';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n private timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n * @returns\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n if (APISettings.isOffline) {\n debug('Development session will not ping because the server is offline.');\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n try {\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n } catch (error) {\n Log.warn(`Non-fatal error updating development session API: ${error}`);\n }\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n public async closeAsync(): Promise<void> {\n this.stopNotifying();\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n }\n}\n"],"names":["ProjectDevices","debug","require","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","DevelopmentSession","constructor","projectRoot","url","timeout","startAsync","exp","getConfig","runtime","APISettings","isOffline","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","error","Log","warn","setTimeout","devices","getDevicesInfoAsync","map","installationId","clearTimeout","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AAExB,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AAIzC,IAAA,yBAAoC,WAApC,oCAAoC,CAAA;AACd,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AAC9B,IAAA,IAAW,WAAX,WAAW,CAAA;AACnBA,IAAAA,cAAc,mCAAM,oBAAoB,EAA1B;;;;;;;;;;;;;;;;;;;;;;AAE1B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAE7F,MAAMC,gBAAgB,GAAG,EAAE,GAAG,IAAI,AAAC,EAAC,aAAa;AAEjD,eAAeC,oBAAoB,GAAqB;IACtD,OAAO,CAAC,CAAE,MAAMC,CAAAA,GAAAA,KAAY,AAAE,CAAA,aAAF,EAAE,CAACC,KAAK,CAAC,IAAM,IAAI;IAAA,CAAC,AAAC,CAAC;CACnD;AAEM,MAAMC,kBAAkB;IAG7BC,YAEUC,WAAmB,EAEpBC,GAAkB,CACzB;aAHQD,WAAmB,GAAnBA,WAAmB;aAEpBC,GAAkB,GAAlBA,GAAkB;aANnBC,OAAO,GAA0B,IAAI;KAOzC;IAEJ;;;;;;;;;;KAUG,CACH,MAAaC,UAAU,CAAC,EACtBC,GAAG,EAAGC,CAAAA,GAAAA,OAAS,AAAkB,CAAA,UAAlB,CAAC,IAAI,CAACL,WAAW,CAAC,CAACI,GAAG,CAAA,EACrCE,OAAO,CAAA,EAIR,EAAiB;QAChB,IAAIC,SAAW,YAAA,CAACC,SAAS,EAAE;YACzBhB,KAAK,CAAC,kEAAkE,CAAC,CAAC;YAC1E,IAAI,CAACiB,aAAa,EAAE,CAAC;YACrB,OAAO;SACR;QAED,MAAMC,SAAS,GAAG,MAAM,IAA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AACP,OAAO,EAAE;YAChBoB,YAAY,CAAC,IAAI,CAACpB,OAAO,CAAC,CAAC;SAC5B;QACD,IAAI,CAACA,OAAO,GAAG,IAAI,CAAC;KACrB;IAED,MAAaqB,UAAU,GAAkB;QACvC,IAAI,CAACd,aAAa,EAAE,CAAC;QAErB,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,6BAA6B,EAAE,AAAC;QAE7D,IAAI,CAAE,MAAMhB,oBAAoB,EAAE,AAAC,IAAI,CAACe,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEE,MAAM,CAAA,EAAE;YACzD,OAAO;SACR;QAED,IAAI,IAAI,CAACX,GAAG,EAAE;YACZ,MAAMuB,CAAAA,GAAAA,yBAA4B,AAGhC,CAAA,6BAHgC,CAAC;gBACjCvB,GAAG,EAAE,IAAI,CAACA,GAAG;gBACbS,SAAS;aACV,CAAC,CAAC;SACJ;KACF;CACF;QA7FYZ,kBAAkB,GAAlBA,kBAAkB"}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
var _assert = _interopRequireDefault(require("assert"));
|
|
6
6
|
var _url = require("url");
|
|
7
7
|
var Log = _interopRequireWildcard(require("../../log"));
|
|
8
|
+
var _env = require("../../utils/env");
|
|
8
9
|
var _ip = require("../../utils/ip");
|
|
9
10
|
function _interopRequireDefault(obj) {
|
|
10
11
|
return obj && obj.__esModule ? obj : {
|
|
@@ -153,9 +154,13 @@ function joinUrlComponents({ protocol , hostname , port }) {
|
|
|
153
154
|
// This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:
|
|
154
155
|
// `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: "-1"`
|
|
155
156
|
// Invoked first in `metro-runtime/src/modules/HMRClient.js`
|
|
156
|
-
const validPort = port || "80";
|
|
157
|
+
const validPort = _env.env.EXPO_NO_DEFAULT_PORT ? port : port || "80";
|
|
157
158
|
const validProtocol = protocol ? `${protocol}://` : "";
|
|
158
|
-
|
|
159
|
+
let url = `${validProtocol}${hostname}`;
|
|
160
|
+
if (validPort) {
|
|
161
|
+
url += `:${validPort}`;
|
|
162
|
+
}
|
|
163
|
+
return url;
|
|
159
164
|
}
|
|
160
165
|
/** @deprecated */ function getProxyUrl() {
|
|
161
166
|
return process.env.EXPO_PACKAGER_PROXY_URL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport { getIpAddress } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\nexport class UrlCreator {\n constructor(\n private defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * @returns URL like `http://localhost:19000/_expo/loading?platform=ios`\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n url.search = new URLSearchParams({ platform }).toString();\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase())\n ) {\n return null;\n }\n\n const manifestUrl = this.constructUrl({ ...options, scheme: 'http' });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nfunction getDefaultHostname(options: Pick<CreateURLOptions, 'hostname'>) {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // Restrict the use of `localhost`\n // TODO: Note why we do this.\n return '127.0.0.1';\n }\n\n return options.hostname || getIpAddress();\n}\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n // Android HMR breaks without this port 80.\n // This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:\n // `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: \"-1\"`\n // Invoked first in `metro-runtime/src/modules/HMRClient.js`\n const validPort = port || '80';\n const validProtocol = protocol ? `${protocol}://` : '';\n\n return `${validProtocol}${hostname}:${validPort}`;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["Log","debug","require","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","hostType","components","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validPort","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAEbA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA,GAAgB,WAAhB,gBAAg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AOO,OAAO,CAACC,GAAG,CAACO,uBAAuB,CAAC;CAC5C,CAED,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { getIpAddress } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\nexport class UrlCreator {\n constructor(\n private defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * @returns URL like `http://localhost:19000/_expo/loading?platform=ios`\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n url.search = new URLSearchParams({ platform }).toString();\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase())\n ) {\n return null;\n }\n\n const manifestUrl = this.constructUrl({ ...options, scheme: 'http' });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nfunction getDefaultHostname(options: Pick<CreateURLOptions, 'hostname'>) {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // Restrict the use of `localhost`\n // TODO: Note why we do this.\n return '127.0.0.1';\n }\n\n return options.hostname || getIpAddress();\n}\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n // Android HMR breaks without this port 80.\n // This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:\n // `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: \"-1\"`\n // Invoked first in `metro-runtime/src/modules/HMRClient.js`\n const validPort = env.EXPO_NO_DEFAULT_PORT ? port : port || '80';\n const validProtocol = protocol ? `${protocol}://` : '';\n\n let url = `${validProtocol}${hostname}`;\n\n if (validPort) {\n url += `:${validPort}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["Log","debug","require","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","hostType","components","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validPort","EXPO_NO_DEFAULT_PORT","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAEbA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACK,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACR,IAAA,GAAgB,WAAhB,gBAAgB,CAAA;;;;;;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AAG,IAAI,CAAC,CAAC,EAAEsC,SAAS,CAAC,CAAC,CAAC;KACxB;IAED,OAAOtC,GAAG,CAAC;CACZ;AAED,kBAAkB,CAClB,SAASyB,WAAW,GAAuB;IACzC,OAAOO,OAAO,CAACC,GAAG,CAACQ,uBAAuB,CAAC;CAC5C,CAED,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
|
|
@@ -77,7 +77,7 @@ class ClassicManifestMiddleware extends _manifestMiddleware.ManifestMiddleware {
|
|
|
77
77
|
}
|
|
78
78
|
trackManifest(version) {
|
|
79
79
|
// Log analytics
|
|
80
|
-
(0, _rudderstackClient).
|
|
80
|
+
(0, _rudderstackClient).logEventAsync("Serve Manifest", {
|
|
81
81
|
sdkVersion: version != null ? version : null
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -128,7 +128,7 @@ async function createHostInfoAsync() {
|
|
|
128
128
|
host: await _userSettings.default.getAnonymousIdentifierAsync(),
|
|
129
129
|
server: "expo",
|
|
130
130
|
// Defined in the build step
|
|
131
|
-
serverVersion: "0.2.
|
|
131
|
+
serverVersion: "0.2.8",
|
|
132
132
|
serverDriver: _manifestMiddleware.DEVELOPER_TOOL,
|
|
133
133
|
serverOS: _os.default.platform(),
|
|
134
134
|
serverOSVersion: _os.default.release()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/ClassicManifestMiddleware.ts"],"sourcesContent":["import { ExpoAppManifest, ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport os from 'os';\n\nimport { APISettings } from '../../../api/settings';\nimport { signClassicExpoGoManifestAsync } from '../../../api/signManifest';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME, getUserAsync } from '../../../api/user/user';\nimport * as Log from '../../../log';\nimport { logEvent } from '../../../utils/analytics/rudderstackClient';\nimport { memoize } from '../../../utils/fn';\nimport { learnMore } from '../../../utils/link';\nimport { stripPort } from '../../../utils/url';\nimport {\n DEVELOPER_TOOL,\n HostInfo,\n ManifestMiddleware,\n ManifestRequestInfo,\n} from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\ntype SignManifestProps = {\n manifest: ExpoAppManifest;\n hostId: string;\n acceptSignature: boolean;\n};\n\ninterface ClassicManifestRequestInfo extends ManifestRequestInfo {}\n\nexport class ClassicManifestMiddleware extends ManifestMiddleware<ClassicManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ClassicManifestRequestInfo {\n const platform = parsePlatformHeader(req) || 'ios';\n assertRuntimePlatform(platform);\n return {\n platform,\n acceptSignature: Boolean(req.headers['exponent-accept-signature']),\n hostname: stripPort(req.headers['host']),\n };\n }\n\n public async _getManifestResponseAsync({\n acceptSignature,\n ...requestOptions\n }: ClassicManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } = await this._resolveProjectSettingsAsync(\n requestOptions\n );\n\n const manifest: ExpoAppManifest = {\n ...(exp as ExpoAppManifest),\n ...expoGoConfig,\n hostUri,\n bundleUrl,\n };\n\n // Gather packager and host info\n const hostInfo = await createHostInfoAsync();\n\n const headers = new Map<string, any>();\n headers.set('Exponent-Server', hostInfo);\n\n // Create the final string\n const body = await this._fetchComputedManifestStringAsync({\n manifest,\n hostId: hostInfo.host,\n acceptSignature,\n });\n\n return {\n body,\n version: manifest.sdkVersion,\n headers,\n };\n }\n\n protected trackManifest(version?: string) {\n // Log analytics\n logEvent('Serve Manifest', {\n sdkVersion: version ?? null,\n });\n }\n\n /** Exposed for testing. */\n async _getManifestStringAsync({\n manifest,\n hostId,\n acceptSignature,\n }: SignManifestProps): Promise<string> {\n const currentSession = await getUserAsync();\n if (!currentSession || APISettings.isOffline) {\n manifest.id = `@${ANONYMOUS_USERNAME}/${manifest.slug}-${hostId}`;\n }\n if (!acceptSignature) {\n return JSON.stringify(manifest);\n } else if (!currentSession || APISettings.isOffline) {\n return getUnsignedManifestString(manifest);\n } else {\n return this.getSignedManifestStringAsync(manifest);\n }\n }\n\n private getSignedManifestStringAsync = memoize(signClassicExpoGoManifestAsync);\n\n /** Exposed for testing. */\n async _fetchComputedManifestStringAsync(props: SignManifestProps): Promise<string> {\n try {\n return await this._getManifestStringAsync(props);\n } catch (error: any) {\n if (error.code === 'UNAUTHORIZED_ERROR' && props.manifest.owner) {\n // Don't have permissions for siging, warn and enable offline mode.\n this.addSigningDisabledWarning(\n `This project belongs to ${chalk.bold(\n `@${props.manifest.owner}`\n )} and you have not been granted the appropriate permissions.\\n` +\n `Please request access from an admin of @${props.manifest.owner} or change the \"owner\" field to an account you belong to.\\n` +\n learnMore('https://docs.expo.dev/versions/latest/config/app/#owner')\n );\n APISettings.isOffline = true;\n return await this._getManifestStringAsync(props);\n } else if (error.code === 'ENOTFOUND') {\n // Got a DNS error, i.e. can't access exp.host, warn and enable offline mode.\n this.addSigningDisabledWarning(\n `Could not reach Expo servers, please check if you can access ${\n error.hostname || 'exp.host'\n }.`\n );\n APISettings.isOffline = true;\n return await this._getManifestStringAsync(props);\n } else {\n throw error;\n }\n }\n }\n\n private addSigningDisabledWarning = memoize((reason: string) => {\n Log.warn(`${reason}\\nFalling back to offline mode.`);\n // For the memo\n return reason;\n });\n}\n\n// Passed to Expo Go and registered as telemetry.\n// TODO: it's unclear why we don't just send it from the CLI.\nasync function createHostInfoAsync(): Promise<HostInfo> {\n return {\n host: await UserSettings.getAnonymousIdentifierAsync(),\n server: 'expo',\n // Defined in the build step\n serverVersion: process.env.__EXPO_VERSION!,\n serverDriver: DEVELOPER_TOOL,\n serverOS: os.platform(),\n serverOSVersion: os.release(),\n };\n}\n\nfunction getUnsignedManifestString(manifest: ExpoConfig) {\n const unsignedManifest = {\n manifestString: JSON.stringify(manifest),\n signature: 'UNSIGNED',\n };\n return JSON.stringify(unsignedManifest);\n}\n"],"names":["Log","ClassicManifestMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","acceptSignature","Boolean","headers","hostname","stripPort","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","manifest","hostInfo","createHostInfoAsync","Map","set","body","_fetchComputedManifestStringAsync","hostId","host","version","sdkVersion","trackManifest","logEvent","_getManifestStringAsync","currentSession","getUserAsync","APISettings","isOffline","id","ANONYMOUS_USERNAME","slug","JSON","stringify","getUnsignedManifestString","getSignedManifestStringAsync","memoize","signClassicExpoGoManifestAsync","props","error","code","owner","addSigningDisabledWarning","chalk","bold","learnMore","reason","warn","UserSettings","getAnonymousIdentifierAsync","server","serverVersion","process","env","__EXPO_VERSION","serverDriver","DEVELOPER_TOOL","serverOS","os","serverOSVersion","release","unsignedManifest","manifestString","signature"],"mappings":"AAAA;;;;AACkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAES,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AACJ,IAAA,aAA2B,WAA3B,2BAA2B,CAAA;AACjD,IAAA,aAAgC,kCAAhC,gCAAgC,EAAA;AACR,IAAA,KAAwB,WAAxB,wBAAwB,CAAA;AAC7DA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACU,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AAC7C,IAAA,GAAmB,WAAnB,mBAAmB,CAAA;AACjB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACrB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAMvC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAC8B,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWvE,MAAMC,yBAAyB,SAASC,mBAAkB,mBAAA;IAC/D,AAAOC,gBAAgB,CAACC,GAAkB,EAA8B;QACtE,MAAMC,QAAQ,GAAGC,CAAAA,GAAAA,gBAAmB,A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EAAEC,OAAO,CAACC,GAAG,CAACC,cAAc;QACzCC,YAAY,EAAEC,mBAAc,eAAA;QAC5BC,QAAQ,EAAEC,GAAE,QAAA,CAAC9D,QAAQ,EAAE;QACvB+D,eAAe,EAAED,GAAE,QAAA,CAACE,OAAO,EAAE;KAC9B,CAAC;CACH;AAED,SAAS1B,yBAAyB,CAACvB,QAAoB,EAAE;IACvD,MAAMkD,gBAAgB,GAAG;QACvBC,cAAc,EAAE9B,IAAI,CAACC,SAAS,CAACtB,QAAQ,CAAC;QACxCoD,SAAS,EAAE,UAAU;KACtB,AAAC;IACF,OAAO/B,IAAI,CAACC,SAAS,CAAC4B,gBAAgB,CAAC,CAAC;CACzC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/ClassicManifestMiddleware.ts"],"sourcesContent":["import { ExpoAppManifest, ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport os from 'os';\n\nimport { APISettings } from '../../../api/settings';\nimport { signClassicExpoGoManifestAsync } from '../../../api/signManifest';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME, getUserAsync } from '../../../api/user/user';\nimport * as Log from '../../../log';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { memoize } from '../../../utils/fn';\nimport { learnMore } from '../../../utils/link';\nimport { stripPort } from '../../../utils/url';\nimport {\n DEVELOPER_TOOL,\n HostInfo,\n ManifestMiddleware,\n ManifestRequestInfo,\n} from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\ntype SignManifestProps = {\n manifest: ExpoAppManifest;\n hostId: string;\n acceptSignature: boolean;\n};\n\ninterface ClassicManifestRequestInfo extends ManifestRequestInfo {}\n\nexport class ClassicManifestMiddleware extends ManifestMiddleware<ClassicManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ClassicManifestRequestInfo {\n const platform = parsePlatformHeader(req) || 'ios';\n assertRuntimePlatform(platform);\n return {\n platform,\n acceptSignature: Boolean(req.headers['exponent-accept-signature']),\n hostname: stripPort(req.headers['host']),\n };\n }\n\n public async _getManifestResponseAsync({\n acceptSignature,\n ...requestOptions\n }: ClassicManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } = await this._resolveProjectSettingsAsync(\n requestOptions\n );\n\n const manifest: ExpoAppManifest = {\n ...(exp as ExpoAppManifest),\n ...expoGoConfig,\n hostUri,\n bundleUrl,\n };\n\n // Gather packager and host info\n const hostInfo = await createHostInfoAsync();\n\n const headers = new Map<string, any>();\n headers.set('Exponent-Server', hostInfo);\n\n // Create the final string\n const body = await this._fetchComputedManifestStringAsync({\n manifest,\n hostId: hostInfo.host,\n acceptSignature,\n });\n\n return {\n body,\n version: manifest.sdkVersion,\n headers,\n };\n }\n\n protected trackManifest(version?: string) {\n // Log analytics\n logEventAsync('Serve Manifest', {\n sdkVersion: version ?? null,\n });\n }\n\n /** Exposed for testing. */\n async _getManifestStringAsync({\n manifest,\n hostId,\n acceptSignature,\n }: SignManifestProps): Promise<string> {\n const currentSession = await getUserAsync();\n if (!currentSession || APISettings.isOffline) {\n manifest.id = `@${ANONYMOUS_USERNAME}/${manifest.slug}-${hostId}`;\n }\n if (!acceptSignature) {\n return JSON.stringify(manifest);\n } else if (!currentSession || APISettings.isOffline) {\n return getUnsignedManifestString(manifest);\n } else {\n return this.getSignedManifestStringAsync(manifest);\n }\n }\n\n private getSignedManifestStringAsync = memoize(signClassicExpoGoManifestAsync);\n\n /** Exposed for testing. */\n async _fetchComputedManifestStringAsync(props: SignManifestProps): Promise<string> {\n try {\n return await this._getManifestStringAsync(props);\n } catch (error: any) {\n if (error.code === 'UNAUTHORIZED_ERROR' && props.manifest.owner) {\n // Don't have permissions for siging, warn and enable offline mode.\n this.addSigningDisabledWarning(\n `This project belongs to ${chalk.bold(\n `@${props.manifest.owner}`\n )} and you have not been granted the appropriate permissions.\\n` +\n `Please request access from an admin of @${props.manifest.owner} or change the \"owner\" field to an account you belong to.\\n` +\n learnMore('https://docs.expo.dev/versions/latest/config/app/#owner')\n );\n APISettings.isOffline = true;\n return await this._getManifestStringAsync(props);\n } else if (error.code === 'ENOTFOUND') {\n // Got a DNS error, i.e. can't access exp.host, warn and enable offline mode.\n this.addSigningDisabledWarning(\n `Could not reach Expo servers, please check if you can access ${\n error.hostname || 'exp.host'\n }.`\n );\n APISettings.isOffline = true;\n return await this._getManifestStringAsync(props);\n } else {\n throw error;\n }\n }\n }\n\n private addSigningDisabledWarning = memoize((reason: string) => {\n Log.warn(`${reason}\\nFalling back to offline mode.`);\n // For the memo\n return reason;\n });\n}\n\n// Passed to Expo Go and registered as telemetry.\n// TODO: it's unclear why we don't just send it from the CLI.\nasync function createHostInfoAsync(): Promise<HostInfo> {\n return {\n host: await UserSettings.getAnonymousIdentifierAsync(),\n server: 'expo',\n // Defined in the build step\n serverVersion: process.env.__EXPO_VERSION!,\n serverDriver: DEVELOPER_TOOL,\n serverOS: os.platform(),\n serverOSVersion: os.release(),\n };\n}\n\nfunction getUnsignedManifestString(manifest: ExpoConfig) {\n const unsignedManifest = {\n manifestString: JSON.stringify(manifest),\n signature: 'UNSIGNED',\n };\n return JSON.stringify(unsignedManifest);\n}\n"],"names":["Log","ClassicManifestMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","acceptSignature","Boolean","headers","hostname","stripPort","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","manifest","hostInfo","createHostInfoAsync","Map","set","body","_fetchComputedManifestStringAsync","hostId","host","version","sdkVersion","trackManifest","logEventAsync","_getManifestStringAsync","currentSession","getUserAsync","APISettings","isOffline","id","ANONYMOUS_USERNAME","slug","JSON","stringify","getUnsignedManifestString","getSignedManifestStringAsync","memoize","signClassicExpoGoManifestAsync","props","error","code","owner","addSigningDisabledWarning","chalk","bold","learnMore","reason","warn","UserSettings","getAnonymousIdentifierAsync","server","serverVersion","process","env","__EXPO_VERSION","serverDriver","DEVELOPER_TOOL","serverOS","os","serverOSVersion","release","unsignedManifest","manifestString","signature"],"mappings":"AAAA;;;;AACkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAES,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AACJ,IAAA,aAA2B,WAA3B,2BAA2B,CAAA;AACjD,IAAA,aAAgC,kCAAhC,gCAAgC,EAAA;AACR,IAAA,KAAwB,WAAxB,wBAAwB,CAAA;AAC7DA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACe,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AAClD,IAAA,GAAmB,WAAnB,mBAAmB,CAAA;AACjB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACrB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAMvC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAC8B,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWvE,MAAMC,yBAAyB,SAASC,mBAAkB,mBAAA;IAC/D,AAAOC,gBAAgB,CAACC,GAAkB,EAA8B;QACtE,MAAMC,QAAQ,GAAGC,CAAAA,GAAAA,gBAAmB,AAAK,CAAA,oBAAL,CAACF,GAAG,CAAC,IAAI,KAAK,AAAC;QACnDG,CAAAA,GAAAA,gBAAqB,AAAU,CAAA,sBAAV,CAACF,QAAQ,CAAC,CAAC;QAChC,OAAO;YACLA,QAAQ;YACRG,eAAe,EAAEC,OAAO,CAACL,GAAG,CAACM,OAAO,CAAC,2BAA2B,CAAC,CAAC;YAClEC,QAAQ,EAAEC,CAAAA,GAAAA,IAAS,AAAqB,CAAA,UAArB,CAACR,GAAG,CAACM,OAAO,CAAC,MAAM,CAAC,CAAC;SACzC,CAAC;KACH;IAED,MAAaG,yBAAyB,CAA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AAI,CAACC,SAAS,CAAC4B,gBAAgB,CAAC,CAAC;CACzC"}
|
|
@@ -147,7 +147,7 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
|
|
|
147
147
|
return form;
|
|
148
148
|
}
|
|
149
149
|
trackManifest(version) {
|
|
150
|
-
(0, _rudderstackClient).
|
|
150
|
+
(0, _rudderstackClient).logEventAsync("Serve Expo Updates Manifest", {
|
|
151
151
|
runtimeVersion: version
|
|
152
152
|
});
|
|
153
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/ExpoGoManifestHandlerMiddleware.ts"],"sourcesContent":["import { ExpoUpdatesManifest } from '@expo/config';\nimport { Updates } from '@expo/config-plugins';\nimport accepts from 'accepts';\nimport assert from 'assert';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { getProjectAsync } from '../../../api/getProject';\nimport { APISettings } from '../../../api/settings';\nimport { signExpoGoManifestAsync } from '../../../api/signManifest';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME, getUserAsync } from '../../../api/user/user';\nimport { logEvent } from '../../../utils/analytics/rudderstackClient';\nimport {\n CodeSigningInfo,\n getCodeSigningInfoAsync,\n signManifestString,\n} from '../../../utils/codesigning';\nimport { CommandError } from '../../../utils/errors';\nimport { memoize } from '../../../utils/fn';\nimport { stripPort } from '../../../utils/url';\nimport { ManifestMiddleware, ManifestRequestInfo } from './ManifestMiddleware';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n} from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n explicitlyPrefersMultipartMixed: boolean;\n expectSignature: string | null;\n}\n\nexport class ExpoGoManifestHandlerMiddleware extends ManifestMiddleware<ExpoGoManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ExpoGoManifestRequestInfo {\n const platform = parsePlatformHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n\n // Expo Updates clients explicitly accept \"multipart/mixed\" responses while browsers implicitly\n // accept them with \"accept: */*\". To make it easier to debug manifest responses by visiting their\n // URLs in a browser, we denote the response as \"text/plain\" if the user agent appears not to be\n // an Expo Updates client.\n const accept = accepts(req);\n const explicitlyPrefersMultipartMixed =\n accept.types(['unknown/unknown', 'multipart/mixed']) === 'multipart/mixed';\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n explicitlyPrefersMultipartMixed,\n platform,\n acceptSignature: !!req.headers['expo-accept-signature'],\n expectSignature: expectSignature ? String(expectSignature) : null,\n hostname: stripPort(req.headers['host']),\n };\n }\n\n private getDefaultResponseHeaders(): ServerHeaders {\n const headers = new Map<string, number | string | readonly string[]>();\n // set required headers for Expo Updates manifest specification\n headers.set('expo-protocol-version', 0);\n headers.set('expo-sfv-version', 0);\n headers.set('cache-control', 'private, max-age=0');\n return headers;\n }\n\n public async _getManifestResponseAsync(requestOptions: ExpoGoManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } = await this._resolveProjectSettingsAsync(\n requestOptions\n );\n\n const runtimeVersion = Updates.getRuntimeVersion(\n { ...exp, runtimeVersion: exp.runtimeVersion ?? { policy: 'sdkVersion' } },\n requestOptions.platform\n );\n if (!runtimeVersion) {\n throw new CommandError(\n 'MANIFEST_MIDDLEWARE',\n `Unable to determine runtime version for platform '${requestOptions.platform}'`\n );\n }\n\n const codeSigningInfo = await getCodeSigningInfoAsync(\n exp,\n requestOptions.expectSignature,\n this.options.privateKeyPath\n );\n\n const easProjectId = exp.extra?.eas?.projectId;\n const shouldUseAnonymousManifest = await shouldUseAnonymousManifestAsync(\n easProjectId,\n codeSigningInfo\n );\n const userAnonymousIdentifier = await UserSettings.getAnonymousIdentifierAsync();\n if (!shouldUseAnonymousManifest) {\n assert(easProjectId);\n }\n const scopeKey = shouldUseAnonymousManifest\n ? `@${ANONYMOUS_USERNAME}/${exp.slug}-${userAnonymousIdentifier}`\n : await this.getScopeKeyForProjectIdAsync(easProjectId);\n\n const expoUpdatesManifest: ExpoUpdatesManifest = {\n id: uuidv4(),\n createdAt: new Date().toISOString(),\n runtimeVersion,\n launchAsset: {\n key: 'bundle',\n contentType: 'application/javascript',\n url: bundleUrl,\n },\n assets: [], // assets are not used in development\n metadata: {}, // required for the client to detect that this is an expo-updates manifest\n extra: {\n eas: {\n projectId: easProjectId ?? undefined,\n },\n expoClient: {\n ...exp,\n hostUri,\n },\n expoGo: expoGoConfig,\n scopeKey,\n },\n };\n\n const headers = this.getDefaultResponseHeaders();\n if (requestOptions.acceptSignature && !shouldUseAnonymousManifest) {\n const manifestSignature = await this.getSignedManifestStringAsync(expoUpdatesManifest);\n headers.set('expo-manifest-signature', manifestSignature);\n }\n\n const stringifiedManifest = JSON.stringify(expoUpdatesManifest);\n\n let manifestPartHeaders: { 'expo-signature': string } | null = null;\n let certificateChainBody: string | null = null;\n if (codeSigningInfo) {\n const signature = signManifestString(stringifiedManifest, codeSigningInfo);\n manifestPartHeaders = {\n 'expo-signature': serializeDictionary(\n convertToDictionaryItemsRepresentation({\n keyid: 'expo-go',\n sig: signature,\n alg: 'rsa-v1_5-sha256',\n })\n ),\n };\n certificateChainBody = codeSigningInfo.certificateChainForResponse.join('\\n');\n }\n\n const form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n\n headers.set(\n 'content-type',\n requestOptions.explicitlyPrefersMultipartMixed\n ? `multipart/mixed; boundary=${form.getBoundary()}`\n : 'text/plain'\n );\n\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\n };\n }\n\n private getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n }: {\n stringifiedManifest: string;\n manifestPartHeaders: { 'expo-signature': string } | null;\n certificateChainBody: string | null;\n }): FormData {\n const form = new FormData();\n form.append('manifest', stringifiedManifest, {\n contentType: 'application/json',\n header: {\n ...manifestPartHeaders,\n },\n });\n if (certificateChainBody && certificateChainBody.length > 0) {\n form.append('certificate_chain', certificateChainBody, {\n contentType: 'application/x-pem-file',\n });\n }\n return form;\n }\n\n protected trackManifest(version?: string) {\n logEvent('Serve Expo Updates Manifest', {\n runtimeVersion: version,\n });\n }\n\n private getSignedManifestStringAsync = memoize(signExpoGoManifestAsync);\n\n private getScopeKeyForProjectIdAsync = memoize(getScopeKeyForProjectIdAsync);\n}\n\n/**\n * 1. No EAS project ID in config, then use anonymous scope key\n * 2. When offline or not logged in\n * a. If code signing not accepted by client (only legacy manifest signing is supported), then use anonymous scope key\n * b. If code signing accepted by client and no development code signing certificate is cached, then use anonymous scope key\n */\nasync function shouldUseAnonymousManifestAsync(\n easProjectId: string | undefined | null,\n codeSigningInfo: CodeSigningInfo | null\n): Promise<boolean> {\n if (!easProjectId || (APISettings.isOffline && codeSigningInfo === null)) {\n return true;\n }\n\n return !(await getUserAsync());\n}\n\nasync function getScopeKeyForProjectIdAsync(projectId: string): Promise<string> {\n const project = await getProjectAsync(projectId);\n return project.scopeKey;\n}\n\nfunction convertToDictionaryItemsRepresentation(obj: { [key: string]: string }): Dictionary {\n return new Map(\n Object.entries(obj).map(([k, v]) => {\n return [k, [v, new Map()]];\n })\n );\n}\n"],"names":["ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertMissingRuntimePlatform","assertRuntimePlatform","accept","accepts","explicitlyPrefersMultipartMixed","types","expectSignature","headers","acceptSignature","String","hostname","stripPort","getDefaultResponseHeaders","Map","set","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","runtimeVersion","Updates","getRuntimeVersion","policy","CommandError","codeSigningInfo","getCodeSigningInfoAsync","options","privateKeyPath","easProjectId","extra","eas","projectId","shouldUseAnonymousManifest","shouldUseAnonymousManifestAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","assert","scopeKey","ANONYMOUS_USERNAME","slug","getScopeKeyForProjectIdAsync","expoUpdatesManifest","id","uuidv4","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","manifestSignature","getSignedManifestStringAsync","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","FormData","append","header","length","trackManifest","logEvent","memoize","signExpoGoManifestAsync","APISettings","isOffline","getUserAsync","project","getProjectAsync","obj","Object","entries","map","k","v"],"mappings":"AAAA;;;;AACwB,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,QAAS,kCAAT,SAAS,EAAA;AACV,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACN,IAAA,SAAW,kCAAX,WAAW,EAAA;AACgB,IAAA,kBAAoB,WAApB,oBAAoB,CAAA;AACvC,IAAA,KAAM,WAAN,MAAM,CAAA;AAEH,IAAA,WAAyB,WAAzB,yBAAyB,CAAA;AAC7B,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AACX,IAAA,aAA2B,WAA3B,2BAA2B,CAAA;AAC1C,IAAA,aAAgC,kCAAhC,gCAAgC,EAAA;AACR,IAAA,KAAwB,WAAxB,wBAAwB,CAAA;AAChD,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AAK9D,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AACN,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAC5B,IAAA,GAAmB,WAAnB,mBAAmB,CAAA;AACjB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACU,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAKvE,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;AAQnB,MAAM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AAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAIxF,GAAG,EAAE;aAAC;SAAC,CAAC;KAC5B,CAAC,CACH,CAAC;CACH"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/ExpoGoManifestHandlerMiddleware.ts"],"sourcesContent":["import { ExpoUpdatesManifest } from '@expo/config';\nimport { Updates } from '@expo/config-plugins';\nimport accepts from 'accepts';\nimport assert from 'assert';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { getProjectAsync } from '../../../api/getProject';\nimport { APISettings } from '../../../api/settings';\nimport { signExpoGoManifestAsync } from '../../../api/signManifest';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME, getUserAsync } from '../../../api/user/user';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport {\n CodeSigningInfo,\n getCodeSigningInfoAsync,\n signManifestString,\n} from '../../../utils/codesigning';\nimport { CommandError } from '../../../utils/errors';\nimport { memoize } from '../../../utils/fn';\nimport { stripPort } from '../../../utils/url';\nimport { ManifestMiddleware, ManifestRequestInfo } from './ManifestMiddleware';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n} from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n explicitlyPrefersMultipartMixed: boolean;\n expectSignature: string | null;\n}\n\nexport class ExpoGoManifestHandlerMiddleware extends ManifestMiddleware<ExpoGoManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ExpoGoManifestRequestInfo {\n const platform = parsePlatformHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n\n // Expo Updates clients explicitly accept \"multipart/mixed\" responses while browsers implicitly\n // accept them with \"accept: */*\". To make it easier to debug manifest responses by visiting their\n // URLs in a browser, we denote the response as \"text/plain\" if the user agent appears not to be\n // an Expo Updates client.\n const accept = accepts(req);\n const explicitlyPrefersMultipartMixed =\n accept.types(['unknown/unknown', 'multipart/mixed']) === 'multipart/mixed';\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n explicitlyPrefersMultipartMixed,\n platform,\n acceptSignature: !!req.headers['expo-accept-signature'],\n expectSignature: expectSignature ? String(expectSignature) : null,\n hostname: stripPort(req.headers['host']),\n };\n }\n\n private getDefaultResponseHeaders(): ServerHeaders {\n const headers = new Map<string, number | string | readonly string[]>();\n // set required headers for Expo Updates manifest specification\n headers.set('expo-protocol-version', 0);\n headers.set('expo-sfv-version', 0);\n headers.set('cache-control', 'private, max-age=0');\n return headers;\n }\n\n public async _getManifestResponseAsync(requestOptions: ExpoGoManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } = await this._resolveProjectSettingsAsync(\n requestOptions\n );\n\n const runtimeVersion = Updates.getRuntimeVersion(\n { ...exp, runtimeVersion: exp.runtimeVersion ?? { policy: 'sdkVersion' } },\n requestOptions.platform\n );\n if (!runtimeVersion) {\n throw new CommandError(\n 'MANIFEST_MIDDLEWARE',\n `Unable to determine runtime version for platform '${requestOptions.platform}'`\n );\n }\n\n const codeSigningInfo = await getCodeSigningInfoAsync(\n exp,\n requestOptions.expectSignature,\n this.options.privateKeyPath\n );\n\n const easProjectId = exp.extra?.eas?.projectId;\n const shouldUseAnonymousManifest = await shouldUseAnonymousManifestAsync(\n easProjectId,\n codeSigningInfo\n );\n const userAnonymousIdentifier = await UserSettings.getAnonymousIdentifierAsync();\n if (!shouldUseAnonymousManifest) {\n assert(easProjectId);\n }\n const scopeKey = shouldUseAnonymousManifest\n ? `@${ANONYMOUS_USERNAME}/${exp.slug}-${userAnonymousIdentifier}`\n : await this.getScopeKeyForProjectIdAsync(easProjectId);\n\n const expoUpdatesManifest: ExpoUpdatesManifest = {\n id: uuidv4(),\n createdAt: new Date().toISOString(),\n runtimeVersion,\n launchAsset: {\n key: 'bundle',\n contentType: 'application/javascript',\n url: bundleUrl,\n },\n assets: [], // assets are not used in development\n metadata: {}, // required for the client to detect that this is an expo-updates manifest\n extra: {\n eas: {\n projectId: easProjectId ?? undefined,\n },\n expoClient: {\n ...exp,\n hostUri,\n },\n expoGo: expoGoConfig,\n scopeKey,\n },\n };\n\n const headers = this.getDefaultResponseHeaders();\n if (requestOptions.acceptSignature && !shouldUseAnonymousManifest) {\n const manifestSignature = await this.getSignedManifestStringAsync(expoUpdatesManifest);\n headers.set('expo-manifest-signature', manifestSignature);\n }\n\n const stringifiedManifest = JSON.stringify(expoUpdatesManifest);\n\n let manifestPartHeaders: { 'expo-signature': string } | null = null;\n let certificateChainBody: string | null = null;\n if (codeSigningInfo) {\n const signature = signManifestString(stringifiedManifest, codeSigningInfo);\n manifestPartHeaders = {\n 'expo-signature': serializeDictionary(\n convertToDictionaryItemsRepresentation({\n keyid: 'expo-go',\n sig: signature,\n alg: 'rsa-v1_5-sha256',\n })\n ),\n };\n certificateChainBody = codeSigningInfo.certificateChainForResponse.join('\\n');\n }\n\n const form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n\n headers.set(\n 'content-type',\n requestOptions.explicitlyPrefersMultipartMixed\n ? `multipart/mixed; boundary=${form.getBoundary()}`\n : 'text/plain'\n );\n\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\n };\n }\n\n private getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n }: {\n stringifiedManifest: string;\n manifestPartHeaders: { 'expo-signature': string } | null;\n certificateChainBody: string | null;\n }): FormData {\n const form = new FormData();\n form.append('manifest', stringifiedManifest, {\n contentType: 'application/json',\n header: {\n ...manifestPartHeaders,\n },\n });\n if (certificateChainBody && certificateChainBody.length > 0) {\n form.append('certificate_chain', certificateChainBody, {\n contentType: 'application/x-pem-file',\n });\n }\n return form;\n }\n\n protected trackManifest(version?: string) {\n logEventAsync('Serve Expo Updates Manifest', {\n runtimeVersion: version,\n });\n }\n\n private getSignedManifestStringAsync = memoize(signExpoGoManifestAsync);\n\n private getScopeKeyForProjectIdAsync = memoize(getScopeKeyForProjectIdAsync);\n}\n\n/**\n * 1. No EAS project ID in config, then use anonymous scope key\n * 2. When offline or not logged in\n * a. If code signing not accepted by client (only legacy manifest signing is supported), then use anonymous scope key\n * b. If code signing accepted by client and no development code signing certificate is cached, then use anonymous scope key\n */\nasync function shouldUseAnonymousManifestAsync(\n easProjectId: string | undefined | null,\n codeSigningInfo: CodeSigningInfo | null\n): Promise<boolean> {\n if (!easProjectId || (APISettings.isOffline && codeSigningInfo === null)) {\n return true;\n }\n\n return !(await getUserAsync());\n}\n\nasync function getScopeKeyForProjectIdAsync(projectId: string): Promise<string> {\n const project = await getProjectAsync(projectId);\n return project.scopeKey;\n}\n\nfunction convertToDictionaryItemsRepresentation(obj: { [key: string]: string }): Dictionary {\n return new Map(\n Object.entries(obj).map(([k, v]) => {\n return [k, [v, new Map()]];\n })\n );\n}\n"],"names":["ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertMissingRuntimePlatform","assertRuntimePlatform","accept","accepts","explicitlyPrefersMultipartMixed","types","expectSignature","headers","acceptSignature","String","hostname","stripPort","getDefaultResponseHeaders","Map","set","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","runtimeVersion","Updates","getRuntimeVersion","policy","CommandError","codeSigningInfo","getCodeSigningInfoAsync","options","privateKeyPath","easProjectId","extra","eas","projectId","shouldUseAnonymousManifest","shouldUseAnonymousManifestAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","assert","scopeKey","ANONYMOUS_USERNAME","slug","getScopeKeyForProjectIdAsync","expoUpdatesManifest","id","uuidv4","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","manifestSignature","getSignedManifestStringAsync","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","FormData","append","header","length","trackManifest","logEventAsync","memoize","signExpoGoManifestAsync","APISettings","isOffline","getUserAsync","project","getProjectAsync","obj","Object","entries","map","k","v"],"mappings":"AAAA;;;;AACwB,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,QAAS,kCAAT,SAAS,EAAA;AACV,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACN,IAAA,SAAW,kCAAX,WAAW,EAAA;AACgB,IAAA,kBAAoB,WAApB,oBAAoB,CAAA;AACvC,IAAA,KAAM,WAAN,MAAM,CAAA;AAEH,IAAA,WAAyB,WAAzB,yBAAyB,CAAA;AAC7B,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AACX,IAAA,aAA2B,WAA3B,2BAA2B,CAAA;AAC1C,IAAA,aAAgC,kCAAhC,gCAAgC,EAAA;AACR,IAAA,KAAwB,WAAxB,wBAAwB,CAAA;AAC3C,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AAKnE,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AACN,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAC5B,IAAA,GAAmB,WAAnB,mBAAmB,CAAA;AACjB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACU,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAKvE,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;AAQnB,MAAMA,+BAA+B,SAASC,mBAAkB,mBAAA;IACrE,AAAOC,gBAAgB,CAACC,GAAkB,EAA6B;QACrE,MAAMC,QAAQ,GAAGC,CAAAA,GAAAA,gBAAmB,AAAK,CAAA,oBAAL,CAACF,GAAG,CAAC,AAAC;QAC1CG,CAAAA,GAAAA,gBAA4B,AAAU,CAAA,6BAAV,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
var _getDevClientProperties = _interopRequireDefault(require("../utils/analytics/getDevClientProperties"));
|
|
10
10
|
var _rudderstackClient = require("../utils/analytics/rudderstackClient");
|
|
11
|
-
var _env = require("../utils/env");
|
|
12
11
|
var _exit = require("../utils/exit");
|
|
12
|
+
var _interactive = require("../utils/interactive");
|
|
13
13
|
var _profile = require("../utils/profile");
|
|
14
14
|
var _validateDependenciesVersions = require("./doctor/dependencies/validateDependenciesVersions");
|
|
15
15
|
var _typeScriptProjectPrerequisite = require("./doctor/typescript/TypeScriptProjectPrerequisite");
|
|
@@ -110,13 +110,13 @@ async function startAsync(projectRoot, options, settings) {
|
|
|
110
110
|
}
|
|
111
111
|
// Some tracking thing
|
|
112
112
|
if (options.devClient) {
|
|
113
|
-
|
|
113
|
+
await trackAsync(projectRoot, exp);
|
|
114
114
|
}
|
|
115
115
|
await (0, _profile).profile(devServerManager.startAsync.bind(devServerManager))(startOptions);
|
|
116
116
|
// Open project on devices.
|
|
117
117
|
await (0, _profile).profile(_openPlatforms.openPlatformsAsync)(devServerManager, options);
|
|
118
118
|
// Present the Terminal UI.
|
|
119
|
-
if (
|
|
119
|
+
if ((0, _interactive).isInteractive()) {
|
|
120
120
|
var _platforms;
|
|
121
121
|
await (0, _profile).profile(_startInterface.startInterfaceAsync)(devServerManager, {
|
|
122
122
|
platforms: (_platforms = exp.platforms) != null ? _platforms : [
|
|
@@ -135,15 +135,15 @@ async function startAsync(projectRoot, options, settings) {
|
|
|
135
135
|
}
|
|
136
136
|
// Final note about closing the server.
|
|
137
137
|
const logLocation = settings.webOnly ? "in the browser console" : "below";
|
|
138
|
-
Log.log(_chalk.default`Logs for your project will appear ${logLocation}.${
|
|
138
|
+
Log.log(_chalk.default`Logs for your project will appear ${logLocation}.${(0, _interactive).isInteractive() ? _chalk.default.dim(` Press Ctrl+C to exit.`) : ""}`);
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
(0, _rudderstackClient).
|
|
140
|
+
async function trackAsync(projectRoot, exp) {
|
|
141
|
+
await (0, _rudderstackClient).logEventAsync("dev client start command", {
|
|
142
142
|
status: "started",
|
|
143
143
|
...(0, _getDevClientProperties).default(projectRoot, exp)
|
|
144
144
|
});
|
|
145
|
-
(0, _exit).installExitHooks(()=>{
|
|
146
|
-
(0, _rudderstackClient).
|
|
145
|
+
(0, _exit).installExitHooks(async ()=>{
|
|
146
|
+
await (0, _rudderstackClient).logEventAsync("dev client start command", {
|
|
147
147
|
status: "finished",
|
|
148
148
|
...(0, _getDevClientProperties).default(projectRoot, exp)
|
|
149
149
|
});
|