@expo/cli 57.0.31 → 57.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +1 -1
- package/build/src/events/index.js +1 -1
- package/build/src/export/compileHermesArtifacts.js +28 -0
- package/build/src/export/compileHermesArtifacts.js.map +1 -0
- package/build/src/export/embed/exportEmbedAsync.js +4 -0
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/exportApp.js +9 -5
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportDomComponents.js +5 -11
- package/build/src/export/exportDomComponents.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +3 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +3 -2
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/ios/appleDevice/ClientManager.js +11 -6
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +12 -4
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/start/interface/cliExtensionMenuItemHandler.js.map +1 -1
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/createDevToolsMenuItems.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/platforms/ios/devicectl.js +2 -5
- package/build/src/start/platforms/ios/devicectl.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +6 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +1 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +10 -4
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/{DevToolsPlugin.js → devtools/DevToolsPlugin.js} +14 -5
- package/build/src/start/server/devtools/DevToolsPlugin.js.map +1 -0
- package/build/src/start/server/devtools/DevToolsPlugin.schema.js +195 -0
- package/build/src/start/server/devtools/DevToolsPlugin.schema.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginCliExtensionExecutor.js → devtools/DevToolsPluginCliExtensionExecutor.js} +1 -1
- package/build/src/start/server/devtools/DevToolsPluginCliExtensionExecutor.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginCliExtensionResults.js → devtools/DevToolsPluginCliExtensionResults.js} +24 -12
- package/build/src/start/server/devtools/DevToolsPluginCliExtensionResults.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginManager.js → devtools/DevToolsPluginManager.js} +2 -2
- package/build/src/start/server/devtools/DevToolsPluginManager.js.map +1 -0
- package/build/src/start/server/devtools/DevToolsPluginServerHelpers.js.map +1 -0
- package/build/src/start/server/{MCP.js → mcp/MCP.js} +25 -15
- package/build/src/start/server/mcp/MCP.js.map +1 -0
- package/build/src/start/server/{MCPDevToolsPluginCLIExtensions.js → mcp/MCPDevToolsPluginCLIExtensions.js} +14 -27
- package/build/src/start/server/mcp/MCPDevToolsPluginCLIExtensions.js.map +1 -0
- package/build/src/start/server/{createMCPDevToolsExtensionSchema.js → mcp/createMCPDevToolsExtensionSchema.js} +8 -15
- package/build/src/start/server/mcp/createMCPDevToolsExtensionSchema.js.map +1 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js +2 -4
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +6 -2
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +4 -1
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/openHandlers.js +2 -6
- package/build/src/start/server/middleware/openHandlers.js.map +1 -1
- package/build/src/start/startAsync.js +2 -4
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/open.js +47 -31
- package/build/src/utils/open.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +25 -21
- package/build/src/start/server/DevToolsPlugin.js.map +0 -1
- package/build/src/start/server/DevToolsPlugin.schema.js +0 -84
- package/build/src/start/server/DevToolsPlugin.schema.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +0 -1
- package/build/src/start/server/DevToolsPluginManager.js.map +0 -1
- package/build/src/start/server/DevToolsPluginServerHelpers.js.map +0 -1
- package/build/src/start/server/MCP.js.map +0 -1
- package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js.map +0 -1
- package/build/src/start/server/createMCPDevToolsExtensionSchema.js.map +0 -1
- /package/build/src/start/server/{DevToolsPluginServerHelpers.js → devtools/DevToolsPluginServerHelpers.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/start/startAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport { getLogFile, shouldReduceLogs } from '../events';\nimport {\n checkDependencies,\n printDependencyCheckResult,\n type DependencyCheckRef,\n} from './checkDependenciesOnStart';\nimport { SimulatorAppPrerequisite } from './doctor/apple/SimulatorAppPrerequisite';\nimport { getXcodeVersionAsync } from './doctor/apple/XcodePrerequisite';\nimport { WebSupportProjectPrerequisite } from './doctor/web/WebSupportProjectPrerequisite';\nimport { printDevToolsPluginCliBannersAsync } from './interface/interactiveActions';\nimport { startInterfaceAsync } from './interface/startInterface';\nimport type { Options } from './resolveOptions';\nimport { resolvePortsAsync } from './resolveOptions';\nimport * as Log from '../log';\nimport type { BundlerStartOptions } from './server/BundlerDevServer';\nimport type { MultiBundlerStartOptions } from './server/DevServerManager';\nimport { DevServerManager } from './server/DevServerManager';\nimport { maybeCreateMCPServerAsync } from './server/MCP';\nimport { openPlatformsAsync } from './server/openPlatforms';\nimport type { PlatformBundlers } from './server/platformBundlers';\nimport { getPlatformBundlers } from './server/platformBundlers';\nimport { env } from '../utils/env';\nimport { isInteractive } from '../utils/interactive';\nimport { profile } from '../utils/profile';\nimport { addMcpCapabilities } from './server/MCPDevToolsPluginCLIExtensions';\n\nasync function getMultiBundlerStartOptions(\n projectRoot: string,\n options: Options,\n settings: { webOnly?: boolean },\n platformBundlers: PlatformBundlers\n): Promise<[BundlerStartOptions, MultiBundlerStartOptions]> {\n const commonOptions: BundlerStartOptions = {\n mode: options.dev ? 'development' : 'production',\n devClient: options.devClient,\n privateKeyPath: options.privateKeyPath ?? undefined,\n https: options.https,\n maxWorkers: options.maxWorkers,\n resetDevServer: options.clear,\n minify: options.minify,\n location: {\n hostType: options.host,\n scheme: options.scheme,\n },\n };\n const multiBundlerSettings = await resolvePortsAsync(projectRoot, options, settings);\n\n const optionalBundlers: Partial<PlatformBundlers> = { ...platformBundlers };\n // In the default case, we don't want to start multiple bundlers since this is\n // a bit slower. Our priority (for legacy) is native platforms.\n if (!options.web) {\n delete optionalBundlers['web'];\n }\n\n const bundlers = [...new Set(Object.values(optionalBundlers))];\n const multiBundlerStartOptions = bundlers.map((bundler) => {\n const port =\n bundler === 'webpack' ? multiBundlerSettings.webpackPort : multiBundlerSettings.metroPort;\n return {\n type: bundler,\n options: {\n ...commonOptions,\n port,\n },\n };\n });\n\n return [commonOptions, multiBundlerStartOptions];\n}\n\nexport async function startAsync(\n projectRoot: string,\n options: Options,\n settings: { webOnly?: boolean }\n) {\n if (!shouldReduceLogs()) {\n Log.log(chalk.gray(`Starting project at ${projectRoot}`));\n const logFile = getLogFile();\n if (!isInteractive() && logFile) {\n Log.log(chalk.gray(`Logs: ${logFile}`));\n }\n }\n\n const { exp, pkg } = profile(getConfig)(projectRoot);\n\n // Start dependency version check in the background as early as possible (non-blocking).\n // The result will be displayed in the TUI once it resolves.\n let dependencyCheckRef: DependencyCheckRef | undefined;\n if (!env.EXPO_OFFLINE && !env.EXPO_NO_DEPENDENCY_VALIDATION && !settings.webOnly) {\n dependencyCheckRef = checkDependencies(projectRoot, exp, pkg);\n }\n\n if (exp.platforms?.includes('ios') && process.platform !== 'win32') {\n // If Xcode could potentially be used, then we should eagerly perform the\n // assertions since they can take a while on cold boots.\n getXcodeVersionAsync({ silent: true });\n SimulatorAppPrerequisite.instance.assertAsync().catch(() => {\n // noop -- this will be thrown again when the user attempts to open the project.\n });\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n const [defaultOptions, startOptions] = await getMultiBundlerStartOptions(\n projectRoot,\n options,\n settings,\n platformBundlers\n );\n\n const devServerManager = new DevServerManager(projectRoot, defaultOptions);\n\n // Validations\n\n if (options.web || settings.webOnly) {\n await devServerManager.ensureProjectPrerequisiteAsync(WebSupportProjectPrerequisite);\n }\n\n // Start the server as soon as possible.\n await profile(devServerManager.startAsync.bind(devServerManager))(startOptions);\n\n if (!settings.webOnly) {\n await devServerManager.watchEnvironmentVariables();\n\n // After the server starts, we can start attempting to bootstrap TypeScript.\n await devServerManager.bootstrapTypeScriptAsync();\n }\n\n // Open project on devices.\n await profile(openPlatformsAsync)(devServerManager, options);\n\n const defaultServerUrl = devServerManager.getDefaultDevServer()?.getDevServerUrl() ?? '';\n const mcpServer =\n (await profile(maybeCreateMCPServerAsync)({\n projectRoot,\n devServerUrl: defaultServerUrl,\n })) ?? undefined;\n\n // Present the Terminal UI.\n if (isInteractive()) {\n await profile(startInterfaceAsync)(devServerManager, {\n platforms: exp.platforms ?? ['ios', 'android', 'web'],\n mcpServer,\n dependencyCheckRef,\n });\n } else {\n // Display the server location in CI...\n if (defaultServerUrl) {\n if (env.__EXPO_E2E_TEST) {\n // Print the URL to stdout for tests\n console.info(`[__EXPO_E2E_TEST:server] ${JSON.stringify({ url: defaultServerUrl })}`);\n }\n Log.log(chalk`Waiting on {underline ${defaultServerUrl}}`);\n Log.log();\n await printDevToolsPluginCliBannersAsync(devServerManager);\n }\n // In non-interactive mode, print the check outside of an interface, if it's available\n if (dependencyCheckRef?.result) {\n printDependencyCheckResult(dependencyCheckRef.result);\n }\n }\n\n if (mcpServer) {\n addMcpCapabilities(mcpServer, devServerManager);\n mcpServer.start();\n }\n\n // Final note about closing the server.\n const logLocation = settings.webOnly ? 'in the browser console' : 'below';\n Log.log(\n chalk`Logs for your project will appear ${logLocation}.${\n isInteractive() ? chalk.dim(` Press Ctrl+C to exit.`) : ''\n }`\n );\n}\n"],"names":["startAsync","getMultiBundlerStartOptions","projectRoot","options","settings","platformBundlers","commonOptions","mode","dev","devClient","privateKeyPath","undefined","https","maxWorkers","resetDevServer","clear","minify","location","hostType","host","scheme","multiBundlerSettings","resolvePortsAsync","optionalBundlers","web","bundlers","Set","Object","values","multiBundlerStartOptions","map","bundler","port","webpackPort","metroPort","type","exp","devServerManager","shouldReduceLogs","Log","log","chalk","gray","logFile","getLogFile","isInteractive","pkg","profile","getConfig","dependencyCheckRef","env","EXPO_OFFLINE","EXPO_NO_DEPENDENCY_VALIDATION","webOnly","checkDependencies","platforms","includes","process","platform","getXcodeVersionAsync","silent","SimulatorAppPrerequisite","instance","assertAsync","catch","getPlatformBundlers","defaultOptions","startOptions","DevServerManager","ensureProjectPrerequisiteAsync","WebSupportProjectPrerequisite","bind","watchEnvironmentVariables","bootstrapTypeScriptAsync","openPlatformsAsync","defaultServerUrl","getDefaultDevServer","getDevServerUrl","mcpServer","maybeCreateMCPServerAsync","devServerUrl","startInterfaceAsync","__EXPO_E2E_TEST","console","info","JSON","stringify","url","printDevToolsPluginCliBannersAsync","result","printDependencyCheckResult","addMcpCapabilities","start","logLocation","dim"],"mappings":";;;;+BAyEsBA;;;eAAAA;;;;yBAzEI;;;;;;;gEACR;;;;;;wBAE2B;0CAKtC;0CACkC;mCACJ;+CACS;oCACK;gCACf;gCAEF;6DACb;kCAGY;qBACS;+BACP;kCAEC;qBAChB;6BACU;yBACN;gDACW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnC,eAAe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"}
|
|
1
|
+
{"version":3,"sources":["../../../src/start/startAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport { getLogFile, shouldReduceLogs } from '../events';\nimport {\n checkDependencies,\n printDependencyCheckResult,\n type DependencyCheckRef,\n} from './checkDependenciesOnStart';\nimport { SimulatorAppPrerequisite } from './doctor/apple/SimulatorAppPrerequisite';\nimport { getXcodeVersionAsync } from './doctor/apple/XcodePrerequisite';\nimport { WebSupportProjectPrerequisite } from './doctor/web/WebSupportProjectPrerequisite';\nimport { printDevToolsPluginCliBannersAsync } from './interface/interactiveActions';\nimport { startInterfaceAsync } from './interface/startInterface';\nimport type { Options } from './resolveOptions';\nimport { resolvePortsAsync } from './resolveOptions';\nimport * as Log from '../log';\nimport type { BundlerStartOptions } from './server/BundlerDevServer';\nimport type { MultiBundlerStartOptions } from './server/DevServerManager';\nimport { DevServerManager } from './server/DevServerManager';\nimport { maybeCreateMCPServerAsync } from './server/mcp/MCP';\nimport { openPlatformsAsync } from './server/openPlatforms';\nimport type { PlatformBundlers } from './server/platformBundlers';\nimport { getPlatformBundlers } from './server/platformBundlers';\nimport { env } from '../utils/env';\nimport { isInteractive } from '../utils/interactive';\nimport { profile } from '../utils/profile';\n\nasync function getMultiBundlerStartOptions(\n projectRoot: string,\n options: Options,\n settings: { webOnly?: boolean },\n platformBundlers: PlatformBundlers\n): Promise<[BundlerStartOptions, MultiBundlerStartOptions]> {\n const commonOptions: BundlerStartOptions = {\n mode: options.dev ? 'development' : 'production',\n devClient: options.devClient,\n privateKeyPath: options.privateKeyPath ?? undefined,\n https: options.https,\n maxWorkers: options.maxWorkers,\n resetDevServer: options.clear,\n minify: options.minify,\n location: {\n hostType: options.host,\n scheme: options.scheme,\n },\n };\n const multiBundlerSettings = await resolvePortsAsync(projectRoot, options, settings);\n\n const optionalBundlers: Partial<PlatformBundlers> = { ...platformBundlers };\n // In the default case, we don't want to start multiple bundlers since this is\n // a bit slower. Our priority (for legacy) is native platforms.\n if (!options.web) {\n delete optionalBundlers['web'];\n }\n\n const bundlers = [...new Set(Object.values(optionalBundlers))];\n const multiBundlerStartOptions = bundlers.map((bundler) => {\n const port =\n bundler === 'webpack' ? multiBundlerSettings.webpackPort : multiBundlerSettings.metroPort;\n return {\n type: bundler,\n options: {\n ...commonOptions,\n port,\n },\n };\n });\n\n return [commonOptions, multiBundlerStartOptions];\n}\n\nexport async function startAsync(\n projectRoot: string,\n options: Options,\n settings: { webOnly?: boolean }\n) {\n if (!shouldReduceLogs()) {\n Log.log(chalk.gray(`Starting project at ${projectRoot}`));\n const logFile = getLogFile();\n if (!isInteractive() && logFile) {\n Log.log(chalk.gray(`Logs: ${logFile}`));\n }\n }\n\n const { exp, pkg } = profile(getConfig)(projectRoot);\n\n // Start dependency version check in the background as early as possible (non-blocking).\n // The result will be displayed in the TUI once it resolves.\n let dependencyCheckRef: DependencyCheckRef | undefined;\n if (!env.EXPO_OFFLINE && !env.EXPO_NO_DEPENDENCY_VALIDATION && !settings.webOnly) {\n dependencyCheckRef = checkDependencies(projectRoot, exp, pkg);\n }\n\n if (exp.platforms?.includes('ios') && process.platform !== 'win32') {\n // If Xcode could potentially be used, then we should eagerly perform the\n // assertions since they can take a while on cold boots.\n getXcodeVersionAsync({ silent: true });\n SimulatorAppPrerequisite.instance.assertAsync().catch(() => {\n // noop -- this will be thrown again when the user attempts to open the project.\n });\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n const [defaultOptions, startOptions] = await getMultiBundlerStartOptions(\n projectRoot,\n options,\n settings,\n platformBundlers\n );\n\n const devServerManager = new DevServerManager(projectRoot, defaultOptions);\n\n // Validations\n\n if (options.web || settings.webOnly) {\n await devServerManager.ensureProjectPrerequisiteAsync(WebSupportProjectPrerequisite);\n }\n\n // Start the server as soon as possible.\n await profile(devServerManager.startAsync.bind(devServerManager))(startOptions);\n\n if (!settings.webOnly) {\n await devServerManager.watchEnvironmentVariables();\n\n // After the server starts, we can start attempting to bootstrap TypeScript.\n await devServerManager.bootstrapTypeScriptAsync();\n }\n\n // Open project on devices.\n await profile(openPlatformsAsync)(devServerManager, options);\n\n const defaultServerUrl = devServerManager.getDefaultDevServer()?.getDevServerUrl() ?? '';\n const mcpServer =\n (await profile(maybeCreateMCPServerAsync)({\n devServerManager,\n devServerUrl: defaultServerUrl,\n })) ?? undefined;\n\n // Present the Terminal UI.\n if (isInteractive()) {\n await profile(startInterfaceAsync)(devServerManager, {\n platforms: exp.platforms ?? ['ios', 'android', 'web'],\n mcpServer,\n dependencyCheckRef,\n });\n } else {\n // Display the server location in CI...\n if (defaultServerUrl) {\n if (env.__EXPO_E2E_TEST) {\n // Print the URL to stdout for tests\n console.info(`[__EXPO_E2E_TEST:server] ${JSON.stringify({ url: defaultServerUrl })}`);\n }\n Log.log(chalk`Waiting on {underline ${defaultServerUrl}}`);\n Log.log();\n await printDevToolsPluginCliBannersAsync(devServerManager);\n }\n // In non-interactive mode, print the check outside of an interface, if it's available\n if (dependencyCheckRef?.result) {\n printDependencyCheckResult(dependencyCheckRef.result);\n }\n }\n\n if (mcpServer) {\n mcpServer.start();\n }\n\n // Final note about closing the server.\n const logLocation = settings.webOnly ? 'in the browser console' : 'below';\n Log.log(\n chalk`Logs for your project will appear ${logLocation}.${\n isInteractive() ? chalk.dim(` Press Ctrl+C to exit.`) : ''\n }`\n );\n}\n"],"names":["startAsync","getMultiBundlerStartOptions","projectRoot","options","settings","platformBundlers","commonOptions","mode","dev","devClient","privateKeyPath","undefined","https","maxWorkers","resetDevServer","clear","minify","location","hostType","host","scheme","multiBundlerSettings","resolvePortsAsync","optionalBundlers","web","bundlers","Set","Object","values","multiBundlerStartOptions","map","bundler","port","webpackPort","metroPort","type","exp","devServerManager","shouldReduceLogs","Log","log","chalk","gray","logFile","getLogFile","isInteractive","pkg","profile","getConfig","dependencyCheckRef","env","EXPO_OFFLINE","EXPO_NO_DEPENDENCY_VALIDATION","webOnly","checkDependencies","platforms","includes","process","platform","getXcodeVersionAsync","silent","SimulatorAppPrerequisite","instance","assertAsync","catch","getPlatformBundlers","defaultOptions","startOptions","DevServerManager","ensureProjectPrerequisiteAsync","WebSupportProjectPrerequisite","bind","watchEnvironmentVariables","bootstrapTypeScriptAsync","openPlatformsAsync","defaultServerUrl","getDefaultDevServer","getDevServerUrl","mcpServer","maybeCreateMCPServerAsync","devServerUrl","startInterfaceAsync","__EXPO_E2E_TEST","console","info","JSON","stringify","url","printDevToolsPluginCliBannersAsync","result","printDependencyCheckResult","start","logLocation","dim"],"mappings":";;;;+BAwEsBA;;;eAAAA;;;;yBAxEI;;;;;;;gEACR;;;;;;wBAE2B;0CAKtC;0CACkC;mCACJ;+CACS;oCACK;gCACf;gCAEF;6DACb;kCAGY;qBACS;+BACP;kCAEC;qBAChB;6BACU;yBACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,eAAeC,4BACbC,WAAmB,EACnBC,OAAgB,EAChBC,QAA+B,EAC/BC,gBAAkC;IAElC,MAAMC,gBAAqC;QACzCC,MAAMJ,QAAQK,GAAG,GAAG,gBAAgB;QACpCC,WAAWN,QAAQM,SAAS;QAC5BC,gBAAgBP,QAAQO,cAAc,IAAIC;QAC1CC,OAAOT,QAAQS,KAAK;QACpBC,YAAYV,QAAQU,UAAU;QAC9BC,gBAAgBX,QAAQY,KAAK;QAC7BC,QAAQb,QAAQa,MAAM;QACtBC,UAAU;YACRC,UAAUf,QAAQgB,IAAI;YACtBC,QAAQjB,QAAQiB,MAAM;QACxB;IACF;IACA,MAAMC,uBAAuB,MAAMC,IAAAA,iCAAiB,EAACpB,aAAaC,SAASC;IAE3E,MAAMmB,mBAA8C;QAAE,GAAGlB,gBAAgB;IAAC;IAC1E,8EAA8E;IAC9E,+DAA+D;IAC/D,IAAI,CAACF,QAAQqB,GAAG,EAAE;QAChB,OAAOD,gBAAgB,CAAC,MAAM;IAChC;IAEA,MAAME,WAAW;WAAI,IAAIC,IAAIC,OAAOC,MAAM,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,CAAA,CAAC,sBAAsB,EAAEkC,iBAAiB,CAAC,CAAC;YACzDpC,KAAIC,GAAG;YACP,MAAMgD,IAAAA,sDAAkC,EAACnD;QAC3C;QACA,sFAAsF;QACtF,IAAIY,sCAAAA,mBAAoBwC,MAAM,EAAE;YAC9BC,IAAAA,oDAA0B,EAACzC,mBAAmBwC,MAAM;QACtD;IACF;IAEA,IAAIX,WAAW;QACbA,UAAUa,KAAK;IACjB;IAEA,uCAAuC;IACvC,MAAMC,cAAcxF,SAASiD,OAAO,GAAG,2BAA2B;IAClEd,KAAIC,GAAG,CACLC,IAAAA,gBAAK,CAAA,CAAC,kCAAkC,EAAEmD,YAAY,CAAC,EACrD/C,IAAAA,0BAAa,MAAKJ,gBAAK,CAACoD,GAAG,CAAC,CAAC,sBAAsB,CAAC,IAAI,GACzD,CAAC;AAEN"}
|
package/build/src/utils/open.js
CHANGED
|
@@ -212,22 +212,8 @@ async function openBrowserAsync(target) {
|
|
|
212
212
|
});
|
|
213
213
|
return true;
|
|
214
214
|
}
|
|
215
|
-
if (process.platform === 'win32') {
|
|
216
|
-
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
// WSL: when the user hasn't overridden BROWSER, route through Windows `cmd.exe` so
|
|
220
|
-
// the URL opens in the user's Windows browser. Falls through to `xdg-open` otherwise.
|
|
221
|
-
if (!browserApp && isWsl()) {
|
|
222
|
-
await (0, _spawnasync().default)('/mnt/c/Windows/System32/cmd.exe', [
|
|
223
|
-
'/c',
|
|
224
|
-
'start',
|
|
225
|
-
'""',
|
|
226
|
-
target
|
|
227
|
-
], {
|
|
228
|
-
stdio: 'ignore'
|
|
229
|
-
});
|
|
230
|
-
return true;
|
|
215
|
+
if (process.platform === 'win32' || !browserApp && isWsl()) {
|
|
216
|
+
return spawnWindowsBrowserAsync(target, browserArgs, browserApp);
|
|
231
217
|
}
|
|
232
218
|
const command = browserApp ?? 'xdg-open';
|
|
233
219
|
await (0, _spawnasync().default)(command, [
|
|
@@ -238,22 +224,52 @@ async function openBrowserAsync(target) {
|
|
|
238
224
|
});
|
|
239
225
|
return true;
|
|
240
226
|
}
|
|
241
|
-
|
|
242
|
-
//
|
|
227
|
+
function quotePowerShellString(value) {
|
|
228
|
+
// PowerShell treats typographic apostrophes as quotes too.
|
|
229
|
+
return `'${value.replace(/['‘’‚‛]/g, (quote)=>quote + quote)}'`;
|
|
230
|
+
}
|
|
231
|
+
function quoteWindowsArgument(value) {
|
|
232
|
+
let quoted = '"';
|
|
233
|
+
let backslashes = 0;
|
|
234
|
+
for(let i = 0; i < value.length; i++){
|
|
235
|
+
const character = value[i];
|
|
236
|
+
if (character === '\\') {
|
|
237
|
+
backslashes++;
|
|
238
|
+
} else {
|
|
239
|
+
quoted += '\\'.repeat(character === '"' ? backslashes * 2 + 1 : backslashes) + character;
|
|
240
|
+
backslashes = 0;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return quoted + '\\'.repeat(backslashes * 2) + '"';
|
|
244
|
+
}
|
|
245
|
+
async function spawnWindowsBrowserAsync(target, browserArgs, browserApp) {
|
|
243
246
|
const systemRoot = process.env.SYSTEMROOT ?? process.env.SystemRoot ?? 'C:\\Windows';
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
247
|
+
const windowsRoot = process.platform === 'win32' ? systemRoot : '/mnt/c/Windows';
|
|
248
|
+
const command = _path().default.join(windowsRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
249
|
+
const args = browserApp ? [
|
|
250
|
+
...browserArgs,
|
|
251
|
+
target
|
|
252
|
+
] : browserArgs;
|
|
253
|
+
let script = `$ErrorActionPreference = 'Stop'; Start-Process -FilePath ${quotePowerShellString(browserApp ?? target)}`;
|
|
254
|
+
if (args.length > 0) {
|
|
255
|
+
// Start-Process joins ArgumentList into a command line.
|
|
256
|
+
const argumentList = args.map(quoteWindowsArgument).join(' ');
|
|
257
|
+
script += ` -ArgumentList ${quotePowerShellString(argumentList)}`;
|
|
258
|
+
}
|
|
259
|
+
const encodedCommand = Buffer.from(script, 'utf16le').toString('base64');
|
|
260
|
+
try {
|
|
261
|
+
await (0, _spawnasync().default)(command, [
|
|
262
|
+
'-NoProfile',
|
|
263
|
+
'-NonInteractive',
|
|
264
|
+
'-EncodedCommand',
|
|
265
|
+
encodedCommand
|
|
266
|
+
], {
|
|
267
|
+
stdio: 'ignore'
|
|
268
|
+
});
|
|
269
|
+
return true;
|
|
270
|
+
} catch {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
257
273
|
}
|
|
258
274
|
function isWsl() {
|
|
259
275
|
if (process.platform !== 'linux') return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/open.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport spawnAsync from '@expo/spawn-async';\nimport os from 'os';\nimport path from 'path';\n\n/** Splits an inline script into trimmed, non-empty lines for `osascript -e <line>`. */\nfunction applescript(strings: TemplateStringsArray, ...values: unknown[]): string[] {\n let raw = strings[0]!;\n for (let i = 0; i < values.length; i++) {\n raw += String(values[i]) + strings[i + 1];\n }\n return raw\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n}\n\nfunction buildOpenChromiumTabScript(target: string, matchUrl: string): string[] {\n const theURL = osascript.escapeString(target);\n const matchURL = osascript.escapeString(matchUrl);\n return applescript`\n property targetTab: null\n property targetTabIndex: -1\n property targetWindow: null\n property theProgram: \"\"\n\n on run\n set theProgram to my findRunningChromium()\n if theProgram is \"\" then error \"No Chromium browser is running.\"\n set theURL to \"${theURL}\"\n set matchURL to \"${matchURL}\"\n using terms from application \"Google Chrome\"\n tell application theProgram\n if (count every window) = 0 then\n make new window\n end if\n set found to my lookupTabWithUrl(matchURL)\n if found then\n set targetWindow's active tab index to targetTabIndex\n tell targetTab to reload\n tell targetWindow to activate\n set index of targetWindow to 1\n return\n end if\n set found to my lookupTabWithUrl(\"chrome://newtab/\")\n if found then\n set targetWindow's active tab index to targetTabIndex\n set URL of targetTab to theURL\n tell targetWindow to activate\n return\n end if\n tell window 1\n activate\n make new tab with properties {URL:theURL}\n end tell\n end tell\n end using terms from\n end run\n\n on findRunningChromium()\n set candidates to {\"Google Chrome Canary\", \"Google Chrome\", \"Microsoft Edge\", \"Brave Browser\", \"Vivaldi\", \"Chromium\"}\n tell application \"System Events\"\n set runningNames to name of every process\n end tell\n repeat with candidate in candidates\n set candidateName to candidate as string\n if candidateName is in runningNames then return candidateName\n end repeat\n return \"\"\n end findRunningChromium\n\n on lookupTabWithUrl(lookupUrl)\n using terms from application \"Google Chrome\"\n tell application theProgram\n set found to false\n set theTabIndex to -1\n repeat with theWindow in every window\n set theTabIndex to 0\n repeat with theTab in every tab of theWindow\n set theTabIndex to theTabIndex + 1\n if (theTab's URL as string) contains lookupUrl then\n set targetTab to theTab\n set targetTabIndex to theTabIndex\n set targetWindow to theWindow\n set found to true\n exit repeat\n end if\n end repeat\n if found then exit repeat\n end repeat\n end tell\n end using terms from\n return found\n end lookupTabWithUrl\n `;\n}\n\nfunction safeOrigin(target: string): string {\n try {\n return new URL(target).origin;\n } catch {\n return target;\n }\n}\n\nasync function tryOpenInChromiumTabAsync(target: string): Promise<boolean> {\n const matchUrl = process.env.OPEN_MATCH_HOST_ONLY === 'true' ? safeOrigin(target) : target;\n try {\n await osascript.spawnAsync(buildOpenChromiumTabScript(target, matchUrl), {\n stdio: 'ignore',\n });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Opens a URL in the user's browser. Honors `BROWSER` (set to `none` to disable) and\n * `BROWSER_ARGS` environment variables. On macOS, reuses an existing tab in a running\n * Chromium-based browser when possible.\n *\n * @returns `true` when a browser was launched, `false` when `BROWSER=none`.\n */\nexport async function openBrowserAsync(target: string): Promise<boolean> {\n const browserEnv = process.env.BROWSER?.trim();\n if (browserEnv?.toLowerCase() === 'none') {\n return false;\n }\n\n // On macOS, `BROWSER=open` historically meant \"use the default handler\" rather than\n // \"launch an app called open\" — treat it as if BROWSER were unset.\n const browserApp =\n browserEnv && !(process.platform === 'darwin' && browserEnv.toLowerCase() === 'open')\n ? browserEnv\n : undefined;\n const browserArgs = process.env.BROWSER_ARGS ? process.env.BROWSER_ARGS.split(' ') : [];\n\n if (process.platform === 'darwin') {\n const isDefaultOrChrome = !browserApp || browserApp.toLowerCase() === 'google chrome';\n if (isDefaultOrChrome && (await tryOpenInChromiumTabAsync(target))) {\n return true;\n }\n const openArgs: string[] = [];\n if (browserApp) openArgs.push('-a', browserApp);\n // Per `open(1)`, everything following `--args` is forwarded to the launched app,\n // so the target URL must come after the args block to reach the app alongside them.\n if (browserArgs.length > 0) openArgs.push('--args', ...browserArgs);\n openArgs.push(target);\n await spawnAsync('open', openArgs, { stdio: 'ignore' });\n return true;\n }\n\n if (process.platform === 'win32') {\n await spawnWindowsStartAsync(target, browserApp, browserArgs);\n return true;\n }\n\n // WSL: when the user hasn't overridden BROWSER, route through Windows `cmd.exe` so\n // the URL opens in the user's Windows browser. Falls through to `xdg-open` otherwise.\n if (!browserApp && isWsl()) {\n await spawnAsync('/mnt/c/Windows/System32/cmd.exe', ['/c', 'start', '\"\"', target], {\n stdio: 'ignore',\n });\n return true;\n }\n\n const command = browserApp ?? 'xdg-open';\n await spawnAsync(command, [...browserArgs, target], { stdio: 'ignore' });\n return true;\n}\n\nasync function spawnWindowsStartAsync(\n target: string,\n browserApp: string | undefined,\n browserArgs: string[]\n): Promise<void> {\n // Windows preserves env var case in Node, but the OS variable is `SystemRoot`.\n const systemRoot = process.env.SYSTEMROOT ?? process.env.SystemRoot ?? 'C:\\\\Windows';\n const cmd = path.join(systemRoot, 'System32', 'cmd.exe');\n // `start \"\"` — the empty quoted string is the window title, so the URL isn't\n // interpreted as a title argument.\n const startArgs = ['/c', 'start', '\"\"'];\n if (browserApp) startArgs.push(browserApp);\n startArgs.push(target, ...browserArgs);\n await spawnAsync(cmd, startArgs, { stdio: 'ignore' });\n}\n\nfunction isWsl(): boolean {\n if (process.platform !== 'linux') return false;\n if (process.env.WSL_DISTRO_NAME) return true;\n const release = os.release().toLowerCase();\n return release.includes('microsoft') || release.includes('wsl');\n}\n"],"names":["openBrowserAsync","applescript","strings","values","raw","i","length","String","split","map","line","trim","filter","buildOpenChromiumTabScript","target","matchUrl","theURL","osascript","escapeString","matchURL","safeOrigin","URL","origin","tryOpenInChromiumTabAsync","process","env","OPEN_MATCH_HOST_ONLY","spawnAsync","stdio","browserEnv","BROWSER","toLowerCase","browserApp","platform","undefined","browserArgs","BROWSER_ARGS","isDefaultOrChrome","openArgs","push","spawnWindowsStartAsync","isWsl","command","systemRoot","SYSTEMROOT","SystemRoot","cmd","path","join","startArgs","WSL_DISTRO_NAME","release","os","includes"],"mappings":";;;;+BA4HsBA;;;eAAAA;;;;iEA5HK;;;;;;;gEACJ;;;;;;;gEACR;;;;;;;gEACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjB,qFAAqF,GACrF,SAASC,YAAYC,OAA6B,EAAE,GAAGC,MAAiB;IACtE,IAAIC,MAAMF,OAAO,CAAC,EAAE;IACpB,IAAK,IAAIG,IAAI,GAAGA,IAAIF,OAAOG,MAAM,EAAED,IAAK;QACtCD,OAAOG,OAAOJ,MAAM,CAACE,EAAE,IAAIH,OAAO,CAACG,IAAI,EAAE;IAC3C;IACA,OAAOD,IACJI,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAASA,KAAKC,IAAI,IACvBC,MAAM,CAAC,CAACF,OAASA,KAAKJ,MAAM,GAAG;AACpC;AAEA,SAASO,2BAA2BC,MAAc,EAAEC,QAAgB;IAClE,MAAMC,SAASC,aAAUC,YAAY,CAACJ;IACtC,MAAMK,WAAWF,aAAUC,YAAY,CAACH;IACxC,OAAOd,WAAW,CAAC;;;;;;;;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"version":3,"sources":["../../../src/utils/open.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport spawnAsync from '@expo/spawn-async';\nimport os from 'os';\nimport path from 'path';\n\n/** Splits an inline script into trimmed, non-empty lines for `osascript -e <line>`. */\nfunction applescript(strings: TemplateStringsArray, ...values: unknown[]): string[] {\n let raw = strings[0]!;\n for (let i = 0; i < values.length; i++) {\n raw += String(values[i]) + strings[i + 1];\n }\n return raw\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n}\n\nfunction buildOpenChromiumTabScript(target: string, matchUrl: string): string[] {\n const theURL = osascript.escapeString(target);\n const matchURL = osascript.escapeString(matchUrl);\n return applescript`\n property targetTab: null\n property targetTabIndex: -1\n property targetWindow: null\n property theProgram: \"\"\n\n on run\n set theProgram to my findRunningChromium()\n if theProgram is \"\" then error \"No Chromium browser is running.\"\n set theURL to \"${theURL}\"\n set matchURL to \"${matchURL}\"\n using terms from application \"Google Chrome\"\n tell application theProgram\n if (count every window) = 0 then\n make new window\n end if\n set found to my lookupTabWithUrl(matchURL)\n if found then\n set targetWindow's active tab index to targetTabIndex\n tell targetTab to reload\n tell targetWindow to activate\n set index of targetWindow to 1\n return\n end if\n set found to my lookupTabWithUrl(\"chrome://newtab/\")\n if found then\n set targetWindow's active tab index to targetTabIndex\n set URL of targetTab to theURL\n tell targetWindow to activate\n return\n end if\n tell window 1\n activate\n make new tab with properties {URL:theURL}\n end tell\n end tell\n end using terms from\n end run\n\n on findRunningChromium()\n set candidates to {\"Google Chrome Canary\", \"Google Chrome\", \"Microsoft Edge\", \"Brave Browser\", \"Vivaldi\", \"Chromium\"}\n tell application \"System Events\"\n set runningNames to name of every process\n end tell\n repeat with candidate in candidates\n set candidateName to candidate as string\n if candidateName is in runningNames then return candidateName\n end repeat\n return \"\"\n end findRunningChromium\n\n on lookupTabWithUrl(lookupUrl)\n using terms from application \"Google Chrome\"\n tell application theProgram\n set found to false\n set theTabIndex to -1\n repeat with theWindow in every window\n set theTabIndex to 0\n repeat with theTab in every tab of theWindow\n set theTabIndex to theTabIndex + 1\n if (theTab's URL as string) contains lookupUrl then\n set targetTab to theTab\n set targetTabIndex to theTabIndex\n set targetWindow to theWindow\n set found to true\n exit repeat\n end if\n end repeat\n if found then exit repeat\n end repeat\n end tell\n end using terms from\n return found\n end lookupTabWithUrl\n `;\n}\n\nfunction safeOrigin(target: string): string {\n try {\n return new URL(target).origin;\n } catch {\n return target;\n }\n}\n\nasync function tryOpenInChromiumTabAsync(target: string): Promise<boolean> {\n const matchUrl = process.env.OPEN_MATCH_HOST_ONLY === 'true' ? safeOrigin(target) : target;\n try {\n await osascript.spawnAsync(buildOpenChromiumTabScript(target, matchUrl), {\n stdio: 'ignore',\n });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Opens a URL in the user's browser. Honors `BROWSER` (set to `none` to disable) and\n * `BROWSER_ARGS` environment variables. On macOS, reuses an existing tab in a running\n * Chromium-based browser when possible.\n *\n * @returns Whether a browser was launched.\n */\nexport async function openBrowserAsync(target: string): Promise<boolean> {\n const browserEnv = process.env.BROWSER?.trim();\n if (browserEnv?.toLowerCase() === 'none') {\n return false;\n }\n\n // On macOS, `BROWSER=open` historically meant \"use the default handler\" rather than\n // \"launch an app called open\" — treat it as if BROWSER were unset.\n const browserApp =\n browserEnv && !(process.platform === 'darwin' && browserEnv.toLowerCase() === 'open')\n ? browserEnv\n : undefined;\n const browserArgs = process.env.BROWSER_ARGS ? process.env.BROWSER_ARGS.split(' ') : [];\n\n if (process.platform === 'darwin') {\n const isDefaultOrChrome = !browserApp || browserApp.toLowerCase() === 'google chrome';\n if (isDefaultOrChrome && (await tryOpenInChromiumTabAsync(target))) {\n return true;\n }\n const openArgs: string[] = [];\n if (browserApp) openArgs.push('-a', browserApp);\n // Per `open(1)`, everything following `--args` is forwarded to the launched app,\n // so the target URL must come after the args block to reach the app alongside them.\n if (browserArgs.length > 0) openArgs.push('--args', ...browserArgs);\n openArgs.push(target);\n await spawnAsync('open', openArgs, { stdio: 'ignore' });\n return true;\n }\n\n if (process.platform === 'win32' || (!browserApp && isWsl())) {\n return spawnWindowsBrowserAsync(target, browserArgs, browserApp);\n }\n\n const command = browserApp ?? 'xdg-open';\n await spawnAsync(command, [...browserArgs, target], { stdio: 'ignore' });\n return true;\n}\n\nfunction quotePowerShellString(value: string): string {\n // PowerShell treats typographic apostrophes as quotes too.\n return `'${value.replace(/['‘’‚‛]/g, (quote) => quote + quote)}'`;\n}\n\nfunction quoteWindowsArgument(value: string): string {\n let quoted = '\"';\n let backslashes = 0;\n for (let i = 0; i < value.length; i++) {\n const character = value[i]!;\n if (character === '\\\\') {\n backslashes++;\n } else {\n quoted += '\\\\'.repeat(character === '\"' ? backslashes * 2 + 1 : backslashes) + character;\n backslashes = 0;\n }\n }\n return quoted + '\\\\'.repeat(backslashes * 2) + '\"';\n}\n\nasync function spawnWindowsBrowserAsync(\n target: string,\n browserArgs: string[],\n browserApp?: string\n): Promise<boolean> {\n const systemRoot = process.env.SYSTEMROOT ?? process.env.SystemRoot ?? 'C:\\\\Windows';\n const windowsRoot = process.platform === 'win32' ? systemRoot : '/mnt/c/Windows';\n const command = path.join(windowsRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');\n const args = browserApp ? [...browserArgs, target] : browserArgs;\n let script = `$ErrorActionPreference = 'Stop'; Start-Process -FilePath ${quotePowerShellString(browserApp ?? target)}`;\n if (args.length > 0) {\n // Start-Process joins ArgumentList into a command line.\n const argumentList = args.map(quoteWindowsArgument).join(' ');\n script += ` -ArgumentList ${quotePowerShellString(argumentList)}`;\n }\n const encodedCommand = Buffer.from(script, 'utf16le').toString('base64');\n try {\n await spawnAsync(\n command,\n ['-NoProfile', '-NonInteractive', '-EncodedCommand', encodedCommand],\n {\n stdio: 'ignore',\n }\n );\n return true;\n } catch {\n return false;\n }\n}\n\nfunction isWsl(): boolean {\n if (process.platform !== 'linux') return false;\n if (process.env.WSL_DISTRO_NAME) return true;\n const release = os.release().toLowerCase();\n return release.includes('microsoft') || release.includes('wsl');\n}\n"],"names":["openBrowserAsync","applescript","strings","values","raw","i","length","String","split","map","line","trim","filter","buildOpenChromiumTabScript","target","matchUrl","theURL","osascript","escapeString","matchURL","safeOrigin","URL","origin","tryOpenInChromiumTabAsync","process","env","OPEN_MATCH_HOST_ONLY","spawnAsync","stdio","browserEnv","BROWSER","toLowerCase","browserApp","platform","undefined","browserArgs","BROWSER_ARGS","isDefaultOrChrome","openArgs","push","isWsl","spawnWindowsBrowserAsync","command","quotePowerShellString","value","replace","quote","quoteWindowsArgument","quoted","backslashes","character","repeat","systemRoot","SYSTEMROOT","SystemRoot","windowsRoot","path","join","args","script","argumentList","encodedCommand","Buffer","from","toString","WSL_DISTRO_NAME","release","os","includes"],"mappings":";;;;+BA4HsBA;;;eAAAA;;;;iEA5HK;;;;;;;gEACJ;;;;;;;gEACR;;;;;;;gEACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjB,qFAAqF,GACrF,SAASC,YAAYC,OAA6B,EAAE,GAAGC,MAAiB;IACtE,IAAIC,MAAMF,OAAO,CAAC,EAAE;IACpB,IAAK,IAAIG,IAAI,GAAGA,IAAIF,OAAOG,MAAM,EAAED,IAAK;QACtCD,OAAOG,OAAOJ,MAAM,CAACE,EAAE,IAAIH,OAAO,CAACG,IAAI,EAAE;IAC3C;IACA,OAAOD,IACJI,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAASA,KAAKC,IAAI,IACvBC,MAAM,CAAC,CAACF,OAASA,KAAKJ,MAAM,GAAG;AACpC;AAEA,SAASO,2BAA2BC,MAAc,EAAEC,QAAgB;IAClE,MAAMC,SAASC,aAAUC,YAAY,CAACJ;IACtC,MAAMK,WAAWF,aAAUC,YAAY,CAACH;IACxC,OAAOd,WAAW,CAAC;;;;;;;;;qBASA,EAAEe,OAAO;uBACP,EAAEG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,GAAG,GAAG;QACnB,wDAAwD;QACxD,MAAMsD,eAAeF,KAAKjD,GAAG,CAACsC,sBAAsBU,IAAI,CAAC;QACzDE,UAAU,CAAC,eAAe,EAAEhB,sBAAsBiB,eAAe;IACnE;IACA,MAAMC,iBAAiBC,OAAOC,IAAI,CAACJ,QAAQ,WAAWK,QAAQ,CAAC;IAC/D,IAAI;QACF,MAAMrC,IAAAA,qBAAU,EACde,SACA;YAAC;YAAc;YAAmB;YAAmBmB;SAAe,EACpE;YACEjC,OAAO;QACT;QAEF,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,SAASY;IACP,IAAIhB,QAAQS,QAAQ,KAAK,SAAS,OAAO;IACzC,IAAIT,QAAQC,GAAG,CAACwC,eAAe,EAAE,OAAO;IACxC,MAAMC,UAAUC,aAAE,CAACD,OAAO,GAAGnC,WAAW;IACxC,OAAOmC,QAAQE,QAAQ,CAAC,gBAAgBF,QAAQE,QAAQ,CAAC;AAC3D"}
|
|
@@ -26,7 +26,7 @@ class FetchClient {
|
|
|
26
26
|
this.headers = {
|
|
27
27
|
accept: 'application/json',
|
|
28
28
|
'content-type': 'application/json',
|
|
29
|
-
'user-agent': `expo-cli/${"57.0.
|
|
29
|
+
'user-agent': `expo-cli/${"57.0.33"}`,
|
|
30
30
|
authorization: 'Basic ' + _nodebuffer().Buffer.from(`${target}:`).toString('base64')
|
|
31
31
|
};
|
|
32
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "57.0.
|
|
3
|
+
"version": "57.0.33",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"bin": {
|
|
@@ -38,24 +38,24 @@
|
|
|
38
38
|
"homepage": "https://github.com/expo/expo/tree/main/packages/@expo/cli",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@expo/code-signing-certificates": "^0.0.6",
|
|
41
|
-
"@expo/config": "~57.0.
|
|
42
|
-
"@expo/config-plugins": "~57.0.
|
|
41
|
+
"@expo/config": "~57.0.11",
|
|
42
|
+
"@expo/config-plugins": "~57.0.12",
|
|
43
43
|
"@expo/devcert": "^1.2.1",
|
|
44
|
-
"@expo/env": "~2.4.
|
|
45
|
-
"@expo/image-utils": "^0.11.
|
|
46
|
-
"@expo/inline-modules": "^0.1.
|
|
44
|
+
"@expo/env": "~2.4.4",
|
|
45
|
+
"@expo/image-utils": "^0.11.7",
|
|
46
|
+
"@expo/inline-modules": "^0.1.9",
|
|
47
47
|
"@expo/json-file": "^11.0.1",
|
|
48
|
-
"@expo/log-box": "^57.0.
|
|
48
|
+
"@expo/log-box": "^57.0.5",
|
|
49
49
|
"@expo/metro": "~56.0.2",
|
|
50
|
-
"@expo/metro-config": "~57.0.
|
|
50
|
+
"@expo/metro-config": "~57.0.14",
|
|
51
51
|
"@expo/metro-file-map": "^57.0.4",
|
|
52
52
|
"@expo/osascript": "^2.7.1",
|
|
53
53
|
"@expo/package-manager": "^1.13.1",
|
|
54
|
-
"@expo/plist": "^0.8.
|
|
55
|
-
"@expo/prebuild-config": "^57.0.
|
|
56
|
-
"@expo/require-utils": "^57.0.
|
|
57
|
-
"@expo/router-server": "^57.0.
|
|
58
|
-
"@expo/schema-utils": "^57.0.
|
|
54
|
+
"@expo/plist": "^0.8.2",
|
|
55
|
+
"@expo/prebuild-config": "^57.0.20",
|
|
56
|
+
"@expo/require-utils": "^57.0.7",
|
|
57
|
+
"@expo/router-server": "^57.0.15",
|
|
58
|
+
"@expo/schema-utils": "^57.0.3",
|
|
59
59
|
"@expo/spawn-async": "^1.8.0",
|
|
60
60
|
"@expo/ws-tunnel": "^2.0.0",
|
|
61
61
|
"@expo/xcpretty": "^4.4.4",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"expo-server": "^57.0.3",
|
|
75
75
|
"fetch-nodeshim": "^0.4.10",
|
|
76
76
|
"getenv": "^2.0.0",
|
|
77
|
-
"glob": "^
|
|
77
|
+
"glob": "^14.0.3",
|
|
78
78
|
"lan-network": "^0.2.1",
|
|
79
79
|
"multitars": "^1.0.2",
|
|
80
80
|
"node-forge": "^1.3.3",
|
|
@@ -94,8 +94,7 @@
|
|
|
94
94
|
"terminal-link": "^2.1.1",
|
|
95
95
|
"toqr": "^0.1.1",
|
|
96
96
|
"wrap-ansi": "^7.0.0",
|
|
97
|
-
"ws": "^8.12.1"
|
|
98
|
-
"zod": "^3.25.76"
|
|
97
|
+
"ws": "^8.12.1"
|
|
99
98
|
},
|
|
100
99
|
"taskr": {
|
|
101
100
|
"requires": [
|
|
@@ -104,10 +103,14 @@
|
|
|
104
103
|
},
|
|
105
104
|
"peerDependencies": {
|
|
106
105
|
"expo": "*",
|
|
106
|
+
"expo-mcp": "*",
|
|
107
107
|
"expo-router": "*",
|
|
108
108
|
"react-native": "*"
|
|
109
109
|
},
|
|
110
110
|
"peerDependenciesMeta": {
|
|
111
|
+
"expo-mcp": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
111
114
|
"expo-router": {
|
|
112
115
|
"optional": true
|
|
113
116
|
},
|
|
@@ -157,13 +160,14 @@
|
|
|
157
160
|
"playwright": "^1.59.0",
|
|
158
161
|
"taskr": "^1.1.0",
|
|
159
162
|
"tree-kill": "^1.2.2",
|
|
160
|
-
"
|
|
161
|
-
"expo
|
|
163
|
+
"zod": "^3.25.76",
|
|
164
|
+
"@expo/fingerprint": "0.20.15",
|
|
165
|
+
"expo": "57.0.32",
|
|
162
166
|
"expo-module-scripts": "56.0.3",
|
|
163
|
-
"expo-router": "57.0.
|
|
164
|
-
"
|
|
167
|
+
"expo-router": "57.0.30",
|
|
168
|
+
"expo-modules-autolinking": "57.0.17"
|
|
165
169
|
},
|
|
166
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "d525588681ae2ac2863deff25d35daa39ede8ac1",
|
|
167
171
|
"scripts": {
|
|
168
172
|
"build": "taskr",
|
|
169
173
|
"clean": "expo-module clean",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevToolsPlugin.ts"],"sourcesContent":["import type { WebSocketServer } from 'ws';\n\nimport type { DevToolsPluginInfo } from './DevToolsPlugin.schema';\nimport { PluginSchema } from './DevToolsPlugin.schema';\nimport { DevToolsPluginCliExtensionExecutor } from './DevToolsPluginCliExtensionExecutor';\nimport { DevToolsPluginEndpoint } from './DevToolsPluginManager';\nimport {\n type DevToolsPluginRequestHandler,\n loadRequestHandlerAsync,\n loadWebSocketServerAsync,\n} from './DevToolsPluginServerHelpers';\nimport { isPathInside, maybeRealpathSync } from '../../utils/dir';\n\nexport type { DevToolsPluginRequestHandler } from './DevToolsPluginServerHelpers';\n\n/**\n * Class that represents a DevTools plugin with CLI and/or web extensions\n *\n * Responsibilities:\n * - Validates plugin configuration against schema\n * - Provides access to plugin metadata (name, description\n * , endpoints)\n * - Manages CLI command execution via DevToolsPluginExecutor\n * - Lazily initializes executor when needed\n * - Constructs web endpoint URLs based on server configuration\n */\nexport class DevToolsPlugin {\n constructor(\n private plugin: DevToolsPluginInfo,\n public readonly projectRoot: string\n ) {\n const result = PluginSchema.safeParse(plugin);\n if (!result.success) {\n throw new Error(`Invalid plugin configuration: ${result.error.message}`, {\n cause: result.error,\n });\n }\n\n if (plugin.webpageRoot != null) {\n const webpageRoot = maybeRealpathSync(plugin.webpageRoot) ?? plugin.webpageRoot;\n if (!isPathInside(webpageRoot, plugin.packageRoot)) {\n throw new Error(\n `webpageRoot (${plugin.webpageRoot}) is not inside packageRoot (${plugin.packageRoot}).`\n );\n }\n }\n\n if (plugin.serverEntryPoint != null) {\n const serverEntryPoint =\n maybeRealpathSync(plugin.serverEntryPoint) ?? plugin.serverEntryPoint;\n if (!isPathInside(serverEntryPoint, plugin.packageRoot)) {\n throw new Error(\n `serverEntryPoint (${plugin.serverEntryPoint}) is not inside packageRoot (${plugin.packageRoot}).`\n );\n }\n }\n }\n\n private _executor: DevToolsPluginCliExtensionExecutor | undefined = undefined;\n private _requestHandler: DevToolsPluginRequestHandler | undefined = undefined;\n private _webSocketServers: Record<string, WebSocketServer> | undefined = undefined;\n\n get packageName(): string {\n return this.plugin.packageName;\n }\n\n get packageRoot(): string {\n return this.plugin.packageRoot;\n }\n\n get webpageEndpoint(): string | undefined {\n return this.plugin?.webpageRoot || this.plugin?.serverEntryPoint\n ? `${DevToolsPluginEndpoint}/${this.plugin?.packageName}`\n : undefined;\n }\n\n get webpageRoot(): string | undefined {\n return this.plugin?.webpageRoot;\n }\n\n get serverEntryPoint(): string | undefined {\n return this.plugin?.serverEntryPoint;\n }\n\n /**\n * Lazily loads the request handler from the plugin's `serverEntryPoint`.\n * The entry point must default-export a handler function\n * (`export default function handler(request) {}` or `module.exports = function handler(request) {}`).\n */\n async getRequestHandlerAsync(): Promise<DevToolsPluginRequestHandler | undefined> {\n if (!this.plugin.serverEntryPoint) {\n return undefined;\n }\n\n if (!this._requestHandler) {\n this._requestHandler = await loadRequestHandlerAsync({\n packageName: this.plugin.packageName,\n serverEntryPoint: this.plugin.serverEntryPoint,\n });\n }\n\n return this._requestHandler;\n }\n\n /**\n * Lazily builds the WebSocket servers contributed by the plugin's `serverEntryPoint`. The entry\n * point exports a `webSocketHandlers` map of route (e.g. `/ws`) to a connection handler; each\n * route becomes a `ws` `WebSocketServer` (in `noServer` mode) that the dev server mounts under\n * `/_expo/plugins/<name>/<route>`. The fetch API based `requestHandler` cannot serve WebSocket\n * upgrades, so this is how a plugin opts into them. Returns an empty object when the plugin\n * exports no handlers.\n */\n async getWebSocketServersAsync(): Promise<Record<string, WebSocketServer>> {\n if (!this.plugin.serverEntryPoint) {\n return {};\n }\n\n if (!this._webSocketServers) {\n this._webSocketServers = await loadWebSocketServerAsync({\n packageName: this.plugin.packageName,\n serverEntryPoint: this.plugin.serverEntryPoint,\n });\n }\n\n return this._webSocketServers;\n }\n\n get cliBanner(): boolean {\n return this.plugin.bannerTitle !== undefined && this.plugin.bannerTitle !== false;\n }\n\n get bannerTitle(): string {\n return typeof this.plugin.bannerTitle === 'string' && this.plugin.bannerTitle\n ? this.plugin.bannerTitle\n : this.plugin.packageName;\n }\n\n get description(): string {\n return this.plugin.cliExtensions?.description ?? '';\n }\n\n get cliExtensions(): DevToolsPluginInfo['cliExtensions'] {\n return this.plugin.cliExtensions;\n }\n\n get executor(): DevToolsPluginCliExtensionExecutor | undefined {\n if (!this.plugin.cliExtensions?.entryPoint) {\n return undefined;\n }\n\n if (!this._executor) {\n this._executor = new DevToolsPluginCliExtensionExecutor(this.plugin, this.projectRoot);\n }\n\n return this._executor;\n }\n}\n"],"names":["DevToolsPlugin","plugin","projectRoot","_executor","undefined","_requestHandler","_webSocketServers","result","PluginSchema","safeParse","success","Error","error","message","cause","webpageRoot","maybeRealpathSync","isPathInside","packageRoot","serverEntryPoint","packageName","webpageEndpoint","DevToolsPluginEndpoint","getRequestHandlerAsync","loadRequestHandlerAsync","getWebSocketServersAsync","loadWebSocketServerAsync","cliBanner","bannerTitle","description","cliExtensions","executor","entryPoint","DevToolsPluginCliExtensionExecutor"],"mappings":";;;;+BA0BaA;;;eAAAA;;;sCAvBgB;oDACsB;uCACZ;6CAKhC;qBACyC;AAezC,MAAMA;IACX,YACE,AAAQC,MAA0B,EAClC,AAAgBC,WAAmB,CACnC;aAFQD,SAAAA;aACQC,cAAAA;aA6BVC,YAA4DC;aAC5DC,kBAA4DD;aAC5DE,oBAAiEF;QA7BvE,MAAMG,SAASC,kCAAY,CAACC,SAAS,CAACR;QACtC,IAAI,CAACM,OAAOG,OAAO,EAAE;YACnB,MAAM,IAAIC,MAAM,CAAC,8BAA8B,EAAEJ,OAAOK,KAAK,CAACC,OAAO,EAAE,EAAE;gBACvEC,OAAOP,OAAOK,KAAK;YACrB;QACF;QAEA,IAAIX,OAAOc,WAAW,IAAI,MAAM;YAC9B,MAAMA,cAAcC,IAAAA,sBAAiB,EAACf,OAAOc,WAAW,KAAKd,OAAOc,WAAW;YAC/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AAa,qBAAzB,2BAA2BE,UAAU,GAAE;YAC1C,OAAO5B;QACT;QAEA,IAAI,CAAC,IAAI,CAACD,SAAS,EAAE;YACnB,IAAI,CAACA,SAAS,GAAG,IAAI8B,sEAAkC,CAAC,IAAI,CAAChC,MAAM,EAAE,IAAI,CAACC,WAAW;QACvF;QAEA,OAAO,IAAI,CAACC,SAAS;IACvB;AACF"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get DevToolsPluginOutputSchema () {
|
|
13
|
-
return DevToolsPluginOutputSchema;
|
|
14
|
-
},
|
|
15
|
-
get PluginSchema () {
|
|
16
|
-
return PluginSchema;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
function _zod() {
|
|
20
|
-
const data = require("zod");
|
|
21
|
-
_zod = function() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
return data;
|
|
25
|
-
}
|
|
26
|
-
const CommandParameterSchema = _zod().z.object({
|
|
27
|
-
name: _zod().z.string().min(1),
|
|
28
|
-
type: _zod().z.enum([
|
|
29
|
-
'text',
|
|
30
|
-
'number',
|
|
31
|
-
'confirm'
|
|
32
|
-
]),
|
|
33
|
-
description: _zod().z.string().optional()
|
|
34
|
-
});
|
|
35
|
-
const CommandSchema = _zod().z.object({
|
|
36
|
-
name: _zod().z.string().min(1),
|
|
37
|
-
title: _zod().z.string().min(1),
|
|
38
|
-
environments: _zod().z.array(_zod().z.enum([
|
|
39
|
-
'cli',
|
|
40
|
-
'mcp'
|
|
41
|
-
])).readonly(),
|
|
42
|
-
parameters: _zod().z.array(CommandParameterSchema).optional()
|
|
43
|
-
});
|
|
44
|
-
const CliExtensionsSchema = _zod().z.object({
|
|
45
|
-
description: _zod().z.string(),
|
|
46
|
-
commands: _zod().z.array(CommandSchema).min(1),
|
|
47
|
-
entryPoint: _zod().z.string().min(1)
|
|
48
|
-
});
|
|
49
|
-
const PluginSchema = _zod().z.object({
|
|
50
|
-
packageName: _zod().z.string().min(1),
|
|
51
|
-
packageRoot: _zod().z.string().min(1),
|
|
52
|
-
webpageRoot: _zod().z.string().optional(),
|
|
53
|
-
bannerTitle: _zod().z.union([
|
|
54
|
-
_zod().z.boolean(),
|
|
55
|
-
_zod().z.string().min(1)
|
|
56
|
-
]).optional(),
|
|
57
|
-
serverEntryPoint: _zod().z.string().optional(),
|
|
58
|
-
cliExtensions: CliExtensionsSchema.optional()
|
|
59
|
-
});
|
|
60
|
-
const DevToolsPluginOutputLinesSchema = _zod().z.union([
|
|
61
|
-
_zod().z.object({
|
|
62
|
-
type: _zod().z.literal('text'),
|
|
63
|
-
text: _zod().z.string(),
|
|
64
|
-
url: _zod().z.string().optional(),
|
|
65
|
-
level: _zod().z.enum([
|
|
66
|
-
'info',
|
|
67
|
-
'warning',
|
|
68
|
-
'error'
|
|
69
|
-
])
|
|
70
|
-
}),
|
|
71
|
-
_zod().z.object({
|
|
72
|
-
type: _zod().z.literal('audio'),
|
|
73
|
-
url: _zod().z.string().url(),
|
|
74
|
-
text: _zod().z.string().optional()
|
|
75
|
-
}),
|
|
76
|
-
_zod().z.object({
|
|
77
|
-
type: _zod().z.literal('image'),
|
|
78
|
-
url: _zod().z.string().url(),
|
|
79
|
-
text: _zod().z.string().optional()
|
|
80
|
-
})
|
|
81
|
-
]);
|
|
82
|
-
const DevToolsPluginOutputSchema = _zod().z.array(DevToolsPluginOutputLinesSchema);
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=DevToolsPlugin.schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevToolsPlugin.schema.ts"],"sourcesContent":["import { z } from 'zod';\n\nconst CommandParameterSchema = z.object({\n name: z.string().min(1),\n type: z.enum(['text', 'number', 'confirm']),\n description: z.string().optional(),\n});\n\nexport type DevToolsPluginCommandParameter = z.infer<typeof CommandParameterSchema>;\n\nconst CommandSchema = z.object({\n name: z.string().min(1),\n title: z.string().min(1),\n environments: z.array(z.enum(['cli', 'mcp'])).readonly(),\n parameters: z.array(CommandParameterSchema).optional(),\n});\n\nexport type DevToolsPluginCommand = z.infer<typeof CommandSchema>;\n\nexport type DevToolsPluginExecutorArguments = {\n command: string;\n metroServerOrigin: string;\n args?: Record<string, string | number | boolean> | undefined;\n onOutput?: (output: DevToolsPluginOutput) => void;\n};\n\nconst CliExtensionsSchema = z.object({\n description: z.string(),\n commands: z.array(CommandSchema).min(1),\n entryPoint: z.string().min(1),\n});\n\nexport type DevToolsPluginCliExtensions = z.infer<typeof CliExtensionsSchema>;\n\nexport const PluginSchema = z.object({\n packageName: z.string().min(1),\n packageRoot: z.string().min(1),\n webpageRoot: z.string().optional(),\n bannerTitle: z.union([z.boolean(), z.string().min(1)]).optional(),\n serverEntryPoint: z.string().optional(),\n cliExtensions: CliExtensionsSchema.optional(),\n});\n\nexport type DevToolsPluginInfo = z.infer<typeof PluginSchema>;\n\nconst DevToolsPluginOutputLinesSchema = z.union([\n z.object({\n type: z.literal('text'),\n text: z.string(),\n url: z.string().optional(),\n level: z.enum(['info', 'warning', 'error']),\n }),\n z.object({\n type: z.literal('audio'),\n url: z.string().url(),\n text: z.string().optional(),\n }),\n z.object({\n type: z.literal('image'),\n url: z.string().url(),\n text: z.string().optional(),\n }),\n]);\n\nexport const DevToolsPluginOutputSchema = z.array(DevToolsPluginOutputLinesSchema);\n\nexport type DevToolsPluginOutput = z.infer<typeof DevToolsPluginOutputSchema>;\n"],"names":["DevToolsPluginOutputSchema","PluginSchema","CommandParameterSchema","z","object","name","string","min","type","enum","description","optional","CommandSchema","title","environments","array","readonly","parameters","CliExtensionsSchema","commands","entryPoint","packageName","packageRoot","webpageRoot","bannerTitle","union","boolean","serverEntryPoint","cliExtensions","DevToolsPluginOutputLinesSchema","literal","text","url","level"],"mappings":";;;;;;;;;;;QAgEaA;eAAAA;;QA9BAC;eAAAA;;;;yBAlCK;;;;;;AAElB,MAAMC,yBAAyBC,QAAC,CAACC,MAAM,CAAC;IACtCC,MAAMF,QAAC,CAACG,MAAM,GAAGC,GAAG,CAAC;IACrBC,MAAML,QAAC,CAACM,IAAI,CAAC;QAAC;QAAQ;QAAU;KAAU;IAC1CC,aAAaP,QAAC,CAACG,MAAM,GAAGK,QAAQ;AAClC;AAIA,MAAMC,gBAAgBT,QAAC,CAACC,MAAM,CAAC;IAC7BC,MAAMF,QAAC,CAACG,MAAM,GAAGC,GAAG,CAAC;IACrBM,OAAOV,QAAC,CAACG,MAAM,GAAGC,GAAG,CAAC;IACtBO,cAAcX,QAAC,CAACY,KAAK,CAACZ,QAAC,CAACM,IAAI,CAAC;QAAC;QAAO;KAAM,GAAGO,QAAQ;IACtDC,YAAYd,QAAC,CAACY,KAAK,CAACb,wBAAwBS,QAAQ;AACtD;AAWA,MAAMO,sBAAsBf,QAAC,CAACC,MAAM,CAAC;IACnCM,aAAaP,QAAC,CAACG,MAAM;IACrBa,UAAUhB,QAAC,CAACY,KAAK,CAACH,eAAeL,GAAG,CAAC;IACrCa,YAAYjB,QAAC,CAACG,MAAM,GAAGC,GAAG,CAAC;AAC7B;AAIO,MAAMN,eAAeE,QAAC,CAACC,MAAM,CAAC;IACnCiB,aAAalB,QAAC,CAACG,MAAM,GAAGC,GAAG,CAAC;IAC5Be,aAAanB,QAAC,CAACG,MAAM,GAAGC,GAAG,CAAC;IAC5BgB,aAAapB,QAAC,CAACG,MAAM,GAAGK,QAAQ;IAChCa,aAAarB,QAAC,CAACsB,KAAK,CAAC;QAACtB,QAAC,CAACuB,OAAO;QAAIvB,QAAC,CAACG,MAAM,GAAGC,GAAG,CAAC;KAAG,EAAEI,QAAQ;IAC/DgB,kBAAkBxB,QAAC,CAACG,MAAM,GAAGK,QAAQ;IACrCiB,eAAeV,oBAAoBP,QAAQ;AAC7C;AAIA,MAAMkB,kCAAkC1B,QAAC,CAACsB,KAAK,CAAC;IAC9CtB,QAAC,CAACC,MAAM,CAAC;QACPI,MAAML,QAAC,CAAC2B,OAAO,CAAC;QAChBC,MAAM5B,QAAC,CAACG,MAAM;QACd0B,KAAK7B,QAAC,CAACG,MAAM,GAAGK,QAAQ;QACxBsB,OAAO9B,QAAC,CAACM,IAAI,CAAC;YAAC;YAAQ;YAAW;SAAQ;IAC5C;IACAN,QAAC,CAACC,MAAM,CAAC;QACPI,MAAML,QAAC,CAAC2B,OAAO,CAAC;QAChBE,KAAK7B,QAAC,CAACG,MAAM,GAAG0B,GAAG;QACnBD,MAAM5B,QAAC,CAACG,MAAM,GAAGK,QAAQ;IAC3B;IACAR,QAAC,CAACC,MAAM,CAAC;QACPI,MAAML,QAAC,CAAC2B,OAAO,CAAC;QAChBE,KAAK7B,QAAC,CAACG,MAAM,GAAG0B,GAAG;QACnBD,MAAM5B,QAAC,CAACG,MAAM,GAAGK,QAAQ;IAC3B;CACD;AAEM,MAAMX,6BAA6BG,QAAC,CAACY,KAAK,CAACc"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevToolsPluginCliExtensionExecutor.ts"],"sourcesContent":["import { spawn, type ChildProcessWithoutNullStreams } from 'child_process';\nimport path from 'path';\n\nimport type {\n DevToolsPluginExecutorArguments,\n DevToolsPluginInfo,\n DevToolsPluginOutput,\n} from './DevToolsPlugin.schema';\nimport { DevToolsPluginCliExtensionResults } from './DevToolsPluginCliExtensionResults';\nimport { isPathInside } from '../../utils/dir';\n\nconst DEFAULT_TIMEOUT_MS = 10_000; // 10 seconds\n\n/**\n * Class that executes CLI Extension commands for a given plugin\n *\n * ## Responsibilities:\n * - Verifies that requested commands exist and have correct parameters\n * - Validates that provided arguments match expected parameter schema\n * - Spawns and manages child processes for command execution\n * - Captures and streams stdout/stderr data from executed commands\n * - Manages process errors, timeouts, and unexpected failures\n * - Enforces execution time limits to prevent hanging processes\n * - Configures proper execution environment with color support\n * - Ensures proper cleanup of processes and timeouts\n * - Provides structured output with exit codes and error states\n */\nexport class DevToolsPluginCliExtensionExecutor {\n private readonly resolvedEntryPoint: string;\n\n constructor(\n private plugin: DevToolsPluginInfo,\n private projectRoot: string,\n private spawnFunc: typeof spawn = spawn, // Used for injection when testing,\n private timeoutMs = DEFAULT_TIMEOUT_MS // Timeout for command execution\n ) {\n // Validate that this is a plugin with cli extensions\n if (!this.plugin.cliExtensions?.entryPoint) {\n throw new Error(`Plugin ${this.plugin.packageName} has no CLI extensions`);\n }\n // Reject entryPoints that escape packageRoot (e.g. \"../../other-pkg/dist/cli.js\").\n const resolved = path.resolve(this.plugin.packageRoot, this.plugin.cliExtensions.entryPoint);\n if (!isPathInside(resolved, this.plugin.packageRoot)) {\n throw new Error(\n `Plugin ${this.plugin.packageName} entryPoint \"${this.plugin.cliExtensions.entryPoint}\" ` +\n `escapes packageRoot (${this.plugin.packageRoot}); must be a relative path inside the package.`\n );\n }\n this.resolvedEntryPoint = resolved;\n }\n\n public validate({ command, args }: Omit<DevToolsPluginExecutorArguments, 'metroServerOrigin'>) {\n const commandElement = this.plugin.cliExtensions?.commands.find((c) => c.name === command);\n if (!commandElement) {\n throw new Error(`Command \"${command}\" not found in plugin ${this.plugin.packageName}`);\n }\n\n const paramLength = commandElement.parameters?.length ?? 0;\n const argsLength = Object.keys(args ?? {}).length;\n if (paramLength !== argsLength) {\n // Quick check to see if the lengths match\n throw new Error(\n `Expected ${paramLength} parameter(s), but got ${argsLength} argument(s) for the command \"${command}\".`\n );\n }\n\n const argsObj = (args ?? {}) as Record<string, unknown>;\n for (const param of commandElement.parameters ?? []) {\n if (!Object.prototype.hasOwnProperty.call(argsObj, param.name)) {\n throw new Error(\n `Parameter \"${param.name}\" not found in command \"${command}\" of plugin ${this.plugin.packageName}`\n );\n }\n // Enforce declared parameter type; don't rely on upstream Zod validation alone.\n const expected =\n param.type === 'confirm' ? 'boolean' : param.type === 'number' ? 'number' : 'string';\n const actual = typeof argsObj[param.name];\n if (actual !== expected) {\n throw new Error(\n `Parameter \"${param.name}\" of \"${command}\" expected ${expected} (declared \"${param.type}\"), got ${actual}.`\n );\n }\n }\n }\n\n /** this function is used for testing and showing the command in UI */\n public getCommandString = ({\n command,\n args,\n }: Omit<DevToolsPluginExecutorArguments, 'metroServerOrigin'>) => {\n return `node ${this.plugin.cliExtensions!.entryPoint} ${command}${Object.keys(args ?? {}).length > 0 ? ' ' + JSON.stringify(args) : ''}`;\n };\n\n public execute = async ({\n command,\n args,\n metroServerOrigin,\n onOutput,\n }: DevToolsPluginExecutorArguments): Promise<DevToolsPluginOutput> => {\n this.validate({ command, args });\n return new Promise<DevToolsPluginOutput>((resolve) => {\n let finished = false;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n const pluginResults = new DevToolsPluginCliExtensionResults(onOutput);\n\n // process.execPath instead of 'node' so the child can't be redirected by a PATH shim.\n let child: ChildProcessWithoutNullStreams;\n try {\n child = this.spawnFunc(\n process.execPath,\n [this.resolvedEntryPoint, command, `${JSON.stringify(args)}`, `${metroServerOrigin}`],\n {\n cwd: this.projectRoot,\n env: { ...process.env },\n }\n );\n } catch (err: any) {\n // spawn can throw synchronously; resolve with an error result instead of hanging.\n pluginResults.append(err?.toString?.() ?? String(err), 'error');\n resolve(pluginResults.getOutput());\n return;\n }\n\n const finishOnTruncation = () => {\n if (pluginResults.isTruncated() && !finished) {\n finished = true;\n if (timeout) clearTimeout(timeout);\n child.kill('SIGKILL');\n resolve(pluginResults.getOutput());\n }\n };\n\n // Collect output/error data\n child.stdout.on('data', (data) => {\n pluginResults.append(data.toString());\n finishOnTruncation();\n });\n child.stderr.on('data', (data) => {\n pluginResults.append(data.toString(), 'error');\n finishOnTruncation();\n });\n\n // Setup timeout\n timeout = setTimeout(() => {\n if (!finished) {\n finished = true;\n child.kill('SIGKILL');\n pluginResults.append('Command timed out', 'error');\n resolve(pluginResults.getOutput());\n }\n }, this.timeoutMs);\n\n child.on('close', (code: number) => {\n if (finished) return;\n if (timeout) clearTimeout(timeout);\n finished = true;\n pluginResults.exit(code);\n resolve(pluginResults.getOutput());\n });\n\n child.on('error', (err: Error) => {\n if (finished) return;\n if (timeout) clearTimeout(timeout);\n finished = true;\n pluginResults.append(err.toString(), 'error');\n resolve(pluginResults.getOutput());\n });\n });\n };\n}\n"],"names":["DevToolsPluginCliExtensionExecutor","DEFAULT_TIMEOUT_MS","plugin","projectRoot","spawnFunc","spawn","timeoutMs","getCommandString","command","args","cliExtensions","entryPoint","Object","keys","length","JSON","stringify","execute","metroServerOrigin","onOutput","validate","Promise","resolve","finished","timeout","pluginResults","DevToolsPluginCliExtensionResults","child","process","execPath","resolvedEntryPoint","cwd","env","err","append","toString","String","getOutput","finishOnTruncation","isTruncated","clearTimeout","kill","stdout","on","data","stderr","setTimeout","code","exit","Error","packageName","resolved","path","packageRoot","isPathInside","commandElement","commands","find","c","name","paramLength","parameters","argsLength","argsObj","param","prototype","hasOwnProperty","call","expected","type","actual"],"mappings":";;;;+BA2BaA;;;eAAAA;;;;yBA3B8C;;;;;;;gEAC1C;;;;;;mDAOiC;qBACrB;;;;;;AAE7B,MAAMC,qBAAqB,OAAQ,aAAa;AAgBzC,MAAMD;IAGX,YACE,AAAQE,MAA0B,EAClC,AAAQC,WAAmB,EAC3B,AAAQC,YAA0BC,sBAAK,EACvC,AAAQC,YAAYL,mBAAmB,gCAAgC;IAAjC,CACtC;YAEK;aANGC,SAAAA;aACAC,cAAAA;aACAC,YAAAA;aACAE,YAAAA;QAmDV,oEAAoE,QAC7DC,mBAAmB,CAAC,EACzBC,OAAO,EACPC,IAAI,EACuD;YAC3D,OAAO,CAAC,KAAK,EAAE,IAAI,CAACP,MAAM,CAACQ,aAAa,CAAEC,UAAU,CAAC,CAAC,EAAEH,UAAUI,OA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AAMC,SAAS,OAAOP,OAAO,CAACC,MAAML,IAAI,CAAC;YACzC,IAAIW,WAAWF,UAAU;gBACvB,MAAM,IAAInB,MACR,CAAC,WAAW,EAAEe,MAAML,IAAI,CAAC,MAAM,EAAEnD,QAAQ,WAAW,EAAE4D,SAAS,YAAY,EAAEJ,MAAMK,IAAI,CAAC,QAAQ,EAAEC,OAAO,CAAC,CAAC;YAE/G;QACF;IACF;AAsFF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevToolsPluginCliExtensionResults.ts"],"sourcesContent":["import { constants as bufferConstants } from 'node:buffer';\n\nimport type { DevToolsPluginOutput } from './DevToolsPlugin.schema';\nimport { DevToolsPluginOutputSchema } from './DevToolsPlugin.schema';\n\n// Cap accumulated output at V8's max single-string length to bound heap growth.\nconst MAX_OUTPUT_LENGTH = bufferConstants.MAX_STRING_LENGTH;\n\n/**\n * Class that collects and manages output from executed plugin commands\n *\n * Responsibilities:\n * - Collects output data from executed commands\n * - Parses and validates output data against expected schema\n * - Provides methods to append new output entries\n * - Handles exit codes and appends relevant messages\n * - Handles streaming of output via optional callback\n */\nexport class DevToolsPluginCliExtensionResults {\n constructor(private onOutput?: (output: DevToolsPluginOutput) => void) {}\n\n private _output: DevToolsPluginOutput = [];\n private _totalLength = 0;\n private _truncated = false;\n\n public append(output: string, level: 'info' | 'warning' | 'error' = 'info') {\n if (this._truncated) return;\n if (this._totalLength + output.length > MAX_OUTPUT_LENGTH) {\n this._truncated = true;\n const message = {\n type: 'text' as const,\n text: `Output truncated: plugin exceeded V8's max string length (${MAX_OUTPUT_LENGTH} chars). Reduce output, paginate, or write to a file.`,\n level: 'error' as const,\n };\n this._output.push(message);\n this.onOutput?.([message]);\n return;\n }\n this._totalLength += output.length;\n const results = this.parseOutputText(output, level);\n this._output.push(...results);\n this.onOutput?.(results);\n }\n\n public isTruncated(): boolean {\n return this._truncated;\n }\n\n public exit(code: number) {\n if (code === 0) return;\n this.append(`Process exited with code ${code}`, 'error');\n }\n\n public getOutput(): DevToolsPluginOutput {\n return this._output;\n }\n\n private parseOutputText(\n txt: string,\n level: 'info' | 'warning' | 'error' = 'info'\n ): DevToolsPluginOutput {\n // Validate against schema\n try {\n const result = DevToolsPluginOutputSchema.safeParse(JSON.parse(txt));\n if (!result.success) {\n return [\n {\n type: 'text',\n text: `Invalid JSON: ${result.error.issues.map((issue) => issue.message).join(', ')}`,\n level: 'error',\n },\n ];\n }\n return result.data;\n } catch {\n // Not JSON, treat as plain text\n const lines = txt.split('\\n');\n const results: DevToolsPluginOutput = [];\n for (const line of lines) {\n if (line) {\n results.push({ type: 'text', text: line, level });\n }\n }\n return results;\n }\n }\n}\n"],"names":["DevToolsPluginCliExtensionResults","MAX_OUTPUT_LENGTH","bufferConstants","MAX_STRING_LENGTH","onOutput","_output","_totalLength","_truncated","append","output","level","length","message","type","text","push","results","parseOutputText","isTruncated","exit","code","getOutput","txt","result","DevToolsPluginOutputSchema","safeParse","JSON","parse","success","error","issues","map","issue","join","data","lines","split","line"],"mappings":";;;;+BAkBaA;;;eAAAA;;;;yBAlBgC;;;;;;sCAGF;AAE3C,gFAAgF;AAChF,MAAMC,oBAAoBC,uBAAe,CAACC,iBAAiB;AAYpD,MAAMH;IACX,YAAY,AAAQI,QAAiD,CAAE;aAAnDA,WAAAA;aAEZC,UAAgC,EAAE;aAClCC,eAAe;aACfC,aAAa;IAJmD;IAMjEC,OAAOC,MAAc,EAAEC,QAAsC,MAAM,EAAE;QAC1E,IAAI,IAAI,CAACH,UAAU,EAAE;QACrB,IAAI,IAAI,CAACD,YAAY,GAAGG,OAAOE,MAAM,GAAGV,mBAAmB;YACzD,IAAI,CAACM,UAAU,GAAG;YAClB,MAAMK,UAAU;gBACdC,MAAM;gBACNC,MAAM,CAAC,0DAA0D,EAAEb,kBAAkB,qDAAqD,CAAC;gBAC3IS,OAAO;YACT;YACA,IAAI,CAACL,OAAO,CAACU,IAAI,CAACH;YAClB,IAAI,CA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,"sources":["../../../../src/start/server/DevToolsPluginManager.ts"],"sourcesContent":["import type { ModuleDescriptorDevTools } from 'expo-modules-autolinking/exports';\n\nimport { DevToolsPlugin } from './DevToolsPlugin';\nimport { events } from '../../events';\nimport { Log } from '../../log';\n\nconst debug = require('debug')('expo:start:server:devtools');\n\nexport const DevToolsPluginEndpoint = '/_expo/plugins';\n\nexport const event = events('expo', (t) => [\n t.event<\n 'dev-tools-plugin:load',\n {\n plugins: {\n packageName: string;\n bannerTitle: string;\n cliBanner: boolean;\n webpageEndpoint: string | undefined;\n }[];\n }\n >(),\n]);\n\nexport default class DevToolsPluginManager {\n private plugins: DevToolsPlugin[] | null = null;\n\n constructor(private projectRoot: string) {}\n\n public async queryPluginsAsync(): Promise<DevToolsPlugin[]> {\n if (!this.plugins) {\n this.plugins = await this.queryAutolinkedPluginsAsync(this.projectRoot);\n event('dev-tools-plugin:load', {\n plugins: this.plugins.map((plugin) => ({\n packageName: plugin.packageName,\n bannerTitle: plugin.bannerTitle,\n cliBanner: plugin.cliBanner,\n webpageEndpoint: plugin.webpageEndpoint,\n })),\n });\n }\n return this.plugins;\n }\n\n public async queryPluginAsync(pluginName: string): Promise<DevToolsPlugin | null> {\n const plugins = await this.queryPluginsAsync();\n return plugins.find((p) => p.packageName === pluginName) ?? null;\n }\n\n private async queryAutolinkedPluginsAsync(projectRoot: string): Promise<DevToolsPlugin[]> {\n const autolinking: typeof import('expo/internal/unstable-autolinking-exports') = require('expo/internal/unstable-autolinking-exports');\n const linker = autolinking.makeCachedDependenciesLinker({ projectRoot });\n const revisions = await autolinking.scanExpoModuleResolutionsForPlatform(linker, 'devtools');\n const { resolveModuleAsync } = autolinking.getLinkingImplementationForPlatform('devtools');\n const plugins: ModuleDescriptorDevTools[] = (\n await Promise.all(\n Object.values(revisions).map((revision) => resolveModuleAsync(revision.name, revision))\n )\n ).filter((maybePlugin) => maybePlugin != null);\n debug('Found autolinked plugins', plugins);\n return plugins\n .map((pluginInfo) => {\n try {\n return new DevToolsPlugin(pluginInfo, this.projectRoot);\n } catch (error: any) {\n Log.warn(\n `Skipping plugin \"${pluginInfo.packageName}\": ${error.message ?? 'invalid configuration'}`\n );\n debug('Plugin validation error for %s: %O', pluginInfo.packageName, error);\n return null;\n }\n })\n .filter((p) => p != null) as DevToolsPlugin[];\n }\n}\n"],"names":["DevToolsPluginEndpoint","DevToolsPluginManager","event","debug","require","events","t","projectRoot","plugins","queryPluginsAsync","queryAutolinkedPluginsAsync","map","plugin","packageName","bannerTitle","cliBanner","webpageEndpoint","queryPluginAsync","pluginName","find","p","autolinking","linker","makeCachedDependenciesLinker","revisions","scanExpoModuleResolutionsForPlatform","resolveModuleAsync","getLinkingImplementationForPlatform","Promise","all","Object","values","revision","name","filter","maybePlugin","pluginInfo","DevToolsPlugin","error","Log","warn","message"],"mappings":";;;;;;;;;;;QAQaA;eAAAA;;QAgBb;eAAqBC;;QAdRC;eAAAA;;;gCARkB;wBACR;qBACH;AAEpB,MAAMC,QAAQC,QAAQ,SAAS;AAExB,MAAMJ,yBAAyB;AAE/B,MAAME,QAAQG,IAAAA,cAAM,EAAC,QAAQ,CAACC,IAAM;QACzCA,EAAEJ,KAAK;KAWR;AAEc,MAAMD;IAGnB,YAAY,AAAQM,WAAmB,CAAE;aAArBA,cAAAA;aAFZC,UAAmC;IAED;IAE1C,MAAaC,oBAA+C;QAC1D,IAAI,CAAC,IAAI,CAACD,OAAO,EAAE;YACjB,IAAI,CAACA,OAAO,GAAG,MAAM,IAAI,CAACE,2BAA2B,CAAC,IAAI,CAACH,WAAW;YACtEL,MAAM,yBAAyB;gBAC7BM,SAAS,IAAI,CAACA,OAAO,CAACG,GAAG,CAAC,CAACC,SAAY,CAAA;wBACrCC,aAAaD,OAAOC,WAAW;wBAC/BC,aAAaF,OAAOE,WAAW;wBAC/BC,WAAWH,OAAOG,SAAS;wBAC3BC,iBAAiBJ,OAAOI,eAAe;oBACzC,CAAA;YACF;QACF;QACA,OAAO,IAAI,CAACR,OAAO;IACrB;IAEA,MAAaS,iBAAiBC,UAAkB,EAAkC;QAChF,MAAMV,UAAU,MAAM,IAAI,CAACC,iBAAiB;QAC5C,OAAOD,QAAQW,IAAI,CAAC,CAACC,IAAMA,EAAEP,WAAW,KAAKK,eAAe;IAC9D;IAEA,MAAcR,4BAA4BH,WAAmB,EAA6B;QACxF,MAAMc,cAA2EjB,QAAQ;QACzF,MAAMkB,SAASD,YAAYE,4BAA4B,CAAC;YAAEhB;QAAY;QACtE,MAAMiB,YAAY,MAAMH,YAAYI,oCAAoC,CAACH,QAAQ;QACjF,MAAM,EAAEI,kBAAkB,EAAE,GAAGL,YAAYM,mCAAmC,CAAC;QAC/E,MAAMnB,UAAsC,AAC1C,CAAA,MAAMoB,QAAQC,GAAG,CACfC,OAAOC,MAAM,CAACP,WAAWb,GAAG,CAAC,CAACqB,WAAaN,mBAAmBM,SAASC,IAAI,EAAED,WAC/E,EACAE,MAAM,CAAC,CAACC,cAAgBA,eAAe;QACzChC,MAAM,4BAA4BK;QAClC,OAAOA,QACJG,GAAG,CAAC,CAACyB;YACJ,IAAI;gBACF,OAAO,IAAIC,8BAAc,CAACD,YAAY,IAAI,CAAC7B,WAAW;YACxD,EAAE,OAAO+B,OAAY;gBACnBC,QAAG,CAACC,IAAI,CACN,CAAC,iBAAiB,EAAEJ,WAAWvB,WAAW,CAAC,GAAG,EAAEyB,MAAMG,OAAO,IAAI,yBAAyB;gBAE5FtC,MAAM,sCAAsCiC,WAAWvB,WAAW,EAAEyB;gBACpE,OAAO;YACT;QACF,GACCJ,MAAM,CAAC,CAACd,IAAMA,KAAK;IACxB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevToolsPluginServerHelpers.ts"],"sourcesContent":["import { loadModule } from '@expo/require-utils';\nimport type { IncomingMessage } from 'node:http';\nimport { type WebSocket, WebSocketServer } from 'ws';\n\nconst debug = require('debug')('expo:start:server:devtools') as typeof console.log;\n\n/**\n * Handler default-exported by a plugin's `serverEntryPoint`. Receives a fetch API `Request`\n * with the plugin endpoint prefix stripped from the URL. Returning `null`/`undefined` falls\n * through to static `webpageRoot` serving.\n */\nexport type DevToolsPluginRequestHandler = (\n request: Request\n) => Response | null | undefined | Promise<Response | null | undefined>;\n\n/**\n * Per-connection WebSocket handler exported by a plugin's `serverEntryPoint`. Receives the\n * connected `ws` socket, the upgrade `request`, and the `WebSocketServer` the connection belongs\n * to (use `server.clients` to broadcast). Mirrors the `ws` `'connection'` event so plugin authors\n * use the familiar `socket.on('message', ...)` / `socket.send(...)` API.\n */\nexport type DevToolsPluginWebSocketHandler = (\n socket: WebSocket,\n request: Request,\n server: WebSocketServer\n) => void;\n\nfunction convertUpgradeRequest(request: IncomingMessage, route: string): Request {\n const proto = 'encrypted' in request.socket && !!request.socket.encrypted ? 'https' : 'http';\n const origin = `${proto}://${request.headers.host}`;\n const url = new URL(request.url ?? '/', origin);\n url.pathname = route;\n const headers = new Headers();\n const { rawHeaders } = request;\n for (let index = 0; index < rawHeaders.length; index += 2) {\n const name = rawHeaders[index];\n const value = rawHeaders[index + 1];\n if (name != null && value != null) {\n headers.append(name, value);\n }\n }\n return new Request(url.href, { method: request.method, headers });\n}\n\nexport async function loadRequestHandlerAsync({\n packageName,\n serverEntryPoint,\n}: {\n packageName: string;\n serverEntryPoint: string;\n}): Promise<DevToolsPluginRequestHandler> {\n debug('Loading DevTools plugin server module: %s', serverEntryPoint);\n const serverModule = (await loadModule(serverEntryPoint)) as\n | DevToolsPluginRequestHandler\n | { default?: DevToolsPluginRequestHandler };\n const handler = typeof serverModule === 'function' ? serverModule : serverModule?.default;\n if (typeof handler !== 'function') {\n throw new Error(\n `The serverEntryPoint (${serverEntryPoint}) of plugin ${packageName} ` +\n `must default-export a handler function that takes a Request and returns a Response. ` +\n `Export it as \\`export default function handler(request) {}\\` ` +\n `or \\`exports.default = function handler(request) {}\\`.`\n );\n }\n return handler;\n}\n\nexport async function loadWebSocketServerAsync({\n packageName,\n serverEntryPoint,\n}: {\n packageName: string;\n serverEntryPoint: string;\n}): Promise<Record<string, WebSocketServer>> {\n debug('Loading DevTools plugin WebSocket server module: %s', serverEntryPoint);\n const serverModule = (await loadModule(serverEntryPoint)) as {\n webSocketHandlers?: Record<string, DevToolsPluginWebSocketHandler>;\n };\n const handlers: Record<string, DevToolsPluginWebSocketHandler> =\n serverModule?.webSocketHandlers ?? {};\n\n return Object.fromEntries(\n Object.entries(handlers).map(([route, handler]) => {\n if (typeof handler !== 'function') {\n throw new Error(\n `The webSocketHandlers[\"${route}\"] export of plugin ${packageName} ` +\n `must be a function (socket, request, server) => void.`\n );\n }\n // Routes are mounted relative to the plugin endpoint, so they must be absolute.\n const normalizedRoute = route.startsWith('/') ? route : `/${route}`;\n const server = new WebSocketServer({ noServer: true });\n server.on('connection', (socket, request) =>\n handler(socket, convertUpgradeRequest(request, normalizedRoute), server)\n );\n return [normalizedRoute, server];\n })\n );\n}\n"],"names":["loadRequestHandlerAsync","loadWebSocketServerAsync","debug","require","convertUpgradeRequest","request","route","proto","socket","encrypted","origin","headers","host","url","URL","pathname","Headers","rawHeaders","index","length","name","value","append","Request","href","method","packageName","serverEntryPoint","serverModule","loadModule","handler","default","Error","handlers","webSocketHandlers","Object","fromEntries","entries","map","normalizedRoute","startsWith","server","WebSocketServer","noServer","on"],"mappings":";;;;;;;;;;;QA4CsBA;eAAAA;;QAuBAC;eAAAA;;;;yBAnEK;;;;;;;yBAEqB;;;;;;AAEhD,MAAMC,QAAQC,QAAQ,SAAS;AAuB/B,SAASC,sBAAsBC,OAAwB,EAAEC,KAAa;IACpE,MAAMC,QAAQ,eAAeF,QAAQG,MAAM,IAAI,CAAC,CAACH,QAAQG,MAAM,CAACC,SAAS,GAAG,UAAU;IACtF,MAAMC,SAAS,GAAGH,MAAM,GAAG,EAAEF,QAAQM,OAAO,CAACC,IAAI,EAAE;IACnD,MAAMC,MAAM,IAAIC,IAAIT,QAAQQ,GAAG,IAAI,KAAKH;IACxCG,I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oBAAoB,EAAEoB,YAAY,CAAC,CAAC,GAClE,CAAC,qDAAqD,CAAC;QAE7D;QACA,gFAAgF;QAChF,MAAMa,kBAAkBjC,MAAMkC,UAAU,CAAC,OAAOlC,QAAQ,CAAC,CAAC,EAAEA,OAAO;QACnE,MAAMmC,SAAS,IAAIC,CAAAA,KAAc,iBAAC,CAAC;YAAEC,UAAU;QAAK;QACpDF,OAAOG,EAAE,CAAC,cAAc,CAACpC,QAAQH,UAC/ByB,QAAQtB,QAAQJ,sBAAsBC,SAASkC,kBAAkBE;QAEnE,OAAO;YAACF;YAAiBE;SAAO;IAClC;AAEJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/MCP.ts"],"sourcesContent":["import type {\n McpServerProxy,\n TunnelMcpServerProxy as TunnelMcpServerProxyType,\n} from '@expo/mcp-tunnel' with { 'resolution-mode': 'import' };\nimport { loadModule } from '@expo/require-utils';\nimport path from 'node:path';\nimport resolveFrom from 'resolve-from';\n\nimport { getAccessToken, getSession } from '../../api/user/UserSettings';\nimport { Log } from '../../log';\nimport { env } from '../../utils/env';\nimport { installExitHooks } from '../../utils/exit';\n\nconst debug = require('debug')('expo:start:server:mcp') as typeof console.log;\n\n/**\n * The MCP server\n */\nexport type McpServer = Omit<McpServerProxy, 'close'> & {\n /**\n * Close the server\n */\n closeAsync: () => Promise<void>;\n};\n\n/**\n * Create the MCP server\n */\nexport async function maybeCreateMCPServerAsync({\n projectRoot,\n devServerUrl,\n}: {\n projectRoot: string;\n devServerUrl: string;\n}): Promise<McpServer | null> {\n const mcpServer = env.EXPO_UNSTABLE_MCP_SERVER;\n if (!mcpServer) {\n return null;\n }\n const mcpPackagePath = resolveFrom.silent(projectRoot, 'expo-mcp');\n if (!mcpPackagePath) {\n Log.error(\n 'Missing the `expo-mcp` package in the project. To enable the MCP integration, add the `expo-mcp` package to your project.'\n );\n return null;\n }\n const mcpTunnelPackagePath = resolveFrom.silent(path.dirname(mcpPackagePath), '@expo/mcp-tunnel');\n if (!mcpTunnelPackagePath) {\n Log.error('Unable to resolve the `@expo/mcp-tunnel` package');\n return null;\n }\n\n const normalizedServer = /^([a-zA-Z][a-zA-Z\\d+\\-.]*):\\/\\//.test(mcpServer)\n ? mcpServer\n : `wss://${mcpServer}`;\n const mcpServerUrlObject = new URL(normalizedServer);\n const scheme = mcpServerUrlObject.protocol ?? 'wss:';\n const mcpServerUrl = `${scheme}//${mcpServerUrlObject.host}`;\n debug(`Creating MCP tunnel - server URL: ${mcpServerUrl}`);\n\n try {\n debug(`Loading MCP modules: expo-mcp=${mcpPackagePath}, mcp-tunnel=${mcpTunnelPackagePath}`);\n const { addMcpCapabilities } = (await loadModule(mcpPackagePath)) as {\n addMcpCapabilities: (server: McpServerProxy, projectRoot: string) => void;\n };\n const { TunnelMcpServerProxy } = (await loadModule(mcpTunnelPackagePath)) as {\n TunnelMcpServerProxy: typeof TunnelMcpServerProxyType;\n };\n\n const logger = {\n ...Log,\n debug(...message: any[]): void {\n debug(...message);\n },\n info(...message: any[]): void {\n Log.log(...message);\n },\n };\n const serverProxy: McpServerProxy = new TunnelMcpServerProxy(mcpServerUrl, {\n logger,\n wsHeaders: createAuthHeaders(),\n projectRoot,\n devServerUrl,\n });\n addMcpCapabilities(serverProxy, projectRoot);\n\n const removeExitHook = installExitHooks(async () => {\n await serverProxy.close();\n });\n const server = serverProxy as unknown as McpServer;\n server.closeAsync = async () => {\n removeExitHook();\n await serverProxy.close();\n };\n\n return server;\n } catch (error: unknown) {\n debug(`Error creating MCP tunnel: ${error}`);\n }\n return null;\n}\n\nfunction createAuthHeaders(): Record<string, string> {\n const token = getAccessToken();\n if (token) {\n return {\n authorization: `Bearer ${token}`,\n };\n }\n const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n return {\n 'expo-session': sessionSecret,\n };\n }\n return {};\n}\n"],"names":["maybeCreateMCPServerAsync","debug","require","projectRoot","devServerUrl","mcpServer","env","EXPO_UNSTABLE_MCP_SERVER","mcpPackagePath","resolveFrom","silent","Log","error","mcpTunnelPackagePath","path","dirname","normalizedServer","test","mcpServerUrlObject","URL","scheme","protocol","mcpServerUrl","host","addMcpCapabilities","loadModule","TunnelMcpServerProxy","logger","message","info","log","serverProxy","wsHeaders","createAuthHeaders","removeExitHook","installExitHooks","close","server","closeAsync","getSession","token","getAccessToken","authorization","sessionSecret"],"mappings":";;;;+BA4BsBA;;;eAAAA;;;;yBAxBK;;;;;;;gEACV;;;;;;;gEACO;;;;;;8BAEmB;qBACvB;qBACA;sBACa;;;;;;AAEjC,MAAMC,QAAQC,QAAQ,SAAS;AAexB,eAAeF,0BAA0B,EAC9CG,WAAW,EACXC,YAAY,EAIb;IACC,MAAMC,YAAYC,QAAG,CAACC,wBAAwB;IAC9C,IAAI,CAACF,WAAW;QACd,OAAO;IACT;IACA,MAAMG,iBAAiBC,sBAAW,CAACC,MAAM,CAACP,aAAa;IACvD,IAAI,CAACK,gBAAgB;QACnBG,QAAG,CAACC,KAAK,CACP;QAEF,OAAO;IACT;IACA,MAAMC,uBAAuBJ,sBAAW,CAACC,MAAM,CAACI,mBAAI,CAACC,OAAO,CAACP,iBAAiB;IAC9E,IAAI,CAACK,sBAAsB;QACzBF,QAAG,CAACC,KAAK,CAAC;QACV,OAAO;IACT;IAEA,MAAMI,mBAAmB,kCAAkCC,IAAI,CAACZ,aAC5DA,YACA,CAAC,MAAM,EAAEA,WAAW;IACxB,MAAMa,qBAAqB,IAAIC,IAAIH;IACnC,MAAMI,SAASF,mBAAmBG,QAAQ,IAAI;IAC9C,MAAMC,eAAe,GAAGF,OAAO,EAAE,EAAEF,mBAAmBK,IAAI,EAAE;IAC5DtB,MAAM,CAAC,kCAAkC,EAAEqB,cAAc;IAEzD,IAAI;QACFrB,MAAM,CAAC,8BAA8B,EAAEO,eAAe,aAAa,EAAEK,sBAAsB;QAC3F,MAAM,EAAEW,kBAAkB,EAAE,GAAI,MAAMC,IAAAA,0BAAU,EAACjB;QAGjD,MAAM,EAAEkB,oBAAoB,EAAE,GAAI,MAAMD,IAAAA,0BAAU,EAACZ;QAInD,MAAMc,SAAS;YACb,GAAGhB,QAAG;YACNV,OAAM,GAAG2B,OAAc;gBACrB3B,SAAS2B;YACX;YACAC,MAAK,GAAGD,OAAc;gBACpBjB,QAAG,CAACmB,GAAG,IAAIF;YACb;QACF;QACA,MAAMG,cAA8B,IAAIL,qBAAqBJ,cAAc;YACzEK;YACAK,WAAWC;YACX9B;YACAC;QACF;QACAoB,mBAAmBO,aAAa5B;QAEhC,MAAM+B,iBAAiBC,IAAAA,sBAAgB,EAAC;YACtC,MAAMJ,YAAYK,KAAK;QACzB;QACA,MAAMC,SAASN;QACfM,OAAOC,UAAU,GAAG;YAClBJ;YACA,MAAMH,YAAYK,KAAK;QACzB;QAEA,OAAOC;IACT,EAAE,OAAOzB,OAAgB;QACvBX,MAAM,CAAC,2BAA2B,EAAEW,OAAO;IAC7C;IACA,OAAO;AACT;AAEA,SAASqB;QAOeM;IANtB,MAAMC,QAAQC,IAAAA,4BAAc;IAC5B,IAAID,OAAO;QACT,OAAO;YACLE,eAAe,CAAC,OAAO,EAAEF,OAAO;QAClC;IACF;IACA,MAAMG,iBAAgBJ,cAAAA,IAAAA,wBAAU,wBAAVA,YAAcI,aAAa;IACjD,IAAIA,eAAe;QACjB,OAAO;YACL,gBAAgBA;QAClB;IACF;IACA,OAAO,CAAC;AACV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/MCPDevToolsPluginCLIExtensions.ts"],"sourcesContent":["import type { DevServerManager } from './DevServerManager';\nimport type { DevToolsPluginInfo } from './DevToolsPlugin.schema';\nimport { DevToolsPluginOutputSchema } from './DevToolsPlugin.schema';\nimport { DevToolsPluginCliExtensionExecutor } from './DevToolsPluginCliExtensionExecutor';\nimport type { McpServer } from './MCP';\nimport { createMCPDevToolsExtensionSchema } from './createMCPDevToolsExtensionSchema';\nimport { Log } from '../../log';\n\nconst debug = require('debug')('expo:start:server:devtools:mcp');\n\nexport async function addMcpCapabilities(mcpServer: McpServer, devServerManager: DevServerManager) {\n const plugins = await devServerManager.devtoolsPluginManager.queryPluginsAsync();\n\n for (const plugin of plugins) {\n if (plugin.cliExtensions) {\n const mcpCommands = (plugin.cliExtensions.commands ?? []).filter((p) =>\n p.environments?.includes('mcp')\n );\n if (mcpCommands.length === 0) {\n continue;\n }\n\n // Build an MCP-scoped descriptor so the schema enum and the executor's\n // existence check both reject commands that were not declared MCP-enabled.\n const mcpPlugin: DevToolsPluginInfo = {\n packageName: plugin.packageName,\n packageRoot: plugin.packageRoot,\n cliExtensions: {\n ...plugin.cliExtensions,\n commands: mcpCommands,\n },\n };\n\n const schema = createMCPDevToolsExtensionSchema(mcpPlugin);\n\n debug(\n `Installing MCP CLI extension for plugin: ${plugin.packageName} - found ${mcpCommands.length} commands`\n );\n\n mcpServer.registerTool(\n plugin.packageName,\n {\n title: plugin.packageName,\n description: plugin.description,\n inputSchema: { parameters: schema },\n },\n async ({ parameters }) => {\n try {\n const { command, ...args } = parameters;\n\n const metroServerOrigin = devServerManager\n .getDefaultDevServer()\n .getJsInspectorBaseUrl();\n\n const results = await new DevToolsPluginCliExtensionExecutor(\n mcpPlugin,\n devServerManager.projectRoot\n ).execute({ command, args, metroServerOrigin });\n\n const parsedResults = DevToolsPluginOutputSchema.safeParse(results);\n if (parsedResults.success === false) {\n throw new Error(\n `Invalid output from CLI command: ${parsedResults.error.issues\n .map((issue) => issue.message)\n .join(', ')}`\n );\n }\n return {\n content: parsedResults.data\n .map((line) => {\n const { type } = line;\n if (type === 'text') {\n return { type, text: line.text, level: line.level, url: line.url };\n } else if (line.type === 'image' || line.type === 'audio') {\n // We could present this as a resource_link, but it seems not to be well supported in MCP clients,\n // so we'll return a text with the link instead.\n return {\n type: 'text',\n text: `${type} resource: ${line.url}${line.text ? ' (' + line.text + ')' : ''}`,\n } as const;\n }\n return null;\n })\n .filter((line): line is Exclude<typeof line, null> => line !== null),\n };\n } catch (e: any) {\n Log.error('Error executing MCP CLI command:', e);\n return {\n content: [{ type: 'text', text: `Error executing command: ${e.toString()}` }],\n isError: true,\n };\n }\n }\n );\n }\n }\n}\n"],"names":["addMcpCapabilities","debug","require","mcpServer","devServerManager","plugins","devtoolsPluginManager","queryPluginsAsync","plugin","cliExtensions","mcpCommands","commands","filter","p","environments","includes","length","mcpPlugin","packageName","packageRoot","schema","createMCPDevToolsExtensionSchema","registerTool","title","description","inputSchema","parameters","command","args","metroServerOrigin","getDefaultDevServer","getJsInspectorBaseUrl","results","DevToolsPluginCliExtensionExecutor","projectRoot","execute","parsedResults","DevToolsPluginOutputSchema","safeParse","success","Error","error","issues","map","issue","message","join","content","data","line","type","text","level","url","e","Log","toString","isError"],"mappings":";;;;+BAUsBA;;;eAAAA;;;sCARqB;oDACQ;kDAEF;qBAC7B;AAEpB,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,mBAAmBG,SAAoB,EAAEC,gBAAkC;IAC/F,MAAMC,UAAU,MAAMD,iBAAiBE,qBAAqB,CAACC,iBAAiB;IAE9E,KAAK,MAAMC,UAAUH,QAAS;QAC5B,IAAIG,OAAOC,aAAa,EAAE;YACxB,MAAMC,cAAc,AAACF,CAAAA,OAAOC,aAAa,CAACE,QAAQ,IAAI,EAAE,AAAD,EAAGC,MAAM,CAAC,CAACC;oBAChEA;wBAAAA,kBAAAA,EAAEC,YAAY,qBAAdD,gBAAgBE,QAAQ,CAAC;;YAE3B,IAAIL,YAAYM,MAAM,KAAK,GAAG;gBAC5B;YACF;YAEA,uEAAuE;YACvE,2EAA2E;YAC3E,MAAMC,YAAgC;gBACpCC,aAAaV,OAAOU,WAAW;gBAC/BC,aAAaX,OAAOW,WAAW;gBAC/BV,eAAe;oBACb,GAAGD,OAAOC,aAAa;oBACvBE,UAAUD;gBACZ;YACF;YAEA,MAAMU,SAASC,IAAAA,kEAAgC,EAACJ;YAEhDhB,MACE,CAAC,yCAAyC,EAAEO,OAAOU,WAA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jF;4BACF;4BACA,OAAO;wBACT,GACCvC,MAAM,CAAC,CAACqC,OAA6CA,SAAS;oBACnE;gBACF,EAAE,OAAOK,GAAQ;oBACfC,QAAG,CAACd,KAAK,CAAC,oCAAoCa;oBAC9C,OAAO;wBACLP,SAAS;4BAAC;gCAAEG,MAAM;gCAAQC,MAAM,CAAC,yBAAyB,EAAEG,EAAEE,QAAQ,IAAI;4BAAC;yBAAE;wBAC7EC,SAAS;oBACX;gBACF;YACF;QAEJ;IACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/createMCPDevToolsExtensionSchema.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport type { DevToolsPluginCommandParameter, DevToolsPluginInfo } from './DevToolsPlugin.schema';\n\n/**\n * Creates an MCP-compatible JSON schema for a DevTools plugin's CLI extensions.\n *\n * LLM agents have varying support for complex JSON schema features like `anyOf`/`oneOf`\n * discriminated unions. This implementation uses a flat schema with an enum for the\n * command name, which provides the best compatibility across different LLM providers:\n *\n * - OpenAI: Supports `anyOf` but requires `additionalProperties: false` and all fields `required`\n * - Claude/Anthropic: Works best with simple flat schemas with enums\n * - Other providers: Generally have limited or inconsistent support for discriminated unions\n *\n * To compensate for the lack of discriminated unions, parameter descriptions include\n * which command(s) they belong to, and command descriptions include their parameters.\n *\n * The resulting schema structure is:\n * ```json\n * {\n * \"type\": \"object\",\n * \"properties\": {\n * \"command\": {\n * \"type\": \"string\",\n * \"enum\": [\"cmd1\", \"cmd2\", ...],\n * \"description\": \"The command to execute. Available commands: \\\"cmd1\\\" - Title 1 (params: foo); ...\"\n * },\n * \"foo\": { \"type\": \"string\", \"description\": \"Foo description (Used by: \\\"cmd1\\\")\" },\n * ...\n * },\n * \"required\": [\"command\"],\n * \"additionalProperties\": false\n * }\n * ```\n */\nexport function createMCPDevToolsExtensionSchema(plugin: DevToolsPluginInfo) {\n if (plugin.cliExtensions == null || plugin.cliExtensions?.commands.length === 0) {\n throw new Error(\n `Plugin ${plugin.packageName} has no commands defined. Please define at least one command.`\n );\n }\n\n const commands = plugin.cliExtensions.commands;\n\n // Build a rich description that explains each command and its parameters\n const commandDescriptions = commands\n .map((c) => {\n const params = c.parameters?.map((p) => p.name).join(', ');\n return params ? `\"${c.name}\": ${c.title} (params: ${params})` : `\"${c.name}\": ${c.title}`;\n })\n .join('. ');\n\n // Create enum of command names for clear LLM selection\n const commandNames = commands.map((c) => c.name) as [string, ...string[]];\n\n // Collect all unique parameters across all commands\n // Track which commands use each parameter for documentation\n const parameterCommandMap: Record<string, string[]> = {};\n const parameterDescriptions: Record<string, string> = {};\n const parameterTypes: Record<string, DevToolsPluginCommandParameter['type']> = {};\n\n for (const command of commands) {\n if (command.parameters && command.parameters.length > 0) {\n for (const param of command.parameters) {\n let commands = parameterCommandMap[param.name];\n if (!commands) {\n commands = [];\n parameterCommandMap[param.name] = commands;\n parameterDescriptions[param.name] = param.description || '';\n parameterTypes[param.name] = param.type;\n }\n commands.push(command.name);\n }\n }\n }\n\n // Build parameters with descriptions that indicate which command(s) they belong to\n const allParameters: Record<string, z.ZodTypeAny> = {};\n for (const [paramName, commandList] of Object.entries(parameterCommandMap)) {\n const baseDescription = parameterDescriptions[paramName];\n const commandsUsingParam =\n commandList.length === commands.length\n ? 'all commands'\n : commandList.map((c) => `\"${c}\"`).join(', ');\n\n // Include command context in the description so LLMs know when to use each parameter\n const fullDescription = baseDescription\n ? `${baseDescription} (Used by: ${commandsUsingParam})`\n : `Parameter for: ${commandsUsingParam}`;\n\n allParameters[paramName] = paramTypeToZod(parameterTypes[paramName]!)\n .optional()\n .describe(fullDescription);\n }\n\n // Build the command description with clear instructions for the LLM\n const hasParameters = Object.keys(allParameters).length > 0;\n const commandDescription = hasParameters\n ? `Required. The command to execute. You must select exactly one command from the enum values. ` +\n `Each command may require specific parameters - only include parameters that belong to the selected command. ` +\n `Commands: ${commandDescriptions}.`\n : `Required. The command to execute. Select exactly one from the available options. ` +\n `Commands: ${commandDescriptions}.`;\n\n // Build the flat schema with additionalProperties: false for LLM compatibility\n const schema = z\n .object({\n command: z.enum(commandNames).describe(commandDescription),\n ...allParameters,\n })\n .strict(); // .strict() adds additionalProperties: false\n\n return schema;\n}\n\nfunction paramTypeToZod(type: DevToolsPluginCommandParameter['type']) {\n switch (type) {\n case 'number':\n return z.number();\n case 'confirm':\n return z.boolean();\n case 'text':\n return z.string();\n }\n}\n"],"names":["createMCPDevToolsExtensionSchema","plugin","cliExtensions","commands","length","Error","packageName","commandDescriptions","map","c","params","parameters","p","name","join","title","commandNames","parameterCommandMap","parameterDescriptions","parameterTypes","command","param","description","type","push","allParameters","paramName","commandList","Object","entries","baseDescription","commandsUsingParam","fullDescription","paramTypeToZod","optional","describe","hasParameters","keys","commandDescription","schema","z","object","enum","strict","number","boolean","string"],"mappings":";;;;+BAoCgBA;;;eAAAA;;;;yBApCE;;;;;;AAoCX,SAASA,iCAAiCC,MAA0B;QACrCA;IAApC,IAAIA,OAAOC,aAAa,IAAI,QAAQD,EAAAA,wBAAAA,OAAOC,aAAa,qBAApBD,sBAAsBE,QAAQ,CAACC,MAAM,MAAK,GAAG;QAC/E,MAAM,IAAIC,MACR,CAAC,OAAO,EAAEJ,OAAOK,WAAW,CAAC,6DAA6D,CAAC;IAE/F;IAEA,MAAMH,WAAWF,OAAOC,aAAa,CAACC,QAAQ;IAE9C,yEAAyE;IACzE,MAAMI,sBAAsBJ,SACzBK,GAAG,CAAC,CAACC;YACWA;QAAf,MAAMC,UAASD,gBAAAA,EAAEE,UAAU,qBAAZF,cAAcD,GAAG,CAAC,CAACI,IAAMA,EAAEC,IAAI,EAAEC,IAAI,CAAC;QACrD,OAAOJ,SAAS,CAAC,CAAC,EAAED,EAAEI,IAAI,CAAC,GAAG,EAAEJ,EAAEM,KAAK,CAAC,UAAU,EAAEL,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,EAAED,EAAEI,IAAI,CAAC,GAAG,EAAEJ,EAAEM,KAAK,EAAE;IAC3F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