@expo/cli 0.22.26 → 0.22.28

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.
@@ -21,25 +21,23 @@ function _ws() {
21
21
  return data;
22
22
  }
23
23
  const _createHandlersFactory = require("./createHandlersFactory");
24
+ const _networkResponse = require("./messageHandlers/NetworkResponse");
24
25
  const _log = require("../../../../log");
25
26
  const _env = require("../../../../utils/env");
26
- const _networkResponse = require("./messageHandlers/NetworkResponse");
27
+ const _net = require("../../../../utils/net");
27
28
  function _interopRequireDefault(obj) {
28
29
  return obj && obj.__esModule ? obj : {
29
30
  default: obj
30
31
  };
31
32
  }
32
33
  const debug = require("debug")("expo:metro:debugging:middleware");
33
- function createDebugMiddleware(metroBundler) {
34
+ function createDebugMiddleware({ projectRoot , serverBaseUrl }) {
34
35
  // Load the React Native debugging tools from project
35
36
  // TODO: check if this works with isolated modules
36
37
  const { createDevMiddleware } = require("@react-native/dev-middleware");
37
38
  const { middleware , websocketEndpoints } = createDevMiddleware({
38
- projectRoot: metroBundler.projectRoot,
39
- serverBaseUrl: metroBundler.getUrlCreator().constructUrl({
40
- scheme: "http",
41
- hostType: "localhost"
42
- }),
39
+ projectRoot,
40
+ serverBaseUrl,
43
41
  logger: createLogger(_chalk().default.bold("Debug:")),
44
42
  unstable_customInspectorMessageHandler: (0, _createHandlersFactory.createHandlersFactory)(),
45
43
  unstable_experiments: {
@@ -50,10 +48,26 @@ function createDebugMiddleware(metroBundler) {
50
48
  enableOpenDebuggerRedirect: _env.env.EXPO_DEBUG
51
49
  }
52
50
  });
51
+ const debuggerWebsocketEndpoint = websocketEndpoints["/inspector/debug"];
53
52
  // NOTE(cedric): add a temporary websocket to handle Network-related CDP events
54
- websocketEndpoints["/inspector/network"] = createNetworkWebsocket(websocketEndpoints["/inspector/debug"]);
53
+ websocketEndpoints["/inspector/network"] = createNetworkWebsocket(debuggerWebsocketEndpoint);
54
+ // Explicitly limit debugger websocket to loopback requests
55
+ debuggerWebsocketEndpoint.on("connection", (socket, request)=>{
56
+ if (!(0, _net.isLocalSocket)(request.socket) || !(0, _net.isMatchingOrigin)(request, serverBaseUrl)) {
57
+ // NOTE: `socket.close` nicely closes the websocket, which will still allow incoming messages
58
+ // `socket.terminate` instead forcefully closes down the socket
59
+ socket.terminate();
60
+ }
61
+ });
55
62
  return {
56
- debugMiddleware: middleware,
63
+ debugMiddleware (req, res, next) {
64
+ // The debugger middleware is skipped entirely if the connection isn't a loopback request
65
+ if ((0, _net.isLocalSocket)(req.socket)) {
66
+ return middleware(req, res, next);
67
+ } else {
68
+ return next();
69
+ }
70
+ },
57
71
  debugWebsocketEndpoints: websocketEndpoints
58
72
  };
59
73
  }
@@ -86,7 +100,7 @@ function createLogger(logPrefix) {
86
100
  // If its a response body, write it to the global storage
87
101
  const { requestId , ...requestInfo } = message.params;
88
102
  _networkResponse.NETWORK_RESPONSE_STORAGE.set(requestId, requestInfo);
89
- } else {
103
+ } else if (message.method.startsWith("Network.")) {
90
104
  // Otherwise, directly re-broadcast the Network events to all connected debuggers
91
105
  debuggerWebsocket.clients.forEach((debuggerSocket)=>{
92
106
  if (debuggerSocket.readyState === debuggerSocket.OPEN) {
@@ -1 +1 @@
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\n .getUrlCreator()\n .constructUrl({ scheme: 'http', hostType: 'localhost' }),\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,qBAAqB,CAACG,YAAmC,EAAE;IACzE,qDAAqD;IACrD,kDAAkD;IAClD,MAAM,EAAEC,mBAAmB,CAAA,EAAE,GAC3BF,OAAO,CAAC,8BAA8B,CAAC,AAAiD,AAAC;IAE3F,MAAM,EAAEG,UAAU,CAAA,EAAEC,kBAAkB,CAAA,EAAE,GAAGF,mBAAmB,CAAC;QAC7DG,WAAW,EAAEJ,YAAY,CAACI,WAAW;QACrCC,aAAa,EAAEL,YAAY,CACxBM,aAAa,EAAE,CACfC,YAAY,CAAC;YAAEC,MAAM,EAAE,MAAM;YAAEC,QAAQ,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AE,CAACC,aAAa,GAAK;QACtCA,aAAa,CAACD,EAAE,CAAC,SAAS,EAAE,CAACE,IAAI,GAAK;YACpC,IAAI;gBACF,4EAA4E;gBAC5E,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,QAAQ,EAAE,CAAC,AAAC;gBAE5C,IAAIH,OAAO,CAACI,MAAM,KAAK,oCAAoC,IAAIJ,OAAO,CAACK,MAAM,EAAE;oBAC7E,yDAAyD;oBACzD,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGC,WAAW,EAAE,GAAGP,OAAO,CAACK,MAAM,AAAC;oBACrDG,gBAAwB,yBAAA,CAACC,GAAG,CAACH,SAAS,EAAEC,WAAW,CAAC,CAAC;gBACvD,OAAO;oBACL,iFAAiF;oBACjFhB,iBAAiB,CAACmB,OAAO,CAACC,OAAO,CAAC,CAACC,cAAc,GAAK;wBACpD,IAAIA,cAAc,CAACC,UAAU,KAAKD,cAAc,CAACE,IAAI,EAAE;4BACrDF,cAAc,CAACG,IAAI,CAAChB,IAAI,CAACI,QAAQ,EAAE,CAAC,CAAC;wBACvC,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,EAAE,OAAOb,KAAK,EAAE;gBACdhC,KAAK,CAAC,oCAAoC,EAAEgC,KAAK,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAOE,GAAG,CAAC;AACb,CAAC"}
1
+ {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/createDebugMiddleware.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { NextHandleFunction } from 'connect';\nimport { WebSocketServer } from 'ws';\n\nimport { createHandlersFactory } from './createHandlersFactory';\nimport { NETWORK_RESPONSE_STORAGE } from './messageHandlers/NetworkResponse';\nimport { Log } from '../../../../log';\nimport { env } from '../../../../utils/env';\nimport { isLocalSocket, isMatchingOrigin } from '../../../../utils/net';\n\nconst debug = require('debug')('expo:metro:debugging:middleware') as typeof console.log;\n\ninterface DebugMiddleware {\n debugMiddleware: NextHandleFunction;\n debugWebsocketEndpoints: Record<string, WebSocketServer>;\n}\n\ninterface DebugMiddlewareParams {\n projectRoot: string;\n serverBaseUrl: string;\n}\n\nexport function createDebugMiddleware({\n projectRoot,\n serverBaseUrl,\n}: DebugMiddlewareParams): DebugMiddleware {\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,\n serverBaseUrl,\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 const debuggerWebsocketEndpoint = websocketEndpoints['/inspector/debug'] as WebSocketServer;\n\n // NOTE(cedric): add a temporary websocket to handle Network-related CDP events\n websocketEndpoints['/inspector/network'] = createNetworkWebsocket(debuggerWebsocketEndpoint);\n\n // Explicitly limit debugger websocket to loopback requests\n debuggerWebsocketEndpoint.on('connection', (socket, request) => {\n if (!isLocalSocket(request.socket) || !isMatchingOrigin(request, serverBaseUrl)) {\n // NOTE: `socket.close` nicely closes the websocket, which will still allow incoming messages\n // `socket.terminate` instead forcefully closes down the socket\n socket.terminate();\n }\n });\n\n return {\n debugMiddleware(req, res, next) {\n // The debugger middleware is skipped entirely if the connection isn't a loopback request\n if (isLocalSocket(req.socket)) {\n return middleware(req, res, next);\n } else {\n return next();\n }\n },\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 if (message.method.startsWith('Network.')) {\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","projectRoot","serverBaseUrl","createDevMiddleware","middleware","websocketEndpoints","logger","createLogger","chalk","bold","unstable_customInspectorMessageHandler","createHandlersFactory","unstable_experiments","enableNetworkInspector","enableOpenDebuggerRedirect","env","EXPO_DEBUG","debuggerWebsocketEndpoint","createNetworkWebsocket","on","socket","request","isLocalSocket","isMatchingOrigin","terminate","debugMiddleware","req","res","next","debugWebsocketEndpoints","logPrefix","info","args","Log","log","warn","error","debuggerWebsocket","wss","WebSocketServer","noServer","perMessageDeflate","maxPayload","networkSocket","data","message","JSON","parse","toString","method","params","requestId","requestInfo","NETWORK_RESPONSE_ST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AACwB,aAAa,GAAK;QACtCA,aAAa,CAACxB,EAAE,CAAC,SAAS,EAAE,CAACyB,IAAI,GAAK;YACpC,IAAI;gBACF,4EAA4E;gBAC5E,MAAMC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,QAAQ,EAAE,CAAC,AAAC;gBAE5C,IAAIH,OAAO,CAACI,MAAM,KAAK,oCAAoC,IAAIJ,OAAO,CAACK,MAAM,EAAE;oBAC7E,yDAAyD;oBACzD,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGC,WAAW,EAAE,GAAGP,OAAO,CAACK,MAAM,AAAC;oBACrDG,gBAAwB,yBAAA,CAACC,GAAG,CAACH,SAAS,EAAEC,WAAW,CAAC,CAAC;gBACvD,OAAO,IAAIP,OAAO,CAACI,MAAM,CAACM,UAAU,CAAC,UAAU,CAAC,EAAE;oBAChD,iFAAiF;oBACjFlB,iBAAiB,CAACmB,OAAO,CAACC,OAAO,CAAC,CAACC,cAAc,GAAK;wBACpD,IAAIA,cAAc,CAACC,UAAU,KAAKD,cAAc,CAACE,IAAI,EAAE;4BACrDF,cAAc,CAACG,IAAI,CAACjB,IAAI,CAACI,QAAQ,EAAE,CAAC,CAAC;wBACvC,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,EAAE,OAAOZ,KAAK,EAAE;gBACdrC,KAAK,CAAC,oCAAoC,EAAEqC,KAAK,CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAOE,GAAG,CAAC;AACb,CAAC"}
@@ -219,11 +219,19 @@ async function instantiateMetroAsync(metroBundler, options, { isExporting , exp
219
219
  });
220
220
  // Create the core middleware stack for Metro, including websocket listeners
221
221
  const { middleware , messagesSocket , eventsSocket , websocketEndpoints } = (0, _createMetroMiddleware.createMetroMiddleware)(metroConfig);
222
+ // Get local URL to Metro bundler server (typically configured as 127.0.0.1:8081)
223
+ const serverBaseUrl = metroBundler.getUrlCreator().constructUrl({
224
+ scheme: "http",
225
+ hostType: "localhost"
226
+ });
222
227
  if (!isExporting) {
223
228
  // Enable correct CORS headers for Expo Router features
224
229
  (0, _mutations.prependMiddleware)(middleware, (0, _corsMiddleware.createCorsMiddleware)(exp));
225
230
  // Enable debug middleware for CDP-related debugging
226
- const { debugMiddleware , debugWebsocketEndpoints } = (0, _createDebugMiddleware.createDebugMiddleware)(metroBundler);
231
+ const { debugMiddleware , debugWebsocketEndpoints } = (0, _createDebugMiddleware.createDebugMiddleware)({
232
+ projectRoot: metroBundler.projectRoot,
233
+ serverBaseUrl
234
+ });
227
235
  Object.assign(websocketEndpoints, debugWebsocketEndpoints);
228
236
  middleware.use(debugMiddleware);
229
237
  middleware.use("/_expo/debugger", (0, _createJsInspectorMiddleware.createJsInspectorMiddleware)());
@@ -238,6 +246,8 @@ async function instantiateMetroAsync(metroBundler, options, { isExporting , exp
238
246
  }
239
247
  return middleware.use(metroMiddleware);
240
248
  };
249
+ const devtoolsWebsocketEndpoints = (0, _devToolsPluginWebsocketEndpoint.createDevToolsPluginWebsocketEndpoint)();
250
+ Object.assign(websocketEndpoints, devtoolsWebsocketEndpoints);
241
251
  }
242
252
  // Attach Expo Atlas if enabled
243
253
  await (0, _attachAtlas.attachAtlasAsync)({
@@ -250,10 +260,7 @@ async function instantiateMetroAsync(metroBundler, options, { isExporting , exp
250
260
  resetAtlasFile: isExporting
251
261
  });
252
262
  const { server , hmrServer , metro } = await (0, _runServerFork.runServer)(metroBundler, metroConfig, {
253
- websocketEndpoints: {
254
- ...websocketEndpoints,
255
- ...(0, _devToolsPluginWebsocketEndpoint.createDevToolsPluginWebsocketEndpoint)()
256
- },
263
+ websocketEndpoints,
257
264
  watch: !isExporting && isWatchEnabled()
258
265
  }, {
259
266
  mockServer: isExporting
@@ -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 { ReadOnlyGraph } from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport hmrJSBundle from 'metro/src/DeltaBundler/Serializers/hmrJSBundle';\nimport type { TransformOptions } from 'metro/src/DeltaBundler/Worker';\nimport MetroHmrServer from 'metro/src/HmrServer';\nimport RevisionNotFoundError from 'metro/src/IncrementalBundler/RevisionNotFoundError';\nimport formatBundlingError from 'metro/src/lib/formatBundlingError';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\nimport path from 'path';\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 const serverActionsEnabled =\n exp.experiments?.reactServerFunctions ?? env.EXPO_UNSTABLE_SERVER_FUNCTIONS;\n\n if (serverActionsEnabled) {\n process.env.EXPO_UNSTABLE_SERVER_FUNCTIONS = '1';\n }\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (exp.experiments?.reactServerComponentRoutes || serverActionsEnabled) {\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 if (serverActionsEnabled) {\n Log.warn(\n `Experimental React Server Functions are enabled. Production exports are not supported yet.`\n );\n if (!exp.experiments?.reactServerComponentRoutes) {\n Log.warn(\n `- React Server Component routes are NOT enabled. Routes will render in client mode.`\n );\n }\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?.reactServerComponentRoutes ||\n serverActionsEnabled ||\n exp.experiments?.reactCanary) ??\n false,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: !!exp.experiments?.reactServerComponentRoutes,\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 // This function ensures that modules in source maps are sorted in the same\n // order as in a plain JS bundle.\n metro._getSortedModules = function (this: Metro.Server, graph: ReadOnlyGraph) {\n const modules = [...graph.dependencies.values()];\n\n const ctx = {\n platform: graph.transformOptions.platform,\n environment: graph.transformOptions.customTransformOptions?.environment,\n };\n // Assign IDs to modules in a consistent order\n for (const module of modules) {\n // @ts-expect-error\n this._createModuleId(module.path, ctx);\n }\n // Sort by IDs\n return modules.sort(\n // @ts-expect-error\n (a, b) => this._createModuleId(a.path, ctx) - this._createModuleId(b.path, ctx)\n );\n };\n\n if (hmrServer) {\n // Patch HMR Server to send more info to the `_createModuleId` function for deterministic module IDs.\n hmrServer._prepareMessage = async function (this: MetroHmrServer, group, options, changeEvent) {\n // Fork of https://github.com/facebook/metro/blob/3b3e0aaf725cfa6907bf2c8b5fbc0da352d29efe/packages/metro/src/HmrServer.js#L327-L393\n // with patch for `_createModuleId`.\n const logger = !options.isInitialUpdate ? changeEvent?.logger : null;\n try {\n const revPromise = this._bundler.getRevision(group.revisionId);\n if (!revPromise) {\n return {\n type: 'error',\n body: formatBundlingError(new RevisionNotFoundError(group.revisionId)),\n };\n }\n logger?.point('updateGraph_start');\n const { revision, delta } = await this._bundler.updateGraph(await revPromise, false);\n logger?.point('updateGraph_end');\n this._clientGroups.delete(group.revisionId);\n group.revisionId = revision.id;\n for (const client of group.clients) {\n client.revisionIds = client.revisionIds.filter(\n (revisionId) => revisionId !== group.revisionId\n );\n client.revisionIds.push(revision.id);\n }\n this._clientGroups.set(group.revisionId, group);\n logger?.point('serialize_start');\n // NOTE(EvanBacon): This is the patch\n const moduleIdContext = {\n platform: revision.graph.transformOptions.platform,\n environment: revision.graph.transformOptions.customTransformOptions?.environment,\n };\n const hmrUpdate = hmrJSBundle(delta, revision.graph, {\n clientUrl: group.clientUrl,\n // NOTE(EvanBacon): This is also the patch\n createModuleId: (moduleId: string) => {\n // @ts-expect-error\n return this._createModuleId(moduleId, moduleIdContext);\n },\n includeAsyncPaths: group.graphOptions.lazy,\n projectRoot: this._config.projectRoot,\n serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,\n });\n logger?.point('serialize_end');\n return {\n type: 'update',\n body: {\n revisionId: revision.id,\n isInitialUpdate: options.isInitialUpdate,\n ...hmrUpdate,\n },\n };\n } catch (error: any) {\n const formattedError = formatBundlingError(error);\n this._config.reporter.update({\n type: 'bundling_error',\n error,\n });\n return {\n type: 'error',\n body: formattedError,\n };\n }\n };\n }\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 // Normalize the filepath for cross platform checking.\n filePath = filePath.split(path.sep).join('/');\n\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/metro-runtime/src/virtual.js` for production RSC exports.\n !filePath.match(/\\/@expo\\/metro-runtime\\/rsc\\/virtual\\.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","serverActionsEnabled","experiments","reactServerFunctions","env","EXPO_UNSTABLE_SERVER_FUNCTIONS","reactServerComponentRoutes","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","_getSortedModules","graph","modules","dependencies","values","ctx","platform","environment","module","_createModuleId","path","sort","a","b","_prepareMessage","group","changeEvent","isInitialUpdate","revision","revPromise","_bundler","getRevision","revisionId","type","body","formatBundlingError","RevisionNotFoundError","point","delta","updateGraph","_clientGroups","delete","id","client","clients","revisionIds","filter","set","moduleIdContext","hmrUpdate","hmrJSBundle","clientUrl","createModuleId","moduleId","includeAsyncPaths","graphOptions","lazy","_config","unstable_serverRoot","error","formattedError","messageSocket","split","sep","join","dom","match","routerRoot","asyncRoutes","clientBoundaries","CI","chalk"],"mappings":"AAAA;;;;;;;;;;;IA+DsBA,oBAAoB,MAApBA,oBAAoB;IAiHpBC,qBAAqB,MAArBA,qBAAqB;IAkQ3BC,cAAc,MAAdA,cAAc;;;yBAlbQ,cAAc;;;;;;;yBACjB,oBAAoB;;;;;;;yBACT,oBAAoB;;;;;;;8DAChD,OAAO;;;;;;;8DAKD,gDAAgD;;;;;;;8DAGtC,oDAAoD;;;;;;;8DACtD,mCAAmC;;;;;;;yBAChB,cAAc;;;;;;;yBACxC,YAAY;;;;;;;8DACpB,WAAW;;;;;;;8DACX,MAAM;;;;;;iDAE+B,mCAAmC;u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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 { ReadOnlyGraph } from 'metro';\nimport Bundler from 'metro/src/Bundler';\nimport hmrJSBundle from 'metro/src/DeltaBundler/Serializers/hmrJSBundle';\nimport type { TransformOptions } from 'metro/src/DeltaBundler/Worker';\nimport MetroHmrServer from 'metro/src/HmrServer';\nimport RevisionNotFoundError from 'metro/src/IncrementalBundler/RevisionNotFoundError';\nimport formatBundlingError from 'metro/src/lib/formatBundlingError';\nimport { loadConfig, resolveConfig, ConfigT } from 'metro-config';\nimport { Terminal } from 'metro-core';\nimport util from 'node:util';\nimport path from 'path';\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 const serverActionsEnabled =\n exp.experiments?.reactServerFunctions ?? env.EXPO_UNSTABLE_SERVER_FUNCTIONS;\n\n if (serverActionsEnabled) {\n process.env.EXPO_UNSTABLE_SERVER_FUNCTIONS = '1';\n }\n\n // NOTE: Enable all the experimental Metro flags when RSC is enabled.\n if (exp.experiments?.reactServerComponentRoutes || serverActionsEnabled) {\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 if (serverActionsEnabled) {\n Log.warn(\n `Experimental React Server Functions are enabled. Production exports are not supported yet.`\n );\n if (!exp.experiments?.reactServerComponentRoutes) {\n Log.warn(\n `- React Server Component routes are NOT enabled. Routes will render in client mode.`\n );\n }\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?.reactServerComponentRoutes ||\n serverActionsEnabled ||\n exp.experiments?.reactCanary) ??\n false,\n isNamedRequiresEnabled: env.EXPO_USE_METRO_REQUIRE,\n isReactServerComponentsEnabled: !!exp.experiments?.reactServerComponentRoutes,\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 // Get local URL to Metro bundler server (typically configured as 127.0.0.1:8081)\n const serverBaseUrl = metroBundler\n .getUrlCreator()\n .constructUrl({ scheme: 'http', hostType: 'localhost' });\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({\n projectRoot: metroBundler.projectRoot,\n serverBaseUrl,\n });\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 const devtoolsWebsocketEndpoints = createDevToolsPluginWebsocketEndpoint();\n Object.assign(websocketEndpoints, devtoolsWebsocketEndpoints);\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 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 // This function ensures that modules in source maps are sorted in the same\n // order as in a plain JS bundle.\n metro._getSortedModules = function (this: Metro.Server, graph: ReadOnlyGraph) {\n const modules = [...graph.dependencies.values()];\n\n const ctx = {\n platform: graph.transformOptions.platform,\n environment: graph.transformOptions.customTransformOptions?.environment,\n };\n // Assign IDs to modules in a consistent order\n for (const module of modules) {\n // @ts-expect-error\n this._createModuleId(module.path, ctx);\n }\n // Sort by IDs\n return modules.sort(\n // @ts-expect-error\n (a, b) => this._createModuleId(a.path, ctx) - this._createModuleId(b.path, ctx)\n );\n };\n\n if (hmrServer) {\n // Patch HMR Server to send more info to the `_createModuleId` function for deterministic module IDs.\n hmrServer._prepareMessage = async function (this: MetroHmrServer, group, options, changeEvent) {\n // Fork of https://github.com/facebook/metro/blob/3b3e0aaf725cfa6907bf2c8b5fbc0da352d29efe/packages/metro/src/HmrServer.js#L327-L393\n // with patch for `_createModuleId`.\n const logger = !options.isInitialUpdate ? changeEvent?.logger : null;\n try {\n const revPromise = this._bundler.getRevision(group.revisionId);\n if (!revPromise) {\n return {\n type: 'error',\n body: formatBundlingError(new RevisionNotFoundError(group.revisionId)),\n };\n }\n logger?.point('updateGraph_start');\n const { revision, delta } = await this._bundler.updateGraph(await revPromise, false);\n logger?.point('updateGraph_end');\n this._clientGroups.delete(group.revisionId);\n group.revisionId = revision.id;\n for (const client of group.clients) {\n client.revisionIds = client.revisionIds.filter(\n (revisionId) => revisionId !== group.revisionId\n );\n client.revisionIds.push(revision.id);\n }\n this._clientGroups.set(group.revisionId, group);\n logger?.point('serialize_start');\n // NOTE(EvanBacon): This is the patch\n const moduleIdContext = {\n platform: revision.graph.transformOptions.platform,\n environment: revision.graph.transformOptions.customTransformOptions?.environment,\n };\n const hmrUpdate = hmrJSBundle(delta, revision.graph, {\n clientUrl: group.clientUrl,\n // NOTE(EvanBacon): This is also the patch\n createModuleId: (moduleId: string) => {\n // @ts-expect-error\n return this._createModuleId(moduleId, moduleIdContext);\n },\n includeAsyncPaths: group.graphOptions.lazy,\n projectRoot: this._config.projectRoot,\n serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,\n });\n logger?.point('serialize_end');\n return {\n type: 'update',\n body: {\n revisionId: revision.id,\n isInitialUpdate: options.isInitialUpdate,\n ...hmrUpdate,\n },\n };\n } catch (error: any) {\n const formattedError = formatBundlingError(error);\n this._config.reporter.update({\n type: 'bundling_error',\n error,\n });\n return {\n type: 'error',\n body: formattedError,\n };\n }\n };\n }\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 // Normalize the filepath for cross platform checking.\n filePath = filePath.split(path.sep).join('/');\n\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/metro-runtime/src/virtual.js` for production RSC exports.\n !filePath.match(/\\/@expo\\/metro-runtime\\/rsc\\/virtual\\.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","serverActionsEnabled","experiments","reactServerFunctions","env","EXPO_UNSTABLE_SERVER_FUNCTIONS","reactServerComponentRoutes","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","serverBaseUrl","getUrlCreator","constructUrl","scheme","hostType","prependMiddleware","createCorsMiddleware","debugMiddleware","debugWebsocketEndpoints","createDebugMiddleware","Object","assign","use","createJsInspectorMiddleware","customEnhanceMiddleware","server","enhanceMiddleware","metroMiddleware","devtoolsWebsocketEndpoints","createDevToolsPluginWebsocketEndpoint","attachAtlasAsync","resetAtlasFile","hmrServer","runServer","watch","mockServer","originalTransformFile","transformFile","bind","filePath","transformOptions","fileBuffer","pruneCustomTransformOptions","customTransformOptions","__proto__","reportMetroEvent","_getSortedModules","graph","modules","dependencies","values","ctx","platform","environment","module","_createModuleId","path","sort","a","b","_prepareMessage","group","changeEvent","isInitialUpdate","revision","revPromise","_bundler","getRevision","revisionId","type","body","formatBundlingError","RevisionNotFoundError","point","delta","updateGraph","_clientGroups","delete","id","client","clients","revisionIds","filter","set","moduleIdContext","hmrUpdate","hmrJSBundle","clientUrl","createModuleId","moduleId","includeAsyncPaths","graphOptions","lazy","_config","unstable_serverRoot","error","formattedError","messageSocket","split","sep","join","dom","match","routerRoot","asyncRoutes","clientBoundaries","CI","chalk"],"mappings":"AAAA;;;;;;;;;;;IA+DsBA,oBAAoB,MAApBA,oBAAoB;IAiHp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A,CAAAA,IAAuC,GAAvCA,gBAAgB,CAACG,sBAAsB,SAAkB,GAAzDH,KAAAA,CAAyD,GAAzDA,IAAuC,CAAEiE,gBAAgB,CAAA,IACzD,0GAA0G;IAC1G,CAAClE,QAAQ,CAAC+D,KAAK,6CAA6C,EAC5D;QACA,OAAO9D,gBAAgB,CAACG,sBAAsB,CAAC8D,gBAAgB,CAAC;IAClE,CAAC;IAED,OAAOjE,gBAAgB,CAAC;AAC1B,CAAC;AAMM,SAASlH,cAAc,GAAG;IAC/B,IAAI6B,IAAG,IAAA,CAACuJ,EAAE,EAAE;QACV1H,IAAG,IAAA,CAAC5C,GAAG,CACLuK,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,8FAA8F,CAAC,CACtG,CAAC;IACJ,CAAC;IAED,OAAO,CAACxJ,IAAG,IAAA,CAACuJ,EAAE,CAAC;AACjB,CAAC"}
@@ -32,19 +32,51 @@ function _interopRequireDefault(obj) {
32
32
  };
33
33
  }
34
34
  const debug = require("debug")("expo:start:server:middleware:createFile");
35
+ const ROUTER_INDEX_CONTENTS = `import { StyleSheet, Text, View } from "react-native";
36
+
37
+ export default function Page() {
38
+ return (
39
+ <View style={styles.container}>
40
+ <View style={styles.main}>
41
+ <Text style={styles.title}>Hello World</Text>
42
+ <Text style={styles.subtitle}>This is the first page of your app.</Text>
43
+ </View>
44
+ </View>
45
+ );
46
+ }
47
+
48
+ const styles = StyleSheet.create({
49
+ container: {
50
+ flex: 1,
51
+ alignItems: "center",
52
+ padding: 24,
53
+ },
54
+ main: {
55
+ flex: 1,
56
+ justifyContent: "center",
57
+ maxWidth: 960,
58
+ marginHorizontal: "auto",
59
+ },
60
+ title: {
61
+ fontSize: 64,
62
+ fontWeight: "bold",
63
+ },
64
+ subtitle: {
65
+ fontSize: 36,
66
+ color: "#38434D",
67
+ },
68
+ });
69
+ `;
35
70
  class CreateFileMiddleware extends _expoMiddleware.ExpoMiddleware {
36
- constructor(projectRoot){
37
- super(projectRoot, [
71
+ constructor(options){
72
+ super(options.projectRoot, [
38
73
  "/_expo/touch"
39
74
  ]);
40
- this.projectRoot = projectRoot;
75
+ this.options = options;
41
76
  }
42
- resolvePath(inputPath) {
43
- return this.resolveExtension(_path().default.join(this.projectRoot, inputPath));
44
- }
45
- resolveExtension(inputPath) {
46
- let resolvedPath = inputPath;
47
- const extension = _path().default.extname(inputPath);
77
+ resolveExtension(basePath, relativePath) {
78
+ let resolvedPath = relativePath;
79
+ const extension = _path().default.extname(relativePath);
48
80
  if (extension === ".js") {
49
81
  // Automatically convert JS files to TS files when added to a project
50
82
  // with TypeScript.
@@ -53,7 +85,7 @@ class CreateFileMiddleware extends _expoMiddleware.ExpoMiddleware {
53
85
  resolvedPath = resolvedPath.replace(/\.js$/, ".tsx");
54
86
  }
55
87
  }
56
- return resolvedPath;
88
+ return _path().default.join(basePath, resolvedPath);
57
89
  }
58
90
  async parseRawBody(req) {
59
91
  const rawBody = await new Promise((resolve, reject)=>{
@@ -68,19 +100,26 @@ class CreateFileMiddleware extends _expoMiddleware.ExpoMiddleware {
68
100
  reject(err);
69
101
  });
70
102
  });
71
- const properties = JSON.parse(rawBody);
72
- this.assertTouchFileBody(properties);
73
- return properties;
74
- }
75
- assertTouchFileBody(body) {
103
+ const body = JSON.parse(rawBody);
76
104
  if (typeof body !== "object" || body == null) {
77
105
  throw new Error("Expected object");
106
+ } else if (typeof body.type !== "string") {
107
+ throw new Error('Expected "type" in body to be string');
78
108
  }
79
- if (typeof body.path !== "string") {
80
- throw new Error('Expected "path" in body to be string');
109
+ switch(body.type){
110
+ case "router_index":
111
+ return body;
112
+ default:
113
+ throw new Error('Unknown "type" passed in body');
81
114
  }
82
- if (typeof body.contents !== "string") {
83
- throw new Error('Expected "contents" in body to be string');
115
+ }
116
+ makeOutputForInput(input) {
117
+ switch(input.type){
118
+ case "router_index":
119
+ return {
120
+ absolutePath: this.resolveExtension(this.options.appDir, "index.js"),
121
+ contents: ROUTER_INDEX_CONTENTS
122
+ };
84
123
  }
85
124
  }
86
125
  async handleRequestAsync(req, res) {
@@ -99,18 +138,18 @@ class CreateFileMiddleware extends _expoMiddleware.ExpoMiddleware {
99
138
  return;
100
139
  }
101
140
  debug(`Requested: %O`, properties);
102
- const resolvedPath = properties.absolutePath ? this.resolveExtension(_path().default.resolve(properties.absolutePath)) : this.resolvePath(properties.path);
103
- if (_fs().default.existsSync(resolvedPath)) {
141
+ const file = this.makeOutputForInput(properties);
142
+ if (_fs().default.existsSync(file.absolutePath)) {
104
143
  res.statusCode = 409;
105
144
  res.end("File already exists.");
106
145
  return;
107
146
  }
108
- debug(`Resolved path:`, resolvedPath);
147
+ debug(`Resolved path:`, file.absolutePath);
109
148
  try {
110
- await _fs().default.promises.mkdir(_path().default.dirname(resolvedPath), {
149
+ await _fs().default.promises.mkdir(_path().default.dirname(file.absolutePath), {
111
150
  recursive: true
112
151
  });
113
- await _fs().default.promises.writeFile(resolvedPath, properties.contents, "utf8");
152
+ await _fs().default.promises.writeFile(file.absolutePath, file.contents, "utf8");
114
153
  } catch (e1) {
115
154
  debug("Error writing file", e1);
116
155
  res.statusCode = 500;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/CreateFileMiddleware.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport path from 'path';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:createFile') as typeof console.log;\n\nexport type TouchFileBody = {\n /** @deprecated */\n path: string;\n absolutePath?: string;\n contents: string;\n};\n\n/**\n * Middleware for creating a file given a `POST` request with\n * `{ contents: string, path: string }` in the body.\n */\nexport class CreateFileMiddleware extends ExpoMiddleware {\n constructor(protected projectRoot: string) {\n super(projectRoot, ['/_expo/touch']);\n }\n\n protected resolvePath(inputPath: string): string {\n return this.resolveExtension(path.join(this.projectRoot, inputPath));\n }\n\n protected resolveExtension(inputPath: string): string {\n let resolvedPath = inputPath;\n const extension = path.extname(inputPath);\n if (extension === '.js') {\n // Automatically convert JS files to TS files when added to a project\n // with TypeScript.\n const tsconfigPath = path.join(this.projectRoot, 'tsconfig.json');\n if (fs.existsSync(tsconfigPath)) {\n resolvedPath = resolvedPath.replace(/\\.js$/, '.tsx');\n }\n }\n\n return resolvedPath;\n }\n\n protected async parseRawBody(req: ServerRequest): Promise<TouchFileBody> {\n const rawBody = await new Promise<string>((resolve, reject) => {\n let body = '';\n req.on('data', (chunk) => {\n body += chunk.toString();\n });\n req.on('end', () => {\n resolve(body);\n });\n req.on('error', (err) => {\n reject(err);\n });\n });\n\n const properties = JSON.parse(rawBody);\n this.assertTouchFileBody(properties);\n\n return properties;\n }\n\n private assertTouchFileBody(body: any): asserts body is TouchFileBody {\n if (typeof body !== 'object' || body == null) {\n throw new Error('Expected object');\n }\n if (typeof body.path !== 'string') {\n throw new Error('Expected \"path\" in body to be string');\n }\n if (typeof body.contents !== 'string') {\n throw new Error('Expected \"contents\" in body to be string');\n }\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n if (req.method !== 'POST') {\n res.statusCode = 405;\n res.end('Method Not Allowed');\n return;\n }\n\n let properties: TouchFileBody;\n\n try {\n properties = await this.parseRawBody(req);\n } catch (e) {\n debug('Error parsing request body', e);\n res.statusCode = 400;\n res.end('Bad Request');\n return;\n }\n\n debug(`Requested: %O`, properties);\n\n const resolvedPath = properties.absolutePath\n ? this.resolveExtension(path.resolve(properties.absolutePath))\n : this.resolvePath(properties.path);\n\n if (fs.existsSync(resolvedPath)) {\n res.statusCode = 409;\n res.end('File already exists.');\n return;\n }\n\n debug(`Resolved path:`, resolvedPath);\n\n try {\n await fs.promises.mkdir(path.dirname(resolvedPath), { recursive: true });\n await fs.promises.writeFile(resolvedPath, properties.contents, 'utf8');\n } catch (e) {\n debug('Error writing file', e);\n res.statusCode = 500;\n res.end('Error writing file.');\n return;\n }\n\n debug(`File created`);\n res.statusCode = 200;\n res.end('OK');\n }\n}\n"],"names":["CreateFileMiddleware","debug","require","ExpoMiddleware","constructor","projectRoot","resolvePath","inputPath","resolveExtension","path","join","resolvedPath","extension","extname","tsconfigPath","fs","existsSync","replace","parseRawBody","req","rawBody","Promise","resolve","reject","body","on","chunk","toString","err","properties","JSON","parse","assertTouchFileBody","Error","contents","handleRequestAsync","res","method","statusCode","end","e","absolutePath","promises","mkdir","dirname","recursive","writeFile"],"mappings":"AAAA;;;;;CAKC,GACD;;;;+BAmBaA,sBAAoB;;aAApBA,oBAAoB;;;8DAnBlB,IAAI;;;;;;;8DACF,MAAM;;;;;;gCAEQ,kBAAkB;;;;;;AAGjD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yCAAyC,CAAC,AAAsB,AAAC;AAazF,MAAMF,oBAAoB,SAASG,eAAc,eAAA;IACtDC,YAAsBC,WAAmB,CAAE;QACzC,KAAK,CAACA,WAAW,EAAE;YAAC,cAAc;SAAC,CAAC,CAAC;QADjBA,mBAAAA,WAAmB,CAAA;IAEzC;IAEUC,WAAW,CAACC,SAAiB,EAAU;QAC/C,OAAO,IAAI,CAACC,gBAAgB,CAACC,KAAI,EAAA,QAAA,CAACC,IAAI,CAAC,IAAI,CAACL,WAAW,EAAEE,SAAS,CAAC,CAAC,CAAC;IACvE;IAEUC,gBAAgB,CAACD,SAAiB,EAAU;QACpD,IAAII,YAAY,GAAGJ,SAAS,AAAC;QAC7B,MAAMK,SAAS,GAAGH,KAAI,EAAA,QAAA,CAACI,OAAO,CAACN,SAAS,CAAC,AAAC;QAC1C,IAAIK,SAAS,KAAK,KAAK,EAAE;YACvB,qEAAqE;YACrE,mBAAmB;YACnB,MAAME,YAAY,GAAGL,KAAI,EAAA,QAAA,CAACC,IAAI,CAAC,IAAI,CAACL,WAAW,EAAE,eAAe,CAAC,AAAC;YAClE,IAAIU,GAAE,EAAA,QAAA,CAAC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AE;gBAAEkC,SAAS,EAAE,IAAI;aAAE,CAAC,CAAC;YACzE,MAAM9B,GAAE,EAAA,QAAA,CAAC2B,QAAQ,CAACI,SAAS,CAACnC,YAAY,EAAEkB,UAAU,CAACK,QAAQ,EAAE,MAAM,CAAC,CAAC;QACzE,EAAE,OAAOM,EAAC,EAAE;YACVvC,KAAK,CAAC,oBAAoB,EAAEuC,EAAC,CAAC,CAAC;YAC/BJ,GAAG,CAACE,UAAU,GAAG,GAAG,CAAC;YACrBF,GAAG,CAACG,GAAG,CAAC,qBAAqB,CAAC,CAAC;YAC/B,OAAO;QACT,CAAC;QAEDtC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;QACtBmC,GAAG,CAACE,UAAU,GAAG,GAAG,CAAC;QACrBF,GAAG,CAACG,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB;CACD"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/CreateFileMiddleware.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport path from 'path';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:createFile') as typeof console.log;\n\ninterface TouchFileInput {\n type: 'router_index';\n}\n\ninterface TouchFileOutput {\n absolutePath: string;\n contents: string;\n}\n\nconst ROUTER_INDEX_CONTENTS = `import { StyleSheet, Text, View } from \"react-native\";\n\nexport default function Page() {\n return (\n <View style={styles.container}>\n <View style={styles.main}>\n <Text style={styles.title}>Hello World</Text>\n <Text style={styles.subtitle}>This is the first page of your app.</Text>\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n alignItems: \"center\",\n padding: 24,\n },\n main: {\n flex: 1,\n justifyContent: \"center\",\n maxWidth: 960,\n marginHorizontal: \"auto\",\n },\n title: {\n fontSize: 64,\n fontWeight: \"bold\",\n },\n subtitle: {\n fontSize: 36,\n color: \"#38434D\",\n },\n});\n`;\n\ninterface CreateFileMiddlewareOptions {\n /** The absolute metro or server root, used to calculate the relative dom entry path */\n metroRoot: string;\n /** The absolute project root, used to resolve the `expo/dom/entry.js` path */\n projectRoot: string;\n /** The expo-router root */\n appDir: string;\n}\n\n/**\n * Middleware for creating a file given a `POST` request with\n * `{ contents: string, path: string }` in the body.\n */\nexport class CreateFileMiddleware extends ExpoMiddleware {\n constructor(protected options: CreateFileMiddlewareOptions) {\n super(options.projectRoot, ['/_expo/touch']);\n }\n\n protected resolveExtension(basePath: string, relativePath: string): string {\n let resolvedPath = relativePath;\n const extension = path.extname(relativePath);\n if (extension === '.js') {\n // Automatically convert JS files to TS files when added to a project\n // with TypeScript.\n const tsconfigPath = path.join(this.projectRoot, 'tsconfig.json');\n if (fs.existsSync(tsconfigPath)) {\n resolvedPath = resolvedPath.replace(/\\.js$/, '.tsx');\n }\n }\n return path.join(basePath, resolvedPath);\n }\n\n protected async parseRawBody(req: ServerRequest): Promise<TouchFileInput> {\n const rawBody = await new Promise<string>((resolve, reject) => {\n let body = '';\n req.on('data', (chunk) => {\n body += chunk.toString();\n });\n req.on('end', () => {\n resolve(body);\n });\n req.on('error', (err) => {\n reject(err);\n });\n });\n\n const body = JSON.parse(rawBody);\n if (typeof body !== 'object' || body == null) {\n throw new Error('Expected object');\n } else if (typeof body.type !== 'string') {\n throw new Error('Expected \"type\" in body to be string');\n }\n\n switch (body.type) {\n case 'router_index':\n return body;\n default:\n throw new Error('Unknown \"type\" passed in body');\n }\n }\n\n private makeOutputForInput(input: TouchFileInput): TouchFileOutput {\n switch (input.type) {\n case 'router_index':\n return {\n absolutePath: this.resolveExtension(this.options.appDir, 'index.js'),\n contents: ROUTER_INDEX_CONTENTS,\n };\n }\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n if (req.method !== 'POST') {\n res.statusCode = 405;\n res.end('Method Not Allowed');\n return;\n }\n\n let properties: TouchFileInput;\n try {\n properties = await this.parseRawBody(req);\n } catch (e) {\n debug('Error parsing request body', e);\n res.statusCode = 400;\n res.end('Bad Request');\n return;\n }\n\n debug(`Requested: %O`, properties);\n\n const file = this.makeOutputForInput(properties);\n if (fs.existsSync(file.absolutePath)) {\n res.statusCode = 409;\n res.end('File already exists.');\n return;\n }\n\n debug(`Resolved path:`, file.absolutePath);\n\n try {\n await fs.promises.mkdir(path.dirname(file.absolutePath), { recursive: true });\n await fs.promises.writeFile(file.absolutePath, file.contents, 'utf8');\n } catch (e) {\n debug('Error writing file', e);\n res.statusCode = 500;\n res.end('Error writing file.');\n return;\n }\n\n debug(`File created`);\n res.statusCode = 200;\n res.end('OK');\n }\n}\n"],"names":["CreateFileMiddleware","debug","require","ROUTER_INDEX_CONTENTS","ExpoMiddleware","constructor","options","projectRoot","resolveExtension","basePath","relativePath","resolvedPath","extension","path","extname","tsconfigPath","join","fs","existsSync","replace","parseRawBody","req","rawBody","Promise","resolve","reject","body","on","chunk","toString","err","JSON","parse","Error","type","makeOutputForInput","input","absolutePath","appDir","contents","handleRequestAsync","res","method","statusCode","end","properties","e","file","promises","mkdir","dirname","recursive","writeFile"],"mappings":"AAAA;;;;;CAKC,GACD;;;;+BAkEaA,sBAAoB;;aAApBA,oBAAoB;;;8DAlElB,IAAI;;;;;;;8DACF,MAAM;;;;;;gCAEQ,kBAAkB;;;;;;AAGjD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yCAAyC,CAAC,AAAsB,AAAC;AAWhG,MAAMC,qBAAqB,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkC/B,CAAC,AAAC;AAeK,MAAMH,oBAAoB,SAASI,eAAc,eAAA;IACtDC,YAAsBC,OAAoC,CAAE;QAC1D,KAAK,CAACA,OAAO,CAACC,WAAW,EAAE;YAAC,cAAc;SAAC,CAAC,CAAC;QADzBD,eAAAA,OAAoC,CAAA;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C,MAAME,IAAI,GAAG,IAAI,CAACZ,kBAAkB,CAACU,UAAU,CAAC,AAAC;QACjD,IAAI5B,GAAE,EAAA,QAAA,CAACC,UAAU,CAAC6B,IAAI,CAACV,YAAY,CAAC,EAAE;YACpCI,GAAG,CAACE,UAAU,GAAG,GAAG,CAAC;YACrBF,GAAG,CAACG,GAAG,CAAC,sBAAsB,CAAC,CAAC;YAChC,OAAO;QACT,CAAC;QAED3C,KAAK,CAAC,CAAC,cAAc,CAAC,EAAE8C,IAAI,CAACV,YAAY,CAAC,CAAC;QAE3C,IAAI;YACF,MAAMpB,GAAE,EAAA,QAAA,CAAC+B,QAAQ,CAACC,KAAK,CAACpC,KAAI,EAAA,QAAA,CAACqC,OAAO,CAACH,IAAI,CAACV,YAAY,CAAC,EAAE;gBAAEc,SAAS,EAAE,IAAI;aAAE,CAAC,CAAC;YAC9E,MAAMlC,GAAE,EAAA,QAAA,CAAC+B,QAAQ,CAACI,SAAS,CAACL,IAAI,CAACV,YAAY,EAAEU,IAAI,CAACR,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxE,EAAE,OAAOO,EAAC,EAAE;YACV7C,KAAK,CAAC,oBAAoB,EAAE6C,EAAC,CAAC,CAAC;YAC/BL,GAAG,CAACE,UAAU,GAAG,GAAG,CAAC;YACrBF,GAAG,CAACG,GAAG,CAAC,qBAAqB,CAAC,CAAC;YAC/B,OAAO;QACT,CAAC;QAED3C,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;QACtBwC,GAAG,CAACE,UAAU,GAAG,GAAG,CAAC;QACrBF,GAAG,CAACG,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB;CACD"}
@@ -0,0 +1,39 @@
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: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ isLocalSocket: ()=>isLocalSocket,
13
+ isMatchingOrigin: ()=>isMatchingOrigin
14
+ });
15
+ const ipv6To4Prefix = "::ffff:";
16
+ const isLocalSocket = (socket)=>{
17
+ let { localAddress , remoteAddress , remoteFamily } = socket;
18
+ const isLoopbackRequest = localAddress && localAddress === remoteAddress;
19
+ if (isLoopbackRequest) {
20
+ return true;
21
+ } else if (!remoteAddress || !remoteFamily) {
22
+ return false;
23
+ }
24
+ if (remoteFamily === "IPv6" && remoteAddress.startsWith(ipv6To4Prefix)) {
25
+ remoteAddress = remoteAddress.slice(ipv6To4Prefix.length);
26
+ }
27
+ return remoteAddress === "::1" || remoteAddress.startsWith("127.");
28
+ };
29
+ const isMatchingOrigin = (request, serverBaseUrl)=>{
30
+ // NOTE(@kitten): The browser will always send an origin header for websocket upgrade connections
31
+ if (!request.headers.origin) {
32
+ return true;
33
+ }
34
+ const actualHost = new URL(`${request.headers.origin}`).host;
35
+ const expectedHost = new URL(serverBaseUrl).host;
36
+ return actualHost === expectedHost;
37
+ };
38
+
39
+ //# sourceMappingURL=net.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/net.ts"],"sourcesContent":["import type { IncomingHttpHeaders } from 'node:http';\nimport type { Socket } from 'node:net';\n\nconst ipv6To4Prefix = '::ffff:';\n\nexport const isLocalSocket = (socket: Socket): boolean => {\n let { localAddress, remoteAddress, remoteFamily } = socket;\n\n const isLoopbackRequest = localAddress && localAddress === remoteAddress;\n if (isLoopbackRequest) {\n return true;\n } else if (!remoteAddress || !remoteFamily) {\n return false;\n }\n\n if (remoteFamily === 'IPv6' && remoteAddress.startsWith(ipv6To4Prefix)) {\n remoteAddress = remoteAddress.slice(ipv6To4Prefix.length);\n }\n\n return remoteAddress === '::1' || remoteAddress.startsWith('127.');\n};\n\ninterface AbstractIncomingMessage {\n headers: IncomingHttpHeaders | Record<string, string | string[]>;\n}\n\nexport const isMatchingOrigin = (\n request: AbstractIncomingMessage,\n serverBaseUrl: string\n): boolean => {\n // NOTE(@kitten): The browser will always send an origin header for websocket upgrade connections\n if (!request.headers.origin) {\n return true;\n }\n const actualHost = new URL(`${request.headers.origin}`).host;\n const expectedHost = new URL(serverBaseUrl).host;\n return actualHost === expectedHost;\n};\n"],"names":["isLocalSocket","isMatchingOrigin","ipv6To4Prefix","socket","localAddress","remoteAddress","remoteFamily","isLoopbackRequest","startsWith","slice","length","request","serverBaseUrl","headers","origin","actualHost","URL","host","expectedHost"],"mappings":"AAAA;;;;;;;;;;;IAKaA,aAAa,MAAbA,aAAa;IAqBbC,gBAAgB,MAAhBA,gBAAgB;;AAvB7B,MAAMC,aAAa,GAAG,SAAS,AAAC;AAEzB,MAAMF,aAAa,GAAG,CAACG,MAAc,GAAc;IACxD,IAAI,EAAEC,YAAY,CAAA,EAAEC,aAAa,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGH,MAAM,AAAC;IAE3D,MAAMI,iBAAiB,GAAGH,YAAY,IAAIA,YAAY,KAAKC,aAAa,AAAC;IACzE,IAAIE,iBAAiB,EAAE;QACrB,OAAO,IAAI,CAAC;IACd,OAAO,IAAI,CAACF,aAAa,IAAI,CAACC,YAAY,EAAE;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAIA,YAAY,KAAK,MAAM,IAAID,aAAa,CAACG,UAAU,CAACN,aAAa,CAAC,EAAE;QACtEG,aAAa,GAAGA,aAAa,CAACI,KAAK,CAACP,aAAa,CAACQ,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED,OAAOL,aAAa,KAAK,KAAK,IAAIA,aAAa,CAACG,UAAU,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC,AAAC;AAMK,MAAMP,gBAAgB,GAAG,CAC9BU,OAAgC,EAChCC,aAAqB,GACT;IACZ,iGAAiG;IACjG,IAAI,CAACD,OAAO,CAACE,OAAO,CAACC,MAAM,EAAE;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAC,CAAC,EAAEL,OAAO,CAACE,OAAO,CAACC,MAAM,CAAC,CAAC,CAAC,CAACG,IAAI,AAAC;IAC7D,MAAMC,YAAY,GAAG,IAAIF,GAAG,CAACJ,aAAa,CAAC,CAACK,IAAI,AAAC;IACjD,OAAOF,UAAU,KAAKG,YAAY,CAAC;AACrC,CAAC,AAAC"}
@@ -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.22.26"}`,
34
+ "user-agent": `expo-cli/${"0.22.28"}`,
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.22.26"
82
+ version: "0.22.28"
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.22.26",
3
+ "version": "0.22.28",
4
4
  "description": "The Expo CLI",
5
5
  "main": "build/bin/cli",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@0no-co/graphql.web": "^1.0.8",
43
43
  "@babel/runtime": "^7.20.0",
44
- "@expo/code-signing-certificates": "^0.0.5",
44
+ "@expo/code-signing-certificates": "^0.0.6",
45
45
  "@expo/config": "~10.0.11",
46
46
  "@expo/config-plugins": "~9.0.17",
47
47
  "@expo/devcert": "^1.1.2",
@@ -83,7 +83,7 @@
83
83
  "is-wsl": "^2.1.1",
84
84
  "lodash.debounce": "^4.0.8",
85
85
  "minimatch": "^3.0.4",
86
- "node-forge": "^1.3.1",
86
+ "node-forge": "^1.3.3",
87
87
  "npm-package-arg": "^11.0.0",
88
88
  "ora": "^3.4.0",
89
89
  "picomatch": "^3.0.1",
@@ -168,5 +168,5 @@
168
168
  "tree-kill": "^1.2.2",
169
169
  "tsd": "^0.28.1"
170
170
  },
171
- "gitHead": "1bb30ea188d37293bfeeaa3a587d34f0554768a8"
171
+ "gitHead": "e8d745201d9f24e4f6ca7f977c56741b549c1c15"
172
172
  }