@expo/cli 0.1.3 → 0.2.0
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 +89 -4
- package/build/bin/cli.map +1 -1
- package/build/src/api/rest/wrapFetchWithOffline.js +2 -23
- package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
- package/build/src/customize/customizeAsync.js +40 -0
- package/build/src/customize/customizeAsync.js.map +1 -0
- package/build/src/customize/generate.js +77 -0
- package/build/src/customize/generate.js.map +1 -0
- package/build/src/customize/index.js +41 -0
- package/build/src/customize/index.js.map +1 -0
- package/build/src/customize/resolveOptions.js +18 -0
- package/build/src/customize/resolveOptions.js.map +1 -0
- package/build/src/customize/templates.js +118 -0
- package/build/src/customize/templates.js.map +1 -0
- package/build/src/export/createMetadataJson.js +10 -7
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/exportApp.js +32 -0
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +2 -3
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +51 -34
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +15 -10
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/printBundleSizes.js +27 -48
- package/build/src/export/printBundleSizes.js.map +1 -1
- package/build/src/export/resolveOptions.js +44 -5
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +2 -1
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +37 -0
- package/build/src/export/web/exportWebAsync.js.map +1 -0
- package/build/src/export/web/index.js +66 -0
- package/build/src/export/web/index.js.map +1 -0
- package/build/src/export/web/resolveOptions.js +13 -0
- package/build/src/export/web/resolveOptions.js.map +1 -0
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/checkPackages.js +2 -1
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/index.js +1 -0
- package/build/src/install/index.js.map +1 -1
- package/build/src/install/installAsync.js +13 -5
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/resolveOptions.js +12 -65
- package/build/src/install/resolveOptions.js.map +1 -1
- package/build/src/install/utils/autoAddConfigPlugins.js +5 -26
- package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -1
- package/build/src/log.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +5 -23
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/index.js +18 -12
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +11 -12
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +17 -0
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +2 -1
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +5 -5
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/resolveInstallApkName.js +5 -26
- package/build/src/run/android/resolveInstallApkName.js.map +1 -1
- package/build/src/run/android/runAndroidAsync.js +3 -3
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +3 -0
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/hints.js +1 -1
- package/build/src/run/hints.js.map +1 -1
- package/build/src/run/ios/XcodeBuild.js +275 -0
- package/build/src/run/ios/XcodeBuild.js.map +1 -0
- package/build/src/run/ios/XcodeBuild.types.js +6 -0
- package/build/src/run/ios/XcodeBuild.types.js.map +1 -0
- package/build/src/run/ios/appleDevice/AppleDevice.js +161 -0
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -0
- package/build/src/run/ios/appleDevice/ClientManager.js +161 -0
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/AFCClient.js +195 -0
- package/build/src/run/ios/appleDevice/client/AFCClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js +107 -0
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js +97 -0
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js +140 -0
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js +91 -0
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/ServiceClient.js +21 -0
- package/build/src/run/ios/appleDevice/client/ServiceClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +117 -0
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +90 -0
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js +332 -0
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js +115 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js +126 -0
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js +74 -0
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js +65 -0
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js.map +1 -0
- package/build/src/run/ios/codeSigning/Security.js +85 -0
- package/build/src/run/ios/codeSigning/Security.js.map +1 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js +77 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -0
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +102 -0
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -0
- package/build/src/run/ios/codeSigning/settings.js +21 -0
- package/build/src/run/ios/codeSigning/settings.js.map +1 -0
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js +76 -0
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js.map +1 -0
- package/build/src/run/ios/index.js +98 -0
- package/build/src/run/ios/index.js.map +1 -0
- package/build/src/run/ios/launchApp.js +75 -0
- package/build/src/run/ios/launchApp.js.map +1 -0
- package/build/src/run/ios/options/promptDevice.js +50 -0
- package/build/src/run/ios/options/promptDevice.js.map +1 -0
- package/build/src/run/ios/options/resolveDevice.js +92 -0
- package/build/src/run/ios/options/resolveDevice.js.map +1 -0
- package/build/src/run/ios/options/resolveNativeScheme.js +92 -0
- package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -0
- package/build/src/run/ios/options/resolveOptions.js +44 -0
- package/build/src/run/ios/options/resolveOptions.js.map +1 -0
- package/build/src/run/ios/options/resolveXcodeProject.js +39 -0
- package/build/src/run/ios/options/resolveXcodeProject.js.map +1 -0
- package/build/src/run/ios/runIosAsync.js +85 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -0
- package/build/src/run/resolveBundlerProps.js +9 -6
- package/build/src/run/resolveBundlerProps.js.map +1 -1
- package/build/src/run/startBundler.js +4 -2
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/Prerequisite.js +4 -4
- package/build/src/start/doctor/Prerequisite.js.map +1 -1
- package/build/src/start/doctor/SecurityBinPrerequisite.js +27 -0
- package/build/src/start/doctor/SecurityBinPrerequisite.js.map +1 -0
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +2 -0
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js +69 -0
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js.map +1 -0
- package/build/src/start/doctor/apple/XcodePrerequisite.js +2 -0
- package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +3 -2
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +7 -13
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/getMissingPackages.js +3 -24
- package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +2 -23
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +17 -9
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +2 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +4 -3
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +32 -31
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/interface/KeyPressHandler.js +2 -0
- package/build/src/start/interface/KeyPressHandler.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +5 -5
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/interface/startInterface.js +3 -2
- package/build/src/start/interface/startInterface.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 +4 -24
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/ADBServer.js +17 -32
- package/build/src/start/platforms/android/ADBServer.js.map +1 -1
- package/build/src/start/platforms/android/AndroidSdk.js +41 -0
- package/build/src/start/platforms/android/AndroidSdk.js.map +1 -0
- package/build/src/start/platforms/android/activateWindow.js +4 -4
- package/build/src/start/platforms/android/activateWindow.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +8 -3
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/android/adbReverse.js +3 -2
- package/build/src/start/platforms/android/adbReverse.js.map +1 -1
- package/build/src/start/platforms/android/emulator.js +8 -0
- package/build/src/start/platforms/android/emulator.js.map +1 -1
- package/build/src/start/platforms/android/gradle.js +2 -2
- package/build/src/start/platforms/android/gradle.js.map +1 -1
- package/build/src/start/platforms/android/promptAndroidDevice.js +1 -5
- package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +5 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/getBestSimulator.js +4 -4
- package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
- package/build/src/start/platforms/ios/promptAppleDevice.js +1 -5
- package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +14 -0
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/platforms/ios/simctlLogging.js +220 -0
- package/build/src/start/platforms/ios/simctlLogging.js.map +1 -0
- package/build/src/start/platforms/ios/xcrun.js +2 -23
- package/build/src/start/platforms/ios/xcrun.js.map +1 -1
- package/build/src/start/project/devices.js +2 -0
- package/build/src/start/project/devices.js.map +1 -1
- package/build/src/start/server/AsyncNgrok.js +6 -5
- package/build/src/start/server/AsyncNgrok.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +15 -8
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +15 -5
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +4 -0
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +10 -3
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +9 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +5 -0
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +11 -1
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/resolveFromProject.js +8 -0
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +115 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -0
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
- package/build/src/start/server/middleware/ExpoMiddleware.js +9 -4
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js +24 -0
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js +2 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +57 -6
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +6 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ServeStaticMiddleware.js +62 -0
- package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -0
- package/build/src/start/server/platformBundlers.js +18 -0
- package/build/src/start/server/platformBundlers.js.map +1 -0
- package/build/src/start/server/webTemplate.js +68 -0
- package/build/src/start/server/webTemplate.js.map +1 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +59 -19
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/server/webpack/compile.js +64 -0
- package/build/src/start/server/webpack/compile.js.map +1 -0
- package/build/src/start/startAsync.js +21 -17
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +5 -2
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +30 -3
- package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
- package/build/src/utils/cocoapods.js +47 -0
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/dir.js +6 -1
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/downloadAppAsync.js +3 -2
- package/build/src/utils/downloadAppAsync.js.map +1 -1
- package/build/src/utils/downloadExpoGoAsync.js +7 -32
- package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
- package/build/src/utils/editor.js +3 -2
- package/build/src/utils/editor.js.map +1 -1
- package/build/src/utils/env.js +3 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/exit.js +4 -25
- package/build/src/utils/exit.js.map +1 -1
- package/build/src/utils/getRunningProcess.js +6 -2
- package/build/src/utils/getRunningProcess.js.map +1 -1
- package/build/src/utils/nodeModules.js +13 -102
- package/build/src/utils/nodeModules.js.map +1 -1
- package/build/src/utils/npm.js +3 -24
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/ora.js +1 -13
- package/build/src/utils/ora.js.map +1 -1
- package/build/src/utils/plist.js +59 -0
- package/build/src/utils/plist.js.map +1 -0
- package/build/src/utils/progress.js +46 -0
- package/build/src/utils/progress.js.map +1 -1
- package/build/src/utils/prompts.js +19 -3
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/utils/resolveArgs.js +4 -1
- package/build/src/utils/resolveArgs.js.map +1 -1
- package/build/src/utils/tar.js +3 -0
- package/build/src/utils/tar.js.map +1 -1
- package/build/src/utils/terminal.js +10 -0
- package/build/src/utils/terminal.js.map +1 -0
- package/build/src/utils/validateApplicationId.js +9 -2
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/build/src/utils/variadic.js +47 -0
- package/build/src/utils/variadic.js.map +1 -0
- package/package.json +14 -10
- package/static/template/babel.config.js +6 -0
- package/static/template/index.html +117 -0
- package/static/template/metro.config.js +4 -0
- package/static/template/serve.json +13 -0
- package/static/template/webpack.config.js +7 -0
|
@@ -39,6 +39,7 @@ function _interopRequireWildcard(obj) {
|
|
|
39
39
|
return newObj;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
const debug = require("debug")("expo:start:server:ngrok");
|
|
42
43
|
const NGROK_CONFIG = {
|
|
43
44
|
authToken: "5W1bR67GNbWcXqmxZzBG1_56GezNeaX6sSRvn8npeQ8",
|
|
44
45
|
domain: "exp.direct"
|
|
@@ -85,12 +86,12 @@ class AsyncNgrok {
|
|
|
85
86
|
this.serverUrl = await this._connectToNgrokAsync({
|
|
86
87
|
timeout
|
|
87
88
|
});
|
|
88
|
-
|
|
89
|
+
debug("Tunnel URL:", this.serverUrl);
|
|
89
90
|
Log.log("Tunnel ready.");
|
|
90
91
|
}
|
|
91
92
|
/** Stop the ngrok process if it's running. */ async stopAsync() {
|
|
92
93
|
var ref;
|
|
93
|
-
|
|
94
|
+
debug("Stopping Tunnel");
|
|
94
95
|
await ((ref = this.resolver.get()) == null ? void 0 : ref.kill == null ? void 0 : ref.kill());
|
|
95
96
|
this.serverUrl = null;
|
|
96
97
|
}
|
|
@@ -121,9 +122,9 @@ class AsyncNgrok {
|
|
|
121
122
|
try {
|
|
122
123
|
// Global config path.
|
|
123
124
|
const configPath = path.join(_userSettings.default.getDirectory(), "ngrok.yml");
|
|
124
|
-
|
|
125
|
+
debug("Global config path:", configPath);
|
|
125
126
|
const hostname = await this._getProjectHostnameAsync();
|
|
126
|
-
|
|
127
|
+
debug("Hostname:", hostname);
|
|
127
128
|
const url = await instance.connect({
|
|
128
129
|
authtoken: NGROK_CONFIG.authToken,
|
|
129
130
|
proto: "http",
|
|
@@ -164,7 +165,7 @@ class AsyncNgrok {
|
|
|
164
165
|
await _settings.ProjectSettings.setAsync(this.projectRoot, {
|
|
165
166
|
urlRandomness: randomness
|
|
166
167
|
});
|
|
167
|
-
|
|
168
|
+
debug("Resetting project randomness:", randomness);
|
|
168
169
|
return randomness;
|
|
169
170
|
}
|
|
170
171
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/AsyncNgrok.ts"],"sourcesContent":["import crypto from 'crypto';\nimport * as path from 'path';\nimport slugify from 'slugify';\n\nimport UserSettings from '../../api/user/UserSettings';\nimport { getActorDisplayName, getUserAsync } from '../../api/user/user';\nimport * as Log from '../../log';\nimport { delayAsync, resolveWithTimeout } from '../../utils/delay';\nimport { CommandError } from '../../utils/errors';\nimport { NgrokInstance, NgrokResolver } from '../doctor/ngrok/NgrokResolver';\nimport { startAdbReverseAsync } from '../platforms/android/adbReverse';\nimport { ProjectSettings } from '../project/settings';\n\nconst NGROK_CONFIG = {\n authToken: '5W1bR67GNbWcXqmxZzBG1_56GezNeaX6sSRvn8npeQ8',\n domain: 'exp.direct',\n};\n\nconst TUNNEL_TIMEOUT = 10 * 1000;\n\nexport class AsyncNgrok {\n /** Resolves the best instance of ngrok, exposed for testing. */\n resolver: NgrokResolver;\n\n /** Info about the currently running instance of ngrok. */\n private serverUrl: string | null = null;\n\n constructor(private projectRoot: string, private port: number) {\n this.resolver = new NgrokResolver(projectRoot);\n }\n\n public getActiveUrl(): string | null {\n return this.serverUrl;\n }\n\n /** Exposed for testing. */\n async _getProjectHostnameAsync() {\n const user = await getUserAsync();\n if (user?.__typename === 'Robot') {\n throw new CommandError('NGROK_ROBOT', 'Cannot use ngrok with a robot user.');\n }\n const username = getActorDisplayName(user);\n\n return [\n // NOTE: https://github.com/expo/expo/pull/16556#discussion_r822944286\n await this.getProjectRandomnessAsync(),\n slugify(username),\n // Use the port to distinguish between multiple tunnels (webpack, metro).\n this.port,\n NGROK_CONFIG.domain,\n ].join('.');\n }\n\n /** Start ngrok on the given port for the project. */\n async startAsync({ timeout }: { timeout?: number } = {}): Promise<void> {\n // Ensure the instance is loaded first, this can linger so we should run it before the timeout.\n await this.resolver.resolveAsync({\n // For now, prefer global install since the package has native code (harder to install) and doesn't change very often.\n prefersGlobalInstall: true,\n });\n\n // Ensure ADB reverse is running.\n if (!(await startAdbReverseAsync([this.port]))) {\n // TODO: Better error message.\n throw new CommandError(\n 'NGROK_ADB',\n `Cannot start tunnel URL because \\`adb reverse\\` failed for the connected Android device(s).`\n );\n }\n\n this.serverUrl = await this._connectToNgrokAsync({ timeout });\n\n Log.debug('[ngrok] Tunnel URL:', this.serverUrl);\n Log.log('Tunnel ready.');\n }\n\n /** Stop the ngrok process if it's running. */\n public async stopAsync(): Promise<void> {\n Log.debug('[ngrok] Stopping Tunnel');\n\n await this.resolver.get()?.kill?.();\n this.serverUrl = null;\n }\n\n /** Exposed for testing. */\n async _connectToNgrokAsync(\n options: { timeout?: number } = {},\n attempts: number = 0\n ): Promise<string> {\n // Attempt to stop any hanging processes, this increases the chances of a successful connection.\n await this.stopAsync();\n\n // Get the instance quietly or assert otherwise.\n const instance = await this.resolver.resolveAsync({\n shouldPrompt: false,\n autoInstall: false,\n });\n\n // TODO(Bacon): Consider dropping the timeout functionality:\n // https://github.com/expo/expo/pull/16556#discussion_r822307373\n const results = await resolveWithTimeout(\n () => this.connectToNgrokInternalAsync(instance, attempts),\n {\n timeout: options.timeout ?? TUNNEL_TIMEOUT,\n errorMessage: 'ngrok tunnel took too long to connect.',\n }\n );\n if (typeof results === 'string') {\n return results;\n }\n\n // Wait 100ms and then try again\n await delayAsync(100);\n\n return this._connectToNgrokAsync(options, attempts + 1);\n }\n\n private async connectToNgrokInternalAsync(\n instance: NgrokInstance,\n attempts: number = 0\n ): Promise<string | false> {\n try {\n // Global config path.\n const configPath = path.join(UserSettings.getDirectory(), 'ngrok.yml');\n Log.debug('[ngrok] Global config path:', configPath);\n const hostname = await this._getProjectHostnameAsync();\n Log.debug('[ngrok] Hostname:', hostname);\n\n const url = await instance.connect({\n authtoken: NGROK_CONFIG.authToken,\n proto: 'http',\n hostname,\n configPath,\n onStatusChange(status) {\n if (status === 'closed') {\n Log.error(\n 'We noticed your tunnel is having issues. ' +\n 'This may be due to intermittent problems with ngrok. ' +\n 'If you have trouble connecting to your app, try to restart the project, ' +\n 'or switch the host to `lan`.'\n );\n } else if (status === 'connected') {\n Log.log('Tunnel connected.');\n }\n },\n port: this.port,\n });\n return url;\n } catch (error: any) {\n // Attempt to connect 3 times\n if (attempts >= 2) {\n throw new CommandError('NGROK_CONNECT', error.toString());\n }\n\n // Attempt to fix the issue\n if (error?.error_code === 103) {\n // Change randomness to avoid conflict if killing ngrok doesn't help\n await this._resetProjectRandomnessAsync();\n }\n return false;\n }\n }\n\n private async getProjectRandomnessAsync() {\n const { urlRandomness: randomness } = await ProjectSettings.readAsync(this.projectRoot);\n if (randomness) {\n return randomness;\n }\n return await this._resetProjectRandomnessAsync();\n }\n\n async _resetProjectRandomnessAsync() {\n const randomness = crypto.randomBytes(5).toString('base64url');\n await ProjectSettings.setAsync(this.projectRoot, { urlRandomness: randomness });\n Log.debug('[ngrok] Resetting project randomness:', randomness);\n return randomness;\n }\n}\n"],"names":["path","Log","NGROK_CONFIG","authToken","domain","TUNNEL_TIMEOUT","AsyncNgrok","constructor","projectRoot","port","serverUrl","resolver","NgrokResolver","getActiveUrl","_getProjectHostnameAsync","user","getUserAsync","__typename","CommandError","username","getActorDisplayName","getProjectRandomnessAsync","slugify","join","startAsync","timeout","resolveAsync","prefersGlobalInstall","startAdbReverseAsync","_connectToNgrokAsync","debug","log","stopAsync","get","kill","options","attempts","instance","shouldPrompt","autoInstall","results","resolveWithTimeout","connectToNgrokInternalAsync","errorMessage","delayAsync","configPath","UserSettings","getDirectory","hostname","url","connect","authtoken","proto","onStatusChange","status","error","toString","error_code","_resetProjectRandomnessAsync","urlRandomness","randomness","ProjectSettings","readAsync","crypto","randomBytes","setAsync"],"mappings":"AAAA;;;;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e,gBAAA,CAACC,SAAS,CAAC,IAAI,CAACtD,WAAW,CAAC,AAAC;QACxF,IAAIoD,UAAU,EAAE;YACd,OAAOA,UAAU,CAAC;SACnB;QACD,OAAO,MAAM,IAAI,CAACF,4BAA4B,EAAE,CAAC;KAClD;IAED,MAAMA,4BAA4B,GAAG;QACnC,MAAME,UAAU,GAAGG,OAAM,QAAA,CAACC,WAAW,CAAC,CAAC,CAAC,CAACR,QAAQ,CAAC,WAAW,CAAC,AAAC;QAC/D,MAAMK,SAAe,gBAAA,CAACI,QAAQ,CAAC,IAAI,CAACzD,WAAW,EAAE;YAAEmD,aAAa,EAAEC,UAAU;SAAE,CAAC,CAAC;QAChF3D,GAAG,CAAC6B,KAAK,CAAC,uCAAuC,EAAE8B,UAAU,CAAC,CAAC;QAC/D,OAAOA,UAAU,CAAC;KACnB;CACF;QA7JYtD,UAAU,GAAVA,UAAU"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/AsyncNgrok.ts"],"sourcesContent":["import crypto from 'crypto';\nimport * as path from 'path';\nimport slugify from 'slugify';\n\nimport UserSettings from '../../api/user/UserSettings';\nimport { getActorDisplayName, getUserAsync } from '../../api/user/user';\nimport * as Log from '../../log';\nimport { delayAsync, resolveWithTimeout } from '../../utils/delay';\nimport { CommandError } from '../../utils/errors';\nimport { NgrokInstance, NgrokResolver } from '../doctor/ngrok/NgrokResolver';\nimport { startAdbReverseAsync } from '../platforms/android/adbReverse';\nimport { ProjectSettings } from '../project/settings';\n\nconst debug = require('debug')('expo:start:server:ngrok') as typeof console.log;\n\nconst NGROK_CONFIG = {\n authToken: '5W1bR67GNbWcXqmxZzBG1_56GezNeaX6sSRvn8npeQ8',\n domain: 'exp.direct',\n};\n\nconst TUNNEL_TIMEOUT = 10 * 1000;\n\nexport class AsyncNgrok {\n /** Resolves the best instance of ngrok, exposed for testing. */\n resolver: NgrokResolver;\n\n /** Info about the currently running instance of ngrok. */\n private serverUrl: string | null = null;\n\n constructor(private projectRoot: string, private port: number) {\n this.resolver = new NgrokResolver(projectRoot);\n }\n\n public getActiveUrl(): string | null {\n return this.serverUrl;\n }\n\n /** Exposed for testing. */\n async _getProjectHostnameAsync() {\n const user = await getUserAsync();\n if (user?.__typename === 'Robot') {\n throw new CommandError('NGROK_ROBOT', 'Cannot use ngrok with a robot user.');\n }\n const username = getActorDisplayName(user);\n\n return [\n // NOTE: https://github.com/expo/expo/pull/16556#discussion_r822944286\n await this.getProjectRandomnessAsync(),\n slugify(username),\n // Use the port to distinguish between multiple tunnels (webpack, metro).\n this.port,\n NGROK_CONFIG.domain,\n ].join('.');\n }\n\n /** Start ngrok on the given port for the project. */\n async startAsync({ timeout }: { timeout?: number } = {}): Promise<void> {\n // Ensure the instance is loaded first, this can linger so we should run it before the timeout.\n await this.resolver.resolveAsync({\n // For now, prefer global install since the package has native code (harder to install) and doesn't change very often.\n prefersGlobalInstall: true,\n });\n\n // Ensure ADB reverse is running.\n if (!(await startAdbReverseAsync([this.port]))) {\n // TODO: Better error message.\n throw new CommandError(\n 'NGROK_ADB',\n `Cannot start tunnel URL because \\`adb reverse\\` failed for the connected Android device(s).`\n );\n }\n\n this.serverUrl = await this._connectToNgrokAsync({ timeout });\n\n debug('Tunnel URL:', this.serverUrl);\n Log.log('Tunnel ready.');\n }\n\n /** Stop the ngrok process if it's running. */\n public async stopAsync(): Promise<void> {\n debug('Stopping Tunnel');\n\n await this.resolver.get()?.kill?.();\n this.serverUrl = null;\n }\n\n /** Exposed for testing. */\n async _connectToNgrokAsync(\n options: { timeout?: number } = {},\n attempts: number = 0\n ): Promise<string> {\n // Attempt to stop any hanging processes, this increases the chances of a successful connection.\n await this.stopAsync();\n\n // Get the instance quietly or assert otherwise.\n const instance = await this.resolver.resolveAsync({\n shouldPrompt: false,\n autoInstall: false,\n });\n\n // TODO(Bacon): Consider dropping the timeout functionality:\n // https://github.com/expo/expo/pull/16556#discussion_r822307373\n const results = await resolveWithTimeout(\n () => this.connectToNgrokInternalAsync(instance, attempts),\n {\n timeout: options.timeout ?? TUNNEL_TIMEOUT,\n errorMessage: 'ngrok tunnel took too long to connect.',\n }\n );\n if (typeof results === 'string') {\n return results;\n }\n\n // Wait 100ms and then try again\n await delayAsync(100);\n\n return this._connectToNgrokAsync(options, attempts + 1);\n }\n\n private async connectToNgrokInternalAsync(\n instance: NgrokInstance,\n attempts: number = 0\n ): Promise<string | false> {\n try {\n // Global config path.\n const configPath = path.join(UserSettings.getDirectory(), 'ngrok.yml');\n debug('Global config path:', configPath);\n const hostname = await this._getProjectHostnameAsync();\n debug('Hostname:', hostname);\n\n const url = await instance.connect({\n authtoken: NGROK_CONFIG.authToken,\n proto: 'http',\n hostname,\n configPath,\n onStatusChange(status) {\n if (status === 'closed') {\n Log.error(\n 'We noticed your tunnel is having issues. ' +\n 'This may be due to intermittent problems with ngrok. ' +\n 'If you have trouble connecting to your app, try to restart the project, ' +\n 'or switch the host to `lan`.'\n );\n } else if (status === 'connected') {\n Log.log('Tunnel connected.');\n }\n },\n port: this.port,\n });\n return url;\n } catch (error: any) {\n // Attempt to connect 3 times\n if (attempts >= 2) {\n throw new CommandError('NGROK_CONNECT', error.toString());\n }\n\n // Attempt to fix the issue\n if (error?.error_code === 103) {\n // Change randomness to avoid conflict if killing ngrok doesn't help\n await this._resetProjectRandomnessAsync();\n }\n return false;\n }\n }\n\n private async getProjectRandomnessAsync() {\n const { urlRandomness: randomness } = await ProjectSettings.readAsync(this.projectRoot);\n if (randomness) {\n return randomness;\n }\n return await this._resetProjectRandomnessAsync();\n }\n\n async _resetProjectRandomnessAsync() {\n const randomness = crypto.randomBytes(5).toString('base64url');\n await ProjectSettings.setAsync(this.projectRoot, { urlRandomness: randomness });\n debug('Resetting project randomness:', randomness);\n return randomness;\n }\n}\n"],"names":["path","Log","debug","require","NGROK_CONFIG","authToken","domain","TUNNEL_TIMEOUT","AsyncNgrok","constructor","projectRoot","port","serverUrl","resolver","NgrokResolver","getActiveUrl","_getProjectHostnameAsync","user","getUserAsync","__typename","CommandError","username","getActorDisplayName","getProjectRandomnessAsync","slugify","join","startAsync","timeout","resolveAsync","prefersGlobalInstall","startAdbReverseAsync","_connectToNgrokAsync","log","stopAsync","get","kill","options","attempts","instance","shouldPrompt","autoInstall","results","resolveWithTimeout","connectToNgrokInternalAsync","errorMessage","delayAsync","configPath","UserSettings","getDirectory","hostname","url","connect","authtoken","proto","onStatusChange","status","error","toString","error_code","_resetProjectRandomnessAsync","urlRandomness","randomness","ProjectSettings","readAsync","crypto","randomBytes","setAsync"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACfA,IAAAA,IAAI,mCAAM,MAAM,EAAZ;AACI,IAAA,QAAS,kCAAT,SAAS,EAAA;AAEJ,IAAA,aAA6B,kCAA7B,6BAA6B,EAAA;AACJ,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AAC3DC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACgC,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AACrC,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACJ,IAAA,cAA+B,WAA/B,+BAA+B,CAAA;AACvC,IAAA,WAAiC,WAAjC,iCAAiC,CAAA;AACtC,IAAA,SAAqB,WAArB,qBAAqB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yBAAyB,CAAC,AAAsB,AAAC;AAEhF,MAAMC,YAAY,GAAG;IACnBC,SAAS,EAAE,6CAA6C;IACxDC,MAAM,EAAE,YAAY;CACrB,AAAC;AAEF,MAAMC,cAAc,GAAG,EAAE,GAAG,IAAI,AAAC;AAE1B,MAAMC,UAAU;IAOrBC,YAAoBC,WAAmB,EAAUC,IAAY,CAAE;aAA3CD,WAAmB,GAAnBA,WAAmB;aAAUC,IAAY,GAAZA,IAAY;aAFrDC,SAAS,GAAkB,IAAI;QAGrC,IAAI,CAACC,QAAQ,GAAG,IAAIC,cAAa,cA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ACC,QAAQ,EAAE,CAAC,CAAC;aAC3D;YAED,2BAA2B;YAC3B,IAAID,CAAAA,KAAK,QAAY,GAAjBA,KAAAA,CAAiB,GAAjBA,KAAK,CAAEE,UAAU,CAAA,KAAK,GAAG,EAAE;gBAC7B,oEAAoE;gBACpE,MAAM,IAAI,CAACC,4BAA4B,EAAE,CAAC;aAC3C;YACD,OAAO,KAAK,CAAC;SACd;KACF;IAED,MAAcpC,yBAAyB,GAAG;QACxC,MAAM,EAAEqC,aAAa,EAAEC,UAAU,CAAA,EAAE,GAAG,MAAMC,SAAe,gBAAA,CAACC,SAAS,CAAC,IAAI,CAACrD,WAAW,CAAC,AAAC;QACxF,IAAImD,UAAU,EAAE;YACd,OAAOA,UAAU,CAAC;SACnB;QACD,OAAO,MAAM,IAAI,CAACF,4BAA4B,EAAE,CAAC;KAClD;IAED,MAAMA,4BAA4B,GAAG;QACnC,MAAME,UAAU,GAAGG,OAAM,QAAA,CAACC,WAAW,CAAC,CAAC,CAAC,CAACR,QAAQ,CAAC,WAAW,CAAC,AAAC;QAC/D,MAAMK,SAAe,gBAAA,CAACI,QAAQ,CAAC,IAAI,CAACxD,WAAW,EAAE;YAAEkD,aAAa,EAAEC,UAAU;SAAE,CAAC,CAAC;QAChF3D,KAAK,CAAC,+BAA+B,EAAE2D,UAAU,CAAC,CAAC;QACnD,OAAOA,UAAU,CAAC;KACnB;CACF;QA7JYrD,UAAU,GAAVA,UAAU"}
|
|
@@ -40,6 +40,7 @@ function _interopRequireWildcard(obj) {
|
|
|
40
40
|
return newObj;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
const debug = require("debug")("expo:start:server:devServer");
|
|
43
44
|
const PLATFORM_MANAGERS = {
|
|
44
45
|
simulator: ()=>require("../platforms/ios/ApplePlatformManager").ApplePlatformManager
|
|
45
46
|
,
|
|
@@ -51,8 +52,9 @@ const MIDDLEWARES = {
|
|
|
51
52
|
"expo-updates": ()=>require("./middleware/ExpoGoManifestHandlerMiddleware").ExpoGoManifestHandlerMiddleware
|
|
52
53
|
};
|
|
53
54
|
class BundlerDevServer {
|
|
54
|
-
constructor(projectRoot, isDevClient){
|
|
55
|
+
constructor(projectRoot, platformBundlers, isDevClient){
|
|
55
56
|
this.projectRoot = projectRoot;
|
|
57
|
+
this.platformBundlers = platformBundlers;
|
|
56
58
|
this.isDevClient = isDevClient;
|
|
57
59
|
this.ngrok = null;
|
|
58
60
|
this.devSession = null;
|
|
@@ -119,8 +121,12 @@ class BundlerDevServer {
|
|
|
119
121
|
}
|
|
120
122
|
};
|
|
121
123
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Runs after the `startAsync` function, performing any additional common operations.
|
|
126
|
+
* You can assume the dev server is started by the time this function is called.
|
|
127
|
+
*/ async postStartAsync(options) {
|
|
128
|
+
if (options.location.hostType === "tunnel" && !_settings.APISettings.isOffline && // This is a hack to prevent using tunnel on web since we block it upstream for some reason.
|
|
129
|
+
this.isTargetingNative()) {
|
|
124
130
|
await this._startTunnelAsync();
|
|
125
131
|
}
|
|
126
132
|
await this.startDevSessionAsync();
|
|
@@ -134,7 +140,7 @@ class BundlerDevServer {
|
|
|
134
140
|
var ref;
|
|
135
141
|
const port = (ref = this.getInstance()) == null ? void 0 : ref.location.port;
|
|
136
142
|
if (!port) return null;
|
|
137
|
-
|
|
143
|
+
debug("[ngrok] connect to port: " + port);
|
|
138
144
|
this.ngrok = new _asyncNgrok.AsyncNgrok(this.projectRoot, port);
|
|
139
145
|
await this.ngrok.startAsync();
|
|
140
146
|
return this.ngrok;
|
|
@@ -158,7 +164,7 @@ class BundlerDevServer {
|
|
|
158
164
|
return true;
|
|
159
165
|
}
|
|
160
166
|
isTargetingWeb() {
|
|
161
|
-
return
|
|
167
|
+
return this.platformBundlers.web === this.name;
|
|
162
168
|
}
|
|
163
169
|
/**
|
|
164
170
|
* Sends a message over web sockets to any connected device,
|
|
@@ -186,10 +192,10 @@ class BundlerDevServer {
|
|
|
186
192
|
return new Promise((resolve, reject)=>{
|
|
187
193
|
var ref;
|
|
188
194
|
// Close the server.
|
|
189
|
-
|
|
195
|
+
debug(`Stopping dev server (bundler: ${this.name})`);
|
|
190
196
|
if ((ref = this.instance) == null ? void 0 : ref.server) {
|
|
191
197
|
this.instance.server.close((error)=>{
|
|
192
|
-
|
|
198
|
+
debug(`Stopped dev server (bundler: ${this.name})`);
|
|
193
199
|
this.instance = null;
|
|
194
200
|
if (error) {
|
|
195
201
|
reject(error);
|
|
@@ -198,7 +204,7 @@ class BundlerDevServer {
|
|
|
198
204
|
}
|
|
199
205
|
});
|
|
200
206
|
} else {
|
|
201
|
-
|
|
207
|
+
debug(`Stopped dev server (bundler: ${this.name})`);
|
|
202
208
|
this.instance = null;
|
|
203
209
|
resolve();
|
|
204
210
|
}
|
|
@@ -296,6 +302,7 @@ class BundlerDevServer {
|
|
|
296
302
|
if (!port || !this.urlCreator) {
|
|
297
303
|
throw new _errors.CommandError("DEV_SERVER", "Cannot interact with native platforms until dev server has started");
|
|
298
304
|
}
|
|
305
|
+
debug(`Creating platform manager (platform: ${platform}, port: ${port})`);
|
|
299
306
|
this.platformManagers[platform] = new Manager(this.projectRoot, port, {
|
|
300
307
|
getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),
|
|
301
308
|
getExpoGoUrl: this.getExpoGoUrl.bind(this, platform),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import { MessageSocket } from '@expo/dev-server';\nimport assert from 'assert';\nimport openBrowserAsync from 'better-opn';\nimport resolveFrom from 'resolve-from';\n\nimport { APISettings } from '../../api/settings';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\nimport { AsyncNgrok } from './AsyncNgrok';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Which manifest type to serve. */\n forceManifestType?: 'expo-updates' | 'classic';\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nconst MIDDLEWARES = {\n classic: () =>\n require('./middleware/ClassicManifestMiddleware')\n .ClassicManifestMiddleware as typeof import('./middleware/ClassicManifestMiddleware').ClassicManifestMiddleware,\n 'expo-updates': () =>\n require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Ngrok instance for managing tunnel connections. */\n protected ngrok: AsyncNgrok | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n // TODO: Replace with custom scheme maybe...\n public isDevClient?: boolean\n ) {}\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<\n BundlerStartOptions,\n 'minify' | 'mode' | 'forceManifestType' | 'privateKeyPath'\n > = {}\n ) {\n const manifestType = options.forceManifestType || 'classic';\n assert(manifestType in MIDDLEWARES, `Manifest middleware for type '${manifestType}' not found`);\n const Middleware = MIDDLEWARES[manifestType]();\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware.getHandler();\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: () => {\n this.instance = null;\n },\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n protected async postStartAsync(options: BundlerStartOptions) {\n if (options.location.hostType === 'tunnel' && !APISettings.isOffline) {\n await this._startTunnelAsync();\n }\n await this.startDevSessionAsync();\n\n this.watchConfig();\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n const notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n Log.debug('[ngrok] connect to port: ' + port);\n this.ngrok = new AsyncNgrok(this.projectRoot, port);\n await this.ngrok.startAsync();\n return this.ngrok;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n\n if (this.devSession) {\n this.devSession.stopNotifying();\n }\n\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' })\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return false;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop ngrok if running.\n await this.ngrok?.stopAsync().catch((e) => {\n Log.error(`Error stopping ngrok:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n Log.debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n this.instance.server.close((error) => {\n Log.debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n } else {\n Log.debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n protected getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl()\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n return location.url ?? null;\n }\n\n /** Get the tunnel URL from ngrok. */\n public getTunnelUrl(): string | null {\n return this.ngrok?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const url = this.getDevServerUrl({ hostType: 'localhost' });\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<BaseOpenInCustomProps> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected shouldUseInterstitialPage(): boolean {\n return (\n env.EXPO_ENABLE_INTERSTITIAL_PAGE &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-launcher')\n );\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(platform: keyof typeof PLATFORM_MANAGERS): string | null {\n if (this.shouldUseInterstitialPage()) {\n const loadingUrl =\n platform === 'emulator'\n ? this.urlCreator?.constructLoadingUrl({}, 'android')\n : this.urlCreator?.constructLoadingUrl({ hostType: 'localhost' }, 'ios');\n return loadingUrl ?? null;\n }\n\n return this.urlCreator?.constructUrl({ scheme: 'exp' }) ?? null;\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["Log","PLATFORM_MANAGERS","simulator","require","ApplePlatformManager","emulator","AndroidPlatformManager","MIDDLEWARES","classic","ClassicManifestMiddleware","ExpoGoManifestHandlerMiddleware","BundlerDevServer","constructor","projectRoot","isDevClient","ngrok","devSession","instance","platformManagers","urlCreator","setInstance","getManifestMiddlewareAsync","options","manifestType","forceManifestType","assert","Middleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","getHandler","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","port","CommandError","server","close","location","host","url","protocol","messageSocket","broadcast","hostType","APISettings","isOffline","_startTunnelAsync","startDevSessionAsync","watchConfig","notifier","FileNotifier","getConfigModuleIds","startObserving","getInstance","debug","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","runtime","isTargetingWeb","broadcastMessage","method","params","closeAsync","catch","e","error","exception","resolveWithTimeout","Promise","resolve","reject","timeout","errorMessage","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getActiveUrl","openPlatformAsync","launchTarget","resolver","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","shouldUseInterstitialPage","env","EXPO_ENABLE_INTERSTITIAL_PAGE","resolveFrom","silent","getExpoGoUrl","platform","loadingUrl","constructLoadingUrl","Manager","getCustomRuntimeUrl"],"mappings":"AAAA;;;;AACmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACE,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACjB,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEV,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AACpCA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AACpB,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AAClC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACR,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAMtB,IAAA,WAAc,WAAd,cAAc,CAAA;AACN,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACZ,IAAA,WAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqD3D,MAAMC,iBAAiB,GAAG;IACxBC,SAAS,EAAE,IACTC,OAAO,CAAC,uCAAuC,CAAC,CAC7CC,oBAAoB;IAA+E;IACxGC,QAAQ,EAAE,IACRF,OAAO,CAAC,6CAA6C,CAAC,CACnDG,sBAAsB;CAC5B,AAAC;AAEF,MAAMC,WAAW,GAAG;IAClBC,OAAO,EAAE,IACPL,OAAO,CAAC,wCAAwC,CAAC,CAC9CM,yBAAyB;IAAqF;IACnH,cAAc,EAAE,IACdN,OAAO,CAAC,8CAA8C,CAAC,CACpDO,+BAA+B;CACrC,AAAC;AAEK,MAAeC,gBAAgB;IAepCC,YAESC,WAAmB,EAEnBC,WAAqB,CAC5B;aAHOD,WAAmB,GAAnBA,WAAmB;a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AChF,IAAI,CAAC,IAAI,CAAC3F,gBAAgB,CAAC2F,QAAQ,CAAC,EAAE;gBAEvB,GAAkB;YAD/B,MAAMG,OAAO,GAAG/G,iBAAiB,CAAC4G,QAAQ,CAAC,EAAE,AAAC;YAC9C,MAAMjE,IAAI,GAAG,CAAA,GAAkB,GAAlB,IAAI,CAACoB,WAAW,EAAE,SAAU,GAA5B,KAAA,CAA4B,GAA5B,GAAkB,CAAEhB,QAAQ,CAACJ,IAAI,AAAC;YAC/C,IAAI,CAACA,IAAI,IAAI,CAAC,IAAI,CAACzB,UAAU,EAAE;gBAC7B,MAAM,IAAI0B,OAAY,aAAA,CACpB,YAAY,EACZ,oEAAoE,CACrE,CAAC;aACH;YACD,IAAI,CAAC3B,gBAAgB,CAAC2F,QAAQ,CAAC,GAAG,IAAIG,OAAO,CAAC,IAAI,CAACnG,WAAW,EAAE+B,IAAI,EAAE;gBACpEqE,mBAAmB,EAAE,IAAI,CAAC9F,UAAU,CAACuE,qBAAqB,CAAC5D,IAAI,CAAC,IAAI,CAACX,UAAU,CAAC;gBAChFyF,YAAY,EAAE,IAAI,CAACA,YAAY,CAAC9E,IAAI,CAAC,IAAI,EAAE+E,QAAQ,CAAC;gBACpDvC,eAAe,EAAE,IAAI,CAACA,eAAe,CAACxC,IAAI,CAAC,IAAI,EAAE;oBAAEwB,QAAQ,EAAE,WAAW;iBAAE,CAAC;aAC5E,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAACpC,gBAAgB,CAAC2F,QAAQ,CAAC,CAAC;KACxC;CACF;QAtUqBlG,gBAAgB,GAAhBA,gBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import { MessageSocket } from '@expo/dev-server';\nimport assert from 'assert';\nimport openBrowserAsync from 'better-opn';\nimport resolveFrom from 'resolve-from';\n\nimport { APISettings } from '../../api/settings';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\nimport { AsyncNgrok } from './AsyncNgrok';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Which manifest type to serve. */\n forceManifestType?: 'expo-updates' | 'classic';\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nconst MIDDLEWARES = {\n classic: () =>\n require('./middleware/ClassicManifestMiddleware')\n .ClassicManifestMiddleware as typeof import('./middleware/ClassicManifestMiddleware').ClassicManifestMiddleware,\n 'expo-updates': () =>\n require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Ngrok instance for managing tunnel connections. */\n protected ngrok: AsyncNgrok | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n // TODO: Replace with custom scheme maybe...\n public isDevClient?: boolean\n ) {}\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<\n BundlerStartOptions,\n 'minify' | 'mode' | 'forceManifestType' | 'privateKeyPath'\n > = {}\n ) {\n const manifestType = options.forceManifestType || 'classic';\n assert(manifestType in MIDDLEWARES, `Manifest middleware for type '${manifestType}' not found`);\n const Middleware = MIDDLEWARES[manifestType]();\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware.getHandler();\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: () => {\n this.instance = null;\n },\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !APISettings.isOffline &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n }\n await this.startDevSessionAsync();\n\n this.watchConfig();\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n const notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[ngrok] connect to port: ' + port);\n this.ngrok = new AsyncNgrok(this.projectRoot, port);\n await this.ngrok.startAsync();\n return this.ngrok;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n\n if (this.devSession) {\n this.devSession.stopNotifying();\n }\n\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' })\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop ngrok if running.\n await this.ngrok?.stopAsync().catch((e) => {\n Log.error(`Error stopping ngrok:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n protected getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl()\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n return location.url ?? null;\n }\n\n /** Get the tunnel URL from ngrok. */\n public getTunnelUrl(): string | null {\n return this.ngrok?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const url = this.getDevServerUrl({ hostType: 'localhost' });\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<BaseOpenInCustomProps> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected shouldUseInterstitialPage(): boolean {\n return (\n env.EXPO_ENABLE_INTERSTITIAL_PAGE &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-launcher')\n );\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(platform: keyof typeof PLATFORM_MANAGERS): string | null {\n if (this.shouldUseInterstitialPage()) {\n const loadingUrl =\n platform === 'emulator'\n ? this.urlCreator?.constructLoadingUrl({}, 'android')\n : this.urlCreator?.constructLoadingUrl({ hostType: 'localhost' }, 'ios');\n return loadingUrl ?? null;\n }\n\n return this.urlCreator?.constructUrl({ scheme: 'exp' }) ?? null;\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["Log","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","MIDDLEWARES","classic","ClassicManifestMiddleware","ExpoGoManifestHandlerMiddleware","BundlerDevServer","constructor","projectRoot","platformBundlers","isDevClient","ngrok","devSession","instance","platformManagers","urlCreator","setInstance","getManifestMiddlewareAsync","options","manifestType","forceManifestType","assert","Middleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","getHandler","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","port","CommandError","server","close","location","host","url","protocol","messageSocket","broadcast","hostType","APISettings","isOffline","_startTunnelAsync","startDevSessionAsync","watchConfig","notifier","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","runtime","isTargetingWeb","web","broadcastMessage","method","params","closeAsync","catch","e","error","exception","resolveWithTimeout","Promise","resolve","reject","timeout","errorMessage","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getActiveUrl","openPlatformAsync","launchTarget","resolver","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","shouldUseInterstitialPage","env","EXPO_ENABLE_INTERSTITIAL_PAGE","resolveFrom","silent","getExpoGoUrl","platform","loadingUrl","constructLoadingUrl","Manager","getCustomRuntimeUrl"],"mappings":"AAAA;;;;AACmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACE,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACjB,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEV,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AACpCA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AACpB,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AAClC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACR,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAMtB,IAAA,WAAc,WAAd,cAAc,CAAA;AACN,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACZ,IAAA,WAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG3D,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC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C,IAAI,CAACpG,WAAW,EAAEgC,IAAI,EAAE;gBACpEqE,mBAAmB,EAAE,IAAI,CAAC9F,UAAU,CAACuE,qBAAqB,CAAC5D,IAAI,CAAC,IAAI,CAACX,UAAU,CAAC;gBAChFyF,YAAY,EAAE,IAAI,CAACA,YAAY,CAAC9E,IAAI,CAAC,IAAI,EAAE+E,QAAQ,CAAC;gBACpDxC,eAAe,EAAE,IAAI,CAACA,eAAe,CAACvC,IAAI,CAAC,IAAI,EAAE;oBAAEwB,QAAQ,EAAE,WAAW;iBAAE,CAAC;aAC5E,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAACpC,gBAAgB,CAAC2F,QAAQ,CAAC,CAAC;KACxC;CACF;QAlVqBnG,gBAAgB,GAAhBA,gBAAgB"}
|
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
var _config = require("@expo/config");
|
|
6
6
|
var _assert = _interopRequireDefault(require("assert"));
|
|
7
|
-
var
|
|
7
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
8
|
var _fileNotifier = require("../../utils/FileNotifier");
|
|
9
9
|
var _rudderstackClient = require("../../utils/analytics/rudderstackClient");
|
|
10
10
|
var AndroidDebugBridge = _interopRequireWildcard(require("../platforms/android/adb"));
|
|
11
|
+
var _platformBundlers = require("./platformBundlers");
|
|
11
12
|
function _interopRequireDefault(obj) {
|
|
12
13
|
return obj && obj.__esModule ? obj : {
|
|
13
14
|
default: obj
|
|
@@ -34,6 +35,7 @@ function _interopRequireWildcard(obj) {
|
|
|
34
35
|
return newObj;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
38
|
+
const debug = require("debug")("expo:start:server:devServerManager");
|
|
37
39
|
const devServers = [];
|
|
38
40
|
const BUNDLERS = {
|
|
39
41
|
webpack: ()=>require("./webpack/WebpackBundlerDevServer").WebpackBundlerDevServer
|
|
@@ -54,7 +56,9 @@ class DevServerManager {
|
|
|
54
56
|
"./.babelrc.json",
|
|
55
57
|
"./.babelrc",
|
|
56
58
|
"./.babelrc.js",
|
|
57
|
-
]
|
|
59
|
+
], {
|
|
60
|
+
additionalWarning: _chalk.default` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`
|
|
61
|
+
});
|
|
58
62
|
notifier.startObserving();
|
|
59
63
|
return notifier;
|
|
60
64
|
}
|
|
@@ -104,10 +108,15 @@ class DevServerManager {
|
|
|
104
108
|
if (server4) {
|
|
105
109
|
return;
|
|
106
110
|
}
|
|
107
|
-
|
|
111
|
+
const { exp } = (0, _config).getConfig(this.projectRoot, {
|
|
112
|
+
skipPlugins: true,
|
|
113
|
+
skipSDKVersionRequirement: true
|
|
114
|
+
});
|
|
115
|
+
const bundler = (0, _platformBundlers).getPlatformBundlers(exp).web;
|
|
116
|
+
debug(`Starting ${bundler} dev server for web`);
|
|
108
117
|
return this.startAsync([
|
|
109
118
|
{
|
|
110
|
-
type:
|
|
119
|
+
type: bundler,
|
|
111
120
|
options: this.options
|
|
112
121
|
},
|
|
113
122
|
]);
|
|
@@ -118,10 +127,11 @@ class DevServerManager {
|
|
|
118
127
|
(0, _rudderstackClient).logEvent("Start Project", {
|
|
119
128
|
sdkVersion: (_sdkVersion = exp.sdkVersion) != null ? _sdkVersion : null
|
|
120
129
|
});
|
|
130
|
+
const platformBundlers = (0, _platformBundlers).getPlatformBundlers(exp);
|
|
121
131
|
// Start all dev servers...
|
|
122
132
|
for (const { type , options } of startOptions){
|
|
123
133
|
const BundlerDevServerClass = await BUNDLERS[type]();
|
|
124
|
-
const server = new BundlerDevServerClass(this.projectRoot, !!(options == null ? void 0 : options.devClient));
|
|
134
|
+
const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, !!(options == null ? void 0 : options.devClient));
|
|
125
135
|
await server.startAsync(options != null ? options : this.options);
|
|
126
136
|
devServers.push(server);
|
|
127
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\n\nimport * as Log from '../../log';\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';\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(this.projectRoot, [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\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 Log.debug('Starting webpack dev server');\n return this.startAsync([\n {\n type: 'webpack',\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 // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, !!options?.devClient);\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":["Log","AndroidDebugBridge","devServers","BUNDLERS","webpack","require","WebpackBundlerDevServer","metro","MetroBundlerDevServer","DevServerManager","constructor","projectRoot","options","projectPrerequisites","watchBabelConfig","notifier","FileNotifier","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","debug","startAsync","type","startOptions","exp","getConfig","logEvent","sdkVersion","BundlerDevServerClass","devClient","stopAsync","Promise","allSettled","map","getServer"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AACjC,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEfA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AAC9B,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AAEtDC,IAAAA,kBAAkB,mCAAM,0BAA0B,EAAhC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQ9B,MAAMC,UAAU,GAAuB,EAAE,AAAC;AAE1C,MAAMC,QAAQ,GAAG;IACfC,OAAO,EAAE,IACPC,OAAO,CAAC,mCAAmC,CAAC,CACzCC,uBAAuB;IAA8E;IAC1GC,KAAK,EAAE,IACLF,OAAO,CAAC,+BAA+B,CAAC,CACrCG,qBAAqB;CAC3B,AAAC;AAGK,MAAMC,gBAAgB;IAG3BC,YACSC,WAAmB,EAEnBC,OAA4B,CACnC;aAHOD,WAAmB,GAAnBA,WAAmB;aAEnBC,OAA4B,GAA5BA,OAA4B;aAL7BC,oBAAoB,GAA0B,EAAE;QAOtD,IAAI,CAACC,gBAAgB,EAAE,CAAC;KACzB;IAED,AAAQA,gBAAgB,GAAG;QACzB,MAAMC,QAAQ,GAAG,IAAIC,aAAY,aAAA,CAAC,IAAI,CAACL,WAAW,EAAE;YAClD,mBAAmB;YACnB,qBAAqB;YACrB,iBAAiB;YACjB,YAAY;YACZ,eAAe;SAChB,CAAC,AAAC;QAEHI,QAAQ,CAACE,cAAc,EAAE,CAAC;QAE1B,OAAOF,QAAQ,CAAC;KAC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C,EAAE,AAAC;YACrD,MAAMf,MAAM,GAAG,IAAIqB,qBAAqB,CAAC,IAAI,CAACtC,WAAW,EAAE,CAAC,CAACC,CAAAA,OAAO,QAAW,GAAlBA,KAAAA,CAAkB,GAAlBA,OAAO,CAAEsC,SAAS,CAAA,CAAC,AAAC;YACjF,MAAMtB,MAAM,CAACc,UAAU,CAAC9B,OAAO,WAAPA,OAAO,GAAI,IAAI,CAACA,OAAO,CAAC,CAAC;YACjDV,UAAU,CAACoB,IAAI,CAACM,MAAM,CAAC,CAAC;SACzB;QAED,OAAOiB,GAAG,CAAC;KACZ;IAED,sCAAsC,CACtC,MAAMM,SAAS,GAAkB;QAC/B,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,uBAAuB;eACpBnD,UAAU,CAACoD,GAAG,CAAC,CAAC1B,MAAM,GAAKA,MAAM,CAACuB,SAAS,EAAE;YAAA,CAAC;YACjD,WAAW;YACXlD,kBAAkB,CAACsD,SAAS,EAAE,CAACJ,SAAS,EAAE;SAC3C,CAAC,CAAC;KACJ;CACF;QAhHY1C,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 { 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,CACzCI,uBAAuB;IAA8E;IAC1GC,KAAK,EAAE,IACLL,OAAO,CAAC,+BAA+B,CAAC,CACrCM,qBAAqB;CAC3B,AAAC;AAGK,MAAMC,gBAAgB;IAG3BC,YACSC,WAAmB,EAEnBC,OAA4B,CACnC;aAHOD,WAAmB,GAAnBA,WAAmB;aAEnBC,OAA4B,GAA5BA,OAA4B;aAL7BC,oBAAoB,GAA0B,EAAE;QAOtD,IAAI,CAACC,gBAAgB,EAAE,CAAC;KACzB;IAED,AAAQA,gBAAgB,GAAG;QACzB,MAAMC,QAAQ,GAAG,IAAIC,aAAY,aAAA,CAC/B,IAAI,CAACL,WAAW,EAChB;YACE,mBAAmB;YACnB,qBAAqB;YACrB,iBAAiB;YACjB,YAAY;YACZ,eAAe;SAChB,EACD;YACEM,iBAAiB,EAAEC,MAAK,QAAA,CAAC,sGAAsG,CAAC;SACjI,CACF,AAAC;QAEFH,QAAQ,CAACI,cAAc,EAAE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newObj;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
const debug = require("debug")("expo:start:server:developmentSession");
|
|
31
32
|
const UPDATE_FREQUENCY = 20 * 1000; // 20 seconds
|
|
32
33
|
async function isAuthenticatedAsync() {
|
|
33
34
|
return !!await (0, _user).getUserAsync().catch(()=>null
|
|
@@ -51,15 +52,18 @@ class DevelopmentSession {
|
|
|
51
52
|
* @returns
|
|
52
53
|
*/ async startAsync({ exp =(0, _config).getConfig(this.projectRoot).exp , runtime }) {
|
|
53
54
|
if (_settings.APISettings.isOffline) {
|
|
55
|
+
debug("Development session will not ping because the server is offline.");
|
|
54
56
|
this.stopNotifying();
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
59
|
const deviceIds = await this.getDeviceInstallationIdsAsync();
|
|
58
60
|
if (!await isAuthenticatedAsync() && !(deviceIds == null ? void 0 : deviceIds.length)) {
|
|
61
|
+
debug("Development session will not ping because the user is not authenticated and there are no devices.");
|
|
59
62
|
this.stopNotifying();
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
65
|
if (this.url) {
|
|
66
|
+
debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);
|
|
63
67
|
await (0, _updateDevelopmentSession).updateDevelopmentSessionAsync({
|
|
64
68
|
url: this.url,
|
|
65
69
|
runtime,
|
|
@@ -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 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 this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\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","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","DevelopmentSession","constructor","projectRoot","url","timeout","startAsync","exp","getConfig","runtime","APISettings","isOffline","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","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;AACtCA,IAAAA,cAAc,mCAAM,oBAAoB,EAA1B;;;;;;;;;;;;;;;;;;;;;;AAE1B,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;
|
|
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 url: this.url,\n runtime,\n exp,\n deviceIds,\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","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;AACtCA,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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c,CAACyB,mBAAmB,CAAC,IAAI,CAAChB,WAAW,CAAC,AAAC;QAC/E,OAAOe,OAAO,CAACE,GAAG,CAAC,CAAC,EAAEC,cAAc,CAAA,EAAE,GAAKA,cAAc;QAAA,CAAC,CAAC;KAC5D;IAED,+EAA+E,CAC/E,AAAOT,aAAa,GAAG;QACrB,IAAI,IAAI,CAACP,OAAO,EAAE;YAChBiB,YAAY,CAAC,IAAI,CAACjB,OAAO,CAAC,CAAC;SAC5B;QACD,IAAI,CAACA,OAAO,GAAG,IAAI,CAAC;KACrB;IAED,MAAakB,UAAU,GAAkB;QACvC,IAAI,CAACX,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,MAAMoB,CAAAA,GAAAA,yBAA4B,AAGhC,CAAA,6BAHgC,CAAC;gBACjCpB,GAAG,EAAE,IAAI,CAACA,GAAG;gBACbS,SAAS;aACV,CAAC,CAAC;SACJ;KACF;CACF;QAzFYZ,kBAAkB,GAAlBA,kBAAkB"}
|
|
@@ -32,6 +32,7 @@ function _interopRequireWildcard(obj) {
|
|
|
32
32
|
return newObj;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
const debug = require("debug")("expo:start:server:urlCreator");
|
|
35
36
|
class UrlCreator {
|
|
36
37
|
constructor(defaults, bundlerInfo){
|
|
37
38
|
this.defaults = defaults;
|
|
@@ -47,7 +48,9 @@ class UrlCreator {
|
|
|
47
48
|
url.search = new URLSearchParams({
|
|
48
49
|
platform
|
|
49
50
|
}).toString();
|
|
50
|
-
|
|
51
|
+
const loadingUrl = url.toString();
|
|
52
|
+
debug(`Loading URL: ${loadingUrl}`);
|
|
53
|
+
return loadingUrl;
|
|
51
54
|
}
|
|
52
55
|
/** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */ constructDevClientUrl(options) {
|
|
53
56
|
var ref;
|
|
@@ -63,14 +66,18 @@ class UrlCreator {
|
|
|
63
66
|
...options,
|
|
64
67
|
scheme: "http"
|
|
65
68
|
});
|
|
66
|
-
|
|
69
|
+
const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(manifestUrl)}`;
|
|
70
|
+
debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);
|
|
71
|
+
return devClientUrl;
|
|
67
72
|
}
|
|
68
73
|
/** Create a generic URL. */ constructUrl(options) {
|
|
69
74
|
const urlComponents = this.getUrlComponents({
|
|
70
75
|
...this.defaults,
|
|
71
76
|
...options
|
|
72
77
|
});
|
|
73
|
-
|
|
78
|
+
const url = joinUrlComponents(urlComponents);
|
|
79
|
+
debug(`URL: ${url}`);
|
|
80
|
+
return url;
|
|
74
81
|
}
|
|
75
82
|
/** Get the URL components from the Ngrok server URL. */ getTunnelUrlComponents(options) {
|
|
76
83
|
var _bundlerInfo, ref;
|
|
@@ -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\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 return url.toString();\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 return `${protocol}://expo-development-client/?url=${encodeURIComponent(manifestUrl)}`;\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 return joinUrlComponents(urlComponents);\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","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","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,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBtC,MAAMC,UAAU;IACrBC,YACUC,QAAsC,EACtCC,WAAiE,CACzE;aAFQD,QAAsC,GAAtCA,QAAsC;aACtCC,WAAiE,GAAjEA,WAAiE;KACvE;IAEJ;;KAEG,CACH,AAAOC,mBAAmB,CAACC,OAAyB,EAAEC,QAAgB,EAAU;QAC9E,MAAMC,GAAG,GAAG,IAAIC,IAAG,IAAA,CAAC,eAAe,EAAE,IAAI,CAACC,YAAY,CAAC;YAAEC,MAAM,EAAE,MAAM;YAAE,GAAGL,OAAO;SAAE,CAAC,CAAC,AAAC;QACxFE,GAAG,CAACI,MAAM,GAAG,IAAIC,eAAe,CAAC;YAAEN,QAAQ;SAAE,CAAC,CAACO,QAAQ,EAAE,CAAC;QAC1D,OAAON,GAAG,CAACM,QAAQ,EAAE,CAAC;KACvB;IAED,0GAA0G,CAC1G,AAAOC,qBAAqB,CAACT,OAA0B,EAAiB;YAClC,GAAa;QAAjD,MAAMU,QAAQ,GAAGV,CAAAA,OAAO,QAAQ,GAAfA,KAAAA,CAAe,GAAfA,OAAO,CAAEK,MAAM,CAAA,IAAI,CAAA,CAAA,GAAa,GAAb,IAAI,CAACR,QAAQ,SAAQ,GAArB,KAAA,CAAqB,GAArB,GAAa,CAAEQ,MAAM,CAAA,AAAC;QAE1D,IACE,CAACK,QAAQ,IACT,+EAA+E;QAC/E;YAAC,MAAM;YAAE,OAAO;SAAC,CAACC,QAAQ,CAACD,QAAQ,CAACE,WAAW,EAAE,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I,EAAES,cAAc,CAACT,IAAI;QACzBC,QAAQ,EAAEQ,cAAc,CAACR,QAAQ;QACjCb,QAAQ;KACT,CAAC;CACH;AAED,SAASoB,kBAAkB,CAAC9B,OAA2C,EAAE;IACvE,4CAA4C;IAC5C,IAAIgC,OAAO,CAACC,GAAG,CAACC,8BAA8B,EAAE;QAC9C,OAAOF,OAAO,CAACC,GAAG,CAACC,8BAA8B,CAACC,IAAI,EAAE,CAAC;KAC1D,MAAM,IAAInC,OAAO,CAACuB,QAAQ,KAAK,WAAW,EAAE;QAC3C,kCAAkC;QAClC,6BAA6B;QAC7B,OAAO,WAAW,CAAC;KACpB;IAED,OAAOvB,OAAO,CAACuB,QAAQ,IAAIa,CAAAA,GAAAA,GAAY,AAAE,CAAA,aAAF,EAAE,CAAC;CAC3C;AAED,SAASnB,iBAAiB,CAAC,EAAEP,QAAQ,CAAA,EAAEa,QAAQ,CAAA,EAAED,IAAI,CAAA,EAA0B,EAAU;IACvFe,CAAAA,GAAAA,OAAM,AAA0C,CAAA,QAA1C,CAACd,QAAQ,EAAE,8BAA8B,CAAC,CAAC;IACjD,2CAA2C;IAC3C,gHAAgH;IAChH,sFAAsF;IACtF,4DAA4D;IAC5D,MAAMe,SAAS,GAAGhB,IAAI,IAAI,IAAI,AAAC;IAC/B,MAAMiB,aAAa,GAAG7B,QAAQ,GAAG,CAAC,EAAEA,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,AAAC;IAEvD,OAAO,CAAC,EAAE6B,aAAa,CAAC,EAAEhB,QAAQ,CAAC,CAAC,EAAEe,SAAS,CAAC,CAAC,CAAC;CACnD;AAED,kBAAkB,CAClB,SAASb,WAAW,GAAuB;IACzC,OAAOO,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 { 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,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,8BAA8B,CAAC,AAAsB,AAAC;AAgB9E,MAAMC,UAAU;IACrBC,YACUC,QAAsC,EACtCC,WAAiE,CACzE;aAFQD,QAAsC,GAAtCA,QAAsC;aACtCC,WAAiE,GAAjEA,WAAiE;KACvE;IAEJ;;KAEG,CACH,AAAOC,mBAAmB,CAACC,OAAyB,EAAEC,QAAgB,EAAU;QAC9E,MAAMC,GAAG,G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