@expo/cli 57.0.32 → 57.0.34
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 +1 -1
- package/build/src/events/index.js +1 -1
- package/build/src/export/compileHermesArtifacts.js +28 -0
- package/build/src/export/compileHermesArtifacts.js.map +1 -0
- package/build/src/export/embed/exportEmbedAsync.js +4 -0
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/exportApp.js +9 -5
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportDomComponents.js +5 -11
- package/build/src/export/exportDomComponents.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +3 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +3 -2
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/ios/appleDevice/ClientManager.js +11 -6
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +12 -4
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/start/interface/cliExtensionMenuItemHandler.js.map +1 -1
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/createDevToolsMenuItems.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +6 -1
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/ios/devicectl.js +2 -5
- package/build/src/start/platforms/ios/devicectl.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +6 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +1 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +10 -4
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/{DevToolsPlugin.js → devtools/DevToolsPlugin.js} +14 -5
- package/build/src/start/server/devtools/DevToolsPlugin.js.map +1 -0
- package/build/src/start/server/devtools/DevToolsPlugin.schema.js +195 -0
- package/build/src/start/server/devtools/DevToolsPlugin.schema.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginCliExtensionExecutor.js → devtools/DevToolsPluginCliExtensionExecutor.js} +1 -1
- package/build/src/start/server/devtools/DevToolsPluginCliExtensionExecutor.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginCliExtensionResults.js → devtools/DevToolsPluginCliExtensionResults.js} +24 -12
- package/build/src/start/server/devtools/DevToolsPluginCliExtensionResults.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginManager.js → devtools/DevToolsPluginManager.js} +2 -2
- package/build/src/start/server/devtools/DevToolsPluginManager.js.map +1 -0
- package/build/src/start/server/devtools/DevToolsPluginServerHelpers.js.map +1 -0
- package/build/src/start/server/{MCP.js → mcp/MCP.js} +25 -15
- package/build/src/start/server/mcp/MCP.js.map +1 -0
- package/build/src/start/server/{MCPDevToolsPluginCLIExtensions.js → mcp/MCPDevToolsPluginCLIExtensions.js} +14 -27
- package/build/src/start/server/mcp/MCPDevToolsPluginCLIExtensions.js.map +1 -0
- package/build/src/start/server/{createMCPDevToolsExtensionSchema.js → mcp/createMCPDevToolsExtensionSchema.js} +8 -15
- package/build/src/start/server/mcp/createMCPDevToolsExtensionSchema.js.map +1 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js +2 -4
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +6 -2
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +4 -1
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/openHandlers.js +2 -6
- package/build/src/start/server/middleware/openHandlers.js.map +1 -1
- package/build/src/start/startAsync.js +2 -4
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/obj.js +1 -1
- package/build/src/utils/obj.js.map +1 -1
- package/build/src/utils/open.js +47 -31
- package/build/src/utils/open.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +26 -22
- package/build/src/start/server/DevToolsPlugin.js.map +0 -1
- package/build/src/start/server/DevToolsPlugin.schema.js +0 -84
- package/build/src/start/server/DevToolsPlugin.schema.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +0 -1
- package/build/src/start/server/DevToolsPluginManager.js.map +0 -1
- package/build/src/start/server/DevToolsPluginServerHelpers.js.map +0 -1
- package/build/src/start/server/MCP.js.map +0 -1
- package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js.map +0 -1
- package/build/src/start/server/createMCPDevToolsExtensionSchema.js.map +0 -1
- /package/build/src/start/server/{DevToolsPluginServerHelpers.js → devtools/DevToolsPluginServerHelpers.js} +0 -0
|
@@ -104,7 +104,7 @@ const _events = require("../../../events");
|
|
|
104
104
|
const _log = require("../../../log");
|
|
105
105
|
const _env = require("../../../utils/env");
|
|
106
106
|
const _errors = require("../../../utils/errors");
|
|
107
|
-
const _DevToolsPluginManager = require("../DevToolsPluginManager");
|
|
107
|
+
const _DevToolsPluginManager = require("../devtools/DevToolsPluginManager");
|
|
108
108
|
const _CorsMiddleware = require("../middleware/CorsMiddleware");
|
|
109
109
|
const _createJsInspectorMiddleware = require("../middleware/inspector/createJsInspectorMiddleware");
|
|
110
110
|
const _mutations = require("../middleware/mutations");
|
|
@@ -196,7 +196,7 @@ function asWritable(input) {
|
|
|
196
196
|
// Share one instance of Terminal for all instances of Metro.
|
|
197
197
|
const terminal = new LogRespectingTerminal(process.stdout);
|
|
198
198
|
async function loadMetroConfigAsync(projectRoot, options, { exp, isExporting, getMetroBundler }) {
|
|
199
|
-
var _exp_experiments, _exp_experiments1, _exp_experiments2, _exp_experiments3, _exp_experiments4, _config_resolver, _exp_experiments5, _exp_experiments6;
|
|
199
|
+
var _exp_experiments, _exp_experiments1, _exp_experiments2, _exp_experiments3, _exp_experiments4, _config_resolver, _exp_experiments5, _config_serializer_polyfillModuleNames, _config_serializer, _exp_experiments6;
|
|
200
200
|
let reportEvent;
|
|
201
201
|
// We're resolving a monorepo root, higher up than the `projectRoot`. If this
|
|
202
202
|
// folder is different (presumably a parent) we're in a monorepo
|
|
@@ -279,6 +279,10 @@ async function loadMetroConfigAsync(projectRoot, options, { exp, isExporting, ge
|
|
|
279
279
|
if (!reduceLogs && _env.env.EXPO_UNSTABLE_LOG_BOX) {
|
|
280
280
|
_log.Log.warn(`Experimental Expo LogBox is enabled.`);
|
|
281
281
|
}
|
|
282
|
+
const workletsBundleModeEnabled = (_config_serializer = config.serializer) == null ? void 0 : (_config_serializer_polyfillModuleNames = _config_serializer.polyfillModuleNames) == null ? void 0 : _config_serializer_polyfillModuleNames.some((modulePath)=>modulePath.includes('react-native-worklets'));
|
|
283
|
+
if (!reduceLogs && workletsBundleModeEnabled) {
|
|
284
|
+
_log.Log.warn(`Experimental react-native-worklets Bundle Mode is enabled.\nBundle mode is currently unstable, not recommended for production use, and may cause unexpected behavior.`);
|
|
285
|
+
}
|
|
282
286
|
if (!reduceLogs && serverActionsEnabled) {
|
|
283
287
|
var _exp_experiments8;
|
|
284
288
|
_log.Log.warn(`React Server Functions (beta) are enabled. Route rendering mode: ${((_exp_experiments8 = exp.experiments) == null ? void 0 : _exp_experiments8.reactServerComponentRoutes) ? 'server' : 'client'}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { type ExpoConfig, getConfig, getPlatformsFromConfig } from '@expo/config';\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport type { Reporter } from '@expo/metro/metro';\nimport type Bundler from '@expo/metro/metro/Bundler';\nimport type { ReadOnlyGraph } from '@expo/metro/metro/DeltaBundler';\nimport type { TransformOptions } from '@expo/metro/metro/DeltaBundler/Worker';\nimport type { Client as MetroHmrClient } from '@expo/metro/metro/HmrServer';\nimport type MetroHmrServer from '@expo/metro/metro/HmrServer';\nimport RevisionNotFoundError from '@expo/metro/metro/IncrementalBundler/RevisionNotFoundError';\nimport type MetroServer from '@expo/metro/metro/Server';\nimport formatBundlingError from '@expo/metro/metro/lib/formatBundlingError';\nimport { Terminal } from '@expo/metro/metro-core';\nimport type { createStableModuleIdFactory } from '@expo/metro-config';\nimport { loadUserConfig } from '@expo/metro-config';\nimport { patchTransformFileForPackedMaps } from '@expo/metro-config/build/serializer/packedMap';\nimport { patchMetroSourceMapStringForPackedMaps } from '@expo/metro-config/build/serializer/sourceMap';\nimport chalk from 'chalk';\nimport type http from 'http';\nimport path from 'path';\n\nimport { createDevToolsPluginWebsocketEndpoint } from './DevToolsPluginWebsocketEndpoint';\nimport type { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { replaceMetroFileMap } from './createFileMap-fork';\nimport { attachAtlasAsync } from './debugging/attachAtlas';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { createMetroMiddleware } from './dev-server/createMetroMiddleware';\nimport { runServer, type ServerAddressInfo, type SecureServerOptions } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { events, shouldReduceLogs } from '../../../events';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport type DevToolsPluginManager from '../DevToolsPluginManager';\nimport { DevToolsPluginEndpoint } from '../DevToolsPluginManager';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// prettier-ignore\nexport const event = events('metro', (t) => [\n t.event<'config', {\n serverRoot: string;\n projectRoot: string;\n exporting: boolean;\n flags: {\n autolinkingModuleResolution: boolean;\n serverActions: boolean;\n serverComponents: boolean;\n reactCompiler: boolean;\n optimizeGraph?: boolean;\n treeshaking?: boolean;\n logbox?: boolean;\n };\n }>(),\n t.event<'instantiate', {\n atlas: boolean;\n workers: number | null;\n host: string | null;\n port: number | null;\n }>(),\n]);\n\n// NOTE(@kitten): We pass a custom createStableModuleIdFactory function into the Metro module ID factory sometimes\ninterface MetroServerWithModuleIdMod extends MetroServer {\n _createModuleId: ReturnType<typeof createStableModuleIdFactory> & ((path: string) => number);\n}\ninterface MetroHmrServerWithModuleIdMod extends MetroHmrServer<MetroHmrClient> {\n _createModuleId: ReturnType<typeof createStableModuleIdFactory> & ((path: string) => number);\n}\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\n// TODO(@kitten): We assign this here to run server-side code bundled by metro\n// It's not isolated into a worker thread yet\n// Check `metro-require/require.ts` for how this setting is used\ndeclare namespace globalThis {\n let __requireCycleIgnorePatterns: readonly RegExp[] | undefined;\n}\n\nfunction asWritable<T>(input: T): { -readonly [K in keyof T]: T[K] } {\n return input;\n}\n\n/**\n * Extends Metro's Terminal to intercept all console methods so they don't\n * corrupt the progress bar status lines.\n *\n * console.log/info are routed through terminal.log() (stdout, managed).\n * console.warn/error are routed through logStderr() which clears the\n * status from stdout before writing to stderr, then restores it.\n * Without this, unmanaged stderr writes shift the cursor and cause\n * progress bars to get stuck as permanent output.\n */\nclass LogRespectingTerminal extends Terminal {\n #stderrQueue: string[] = [];\n #drainingStderr = false;\n\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream, { ttyPrint: true });\n\n const sendLog = (...msg: any[]) => {\n if (!msg.length) {\n this.log('');\n } else {\n const [format, ...args] = msg;\n this.log(format, ...args);\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 const sendStderr = (...msg: any[]) => {\n if (!msg.length) {\n this.logStderr('');\n } else {\n const [format, ...args] = msg;\n this.logStderr(require('util').format(format, ...args));\n }\n };\n\n console.log = sendLog;\n console.info = sendLog;\n console.warn = sendStderr;\n console.error = sendStderr;\n\n // NOTE(@kitten): We flush the stderr queue immediately when we're about to exit\n process.on('exit', () => {\n if (!this.#drainingStderr && this.#stderrQueue.length) {\n this.#drainingStderr = true;\n this.status('');\n const lines = this.#stderrQueue.splice(0);\n process.stderr.write(lines.join('\\n') + '\\n');\n }\n });\n }\n\n /** Write to stderr without corrupting Terminal's cursor tracking. */\n logStderr(line: string): void {\n if (!(process.stdout as any).isTTY) {\n process.stderr.write(line + '\\n');\n return;\n }\n this.#stderrQueue.push(line);\n this.#drainStderr();\n }\n\n async #drainStderr(): Promise<void> {\n if (this.#drainingStderr) return;\n this.#drainingStderr = true;\n\n while (this.#stderrQueue.length > 0) {\n // Clear status, flush to ensure it's removed from screen\n const prev = this.status('');\n await this.flush();\n\n // Write to stderr while status is cleared\n const lines = this.#stderrQueue.splice(0);\n process.stderr.write(lines.join('\\n') + '\\n');\n\n // Restore status\n this.status(prev);\n }\n\n this.#drainingStderr = false;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\ninterface LoadMetroConfigOptions {\n maxWorkers?: number;\n port?: number;\n reporter?: Reporter;\n resetCache?: boolean;\n}\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadMetroConfigOptions,\n {\n exp,\n isExporting,\n getMetroBundler,\n }: { exp: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n\n // We're resolving a monorepo root, higher up than the `projectRoot`. If this\n // folder is different (presumably a parent) we're in a monorepo\n const serverRoot = getMetroServerRoot(projectRoot);\n const isWorkspace = serverRoot !== projectRoot;\n\n // Out-of-tree platforms (tvos/macos) rely on the autolinking module resolver to remap the\n // react-native package to their support package, and require autolinking module resolution\n const targetsOutOfTreePlatform = getPlatformsFromConfig(projectRoot, exp).some(\n (platform) => platform === 'tvos' || platform === 'macos'\n );\n\n // Autolinking Module Resolution is enabled by default in a monorepo or for out-of-tree platforms.\n const autolinkingModuleResolutionEnabled =\n exp.experiments?.autolinkingModuleResolution ?? (isWorkspace || targetsOutOfTreePlatform);\n\n const serverActionsEnabled =\n exp.experiments?.reactServerFunctions ?? env.EXPO_UNSTABLE_SERVER_FUNCTIONS;\n const serverComponentsEnabled = !!exp.experiments?.reactServerComponentRoutes;\n if (serverActionsEnabled) {\n process.env.EXPO_UNSTABLE_SERVER_FUNCTIONS = '1';\n }\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (serverComponentsEnabled || serverActionsEnabled) {\n process.env.EXPO_USE_METRO_REQUIRE = '1';\n }\n\n if (exp.experiments?.reactCanary) {\n Log.warn(`React 19 is enabled by default. Remove unused experiments.reactCanary flag.`);\n }\n\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n let config = await loadUserConfig({\n projectRoot,\n serverRoot,\n // NOTE: Allow external tools to override the metro config. This is considered internal and unstable\n overrideConfigPath: env.EXPO_OVERRIDE_METRO_CONFIG ?? undefined,\n });\n\n config = {\n ...config,\n // See: `overrideConfigWithArguments` https://github.com/facebook/metro/blob/5059e26/packages/metro-config/src/loadConfig.js#L274-L339\n // Compare to `LoadOptions` type (disregard `reporter` as we don't expose this)\n resetCache: !!options.resetCache,\n maxWorkers: options.maxWorkers ?? config.maxWorkers,\n server: {\n ...config.server,\n port: options.port ?? config.server.port,\n },\n // Force-override the reporter\n reporter: {\n update(event) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n // On-Demand Filesystem is enabled by default\n // TODO(@kitten): Add to config-types JSON schema\n const onDemandFilesystem = exp.experiments?.onDemandFilesystem ?? true;\n asWritable(config.resolver).unstable_onDemandFilesystem = onDemandFilesystem;\n\n globalThis.__requireCycleIgnorePatterns = config.resolver?.requireCycleIgnorePatterns;\n\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n asWritable(config.transformer).publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n asWritable(config.transformer).publicPath = '/assets/?unstable_path=.';\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n const reduceLogs = shouldReduceLogs();\n\n const reactCompilerEnabled = !!exp.experiments?.reactCompiler;\n if (!reduceLogs && reactCompilerEnabled) {\n Log.log(chalk.gray`React Compiler enabled`);\n }\n\n if (!reduceLogs && autolinkingModuleResolutionEnabled) {\n Log.log(chalk.gray`Expo Autolinking module resolution enabled`);\n }\n\n if (env.EXPO_UNSTABLE_TREE_SHAKING && !env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n throw new CommandError(\n 'EXPO_UNSTABLE_TREE_SHAKING requires EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH to be enabled.'\n );\n }\n\n if (!reduceLogs && env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n Log.warn(`Experimental bundle optimization is enabled.`);\n }\n if (!reduceLogs && env.EXPO_UNSTABLE_TREE_SHAKING) {\n Log.warn(`Experimental tree shaking is enabled.`);\n }\n if (!reduceLogs && env.EXPO_UNSTABLE_LOG_BOX) {\n Log.warn(`Experimental Expo LogBox is enabled.`);\n }\n\n if (!reduceLogs && serverActionsEnabled) {\n Log.warn(\n `React Server Functions (beta) are enabled. Route rendering mode: ${exp.experiments?.reactServerComponentRoutes ? 'server' : 'client'}`\n );\n }\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n serverRoot,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n isAutolinkingResolverEnabled: autolinkingModuleResolutionEnabled,\n isExporting,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: serverComponentsEnabled,\n getMetroBundler,\n });\n\n event('config', {\n serverRoot: event.path(serverRoot),\n projectRoot: event.path(projectRoot),\n exporting: isExporting,\n flags: {\n autolinkingModuleResolution: autolinkingModuleResolutionEnabled,\n serverActions: serverActionsEnabled,\n serverComponents: serverComponentsEnabled,\n reactCompiler: reactCompilerEnabled,\n optimizeGraph: env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH,\n treeshaking: env.EXPO_UNSTABLE_TREE_SHAKING,\n logbox: env.EXPO_UNSTABLE_LOG_BOX,\n },\n });\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\ninterface InstantiateMetroConfigOptions extends LoadMetroConfigOptions {\n host?: string;\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: InstantiateMetroConfigOptions,\n {\n isExporting,\n exp = getConfig(metroBundler.projectRoot, {\n skipSDKVersionRequirement: true,\n }).exp,\n devToolsPluginManager,\n }: {\n isExporting: boolean;\n exp?: ExpoConfig;\n devToolsPluginManager: DevToolsPluginManager;\n }\n): Promise<{\n metro: MetroServer;\n hmrServer: MetroHmrServer<MetroHmrClient> | null;\n server: http.Server;\n address: ServerAddressInfo | null;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n const getMetroBundler = () => metro.getBundler().getBundler();\n\n const {\n config: metroConfig,\n setEventReporter,\n reporter,\n } = await loadMetroConfigAsync(projectRoot, options, {\n exp,\n isExporting,\n getMetroBundler,\n });\n\n // Get local URL to Metro bundler server (typically configured as 127.0.0.1:8081)\n const serverBaseUrl = metroBundler\n .getUrlCreator()\n .constructUrl({ scheme: 'http', hostType: 'localhost' });\n\n // Create the core middleware stack for Metro, including websocket listeners\n const { middleware, messagesSocket, eventsSocket, websocketEndpoints } = createMetroMiddleware(\n metroConfig,\n { getMetroBundler, serverBaseUrl }\n );\n\n if (!isExporting) {\n // Enable correct CORS headers for Expo Router features\n prependMiddleware(middleware, createCorsMiddleware(exp));\n\n // Enable debug middleware for CDP-related debugging\n const { debugMiddleware, debugWebsocketEndpoints } = createDebugMiddleware({\n serverBaseUrl,\n reporter,\n });\n Object.assign(websocketEndpoints, debugWebsocketEndpoints);\n middleware.use(debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware({ serverBaseUrl }));\n\n // TODO(cedric): `enhanceMiddleware` is deprecated, but is currently used to unify the middleware stacks\n // See: https://github.com/facebook/metro/commit/22e85fde85ec454792a1b70eba4253747a2587a9\n // See: https://github.com/facebook/metro/commit/d0d554381f119bb80ab09dbd6a1d310b54737e52\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n asWritable(metroConfig.server).enhanceMiddleware = (\n metroMiddleware: any,\n server: MetroServer\n ) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n const devtoolsWebsocketEndpoints = createDevToolsPluginWebsocketEndpoint();\n Object.assign(websocketEndpoints, devtoolsWebsocketEndpoints);\n\n // Register WebSocket endpoints contributed by DevTools plugins. A plugin's `serverEntryPoint`\n // exports a `webSocketHandlers` map (route -> connection handler); each becomes a `ws` server\n // mounted at `/_expo/plugins/<name>/<route>`, reusing Metro's exact-path upgrade dispatch (and\n // its shutdown cleanup). Endpoints must be known before the server starts, so unlike the\n // fetch-based request handler, plugin server modules are loaded eagerly here.\n for (const plugin of await devToolsPluginManager.queryPluginsAsync()) {\n try {\n for (const [route, server] of Object.entries(await plugin.getWebSocketServersAsync())) {\n Object.assign(websocketEndpoints, {\n [`${DevToolsPluginEndpoint}/${plugin.packageName}${route}`]: server,\n });\n }\n } catch (error: any) {\n Log.warn(\n `Skipping WebSocket endpoints for DevTools plugin \"${plugin.packageName}\": ${error.message ?? error}`\n );\n }\n }\n }\n\n // Attach Expo Atlas if enabled\n await attachAtlasAsync({\n isExporting,\n exp,\n projectRoot,\n middleware,\n metroConfig,\n // NOTE(cedric): reset the Atlas file once, and reuse it for static exports\n resetAtlasFile: isExporting,\n });\n\n // Support HTTPS based on the metro's tls server config\n // TODO(@kitten): Remove cast once `@expo/metro` is updated to a Metro version that supports the tls config\n const tls = (metroConfig.server as typeof metroConfig.server & { tls?: SecureServerOptions })\n ?.tls;\n const secureServerOptions = tls\n ? {\n key: tls.key,\n cert: tls.cert,\n ca: tls.ca,\n requestCert: tls.requestCert,\n }\n : undefined;\n\n const watch = !isExporting && isWatchEnabled();\n\n const { address, server, hmrServer, metro } = await replaceMetroFileMap(() => {\n return runServer(\n metroBundler,\n metroConfig,\n {\n host: options.host,\n websocketEndpoints,\n watch,\n secureServerOptions,\n },\n {\n mockServer: isExporting,\n }\n );\n });\n\n event('instantiate', {\n atlas: env.EXPO_ATLAS,\n workers: metroConfig.maxWorkers ?? null,\n host: address?.address ?? null,\n port: address?.port ?? null,\n });\n\n // Patch transform file to remove inconvenient customTransformOptions which are only used in single well-known files.\n const originalTransformFile = metro\n .getBundler()\n .getBundler()\n .transformFile.bind(metro.getBundler().getBundler());\n\n metro.getBundler().getBundler().transformFile = async function (\n filePath: string,\n transformOptions: TransformOptions,\n fileBuffer?: Buffer\n ) {\n return originalTransformFile(\n filePath,\n pruneCustomTransformOptions(\n projectRoot,\n filePath,\n // Clone the options so we don't mutate the original.\n {\n ...transformOptions,\n customTransformOptions: {\n __proto__: null,\n ...transformOptions.customTransformOptions,\n },\n }\n ),\n fileBuffer\n );\n };\n\n // Layered on top of the prune patch above. Both fresh worker results\n // and cache hits flow through `Bundler.transformFile`, so wrapping\n // here covers both.\n patchTransformFileForPackedMaps(metro.getBundler().getBundler());\n patchMetroSourceMapStringForPackedMaps();\n\n setEventReporter(eventsSocket.reportMetroEvent);\n\n // This function ensures that modules in source maps are sorted in the same\n // order as in a plain JS bundle.\n metro._getSortedModules = function (this: MetroServerWithModuleIdMod, graph: ReadOnlyGraph) {\n const modules = [...graph.dependencies.values()];\n\n const ctx = {\n // TODO(@kitten): Increase type-safety here\n platform: graph.transformOptions.platform!,\n environment: graph.transformOptions.customTransformOptions?.environment,\n };\n // Assign IDs to modules in a consistent order\n for (const module of modules) {\n this._createModuleId(module.path, ctx);\n }\n // Sort by IDs\n return modules.sort(\n (a, b) => this._createModuleId(a.path, ctx) - this._createModuleId(b.path, ctx)\n );\n };\n\n if (hmrServer) {\n let hmrJSBundle:\n | typeof import('@expo/metro-config/build/serializer/fork/hmrJSBundle').default\n | typeof import('@expo/metro/metro/DeltaBundler/Serializers/hmrJSBundle').default;\n\n try {\n hmrJSBundle = require('@expo/metro-config/build/serializer/fork/hmrJSBundle').default;\n } catch {\n // TODO: Add fallback for monorepo tests up until the fork is merged.\n Log.warn('Failed to load HMR serializer from @expo/metro-config, using fallback version.');\n hmrJSBundle = require('@expo/metro/metro/DeltaBundler/Serializers/hmrJSBundle');\n }\n\n // Patch HMR Server to send more info to the `_createModuleId` function for deterministic module IDs and add support for serializing HMR updates the same as all other bundles.\n hmrServer._prepareMessage = async function (\n this: MetroHmrServerWithModuleIdMod,\n group,\n options,\n changeEvent\n ) {\n // Fork of https://github.com/facebook/metro/blob/3b3e0aaf725cfa6907bf2c8b5fbc0da352d29efe/packages/metro/src/HmrServer.js#L327-L393\n // with patch for `_createModuleId`.\n const logger = !options.isInitialUpdate ? changeEvent?.logger : null;\n try {\n const revPromise = this._bundler.getRevision(group.revisionId);\n if (!revPromise) {\n return {\n type: 'error',\n body: formatBundlingError(new RevisionNotFoundError(group.revisionId)),\n };\n }\n logger?.point('updateGraph_start');\n const { revision, delta } = await this._bundler.updateGraph(await revPromise, false);\n logger?.point('updateGraph_end');\n this._clientGroups.delete(group.revisionId);\n group.revisionId = revision.id;\n for (const client of group.clients) {\n client.revisionIds = client.revisionIds.filter(\n (revisionId) => revisionId !== group.revisionId\n );\n client.revisionIds.push(revision.id);\n }\n this._clientGroups.set(group.revisionId, group);\n logger?.point('serialize_start');\n // NOTE(EvanBacon): This is the patch\n const moduleIdContext = {\n // TODO(@kitten): Increase type-safety here\n platform: revision.graph.transformOptions.platform!,\n environment: revision.graph.transformOptions.customTransformOptions?.environment,\n };\n const hmrUpdate = hmrJSBundle(delta, revision.graph, {\n clientUrl: group.clientUrl,\n // NOTE(EvanBacon): This is also the patch\n createModuleId: (moduleId: string) => {\n return this._createModuleId(moduleId, moduleIdContext);\n },\n includeAsyncPaths: group.graphOptions.lazy,\n projectRoot: this._config.projectRoot,\n serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,\n });\n logger?.point('serialize_end');\n return {\n type: 'update',\n body: {\n revisionId: revision.id,\n isInitialUpdate: options.isInitialUpdate,\n ...hmrUpdate,\n },\n };\n } catch (error: any) {\n const formattedError = formatBundlingError(error);\n this._config.reporter.update({\n type: 'bundling_error',\n error,\n });\n return {\n type: 'error',\n body: formattedError,\n };\n }\n };\n }\n\n return {\n metro,\n hmrServer,\n server,\n middleware,\n messageSocket: messagesSocket,\n address,\n };\n}\n\n// TODO: Fork the entire transform function so we can simply regex the file contents for keywords instead.\nfunction pruneCustomTransformOptions(\n projectRoot: string,\n filePath: string,\n transformOptions: TransformOptions\n): TransformOptions {\n // Normalize the filepath for cross platform checking.\n filePath = filePath.split(path.sep).join('/');\n\n if (\n transformOptions.customTransformOptions?.dom &&\n // The only generated file that needs the dom root is `expo/dom/entry.js`\n !filePath.match(/expo\\/dom\\/entry\\.js$/)\n ) {\n // Clear the dom root option if we aren't transforming the magic entry file, this ensures\n // that cached artifacts from other DOM component bundles can be reused.\n transformOptions.customTransformOptions.dom = 'true';\n }\n\n const routerRoot = transformOptions.customTransformOptions?.routerRoot;\n if (typeof routerRoot === 'string') {\n const isRouterEntry = /\\/expo-router\\/_ctx/.test(filePath);\n // The router root is used all over expo-router (`process.env.EXPO_ROUTER_ABS_APP_ROOT`, `process.env.EXPO_ROUTER_APP_ROOT`) so we'll just ignore the entire package.\n const isRouterModule = /\\/expo-router\\/build\\//.test(filePath);\n // Any page/router inside the expo-router app folder may access the `routerRoot` option to determine whether it's in the app folder\n const resolvedRouterRoot = path.resolve(projectRoot, routerRoot).split(path.sep).join('/');\n const isRouterRoute = path.isAbsolute(filePath) && filePath.startsWith(resolvedRouterRoot);\n\n // In any other file than the above, we enforce that we mustn't use `routerRoot`, and set it to an arbitrary value here (the default)\n // to ensure that the cache never invalidates when this value is changed\n if (!isRouterEntry && !isRouterModule && !isRouterRoute) {\n transformOptions.customTransformOptions!.routerRoot = 'app';\n }\n }\n\n if (\n transformOptions.customTransformOptions?.asyncRoutes &&\n // The async routes settings are also used in `expo-router/_ctx.ios.js` (and other platform variants) via `process.env.EXPO_ROUTER_IMPORT_MODE`\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n delete transformOptions.customTransformOptions.asyncRoutes;\n }\n\n if (\n transformOptions.customTransformOptions?.clientBoundaries &&\n // The client boundaries are only used in `expo/virtual/rsc.js` for production RSC exports.\n !filePath.match(/\\/expo\\/virtual\\/rsc\\.js$/)\n ) {\n delete transformOptions.customTransformOptions.clientBoundaries;\n }\n\n return transformOptions;\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":["event","instantiateMetroAsync","isWatchEnabled","loadMetroConfigAsync","events","t","asWritable","input","LogRespectingTerminal","Terminal","stream","ttyPrint","sendLog","msg","length","log","format","args","flush","sendStderr","logStderr","require","console","info","warn","error","process","on","status","lines","splice","stderr","write","join","line","stdout","isTTY","push","prev","terminal","projectRoot","options","exp","isExporting","getMetroBundler","config","reportEvent","serverRoot","getMetroServerRoot","isWorkspace","targetsOutOfTreePlatform","getPlatformsFromConfig","some","platform","autolinkingModuleResolutionEnabled","experiments","autolinkingModuleResolution","serverActionsEnabled","reactServerFunctions","env","EXPO_UNSTABLE_SERVER_FUNCTIONS","serverComponentsEnabled","reactServerComponentRoutes","EXPO_USE_METRO_REQUIRE","reactCanary","Log","terminalReporter","MetroTerminalReporter","loadUserConfig","overrideConfigPath","EXPO_OVERRIDE_METRO_CONFIG","undefined","resetCache","maxWorkers","server","port","reporter","update","onDemandFilesystem","resolver","unstable_onDemandFilesystem","globalThis","__requireCycleIgnorePatterns","requireCycleIgnorePatterns","transformer","publicPath","baseUrl","platformBundlers","getPlatformBundlers","reduceLogs","shouldReduceLogs","reactCompilerEnabled","reactCompiler","chalk","gray","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","CommandError","EXPO_UNSTABLE_LOG_BOX","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","isAutolinkingResolverEnabled","isNamedRequiresEnabled","isReactServerComponentsEnabled","path","exporting","flags","serverActions","serverComponents","optimizeGraph","treeshaking","logbox","setEventReporter","logger","metroBundler","getConfig","skipSDKVersionRequirement","devToolsPluginManager","metroConfig","metro","getBundler","serverBaseUrl","getUrlCreator","constructUrl","scheme","hostType","middleware","messagesSocket","eventsSocket","websocketEndpoints","createMetroMiddleware","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","devtoolsWebsocketEndpoints","createDevToolsPluginWebsocketEndpoint","plugin","queryPluginsAsync","route","entries","getWebSocketServersAsync","DevToolsPluginEndpoint","packageName","message","attachAtlasAsync","resetAtlasFile","tls","secureServerOptions","key","cert","ca","requestCert","watch","address","hmrServer","replaceMetroFileMap","runServer","host","mockServer","atlas","EXPO_ATLAS","workers","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","patchTransformFileForPackedMaps","patchMetroSourceMapStringForPackedMaps","reportMetroEvent","_getSortedModules","graph","modules","dependencies","values","ctx","environment","module","_createModuleId","sort","a","b","hmrJSBundle","default","_prepareMessage","group","changeEvent","isInitialUpdate","revision","revPromise","_bundler","getRevision","revisionId","type","body","formatBundlingError","RevisionNotFoundError","point","delta","updateGraph","_clientGroups","delete","id","client","clients","revisionIds","filter","set","moduleIdContext","hmrUpdate","clientUrl","createModuleId","moduleId","includeAsyncPaths","graphOptions","lazy","_config","unstable_serverRoot","formattedError","messageSocket","split","sep","dom","match","routerRoot","isRouterEntry","test","isRouterModule","resolvedRouterRoot","resolve","isRouterRoute","isAbsolute","startsWith","asyncRoutes","clientBoundaries","CI"],"mappings":";;;;;;;;;;;QAyCaA;eAAAA;;QA+SSC;eAAAA;;QAiWNC;eAAAA;;QAngBMC;eAAAA;;;;yBAtL6C;;;;;;;yBAChC;;;;;;;gEAOD;;;;;;;gEAEF;;;;;;;yBACP;;;;;;;yBAEM;;;;;;;yBACiB;;;;;;;yBACO;;;;;;;gEACrC;;;;;;;gEAED;;;;;;iDAEqC;uCAEhB;mCACF;6BACH;uCACK;uCACA;+BACsC;wCAChC;wBACH;qBACrB;qBACA;wBACS;uCAEU;gCACF;6CACO;2BACV;kCACE;;;;;;AAG7B,MAAMH,QAAQI,IAAAA,cAAM,EAAC,SAAS,CAACC,IAAM;QAC1CA,EAAEL,KAAK;QAcPK,EAAEL,KAAK;KAMR;AAsBD,SAASM,WAAcC,KAAQ;IAC7B,OAAOA;AACT;AAEA;;;;;;;;;CASC,GACD,MAAMC,8BAA8BC,qBAAQ;IAC1C,CAAA,WAAY,CAAgB;IAC5B,CAAA,cAAe,CAAS;IAExB,YAAYC,MAAkE,CAAE;QAC9E,KAAK,CAACA,QAAQ;YAAEC,UAAU;QAAK,SAJjC,CAAA,WAAY,GAAa,EAAE,OAC3B,CAAA,cAAe,GAAG;QAKhB,MAAMC,UAAU,CAAC,GAAGC;YAClB,IAAI,CAACA,IAAIC,MAAM,EAAE;gBACf,IAAI,CAACC,GAAG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IAAI,CAACjE;QACjD,qKAAqK;QACrK,MAAMkE,iBAAiB,yBAAyBD,IAAI,CAACjE;QACrD,mIAAmI;QACnI,MAAMmE,qBAAqBzI,eAAI,CAAC0I,OAAO,CAAC3M,aAAasM,YAAYJ,KAAK,CAACjI,eAAI,CAACkI,GAAG,EAAE1M,IAAI,CAAC;QACtF,MAAMmN,gBAAgB3I,eAAI,CAAC4I,UAAU,CAACtE,aAAaA,SAASuE,UAAU,CAACJ;QAEvE,qIAAqI;QACrI,wEAAwE;QACxE,IAAI,CAACH,iBAAiB,CAACE,kBAAkB,CAACG,eAAe;YACvDpE,iBAAiBG,sBAAsB,CAAE2D,UAAU,GAAG;QACxD;IACF;IAEA,IACE9D,EAAAA,4CAAAA,iBAAiBG,sBAAsB,qBAAvCH,0CAAyCuE,WAAW,KACpD,+IAA+I;IAC/I,CAAExE,CAAAA,SAAS8D,KAAK,CAAC,0BAA0B9D,SAAS8D,KAAK,CAAC,yBAAwB,GAClF;QACA,OAAO7D,iBAAiBG,sBAAsB,CAACoE,WAAW;IAC5D;IAEA,IACEvE,EAAAA,4CAAAA,iBAAiBG,sBAAsB,qBAAvCH,0CAAyCwE,gBAAgB,KACzD,2FAA2F;IAC3F,CAACzE,SAAS8D,KAAK,CAAC,8BAChB;QACA,OAAO7D,iBAAiBG,sBAAsB,CAACqE,gBAAgB;IACjE;IAEA,OAAOxE;AACT;AAMO,SAAS9K;IACd,IAAIyD,QAAG,CAAC8L,EAAE,EAAE;QACVxL,QAAG,CAAClD,GAAG,CACL8E,IAAAA,gBAAK,CAAA,CAAC,8FAA8F,CAAC;IAEzG;IAEA,OAAO,CAAClC,QAAG,CAAC8L,EAAE;AAChB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { type ExpoConfig, getConfig, getPlatformsFromConfig } from '@expo/config';\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport type { Reporter } from '@expo/metro/metro';\nimport type Bundler from '@expo/metro/metro/Bundler';\nimport type { ReadOnlyGraph } from '@expo/metro/metro/DeltaBundler';\nimport type { TransformOptions } from '@expo/metro/metro/DeltaBundler/Worker';\nimport type { Client as MetroHmrClient } from '@expo/metro/metro/HmrServer';\nimport type MetroHmrServer from '@expo/metro/metro/HmrServer';\nimport RevisionNotFoundError from '@expo/metro/metro/IncrementalBundler/RevisionNotFoundError';\nimport type MetroServer from '@expo/metro/metro/Server';\nimport formatBundlingError from '@expo/metro/metro/lib/formatBundlingError';\nimport { Terminal } from '@expo/metro/metro-core';\nimport type { createStableModuleIdFactory } from '@expo/metro-config';\nimport { loadUserConfig } from '@expo/metro-config';\nimport { patchTransformFileForPackedMaps } from '@expo/metro-config/build/serializer/packedMap';\nimport { patchMetroSourceMapStringForPackedMaps } from '@expo/metro-config/build/serializer/sourceMap';\nimport chalk from 'chalk';\nimport type http from 'http';\nimport path from 'path';\n\nimport { createDevToolsPluginWebsocketEndpoint } from './DevToolsPluginWebsocketEndpoint';\nimport type { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { replaceMetroFileMap } from './createFileMap-fork';\nimport { attachAtlasAsync } from './debugging/attachAtlas';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { createMetroMiddleware } from './dev-server/createMetroMiddleware';\nimport { runServer, type ServerAddressInfo, type SecureServerOptions } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { events, shouldReduceLogs } from '../../../events';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport type DevToolsPluginManager from '../devtools/DevToolsPluginManager';\nimport { DevToolsPluginEndpoint } from '../devtools/DevToolsPluginManager';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// prettier-ignore\nexport const event = events('metro', (t) => [\n t.event<'config', {\n serverRoot: string;\n projectRoot: string;\n exporting: boolean;\n flags: {\n autolinkingModuleResolution: boolean;\n serverActions: boolean;\n serverComponents: boolean;\n reactCompiler: boolean;\n optimizeGraph?: boolean;\n treeshaking?: boolean;\n logbox?: boolean;\n };\n }>(),\n t.event<'instantiate', {\n atlas: boolean;\n workers: number | null;\n host: string | null;\n port: number | null;\n }>(),\n]);\n\n// NOTE(@kitten): We pass a custom createStableModuleIdFactory function into the Metro module ID factory sometimes\ninterface MetroServerWithModuleIdMod extends MetroServer {\n _createModuleId: ReturnType<typeof createStableModuleIdFactory> & ((path: string) => number);\n}\ninterface MetroHmrServerWithModuleIdMod extends MetroHmrServer<MetroHmrClient> {\n _createModuleId: ReturnType<typeof createStableModuleIdFactory> & ((path: string) => number);\n}\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\n// TODO(@kitten): We assign this here to run server-side code bundled by metro\n// It's not isolated into a worker thread yet\n// Check `metro-require/require.ts` for how this setting is used\ndeclare namespace globalThis {\n let __requireCycleIgnorePatterns: readonly RegExp[] | undefined;\n}\n\nfunction asWritable<T>(input: T): { -readonly [K in keyof T]: T[K] } {\n return input;\n}\n\n/**\n * Extends Metro's Terminal to intercept all console methods so they don't\n * corrupt the progress bar status lines.\n *\n * console.log/info are routed through terminal.log() (stdout, managed).\n * console.warn/error are routed through logStderr() which clears the\n * status from stdout before writing to stderr, then restores it.\n * Without this, unmanaged stderr writes shift the cursor and cause\n * progress bars to get stuck as permanent output.\n */\nclass LogRespectingTerminal extends Terminal {\n #stderrQueue: string[] = [];\n #drainingStderr = false;\n\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream, { ttyPrint: true });\n\n const sendLog = (...msg: any[]) => {\n if (!msg.length) {\n this.log('');\n } else {\n const [format, ...args] = msg;\n this.log(format, ...args);\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 const sendStderr = (...msg: any[]) => {\n if (!msg.length) {\n this.logStderr('');\n } else {\n const [format, ...args] = msg;\n this.logStderr(require('util').format(format, ...args));\n }\n };\n\n console.log = sendLog;\n console.info = sendLog;\n console.warn = sendStderr;\n console.error = sendStderr;\n\n // NOTE(@kitten): We flush the stderr queue immediately when we're about to exit\n process.on('exit', () => {\n if (!this.#drainingStderr && this.#stderrQueue.length) {\n this.#drainingStderr = true;\n this.status('');\n const lines = this.#stderrQueue.splice(0);\n process.stderr.write(lines.join('\\n') + '\\n');\n }\n });\n }\n\n /** Write to stderr without corrupting Terminal's cursor tracking. */\n logStderr(line: string): void {\n if (!(process.stdout as any).isTTY) {\n process.stderr.write(line + '\\n');\n return;\n }\n this.#stderrQueue.push(line);\n this.#drainStderr();\n }\n\n async #drainStderr(): Promise<void> {\n if (this.#drainingStderr) return;\n this.#drainingStderr = true;\n\n while (this.#stderrQueue.length > 0) {\n // Clear status, flush to ensure it's removed from screen\n const prev = this.status('');\n await this.flush();\n\n // Write to stderr while status is cleared\n const lines = this.#stderrQueue.splice(0);\n process.stderr.write(lines.join('\\n') + '\\n');\n\n // Restore status\n this.status(prev);\n }\n\n this.#drainingStderr = false;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\ninterface LoadMetroConfigOptions {\n maxWorkers?: number;\n port?: number;\n reporter?: Reporter;\n resetCache?: boolean;\n}\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadMetroConfigOptions,\n {\n exp,\n isExporting,\n getMetroBundler,\n }: { exp: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n\n // We're resolving a monorepo root, higher up than the `projectRoot`. If this\n // folder is different (presumably a parent) we're in a monorepo\n const serverRoot = getMetroServerRoot(projectRoot);\n const isWorkspace = serverRoot !== projectRoot;\n\n // Out-of-tree platforms (tvos/macos) rely on the autolinking module resolver to remap the\n // react-native package to their support package, and require autolinking module resolution\n const targetsOutOfTreePlatform = getPlatformsFromConfig(projectRoot, exp).some(\n (platform) => platform === 'tvos' || platform === 'macos'\n );\n\n // Autolinking Module Resolution is enabled by default in a monorepo or for out-of-tree platforms.\n const autolinkingModuleResolutionEnabled =\n exp.experiments?.autolinkingModuleResolution ?? (isWorkspace || targetsOutOfTreePlatform);\n\n const serverActionsEnabled =\n exp.experiments?.reactServerFunctions ?? env.EXPO_UNSTABLE_SERVER_FUNCTIONS;\n const serverComponentsEnabled = !!exp.experiments?.reactServerComponentRoutes;\n if (serverActionsEnabled) {\n process.env.EXPO_UNSTABLE_SERVER_FUNCTIONS = '1';\n }\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (serverComponentsEnabled || serverActionsEnabled) {\n process.env.EXPO_USE_METRO_REQUIRE = '1';\n }\n\n if (exp.experiments?.reactCanary) {\n Log.warn(`React 19 is enabled by default. Remove unused experiments.reactCanary flag.`);\n }\n\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n let config = await loadUserConfig({\n projectRoot,\n serverRoot,\n // NOTE: Allow external tools to override the metro config. This is considered internal and unstable\n overrideConfigPath: env.EXPO_OVERRIDE_METRO_CONFIG ?? undefined,\n });\n\n config = {\n ...config,\n // See: `overrideConfigWithArguments` https://github.com/facebook/metro/blob/5059e26/packages/metro-config/src/loadConfig.js#L274-L339\n // Compare to `LoadOptions` type (disregard `reporter` as we don't expose this)\n resetCache: !!options.resetCache,\n maxWorkers: options.maxWorkers ?? config.maxWorkers,\n server: {\n ...config.server,\n port: options.port ?? config.server.port,\n },\n // Force-override the reporter\n reporter: {\n update(event) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n // On-Demand Filesystem is enabled by default\n // TODO(@kitten): Add to config-types JSON schema\n const onDemandFilesystem = exp.experiments?.onDemandFilesystem ?? true;\n asWritable(config.resolver).unstable_onDemandFilesystem = onDemandFilesystem;\n\n globalThis.__requireCycleIgnorePatterns = config.resolver?.requireCycleIgnorePatterns;\n\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n asWritable(config.transformer).publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n asWritable(config.transformer).publicPath = '/assets/?unstable_path=.';\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n const reduceLogs = shouldReduceLogs();\n\n const reactCompilerEnabled = !!exp.experiments?.reactCompiler;\n if (!reduceLogs && reactCompilerEnabled) {\n Log.log(chalk.gray`React Compiler enabled`);\n }\n\n if (!reduceLogs && autolinkingModuleResolutionEnabled) {\n Log.log(chalk.gray`Expo Autolinking module resolution enabled`);\n }\n\n if (env.EXPO_UNSTABLE_TREE_SHAKING && !env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n throw new CommandError(\n 'EXPO_UNSTABLE_TREE_SHAKING requires EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH to be enabled.'\n );\n }\n\n if (!reduceLogs && env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n Log.warn(`Experimental bundle optimization is enabled.`);\n }\n if (!reduceLogs && env.EXPO_UNSTABLE_TREE_SHAKING) {\n Log.warn(`Experimental tree shaking is enabled.`);\n }\n if (!reduceLogs && env.EXPO_UNSTABLE_LOG_BOX) {\n Log.warn(`Experimental Expo LogBox is enabled.`);\n }\n const workletsBundleModeEnabled = config.serializer?.polyfillModuleNames?.some((modulePath) =>\n modulePath.includes('react-native-worklets')\n );\n if (!reduceLogs && workletsBundleModeEnabled) {\n Log.warn(\n `Experimental react-native-worklets Bundle Mode is enabled.\\nBundle mode is currently unstable, not recommended for production use, and may cause unexpected behavior.`\n );\n }\n\n if (!reduceLogs && serverActionsEnabled) {\n Log.warn(\n `React Server Functions (beta) are enabled. Route rendering mode: ${exp.experiments?.reactServerComponentRoutes ? 'server' : 'client'}`\n );\n }\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n serverRoot,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n isAutolinkingResolverEnabled: autolinkingModuleResolutionEnabled,\n isExporting,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: serverComponentsEnabled,\n getMetroBundler,\n });\n\n event('config', {\n serverRoot: event.path(serverRoot),\n projectRoot: event.path(projectRoot),\n exporting: isExporting,\n flags: {\n autolinkingModuleResolution: autolinkingModuleResolutionEnabled,\n serverActions: serverActionsEnabled,\n serverComponents: serverComponentsEnabled,\n reactCompiler: reactCompilerEnabled,\n optimizeGraph: env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH,\n treeshaking: env.EXPO_UNSTABLE_TREE_SHAKING,\n logbox: env.EXPO_UNSTABLE_LOG_BOX,\n },\n });\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\ninterface InstantiateMetroConfigOptions extends LoadMetroConfigOptions {\n host?: string;\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: InstantiateMetroConfigOptions,\n {\n isExporting,\n exp = getConfig(metroBundler.projectRoot, {\n skipSDKVersionRequirement: true,\n }).exp,\n devToolsPluginManager,\n }: {\n isExporting: boolean;\n exp?: ExpoConfig;\n devToolsPluginManager: DevToolsPluginManager;\n }\n): Promise<{\n metro: MetroServer;\n hmrServer: MetroHmrServer<MetroHmrClient> | null;\n server: http.Server;\n address: ServerAddressInfo | null;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n const getMetroBundler = () => metro.getBundler().getBundler();\n\n const {\n config: metroConfig,\n setEventReporter,\n reporter,\n } = await loadMetroConfigAsync(projectRoot, options, {\n exp,\n isExporting,\n getMetroBundler,\n });\n\n // Get local URL to Metro bundler server (typically configured as 127.0.0.1:8081)\n const serverBaseUrl = metroBundler\n .getUrlCreator()\n .constructUrl({ scheme: 'http', hostType: 'localhost' });\n\n // Create the core middleware stack for Metro, including websocket listeners\n const { middleware, messagesSocket, eventsSocket, websocketEndpoints } = createMetroMiddleware(\n metroConfig,\n { getMetroBundler, serverBaseUrl }\n );\n\n if (!isExporting) {\n // Enable correct CORS headers for Expo Router features\n prependMiddleware(middleware, createCorsMiddleware(exp));\n\n // Enable debug middleware for CDP-related debugging\n const { debugMiddleware, debugWebsocketEndpoints } = createDebugMiddleware({\n serverBaseUrl,\n reporter,\n });\n Object.assign(websocketEndpoints, debugWebsocketEndpoints);\n middleware.use(debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware({ serverBaseUrl }));\n\n // TODO(cedric): `enhanceMiddleware` is deprecated, but is currently used to unify the middleware stacks\n // See: https://github.com/facebook/metro/commit/22e85fde85ec454792a1b70eba4253747a2587a9\n // See: https://github.com/facebook/metro/commit/d0d554381f119bb80ab09dbd6a1d310b54737e52\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n asWritable(metroConfig.server).enhanceMiddleware = (\n metroMiddleware: any,\n server: MetroServer\n ) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n const devtoolsWebsocketEndpoints = createDevToolsPluginWebsocketEndpoint();\n Object.assign(websocketEndpoints, devtoolsWebsocketEndpoints);\n\n // Register WebSocket endpoints contributed by DevTools plugins. A plugin's `serverEntryPoint`\n // exports a `webSocketHandlers` map (route -> connection handler); each becomes a `ws` server\n // mounted at `/_expo/plugins/<name>/<route>`, reusing Metro's exact-path upgrade dispatch (and\n // its shutdown cleanup). Endpoints must be known before the server starts, so unlike the\n // fetch-based request handler, plugin server modules are loaded eagerly here.\n for (const plugin of await devToolsPluginManager.queryPluginsAsync()) {\n try {\n for (const [route, server] of Object.entries(await plugin.getWebSocketServersAsync())) {\n Object.assign(websocketEndpoints, {\n [`${DevToolsPluginEndpoint}/${plugin.packageName}${route}`]: server,\n });\n }\n } catch (error: any) {\n Log.warn(\n `Skipping WebSocket endpoints for DevTools plugin \"${plugin.packageName}\": ${error.message ?? error}`\n );\n }\n }\n }\n\n // Attach Expo Atlas if enabled\n await attachAtlasAsync({\n isExporting,\n exp,\n projectRoot,\n middleware,\n metroConfig,\n // NOTE(cedric): reset the Atlas file once, and reuse it for static exports\n resetAtlasFile: isExporting,\n });\n\n // Support HTTPS based on the metro's tls server config\n // TODO(@kitten): Remove cast once `@expo/metro` is updated to a Metro version that supports the tls config\n const tls = (metroConfig.server as typeof metroConfig.server & { tls?: SecureServerOptions })\n ?.tls;\n const secureServerOptions = tls\n ? {\n key: tls.key,\n cert: tls.cert,\n ca: tls.ca,\n requestCert: tls.requestCert,\n }\n : undefined;\n\n const watch = !isExporting && isWatchEnabled();\n\n const { address, server, hmrServer, metro } = await replaceMetroFileMap(() => {\n return runServer(\n metroBundler,\n metroConfig,\n {\n host: options.host,\n websocketEndpoints,\n watch,\n secureServerOptions,\n },\n {\n mockServer: isExporting,\n }\n );\n });\n\n event('instantiate', {\n atlas: env.EXPO_ATLAS,\n workers: metroConfig.maxWorkers ?? null,\n host: address?.address ?? null,\n port: address?.port ?? null,\n });\n\n // Patch transform file to remove inconvenient customTransformOptions which are only used in single well-known files.\n const originalTransformFile = metro\n .getBundler()\n .getBundler()\n .transformFile.bind(metro.getBundler().getBundler());\n\n metro.getBundler().getBundler().transformFile = async function (\n filePath: string,\n transformOptions: TransformOptions,\n fileBuffer?: Buffer\n ) {\n return originalTransformFile(\n filePath,\n pruneCustomTransformOptions(\n projectRoot,\n filePath,\n // Clone the options so we don't mutate the original.\n {\n ...transformOptions,\n customTransformOptions: {\n __proto__: null,\n ...transformOptions.customTransformOptions,\n },\n }\n ),\n fileBuffer\n );\n };\n\n // Layered on top of the prune patch above. Both fresh worker results\n // and cache hits flow through `Bundler.transformFile`, so wrapping\n // here covers both.\n patchTransformFileForPackedMaps(metro.getBundler().getBundler());\n patchMetroSourceMapStringForPackedMaps();\n\n setEventReporter(eventsSocket.reportMetroEvent);\n\n // This function ensures that modules in source maps are sorted in the same\n // order as in a plain JS bundle.\n metro._getSortedModules = function (this: MetroServerWithModuleIdMod, graph: ReadOnlyGraph) {\n const modules = [...graph.dependencies.values()];\n\n const ctx = {\n // TODO(@kitten): Increase type-safety here\n platform: graph.transformOptions.platform!,\n environment: graph.transformOptions.customTransformOptions?.environment,\n };\n // Assign IDs to modules in a consistent order\n for (const module of modules) {\n this._createModuleId(module.path, ctx);\n }\n // Sort by IDs\n return modules.sort(\n (a, b) => this._createModuleId(a.path, ctx) - this._createModuleId(b.path, ctx)\n );\n };\n\n if (hmrServer) {\n let hmrJSBundle:\n | typeof import('@expo/metro-config/build/serializer/fork/hmrJSBundle').default\n | typeof import('@expo/metro/metro/DeltaBundler/Serializers/hmrJSBundle').default;\n\n try {\n hmrJSBundle = require('@expo/metro-config/build/serializer/fork/hmrJSBundle').default;\n } catch {\n // TODO: Add fallback for monorepo tests up until the fork is merged.\n Log.warn('Failed to load HMR serializer from @expo/metro-config, using fallback version.');\n hmrJSBundle = require('@expo/metro/metro/DeltaBundler/Serializers/hmrJSBundle');\n }\n\n // Patch HMR Server to send more info to the `_createModuleId` function for deterministic module IDs and add support for serializing HMR updates the same as all other bundles.\n hmrServer._prepareMessage = async function (\n this: MetroHmrServerWithModuleIdMod,\n group,\n options,\n changeEvent\n ) {\n // Fork of https://github.com/facebook/metro/blob/3b3e0aaf725cfa6907bf2c8b5fbc0da352d29efe/packages/metro/src/HmrServer.js#L327-L393\n // with patch for `_createModuleId`.\n const logger = !options.isInitialUpdate ? changeEvent?.logger : null;\n try {\n const revPromise = this._bundler.getRevision(group.revisionId);\n if (!revPromise) {\n return {\n type: 'error',\n body: formatBundlingError(new RevisionNotFoundError(group.revisionId)),\n };\n }\n logger?.point('updateGraph_start');\n const { revision, delta } = await this._bundler.updateGraph(await revPromise, false);\n logger?.point('updateGraph_end');\n this._clientGroups.delete(group.revisionId);\n group.revisionId = revision.id;\n for (const client of group.clients) {\n client.revisionIds = client.revisionIds.filter(\n (revisionId) => revisionId !== group.revisionId\n );\n client.revisionIds.push(revision.id);\n }\n this._clientGroups.set(group.revisionId, group);\n logger?.point('serialize_start');\n // NOTE(EvanBacon): This is the patch\n const moduleIdContext = {\n // TODO(@kitten): Increase type-safety here\n platform: revision.graph.transformOptions.platform!,\n environment: revision.graph.transformOptions.customTransformOptions?.environment,\n };\n const hmrUpdate = hmrJSBundle(delta, revision.graph, {\n clientUrl: group.clientUrl,\n // NOTE(EvanBacon): This is also the patch\n createModuleId: (moduleId: string) => {\n return this._createModuleId(moduleId, moduleIdContext);\n },\n includeAsyncPaths: group.graphOptions.lazy,\n projectRoot: this._config.projectRoot,\n serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,\n });\n logger?.point('serialize_end');\n return {\n type: 'update',\n body: {\n revisionId: revision.id,\n isInitialUpdate: options.isInitialUpdate,\n ...hmrUpdate,\n },\n };\n } catch (error: any) {\n const formattedError = formatBundlingError(error);\n this._config.reporter.update({\n type: 'bundling_error',\n error,\n });\n return {\n type: 'error',\n body: formattedError,\n };\n }\n };\n }\n\n return {\n metro,\n hmrServer,\n server,\n middleware,\n messageSocket: messagesSocket,\n address,\n };\n}\n\n// TODO: Fork the entire transform function so we can simply regex the file contents for keywords instead.\nfunction pruneCustomTransformOptions(\n projectRoot: string,\n filePath: string,\n transformOptions: TransformOptions\n): TransformOptions {\n // Normalize the filepath for cross platform checking.\n filePath = filePath.split(path.sep).join('/');\n\n if (\n transformOptions.customTransformOptions?.dom &&\n // The only generated file that needs the dom root is `expo/dom/entry.js`\n !filePath.match(/expo\\/dom\\/entry\\.js$/)\n ) {\n // Clear the dom root option if we aren't transforming the magic entry file, this ensures\n // that cached artifacts from other DOM component bundles can be reused.\n transformOptions.customTransformOptions.dom = 'true';\n }\n\n const routerRoot = transformOptions.customTransformOptions?.routerRoot;\n if (typeof routerRoot === 'string') {\n const isRouterEntry = /\\/expo-router\\/_ctx/.test(filePath);\n // The router root is used all over expo-router (`process.env.EXPO_ROUTER_ABS_APP_ROOT`, `process.env.EXPO_ROUTER_APP_ROOT`) so we'll just ignore the entire package.\n const isRouterModule = /\\/expo-router\\/build\\//.test(filePath);\n // Any page/router inside the expo-router app folder may access the `routerRoot` option to determine whether it's in the app folder\n const resolvedRouterRoot = path.resolve(projectRoot, routerRoot).split(path.sep).join('/');\n const isRouterRoute = path.isAbsolute(filePath) && filePath.startsWith(resolvedRouterRoot);\n\n // In any other file than the above, we enforce that we mustn't use `routerRoot`, and set it to an arbitrary value here (the default)\n // to ensure that the cache never invalidates when this value is changed\n if (!isRouterEntry && !isRouterModule && !isRouterRoute) {\n transformOptions.customTransformOptions!.routerRoot = 'app';\n }\n }\n\n if (\n transformOptions.customTransformOptions?.asyncRoutes &&\n // The async routes settings are also used in `expo-router/_ctx.ios.js` (and other platform variants) via `process.env.EXPO_ROUTER_IMPORT_MODE`\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n delete transformOptions.customTransformOptions.asyncRoutes;\n }\n\n if (\n transformOptions.customTransformOptions?.clientBoundaries &&\n // The client boundaries are only used in `expo/virtual/rsc.js` for production RSC exports.\n !filePath.match(/\\/expo\\/virtual\\/rsc\\.js$/)\n ) {\n delete transformOptions.customTransformOptions.clientBoundaries;\n }\n\n return transformOptions;\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":["event","instantiateMetroAsync","isWatchEnabled","loadMetroConfigAsync","events","t","asWritable","input","LogRespectingTerminal","Terminal","stream","ttyPrint","sendLog","msg","length","log","format","args","flush","sendStderr","logStderr","require","console","info","warn","error","process","on","status","lines","splice","stderr","write","join","line","stdout","isTTY","push","prev","terminal","projectRoot","options","exp","isExporting","getMetroBundler","config","reportEvent","serverRoot","getMetroServerRoot","isWorkspace","targetsOutOfTreePlatform","getPlatformsFromConfig","some","platform","autolinkingModuleResolutionEnabled","experiments","autolinkingModuleResolution","serverActionsEnabled","reactServerFunctions","env","EXPO_UNSTABLE_SERVER_FUNCTIONS","serverComponentsEnabled","reactServerComponentRoutes","EXPO_USE_METRO_REQUIRE","reactCanary","Log","terminalReporter","MetroTerminalReporter","loadUserConfig","overrideConfigPath","EXPO_OVERRIDE_METRO_CONFIG","undefined","resetCache","maxWorkers","server","port","reporter","update","onDemandFilesystem","resolver","unstable_onDemandFilesystem","globalThis","__requireCycleIgnorePatterns","requireCycleIgnorePatterns","transformer","publicPath","baseUrl","platformBundlers","getPlatformBundlers","reduceLogs","shouldReduceLogs","reactCompilerEnabled","reactCompiler","chalk","gray","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","CommandError","EXPO_UNSTABLE_LOG_BOX","workletsBundleModeEnabled","serializer","polyfillModuleNames","modulePath","includes","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","isAutolinkingResolverEnabled","isNamedRequiresEnabled","isReactServerComponentsEnabled","path","exporting","flags","serverActions","serverComponents","optimizeGraph","treeshaking","logbox","setEventReporter","logger","metroBundler","getConfig","skipSDKVersionRequirement","devToolsPluginManager","metroConfig","metro","getBundler","serverBaseUrl","getUrlCreator","constructUrl","scheme","hostType","middleware","messagesSocket","eventsSocket","websocketEndpoints","createMetroMiddleware","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","devtoolsWebsocketEndpoints","createDevToolsPluginWebsocketEndpoint","plugin","queryPluginsAsync","route","entries","getWebSocketServersAsync","DevToolsPluginEndpoint","packageName","message","attachAtlasAsync","resetAtlasFile","tls","secureServerOptions","key","cert","ca","requestCert","watch","address","hmrServer","replaceMetroFileMap","runServer","host","mockServer","atlas","EXPO_ATLAS","workers","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","patchTransformFileForPackedMaps","patchMetroSourceMapStringForPackedMaps","reportMetroEvent","_getSortedModules","graph","modules","dependencies","values","ctx","environment","module","_createModuleId","sort","a","b","hmrJSBundle","default","_prepareMessage","group","changeEvent","isInitialUpdate","revision","revPromise","_bundler","getRevision","revisionId","type","body","formatBundlingError","RevisionNotFoundError","point","delta","updateGraph","_clientGroups","delete","id","client","clients","revisionIds","filter","set","moduleIdContext","hmrUpdate","clientUrl","createModuleId","moduleId","includeAsyncPaths","graphOptions","lazy","_config","unstable_serverRoot","formattedError","messageSocket","split","sep","dom","match","routerRoot","isRouterEntry","test","isRouterModule","resolvedRouterRoot","resolve","isRouterRoute","isAbsolute","startsWith","asyncRoutes","clientBoundaries","CI"],"mappings":";;;;;;;;;;;QAyCaA;eAAAA;;QAuTSC;eAAAA;;QAiWNC;eAAAA;;QA3gBMC;eAAAA;;;;yBAtL6C;;;;;;;yBAChC;;;;;;;gEAOD;;;;;;;gEAEF;;;;;;;yBACP;;;;;;;yBAEM;;;;;;;yBACiB;;;;;;;yBACO;;;;;;;gEACrC;;;;;;;gEAED;;;;;;iDAEqC;uCAEhB;mCACF;6BACH;uCACK;uCACA;+BACsC;wCAChC;wBACH;qBACrB;qBACA;wBACS;uCAEU;gCACF;6CACO;2BACV;kCACE;;;;;;AAG7B,MAAMH,QAAQI,IAAAA,cAAM,EAAC,SAAS,CAACC,IAAM;QAC1CA,EAAEL,KAAK;QAcPK,EAAEL,KAAK;KAMR;AAsBD,SAASM,WAAcC,KAAQ;IAC7B,OAAOA;AACT;AAEA;;;;;;;;;CASC,GACD,MAAMC,8BAA8BC,qBAAQ;IAC1C,CAAA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qBAAvCH,0CAAyCwE,gBAAgB,KACzD,2FAA2F;IAC3F,CAACzE,SAAS8D,KAAK,CAAC,8BAChB;QACA,OAAO7D,iBAAiBG,sBAAsB,CAACqE,gBAAgB;IACjE;IAEA,OAAOxE;AACT;AAMO,SAASnL;IACd,IAAIyD,QAAG,CAACmM,EAAE,EAAE;QACV7L,QAAG,CAAClD,GAAG,CACL8E,IAAAA,gBAAK,CAAA,CAAC,8FAA8F,CAAC;IAEzG;IAEA,OAAO,CAAClC,QAAG,CAACmM,EAAE;AAChB"}
|
|
@@ -38,7 +38,7 @@ function _send() {
|
|
|
38
38
|
return data;
|
|
39
39
|
}
|
|
40
40
|
const _ExpoMiddleware = require("./ExpoMiddleware");
|
|
41
|
-
const _DevToolsPluginManager = require("../DevToolsPluginManager");
|
|
41
|
+
const _DevToolsPluginManager = require("../devtools/DevToolsPluginManager");
|
|
42
42
|
function _interop_require_default(obj) {
|
|
43
43
|
return obj && obj.__esModule ? obj : {
|
|
44
44
|
default: obj
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/DevToolsPluginMiddleware.ts"],"sourcesContent":["import assert from 'assert';\nimport { convertRequest, respond } from 'expo-server/adapter/http';\nimport type * as http from 'http';\nimport send from 'send';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport type { ServerRequest, ServerResponse } from './server.types';\nimport type { DevToolsPlugin } from '../DevToolsPlugin';\nimport type DevToolsPluginManager from '../DevToolsPluginManager';\nimport { DevToolsPluginEndpoint } from '../DevToolsPluginManager';\n\nconst debug = require('debug')('expo:start:server:middleware:devToolsPlugin') as typeof console.log;\n\nexport { DevToolsPluginEndpoint };\n\nexport class DevToolsPluginMiddleware extends ExpoMiddleware {\n constructor(\n projectRoot: string,\n private readonly pluginManager: DevToolsPluginManager\n ) {\n super(projectRoot, [DevToolsPluginEndpoint]);\n }\n\n override shouldHandleRequest(req: ServerRequest): boolean {\n if (!req.url?.startsWith(DevToolsPluginEndpoint)) {\n return false;\n }\n return true;\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n assert(req.headers.host, 'Request headers must include host');\n const { pathname, search } = new URL(req.url ?? '/', `http://${req.headers.host}`);\n const pluginName = this.queryPossiblePluginName(\n pathname.substring(DevToolsPluginEndpoint.length + 1)\n );\n const plugin = await this.pluginManager.queryPluginAsync(pluginName);\n if (!plugin) {\n res.statusCode = 404;\n res.end();\n return;\n }\n\n const pathInPluginRoot =\n pathname.substring(DevToolsPluginEndpoint.length + pluginName.length + 1) || '/';\n\n if (plugin.serverEntryPoint != null) {\n const handled = await this.handleWithPluginServerAsync(\n plugin,\n req,\n res,\n `${pathInPluginRoot}${search}`\n );\n if (handled) {\n return;\n }\n }\n\n if (plugin.webpageRoot != null) {\n send(req, pathInPluginRoot, { root: plugin.webpageRoot }).pipe(res);\n return;\n }\n\n res.statusCode = 404;\n res.end();\n }\n\n /**\n * Passes the request to the plugin's `serverEntryPoint` fetch handler with the plugin\n * endpoint prefix stripped from the URL. Returns false when the handler returns no\n * response, so the request falls through to static `webpageRoot` serving.\n */\n private async handleWithPluginServerAsync(\n plugin: DevToolsPlugin,\n req: ServerRequest,\n res: ServerResponse,\n urlInPluginRoot: string\n ): Promise<boolean> {\n const originalUrl = req.url;\n let request: Request | undefined;\n try {\n req.url = urlInPluginRoot;\n request = convertRequest(req as http.IncomingMessage, res as http.ServerResponse);\n const handler = await plugin.getRequestHandlerAsync();\n const response = await handler?.(request);\n if (response == null) {\n return false;\n }\n await respond(res as http.ServerResponse, response, { signal: request.signal });\n return true;\n } catch (error: any) {\n debug('DevTools plugin server request failed: %O', error);\n if (res.headersSent || res.writableEnded || res.destroyed || request?.signal.aborted) {\n return true;\n }\n res.statusCode = 500;\n res.setHeader('Content-Type', 'text/plain');\n res.end(\n `The DevTools plugin \"${plugin.packageName}\" failed to handle the request to \"${urlInPluginRoot}\": ` +\n `${error?.message ?? error}. This is likely a bug in the plugin's server entry point ` +\n `(${plugin.serverEntryPoint}); report it to the plugin author.`\n );\n return true;\n } finally {\n req.url = originalUrl;\n }\n }\n\n private queryPossiblePluginName(pathname: string): string {\n const parts = pathname.split('/');\n if (parts[0]![0] === '@' && parts.length > 1) {\n // Scoped package name\n return `${parts[0]}/${parts[1]}`;\n }\n return parts[0]!;\n }\n}\n"],"names":["DevToolsPluginEndpoint","DevToolsPluginMiddleware","debug","require","ExpoMiddleware","projectRoot","pluginManager","shouldHandleRequest","req","url","startsWith","handleRequestAsync","res","assert","headers","host","pathname","search","URL","pluginName","queryPossiblePluginName","substring","length","plugin","queryPluginAsync","statusCode","end","pathInPluginRoot","serverEntryPoint","handled","handleWithPluginServerAsync","webpageRoot","send","root","pipe","urlInPluginRoot","originalUrl","request","convertRequest","handler","getRequestHandlerAsync","response","respond","signal","error","headersSent","writableEnded","destroyed","aborted","setHeader","packageName","message","parts","split"],"mappings":";;;;;;;;;;;QAaSA;eAAAA,6CAAsB;;QAElBC;eAAAA;;;;gEAfM;;;;;;;yBACqB;;;;;;;gEAEvB;;;;;;gCAEc;uCAIQ;;;;;;AAEvC,MAAMC,QAAQC,QAAQ,SAAS;AAIxB,MAAMF,iCAAiCG,8BAAc;IAC1D,YACEC,WAAmB,EACnB,AAAiBC,aAAoC,CACrD;QACA,KAAK,CAACD,aAAa;YAACL,6CAAsB;SAAC,QAF1BM,gBAAAA;IAGnB;IAESC,oBAAoBC,GAAkB,EAAW;YACnDA;QAAL,IAAI,GAACA,WAAAA,IAAIC,GAAG,qBAAPD,SAASE,UAAU,CAACV,6CAAsB,IAAG;YAChD,OAAO;QACT;QACA,OAAO;IACT;IAEA,MAAMW,mBAAmBH,GAAkB,EAAEI,GAAmB,EAAiB;QAC/EC,IAAAA,iBAAM,EAACL,IAAIM,OAAO,CAACC,IAAI,EAAE;QACzB,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAG,IAAIC,IAAIV,IAAIC,GAAG,IAAI,KAAK,CAAC,OAAO,EAAED,IAAI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M,6CAA6C0C;YACnD,IAAIhC,IAAIiC,WAAW,IAAIjC,IAAIkC,aAAa,IAAIlC,IAAImC,SAAS,KAAIV,2BAAAA,QAASM,MAAM,CAACK,OAAO,GAAE;gBACpF,OAAO;YACT;YACApC,IAAIa,UAAU,GAAG;YACjBb,IAAIqC,SAAS,CAAC,gBAAgB;YAC9BrC,IAAIc,GAAG,CACL,CAAC,qBAAqB,EAAEH,OAAO2B,WAAW,CAAC,mCAAmC,EAAEf,gBAAgB,GAAG,CAAC,GAClG,GAAGS,CAAAA,yBAAAA,MAAOO,OAAO,KAAIP,MAAM,0DAA0D,CAAC,GACtF,CAAC,CAAC,EAAErB,OAAOK,gBAAgB,CAAC,kCAAkC,CAAC;YAEnE,OAAO;QACT,SAAU;YACRpB,IAAIC,GAAG,GAAG2B;QACZ;IACF;IAEQhB,wBAAwBJ,QAAgB,EAAU;QACxD,MAAMoC,QAAQpC,SAASqC,KAAK,CAAC;QAC7B,IAAID,KAAK,CAAC,EAAE,AAAC,CAAC,EAAE,KAAK,OAAOA,MAAM9B,MAAM,GAAG,GAAG;YAC5C,sBAAsB;YACtB,OAAO,GAAG8B,KAAK,CAAC,EAAE,CAAC,CAAC,EAAEA,KAAK,CAAC,EAAE,EAAE;QAClC;QACA,OAAOA,KAAK,CAAC,EAAE;IACjB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/DevToolsPluginMiddleware.ts"],"sourcesContent":["import assert from 'assert';\nimport { convertRequest, respond } from 'expo-server/adapter/http';\nimport type * as http from 'http';\nimport send from 'send';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport type { ServerRequest, ServerResponse } from './server.types';\nimport type { DevToolsPlugin } from '../devtools/DevToolsPlugin';\nimport type DevToolsPluginManager from '../devtools/DevToolsPluginManager';\nimport { DevToolsPluginEndpoint } from '../devtools/DevToolsPluginManager';\n\nconst debug = require('debug')('expo:start:server:middleware:devToolsPlugin') as typeof console.log;\n\nexport { DevToolsPluginEndpoint };\n\nexport class DevToolsPluginMiddleware extends ExpoMiddleware {\n constructor(\n projectRoot: string,\n private readonly pluginManager: DevToolsPluginManager\n ) {\n super(projectRoot, [DevToolsPluginEndpoint]);\n }\n\n override shouldHandleRequest(req: ServerRequest): boolean {\n if (!req.url?.startsWith(DevToolsPluginEndpoint)) {\n return false;\n }\n return true;\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n assert(req.headers.host, 'Request headers must include host');\n const { pathname, search } = new URL(req.url ?? '/', `http://${req.headers.host}`);\n const pluginName = this.queryPossiblePluginName(\n pathname.substring(DevToolsPluginEndpoint.length + 1)\n );\n const plugin = await this.pluginManager.queryPluginAsync(pluginName);\n if (!plugin) {\n res.statusCode = 404;\n res.end();\n return;\n }\n\n const pathInPluginRoot =\n pathname.substring(DevToolsPluginEndpoint.length + pluginName.length + 1) || '/';\n\n if (plugin.serverEntryPoint != null) {\n const handled = await this.handleWithPluginServerAsync(\n plugin,\n req,\n res,\n `${pathInPluginRoot}${search}`\n );\n if (handled) {\n return;\n }\n }\n\n if (plugin.webpageRoot != null) {\n send(req, pathInPluginRoot, { root: plugin.webpageRoot }).pipe(res);\n return;\n }\n\n res.statusCode = 404;\n res.end();\n }\n\n /**\n * Passes the request to the plugin's `serverEntryPoint` fetch handler with the plugin\n * endpoint prefix stripped from the URL. Returns false when the handler returns no\n * response, so the request falls through to static `webpageRoot` serving.\n */\n private async handleWithPluginServerAsync(\n plugin: DevToolsPlugin,\n req: ServerRequest,\n res: ServerResponse,\n urlInPluginRoot: string\n ): Promise<boolean> {\n const originalUrl = req.url;\n let request: Request | undefined;\n try {\n req.url = urlInPluginRoot;\n request = convertRequest(req as http.IncomingMessage, res as http.ServerResponse);\n const handler = await plugin.getRequestHandlerAsync();\n const response = await handler?.(request);\n if (response == null) {\n return false;\n }\n await respond(res as http.ServerResponse, response, { signal: request.signal });\n return true;\n } catch (error: any) {\n debug('DevTools plugin server request failed: %O', error);\n if (res.headersSent || res.writableEnded || res.destroyed || request?.signal.aborted) {\n return true;\n }\n res.statusCode = 500;\n res.setHeader('Content-Type', 'text/plain');\n res.end(\n `The DevTools plugin \"${plugin.packageName}\" failed to handle the request to \"${urlInPluginRoot}\": ` +\n `${error?.message ?? error}. This is likely a bug in the plugin's server entry point ` +\n `(${plugin.serverEntryPoint}); report it to the plugin author.`\n );\n return true;\n } finally {\n req.url = originalUrl;\n }\n }\n\n private queryPossiblePluginName(pathname: string): string {\n const parts = pathname.split('/');\n if (parts[0]![0] === '@' && parts.length > 1) {\n // Scoped package name\n return `${parts[0]}/${parts[1]}`;\n }\n return parts[0]!;\n }\n}\n"],"names":["DevToolsPluginEndpoint","DevToolsPluginMiddleware","debug","require","ExpoMiddleware","projectRoot","pluginManager","shouldHandleRequest","req","url","startsWith","handleRequestAsync","res","assert","headers","host","pathname","search","URL","pluginName","queryPossiblePluginName","substring","length","plugin","queryPluginAsync","statusCode","end","pathInPluginRoot","serverEntryPoint","handled","handleWithPluginServerAsync","webpageRoot","send","root","pipe","urlInPluginRoot","originalUrl","request","convertRequest","handler","getRequestHandlerAsync","response","respond","signal","error","headersSent","writableEnded","destroyed","aborted","setHeader","packageName","message","parts","split"],"mappings":";;;;;;;;;;;QAaSA;eAAAA,6CAAsB;;QAElBC;eAAAA;;;;gEAfM;;;;;;;yBACqB;;;;;;;gEAEvB;;;;;;gCAEc;uCAIQ;;;;;;AAEvC,MAAMC,QAAQC,QAAQ,SAAS;AAIxB,MAAMF,iCAAiCG,8BAAc;IAC1D,YACEC,WAAmB,EACnB,AAAiBC,aAAoC,CACrD;QACA,KAAK,CAACD,aAAa;YAACL,6CAAsB;SAAC,QAF1BM,gBAAAA;IAGnB;IAESC,oBAAoBC,GAAkB,EAAW;YACnDA;QAAL,IAAI,GAACA,WAAAA,IAAIC,GAAG,qBAAPD,SAASE,UAAU,CAACV,6CAAsB,IAAG;YAChD,OAAO;QACT;QACA,OAAO;IACT;IAEA,MAAMW,mBAAmBH,GAAkB,EAA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,2BAAAA,QAAUF;YACjC,IAAII,YAAY,MAAM;gBACpB,OAAO;YACT;YACA,MAAMC,IAAAA,eAAO,EAAC9B,KAA4B6B,UAAU;gBAAEE,QAAQN,QAAQM,MAAM;YAAC;YAC7E,OAAO;QACT,EAAE,OAAOC,OAAY;YACnB1C,MAAM,6CAA6C0C;YACnD,IAAIhC,IAAIiC,WAAW,IAAIjC,IAAIkC,aAAa,IAAIlC,IAAImC,SAAS,KAAIV,2BAAAA,QAASM,MAAM,CAACK,OAAO,GAAE;gBACpF,OAAO;YACT;YACApC,IAAIa,UAAU,GAAG;YACjBb,IAAIqC,SAAS,CAAC,gBAAgB;YAC9BrC,IAAIc,GAAG,CACL,CAAC,qBAAqB,EAAEH,OAAO2B,WAAW,CAAC,mCAAmC,EAAEf,gBAAgB,GAAG,CAAC,GAClG,GAAGS,CAAAA,yBAAAA,MAAOO,OAAO,KAAIP,MAAM,0DAA0D,CAAC,GACtF,CAAC,CAAC,EAAErB,OAAOK,gBAAgB,CAAC,kCAAkC,CAAC;YAEnE,OAAO;QACT,SAAU;YACRpB,IAAIC,GAAG,GAAG2B;QACZ;IACF;IAEQhB,wBAAwBJ,QAAgB,EAAU;QACxD,MAAMoC,QAAQpC,SAASqC,KAAK,CAAC;QAC7B,IAAID,KAAK,CAAC,EAAE,AAAC,CAAC,EAAE,KAAK,OAAOA,MAAM9B,MAAM,GAAG,GAAG;YAC5C,sBAAsB;YACtB,OAAO,GAAG8B,KAAK,CAAC,EAAE,CAAC,CAAC,EAAEA,KAAK,CAAC,EAAE,EAAE;QAClC;QACA,OAAOA,KAAK,CAAC,EAAE;IACjB;AACF"}
|
|
@@ -215,7 +215,7 @@ function createBundleOsPath(options) {
|
|
|
215
215
|
return `${mainModuleName}.bundle?${queryParams.toString()}`;
|
|
216
216
|
}
|
|
217
217
|
function createBundleUrlSearchParams(options) {
|
|
218
|
-
const { platform, mode, minify, environment, serializerOutput, serializerIncludeMaps, lazy, bytecode, engine, preserveEnvVars, asyncRoutes, baseUrl, routerRoot, reactCompiler, inlineSourceMap, isExporting, clientBoundaries, splitChunks, usedExports, optimize, domRoot, modulesOnly, runModule, hosted, liveBindings } = withDefaults(options);
|
|
218
|
+
const { platform, mode, minify, environment, serializerOutput, serializerIncludeMaps, lazy, bytecode, engine, preserveEnvVars, asyncRoutes, baseUrl, routerRoot, reactCompiler, inlineSourceMap, isExporting, clientBoundaries, splitChunks, usedExports, optimize, domRoot, modulesOnly, runModule, hosted, liveBindings, isLoaderBundle } = withDefaults(options);
|
|
219
219
|
const dev = String(mode !== 'production');
|
|
220
220
|
const queryParams = new URLSearchParams({
|
|
221
221
|
platform: encodeURIComponent(platform),
|
|
@@ -266,6 +266,9 @@ function createBundleUrlSearchParams(options) {
|
|
|
266
266
|
if (hosted) {
|
|
267
267
|
queryParams.append('transform.hosted', '1');
|
|
268
268
|
}
|
|
269
|
+
if (isLoaderBundle) {
|
|
270
|
+
queryParams.append('transform.isLoaderBundle', 'true');
|
|
271
|
+
}
|
|
269
272
|
if (environment) {
|
|
270
273
|
queryParams.append('resolver.environment', environment);
|
|
271
274
|
queryParams.append('transform.environment', environment);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/metroOptions.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport Server from '@expo/metro/metro/Server';\nimport type { BundleOptions as MetroBundleOptions } from '@expo/metro/metro/shared/types';\n\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { toPosixPath } from '../../../utils/filePath';\nimport { getRouterDirectoryModuleIdWithManifest } from '../metro/router';\n\nconst debug = require('debug')('expo:metro:options') as typeof console.log;\n\n/** Enforce conversion of `true` to `'true'` */\nfunction toBoolStr(x: true): 'true';\nfunction toBoolStr(x: false): 'false';\nfunction toBoolStr(x: boolean): 'true' | 'false';\nfunction toBoolStr(x: boolean): 'true' | 'false' {\n return x ? 'true' : 'false';\n}\n\nexport type MetroEnvironment = 'node' | 'react-server' | 'client';\n\nexport type ExpoMetroOptions = {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: MetroEnvironment;\n serializerOutput?: 'static';\n serializerIncludeMaps?: boolean;\n lazy?: boolean;\n engine?: 'hermes';\n preserveEnvVars?: boolean;\n bytecode?: boolean;\n /** Enable async routes (route-based bundle splitting) in Expo Router. */\n asyncRoutes?: boolean;\n /** Module ID relative to the projectRoot for the Expo Router app directory. */\n routerRoot?: string;\n /** Enable React compiler support in Babel. */\n reactCompiler?: boolean;\n baseUrl?: string;\n isExporting: boolean;\n /** Is bundling a DOM Component (\"use dom\"). Requires the entry dom component file path. */\n domRoot?: string;\n /** Exporting MD5 filename based on file contents, for EAS Update. */\n useMd5Filename?: boolean;\n inlineSourceMap?: boolean;\n clientBoundaries?: string[];\n splitChunks?: boolean;\n usedExports?: boolean;\n /** Enable optimized bundling (required for tree shaking). */\n optimize?: boolean;\n\n modulesOnly?: boolean;\n runModule?: boolean;\n\n /** When true, omits `sourcesContent` from generated source maps (saves ~80x memory for SSR). */\n excludeSource?: boolean;\n\n /** Should assets be exported for hosting. Always true on web. Always false for embedded builds. Optional for native exports. */\n hosted?: boolean;\n /** Disable live bindings (enabled by default, required for circular deps) in experimental import export support. */\n liveBindings?: boolean;\n /** When true, indicates this bundle should contain only the loader export. */\n isLoaderBundle?: boolean;\n};\n\n// See: @expo/metro-config/src/serializer/fork/baseJSBundle.ts `ExpoSerializerOptions`\nexport type SerializerOptions = {\n includeSourceMaps?: boolean;\n output?: 'static';\n splitChunks?: boolean;\n usedExports?: boolean;\n exporting?: boolean;\n};\n\nexport type ExpoMetroBundleOptions = MetroBundleOptions & {\n serializerOptions?: SerializerOptions;\n};\n\nexport function isServerEnvironment(environment?: any): boolean {\n return environment === 'node' || environment === 'react-server';\n}\n\nfunction withDefaults({\n mode = 'development',\n minify = mode === 'production',\n preserveEnvVars = mode !== 'development' && env.EXPO_NO_CLIENT_ENV_VARS,\n lazy,\n environment,\n ...props\n}: ExpoMetroOptions): ExpoMetroOptions {\n if (props.bytecode) {\n if (props.platform === 'web') {\n throw new CommandError('Cannot use bytecode with the web platform');\n }\n if (props.engine !== 'hermes') {\n throw new CommandError('Bytecode is only supported with the Hermes engine');\n }\n }\n\n const optimize =\n props.optimize ??\n (environment !== 'node' && mode === 'production' && env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH);\n\n return {\n mode,\n minify,\n preserveEnvVars,\n optimize,\n usedExports: optimize && env.EXPO_UNSTABLE_TREE_SHAKING,\n lazy: !props.isExporting && lazy,\n environment: environment === 'client' ? undefined : environment,\n liveBindings: env.EXPO_UNSTABLE_LIVE_BINDINGS,\n excludeSource: isServerEnvironment(environment),\n ...props,\n };\n}\n\nexport function getBaseUrlFromExpoConfig(exp: ExpoConfig) {\n return exp.experiments?.baseUrl?.trim().replace(/\\/+$/, '') ?? '';\n}\n\nexport function getAsyncRoutesFromExpoConfig(exp: ExpoConfig, mode: string, platform: string) {\n let asyncRoutesSetting;\n\n if (exp.extra?.router?.asyncRoutes) {\n const asyncRoutes = exp.extra?.router?.asyncRoutes;\n if (['boolean', 'string'].includes(typeof asyncRoutes)) {\n asyncRoutesSetting = asyncRoutes;\n } else if (typeof asyncRoutes === 'object') {\n asyncRoutesSetting = asyncRoutes[platform] ?? asyncRoutes.default;\n }\n }\n\n return [mode, true].includes(asyncRoutesSetting);\n}\n\nexport function getMetroDirectBundleOptionsForExpoConfig(\n projectRoot: string,\n exp: ExpoConfig,\n options: Omit<ExpoMetroOptions, 'baseUrl' | 'reactCompiler' | 'routerRoot' | 'asyncRoutes'>\n) {\n return getMetroDirectBundleOptions({\n ...options,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: getBaseUrlFromExpoConfig(exp),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n asyncRoutes: getAsyncRoutesFromExpoConfig(exp, options.mode, options.platform),\n });\n}\n\nexport function getMetroDirectBundleOptions(options: ExpoMetroOptions) {\n const {\n mainModuleName,\n platform,\n mode,\n minify,\n environment,\n serializerOutput,\n serializerIncludeMaps,\n bytecode,\n lazy,\n engine,\n preserveEnvVars,\n asyncRoutes,\n baseUrl,\n routerRoot,\n isExporting,\n inlineSourceMap,\n splitChunks,\n usedExports,\n reactCompiler,\n optimize,\n domRoot,\n clientBoundaries,\n runModule,\n modulesOnly,\n useMd5Filename,\n hosted,\n liveBindings,\n isLoaderBundle,\n excludeSource,\n } = withDefaults(options);\n\n const dev = mode !== 'production';\n const isHermes = engine === 'hermes';\n\n if (isExporting) {\n debug('Disabling lazy bundling for export build');\n options.lazy = false;\n }\n\n let fakeSourceUrl: string | undefined;\n let fakeSourceMapUrl: string | undefined;\n\n // TODO: Upstream support to Metro for passing custom serializer options.\n if (serializerIncludeMaps != null || serializerOutput != null) {\n fakeSourceUrl = new URL(\n createBundleUrlPath(options).replace(/^\\//, ''),\n 'http://localhost:8081'\n ).toString();\n if (serializerIncludeMaps) {\n fakeSourceMapUrl = fakeSourceUrl.replace('.bundle?', '.map?');\n }\n }\n\n const customTransformOptions: ExpoMetroBundleOptions['customTransformOptions'] = {\n __proto__: null,\n optimize: optimize || undefined,\n engine,\n clientBoundaries,\n preserveEnvVars: preserveEnvVars || undefined,\n // Use string to match the query param behavior.\n asyncRoutes: asyncRoutes ? toBoolStr(asyncRoutes) : undefined,\n environment,\n baseUrl: baseUrl || undefined,\n routerRoot,\n bytecode: bytecode ? '1' : undefined,\n reactCompiler: reactCompiler ? toBoolStr(reactCompiler) : undefined,\n dom: domRoot,\n hosted: hosted ? '1' : undefined,\n useMd5Filename: useMd5Filename || undefined,\n liveBindings: !liveBindings ? toBoolStr(!!liveBindings) : undefined,\n isLoaderBundle: isLoaderBundle ? toBoolStr(isLoaderBundle) : undefined,\n };\n\n // Iterate and delete undefined values\n for (const key in customTransformOptions) {\n if (customTransformOptions[key] === undefined) {\n delete customTransformOptions[key];\n }\n }\n\n return {\n platform,\n entryFile: mainModuleName,\n dev,\n minify: minify ?? !dev,\n inlineSourceMap: inlineSourceMap ?? false,\n lazy: (!isExporting && lazy) || undefined,\n unstable_transformProfile: isHermes ? 'hermes-stable' : 'default',\n customTransformOptions,\n runModule,\n modulesOnly,\n customResolverOptions: {\n __proto__: null,\n environment,\n exporting: isExporting || undefined,\n },\n sourceMapUrl: fakeSourceMapUrl,\n sourceUrl: fakeSourceUrl,\n serializerOptions: {\n splitChunks,\n usedExports: usedExports || undefined,\n output: serializerOutput,\n includeSourceMaps: serializerIncludeMaps,\n exporting: isExporting || undefined,\n excludeSource: excludeSource ?? Server.DEFAULT_BUNDLE_OPTIONS.excludeSource,\n },\n // TODO(@kitten): See comments in MetroBundlerDevServer.ts; should all defaults be added and the logic\n // from `src/start/server/middleware/metroOptions.ts` that adds default be moved here?\n shallow: Server.DEFAULT_BUNDLE_OPTIONS.shallow,\n } as const;\n}\n\nexport function createBundleUrlPathFromExpoConfig(\n projectRoot: string,\n exp: ExpoConfig,\n options: Omit<ExpoMetroOptions, 'reactCompiler' | 'baseUrl' | 'routerRoot'>\n): string {\n return createBundleUrlPath({\n ...options,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: getBaseUrlFromExpoConfig(exp),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n });\n}\n\nexport function createBundleUrlPath(options: ExpoMetroOptions): string {\n const queryParams = createBundleUrlSearchParams(options);\n return `/${encodeURI(options.mainModuleName.replace(/^\\/+/, ''))}.bundle?${queryParams.toString()}`;\n}\n\n/**\n * Create a bundle URL, containing all required query parameters, using a valid \"os path\".\n * On POSIX systems, this would look something like `/Users/../project/file.js?dev=false&..`.\n * On UNIX systems, this would look something like `C:\\Users\\..\\project\\file.js?dev=false&..`.\n * This path can safely be used with `path.*` modifiers and resolved.\n */\nexport function createBundleOsPath(options: ExpoMetroOptions): string {\n const queryParams = createBundleUrlSearchParams(options);\n const mainModuleName = toPosixPath(options.mainModuleName);\n return `${mainModuleName}.bundle?${queryParams.toString()}`;\n}\n\nexport function createBundleUrlSearchParams(options: ExpoMetroOptions): URLSearchParams {\n const {\n platform,\n mode,\n minify,\n environment,\n serializerOutput,\n serializerIncludeMaps,\n lazy,\n bytecode,\n engine,\n preserveEnvVars,\n asyncRoutes,\n baseUrl,\n routerRoot,\n reactCompiler,\n inlineSourceMap,\n isExporting,\n clientBoundaries,\n splitChunks,\n usedExports,\n optimize,\n domRoot,\n modulesOnly,\n runModule,\n hosted,\n liveBindings,\n } = withDefaults(options);\n\n const dev = String(mode !== 'production');\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev,\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n // Lazy bundling must be disabled for bundle splitting to work.\n if (!isExporting && lazy) {\n queryParams.append('lazy', String(lazy));\n }\n\n if (inlineSourceMap) {\n queryParams.append('inlineSourceMap', String(inlineSourceMap));\n }\n\n if (minify) {\n queryParams.append('minify', String(minify));\n }\n\n // We split bytecode from the engine since you could technically use Hermes without bytecode.\n // Hermes indicates the type of language features you want to transform out of the JS, whereas bytecode\n // indicates whether you want to use the Hermes bytecode format.\n if (engine) {\n queryParams.append('transform.engine', engine);\n }\n if (bytecode) {\n queryParams.append('transform.bytecode', '1');\n }\n if (asyncRoutes) {\n queryParams.append('transform.asyncRoutes', String(asyncRoutes));\n }\n if (preserveEnvVars) {\n queryParams.append('transform.preserveEnvVars', String(preserveEnvVars));\n }\n if (baseUrl) {\n queryParams.append('transform.baseUrl', baseUrl);\n }\n if (clientBoundaries?.length) {\n queryParams.append('transform.clientBoundaries', JSON.stringify(clientBoundaries));\n }\n if (routerRoot != null) {\n queryParams.append('transform.routerRoot', routerRoot);\n }\n if (reactCompiler) {\n queryParams.append('transform.reactCompiler', String(reactCompiler));\n }\n if (domRoot) {\n queryParams.append('transform.dom', domRoot);\n }\n if (hosted) {\n queryParams.append('transform.hosted', '1');\n }\n\n if (environment) {\n queryParams.append('resolver.environment', environment);\n queryParams.append('transform.environment', environment);\n }\n\n if (isExporting) {\n queryParams.append('resolver.exporting', String(isExporting));\n }\n\n if (splitChunks) {\n queryParams.append('serializer.splitChunks', String(splitChunks));\n }\n if (usedExports) {\n queryParams.append('serializer.usedExports', String(usedExports));\n }\n if (optimize) {\n queryParams.append('transform.optimize', String(optimize));\n }\n if (serializerOutput) {\n queryParams.append('serializer.output', serializerOutput);\n }\n if (serializerIncludeMaps) {\n queryParams.append('serializer.map', String(serializerIncludeMaps));\n }\n if (engine === 'hermes') {\n queryParams.append('unstable_transformProfile', 'hermes-stable');\n }\n\n if (modulesOnly != null) {\n queryParams.set('modulesOnly', String(modulesOnly));\n }\n if (runModule != null) {\n queryParams.set('runModule', String(runModule));\n }\n\n if (liveBindings === false) {\n queryParams.append('transform.liveBindings', String(false));\n }\n\n return queryParams;\n}\n\n/**\n * Convert all path separators to `/`, including on Windows.\n * Metro asumes that all module specifiers are posix paths.\n * References to directories can still be Windows-style paths in Metro.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#importing_features_into_your_script\n * @see https://github.com/facebook/metro/pull/1286\n */\nexport function convertPathToModuleSpecifier(pathLike: string) {\n return toPosixPath(pathLike);\n}\n\nexport function getMetroOptionsFromUrl(urlFragment: string) {\n const url = new URL(urlFragment, 'http://localhost:0');\n const getStringParam = (key: string) => {\n const param = url.searchParams.get(key);\n if (Array.isArray(param)) {\n throw new Error(`Expected single value for ${key}`);\n }\n return param;\n };\n\n let pathname = url.pathname;\n if (pathname.endsWith('.bundle')) {\n pathname = pathname.slice(0, -'.bundle'.length);\n }\n\n const options: ExpoMetroOptions = {\n mode: isTruthy(getStringParam('dev') ?? 'true') ? 'development' : 'production',\n minify: isTruthy(getStringParam('minify') ?? 'false'),\n lazy: isTruthy(getStringParam('lazy') ?? 'false'),\n routerRoot: getStringParam('transform.routerRoot') ?? 'app',\n hosted: isTruthy(getStringParam('transform.hosted')),\n isExporting: isTruthy(getStringParam('resolver.exporting') ?? 'false'),\n environment: assertEnvironment(getStringParam('transform.environment') ?? 'node'),\n platform: url.searchParams.get('platform') ?? 'web',\n bytecode: isTruthy(getStringParam('transform.bytecode') ?? 'false'),\n mainModuleName: convertPathToModuleSpecifier(pathname),\n reactCompiler: isTruthy(getStringParam('transform.reactCompiler') ?? 'false'),\n asyncRoutes: isTruthy(getStringParam('transform.asyncRoutes') ?? 'false'),\n baseUrl: getStringParam('transform.baseUrl') ?? undefined,\n // clientBoundaries: JSON.parse(getStringParam('transform.clientBoundaries') ?? '[]'),\n engine: assertEngine(getStringParam('transform.engine')),\n runModule: isTruthy(getStringParam('runModule') ?? 'true'),\n modulesOnly: isTruthy(getStringParam('modulesOnly') ?? 'false'),\n liveBindings: isTruthy(getStringParam('transform.liveBindings') ?? 'true'),\n };\n\n return options;\n}\n\nfunction isTruthy(value: string | null): boolean {\n return value === 'true' || value === '1';\n}\n\nfunction assertEnvironment(environment: string | undefined): MetroEnvironment | undefined {\n if (!environment) {\n return undefined;\n }\n if (!['node', 'react-server', 'client'].includes(environment)) {\n throw new Error(`Expected transform.environment to be one of: node, react-server, client`);\n }\n return environment as MetroEnvironment;\n}\nfunction assertEngine(engine: string | undefined | null): 'hermes' | undefined {\n if (!engine) {\n return undefined;\n }\n if (!['hermes'].includes(engine)) {\n throw new Error(`Expected transform.engine to be one of: hermes`);\n }\n return engine as 'hermes';\n}\n"],"names":["convertPathToModuleSpecifier","createBundleOsPath","createBundleUrlPath","createBundleUrlPathFromExpoConfig","createBundleUrlSearchParams","getAsyncRoutesFromExpoConfig","getBaseUrlFromExpoConfig","getMetroDirectBundleOptions","getMetroDirectBundleOptionsForExpoConfig","getMetroOptionsFromUrl","isServerEnvironment","debug","require","toBoolStr","x","environment","withDefaults","mode","minify","preserveEnvVars","env","EXPO_NO_CLIENT_ENV_VARS","lazy","props","bytecode","platform","CommandError","engine","optimize","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","usedExports","EXPO_UNSTABLE_TREE_SHAKING","isExporting","undefined","liveBindings","EXPO_UNSTABLE_LIVE_BINDINGS","excludeSource","exp","experiments","baseUrl","trim","replace","asyncRoutesSetting","extra","router","asyncRoutes","includes","default","projectRoot","options","reactCompiler","routerRoot","getRouterDirectoryModuleIdWithManifest","mainModuleName","serializerOutput","serializerIncludeMaps","inlineSourceMap","splitChunks","domRoot","clientBoundaries","runModule","modulesOnly","useMd5Filename","hosted","isLoaderBundle","dev","isHermes","fakeSourceUrl","fakeSourceMapUrl","URL","toString","customTransformOptions","__proto__","dom","key","entryFile","unstable_transformProfile","customResolverOptions","exporting","sourceMapUrl","sourceUrl","serializerOptions","output","includeSourceMaps","Server","DEFAULT_BUNDLE_OPTIONS","shallow","queryParams","encodeURI","toPosixPath","String","URLSearchParams","encodeURIComponent","hot","append","length","JSON","stringify","set","pathLike","urlFragment","url","getStringParam","param","searchParams","get","Array","isArray","Error","pathname","endsWith","slice","isTruthy","assertEnvironment","assertEngine","value"],"mappings":";;;;;;;;;;;QA6agBA;eAAAA;;QA5IAC;eAAAA;;QAXAC;eAAAA;;QAbAC;eAAAA;;QA8BAC;eAAAA;;QA7KAC;eAAAA;;QAJAC;eAAAA;;QAiCAC;eAAAA;;QAdAC;eAAAA;;QAwSAC;eAAAA;;QAlWAC;eAAAA;;;;gEA9EG;;;;;;qBAGC;wBACS;0BACD;wBAC2B;;;;;;AAEvD,MAAMC,QAAQC,QAAQ,SAAS;AAM/B,SAASC,UAAUC,CAAU;IAC3B,OAAOA,IAAI,SAAS;AACtB;AA8DO,SAASJ,oBAAoBK,WAAiB;IACnD,OAAOA,gBAAgB,UAAUA,gBAAgB;AACnD;AAEA,SAASC,aAAa,EACpBC,OAAO,aAAa,EACpBC,SAASD,SAAS,YAAY,EAC9BE,kBAAkBF,SAAS,iBAAiBG,QAAG,CAACC,uBAAuB,EACvEC,IAAI,EACJP,WAAW,EACX,GAAGQ,OACc;IACjB,IAAIA,MAAMC,QAAQ,EAAE;QAClB,IAAID,MAAME,QAAQ,KAAK,OAAO;YAC5B,MAAM,IAAIC,oBAAY,CAAC;Q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rD,6BAA6B6G;QAC7C3D,eAAe8D,SAASV,eAAe,8BAA8B;QACrEzD,aAAamE,SAASV,eAAe,4BAA4B;QACjE/D,SAAS+D,eAAe,wBAAwBrE;QAChD,sFAAsF;QACtFN,QAAQuF,aAAaZ,eAAe;QACpC1C,WAAWoD,SAASV,eAAe,gBAAgB;QACnDzC,aAAamD,SAASV,eAAe,kBAAkB;QACvDpE,cAAc8E,SAASV,eAAe,6BAA6B;IACrE;IAEA,OAAOrD;AACT;AAEA,SAAS+D,SAASG,KAAoB;IACpC,OAAOA,UAAU,UAAUA,UAAU;AACvC;AAEA,SAASF,kBAAkBlG,WAA+B;IACxD,IAAI,CAACA,aAAa;QAChB,OAAOkB;IACT;IACA,IAAI,CAAC;QAAC;QAAQ;QAAgB;KAAS,CAACa,QAAQ,CAAC/B,cAAc;QAC7D,MAAM,IAAI6F,MAAM,CAAC,uEAAuE,CAAC;IAC3F;IACA,OAAO7F;AACT;AACA,SAASmG,aAAavF,MAAiC;IACrD,IAAI,CAACA,QAAQ;QACX,OAAOM;IACT;IACA,IAAI,CAAC;QAAC;KAAS,CAACa,QAAQ,CAACnB,SAAS;QAChC,MAAM,IAAIiF,MAAM,CAAC,8CAA8C,CAAC;IAClE;IACA,OAAOjF;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/metroOptions.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport Server from '@expo/metro/metro/Server';\nimport type { BundleOptions as MetroBundleOptions } from '@expo/metro/metro/shared/types';\n\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { toPosixPath } from '../../../utils/filePath';\nimport { getRouterDirectoryModuleIdWithManifest } from '../metro/router';\n\nconst debug = require('debug')('expo:metro:options') as typeof console.log;\n\n/** Enforce conversion of `true` to `'true'` */\nfunction toBoolStr(x: true): 'true';\nfunction toBoolStr(x: false): 'false';\nfunction toBoolStr(x: boolean): 'true' | 'false';\nfunction toBoolStr(x: boolean): 'true' | 'false' {\n return x ? 'true' : 'false';\n}\n\nexport type MetroEnvironment = 'node' | 'react-server' | 'client';\n\nexport type ExpoMetroOptions = {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: MetroEnvironment;\n serializerOutput?: 'static';\n serializerIncludeMaps?: boolean;\n lazy?: boolean;\n engine?: 'hermes';\n preserveEnvVars?: boolean;\n bytecode?: boolean;\n /** Enable async routes (route-based bundle splitting) in Expo Router. */\n asyncRoutes?: boolean;\n /** Module ID relative to the projectRoot for the Expo Router app directory. */\n routerRoot?: string;\n /** Enable React compiler support in Babel. */\n reactCompiler?: boolean;\n baseUrl?: string;\n isExporting: boolean;\n /** Is bundling a DOM Component (\"use dom\"). Requires the entry dom component file path. */\n domRoot?: string;\n /** Exporting MD5 filename based on file contents, for EAS Update. */\n useMd5Filename?: boolean;\n inlineSourceMap?: boolean;\n clientBoundaries?: string[];\n splitChunks?: boolean;\n usedExports?: boolean;\n /** Enable optimized bundling (required for tree shaking). */\n optimize?: boolean;\n\n modulesOnly?: boolean;\n runModule?: boolean;\n\n /** When true, omits `sourcesContent` from generated source maps (saves ~80x memory for SSR). */\n excludeSource?: boolean;\n\n /** Should assets be exported for hosting. Always true on web. Always false for embedded builds. Optional for native exports. */\n hosted?: boolean;\n /** Disable live bindings (enabled by default, required for circular deps) in experimental import export support. */\n liveBindings?: boolean;\n /** When true, indicates this bundle should contain only the loader export. */\n isLoaderBundle?: boolean;\n};\n\n// See: @expo/metro-config/src/serializer/fork/baseJSBundle.ts `ExpoSerializerOptions`\nexport type SerializerOptions = {\n includeSourceMaps?: boolean;\n output?: 'static';\n splitChunks?: boolean;\n usedExports?: boolean;\n exporting?: boolean;\n};\n\nexport type ExpoMetroBundleOptions = MetroBundleOptions & {\n serializerOptions?: SerializerOptions;\n};\n\nexport function isServerEnvironment(environment?: any): boolean {\n return environment === 'node' || environment === 'react-server';\n}\n\nfunction withDefaults({\n mode = 'development',\n minify = mode === 'production',\n preserveEnvVars = mode !== 'development' && env.EXPO_NO_CLIENT_ENV_VARS,\n lazy,\n environment,\n ...props\n}: ExpoMetroOptions): ExpoMetroOptions {\n if (props.bytecode) {\n if (props.platform === 'web') {\n throw new CommandError('Cannot use bytecode with the web platform');\n }\n if (props.engine !== 'hermes') {\n throw new CommandError('Bytecode is only supported with the Hermes engine');\n }\n }\n\n const optimize =\n props.optimize ??\n (environment !== 'node' && mode === 'production' && env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH);\n\n return {\n mode,\n minify,\n preserveEnvVars,\n optimize,\n usedExports: optimize && env.EXPO_UNSTABLE_TREE_SHAKING,\n lazy: !props.isExporting && lazy,\n environment: environment === 'client' ? undefined : environment,\n liveBindings: env.EXPO_UNSTABLE_LIVE_BINDINGS,\n excludeSource: isServerEnvironment(environment),\n ...props,\n };\n}\n\nexport function getBaseUrlFromExpoConfig(exp: ExpoConfig) {\n return exp.experiments?.baseUrl?.trim().replace(/\\/+$/, '') ?? '';\n}\n\nexport function getAsyncRoutesFromExpoConfig(exp: ExpoConfig, mode: string, platform: string) {\n let asyncRoutesSetting;\n\n if (exp.extra?.router?.asyncRoutes) {\n const asyncRoutes = exp.extra?.router?.asyncRoutes;\n if (['boolean', 'string'].includes(typeof asyncRoutes)) {\n asyncRoutesSetting = asyncRoutes;\n } else if (typeof asyncRoutes === 'object') {\n asyncRoutesSetting = asyncRoutes[platform] ?? asyncRoutes.default;\n }\n }\n\n return [mode, true].includes(asyncRoutesSetting);\n}\n\nexport function getMetroDirectBundleOptionsForExpoConfig(\n projectRoot: string,\n exp: ExpoConfig,\n options: Omit<ExpoMetroOptions, 'baseUrl' | 'reactCompiler' | 'routerRoot' | 'asyncRoutes'>\n) {\n return getMetroDirectBundleOptions({\n ...options,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: getBaseUrlFromExpoConfig(exp),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n asyncRoutes: getAsyncRoutesFromExpoConfig(exp, options.mode, options.platform),\n });\n}\n\nexport function getMetroDirectBundleOptions(options: ExpoMetroOptions) {\n const {\n mainModuleName,\n platform,\n mode,\n minify,\n environment,\n serializerOutput,\n serializerIncludeMaps,\n bytecode,\n lazy,\n engine,\n preserveEnvVars,\n asyncRoutes,\n baseUrl,\n routerRoot,\n isExporting,\n inlineSourceMap,\n splitChunks,\n usedExports,\n reactCompiler,\n optimize,\n domRoot,\n clientBoundaries,\n runModule,\n modulesOnly,\n useMd5Filename,\n hosted,\n liveBindings,\n isLoaderBundle,\n excludeSource,\n } = withDefaults(options);\n\n const dev = mode !== 'production';\n const isHermes = engine === 'hermes';\n\n if (isExporting) {\n debug('Disabling lazy bundling for export build');\n options.lazy = false;\n }\n\n let fakeSourceUrl: string | undefined;\n let fakeSourceMapUrl: string | undefined;\n\n // TODO: Upstream support to Metro for passing custom serializer options.\n if (serializerIncludeMaps != null || serializerOutput != null) {\n fakeSourceUrl = new URL(\n createBundleUrlPath(options).replace(/^\\//, ''),\n 'http://localhost:8081'\n ).toString();\n if (serializerIncludeMaps) {\n fakeSourceMapUrl = fakeSourceUrl.replace('.bundle?', '.map?');\n }\n }\n\n const customTransformOptions: ExpoMetroBundleOptions['customTransformOptions'] = {\n __proto__: null,\n optimize: optimize || undefined,\n engine,\n clientBoundaries,\n preserveEnvVars: preserveEnvVars || undefined,\n // Use string to match the query param behavior.\n asyncRoutes: asyncRoutes ? toBoolStr(asyncRoutes) : undefined,\n environment,\n baseUrl: baseUrl || undefined,\n routerRoot,\n bytecode: bytecode ? '1' : undefined,\n reactCompiler: reactCompiler ? toBoolStr(reactCompiler) : undefined,\n dom: domRoot,\n hosted: hosted ? '1' : undefined,\n useMd5Filename: useMd5Filename || undefined,\n liveBindings: !liveBindings ? toBoolStr(!!liveBindings) : undefined,\n isLoaderBundle: isLoaderBundle ? toBoolStr(isLoaderBundle) : undefined,\n };\n\n // Iterate and delete undefined values\n for (const key in customTransformOptions) {\n if (customTransformOptions[key] === undefined) {\n delete customTransformOptions[key];\n }\n }\n\n return {\n platform,\n entryFile: mainModuleName,\n dev,\n minify: minify ?? !dev,\n inlineSourceMap: inlineSourceMap ?? false,\n lazy: (!isExporting && lazy) || undefined,\n unstable_transformProfile: isHermes ? 'hermes-stable' : 'default',\n customTransformOptions,\n runModule,\n modulesOnly,\n customResolverOptions: {\n __proto__: null,\n environment,\n exporting: isExporting || undefined,\n },\n sourceMapUrl: fakeSourceMapUrl,\n sourceUrl: fakeSourceUrl,\n serializerOptions: {\n splitChunks,\n usedExports: usedExports || undefined,\n output: serializerOutput,\n includeSourceMaps: serializerIncludeMaps,\n exporting: isExporting || undefined,\n excludeSource: excludeSource ?? Server.DEFAULT_BUNDLE_OPTIONS.excludeSource,\n },\n // TODO(@kitten): See comments in MetroBundlerDevServer.ts; should all defaults be added and the logic\n // from `src/start/server/middleware/metroOptions.ts` that adds default be moved here?\n shallow: Server.DEFAULT_BUNDLE_OPTIONS.shallow,\n } as const;\n}\n\nexport function createBundleUrlPathFromExpoConfig(\n projectRoot: string,\n exp: ExpoConfig,\n options: Omit<ExpoMetroOptions, 'reactCompiler' | 'baseUrl' | 'routerRoot'>\n): string {\n return createBundleUrlPath({\n ...options,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: getBaseUrlFromExpoConfig(exp),\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n });\n}\n\nexport function createBundleUrlPath(options: ExpoMetroOptions): string {\n const queryParams = createBundleUrlSearchParams(options);\n return `/${encodeURI(options.mainModuleName.replace(/^\\/+/, ''))}.bundle?${queryParams.toString()}`;\n}\n\n/**\n * Create a bundle URL, containing all required query parameters, using a valid \"os path\".\n * On POSIX systems, this would look something like `/Users/../project/file.js?dev=false&..`.\n * On UNIX systems, this would look something like `C:\\Users\\..\\project\\file.js?dev=false&..`.\n * This path can safely be used with `path.*` modifiers and resolved.\n */\nexport function createBundleOsPath(options: ExpoMetroOptions): string {\n const queryParams = createBundleUrlSearchParams(options);\n const mainModuleName = toPosixPath(options.mainModuleName);\n return `${mainModuleName}.bundle?${queryParams.toString()}`;\n}\n\nexport function createBundleUrlSearchParams(options: ExpoMetroOptions): URLSearchParams {\n const {\n platform,\n mode,\n minify,\n environment,\n serializerOutput,\n serializerIncludeMaps,\n lazy,\n bytecode,\n engine,\n preserveEnvVars,\n asyncRoutes,\n baseUrl,\n routerRoot,\n reactCompiler,\n inlineSourceMap,\n isExporting,\n clientBoundaries,\n splitChunks,\n usedExports,\n optimize,\n domRoot,\n modulesOnly,\n runModule,\n hosted,\n liveBindings,\n isLoaderBundle,\n } = withDefaults(options);\n\n const dev = String(mode !== 'production');\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev,\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n // Lazy bundling must be disabled for bundle splitting to work.\n if (!isExporting && lazy) {\n queryParams.append('lazy', String(lazy));\n }\n\n if (inlineSourceMap) {\n queryParams.append('inlineSourceMap', String(inlineSourceMap));\n }\n\n if (minify) {\n queryParams.append('minify', String(minify));\n }\n\n // We split bytecode from the engine since you could technically use Hermes without bytecode.\n // Hermes indicates the type of language features you want to transform out of the JS, whereas bytecode\n // indicates whether you want to use the Hermes bytecode format.\n if (engine) {\n queryParams.append('transform.engine', engine);\n }\n if (bytecode) {\n queryParams.append('transform.bytecode', '1');\n }\n if (asyncRoutes) {\n queryParams.append('transform.asyncRoutes', String(asyncRoutes));\n }\n if (preserveEnvVars) {\n queryParams.append('transform.preserveEnvVars', String(preserveEnvVars));\n }\n if (baseUrl) {\n queryParams.append('transform.baseUrl', baseUrl);\n }\n if (clientBoundaries?.length) {\n queryParams.append('transform.clientBoundaries', JSON.stringify(clientBoundaries));\n }\n if (routerRoot != null) {\n queryParams.append('transform.routerRoot', routerRoot);\n }\n if (reactCompiler) {\n queryParams.append('transform.reactCompiler', String(reactCompiler));\n }\n if (domRoot) {\n queryParams.append('transform.dom', domRoot);\n }\n if (hosted) {\n queryParams.append('transform.hosted', '1');\n }\n if (isLoaderBundle) {\n queryParams.append('transform.isLoaderBundle', 'true');\n }\n\n if (environment) {\n queryParams.append('resolver.environment', environment);\n queryParams.append('transform.environment', environment);\n }\n\n if (isExporting) {\n queryParams.append('resolver.exporting', String(isExporting));\n }\n\n if (splitChunks) {\n queryParams.append('serializer.splitChunks', String(splitChunks));\n }\n if (usedExports) {\n queryParams.append('serializer.usedExports', String(usedExports));\n }\n if (optimize) {\n queryParams.append('transform.optimize', String(optimize));\n }\n if (serializerOutput) {\n queryParams.append('serializer.output', serializerOutput);\n }\n if (serializerIncludeMaps) {\n queryParams.append('serializer.map', String(serializerIncludeMaps));\n }\n if (engine === 'hermes') {\n queryParams.append('unstable_transformProfile', 'hermes-stable');\n }\n\n if (modulesOnly != null) {\n queryParams.set('modulesOnly', String(modulesOnly));\n }\n if (runModule != null) {\n queryParams.set('runModule', String(runModule));\n }\n\n if (liveBindings === false) {\n queryParams.append('transform.liveBindings', String(false));\n }\n\n return queryParams;\n}\n\n/**\n * Convert all path separators to `/`, including on Windows.\n * Metro asumes that all module specifiers are posix paths.\n * References to directories can still be Windows-style paths in Metro.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#importing_features_into_your_script\n * @see https://github.com/facebook/metro/pull/1286\n */\nexport function convertPathToModuleSpecifier(pathLike: string) {\n return toPosixPath(pathLike);\n}\n\nexport function getMetroOptionsFromUrl(urlFragment: string) {\n const url = new URL(urlFragment, 'http://localhost:0');\n const getStringParam = (key: string) => {\n const param = url.searchParams.get(key);\n if (Array.isArray(param)) {\n throw new Error(`Expected single value for ${key}`);\n }\n return param;\n };\n\n let pathname = url.pathname;\n if (pathname.endsWith('.bundle')) {\n pathname = pathname.slice(0, -'.bundle'.length);\n }\n\n const options: ExpoMetroOptions = {\n mode: isTruthy(getStringParam('dev') ?? 'true') ? 'development' : 'production',\n minify: isTruthy(getStringParam('minify') ?? 'false'),\n lazy: isTruthy(getStringParam('lazy') ?? 'false'),\n routerRoot: getStringParam('transform.routerRoot') ?? 'app',\n hosted: isTruthy(getStringParam('transform.hosted')),\n isExporting: isTruthy(getStringParam('resolver.exporting') ?? 'false'),\n environment: assertEnvironment(getStringParam('transform.environment') ?? 'node'),\n platform: url.searchParams.get('platform') ?? 'web',\n bytecode: isTruthy(getStringParam('transform.bytecode') ?? 'false'),\n mainModuleName: convertPathToModuleSpecifier(pathname),\n reactCompiler: isTruthy(getStringParam('transform.reactCompiler') ?? 'false'),\n asyncRoutes: isTruthy(getStringParam('transform.asyncRoutes') ?? 'false'),\n baseUrl: getStringParam('transform.baseUrl') ?? undefined,\n // clientBoundaries: JSON.parse(getStringParam('transform.clientBoundaries') ?? '[]'),\n engine: assertEngine(getStringParam('transform.engine')),\n runModule: isTruthy(getStringParam('runModule') ?? 'true'),\n modulesOnly: isTruthy(getStringParam('modulesOnly') ?? 'false'),\n liveBindings: isTruthy(getStringParam('transform.liveBindings') ?? 'true'),\n };\n\n return options;\n}\n\nfunction isTruthy(value: string | null): boolean {\n return value === 'true' || value === '1';\n}\n\nfunction assertEnvironment(environment: string | undefined): MetroEnvironment | undefined {\n if (!environment) {\n return undefined;\n }\n if (!['node', 'react-server', 'client'].includes(environment)) {\n throw new Error(`Expected transform.environment to be one of: node, react-server, client`);\n }\n return environment as MetroEnvironment;\n}\nfunction assertEngine(engine: string | undefined | null): 'hermes' | undefined {\n if (!engine) {\n return undefined;\n }\n if (!['hermes'].includes(engine)) {\n throw new Error(`Expected transform.engine to be one of: hermes`);\n }\n return engine as 'hermes';\n}\n"],"names":["convertPathToModuleSpecifier","createBundleOsPath","createBundleUrlPath","createBundleUrlPathFromExpoConfig","createBundleUrlSearchParams","getAsyncRoutesFromExpoConfig","getBaseUrlFromExpoConfig","getMetroDirectBundleOptions","getMetroDirectBundleOptionsForExpoConfig","getMetroOptionsFromUrl","isServerEnvironment","debug","require","toBoolStr","x","environment","withDefaults","mode","minify","preserveEnvVars","env","EXPO_NO_CLIENT_ENV_VARS","lazy","props","bytecode","platform","CommandError","engine","optimize","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","usedExports","EXPO_UNSTABLE_TREE_SHAKING","isExporting","undefined","liveBindings","EXPO_UNSTABLE_LIVE_BINDINGS","excludeSource","exp","experiments","baseUrl","trim","replace","asyncRoutesSetting","extra","router","asyncRoutes","includes","default","projectRoot","options","reactCompiler","routerRoot","getRouterDirectoryModuleIdWithManifest","mainModuleName","serializerOutput","serializerIncludeMaps","inlineSourceMap","splitChunks","domRoot","clientBoundaries","runModule","modulesOnly","useMd5Filename","hosted","isLoaderBundle","dev","isHermes","fakeSourceUrl","fakeSourceMapUrl","URL","toString","customTransformOptions","__proto__","dom","key","entryFile","unstable_transformProfile","customResolverOptions","exporting","sourceMapUrl","sourceUrl","serializerOptions","output","includeSourceMaps","Server","DEFAULT_BUNDLE_OPTIONS","shallow","queryParams","encodeURI","toPosixPath","String","URLSearchParams","encodeURIComponent","hot","append","length","JSON","stringify","set","pathLike","urlFragment","url","getStringParam","param","searchParams","get","Array","isArray","Error","pathname","endsWith","slice","isTruthy","assertEnvironment","assertEngine","value"],"mappings":";;;;;;;;;;;QAibgBA;eAAAA;;QAhJAC;eAAAA;;QAXAC;eAAAA;;QAbAC;eAAAA;;QA8BAC;eAAAA;;QA7KAC;eAAAA;;QAJAC;eAAAA;;QAiCAC;eAAAA;;QAdAC;eAAAA;;QA4SAC;eAAAA;;QAtWAC;eAAAA;;;;gEA9EG;;;;;;qBAGC;wBACS;0BACD;wBAC2B;;;;;;AAEvD,MAAMC,QAAQC,QAAQ,SAAS;AAM/B,SAASC,UAAUC,CAAU;IAC3B,OAAOA,IAAI,SAAS;AACtB;AA8DO,SAASJ,oBAAoBK,WAAiB;IACnD,OAAOA,gBAAgB,UAAUA,gBAAgB;AACnD;AAEA,SAASC,aAAa,EACpBC,OAAO,aAAa,EACpBC,SAASD,SAAS,YAAY,EAC9BE,kBAAkBF,SAAS,iBAAiBG,QAAG,CAACC,uBAAuB,EACvEC,IAAI,EACJP,WAAW,E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,SAASV,eAAe;QAChCtE,aAAagF,SAASV,eAAe,yBAAyB;QAC9DvF,aAAakG,kBAAkBX,eAAe,4BAA4B;QAC1E7E,UAAU4E,IAAIG,YAAY,CAACC,GAAG,CAAC,eAAe;QAC9CjF,UAAUwF,SAASV,eAAe,yBAAyB;QAC3DjD,gBAAgBrD,6BAA6B6G;QAC7C3D,eAAe8D,SAASV,eAAe,8BAA8B;QACrEzD,aAAamE,SAASV,eAAe,4BAA4B;QACjE/D,SAAS+D,eAAe,wBAAwBrE;QAChD,sFAAsF;QACtFN,QAAQuF,aAAaZ,eAAe;QACpC1C,WAAWoD,SAASV,eAAe,gBAAgB;QACnDzC,aAAamD,SAASV,eAAe,kBAAkB;QACvDpE,cAAc8E,SAASV,eAAe,6BAA6B;IACrE;IAEA,OAAOrD;AACT;AAEA,SAAS+D,SAASG,KAAoB;IACpC,OAAOA,UAAU,UAAUA,UAAU;AACvC;AAEA,SAASF,kBAAkBlG,WAA+B;IACxD,IAAI,CAACA,aAAa;QAChB,OAAOkB;IACT;IACA,IAAI,CAAC;QAAC;QAAQ;QAAgB;KAAS,CAACa,QAAQ,CAAC/B,cAAc;QAC7D,MAAM,IAAI6F,MAAM,CAAC,uEAAuE,CAAC;IAC3F;IACA,OAAO7F;AACT;AACA,SAASmG,aAAavF,MAAiC;IACrD,IAAI,CAACA,QAAQ;QACX,OAAOM;IACT;IACA,IAAI,CAAC;QAAC;KAAS,CAACa,QAAQ,CAACnB,SAAS;QAChC,MAAM,IAAIiF,MAAM,CAAC,8CAA8C,CAAC;IAClE;IACA,OAAOjF;AACT"}
|
|
@@ -118,17 +118,13 @@ async function resolvePlatformInfo(platform, runtime, deps, state) {
|
|
|
118
118
|
}
|
|
119
119
|
return {
|
|
120
120
|
runtime: 'expo',
|
|
121
|
-
url: urlCreator.
|
|
122
|
-
scheme: 'exp'
|
|
123
|
-
}),
|
|
121
|
+
url: urlCreator.constructExpoGoUrl(),
|
|
124
122
|
appId
|
|
125
123
|
};
|
|
126
124
|
}
|
|
127
125
|
return {
|
|
128
126
|
runtime,
|
|
129
|
-
url: runtime === 'custom' ? urlCreator.constructDevClientUrl() : urlCreator.
|
|
130
|
-
scheme: 'exp'
|
|
131
|
-
}),
|
|
127
|
+
url: runtime === 'custom' ? urlCreator.constructDevClientUrl() : urlCreator.constructExpoGoUrl(),
|
|
132
128
|
appId
|
|
133
129
|
};
|
|
134
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/openHandlers.ts"],"sourcesContent":["import type {\n OpenActionResult,\n OpenInfoResult,\n OpenMiddlewareOptions,\n OpenNativeRuntime,\n OpenPlatform,\n OpenPlatformInfo,\n OpenRequestedRuntime,\n} from './OpenMiddleware';\nimport type { UrlCreator } from '../UrlCreator';\n\ninterface InfoHandlerDeps {\n /** Stable UrlCreator instance — its `defaults` mutate when `toggleRuntimeMode` runs, so the same instance keeps producing fresh URLs and reflects the current scheme. */\n urlCreator: UrlCreator;\n /**\n * Read live values every call. The dev server's runtime mode can flip mid-run via the `s` key\n * in the terminal, and `expo-dev-client` can be installed while the server is running — both\n * change `isDevClient` and `isRedirectPageEnabled`, and the endpoint should reflect the\n * current state on every request.\n */\n getIsDevClient: () => boolean;\n /** Live mirror of `BundlerDevServer.isRedirectPageEnabled()`. */\n getIsRedirectPageEnabled: () => boolean;\n /**\n * Resolve the native application identifier for a platform (iOS bundle id / Android package\n * name). Implementations should return `null` instead of throwing when the project has no\n * configured identifier; the endpoint surfaces `null` so distributed preview systems can detect\n * that the build can't be matched by app id and either bail out or prompt the user.\n */\n getAppId: (platform: OpenPlatform) => Promise<string | null>;\n}\n\n/**\n * Build the GET handler for `/_expo/open`. Resolves dry-run info for a single platform, or for\n * every platform in discovery mode. Extracted so it can be exercised with a real\n * {@link UrlCreator} in tests (covers tunnel routing in particular).\n */\nexport function createInfoHandler(deps: InfoHandlerDeps): OpenMiddlewareOptions['getInfo'] {\n return ({ platform, runtime }) => resolveOpenInfo({ platform, runtime }, deps);\n}\n\nexport async function resolveOpenInfo(\n { platform, runtime }: { platform: OpenPlatform | null; runtime: OpenRequestedRuntime },\n deps: InfoHandlerDeps\n): Promise<OpenInfoResult> {\n // Snapshot the live state once per request so the response is internally consistent even if a\n // toggle happens between sub-resolutions.\n const scheme = deps.urlCreator.getScheme();\n const isDevClient = deps.getIsDevClient();\n const isRedirectPageEnabled = deps.getIsRedirectPageEnabled();\n const availableRuntimes: OpenNativeRuntime[] = isDevClient\n ? ['custom']\n : isRedirectPageEnabled\n ? ['expo', 'custom']\n : ['expo'];\n\n if (platform) {\n return {\n scheme,\n availableRuntimes,\n ...(await resolvePlatformInfo(platform, runtime, deps, {\n isDevClient,\n isRedirectPageEnabled,\n })),\n };\n }\n\n const [ios, android, web] = await Promise.all([\n resolvePlatformInfo('ios', runtime, deps, { isDevClient, isRedirectPageEnabled }),\n resolvePlatformInfo('android', runtime, deps, { isDevClient, isRedirectPageEnabled }),\n resolvePlatformInfo('web', runtime, deps, { isDevClient, isRedirectPageEnabled }),\n ]);\n return { scheme, availableRuntimes, platforms: { ios, android, web } };\n}\n\nasync function resolvePlatformInfo(\n platform: OpenPlatform,\n runtime: OpenRequestedRuntime,\n deps: InfoHandlerDeps,\n state: { isDevClient: boolean; isRedirectPageEnabled: boolean }\n): Promise<OpenPlatformInfo> {\n const { urlCreator, getAppId } = deps;\n const { isDevClient, isRedirectPageEnabled } = state;\n const appId = await getAppId(platform);\n\n if (platform === 'web') {\n // constructUrl inherits the tunnel host from `defaults.hostType` when --tunnel is active,\n // so this returns the ngrok URL instead of localhost in that case.\n return { runtime: 'web', url: urlCreator.constructUrl({ scheme: 'http' }), appId };\n }\n\n // Caller explicitly wants the disambiguation page — useful when they want the device (not the\n // dev server) to pick between Expo Go and the dev build. No `runtime` field on the response\n // since the actual runtime depends on the device's choice.\n if (runtime === 'unknown') {\n return { url: urlCreator.constructLoadingUrl({}, platform), appId };\n }\n\n // `runtime: 'default'` mirrors what pressing `i` / `a` does in the terminal:\n // --dev-client server → open the dev client directly.\n // project has both → hand off to the disambiguation interstitial so the\n // device resolves between Expo Go and the dev build.\n // else → open Expo Go directly.\n if (runtime === 'default') {\n if (isDevClient) {\n return { runtime: 'custom', url: urlCreator.constructDevClientUrl(), appId };\n }\n if (isRedirectPageEnabled) {\n return { url: urlCreator.constructLoadingUrl({}, platform), appId };\n }\n return { runtime: 'expo', url: urlCreator.
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/openHandlers.ts"],"sourcesContent":["import type {\n OpenActionResult,\n OpenInfoResult,\n OpenMiddlewareOptions,\n OpenNativeRuntime,\n OpenPlatform,\n OpenPlatformInfo,\n OpenRequestedRuntime,\n} from './OpenMiddleware';\nimport type { UrlCreator } from '../UrlCreator';\n\ninterface InfoHandlerDeps {\n /** Stable UrlCreator instance — its `defaults` mutate when `toggleRuntimeMode` runs, so the same instance keeps producing fresh URLs and reflects the current scheme. */\n urlCreator: UrlCreator;\n /**\n * Read live values every call. The dev server's runtime mode can flip mid-run via the `s` key\n * in the terminal, and `expo-dev-client` can be installed while the server is running — both\n * change `isDevClient` and `isRedirectPageEnabled`, and the endpoint should reflect the\n * current state on every request.\n */\n getIsDevClient: () => boolean;\n /** Live mirror of `BundlerDevServer.isRedirectPageEnabled()`. */\n getIsRedirectPageEnabled: () => boolean;\n /**\n * Resolve the native application identifier for a platform (iOS bundle id / Android package\n * name). Implementations should return `null` instead of throwing when the project has no\n * configured identifier; the endpoint surfaces `null` so distributed preview systems can detect\n * that the build can't be matched by app id and either bail out or prompt the user.\n */\n getAppId: (platform: OpenPlatform) => Promise<string | null>;\n}\n\n/**\n * Build the GET handler for `/_expo/open`. Resolves dry-run info for a single platform, or for\n * every platform in discovery mode. Extracted so it can be exercised with a real\n * {@link UrlCreator} in tests (covers tunnel routing in particular).\n */\nexport function createInfoHandler(deps: InfoHandlerDeps): OpenMiddlewareOptions['getInfo'] {\n return ({ platform, runtime }) => resolveOpenInfo({ platform, runtime }, deps);\n}\n\nexport async function resolveOpenInfo(\n { platform, runtime }: { platform: OpenPlatform | null; runtime: OpenRequestedRuntime },\n deps: InfoHandlerDeps\n): Promise<OpenInfoResult> {\n // Snapshot the live state once per request so the response is internally consistent even if a\n // toggle happens between sub-resolutions.\n const scheme = deps.urlCreator.getScheme();\n const isDevClient = deps.getIsDevClient();\n const isRedirectPageEnabled = deps.getIsRedirectPageEnabled();\n const availableRuntimes: OpenNativeRuntime[] = isDevClient\n ? ['custom']\n : isRedirectPageEnabled\n ? ['expo', 'custom']\n : ['expo'];\n\n if (platform) {\n return {\n scheme,\n availableRuntimes,\n ...(await resolvePlatformInfo(platform, runtime, deps, {\n isDevClient,\n isRedirectPageEnabled,\n })),\n };\n }\n\n const [ios, android, web] = await Promise.all([\n resolvePlatformInfo('ios', runtime, deps, { isDevClient, isRedirectPageEnabled }),\n resolvePlatformInfo('android', runtime, deps, { isDevClient, isRedirectPageEnabled }),\n resolvePlatformInfo('web', runtime, deps, { isDevClient, isRedirectPageEnabled }),\n ]);\n return { scheme, availableRuntimes, platforms: { ios, android, web } };\n}\n\nasync function resolvePlatformInfo(\n platform: OpenPlatform,\n runtime: OpenRequestedRuntime,\n deps: InfoHandlerDeps,\n state: { isDevClient: boolean; isRedirectPageEnabled: boolean }\n): Promise<OpenPlatformInfo> {\n const { urlCreator, getAppId } = deps;\n const { isDevClient, isRedirectPageEnabled } = state;\n const appId = await getAppId(platform);\n\n if (platform === 'web') {\n // constructUrl inherits the tunnel host from `defaults.hostType` when --tunnel is active,\n // so this returns the ngrok URL instead of localhost in that case.\n return { runtime: 'web', url: urlCreator.constructUrl({ scheme: 'http' }), appId };\n }\n\n // Caller explicitly wants the disambiguation page — useful when they want the device (not the\n // dev server) to pick between Expo Go and the dev build. No `runtime` field on the response\n // since the actual runtime depends on the device's choice.\n if (runtime === 'unknown') {\n return { url: urlCreator.constructLoadingUrl({}, platform), appId };\n }\n\n // `runtime: 'default'` mirrors what pressing `i` / `a` does in the terminal:\n // --dev-client server → open the dev client directly.\n // project has both → hand off to the disambiguation interstitial so the\n // device resolves between Expo Go and the dev build.\n // else → open Expo Go directly.\n if (runtime === 'default') {\n if (isDevClient) {\n return { runtime: 'custom', url: urlCreator.constructDevClientUrl(), appId };\n }\n if (isRedirectPageEnabled) {\n return { url: urlCreator.constructLoadingUrl({}, platform), appId };\n }\n return { runtime: 'expo', url: urlCreator.constructExpoGoUrl(), appId };\n }\n\n return {\n runtime,\n url:\n runtime === 'custom' ? urlCreator.constructDevClientUrl() : urlCreator.constructExpoGoUrl(),\n appId,\n };\n}\n\ninterface OpenHandlerDeps {\n /** Live `BundlerDevServer.isDevClient` — `s` in the terminal can flip this between dispatch and response. */\n getIsDevClient: () => boolean;\n /** Same shape as `BundlerDevServer.openPlatformAsync`. */\n openPlatformAsync: (\n launchTarget: 'simulator' | 'emulator' | 'desktop',\n resolver?: { shouldPrompt?: boolean }\n ) => Promise<{ url: string | null }>;\n}\n\n/** Build the POST handler for `/_expo/open` — dispatches to the dev server's platform launcher. */\nexport function createOpen(deps: OpenHandlerDeps): OpenMiddlewareOptions['open'] {\n return async ({ platform }): Promise<OpenActionResult> => {\n if (platform === 'web') {\n const result = await deps.openPlatformAsync('desktop');\n return { platform, runtime: 'web', url: result.url ?? '' };\n }\n const launchTarget = platform === 'ios' ? 'simulator' : 'emulator';\n const result = await deps.openPlatformAsync(launchTarget, { shouldPrompt: false });\n return {\n platform,\n runtime: deps.getIsDevClient() ? 'custom' : 'expo',\n url: result.url ?? '',\n };\n };\n}\n"],"names":["createInfoHandler","createOpen","resolveOpenInfo","deps","platform","runtime","scheme","urlCreator","getScheme","isDevClient","getIsDevClient","isRedirectPageEnabled","getIsRedirectPageEnabled","availableRuntimes","resolvePlatformInfo","ios","android","web","Promise","all","platforms","state","getAppId","appId","url","constructUrl","constructLoadingUrl","constructDevClientUrl","constructExpoGoUrl","result","openPlatformAsync","launchTarget","shouldPrompt"],"mappings":";;;;;;;;;;;QAqCgBA;eAAAA;;QA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face/startInterface");
|
|
|
32
32
|
const _resolveOptions = require("./resolveOptions");
|
|
33
33
|
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../log"));
|
|
34
34
|
const _DevServerManager = require("./server/DevServerManager");
|
|
35
|
-
const _MCP = require("./server/MCP");
|
|
35
|
+
const _MCP = require("./server/mcp/MCP");
|
|
36
36
|
const _openPlatforms = require("./server/openPlatforms");
|
|
37
37
|
const _platformBundlers = require("./server/platformBundlers");
|
|
38
38
|
const _env = require("../utils/env");
|
|
39
39
|
const _interactive = require("../utils/interactive");
|
|
40
40
|
const _profile = require("../utils/profile");
|
|
41
|
-
const _MCPDevToolsPluginCLIExtensions = require("./server/MCPDevToolsPluginCLIExtensions");
|
|
42
41
|
function _interop_require_default(obj) {
|
|
43
42
|
return obj && obj.__esModule ? obj : {
|
|
44
43
|
default: obj
|
|
@@ -170,7 +169,7 @@ async function startAsync(projectRoot, options, settings) {
|
|
|
170
169
|
await (0, _profile.profile)(_openPlatforms.openPlatformsAsync)(devServerManager, options);
|
|
171
170
|
const defaultServerUrl = ((_devServerManager_getDefaultDevServer = devServerManager.getDefaultDevServer()) == null ? void 0 : _devServerManager_getDefaultDevServer.getDevServerUrl()) ?? '';
|
|
172
171
|
const mcpServer = await (0, _profile.profile)(_MCP.maybeCreateMCPServerAsync)({
|
|
173
|
-
|
|
172
|
+
devServerManager,
|
|
174
173
|
devServerUrl: defaultServerUrl
|
|
175
174
|
}) ?? undefined;
|
|
176
175
|
// Present the Terminal UI.
|
|
@@ -203,7 +202,6 @@ async function startAsync(projectRoot, options, settings) {
|
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
204
|
if (mcpServer) {
|
|
206
|
-
(0, _MCPDevToolsPluginCLIExtensions.addMcpCapabilities)(mcpServer, devServerManager);
|
|
207
205
|
mcpServer.start();
|
|
208
206
|
}
|
|
209
207
|
// Final note about closing the server.
|