@expo/cli 0.0.0 → 0.1.2
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/README.md +106 -0
- package/build/bin/cli +152 -0
- package/build/bin/cli.map +1 -0
- package/build/src/api/endpoint.js +17 -0
- package/build/src/api/endpoint.js.map +1 -0
- package/build/src/api/getExpoGoIntermediateCertificate.js +21 -0
- package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -0
- package/build/src/api/getExpoSchema.js +69 -0
- package/build/src/api/getExpoSchema.js.map +1 -0
- package/build/src/api/getNativeModuleVersions.js +31 -0
- package/build/src/api/getNativeModuleVersions.js.map +1 -0
- package/build/src/api/getProject.js +19 -0
- package/build/src/api/getProject.js.map +1 -0
- package/build/src/api/getProjectDevelopmentCertificate.js +24 -0
- package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -0
- package/build/src/api/getVersions.js +37 -0
- package/build/src/api/getVersions.js.map +1 -0
- package/build/src/api/graphql/client.js +104 -0
- package/build/src/api/graphql/client.js.map +1 -0
- package/build/src/api/graphql/generated.js +113 -0
- package/build/src/api/graphql/generated.js.map +1 -0
- package/build/src/api/graphql/queries/UserQuery.js +43 -0
- package/build/src/api/graphql/queries/UserQuery.js.map +1 -0
- package/build/src/api/rest/cache/FileSystemCache.js +79 -0
- package/build/src/api/rest/cache/FileSystemCache.js.map +1 -0
- package/build/src/api/rest/cache/response.js +31 -0
- package/build/src/api/rest/cache/response.js.map +1 -0
- package/build/src/api/rest/cache/wrapFetchWithCache.js +156 -0
- package/build/src/api/rest/cache/wrapFetchWithCache.js.map +1 -0
- package/build/src/api/rest/client.js +94 -0
- package/build/src/api/rest/client.js.map +1 -0
- package/build/src/api/rest/client.types.js +6 -0
- package/build/src/api/rest/client.types.js.map +1 -0
- package/build/src/api/rest/wrapFetchWithBaseUrl.js +20 -0
- package/build/src/api/rest/wrapFetchWithBaseUrl.js.map +1 -0
- package/build/src/api/rest/wrapFetchWithOffline.js +39 -0
- package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -0
- package/build/src/api/rest/wrapFetchWithProgress.js +59 -0
- package/build/src/api/rest/wrapFetchWithProgress.js.map +1 -0
- package/build/src/api/settings.js +11 -0
- package/build/src/api/settings.js.map +1 -0
- package/build/src/api/signManifest.js +38 -0
- package/build/src/api/signManifest.js.map +1 -0
- package/build/src/api/updateDevelopmentSession.js +74 -0
- package/build/src/api/updateDevelopmentSession.js.map +1 -0
- package/build/src/api/user/UserSettings.js +71 -0
- package/build/src/api/user/UserSettings.js.map +1 -0
- package/build/src/api/user/actions.js +97 -0
- package/build/src/api/user/actions.js.map +1 -0
- package/build/src/api/user/otp.js +139 -0
- package/build/src/api/user/otp.js.map +1 -0
- package/build/src/api/user/user.js +114 -0
- package/build/src/api/user/user.js.map +1 -0
- package/build/src/config/configAsync.js +118 -0
- package/build/src/config/configAsync.js.map +1 -0
- package/build/src/config/index.js +75 -0
- package/build/src/config/index.js.map +1 -0
- package/build/src/export/createBundles.js +62 -0
- package/build/src/export/createBundles.js.map +1 -0
- package/build/src/export/createMetadataJson.js +36 -0
- package/build/src/export/createMetadataJson.js.map +1 -0
- package/build/src/export/exportApp.js +102 -0
- package/build/src/export/exportApp.js.map +1 -0
- package/build/src/export/exportAssets.js +106 -0
- package/build/src/export/exportAssets.js.map +1 -0
- package/build/src/export/exportAsync.js +49 -0
- package/build/src/export/exportAsync.js.map +1 -0
- package/build/src/export/fork-bundleAsync.js +138 -0
- package/build/src/export/fork-bundleAsync.js.map +1 -0
- package/build/src/export/getPublicExpoManifest.js +28 -0
- package/build/src/export/getPublicExpoManifest.js.map +1 -0
- package/build/src/export/getResolvedLocales.js +35 -0
- package/build/src/export/getResolvedLocales.js.map +1 -0
- package/build/src/export/index.js +77 -0
- package/build/src/export/index.js.map +1 -0
- package/build/src/export/printBundleSizes.js +122 -0
- package/build/src/export/printBundleSizes.js.map +1 -0
- package/build/src/export/resolveOptions.js +24 -0
- package/build/src/export/resolveOptions.js.map +1 -0
- package/build/src/export/saveAssets.js +65 -0
- package/build/src/export/saveAssets.js.map +1 -0
- package/build/src/export/writeContents.js +108 -0
- package/build/src/export/writeContents.js.map +1 -0
- package/build/src/install/checkPackages.js +74 -0
- package/build/src/install/checkPackages.js.map +1 -0
- package/build/src/install/index.js +49 -0
- package/build/src/install/index.js.map +1 -0
- package/build/src/install/installAsync.js +103 -0
- package/build/src/install/installAsync.js.map +1 -0
- package/build/src/install/resolveOptions.js +99 -0
- package/build/src/install/resolveOptions.js.map +1 -0
- package/build/src/install/utils/autoAddConfigPlugins.js +87 -0
- package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -0
- package/build/src/log.js +74 -0
- package/build/src/log.js.map +1 -0
- package/build/src/login/index.js +62 -0
- package/build/src/login/index.js.map +1 -0
- package/build/src/logout/index.js +48 -0
- package/build/src/logout/index.js.map +1 -0
- package/build/src/prebuild/clearNativeFolder.js +137 -0
- package/build/src/prebuild/clearNativeFolder.js.map +1 -0
- package/build/src/prebuild/configureProjectAsync.js +68 -0
- package/build/src/prebuild/configureProjectAsync.js.map +1 -0
- package/build/src/prebuild/copyTemplateFiles.js +124 -0
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -0
- package/build/src/prebuild/ensureConfigAsync.js +86 -0
- package/build/src/prebuild/ensureConfigAsync.js.map +1 -0
- package/build/src/prebuild/index.js +90 -0
- package/build/src/prebuild/index.js.map +1 -0
- package/build/src/prebuild/prebuildAsync.js +112 -0
- package/build/src/prebuild/prebuildAsync.js.map +1 -0
- package/build/src/prebuild/resolveOptions.js +97 -0
- package/build/src/prebuild/resolveOptions.js.map +1 -0
- package/build/src/prebuild/resolveTemplate.js +157 -0
- package/build/src/prebuild/resolveTemplate.js.map +1 -0
- package/build/src/prebuild/updateFromTemplate.js +102 -0
- package/build/src/prebuild/updateFromTemplate.js.map +1 -0
- package/build/src/prebuild/updatePackageJson.js +236 -0
- package/build/src/prebuild/updatePackageJson.js.map +1 -0
- package/build/src/prebuild/writeMetroConfig.js +89 -0
- package/build/src/prebuild/writeMetroConfig.js.map +1 -0
- package/build/src/register/index.js +48 -0
- package/build/src/register/index.js.map +1 -0
- package/build/src/register/registerAsync.js +37 -0
- package/build/src/register/registerAsync.js.map +1 -0
- package/build/src/run/android/index.js +97 -0
- package/build/src/run/android/index.js.map +1 -0
- package/build/src/run/android/resolveDevice.js +23 -0
- package/build/src/run/android/resolveDevice.js.map +1 -0
- package/build/src/run/android/resolveGradleProps.js +37 -0
- package/build/src/run/android/resolveGradleProps.js.map +1 -0
- package/build/src/run/android/resolveInstallApkName.js +72 -0
- package/build/src/run/android/resolveInstallApkName.js.map +1 -0
- package/build/src/run/android/resolveLaunchProps.js +32 -0
- package/build/src/run/android/resolveLaunchProps.js.map +1 -0
- package/build/src/run/android/resolveOptions.js +25 -0
- package/build/src/run/android/resolveOptions.js.map +1 -0
- package/build/src/run/android/runAndroidAsync.js +74 -0
- package/build/src/run/android/runAndroidAsync.js.map +1 -0
- package/build/src/run/ensureNativeProject.js +33 -0
- package/build/src/run/ensureNativeProject.js.map +1 -0
- package/build/src/run/hints.js +22 -0
- package/build/src/run/hints.js.map +1 -0
- package/build/src/run/resolveBundlerProps.js +31 -0
- package/build/src/run/resolveBundlerProps.js.map +1 -0
- package/build/src/run/startBundler.js +76 -0
- package/build/src/run/startBundler.js.map +1 -0
- package/build/src/start/doctor/Prerequisite.js +47 -0
- package/build/src/start/doctor/Prerequisite.js.map +1 -0
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +68 -0
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -0
- package/build/src/start/doctor/apple/XcodePrerequisite.js +115 -0
- package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -0
- package/build/src/start/doctor/apple/XcrunPrerequisite.js +65 -0
- package/build/src/start/doctor/apple/XcrunPrerequisite.js.map +1 -0
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +64 -0
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -0
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +131 -0
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -0
- package/build/src/start/doctor/dependencies/getMissingPackages.js +95 -0
- package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -0
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +119 -0
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -0
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +147 -0
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -0
- package/build/src/start/doctor/ngrok/ExternalModule.js +164 -0
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -0
- package/build/src/start/doctor/ngrok/NgrokResolver.js +17 -0
- package/build/src/start/doctor/ngrok/NgrokResolver.js.map +1 -0
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +142 -0
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -0
- package/build/src/start/doctor/typescript/updateTSConfig.js +92 -0
- package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -0
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +112 -0
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -0
- package/build/src/start/index.js +116 -0
- package/build/src/start/index.js.map +1 -0
- package/build/src/start/interface/KeyPressHandler.js +99 -0
- package/build/src/start/interface/KeyPressHandler.js.map +1 -0
- package/build/src/start/interface/commandsTable.js +175 -0
- package/build/src/start/interface/commandsTable.js.map +1 -0
- package/build/src/start/interface/interactiveActions.js +134 -0
- package/build/src/start/interface/interactiveActions.js.map +1 -0
- package/build/src/start/interface/startInterface.js +217 -0
- package/build/src/start/interface/startInterface.js.map +1 -0
- package/build/src/start/platforms/AppIdResolver.js +44 -0
- package/build/src/start/platforms/AppIdResolver.js.map +1 -0
- package/build/src/start/platforms/DeviceManager.js +43 -0
- package/build/src/start/platforms/DeviceManager.js.map +1 -0
- package/build/src/start/platforms/ExpoGoInstaller.js +111 -0
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -0
- package/build/src/start/platforms/PlatformManager.js +121 -0
- package/build/src/start/platforms/PlatformManager.js.map +1 -0
- package/build/src/start/platforms/android/ADBServer.js +129 -0
- package/build/src/start/platforms/android/ADBServer.js.map +1 -0
- package/build/src/start/platforms/android/AndroidAppIdResolver.js +40 -0
- package/build/src/start/platforms/android/AndroidAppIdResolver.js.map +1 -0
- package/build/src/start/platforms/android/AndroidDeviceManager.js +183 -0
- package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -0
- package/build/src/start/platforms/android/AndroidPlatformManager.js +35 -0
- package/build/src/start/platforms/android/AndroidPlatformManager.js.map +1 -0
- package/build/src/start/platforms/android/activateWindow.js +80 -0
- package/build/src/start/platforms/android/activateWindow.js.map +1 -0
- package/build/src/start/platforms/android/adb.js +263 -0
- package/build/src/start/platforms/android/adb.js.map +1 -0
- package/build/src/start/platforms/android/adbReverse.js +84 -0
- package/build/src/start/platforms/android/adbReverse.js.map +1 -0
- package/build/src/start/platforms/android/emulator.js +118 -0
- package/build/src/start/platforms/android/emulator.js.map +1 -0
- package/build/src/start/platforms/android/getDevices.js +36 -0
- package/build/src/start/platforms/android/getDevices.js.map +1 -0
- package/build/src/start/platforms/android/gradle.js +86 -0
- package/build/src/start/platforms/android/gradle.js.map +1 -0
- package/build/src/start/platforms/android/promptAndroidDevice.js +60 -0
- package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -0
- package/build/src/start/platforms/ios/AppleAppIdResolver.js +46 -0
- package/build/src/start/platforms/ios/AppleAppIdResolver.js.map +1 -0
- package/build/src/start/platforms/ios/AppleDeviceManager.js +201 -0
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -0
- package/build/src/start/platforms/ios/ApplePlatformManager.js +31 -0
- package/build/src/start/platforms/ios/ApplePlatformManager.js.map +1 -0
- package/build/src/start/platforms/ios/assertSystemRequirements.js +16 -0
- package/build/src/start/platforms/ios/assertSystemRequirements.js.map +1 -0
- package/build/src/start/platforms/ios/ensureSimulatorAppRunning.js +85 -0
- package/build/src/start/platforms/ios/ensureSimulatorAppRunning.js.map +1 -0
- package/build/src/start/platforms/ios/getBestSimulator.js +101 -0
- package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -0
- package/build/src/start/platforms/ios/promptAppleDevice.js +60 -0
- package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -0
- package/build/src/start/platforms/ios/simctl.js +229 -0
- package/build/src/start/platforms/ios/simctl.js.map +1 -0
- package/build/src/start/platforms/ios/xcrun.js +67 -0
- package/build/src/start/platforms/ios/xcrun.js.map +1 -0
- package/build/src/start/project/devices.js +77 -0
- package/build/src/start/project/devices.js.map +1 -0
- package/build/src/start/project/dotExpo.js +74 -0
- package/build/src/start/project/dotExpo.js.map +1 -0
- package/build/src/start/project/settings.js +13 -0
- package/build/src/start/project/settings.js.map +1 -0
- package/build/src/start/resolveOptions.js +156 -0
- package/build/src/start/resolveOptions.js.map +1 -0
- package/build/src/start/server/AsyncNgrok.js +173 -0
- package/build/src/start/server/AsyncNgrok.js.map +1 -0
- package/build/src/start/server/BundlerDevServer.js +312 -0
- package/build/src/start/server/BundlerDevServer.js.map +1 -0
- package/build/src/start/server/DevServerManager.js +142 -0
- package/build/src/start/server/DevServerManager.js.map +1 -0
- package/build/src/start/server/DevelopmentSession.js +104 -0
- package/build/src/start/server/DevelopmentSession.js.map +1 -0
- package/build/src/start/server/UrlCreator.js +159 -0
- package/build/src/start/server/UrlCreator.js.map +1 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js +97 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -0
- package/build/src/start/server/metro/MetroTerminalReporter.js +178 -0
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -0
- package/build/src/start/server/metro/TerminalReporter.js +87 -0
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -0
- package/build/src/start/server/metro/TerminalReporter.types.js +6 -0
- package/build/src/start/server/metro/TerminalReporter.types.js.map +1 -0
- package/build/src/start/server/metro/instantiateMetro.js +66 -0
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -0
- package/build/src/start/server/metro/resolveFromProject.js +38 -0
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -0
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +145 -0
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +185 -0
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ExpoMiddleware.js +78 -0
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js +70 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ManifestMiddleware.js +177 -0
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +69 -0
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/createDevServerMiddleware.js +24 -0
- package/build/src/start/server/middleware/createDevServerMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/resolveAssets.js +110 -0
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -0
- package/build/src/start/server/middleware/resolveEntryPoint.js +37 -0
- package/build/src/start/server/middleware/resolveEntryPoint.js.map +1 -0
- package/build/src/start/server/middleware/resolvePlatform.js +32 -0
- package/build/src/start/server/middleware/resolvePlatform.js.map +1 -0
- package/build/src/start/server/middleware/server.types.js +6 -0
- package/build/src/start/server/middleware/server.types.js.map +1 -0
- package/build/src/start/server/openPlatforms.js +30 -0
- package/build/src/start/server/openPlatforms.js.map +1 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +299 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -0
- package/build/src/start/server/webpack/formatWebpackMessages.js +94 -0
- package/build/src/start/server/webpack/formatWebpackMessages.js.map +1 -0
- package/build/src/start/server/webpack/resolveFromProject.js +43 -0
- package/build/src/start/server/webpack/resolveFromProject.js.map +1 -0
- package/build/src/start/server/webpack/tls.js +72 -0
- package/build/src/start/server/webpack/tls.js.map +1 -0
- package/build/src/start/startAsync.js +150 -0
- package/build/src/start/startAsync.js.map +1 -0
- package/build/src/utils/FileNotifier.js +71 -0
- package/build/src/utils/FileNotifier.js.map +1 -0
- package/build/src/utils/analytics/getDevClientProperties.js +41 -0
- package/build/src/utils/analytics/getDevClientProperties.js.map +1 -0
- package/build/src/utils/analytics/rudderstackClient.js +106 -0
- package/build/src/utils/analytics/rudderstackClient.js.map +1 -0
- package/build/src/utils/ansi.js +17 -0
- package/build/src/utils/ansi.js.map +1 -0
- package/build/src/utils/args.js +77 -0
- package/build/src/utils/args.js.map +1 -0
- package/build/src/utils/array.js +56 -0
- package/build/src/utils/array.js.map +1 -0
- package/build/src/utils/cocoapods.js +143 -0
- package/build/src/utils/cocoapods.js.map +1 -0
- package/build/src/utils/codesigning.js +283 -0
- package/build/src/utils/codesigning.js.map +1 -0
- package/build/src/utils/createFileTransform.js +89 -0
- package/build/src/utils/createFileTransform.js.map +1 -0
- package/build/src/utils/delay.js +39 -0
- package/build/src/utils/delay.js.map +1 -0
- package/build/src/utils/dir.js +38 -0
- package/build/src/utils/dir.js.map +1 -0
- package/build/src/utils/downloadAppAsync.js +74 -0
- package/build/src/utils/downloadAppAsync.js.map +1 -0
- package/build/src/utils/downloadExpoGoAsync.js +99 -0
- package/build/src/utils/downloadExpoGoAsync.js.map +1 -0
- package/build/src/utils/editor.js +60 -0
- package/build/src/utils/editor.js.map +1 -0
- package/build/src/utils/env.js +62 -0
- package/build/src/utils/env.js.map +1 -0
- package/build/src/utils/errors.js +69 -0
- package/build/src/utils/errors.js.map +1 -0
- package/build/src/utils/exit.js +90 -0
- package/build/src/utils/exit.js.map +1 -0
- package/build/src/utils/findUp.js +33 -0
- package/build/src/utils/findUp.js.map +1 -0
- package/build/src/utils/fn.js +32 -0
- package/build/src/utils/fn.js.map +1 -0
- package/build/src/utils/getOrPromptApplicationId.js +183 -0
- package/build/src/utils/getOrPromptApplicationId.js.map +1 -0
- package/build/src/utils/getRunningProcess.js +92 -0
- package/build/src/utils/getRunningProcess.js.map +1 -0
- package/build/src/utils/git.js +88 -0
- package/build/src/utils/git.js.map +1 -0
- package/build/src/utils/glob.js +65 -0
- package/build/src/utils/glob.js.map +1 -0
- package/build/src/utils/ip.js +16 -0
- package/build/src/utils/ip.js.map +1 -0
- package/build/src/utils/isModuleSymlinked.js +37 -0
- package/build/src/utils/isModuleSymlinked.js.map +1 -0
- package/build/src/utils/link.js +31 -0
- package/build/src/utils/link.js.map +1 -0
- package/build/src/utils/mergeGitIgnorePaths.js +112 -0
- package/build/src/utils/mergeGitIgnorePaths.js.map +1 -0
- package/build/src/utils/modifyConfigAsync.js +68 -0
- package/build/src/utils/modifyConfigAsync.js.map +1 -0
- package/build/src/utils/modifyConfigPlugins.js +51 -0
- package/build/src/utils/modifyConfigPlugins.js.map +1 -0
- package/build/src/utils/nodeModules.js +118 -0
- package/build/src/utils/nodeModules.js.map +1 -0
- package/build/src/utils/npm.js +144 -0
- package/build/src/utils/npm.js.map +1 -0
- package/build/src/utils/obj.js +45 -0
- package/build/src/utils/obj.js.map +1 -0
- package/build/src/utils/ora.js +102 -0
- package/build/src/utils/ora.js.map +1 -0
- package/build/src/utils/port.js +130 -0
- package/build/src/utils/port.js.map +1 -0
- package/build/src/utils/profile.js +63 -0
- package/build/src/utils/profile.js.map +1 -0
- package/build/src/utils/progress.js +15 -0
- package/build/src/utils/progress.js.map +1 -0
- package/build/src/utils/prompts.js +127 -0
- package/build/src/utils/prompts.js.map +1 -0
- package/build/src/utils/resolveArgs.js +94 -0
- package/build/src/utils/resolveArgs.js.map +1 -0
- package/build/src/utils/scheme.js +106 -0
- package/build/src/utils/scheme.js.map +1 -0
- package/build/src/utils/tar.js +59 -0
- package/build/src/utils/tar.js.map +1 -0
- package/build/src/utils/url.js +67 -0
- package/build/src/utils/url.js.map +1 -0
- package/build/src/utils/validateApplicationId.js +90 -0
- package/build/src/utils/validateApplicationId.js.map +1 -0
- package/build/src/whoami/index.js +47 -0
- package/build/src/whoami/index.js.map +1 -0
- package/build/src/whoami/whoamiAsync.js +44 -0
- package/build/src/whoami/whoamiAsync.js.map +1 -0
- package/package.json +132 -4
- package/static/loading-page/index.html +270 -0
- package/index.js +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _assert = _interopRequireDefault(require("assert"));
|
|
6
|
+
var _url = require("url");
|
|
7
|
+
var Log = _interopRequireWildcard(require("../../log"));
|
|
8
|
+
var _ip = require("../../utils/ip");
|
|
9
|
+
function _interopRequireDefault(obj) {
|
|
10
|
+
return obj && obj.__esModule ? obj : {
|
|
11
|
+
default: obj
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function _interopRequireWildcard(obj) {
|
|
15
|
+
if (obj && obj.__esModule) {
|
|
16
|
+
return obj;
|
|
17
|
+
} else {
|
|
18
|
+
var newObj = {};
|
|
19
|
+
if (obj != null) {
|
|
20
|
+
for(var key in obj){
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
22
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
23
|
+
if (desc.get || desc.set) {
|
|
24
|
+
Object.defineProperty(newObj, key, desc);
|
|
25
|
+
} else {
|
|
26
|
+
newObj[key] = obj[key];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
newObj.default = obj;
|
|
32
|
+
return newObj;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class UrlCreator {
|
|
36
|
+
constructor(defaults, bundlerInfo){
|
|
37
|
+
this.defaults = defaults;
|
|
38
|
+
this.bundlerInfo = bundlerInfo;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @returns URL like `http://localhost:19000/_expo/loading?platform=ios`
|
|
42
|
+
*/ constructLoadingUrl(options, platform) {
|
|
43
|
+
const url = new _url.URL("_expo/loading", this.constructUrl({
|
|
44
|
+
scheme: "http",
|
|
45
|
+
...options
|
|
46
|
+
}));
|
|
47
|
+
url.search = new URLSearchParams({
|
|
48
|
+
platform
|
|
49
|
+
}).toString();
|
|
50
|
+
return url.toString();
|
|
51
|
+
}
|
|
52
|
+
/** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */ constructDevClientUrl(options) {
|
|
53
|
+
var ref;
|
|
54
|
+
const protocol = (options == null ? void 0 : options.scheme) || ((ref = this.defaults) == null ? void 0 : ref.scheme);
|
|
55
|
+
if (!protocol || // Prohibit the use of http(s) in dev client URIs since they'll never be valid.
|
|
56
|
+
[
|
|
57
|
+
"http",
|
|
58
|
+
"https"
|
|
59
|
+
].includes(protocol.toLowerCase())) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const manifestUrl = this.constructUrl({
|
|
63
|
+
...options,
|
|
64
|
+
scheme: "http"
|
|
65
|
+
});
|
|
66
|
+
return `${protocol}://expo-development-client/?url=${encodeURIComponent(manifestUrl)}`;
|
|
67
|
+
}
|
|
68
|
+
/** Create a generic URL. */ constructUrl(options) {
|
|
69
|
+
const urlComponents = this.getUrlComponents({
|
|
70
|
+
...this.defaults,
|
|
71
|
+
...options
|
|
72
|
+
});
|
|
73
|
+
return joinUrlComponents(urlComponents);
|
|
74
|
+
}
|
|
75
|
+
/** Get the URL components from the Ngrok server URL. */ getTunnelUrlComponents(options) {
|
|
76
|
+
var _bundlerInfo, ref;
|
|
77
|
+
const tunnelUrl = (ref = (_bundlerInfo = this.bundlerInfo).getTunnelUrl) == null ? void 0 : ref.call(_bundlerInfo);
|
|
78
|
+
if (!tunnelUrl) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const parsed = new _url.URL(tunnelUrl);
|
|
82
|
+
var _scheme;
|
|
83
|
+
return {
|
|
84
|
+
port: parsed.port,
|
|
85
|
+
hostname: parsed.hostname,
|
|
86
|
+
protocol: (_scheme = options.scheme) != null ? _scheme : "http"
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
getUrlComponents(options) {
|
|
90
|
+
// Proxy comes first.
|
|
91
|
+
const proxyURL = getProxyUrl();
|
|
92
|
+
if (proxyURL) {
|
|
93
|
+
return getUrlComponentsFromProxyUrl(options, proxyURL);
|
|
94
|
+
}
|
|
95
|
+
// Ngrok.
|
|
96
|
+
if (options.hostType === "tunnel") {
|
|
97
|
+
const components = this.getTunnelUrlComponents(options);
|
|
98
|
+
if (components) {
|
|
99
|
+
return components;
|
|
100
|
+
}
|
|
101
|
+
Log.warn("Tunnel URL not found (it might not be ready yet), falling back to LAN URL.");
|
|
102
|
+
} else if (options.hostType === "localhost" && !options.hostname) {
|
|
103
|
+
options.hostname = "localhost";
|
|
104
|
+
}
|
|
105
|
+
var _scheme;
|
|
106
|
+
return {
|
|
107
|
+
hostname: getDefaultHostname(options),
|
|
108
|
+
port: this.bundlerInfo.port.toString(),
|
|
109
|
+
protocol: (_scheme = options.scheme) != null ? _scheme : "http"
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.UrlCreator = UrlCreator;
|
|
114
|
+
function getUrlComponentsFromProxyUrl(options, url) {
|
|
115
|
+
const parsedProxyUrl = new _url.URL(url);
|
|
116
|
+
var _scheme;
|
|
117
|
+
let protocol = (_scheme = options.scheme) != null ? _scheme : "http";
|
|
118
|
+
if (parsedProxyUrl.protocol === "https:") {
|
|
119
|
+
if (protocol === "http") {
|
|
120
|
+
protocol = "https";
|
|
121
|
+
}
|
|
122
|
+
if (!parsedProxyUrl.port) {
|
|
123
|
+
parsedProxyUrl.port = "443";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
port: parsedProxyUrl.port,
|
|
128
|
+
hostname: parsedProxyUrl.hostname,
|
|
129
|
+
protocol
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function getDefaultHostname(options) {
|
|
133
|
+
// TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME
|
|
134
|
+
if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {
|
|
135
|
+
return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();
|
|
136
|
+
} else if (options.hostname === "localhost") {
|
|
137
|
+
// Restrict the use of `localhost`
|
|
138
|
+
// TODO: Note why we do this.
|
|
139
|
+
return "127.0.0.1";
|
|
140
|
+
}
|
|
141
|
+
return options.hostname || (0, _ip).getIpAddress();
|
|
142
|
+
}
|
|
143
|
+
function joinUrlComponents({ protocol , hostname , port }) {
|
|
144
|
+
(0, _assert).default(hostname, "hostname cannot be inferred.");
|
|
145
|
+
// Android HMR breaks without this port 80.
|
|
146
|
+
// This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:
|
|
147
|
+
// `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: "-1"`
|
|
148
|
+
// Invoked first in `metro-runtime/src/modules/HMRClient.js`
|
|
149
|
+
const validPort = port || "80";
|
|
150
|
+
const validProtocol = protocol ? `${protocol}://` : "";
|
|
151
|
+
return `${validProtocol}${hostname}:${validPort}`;
|
|
152
|
+
}
|
|
153
|
+
/** @deprecated */ function getProxyUrl() {
|
|
154
|
+
return process.env.EXPO_PACKAGER_PROXY_URL;
|
|
155
|
+
} // TODO: Drop the undocumented env variables:
|
|
156
|
+
// REACT_NATIVE_PACKAGER_HOSTNAME
|
|
157
|
+
// EXPO_PACKAGER_PROXY_URL
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=UrlCreator.js.map
|
|
@@ -0,0 +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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AS,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"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _devServer = require("@expo/dev-server");
|
|
6
|
+
var _port = require("../../../utils/port");
|
|
7
|
+
var _bundlerDevServer = require("../BundlerDevServer");
|
|
8
|
+
var _interstitialPageMiddleware = require("../middleware/InterstitialPageMiddleware");
|
|
9
|
+
var _runtimeRedirectMiddleware = require("../middleware/RuntimeRedirectMiddleware");
|
|
10
|
+
var _instantiateMetro = require("./instantiateMetro");
|
|
11
|
+
/** Default port to use for apps running in Expo Go. */ const EXPO_GO_METRO_PORT = 19000;
|
|
12
|
+
/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */ const DEV_CLIENT_METRO_PORT = 8081;
|
|
13
|
+
class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
14
|
+
get name() {
|
|
15
|
+
return "metro";
|
|
16
|
+
}
|
|
17
|
+
async resolvePortAsync(options = {}) {
|
|
18
|
+
var // If the manually defined port is busy then an error should be thrown...
|
|
19
|
+
_port1;
|
|
20
|
+
const port = (_port1 = options.port) != null ? _port1 : // Otherwise use the default port based on the runtime target.
|
|
21
|
+
(options.devClient ? Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT : await (0, _port).getFreePortAsync(EXPO_GO_METRO_PORT));
|
|
22
|
+
return port;
|
|
23
|
+
}
|
|
24
|
+
async startImplementationAsync(options) {
|
|
25
|
+
options.port = await this.resolvePortAsync(options);
|
|
26
|
+
this.urlCreator = this.getUrlCreator(options);
|
|
27
|
+
const parsedOptions = {
|
|
28
|
+
port: options.port,
|
|
29
|
+
maxWorkers: options.maxWorkers,
|
|
30
|
+
resetCache: options.resetDevServer,
|
|
31
|
+
// Use the unversioned metro config.
|
|
32
|
+
// TODO: Deprecate this property when expo-cli goes away.
|
|
33
|
+
unversioned: false
|
|
34
|
+
};
|
|
35
|
+
const { server , middleware , messageSocket } = await (0, _instantiateMetro).instantiateMetroAsync(this.projectRoot, parsedOptions);
|
|
36
|
+
const manifestMiddleware = await this.getManifestMiddlewareAsync(options);
|
|
37
|
+
// We need the manifest handler to be the first middleware to run so our
|
|
38
|
+
// routes take precedence over static files. For example, the manifest is
|
|
39
|
+
// served from '/' and if the user has an index.html file in their project
|
|
40
|
+
// then the manifest handler will never run, the static middleware will run
|
|
41
|
+
// and serve index.html instead of the manifest.
|
|
42
|
+
// https://github.com/expo/expo/issues/13114
|
|
43
|
+
(0, _devServer).prependMiddleware(middleware, manifestMiddleware);
|
|
44
|
+
middleware.use(new _interstitialPageMiddleware.InterstitialPageMiddleware(this.projectRoot).getHandler());
|
|
45
|
+
const deepLinkMiddleware = new _runtimeRedirectMiddleware.RuntimeRedirectMiddleware(this.projectRoot, {
|
|
46
|
+
onDeepLink: ({ runtime })=>{
|
|
47
|
+
// eslint-disable-next-line no-useless-return
|
|
48
|
+
if (runtime === "expo") return;
|
|
49
|
+
// TODO: Some heavy analytics...
|
|
50
|
+
},
|
|
51
|
+
getLocation: ({ runtime })=>{
|
|
52
|
+
if (runtime === "custom") {
|
|
53
|
+
var ref;
|
|
54
|
+
return (ref = this.urlCreator) == null ? void 0 : ref.constructDevClientUrl();
|
|
55
|
+
} else {
|
|
56
|
+
var ref1;
|
|
57
|
+
return (ref1 = this.urlCreator) == null ? void 0 : ref1.constructUrl({
|
|
58
|
+
scheme: "exp"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
middleware.use(deepLinkMiddleware.getHandler());
|
|
64
|
+
// Extend the close method to ensure that we clean up the local info.
|
|
65
|
+
const originalClose = server.close.bind(server);
|
|
66
|
+
server.close = (callback)=>{
|
|
67
|
+
return originalClose((err)=>{
|
|
68
|
+
this.instance = null;
|
|
69
|
+
callback == null ? void 0 : callback(err);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
server,
|
|
74
|
+
location: {
|
|
75
|
+
// The port is the main thing we want to send back.
|
|
76
|
+
port: options.port,
|
|
77
|
+
// localhost isn't always correct.
|
|
78
|
+
host: "localhost",
|
|
79
|
+
// http is the only supported protocol on native.
|
|
80
|
+
url: `http://localhost:${options.port}`,
|
|
81
|
+
protocol: "http"
|
|
82
|
+
},
|
|
83
|
+
middleware,
|
|
84
|
+
messageSocket
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
getConfigModuleIds() {
|
|
88
|
+
return [
|
|
89
|
+
"./metro.config.js",
|
|
90
|
+
"./metro.config.json",
|
|
91
|
+
"./rn-cli.config.js"
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.MetroBundlerDevServer = MetroBundlerDevServer;
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=MetroBundlerDevServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["import { prependMiddleware } from '@expo/dev-server';\n\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport { RuntimeRedirectMiddleware } from '../middleware/RuntimeRedirectMiddleware';\nimport { instantiateMetroAsync } from './instantiateMetro';\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 19000;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 19000 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n\n // Use the unversioned metro config.\n // TODO: Deprecate this property when expo-cli goes away.\n unversioned: false,\n };\n\n const { server, middleware, messageSocket } = await instantiateMetroAsync(\n this.projectRoot,\n parsedOptions\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n prependMiddleware(middleware, manifestMiddleware);\n\n middleware.use(new InterstitialPageMiddleware(this.projectRoot).getHandler());\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: ({ runtime }) => {\n // eslint-disable-next-line no-useless-return\n if (runtime === 'expo') return;\n // TODO: Some heavy analytics...\n },\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n callback?.(err);\n });\n };\n\n return {\n server,\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 };\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n}\n"],"names":["EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","server","middleware","messageSocket","instantiateMetroAsync","projectRoot","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","use","InterstitialPageMiddleware","getHandler","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","runtime","getLocation","constructDevClientUrl","constructUrl","scheme","originalClose","close","bind","callback","err","instance","location","host","url","protocol","getConfigModuleIds"],"mappings":"AAAA;;;;AAAkC,IAAA,UAAkB,WAAlB,kBAAkB,CAAA;AAEnB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACmB,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACnD,IAAA,2BAA0C,WAA1C,0CAA0C,CAAA;AAC3C,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AAC7C,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAE1D,uDAAuD,CACvD,MAAMA,kBAAkB,GAAG,KAAK,AAAC;AAEjC,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AG,IAAI,CAAC;gBACrBF,QAAQ,QAAO,GAAfA,KAAAA,CAAe,GAAfA,QAAQ,CAAGC,GAAG,CAAC,AA1FvB,CA0FwB;aACjB,CAAC,CAAC;SACJ,CAAC;QAEF,OAAO;YACLvB,MAAM;YACNyB,QAAQ,EAAE;gBACR,mDAAmD;gBACnDxC,IAAI,EAAED,OAAO,CAACC,IAAI;gBAClB,kCAAkC;gBAClCyC,IAAI,EAAE,WAAW;gBACjB,iDAAiD;gBACjDC,GAAG,EAAE,CAAC,iBAAiB,EAAE3C,OAAO,CAACC,IAAI,CAAC,CAAC;gBACvC2C,QAAQ,EAAE,MAAM;aACjB;YACD3B,UAAU;YACVC,aAAa;SACd,CAAC;KACH;IAED,AAAU2B,kBAAkB,GAAa;QACvC,OAAO;YAAC,mBAAmB;YAAE,qBAAqB;YAAE,oBAAoB;SAAC,CAAC;KAC3E;CACF;QAnGYjD,qBAAqB,GAArBA,qBAAqB"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.formatUsingNodeStandardLibraryError = formatUsingNodeStandardLibraryError;
|
|
6
|
+
exports.isNodeStdLibraryModule = isNodeStdLibraryModule;
|
|
7
|
+
exports.stripMetroInfo = stripMetroInfo;
|
|
8
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _link = require("../../../utils/link");
|
|
11
|
+
var _terminalReporter = require("./TerminalReporter");
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const MAX_PROGRESS_BAR_CHAR_WIDTH = 16;
|
|
18
|
+
const DARK_BLOCK_CHAR = "\u2593";
|
|
19
|
+
const LIGHT_BLOCK_CHAR = "\u2591";
|
|
20
|
+
class MetroTerminalReporter extends _terminalReporter.TerminalReporter {
|
|
21
|
+
constructor(projectRoot, terminal){
|
|
22
|
+
super(terminal);
|
|
23
|
+
this.projectRoot = projectRoot;
|
|
24
|
+
}
|
|
25
|
+
// Used for testing
|
|
26
|
+
_getElapsedTime(startTime) {
|
|
27
|
+
return Date.now() - startTime;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Extends the bundle progress to include the current platform that we're bundling.
|
|
31
|
+
*
|
|
32
|
+
* @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`
|
|
33
|
+
*/ _getBundleStatusMessage(progress, phase) {
|
|
34
|
+
const platform = getPlatformTagForBuildDetails(progress.bundleDetails);
|
|
35
|
+
const inProgress = phase === "in_progress";
|
|
36
|
+
if (!inProgress) {
|
|
37
|
+
const status = phase === "done" ? `Bundling complete ` : `Bundling failed `;
|
|
38
|
+
const color = phase === "done" ? _chalk.default.green : _chalk.default.red;
|
|
39
|
+
const startTime = this._bundleTimers.get(progress.bundleDetails.buildID);
|
|
40
|
+
const time = startTime != null ? _chalk.default.dim(this._getElapsedTime(startTime) + "ms") : "";
|
|
41
|
+
// iOS Bundling complete 150ms
|
|
42
|
+
return color(platform + status) + time;
|
|
43
|
+
}
|
|
44
|
+
const localPath = _path.default.relative(".", progress.bundleDetails.entryFile);
|
|
45
|
+
const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);
|
|
46
|
+
const _progress = inProgress ? _chalk.default.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) + _chalk.default.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) + _chalk.default.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) + _chalk.default.dim(`(${progress.transformedFileCount.toString().padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`) : "";
|
|
47
|
+
return platform + _chalk.default.reset.dim(`${_path.default.dirname(localPath)}/`) + _chalk.default.bold(_path.default.basename(localPath)) + " " + _progress;
|
|
48
|
+
}
|
|
49
|
+
_logInitializing(port, hasReducedPerformance) {
|
|
50
|
+
// Don't print a giant logo...
|
|
51
|
+
this.terminal.log("Starting Metro Bundler");
|
|
52
|
+
}
|
|
53
|
+
shouldFilterClientLog(event) {
|
|
54
|
+
return isAppRegistryStartupMessage(event.data);
|
|
55
|
+
}
|
|
56
|
+
/** Print the cache clear message. */ transformCacheReset() {
|
|
57
|
+
(0, _terminalReporter).logWarning(this.terminal, _chalk.default`Bundler cache is empty, rebuilding {dim (this may take a minute)}`);
|
|
58
|
+
}
|
|
59
|
+
/** One of the first logs that will be printed */ dependencyGraphLoading(hasReducedPerformance) {
|
|
60
|
+
// this.terminal.log('Dependency graph is loading...');
|
|
61
|
+
if (hasReducedPerformance) {
|
|
62
|
+
// Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290
|
|
63
|
+
this.terminal.log(_chalk.default.red([
|
|
64
|
+
"Metro is operating with reduced performance.",
|
|
65
|
+
"Please fix the problem above and restart Metro.",
|
|
66
|
+
].join("\n")));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_logBundlingError(error) {
|
|
70
|
+
const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);
|
|
71
|
+
if (moduleResolutionError) {
|
|
72
|
+
return this.terminal.log(maybeAppendCodeFrame(moduleResolutionError, error.message));
|
|
73
|
+
}
|
|
74
|
+
return super._logBundlingError(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.MetroTerminalReporter = MetroTerminalReporter;
|
|
78
|
+
function formatUsingNodeStandardLibraryError(projectRoot, error) {
|
|
79
|
+
if (!error.message) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const { targetModuleName , originModulePath } = error;
|
|
83
|
+
if (!targetModuleName || !originModulePath) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const relativePath = _path.default.relative(projectRoot, originModulePath);
|
|
87
|
+
const DOCS_PAGE_URL = "https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries";
|
|
88
|
+
if (isNodeStdLibraryModule(targetModuleName)) {
|
|
89
|
+
if (originModulePath.includes("node_modules")) {
|
|
90
|
+
return [
|
|
91
|
+
`The package at "${_chalk.default.bold(relativePath)}" attempted to import the Node standard library module "${_chalk.default.bold(targetModuleName)}".`,
|
|
92
|
+
`It failed because the native React runtime does not include the Node standard library.`,
|
|
93
|
+
(0, _link).learnMore(DOCS_PAGE_URL),
|
|
94
|
+
].join("\n");
|
|
95
|
+
} else {
|
|
96
|
+
return [
|
|
97
|
+
`You attempted attempted to import the Node standard library module "${_chalk.default.bold(targetModuleName)}" from "${_chalk.default.bold(relativePath)}".`,
|
|
98
|
+
`It failed because the native React runtime does not include the Node standard library.`,
|
|
99
|
+
(0, _link).learnMore(DOCS_PAGE_URL),
|
|
100
|
+
].join("\n");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return `Unable to resolve "${targetModuleName}" from "${relativePath}"`;
|
|
104
|
+
}
|
|
105
|
+
function isNodeStdLibraryModule(moduleName) {
|
|
106
|
+
return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);
|
|
107
|
+
}
|
|
108
|
+
/** If the code frame can be found then append it to the existing message. */ function maybeAppendCodeFrame(message, rawMessage) {
|
|
109
|
+
const codeFrame = stripMetroInfo(rawMessage);
|
|
110
|
+
if (codeFrame) {
|
|
111
|
+
message += "\n" + codeFrame;
|
|
112
|
+
}
|
|
113
|
+
return message;
|
|
114
|
+
}
|
|
115
|
+
function stripMetroInfo(errorMessage) {
|
|
116
|
+
// Newer versions of Metro don't include the list.
|
|
117
|
+
if (!errorMessage.includes("4. Remove the cache")) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const lines = errorMessage.split("\n");
|
|
121
|
+
const index = lines.findIndex((line)=>line.includes("4. Remove the cache")
|
|
122
|
+
);
|
|
123
|
+
if (index === -1) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return lines.slice(index + 1).join("\n");
|
|
127
|
+
}
|
|
128
|
+
/** @returns if the message matches the initial startup log */ function isAppRegistryStartupMessage(body) {
|
|
129
|
+
return body.length === 1 && (/^Running application "main" with appParams:/.test(body[0]) || /^Running "main" with \{/.test(body[0]));
|
|
130
|
+
}
|
|
131
|
+
/** @returns platform specific tag for a `BundleDetails` object */ function getPlatformTagForBuildDetails(bundleDetails) {
|
|
132
|
+
var ref;
|
|
133
|
+
const platform = (ref = bundleDetails == null ? void 0 : bundleDetails.platform) != null ? ref : null;
|
|
134
|
+
if (platform) {
|
|
135
|
+
const formatted = {
|
|
136
|
+
ios: "iOS",
|
|
137
|
+
android: "Android",
|
|
138
|
+
web: "Web"
|
|
139
|
+
}[platform] || platform;
|
|
140
|
+
return `${_chalk.default.bold(formatted)} `;
|
|
141
|
+
}
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
// A list of the Node.js standard library modules.
|
|
145
|
+
const NODE_STDLIB_MODULES = [
|
|
146
|
+
"assert",
|
|
147
|
+
"async_hooks",
|
|
148
|
+
"buffer",
|
|
149
|
+
"child_process",
|
|
150
|
+
"cluster",
|
|
151
|
+
"crypto",
|
|
152
|
+
"dgram",
|
|
153
|
+
"dns",
|
|
154
|
+
"domain",
|
|
155
|
+
"events",
|
|
156
|
+
"fs",
|
|
157
|
+
"fs/promises",
|
|
158
|
+
"http",
|
|
159
|
+
"https",
|
|
160
|
+
"net",
|
|
161
|
+
"os",
|
|
162
|
+
"path",
|
|
163
|
+
"punycode",
|
|
164
|
+
"querystring",
|
|
165
|
+
"readline",
|
|
166
|
+
"repl",
|
|
167
|
+
"stream",
|
|
168
|
+
"string_decoder",
|
|
169
|
+
"tls",
|
|
170
|
+
"tty",
|
|
171
|
+
"url",
|
|
172
|
+
"util",
|
|
173
|
+
"v8",
|
|
174
|
+
"vm",
|
|
175
|
+
"zlib",
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=MetroTerminalReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/MetroTerminalReporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { learnMore } from '../../../utils/link';\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport { BuildPhase, BundleDetails, BundleProgress, SnippetError } from './TerminalReporter.types';\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(public projectRoot: string, terminal: Terminal) {\n super(terminal);\n }\n\n // Used for testing\n _getElapsedTime(startTime: number): number {\n return Date.now() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const platform = getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundling complete ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n const time = startTime != null ? chalk.dim(this._getElapsedTime(startTime) + 'ms') : '';\n // iOS Bundling complete 150ms\n return color(platform + status) + time;\n }\n\n const localPath = path.relative('.', progress.bundleDetails.entryFile);\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}/`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log('Starting Metro Bundler');\n }\n\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Please fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n if (moduleResolutionError) {\n return this.terminal.log(maybeAppendCodeFrame(moduleResolutionError, error.message));\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n\n// A list of the Node.js standard library modules.\nconst NODE_STDLIB_MODULES = [\n 'assert',\n 'async_hooks',\n 'buffer',\n 'child_process',\n 'cluster',\n 'crypto',\n 'dgram',\n 'dns',\n 'domain',\n 'events',\n 'fs',\n 'fs/promises',\n 'http',\n 'https',\n 'net',\n 'os',\n 'path',\n 'punycode',\n 'querystring',\n 'readline',\n 'repl',\n 'stream',\n 'string_decoder',\n 'tls',\n 'tty',\n 'url',\n 'util',\n 'v8',\n 'vm',\n 'zlib',\n];\n"],"names":["formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","MetroTerminalReporter","TerminalReporter","constructor","projectRoot","terminal","_getElapsedTime","startTime","Date","now","_getBundleStatusMessage","progress","phase","platform","getPlatformTagForBuildDetails","bundleDetails","inProgress","status","color","chalk","green","red","_bundleTimers","get","buildID","time","dim","localPath","path","relative","entryFile","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","bold","toFixed","padStart","transformedFileCount","toString","totalFileCount","length","reset","dirname","basename","_logInitializing","port","hasReducedPerformance","log","shouldFilterClientLog","event","isAppRegistryStartupMessage","data","transformCacheReset","logWarning","dependencyGraphLoading","join","_logBundlingError","error","moduleResolutionError","maybeAppendCodeFrame","message","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","includes","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted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,CAClE,SAASvE,6BAA6B,CAACC,aAAoC,EAAU;QAClEA,GAAuB;IAAxC,MAAMF,QAAQ,GAAGE,CAAAA,GAAuB,GAAvBA,aAAa,QAAU,GAAvBA,KAAAA,CAAuB,GAAvBA,aAAa,CAAEF,QAAQ,YAAvBE,GAAuB,GAAI,IAAI,AAAC;IACjD,IAAIF,QAAQ,EAAE;QACZ,MAAMyE,SAAS,GAAG;YAAEC,GAAG,EAAE,KAAK;YAAEC,OAAO,EAAE,SAAS;YAAEC,GAAG,EAAE,KAAK;SAAE,CAAC5E,QAAQ,CAAC,IAAIA,QAAQ,AAAC;QACvF,OAAO,CAAC,EAAEM,MAAK,QAAA,CAACqB,IAAI,CAAC8C,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KACpC;IAED,OAAO,EAAE,CAAC;CACX;AAED,kDAAkD;AAClD,MAAMX,mBAAmB,GAAG;IAC1B,QAAQ;IACR,aAAa;IACb,QAAQ;IACR,eAAe;IACf,SAAS;IACT,QAAQ;IACR,OAAO;IACP,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,IAAI;IACJ,aAAa;IACb,MAAM;IACN,OAAO;IACP,KAAK;IACL,IAAI;IACJ,MAAM;IACN,UAAU;IACV,aAAa;IACb,UAAU;IACV,MAAM;IACN,QAAQ;IACR,gBAAgB;IAChB,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,MAAM;CACP,AAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.logWarning = logWarning;
|
|
6
|
+
exports.logError = logError;
|
|
7
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
+
var _terminalReporter = _interopRequireDefault(require("metro/src/lib/TerminalReporter"));
|
|
9
|
+
var _util = _interopRequireDefault(require("util"));
|
|
10
|
+
var _ansi = require("../../../utils/ansi");
|
|
11
|
+
function _interopRequireDefault(obj) {
|
|
12
|
+
return obj && obj.__esModule ? obj : {
|
|
13
|
+
default: obj
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function logWarning(terminal, format, ...args) {
|
|
17
|
+
const str = _util.default.format(format, ...args);
|
|
18
|
+
terminal.log("%s: %s", _chalk.default.yellow("warning"), str);
|
|
19
|
+
}
|
|
20
|
+
function logError(terminal, format, ...args) {
|
|
21
|
+
terminal.log("%s: %s", _chalk.default.red("error"), // Syntax errors may have colors applied for displaying code frames
|
|
22
|
+
// in various places outside of where Metro is currently running.
|
|
23
|
+
// If the current terminal does not support color, we'll strip the colors
|
|
24
|
+
// here.
|
|
25
|
+
_util.default.format(_chalk.default.supportsColor ? format : (0, _ansi).stripAnsi(format), ...args));
|
|
26
|
+
}
|
|
27
|
+
const XTerminalReporter = _terminalReporter.default;
|
|
28
|
+
class TerminalReporter extends XTerminalReporter {
|
|
29
|
+
/**
|
|
30
|
+
* A cache of { [buildID]: BundleDetails } which can be used to
|
|
31
|
+
* add more contextual logs. BundleDetails is currently only sent with `bundle_build_started`
|
|
32
|
+
* so we need to cache the details in order to print the platform info with other event types.
|
|
33
|
+
*/ _bundleDetails = new Map();
|
|
34
|
+
/** Keep track of how long a bundle takes to complete */ _bundleTimers = new Map();
|
|
35
|
+
_log(event) {
|
|
36
|
+
switch(event.type){
|
|
37
|
+
case "transform_cache_reset":
|
|
38
|
+
return this.transformCacheReset();
|
|
39
|
+
case "dep_graph_loading":
|
|
40
|
+
return this.dependencyGraphLoading(event.hasReducedPerformance);
|
|
41
|
+
case "client_log":
|
|
42
|
+
if (this.shouldFilterClientLog(event)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
return super._log(event);
|
|
48
|
+
}
|
|
49
|
+
/** Gives subclasses an easy interface for filtering out logs. Return `true` to skip. */ shouldFilterClientLog(event) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
/** Cache has been reset. */ transformCacheReset() {}
|
|
53
|
+
/** One of the first logs that will be printed. */ dependencyGraphLoading(hasReducedPerformance) {}
|
|
54
|
+
/**
|
|
55
|
+
* Custom log event representing the end of the bundling.
|
|
56
|
+
*
|
|
57
|
+
* @param event event object.
|
|
58
|
+
* @param duration duration of the build in milliseconds.
|
|
59
|
+
*/ bundleBuildEnded(event, duration) {}
|
|
60
|
+
/**
|
|
61
|
+
* This function is exclusively concerned with updating the internal state.
|
|
62
|
+
* No logging or status updates should be done at this point.
|
|
63
|
+
*/ _updateState(event) {
|
|
64
|
+
// Append the buildID to the bundleDetails.
|
|
65
|
+
if (event.bundleDetails) {
|
|
66
|
+
event.bundleDetails.buildID = event.buildID;
|
|
67
|
+
}
|
|
68
|
+
super._updateState(event);
|
|
69
|
+
switch(event.type){
|
|
70
|
+
case "bundle_build_done":
|
|
71
|
+
case "bundle_build_failed":
|
|
72
|
+
{
|
|
73
|
+
const startTime = this._bundleTimers.get(event.buildID);
|
|
74
|
+
this.bundleBuildEnded(event, startTime ? Date.now() - startTime : 0);
|
|
75
|
+
this._bundleTimers.delete(event.buildID);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case "bundle_build_started":
|
|
79
|
+
this._bundleDetails.set(event.buildID, event.bundleDetails);
|
|
80
|
+
this._bundleTimers.set(event.buildID, Date.now());
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.TerminalReporter = TerminalReporter;
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=TerminalReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/TerminalReporter.ts"],"sourcesContent":["// This file represents an abstraction on the metro TerminalReporter.\n// We use this abstraction to safely extend the TerminalReporter for our own custom logging.\nimport chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport UpstreamTerminalReporter from 'metro/src/lib/TerminalReporter';\nimport util from 'util';\n\nimport { stripAnsi } from '../../../utils/ansi';\nimport {\n BundleDetails,\n TerminalReportableEvent,\n TerminalReporterInterface,\n} from './TerminalReporter.types';\n\n/**\n * A standard way to log a warning to the terminal. This should not be called\n * from some arbitrary Metro logic, only from the reporters. Instead of\n * calling this, add a new type of ReportableEvent instead, and implement a\n * proper handler in the reporter(s).\n */\nexport function logWarning(terminal: Terminal, format: string, ...args: any[]): void {\n const str = util.format(format, ...args);\n terminal.log('%s: %s', chalk.yellow('warning'), str);\n}\n\n/**\n * Similar to `logWarning`, but for messages that require the user to act.\n */\nexport function logError(terminal: Terminal, format: string, ...args: any[]): void {\n terminal.log(\n '%s: %s',\n chalk.red('error'),\n // Syntax errors may have colors applied for displaying code frames\n // in various places outside of where Metro is currently running.\n // If the current terminal does not support color, we'll strip the colors\n // here.\n util.format(chalk.supportsColor ? format : stripAnsi(format), ...args)\n );\n}\n\nconst XTerminalReporter = UpstreamTerminalReporter as unknown as TerminalReporterInterface;\n\n/** Extended TerminalReporter class but with proper types and extra functionality to avoid using the `_log` method directly in subclasses. */\nexport class TerminalReporter extends XTerminalReporter implements TerminalReporterInterface {\n /**\n * A cache of { [buildID]: BundleDetails } which can be used to\n * add more contextual logs. BundleDetails is currently only sent with `bundle_build_started`\n * so we need to cache the details in order to print the platform info with other event types.\n */\n _bundleDetails: Map<string, BundleDetails> = new Map();\n\n /** Keep track of how long a bundle takes to complete */\n _bundleTimers: Map<string, number> = new Map();\n\n _log(event: TerminalReportableEvent): void {\n switch (event.type) {\n case 'transform_cache_reset':\n return this.transformCacheReset();\n case 'dep_graph_loading':\n return this.dependencyGraphLoading(event.hasReducedPerformance);\n case 'client_log':\n if (this.shouldFilterClientLog(event)) {\n return;\n }\n break;\n }\n return super._log(event);\n }\n\n /** Gives subclasses an easy interface for filtering out logs. Return `true` to skip. */\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return false;\n }\n\n /** Cache has been reset. */\n transformCacheReset(): void {}\n\n /** One of the first logs that will be printed. */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {}\n\n /**\n * Custom log event representing the end of the bundling.\n *\n * @param event event object.\n * @param duration duration of the build in milliseconds.\n */\n bundleBuildEnded(event: TerminalReportableEvent, duration: number): void {}\n\n /**\n * This function is exclusively concerned with updating the internal state.\n * No logging or status updates should be done at this point.\n */\n _updateState(\n event: TerminalReportableEvent & { bundleDetails?: BundleDetails; buildID?: string }\n ) {\n // Append the buildID to the bundleDetails.\n if (event.bundleDetails) {\n event.bundleDetails.buildID = event.buildID;\n }\n\n super._updateState(event);\n switch (event.type) {\n case 'bundle_build_done':\n case 'bundle_build_failed': {\n const startTime = this._bundleTimers.get(event.buildID);\n this.bundleBuildEnded(event, startTime ? Date.now() - startTime : 0);\n this._bundleTimers.delete(event.buildID);\n break;\n }\n case 'bundle_build_started':\n this._bundleDetails.set(event.buildID, event.bundleDetails);\n this._bundleTimers.set(event.buildID, Date.now());\n break;\n }\n }\n}\n"],"names":["logWarning","logError","terminal","format","args","str","util","log","chalk","yellow","red","supportsColor","stripAnsi","XTerminalReporter","UpstreamTerminalReporter","TerminalReporter","_bundleDetails","Map","_bundleTimers","_log","event","type","transformCacheReset","dependencyGraphLoading","hasReducedPerformance","shouldFilterClientLog","bundleBuildEnded","duration","_updateState","bundleDetails","buildID","startTime","get","Date","now","delete","set"],"mappings":"AAEA;;;;QAkBgBA,UAAU,GAAVA,UAAU;QAQVC,QAAQ,GAARA,QAAQ;AA1BN,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEY,IAAA,iBAAgC,kCAAhC,gCAAgC,EAAA;AACpD,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEG,IAAA,KAAqB,WAArB,qBAAqB,CAAA;;;;;;AAaxC,SAASD,UAAU,CAACE,QAAkB,EAAEC,MAAc,EAAE,GAAGC,IAAI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minalReporter.types.ts"],"sourcesContent":["import type { ReportableEvent } from 'metro';\nimport type { Terminal } from 'metro-core';\nimport type { TerminalReportableEvent } from 'metro/src/lib/TerminalReporter';\n\nexport type GlobalCacheDisabledReason = 'too_many_errors' | 'too_many_misses';\n\nexport type BundleDetails = {\n buildID?: string;\n bundleType: string;\n dev: boolean;\n entryFile: string;\n minify: boolean;\n platform: string | null | undefined;\n runtimeBytecodeVersion: number | null | undefined;\n};\n\nexport type BundleProgress = {\n bundleDetails: BundleDetails;\n transformedFileCount: number;\n totalFileCount: number;\n ratio: number;\n};\n\nexport { TerminalReportableEvent };\n\nexport type BuildPhase = 'in_progress' | 'done' | 'failed';\n\n/**\n * Code across the application takes a reporter as an option and calls the\n * update whenever one of the ReportableEvent happens. Code does not directly\n * write to the standard output, because a build would be:\n *\n * 1. ad-hoc, embedded into another tool, in which case we do not want to\n * pollute that tool's own output. The tool is free to present the\n * warnings/progress we generate any way they want, by specifying a custom\n * reporter.\n * 2. run as a background process from another tool, in which case we want\n * to expose updates in a way that is easily machine-readable, for example\n * a JSON-stream. We don't want to pollute it with textual messages.\n *\n * We centralize terminal reporting into a single place because we want the\n * output to be robust and consistent. The most common reporter is\n * TerminalReporter, that should be the only place in the application should\n * access the `terminal` module (nor the `console`).\n */\nexport type Reporter = { update(event: ReportableEvent): void };\n\nexport interface SnippetError extends Error {\n code?: string;\n filename?: string;\n snippet?: string;\n\n /** Module that failed to load ex 'fs' */\n targetModuleName?: string;\n originModulePath?: string;\n\n errors?: any[];\n}\n\nexport interface TerminalReporterInterface {\n new (terminal: Terminal): TerminalReporterInterface;\n\n /**\n * The bundle builds for which we are actively maintaining the status on the\n * terminal, ie. showing a progress bar. There can be several bundles being\n * built at the same time.\n */\n _activeBundles: Map<string, BundleProgress>;\n\n _scheduleUpdateBundleProgress: {\n (data: { buildID: string; transformedFileCount: number; totalFileCount: number }): void;\n cancel(): void;\n };\n\n /** Set in super type */\n terminal: Terminal;\n\n /**\n * Construct a message that represents the progress of a\n * single bundle build, for example:\n *\n * BUNDLE path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)\n */\n _getBundleStatusMessage(\n {\n bundleDetails: { entryFile, bundleType, runtimeBytecodeVersion },\n transformedFileCount,\n totalFileCount,\n ratio,\n }: BundleProgress,\n phase: BuildPhase\n ): string;\n\n /**\n * This function is only concerned with logging and should not do state\n * or terminal status updates.\n */\n _log(event: TerminalReportableEvent): void;\n\n _logCacheDisabled(reason: GlobalCacheDisabledReason): void;\n\n _logBundleBuildDone(buildID: string): void;\n\n _logBundleBuildFailed(buildID: string): void;\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void;\n\n _logInitializingFailed(port: number, error: SnippetError): void;\n\n /**\n * We do not want to log the whole stacktrace for bundling error, because\n * these are operational errors, not programming errors, and the stacktrace\n * is not actionable to end users.\n */\n _logBundlingError(error: SnippetError): void;\n\n /**\n * We use Math.pow(ratio, 2) to as a conservative measure of progress because\n * we know the `totalCount` is going to progressively increase as well. We\n * also prevent the ratio from going backwards.\n */\n _updateBundleProgress({\n buildID,\n transformedFileCount,\n totalFileCount,\n }: {\n buildID: string;\n transformedFileCount: number;\n totalFileCount: number;\n }): void;\n\n /**\n * This function is exclusively concerned with updating the internal state.\n * No logging or status updates should be done at this point.\n */\n _updateState(event: TerminalReportableEvent): void;\n /**\n * Return a status message that is always consistent with the current state\n * of the application. Having this single function ensures we don't have\n * different call sites overriding each other status messages.\n */\n _getStatusMessage(): string;\n\n _logHmrClientError(e: Error): void;\n\n /**\n * Single entry point for reporting events. That allows us to implement the\n * corresponding JSON reporter easily and have a consistent reporting.\n */\n update(event: TerminalReportableEvent): void;\n}\n"],"names":[],"mappings":"AAAA"}
|