@expo/cli 0.19.2 → 0.19.3
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/start/server/metro/instantiateMetro.js +1 -1
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/middleware/inspector/CdpClient.js +77 -0
- package/build/src/start/server/middleware/inspector/CdpClient.js.map +1 -0
- package/build/src/start/server/middleware/inspector/JsInspector.js +20 -2
- package/build/src/start/server/middleware/inspector/JsInspector.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 +2 -2
package/build/bin/cli
CHANGED
|
@@ -255,7 +255,7 @@ function pruneCustomTransformOptions(filePath, transformOptions) {
|
|
|
255
255
|
transformOptions.customTransformOptions.routerRoot = "app";
|
|
256
256
|
}
|
|
257
257
|
if (((ref2 = transformOptions.customTransformOptions) == null ? void 0 : ref2.asyncRoutes) && // The async routes settings are also used in `expo-router/_ctx.ios.js` (and other platform variants) via `process.env.EXPO_ROUTER_IMPORT_MODE`
|
|
258
|
-
!(filePath.match(/\/expo-router\/_ctx
|
|
258
|
+
!(filePath.match(/\/expo-router\/_ctx/) || filePath.match(/\/expo-router\/build\//))) {
|
|
259
259
|
delete transformOptions.customTransformOptions.asyncRoutes;
|
|
260
260
|
}
|
|
261
261
|
if (((ref3 = transformOptions.customTransformOptions) == null ? void 0 : ref3.clientBoundaries) && // The client boundaries are only used in `expo-router/virtual-client-boundaries.js` for production RSC exports.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport { getDefaultConfig, LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport http from 'http';\nimport type Metro from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport type { TransformOptions } from 'metro/src/DeltaBundler/Worker';\nimport MetroHmrServer from 'metro/src/HmrServer';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\n\nimport { createDevToolsPluginWebsocketEndpoint } from './DevToolsPluginWebsocketEndpoint';\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { attachAtlasAsync } from './debugging/attachAtlas';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { createMetroMiddleware } from './dev-server/createMetroMiddleware';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n// Wrap terminal and polyfill console.log so we can log during bundling without breaking the indicator.\nclass LogRespectingTerminal extends Terminal {\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream);\n\n const sendLog = (...args: any[]) => {\n this._logLines.push(\n // format args like console.log\n util.format(...args)\n );\n this._scheduleUpdate();\n\n // Flush the logs to the terminal immediately so logs at the end of the process are not lost.\n this.flush();\n };\n\n console.log = sendLog;\n console.info = sendLog;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp,\n isExporting,\n getMetroBundler,\n }: { exp: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (exp.experiments?.reactServerComponents) {\n process.env.EXPO_USE_METRO_REQUIRE = '1';\n process.env.EXPO_USE_FAST_RESOLVER = '1';\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const hasConfig = await resolveConfig(options.config, projectRoot);\n let config: ConfigT = {\n ...(await loadConfig(\n { cwd: projectRoot, projectRoot, ...options },\n // If the project does not have a metro.config.js, then we use the default config.\n hasConfig.isEmpty ? getDefaultConfig(projectRoot) : undefined\n )),\n reporter: {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n // @ts-expect-error: Set the global require cycle ignore patterns for SSR bundles. This won't work with custom global prefixes, but we don't use those.\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 // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n if (exp.experiments?.reactCompiler) {\n Log.warn(`Experimental React Compiler is 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 (env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n Log.warn(`Experimental bundle optimization is enabled.`);\n }\n if (env.EXPO_UNSTABLE_TREE_SHAKING) {\n Log.warn(`Experimental tree shaking is enabled.`);\n }\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n isExporting,\n isReactCanaryEnabled:\n (exp.experiments?.reactServerComponents || exp.experiments?.reactCanary) ?? false,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: !!exp.experiments?.reactServerComponents,\n getMetroBundler,\n });\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<LoadOptions, 'logger'>,\n {\n isExporting,\n exp = getConfig(metroBundler.projectRoot, {\n skipSDKVersionRequirement: true,\n }).exp,\n }: { isExporting: boolean; exp?: ExpoConfig }\n): Promise<{\n metro: Metro.Server;\n hmrServer: MetroHmrServer | null;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n {\n exp,\n isExporting,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n // Create the core middleware stack for Metro, including websocket listeners\n const { middleware, messagesSocket, eventsSocket, websocketEndpoints } =\n createMetroMiddleware(metroConfig);\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(metroBundler);\n Object.assign(websocketEndpoints, debugWebsocketEndpoints);\n middleware.use(debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware());\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 // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n }\n\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 const { server, hmrServer, metro } = await runServer(\n metroBundler,\n metroConfig,\n {\n websocketEndpoints: {\n ...websocketEndpoints,\n ...createDevToolsPluginWebsocketEndpoint(),\n },\n watch: !isExporting && isWatchEnabled(),\n },\n {\n mockServer: isExporting,\n }\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 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 setEventReporter(eventsSocket.reportMetroEvent);\n\n return {\n metro,\n hmrServer,\n server,\n middleware,\n messageSocket: messagesSocket,\n };\n}\n\n// TODO: Fork the entire transform function so we can simply regex the file contents for keywords instead.\nfunction pruneCustomTransformOptions(\n filePath: string,\n transformOptions: TransformOptions\n): TransformOptions {\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 if (\n transformOptions.customTransformOptions?.routerRoot &&\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 !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n // Set to the default value.\n transformOptions.customTransformOptions.routerRoot = 'app';\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 !(\n filePath.match(/\\/expo-router\\/_ctx\\.(ios|android|web)\\.js$/) ||\n filePath.match(/\\/expo-router\\/build\\/import-mode\\/index\\.js$/)\n )\n ) {\n delete transformOptions.customTransformOptions.asyncRoutes;\n }\n\n if (\n transformOptions.customTransformOptions?.clientBoundaries &&\n // The client boundaries are only used in `expo-router/virtual-client-boundaries.js` for production RSC exports.\n !filePath.match(/\\/expo-router\\/virtual-client-boundaries\\.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":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","LogRespectingTerminal","Terminal","constructor","stream","sendLog","args","_logLines","push","util","format","_scheduleUpdate","flush","console","log","info","terminal","process","stdout","projectRoot","options","exp","isExporting","getMetroBundler","config","reportEvent","experiments","reactServerComponents","env","EXPO_USE_METRO_REQUIRE","EXPO_USE_FAST_RESOLVER","serverRoot","getMetroServerRoot","terminalReporter","MetroTerminalReporter","hasConfig","resolveConfig","loadConfig","cwd","isEmpty","getDefaultConfig","undefined","reporter","update","event","globalThis","__requireCycleIgnorePatterns","resolver","requireCycleIgnorePatterns","transformer","publicPath","baseUrl","platformBundlers","getPlatformBundlers","reactCompiler","Log","warn","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","CommandError","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","isFastResolverEnabled","isReactCanaryEnabled","reactCanary","isNamedRequiresEnabled","isReactServerComponentsEnabled","setEventReporter","logger","metroBundler","getConfig","skipSDKVersionRequirement","metroConfig","metro","getBundler","middleware","messagesSocket","eventsSocket","websocketEndpoints","createMetroMiddleware","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","server","enhanceMiddleware","metroMiddleware","attachAtlasAsync","resetAtlasFile","hmrServer","runServer","createDevToolsPluginWebsocketEndpoint","watch","mockServer","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","reportMetroEvent","messageSocket","dom","match","routerRoot","asyncRoutes","clientBoundaries","CI","chalk"],"mappings":"AAAA;;;;;;;;;;;IA0DsBA,oBAAoB,MAApBA,oBAAoB;IA4FpBC,qBAAqB,MAArBA,qBAAqB;IA2K3BC,cAAc,MAAdA,cAAc;;;yBAjUQ,cAAc;;;;;;;yBACjB,oBAAoB;;;;;;;yBACT,oBAAoB;;;;;;;8DAChD,OAAO;;;;;;;yBAM0B,cAAc;;;;;;;yBACxC,YAAY;;;;;;;8DACpB,WAAW;;;;;;iDAE0B,mCAAmC;uCAEnD,yBAAyB;6BAC9B,yBAAyB;uCACpB,mCAAmC;uCACnC,oCAAoC;+BAChD,kBAAkB;wCACA,0BAA0B;qBAClD,cAAc;qBACd,oBAAoB;wBACX,uBAAuB;gCACf,8BAA8B;6CACvB,qDA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+
{"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport { getDefaultConfig, LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport http from 'http';\nimport type Metro from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport type { TransformOptions } from 'metro/src/DeltaBundler/Worker';\nimport MetroHmrServer from 'metro/src/HmrServer';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\n\nimport { createDevToolsPluginWebsocketEndpoint } from './DevToolsPluginWebsocketEndpoint';\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { attachAtlasAsync } from './debugging/attachAtlas';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { createMetroMiddleware } from './dev-server/createMetroMiddleware';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n// Wrap terminal and polyfill console.log so we can log during bundling without breaking the indicator.\nclass LogRespectingTerminal extends Terminal {\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream);\n\n const sendLog = (...args: any[]) => {\n this._logLines.push(\n // format args like console.log\n util.format(...args)\n );\n this._scheduleUpdate();\n\n // Flush the logs to the terminal immediately so logs at the end of the process are not lost.\n this.flush();\n };\n\n console.log = sendLog;\n console.info = sendLog;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp,\n isExporting,\n getMetroBundler,\n }: { exp: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (exp.experiments?.reactServerComponents) {\n process.env.EXPO_USE_METRO_REQUIRE = '1';\n process.env.EXPO_USE_FAST_RESOLVER = '1';\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const hasConfig = await resolveConfig(options.config, projectRoot);\n let config: ConfigT = {\n ...(await loadConfig(\n { cwd: projectRoot, projectRoot, ...options },\n // If the project does not have a metro.config.js, then we use the default config.\n hasConfig.isEmpty ? getDefaultConfig(projectRoot) : undefined\n )),\n reporter: {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n // @ts-expect-error: Set the global require cycle ignore patterns for SSR bundles. This won't work with custom global prefixes, but we don't use those.\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 // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n if (exp.experiments?.reactCompiler) {\n Log.warn(`Experimental React Compiler is 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 (env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n Log.warn(`Experimental bundle optimization is enabled.`);\n }\n if (env.EXPO_UNSTABLE_TREE_SHAKING) {\n Log.warn(`Experimental tree shaking is enabled.`);\n }\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n isExporting,\n isReactCanaryEnabled:\n (exp.experiments?.reactServerComponents || exp.experiments?.reactCanary) ?? false,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: !!exp.experiments?.reactServerComponents,\n getMetroBundler,\n });\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<LoadOptions, 'logger'>,\n {\n isExporting,\n exp = getConfig(metroBundler.projectRoot, {\n skipSDKVersionRequirement: true,\n }).exp,\n }: { isExporting: boolean; exp?: ExpoConfig }\n): Promise<{\n metro: Metro.Server;\n hmrServer: MetroHmrServer | null;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n {\n exp,\n isExporting,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n // Create the core middleware stack for Metro, including websocket listeners\n const { middleware, messagesSocket, eventsSocket, websocketEndpoints } =\n createMetroMiddleware(metroConfig);\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(metroBundler);\n Object.assign(websocketEndpoints, debugWebsocketEndpoints);\n middleware.use(debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware());\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 // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n }\n\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 const { server, hmrServer, metro } = await runServer(\n metroBundler,\n metroConfig,\n {\n websocketEndpoints: {\n ...websocketEndpoints,\n ...createDevToolsPluginWebsocketEndpoint(),\n },\n watch: !isExporting && isWatchEnabled(),\n },\n {\n mockServer: isExporting,\n }\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 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 setEventReporter(eventsSocket.reportMetroEvent);\n\n return {\n metro,\n hmrServer,\n server,\n middleware,\n messageSocket: messagesSocket,\n };\n}\n\n// TODO: Fork the entire transform function so we can simply regex the file contents for keywords instead.\nfunction pruneCustomTransformOptions(\n filePath: string,\n transformOptions: TransformOptions\n): TransformOptions {\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 if (\n transformOptions.customTransformOptions?.routerRoot &&\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 !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n // Set to the default value.\n transformOptions.customTransformOptions.routerRoot = 'app';\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-router/virtual-client-boundaries.js` for production RSC exports.\n !filePath.match(/\\/expo-router\\/virtual-client-boundaries\\.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":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","LogRespectingTerminal","Terminal","constructor","stream","sendLog","args","_logLines","push","util","format","_scheduleUpdate","flush","console","log","info","terminal","process","stdout","projectRoot","options","exp","isExporting","getMetroBundler","config","reportEvent","experiments","reactServerComponents","env","EXPO_USE_METRO_REQUIRE","EXPO_USE_FAST_RESOLVER","serverRoot","getMetroServerRoot","terminalReporter","MetroTerminalReporter","hasConfig","resolveConfig","loadConfig","cwd","isEmpty","getDefaultConfig","undefined","reporter","update","event","globalThis","__requireCycleIgnorePatterns","resolver","requireCycleIgnorePatterns","transformer","publicPath","baseUrl","platformBundlers","getPlatformBundlers","reactCompiler","Log","warn","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","CommandError","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","isFastResolverEnabled","isReactCanaryEnabled","reactCanary","isNamedRequiresEnabled","isReactServerComponentsEnabled","setEventReporter","logger","metroBundler","getConfig","skipSDKVersionRequirement","metroConfig","metro","getBundler","middleware","messagesSocket","eventsSocket","websocketEndpoints","createMetroMiddleware","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","server","enhanceMiddleware","metroMiddleware","attachAtlasAsync","resetAtlasFile","hmrServer","runServer","createDevToolsPluginWebsocketEndpoint","watch","mockServer","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","reportMetroEvent","messageSocket","dom","match","routerRoot","asyncRoutes","clientBoundaries","CI","chalk"],"mappings":"AAAA;;;;;;;;;;;IA0DsBA,oBAAoB,MAApBA,oBAAoB;IA4FpBC,qBAAqB,MAArBA,qBAAqB;IAwK3BC,cAAc,MAAdA,cAAc;;;yBA9TQ,cAAc;;;;;;;yBACjB,oBAAoB;;;;;;;yBACT,oBAAoB;;;;;;;8DAChD,OAAO;;;;;;;yBAM0B,cAAc;;;;;;;yBACxC,YAAY;;;;;;;8DACpB,WAAW;;;;;;iDAE0B,mCA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zC,GAAG,CACLwG,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;IACJ,CAAC;IAED,OAAO,CAAC1F,IAAG,IAAA,CAACyF,EAAE,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "evaluateJsFromCdpAsync", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>evaluateJsFromCdpAsync
|
|
8
|
+
});
|
|
9
|
+
function _ws() {
|
|
10
|
+
const data = require("ws");
|
|
11
|
+
_ws = function() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
const debug = require("debug")("expo:start:server:middleware:inspector:CdpClient");
|
|
17
|
+
function evaluateJsFromCdpAsync(webSocketDebuggerUrl, source, timeoutMs = 2000) {
|
|
18
|
+
const REQUEST_ID = 0;
|
|
19
|
+
let timeoutHandle;
|
|
20
|
+
return new Promise((resolve, reject)=>{
|
|
21
|
+
let settled = false;
|
|
22
|
+
const ws = new (_ws()).WebSocket(webSocketDebuggerUrl);
|
|
23
|
+
timeoutHandle = setTimeout(()=>{
|
|
24
|
+
debug(`[evaluateJsFromCdpAsync] Request timeout from ${webSocketDebuggerUrl}`);
|
|
25
|
+
reject(new Error("Request timeout"));
|
|
26
|
+
settled = true;
|
|
27
|
+
ws.close();
|
|
28
|
+
}, timeoutMs);
|
|
29
|
+
ws.on("open", ()=>{
|
|
30
|
+
ws.send(JSON.stringify({
|
|
31
|
+
id: REQUEST_ID,
|
|
32
|
+
method: "Runtime.evaluate",
|
|
33
|
+
params: {
|
|
34
|
+
expression: source
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
ws.on("error", (e)=>{
|
|
39
|
+
debug(`[evaluateJsFromCdpAsync] Failed to connect ${webSocketDebuggerUrl}`, e);
|
|
40
|
+
reject(e);
|
|
41
|
+
settled = true;
|
|
42
|
+
clearTimeout(timeoutHandle);
|
|
43
|
+
ws.close();
|
|
44
|
+
});
|
|
45
|
+
ws.on("close", ()=>{
|
|
46
|
+
if (!settled) {
|
|
47
|
+
reject(new Error("WebSocket closed before response was received."));
|
|
48
|
+
clearTimeout(timeoutHandle);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
ws.on("message", (data)=>{
|
|
52
|
+
debug(`[evaluateJsFromCdpAsync] message received from ${webSocketDebuggerUrl}: ${data.toString()}`);
|
|
53
|
+
try {
|
|
54
|
+
const response = JSON.parse(data.toString());
|
|
55
|
+
if (response.id === REQUEST_ID) {
|
|
56
|
+
if (response.error) {
|
|
57
|
+
reject(new Error(response.error.message));
|
|
58
|
+
} else if (response.result.result.type === "string") {
|
|
59
|
+
resolve(response.result.result.value);
|
|
60
|
+
} else {
|
|
61
|
+
resolve(undefined);
|
|
62
|
+
}
|
|
63
|
+
settled = true;
|
|
64
|
+
clearTimeout(timeoutHandle);
|
|
65
|
+
ws.close();
|
|
66
|
+
}
|
|
67
|
+
} catch (e) {
|
|
68
|
+
reject(e);
|
|
69
|
+
settled = true;
|
|
70
|
+
clearTimeout(timeoutHandle);
|
|
71
|
+
ws.close();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=CdpClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/CdpClient.ts"],"sourcesContent":["import { WebSocket } from 'ws';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:inspector:CdpClient'\n) as typeof console.log;\n\nexport function evaluateJsFromCdpAsync(\n webSocketDebuggerUrl: string,\n source: string,\n timeoutMs: number = 2000\n): Promise<string | undefined> {\n const REQUEST_ID = 0;\n let timeoutHandle: NodeJS.Timeout;\n\n return new Promise((resolve, reject) => {\n let settled = false;\n const ws = new WebSocket(webSocketDebuggerUrl);\n\n timeoutHandle = setTimeout(() => {\n debug(`[evaluateJsFromCdpAsync] Request timeout from ${webSocketDebuggerUrl}`);\n reject(new Error('Request timeout'));\n settled = true;\n ws.close();\n }, timeoutMs);\n\n ws.on('open', () => {\n ws.send(\n JSON.stringify({\n id: REQUEST_ID,\n method: 'Runtime.evaluate',\n params: { expression: source },\n })\n );\n });\n\n ws.on('error', (e) => {\n debug(`[evaluateJsFromCdpAsync] Failed to connect ${webSocketDebuggerUrl}`, e);\n reject(e);\n settled = true;\n clearTimeout(timeoutHandle);\n ws.close();\n });\n\n ws.on('close', () => {\n if (!settled) {\n reject(new Error('WebSocket closed before response was received.'));\n clearTimeout(timeoutHandle);\n }\n });\n\n ws.on('message', (data) => {\n debug(\n `[evaluateJsFromCdpAsync] message received from ${webSocketDebuggerUrl}: ${data.toString()}`\n );\n try {\n const response = JSON.parse(data.toString());\n if (response.id === REQUEST_ID) {\n if (response.error) {\n reject(new Error(response.error.message));\n } else if (response.result.result.type === 'string') {\n resolve(response.result.result.value);\n } else {\n resolve(undefined);\n }\n settled = true;\n clearTimeout(timeoutHandle);\n ws.close();\n }\n } catch (e) {\n reject(e);\n settled = true;\n clearTimeout(timeoutHandle);\n ws.close();\n }\n });\n });\n}\n"],"names":["evaluateJsFromCdpAsync","debug","require","webSocketDebuggerUrl","source","timeoutMs","REQUEST_ID","timeoutHandle","Promise","resolve","reject","settled","ws","WebSocket","setTimeout","Error","close","on","send","JSON","stringify","id","method","params","expression","e","clearTimeout","data","toString","response","parse","error","message","result","type","value","undefined"],"mappings":"AAAA;;;;+BAMgBA,wBAAsB;;aAAtBA,sBAAsB;;;yBANZ,IAAI;;;;;;AAE9B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,kDAAkD,CACnD,AAAsB,AAAC;AAEjB,SAASF,sBAAsB,CACpCG,oBAA4B,EAC5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
|
@@ -21,6 +21,7 @@ function _chalk() {
|
|
|
21
21
|
};
|
|
22
22
|
return data;
|
|
23
23
|
}
|
|
24
|
+
const _cdpClient = require("./CdpClient");
|
|
24
25
|
const _prompts = require("../../../../utils/prompts");
|
|
25
26
|
const _pageIsSupported = require("../../metro/debugging/pageIsSupported");
|
|
26
27
|
function _interopRequireDefault(obj) {
|
|
@@ -54,8 +55,19 @@ async function queryInspectorAppAsync(metroServerOrigin, appId) {
|
|
|
54
55
|
async function queryAllInspectorAppsAsync(metroServerOrigin) {
|
|
55
56
|
const resp = await fetch(`${metroServerOrigin}/json/list`);
|
|
56
57
|
const apps = transformApps(await resp.json());
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const results = [];
|
|
59
|
+
for (const app of apps){
|
|
60
|
+
// Only use targets with better reloading support
|
|
61
|
+
if (!(0, _pageIsSupported.pageIsSupported)(app)) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Hide targets that are marked as hidden from the inspector, e.g. instances from expo-dev-menu and expo-dev-launcher.
|
|
65
|
+
if (await appShouldBeIgnoredAsync(app)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
results.push(app);
|
|
69
|
+
}
|
|
70
|
+
return results;
|
|
59
71
|
}
|
|
60
72
|
async function promptInspectorAppAsync(apps) {
|
|
61
73
|
var ref;
|
|
@@ -97,5 +109,11 @@ function transformApps(apps) {
|
|
|
97
109
|
return app;
|
|
98
110
|
});
|
|
99
111
|
}
|
|
112
|
+
const HIDE_FROM_INSPECTOR_ENV = "globalThis.__expo_hide_from_inspector__";
|
|
113
|
+
async function appShouldBeIgnoredAsync(app) {
|
|
114
|
+
const hideFromInspector = await (0, _cdpClient.evaluateJsFromCdpAsync)(app.webSocketDebuggerUrl, HIDE_FROM_INSPECTOR_ENV);
|
|
115
|
+
debug(`[appShouldBeIgnoredAsync] webSocketDebuggerUrl[${app.webSocketDebuggerUrl}] hideFromInspector[${hideFromInspector}]`);
|
|
116
|
+
return hideFromInspector !== undefined;
|
|
117
|
+
}
|
|
100
118
|
|
|
101
119
|
//# sourceMappingURL=JsInspector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/JsInspector.ts"],"sourcesContent":["import type { CustomMessageHandlerConnection } from '@react-native/dev-middleware';\nimport chalk from 'chalk';\n\nimport { selectAsync } from '../../../../utils/prompts';\nimport { pageIsSupported } from '../../metro/debugging/pageIsSupported';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:inspector:jsInspector'\n) as typeof console.log;\n\nexport interface MetroInspectorProxyApp {\n /** Unique device ID combined with the page ID */\n id: string;\n /** Information about the underlying CDP implementation, e.g. \"React Native Bridgeless [C++ connection]\" */\n title: string;\n /** The application ID that is currently running on the device, e.g. \"dev.expo.bareexpo\" */\n description: string;\n /** The CDP debugger type, which should always be \"node\" */\n type: 'node';\n /** The internal `devtools://..` URL for the debugger to connect to */\n devtoolsFrontendUrl: string;\n /** The websocket URL for the debugger to connect to */\n webSocketDebuggerUrl: string;\n /**\n * Human-readable device name\n * @since react-native@0.73\n */\n deviceName: string;\n /**\n * React Native specific information, like the unique device ID and native capabilities\n * @since react-native@0.74\n */\n reactNative?: {\n /** The unique device ID */\n logicalDeviceId: string;\n /** All supported native capabilities */\n capabilities: CustomMessageHandlerConnection['page']['capabilities'];\n };\n}\n\n/**\n * Launch the React Native DevTools by executing the `POST /open-debugger` request.\n * This endpoint is handled through `@react-native/dev-middleware`.\n */\nexport async function openJsInspector(metroBaseUrl: string, app: MetroInspectorProxyApp) {\n if (!app.reactNative?.logicalDeviceId) {\n debug('Failed to open React Native DevTools, target is missing device ID');\n return false;\n }\n\n const url = new URL('/open-debugger', metroBaseUrl);\n url.searchParams.set('appId', app.description);\n url.searchParams.set('device', app.reactNative.logicalDeviceId);\n url.searchParams.set('target', app.id);\n\n const response = await fetch(url, { method: 'POST' });\n if (!response.ok) {\n debug('Failed to open React Native DevTools, received response:', response.status);\n }\n\n return response.ok;\n}\n\nexport async function queryInspectorAppAsync(\n metroServerOrigin: string,\n appId: string\n): Promise<MetroInspectorProxyApp | null> {\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n return apps.find((app) => app.description === appId) ?? null;\n}\n\nexport async function queryAllInspectorAppsAsync(\n metroServerOrigin: string\n): Promise<MetroInspectorProxyApp[]> {\n const resp = await fetch(`${metroServerOrigin}/json/list`);\n const apps: MetroInspectorProxyApp[] = transformApps(await resp.json());\n // Only use targets with better reloading support\n return apps.filter((app) => pageIsSupported(app));\n}\n\nexport async function promptInspectorAppAsync(apps: MetroInspectorProxyApp[]) {\n if (apps.length === 1) {\n return apps[0];\n }\n\n // Check if multiple devices are connected with the same device names\n // In this case, append the actual app id (device ID + page number) to the prompt\n const hasDuplicateNames = apps.some(\n (app, index) => index !== apps.findIndex((other) => app.deviceName === other.deviceName)\n );\n\n const choices = apps.map((app) => {\n const name = app.deviceName ?? 'Unknown device';\n return {\n title: hasDuplicateNames ? chalk`${name}{dim - ${app.id}}` : name,\n value: app.id,\n app,\n };\n });\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n\n return choices.find((item) => item.value === value)?.app;\n}\n\n// The description of `React Native Experimental (Improved Chrome Reloads)` target is `don't use` from metro.\n// This function tries to transform the unmeaningful description to appId\nfunction transformApps(apps: MetroInspectorProxyApp[]): MetroInspectorProxyApp[] {\n const deviceIdToAppId: Record<string, string> = {};\n\n for (const app of apps) {\n if (app.description !== \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n const appId = app.description;\n deviceIdToAppId[deviceId] = appId;\n }\n }\n\n return apps.map((app) => {\n if (app.description === \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n app.description = deviceIdToAppId[deviceId] ?? app.description;\n }\n return app;\n });\n}\n"],"names":["openJsInspector","queryInspectorAppAsync","queryAllInspectorAppsAsync","promptInspectorAppAsync","debug","require","metroBaseUrl","app","reactNative","logicalDeviceId","url","URL","searchParams","set","description","id","response","fetch","method","ok","status","metroServerOrigin","appId","apps","find","resp","transformApps","json","filter","pageIsSupported","choices","length","hasDuplicateNames","some","index","findIndex","other","deviceName","map","name","title","chalk","value","selectAsync","item","deviceIdToAppId","deviceId","split"],"mappings":"AAAA;;;;;;;;;;;IA4CsBA,eAAe,MAAfA,eAAe;IAmBfC,sBAAsB,MAAtBA,sBAAsB;IAQtBC,0BAA0B,MAA1BA,0BAA0B;IAS1BC,uBAAuB,MAAvBA,uBAAuB;;;8DA/E3B,OAAO;;;;;;yBAEG,2BAA2B;iCACvB,uCAAuC;;;;;;AAEvE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,oDAAoD,CACrD,AAAsB,AAAC;AAoCjB,eAAeL,eAAe,CAACM,YAAoB,EAAEC,GAA2B,EAAE;QAClFA,GAAe;IAApB,IAAI,CAACA,CAAAA,CAAAA,GAAe,GAAfA,GAAG,CAACC,WAAW,SAAiB,GAAhCD,KAAAA,CAAgC,GAAhCA,GAAe,CAAEE,eAAe,CAAA,EAAE;QACrCL,KAAK,CAAC,mEAAmE,CAAC,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAMM,GAAG,GAAG,IAAIC,GAAG,CAAC,gBAAgB,EAAEL,YAAY,CAAC,AAAC;IACpDI,GAAG,CAACE,YAAY,CAACC,GAAG,CAAC,OAAO,EAAEN,GAAG,CAACO,WAAW,CAAC,CAAC;IAC/CJ,GAAG,CAACE,YAAY,CAACC,GAAG,CAAC,QAAQ,EAAEN,GAAG,CAACC,WAAW,CAACC,eAAe,CAAC,CAAC;IAChEC,GAAG,CAACE,YAAY,CAACC,GAAG,CAAC,QAAQ,EAAEN,GAAG,CAACQ,EAAE,CAAC,CAAC;IAEvC,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACP,GAAG,EAAE;QAAEQ,MAAM,EAAE,MAAM;KAAE,CAAC,A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AAC,GAAGxB,KAAK,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAOC,IAAI,CAACe,GAAG,CAAC,CAAC/B,GAAG,GAAK;QACvB,IAAIA,GAAG,CAACO,WAAW,KAAK,WAAW,EAAE;gBAClBP,GAAe;YAAhC,MAAMuC,QAAQ,GAAGvC,CAAAA,CAAAA,GAAe,GAAfA,GAAG,CAACC,WAAW,SAAiB,GAAhCD,KAAAA,CAAgC,GAAhCA,GAAe,CAAEE,eAAe,CAAA,IAAIF,GAAG,CAACQ,EAAE,CAACgC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,AAAC;YAC1ExC,GAAG,CAACO,WAAW,GAAG+B,eAAe,CAACC,QAAQ,CAAC,IAAIvC,GAAG,CAACO,WAAW,CAAC;QACjE,CAAC;QACD,OAAOP,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/JsInspector.ts"],"sourcesContent":["import type { CustomMessageHandlerConnection } from '@react-native/dev-middleware';\nimport chalk from 'chalk';\n\nimport { evaluateJsFromCdpAsync } from './CdpClient';\nimport { selectAsync } from '../../../../utils/prompts';\nimport { pageIsSupported } from '../../metro/debugging/pageIsSupported';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:inspector:jsInspector'\n) as typeof console.log;\n\nexport interface MetroInspectorProxyApp {\n /** Unique device ID combined with the page ID */\n id: string;\n /** Information about the underlying CDP implementation, e.g. \"React Native Bridgeless [C++ connection]\" */\n title: string;\n /** The application ID that is currently running on the device, e.g. \"dev.expo.bareexpo\" */\n description: string;\n /** The CDP debugger type, which should always be \"node\" */\n type: 'node';\n /** The internal `devtools://..` URL for the debugger to connect to */\n devtoolsFrontendUrl: string;\n /** The websocket URL for the debugger to connect to */\n webSocketDebuggerUrl: string;\n /**\n * Human-readable device name\n * @since react-native@0.73\n */\n deviceName: string;\n /**\n * React Native specific information, like the unique device ID and native capabilities\n * @since react-native@0.74\n */\n reactNative?: {\n /** The unique device ID */\n logicalDeviceId: string;\n /** All supported native capabilities */\n capabilities: CustomMessageHandlerConnection['page']['capabilities'];\n };\n}\n\n/**\n * Launch the React Native DevTools by executing the `POST /open-debugger` request.\n * This endpoint is handled through `@react-native/dev-middleware`.\n */\nexport async function openJsInspector(metroBaseUrl: string, app: MetroInspectorProxyApp) {\n if (!app.reactNative?.logicalDeviceId) {\n debug('Failed to open React Native DevTools, target is missing device ID');\n return false;\n }\n\n const url = new URL('/open-debugger', metroBaseUrl);\n url.searchParams.set('appId', app.description);\n url.searchParams.set('device', app.reactNative.logicalDeviceId);\n url.searchParams.set('target', app.id);\n\n const response = await fetch(url, { method: 'POST' });\n if (!response.ok) {\n debug('Failed to open React Native DevTools, received response:', response.status);\n }\n\n return response.ok;\n}\n\nexport async function queryInspectorAppAsync(\n metroServerOrigin: string,\n appId: string\n): Promise<MetroInspectorProxyApp | null> {\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n return apps.find((app) => app.description === appId) ?? null;\n}\n\nexport async function queryAllInspectorAppsAsync(\n metroServerOrigin: string\n): Promise<MetroInspectorProxyApp[]> {\n const resp = await fetch(`${metroServerOrigin}/json/list`);\n const apps: MetroInspectorProxyApp[] = transformApps(await resp.json());\n const results: MetroInspectorProxyApp[] = [];\n for (const app of apps) {\n // Only use targets with better reloading support\n if (!pageIsSupported(app)) {\n continue;\n }\n // Hide targets that are marked as hidden from the inspector, e.g. instances from expo-dev-menu and expo-dev-launcher.\n if (await appShouldBeIgnoredAsync(app)) {\n continue;\n }\n results.push(app);\n }\n return results;\n}\n\nexport async function promptInspectorAppAsync(apps: MetroInspectorProxyApp[]) {\n if (apps.length === 1) {\n return apps[0];\n }\n\n // Check if multiple devices are connected with the same device names\n // In this case, append the actual app id (device ID + page number) to the prompt\n const hasDuplicateNames = apps.some(\n (app, index) => index !== apps.findIndex((other) => app.deviceName === other.deviceName)\n );\n\n const choices = apps.map((app) => {\n const name = app.deviceName ?? 'Unknown device';\n return {\n title: hasDuplicateNames ? chalk`${name}{dim - ${app.id}}` : name,\n value: app.id,\n app,\n };\n });\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n\n return choices.find((item) => item.value === value)?.app;\n}\n\n// The description of `React Native Experimental (Improved Chrome Reloads)` target is `don't use` from metro.\n// This function tries to transform the unmeaningful description to appId\nfunction transformApps(apps: MetroInspectorProxyApp[]): MetroInspectorProxyApp[] {\n const deviceIdToAppId: Record<string, string> = {};\n\n for (const app of apps) {\n if (app.description !== \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n const appId = app.description;\n deviceIdToAppId[deviceId] = appId;\n }\n }\n\n return apps.map((app) => {\n if (app.description === \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n app.description = deviceIdToAppId[deviceId] ?? app.description;\n }\n return app;\n });\n}\n\nconst HIDE_FROM_INSPECTOR_ENV = 'globalThis.__expo_hide_from_inspector__';\n\nasync function appShouldBeIgnoredAsync(app: MetroInspectorProxyApp): Promise<boolean> {\n const hideFromInspector = await evaluateJsFromCdpAsync(\n app.webSocketDebuggerUrl,\n HIDE_FROM_INSPECTOR_ENV\n );\n debug(\n `[appShouldBeIgnoredAsync] webSocketDebuggerUrl[${app.webSocketDebuggerUrl}] hideFromInspector[${hideFromInspector}]`\n );\n return hideFromInspector !== undefined;\n}\n"],"names":["openJsInspector","queryInspectorAppAsync","queryAllInspectorAppsAsync","promptInspectorAppAsync","debug","require","metroBaseUrl","app","reactNative","logicalDeviceId","url","URL","searchParams","set","description","id","response","fetch","method","ok","status","metroServerOrigin","appId","apps","find","resp","transformApps","json","results","pageIsSupported","appShouldBeIgnoredAsync","push","choices","length","hasDuplicateNames","some","index","findIndex","other","deviceName","map","name","title","chalk","value","selectAsync","item","deviceIdToAppId","deviceId","split","HIDE_FROM_INSPECTOR_ENV","hideFromInspector","evaluateJsFromCdpAsync","webSocketDebuggerUr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f,GAAG,CAACO,WAAW,AAAC;YAC9BiC,eAAe,CAACC,QAAQ,CAAC,GAAG1B,KAAK,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAOC,IAAI,CAACiB,GAAG,CAAC,CAACjC,GAAG,GAAK;QACvB,IAAIA,GAAG,CAACO,WAAW,KAAK,WAAW,EAAE;gBAClBP,GAAe;YAAhC,MAAMyC,QAAQ,GAAGzC,CAAAA,CAAAA,GAAe,GAAfA,GAAG,CAACC,WAAW,SAAiB,GAAhCD,KAAAA,CAAgC,GAAhCA,GAAe,CAAEE,eAAe,CAAA,IAAIF,GAAG,CAACQ,EAAE,CAACkC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,AAAC;YAC1E1C,GAAG,CAACO,WAAW,GAAGiC,eAAe,CAACC,QAAQ,CAAC,IAAIzC,GAAG,CAACO,WAAW,CAAC;QACjE,CAAC;QACD,OAAOP,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM2C,uBAAuB,GAAG,yCAAyC,AAAC;AAE1E,eAAepB,uBAAuB,CAACvB,GAA2B,EAAoB;IACpF,MAAM4C,iBAAiB,GAAG,MAAMC,IAAAA,UAAsB,uBAAA,EACpD7C,GAAG,CAAC8C,oBAAoB,EACxBH,uBAAuB,CACxB,AAAC;IACF9C,KAAK,CACH,CAAC,+CAA+C,EAAEG,GAAG,CAAC8C,oBAAoB,CAAC,oBAAoB,EAAEF,iBAAiB,CAAC,CAAC,CAAC,CACtH,CAAC;IACF,OAAOA,iBAAiB,KAAKG,SAAS,CAAC;AACzC,CAAC"}
|
|
@@ -31,7 +31,7 @@ class FetchClient {
|
|
|
31
31
|
this.headers = {
|
|
32
32
|
accept: "application/json",
|
|
33
33
|
"content-type": "application/json",
|
|
34
|
-
"user-agent": `expo-cli/${"0.19.
|
|
34
|
+
"user-agent": `expo-cli/${"0.19.3"}`,
|
|
35
35
|
authorization: "Basic " + _nodeBuffer().Buffer.from(`${target}:`).toString("base64")
|
|
36
36
|
};
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"tree-kill": "^1.2.2",
|
|
168
168
|
"tsd": "^0.28.1"
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "5ad642a63afa9190ceb4e57dd52c8bdf71d93dd8"
|
|
171
171
|
}
|