@expo/cli 57.0.32 → 57.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +1 -1
- package/build/src/events/index.js +1 -1
- package/build/src/export/compileHermesArtifacts.js +28 -0
- package/build/src/export/compileHermesArtifacts.js.map +1 -0
- package/build/src/export/embed/exportEmbedAsync.js +4 -0
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/exportApp.js +9 -5
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportDomComponents.js +5 -11
- package/build/src/export/exportDomComponents.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +3 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +3 -2
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/ios/appleDevice/ClientManager.js +11 -6
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +12 -4
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/start/interface/cliExtensionMenuItemHandler.js.map +1 -1
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/createDevToolsMenuItems.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +6 -1
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/ios/devicectl.js +2 -5
- package/build/src/start/platforms/ios/devicectl.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +6 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +1 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +10 -4
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/{DevToolsPlugin.js → devtools/DevToolsPlugin.js} +14 -5
- package/build/src/start/server/devtools/DevToolsPlugin.js.map +1 -0
- package/build/src/start/server/devtools/DevToolsPlugin.schema.js +195 -0
- package/build/src/start/server/devtools/DevToolsPlugin.schema.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginCliExtensionExecutor.js → devtools/DevToolsPluginCliExtensionExecutor.js} +1 -1
- package/build/src/start/server/devtools/DevToolsPluginCliExtensionExecutor.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginCliExtensionResults.js → devtools/DevToolsPluginCliExtensionResults.js} +24 -12
- package/build/src/start/server/devtools/DevToolsPluginCliExtensionResults.js.map +1 -0
- package/build/src/start/server/{DevToolsPluginManager.js → devtools/DevToolsPluginManager.js} +2 -2
- package/build/src/start/server/devtools/DevToolsPluginManager.js.map +1 -0
- package/build/src/start/server/devtools/DevToolsPluginServerHelpers.js.map +1 -0
- package/build/src/start/server/{MCP.js → mcp/MCP.js} +25 -15
- package/build/src/start/server/mcp/MCP.js.map +1 -0
- package/build/src/start/server/{MCPDevToolsPluginCLIExtensions.js → mcp/MCPDevToolsPluginCLIExtensions.js} +14 -27
- package/build/src/start/server/mcp/MCPDevToolsPluginCLIExtensions.js.map +1 -0
- package/build/src/start/server/{createMCPDevToolsExtensionSchema.js → mcp/createMCPDevToolsExtensionSchema.js} +8 -15
- package/build/src/start/server/mcp/createMCPDevToolsExtensionSchema.js.map +1 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js +2 -4
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +6 -2
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +4 -1
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/openHandlers.js +2 -6
- package/build/src/start/server/middleware/openHandlers.js.map +1 -1
- package/build/src/start/startAsync.js +2 -4
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/obj.js +1 -1
- package/build/src/utils/obj.js.map +1 -1
- package/build/src/utils/open.js +47 -31
- package/build/src/utils/open.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +26 -22
- package/build/src/start/server/DevToolsPlugin.js.map +0 -1
- package/build/src/start/server/DevToolsPlugin.schema.js +0 -84
- package/build/src/start/server/DevToolsPlugin.schema.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionExecutor.js.map +0 -1
- package/build/src/start/server/DevToolsPluginCliExtensionResults.js.map +0 -1
- package/build/src/start/server/DevToolsPluginManager.js.map +0 -1
- package/build/src/start/server/DevToolsPluginServerHelpers.js.map +0 -1
- package/build/src/start/server/MCP.js.map +0 -1
- package/build/src/start/server/MCPDevToolsPluginCLIExtensions.js.map +0 -1
- package/build/src/start/server/createMCPDevToolsExtensionSchema.js.map +0 -1
- /package/build/src/start/server/{DevToolsPluginServerHelpers.js → devtools/DevToolsPluginServerHelpers.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import { getOriginalEnvValue } from '@expo/env';\nimport assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport type { GatewayInfo } from '../../utils/ip';\nimport { getGateway, getGatewayAsync } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\n\ninterface BundlerInfo {\n port: number;\n getTunnelUrl?(): string | null;\n}\n\nexport class UrlCreator {\n constructor(\n public defaults: CreateURLOptions,\n private bundlerInfo: BundlerInfo,\n private gatewayInfo: GatewayInfo = getGateway()\n ) {}\n\n static async init(defaults: CreateURLOptions | undefined | null, bundlerInfo: BundlerInfo) {\n const gatewayInfo = await getGatewayAsync();\n return new UrlCreator(defaults || {}, bundlerInfo, gatewayInfo);\n }\n\n /**\n * Return a URL for the \"loading\" interstitial page that is used to disambiguate which\n * native runtime to open the dev server with.\n *\n * @param options options for creating the URL\n * @param platform when opening the URL from the CLI to a connected device we can specify the platform as a query parameter, otherwise it will be inferred from the unsafe user agent sniffing.\n *\n * @returns URL like `http://localhost:8081/_expo/loading?platform=ios`\n * @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string | null): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n if (platform) {\n url.search = new URLSearchParams({ platform }).toString();\n }\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase()) ||\n // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs\n protocol.includes('_')\n ) {\n debug(`Invalid protocol for dev client URL: ${protocol}`);\n return null;\n }\n\n const manifestUrl = this.constructUrl({\n ...options,\n scheme: this.defaults?.hostType === 'tunnel' ? 'https' : 'http',\n });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n public getDefaultRouteAddress(): string {\n return this.gatewayInfo.address;\n }\n\n /** URL scheme configured for development-build deep links (e.g. `myapp`). `null` when unset. */\n public getScheme(): string | null {\n return this.defaults?.scheme ?? null;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options, this.gatewayInfo),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nconst getDefaultHostname = (options: CreateURLOptions, gateway: GatewayInfo) => {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // NOTE: We always convert \"localhost\" as a request to 127.0.0.1,\n // to normalize to an address that's consistent\n return '127.0.0.1';\n } else {\n // Fall back to local address\n return options.hostname || gateway.address;\n }\n};\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n const validProtocol = protocol ? `${protocol}://` : '';\n\n const url = `${validProtocol}${hostname}`;\n\n if (port) {\n return url + `:${port}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n // Read from the pre-dotenv env — overriding this would redirect connected dev\n // clients through an attacker-controlled URL.\n return getOriginalEnvValue('EXPO_PACKAGER_PROXY_URL');\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["UrlCreator","debug","require","defaults","bundlerInfo","gatewayInfo","getGateway","init","getGatewayAsync","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","hostType","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getDefaultRouteAddress","address","getScheme","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","components","Log","warn","getDefaultHostname","parsedProxyUrl","gateway","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","assert","validProtocol","getOriginalEnvValue"],"mappings":";;;;+BA8BaA;;;eAAAA;;;;yBA9BuB;;;;;;;gEACjB;;;;;;;yBACC;;;;;;6DAEC;oBAEuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5C,MAAMC,QAAQC,QAAQ,SAAS;AAsBxB,MAAMF;IACX,YACE,AAAOG,QAA0B,EACj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B,MAAM,CAAC,CAAC,EAAE0B,MAAM;IACzB;IAEA,OAAO1B;AACT;AAEA,gBAAgB,GAChB,SAAS6B;IACP,8EAA8E;IAC9E,8CAA8C;IAC9C,OAAOc,IAAAA,0BAAmB,EAAC;AAC7B,EAEA,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import { getOriginalEnvValue } from '@expo/env';\nimport assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport type { GatewayInfo } from '../../utils/ip';\nimport { getGateway, getGatewayAsync } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\n\ninterface BundlerInfo {\n port: number;\n getTunnelUrl?(): string | null;\n}\n\nexport class UrlCreator {\n constructor(\n public defaults: CreateURLOptions,\n private bundlerInfo: BundlerInfo,\n private gatewayInfo: GatewayInfo = getGateway()\n ) {}\n\n static async init(defaults: CreateURLOptions | undefined | null, bundlerInfo: BundlerInfo) {\n const gatewayInfo = await getGatewayAsync();\n return new UrlCreator(defaults || {}, bundlerInfo, gatewayInfo);\n }\n\n /**\n * Return a URL for the \"loading\" interstitial page that is used to disambiguate which\n * native runtime to open the dev server with.\n *\n * @param options options for creating the URL\n * @param platform when opening the URL from the CLI to a connected device we can specify the platform as a query parameter, otherwise it will be inferred from the unsafe user agent sniffing.\n *\n * @returns URL like `http://localhost:8081/_expo/loading?platform=ios`\n * @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string | null): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n if (platform) {\n url.search = new URLSearchParams({ platform }).toString();\n }\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase()) ||\n // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs\n protocol.includes('_')\n ) {\n debug(`Invalid protocol for dev client URL: ${protocol}`);\n return null;\n }\n\n const manifestUrl = this.constructUrl({\n ...options,\n scheme: 'http',\n });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a URL for launching in Expo Go, e.g. `exp://192.168.1.10:8081`. */\n public constructExpoGoUrl(options?: Partial<CreateURLOptions> | null): string {\n return this.constructUrl({ ...options, scheme: 'http' }).replace(/^http/, 'exp');\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n public getDefaultRouteAddress(): string {\n return this.gatewayInfo.address;\n }\n\n /** URL scheme configured for development-build deep links (e.g. `myapp`). `null` when unset. */\n public getScheme(): string | null {\n return this.defaults?.scheme ?? null;\n }\n\n /** Get the URL components from the tunnel URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol:\n parsed.protocol === 'https:' && (options.scheme == null || options.scheme === 'http')\n ? 'https'\n : (options.scheme ?? 'http'),\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options, this.gatewayInfo),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nconst getDefaultHostname = (options: CreateURLOptions, gateway: GatewayInfo) => {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // NOTE: We always convert \"localhost\" as a request to 127.0.0.1,\n // to normalize to an address that's consistent\n return '127.0.0.1';\n } else {\n // Fall back to local address\n return options.hostname || gateway.address;\n }\n};\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n const validProtocol = protocol ? `${protocol}://` : '';\n\n const url = `${validProtocol}${hostname}`;\n\n if (port) {\n return url + `:${port}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n // Read from the pre-dotenv env — overriding this would redirect connected dev\n // clients through an attacker-controlled URL.\n return getOriginalEnvValue('EXPO_PACKAGER_PROXY_URL');\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["UrlCreator","debug","require","defaults","bundlerInfo","gatewayInfo","getGateway","init","getGatewayAsync","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","devClientUrl","encodeURIComponent","constructExpoGoUrl","replace","urlComponents","getUrlComponents","joinUrlComponents","getDefaultRouteAddress","address","getScheme","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","hostType","components","Log","warn","getDefaultHostname","parsedProxyUrl","gateway","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","assert","validProtocol","getOriginalEnvValue"],"mappings":";;;;+BA8BaA;;;eAAAA;;;;yBA9BuB;;;;;;;gEACjB;;;;;;;yBACC;;;;;;6DAEC;oBAEuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5C,MAAMC,QAAQC,QAAQ,SAAS;AAsBxB,MAAMF;IACX,YACE,AAAOG,QAA0B,EACjC,AAAQC,WAAwB,EAChC,AAAQC,cAA2BC,IAAAA,cAAU,GAAE,CAC/C;aAHOH,WAAAA;aACCC,cAAAA;aACAC,cAAAA;IACP;IAEH,aAAaE,KAAKJ,QAA6C,EAAEC,WAAwB,EAAE;QACzF,MAAMC,cAAc,MAAMG,IAAAA,mBAAe;QACzC,OAAO,IAAIR,WAAWG,YAAY,CAAC,GAAGC,aAAaC;IACrD;IAEA;;;;;;;;;GASC,GACD,AAAOI,oBAAoBC,OAA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,OAAOe,IAAAA,0BAAmB,EAAC;AAC7B,EAEA,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
|
|
@@ -8,11 +8,18 @@ Object.defineProperty(exports, "DevToolsPlugin", {
|
|
|
8
8
|
return DevToolsPlugin;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
function _schemautils() {
|
|
12
|
+
const data = require("@expo/schema-utils");
|
|
13
|
+
_schemautils = function() {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
11
18
|
const _DevToolsPluginschema = require("./DevToolsPlugin.schema");
|
|
12
19
|
const _DevToolsPluginCliExtensionExecutor = require("./DevToolsPluginCliExtensionExecutor");
|
|
13
20
|
const _DevToolsPluginManager = require("./DevToolsPluginManager");
|
|
14
21
|
const _DevToolsPluginServerHelpers = require("./DevToolsPluginServerHelpers");
|
|
15
|
-
const _dir = require("
|
|
22
|
+
const _dir = require("../../../utils/dir");
|
|
16
23
|
class DevToolsPlugin {
|
|
17
24
|
constructor(plugin, projectRoot){
|
|
18
25
|
this.plugin = plugin;
|
|
@@ -20,10 +27,12 @@ class DevToolsPlugin {
|
|
|
20
27
|
this._executor = undefined;
|
|
21
28
|
this._requestHandler = undefined;
|
|
22
29
|
this._webSocketServers = undefined;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
try {
|
|
31
|
+
(0, _schemautils().validate)(_DevToolsPluginschema.PluginSchema, plugin);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (!(error instanceof _schemautils().ValidationError)) throw error;
|
|
34
|
+
throw new Error(`Invalid plugin configuration:${error.toErrorsMessage().join('')}`, {
|
|
35
|
+
cause: error
|
|
27
36
|
});
|
|
28
37
|
}
|
|
29
38
|
if (plugin.webpageRoot != null) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/devtools/DevToolsPlugin.ts"],"sourcesContent":["import { validate, ValidationError } from '@expo/schema-utils';\nimport 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 try {\n validate(PluginSchema, plugin);\n } catch (error) {\n if (!(error instanceof ValidationError)) throw error;\n throw new Error(`Invalid plugin configuration:${error.toErrorsMessage().join('')}`, {\n cause: 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","validate","PluginSchema","error","ValidationError","Error","toErrorsMessage","join","cause","webpageRoot","maybeRealpathSync","isPathInside","packageRoot","serverEntryPoint","packageName","webpageEndpoint","DevToolsPluginEndpoint","getRequestHandlerAsync","loadRequestHandlerAsync","getWebSocketServersAsync","loadWebSocketServerAsync","cliBanner","bannerTitle","description","cliExtensions","executor","entryPoint","DevToolsPluginCliExtensionExecutor"],"mappings":";;;;+BA2BaA;;;eAAAA;;;;yBA3B6B;;;;;;sCAIb;oDACsB;uCACZ;6CAKhC;qBACyC;AAezC,MAAMA;IACX,YACE,AAAQC,MAA0B,EAClC,AAAgBC,WAAmB,CACnC;aAFQD,SAAAA;aACQC,cAAAA;aA+BVC,YAA4DC;aAC5DC,kBAA4DD;aAC5DE,oBAAiEF;QA/BvE,IAAI;YACFG,IAAAA,uBAAQ,EAACC,kCAAY,EAAEP;QACzB,EAAE,OAAOQ,OAAO;YACd,IAAI,CAAEA,CAAAA,iBAAiBC,8BAAe,AAAD,GAAI,MAAMD;YAC/C,MAAM,IAAIE,MAAM,CAAC,6BAA6B,EAAEF,MAAMG,eAAe,GAAGC,IAAI,CAAC,KAAK,EAAE;gBAClFC,OAAOL;YACT;QACF;QAEA,IAAIR,OAAOc,WAAW,IAAI,MAAM;YAC9B,MAAMA,cAAcC,IAAAA,sBAAiB,EAACf,OAAOc,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,IAAI,CAAC9B,MAAM,CAAC6B,aAAa,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"}
|
|
@@ -0,0 +1,195 @@
|
|
|
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
|
+
const CommandParameterSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
required: [
|
|
22
|
+
'name',
|
|
23
|
+
'type'
|
|
24
|
+
],
|
|
25
|
+
properties: {
|
|
26
|
+
name: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
minLength: 1
|
|
29
|
+
},
|
|
30
|
+
type: {
|
|
31
|
+
enum: [
|
|
32
|
+
'text',
|
|
33
|
+
'number',
|
|
34
|
+
'confirm'
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
description: {
|
|
38
|
+
type: 'string'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const CommandSchema = {
|
|
43
|
+
type: 'object',
|
|
44
|
+
required: [
|
|
45
|
+
'name',
|
|
46
|
+
'title',
|
|
47
|
+
'environments'
|
|
48
|
+
],
|
|
49
|
+
properties: {
|
|
50
|
+
name: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
minLength: 1
|
|
53
|
+
},
|
|
54
|
+
title: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
minLength: 1
|
|
57
|
+
},
|
|
58
|
+
environments: {
|
|
59
|
+
type: 'array',
|
|
60
|
+
items: {
|
|
61
|
+
enum: [
|
|
62
|
+
'cli',
|
|
63
|
+
'mcp'
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
parameters: {
|
|
68
|
+
type: 'array',
|
|
69
|
+
items: CommandParameterSchema
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const CliExtensionsSchema = {
|
|
74
|
+
type: 'object',
|
|
75
|
+
required: [
|
|
76
|
+
'description',
|
|
77
|
+
'commands',
|
|
78
|
+
'entryPoint'
|
|
79
|
+
],
|
|
80
|
+
properties: {
|
|
81
|
+
description: {
|
|
82
|
+
type: 'string'
|
|
83
|
+
},
|
|
84
|
+
commands: {
|
|
85
|
+
type: 'array',
|
|
86
|
+
items: CommandSchema,
|
|
87
|
+
minItems: 1
|
|
88
|
+
},
|
|
89
|
+
entryPoint: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
minLength: 1
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const PluginSchema = {
|
|
96
|
+
type: 'object',
|
|
97
|
+
required: [
|
|
98
|
+
'packageName',
|
|
99
|
+
'packageRoot'
|
|
100
|
+
],
|
|
101
|
+
properties: {
|
|
102
|
+
packageName: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
minLength: 1
|
|
105
|
+
},
|
|
106
|
+
packageRoot: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
minLength: 1
|
|
109
|
+
},
|
|
110
|
+
webpageRoot: {
|
|
111
|
+
type: 'string'
|
|
112
|
+
},
|
|
113
|
+
bannerTitle: {
|
|
114
|
+
type: [
|
|
115
|
+
'boolean',
|
|
116
|
+
'string'
|
|
117
|
+
],
|
|
118
|
+
minLength: 1
|
|
119
|
+
},
|
|
120
|
+
serverEntryPoint: {
|
|
121
|
+
type: 'string'
|
|
122
|
+
},
|
|
123
|
+
cliExtensions: CliExtensionsSchema
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const DevToolsPluginOutputSchema = {
|
|
127
|
+
type: 'array',
|
|
128
|
+
items: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
allOf: [
|
|
131
|
+
{
|
|
132
|
+
required: [
|
|
133
|
+
'type'
|
|
134
|
+
],
|
|
135
|
+
properties: {
|
|
136
|
+
type: {
|
|
137
|
+
enum: [
|
|
138
|
+
'text',
|
|
139
|
+
'audio',
|
|
140
|
+
'image'
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
if: {
|
|
147
|
+
properties: {
|
|
148
|
+
type: {
|
|
149
|
+
enum: [
|
|
150
|
+
'text'
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
then: {
|
|
156
|
+
required: [
|
|
157
|
+
'text',
|
|
158
|
+
'level'
|
|
159
|
+
],
|
|
160
|
+
properties: {
|
|
161
|
+
text: {
|
|
162
|
+
type: 'string'
|
|
163
|
+
},
|
|
164
|
+
url: {
|
|
165
|
+
type: 'string'
|
|
166
|
+
},
|
|
167
|
+
level: {
|
|
168
|
+
enum: [
|
|
169
|
+
'info',
|
|
170
|
+
'warning',
|
|
171
|
+
'error'
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
else: {
|
|
177
|
+
required: [
|
|
178
|
+
'url'
|
|
179
|
+
],
|
|
180
|
+
properties: {
|
|
181
|
+
url: {
|
|
182
|
+
type: 'string',
|
|
183
|
+
format: 'url'
|
|
184
|
+
},
|
|
185
|
+
text: {
|
|
186
|
+
type: 'string'
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
//# sourceMappingURL=DevToolsPlugin.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/devtools/DevToolsPlugin.schema.ts"],"sourcesContent":["import type { JSONSchema } from '@expo/schema-utils';\n\nexport type DevToolsPluginCommandParameter = {\n name: string;\n type: 'text' | 'number' | 'confirm';\n description?: string;\n};\n\nconst CommandParameterSchema: JSONSchema<DevToolsPluginCommandParameter> = {\n type: 'object',\n required: ['name', 'type'],\n properties: {\n name: { type: 'string', minLength: 1 },\n type: { enum: ['text', 'number', 'confirm'] },\n description: { type: 'string' },\n },\n};\n\nexport type DevToolsPluginCommand = {\n name: string;\n title: string;\n environments: readonly ('cli' | 'mcp')[];\n parameters?: DevToolsPluginCommandParameter[];\n};\n\nconst CommandSchema: JSONSchema<DevToolsPluginCommand> = {\n type: 'object',\n required: ['name', 'title', 'environments'],\n properties: {\n name: { type: 'string', minLength: 1 },\n title: { type: 'string', minLength: 1 },\n environments: { type: 'array', items: { enum: ['cli', 'mcp'] } },\n parameters: { type: 'array', items: CommandParameterSchema },\n },\n};\n\nexport type DevToolsPluginCliExtensions = {\n description: string;\n commands: DevToolsPluginCommand[];\n entryPoint: string;\n};\n\nconst CliExtensionsSchema: JSONSchema<DevToolsPluginCliExtensions> = {\n type: 'object',\n required: ['description', 'commands', 'entryPoint'],\n properties: {\n description: { type: 'string' },\n commands: { type: 'array', items: CommandSchema, minItems: 1 },\n entryPoint: { type: 'string', minLength: 1 },\n },\n};\n\nexport type DevToolsPluginInfo = {\n packageName: string;\n packageRoot: string;\n webpageRoot?: string;\n bannerTitle?: boolean | string;\n serverEntryPoint?: string;\n cliExtensions?: DevToolsPluginCliExtensions;\n};\n\nexport const PluginSchema: JSONSchema<DevToolsPluginInfo> = {\n type: 'object',\n required: ['packageName', 'packageRoot'],\n properties: {\n packageName: { type: 'string', minLength: 1 },\n packageRoot: { type: 'string', minLength: 1 },\n webpageRoot: { type: 'string' },\n bannerTitle: { type: ['boolean', 'string'], minLength: 1 },\n serverEntryPoint: { type: 'string' },\n cliExtensions: CliExtensionsSchema,\n },\n};\n\nexport type DevToolsPluginOutput = (\n | { type: 'text'; text: string; url?: string; level: 'info' | 'warning' | 'error' }\n | { type: 'audio'; url: string; text?: string }\n | { type: 'image'; url: string; text?: string }\n)[];\n\nexport const DevToolsPluginOutputSchema: JSONSchema<DevToolsPluginOutput> = {\n type: 'array',\n items: {\n type: 'object',\n allOf: [\n {\n required: ['type'],\n properties: { type: { enum: ['text', 'audio', 'image'] } },\n },\n {\n if: { properties: { type: { enum: ['text'] } } },\n then: {\n required: ['text', 'level'],\n properties: {\n text: { type: 'string' },\n url: { type: 'string' },\n level: { enum: ['info', 'warning', 'error'] },\n },\n },\n else: {\n required: ['url'],\n properties: {\n url: { type: 'string', format: 'url' },\n text: { type: 'string' },\n },\n },\n },\n ],\n },\n};\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"],"names":["DevToolsPluginOutputSchema","PluginSchema","CommandParameterSchema","type","required","properties","name","minLength","enum","description","CommandSchema","title","environments","items","parameters","CliExtensionsSchema","commands","minItems","entryPoint","packageName","packageRoot","webpageRoot","bannerTitle","serverEntryPoint","cliExtensions","allOf","if","then","text","url","level","else","format"],"mappings":";;;;;;;;;;;QAgFaA;eAAAA;;QAnBAC;eAAAA;;;AArDb,MAAMC,yBAAqE;IACzEC,MAAM;IACNC,UAAU;QAAC;QAAQ;KAAO;IAC1BC,YAAY;QACVC,MAAM;YAAEH,MAAM;YAAUI,WAAW;QAAE;QACrCJ,MAAM;YAAEK,MAAM;gBAAC;gBAAQ;gBAAU;aAAU;QAAC;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AAE;gBAAE;gBAC/CmB,MAAM;oBACJvB,UAAU;wBAAC;wBAAQ;qBAAQ;oBAC3BC,YAAY;wBACVuB,MAAM;4BAAEzB,MAAM;wBAAS;wBACvB0B,KAAK;4BAAE1B,MAAM;wBAAS;wBACtB2B,OAAO;4BAAEtB,MAAM;gCAAC;gCAAQ;gCAAW;6BAAQ;wBAAC;oBAC9C;gBACF;gBACAuB,MAAM;oBACJ3B,UAAU;wBAAC;qBAAM;oBACjBC,YAAY;wBACVwB,KAAK;4BAAE1B,MAAM;4BAAU6B,QAAQ;wBAAM;wBACrCJ,MAAM;4BAAEzB,MAAM;wBAAS;oBACzB;gBACF;YACF;SACD;IACH;AACF"}
|
|
@@ -23,7 +23,7 @@ function _path() {
|
|
|
23
23
|
return data;
|
|
24
24
|
}
|
|
25
25
|
const _DevToolsPluginCliExtensionResults = require("./DevToolsPluginCliExtensionResults");
|
|
26
|
-
const _dir = require("
|
|
26
|
+
const _dir = require("../../../utils/dir");
|
|
27
27
|
function _interop_require_default(obj) {
|
|
28
28
|
return obj && obj.__esModule ? obj : {
|
|
29
29
|
default: obj
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/devtools/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,OAAOC,IAAI,CAACJ,QAAQ,CAAC,GAAGK,MAAM,GAAG,IAAI,MAAMC,KAAKC,SAAS,CAACP,Q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AAM,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"}
|
|
@@ -8,6 +8,13 @@ Object.defineProperty(exports, "DevToolsPluginCliExtensionResults", {
|
|
|
8
8
|
return DevToolsPluginCliExtensionResults;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
function _schemautils() {
|
|
12
|
+
const data = require("@expo/schema-utils");
|
|
13
|
+
_schemautils = function() {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
11
18
|
function _nodebuffer() {
|
|
12
19
|
const data = require("node:buffer");
|
|
13
20
|
_nodebuffer = function() {
|
|
@@ -56,19 +63,9 @@ class DevToolsPluginCliExtensionResults {
|
|
|
56
63
|
return this._output;
|
|
57
64
|
}
|
|
58
65
|
parseOutputText(txt, level = 'info') {
|
|
59
|
-
|
|
66
|
+
let output;
|
|
60
67
|
try {
|
|
61
|
-
|
|
62
|
-
if (!result.success) {
|
|
63
|
-
return [
|
|
64
|
-
{
|
|
65
|
-
type: 'text',
|
|
66
|
-
text: `Invalid JSON: ${result.error.issues.map((issue)=>issue.message).join(', ')}`,
|
|
67
|
-
level: 'error'
|
|
68
|
-
}
|
|
69
|
-
];
|
|
70
|
-
}
|
|
71
|
-
return result.data;
|
|
68
|
+
output = JSON.parse(txt);
|
|
72
69
|
} catch {
|
|
73
70
|
// Not JSON, treat as plain text
|
|
74
71
|
const lines = txt.split('\n');
|
|
@@ -84,6 +81,21 @@ class DevToolsPluginCliExtensionResults {
|
|
|
84
81
|
}
|
|
85
82
|
return results;
|
|
86
83
|
}
|
|
84
|
+
try {
|
|
85
|
+
(0, _schemautils().validate)(_DevToolsPluginschema.DevToolsPluginOutputSchema, output);
|
|
86
|
+
return output;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (!(error instanceof _schemautils().ValidationError)) throw error;
|
|
89
|
+
// Conditional schemas include a parent error; report the failing field.
|
|
90
|
+
const issue = error.errors[error.errors.length - 1];
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
type: 'text',
|
|
94
|
+
text: `Invalid JSON: ${issue.path || 'output'}: ${issue.message}`,
|
|
95
|
+
level: 'error'
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
}
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
101
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/devtools/DevToolsPluginCliExtensionResults.ts"],"sourcesContent":["import { validate, ValidationError } from '@expo/schema-utils';\nimport { 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 let output: unknown;\n try {\n output = JSON.parse(txt);\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 try {\n validate(DevToolsPluginOutputSchema, output);\n return output;\n } catch (error) {\n if (!(error instanceof ValidationError)) throw error;\n // Conditional schemas include a parent error; report the failing field.\n const issue = error.errors[error.errors.length - 1]!;\n return [\n {\n type: 'text',\n text: `Invalid JSON: ${issue.path || 'output'}: ${issue.message}`,\n level: 'error',\n },\n ];\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","JSON","parse","lines","split","line","validate","DevToolsPluginOutputSchema","error","ValidationError","issue","errors","path"],"mappings":";;;;+BAmBaA;;;eAAAA;;;;yBAnB6B;;;;;;;yBACG;;;;;;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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E;YACxE,MAAME,QAAQF,MAAMG,MAAM,CAACH,MAAMG,MAAM,CAACtB,MAAM,GAAG,EAAE;YACnD,OAAO;gBACL;oBACEE,MAAM;oBACNC,MAAM,CAAC,cAAc,EAAEkB,MAAME,IAAI,IAAI,SAAS,EAAE,EAAEF,MAAMpB,OAAO,EAAE;oBACjEF,OAAO;gBACT;aACD;QACH;IACF;AACF"}
|
package/build/src/start/server/{DevToolsPluginManager.js → devtools/DevToolsPluginManager.js}
RENAMED
|
@@ -20,8 +20,8 @@ _export(exports, {
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
const _DevToolsPlugin = require("./DevToolsPlugin");
|
|
23
|
-
const _events = require("
|
|
24
|
-
const _log = require("
|
|
23
|
+
const _events = require("../../../events");
|
|
24
|
+
const _log = require("../../../log");
|
|
25
25
|
const debug = require('debug')('expo:start:server:devtools');
|
|
26
26
|
const DevToolsPluginEndpoint = '/_expo/plugins';
|
|
27
27
|
const event = (0, _events.events)('expo', (t)=>[
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/devtools/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;;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AC/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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/devtools/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,IAAIE,QAAQ,GAAGT;IACf,MAAMK,UAAU,IAAIK;IACpB,MAAM,EAAEC,UAAU,EAAE,GAAGZ;IACvB,IAAK,IAAIa,QAAQ,GAAGA,QAAQD,WAAWE,MAAM,EAAED,SAAS,EAAG;QACzD,MAAME,OAAOH,UAAU,CAACC,MAAM;QAC9B,MAAMG,QAAQJ,UAAU,CAACC,QAAQ,EAAE;QACnC,IAAIE,QAAQ,QAAQC,SAAS,MAAM;YACjCV,QAAQW,MAAM,CAACF,MAAMC;QACvB;IACF;IACA,OAAO,IAAIE,QAAQV,IAAIW,IAAI,EAAE;QAAEC,QAAQpB,QAAQoB,MAAM;QAAEd;IAAQ;AACjE;AAEO,eAAeX,wBAAwB,EAC5C0B,WAAW,EACXC,gBAAgB,EAIjB;IACCzB,MAAM,6CAA6CyB;IACnD,MAAMC,eAAgB,MAAMC,IAAAA,0BAAU,EAAC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
|
31
|
-
}
|
|
32
|
-
const _UserSettings = require("../../api/user/UserSettings");
|
|
33
|
-
const _log = require("../../log");
|
|
34
|
-
const _env = require("../../utils/env");
|
|
35
|
-
const _exit = require("../../utils/exit");
|
|
25
|
+
const _UserSettings = require("../../../api/user/UserSettings");
|
|
26
|
+
const _log = require("../../../log");
|
|
27
|
+
const _env = require("../../../utils/env");
|
|
28
|
+
const _exit = require("../../../utils/exit");
|
|
29
|
+
const _MCPDevToolsPluginCLIExtensions = require("./MCPDevToolsPluginCLIExtensions");
|
|
36
30
|
function _interop_require_default(obj) {
|
|
37
31
|
return obj && obj.__esModule ? obj : {
|
|
38
32
|
default: obj
|
|
39
33
|
};
|
|
40
34
|
}
|
|
41
35
|
const debug = require('debug')('expo:start:server:mcp');
|
|
42
|
-
async function maybeCreateMCPServerAsync({
|
|
36
|
+
async function maybeCreateMCPServerAsync({ devServerManager, devServerUrl }) {
|
|
43
37
|
const mcpServer = _env.env.EXPO_UNSTABLE_MCP_SERVER;
|
|
44
38
|
if (!mcpServer) {
|
|
45
39
|
return null;
|
|
46
40
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
41
|
+
const { projectRoot } = devServerManager;
|
|
42
|
+
let mcpPackagePath;
|
|
43
|
+
try {
|
|
44
|
+
mcpPackagePath = require.resolve('expo-mcp', {
|
|
45
|
+
paths: [
|
|
46
|
+
__dirname,
|
|
47
|
+
projectRoot
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
} catch {
|
|
49
51
|
_log.Log.error('Missing the `expo-mcp` package in the project. To enable the MCP integration, add the `expo-mcp` package to your project.');
|
|
50
52
|
return null;
|
|
51
53
|
}
|
|
52
|
-
const mcpTunnelPackagePath =
|
|
54
|
+
const mcpTunnelPackagePath = (0, _requireutils().resolveFrom)(_nodepath().default.dirname(mcpPackagePath), '@expo/mcp-tunnel');
|
|
53
55
|
if (!mcpTunnelPackagePath) {
|
|
54
56
|
_log.Log.error('Unable to resolve the `@expo/mcp-tunnel` package');
|
|
55
57
|
return null;
|
|
56
58
|
}
|
|
59
|
+
// TODO(@kitten): Move the Zod dependency and MCP schema construction into expo-mcp.
|
|
60
|
+
const zodPackagePath = (0, _requireutils().resolveFrom)(_nodepath().default.dirname(mcpPackagePath), 'zod');
|
|
61
|
+
if (!zodPackagePath) {
|
|
62
|
+
_log.Log.error('Unable to resolve Zod from `expo-mcp`. Reinstall your project dependencies to enable MCP.');
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
57
65
|
const normalizedServer = /^([a-zA-Z][a-zA-Z\d+\-.]*):\/\//.test(mcpServer) ? mcpServer : `wss://${mcpServer}`;
|
|
58
66
|
const mcpServerUrlObject = new URL(normalizedServer);
|
|
59
67
|
const scheme = mcpServerUrlObject.protocol ?? 'wss:';
|
|
@@ -63,6 +71,7 @@ async function maybeCreateMCPServerAsync({ projectRoot, devServerUrl }) {
|
|
|
63
71
|
debug(`Loading MCP modules: expo-mcp=${mcpPackagePath}, mcp-tunnel=${mcpTunnelPackagePath}`);
|
|
64
72
|
const { addMcpCapabilities } = await (0, _requireutils().loadModule)(mcpPackagePath);
|
|
65
73
|
const { TunnelMcpServerProxy } = await (0, _requireutils().loadModule)(mcpTunnelPackagePath);
|
|
74
|
+
const { z } = await (0, _requireutils().loadModule)(zodPackagePath);
|
|
66
75
|
const logger = {
|
|
67
76
|
..._log.Log,
|
|
68
77
|
debug (...message) {
|
|
@@ -79,6 +88,7 @@ async function maybeCreateMCPServerAsync({ projectRoot, devServerUrl }) {
|
|
|
79
88
|
devServerUrl
|
|
80
89
|
});
|
|
81
90
|
addMcpCapabilities(serverProxy, projectRoot);
|
|
91
|
+
await (0, _MCPDevToolsPluginCLIExtensions.addMcpCapabilities)(serverProxy, devServerManager, z);
|
|
82
92
|
const removeExitHook = (0, _exit.installExitHooks)(async ()=>{
|
|
83
93
|
await serverProxy.close();
|
|
84
94
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/mcp/MCP.ts"],"sourcesContent":["import type {\n McpServerProxy,\n TunnelMcpServerProxy as TunnelMcpServerProxyType,\n} from '@expo/mcp-tunnel' with { 'resolution-mode': 'import' };\nimport { loadModule, resolveFrom } from '@expo/require-utils';\nimport path from 'node:path';\n\nimport { getAccessToken, getSession } from '../../../api/user/UserSettings';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { installExitHooks } from '../../../utils/exit';\nimport type { DevServerManager } from '../DevServerManager';\nimport { addMcpCapabilities as addDevToolsPluginCapabilities } from './MCPDevToolsPluginCLIExtensions';\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 devServerManager,\n devServerUrl,\n}: {\n devServerManager: DevServerManager;\n devServerUrl: string;\n}): Promise<McpServer | null> {\n const mcpServer = env.EXPO_UNSTABLE_MCP_SERVER;\n if (!mcpServer) {\n return null;\n }\n const { projectRoot } = devServerManager;\n let mcpPackagePath: string;\n try {\n mcpPackagePath = require.resolve('expo-mcp', { paths: [__dirname, projectRoot] });\n } catch {\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(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 // TODO(@kitten): Move the Zod dependency and MCP schema construction into expo-mcp.\n const zodPackagePath = resolveFrom(path.dirname(mcpPackagePath), 'zod');\n if (!zodPackagePath) {\n Log.error(\n 'Unable to resolve Zod from `expo-mcp`. Reinstall your project dependencies to enable MCP.'\n );\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 const { z } = (await loadModule(zodPackagePath)) as typeof import('zod');\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 await addDevToolsPluginCapabilities(serverProxy, devServerManager, z);\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","devServerManager","devServerUrl","mcpServer","env","EXPO_UNSTABLE_MCP_SERVER","projectRoot","mcpPackagePath","resolve","paths","__dirname","Log","error","mcpTunnelPackagePath","resolveFrom","path","dirname","zodPackagePath","normalizedServer","test","mcpServerUrlObject","URL","scheme","protocol","mcpServerUrl","host","addMcpCapabilities","loadModule","TunnelMcpServerProxy","z","logger","message","info","log","serverProxy","wsHeaders","createAuthHeaders","addDevToolsPluginCapabilities","removeExitHook","installExitHooks","close","server","closeAsync","getSession","token","getAccessToken","authorization","sessionSecret"],"mappings":";;;;+BA6BsBA;;;eAAAA;;;;yBAzBkB;;;;;;;gEACvB;;;;;;8BAE0B;qBACvB;qBACA;sBACa;gDAEmC;;;;;;AAEpE,MAAMC,QAAQC,QAAQ,SAAS;AAexB,eAAeF,0BAA0B,EAC9CG,gBAAgB,EAChBC,YAAY,EAIb;IACC,MAAMC,YAAYC,QAAG,CAACC,wBAAwB;IAC9C,IAAI,CAACF,WAAW;QACd,OAAO;IACT;IACA,MAAM,EAAEG,WAAW,EAAE,GAAGL;IACxB,IAAIM;IACJ,IAAI;QACFA,iBAAiBP,QAAQQ,OAAO,CAAC,YAAY;YAAEC,OAAO;gBAACC;gBAAWJ;aAAY;QAAC;IACjF,EAAE,OAAM;QACNK,QAAG,CAACC,KAAK,CACP;QAEF,OAAO;IACT;IACA,MAAMC,uBAAuBC,IAAAA,2BAAW,EAACC,mBAAI,CAACC,OAAO,CAACT,iBAAiB;IACvE,IAAI,CAACM,sBAAsB;QACzBF,QAAG,CAACC,KAAK,CAAC;QACV,OAAO;IACT;IAEA,oFAAoF;IACpF,MAAMK,iBAAiBH,IAAAA,2BAAW,EAACC,mBAAI,CAACC,OAAO,CAACT,iBAAiB;IACjE,IAAI,CAACU,gBAAgB;QACnBN,QAAG,CAACC,KAAK,CACP;QAEF,OAAO;IACT;IAEA,MAAMM,mBAAmB,kCAAkCC,IAAI,CAAChB,aAC5DA,YACA,CAAC,MAAM,EAAEA,WAAW;IACxB,MAAMiB,qBAAqB,IAAIC,IAAIH;IACnC,MAAMI,SAASF,mBAAmBG,QAAQ,IAAI;IAC9C,MAAMC,eAAe,GAAGF,OAAO,EAAE,EAAEF,mB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