@expo/cli 0.17.9 → 0.18.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 +11 -7
- package/build/bin/cli.map +1 -1
- package/build/src/api/getExpoSchema.js +23 -5
- package/build/src/api/getExpoSchema.js.map +1 -1
- package/build/src/api/graphql/client.js +28 -10
- package/build/src/api/graphql/client.js.map +1 -1
- package/build/src/api/graphql/queries/AppQuery.js +16 -4
- package/build/src/api/graphql/queries/AppQuery.js.map +1 -1
- package/build/src/api/graphql/queries/UserQuery.js +8 -2
- package/build/src/api/graphql/queries/UserQuery.js.map +1 -1
- package/build/src/api/graphql/types/App.js +8 -2
- package/build/src/api/graphql/types/App.js.map +1 -1
- package/build/src/api/rest/cache/FileSystemCache.js +21 -9
- package/build/src/api/rest/cache/FileSystemCache.js.map +1 -1
- package/build/src/api/rest/cache/response.js +9 -3
- package/build/src/api/rest/cache/response.js.map +1 -1
- package/build/src/api/rest/cache/wrapFetchWithCache.js +32 -8
- package/build/src/api/rest/cache/wrapFetchWithCache.js.map +1 -1
- package/build/src/api/rest/client.js +23 -5
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithBaseUrl.js +9 -4
- package/build/src/api/rest/wrapFetchWithBaseUrl.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithProxy.js +8 -2
- package/build/src/api/rest/wrapFetchWithProxy.js.map +1 -1
- package/build/src/api/settings.js +8 -2
- package/build/src/api/settings.js.map +1 -1
- package/build/src/api/updateDevelopmentSession.js +18 -6
- package/build/src/api/updateDevelopmentSession.js.map +1 -1
- package/build/src/api/user/UserSettings.js +26 -8
- package/build/src/api/user/UserSettings.js.map +1 -1
- package/build/src/api/user/actions.js +17 -5
- package/build/src/api/user/actions.js.map +1 -1
- package/build/src/api/user/expoSsoLauncher.js +32 -8
- package/build/src/api/user/expoSsoLauncher.js.map +1 -1
- package/build/src/api/user/otp.js +17 -5
- package/build/src/api/user/otp.js.map +1 -1
- package/build/src/api/user/user.js +19 -12
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/config/configAsync.js +25 -7
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/config/index.js +9 -3
- package/build/src/config/index.js.map +1 -1
- package/build/src/customize/customizeAsync.js +8 -2
- package/build/src/customize/customizeAsync.js.map +1 -1
- package/build/src/customize/generate.js +16 -4
- package/build/src/customize/generate.js.map +1 -1
- package/build/src/customize/index.js +10 -4
- package/build/src/customize/index.js.map +1 -1
- package/build/src/customize/templates.js +33 -9
- package/build/src/customize/templates.js.map +1 -1
- package/build/src/customize/typescript.js +8 -2
- package/build/src/customize/typescript.js.map +1 -1
- package/build/src/export/createMetadataJson.js +8 -2
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +58 -18
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/index.js +17 -5
- package/build/src/export/embed/index.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +8 -2
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/embed/xcodeCompilerLogger.js +16 -4
- package/build/src/export/embed/xcodeCompilerLogger.js.map +1 -1
- package/build/src/export/exportApp.js +32 -12
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +27 -9
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportAsync.js +10 -2
- package/build/src/export/exportAsync.js.map +1 -1
- package/build/src/export/exportHermes.js +29 -17
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +69 -37
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/favicon.js +33 -9
- package/build/src/export/favicon.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +61 -16
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/getPublicExpoManifest.js +8 -2
- package/build/src/export/getPublicExpoManifest.js.map +1 -1
- package/build/src/export/getResolvedLocales.js +15 -3
- package/build/src/export/getResolvedLocales.js.map +1 -1
- package/build/src/export/index.js +11 -5
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/metroAssetLocalPath.js +9 -3
- package/build/src/export/metroAssetLocalPath.js.map +1 -1
- package/build/src/export/persistMetroAssets.js +27 -15
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/export/publicFolder.js +18 -6
- package/build/src/export/publicFolder.js.map +1 -1
- package/build/src/export/resolveOptions.js +8 -2
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +43 -19
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +16 -4
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/export/web/index.js +9 -3
- package/build/src/export/web/index.js.map +1 -1
- package/build/src/install/applyPlugins.js +8 -2
- package/build/src/install/applyPlugins.js.map +1 -1
- package/build/src/install/checkPackages.js +18 -6
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/fixPackages.js +8 -2
- package/build/src/install/fixPackages.js.map +1 -1
- package/build/src/install/index.js +14 -8
- package/build/src/install/index.js.map +1 -1
- package/build/src/install/installAsync.js +27 -9
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/installExpoPackage.js +17 -5
- package/build/src/install/installExpoPackage.js.map +1 -1
- package/build/src/install/utils/autoAddConfigPlugins.js +17 -5
- package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -1
- package/build/src/log.js +9 -3
- package/build/src/log.js.map +1 -1
- package/build/src/prebuild/clearNativeFolder.js +37 -13
- package/build/src/prebuild/clearNativeFolder.js.map +1 -1
- package/build/src/prebuild/configureProjectAsync.js +16 -4
- package/build/src/prebuild/configureProjectAsync.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +29 -11
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/ensureConfigAsync.js +24 -6
- package/build/src/prebuild/ensureConfigAsync.js.map +1 -1
- package/build/src/prebuild/index.js +14 -8
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +9 -3
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/renameTemplateAppName.js +119 -0
- package/build/src/prebuild/renameTemplateAppName.js.map +1 -0
- package/build/src/prebuild/resolveOptions.js +32 -8
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +44 -14
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +18 -2
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +49 -13
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/prebuild/validateTemplatePlatforms.js +16 -4
- package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -1
- package/build/src/run/android/index.js +20 -4
- package/build/src/run/android/index.js.map +1 -1
- package/build/src/run/android/resolveGradlePropsAsync.js +55 -0
- package/build/src/run/android/resolveGradlePropsAsync.js.map +1 -0
- package/build/src/run/android/resolveInstallApkName.js +18 -6
- package/build/src/run/android/resolveInstallApkName.js.map +1 -1
- package/build/src/run/android/resolveLaunchProps.js +10 -4
- package/build/src/run/android/resolveLaunchProps.js.map +1 -1
- package/build/src/run/android/resolveOptions.js +5 -3
- package/build/src/run/android/resolveOptions.js.map +1 -1
- package/build/src/run/android/runAndroidAsync.js +13 -4
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +15 -3
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/hints.js +10 -4
- package/build/src/run/hints.js.map +1 -1
- package/build/src/run/index.js +8 -2
- package/build/src/run/index.js.map +1 -1
- package/build/src/run/ios/XcodeBuild.js +57 -21
- package/build/src/run/ios/XcodeBuild.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +25 -7
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/appleDevice/ClientManager.js +10 -4
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/AFCClient.js +34 -10
- package/build/src/run/ios/appleDevice/client/AFCClient.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js +16 -4
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js +8 -2
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js +17 -5
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js +17 -5
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +25 -7
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -1
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +24 -6
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js +8 -2
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js.map +1 -1
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js +16 -4
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -1
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js +8 -2
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js.map +1 -1
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js +16 -4
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js.map +1 -1
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js +16 -4
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js.map +1 -1
- package/build/src/run/ios/codeSigning/Security.js +17 -5
- package/build/src/run/ios/codeSigning/Security.js.map +1 -1
- package/build/src/run/ios/codeSigning/configureCodeSigning.js +8 -2
- package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -1
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +9 -3
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -1
- package/build/src/run/ios/codeSigning/simulatorCodeSigning.js +25 -7
- package/build/src/run/ios/codeSigning/simulatorCodeSigning.js.map +1 -1
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js +22 -10
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js.map +1 -1
- package/build/src/run/ios/index.js +19 -7
- package/build/src/run/ios/index.js.map +1 -1
- package/build/src/run/ios/launchApp.js +17 -5
- package/build/src/run/ios/launchApp.js.map +1 -1
- package/build/src/run/ios/options/promptDevice.js +9 -3
- package/build/src/run/ios/options/promptDevice.js.map +1 -1
- package/build/src/run/ios/options/resolveDevice.js +1 -2
- package/build/src/run/ios/options/resolveDevice.js.map +1 -1
- package/build/src/run/ios/options/resolveNativeScheme.js +27 -9
- package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
- package/build/src/run/ios/options/resolveXcodeProject.js +8 -2
- package/build/src/run/ios/options/resolveXcodeProject.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +10 -2
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/run/startBundler.js +16 -4
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/detectDevClient.js +29 -0
- package/build/src/start/detectDevClient.js.map +1 -0
- package/build/src/start/doctor/SecurityBinPrerequisite.js +8 -2
- package/build/src/start/doctor/SecurityBinPrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +16 -4
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js +16 -4
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/XcodePrerequisite.js +79 -29
- package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/XcrunPrerequisite.js +24 -6
- package/build/src/start/doctor/apple/XcrunPrerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +25 -7
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +27 -9
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/getMissingPackages.js +24 -6
- package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +8 -2
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/resolvePackages.js +25 -7
- package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +32 -21
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +33 -9
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +18 -6
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/typescript/updateTSConfig.js +29 -11
- package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +18 -6
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/index.js +17 -11
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/interface/commandsTable.js +27 -9
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +17 -11
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/interface/startInterface.js +8 -2
- package/build/src/start/interface/startInterface.js.map +1 -1
- package/build/src/start/platforms/AppIdResolver.js +9 -3
- package/build/src/start/platforms/AppIdResolver.js.map +1 -1
- package/build/src/start/platforms/DeviceManager.js +8 -2
- package/build/src/start/platforms/DeviceManager.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +30 -14
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +33 -13
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/ADBServer.js +17 -5
- package/build/src/start/platforms/android/ADBServer.js.map +1 -1
- package/build/src/start/platforms/android/AndroidAppIdResolver.js +13 -7
- package/build/src/start/platforms/android/AndroidAppIdResolver.js.map +1 -1
- package/build/src/start/platforms/android/AndroidDeviceManager.js +19 -7
- package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
- package/build/src/start/platforms/android/AndroidSdk.js +34 -10
- package/build/src/start/platforms/android/AndroidSdk.js.map +1 -1
- package/build/src/start/platforms/android/activateWindow.js +16 -4
- package/build/src/start/platforms/android/activateWindow.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +21 -4
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/android/emulator.js +32 -8
- package/build/src/start/platforms/android/emulator.js.map +1 -1
- package/build/src/start/platforms/android/gradle.js +23 -6
- package/build/src/start/platforms/android/gradle.js.map +1 -1
- package/build/src/start/platforms/android/promptAndroidDevice.js +10 -4
- package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -1
- package/build/src/start/platforms/ios/AppleAppIdResolver.js +26 -8
- package/build/src/start/platforms/ios/AppleAppIdResolver.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +50 -18
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/assertSystemRequirements.js +4 -3
- package/build/src/start/platforms/ios/assertSystemRequirements.js.map +1 -1
- package/build/src/start/platforms/ios/ensureSimulatorAppRunning.js +16 -4
- package/build/src/start/platforms/ios/ensureSimulatorAppRunning.js.map +1 -1
- package/build/src/start/platforms/ios/getBestSimulator.js +8 -2
- package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
- package/build/src/start/platforms/ios/promptAppleDevice.js +9 -3
- package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +12 -6
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/platforms/ios/simctlLogging.js +40 -10
- package/build/src/start/platforms/ios/simctlLogging.js.map +1 -1
- package/build/src/start/platforms/ios/xcrun.js +16 -4
- package/build/src/start/platforms/ios/xcrun.js.map +1 -1
- package/build/src/start/project/dotExpo.js +27 -9
- package/build/src/start/project/dotExpo.js.map +1 -1
- package/build/src/start/resolveOptions.js +33 -15
- package/build/src/start/resolveOptions.js.map +1 -1
- package/build/src/start/server/AsyncNgrok.js +34 -10
- package/build/src/start/server/AsyncNgrok.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +16 -4
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +28 -10
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +16 -4
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +9 -3
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/ReactDevToolsProxy.js +26 -8
- package/build/src/start/server/ReactDevToolsProxy.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +19 -6
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +91 -55
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +231 -83
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +30 -15
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +26 -8
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.types.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js +56 -20
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
- package/build/src/start/server/metro/createJResolver.js +90 -45
- package/build/src/start/server/metro/createJResolver.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +29 -28
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/debugging/MessageHandler.js +27 -0
- package/build/src/start/server/metro/debugging/MessageHandler.js.map +1 -0
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js +11 -8
- package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
- package/build/src/start/server/metro/debugging/createHandlersFactory.js +63 -0
- package/build/src/start/server/metro/debugging/createHandlersFactory.js.map +1 -0
- package/build/src/start/server/metro/debugging/{inspectorHandlers/utils.js → getDebuggerType.js} +1 -6
- package/build/src/start/server/metro/debugging/getDebuggerType.js.map +1 -0
- package/build/src/start/server/metro/debugging/{inspectorHandlers → messageHandlers}/NetworkResponse.js +8 -5
- package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js.map +1 -0
- package/build/src/start/server/metro/debugging/{inspectorHandlers → messageHandlers}/PageReload.js +7 -6
- package/build/src/start/server/metro/debugging/messageHandlers/PageReload.js.map +1 -0
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeDebuggerGetPossibleBreakpoints.js +25 -0
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -0
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeDebuggerSetBreakpointByUrl.js +22 -0
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeDebuggerSetBreakpointByUrl.js.map +1 -0
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeRuntimeCallFunctionOn.js +28 -0
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
- package/build/src/start/server/metro/debugging/{inspectorHandlers → messageHandlers}/VscodeRuntimeGetProperties.js +10 -6
- package/build/src/start/server/metro/debugging/messageHandlers/VscodeRuntimeGetProperties.js.map +1 -0
- package/build/src/start/server/metro/debugging/pageIsSupported.js +14 -0
- package/build/src/start/server/metro/debugging/pageIsSupported.js.map +1 -0
- package/build/src/start/server/metro/debugging/types.js.map +1 -0
- package/build/src/start/server/metro/externals.js +51 -64
- package/build/src/start/server/metro/externals.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js +8 -2
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/formatFileCandidates.js +8 -2
- package/build/src/start/server/metro/formatFileCandidates.js.map +1 -1
- package/build/src/start/server/metro/getCssModulesFromBundler.js +34 -10
- package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +96 -30
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +40 -21
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/metroVirtualModules.js +82 -0
- package/build/src/start/server/metro/metroVirtualModules.js.map +1 -0
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js +8 -2
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -1
- package/build/src/start/server/metro/router.js +44 -17
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +56 -14
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/serializeHtml.js +25 -12
- package/build/src/start/server/metro/serializeHtml.js.map +1 -1
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +8 -2
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +148 -46
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/metro/withMetroResolvers.js +31 -13
- package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
- package/build/src/start/server/middleware/CreateFileMiddleware.js +22 -10
- package/build/src/start/server/middleware/CreateFileMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +16 -4
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +42 -12
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoMiddleware.js +8 -2
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js +41 -11
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +40 -10
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ReactDevToolsPageMiddleware.js +24 -6
- package/build/src/start/server/middleware/ReactDevToolsPageMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +8 -2
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ServeStaticMiddleware.js +24 -6
- package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js +25 -8
- package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js +10 -4
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +24 -6
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +33 -9
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +27 -11
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
- package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +33 -9
- package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +12 -2
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/resolveAssets.js +17 -5
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/start/server/middleware/resolvePlatform.js +8 -2
- package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
- package/build/src/start/server/platformBundlers.js +8 -2
- package/build/src/start/server/platformBundlers.js.map +1 -1
- package/build/src/start/server/serverLogLikeMetro.js +37 -13
- package/build/src/start/server/serverLogLikeMetro.js.map +1 -1
- package/build/src/start/server/type-generation/expo-env.js +16 -4
- package/build/src/start/server/type-generation/expo-env.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +91 -37
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +27 -9
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
- package/build/src/start/server/type-generation/tsconfig.js +27 -9
- package/build/src/start/server/type-generation/tsconfig.js.map +1 -1
- package/build/src/start/server/webTemplate.js +26 -8
- package/build/src/start/server/webTemplate.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +36 -12
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/server/webpack/compile.js +17 -5
- package/build/src/start/server/webpack/compile.js.map +1 -1
- package/build/src/start/server/webpack/resolveFromProject.js +8 -2
- package/build/src/start/server/webpack/resolveFromProject.js.map +1 -1
- package/build/src/start/server/webpack/tls.js +35 -11
- package/build/src/start/server/webpack/tls.js.map +1 -1
- package/build/src/start/startAsync.js +36 -11
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +32 -8
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/getDevClientProperties.js +26 -8
- package/build/src/utils/analytics/getDevClientProperties.js.map +1 -1
- package/build/src/utils/analytics/metroDebuggerMiddleware.js +2 -2
- package/build/src/utils/analytics/metroDebuggerMiddleware.js.map +1 -1
- package/build/src/utils/args.js +32 -8
- package/build/src/utils/args.js.map +1 -1
- package/build/src/utils/cocoapods.js +64 -28
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/codesigning.js +79 -29
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/createFileTransform.js +24 -69
- package/build/src/utils/createFileTransform.js.map +1 -1
- package/build/src/utils/dir.js +33 -26
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/downloadAppAsync.js +40 -10
- package/build/src/utils/downloadAppAsync.js.map +1 -1
- package/build/src/utils/downloadExpoGoAsync.js +26 -11
- package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
- package/build/src/utils/editor.js +18 -6
- package/build/src/utils/editor.js.map +1 -1
- package/build/src/utils/env.js +40 -31
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/errors.js +20 -5
- package/build/src/utils/errors.js.map +1 -1
- package/build/src/utils/findUp.js +18 -6
- package/build/src/utils/findUp.js.map +1 -1
- package/build/src/utils/getOrPromptApplicationId.js +19 -7
- package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
- package/build/src/utils/getRunningProcess.js +18 -6
- package/build/src/utils/getRunningProcess.js.map +1 -1
- package/build/src/utils/git.js +18 -6
- package/build/src/utils/git.js.map +1 -1
- package/build/src/utils/glob.js +9 -3
- package/build/src/utils/glob.js.map +1 -1
- package/build/src/utils/ip.js +8 -2
- package/build/src/utils/ip.js.map +1 -1
- package/build/src/utils/isModuleSymlinked.js +16 -4
- package/build/src/utils/isModuleSymlinked.js.map +1 -1
- package/build/src/utils/link.js +18 -6
- package/build/src/utils/link.js.map +1 -1
- package/build/src/utils/mergeGitIgnorePaths.js +25 -13
- package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
- package/build/src/utils/modifyConfigAsync.js +18 -6
- package/build/src/utils/modifyConfigAsync.js.map +1 -1
- package/build/src/utils/modifyConfigPlugins.js +8 -2
- package/build/src/utils/modifyConfigPlugins.js.map +1 -1
- package/build/src/utils/nodeEnv.js +2 -0
- package/build/src/utils/nodeEnv.js.map +1 -1
- package/build/src/utils/nodeModules.js +23 -5
- package/build/src/utils/nodeModules.js.map +1 -1
- package/build/src/utils/npm.js +64 -17
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/open.js +9 -3
- package/build/src/utils/open.js.map +1 -1
- package/build/src/utils/ora.js +16 -4
- package/build/src/utils/ora.js.map +1 -1
- package/build/src/utils/plist.js +24 -6
- package/build/src/utils/plist.js.map +1 -1
- package/build/src/utils/port.js +22 -10
- package/build/src/utils/port.js.map +1 -1
- package/build/src/utils/profile.js +8 -2
- package/build/src/utils/profile.js.map +1 -1
- package/build/src/utils/progress.js +8 -2
- package/build/src/utils/progress.js.map +1 -1
- package/build/src/utils/prompts.js +16 -4
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/utils/scheme.js +75 -23
- package/build/src/utils/scheme.js.map +1 -1
- package/build/src/utils/tar.js +16 -4
- package/build/src/utils/tar.js.map +1 -1
- package/build/src/utils/telemetry/DetachedClient.js +87 -0
- package/build/src/utils/telemetry/DetachedClient.js.map +1 -0
- package/build/src/utils/telemetry/RudderClient.js +98 -0
- package/build/src/utils/telemetry/RudderClient.js.map +1 -0
- package/build/src/utils/telemetry/flushDetached.js +43 -0
- package/build/src/utils/telemetry/flushDetached.js.map +1 -0
- package/build/src/utils/telemetry/getContext.js +92 -0
- package/build/src/utils/telemetry/getContext.js.map +1 -0
- package/build/src/utils/telemetry/index.js +32 -0
- package/build/src/utils/telemetry/index.js.map +1 -0
- package/build/src/utils/telemetry/types.js +6 -0
- package/build/src/utils/telemetry/types.js.map +1 -0
- package/build/src/utils/tsconfig/evaluateTsConfig.js +16 -4
- package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -1
- package/build/src/utils/tsconfig/loadTsConfigPaths.js +18 -6
- package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +10 -4
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -1
- package/build/src/utils/url.js +19 -10
- package/build/src/utils/url.js.map +1 -1
- package/build/src/utils/validateApplicationId.js +18 -6
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/build/src/whoami/whoamiAsync.js +8 -2
- package/build/src/whoami/whoamiAsync.js.map +1 -1
- package/package.json +15 -16
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js +27907 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js +9494 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js +10015 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +28375 -0
- package/static/canary/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +9714 -0
- package/build/src/run/android/resolveGradleProps.js +0 -37
- package/build/src/run/android/resolveGradleProps.js.map +0 -1
- package/build/src/start/server/metro/bundleApiRoutes.js +0 -52
- package/build/src/start/server/metro/bundleApiRoutes.js.map +0 -1
- package/build/src/start/server/metro/debugging/InspectorDevice.js +0 -80
- package/build/src/start/server/metro/debugging/InspectorDevice.js.map +0 -1
- package/build/src/start/server/metro/debugging/InspectorProxy.js +0 -116
- package/build/src/start/server/metro/debugging/InspectorProxy.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/NetworkResponse.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/PageReload.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerGetPossibleBreakpoints.js +0 -21
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerGetPossibleBreakpoints.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerScriptParsed.js +0 -56
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerScriptParsed.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerSetBreakpointByUrl.js +0 -18
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerSetBreakpointByUrl.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeCallFunctionOn.js +0 -24
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeCallFunctionOn.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeGetProperties.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/types.js.map +0 -1
- package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js.map +0 -1
- package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js +0 -38
- package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +0 -1
- package/build/src/start/server/type-generation/__typetests__/generateFixtures.js +0 -38
- package/build/src/start/server/type-generation/__typetests__/generateFixtures.js.map +0 -1
- package/build/src/start/server/type-generation/__typetests__/route.test.js +0 -184
- package/build/src/start/server/type-generation/__typetests__/route.test.js.map +0 -1
- package/build/src/utils/analytics/rudderstackClient.js +0 -147
- package/build/src/utils/analytics/rudderstackClient.js.map +0 -1
- /package/build/src/start/server/metro/debugging/{inspectorHandlers/types.js → types.js} +0 -0
|
@@ -5,16 +5,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.startReactDevToolsProxyAsync = startReactDevToolsProxyAsync;
|
|
6
6
|
exports.closeReactDevToolsProxy = closeReactDevToolsProxy;
|
|
7
7
|
exports.addReactDevToolsReloadListener = addReactDevToolsReloadListener;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
function _assert() {
|
|
9
|
+
const data = _interopRequireDefault(require("assert"));
|
|
10
|
+
_assert = function() {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function _events() {
|
|
16
|
+
const data = require("events");
|
|
17
|
+
_events = function() {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _ws() {
|
|
23
|
+
const data = _interopRequireDefault(require("ws"));
|
|
24
|
+
_ws = function() {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
11
29
|
function _interopRequireDefault(obj) {
|
|
12
30
|
return obj && obj.__esModule ? obj : {
|
|
13
31
|
default: obj
|
|
14
32
|
};
|
|
15
33
|
}
|
|
16
34
|
let serverInstance = null;
|
|
17
|
-
const eventEmitter = new _events.EventEmitter();
|
|
35
|
+
const eventEmitter = new (_events()).EventEmitter();
|
|
18
36
|
/**
|
|
19
37
|
* Private command to support DevTools frontend reload.
|
|
20
38
|
*
|
|
@@ -28,12 +46,12 @@ async function startReactDevToolsProxyAsync(options) {
|
|
|
28
46
|
return;
|
|
29
47
|
}
|
|
30
48
|
var ref;
|
|
31
|
-
serverInstance = new _ws.default.WebSocketServer({
|
|
49
|
+
serverInstance = new (_ws()).default.WebSocketServer({
|
|
32
50
|
port: (ref = options == null ? void 0 : options.port) != null ? ref : 8097
|
|
33
51
|
});
|
|
34
52
|
serverInstance.on("connection", function connection(ws) {
|
|
35
53
|
ws.on("message", function message(rawData, isBinary) {
|
|
36
|
-
(
|
|
54
|
+
_assert().default(!isBinary);
|
|
37
55
|
const data = rawData.toString();
|
|
38
56
|
if (data === RELOAD_COMMAND) {
|
|
39
57
|
closeAllOtherClients(ws);
|
|
@@ -41,7 +59,7 @@ async function startReactDevToolsProxyAsync(options) {
|
|
|
41
59
|
return;
|
|
42
60
|
}
|
|
43
61
|
serverInstance == null ? void 0 : serverInstance.clients.forEach(function each(client) {
|
|
44
|
-
if (client !== ws && client.readyState === _ws.default.OPEN) {
|
|
62
|
+
if (client !== ws && client.readyState === _ws().default.OPEN) {
|
|
45
63
|
client.send(data, {
|
|
46
64
|
binary: isBinary
|
|
47
65
|
});
|
|
@@ -64,7 +82,7 @@ function addReactDevToolsReloadListener(listener) {
|
|
|
64
82
|
* Close all other WebSocket clients other than the current `self` client
|
|
65
83
|
*/ function closeAllOtherClients(self) {
|
|
66
84
|
serverInstance == null ? void 0 : serverInstance.clients.forEach(function each(client) {
|
|
67
|
-
if (client !== self && client.readyState === _ws.default.OPEN) {
|
|
85
|
+
if (client !== self && client.readyState === _ws().default.OPEN) {
|
|
68
86
|
client.close();
|
|
69
87
|
}
|
|
70
88
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/ReactDevToolsProxy.ts"],"sourcesContent":["import assert from 'assert';\nimport { EventEmitter } from 'events';\nimport WebSocket from 'ws';\n\nlet serverInstance: WebSocket.WebSocketServer | null = null;\n\nconst eventEmitter = new EventEmitter();\n\n/**\n * Private command to support DevTools frontend reload.\n *\n * The react-devtools maintains state between frontend(webpage) and backend(app).\n * If we reload the frontend without reloading the app, the react-devtools will stuck on incorrect state.\n * We introduce this special reload command.\n * As long as the frontend reload, we will close app's WebSocket connection and tell app to reconnect again.\n */\nconst RELOAD_COMMAND = 'Expo::RELOAD';\n\n/**\n * Start the react-devtools WebSocket proxy server\n */\nexport async function startReactDevToolsProxyAsync(options?: { port: number }) {\n if (serverInstance != null) {\n return;\n }\n\n serverInstance = new WebSocket.WebSocketServer({ port: options?.port ?? 8097 });\n\n serverInstance.on('connection', function connection(ws) {\n ws.on('message', function message(rawData, isBinary) {\n assert(!isBinary);\n const data = rawData.toString();\n\n if (data === RELOAD_COMMAND) {\n closeAllOtherClients(ws);\n eventEmitter.emit(RELOAD_COMMAND);\n return;\n }\n\n serverInstance?.clients.forEach(function each(client) {\n if (client !== ws && client.readyState === WebSocket.OPEN) {\n client.send(data, { binary: isBinary });\n }\n });\n });\n });\n\n serverInstance.on('close', function () {\n serverInstance = null;\n });\n}\n\n/**\n * Close the WebSocket server\n */\nexport function closeReactDevToolsProxy() {\n serverInstance?.close();\n serverInstance = null;\n}\n\n/**\n * add event listener from react-devtools frontend reload\n */\nexport function addReactDevToolsReloadListener(listener: (...args: any[]) => void) {\n eventEmitter.addListener(RELOAD_COMMAND, listener);\n}\n\n/**\n * Close all other WebSocket clients other than the current `self` client\n */\nfunction closeAllOtherClients(self: WebSocket.WebSocket) {\n serverInstance?.clients.forEach(function each(client) {\n if (client !== self && client.readyState === WebSocket.OPEN) {\n client.close();\n }\n });\n}\n"],"names":["startReactDevToolsProxyAsync","closeReactDevToolsProxy","addReactDevToolsReloadListener","serverInstance","eventEmitter","EventEmitter","RELOAD_COMMAND","options","WebSocket","WebSocketServer","port","on","connection","ws","message","rawData","isBinary","assert","data","toString","closeAllOtherClients","emit","clients","forEach","each","client","readyState","OPEN","send","binary","close","listener","addListener","self"],"mappings":"AAAA;;;;QAqBsBA,4BAA4B,GAA5BA,4BAA4B;QAkClCC,uBAAuB,GAAvBA,uBAAuB;QAQvBC,8BAA8B,GAA9BA,8BAA8B;
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/ReactDevToolsProxy.ts"],"sourcesContent":["import assert from 'assert';\nimport { EventEmitter } from 'events';\nimport WebSocket from 'ws';\n\nlet serverInstance: WebSocket.WebSocketServer | null = null;\n\nconst eventEmitter = new EventEmitter();\n\n/**\n * Private command to support DevTools frontend reload.\n *\n * The react-devtools maintains state between frontend(webpage) and backend(app).\n * If we reload the frontend without reloading the app, the react-devtools will stuck on incorrect state.\n * We introduce this special reload command.\n * As long as the frontend reload, we will close app's WebSocket connection and tell app to reconnect again.\n */\nconst RELOAD_COMMAND = 'Expo::RELOAD';\n\n/**\n * Start the react-devtools WebSocket proxy server\n */\nexport async function startReactDevToolsProxyAsync(options?: { port: number }) {\n if (serverInstance != null) {\n return;\n }\n\n serverInstance = new WebSocket.WebSocketServer({ port: options?.port ?? 8097 });\n\n serverInstance.on('connection', function connection(ws) {\n ws.on('message', function message(rawData, isBinary) {\n assert(!isBinary);\n const data = rawData.toString();\n\n if (data === RELOAD_COMMAND) {\n closeAllOtherClients(ws);\n eventEmitter.emit(RELOAD_COMMAND);\n return;\n }\n\n serverInstance?.clients.forEach(function each(client) {\n if (client !== ws && client.readyState === WebSocket.OPEN) {\n client.send(data, { binary: isBinary });\n }\n });\n });\n });\n\n serverInstance.on('close', function () {\n serverInstance = null;\n });\n}\n\n/**\n * Close the WebSocket server\n */\nexport function closeReactDevToolsProxy() {\n serverInstance?.close();\n serverInstance = null;\n}\n\n/**\n * add event listener from react-devtools frontend reload\n */\nexport function addReactDevToolsReloadListener(listener: (...args: any[]) => void) {\n eventEmitter.addListener(RELOAD_COMMAND, listener);\n}\n\n/**\n * Close all other WebSocket clients other than the current `self` client\n */\nfunction closeAllOtherClients(self: WebSocket.WebSocket) {\n serverInstance?.clients.forEach(function each(client) {\n if (client !== self && client.readyState === WebSocket.OPEN) {\n client.close();\n }\n });\n}\n"],"names":["startReactDevToolsProxyAsync","closeReactDevToolsProxy","addReactDevToolsReloadListener","serverInstance","eventEmitter","EventEmitter","RELOAD_COMMAND","options","WebSocket","WebSocketServer","port","on","connection","ws","message","rawData","isBinary","assert","data","toString","closeAllOtherClients","emit","clients","forEach","each","client","readyState","OPEN","send","binary","close","listener","addListener","self"],"mappings":"AAAA;;;;QAqBsBA,4BAA4B,GAA5BA,4BAA4B;QAkClCC,uBAAuB,GAAvBA,uBAAuB;QAQvBC,8BAA8B,GAA9BA,8BAA8B;SA/D3B,OAAQ;gDAAR,QAAQ;IAAR,OAAQ;;;;;SACE,OAAQ;yBAAR,QAAQ;IAAR,OAAQ;;;;;SACf,GAAI;gDAAJ,IAAI;IAAJ,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AAC;iBACzC;aACF,CAAC,CAAC;SACJ,CAAC,CAAC;KACJ,CAAC,CAAC;IAEHb,cAAc,CAACQ,EAAE,CAAC,OAAO,EAAE,WAAY;QACrCR,cAAc,GAAG,IAAI,CAAC;KACvB,CAAC,CAAC;CACJ;AAKM,SAASF,uBAAuB,GAAG;IACxCE,cAAc,QAAO,GAArBA,KAAAA,CAAqB,GAArBA,cAAc,CAAE2B,KAAK,EAAE,AAxDzB,CAwD0B;IACxB3B,cAAc,GAAG,IAAI,CAAC;CACvB;AAKM,SAASD,8BAA8B,CAAC6B,QAAkC,EAAE;IACjF3B,YAAY,CAAC4B,WAAW,CAAC1B,cAAc,EAAEyB,QAAQ,CAAC,CAAC;CACpD;AAED;;GAEG,CACH,SAASX,oBAAoB,CAACa,IAAyB,EAAE;IACvD9B,cAAc,QAAS,GAAvBA,KAAAA,CAAuB,GAAvBA,cAAc,CAAEmB,OAAO,CAACC,OAAO,CAAC,SAASC,IAAI,CAACC,MAAM,EAAE;QACpD,IAAIA,MAAM,KAAKQ,IAAI,IAAIR,MAAM,CAACC,UAAU,KAAKlB,GAAS,UAAA,CAACmB,IAAI,EAAE;YAC3DF,MAAM,CAACK,KAAK,EAAE,CAAC;SAChB;KACF,CAAC,CAAC;CACJ"}
|
|
@@ -2,8 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function _assert() {
|
|
6
|
+
const data = _interopRequireDefault(require("assert"));
|
|
7
|
+
_assert = function() {
|
|
8
|
+
return data;
|
|
9
|
+
};
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
function _url() {
|
|
13
|
+
const data = require("url");
|
|
14
|
+
_url = function() {
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
7
19
|
var Log = _interopRequireWildcard(require("../../log"));
|
|
8
20
|
var _ip = require("../../utils/ip");
|
|
9
21
|
function _interopRequireDefault(obj) {
|
|
@@ -48,7 +60,7 @@ class UrlCreator {
|
|
|
48
60
|
* @returns URL like `http://localhost:8081/_expo/loading?platform=ios`
|
|
49
61
|
* @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.
|
|
50
62
|
*/ constructLoadingUrl(options, platform) {
|
|
51
|
-
const url = new _url.URL("_expo/loading", this.constructUrl({
|
|
63
|
+
const url = new (_url()).URL("_expo/loading", this.constructUrl({
|
|
52
64
|
scheme: "http",
|
|
53
65
|
...options
|
|
54
66
|
}));
|
|
@@ -70,6 +82,7 @@ class UrlCreator {
|
|
|
70
82
|
"https"
|
|
71
83
|
].includes(protocol.toLowerCase()) || // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs
|
|
72
84
|
protocol.includes("_")) {
|
|
85
|
+
debug(`Invalid protocol for dev client URL: ${protocol}`);
|
|
73
86
|
return null;
|
|
74
87
|
}
|
|
75
88
|
const manifestUrl = this.constructUrl({
|
|
@@ -95,7 +108,7 @@ class UrlCreator {
|
|
|
95
108
|
if (!tunnelUrl) {
|
|
96
109
|
return null;
|
|
97
110
|
}
|
|
98
|
-
const parsed = new _url.URL(tunnelUrl);
|
|
111
|
+
const parsed = new (_url()).URL(tunnelUrl);
|
|
99
112
|
var _scheme;
|
|
100
113
|
return {
|
|
101
114
|
port: parsed.port,
|
|
@@ -129,7 +142,7 @@ class UrlCreator {
|
|
|
129
142
|
}
|
|
130
143
|
exports.UrlCreator = UrlCreator;
|
|
131
144
|
function getUrlComponentsFromProxyUrl(options, url) {
|
|
132
|
-
const parsedProxyUrl = new _url.URL(url);
|
|
145
|
+
const parsedProxyUrl = new (_url()).URL(url);
|
|
133
146
|
var _scheme;
|
|
134
147
|
let protocol = (_scheme = options.scheme) != null ? _scheme : "http";
|
|
135
148
|
if (parsedProxyUrl.protocol === "https:") {
|
|
@@ -158,7 +171,7 @@ function getDefaultHostname(options) {
|
|
|
158
171
|
return options.hostname || (0, _ip).getIpAddress();
|
|
159
172
|
}
|
|
160
173
|
function joinUrlComponents({ protocol , hostname , port }) {
|
|
161
|
-
(
|
|
174
|
+
_assert().default(hostname, "hostname cannot be inferred.");
|
|
162
175
|
const validProtocol = protocol ? `${protocol}://` : "";
|
|
163
176
|
const url = `${validProtocol}${hostname}`;
|
|
164
177
|
if (port) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport { getIpAddress } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\nexport class UrlCreator {\n constructor(\n public defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * Return a URL for the \"loading\" interstitial page that is used to disambiguate which\n * native runtime to open the dev server with.\n *\n * @param options options for creating the URL\n * @param platform when opening the URL from the CLI to a connected device we can specify the platform as a query parameter, otherwise it will be inferred from the unsafe user agent sniffing.\n *\n * @returns URL like `http://localhost:8081/_expo/loading?platform=ios`\n * @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string | null): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n if (platform) {\n url.search = new URLSearchParams({ platform }).toString();\n }\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 // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs\n protocol.includes('_')\n ) {\n return null;\n }\n\n const manifestUrl = this.constructUrl({\n ...options,\n scheme: this.defaults?.hostType === 'tunnel' ? 'https' : 'http',\n });\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 const validProtocol = protocol ? `${protocol}://` : '';\n\n const url = `${validProtocol}${hostname}`;\n\n if (port) {\n return url + `:${port}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["Log","debug","require","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","hostType","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","components","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":"AAAA;;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AQ,EAAE,8BAA8B,CAAC,CAAC;IACjD,MAAMc,aAAa,GAAG7B,QAAQ,GAAG,CAAC,EAAEA,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,AAAC;IAEvD,MAAMT,GAAG,GAAG,CAAC,EAAEsC,aAAa,CAAC,EAAEd,QAAQ,CAAC,CAAC,AAAC;IAE1C,IAAID,IAAI,EAAE;QACR,OAAOvB,GAAG,GAAG,CAAC,CAAC,EAAEuB,IAAI,CAAC,CAAC,CAAC;KACzB;IAED,OAAOvB,GAAG,CAAC;CACZ;AAED,kBAAkB,CAClB,SAAS0B,WAAW,GAAuB;IACzC,OAAOM,OAAO,CAACC,GAAG,CAACM,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 public defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * Return a URL for the \"loading\" interstitial page that is used to disambiguate which\n * native runtime to open the dev server with.\n *\n * @param options options for creating the URL\n * @param platform when opening the URL from the CLI to a connected device we can specify the platform as a query parameter, otherwise it will be inferred from the unsafe user agent sniffing.\n *\n * @returns URL like `http://localhost:8081/_expo/loading?platform=ios`\n * @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string | null): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n if (platform) {\n url.search = new URLSearchParams({ platform }).toString();\n }\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 // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs\n protocol.includes('_')\n ) {\n debug(`Invalid protocol for dev client URL: ${protocol}`);\n return null;\n }\n\n const manifestUrl = this.constructUrl({\n ...options,\n scheme: this.defaults?.hostType === 'tunnel' ? 'https' : 'http',\n });\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 const validProtocol = protocol ? `${protocol}://` : '';\n\n const url = `${validProtocol}${hostname}`;\n\n if (port) {\n return url + `:${port}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["Log","debug","require","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","hostType","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","components","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":"AAAA;;;;SAAmB,OAAQ;gDAAR,QAAQ;IAAR,OAAQ;;;;;SACP,IAAK;yBAAL,KAAK;IAAL,IAAK;;;;;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,YACSC,QAAsC,EACrCC,WAAiE,CACzE;aAFOD,QAAsC,GAAtCA,QAAsC;aACrCC,WAAiE,GAAjEA,WAAiE;KACvE;IAEJ;;;;;;;;;KASG,CACH,AAAOC,mBAAmB,CAACC,OAAyB,EAAEC,QAAuB,EAAU;QACrF,MAAMC,GAAG,GAAG,IAAIC,CAAAA,IAAG,OAAA,CAAC,eAAe,EAAE,IAAI,CAACC,YAAY,CAAC;YAAEC,MAAM,EAAE,MAAM;YAAE,GAAGL,OAAO;SAAE,CAAC,CAAC,AAAC;QACxF,IAAIC,QAAQ,EAAE;YACZC,GAAG,CAACI,MAAM,GAAG,IAAIC,eAAe,CAAC;gBAAEN,QAAQ;aAAE,CAAC,CAACO,QAAQ,EAAE,CAAC;SAC3D;QACD,MAAMC,UAAU,GAAGP,GAAG,CAACM,QAAQ,EAAE,AAAC;QAClCf,KAAK,CAAC,CAAC,aAAa,EAAEgB,UAAU,CAAC,CAAC,CAAC,CAAC;QACpC,OAAOA,UAAU,CAAC;KACn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,IAAI,EAAE,CAAC;KAC1D,MAAM,IAAIrC,OAAO,CAAC0B,QAAQ,KAAK,WAAW,EAAE;QAC3C,kCAAkC;QAClC,6BAA6B;QAC7B,OAAO,WAAW,CAAC;KACpB;IAED,OAAO1B,OAAO,CAAC0B,QAAQ,IAAIY,CAAAA,GAAAA,GAAY,AAAE,CAAA,aAAF,EAAE,CAAC;CAC3C;AAED,SAASlB,iBAAiB,CAAC,EAAET,QAAQ,CAAA,EAAEe,QAAQ,CAAA,EAAED,IAAI,CAAA,EAA0B,EAAU;IACvFc,OAAM,UAAA,CAACb,QAAQ,EAAE,8BAA8B,CAAC,CAAC;IACjD,MAAMc,aAAa,GAAG7B,QAAQ,GAAG,CAAC,EAAEA,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,AAAC;IAEvD,MAAMT,GAAG,GAAG,CAAC,EAAEsC,aAAa,CAAC,EAAEd,QAAQ,CAAC,CAAC,AAAC;IAE1C,IAAID,IAAI,EAAE;QACR,OAAOvB,GAAG,GAAG,CAAC,CAAC,EAAEuB,IAAI,CAAC,CAAC,CAAC;KACzB;IAED,OAAOvB,GAAG,CAAC;CACZ;AAED,kBAAkB,CAClB,SAAS0B,WAAW,GAAuB;IACzC,OAAOM,OAAO,CAACC,GAAG,CAACM,uBAAuB,CAAC;CAC5C,CAED,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
|
|
@@ -4,12 +4,44 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.createMetroEndpointAsync = createMetroEndpointAsync;
|
|
6
6
|
exports.requireFileContentsWithMetro = requireFileContentsWithMetro;
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
exports.getStaticRenderFunctionsForEntry = getStaticRenderFunctionsForEntry;
|
|
8
|
+
exports.evalMetro = evalMetro;
|
|
9
|
+
exports.evalMetroNoHandling = evalMetroNoHandling;
|
|
10
|
+
function _fs() {
|
|
11
|
+
const data = _interopRequireDefault(require("fs"));
|
|
12
|
+
_fs = function() {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function _nodeFetch() {
|
|
18
|
+
const data = _interopRequireDefault(require("node-fetch"));
|
|
19
|
+
_nodeFetch = function() {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function _path() {
|
|
25
|
+
const data = _interopRequireDefault(require("path"));
|
|
26
|
+
_path = function() {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
function _requireFromString() {
|
|
32
|
+
const data = _interopRequireDefault(require("require-from-string"));
|
|
33
|
+
_requireFromString = function() {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
function _resolveFrom() {
|
|
39
|
+
const data = _interopRequireDefault(require("resolve-from"));
|
|
40
|
+
_resolveFrom = function() {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
13
45
|
var _metroErrorInterface = require("./metro/metroErrorInterface");
|
|
14
46
|
var _manifestMiddleware = require("./middleware/ManifestMiddleware");
|
|
15
47
|
var _metroOptions = require("./middleware/metroOptions");
|
|
@@ -33,14 +65,18 @@ class MetroNodeError extends Error {
|
|
|
33
65
|
const debug = require("debug")("expo:start:server:node-renderer");
|
|
34
66
|
const cachedSourceMaps = new Map();
|
|
35
67
|
// Support unhandled rejections
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
68
|
+
// Detect if running in Bun
|
|
69
|
+
// @ts-expect-error: This is a global variable that is set by Bun.
|
|
70
|
+
if (!process.isBun) {
|
|
71
|
+
require("source-map-support").install({
|
|
72
|
+
retrieveSourceMap (source) {
|
|
73
|
+
if (cachedSourceMaps.has(source)) {
|
|
74
|
+
return cachedSourceMaps.get(source);
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
40
77
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
44
80
|
function wrapBundle(str) {
|
|
45
81
|
// Skip the metro runtime so debugging is a bit easier.
|
|
46
82
|
// Replace the __r() call with an export statement.
|
|
@@ -48,8 +84,8 @@ function wrapBundle(str) {
|
|
|
48
84
|
return str.replace(/^(__r\(.*\);)$/gm, "module.exports = $1");
|
|
49
85
|
}
|
|
50
86
|
// TODO(EvanBacon): Group all the code together and version.
|
|
51
|
-
const getRenderModuleId = (projectRoot)=>{
|
|
52
|
-
const moduleId = _resolveFrom.default.silent(projectRoot,
|
|
87
|
+
const getRenderModuleId = (projectRoot, entry = "expo-router/node/render.js")=>{
|
|
88
|
+
const moduleId = _resolveFrom().default.silent(projectRoot, entry);
|
|
53
89
|
if (!moduleId) {
|
|
54
90
|
throw new Error(`A version of expo-router with Node.js support is not installed in the project.`);
|
|
55
91
|
}
|
|
@@ -58,69 +94,58 @@ const getRenderModuleId = (projectRoot)=>{
|
|
|
58
94
|
const moveStaticRenderFunction = (0, _fn).memoize(async (projectRoot, requiredModuleId)=>{
|
|
59
95
|
// Copy the file into the project to ensure it works in monorepos.
|
|
60
96
|
// This means the file cannot have any relative imports.
|
|
61
|
-
const tempDir = _path.default.join(projectRoot, ".expo/static");
|
|
62
|
-
await _fs.default.promises.mkdir(tempDir, {
|
|
97
|
+
const tempDir = _path().default.join(projectRoot, ".expo/static");
|
|
98
|
+
await _fs().default.promises.mkdir(tempDir, {
|
|
63
99
|
recursive: true
|
|
64
100
|
});
|
|
65
|
-
const moduleId = _path.default.join(tempDir, "render.js");
|
|
66
|
-
await _fs.default.promises.writeFile(moduleId, await _fs.default.promises.readFile(requiredModuleId, "utf8"));
|
|
101
|
+
const moduleId = _path().default.join(tempDir, "render.js");
|
|
102
|
+
await _fs().default.promises.writeFile(moduleId, await _fs().default.promises.readFile(requiredModuleId, "utf8"));
|
|
67
103
|
// Sleep to give watchman time to register the file.
|
|
68
104
|
await (0, _delay).delayAsync(50);
|
|
69
105
|
return moduleId;
|
|
70
106
|
});
|
|
71
|
-
/** @returns the js file contents required to generate the static generation function. */ async function getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl,
|
|
107
|
+
/** @returns the js file contents required to generate the static generation function. */ async function getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, props, entry) {
|
|
72
108
|
const root = (0, _manifestMiddleware).getMetroServerRoot(projectRoot);
|
|
73
|
-
const requiredModuleId = getRenderModuleId(root);
|
|
109
|
+
const requiredModuleId = getRenderModuleId(root, entry);
|
|
74
110
|
let moduleId = requiredModuleId;
|
|
75
111
|
// Cannot be accessed using Metro's server API, we need to move the file
|
|
76
112
|
// into the project root and try again.
|
|
77
|
-
if (_path.default.relative(root, moduleId).startsWith("..")) {
|
|
113
|
+
if (_path().default.relative(root, moduleId).startsWith("..")) {
|
|
78
114
|
moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);
|
|
79
115
|
}
|
|
80
|
-
return requireFileContentsWithMetro(root, devServerUrl, moduleId,
|
|
81
|
-
dev,
|
|
82
|
-
minify,
|
|
83
|
-
environment,
|
|
84
|
-
baseUrl,
|
|
85
|
-
routerRoot
|
|
86
|
-
});
|
|
116
|
+
return requireFileContentsWithMetro(root, devServerUrl, moduleId, props);
|
|
87
117
|
}
|
|
88
118
|
async function ensureFileInRootDirectory(projectRoot, otherFile) {
|
|
89
119
|
// Cannot be accessed using Metro's server API, we need to move the file
|
|
90
120
|
// into the project root and try again.
|
|
91
|
-
if (!_path.default.relative(projectRoot, otherFile).startsWith(".." + _path.default.sep)) {
|
|
121
|
+
if (!_path().default.relative(projectRoot, otherFile).startsWith(".." + _path().default.sep)) {
|
|
92
122
|
return otherFile;
|
|
93
123
|
}
|
|
94
124
|
// Copy the file into the project to ensure it works in monorepos.
|
|
95
125
|
// This means the file cannot have any relative imports.
|
|
96
|
-
const tempDir = _path.default.join(projectRoot, ".expo/static-tmp");
|
|
97
|
-
await _fs.default.promises.mkdir(tempDir, {
|
|
126
|
+
const tempDir = _path().default.join(projectRoot, ".expo/static-tmp");
|
|
127
|
+
await _fs().default.promises.mkdir(tempDir, {
|
|
98
128
|
recursive: true
|
|
99
129
|
});
|
|
100
|
-
const moduleId = _path.default.join(tempDir, _path.default.basename(otherFile));
|
|
101
|
-
await _fs.default.promises.writeFile(moduleId, await _fs.default.promises.readFile(otherFile, "utf8"));
|
|
130
|
+
const moduleId = _path().default.join(tempDir, _path().default.basename(otherFile));
|
|
131
|
+
await _fs().default.promises.writeFile(moduleId, await _fs().default.promises.readFile(otherFile, "utf8"));
|
|
102
132
|
// Sleep to give watchman time to register the file.
|
|
103
133
|
await (0, _delay).delayAsync(50);
|
|
104
134
|
return moduleId;
|
|
105
135
|
}
|
|
106
|
-
async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath,
|
|
136
|
+
async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props) {
|
|
107
137
|
const root = (0, _manifestMiddleware).getMetroServerRoot(projectRoot);
|
|
108
138
|
const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);
|
|
109
|
-
const serverPath = _path.default.relative(root, safeOtherFile).replace(/\.[jt]sx?$/, "");
|
|
139
|
+
const serverPath = _path().default.relative(root, safeOtherFile).replace(/\.[jt]sx?$/, "");
|
|
110
140
|
const urlFragment = (0, _metroOptions).createBundleUrlPath({
|
|
111
|
-
platform,
|
|
112
|
-
mode: dev ? "development" : "production",
|
|
113
141
|
mainModuleName: serverPath,
|
|
114
|
-
engine,
|
|
115
|
-
environment,
|
|
116
142
|
lazy: false,
|
|
117
|
-
minify,
|
|
118
|
-
baseUrl,
|
|
119
|
-
isExporting: true,
|
|
120
143
|
asyncRoutes: false,
|
|
121
|
-
routerRoot,
|
|
122
144
|
inlineSourceMap: false,
|
|
123
|
-
|
|
145
|
+
engine: "hermes",
|
|
146
|
+
minify: false,
|
|
147
|
+
bytecode: false,
|
|
148
|
+
...props
|
|
124
149
|
});
|
|
125
150
|
let url;
|
|
126
151
|
if (devServerUrl) {
|
|
@@ -128,12 +153,16 @@ async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFileP
|
|
|
128
153
|
} else {
|
|
129
154
|
url = "/" + urlFragment.replace(/^\/+/, "");
|
|
130
155
|
}
|
|
131
|
-
debug("fetching from Metro:", root, serverPath, url);
|
|
132
156
|
return url;
|
|
133
157
|
}
|
|
134
158
|
async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteFilePath, props) {
|
|
135
159
|
const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);
|
|
136
|
-
|
|
160
|
+
return await metroFetchAsync(projectRoot, url);
|
|
161
|
+
}
|
|
162
|
+
async function metroFetchAsync(projectRoot, url) {
|
|
163
|
+
debug("Fetching from Metro:", url);
|
|
164
|
+
// TODO: Skip the dev server and use the Metro instance directly for better results, faster.
|
|
165
|
+
const res = await _nodeFetch().default(url);
|
|
137
166
|
// TODO: Improve error handling
|
|
138
167
|
if (res.status === 500) {
|
|
139
168
|
const text = await res.text();
|
|
@@ -148,7 +177,7 @@ async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteF
|
|
|
148
177
|
throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);
|
|
149
178
|
}
|
|
150
179
|
const content = await res.text();
|
|
151
|
-
const map = await (
|
|
180
|
+
const map = await _nodeFetch().default(url.replace(".bundle?", ".map?")).then((r)=>r.json()
|
|
152
181
|
);
|
|
153
182
|
cachedSourceMaps.set(url, {
|
|
154
183
|
url: projectRoot,
|
|
@@ -156,12 +185,16 @@ async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteF
|
|
|
156
185
|
});
|
|
157
186
|
return {
|
|
158
187
|
src: wrapBundle(content),
|
|
159
|
-
filename: url
|
|
188
|
+
filename: url,
|
|
189
|
+
map
|
|
160
190
|
};
|
|
161
191
|
}
|
|
162
|
-
async function
|
|
163
|
-
const { src: scriptContents , filename } = await getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, options);
|
|
164
|
-
return
|
|
192
|
+
async function getStaticRenderFunctionsForEntry(projectRoot, devServerUrl, options, entry) {
|
|
193
|
+
const { src: scriptContents , filename } = await getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, options, entry);
|
|
194
|
+
return {
|
|
195
|
+
filename,
|
|
196
|
+
fn: await evalMetroAndWrapFunctions(projectRoot, scriptContents, filename)
|
|
197
|
+
};
|
|
165
198
|
}
|
|
166
199
|
function evalMetroAndWrapFunctions(projectRoot, script, filename) {
|
|
167
200
|
const contents = evalMetro(projectRoot, script, filename);
|
|
@@ -188,9 +221,8 @@ function evalMetroAndWrapFunctions(projectRoot, script, filename) {
|
|
|
188
221
|
}, {});
|
|
189
222
|
}
|
|
190
223
|
function evalMetro(projectRoot, src, filename) {
|
|
191
|
-
(0, _serverLogLikeMetro).augmentLogs(projectRoot);
|
|
192
224
|
try {
|
|
193
|
-
return (
|
|
225
|
+
return evalMetroNoHandling(projectRoot, src, filename);
|
|
194
226
|
} catch (error) {
|
|
195
227
|
// Format any errors that were thrown in the global scope of the evaluation.
|
|
196
228
|
if (error instanceof Error) {
|
|
@@ -204,7 +236,11 @@ function evalMetro(projectRoot, src, filename) {
|
|
|
204
236
|
} else {
|
|
205
237
|
throw error;
|
|
206
238
|
}
|
|
207
|
-
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function evalMetroNoHandling(projectRoot, src, filename) {
|
|
242
|
+
(0, _serverLogLikeMetro).augmentLogs(projectRoot);
|
|
243
|
+
return (0, _profile).profile(_requireFromString().default, "eval-metro-bundle")(src, filename);
|
|
208
244
|
}
|
|
209
245
|
|
|
210
246
|
//# sourceMappingURL=getStaticRenderFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport fetch from 'node-fetch';\nimport path from 'path';\nimport requireString from 'require-from-string';\nimport resolveFrom from 'resolve-from';\n\nimport { logMetroError, logMetroErrorAsync } from './metro/metroErrorInterface';\nimport { getMetroServerRoot } from './middleware/ManifestMiddleware';\nimport { createBundleUrlPath } from './middleware/metroOptions';\nimport { augmentLogs } from './serverLogLikeMetro';\nimport { stripAnsi } from '../../utils/ansi';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { memoize } from '../../utils/fn';\nimport { profile } from '../../utils/profile';\n\ntype StaticRenderOptions = {\n // Ensure the style format is `css-xxxx` (prod) instead of `css-view-xxxx` (dev)\n dev?: boolean;\n minify?: boolean;\n platform?: string;\n environment?: 'node';\n engine?: 'hermes';\n baseUrl: string;\n routerRoot: string;\n};\n\nclass MetroNodeError extends Error {\n constructor(\n message: string,\n public rawObject: any\n ) {\n super(message);\n }\n}\n\nconst debug = require('debug')('expo:start:server:node-renderer') as typeof console.log;\n\nconst cachedSourceMaps: Map<string, { url: string; map: string }> = new Map();\n\n// Support unhandled rejections\nrequire('source-map-support').install({\n retrieveSourceMap(source: string) {\n if (cachedSourceMaps.has(source)) {\n return cachedSourceMaps.get(source);\n }\n return null;\n },\n});\n\nfunction wrapBundle(str: string) {\n // Skip the metro runtime so debugging is a bit easier.\n // Replace the __r() call with an export statement.\n // Use gm to apply to the last require line. This is needed when the bundle has side-effects.\n return str.replace(/^(__r\\(.*\\);)$/gm, 'module.exports = $1');\n}\n\n// TODO(EvanBacon): Group all the code together and version.\nconst getRenderModuleId = (projectRoot: string): string => {\n const moduleId = resolveFrom.silent(projectRoot, 'expo-router/node/render.js');\n if (!moduleId) {\n throw new Error(\n `A version of expo-router with Node.js support is not installed in the project.`\n );\n }\n\n return moduleId;\n};\n\nconst moveStaticRenderFunction = memoize(async (projectRoot: string, requiredModuleId: string) => {\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, 'render.js');\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(requiredModuleId, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n});\n\n/** @returns the js file contents required to generate the static generation function. */\nasync function getStaticRenderFunctionsContentAsync(\n projectRoot: string,\n devServerUrl: string,\n { dev = false, minify = false, environment, baseUrl, routerRoot }: StaticRenderOptions\n): Promise<{ src: string; filename: string }> {\n const root = getMetroServerRoot(projectRoot);\n const requiredModuleId = getRenderModuleId(root);\n let moduleId = requiredModuleId;\n\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (path.relative(root, moduleId).startsWith('..')) {\n moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);\n }\n\n return requireFileContentsWithMetro(root, devServerUrl, moduleId, {\n dev,\n minify,\n environment,\n baseUrl,\n routerRoot,\n });\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n {\n dev = false,\n platform = 'web',\n minify = false,\n environment,\n engine = 'hermes',\n baseUrl,\n routerRoot,\n }: StaticRenderOptions\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n platform,\n mode: dev ? 'development' : 'production',\n mainModuleName: serverPath,\n engine,\n environment,\n lazy: false,\n minify,\n baseUrl,\n isExporting: true,\n asyncRoutes: false,\n routerRoot,\n inlineSourceMap: false,\n bytecode: false,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n debug('fetching from Metro:', root, serverPath, url);\n return url;\n}\n\nexport async function requireFileContentsWithMetro(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: StaticRenderOptions\n): Promise<{ src: string; filename: string }> {\n const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);\n\n const res = await fetch(url);\n\n // TODO: Improve error handling\n if (res.status === 500) {\n const text = await res.text();\n if (text.startsWith('{\"originModulePath\"') || text.startsWith('{\"type\":\"TransformError\"')) {\n const errorObject = JSON.parse(text);\n\n throw new MetroNodeError(stripAnsi(errorObject.message) ?? errorObject.message, errorObject);\n }\n throw new Error(`[${res.status}]: ${res.statusText}\\n${text}`);\n }\n\n if (!res.ok) {\n throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);\n }\n\n const content = await res.text();\n\n const map = await fetch(url.replace('.bundle?', '.map?')).then((r) => r.json());\n cachedSourceMaps.set(url, { url: projectRoot, map });\n\n return { src: wrapBundle(content), filename: url };\n}\n\nexport async function getStaticRenderFunctions(\n projectRoot: string,\n devServerUrl: string,\n options: StaticRenderOptions\n): Promise<Record<string, (...args: any[]) => Promise<any>>> {\n const { src: scriptContents, filename } = await getStaticRenderFunctionsContentAsync(\n projectRoot,\n devServerUrl,\n options\n );\n\n return evalMetroAndWrapFunctions(projectRoot, scriptContents, filename);\n}\n\nfunction evalMetroAndWrapFunctions<T = Record<string, (...args: any[]) => Promise<any>>>(\n projectRoot: string,\n script: string,\n filename: string\n): Promise<T> {\n const contents = evalMetro(projectRoot, script, filename);\n\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n throw new SilentError(error);\n }\n };\n return acc;\n }, {} as any);\n}\n\nfunction evalMetro(projectRoot: string, src: string, filename: string) {\n augmentLogs(projectRoot);\n try {\n return profile(requireString, 'eval-metro-bundle')(src, filename);\n } catch (error: any) {\n // Format any errors that were thrown in the global scope of the evaluation.\n if (error instanceof Error) {\n logMetroErrorAsync({ projectRoot, error }).catch((internalError) => {\n debug('Failed to log metro error:', internalError);\n throw error;\n });\n } else {\n throw error;\n }\n } finally {\n }\n}\n"],"names":["createMetroEndpointAsync","requireFileContentsWithMetro","getStaticRenderFunctions","MetroNodeError","Error","constructor","message","rawObject","debug","require","cachedSourceMaps","Map","install","retrieveSourceMap","source","has","get","wrapBundle","str","replace","getRenderModuleId","projectRoot","moduleId","resolveFrom","silent","moveStaticRenderFunction","memoize","requiredModuleId","tempDir","path","join","fs","promises","mkdir","recursive","writeFile","readFile","delayAsync","getStaticRenderFunctionsContentAsync","devServerUrl","dev","minify","environment","baseUrl","routerRoot","root","getMetroServerRoot","relative","startsWith","ensureFileInRootDirectory","otherFile","sep","basename","absoluteFilePath","platform","engine","safeOtherFile","serverPath","urlFragment","createBundleUrlPath","mode","mainModuleName","lazy","isExporting","asyncRoutes","inlineSourceMap","bytecode","url","URL","toString","props","res","fetch","status","text","errorObject","JSON","parse","stripAnsi","statusText","ok","content","map","then","r","json","set","src","filename","options","scriptContents","evalMetroAndWrapFunctions","script","contents","evalMetro","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","SilentError","augmentLogs","profile","requireString","logMetroErrorAsync","catch","internalError"],"mappings":"AAMA;;;;QA4HsBA,wBAAwB,GAAxBA,wBAAwB;QA4CxBC,4BAA4B,GAA5BA,4BAA4B;QAiC5BC,wBAAwB,GAAxBA,wBAAwB;AAzM/B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACD,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACb,IAAA,KAAM,kCAAN,MAAM,EAAA;AACG,IAAA,kBAAqB,kCAArB,qBAAqB,EAAA;AACvB,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEY,IAAA,oBAA6B,WAA7B,6BAA6B,CAAA;AAC5C,IAAA,mBAAiC,WAAjC,iCAAiC,CAAA;AAChC,IAAA,aAA2B,WAA3B,2BAA2B,CAAA;AACnC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACxB,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACjB,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AAClB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACxB,IAAA,GAAgB,WAAhB,gBAAgB,CAAA;AAChB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;;;;;;AAa7C,MAAMC,cAAc,SAASC,KAAK;IAChCC,YACEC,OAAe,EACRC,SAAc,CACrB;QACA,KAAK,CAACD,OAAO,CAAC,CAAC;aAFRC,SAAc,GAAdA,SAAc;KAGtB;CACF;AAED,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAExF,MAAMC,gBAAgB,GAA8C,IAAIC,GAAG,EAAE,AAAC;AAE9E,+BAA+B;AAC/BF,OAAO,CAAC,oBAAoB,CAAC,CAACG,OAAO,CAAC;IACpCC,iBAAiB,EAACC,MAAc,EAAE;QAChC,IAAIJ,gBAAgB,CAACK,GAAG,CAACD,MAAM,CAAC,EAAE;YAChC,OAAOJ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,QAApC,CAACC,kBAAa,QAAA,EAAE,mBAAmB,CAAC,CAACpB,GAAG,EAAEC,QAAQ,CAAC,CAAC;KACnE,CAAC,OAAOc,KAAK,EAAO;QACnB,4EAA4E;QAC5E,IAAIA,KAAK,YAAYlG,KAAK,EAAE;YAC1BwG,CAAAA,GAAAA,oBAAkB,AAAwB,CAAA,mBAAxB,CAAC;gBAAEvF,WAAW;gBAAEiF,KAAK;aAAE,CAAC,CAACO,KAAK,CAAC,CAACC,aAAa,GAAK;gBAClEtG,KAAK,CAAC,4BAA4B,EAAEsG,aAAa,CAAC,CAAC;gBACnD,MAAMR,KAAK,CAAC;aACb,CAAC,CAAC;SACJ,MAAM;YACL,MAAMA,KAAK,CAAC;SACb;KACF,QAAS,EACT;CACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport fetch from 'node-fetch';\nimport path from 'path';\nimport requireString from 'require-from-string';\nimport resolveFrom from 'resolve-from';\n\nimport { logMetroError, logMetroErrorAsync } from './metro/metroErrorInterface';\nimport { getMetroServerRoot } from './middleware/ManifestMiddleware';\nimport { createBundleUrlPath, ExpoMetroOptions } from './middleware/metroOptions';\nimport { augmentLogs } from './serverLogLikeMetro';\nimport { stripAnsi } from '../../utils/ansi';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { memoize } from '../../utils/fn';\nimport { profile } from '../../utils/profile';\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nclass MetroNodeError extends Error {\n constructor(\n message: string,\n public rawObject: any\n ) {\n super(message);\n }\n}\n\nconst debug = require('debug')('expo:start:server:node-renderer') as typeof console.log;\n\nconst cachedSourceMaps: Map<string, { url: string; map: string }> = new Map();\n\n// Support unhandled rejections\n// Detect if running in Bun\n\n// @ts-expect-error: This is a global variable that is set by Bun.\nif (!process.isBun) {\n require('source-map-support').install({\n retrieveSourceMap(source: string) {\n if (cachedSourceMaps.has(source)) {\n return cachedSourceMaps.get(source);\n }\n return null;\n },\n });\n}\n\nfunction wrapBundle(str: string) {\n // Skip the metro runtime so debugging is a bit easier.\n // Replace the __r() call with an export statement.\n // Use gm to apply to the last require line. This is needed when the bundle has side-effects.\n return str.replace(/^(__r\\(.*\\);)$/gm, 'module.exports = $1');\n}\n\n// TODO(EvanBacon): Group all the code together and version.\nconst getRenderModuleId = (\n projectRoot: string,\n entry: string = 'expo-router/node/render.js'\n): string => {\n const moduleId = resolveFrom.silent(projectRoot, entry);\n if (!moduleId) {\n throw new Error(\n `A version of expo-router with Node.js support is not installed in the project.`\n );\n }\n\n return moduleId;\n};\n\nconst moveStaticRenderFunction = memoize(async (projectRoot: string, requiredModuleId: string) => {\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, 'render.js');\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(requiredModuleId, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n});\n\n/** @returns the js file contents required to generate the static generation function. */\nasync function getStaticRenderFunctionsContentAsync(\n projectRoot: string,\n devServerUrl: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>,\n entry?: string\n): Promise<{ src: string; filename: string }> {\n const root = getMetroServerRoot(projectRoot);\n const requiredModuleId = getRenderModuleId(root, entry);\n let moduleId = requiredModuleId;\n\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (path.relative(root, moduleId).startsWith('..')) {\n moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);\n }\n\n return requireFileContentsWithMetro(root, devServerUrl, moduleId, props);\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n mainModuleName: serverPath,\n lazy: false,\n asyncRoutes: false,\n inlineSourceMap: false,\n engine: 'hermes',\n minify: false,\n bytecode: false,\n ...props,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n return url;\n}\n\nexport async function requireFileContentsWithMetro(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<{ src: string; filename: string }> {\n const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);\n return await metroFetchAsync(projectRoot, url);\n}\n\nasync function metroFetchAsync(\n projectRoot: string,\n url: string\n): Promise<{ src: string; filename: string; map?: any }> {\n debug('Fetching from Metro:', url);\n // TODO: Skip the dev server and use the Metro instance directly for better results, faster.\n const res = await fetch(url);\n\n // TODO: Improve error handling\n if (res.status === 500) {\n const text = await res.text();\n if (text.startsWith('{\"originModulePath\"') || text.startsWith('{\"type\":\"TransformError\"')) {\n const errorObject = JSON.parse(text);\n\n throw new MetroNodeError(stripAnsi(errorObject.message) ?? errorObject.message, errorObject);\n }\n throw new Error(`[${res.status}]: ${res.statusText}\\n${text}`);\n }\n\n if (!res.ok) {\n throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);\n }\n\n const content = await res.text();\n\n const map = await fetch(url.replace('.bundle?', '.map?')).then((r) => r.json());\n cachedSourceMaps.set(url, { url: projectRoot, map });\n\n return {\n src: wrapBundle(content),\n filename: url,\n map,\n };\n}\n\nexport async function getStaticRenderFunctionsForEntry<T = any>(\n projectRoot: string,\n devServerUrl: string,\n options: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>,\n entry: string\n) {\n const { src: scriptContents, filename } = await getStaticRenderFunctionsContentAsync(\n projectRoot,\n devServerUrl,\n options,\n entry\n );\n\n return {\n filename,\n fn: await evalMetroAndWrapFunctions<T>(projectRoot, scriptContents, filename),\n };\n}\n\nfunction evalMetroAndWrapFunctions<T = Record<string, any>>(\n projectRoot: string,\n script: string,\n filename: string\n): Promise<T> {\n const contents = evalMetro(projectRoot, script, filename);\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n throw new SilentError(error);\n }\n };\n return acc;\n }, {} as any);\n}\n\nexport function evalMetro(projectRoot: string, src: string, filename: string) {\n try {\n return evalMetroNoHandling(projectRoot, src, filename);\n } catch (error: any) {\n // Format any errors that were thrown in the global scope of the evaluation.\n if (error instanceof Error) {\n logMetroErrorAsync({ projectRoot, error }).catch((internalError) => {\n debug('Failed to log metro error:', internalError);\n throw error;\n });\n } else {\n throw error;\n }\n }\n}\n\nexport function evalMetroNoHandling(projectRoot: string, src: string, filename: string) {\n augmentLogs(projectRoot);\n\n return profile(requireString, 'eval-metro-bundle')(src, filename);\n}\n"],"names":["createMetroEndpointAsync","requireFileContentsWithMetro","getStaticRenderFunctionsForEntry","evalMetro","evalMetroNoHandling","MetroNodeError","Error","constructor","message","rawObject","debug","require","cachedSourceMaps","Map","process","isBun","install","retrieveSourceMap","source","has","get","wrapBundle","str","replace","getRenderModuleId","projectRoot","entry","moduleId","resolveFrom","silent","moveStaticRenderFunction","memoize","requiredModuleId","tempDir","path","join","fs","promises","mkdir","recursive","writeFile","readFile","delayAsync","getStaticRenderFunctionsContentAsync","devServerUrl","props","root","getMetroServerRoot","relative","startsWith","ensureFileInRootDirectory","otherFile","sep","basename","absoluteFilePath","safeOtherFile","serverPath","urlFragment","createBundleUrlPath","mainModuleName","lazy","asyncRoutes","inlineSourceMap","engine","minify","bytecode","url","URL","toString","metroFetchAsync","res","fetch","status","text","errorObject","JSON","parse","stripAnsi","statusText","ok","content","map","then","r","json","set","src","filename","options","scriptContents","fn","evalMetroAndWrapFunctions","script","contents","Object","keys","reduce","acc","key","apply","error","logMetroError","SilentError","logMetroErrorAsync","catch","internalError","augmentLogs","profile","requireString"],"mappings":"AAMA;;;;QAuHsBA,wBAAwB,GAAxBA,wBAAwB;QA8BxBC,4BAA4B,GAA5BA,4BAA4B;QA6C5BC,gCAAgC,GAAhCA,gCAAgC;QA4CtCC,SAAS,GAATA,SAAS;QAgBTC,mBAAmB,GAAnBA,mBAAmB;SA9PpB,GAAI;gDAAJ,IAAI;IAAJ,GAAI;;;;;SACD,UAAY;gDAAZ,YAAY;IAAZ,UAAY;;;;;SACb,KAAM;gDAAN,MAAM;IAAN,KAAM;;;;;SACG,kBAAqB;gDAArB,qBAAqB;IAArB,kBAAqB;;;;;SACvB,YAAc;gDAAd,cAAc;IAAd,YAAc;;;;;AAEY,IAAA,oBAA6B,WAA7B,6B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