@expo/cli 0.19.1 → 0.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/bin/cli CHANGED
@@ -120,7 +120,7 @@ const args = (0, _arg().default)({
120
120
  });
121
121
  if (args["--version"]) {
122
122
  // Version is added in the build script.
123
- console.log("0.19.1");
123
+ console.log("0.19.3");
124
124
  process.exit(0);
125
125
  }
126
126
  if (args["--non-interactive"]) {
@@ -13,14 +13,23 @@ function _chalk() {
13
13
  };
14
14
  return data;
15
15
  }
16
+ function _ws() {
17
+ const data = require("ws");
18
+ _ws = function() {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
16
23
  const _createHandlersFactory = require("./createHandlersFactory");
17
24
  const _log = require("../../../../log");
18
25
  const _env = require("../../../../utils/env");
26
+ const _networkResponse = require("./messageHandlers/NetworkResponse");
19
27
  function _interopRequireDefault(obj) {
20
28
  return obj && obj.__esModule ? obj : {
21
29
  default: obj
22
30
  };
23
31
  }
32
+ const debug = require("debug")("expo:metro:debugging:middleware");
24
33
  function createDebugMiddleware(metroBundler) {
25
34
  // Load the React Native debugging tools from project
26
35
  // TODO: check if this works with isolated modules
@@ -32,7 +41,7 @@ function createDebugMiddleware(metroBundler) {
32
41
  hostType: "lan"
33
42
  }),
34
43
  logger: createLogger(_chalk().default.bold("Debug:")),
35
- unstable_customInspectorMessageHandler: (0, _createHandlersFactory.createHandlersFactory)(metroBundler),
44
+ unstable_customInspectorMessageHandler: (0, _createHandlersFactory.createHandlersFactory)(),
36
45
  unstable_experiments: {
37
46
  // Enable the Network tab in React Native DevTools
38
47
  enableNetworkInspector: true,
@@ -41,6 +50,8 @@ function createDebugMiddleware(metroBundler) {
41
50
  enableOpenDebuggerRedirect: _env.env.EXPO_DEBUG
42
51
  }
43
52
  });
53
+ // NOTE(cedric): add a temporary websocket to handle Network-related CDP events
54
+ websocketEndpoints["/inspector/network"] = createNetworkWebsocket(websocketEndpoints["/inspector/debug"]);
44
55
  return {
45
56
  debugMiddleware: middleware,
46
57
  debugWebsocketEndpoints: websocketEndpoints
@@ -53,5 +64,42 @@ function createLogger(logPrefix) {
53
64
  error: (...args)=>_log.Log.error(logPrefix, ...args)
54
65
  };
55
66
  }
67
+ /**
68
+ * This adds a dedicated websocket connection that handles Network-related CDP events.
69
+ * It's a temporary solution until Fusebox either implements the Network CDP domain,
70
+ * or allows external domain agents that can send messages over the CDP socket to the debugger.
71
+ * The Network websocket rebroadcasts events on the debugger CDP connections.
72
+ */ function createNetworkWebsocket(debuggerWebsocket) {
73
+ const wss = new (_ws()).WebSocketServer({
74
+ noServer: true,
75
+ perMessageDeflate: true,
76
+ // Don't crash on exceptionally large messages - assume the device is
77
+ // well-behaved and the debugger is prepared to handle large messages.
78
+ maxPayload: 0
79
+ });
80
+ wss.on("connection", (networkSocket)=>{
81
+ networkSocket.on("message", (data)=>{
82
+ try {
83
+ // Parse the network message, to determine how the message should be handled
84
+ const message = JSON.parse(data.toString());
85
+ if (message.method === "Expo(Network.receivedResponseBody)" && message.params) {
86
+ // If its a response body, write it to the global storage
87
+ const { requestId , ...requestInfo } = message.params;
88
+ _networkResponse.NETWORK_RESPONSE_STORAGE.set(requestId, requestInfo);
89
+ } else {
90
+ // Otherwise, directly re-broadcast the Network events to all connected debuggers
91
+ debuggerWebsocket.clients.forEach((debuggerSocket)=>{
92
+ if (debuggerSocket.readyState === debuggerSocket.OPEN) {
93
+ debuggerSocket.send(data.toString());
94
+ }
95
+ });
96
+ }
97
+ } catch (error) {
98
+ debug("Failed to handle Network CDP event", error);
99
+ }
100
+ });
101
+ });
102
+ return wss;
103
+ }
56
104
 
57
105
  //# sourceMappingURL=createDebugMiddleware.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/createDebugMiddleware.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { createHandlersFactory } from './createHandlersFactory';\nimport { Log } from '../../../../log';\nimport { env } from '../../../../utils/env';\nimport { type MetroBundlerDevServer } from '../MetroBundlerDevServer';\n\nexport function createDebugMiddleware(metroBundler: MetroBundlerDevServer) {\n // Load the React Native debugging tools from project\n // TODO: check if this works with isolated modules\n const { createDevMiddleware } =\n require('@react-native/dev-middleware') as typeof import('@react-native/dev-middleware');\n\n const { middleware, websocketEndpoints } = createDevMiddleware({\n projectRoot: metroBundler.projectRoot,\n serverBaseUrl: metroBundler.getUrlCreator().constructUrl({ scheme: 'http', hostType: 'lan' }),\n logger: createLogger(chalk.bold('Debug:')),\n unstable_customInspectorMessageHandler: createHandlersFactory(metroBundler),\n unstable_experiments: {\n // Enable the Network tab in React Native DevTools\n enableNetworkInspector: true,\n // Only enable opening the browser version of React Native DevTools when debugging.\n // This is useful when debugging the React Native DevTools by going to `/open-debugger` in the browser.\n enableOpenDebuggerRedirect: env.EXPO_DEBUG,\n },\n });\n\n return {\n debugMiddleware: middleware,\n debugWebsocketEndpoints: websocketEndpoints,\n };\n}\n\nfunction createLogger(\n logPrefix: string\n): Parameters<typeof import('@react-native/dev-middleware').createDevMiddleware>[0]['logger'] {\n return {\n info: (...args) => Log.log(logPrefix, ...args),\n warn: (...args) => Log.warn(logPrefix, ...args),\n error: (...args) => Log.error(logPrefix, ...args),\n };\n}\n"],"names":["createDebugMiddleware","metroBundler","createDevMiddleware","require","middleware","websocketEndpoints","projectRoot","serverBaseUrl","getUrlCreator","constructUrl","scheme","hostType","logger","createLogger","chalk","bold","unstable_customInspectorMessageHandler","createHandlersFactory","unstable_experiments","enableNetworkInspector","enableOpenDebuggerRedirect","env","EXPO_DEBUG","debugMiddleware","debugWebsocketEndpoints","logPrefix","info","args","Log","log","warn","error"],"mappings":"AAAA;;;;+BAOgBA,uBAAqB;;aAArBA,qBAAqB;;;8DAPnB,OAAO;;;;;;uCAEa,yBAAyB;qBAC3C,iBAAiB;qBACjB,uBAAuB;;;;;;AAGpC,SAASA,qBAAqB,CAACC,YAAmC,EAAE;IACzE,qDAAqD;IACrD,kDAAkD;IAClD,MAAM,EAAEC,mBAAmB,CAAA,EAAE,GAC3BC,OAAO,CAAC,8BAA8B,CAAC,AAAiD,AAAC;IAE3F,MAAM,EAAEC,UAAU,CAAA,EAAEC,kBAAkB,CAAA,EAAE,GAAGH,mBAAmB,CAAC;QAC7DI,WAAW,EAAEL,YAAY,CAACK,WAAW;QACrCC,aAAa,EAAEN,YAAY,CAACO,aAAa,EAAE,CAACC,YAAY,CAAC;YAAEC,MAAM,EAAE,MAAM;YAAEC,QAAQ,EAAE,KAAK;SAAE,CAAC;QAC7FC,MAAM,EAAEC,YAAY,CAACC,MAAK,EAAA,QAAA,CAACC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1CC,sCAAsC,EAAEC,IAAAA,sBAAqB,sBAAA,EAAChB,YAAY,CAAC;QAC3EiB,oBAAoB,EAAE;YACpB,kDAAkD;YAClDC,sBAAsB,EAAE,IAAI;YAC5B,mFAAmF;YACnF,uGAAuG;YACvGC,0BAA0B,EAAEC,IAAG,IAAA,CAACC,UAAU;SAC3C;KACF,CAAC,AAAC;IAEH,OAAO;QACLC,eAAe,EAAEnB,UAAU;QAC3BoB,uBAAuB,EAAEnB,kBAAkB;KAC5C,CAAC;AACJ,CAAC;AAED,SAASQ,YAAY,CACnBY,SAAiB,EAC2E;IAC5F,OAAO;QACLC,IAAI,EAAE,CAAIC,GAAAA,IAAI,GAAKC,IAAG,IAAA,CAACC,GAAG,CAACJ,SAAS,KAAKE,IAAI,CAAC;QAC9CG,IAAI,EAAE,CAAIH,GAAAA,IAAI,GAAKC,IAAG,IAAA,CAACE,IAAI,CAACL,SAAS,KAAKE,IAAI,CAAC;QAC/CI,KAAK,EAAE,CAAIJ,GAAAA,IAAI,GAAKC,IAAG,IAAA,CAACG,KAAK,CAACN,SAAS,KAAKE,IAAI,CAAC;KAClD,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/createDebugMiddleware.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { WebSocketServer } from 'ws';\n\nimport { createHandlersFactory } from './createHandlersFactory';\nimport { Log } from '../../../../log';\nimport { env } from '../../../../utils/env';\nimport { type MetroBundlerDevServer } from '../MetroBundlerDevServer';\nimport { NETWORK_RESPONSE_STORAGE } from './messageHandlers/NetworkResponse';\n\nconst debug = require('debug')('expo:metro:debugging:middleware') as typeof console.log;\n\nexport function createDebugMiddleware(metroBundler: MetroBundlerDevServer) {\n // Load the React Native debugging tools from project\n // TODO: check if this works with isolated modules\n const { createDevMiddleware } =\n require('@react-native/dev-middleware') as typeof import('@react-native/dev-middleware');\n\n const { middleware, websocketEndpoints } = createDevMiddleware({\n projectRoot: metroBundler.projectRoot,\n serverBaseUrl: metroBundler.getUrlCreator().constructUrl({ scheme: 'http', hostType: 'lan' }),\n logger: createLogger(chalk.bold('Debug:')),\n unstable_customInspectorMessageHandler: createHandlersFactory(),\n unstable_experiments: {\n // Enable the Network tab in React Native DevTools\n enableNetworkInspector: true,\n // Only enable opening the browser version of React Native DevTools when debugging.\n // This is useful when debugging the React Native DevTools by going to `/open-debugger` in the browser.\n enableOpenDebuggerRedirect: env.EXPO_DEBUG,\n },\n });\n\n // NOTE(cedric): add a temporary websocket to handle Network-related CDP events\n websocketEndpoints['/inspector/network'] = createNetworkWebsocket(\n websocketEndpoints['/inspector/debug']\n );\n\n return {\n debugMiddleware: middleware,\n debugWebsocketEndpoints: websocketEndpoints,\n };\n}\n\nfunction createLogger(\n logPrefix: string\n): Parameters<typeof import('@react-native/dev-middleware').createDevMiddleware>[0]['logger'] {\n return {\n info: (...args) => Log.log(logPrefix, ...args),\n warn: (...args) => Log.warn(logPrefix, ...args),\n error: (...args) => Log.error(logPrefix, ...args),\n };\n}\n\n/**\n * This adds a dedicated websocket connection that handles Network-related CDP events.\n * It's a temporary solution until Fusebox either implements the Network CDP domain,\n * or allows external domain agents that can send messages over the CDP socket to the debugger.\n * The Network websocket rebroadcasts events on the debugger CDP connections.\n */\nfunction createNetworkWebsocket(debuggerWebsocket: WebSocketServer) {\n const wss = new WebSocketServer({\n noServer: true,\n perMessageDeflate: true,\n // Don't crash on exceptionally large messages - assume the device is\n // well-behaved and the debugger is prepared to handle large messages.\n maxPayload: 0,\n });\n\n wss.on('connection', (networkSocket) => {\n networkSocket.on('message', (data) => {\n try {\n // Parse the network message, to determine how the message should be handled\n const message = JSON.parse(data.toString());\n\n if (message.method === 'Expo(Network.receivedResponseBody)' && message.params) {\n // If its a response body, write it to the global storage\n const { requestId, ...requestInfo } = message.params;\n NETWORK_RESPONSE_STORAGE.set(requestId, requestInfo);\n } else {\n // Otherwise, directly re-broadcast the Network events to all connected debuggers\n debuggerWebsocket.clients.forEach((debuggerSocket) => {\n if (debuggerSocket.readyState === debuggerSocket.OPEN) {\n debuggerSocket.send(data.toString());\n }\n });\n }\n } catch (error) {\n debug('Failed to handle Network CDP event', error);\n }\n });\n });\n\n return wss;\n}\n"],"names":["createDebugMiddleware","debug","require","metroBundler","createDevMiddleware","middleware","websocketEndpoints","projectRoot","serverBaseUrl","getUrlCreator","constructUrl","scheme","hostType","logger","createLogger","chalk","bold","unstable_customInspectorMessageHandler","createHandlersFactory","unstable_experiments","enableNetworkInspector","enableOpenDebuggerRedirect","env","EXPO_DEBUG","createNetworkWebsocket","debugMiddleware","debugWebsocketEndpoints","logPrefix","info","args","Log","log","warn","error","debuggerWebsocket","wss","WebSocketServer","noServer","perMessageDeflate","maxPayload","on","networkSocket","data","message","JSON","parse","toString","method","params","requestId","requestInfo","NETWORK_RESPONSE_STORAGE","set","clients","forEach","debuggerSocket","readyState","OPEN","send"],"mappings":"AAAA;;;;+BAWgBA,uBAAqB;;aAArBA,qBAAqB;;;8DAXnB,OAAO;;;;;;;yBACO,IAAI;;;;;;uCAEE,yBAAyB;qBAC3C,iBAAiB;qBACjB,uBAAuB;iCAEF,mCAAmC;;;;;;AAE5E,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAEjF,SAASF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L,CAAC,CAAC,CAAC;IAEH,OAAOE,GAAG,CAAC;AACb,CAAC"}
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "createHandlersFactory", {
7
7
  get: ()=>createHandlersFactory
8
8
  });
9
9
  const _networkResponse = require("./messageHandlers/NetworkResponse");
10
- const _pageReload = require("./messageHandlers/PageReload");
11
10
  const _vscodeDebuggerGetPossibleBreakpoints = require("./messageHandlers/VscodeDebuggerGetPossibleBreakpoints");
12
11
  const _vscodeDebuggerSetBreakpointByUrl = require("./messageHandlers/VscodeDebuggerSetBreakpointByUrl");
13
12
  const _vscodeRuntimeCallFunctionOn = require("./messageHandlers/VscodeRuntimeCallFunctionOn");
@@ -15,7 +14,7 @@ const _vscodeRuntimeEvaluate = require("./messageHandlers/VscodeRuntimeEvaluate"
15
14
  const _vscodeRuntimeGetProperties = require("./messageHandlers/VscodeRuntimeGetProperties");
16
15
  const _pageIsSupported = require("./pageIsSupported");
17
16
  const debug = require("debug")("expo:metro:debugging:messageHandlers");
18
- function createHandlersFactory(metroBundler) {
17
+ function createHandlersFactory() {
19
18
  return (connection)=>{
20
19
  debug("Initializing for connection: ", connection.page.title);
21
20
  if (!(0, _pageIsSupported.pageIsSupported)(connection.page)) {
@@ -25,7 +24,6 @@ function createHandlersFactory(metroBundler) {
25
24
  const handlers = [
26
25
  // Generic handlers
27
26
  new _networkResponse.NetworkResponseHandler(connection),
28
- new _pageReload.PageReloadHandler(connection, metroBundler),
29
27
  // Vscode-specific handlers
30
28
  new _vscodeDebuggerGetPossibleBreakpoints.VscodeDebuggerGetPossibleBreakpointsHandler(connection),
31
29
  new _vscodeDebuggerSetBreakpointByUrl.VscodeDebuggerSetBreakpointByUrlHandler(connection),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/createHandlersFactory.ts"],"sourcesContent":["import type { CreateCustomMessageHandlerFn } from '@react-native/dev-middleware';\n\nimport { NetworkResponseHandler } from './messageHandlers/NetworkResponse';\nimport { PageReloadHandler } from './messageHandlers/PageReload';\nimport { VscodeDebuggerGetPossibleBreakpointsHandler } from './messageHandlers/VscodeDebuggerGetPossibleBreakpoints';\nimport { VscodeDebuggerSetBreakpointByUrlHandler } from './messageHandlers/VscodeDebuggerSetBreakpointByUrl';\nimport { VscodeRuntimeCallFunctionOnHandler } from './messageHandlers/VscodeRuntimeCallFunctionOn';\nimport { VscodeRuntimeEvaluateHandler } from './messageHandlers/VscodeRuntimeEvaluate';\nimport { VscodeRuntimeGetPropertiesHandler } from './messageHandlers/VscodeRuntimeGetProperties';\nimport { pageIsSupported } from './pageIsSupported';\nimport type { MetroBundlerDevServer } from '../MetroBundlerDevServer';\n\nconst debug = require('debug')('expo:metro:debugging:messageHandlers') as typeof console.log;\n\nexport function createHandlersFactory(\n metroBundler: Pick<MetroBundlerDevServer, 'broadcastMessage'>\n): CreateCustomMessageHandlerFn {\n return (connection) => {\n debug('Initializing for connection: ', connection.page.title);\n\n if (!pageIsSupported(connection.page)) {\n debug('Aborted, unsupported page capabiltiies:', connection.page.capabilities);\n return null;\n }\n\n const handlers = [\n // Generic handlers\n new NetworkResponseHandler(connection),\n new PageReloadHandler(connection, metroBundler),\n // Vscode-specific handlers\n new VscodeDebuggerGetPossibleBreakpointsHandler(connection),\n new VscodeDebuggerSetBreakpointByUrlHandler(connection),\n new VscodeRuntimeGetPropertiesHandler(connection),\n new VscodeRuntimeCallFunctionOnHandler(connection),\n new VscodeRuntimeEvaluateHandler(connection),\n ].filter((middleware) => middleware.isEnabled());\n\n if (!handlers.length) {\n debug('Aborted, all handlers are disabled');\n return null;\n }\n\n debug(\n 'Initialized with handlers: ',\n handlers.map((middleware) => middleware.constructor.name).join(', ')\n );\n\n return {\n handleDeviceMessage: (message: any) =>\n withMessageDebug(\n 'device',\n message,\n handlers.some((middleware) => middleware.handleDeviceMessage?.(message))\n ),\n handleDebuggerMessage: (message: any) =>\n withMessageDebug(\n 'debugger',\n message,\n handlers.some((middleware) => middleware.handleDebuggerMessage?.(message))\n ),\n };\n };\n}\n\nfunction withMessageDebug(type: 'device' | 'debugger', message: any, result?: null | boolean) {\n const status = result ? 'handled' : 'ignored';\n const prefix = type === 'device' ? '(debugger) <- (device)' : '(debugger) -> (device)';\n\n try {\n debug(`%s = %s:`, prefix, status, JSON.stringify(message));\n } catch {\n debug(`%s = %s:`, prefix, status, 'message not serializable');\n }\n\n return result || undefined;\n}\n"],"names":["createHandlersFactory","debug","require","metroBundler","connection","page","title","pageIsSupported","capabilities","handlers","NetworkResponseHandler","PageReloadHandler","VscodeDebuggerGetPossibleBreakpointsHandler","VscodeDebuggerSetBreakpointByUrlHandler","VscodeRuntimeGetPropertiesHandler","VscodeRuntimeCallFunctionOnHandler","VscodeRuntimeEvaluateHandler","filter","middleware","isEnabled","length","map","constructor","name","join","handleDeviceMessage","message","withMessageDebug","some","handleDebuggerMessage","type","result","status","prefix","JSON","stringify","undefined"],"mappings":"AAAA;;;;+BAcgBA,uBAAqB;;aAArBA,qBAAqB;;iCAZE,mCAAmC;4BACxC,8BAA8B;sDACJ,wDAAwD;kDAC5D,oDAAoD;6CACzD,+CAA+C;uCACrD,yCAAyC;4CACpC,8CAA8C;iCAChE,mBAAmB;AAGnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAEtF,SAASF,qBAAqB,CACnCG,YAA6D,EAC/B;IAC9B,OAAO,CAACC,UAAU,GAAK;QACrBH,KAAK,CAAC,+BAA+B,EAAEG,UAAU,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC;QAE9D,IAAI,CAACC,IAAAA,gBAAe,gBAAA,EAACH,UAAU,CAACC,IAAI,CAAC,EAAE;YACrCJ,KAAK,CAAC,yCAAyC,EAAEG,UAAU,CAACC,IAAI,CAACG,YAAY,CAAC,CAAC;YAC/E,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAMC,QAAQ,GAAG;YACf,mBAAmB;YACnB,IAAIC,gBAAsB,uBAAA,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AAC,CAC3E,CAAA;aAAA;SACJ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAASC,gBAAgB,CAACG,IAA2B,EAAEJ,OAAY,EAAEK,MAAuB,EAAE;IAC5F,MAAMC,MAAM,GAAGD,MAAM,GAAG,SAAS,GAAG,SAAS,AAAC;IAC9C,MAAME,MAAM,GAAGH,IAAI,KAAK,QAAQ,GAAG,wBAAwB,GAAG,wBAAwB,AAAC;IAEvF,IAAI;QACF7B,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAEgC,MAAM,EAAED,MAAM,EAAEE,IAAI,CAACC,SAAS,CAACT,OAAO,CAAC,CAAC,CAAC;IAC7D,EAAE,OAAM;QACNzB,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAEgC,MAAM,EAAED,MAAM,EAAE,0BAA0B,CAAC,CAAC;IAChE,CAAC;IAED,OAAOD,MAAM,IAAIK,SAAS,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/createHandlersFactory.ts"],"sourcesContent":["import type { CreateCustomMessageHandlerFn } from '@react-native/dev-middleware';\n\nimport { NetworkResponseHandler } from './messageHandlers/NetworkResponse';\nimport { VscodeDebuggerGetPossibleBreakpointsHandler } from './messageHandlers/VscodeDebuggerGetPossibleBreakpoints';\nimport { VscodeDebuggerSetBreakpointByUrlHandler } from './messageHandlers/VscodeDebuggerSetBreakpointByUrl';\nimport { VscodeRuntimeCallFunctionOnHandler } from './messageHandlers/VscodeRuntimeCallFunctionOn';\nimport { VscodeRuntimeEvaluateHandler } from './messageHandlers/VscodeRuntimeEvaluate';\nimport { VscodeRuntimeGetPropertiesHandler } from './messageHandlers/VscodeRuntimeGetProperties';\nimport { pageIsSupported } from './pageIsSupported';\n\nconst debug = require('debug')('expo:metro:debugging:messageHandlers') as typeof console.log;\n\nexport function createHandlersFactory(): CreateCustomMessageHandlerFn {\n return (connection) => {\n debug('Initializing for connection: ', connection.page.title);\n\n if (!pageIsSupported(connection.page)) {\n debug('Aborted, unsupported page capabiltiies:', connection.page.capabilities);\n return null;\n }\n\n const handlers = [\n // Generic handlers\n new NetworkResponseHandler(connection),\n // Vscode-specific handlers\n new VscodeDebuggerGetPossibleBreakpointsHandler(connection),\n new VscodeDebuggerSetBreakpointByUrlHandler(connection),\n new VscodeRuntimeGetPropertiesHandler(connection),\n new VscodeRuntimeCallFunctionOnHandler(connection),\n new VscodeRuntimeEvaluateHandler(connection),\n ].filter((middleware) => middleware.isEnabled());\n\n if (!handlers.length) {\n debug('Aborted, all handlers are disabled');\n return null;\n }\n\n debug(\n 'Initialized with handlers: ',\n handlers.map((middleware) => middleware.constructor.name).join(', ')\n );\n\n return {\n handleDeviceMessage: (message: any) =>\n withMessageDebug(\n 'device',\n message,\n handlers.some((middleware) => middleware.handleDeviceMessage?.(message))\n ),\n handleDebuggerMessage: (message: any) =>\n withMessageDebug(\n 'debugger',\n message,\n handlers.some((middleware) => middleware.handleDebuggerMessage?.(message))\n ),\n };\n };\n}\n\nfunction withMessageDebug(type: 'device' | 'debugger', message: any, result?: null | boolean) {\n const status = result ? 'handled' : 'ignored';\n const prefix = type === 'device' ? '(debugger) <- (device)' : '(debugger) -> (device)';\n\n try {\n debug(`%s = %s:`, prefix, status, JSON.stringify(message));\n } catch {\n debug(`%s = %s:`, prefix, status, 'message not serializable');\n }\n\n return result || undefined;\n}\n"],"names":["createHandlersFactory","debug","require","connection","page","title","pageIsSupported","capabilities","handlers","NetworkResponseHandler","VscodeDebuggerGetPossibleBreakpointsHandler","VscodeDebuggerSetBreakpointByUrlHandler","VscodeRuntimeGetPropertiesHandler","VscodeRuntimeCallFunctionOnHandler","VscodeRuntimeEvaluateHandler","filter","middleware","isEnabled","length","map","constructor","name","join","handleDeviceMessage","message","withMessageDebug","some","handleDebuggerMessage","type","result","status","prefix","JSON","stringify","undefined"],"mappings":"AAAA;;;;+BAYgBA,uBAAqB;;aAArBA,qBAAqB;;iCAVE,mCAAmC;sDACd,wDAAwD;kDA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AChCC,OAAAA,gBAAgB,CACd,QAAQ,EACRD,OAAO,EACPhB,QAAQ,CAACkB,IAAI,CAAC,CAACV,UAAU;oBAAKA,OAAAA,UAAU,CAACO,mBAAmB,QAAW,GAAzCP,KAAAA,CAAyC,GAAzCA,UAAU,CAACO,mBAAmB,CAAGC,OAAO,CAAC,CAAA;iBAAA,CAAC,CACzE,CAAA;aAAA;YACHG,qBAAqB,EAAE,CAACH,OAAY;gBAClCC,OAAAA,gBAAgB,CACd,UAAU,EACVD,OAAO,EACPhB,QAAQ,CAACkB,IAAI,CAAC,CAACV,UAAU;oBAAKA,OAAAA,UAAU,CAACW,qBAAqB,QAAW,GAA3CX,KAAAA,CAA2C,GAA3CA,UAAU,CAACW,qBAAqB,CAAGH,OAAO,CAAC,CAAA;iBAAA,CAAC,CAC3E,CAAA;aAAA;SACJ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAASC,gBAAgB,CAACG,IAA2B,EAAEJ,OAAY,EAAEK,MAAuB,EAAE;IAC5F,MAAMC,MAAM,GAAGD,MAAM,GAAG,SAAS,GAAG,SAAS,AAAC;IAC9C,MAAME,MAAM,GAAGH,IAAI,KAAK,QAAQ,GAAG,wBAAwB,GAAG,wBAAwB,AAAC;IAEvF,IAAI;QACF3B,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE8B,MAAM,EAAED,MAAM,EAAEE,IAAI,CAACC,SAAS,CAACT,OAAO,CAAC,CAAC,CAAC;IAC7D,EAAE,OAAM;QACNvB,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE8B,MAAM,EAAED,MAAM,EAAE,0BAA0B,CAAC,CAAC;IAChE,CAAC;IAED,OAAOD,MAAM,IAAIK,SAAS,CAAC;AAC7B,CAAC"}
@@ -2,13 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "NetworkResponseHandler", {
6
- enumerable: true,
7
- get: ()=>NetworkResponseHandler
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ NETWORK_RESPONSE_STORAGE: ()=>NETWORK_RESPONSE_STORAGE,
13
+ NetworkResponseHandler: ()=>NetworkResponseHandler
8
14
  });
9
15
  const _messageHandler = require("../MessageHandler");
16
+ const NETWORK_RESPONSE_STORAGE = new Map();
10
17
  class NetworkResponseHandler extends _messageHandler.MessageHandler {
11
- /** All known responses, mapped by request id */ storage = new Map();
18
+ /** All known responses, mapped by request id */ storage = NETWORK_RESPONSE_STORAGE;
12
19
  isEnabled() {
13
20
  return this.page.capabilities.nativeNetworkInspection !== true;
14
21
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/messageHandlers/NetworkResponse.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport { MessageHandler } from '../MessageHandler';\nimport type {\n CdpMessage,\n DeviceRequest,\n DebuggerRequest,\n DebuggerResponse,\n DeviceResponse,\n} from '../types';\n\nexport class NetworkResponseHandler extends MessageHandler {\n /** All known responses, mapped by request id */\n storage = new Map<string, DebuggerResponse<NetworkGetResponseBody>['result']>();\n\n isEnabled() {\n return this.page.capabilities.nativeNetworkInspection !== true;\n }\n\n handleDeviceMessage(message: DeviceRequest<NetworkReceivedResponseBody>) {\n if (message.method === 'Expo(Network.receivedResponseBody)') {\n const { requestId, ...requestInfo } = message.params;\n this.storage.set(requestId, requestInfo);\n return true;\n }\n\n return false;\n }\n\n handleDebuggerMessage(message: DebuggerRequest<NetworkGetResponseBody>) {\n if (\n message.method === 'Network.getResponseBody' &&\n this.storage.has(message.params.requestId)\n ) {\n return this.sendToDebugger<DeviceResponse<NetworkGetResponseBody>>({\n id: message.id,\n result: this.storage.get(message.params.requestId)!,\n });\n }\n\n return false;\n }\n}\n\n/** Custom message to transfer the response body data to the proxy */\nexport type NetworkReceivedResponseBody = CdpMessage<\n 'Expo(Network.receivedResponseBody)',\n Protocol.Network.GetResponseBodyRequest & Protocol.Network.GetResponseBodyResponse,\n never\n>;\n\n/** @see https://chromedevtools.github.io/devtools-protocol/1-2/Network/#method-getResponseBody */\nexport type NetworkGetResponseBody = CdpMessage<\n 'Network.getResponseBody',\n Protocol.Network.GetResponseBodyRequest,\n Protocol.Network.GetResponseBodyResponse\n>;\n"],"names":["NetworkResponseHandler","MessageHandler","storage","Map","isEnabled","page","capabilities","nativeNetworkInspection","handleDeviceMessage","message","method","requestId","requestInfo","params","set","handleDebuggerMessage","has","sendToDebugger","id","result","get"],"mappings":"AAAA;;;;+BAWaA,wBAAsB;;aAAtBA,sBAAsB;;gCATJ,mBAAmB;AAS3C,MAAMA,sBAAsB,SAASC,eAAc,eAAA;IACxD,8CAA8C,GAC9CC,OAAO,GAAG,IAAIC,GAAG,EAA8D,CAAC;IAEhFC,SAAS,GAAG;QACV,OAAO,IAAI,CAACC,IAAI,CAACC,YAAY,CAACC,uBAAuB,KAAK,IAAI,CAAC;IACjE;IAEAC,mBAAmB,CAACC,OAAmD,EAAE;QACvE,IAAIA,OAAO,CAACC,MAAM,KAAK,oCAAoC,EAAE;YAC3D,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGC,WAAW,EAAE,GAAGH,OAAO,CAACI,MAAM,AAAC;YACrD,IAAI,CAACX,OAAO,CAACY,GAAG,CAACH,SAAS,EAAEC,WAAW,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf;IAEAG,qBAAqB,CAACN,OAAgD,EAAE;QACtE,IACEA,OAAO,CAACC,MAAM,KAAK,yBAAyB,IAC5C,IAAI,CAACR,OAAO,CAACc,GAAG,CAACP,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC,EAC1C;YACA,OAAO,IAAI,CAACM,cAAc,CAAyC;gBACjEC,EAAE,EAAET,OAAO,CAACS,EAAE;gBACdC,MAAM,EAAE,IAAI,CAACjB,OAAO,CAACkB,GAAG,CAACX,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC;aACnD,CAAC,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACf;CACD"}
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/messageHandlers/NetworkResponse.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport { MessageHandler } from '../MessageHandler';\nimport type {\n CdpMessage,\n DeviceRequest,\n DebuggerRequest,\n DebuggerResponse,\n DeviceResponse,\n} from '../types';\n\n/**\n * The global network response storage, as a workaround for the network inspector.\n * @see createDebugMiddleware#createNetworkWebsocket\n */\nexport const NETWORK_RESPONSE_STORAGE = new Map<\n string,\n DebuggerResponse<NetworkGetResponseBody>['result']\n>();\n\nexport class NetworkResponseHandler extends MessageHandler {\n /** All known responses, mapped by request id */\n storage = NETWORK_RESPONSE_STORAGE;\n\n isEnabled() {\n return this.page.capabilities.nativeNetworkInspection !== true;\n }\n\n handleDeviceMessage(message: DeviceRequest<NetworkReceivedResponseBody>) {\n if (message.method === 'Expo(Network.receivedResponseBody)') {\n const { requestId, ...requestInfo } = message.params;\n this.storage.set(requestId, requestInfo);\n return true;\n }\n\n return false;\n }\n\n handleDebuggerMessage(message: DebuggerRequest<NetworkGetResponseBody>) {\n if (\n message.method === 'Network.getResponseBody' &&\n this.storage.has(message.params.requestId)\n ) {\n return this.sendToDebugger<DeviceResponse<NetworkGetResponseBody>>({\n id: message.id,\n result: this.storage.get(message.params.requestId)!,\n });\n }\n\n return false;\n }\n}\n\n/** Custom message to transfer the response body data to the proxy */\nexport type NetworkReceivedResponseBody = CdpMessage<\n 'Expo(Network.receivedResponseBody)',\n Protocol.Network.GetResponseBodyRequest & Protocol.Network.GetResponseBodyResponse,\n never\n>;\n\n/** @see https://chromedevtools.github.io/devtools-protocol/1-2/Network/#method-getResponseBody */\nexport type NetworkGetResponseBody = CdpMessage<\n 'Network.getResponseBody',\n Protocol.Network.GetResponseBodyRequest,\n Protocol.Network.GetResponseBodyResponse\n>;\n"],"names":["NETWORK_RESPONSE_STORAGE","NetworkResponseHandler","Map","MessageHandler","storage","isEnabled","page","capabilities","nativeNetworkInspection","handleDeviceMessage","message","method","requestId","requestInfo","params","set","handleDebuggerMessage","has","sendToDebugger","id","result","get"],"mappings":"AAAA;;;;;;;;;;;IAeaA,wBAAwB,MAAxBA,wBAAwB;IAKxBC,sBAAsB,MAAtBA,sBAAsB;;gCAlBJ,mBAAmB;AAa3C,MAAMD,wBAAwB,GAAG,IAAIE,GAAG,EAG5C,AAAC;AAEG,MAAMD,sBAAsB,SAASE,eAAc,eAAA;IACxD,8CAA8C,GAC9CC,OAAO,GAAGJ,wBAAwB,CAAC;IAEnCK,SAAS,GAAG;QACV,OAAO,IAAI,CAACC,IAAI,CAACC,YAAY,CAACC,uBAAuB,KAAK,IAAI,CAAC;IACjE;IAEAC,mBAAmB,CAACC,OAAmD,EAAE;QACvE,IAAIA,OAAO,CAACC,MAAM,KAAK,oCAAoC,EAAE;YAC3D,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGC,WAAW,EAAE,GAAGH,OAAO,CAACI,MAAM,AAAC;YACrD,IAAI,CAACV,OAAO,CAACW,GAAG,CAACH,SAAS,EAAEC,WAAW,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf;IAEAG,qBAAqB,CAACN,OAAgD,EAAE;QACtE,IACEA,OAAO,CAACC,MAAM,KAAK,yBAAyB,IAC5C,IAAI,CAACP,OAAO,CAACa,GAAG,CAACP,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC,EAC1C;YACA,OAAO,IAAI,CAACM,cAAc,CAAyC;gBACjEC,EAAE,EAAET,OAAO,CAACS,EAAE;gBACdC,MAAM,EAAE,IAAI,CAAChB,OAAO,CAACiB,GAAG,CAACX,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC;aACnD,CAAC,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC;IACf;CACD"}
@@ -255,7 +255,7 @@ function pruneCustomTransformOptions(filePath, transformOptions) {
255
255
  transformOptions.customTransformOptions.routerRoot = "app";
256
256
  }
257
257
  if (((ref2 = transformOptions.customTransformOptions) == null ? void 0 : ref2.asyncRoutes) && // The async routes settings are also used in `expo-router/_ctx.ios.js` (and other platform variants) via `process.env.EXPO_ROUTER_IMPORT_MODE`
258
- !(filePath.match(/\/expo-router\/_ctx\.(ios|android|web)\.js$/) || filePath.match(/\/expo-router\/build\/import-mode\/index\.js$/))) {
258
+ !(filePath.match(/\/expo-router\/_ctx/) || filePath.match(/\/expo-router\/build\//))) {
259
259
  delete transformOptions.customTransformOptions.asyncRoutes;
260
260
  }
261
261
  if (((ref3 = transformOptions.customTransformOptions) == null ? void 0 : ref3.clientBoundaries) && // The client boundaries are only used in `expo-router/virtual-client-boundaries.js` for production RSC exports.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport { getDefaultConfig, LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport http from 'http';\nimport type Metro from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport type { TransformOptions } from 'metro/src/DeltaBundler/Worker';\nimport MetroHmrServer from 'metro/src/HmrServer';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\n\nimport { createDevToolsPluginWebsocketEndpoint } from './DevToolsPluginWebsocketEndpoint';\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { attachAtlasAsync } from './debugging/attachAtlas';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { createMetroMiddleware } from './dev-server/createMetroMiddleware';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n// Wrap terminal and polyfill console.log so we can log during bundling without breaking the indicator.\nclass LogRespectingTerminal extends Terminal {\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream);\n\n const sendLog = (...args: any[]) => {\n this._logLines.push(\n // format args like console.log\n util.format(...args)\n );\n this._scheduleUpdate();\n\n // Flush the logs to the terminal immediately so logs at the end of the process are not lost.\n this.flush();\n };\n\n console.log = sendLog;\n console.info = sendLog;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp,\n isExporting,\n getMetroBundler,\n }: { exp: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (exp.experiments?.reactServerComponents) {\n process.env.EXPO_USE_METRO_REQUIRE = '1';\n process.env.EXPO_USE_FAST_RESOLVER = '1';\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const hasConfig = await resolveConfig(options.config, projectRoot);\n let config: ConfigT = {\n ...(await loadConfig(\n { cwd: projectRoot, projectRoot, ...options },\n // If the project does not have a metro.config.js, then we use the default config.\n hasConfig.isEmpty ? getDefaultConfig(projectRoot) : undefined\n )),\n reporter: {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n // @ts-expect-error: Set the global require cycle ignore patterns for SSR bundles. This won't work with custom global prefixes, but we don't use those.\n globalThis.__requireCycleIgnorePatterns = config.resolver?.requireCycleIgnorePatterns;\n\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n if (exp.experiments?.reactCompiler) {\n Log.warn(`Experimental React Compiler is enabled.`);\n }\n\n if (env.EXPO_UNSTABLE_TREE_SHAKING && !env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n throw new CommandError(\n 'EXPO_UNSTABLE_TREE_SHAKING requires EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH to be enabled.'\n );\n }\n\n if (env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n Log.warn(`Experimental bundle optimization is enabled.`);\n }\n if (env.EXPO_UNSTABLE_TREE_SHAKING) {\n Log.warn(`Experimental tree shaking is enabled.`);\n }\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n isExporting,\n isReactCanaryEnabled:\n (exp.experiments?.reactServerComponents || exp.experiments?.reactCanary) ?? false,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: !!exp.experiments?.reactServerComponents,\n getMetroBundler,\n });\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<LoadOptions, 'logger'>,\n {\n isExporting,\n exp = getConfig(metroBundler.projectRoot, {\n skipSDKVersionRequirement: true,\n }).exp,\n }: { isExporting: boolean; exp?: ExpoConfig }\n): Promise<{\n metro: Metro.Server;\n hmrServer: MetroHmrServer | null;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n {\n exp,\n isExporting,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n // Create the core middleware stack for Metro, including websocket listeners\n const { middleware, messagesSocket, eventsSocket, websocketEndpoints } =\n createMetroMiddleware(metroConfig);\n\n if (!isExporting) {\n // Enable correct CORS headers for Expo Router features\n prependMiddleware(middleware, createCorsMiddleware(exp));\n\n // Enable debug middleware for CDP-related debugging\n const { debugMiddleware, debugWebsocketEndpoints } = createDebugMiddleware(metroBundler);\n Object.assign(websocketEndpoints, debugWebsocketEndpoints);\n middleware.use(debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware());\n\n // TODO(cedric): `enhanceMiddleware` is deprecated, but is currently used to unify the middleware stacks\n // See: https://github.com/facebook/metro/commit/22e85fde85ec454792a1b70eba4253747a2587a9\n // See: https://github.com/facebook/metro/commit/d0d554381f119bb80ab09dbd6a1d310b54737e52\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n }\n\n // Attach Expo Atlas if enabled\n await attachAtlasAsync({\n isExporting,\n exp,\n projectRoot,\n middleware,\n metroConfig,\n // NOTE(cedric): reset the Atlas file once, and reuse it for static exports\n resetAtlasFile: isExporting,\n });\n\n const { server, hmrServer, metro } = await runServer(\n metroBundler,\n metroConfig,\n {\n websocketEndpoints: {\n ...websocketEndpoints,\n ...createDevToolsPluginWebsocketEndpoint(),\n },\n watch: !isExporting && isWatchEnabled(),\n },\n {\n mockServer: isExporting,\n }\n );\n\n // Patch transform file to remove inconvenient customTransformOptions which are only used in single well-known files.\n const originalTransformFile = metro\n .getBundler()\n .getBundler()\n .transformFile.bind(metro.getBundler().getBundler());\n\n metro.getBundler().getBundler().transformFile = async function (\n filePath: string,\n transformOptions: TransformOptions,\n fileBuffer?: Buffer\n ) {\n return originalTransformFile(\n filePath,\n pruneCustomTransformOptions(\n filePath,\n // Clone the options so we don't mutate the original.\n {\n ...transformOptions,\n customTransformOptions: {\n __proto__: null,\n ...transformOptions.customTransformOptions,\n },\n }\n ),\n fileBuffer\n );\n };\n\n setEventReporter(eventsSocket.reportMetroEvent);\n\n return {\n metro,\n hmrServer,\n server,\n middleware,\n messageSocket: messagesSocket,\n };\n}\n\n// TODO: Fork the entire transform function so we can simply regex the file contents for keywords instead.\nfunction pruneCustomTransformOptions(\n filePath: string,\n transformOptions: TransformOptions\n): TransformOptions {\n if (\n transformOptions.customTransformOptions?.dom &&\n // The only generated file that needs the dom root is `expo/dom/entry.js`\n !filePath.match(/expo\\/dom\\/entry\\.js$/)\n ) {\n // Clear the dom root option if we aren't transforming the magic entry file, this ensures\n // that cached artifacts from other DOM component bundles can be reused.\n transformOptions.customTransformOptions.dom = 'true';\n }\n\n if (\n transformOptions.customTransformOptions?.routerRoot &&\n // The router root is used all over expo-router (`process.env.EXPO_ROUTER_ABS_APP_ROOT`, `process.env.EXPO_ROUTER_APP_ROOT`) so we'll just ignore the entire package.\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n // Set to the default value.\n transformOptions.customTransformOptions.routerRoot = 'app';\n }\n if (\n transformOptions.customTransformOptions?.asyncRoutes &&\n // The async routes settings are also used in `expo-router/_ctx.ios.js` (and other platform variants) via `process.env.EXPO_ROUTER_IMPORT_MODE`\n !(\n filePath.match(/\\/expo-router\\/_ctx\\.(ios|android|web)\\.js$/) ||\n filePath.match(/\\/expo-router\\/build\\/import-mode\\/index\\.js$/)\n )\n ) {\n delete transformOptions.customTransformOptions.asyncRoutes;\n }\n\n if (\n transformOptions.customTransformOptions?.clientBoundaries &&\n // The client boundaries are only used in `expo-router/virtual-client-boundaries.js` for production RSC exports.\n !filePath.match(/\\/expo-router\\/virtual-client-boundaries\\.js$/)\n ) {\n delete transformOptions.customTransformOptions.clientBoundaries;\n }\n\n return transformOptions;\n}\n\n/**\n * Simplify and communicate if Metro is running without watching file updates,.\n * Exposed for testing.\n */\nexport function isWatchEnabled() {\n if (env.CI) {\n Log.log(\n chalk`Metro is running in CI mode, reloads are disabled. Remove {bold CI=true} to enable watch mode.`\n );\n }\n\n return !env.CI;\n}\n"],"names":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","LogRespectingTerminal","Terminal","constructor","stream","sendLog","args","_logLines","push","util","format","_scheduleUpdate","flush","console","log","info","terminal","process","stdout","projectRoot","options","exp","isExporting","getMetroBundler","config","reportEvent","experiments","reactServerComponents","env","EXPO_USE_METRO_REQUIRE","EXPO_USE_FAST_RESOLVER","serverRoot","getMetroServerRoot","terminalReporter","MetroTerminalReporter","hasConfig","resolveConfig","loadConfig","cwd","isEmpty","getDefaultConfig","undefined","reporter","update","event","globalThis","__requireCycleIgnorePatterns","resolver","requireCycleIgnorePatterns","transformer","publicPath","baseUrl","platformBundlers","getPlatformBundlers","reactCompiler","Log","warn","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","CommandError","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","isFastResolverEnabled","isReactCanaryEnabled","reactCanary","isNamedRequiresEnabled","isReactServerComponentsEnabled","setEventReporter","logger","metroBundler","getConfig","skipSDKVersionRequirement","metroConfig","metro","getBundler","middleware","messagesSocket","eventsSocket","websocketEndpoints","createMetroMiddleware","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","server","enhanceMiddleware","metroMiddleware","attachAtlasAsync","resetAtlasFile","hmrServer","runServer","createDevToolsPluginWebsocketEndpoint","watch","mockServer","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","reportMetroEvent","messageSocket","dom","match","routerRoot","asyncRoutes","clientBoundaries","CI","chalk"],"mappings":"AAAA;;;;;;;;;;;IA0DsBA,oBAAoB,MAApBA,oBAAoB;IA4FpBC,qBAAqB,MAArBA,qBAAqB;IA2K3BC,cAAc,MAAdA,cAAc;;;yBAjUQ,cAAc;;;;;;;yBACjB,oBAAoB;;;;;;;yBACT,oBAAoB;;;;;;;8DAChD,OAAO;;;;;;;yBAM0B,cAAc;;;;;;;yBACxC,YAAY;;;;;;;8DACpB,WAAW;;;;;;iDAE0B,mCAAmC;uCAEnD,yBAAyB;6BAC9B,yBAAyB;uCACpB,mCAAmC;uCACnC,oCAAoC;+BAChD,kBAAkB;wCACA,0BAA0B;qBAClD,cAAc;qBACd,oBAAoB;wBACX,uBAAuB;gCACf,8BAA8B;6CACvB,qDAAqD;2BAC/D,yBAAyB;kCACvB,qBAAqB;;;;;;AAOzD,uGAAuG;AACvG,MAAMC,qBAAqB,SAASC,UAAQ,EAAA,SAAA;IAC1CC,YAAYC,MAAkE,CAAE;QAC9E,KAAK,CAACA,MAAM,CAAC,CAAC;QAEd,MAAMC,OAAO,GAAG,CAAC,GAAGC,IAAI,AAAO,GAAK;YAClC,IAAI,CAACC,SAAS,CAACC,IAAI,CACjB,+BAA+B;YAC/BC,SAAI,EAAA,QAAA,CAACC,MAAM,IAAIJ,IAAI,CAAC,CACrB,CAAC;YACF,IAAI,CAACK,eAAe,EAAE,CAAC;YAEvB,6FAA6F;YAC7F,IAAI,CAACC,KAAK,EAAE,CAAC;QACf,CAAC,AAAC;QAEFC,OAAO,C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AAuC,CAAEU,WAAW,CAAA,IACpD,+IAA+I;IAC/I,CAAC,CACCX,QAAQ,CAACS,KAAK,+CAA+C,IAC7DT,QAAQ,CAACS,KAAK,iDAAiD,CAChE,EACD;QACA,OAAOR,gBAAgB,CAACG,sBAAsB,CAACO,WAAW,CAAC;IAC7D,CAAC;IAED,IACEV,CAAAA,CAAAA,IAAuC,GAAvCA,gBAAgB,CAACG,sBAAsB,SAAkB,GAAzDH,KAAAA,CAAyD,GAAzDA,IAAuC,CAAEW,gBAAgB,CAAA,IACzD,gHAAgH;IAChH,CAACZ,QAAQ,CAACS,KAAK,iDAAiD,EAChE;QACA,OAAOR,gBAAgB,CAACG,sBAAsB,CAACQ,gBAAgB,CAAC;IAClE,CAAC;IAED,OAAOX,gBAAgB,CAAC;AAC1B,CAAC;AAMM,SAASzG,cAAc,GAAG;IAC/B,IAAI4B,IAAG,IAAA,CAACyF,EAAE,EAAE;QACV9D,IAAG,IAAA,CAACzC,GAAG,CACLwG,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;IACJ,CAAC;IAED,OAAO,CAAC1F,IAAG,IAAA,CAACyF,EAAE,CAAC;AACjB,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport { getDefaultConfig, LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport http from 'http';\nimport type Metro from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport type { TransformOptions } from 'metro/src/DeltaBundler/Worker';\nimport MetroHmrServer from 'metro/src/HmrServer';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\n\nimport { createDevToolsPluginWebsocketEndpoint } from './DevToolsPluginWebsocketEndpoint';\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { attachAtlasAsync } from './debugging/attachAtlas';\nimport { createDebugMiddleware } from './debugging/createDebugMiddleware';\nimport { createMetroMiddleware } from './dev-server/createMetroMiddleware';\nimport { runServer } from './runServer-fork';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { createCorsMiddleware } from '../middleware/CorsMiddleware';\nimport { createJsInspectorMiddleware } from '../middleware/inspector/createJsInspectorMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { getPlatformBundlers } from '../platformBundlers';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n// Wrap terminal and polyfill console.log so we can log during bundling without breaking the indicator.\nclass LogRespectingTerminal extends Terminal {\n constructor(stream: import('node:net').Socket | import('node:stream').Writable) {\n super(stream);\n\n const sendLog = (...args: any[]) => {\n this._logLines.push(\n // format args like console.log\n util.format(...args)\n );\n this._scheduleUpdate();\n\n // Flush the logs to the terminal immediately so logs at the end of the process are not lost.\n this.flush();\n };\n\n console.log = sendLog;\n console.info = sendLog;\n }\n}\n\n// Share one instance of Terminal for all instances of Metro.\nconst terminal = new LogRespectingTerminal(process.stdout);\n\nexport async function loadMetroConfigAsync(\n projectRoot: string,\n options: LoadOptions,\n {\n exp,\n isExporting,\n getMetroBundler,\n }: { exp: ExpoConfig; isExporting: boolean; getMetroBundler: () => Bundler }\n) {\n let reportEvent: ((event: any) => void) | undefined;\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (exp.experiments?.reactServerComponents) {\n process.env.EXPO_USE_METRO_REQUIRE = '1';\n process.env.EXPO_USE_FAST_RESOLVER = '1';\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n const terminalReporter = new MetroTerminalReporter(serverRoot, terminal);\n\n const hasConfig = await resolveConfig(options.config, projectRoot);\n let config: ConfigT = {\n ...(await loadConfig(\n { cwd: projectRoot, projectRoot, ...options },\n // If the project does not have a metro.config.js, then we use the default config.\n hasConfig.isEmpty ? getDefaultConfig(projectRoot) : undefined\n )),\n reporter: {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n },\n };\n\n // @ts-expect-error: Set the global require cycle ignore patterns for SSR bundles. This won't work with custom global prefixes, but we don't use those.\n globalThis.__requireCycleIgnorePatterns = config.resolver?.requireCycleIgnorePatterns;\n\n if (isExporting) {\n // This token will be used in the asset plugin to ensure the path is correct for writing locally.\n // @ts-expect-error: typed as readonly.\n config.transformer.publicPath = `/assets?export_path=${\n (exp.experiments?.baseUrl ?? '') + '/assets'\n }`;\n } else {\n // @ts-expect-error: typed as readonly\n config.transformer.publicPath = '/assets/?unstable_path=.';\n }\n\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n if (exp.experiments?.reactCompiler) {\n Log.warn(`Experimental React Compiler is enabled.`);\n }\n\n if (env.EXPO_UNSTABLE_TREE_SHAKING && !env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n throw new CommandError(\n 'EXPO_UNSTABLE_TREE_SHAKING requires EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH to be enabled.'\n );\n }\n\n if (env.EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH) {\n Log.warn(`Experimental bundle optimization is enabled.`);\n }\n if (env.EXPO_UNSTABLE_TREE_SHAKING) {\n Log.warn(`Experimental tree shaking is enabled.`);\n }\n\n config = await withMetroMultiPlatformAsync(projectRoot, {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled: exp.experiments?.tsconfigPaths ?? true,\n isFastResolverEnabled: env.EXPO_USE_FAST_RESOLVER,\n isExporting,\n isReactCanaryEnabled:\n (exp.experiments?.reactServerComponents || exp.experiments?.reactCanary) ?? false,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: !!exp.experiments?.reactServerComponents,\n getMetroBundler,\n });\n\n return {\n config,\n setEventReporter: (logger: (event: any) => void) => (reportEvent = logger),\n reporter: terminalReporter,\n };\n}\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n metroBundler: MetroBundlerDevServer,\n options: Omit<LoadOptions, 'logger'>,\n {\n isExporting,\n exp = getConfig(metroBundler.projectRoot, {\n skipSDKVersionRequirement: true,\n }).exp,\n }: { isExporting: boolean; exp?: ExpoConfig }\n): Promise<{\n metro: Metro.Server;\n hmrServer: MetroHmrServer | null;\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n const projectRoot = metroBundler.projectRoot;\n\n const { config: metroConfig, setEventReporter } = await loadMetroConfigAsync(\n projectRoot,\n options,\n {\n exp,\n isExporting,\n getMetroBundler() {\n return metro.getBundler().getBundler();\n },\n }\n );\n\n // Create the core middleware stack for Metro, including websocket listeners\n const { middleware, messagesSocket, eventsSocket, websocketEndpoints } =\n createMetroMiddleware(metroConfig);\n\n if (!isExporting) {\n // Enable correct CORS headers for Expo Router features\n prependMiddleware(middleware, createCorsMiddleware(exp));\n\n // Enable debug middleware for CDP-related debugging\n const { debugMiddleware, debugWebsocketEndpoints } = createDebugMiddleware(metroBundler);\n Object.assign(websocketEndpoints, debugWebsocketEndpoints);\n middleware.use(debugMiddleware);\n middleware.use('/_expo/debugger', createJsInspectorMiddleware());\n\n // TODO(cedric): `enhanceMiddleware` is deprecated, but is currently used to unify the middleware stacks\n // See: https://github.com/facebook/metro/commit/22e85fde85ec454792a1b70eba4253747a2587a9\n // See: https://github.com/facebook/metro/commit/d0d554381f119bb80ab09dbd6a1d310b54737e52\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-expect-error: can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n }\n\n // Attach Expo Atlas if enabled\n await attachAtlasAsync({\n isExporting,\n exp,\n projectRoot,\n middleware,\n metroConfig,\n // NOTE(cedric): reset the Atlas file once, and reuse it for static exports\n resetAtlasFile: isExporting,\n });\n\n const { server, hmrServer, metro } = await runServer(\n metroBundler,\n metroConfig,\n {\n websocketEndpoints: {\n ...websocketEndpoints,\n ...createDevToolsPluginWebsocketEndpoint(),\n },\n watch: !isExporting && isWatchEnabled(),\n },\n {\n mockServer: isExporting,\n }\n );\n\n // Patch transform file to remove inconvenient customTransformOptions which are only used in single well-known files.\n const originalTransformFile = metro\n .getBundler()\n .getBundler()\n .transformFile.bind(metro.getBundler().getBundler());\n\n metro.getBundler().getBundler().transformFile = async function (\n filePath: string,\n transformOptions: TransformOptions,\n fileBuffer?: Buffer\n ) {\n return originalTransformFile(\n filePath,\n pruneCustomTransformOptions(\n filePath,\n // Clone the options so we don't mutate the original.\n {\n ...transformOptions,\n customTransformOptions: {\n __proto__: null,\n ...transformOptions.customTransformOptions,\n },\n }\n ),\n fileBuffer\n );\n };\n\n setEventReporter(eventsSocket.reportMetroEvent);\n\n return {\n metro,\n hmrServer,\n server,\n middleware,\n messageSocket: messagesSocket,\n };\n}\n\n// TODO: Fork the entire transform function so we can simply regex the file contents for keywords instead.\nfunction pruneCustomTransformOptions(\n filePath: string,\n transformOptions: TransformOptions\n): TransformOptions {\n if (\n transformOptions.customTransformOptions?.dom &&\n // The only generated file that needs the dom root is `expo/dom/entry.js`\n !filePath.match(/expo\\/dom\\/entry\\.js$/)\n ) {\n // Clear the dom root option if we aren't transforming the magic entry file, this ensures\n // that cached artifacts from other DOM component bundles can be reused.\n transformOptions.customTransformOptions.dom = 'true';\n }\n\n if (\n transformOptions.customTransformOptions?.routerRoot &&\n // The router root is used all over expo-router (`process.env.EXPO_ROUTER_ABS_APP_ROOT`, `process.env.EXPO_ROUTER_APP_ROOT`) so we'll just ignore the entire package.\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n // Set to the default value.\n transformOptions.customTransformOptions.routerRoot = 'app';\n }\n if (\n transformOptions.customTransformOptions?.asyncRoutes &&\n // The async routes settings are also used in `expo-router/_ctx.ios.js` (and other platform variants) via `process.env.EXPO_ROUTER_IMPORT_MODE`\n !(filePath.match(/\\/expo-router\\/_ctx/) || filePath.match(/\\/expo-router\\/build\\//))\n ) {\n delete transformOptions.customTransformOptions.asyncRoutes;\n }\n\n if (\n transformOptions.customTransformOptions?.clientBoundaries &&\n // The client boundaries are only used in `expo-router/virtual-client-boundaries.js` for production RSC exports.\n !filePath.match(/\\/expo-router\\/virtual-client-boundaries\\.js$/)\n ) {\n delete transformOptions.customTransformOptions.clientBoundaries;\n }\n\n return transformOptions;\n}\n\n/**\n * Simplify and communicate if Metro is running without watching file updates,.\n * Exposed for testing.\n */\nexport function isWatchEnabled() {\n if (env.CI) {\n Log.log(\n chalk`Metro is running in CI mode, reloads are disabled. Remove {bold CI=true} to enable watch mode.`\n );\n }\n\n return !env.CI;\n}\n"],"names":["loadMetroConfigAsync","instantiateMetroAsync","isWatchEnabled","LogRespectingTerminal","Terminal","constructor","stream","sendLog","args","_logLines","push","util","format","_scheduleUpdate","flush","console","log","info","terminal","process","stdout","projectRoot","options","exp","isExporting","getMetroBundler","config","reportEvent","experiments","reactServerComponents","env","EXPO_USE_METRO_REQUIRE","EXPO_USE_FAST_RESOLVER","serverRoot","getMetroServerRoot","terminalReporter","MetroTerminalReporter","hasConfig","resolveConfig","loadConfig","cwd","isEmpty","getDefaultConfig","undefined","reporter","update","event","globalThis","__requireCycleIgnorePatterns","resolver","requireCycleIgnorePatterns","transformer","publicPath","baseUrl","platformBundlers","getPlatformBundlers","reactCompiler","Log","warn","EXPO_UNSTABLE_TREE_SHAKING","EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH","CommandError","withMetroMultiPlatformAsync","isTsconfigPathsEnabled","tsconfigPaths","isFastResolverEnabled","isReactCanaryEnabled","reactCanary","isNamedRequiresEnabled","isReactServerComponentsEnabled","setEventReporter","logger","metroBundler","getConfig","skipSDKVersionRequirement","metroConfig","metro","getBundler","middleware","messagesSocket","eventsSocket","websocketEndpoints","createMetroMiddleware","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","server","enhanceMiddleware","metroMiddleware","attachAtlasAsync","resetAtlasFile","hmrServer","runServer","createDevToolsPluginWebsocketEndpoint","watch","mockServer","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","reportMetroEvent","messageSocket","dom","match","routerRoot","asyncRoutes","clientBoundaries","CI","chalk"],"mappings":"AAAA;;;;;;;;;;;IA0DsBA,oBAAoB,MAApBA,oBAAoB;IA4FpBC,qBAAqB,MAArBA,qBAAqB;IAwK3BC,cAAc,MAAdA,cAAc;;;yBA9TQ,cAAc;;;;;;;yBACjB,oBAAoB;;;;;;;yBACT,oBAAoB;;;;;;;8DAChD,OAAO;;;;;;;yBAM0B,cAAc;;;;;;;yBACxC,YAAY;;;;;;;8DACpB,WAAW;;;;;;iDAE0B,mCAAmC;uCAEnD,yBAAyB;6BAC9B,yBAAyB;uCACpB,mCAAmC;uCACnC,oCAAoC;+BAChD,kBAAkB;wCACA,0BAA0B;qBAClD,cAAc;qBACd,oBAAoB;wBACX,uBAAuB;gCACf,8BAA8B;6CACvB,qDAAqD;2BAC/D,yBAAyB;kCACvB,qBAAqB;;;;;;AAOzD,uGAAuG;AACvG,MAAMC,qBAAqB,SAASC,UAAQ,EAAA,SAAA;IAC1CC,YAAYC,MAAkE,CAAE;QAC9E,KAAK,CAACA,MAAM,CAAC,CAAC;QAEd,MAAMC,OAAO,GAAG,CAAC,GAAGC,IAAI,AAAO,GAAK;YAClC,IAAI,CAACC,SAAS,CAACC,IAAI,CACjB,+BAA+B;YAC/BC,SAAI,EAAA,QAAA,CAAC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gB,CAACG,sBAAsB,CAACM,UAAU,GAAG,KAAK,CAAC;IAC7D,CAAC;IACD,IACET,CAAAA,CAAAA,IAAuC,GAAvCA,gBAAgB,CAACG,sBAAsB,SAAa,GAApDH,KAAAA,CAAoD,GAApDA,IAAuC,CAAEU,WAAW,CAAA,IACpD,+IAA+I;IAC/I,CAAC,CAACX,QAAQ,CAACS,KAAK,uBAAuB,IAAIT,QAAQ,CAACS,KAAK,0BAA0B,CAAC,EACpF;QACA,OAAOR,gBAAgB,CAACG,sBAAsB,CAACO,WAAW,CAAC;IAC7D,CAAC;IAED,IACEV,CAAAA,CAAAA,IAAuC,GAAvCA,gBAAgB,CAACG,sBAAsB,SAAkB,GAAzDH,KAAAA,CAAyD,GAAzDA,IAAuC,CAAEW,gBAAgB,CAAA,IACzD,gHAAgH;IAChH,CAACZ,QAAQ,CAACS,KAAK,iDAAiD,EAChE;QACA,OAAOR,gBAAgB,CAACG,sBAAsB,CAACQ,gBAAgB,CAAC;IAClE,CAAC;IAED,OAAOX,gBAAgB,CAAC;AAC1B,CAAC;AAMM,SAASzG,cAAc,GAAG;IAC/B,IAAI4B,IAAG,IAAA,CAACyF,EAAE,EAAE;QACV9D,IAAG,IAAA,CAACzC,GAAG,CACLwG,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;IACJ,CAAC;IAED,OAAO,CAAC1F,IAAG,IAAA,CAACyF,EAAE,CAAC;AACjB,CAAC"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "evaluateJsFromCdpAsync", {
6
+ enumerable: true,
7
+ get: ()=>evaluateJsFromCdpAsync
8
+ });
9
+ function _ws() {
10
+ const data = require("ws");
11
+ _ws = function() {
12
+ return data;
13
+ };
14
+ return data;
15
+ }
16
+ const debug = require("debug")("expo:start:server:middleware:inspector:CdpClient");
17
+ function evaluateJsFromCdpAsync(webSocketDebuggerUrl, source, timeoutMs = 2000) {
18
+ const REQUEST_ID = 0;
19
+ let timeoutHandle;
20
+ return new Promise((resolve, reject)=>{
21
+ let settled = false;
22
+ const ws = new (_ws()).WebSocket(webSocketDebuggerUrl);
23
+ timeoutHandle = setTimeout(()=>{
24
+ debug(`[evaluateJsFromCdpAsync] Request timeout from ${webSocketDebuggerUrl}`);
25
+ reject(new Error("Request timeout"));
26
+ settled = true;
27
+ ws.close();
28
+ }, timeoutMs);
29
+ ws.on("open", ()=>{
30
+ ws.send(JSON.stringify({
31
+ id: REQUEST_ID,
32
+ method: "Runtime.evaluate",
33
+ params: {
34
+ expression: source
35
+ }
36
+ }));
37
+ });
38
+ ws.on("error", (e)=>{
39
+ debug(`[evaluateJsFromCdpAsync] Failed to connect ${webSocketDebuggerUrl}`, e);
40
+ reject(e);
41
+ settled = true;
42
+ clearTimeout(timeoutHandle);
43
+ ws.close();
44
+ });
45
+ ws.on("close", ()=>{
46
+ if (!settled) {
47
+ reject(new Error("WebSocket closed before response was received."));
48
+ clearTimeout(timeoutHandle);
49
+ }
50
+ });
51
+ ws.on("message", (data)=>{
52
+ debug(`[evaluateJsFromCdpAsync] message received from ${webSocketDebuggerUrl}: ${data.toString()}`);
53
+ try {
54
+ const response = JSON.parse(data.toString());
55
+ if (response.id === REQUEST_ID) {
56
+ if (response.error) {
57
+ reject(new Error(response.error.message));
58
+ } else if (response.result.result.type === "string") {
59
+ resolve(response.result.result.value);
60
+ } else {
61
+ resolve(undefined);
62
+ }
63
+ settled = true;
64
+ clearTimeout(timeoutHandle);
65
+ ws.close();
66
+ }
67
+ } catch (e) {
68
+ reject(e);
69
+ settled = true;
70
+ clearTimeout(timeoutHandle);
71
+ ws.close();
72
+ }
73
+ });
74
+ });
75
+ }
76
+
77
+ //# sourceMappingURL=CdpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/CdpClient.ts"],"sourcesContent":["import { WebSocket } from 'ws';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:inspector:CdpClient'\n) as typeof console.log;\n\nexport function evaluateJsFromCdpAsync(\n webSocketDebuggerUrl: string,\n source: string,\n timeoutMs: number = 2000\n): Promise<string | undefined> {\n const REQUEST_ID = 0;\n let timeoutHandle: NodeJS.Timeout;\n\n return new Promise((resolve, reject) => {\n let settled = false;\n const ws = new WebSocket(webSocketDebuggerUrl);\n\n timeoutHandle = setTimeout(() => {\n debug(`[evaluateJsFromCdpAsync] Request timeout from ${webSocketDebuggerUrl}`);\n reject(new Error('Request timeout'));\n settled = true;\n ws.close();\n }, timeoutMs);\n\n ws.on('open', () => {\n ws.send(\n JSON.stringify({\n id: REQUEST_ID,\n method: 'Runtime.evaluate',\n params: { expression: source },\n })\n );\n });\n\n ws.on('error', (e) => {\n debug(`[evaluateJsFromCdpAsync] Failed to connect ${webSocketDebuggerUrl}`, e);\n reject(e);\n settled = true;\n clearTimeout(timeoutHandle);\n ws.close();\n });\n\n ws.on('close', () => {\n if (!settled) {\n reject(new Error('WebSocket closed before response was received.'));\n clearTimeout(timeoutHandle);\n }\n });\n\n ws.on('message', (data) => {\n debug(\n `[evaluateJsFromCdpAsync] message received from ${webSocketDebuggerUrl}: ${data.toString()}`\n );\n try {\n const response = JSON.parse(data.toString());\n if (response.id === REQUEST_ID) {\n if (response.error) {\n reject(new Error(response.error.message));\n } else if (response.result.result.type === 'string') {\n resolve(response.result.result.value);\n } else {\n resolve(undefined);\n }\n settled = true;\n clearTimeout(timeoutHandle);\n ws.close();\n }\n } catch (e) {\n reject(e);\n settled = true;\n clearTimeout(timeoutHandle);\n ws.close();\n }\n });\n });\n}\n"],"names":["evaluateJsFromCdpAsync","debug","require","webSocketDebuggerUrl","source","timeoutMs","REQUEST_ID","timeoutHandle","Promise","resolve","reject","settled","ws","WebSocket","setTimeout","Error","close","on","send","JSON","stringify","id","method","params","expression","e","clearTimeout","data","toString","response","parse","error","message","result","type","value","undefined"],"mappings":"AAAA;;;;+BAMgBA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ACVd,OAAO,GAAG,IAAI,CAAC;gBACfe,YAAY,CAACnB,aAAa,CAAC,CAAC;gBAC5BK,EAAE,CAACI,KAAK,EAAE,CAAC;YACb,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -21,6 +21,7 @@ function _chalk() {
21
21
  };
22
22
  return data;
23
23
  }
24
+ const _cdpClient = require("./CdpClient");
24
25
  const _prompts = require("../../../../utils/prompts");
25
26
  const _pageIsSupported = require("../../metro/debugging/pageIsSupported");
26
27
  function _interopRequireDefault(obj) {
@@ -54,8 +55,19 @@ async function queryInspectorAppAsync(metroServerOrigin, appId) {
54
55
  async function queryAllInspectorAppsAsync(metroServerOrigin) {
55
56
  const resp = await fetch(`${metroServerOrigin}/json/list`);
56
57
  const apps = transformApps(await resp.json());
57
- // Only use targets with better reloading support
58
- return apps.filter((app)=>(0, _pageIsSupported.pageIsSupported)(app));
58
+ const results = [];
59
+ for (const app of apps){
60
+ // Only use targets with better reloading support
61
+ if (!(0, _pageIsSupported.pageIsSupported)(app)) {
62
+ continue;
63
+ }
64
+ // Hide targets that are marked as hidden from the inspector, e.g. instances from expo-dev-menu and expo-dev-launcher.
65
+ if (await appShouldBeIgnoredAsync(app)) {
66
+ continue;
67
+ }
68
+ results.push(app);
69
+ }
70
+ return results;
59
71
  }
60
72
  async function promptInspectorAppAsync(apps) {
61
73
  var ref;
@@ -97,5 +109,11 @@ function transformApps(apps) {
97
109
  return app;
98
110
  });
99
111
  }
112
+ const HIDE_FROM_INSPECTOR_ENV = "globalThis.__expo_hide_from_inspector__";
113
+ async function appShouldBeIgnoredAsync(app) {
114
+ const hideFromInspector = await (0, _cdpClient.evaluateJsFromCdpAsync)(app.webSocketDebuggerUrl, HIDE_FROM_INSPECTOR_ENV);
115
+ debug(`[appShouldBeIgnoredAsync] webSocketDebuggerUrl[${app.webSocketDebuggerUrl}] hideFromInspector[${hideFromInspector}]`);
116
+ return hideFromInspector !== undefined;
117
+ }
100
118
 
101
119
  //# sourceMappingURL=JsInspector.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/JsInspector.ts"],"sourcesContent":["import type { CustomMessageHandlerConnection } from '@react-native/dev-middleware';\nimport chalk from 'chalk';\n\nimport { selectAsync } from '../../../../utils/prompts';\nimport { pageIsSupported } from '../../metro/debugging/pageIsSupported';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:inspector:jsInspector'\n) as typeof console.log;\n\nexport interface MetroInspectorProxyApp {\n /** Unique device ID combined with the page ID */\n id: string;\n /** Information about the underlying CDP implementation, e.g. \"React Native Bridgeless [C++ connection]\" */\n title: string;\n /** The application ID that is currently running on the device, e.g. \"dev.expo.bareexpo\" */\n description: string;\n /** The CDP debugger type, which should always be \"node\" */\n type: 'node';\n /** The internal `devtools://..` URL for the debugger to connect to */\n devtoolsFrontendUrl: string;\n /** The websocket URL for the debugger to connect to */\n webSocketDebuggerUrl: string;\n /**\n * Human-readable device name\n * @since react-native@0.73\n */\n deviceName: string;\n /**\n * React Native specific information, like the unique device ID and native capabilities\n * @since react-native@0.74\n */\n reactNative?: {\n /** The unique device ID */\n logicalDeviceId: string;\n /** All supported native capabilities */\n capabilities: CustomMessageHandlerConnection['page']['capabilities'];\n };\n}\n\n/**\n * Launch the React Native DevTools by executing the `POST /open-debugger` request.\n * This endpoint is handled through `@react-native/dev-middleware`.\n */\nexport async function openJsInspector(metroBaseUrl: string, app: MetroInspectorProxyApp) {\n if (!app.reactNative?.logicalDeviceId) {\n debug('Failed to open React Native DevTools, target is missing device ID');\n return false;\n }\n\n const url = new URL('/open-debugger', metroBaseUrl);\n url.searchParams.set('appId', app.description);\n url.searchParams.set('device', app.reactNative.logicalDeviceId);\n url.searchParams.set('target', app.id);\n\n const response = await fetch(url, { method: 'POST' });\n if (!response.ok) {\n debug('Failed to open React Native DevTools, received response:', response.status);\n }\n\n return response.ok;\n}\n\nexport async function queryInspectorAppAsync(\n metroServerOrigin: string,\n appId: string\n): Promise<MetroInspectorProxyApp | null> {\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n return apps.find((app) => app.description === appId) ?? null;\n}\n\nexport async function queryAllInspectorAppsAsync(\n metroServerOrigin: string\n): Promise<MetroInspectorProxyApp[]> {\n const resp = await fetch(`${metroServerOrigin}/json/list`);\n const apps: MetroInspectorProxyApp[] = transformApps(await resp.json());\n // Only use targets with better reloading support\n return apps.filter((app) => pageIsSupported(app));\n}\n\nexport async function promptInspectorAppAsync(apps: MetroInspectorProxyApp[]) {\n if (apps.length === 1) {\n return apps[0];\n }\n\n // Check if multiple devices are connected with the same device names\n // In this case, append the actual app id (device ID + page number) to the prompt\n const hasDuplicateNames = apps.some(\n (app, index) => index !== apps.findIndex((other) => app.deviceName === other.deviceName)\n );\n\n const choices = apps.map((app) => {\n const name = app.deviceName ?? 'Unknown device';\n return {\n title: hasDuplicateNames ? chalk`${name}{dim - ${app.id}}` : name,\n value: app.id,\n app,\n };\n });\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n\n return choices.find((item) => item.value === value)?.app;\n}\n\n// The description of `React Native Experimental (Improved Chrome Reloads)` target is `don't use` from metro.\n// This function tries to transform the unmeaningful description to appId\nfunction transformApps(apps: MetroInspectorProxyApp[]): MetroInspectorProxyApp[] {\n const deviceIdToAppId: Record<string, string> = {};\n\n for (const app of apps) {\n if (app.description !== \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n const appId = app.description;\n deviceIdToAppId[deviceId] = appId;\n }\n }\n\n return apps.map((app) => {\n if (app.description === \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n app.description = deviceIdToAppId[deviceId] ?? app.description;\n }\n return app;\n });\n}\n"],"names":["openJsInspector","queryInspectorAppAsync","queryAllInspectorAppsAsync","promptInspectorAppAsync","debug","require","metroBaseUrl","app","reactNative","logicalDeviceId","url","URL","searchParams","set","description","id","response","fetch","method","ok","status","metroServerOrigin","appId","apps","find","resp","transformApps","json","filter","pageIsSupported","choices","length","hasDuplicateNames","some","index","findIndex","other","deviceName","map","name","title","chalk","value","selectAsync","item","deviceIdToAppId","deviceId","split"],"mappings":"AAAA;;;;;;;;;;;IA4CsBA,eAAe,MAAfA,eAAe;IAmBfC,sBAAsB,MAAtBA,sBAAsB;IAQtBC,0BAA0B,MAA1BA,0BAA0B;IAS1BC,uBAAuB,MAAvBA,uBAAuB;;;8DA/E3B,OAAO;;;;;;yBAEG,2BAA2B;iCACvB,uCAAuC;;;;;;AAEvE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,oDAAoD,CACrD,AAAsB,AAAC;AAoCjB,eAAeL,eAAe,CAACM,YAAoB,EAAEC,GAA2B,EAAE;QAClFA,GAAe;IAApB,IAAI,CAACA,CAAAA,CAAAA,GAAe,GAAfA,GAAG,CAACC,WAAW,SAAiB,GAAhCD,KAAAA,CAAgC,GAAhCA,GAAe,CAAEE,eAAe,CAAA,EAAE;QACrCL,KAAK,CAAC,mEAAmE,CAAC,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAMM,GAAG,GAAG,IAAIC,GAAG,CAAC,gBAAgB,EAAEL,YAAY,CAAC,AAAC;IACpDI,GAAG,CAACE,YAAY,CAACC,GAAG,CAAC,OAAO,EAAEN,GAAG,CAACO,WAAW,CAAC,CAAC;IAC/CJ,GAAG,CAACE,YAAY,CAACC,GAAG,CAAC,QAAQ,EAAEN,GAAG,CAACC,WAAW,CAACC,eAAe,CAAC,CAAC;IAChEC,GAAG,CAACE,YAAY,CAACC,GAAG,CAAC,QAAQ,EAAEN,GAAG,CAACQ,EAAE,CAAC,CAAC;IAEvC,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACP,GAAG,EAAE;QAAEQ,MAAM,EAAE,MAAM;KAAE,CAAC,AAAC;IACtD,IAAI,CAACF,QAAQ,CAACG,EAAE,EAAE;QAChBf,KAAK,CA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I,CAACe,GAAG,CAAC,CAAC/B,GAAG,GAAK;QACvB,IAAIA,GAAG,CAACO,WAAW,KAAK,WAAW,EAAE;gBAClBP,GAAe;YAAhC,MAAMuC,QAAQ,GAAGvC,CAAAA,CAAAA,GAAe,GAAfA,GAAG,CAACC,WAAW,SAAiB,GAAhCD,KAAAA,CAAgC,GAAhCA,GAAe,CAAEE,eAAe,CAAA,IAAIF,GAAG,CAACQ,EAAE,CAACgC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,AAAC;YAC1ExC,GAAG,CAACO,WAAW,GAAG+B,eAAe,CAACC,QAAQ,CAAC,IAAIvC,GAAG,CAACO,WAAW,CAAC;QACjE,CAAC;QACD,OAAOP,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/JsInspector.ts"],"sourcesContent":["import type { CustomMessageHandlerConnection } from '@react-native/dev-middleware';\nimport chalk from 'chalk';\n\nimport { evaluateJsFromCdpAsync } from './CdpClient';\nimport { selectAsync } from '../../../../utils/prompts';\nimport { pageIsSupported } from '../../metro/debugging/pageIsSupported';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:inspector:jsInspector'\n) as typeof console.log;\n\nexport interface MetroInspectorProxyApp {\n /** Unique device ID combined with the page ID */\n id: string;\n /** Information about the underlying CDP implementation, e.g. \"React Native Bridgeless [C++ connection]\" */\n title: string;\n /** The application ID that is currently running on the device, e.g. \"dev.expo.bareexpo\" */\n description: string;\n /** The CDP debugger type, which should always be \"node\" */\n type: 'node';\n /** The internal `devtools://..` URL for the debugger to connect to */\n devtoolsFrontendUrl: string;\n /** The websocket URL for the debugger to connect to */\n webSocketDebuggerUrl: string;\n /**\n * Human-readable device name\n * @since react-native@0.73\n */\n deviceName: string;\n /**\n * React Native specific information, like the unique device ID and native capabilities\n * @since react-native@0.74\n */\n reactNative?: {\n /** The unique device ID */\n logicalDeviceId: string;\n /** All supported native capabilities */\n capabilities: CustomMessageHandlerConnection['page']['capabilities'];\n };\n}\n\n/**\n * Launch the React Native DevTools by executing the `POST /open-debugger` request.\n * This endpoint is handled through `@react-native/dev-middleware`.\n */\nexport async function openJsInspector(metroBaseUrl: string, app: MetroInspectorProxyApp) {\n if (!app.reactNative?.logicalDeviceId) {\n debug('Failed to open React Native DevTools, target is missing device ID');\n return false;\n }\n\n const url = new URL('/open-debugger', metroBaseUrl);\n url.searchParams.set('appId', app.description);\n url.searchParams.set('device', app.reactNative.logicalDeviceId);\n url.searchParams.set('target', app.id);\n\n const response = await fetch(url, { method: 'POST' });\n if (!response.ok) {\n debug('Failed to open React Native DevTools, received response:', response.status);\n }\n\n return response.ok;\n}\n\nexport async function queryInspectorAppAsync(\n metroServerOrigin: string,\n appId: string\n): Promise<MetroInspectorProxyApp | null> {\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n return apps.find((app) => app.description === appId) ?? null;\n}\n\nexport async function queryAllInspectorAppsAsync(\n metroServerOrigin: string\n): Promise<MetroInspectorProxyApp[]> {\n const resp = await fetch(`${metroServerOrigin}/json/list`);\n const apps: MetroInspectorProxyApp[] = transformApps(await resp.json());\n const results: MetroInspectorProxyApp[] = [];\n for (const app of apps) {\n // Only use targets with better reloading support\n if (!pageIsSupported(app)) {\n continue;\n }\n // Hide targets that are marked as hidden from the inspector, e.g. instances from expo-dev-menu and expo-dev-launcher.\n if (await appShouldBeIgnoredAsync(app)) {\n continue;\n }\n results.push(app);\n }\n return results;\n}\n\nexport async function promptInspectorAppAsync(apps: MetroInspectorProxyApp[]) {\n if (apps.length === 1) {\n return apps[0];\n }\n\n // Check if multiple devices are connected with the same device names\n // In this case, append the actual app id (device ID + page number) to the prompt\n const hasDuplicateNames = apps.some(\n (app, index) => index !== apps.findIndex((other) => app.deviceName === other.deviceName)\n );\n\n const choices = apps.map((app) => {\n const name = app.deviceName ?? 'Unknown device';\n return {\n title: hasDuplicateNames ? chalk`${name}{dim - ${app.id}}` : name,\n value: app.id,\n app,\n };\n });\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n\n return choices.find((item) => item.value === value)?.app;\n}\n\n// The description of `React Native Experimental (Improved Chrome Reloads)` target is `don't use` from metro.\n// This function tries to transform the unmeaningful description to appId\nfunction transformApps(apps: MetroInspectorProxyApp[]): MetroInspectorProxyApp[] {\n const deviceIdToAppId: Record<string, string> = {};\n\n for (const app of apps) {\n if (app.description !== \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n const appId = app.description;\n deviceIdToAppId[deviceId] = appId;\n }\n }\n\n return apps.map((app) => {\n if (app.description === \"don't use\") {\n const deviceId = app.reactNative?.logicalDeviceId ?? app.id.split('-')[0];\n app.description = deviceIdToAppId[deviceId] ?? app.description;\n }\n return app;\n });\n}\n\nconst HIDE_FROM_INSPECTOR_ENV = 'globalThis.__expo_hide_from_inspector__';\n\nasync function appShouldBeIgnoredAsync(app: MetroInspectorProxyApp): Promise<boolean> {\n const hideFromInspector = await evaluateJsFromCdpAsync(\n app.webSocketDebuggerUrl,\n HIDE_FROM_INSPECTOR_ENV\n );\n debug(\n `[appShouldBeIgnoredAsync] webSocketDebuggerUrl[${app.webSocketDebuggerUrl}] hideFromInspector[${hideFromInspector}]`\n );\n return hideFromInspector !== undefined;\n}\n"],"names":["openJsInspector","queryInspectorAppAsync","queryAllInspectorAppsAsync","promptInspectorAppAsync","debug","require","metroBaseUrl","app","reactNative","logicalDeviceId","url","URL","searchParams","set","description","id","response","fetch","method","ok","status","metroServerOrigin","appId","apps","find","resp","transformApps","json","results","pageIsSupported","appShouldBeIgnoredAsync","push","choices","length","hasDuplicateNames","some","index","findIndex","other","deviceName","map","name","title","chalk","value","selectAsync","item","deviceIdToAppId","deviceId","split","HIDE_FROM_INSPECTOR_ENV","hideFromInspector","evaluateJsFromCdpAsync","webSocketDebuggerUrl","undefined"],"mappings":"AAAA;;;;;;;;;;;IA6CsBA,eAAe,MAAfA,eAAe;IAmBfC,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AAK,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAOC,IAAI,CAACiB,GAAG,CAAC,CAACjC,GAAG,GAAK;QACvB,IAAIA,GAAG,CAACO,WAAW,KAAK,WAAW,EAAE;gBAClBP,GAAe;YAAhC,MAAMyC,QAAQ,GAAGzC,CAAAA,CAAAA,GAAe,GAAfA,GAAG,CAACC,WAAW,SAAiB,GAAhCD,KAAAA,CAAgC,GAAhCA,GAAe,CAAEE,eAAe,CAAA,IAAIF,GAAG,CAACQ,EAAE,CAACkC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,AAAC;YAC1E1C,GAAG,CAACO,WAAW,GAAGiC,eAAe,CAACC,QAAQ,CAAC,IAAIzC,GAAG,CAACO,WAAW,CAAC;QACjE,CAAC;QACD,OAAOP,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM2C,uBAAuB,GAAG,yCAAyC,AAAC;AAE1E,eAAepB,uBAAuB,CAACvB,GAA2B,EAAoB;IACpF,MAAM4C,iBAAiB,GAAG,MAAMC,IAAAA,UAAsB,uBAAA,EACpD7C,GAAG,CAAC8C,oBAAoB,EACxBH,uBAAuB,CACxB,AAAC;IACF9C,KAAK,CACH,CAAC,+CAA+C,EAAEG,GAAG,CAAC8C,oBAAoB,CAAC,oBAAoB,EAAEF,iBAAiB,CAAC,CAAC,CAAC,CACtH,CAAC;IACF,OAAOA,iBAAiB,KAAKG,SAAS,CAAC;AACzC,CAAC"}
@@ -31,7 +31,7 @@ class FetchClient {
31
31
  this.headers = {
32
32
  accept: "application/json",
33
33
  "content-type": "application/json",
34
- "user-agent": `expo-cli/${"0.19.1"}`,
34
+ "user-agent": `expo-cli/${"0.19.3"}`,
35
35
  authorization: "Basic " + _nodeBuffer().Buffer.from(`${target}:`).toString("base64")
36
36
  };
37
37
  }
@@ -79,7 +79,7 @@ function createContext() {
79
79
  cpu: summarizeCpuInfo(),
80
80
  app: {
81
81
  name: "expo/cli",
82
- version: "0.19.1"
82
+ version: "0.19.3"
83
83
  },
84
84
  ci: _ciInfo().isCI ? {
85
85
  name: _ciInfo().name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/cli",
3
- "version": "0.19.1",
3
+ "version": "0.19.3",
4
4
  "description": "The Expo CLI",
5
5
  "main": "build/bin/cli",
6
6
  "bin": {
@@ -167,5 +167,5 @@
167
167
  "tree-kill": "^1.2.2",
168
168
  "tsd": "^0.28.1"
169
169
  },
170
- "gitHead": "0a07b965c4bef67e7718355a0dc770d524ad3cee"
170
+ "gitHead": "5ad642a63afa9190ceb4e57dd52c8bdf71d93dd8"
171
171
  }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "PageReloadHandler", {
6
- enumerable: true,
7
- get: ()=>PageReloadHandler
8
- });
9
- const _messageHandler = require("../MessageHandler");
10
- class PageReloadHandler extends _messageHandler.MessageHandler {
11
- constructor(connection, metroBundler){
12
- super(connection);
13
- this.metroBundler = metroBundler;
14
- }
15
- handleDebuggerMessage(message) {
16
- if (message.method === "Page.reload") {
17
- this.metroBundler.broadcastMessage("reload");
18
- return this.sendToDebugger({
19
- id: message.id
20
- });
21
- }
22
- return false;
23
- }
24
- }
25
-
26
- //# sourceMappingURL=PageReload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/messageHandlers/PageReload.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport type { MetroBundlerDevServer } from '../../MetroBundlerDevServer';\nimport { MessageHandler } from '../MessageHandler';\nimport type { CdpMessage, Connection, DebuggerRequest } from '../types';\n\nexport class PageReloadHandler extends MessageHandler {\n private metroBundler: Pick<MetroBundlerDevServer, 'broadcastMessage'>;\n\n constructor(\n connection: Connection,\n metroBundler: Pick<MetroBundlerDevServer, 'broadcastMessage'>\n ) {\n super(connection);\n this.metroBundler = metroBundler;\n }\n\n handleDebuggerMessage(message: DebuggerRequest<PageReload>) {\n if (message.method === 'Page.reload') {\n this.metroBundler.broadcastMessage('reload');\n return this.sendToDebugger({ id: message.id });\n }\n\n return false;\n }\n}\n\n/** @see https://chromedevtools.github.io/devtools-protocol/1-2/Page/#method-reload */\nexport type PageReload = CdpMessage<'Page.reload', Protocol.Page.ReloadRequest, never>;\n"],"names":["PageReloadHandler","MessageHandler","constructor","connection","metroBundler","handleDebuggerMessage","message","method","broadcastMessage","sendToDebugger","id"],"mappings":"AAAA;;;;+BAMaA,mBAAiB;;aAAjBA,iBAAiB;;gCAHC,mBAAmB;AAG3C,MAAMA,iBAAiB,SAASC,eAAc,eAAA;IAGnDC,YACEC,UAAsB,EACtBC,YAA6D,CAC7D;QACA,KAAK,CAACD,UAAU,CAAC,CAAC;QAClB,IAAI,CAACC,YAAY,GAAGA,YAAY,CAAC;IACnC;IAEAC,qBAAqB,CAACC,OAAoC,EAAE;QAC1D,IAAIA,OAAO,CAACC,MAAM,KAAK,aAAa,EAAE;YACpC,IAAI,CAACH,YAAY,CAACI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC7C,OAAO,IAAI,CAACC,cAAc,CAAC;gBAAEC,EAAE,EAAEJ,OAAO,CAACI,EAAE;aAAE,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,KAAK,CAAC;IACf;CACD"}