@expo/cli 1.0.0-canary-20250403-13261ac → 1.0.0-canary-20250404-87e2506

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/MetroTerminalReporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport {\n BuildPhase,\n BundleDetails,\n BundleProgress,\n SnippetError,\n TerminalReportableEvent,\n} from './TerminalReporter.types';\nimport { NODE_STDLIB_MODULES } from './externals';\nimport { learnMore } from '../../../utils/link';\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(\n public projectRoot: string,\n terminal: Terminal\n ) {\n super(terminal);\n }\n\n // Used for testing\n _getElapsedTime(startTime: bigint): bigint {\n return process.hrtime.bigint() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const env = getEnvironmentForBuildDetails(progress.bundleDetails);\n const platform = env || getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n let localPath: string;\n\n if (\n typeof progress.bundleDetails?.customTransformOptions?.dom === 'string' &&\n progress.bundleDetails.customTransformOptions.dom.includes(path.sep)\n ) {\n // Because we use a generated entry file for DOM components, we need to adjust the logging path so it\n // shows a unique path for each component.\n // Here, we take the relative import path and remove all the starting slashes.\n localPath = progress.bundleDetails.customTransformOptions.dom.replace(/^(\\.?\\.[\\\\/])+/, '');\n } else {\n const inputFile = progress.bundleDetails.entryFile;\n\n localPath = path.isAbsolute(inputFile)\n ? path.relative(this.projectRoot, inputFile)\n : inputFile;\n }\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundled ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n\n let time: string = '';\n\n if (startTime != null) {\n const elapsed: bigint = this._getElapsedTime(startTime);\n const micro = Number(elapsed) / 1000;\n const converted = Number(elapsed) / 1e6;\n // If the milliseconds are < 0.5 then it will display as 0, so we display in microseconds.\n if (converted <= 0.5) {\n const tenthFractionOfMicro = ((micro * 10) / 1000).toFixed(0);\n // Format as microseconds to nearest tenth\n time = chalk.cyan.bold(`0.${tenthFractionOfMicro}ms`);\n } else {\n time = chalk.dim(converted.toFixed(0) + 'ms');\n }\n }\n\n // iOS Bundled 150ms\n const plural = progress.totalFileCount === 1 ? '' : 's';\n return (\n color(platform + status) +\n time +\n chalk.reset.dim(` ${localPath} (${progress.totalFileCount} module${plural})`)\n );\n }\n\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}${path.sep}`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log(chalk.dim('Starting Metro Bundler'));\n }\n\n shouldFilterClientLog(event: {\n type: 'client_log';\n level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';\n data: unknown[];\n }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n shouldFilterBundleEvent(event: TerminalReportableEvent): boolean {\n return 'bundleDetails' in event && event.bundleDetails?.bundleType === 'map';\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Please fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n const cause = error.cause as undefined | { _expoImportStack?: string };\n if (moduleResolutionError) {\n let message = maybeAppendCodeFrame(moduleResolutionError, error.message);\n if (cause?._expoImportStack) {\n message += `\\n\\n${cause?._expoImportStack}`;\n }\n return this.terminal.log(message);\n }\n if (cause?._expoImportStack) {\n error.message += `\\n\\n${cause._expoImportStack}`;\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getEnvironmentForBuildDetails(bundleDetails?: BundleDetails | null): string {\n // Expo CLI will pass `customTransformOptions.environment = 'node'` when bundling for the server.\n const env = bundleDetails?.customTransformOptions?.environment ?? null;\n if (env === 'node') {\n return chalk.bold('λ') + ' ';\n } else if (env === 'react-server') {\n return chalk.bold(`RSC(${getPlatformTagForBuildDetails(bundleDetails).trim()})`) + ' ';\n }\n\n if (\n bundleDetails?.customTransformOptions?.dom &&\n typeof bundleDetails?.customTransformOptions?.dom === 'string'\n ) {\n return chalk.bold(`DOM`) + ' ';\n }\n\n return '';\n}\n"],"names":["MetroTerminalReporter","formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","TerminalReporter","constructor","projectRoot","terminal","_getElapsedTime","startTime","process","hrtime","bigint","_getBundleStatusMessage","progress","phase","env","getEnvironmentForBuildDetails","bundleDetails","platform","getPlatformTagForBuildDetails","inProgress","localPath","customTransformOptions","dom","includes","path","sep","replace","inputFile","entryFile","isAbsolute","relative","status","color","chalk","green","red","_bundleTimers","get","buildID","time","elapsed","micro","Number","converted","tenthFractionOfMicro","toFixed","cyan","bold","dim","plural","totalFileCount","reset","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","padStart","transformedFileCount","toString","length","dirname","basename","_logInitializing","port","hasReducedPerformance","log","shouldFilterClientLog","event","isAppRegistryStartupMessage","data","shouldFilterBundleEvent","bundleType","transformCacheReset","logWarning","dependencyGraphLoading","join","_logBundlingError","error","moduleResolutionError","cause","message","maybeAppendCodeFrame","_expoImportStack","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted","ios","android","web","environment","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,CAAC;IACpC;IAEA,OAAO;AACT;AACA,gEAAgE,GAChE,SAAS3F,8BAA8BC,aAAoC;QAE7DA,uCAQVA,wCACOA;IAVT,iGAAiG;IACjG,MAAMF,MAAME,CAAAA,kCAAAA,wCAAAA,cAAeK,sBAAsB,qBAArCL,sCAAuC8F,WAAW,KAAI;IAClE,IAAIhG,QAAQ,QAAQ;QAClB,OAAOmB,gBAAK,CAACc,IAAI,CAAC,OAAO;IAC3B,OAAO,IAAIjC,QAAQ,gBAAgB;QACjC,OAAOmB,gBAAK,CAACc,IAAI,CAAC,CAAC,IAAI,EAAE7B,8BAA8BF,eAAe+F,IAAI,GAAG,CAAC,CAAC,IAAI;IACrF;IAEA,IACE/F,CAAAA,kCAAAA,yCAAAA,cAAeK,sBAAsB,qBAArCL,uCAAuCM,GAAG,KAC1C,QAAON,kCAAAA,yCAAAA,cAAeK,sBAAsB,qBAArCL,uCAAuCM,GAAG,MAAK,UACtD;QACA,OAAOW,gBAAK,CAACc,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI;IAC7B;IAEA,OAAO;AACT"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/MetroTerminalReporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport {\n BuildPhase,\n BundleDetails,\n BundleProgress,\n SnippetError,\n TerminalReportableEvent,\n} from './TerminalReporter.types';\nimport { NODE_STDLIB_MODULES } from './externals';\nimport { learnMore } from '../../../utils/link';\nimport {\n logLikeMetro,\n maybeSymbolicateAndFormatReactErrorLogAsync,\n parseErrorStringToObject,\n} from '../serverLogLikeMetro';\n\nconst debug = require('debug')('expo:metro:logger') as typeof console.log;\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(\n public projectRoot: string,\n terminal: Terminal\n ) {\n super(terminal);\n }\n\n _log(event: TerminalReportableEvent): void {\n switch (event.type) {\n case 'client_log': {\n if (this.shouldFilterClientLog(event)) {\n return;\n }\n const { level } = event;\n\n if (!level) {\n break;\n }\n\n const mode = event.mode === 'NOBRIDGE' ? '' : (event.mode ?? '');\n // @ts-expect-error\n if (level === 'warn' || level === 'error') {\n // Quick check to see if an unsymbolicated stack is being logged.\n const msg = event.data.join('\\n');\n if (msg.includes('.bundle//&platform=')) {\n const parsed = parseErrorStringToObject(msg);\n if (parsed) {\n maybeSymbolicateAndFormatReactErrorLogAsync(this.projectRoot, level, parsed)\n .then((res) => {\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, res);\n })\n .catch((e) => {\n // Fallback on the original error message if we can't symbolicate the stack.\n debug('Error formatting stack', e);\n\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, ...event.data);\n });\n\n return;\n }\n }\n }\n\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, ...event.data);\n return;\n }\n }\n return super._log(event);\n }\n\n // Used for testing\n _getElapsedTime(startTime: bigint): bigint {\n return process.hrtime.bigint() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const env = getEnvironmentForBuildDetails(progress.bundleDetails);\n const platform = env || getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n let localPath: string;\n\n if (\n typeof progress.bundleDetails?.customTransformOptions?.dom === 'string' &&\n progress.bundleDetails.customTransformOptions.dom.includes(path.sep)\n ) {\n // Because we use a generated entry file for DOM components, we need to adjust the logging path so it\n // shows a unique path for each component.\n // Here, we take the relative import path and remove all the starting slashes.\n localPath = progress.bundleDetails.customTransformOptions.dom.replace(/^(\\.?\\.[\\\\/])+/, '');\n } else {\n const inputFile = progress.bundleDetails.entryFile;\n\n localPath = path.isAbsolute(inputFile)\n ? path.relative(this.projectRoot, inputFile)\n : inputFile;\n }\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundled ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n\n let time: string = '';\n\n if (startTime != null) {\n const elapsed: bigint = this._getElapsedTime(startTime);\n const micro = Number(elapsed) / 1000;\n const converted = Number(elapsed) / 1e6;\n // If the milliseconds are < 0.5 then it will display as 0, so we display in microseconds.\n if (converted <= 0.5) {\n const tenthFractionOfMicro = ((micro * 10) / 1000).toFixed(0);\n // Format as microseconds to nearest tenth\n time = chalk.cyan.bold(`0.${tenthFractionOfMicro}ms`);\n } else {\n time = chalk.dim(converted.toFixed(0) + 'ms');\n }\n }\n\n // iOS Bundled 150ms\n const plural = progress.totalFileCount === 1 ? '' : 's';\n return (\n color(platform + status) +\n time +\n chalk.reset.dim(` ${localPath} (${progress.totalFileCount} module${plural})`)\n );\n }\n\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}${path.sep}`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log(chalk.dim('Starting Metro Bundler'));\n }\n\n shouldFilterClientLog(event: { type: 'client_log'; data: unknown[] }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n shouldFilterBundleEvent(event: TerminalReportableEvent): boolean {\n return 'bundleDetails' in event && event.bundleDetails?.bundleType === 'map';\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Please fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n const cause = error.cause as undefined | { _expoImportStack?: string };\n if (moduleResolutionError) {\n let message = maybeAppendCodeFrame(moduleResolutionError, error.message);\n if (cause?._expoImportStack) {\n message += `\\n\\n${cause?._expoImportStack}`;\n }\n return this.terminal.log(message);\n }\n if (cause?._expoImportStack) {\n error.message += `\\n\\n${cause._expoImportStack}`;\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getEnvironmentForBuildDetails(bundleDetails?: BundleDetails | null): string {\n // Expo CLI will pass `customTransformOptions.environment = 'node'` when bundling for the server.\n const env = bundleDetails?.customTransformOptions?.environment ?? null;\n if (env === 'node') {\n return chalk.bold('λ') + ' ';\n } else if (env === 'react-server') {\n return chalk.bold(`RSC(${getPlatformTagForBuildDetails(bundleDetails).trim()})`) + ' ';\n }\n\n if (\n bundleDetails?.customTransformOptions?.dom &&\n typeof bundleDetails?.customTransformOptions?.dom === 'string'\n ) {\n return chalk.bold(`DOM`) + ' ';\n }\n\n return '';\n}\n"],"names":["MetroTerminalReporter","formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","debug","require","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","TerminalReporter","constructor","projectRoot","terminal","_log","event","type","shouldFilterClientLog","level","mode","msg","data","join","includes","parsed","parseErrorStringToObject","maybeSymbolicateAndFormatReactErrorLogAsync","then","res","logLikeMetro","log","bind","catch","e","_getElapsedTime","startTime","process","hrtime","bigint","_getBundleStatusMessage","progress","phase","env","getEnvironmentForBuildDetails","bundleDetails","platform","getPlatformTagForBuildDetails","inProgress","localPath","customTransformOptions","dom","path","sep","replace","inputFile","entryFile","isAbsolute","relative","status","color","chalk","green","red","_bundleTimers","get","buildID","time","elapsed","micro","Number","converted","tenthFractionOfMicro","toFixed","cyan","bold","dim","plural","totalFileCount","reset","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","padStart","transformedFileCount","toString","length","dirname","basename","_logInitializing","port","hasReducedPerformance","isAppRegistryStartupMessage","shouldFilterBundleEvent","bundleType","transformCacheReset","logWarning","dependencyGraphLoading","_logBundlingError","error","moduleResolutionError","cause","message","maybeAppendCodeFrame","_expoImportStack","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted","ios","android","web","environment","trim"],"mappings":";;;;;;;;;;;IA6BaA,qBAAqB;eAArBA;;IAwMGC,mCAAmC;eAAnCA;;IAwCAC,sBAAsB;eAAtBA;;IAkBAC,cAAc;eAAdA;;;;gEA/RE;;;;;;;gEAED;;;;;;kCAE4B;2BAQT;sBACV;oCAKnB;;;;;;AAEP,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,8BAA8B;AACpC,MAAMC,kBAAkB;AACxB,MAAMC,mBAAmB;AAKlB,MAAMR,8BAA8BS,kCAAgB;IACzDC,YACE,AAAOC,WAAmB,EAC1BC,QAAkB,CAClB;QACA,KAAK,CAACA,gBAHCD,cAAAA;IAIT;IAEAE,KAAKC,KAA8B,EAAQ;QACzC,OAAQA,MAAMC,IAAI;YAChB,KAAK;gBAAc;oBACjB,IAAI,IAAI,CAACC,qBAAqB,CAACF,QAAQ;wBACrC;oBACF;oBACA,MAAM,EAAEG,KAAK,EAAE,GAAGH;oBAElB,IAAI,CAACG,OAAO;wBACV;oBACF;oBAEA,MAAMC,OAAOJ,MAAMI,IAAI,KAAK,aAAa,KAAMJ,MAAMI,IAAI,IAAI;oBAC7D,mBAAmB;oBACnB,IAAID,UAAU,UAAUA,UAAU,SAAS;wBACzC,iEAAiE;wBACjE,MAAME,MAAML,MAAMM,IAAI,CAACC,IAAI,CAAC;wBAC5B,IAAIF,IAAIG,QAAQ,CAAC,wBAAwB;4BACvC,MAAMC,SAASC,IAAAA,4CAAwB,EAACL;4BACxC,IAAII,QAAQ;gCACVE,IAAAA,+DAA2C,EAAC,IAAI,CAACd,WAAW,EAAEM,OAAOM,QAClEG,IAAI,CAAC,CAACC;oCACL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,SAASjF,8BAA8BF,aAAoC;IACzE,MAAMC,WAAWD,CAAAA,iCAAAA,cAAeC,QAAQ,KAAI;IAC5C,IAAIA,UAAU;QACZ,MAAMmF,YAAY;YAAEC,KAAK;YAAOC,SAAS;YAAWC,KAAK;QAAM,CAAC,CAACtF,SAAS,IAAIA;QAC9E,OAAO,GAAGe,gBAAK,CAACc,IAAI,CAACsD,WAAW,CAAC,CAAC;IACpC;IAEA,OAAO;AACT;AACA,gEAAgE,GAChE,SAASrF,8BAA8BC,aAAoC;QAE7DA,uCAQVA,wCACOA;IAVT,iGAAiG;IACjG,MAAMF,MAAME,CAAAA,kCAAAA,wCAAAA,cAAeK,sBAAsB,qBAArCL,sCAAuCwF,WAAW,KAAI;IAClE,IAAI1F,QAAQ,QAAQ;QAClB,OAAOkB,gBAAK,CAACc,IAAI,CAAC,OAAO;IAC3B,OAAO,IAAIhC,QAAQ,gBAAgB;QACjC,OAAOkB,gBAAK,CAACc,IAAI,CAAC,CAAC,IAAI,EAAE5B,8BAA8BF,eAAeyF,IAAI,GAAG,CAAC,CAAC,IAAI;IACrF;IAEA,IACEzF,CAAAA,kCAAAA,yCAAAA,cAAeK,sBAAsB,qBAArCL,uCAAuCM,GAAG,KAC1C,QAAON,kCAAAA,yCAAAA,cAAeK,sBAAsB,qBAArCL,uCAAuCM,GAAG,MAAK,UACtD;QACA,OAAOU,gBAAK,CAACc,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI;IAC7B;IAEA,OAAO;AACT"}
@@ -20,6 +20,9 @@ _export(exports, {
20
20
  getErrorOverlayHtmlAsync: function() {
21
21
  return getErrorOverlayHtmlAsync;
22
22
  },
23
+ getStackAsFormattedLog: function() {
24
+ return getStackAsFormattedLog;
25
+ },
23
26
  logMetroError: function() {
24
27
  return logMetroError;
25
28
  },
@@ -76,6 +79,7 @@ const _LogBoxLog = require("./log-box/LogBoxLog");
76
79
  const _formatProjectFilePath = require("./log-box/formatProjectFilePath");
77
80
  const _log = require("../../../log");
78
81
  const _ansi = require("../../../utils/ansi");
82
+ const _env = require("../../../utils/env");
79
83
  const _errors = require("../../../utils/errors");
80
84
  const _getStaticRenderFunctions = require("../getStaticRenderFunctions");
81
85
  function _interop_require_default(obj) {
@@ -105,9 +109,18 @@ async function logMetroErrorWithStack(projectRoot, { stack, codeFrame, error })
105
109
  if (error instanceof _errors.CommandError) {
106
110
  return;
107
111
  }
112
+ _log.Log.log(getStackAsFormattedLog(projectRoot, {
113
+ stack,
114
+ codeFrame,
115
+ error,
116
+ showCollapsedFrames: true
117
+ }));
118
+ }
119
+ function getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showCollapsedFrames = _env.env.EXPO_DEBUG }) {
120
+ const logs = [];
108
121
  if (codeFrame) {
109
122
  var _codeFrame_location;
110
- const maxWarningLineLength = Math.max(200, process.stdout.columns);
123
+ const maxWarningLineLength = Math.max(800, process.stdout.columns);
111
124
  const lineText = codeFrame.content;
112
125
  const isPreviewTooLong = codeFrame.content.split('\n').some((line)=>line.length > maxWarningLineLength);
113
126
  const column = (_codeFrame_location = codeFrame.location) == null ? void 0 : _codeFrame_location.column;
@@ -143,16 +156,10 @@ async function logMetroErrorWithStack(projectRoot, { stack, codeFrame, error })
143
156
  }
144
157
  // If the column property could be found, then use that to fix the cursor location which is often broken in regex.
145
158
  cursorLine = (column == null ? '' : fill(column) + _chalk().default.reset('^')).slice(minBounds);
146
- _log.Log.log([
147
- formattedPath,
148
- '',
149
- previewLine,
150
- cursorLine,
151
- _chalk().default.dim('(error truncated)')
152
- ].join('\n'));
159
+ logs.push(formattedPath, '', previewLine, cursorLine, _chalk().default.dim('(error truncated)'));
153
160
  }
154
161
  } else {
155
- _log.Log.log(codeFrame.content);
162
+ logs.push(codeFrame.content);
156
163
  }
157
164
  }
158
165
  if (stack == null ? void 0 : stack.length) {
@@ -165,6 +172,9 @@ async function logMetroErrorWithStack(projectRoot, { stack, codeFrame, error })
165
172
  });
166
173
  const stackLines = [];
167
174
  stackProps.forEach((frame)=>{
175
+ if (frame.collapse && !showCollapsedFrames) {
176
+ return;
177
+ }
168
178
  const position = _terminallink().default.isSupported ? (0, _terminallink().default)(frame.subtitle, frame.subtitle) : frame.subtitle;
169
179
  let lineItem = _chalk().default.gray(` ${frame.title} (${position})`);
170
180
  if (frame.collapse) {
@@ -175,16 +185,17 @@ async function logMetroErrorWithStack(projectRoot, { stack, codeFrame, error })
175
185
  stackLines.push(lineItem);
176
186
  }
177
187
  });
178
- _log.Log.log();
179
- _log.Log.log(_chalk().default.bold`Call Stack`);
188
+ logs.push('');
189
+ logs.push(_chalk().default.bold`Call Stack`);
180
190
  if (!stackLines.length) {
181
- _log.Log.log(_chalk().default.gray(' No stack trace available.'));
191
+ logs.push(_chalk().default.gray(' No stack trace available.'));
182
192
  } else {
183
- _log.Log.log(stackLines.join('\n'));
193
+ logs.push(stackLines.join('\n'));
184
194
  }
185
- } else {
186
- _log.Log.log(_chalk().default.gray(` ${error.stack}`));
195
+ } else if (error) {
196
+ logs.push(_chalk().default.gray(` ${error.stack}`));
187
197
  }
198
+ return logs.join('\n');
188
199
  }
189
200
  const IS_METRO_BUNDLE_ERROR_SYMBOL = Symbol('_isMetroBundleError');
190
201
  const HAS_LOGGED_SYMBOL = Symbol('_hasLoggedInCLI');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/metroErrorInterface.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { parse, StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { LogBoxLog } from './log-box/LogBoxLog';\nimport type { CodeFrame, StackFrame as MetroStackFrame } from './log-box/LogBoxSymbolication';\nimport { getStackFormattedLocation } from './log-box/formatProjectFilePath';\nimport { Log } from '../../../log';\nimport { stripAnsi } from '../../../utils/ansi';\nimport { CommandError, SilentError } from '../../../utils/errors';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error: Error;\n }\n) {\n if (error instanceof SilentError) {\n return;\n }\n\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (error instanceof CommandError) {\n return;\n }\n\n if (codeFrame) {\n const maxWarningLineLength = Math.max(200, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const isPreviewTooLong = codeFrame.content\n .split('\\n')\n .some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n Log.log(\n [formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)')].join('\\n')\n );\n }\n } else {\n Log.log(codeFrame.content);\n }\n }\n\n if (stack?.length) {\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse,\n };\n });\n\n const stackLines: string[] = [];\n\n stackProps.forEach((frame) => {\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n // Never show the internal module system.\n if (!frame.subtitle.match(/\\/metro-require\\/require\\.js/)) {\n stackLines.push(lineItem);\n }\n });\n\n Log.log();\n Log.log(chalk.bold`Call Stack`);\n if (!stackLines.length) {\n Log.log(chalk.gray(' No stack trace available.'));\n } else {\n Log.log(stackLines.join('\\n'));\n }\n } else {\n Log.log(chalk.gray(` ${error.stack}`));\n }\n}\n\nexport const IS_METRO_BUNDLE_ERROR_SYMBOL = Symbol('_isMetroBundleError');\nconst HAS_LOGGED_SYMBOL = Symbol('_hasLoggedInCLI');\n\nexport async function logMetroError(\n projectRoot: string,\n {\n error,\n }: {\n error: Error & {\n [HAS_LOGGED_SYMBOL]?: boolean;\n };\n }\n) {\n if (error instanceof SilentError || error[HAS_LOGGED_SYMBOL]) {\n return;\n }\n error[HAS_LOGGED_SYMBOL] = true;\n\n const stack = parseErrorStack(projectRoot, error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\nfunction isTransformError(\n error: any\n): error is { type: 'TransformError'; filename: string; lineNumber: number; column: number } {\n return error.type === 'TransformError';\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nfunction logFromError({ error, projectRoot }: { error: Error; projectRoot: string }) {\n // Remap direct Metro Node.js errors to a format that will appear more client-friendly in the logbox UI.\n let stack: MetroStackFrame[] | undefined;\n if (isTransformError(error) && error.filename) {\n // Syntax errors in static rendering.\n stack = [\n {\n file: path.join(projectRoot, error.filename),\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: error.lineNumber,\n column: error.column,\n },\n ];\n } else if ('originModulePath' in error && typeof error.originModulePath === 'string') {\n // TODO: Use import stack here when the error is resolution based.\n stack = [\n {\n file: error.originModulePath,\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: 0,\n column: 0,\n },\n ];\n } else {\n stack = parseErrorStack(projectRoot, error.stack);\n }\n\n return new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', () => res()));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n routerRoot,\n}: {\n error: Error;\n projectRoot: string;\n routerRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', () => res()));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n if ('message' in log && 'content' in log.message && typeof log.message.content === 'string') {\n log.message.content = stripAnsi(log.message.content)!;\n }\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n mode: 'development',\n platform: 'web',\n minify: false,\n optimize: false,\n usedExports: false,\n baseUrl: '',\n routerRoot,\n isExporting: false,\n reactCompiler: false,\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n\nfunction parseErrorStack(\n projectRoot: string,\n stack?: string\n): (StackFrame & { collapse?: boolean })[] {\n if (stack == null) {\n return [];\n }\n if (Array.isArray(stack)) {\n return stack;\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n\n return parse(stack)\n .map((frame) => {\n // frame.file will mostly look like `http://localhost:8081/index.bundle?platform=web&dev=true&hot=false`\n\n if (frame.file) {\n // SSR will sometimes have absolute paths followed by `.bundle?...`, we need to try and make them relative paths and append a dev server URL.\n if (frame.file.startsWith('/') && frame.file.includes('bundle?') && !canParse(frame.file)) {\n // Malformed stack file from SSR. Attempt to repair.\n frame.file = 'https://localhost:8081/' + path.relative(serverRoot, frame.file);\n }\n }\n\n return {\n ...frame,\n column: frame.column != null ? frame.column - 1 : null,\n };\n })\n .filter((frame) => frame.file && !frame.file.includes('node_modules'));\n}\n\nfunction canParse(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["IS_METRO_BUNDLE_ERROR_SYMBOL","getErrorOverlayHtmlAsync","logMetroError","logMetroErrorAsync","logMetroErrorWithStack","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","SilentError","Log","log","red","message","CommandError","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","isPreviewTooLong","split","some","length","column","location","previewLine","cursorLine","formattedPath","fileName","row","rangeWindow","round","minBounds","maxBounds","min","slice","stackProps","map","frame","title","methodName","subtitle","getStackFormattedLocation","collapse","stackLines","forEach","position","terminalLink","isSupported","lineItem","gray","match","push","bold","Symbol","HAS_LOGGED_SYMBOL","parseErrorStack","LogBoxLog","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","isTransformError","type","logFromError","filename","file","path","arguments","lineNumber","originModulePath","routerRoot","stripAnsi","logBoxContext","selectedLogIndex","isDisabled","logs","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","resolveFrom","mode","platform","minify","optimize","usedExports","baseUrl","isExporting","reactCompiler","htmlWithJs","replace","isArray","serverRoot","getMetroServerRoot","parse","startsWith","includes","canParse","relative","url","URL"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAkJYA,4BAA4B;eAA5BA;;IAgHSC,wBAAwB;eAAxBA;;IA7GAC,aAAa;eAAbA;;IA0FAC,kBAAkB;eAAlBA;;IAlNAC,sBAAsB;eAAtBA;;;;yBA5Ba;;;;;;;gEACjB;;;;;;;gEACD;;;;;;;gEACO;;;;;;;yBACU;;;;;;;gEACT;;;;;;2BAEC;uCAEgB;qBACtB;sBACM;wBACgB;0CACD;;;;;;AAEzC,SAASC,KAAKC,KAAa;IACzB,OAAOC,MAAMD,OAAOE,IAAI,CAAC;AAC3B;AAEA,SAASC,YAAYC,MAAgE;IACnF,MAAMC,WAAWC,gBAAK,CAACC,KAAK,CAACH,OAAOC,QAAQ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ourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { parse, StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { LogBoxLog } from './log-box/LogBoxLog';\nimport type { CodeFrame, StackFrame as MetroStackFrame } from './log-box/LogBoxSymbolication';\nimport { getStackFormattedLocation } from './log-box/formatProjectFilePath';\nimport { Log } from '../../../log';\nimport { stripAnsi } from '../../../utils/ansi';\nimport { env } from '../../../utils/env';\nimport { CommandError, SilentError } from '../../../utils/errors';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error: Error;\n }\n) {\n if (error instanceof SilentError) {\n return;\n }\n\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (error instanceof CommandError) {\n return;\n }\n\n Log.log(\n getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showCollapsedFrames: true })\n );\n}\n\nexport function getStackAsFormattedLog(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n showCollapsedFrames = env.EXPO_DEBUG,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error?: Error;\n showCollapsedFrames?: boolean;\n }\n): string {\n const logs: string[] = [];\n if (codeFrame) {\n const maxWarningLineLength = Math.max(800, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const isPreviewTooLong = codeFrame.content\n .split('\\n')\n .some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n logs.push(formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)'));\n }\n } else {\n logs.push(codeFrame.content);\n }\n }\n\n if (stack?.length) {\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse,\n };\n });\n\n const stackLines: string[] = [];\n\n stackProps.forEach((frame) => {\n if (frame.collapse && !showCollapsedFrames) {\n return;\n }\n\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n // Never show the internal module system.\n if (!frame.subtitle.match(/\\/metro-require\\/require\\.js/)) {\n stackLines.push(lineItem);\n }\n });\n\n logs.push('');\n logs.push(chalk.bold`Call Stack`);\n\n if (!stackLines.length) {\n logs.push(chalk.gray(' No stack trace available.'));\n } else {\n logs.push(stackLines.join('\\n'));\n }\n } else if (error) {\n logs.push(chalk.gray(` ${error.stack}`));\n }\n return logs.join('\\n');\n}\n\nexport const IS_METRO_BUNDLE_ERROR_SYMBOL = Symbol('_isMetroBundleError');\nconst HAS_LOGGED_SYMBOL = Symbol('_hasLoggedInCLI');\n\nexport async function logMetroError(\n projectRoot: string,\n {\n error,\n }: {\n error: Error & {\n [HAS_LOGGED_SYMBOL]?: boolean;\n };\n }\n) {\n if (error instanceof SilentError || error[HAS_LOGGED_SYMBOL]) {\n return;\n }\n error[HAS_LOGGED_SYMBOL] = true;\n\n const stack = parseErrorStack(projectRoot, error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\nfunction isTransformError(\n error: any\n): error is { type: 'TransformError'; filename: string; lineNumber: number; column: number } {\n return error.type === 'TransformError';\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nfunction logFromError({ error, projectRoot }: { error: Error; projectRoot: string }) {\n // Remap direct Metro Node.js errors to a format that will appear more client-friendly in the logbox UI.\n let stack: MetroStackFrame[] | undefined;\n if (isTransformError(error) && error.filename) {\n // Syntax errors in static rendering.\n stack = [\n {\n file: path.join(projectRoot, error.filename),\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: error.lineNumber,\n column: error.column,\n },\n ];\n } else if ('originModulePath' in error && typeof error.originModulePath === 'string') {\n // TODO: Use import stack here when the error is resolution based.\n stack = [\n {\n file: error.originModulePath,\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: 0,\n column: 0,\n },\n ];\n } else {\n stack = parseErrorStack(projectRoot, error.stack);\n }\n\n return new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', () => res()));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n routerRoot,\n}: {\n error: Error;\n projectRoot: string;\n routerRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', () => res()));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n if ('message' in log && 'content' in log.message && typeof log.message.content === 'string') {\n log.message.content = stripAnsi(log.message.content)!;\n }\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n mode: 'development',\n platform: 'web',\n minify: false,\n optimize: false,\n usedExports: false,\n baseUrl: '',\n routerRoot,\n isExporting: false,\n reactCompiler: false,\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n\nfunction parseErrorStack(\n projectRoot: string,\n stack?: string\n): (StackFrame & { collapse?: boolean })[] {\n if (stack == null) {\n return [];\n }\n if (Array.isArray(stack)) {\n return stack;\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n\n return parse(stack)\n .map((frame) => {\n // frame.file will mostly look like `http://localhost:8081/index.bundle?platform=web&dev=true&hot=false`\n\n if (frame.file) {\n // SSR will sometimes have absolute paths followed by `.bundle?...`, we need to try and make them relative paths and append a dev server URL.\n if (frame.file.startsWith('/') && frame.file.includes('bundle?') && !canParse(frame.file)) {\n // Malformed stack file from SSR. Attempt to repair.\n frame.file = 'https://localhost:8081/' + path.relative(serverRoot, frame.file);\n }\n }\n\n return {\n ...frame,\n column: frame.column != null ? frame.column - 1 : null,\n };\n })\n .filter((frame) => frame.file && !frame.file.includes('node_modules'));\n}\n\nfunction canParse(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["IS_METRO_BUNDLE_ERROR_SYMBOL","getErrorOverlayHtmlAsync","getStackAsFormattedLog","logMetroError","logMetroErrorAsync","logMetroErrorWithStack","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","SilentError","Log","log","red","message","CommandError","showCollapsedFrames","env","EXPO_DEBUG","logs","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","isPreviewTooLong","split","some","length","column","location","previewLine","cursorLine","formattedPath","fileName","row","rangeWindow","round","minBounds","maxBounds","min","slice","push","stackProps","map","frame","title","methodName","subtitle","getStackFormattedLocation","collapse","stackLines","forEach","position","terminalLink","isSupported","lineItem","gray","match","bold","Symbol","HAS_LOGGED_SYMBOL","parseErrorStack","LogBoxLog","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","isTransformError","type","logFromError","filename","file","path","arguments","lineNumber","originModulePath","routerRoot","stripAnsi","logBoxContext","selectedLogIndex","isDisabled","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","resolveFrom","mode","platform","minify","optimize","usedExports","baseUrl","isExporting","reactCompiler","htmlWithJs","replace","isArray","serverRoot","getMetroServerRoot","parse","startsWith","includes","canParse","relative","url","URL"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IA4KYA,4BAA4B;eAA5BA;;IAgHSC,wBAAwB;eAAxBA;;IA9NNC,sBAAsB;eAAtBA;;IAiHMC,aAAa;eAAbA;;IA0FAC,kBAAkB;eAAlBA;;IA3OAC,sBAAsB;eAAtBA;;;;yBA7Ba;;;;;;;gEACjB;;;;;;;gEACD;;;;;;;gEACO;;;;;;;yBACU;;;;;;;gEACT;;;;;;2BAEC;uCAEgB;qBACtB;sBACM;qBACN;wBACsB;0CACD;;;;;;AAEzC,SAASC,KAAKC,KAAa;IACzB,OAAOC,MAAMD,OAAOE,IAAI,CAAC;AAC3B;AAEA,SAASC,YAAYC,MAAgE;IACnF,MAAMC,WAAWC,gBAAK,CAACC,KAAK,CAACH,OAAOC,QAAQ;IAC5C,OACEC,gBAAK,CAACE,GAAG,CAAC,OACVH,WACAC,gBAAK,CAACE,GAAG,CAAC,CAAC,CAAC,EAAE;QAACJ,OAAOK,IAAI;QAAEL,OAAOM,GAAG;KAAC,CAACC,MAAM,CAACC,SAASV,IAAI,CAAC,KAAK,CAAC,CAAC;AAExE;AAEO,eAAeJ,uBACpBe,WAAmB,EACnB,EACEC,KAAK,EACLC,SAAS,EACTC,KAAK,EAKN;IAED,IAAIA,iBAAiBC,mBAAW,EAAE;QAChC;IACF;IAEA,yDAAyD;IACzD,yDAAyD;IAEzDC,QAAG,CAACC,GAAG;IACPD,QAAG,CAACC,GAAG,CAACb,gBAAK,CAACc,GAAG,CAAC,mBAAmBJ,MA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iB,aAAa;QACbC,eAAe;IACjB;IAGF,MAAMC,aAAad,KAAKe,OAAO,CAAC,WAAW,CAAC,YAAY,EAAEZ,kBAAkB,iBAAiB,CAAC;IAC9F,OAAOW;AACT;AAEA,SAASvC,gBACP3D,WAAmB,EACnBC,KAAc;IAEd,IAAIA,SAAS,MAAM;QACjB,OAAO,EAAE;IACX;IACA,IAAIb,MAAMgH,OAAO,CAACnG,QAAQ;QACxB,OAAOA;IACT;IAEA,MAAMoG,aAAaC,IAAAA,2BAAkB,EAACtG;IAEtC,OAAOuG,IAAAA,yBAAK,EAACtG,OACVwC,GAAG,CAAC,CAACC;QACJ,wGAAwG;QAExG,IAAIA,MAAMgC,IAAI,EAAE;YACd,6IAA6I;YAC7I,IAAIhC,MAAMgC,IAAI,CAAC8B,UAAU,CAAC,QAAQ9D,MAAMgC,IAAI,CAAC+B,QAAQ,CAAC,cAAc,CAACC,SAAShE,MAAMgC,IAAI,GAAG;gBACzF,oDAAoD;gBACpDhC,MAAMgC,IAAI,GAAG,4BAA4BC,eAAI,CAACgC,QAAQ,CAACN,YAAY3D,MAAMgC,IAAI;YAC/E;QACF;QAEA,OAAO;YACL,GAAGhC,KAAK;YACRhB,QAAQgB,MAAMhB,MAAM,IAAI,OAAOgB,MAAMhB,MAAM,GAAG,IAAI;QACpD;IACF,GACC5B,MAAM,CAAC,CAAC4C,QAAUA,MAAMgC,IAAI,IAAI,CAAChC,MAAMgC,IAAI,CAAC+B,QAAQ,CAAC;AAC1D;AAEA,SAASC,SAASE,GAAW;IAC3B,IAAI;QACF,kCAAkC;QAClC,IAAIC,IAAID;QACR,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
@@ -22,6 +22,12 @@ _export(exports, {
22
22
  },
23
23
  logLikeMetro: function() {
24
24
  return logLikeMetro;
25
+ },
26
+ maybeSymbolicateAndFormatReactErrorLogAsync: function() {
27
+ return maybeSymbolicateAndFormatReactErrorLogAsync;
28
+ },
29
+ parseErrorStringToObject: function() {
30
+ return parseErrorStringToObject;
25
31
  }
26
32
  });
27
33
  function _metroconfig() {
@@ -62,6 +68,8 @@ function _stacktraceparser() {
62
68
  const _LogBoxSymbolication = require("./metro/log-box/LogBoxSymbolication");
63
69
  const _env = require("../../utils/env");
64
70
  const _fn = require("../../utils/fn");
71
+ const _LogBoxLog = require("./metro/log-box/LogBoxLog");
72
+ const _metroErrorInterface = require("./metro/metroErrorInterface");
65
73
  function _interop_require_default(obj) {
66
74
  return obj && obj.__esModule ? obj : {
67
75
  default: obj
@@ -108,6 +116,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
108
116
  }
109
117
  return newObj;
110
118
  }
119
+ const debug = require('debug')('expo:metro:logger');
111
120
  const groupStack = [];
112
121
  let collapsedGuardTimer;
113
122
  function logLikeMetro(originalLogFunction, level, platform, ...data) {
@@ -140,12 +149,56 @@ function logLikeMetro(originalLogFunction, level, platform, ...data) {
140
149
  if (typeof lastItem === 'string') {
141
150
  data[data.length - 1] = lastItem.trimEnd();
142
151
  }
143
- const modePrefix = _chalk().default.bold`${platform}`;
144
- originalLogFunction(modePrefix + ' ' + color.bold(` ${logFunction.toUpperCase()} `) + ''.padEnd(groupStack.length * 2, ' '), ...data);
152
+ const modePrefix = platform === '' ? '' : _chalk().default.bold`${platform} `;
153
+ originalLogFunction(modePrefix + color.bold(` ${logFunction.toUpperCase()} `) + ''.padEnd(groupStack.length * 2, ' '), ...data);
145
154
  }
146
155
  }
147
156
  const escapedPathSep = _path().default.sep === '\\' ? '\\\\' : _path().default.sep;
148
157
  const SERVER_STACK_MATCHER = new RegExp(`${escapedPathSep}(react-dom|metro-runtime|expo-router)${escapedPathSep}`);
158
+ async function maybeSymbolicateAndFormatReactErrorLogAsync(projectRoot, level, error) {
159
+ var _log_symbolicated_stack, _log_symbolicated;
160
+ const log = new _LogBoxLog.LogBoxLog({
161
+ level: level,
162
+ message: {
163
+ content: error.message,
164
+ substitutions: []
165
+ },
166
+ isComponentError: false,
167
+ stack: error.stack,
168
+ category: 'static',
169
+ componentStack: []
170
+ });
171
+ await new Promise((res)=>log.symbolicate('stack', res));
172
+ const symbolicatedErrorMessageAndStackLog = [
173
+ log.message.content,
174
+ (0, _metroErrorInterface.getStackAsFormattedLog)(projectRoot, {
175
+ stack: ((_log_symbolicated = log.symbolicated) == null ? void 0 : (_log_symbolicated_stack = _log_symbolicated.stack) == null ? void 0 : _log_symbolicated_stack.stack) ?? [],
176
+ codeFrame: log.codeFrame
177
+ })
178
+ ].join('\n\n');
179
+ return symbolicatedErrorMessageAndStackLog;
180
+ }
181
+ function parseErrorStringToObject(errorString) {
182
+ // Find the first line of the possible stack trace
183
+ const stackStartIndex = errorString.indexOf('\n at ');
184
+ if (stackStartIndex === -1) {
185
+ // No stack trace found, return the original error string
186
+ return null;
187
+ }
188
+ const message = errorString.slice(0, stackStartIndex).trim();
189
+ const stack = errorString.slice(stackStartIndex + 1);
190
+ try {
191
+ const parsedStack = (0, _LogBoxSymbolication.parseErrorStack)(stack);
192
+ return {
193
+ message,
194
+ stack: parsedStack
195
+ };
196
+ } catch (e) {
197
+ // If parsing fails, return the original error string
198
+ debug('Failed to parse error stack:', e);
199
+ return null;
200
+ }
201
+ }
149
202
  function augmentLogsInternal(projectRoot) {
150
203
  const augmentLog = (name, fn)=>{
151
204
  // @ts-expect-error: TypeScript doesn't know about polyfilled functions.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/serverLogLikeMetro.ts"],"sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { INTERNAL_CALLSITES_REGEX } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport path from 'path';\n// @ts-expect-error\nimport { mapSourcePosition } from 'source-map-support';\nimport * as stackTraceParser from 'stacktrace-parser';\n\nimport { parseErrorStack } from './metro/log-box/LogBoxSymbolication';\nimport { env } from '../../utils/env';\nimport { memoize } from '../../utils/fn';\n\nconst groupStack: any = [];\nlet collapsedGuardTimer: ReturnType<typeof setTimeout> | undefined;\n\nexport function logLikeMetro(\n originalLogFunction: (...args: any[]) => void,\n level: string,\n platform: string,\n ...data: any[]\n) {\n // @ts-expect-error\n const logFunction = console[level] && level !== 'trace' ? level : 'log';\n const color =\n level === 'error'\n ? chalk.inverse.red\n : level === 'warn'\n ? chalk.inverse.yellow\n : chalk.inverse.white;\n\n if (level === 'group') {\n groupStack.push(level);\n } else if (level === 'groupCollapsed') {\n groupStack.push(level);\n clearTimeout(collapsedGuardTimer);\n // Inform users that logs get swallowed if they forget to call `groupEnd`.\n collapsedGuardTimer = setTimeout(() => {\n if (groupStack.includes('groupCollapsed')) {\n originalLogFunction(\n chalk.inverse.yellow.bold(' WARN '),\n 'Expected `console.groupEnd` to be called after `console.groupCollapsed`.'\n );\n groupStack.length = 0;\n }\n }, 3000);\n return;\n } else if (level === 'groupEnd') {\n groupStack.pop();\n if (!groupStack.length) {\n clearTimeout(collapsedGuardTimer);\n }\n return;\n }\n\n if (!groupStack.includes('groupCollapsed')) {\n // Remove excess whitespace at the end of a log message, if possible.\n const lastItem = data[data.length - 1];\n if (typeof lastItem === 'string') {\n data[data.length - 1] = lastItem.trimEnd();\n }\n\n const modePrefix = chalk.bold`${platform}`;\n originalLogFunction(\n modePrefix +\n ' ' +\n color.bold(` ${logFunction.toUpperCase()} `) +\n ''.padEnd(groupStack.length * 2, ' '),\n ...data\n );\n }\n}\n\nconst escapedPathSep = path.sep === '\\\\' ? '\\\\\\\\' : path.sep;\nconst SERVER_STACK_MATCHER = new RegExp(\n `${escapedPathSep}(react-dom|metro-runtime|expo-router)${escapedPathSep}`\n);\n\nfunction augmentLogsInternal(projectRoot: string) {\n const augmentLog = (name: string, fn: typeof console.log) => {\n // @ts-expect-error: TypeScript doesn't know about polyfilled functions.\n if (fn.__polyfilled) {\n return fn;\n }\n const originalFn = fn.bind(console);\n function logWithStack(...args: any[]) {\n const stack = new Error().stack;\n // Check if the log originates from the server.\n const isServerLog = !!stack?.match(SERVER_STACK_MATCHER);\n\n if (isServerLog) {\n if (name === 'error' || name === 'warn') {\n if (\n args.length === 2 &&\n typeof args[1] === 'string' &&\n args[1].trim().startsWith('at ')\n ) {\n // react-dom custom stacks which are always broken.\n // A stack string like:\n // at div\n // at http://localhost:8081/node_modules/expo-router/node/render.bundle?platform=web&dev=true&hot=false&transform.engine=hermes&transform.routerRoot=app&resolver.environment=node&transform.environment=node:38008:27\n // at Background (http://localhost:8081/node_modules/expo-router/node/render.bundle?platform=web&dev=true&hot=false&transform.engine=hermes&transform.routerRoot=app&resolver.environment=node&transform.environment=node:151009:7)\n const customStack = args[1];\n\n try {\n const parsedStack = parseErrorStack(customStack);\n const symbolicatedStack = parsedStack.map((line: any) => {\n const mapped = mapSourcePosition({\n source: line.file,\n line: line.lineNumber,\n column: line.column,\n }) as {\n // '/Users/evanbacon/Documents/GitHub/lab/sdk51-beta/node_modules/react-native-web/dist/exports/View/index.js',\n source: string;\n line: number;\n column: number;\n // 'hrefAttrs'\n name: string | null;\n };\n\n const fallbackName = mapped.name ?? '<unknown>';\n return {\n file: mapped.source,\n lineNumber: mapped.line,\n column: mapped.column,\n // Attempt to preserve the react component name if possible.\n methodName: line.methodName\n ? line.methodName === '<unknown>'\n ? fallbackName\n : line.methodName\n : fallbackName,\n arguments: line.arguments ?? [],\n };\n });\n\n // Replace args[1] with the formatted stack.\n args[1] = '\\n' + formatParsedStackLikeMetro(projectRoot, symbolicatedStack, true);\n } catch {\n // If symbolication fails, log the original stack.\n args.push('\\n' + formatStackLikeMetro(projectRoot, customStack));\n }\n } else {\n args.push('\\n' + formatStackLikeMetro(projectRoot, stack!));\n }\n }\n\n logLikeMetro(originalFn, name, 'λ', ...args);\n } else {\n originalFn(...args);\n }\n }\n logWithStack.__polyfilled = true;\n return logWithStack;\n };\n\n ['trace', 'info', 'error', 'warn', 'log', 'group', 'groupCollapsed', 'groupEnd', 'debug'].forEach(\n (name) => {\n // @ts-expect-error\n console[name] = augmentLog(name, console[name]);\n }\n );\n}\n\nexport function formatStackLikeMetro(projectRoot: string, stack: string) {\n // Remove `Error: ` from the beginning of the stack trace.\n // Dim traces that match `INTERNAL_CALLSITES_REGEX`\n\n const stackTrace = stackTraceParser.parse(stack);\n return formatParsedStackLikeMetro(projectRoot, stackTrace);\n}\n\nfunction formatParsedStackLikeMetro(\n projectRoot: string,\n stackTrace: stackTraceParser.StackFrame[],\n isComponentStack = false\n) {\n // Remove `Error: ` from the beginning of the stack trace.\n // Dim traces that match `INTERNAL_CALLSITES_REGEX`\n\n return stackTrace\n .filter(\n (line) =>\n line.file &&\n // Ignore unsymbolicated stack frames. It's not clear how this is possible but it sometimes happens when the graph changes.\n !/^https?:\\/\\//.test(line.file) &&\n (isComponentStack ? true : line.file !== '<anonymous>')\n )\n .map((line) => {\n // Use the same regex we use in Metro config to filter out traces:\n const isCollapsed = INTERNAL_CALLSITES_REGEX.test(line.file!);\n if (!isComponentStack && isCollapsed && !env.EXPO_DEBUG) {\n return null;\n }\n // If a file is collapsed, print it with dim styling.\n const style = isCollapsed ? chalk.dim : chalk.gray;\n // Use the `at` prefix to match Node.js\n let fileName = line.file!;\n if (fileName.startsWith(path.sep)) {\n fileName = path.relative(projectRoot, fileName);\n }\n if (line.lineNumber != null) {\n fileName += `:${line.lineNumber}`;\n if (line.column != null) {\n fileName += `:${line.column}`;\n }\n }\n\n return style(` ${line.methodName} (${fileName})`);\n })\n .filter(Boolean)\n .join('\\n');\n}\n\n/** Augment console logs to check the stack trace and format like Metro logs if we think the log came from the SSR renderer or an API route. */\nexport const augmentLogs = memoize(augmentLogsInternal);\n"],"names":["augmentLogs","formatStackLikeMetro","logLikeMetro","groupStack","collapsedGuardTimer","originalLogFunction","level","platform","data","logFunction","console","color","chalk","inverse","red","yellow","white","push","clearTimeout","setTimeout","includes","bold","length","pop","lastItem","trimEnd","modePrefix","toUpperCase","padEnd","escapedPathSep","path","sep","SERVER_STACK_MATCHER","RegExp","augmentLogsInternal","projectRoot","augmentLog","name","fn","__polyfilled","originalFn","bind","logWithStack","args","stack","Error","isServerLog","match","trim","startsWith","customStack","parsedStack","parseErrorStack","symbolicatedStack","map","line","mapped","mapSourcePosition","source","file","lineNumber","column","fallbackName","methodName","arguments","formatParsedStackLikeMetro","forEach","stackTrace","stackTraceParser","parse","isComponentStack","filter","test","isCollapsed","INTERNAL_CALLSITES_REGEX","env","EXPO_DEBUG","style","dim","gray","fileName","relative","Boolean","join","memoize"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAqNYA,WAAW;eAAXA;;IAnDGC,oBAAoB;eAApBA;;IAnJAC,YAAY;eAAZA;;;;yBAdyB;;;;;;;gEACvB;;;;;;;gEACD;;;;;;;yBAEiB;;;;;;;iEACA;;;;;;qCAEF;qBACZ;oBACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,MAAMC,aAAkB,EAAE;AAC1B,IAAIC;AAEG,SAASF,aACdG,mBAA6C,EAC7CC,KAAa,EACbC,QAAgB,EAChB,GAAGC,IAAW;IAEd,mBAAmB;IACnB,MAAMC,cAAcC,OAAO,CAACJ,MAAM,IAAIA,UAAU,UAAUA,QAAQ;IAClE,MAAMK,QACJL,UAAU,UACNM,gBAAK,CAACC,OAAO,CAACC,GAAG,GACjBR,UAAU,SACRM,gBAAK,CAACC,OAAO,CAACE,MAAM,GACpBH,gBAAK,CAACC,OAAO,CAACG,KAAK;IAE3B,IAAIV,UAAU,SAAS;QACrBH,WAAWc,IAAI,CAACX;IAClB,OAAO,IAAIA,UAAU,kBAAkB;QACrCH,WAAWc,IAAI,CAACX;QAChBY,aAAad;QACb,0EAA0E;QAC1EA,sBAAsBe,WAAW;YAC/B,IAAIhB,WAAWiB,QAAQ,CAAC,mBAAmB;gBACzCf,oBACEO,gBAAK,CAACC,OAAO,CAACE,MAAM,CAACM,IAAI,CAAC,WAC1B;gBAEFlB,WAAWmB,MAAM,GAAG;YACtB;QACF,GAAG;QACH;IACF,OAAO,I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GO,MAAMnF,cAAcoF,IAAAA,WAAO,EAAClD"}
1
+ {"version":3,"sources":["../../../../src/start/server/serverLogLikeMetro.ts"],"sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { INTERNAL_CALLSITES_REGEX } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport path from 'path';\n// @ts-expect-error\nimport { mapSourcePosition } from 'source-map-support';\nimport * as stackTraceParser from 'stacktrace-parser';\n\nimport { parseErrorStack, StackFrame } from './metro/log-box/LogBoxSymbolication';\nimport { env } from '../../utils/env';\nimport { memoize } from '../../utils/fn';\nimport { LogBoxLog } from './metro/log-box/LogBoxLog';\nimport { getStackAsFormattedLog } from './metro/metroErrorInterface';\n\nconst debug = require('debug')('expo:metro:logger') as typeof console.log;\n\nconst groupStack: any = [];\nlet collapsedGuardTimer: ReturnType<typeof setTimeout> | undefined;\n\nexport function logLikeMetro(\n originalLogFunction: (...args: any[]) => void,\n level: string,\n platform: string,\n ...data: any[]\n) {\n // @ts-expect-error\n const logFunction = console[level] && level !== 'trace' ? level : 'log';\n const color =\n level === 'error'\n ? chalk.inverse.red\n : level === 'warn'\n ? chalk.inverse.yellow\n : chalk.inverse.white;\n\n if (level === 'group') {\n groupStack.push(level);\n } else if (level === 'groupCollapsed') {\n groupStack.push(level);\n clearTimeout(collapsedGuardTimer);\n // Inform users that logs get swallowed if they forget to call `groupEnd`.\n collapsedGuardTimer = setTimeout(() => {\n if (groupStack.includes('groupCollapsed')) {\n originalLogFunction(\n chalk.inverse.yellow.bold(' WARN '),\n 'Expected `console.groupEnd` to be called after `console.groupCollapsed`.'\n );\n groupStack.length = 0;\n }\n }, 3000);\n return;\n } else if (level === 'groupEnd') {\n groupStack.pop();\n if (!groupStack.length) {\n clearTimeout(collapsedGuardTimer);\n }\n return;\n }\n\n if (!groupStack.includes('groupCollapsed')) {\n // Remove excess whitespace at the end of a log message, if possible.\n const lastItem = data[data.length - 1];\n if (typeof lastItem === 'string') {\n data[data.length - 1] = lastItem.trimEnd();\n }\n\n const modePrefix = platform === '' ? '' : chalk.bold`${platform} `;\n originalLogFunction(\n modePrefix +\n color.bold(` ${logFunction.toUpperCase()} `) +\n ''.padEnd(groupStack.length * 2, ' '),\n ...data\n );\n }\n}\n\nconst escapedPathSep = path.sep === '\\\\' ? '\\\\\\\\' : path.sep;\nconst SERVER_STACK_MATCHER = new RegExp(\n `${escapedPathSep}(react-dom|metro-runtime|expo-router)${escapedPathSep}`\n);\n\nexport async function maybeSymbolicateAndFormatReactErrorLogAsync(\n projectRoot: string,\n level: 'error' | 'warn',\n error: {\n message: string;\n stack: StackFrame[];\n }\n): Promise<string> {\n const log = new LogBoxLog({\n level: level as 'error' | 'warn',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack: error.stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n const symbolicatedErrorMessageAndStackLog = [\n log.message.content,\n getStackAsFormattedLog(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n }),\n ].join('\\n\\n');\n\n return symbolicatedErrorMessageAndStackLog;\n}\n\n/** Attempt to parse an error message string to an unsymbolicated stack. */\nexport function parseErrorStringToObject(errorString: string) {\n // Find the first line of the possible stack trace\n const stackStartIndex = errorString.indexOf('\\n at ');\n if (stackStartIndex === -1) {\n // No stack trace found, return the original error string\n return null;\n }\n const message = errorString.slice(0, stackStartIndex).trim();\n const stack = errorString.slice(stackStartIndex + 1);\n\n try {\n const parsedStack = parseErrorStack(stack);\n\n return {\n message,\n stack: parsedStack,\n };\n } catch (e) {\n // If parsing fails, return the original error string\n debug('Failed to parse error stack:', e);\n return null;\n }\n}\n\nfunction augmentLogsInternal(projectRoot: string) {\n const augmentLog = (name: string, fn: typeof console.log) => {\n // @ts-expect-error: TypeScript doesn't know about polyfilled functions.\n if (fn.__polyfilled) {\n return fn;\n }\n const originalFn = fn.bind(console);\n function logWithStack(...args: any[]) {\n const stack = new Error().stack;\n // Check if the log originates from the server.\n const isServerLog = !!stack?.match(SERVER_STACK_MATCHER);\n\n if (isServerLog) {\n if (name === 'error' || name === 'warn') {\n if (\n args.length === 2 &&\n typeof args[1] === 'string' &&\n args[1].trim().startsWith('at ')\n ) {\n // react-dom custom stacks which are always broken.\n // A stack string like:\n // at div\n // at http://localhost:8081/node_modules/expo-router/node/render.bundle?platform=web&dev=true&hot=false&transform.engine=hermes&transform.routerRoot=app&resolver.environment=node&transform.environment=node:38008:27\n // at Background (http://localhost:8081/node_modules/expo-router/node/render.bundle?platform=web&dev=true&hot=false&transform.engine=hermes&transform.routerRoot=app&resolver.environment=node&transform.environment=node:151009:7)\n const customStack = args[1];\n\n try {\n const parsedStack = parseErrorStack(customStack);\n const symbolicatedStack = parsedStack.map((line: any) => {\n const mapped = mapSourcePosition({\n source: line.file,\n line: line.lineNumber,\n column: line.column,\n }) as {\n // '/Users/evanbacon/Documents/GitHub/lab/sdk51-beta/node_modules/react-native-web/dist/exports/View/index.js',\n source: string;\n line: number;\n column: number;\n // 'hrefAttrs'\n name: string | null;\n };\n\n const fallbackName = mapped.name ?? '<unknown>';\n return {\n file: mapped.source,\n lineNumber: mapped.line,\n column: mapped.column,\n // Attempt to preserve the react component name if possible.\n methodName: line.methodName\n ? line.methodName === '<unknown>'\n ? fallbackName\n : line.methodName\n : fallbackName,\n arguments: line.arguments ?? [],\n };\n });\n\n // Replace args[1] with the formatted stack.\n args[1] = '\\n' + formatParsedStackLikeMetro(projectRoot, symbolicatedStack, true);\n } catch {\n // If symbolication fails, log the original stack.\n args.push('\\n' + formatStackLikeMetro(projectRoot, customStack));\n }\n } else {\n args.push('\\n' + formatStackLikeMetro(projectRoot, stack!));\n }\n }\n\n logLikeMetro(originalFn, name, 'λ', ...args);\n } else {\n originalFn(...args);\n }\n }\n logWithStack.__polyfilled = true;\n return logWithStack;\n };\n\n ['trace', 'info', 'error', 'warn', 'log', 'group', 'groupCollapsed', 'groupEnd', 'debug'].forEach(\n (name) => {\n // @ts-expect-error\n console[name] = augmentLog(name, console[name]);\n }\n );\n}\n\nexport function formatStackLikeMetro(projectRoot: string, stack: string) {\n // Remove `Error: ` from the beginning of the stack trace.\n // Dim traces that match `INTERNAL_CALLSITES_REGEX`\n\n const stackTrace = stackTraceParser.parse(stack);\n return formatParsedStackLikeMetro(projectRoot, stackTrace);\n}\n\nfunction formatParsedStackLikeMetro(\n projectRoot: string,\n stackTrace: stackTraceParser.StackFrame[],\n isComponentStack = false\n) {\n // Remove `Error: ` from the beginning of the stack trace.\n // Dim traces that match `INTERNAL_CALLSITES_REGEX`\n\n return stackTrace\n .filter(\n (line) =>\n line.file &&\n // Ignore unsymbolicated stack frames. It's not clear how this is possible but it sometimes happens when the graph changes.\n !/^https?:\\/\\//.test(line.file) &&\n (isComponentStack ? true : line.file !== '<anonymous>')\n )\n .map((line) => {\n // Use the same regex we use in Metro config to filter out traces:\n const isCollapsed = INTERNAL_CALLSITES_REGEX.test(line.file!);\n if (!isComponentStack && isCollapsed && !env.EXPO_DEBUG) {\n return null;\n }\n // If a file is collapsed, print it with dim styling.\n const style = isCollapsed ? chalk.dim : chalk.gray;\n // Use the `at` prefix to match Node.js\n let fileName = line.file!;\n if (fileName.startsWith(path.sep)) {\n fileName = path.relative(projectRoot, fileName);\n }\n if (line.lineNumber != null) {\n fileName += `:${line.lineNumber}`;\n if (line.column != null) {\n fileName += `:${line.column}`;\n }\n }\n\n return style(` ${line.methodName} (${fileName})`);\n })\n .filter(Boolean)\n .join('\\n');\n}\n\n/** Augment console logs to check the stack trace and format like Metro logs if we think the log came from the SSR renderer or an API route. */\nexport const augmentLogs = memoize(augmentLogsInternal);\n"],"names":["augmentLogs","formatStackLikeMetro","logLikeMetro","maybeSymbolicateAndFormatReactErrorLogAsync","parseErrorStringToObject","debug","require","groupStack","collapsedGuardTimer","originalLogFunction","level","platform","data","logFunction","console","color","chalk","inverse","red","yellow","white","push","clearTimeout","setTimeout","includes","bold","length","pop","lastItem","trimEnd","modePrefix","toUpperCase","padEnd","escapedPathSep","path","sep","SERVER_STACK_MATCHER","RegExp","projectRoot","error","log","LogBoxLog","message","content","substitutions","isComponentError","stack","category","componentStack","Promise","res","symbolicate","symbolicatedErrorMessageAndStackLog","getStackAsFormattedLog","symbolicated","codeFrame","join","errorString","stackStartIndex","indexOf","slice","trim","parsedStack","parseErrorStack","e","augmentLogsInternal","augmentLog","name","fn","__polyfilled","originalFn","bind","logWithStack","args","Error","isServerLog","match","startsWith","customStack","symbolicatedStack","map","line","mapped","mapSourcePosition","source","file","lineNumber","column","fallbackName","methodName","arguments","formatParsedStackLikeMetro","forEach","stackTrace","stackTraceParser","parse","isComponentStack","filter","test","isCollapsed","INTERNAL_CALLSITES_REGEX","env","EXPO_DEBUG","style","dim","gray","fileName","relative","Boolean","memoize"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAkRYA,WAAW;eAAXA;;IAnDGC,oBAAoB;eAApBA;;IA5MAC,YAAY;eAAZA;;IA6DMC,2CAA2C;eAA3CA;;IAkCNC,wBAAwB;eAAxBA;;;;yBAjHyB;;;;;;;gEACvB;;;;;;;gEACD;;;;;;;yBAEiB;;;;;;;iEACA;;;;;;qCAEU;qBACxB;oBACI;2BACE;qCACa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,aAAkB,EAAE;AAC1B,IAAIC;AAEG,SAASN,aACdO,mBAA6C,EAC7CC,KAAa,EACbC,QAAgB,EAChB,GAAGC,IAAW;IAEd,mBAAmB;IACnB,MAAMC,cAAcC,OAAO,CAACJ,MAAM,IAAIA,UAAU,UAAUA,QAAQ;IAClE,MAAMK,QACJL,UAAU,UACNM,gBAAK,CAACC,OAAO,CAACC,GAAG,GACjBR,UAAU,SACRM,gBAAK,CAACC,OAAO,CAACE,MAAM,GACpBH,gBAAK,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AE;YACjC,IAAIL,KAAKM,MAAM,IAAI,MAAM;gBACvBmB,YAAY,CAAC,CAAC,EAAEzB,KAAKM,MAAM,EAAE;YAC/B;QACF;QAEA,OAAOgB,MAAM,CAAC,EAAE,EAAEtB,KAAKQ,UAAU,CAAC,EAAE,EAAEiB,SAAS,CAAC,CAAC;IACnD,GACCT,MAAM,CAACW,SACPpD,IAAI,CAAC;AACV;AAGO,MAAMxD,cAAc6G,IAAAA,WAAO,EAAC5C"}
@@ -33,7 +33,7 @@ class FetchClient {
33
33
  this.headers = {
34
34
  accept: 'application/json',
35
35
  'content-type': 'application/json',
36
- 'user-agent': `expo-cli/${"1.0.0-canary-20250403-13261ac"}`,
36
+ 'user-agent': `expo-cli/${"1.0.0-canary-20250404-87e2506"}`,
37
37
  authorization: 'Basic ' + _nodebuffer().Buffer.from(`${target}:`).toString('base64')
38
38
  };
39
39
  }
@@ -83,7 +83,7 @@ function createContext() {
83
83
  cpu: summarizeCpuInfo(),
84
84
  app: {
85
85
  name: 'expo/cli',
86
- version: "1.0.0-canary-20250403-13261ac"
86
+ version: "1.0.0-canary-20250404-87e2506"
87
87
  },
88
88
  ci: _ciinfo().isCI ? {
89
89
  name: _ciinfo().name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/cli",
3
- "version": "1.0.0-canary-20250403-13261ac",
3
+ "version": "1.0.0-canary-20250404-87e2506",
4
4
  "description": "The Expo CLI",
5
5
  "main": "build/bin/cli",
6
6
  "bin": {
@@ -42,17 +42,17 @@
42
42
  "@0no-co/graphql.web": "^1.0.8",
43
43
  "@babel/runtime": "^7.20.0",
44
44
  "@expo/code-signing-certificates": "^0.0.5",
45
- "@expo/config": "11.0.0-canary-20250403-13261ac",
46
- "@expo/config-plugins": "9.1.0-canary-20250403-13261ac",
45
+ "@expo/config": "11.0.0-canary-20250404-87e2506",
46
+ "@expo/config-plugins": "9.1.0-canary-20250404-87e2506",
47
47
  "@expo/devcert": "^1.1.2",
48
- "@expo/env": "1.0.1-canary-20250403-13261ac",
49
- "@expo/image-utils": "0.6.6-canary-20250403-13261ac",
50
- "@expo/json-file": "9.0.3-canary-20250403-13261ac",
51
- "@expo/metro-config": "0.20.0-canary-20250403-13261ac",
52
- "@expo/osascript": "2.1.7-canary-20250403-13261ac",
53
- "@expo/package-manager": "1.6.2-canary-20250403-13261ac",
54
- "@expo/plist": "0.2.3-canary-20250403-13261ac",
55
- "@expo/prebuild-config": "9.0.0-canary-20250403-13261ac",
48
+ "@expo/env": "1.0.1-canary-20250404-87e2506",
49
+ "@expo/image-utils": "0.6.6-canary-20250404-87e2506",
50
+ "@expo/json-file": "9.0.3-canary-20250404-87e2506",
51
+ "@expo/metro-config": "0.20.0-canary-20250404-87e2506",
52
+ "@expo/osascript": "2.1.7-canary-20250404-87e2506",
53
+ "@expo/package-manager": "1.6.2-canary-20250404-87e2506",
54
+ "@expo/plist": "0.2.3-canary-20250404-87e2506",
55
+ "@expo/prebuild-config": "9.0.0-canary-20250404-87e2506",
56
56
  "@expo/spawn-async": "^1.7.2",
57
57
  "@expo/ws-tunnel": "^1.0.1",
58
58
  "@expo/xcpretty": "^4.3.0",
@@ -109,7 +109,7 @@
109
109
  "devDependencies": {
110
110
  "@expo/multipart-body-parser": "^1.0.0",
111
111
  "@expo/ngrok": "4.1.3",
112
- "@expo/server": "0.6.0-canary-20250403-13261ac",
112
+ "@expo/server": "0.6.0-canary-20250404-87e2506",
113
113
  "@graphql-codegen/cli": "^2.16.3",
114
114
  "@graphql-codegen/typescript": "^2.8.7",
115
115
  "@graphql-codegen/typescript-operations": "^2.5.12",
@@ -139,7 +139,7 @@
139
139
  "@types/ws": "^8.5.4",
140
140
  "devtools-protocol": "^0.0.1113120",
141
141
  "expo-atlas": "^0.4.0",
142
- "expo-module-scripts": "4.0.5-canary-20250403-13261ac",
142
+ "expo-module-scripts": "4.0.6-canary-20250404-87e2506",
143
143
  "find-process": "^1.4.7",
144
144
  "jest-runner-tsd": "^6.0.0",
145
145
  "klaw-sync": "^6.0.0",
@@ -151,6 +151,5 @@
151
151
  "taskr": "^1.1.0",
152
152
  "tree-kill": "^1.2.2",
153
153
  "tsd": "^0.28.1"
154
- },
155
- "gitHead": "13261ac5856369e1ce42ef4c380d5af1d7a40392"
154
+ }
156
155
  }