@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport { getDefaultConfig, LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport { Server as ConnectServer } from 'connect';\nimport http from 'http';\nimport type Metro from 'metro';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport semver from 'semver';\nimport { URL } from 'url';\n\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { MetroDevServerOptions } from '../../../export/fork-bundleAsync';\nimport { Log } from '../../../log';\nimport { getMetroProperties } from '../../../utils/analytics/getMetroProperties';\nimport { createDebuggerTelemetryMiddleware } from '../../../utils/analytics/metroDebuggerMiddleware';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { env } from '../../../utils/env';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { getMetroServerRoot } from '../middleware/ManifestMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware, replaceMiddlewareWith } from '../middleware/mutations';\nimport { ServerNext, ServerRequest, ServerResponse } from '../middleware/server.types';\nimport { suppressRemoteDebuggingErrorMiddleware } from '../middleware/suppressErrorMiddleware';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nfunction gteSdkVersion(exp: Pick<ExpoConfig, 'sdkVersion'>, sdkVersion: string): boolean {\n if (!exp.sdkVersion) {\n return false;\n }\n\n if (exp.sdkVersion === 'UNVERSIONED') {\n return true;\n }\n\n try {\n return semver.gte(exp.sdkVersion, sdkVersion);\n } catch {\n throw new Error(`${exp.sdkVersion} is not a valid version. Must be in the form of x.y.z`);\n }\n}\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp,\n isExporting,\n }: { exp?: ExpoConfig; isExporting: boolean }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n const serverRoot = getMetroServerRoot(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const hasConfig = await resolveConfig(options.config, projectRoot);\n let config: ConfigT = {\n ...(await loadConfig(\n { cwd: projectRoot, projectRoot, ...options },\n // If the project does not have a metro.config.js, then we use the default config.\n hasConfig.isEmpty ? getDefaultConfig(projectRoot) : undefined\n )),\n reporter: {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n if (\n // Requires SDK 50 for expo-assets hashAssetPlugin change.\n !exp.sdkVersion ||\n gteSdkVersion(exp, '50.0.0')\n ) {\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n } else {\n if (isExporting && exp.experiments?.baseUrl) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = exp.experiments?.baseUrl;\n }\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n webOutput: exp.web?.output ?? 'single',\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n isExporting,\n });\n\n if (process.env.NODE_ENV !== 'test') {\n logEventAsync('metro config', getMetroProperties(projectRoot, exp, config));\n }\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<MetroDevServerOptions, 'logger'>,\n { isExporting }: { isExporting: boolean }\n): Promise<{\n metro: Metro.Server;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n // TODO: When we bring expo/metro-config into the expo/expo repo, then we can upstream this.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n });\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n { exp, isExporting }\n );\n\n const { createDevServerMiddleware, securityHeadersMiddleware } =\n require('@react-native-community/cli-server-api') as typeof import('@react-native-community/cli-server-api');\n\n const { middleware, messageSocketEndpoint, eventsSocketEndpoint, websocketEndpoints } =\n createDevServerMiddleware({\n port: metroConfig.server.port,\n watchFolders: metroConfig.watchFolders,\n });\n\n // The `securityHeadersMiddleware` does not support cross-origin requests, we replace with the enhanced version.\n replaceMiddlewareWith(\n middleware as ConnectServer,\n securityHeadersMiddleware,\n createCorsMiddleware(exp)\n );\n\n prependMiddleware(middleware, suppressRemoteDebuggingErrorMiddleware);\n\n // TODO: We can probably drop this now.\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n middleware.use(createDebuggerTelemetryMiddleware(projectRoot, exp));\n\n // Initialize all React Native debug features\n const { debugMiddleware, debugWebsocketEndpoints } = createDebugMiddleware(metroBundler);\n prependMiddleware(middleware, debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware());\n\n const { server, metro } = await runServer(metroBundler, metroConfig, {\n // @ts-expect-error: Inconsistent `websocketEndpoints` type between metro and @react-native-community/cli-server-api\n websocketEndpoints: {\n ...websocketEndpoints,\n ...debugWebsocketEndpoints,\n },\n watch: !isExporting && isWatchEnabled(),\n });\n\n prependMiddleware(middleware, (req: ServerRequest, res: ServerResponse, next: ServerNext) => {\n // If the URL is a Metro asset request, then we need to skip all other middleware to prevent\n // the community CLI's serve-static from hosting `/assets/index.html` in place of all assets if it exists.\n // /assets/?unstable_path=.\n if (req.url) {\n const url = new URL(req.url!, 'http://localhost:8000');\n if (url.pathname.match(/^\\/assets\\/?/) && url.searchParams.get('unstable_path') != null) {\n return metro.processRequest(req, res, next);\n }\n }\n return next();\n });\n\n setEventReporter(eventsSocketEndpoint.reportEvent);\n\n return {\n metro,\n server,\n middleware,\n messageSocket: messageSocketEndpoint,\n };\n}\n\n/**\n * Simplify and communicate if Metro is running without watching file updates,.\n * Exposed for testing.\n */\nexport function isWatchEnabled() {\n if (env.CI) {\n Log.log(\n chalk`Metro is running in CI mode, reloads are disabled. Remove {bold CI=true} to enable watch mode.`\n );\n }\n\n return !env.CI;\n}\n"],"names":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","gteSdkVersion","exp","sdkVersion","semver","gte","Error","projectRoot","options","getConfig","skipSDKVersionRequirement","isExporting","reportEvent","serverRoot","getMetroServerRoot","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","hasConfig","resolveConfig","config","loadConfig","cwd","isEmpty","getDefaultConfig","undefined","reporter","update","event","transformer","publicPath","experiments","baseUrl","platformBundlers","getPlatformBundlers","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","webOutput","web","output","isFastResolverEnabled","env","EXPO_USE_FAST_RESOLVER","NODE_ENV","logEventAsync","getMetroProperties","setEventReporter","logger","metroBundler","metroConfig","createDevServerMiddleware","securityHeadersMiddleware","require","middleware","messageSocketEndpoint","eventsSocketEndpoint","websocketEndpoints","port","server","watchFolders","replaceMiddlewareWith","createCorsMiddleware","prependMiddleware","suppressRemoteDebuggingErrorMiddleware","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","use","createDebuggerTelemetryMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","createJsInspectorMiddleware","metro","runServer","watch","req","res","next","url","URL","pathname","match","searchParams","get","processRequest","messageSocket","CI","Log","log","chalk"],"mappings":"AAAA;;;;QAmDsBA,oBAAoB,GAApBA,oBAAoB;QA8EpBC,qBAAqB,GAArBA,qBAAqB;QA8F3BC,cAAc,GAAdA,cAAc;AA/NQ,IAAA,OAAc,WAAd,cAAc,CAAA;AACN,IAAA,YAAoB,WAApB,oBAAoB,CAAA;AAChD,IAAA,MAAO,kCAAP,OAAO,EAAA;AAI0B,IAAA,aAAc,WAAd,cAAc,CAAA;AACxC,IAAA,UAAY,WAAZ,YAAY,CAAA;AAClB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAGa,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AACzB,IAAA,sBAAmC,WAAnC,mCAAmC,CAAA;AAC/C,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;AACA,IAAA,uBAA0B,WAA1B,0BAA0B,CAAA;AAElD,IAAA,IAAc,WAAd,cAAc,CAAA;AACC,IAAA,mBAA6C,WAA7C,6CAA6C,CAAA;AAC9B,IAAA,wBAAkD,WAAlD,kDAAkD,CAAA;AACtE,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AACtD,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACH,IAAA,eAA8B,WAA9B,8BAA8B,CAAA;AAChC,IAAA,mBAAkC,WAAlC,kCAAkC,CAAA;AACzB,IAAA,4BAAqD,WAArD,qDAAqD,CAAA;AACxC,IAAA,UAAyB,WAAzB,yBAAyB,CAAA;AAE3B,IAAA,wBAAuC,WAAvC,uCAAuC,CAAA;AAC1D,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;;;;;;AAOzD,SAASC,aAAa,CAACC,GAAmC,EAAEC,UAAkB,EAAW;IACvF,IAAI,CAACD,GAAG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AAI,EAAE;gBACvF,OAAOX,KAAK,CAACY,cAAc,CAACT,GAAG,EAAEC,GAAG,EAAEC,IAAI,CAAC,CAAC;aAC7C;SACF;QACD,OAAOA,IAAI,EAAE,CAAC;KACf,CAAC,CAAC;IAEHhC,gBAAgB,CAACS,oBAAoB,CAAC/C,WAAW,CAAC,CAAC;IAEnD,OAAO;QACLiE,KAAK;QACLf,MAAM,EAANA,OAAM;QACNL,UAAU;QACViC,aAAa,EAAEhC,qBAAqB;KACrC,CAAC;CACH;AAMM,SAAS1D,cAAc,GAAG;IAC/B,IAAI6C,IAAG,IAAA,CAAC8C,EAAE,EAAE;QACVC,IAAG,IAAA,CAACC,GAAG,CACLC,MAAK,QAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;KACH;IAED,OAAO,CAACjD,IAAG,IAAA,CAAC8C,EAAE,CAAC;CAChB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport { getDefaultConfig, LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport { Server as ConnectServer } from 'connect';\nimport http from 'http';\nimport type Metro from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\nimport semver from 'semver';\nimport { URL } from 'url';\n\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { MetroDevServerOptions } from '../../../export/fork-bundleAsync';\nimport { Log } from '../../../log';\nimport { getMetroProperties } from '../../../utils/analytics/getMetroProperties';\nimport { createDebuggerTelemetryMiddleware } from '../../../utils/analytics/metroDebuggerMiddleware';\nimport { env } from '../../../utils/env';\nimport { logEventAsync } from '../../../utils/telemetry';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { getMetroServerRoot } from '../middleware/ManifestMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware, replaceMiddlewareWith } from '../middleware/mutations';\nimport { ServerNext, ServerRequest, ServerResponse } from '../middleware/server.types';\nimport { suppressRemoteDebuggingErrorMiddleware } from '../middleware/suppressErrorMiddleware';\nimport { getPlatformBundlers } from '../platformBundlers';\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nfunction gteSdkVersion(exp: Pick<ExpoConfig, 'sdkVersion'>, sdkVersion: string): boolean {\n if (!exp.sdkVersion) {\n return false;\n }\n\n if (exp.sdkVersion === 'UNVERSIONED') {\n return true;\n }\n\n try {\n return semver.gte(exp.sdkVersion, sdkVersion);\n } catch {\n throw new Error(`${exp.sdkVersion} is not a valid version. Must be in the form of x.y.z`);\n }\n}\n\n// Wrap terminal and polyfill console.log so we can log during bundling without breaking the indicator.\nclass LogRespectingTerminal extends Terminal {\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream);\n\n const sendLog = (...args: any[]) => {\n // @ts-expect-error\n this._logLines.push(\n // format args like console.log\n util.format(...args)\n );\n // @ts-expect-error\n this._scheduleUpdate();\n\n // Flush the logs to the terminal immediately so logs at the end of the process are not lost.\n this.flush();\n };\n\n console.log = sendLog;\n console.info = sendLog;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp,\n isExporting,\n getMetroBundler,\n }: { exp?: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n const serverRoot = getMetroServerRoot(projectRoot);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const hasConfig = await resolveConfig(options.config, projectRoot);\n let config: ConfigT = {\n ...(await loadConfig(\n { cwd: projectRoot, projectRoot, ...options },\n // If the project does not have a metro.config.js, then we use the default config.\n hasConfig.isEmpty ? getDefaultConfig(projectRoot) : undefined\n )),\n reporter: {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n if (\n // Requires SDK 50 for expo-assets hashAssetPlugin change.\n !exp.sdkVersion ||\n gteSdkVersion(exp, '50.0.0')\n ) {\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n } else {\n if (isExporting && exp.experiments?.baseUrl) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = exp.experiments?.baseUrl;\n }\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n webOutput: exp.web?.output ?? 'single',\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n isExporting,\n isReactCanaryEnabled: exp.experiments?.reactCanary ?? false,\n getMetroBundler,\n });\n\n if (process.env.NODE_ENV !== 'test') {\n logEventAsync('metro config', getMetroProperties(projectRoot, exp, config));\n }\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<MetroDevServerOptions, 'logger'>,\n { isExporting }: { isExporting: boolean }\n): Promise<{\n metro: Metro.Server;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n // TODO: When we bring expo/metro-config into the expo/expo repo, then we can upstream this.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n });\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n {\n exp,\n isExporting,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n const { createDevServerMiddleware, securityHeadersMiddleware } =\n require('@react-native-community/cli-server-api') as typeof import('@react-native-community/cli-server-api');\n\n const { middleware, messageSocketEndpoint, eventsSocketEndpoint, websocketEndpoints } =\n createDevServerMiddleware({\n port: metroConfig.server.port,\n watchFolders: metroConfig.watchFolders,\n });\n\n // The `securityHeadersMiddleware` does not support cross-origin requests, we replace with the enhanced version.\n replaceMiddlewareWith(\n middleware as ConnectServer,\n securityHeadersMiddleware,\n createCorsMiddleware(exp)\n );\n\n prependMiddleware(middleware, suppressRemoteDebuggingErrorMiddleware);\n\n // TODO: We can probably drop this now.\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n middleware.use(createDebuggerTelemetryMiddleware(projectRoot, exp));\n\n // Initialize all React Native debug features\n const { debugMiddleware, debugWebsocketEndpoints } = createDebugMiddleware(metroBundler);\n prependMiddleware(middleware, debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware());\n\n const { server, metro } = await runServer(metroBundler, metroConfig, {\n // @ts-expect-error: Inconsistent `websocketEndpoints` type between metro and @react-native-community/cli-server-api\n websocketEndpoints: {\n ...websocketEndpoints,\n ...debugWebsocketEndpoints,\n },\n watch: !isExporting && isWatchEnabled(),\n });\n\n prependMiddleware(middleware, (req: ServerRequest, res: ServerResponse, next: ServerNext) => {\n // If the URL is a Metro asset request, then we need to skip all other middleware to prevent\n // the community CLI's serve-static from hosting `/assets/index.html` in place of all assets if it exists.\n // /assets/?unstable_path=.\n if (req.url) {\n const url = new URL(req.url!, 'http://localhost:8000');\n if (url.pathname.match(/^\\/assets\\/?/) && url.searchParams.get('unstable_path') != null) {\n return metro.processRequest(req, res, next);\n }\n }\n return next();\n });\n\n setEventReporter(eventsSocketEndpoint.reportEvent);\n\n return {\n metro,\n server,\n middleware,\n messageSocket: messageSocketEndpoint,\n };\n}\n\n/**\n * Simplify and communicate if Metro is running without watching file updates,.\n * Exposed for testing.\n */\nexport function isWatchEnabled() {\n if (env.CI) {\n Log.log(\n chalk`Metro is running in CI mode, reloads are disabled. Remove {bold CI=true} to enable watch mode.`\n );\n }\n\n return !env.CI;\n}\n"],"names":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","gteSdkVersion","exp","sdkVersion","semver","gte","Error","LogRespectingTerminal","Terminal","constructor","stream","sendLog","args","_logLines","push","util","format","_scheduleUpdate","flush","console","log","info","terminal","process","stdout","projectRoot","options","getConfig","skipSDKVersionRequirement","isExporting","getMetroBundler","reportEvent","serverRoot","getMetroServerRoot","terminalReporter","MetroTerminalReporter","hasConfig","resolveConfig","config","loadConfig","cwd","isEmpty","getDefaultConfig","undefined","reporter","update","event","transformer","publicPath","experiments","baseUrl","platformBundlers","getPlatformBundlers","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","webOutput","web","output","isFastResolverEnabled","env","EXPO_USE_FAST_RESOLVER","isReactCanaryEnabled","reactCanary","NODE_ENV","logEventAsync","getMetroProperties","setEventReporter","logger","metroBundler","metroConfig","metro","getBundler","createDevServerMiddleware","securityHeadersMiddleware","require","middleware","messageSocketEndpoint","eventsSocketEndpoint","websocketEndpoints","port","server","watchFolders","replaceMiddlewareWith","createCorsMiddleware","prependMiddleware","suppressRemoteDebuggingErrorMiddleware","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","use","createDebuggerTelemetryMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","createJsInspectorMiddleware","runServer","watch","req","res","next","url","URL","pathname","match","searchParams","get","processRequest","messageSocket","CI","Log","chalk"],"mappings":"AAAA;;;;QA8EsBA,oBAAoB,GAApBA,oBAAoB;QA+EpBC,qBAAqB,GAArBA,qBAAqB;QAoG3BC,cAAc,GAAdA,cAAc;SAjQQ,OAAc;yBAAd,cAAc;IAAd,OAAc;;;;;SACN,YAAoB;yBAApB,oBAAoB;IAApB,YAAoB;;;;;SAChD,MAAO;gDAAP,OAAO;IAAP,MAAO;;;;;SAK0B,aAAc;yBAAd,cAAc;IAAd,aAAc;;;;;AACxC,IAAA,UAAY,WAAZ,YAAY,CAAA;SACpB,SAAW;gDAAX,WAAW;IAAX,SAAW;;;;;SACT,OAAQ;gDAAR,QAAQ;IAAR,OAAQ;;;;;SACP,IAAK;yBAAL,KAAK;IAAL,IAAK;;;;;AAGa,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AACzB,IAAA,sBAAmC,WAAnC,mCAAmC,CAAA;AAC/C,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;AACA,IAAA,uBAA0B,WAA1B,0BAA0B,CAAA;AAElD,IAAA,IAAc,WAAd,cAAc,CAAA;AACC,IAAA,mBAA6C,WAA7C,6CAA6C,CAAA;AAC9B,IAAA,wBAAkD,WAAlD,kDAAkD,CAAA;AAChF,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACV,IAAA,UAA0B,WAA1B,0BAA0B,CAAA;AACnB,IAAA,eAA8B,WAA9B,8BAA8B,CAAA;AAChC,IAAA,mBAAkC,WAAlC,kCAAkC,CAAA;AACzB,IAAA,4BAAqD,WAArD,qDAAqD,CAAA;AACxC,IAAA,UAAyB,WAAzB,yBAAyB,CAAA;AAE3B,IAAA,wBAAuC,WAAvC,uCAAuC,CAAA;A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D,IAAG,IAAA,CAACiD,EAAE,EAAE;QACVC,IAAG,IAAA,CAAC1F,GAAG,CACL2F,MAAK,UAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;KACH;IAED,OAAO,CAACnD,IAAG,IAAA,CAACiD,EAAE,CAAC;CAChB"}
|
|
@@ -6,9 +6,27 @@ exports.logMetroErrorWithStack = logMetroErrorWithStack;
|
|
|
6
6
|
exports.logMetroError = logMetroError;
|
|
7
7
|
exports.logMetroErrorAsync = logMetroErrorAsync;
|
|
8
8
|
exports.getErrorOverlayHtmlAsync = getErrorOverlayHtmlAsync;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function _chalk() {
|
|
10
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
11
|
+
_chalk = function() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function _resolveFrom() {
|
|
17
|
+
const data = _interopRequireDefault(require("resolve-from"));
|
|
18
|
+
_resolveFrom = function() {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
function _terminalLink() {
|
|
24
|
+
const data = _interopRequireDefault(require("terminal-link"));
|
|
25
|
+
_terminalLink = function() {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
12
30
|
var _log = require("../../../log");
|
|
13
31
|
var _errors = require("../../../utils/errors");
|
|
14
32
|
var _getStaticRenderFunctions = require("../getStaticRenderFunctions");
|
|
@@ -21,8 +39,8 @@ function fill(width) {
|
|
|
21
39
|
return Array(width).join(" ");
|
|
22
40
|
}
|
|
23
41
|
function formatPaths(config) {
|
|
24
|
-
const filePath = _chalk.default.reset(config.filePath);
|
|
25
|
-
return _chalk.default.dim("(") + filePath + _chalk.default.dim(`:${[
|
|
42
|
+
const filePath = _chalk().default.reset(config.filePath);
|
|
43
|
+
return _chalk().default.dim("(") + filePath + _chalk().default.dim(`:${[
|
|
26
44
|
config.line,
|
|
27
45
|
config.col
|
|
28
46
|
].filter(Boolean).join(":")})`);
|
|
@@ -33,9 +51,9 @@ async function logMetroErrorWithStack(projectRoot, { stack , codeFrame , error
|
|
|
33
51
|
}
|
|
34
52
|
// process.stdout.write('\u001b[0m'); // Reset attributes
|
|
35
53
|
// process.stdout.write('\u001bc'); // Reset the terminal
|
|
36
|
-
const { getStackFormattedLocation } = require((
|
|
54
|
+
const { getStackFormattedLocation } = require(_resolveFrom().default(projectRoot, "@expo/metro-runtime/symbolicate"));
|
|
37
55
|
_log.Log.log();
|
|
38
|
-
_log.Log.log(_chalk.default.red("Metro error: ") + error.message);
|
|
56
|
+
_log.Log.log(_chalk().default.red("Metro error: ") + error.message);
|
|
39
57
|
_log.Log.log();
|
|
40
58
|
if (codeFrame) {
|
|
41
59
|
var ref;
|
|
@@ -70,19 +88,19 @@ async function logMetroErrorWithStack(projectRoot, { stack , codeFrame , error
|
|
|
70
88
|
if (minBounds > 0) {
|
|
71
89
|
// Adjust the min bounds so the cursor is aligned after we add the "..."
|
|
72
90
|
minBounds -= 3;
|
|
73
|
-
previewLine = _chalk.default.dim("...") + previewLine;
|
|
91
|
+
previewLine = _chalk().default.dim("...") + previewLine;
|
|
74
92
|
}
|
|
75
93
|
if (maxBounds < lineText.length) {
|
|
76
|
-
previewLine += _chalk.default.dim("...");
|
|
94
|
+
previewLine += _chalk().default.dim("...");
|
|
77
95
|
}
|
|
78
96
|
// If the column property could be found, then use that to fix the cursor location which is often broken in regex.
|
|
79
|
-
cursorLine = (column == null ? "" : fill(column) + _chalk.default.reset("^")).slice(minBounds);
|
|
97
|
+
cursorLine = (column == null ? "" : fill(column) + _chalk().default.reset("^")).slice(minBounds);
|
|
80
98
|
_log.Log.log([
|
|
81
99
|
formattedPath,
|
|
82
100
|
"",
|
|
83
101
|
previewLine,
|
|
84
102
|
cursorLine,
|
|
85
|
-
_chalk.default.dim("(error truncated)")
|
|
103
|
+
_chalk().default.dim("(error truncated)")
|
|
86
104
|
].join("\n"));
|
|
87
105
|
}
|
|
88
106
|
} else {
|
|
@@ -91,7 +109,7 @@ async function logMetroErrorWithStack(projectRoot, { stack , codeFrame , error
|
|
|
91
109
|
}
|
|
92
110
|
if (stack == null ? void 0 : stack.length) {
|
|
93
111
|
_log.Log.log();
|
|
94
|
-
_log.Log.log(_chalk.default.bold`Call Stack`);
|
|
112
|
+
_log.Log.log(_chalk().default.bold`Call Stack`);
|
|
95
113
|
const stackProps = stack.map((frame)=>{
|
|
96
114
|
return {
|
|
97
115
|
title: frame.methodName,
|
|
@@ -100,15 +118,15 @@ async function logMetroErrorWithStack(projectRoot, { stack , codeFrame , error
|
|
|
100
118
|
};
|
|
101
119
|
});
|
|
102
120
|
stackProps.forEach((frame)=>{
|
|
103
|
-
const position = _terminalLink.default.isSupported ? (
|
|
104
|
-
let lineItem = _chalk.default.gray(` ${frame.title} (${position})`);
|
|
121
|
+
const position = _terminalLink().default.isSupported ? _terminalLink().default(frame.subtitle, frame.subtitle) : frame.subtitle;
|
|
122
|
+
let lineItem = _chalk().default.gray(` ${frame.title} (${position})`);
|
|
105
123
|
if (frame.collapse) {
|
|
106
|
-
lineItem = _chalk.default.dim(lineItem);
|
|
124
|
+
lineItem = _chalk().default.dim(lineItem);
|
|
107
125
|
}
|
|
108
126
|
_log.Log.log(lineItem);
|
|
109
127
|
});
|
|
110
128
|
} else {
|
|
111
|
-
_log.Log.log(_chalk.default.gray(` ${error.stack}`));
|
|
129
|
+
_log.Log.log(_chalk().default.gray(` ${error.stack}`));
|
|
112
130
|
}
|
|
113
131
|
}
|
|
114
132
|
async function logMetroError(projectRoot, { error }) {
|
|
@@ -116,7 +134,7 @@ async function logMetroError(projectRoot, { error }) {
|
|
|
116
134
|
if (error instanceof _errors.SilentError) {
|
|
117
135
|
return;
|
|
118
136
|
}
|
|
119
|
-
const { LogBoxLog , parseErrorStack } = require((
|
|
137
|
+
const { LogBoxLog , parseErrorStack } = require(_resolveFrom().default(projectRoot, "@expo/metro-runtime/symbolicate"));
|
|
120
138
|
const stack = parseErrorStack(error.stack);
|
|
121
139
|
const log = new LogBoxLog({
|
|
122
140
|
level: "static",
|
|
@@ -139,7 +157,7 @@ async function logMetroError(projectRoot, { error }) {
|
|
|
139
157
|
});
|
|
140
158
|
}
|
|
141
159
|
/** @returns the html required to render the static metro error as an SPA. */ function logFromError({ error , projectRoot }) {
|
|
142
|
-
const { LogBoxLog , parseErrorStack } = require((
|
|
160
|
+
const { LogBoxLog , parseErrorStack } = require(_resolveFrom().default(projectRoot, "@expo/metro-runtime/symbolicate"));
|
|
143
161
|
const stack = parseErrorStack(error.stack);
|
|
144
162
|
return new LogBoxLog({
|
|
145
163
|
level: "static",
|
|
@@ -191,12 +209,13 @@ async function getErrorOverlayHtmlAsync({ error , projectRoot , routerRoot }) {
|
|
|
191
209
|
};
|
|
192
210
|
const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id="root"></div><script id="_expo-static-error" type="application/json">${JSON.stringify(logBoxContext)}</script></body></html>`;
|
|
193
211
|
const errorOverlayEntry = await (0, _getStaticRenderFunctions).createMetroEndpointAsync(projectRoot, // Keep the URL relative
|
|
194
|
-
"", (
|
|
195
|
-
|
|
212
|
+
"", _resolveFrom().default(projectRoot, "expo-router/_error"), {
|
|
213
|
+
mode: "development",
|
|
196
214
|
platform: "web",
|
|
197
215
|
minify: false,
|
|
198
216
|
baseUrl: "",
|
|
199
|
-
routerRoot
|
|
217
|
+
routerRoot,
|
|
218
|
+
isExporting: false
|
|
200
219
|
});
|
|
201
220
|
const htmlWithJs = html.replace("</body>", `<script src=${errorOverlayEntry}></script></body>`);
|
|
202
221
|
return htmlWithJs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/metroErrorInterface.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 chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\nimport { StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { Log } from '../../../log';\nimport { SilentError } from '../../../utils/errors';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n\ntype CodeFrame = {\n content: string;\n location?: {\n row: number;\n column: number;\n [key: string]: any;\n };\n fileName: string;\n};\n\ntype MetroStackFrame = StackFrame & { collapse?: boolean };\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame: CodeFrame;\n error: Error;\n }\n) {\n if (error instanceof SilentError) {\n return;\n }\n\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n const { getStackFormattedLocation } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (codeFrame) {\n const maxWarningLineLength = Math.max(200, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const isPreviewTooLong = codeFrame.content\n .split('\\n')\n .some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n Log.log(\n [formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)')].join('\\n')\n );\n }\n } else {\n Log.log(codeFrame.content);\n }\n }\n\n if (stack?.length) {\n Log.log();\n Log.log(chalk.bold`Call Stack`);\n\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse,\n };\n });\n\n stackProps.forEach((frame) => {\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n Log.log(lineItem);\n });\n } else {\n Log.log(chalk.gray(` ${error.stack}`));\n }\n}\n\nexport async function logMetroError(projectRoot: string, { error }: { error: Error }) {\n if (error instanceof SilentError) {\n return;\n }\n\n const { LogBoxLog, parseErrorStack } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n const stack = parseErrorStack(error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nfunction logFromError({ error, projectRoot }: { error: Error; projectRoot: string }): {\n symbolicated: any;\n symbolicate: (type: string, callback: () => void) => void;\n codeFrame: CodeFrame;\n} {\n const { LogBoxLog, parseErrorStack } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n const stack = parseErrorStack(error.stack);\n\n return new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n routerRoot,\n}: {\n error: Error;\n projectRoot: string;\n routerRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n dev: true,\n platform: 'web',\n minify: false,\n baseUrl: '',\n routerRoot,\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n"],"names":["logMetroErrorWithStack","logMetroError","logMetroErrorAsync","getErrorOverlayHtmlAsync","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","SilentError","getStackFormattedLocation","require","resolveFrom","Log","log","red","message","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","isPreviewTooLong","split","some","length","column","location","previewLine","cursorLine","formattedPath","fileName","row","rangeWindow","round","minBounds","maxBounds","min","slice","bold","stackProps","map","frame","title","methodName","subtitle","collapse","forEach","position","terminalLink","isSupported","lineItem","gray","LogBoxLog","parseErrorStack","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","logFromError","routerRoot","logBoxContext","selectedLogIndex","isDisabled","logs","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","dev","platform","minify","baseUrl","htmlWithJs","replace"],"mappings":"AAMA;;;;QAkCsBA,sBAAsB,GAAtBA,sBAAsB;QA2GtBC,aAAa,GAAbA,aAAa;QA0DbC,kBAAkB,GAAlBA,kBAAkB;QAmBlBC,wBAAwB,GAAxBA,wBAAwB;AA1N5B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACD,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEb,IAAA,aAAe,kCAAf,eAAe,EAAA;AAEpB,IAAA,IAAc,WAAd,cAAc,CAAA;AACN,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACV,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;;;;;;AActE,SAASC,IAAI,CAACC,KAAa,EAAU;IACnC,OAAOC,KAAK,CAACD,KAAK,CAAC,CAACE,IAAI,CAAC,GAAG,CAAC,CAAC;CAC/B;AAED,SAASC,WAAW,CAACC,MAAgE,EAAE;IACrF,MAAMC,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,"sources":["../../../../../src/start/server/metro/metroErrorInterface.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 chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\nimport { StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { Log } from '../../../log';\nimport { SilentError } from '../../../utils/errors';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n\ntype CodeFrame = {\n content: string;\n location?: {\n row: number;\n column: number;\n [key: string]: any;\n };\n fileName: string;\n};\n\ntype MetroStackFrame = StackFrame & { collapse?: boolean };\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame: CodeFrame;\n error: Error;\n }\n) {\n if (error instanceof SilentError) {\n return;\n }\n\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n const { getStackFormattedLocation } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (codeFrame) {\n const maxWarningLineLength = Math.max(200, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const isPreviewTooLong = codeFrame.content\n .split('\\n')\n .some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n Log.log(\n [formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)')].join('\\n')\n );\n }\n } else {\n Log.log(codeFrame.content);\n }\n }\n\n if (stack?.length) {\n Log.log();\n Log.log(chalk.bold`Call Stack`);\n\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse,\n };\n });\n\n stackProps.forEach((frame) => {\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n Log.log(lineItem);\n });\n } else {\n Log.log(chalk.gray(` ${error.stack}`));\n }\n}\n\nexport async function logMetroError(projectRoot: string, { error }: { error: Error }) {\n if (error instanceof SilentError) {\n return;\n }\n\n const { LogBoxLog, parseErrorStack } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n const stack = parseErrorStack(error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nfunction logFromError({ error, projectRoot }: { error: Error; projectRoot: string }): {\n symbolicated: any;\n symbolicate: (type: string, callback: () => void) => void;\n codeFrame: CodeFrame;\n} {\n const { LogBoxLog, parseErrorStack } = require(\n resolveFrom(projectRoot, '@expo/metro-runtime/symbolicate')\n );\n\n const stack = parseErrorStack(error.stack);\n\n return new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n routerRoot,\n}: {\n error: Error;\n projectRoot: string;\n routerRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n mode: 'development',\n platform: 'web',\n minify: false,\n baseUrl: '',\n routerRoot,\n isExporting: false,\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n"],"names":["logMetroErrorWithStack","logMetroError","logMetroErrorAsync","getErrorOverlayHtmlAsync","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","SilentError","getStackFormattedLocation","require","resolveFrom","Log","log","red","message","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","isPreviewTooLong","split","some","length","column","location","previewLine","cursorLine","formattedPath","fileName","row","rangeWindow","round","minBounds","maxBounds","min","slice","bold","stackProps","map","frame","title","methodName","subtitle","collapse","forEach","position","terminalLink","isSupported","lineItem","gray","LogBoxLog","parseErrorStack","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","logFromError","routerRoot","logBoxContext","selectedLogIndex","isDisabled","logs","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","mode","platform","minify","baseUrl","isExporting","htmlWithJs","replace"],"mappings":"AAMA;;;;QAkCsBA,sBAAsB,GAAtBA,sBAAsB;QA2GtBC,aAAa,GAAbA,aAAa;QA0DbC,kBAAkB,GAAlBA,kBAAkB;QAmBlBC,wBAAwB,GAAxBA,wBAAwB;SA1N5B,MAAO;gDAAP,OAAO;IAAP,MAAO;;;;;SACD,YAAc;gDAAd,cAAc;IAAd,YAAc;;;;;SAEb,aAAe;gDAAf,eAAe;IAAf,aAAe;;;;;AAEpB,IAAA,IAAc,WAAd,cAAc,CAAA;AACN,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACV,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;;;;;;AActE,SAASC,IA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AAC;CACnB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.getMetroBundlerWithVirtualModules = getMetroBundlerWithVirtualModules;
|
|
6
|
+
function assertBundlerHasPrivateMembers(bundler) {
|
|
7
|
+
if (!("_depGraph" in bundler)) {
|
|
8
|
+
throw new Error("Expected bundler to have member: _depGraph. Upstream metro may have removed this property.");
|
|
9
|
+
}
|
|
10
|
+
assertDepGraphHasPrivateMembers(bundler._depGraph);
|
|
11
|
+
}
|
|
12
|
+
function assertDepGraphHasPrivateMembers(depGraph) {
|
|
13
|
+
if (!depGraph || typeof depGraph !== "object" || !("_fileSystem" in depGraph)) {
|
|
14
|
+
throw new Error("Expected bundler._depGraph to have member: _fileSystem. Upstream metro may have removed this property.");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function ensureMetroBundlerPatchedWithSetVirtualModule(bundler) {
|
|
18
|
+
if (!bundler.setVirtualModule) {
|
|
19
|
+
bundler.setVirtualModule = function(id, contents) {
|
|
20
|
+
assertBundlerHasPrivateMembers(this);
|
|
21
|
+
const fs = ensureFileSystemPatched(this._depGraph._fileSystem);
|
|
22
|
+
fs.expoVirtualModules.set(ensureStartsWithNullByte(id), Buffer.from(contents));
|
|
23
|
+
};
|
|
24
|
+
bundler.hasVirtualModule = function(id) {
|
|
25
|
+
assertBundlerHasPrivateMembers(this);
|
|
26
|
+
const fs = ensureFileSystemPatched(this._depGraph._fileSystem);
|
|
27
|
+
return fs.expoVirtualModules.has(ensureStartsWithNullByte(id));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return bundler;
|
|
31
|
+
}
|
|
32
|
+
function ensureStartsWithNullByte(id) {
|
|
33
|
+
// Because you'll likely need to return the path somewhere, we should just assert with a useful error message instead of
|
|
34
|
+
// attempting to mutate the value behind the scenes. This ensures correctness in the resolution.
|
|
35
|
+
if (!id.startsWith("\0")) {
|
|
36
|
+
throw new Error(`Virtual modules in Expo CLI must start with with null byte (\\0), got: ${id}`);
|
|
37
|
+
}
|
|
38
|
+
return id;
|
|
39
|
+
}
|
|
40
|
+
function getMetroBundlerWithVirtualModules(bundler) {
|
|
41
|
+
if (!bundler.transformFile.__patched) {
|
|
42
|
+
const originalTransformFile = bundler.transformFile.bind(bundler);
|
|
43
|
+
bundler.transformFile = async function(filePath, transformOptions, /** Optionally provide the file contents, this can be used to provide virtual contents for a file. */ fileBuffer) {
|
|
44
|
+
// file buffer will be defined for virtual modules in Metro, e.g. context modules.
|
|
45
|
+
if (!fileBuffer) {
|
|
46
|
+
if (filePath.startsWith("\0")) {
|
|
47
|
+
const graph = await this.getDependencyGraph();
|
|
48
|
+
assertDepGraphHasPrivateMembers(graph);
|
|
49
|
+
if (graph._fileSystem.expoVirtualModules) {
|
|
50
|
+
fileBuffer = graph._fileSystem.expoVirtualModules.get(filePath);
|
|
51
|
+
}
|
|
52
|
+
if (!fileBuffer) {
|
|
53
|
+
throw new Error(`Virtual module "${filePath}" not found.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return originalTransformFile(filePath, transformOptions, fileBuffer);
|
|
58
|
+
};
|
|
59
|
+
bundler.transformFile.__patched = true;
|
|
60
|
+
}
|
|
61
|
+
return ensureMetroBundlerPatchedWithSetVirtualModule(bundler);
|
|
62
|
+
}
|
|
63
|
+
function ensureFileSystemPatched(fs) {
|
|
64
|
+
if (!fs.getSha1.__patched) {
|
|
65
|
+
const original_getSha1 = fs.getSha1.bind(fs);
|
|
66
|
+
fs.getSha1 = (filename)=>{
|
|
67
|
+
// Rollup virtual module format.
|
|
68
|
+
if (filename.startsWith("\0")) {
|
|
69
|
+
return filename;
|
|
70
|
+
}
|
|
71
|
+
return original_getSha1(filename);
|
|
72
|
+
};
|
|
73
|
+
fs.getSha1.__patched = true;
|
|
74
|
+
}
|
|
75
|
+
// TODO: Connect virtual modules to a specific context so they don't cross-bundles.
|
|
76
|
+
if (!fs.expoVirtualModules) {
|
|
77
|
+
fs.expoVirtualModules = new Map();
|
|
78
|
+
}
|
|
79
|
+
return fs;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=metroVirtualModules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/metroVirtualModules.ts"],"sourcesContent":["/**\n * Copyright © 2024 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 Bundler from 'metro/src/Bundler';\nimport DependencyGraph from 'metro/src/node-haste/DependencyGraph';\nimport { FileSystem } from 'metro-file-map';\n\ntype ExpoPatchedFileSystem = Omit<FileSystem, 'getSha1'> & {\n getSha1: FileSystem['getSha1'] & { __patched?: boolean };\n expoVirtualModules?: Map<string, Buffer>;\n};\n\ntype ActualDependencyGraph = DependencyGraph & {\n _fileSystem: ExpoPatchedFileSystem;\n};\n\ntype ActualBundler = Bundler & {\n _depGraph: ActualDependencyGraph;\n};\n\ntype ExpoPatchedBundler = Bundler & {\n setVirtualModule: (id: string, contents: string) => void;\n hasVirtualModule: (id: string) => boolean;\n};\n\nfunction assertBundlerHasPrivateMembers(bundler: Bundler): asserts bundler is ActualBundler {\n if (!('_depGraph' in bundler)) {\n throw new Error(\n 'Expected bundler to have member: _depGraph. Upstream metro may have removed this property.'\n );\n }\n\n assertDepGraphHasPrivateMembers(bundler._depGraph);\n}\n\nfunction assertDepGraphHasPrivateMembers(\n depGraph: unknown\n): asserts depGraph is ActualDependencyGraph {\n if (!depGraph || typeof depGraph !== 'object' || !('_fileSystem' in depGraph)) {\n throw new Error(\n 'Expected bundler._depGraph to have member: _fileSystem. Upstream metro may have removed this property.'\n );\n }\n}\n\nfunction ensureMetroBundlerPatchedWithSetVirtualModule(\n bundler: Bundler & {\n setVirtualModule?: (id: string, contents: string) => void;\n hasVirtualModule?: (id: string) => boolean;\n }\n): ExpoPatchedBundler {\n if (!bundler.setVirtualModule) {\n bundler.setVirtualModule = function (this: Bundler, id: string, contents: string) {\n assertBundlerHasPrivateMembers(this);\n const fs = ensureFileSystemPatched(this._depGraph._fileSystem);\n fs.expoVirtualModules!.set(ensureStartsWithNullByte(id), Buffer.from(contents));\n };\n bundler.hasVirtualModule = function (this: Bundler, id: string) {\n assertBundlerHasPrivateMembers(this);\n const fs = ensureFileSystemPatched(this._depGraph._fileSystem);\n return fs.expoVirtualModules!.has(ensureStartsWithNullByte(id));\n };\n }\n\n return bundler as ExpoPatchedBundler;\n}\n\nfunction ensureStartsWithNullByte(id: string): string {\n // Because you'll likely need to return the path somewhere, we should just assert with a useful error message instead of\n // attempting to mutate the value behind the scenes. This ensures correctness in the resolution.\n if (!id.startsWith('\\0')) {\n throw new Error(`Virtual modules in Expo CLI must start with with null byte (\\\\0), got: ${id}`);\n }\n return id;\n}\n\nexport function getMetroBundlerWithVirtualModules(\n bundler: Bundler & {\n transformFile: Bundler['transformFile'] & { __patched?: boolean };\n }\n): ExpoPatchedBundler {\n if (!bundler.transformFile.__patched) {\n const originalTransformFile = bundler.transformFile.bind(bundler);\n\n bundler.transformFile = async function (\n filePath: string,\n transformOptions: any,\n /** Optionally provide the file contents, this can be used to provide virtual contents for a file. */\n fileBuffer?: Buffer\n ) {\n // file buffer will be defined for virtual modules in Metro, e.g. context modules.\n if (!fileBuffer) {\n if (filePath.startsWith('\\0')) {\n const graph = await this.getDependencyGraph();\n\n assertDepGraphHasPrivateMembers(graph);\n\n if (graph._fileSystem.expoVirtualModules) {\n fileBuffer = graph._fileSystem.expoVirtualModules.get(filePath);\n }\n\n if (!fileBuffer) {\n throw new Error(`Virtual module \"${filePath}\" not found.`);\n }\n }\n }\n return originalTransformFile(filePath, transformOptions, fileBuffer);\n };\n\n bundler.transformFile.__patched = true;\n }\n\n return ensureMetroBundlerPatchedWithSetVirtualModule(bundler);\n}\n\nfunction ensureFileSystemPatched(fs: ExpoPatchedFileSystem): ExpoPatchedFileSystem {\n if (!fs.getSha1.__patched) {\n const original_getSha1 = fs.getSha1.bind(fs);\n fs.getSha1 = (filename: string) => {\n // Rollup virtual module format.\n if (filename.startsWith('\\0')) {\n return filename;\n }\n\n return original_getSha1(filename);\n };\n fs.getSha1.__patched = true;\n }\n\n // TODO: Connect virtual modules to a specific context so they don't cross-bundles.\n if (!fs.expoVirtualModules) {\n fs.expoVirtualModules = new Map<string, Buffer>();\n }\n\n return fs;\n}\n"],"names":["getMetroBundlerWithVirtualModules","assertBundlerHasPrivateMembers","bundler","Error","assertDepGraphHasPrivateMembers","_depGraph","depGraph","ensureMetroBundlerPatchedWithSetVirtualModule","setVirtualModule","id","contents","fs","ensureFileSystemPatched","_fileSystem","expoVirtualModules","set","ensureStartsWithNullByte","Buffer","from","hasVirtualModule","has","startsWith","transformFile","__patched","originalTransformFile","bind","filePath","transformOptions","fileBuffer","graph","getDependencyGraph","get","getSha1","original_getSha1","filename","Map"],"mappings":"AAMA;;;;QAyEgBA,iCAAiC,GAAjCA,iCAAiC;AAnDjD,SAASC,8BAA8B,CAACC,OAAgB,EAAoC;IAC1F,IAAI,CAAC,CAAC,WAAW,IAAIA,OAAO,CAAC,EAAE;QAC7B,MAAM,IAAIC,KAAK,CACb,4FAA4F,CAC7F,CAAC;KACH;IAEDC,+BAA+B,CAACF,OAAO,CAACG,SAAS,CAAC,CAAC;CACpD;AAED,SAASD,+BAA+B,CACtCE,QAAiB,EAC0B;IAC3C,IAAI,CAACA,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,aAAa,IAAIA,QAAQ,CAAC,EAAE;QAC7E,MAAM,IAAIH,KAAK,CACb,wGAAwG,CACzG,CAAC;KACH;CACF;AAED,SAASI,6CAA6C,CACpDL,OAGC,EACmB;IACpB,IAAI,CAACA,OAAO,CAACM,gBAAgB,EAAE;QAC7BN,OAAO,CAACM,gBAAgB,GAAG,SAAyBC,EAAU,EAAEC,QAAgB,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-3,7 +3,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.metroWatchTypeScriptFiles = metroWatchTypeScriptFiles;
|
|
6
|
-
|
|
6
|
+
function _path() {
|
|
7
|
+
const data = _interopRequireDefault(require("path"));
|
|
8
|
+
_path = function() {
|
|
9
|
+
return data;
|
|
10
|
+
};
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
7
13
|
function _interopRequireDefault(obj) {
|
|
8
14
|
return obj && obj.__esModule ? obj : {
|
|
9
15
|
default: obj
|
|
@@ -16,7 +22,7 @@ function metroWatchTypeScriptFiles({ metro , server , projectRoot , callback , t
|
|
|
16
22
|
"delete"
|
|
17
23
|
] }) {
|
|
18
24
|
const watcher = metro.getBundler().getBundler().getWatcher();
|
|
19
|
-
const tsconfigPath = _path.default.join(projectRoot, "tsconfig.json");
|
|
25
|
+
const tsconfigPath = _path().default.join(projectRoot, "tsconfig.json");
|
|
20
26
|
const listener = ({ eventsQueue })=>{
|
|
21
27
|
for (const event of eventsQueue){
|
|
22
28
|
var ref;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/metroWatchTypeScriptFiles.ts"],"sourcesContent":["import path from 'path';\n\nimport type { ServerLike } from '../BundlerDevServer';\n\nconst debug = require('debug')(\n 'expo:start:server:metro:metroWatchTypeScriptFiles'\n) as typeof console.log;\n\nexport interface MetroWatchTypeScriptFilesOptions {\n projectRoot: string;\n metro: import('metro').Server;\n server: ServerLike;\n /* Include tsconfig.json in the watcher */\n tsconfig?: boolean;\n callback: (event: WatchEvent) => void;\n /* Array of eventTypes to watch. Defaults to all events */\n eventTypes?: string[];\n /* Throlle the callback. When true and a group of events are recieved, callback it will only be called with the\n * first event */\n throttle?: boolean;\n}\n\ninterface WatchEvent {\n filePath: string;\n metadata?: {\n type: 'f' | 'd' | 'l'; // Regular file / Directory / Symlink\n } | null;\n type: string;\n}\n\n/**\n * Use the native file watcher / Metro ruleset to detect if a\n * TypeScript file is added to the project during development.\n */\nexport function metroWatchTypeScriptFiles({\n metro,\n server,\n projectRoot,\n callback,\n tsconfig = false,\n throttle = false,\n eventTypes = ['add', 'change', 'delete'],\n}: MetroWatchTypeScriptFilesOptions): () => void {\n const watcher = metro.getBundler().getBundler().getWatcher();\n\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n\n const listener = ({ eventsQueue }: { eventsQueue: WatchEvent[] }) => {\n for (const event of eventsQueue) {\n if (\n eventTypes.includes(event.type) &&\n event.metadata?.type !== 'd' &&\n // We need to ignore node_modules because Metro will add all of the files in node_modules to the watcher.\n !/node_modules/.test(event.filePath) &&\n // Ignore declaration files\n !/\\.d\\.ts$/.test(event.filePath)\n ) {\n const { filePath } = event;\n // Is TypeScript?\n if (\n // If the user adds a TypeScript file to the observable files in their project.\n /\\.tsx?$/.test(filePath) ||\n // Or if the user adds a tsconfig.json file to the project root.\n (tsconfig && filePath === tsconfigPath)\n ) {\n debug('Detected TypeScript file changed in the project: ', filePath);\n callback(event);\n\n if (throttle) {\n return;\n }\n }\n }\n }\n };\n\n debug('Waiting for TypeScript files to be added to the project...');\n watcher.addListener('change', listener);\n watcher.addListener('add', listener);\n\n const off = () => {\n watcher.removeListener('change', listener);\n watcher.removeListener('add', listener);\n };\n\n server.addListener?.('close', off);\n return off;\n}\n"],"names":["metroWatchTypeScriptFiles","debug","require","metro","server","projectRoot","callback","tsconfig","throttle","eventTypes","watcher","getBundler","getWatcher","tsconfigPath","path","join","listener","eventsQueue","event","includes","type","metadata","test","filePath","addListener","off","removeListener"],"mappings":"AAAA;;;;QAkCgBA,yBAAyB,GAAzBA,yBAAyB;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/metroWatchTypeScriptFiles.ts"],"sourcesContent":["import path from 'path';\n\nimport type { ServerLike } from '../BundlerDevServer';\n\nconst debug = require('debug')(\n 'expo:start:server:metro:metroWatchTypeScriptFiles'\n) as typeof console.log;\n\nexport interface MetroWatchTypeScriptFilesOptions {\n projectRoot: string;\n metro: import('metro').Server;\n server: ServerLike;\n /* Include tsconfig.json in the watcher */\n tsconfig?: boolean;\n callback: (event: WatchEvent) => void;\n /* Array of eventTypes to watch. Defaults to all events */\n eventTypes?: string[];\n /* Throlle the callback. When true and a group of events are recieved, callback it will only be called with the\n * first event */\n throttle?: boolean;\n}\n\ninterface WatchEvent {\n filePath: string;\n metadata?: {\n type: 'f' | 'd' | 'l'; // Regular file / Directory / Symlink\n } | null;\n type: string;\n}\n\n/**\n * Use the native file watcher / Metro ruleset to detect if a\n * TypeScript file is added to the project during development.\n */\nexport function metroWatchTypeScriptFiles({\n metro,\n server,\n projectRoot,\n callback,\n tsconfig = false,\n throttle = false,\n eventTypes = ['add', 'change', 'delete'],\n}: MetroWatchTypeScriptFilesOptions): () => void {\n const watcher = metro.getBundler().getBundler().getWatcher();\n\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n\n const listener = ({ eventsQueue }: { eventsQueue: WatchEvent[] }) => {\n for (const event of eventsQueue) {\n if (\n eventTypes.includes(event.type) &&\n event.metadata?.type !== 'd' &&\n // We need to ignore node_modules because Metro will add all of the files in node_modules to the watcher.\n !/node_modules/.test(event.filePath) &&\n // Ignore declaration files\n !/\\.d\\.ts$/.test(event.filePath)\n ) {\n const { filePath } = event;\n // Is TypeScript?\n if (\n // If the user adds a TypeScript file to the observable files in their project.\n /\\.tsx?$/.test(filePath) ||\n // Or if the user adds a tsconfig.json file to the project root.\n (tsconfig && filePath === tsconfigPath)\n ) {\n debug('Detected TypeScript file changed in the project: ', filePath);\n callback(event);\n\n if (throttle) {\n return;\n }\n }\n }\n }\n };\n\n debug('Waiting for TypeScript files to be added to the project...');\n watcher.addListener('change', listener);\n watcher.addListener('add', listener);\n\n const off = () => {\n watcher.removeListener('change', listener);\n watcher.removeListener('add', listener);\n };\n\n server.addListener?.('close', off);\n return off;\n}\n"],"names":["metroWatchTypeScriptFiles","debug","require","metro","server","projectRoot","callback","tsconfig","throttle","eventTypes","watcher","getBundler","getWatcher","tsconfigPath","path","join","listener","eventsQueue","event","includes","type","metadata","test","filePath","addListener","off","removeListener"],"mappings":"AAAA;;;;QAkCgBA,yBAAyB,GAAzBA,yBAAyB;SAlCxB,KAAM;gDAAN,MAAM;IAAN,KAAM;;;;;;;;;;AAIvB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,mDAAmD,CACpD,AAAsB,AAAC;AA4BjB,SAASF,yBAAyB,CAAC,EACxCG,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,WAAW,CAAA,EACXC,QAAQ,CAAA,EACRC,QAAQ,EAAG,KAAK,CAAA,EAChBC,QAAQ,EAAG,KAAK,CAAA,EAChBC,UAAU,EAAG;IAAC,KAAK;IAAE,QAAQ;IAAE,QAAQ;CAAC,CAAA,EACP,EAAc;IAC/C,MAAMC,OAAO,GAAGP,KAAK,CAACQ,UAAU,EAAE,CAACA,UAAU,EAAE,CAACC,UAAU,EAAE,AAAC;IAE7D,MAAMC,YAAY,GAAGC,KAAI,UAAA,CAACC,IAAI,CAACV,WAAW,EAAE,eAAe,CAAC,AAAC;IAE7D,MAAMW,QAAQ,GAAG,CAAC,EAAEC,WAAW,CAAA,EAAiC,GAAK;QACnE,KAAK,MAAMC,KAAK,IAAID,WAAW,CAAE;gBAG7BC,GAAc;YAFhB,IACET,UAAU,CAACU,QAAQ,CAACD,KAAK,CAACE,IAAI,CAAC,IAC/BF,CAAAA,CAAAA,GAAc,GAAdA,KAAK,CAACG,QAAQ,SAAM,GAApBH,KAAAA,CAAoB,GAApBA,GAAc,CAAEE,IAAI,CAAA,KAAK,GAAG,IAC5B,yGAAyG;YACzG,CAAC,eAAeE,IAAI,CAACJ,KAAK,CAACK,QAAQ,CAAC,IACpC,2BAA2B;YAC3B,CAAC,WAAWD,IAAI,CAACJ,KAAK,CAACK,QAAQ,CAAC,EAChC;gBACA,MAAM,EAAEA,QAAQ,CAAA,EAAE,GAAGL,KAAK,AAAC;gBAC3B,iBAAiB;gBACjB,IACE,+EAA+E;gBAC/E,UAAUI,IAAI,CAACC,QAAQ,CAAC,IACxB,gEAAgE;gBAChE,CAAChB,QAAQ,IAAIgB,QAAQ,KAAKV,YAAY,CAAC,EACvC;oBACAZ,KAAK,CAAC,mDAAmD,EAAEsB,QAAQ,CAAC,CAAC;oBACrEjB,QAAQ,CAACY,KAAK,CAAC,CAAC;oBAEhB,IAAIV,QAAQ,EAAE;wBACZ,OAAO;qBACR;iBACF;aACF;SACF;KACF,AAAC;IAEFP,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACpES,OAAO,CAACc,WAAW,CAAC,QAAQ,EAAER,QAAQ,CAAC,CAAC;IACxCN,OAAO,CAACc,WAAW,CAAC,KAAK,EAAER,QAAQ,CAAC,CAAC;IAErC,MAAMS,GAAG,GAAG,IAAM;QAChBf,OAAO,CAACgB,cAAc,CAAC,QAAQ,EAAEV,QAAQ,CAAC,CAAC;QAC3CN,OAAO,CAACgB,cAAc,CAAC,KAAK,EAAEV,QAAQ,CAAC,CAAC;KACzC,AAAC;IAEFZ,MAAM,CAACoB,WAAW,QAAgB,GAAlCpB,KAAAA,CAAkC,GAAlCA,MAAM,CAACoB,WAAW,CAAG,OAAO,EAAEC,GAAG,CAAC,AArFpC,CAqFqC;IACnC,OAAOA,GAAG,CAAC;CACZ"}
|
|
@@ -10,13 +10,36 @@ exports.getApiRoutesForDirectory = getApiRoutesForDirectory;
|
|
|
10
10
|
exports.getRoutePaths = getRoutePaths;
|
|
11
11
|
exports.hasWarnedAboutApiRoutes = hasWarnedAboutApiRoutes;
|
|
12
12
|
exports.warnInvalidWebOutput = warnInvalidWebOutput;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
function _chalk() {
|
|
14
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
15
|
+
_chalk = function() {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
function _glob() {
|
|
21
|
+
const data = require("glob");
|
|
22
|
+
_glob = function() {
|
|
23
|
+
return data;
|
|
24
|
+
};
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
function _path() {
|
|
28
|
+
const data = _interopRequireDefault(require("path"));
|
|
29
|
+
_path = function() {
|
|
30
|
+
return data;
|
|
31
|
+
};
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
function _resolveFrom() {
|
|
35
|
+
const data = _interopRequireDefault(require("resolve-from"));
|
|
36
|
+
_resolveFrom = function() {
|
|
37
|
+
return data;
|
|
38
|
+
};
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
17
41
|
var _log = require("../../../log");
|
|
18
42
|
var _dir = require("../../../utils/dir");
|
|
19
|
-
var _fn = require("../../../utils/fn");
|
|
20
43
|
var _link = require("../../../utils/link");
|
|
21
44
|
function _interopRequireDefault(obj) {
|
|
22
45
|
return obj && obj.__esModule ? obj : {
|
|
@@ -27,33 +50,37 @@ const debug = require("debug")("expo:start:server:metro:router");
|
|
|
27
50
|
function getAppRouterRelativeEntryPath(projectRoot, routerDirectory = getRouterDirectory(projectRoot)) {
|
|
28
51
|
var ref;
|
|
29
52
|
// Auto pick App entry
|
|
30
|
-
const routerEntry = (ref = _resolveFrom.default.silent(projectRoot, "expo-router/entry")) != null ? ref : getFallbackEntryRoot(projectRoot);
|
|
53
|
+
const routerEntry = (ref = _resolveFrom().default.silent(projectRoot, "expo-router/entry")) != null ? ref : getFallbackEntryRoot(projectRoot);
|
|
31
54
|
if (!routerEntry) {
|
|
32
55
|
return undefined;
|
|
33
56
|
}
|
|
34
57
|
// It doesn't matter if the app folder exists.
|
|
35
|
-
const appFolder = _path.default.join(projectRoot, routerDirectory);
|
|
36
|
-
const appRoot = _path.default.relative(_path.default.dirname(routerEntry), appFolder);
|
|
58
|
+
const appFolder = _path().default.join(projectRoot, routerDirectory);
|
|
59
|
+
const appRoot = _path().default.relative(_path().default.dirname(routerEntry), appFolder);
|
|
37
60
|
debug("expo-router entry", routerEntry, appFolder, appRoot);
|
|
38
61
|
return appRoot;
|
|
39
62
|
}
|
|
40
63
|
/** If the `expo-router` package is not installed, then use the `expo` package to determine where the node modules are relative to the project. */ function getFallbackEntryRoot(projectRoot) {
|
|
41
|
-
const expoRoot = _resolveFrom.default.silent(projectRoot, "expo/package.json");
|
|
64
|
+
const expoRoot = _resolveFrom().default.silent(projectRoot, "expo/package.json");
|
|
42
65
|
if (expoRoot) {
|
|
43
|
-
return _path.default.join(_path.default.dirname(_path.default.dirname(expoRoot)), "expo-router/entry");
|
|
66
|
+
return _path().default.join(_path().default.dirname(_path().default.dirname(expoRoot)), "expo-router/entry");
|
|
44
67
|
}
|
|
45
|
-
return _path.default.join(projectRoot, "node_modules/expo-router/entry");
|
|
68
|
+
return _path().default.join(projectRoot, "node_modules/expo-router/entry");
|
|
46
69
|
}
|
|
47
70
|
function getRouterDirectoryModuleIdWithManifest(projectRoot, exp) {
|
|
48
71
|
var ref, ref1;
|
|
49
72
|
var ref2;
|
|
50
73
|
return (ref2 = (ref = exp.extra) == null ? void 0 : (ref1 = ref.router) == null ? void 0 : ref1.root) != null ? ref2 : getRouterDirectory(projectRoot);
|
|
51
74
|
}
|
|
52
|
-
|
|
53
|
-
)
|
|
75
|
+
let hasWarnedAboutSrcDir = false;
|
|
76
|
+
const logSrcDir = ()=>{
|
|
77
|
+
if (hasWarnedAboutSrcDir) return;
|
|
78
|
+
hasWarnedAboutSrcDir = true;
|
|
79
|
+
_log.Log.log(_chalk().default.gray("Using src/app as the root directory for Expo Router."));
|
|
80
|
+
};
|
|
54
81
|
function getRouterDirectory(projectRoot) {
|
|
55
82
|
// more specific directories first
|
|
56
|
-
if ((0, _dir).directoryExistsSync(_path.default.join(projectRoot, "src/app"))) {
|
|
83
|
+
if ((0, _dir).directoryExistsSync(_path().default.join(projectRoot, "src/app"))) {
|
|
57
84
|
logSrcDir();
|
|
58
85
|
return "src/app";
|
|
59
86
|
}
|
|
@@ -64,13 +91,13 @@ function isApiRouteConvention(name) {
|
|
|
64
91
|
return /\+api\.[tj]sx?$/.test(name);
|
|
65
92
|
}
|
|
66
93
|
function getApiRoutesForDirectory(cwd) {
|
|
67
|
-
return (
|
|
94
|
+
return _glob().sync("**/*+api.@(ts|tsx|js|jsx)", {
|
|
68
95
|
cwd,
|
|
69
96
|
absolute: true
|
|
70
97
|
});
|
|
71
98
|
}
|
|
72
99
|
function getRoutePaths(cwd) {
|
|
73
|
-
return (
|
|
100
|
+
return _glob().sync("**/*.@(ts|tsx|js|jsx)", {
|
|
74
101
|
cwd
|
|
75
102
|
}).map((p)=>"./" + normalizePaths(p)
|
|
76
103
|
);
|
|
@@ -84,7 +111,7 @@ function hasWarnedAboutApiRoutes() {
|
|
|
84
111
|
}
|
|
85
112
|
function warnInvalidWebOutput() {
|
|
86
113
|
if (!hasWarnedAboutApiRouteOutput) {
|
|
87
|
-
_log.Log.warn(_chalk.default.yellow`Using API routes requires the {bold web.output} to be set to {bold "server"} in the project {bold app.json}. ${(0, _link).learnMore("https://docs.expo.dev/router/reference/api-routes/")}`);
|
|
114
|
+
_log.Log.warn(_chalk().default.yellow`Using API routes requires the {bold web.output} to be set to {bold "server"} in the project {bold app.json}. ${(0, _link).learnMore("https://docs.expo.dev/router/reference/api-routes/")}`);
|
|
88
115
|
}
|
|
89
116
|
hasWarnedAboutApiRouteOutput = true;
|
|
90
117
|
}
|