@expo/cli 0.15.0 → 0.16.0

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.
Files changed (148) hide show
  1. package/build/bin/cli +10 -3
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/user/actions.js +1 -1
  4. package/build/src/api/user/actions.js.map +1 -1
  5. package/build/src/export/createMetadataJson.js +2 -1
  6. package/build/src/export/createMetadataJson.js.map +1 -1
  7. package/build/src/export/embed/exportEmbedAsync.js +50 -3
  8. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  9. package/build/src/export/embed/xcodeCompilerLogger.js +97 -0
  10. package/build/src/export/embed/xcodeCompilerLogger.js.map +1 -0
  11. package/build/src/export/exportApp.js +90 -103
  12. package/build/src/export/exportApp.js.map +1 -1
  13. package/build/src/export/exportAssets.js +18 -23
  14. package/build/src/export/exportAssets.js.map +1 -1
  15. package/build/src/export/exportAsync.js +1 -1
  16. package/build/src/export/exportAsync.js.map +1 -1
  17. package/build/src/export/exportHermes.js +0 -90
  18. package/build/src/export/exportHermes.js.map +1 -1
  19. package/build/src/export/exportStaticAsync.js +137 -108
  20. package/build/src/export/exportStaticAsync.js.map +1 -1
  21. package/build/src/export/favicon.js +12 -4
  22. package/build/src/export/favicon.js.map +1 -1
  23. package/build/src/export/fork-bundleAsync.js +74 -49
  24. package/build/src/export/fork-bundleAsync.js.map +1 -1
  25. package/build/src/export/metroAssetLocalPath.js +1 -1
  26. package/build/src/export/metroAssetLocalPath.js.map +1 -1
  27. package/build/src/export/persistMetroAssets.js +28 -17
  28. package/build/src/export/persistMetroAssets.js.map +1 -1
  29. package/build/src/export/publicFolder.js +7 -0
  30. package/build/src/export/publicFolder.js.map +1 -1
  31. package/build/src/export/saveAssets.js +176 -12
  32. package/build/src/export/saveAssets.js.map +1 -1
  33. package/build/src/export/writeContents.js +8 -107
  34. package/build/src/export/writeContents.js.map +1 -1
  35. package/build/src/install/installAsync.js +29 -10
  36. package/build/src/install/installAsync.js.map +1 -1
  37. package/build/src/prebuild/prebuildAsync.js +9 -2
  38. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  39. package/build/src/run/hints.js +4 -0
  40. package/build/src/run/hints.js.map +1 -1
  41. package/build/src/run/index.js +101 -0
  42. package/build/src/run/index.js.map +1 -0
  43. package/build/src/start/doctor/dependencies/bundledNativeModules.js +2 -2
  44. package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
  45. package/build/src/start/doctor/dependencies/getVersionedPackages.js +10 -3
  46. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  47. package/build/src/start/doctor/dependencies/resolvePackages.js +66 -0
  48. package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -0
  49. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +2 -30
  50. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  51. package/build/src/start/interface/interactiveActions.js +24 -8
  52. package/build/src/start/interface/interactiveActions.js.map +1 -1
  53. package/build/src/start/server/getStaticRenderFunctions.js +8 -4
  54. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  55. package/build/src/start/server/metro/MetroBundlerDevServer.js +39 -16
  56. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  57. package/build/src/start/server/metro/MetroTerminalReporter.js +6 -2
  58. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  59. package/build/src/start/server/metro/TerminalReporter.js +18 -1
  60. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  61. package/build/src/start/server/metro/bundleApiRoutes.js +3 -2
  62. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  63. package/build/src/start/server/metro/createExpoMetroResolver.js +22 -5
  64. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
  65. package/build/src/start/server/metro/createJResolver.js +5 -2
  66. package/build/src/start/server/metro/createJResolver.js.map +1 -1
  67. package/build/src/start/server/metro/createServerRouteMiddleware.js +2 -1
  68. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  69. package/build/src/start/server/metro/{inspector-proxy/device.js → debugging/InspectorDevice.js} +8 -38
  70. package/build/src/start/server/metro/debugging/InspectorDevice.js.map +1 -0
  71. package/build/src/start/server/metro/debugging/InspectorProxy.js +116 -0
  72. package/build/src/start/server/metro/debugging/InspectorProxy.js.map +1 -0
  73. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +45 -0
  74. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -0
  75. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/NetworkResponse.js +3 -4
  76. package/build/src/start/server/metro/debugging/inspectorHandlers/NetworkResponse.js.map +1 -0
  77. package/build/src/start/server/metro/debugging/inspectorHandlers/PageReload.js.map +1 -0
  78. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerGetPossibleBreakpoints.js +2 -2
  79. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -0
  80. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerScriptParsed.js +3 -2
  81. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerScriptParsed.js.map +1 -0
  82. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerSetBreakpointByUrl.js +3 -2
  83. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerSetBreakpointByUrl.js.map +1 -0
  84. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeRuntimeCallFunctionOn.js +2 -2
  85. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
  86. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeRuntimeGetProperties.js +5 -4
  87. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeGetProperties.js.map +1 -0
  88. package/build/src/start/server/metro/debugging/inspectorHandlers/types.js.map +1 -0
  89. package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js +20 -0
  90. package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js.map +1 -0
  91. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
  92. package/build/src/start/server/metro/instantiateMetro.js +8 -5
  93. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  94. package/build/src/start/server/metro/metroErrorInterface.js +3 -2
  95. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  96. package/build/src/start/server/metro/router.js +1 -5
  97. package/build/src/start/server/metro/router.js.map +1 -1
  98. package/build/src/start/server/metro/runServer-fork.js +0 -19
  99. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  100. package/build/src/start/server/metro/serializeHtml.js +20 -4
  101. package/build/src/start/server/metro/serializeHtml.js.map +1 -1
  102. package/build/src/start/server/metro/withMetroMultiPlatform.js +48 -85
  103. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  104. package/build/src/start/server/middleware/ManifestMiddleware.js +12 -5
  105. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  106. package/build/src/start/server/middleware/inspector/JsInspector.js +22 -1
  107. package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
  108. package/build/src/start/server/middleware/metroOptions.js +62 -9
  109. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  110. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  111. package/build/src/start/server/type-generation/__typetests__/route.test.js +11 -3
  112. package/build/src/start/server/type-generation/__typetests__/route.test.js.map +1 -1
  113. package/build/src/start/server/type-generation/routes.js +6 -4
  114. package/build/src/start/server/type-generation/routes.js.map +1 -1
  115. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +1 -1
  116. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
  117. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  118. package/build/src/utils/codesigning.js +11 -1
  119. package/build/src/utils/codesigning.js.map +1 -1
  120. package/build/src/utils/env.js +7 -1
  121. package/build/src/utils/env.js.map +1 -1
  122. package/build/src/utils/tsconfig/loadTsConfigPaths.js +3 -11
  123. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
  124. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +22 -12
  125. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -1
  126. package/package.json +10 -10
  127. package/static/template/index.html +14 -95
  128. package/build/src/export/printBundleSizes.js +0 -101
  129. package/build/src/export/printBundleSizes.js.map +0 -1
  130. package/build/src/start/server/metro/inspector-proxy/device.js.map +0 -1
  131. package/build/src/start/server/metro/inspector-proxy/handlers/NetworkResponse.js.map +0 -1
  132. package/build/src/start/server/metro/inspector-proxy/handlers/PageReload.js.map +0 -1
  133. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +0 -1
  134. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js.map +0 -1
  135. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js.map +0 -1
  136. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +0 -1
  137. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js.map +0 -1
  138. package/build/src/start/server/metro/inspector-proxy/handlers/types.js.map +0 -1
  139. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +0 -11
  140. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +0 -1
  141. package/build/src/start/server/metro/inspector-proxy/index.js +0 -30
  142. package/build/src/start/server/metro/inspector-proxy/index.js.map +0 -1
  143. package/build/src/start/server/metro/inspector-proxy/proxy.js +0 -169
  144. package/build/src/start/server/metro/inspector-proxy/proxy.js.map +0 -1
  145. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +0 -64
  146. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +0 -1
  147. /package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/PageReload.js +0 -0
  148. /package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/types.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/InspectorDevice.ts"],"sourcesContent":["import type { unstable_Device } from '@react-native/dev-middleware';\nimport fetch from 'node-fetch';\nimport type WS from 'ws';\n\nimport { NetworkResponseHandler } from './inspectorHandlers/NetworkResponse';\nimport { PageReloadHandler } from './inspectorHandlers/PageReload';\nimport { VscodeDebuggerGetPossibleBreakpointsHandler } from './inspectorHandlers/VscodeDebuggerGetPossibleBreakpoints';\nimport { VscodeDebuggerScriptParsedHandler } from './inspectorHandlers/VscodeDebuggerScriptParsed';\nimport { VscodeDebuggerSetBreakpointByUrlHandler } from './inspectorHandlers/VscodeDebuggerSetBreakpointByUrl';\nimport { VscodeRuntimeCallFunctionOnHandler } from './inspectorHandlers/VscodeRuntimeCallFunctionOn';\nimport { VscodeRuntimeGetPropertiesHandler } from './inspectorHandlers/VscodeRuntimeGetProperties';\nimport { DebuggerMetadata, DeviceRequest, InspectorHandler } from './inspectorHandlers/types';\nimport { type MetroBundlerDevServer } from '../MetroBundlerDevServer';\n\nexport function createInspectorDeviceClass(\n metroBundler: MetroBundlerDevServer,\n MetroDeviceClass: typeof unstable_Device\n): typeof unstable_Device {\n return class ExpoInspectorDevice extends MetroDeviceClass implements InspectorHandler {\n /** All handlers that should be used to intercept or reply to CDP events */\n public handlers: InspectorHandler[] = [\n // Generic handlers\n new NetworkResponseHandler(),\n new PageReloadHandler(metroBundler),\n // Vscode-specific handlers\n new VscodeDebuggerGetPossibleBreakpointsHandler(),\n new VscodeDebuggerScriptParsedHandler(this),\n new VscodeDebuggerSetBreakpointByUrlHandler(),\n new VscodeRuntimeGetPropertiesHandler(),\n new VscodeRuntimeCallFunctionOnHandler(),\n ];\n\n onDeviceMessage(message: any, info: DebuggerMetadata): boolean {\n return this.handlers.some((handler) => handler.onDeviceMessage?.(message, info) ?? false);\n }\n\n onDebuggerMessage(message: any, info: DebuggerMetadata): boolean {\n return this.handlers.some((handler) => handler.onDebuggerMessage?.(message, info) ?? false);\n }\n\n /** Hook into the message life cycle to answer more complex CDP messages */\n async _processMessageFromDevice(message: DeviceRequest<any>, info: DebuggerMetadata) {\n if (!this.onDeviceMessage(message, info)) {\n await super._processMessageFromDevice(message, info);\n }\n }\n\n /** Hook into the message life cycle to answer more complex CDP messages */\n _interceptMessageFromDebugger(\n request: Parameters<unstable_Device['_interceptMessageFromDebugger']>[0],\n info: DebuggerMetadata,\n socket: WS\n ): boolean {\n // Note, `socket` is the exact same as `info.socket`\n if (this.onDebuggerMessage(request, info)) {\n return true;\n }\n\n return super._interceptMessageFromDebugger(request, info, socket);\n }\n\n /**\n * Overwrite the default text fetcher, to load sourcemaps from sources other than `localhost`.\n * @todo Cedric: remove the custom `DebuggerScriptSource` handler when switching over to `metro@>=0.75.1`\n * @see https://github.com/facebook/metro/blob/77f445f1bcd2264ad06174dbf8d542bc75834d29/packages/metro-inspector-proxy/src/Device.js#L573-L588\n * @since metro-inspector-proxy@0.75.1\n */\n async _fetchText(url: URL): Promise<string> {\n const LENGTH_LIMIT_BYTES = 350_000_000; // 350mb\n\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Received status ${response.status} while fetching: ${url}`);\n }\n\n const contentLength = response.headers.get('Content-Length');\n if (contentLength && Number(contentLength) > LENGTH_LIMIT_BYTES) {\n throw new Error('Expected file size is too large (more than 350mb)');\n }\n\n const text = await response.text();\n if (Buffer.byteLength(text, 'utf8') > LENGTH_LIMIT_BYTES) {\n throw new Error('File size is too large (more than 350mb)');\n }\n\n return text;\n }\n };\n}\n"],"names":["createInspectorDeviceClass","metroBundler","MetroDeviceClass","ExpoInspectorDevice","handlers","NetworkResponseHandler","PageReloadHandler","VscodeDebuggerGetPossibleBreakpointsHandler","VscodeDebuggerScriptParsedHandler","VscodeDebuggerSetBreakpointByUrlHandler","VscodeRuntimeGetPropertiesHandler","VscodeRuntimeCallFunctionOnHandler","onDeviceMessage","message","info","handler","some","onDebuggerMessage","_processMessageFromDevice","_interceptMessageFromDebugger","request","socket","_fetchText","url","LENGTH_LIMIT_BYTES","response","fetch","ok","Error","status","contentLength","headers","get","Number","text","Buffer","byteLength"],"mappings":"AAAA;;;;QAcgBA,0BAA0B,GAA1BA,0BAA0B;AAbxB,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAGS,IAAA,gBAAqC,WAArC,qCAAqC,CAAA;AAC1C,IAAA,WAAgC,WAAhC,gCAAgC,CAAA;AACN,IAAA,qCAA0D,WAA1D,0DAA0D,CAAA;AACpE,IAAA,2BAAgD,WAAhD,gDAAgD,CAAA;AAC1C,IAAA,iCAAsD,WAAtD,sDAAsD,CAAA;AAC3D,IAAA,4BAAiD,WAAjD,iDAAiD,CAAA;AAClD,IAAA,2BAAgD,WAAhD,gDAAgD,CAAA;;;;;;AAI3F,SAASA,0BAA0B,CACxCC,YAAmC,EACnCC,gBAAwC,EAChB;IACxB,OAAO,MAAMC,mBAAmB,SAASD,gBAAgB;QACvD,2EAA2E,CAC3E,AAAOE,QAAQ,GAAuB;YACpC,mBAAmB;YACnB,IAAIC,gBAAsB,uBAAA,EAAE;YAC5B,IAAIC,WAAiB,kBAAA,CAACL,YAAY,CAAC;YACnC,2BAA2B;YAC3B,IAAIM,qCAA2C,4CAAA,EAAE;YACjD,IAAIC,2BAAiC,kCAAA,CAAC,IAAI,CAAC;YAC3C,IAAIC,iCAAuC,wCAAA,EAAE;YAC7C,IAAIC,2BAAiC,kCAAA,EAAE;YACvC,IAAIC,4BAAkC,mCAAA,EAAE;SACzC,CAAC;QAEFC,eAAe,CAACC,OAAY,EAAEC,IAAsB,EAAW;gBACtBC,GAAwC;YAA/E,OAAO,IAAI,CAACX,Q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A,GAAAA,UAAK,AAAK,CAAA,QAAL,CAACH,GAAG,CAAC,AAAC;YAClC,IAAI,CAACE,QAAQ,CAACE,EAAE,EAAE;gBAChB,MAAM,IAAIC,KAAK,CAAC,CAAC,gBAAgB,EAAEH,QAAQ,CAACI,MAAM,CAAC,iBAAiB,EAAEN,GAAG,CAAC,CAAC,CAAC,CAAC;aAC9E;YAED,MAAMO,aAAa,GAAGL,QAAQ,CAACM,OAAO,CAACC,GAAG,CAAC,gBAAgB,CAAC,AAAC;YAC7D,IAAIF,aAAa,IAAIG,MAAM,CAACH,aAAa,CAAC,GAAGN,kBAAkB,EAAE;gBAC/D,MAAM,IAAII,KAAK,CAAC,mDAAmD,CAAC,CAAC;aACtE;YAED,MAAMM,IAAI,GAAG,MAAMT,QAAQ,CAACS,IAAI,EAAE,AAAC;YACnC,IAAIC,MAAM,CAACC,UAAU,CAACF,IAAI,EAAE,MAAM,CAAC,GAAGV,kBAAkB,EAAE;gBACxD,MAAM,IAAII,KAAK,CAAC,0CAA0C,CAAC,CAAC;aAC7D;YAED,OAAOM,IAAI,CAAC;SACb;KACF,CAAC;CACH"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.createInspectorProxyClass = createInspectorProxyClass;
6
+ var _url = _interopRequireDefault(require("url"));
7
+ var _ws = _interopRequireDefault(require("ws"));
8
+ function _interopRequireDefault(obj) {
9
+ return obj && obj.__esModule ? obj : {
10
+ default: obj
11
+ };
12
+ }
13
+ const debug = require("debug")("expo:metro:inspector-proxy:proxy");
14
+ /** Web socket error code for unknown internal errors */ const INTERNAL_ERROR_CODE = 1011;
15
+ function createInspectorProxyClass(MetroInspectorProxyClass, MetroDeviceClass) {
16
+ return class ExpoInspectorProxy extends MetroInspectorProxyClass {
17
+ /**
18
+ * This method is overwritten to inject our own device class.
19
+ * @see https://github.com/facebook/react-native/blob/f1df4ceb8479a6fc9c30f7571f5aeec255b116d2/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js#L179-L227
20
+ */ _createDeviceConnectionWSServer() {
21
+ const wss = new _ws.default.Server({
22
+ noServer: true,
23
+ perMessageDeflate: true,
24
+ // Don't crash on exceptionally large messages - assume the device is
25
+ // well-behaved and the debugger is prepared to handle large messages.
26
+ maxPayload: 0
27
+ });
28
+ wss.on("connection", async (socket, req)=>{
29
+ try {
30
+ const fallbackDeviceId = String(this._deviceCounter++);
31
+ const query = _url.default.parse(req.url || "", true).query || {};
32
+ const deviceId = asString(query.device) || fallbackDeviceId;
33
+ const deviceName = asString(query.name) || "Unknown";
34
+ const appName = asString(query.app) || "Unknown";
35
+ const oldDevice = this._devices.get(deviceId);
36
+ // FIX: Create a new device instance using our own extended class
37
+ const newDevice = new MetroDeviceClass(deviceId, deviceName, appName, socket, this._projectRoot, this._eventReporter);
38
+ if (oldDevice) {
39
+ oldDevice.handleDuplicateDeviceConnection(newDevice);
40
+ }
41
+ this._devices.set(deviceId, newDevice);
42
+ debug(`Got new connection: name=${deviceName}, app=${appName}, device=${deviceId}`);
43
+ socket.on("close", ()=>{
44
+ // FIX: Only clean up the device reference, if not replaced by new device
45
+ if (this._devices.get(deviceId) === newDevice) {
46
+ this._devices.delete(deviceId);
47
+ debug(`Device ${deviceName} disconnected.`);
48
+ } else {
49
+ debug(`Device ${deviceName} reconnected.`);
50
+ }
51
+ });
52
+ } catch (e) {
53
+ var // FIX: add missing event reporter
54
+ ref;
55
+ console.error("error", e);
56
+ var ref1;
57
+ socket.close(INTERNAL_ERROR_CODE, (ref1 = e == null ? void 0 : e.toString()) != null ? ref1 : "Unknown error");
58
+ (ref = this._eventReporter) == null ? void 0 : ref.logEvent({
59
+ type: "connect_debugger_app",
60
+ status: "error",
61
+ error: e
62
+ });
63
+ }
64
+ });
65
+ return wss;
66
+ }
67
+ /**
68
+ * This method is overwritten to allow user agents to be passed as query parameter.
69
+ * The built-in debugger in vscode does not add any user agent headers.
70
+ * @see https://github.com/facebook/react-native/blob/f1df4ceb8479a6fc9c30f7571f5aeec255b116d2/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js#L234-L272
71
+ */ _createDebuggerConnectionWSServer() {
72
+ const wss = new _ws.default.Server({
73
+ noServer: true,
74
+ perMessageDeflate: false,
75
+ // Don't crash on exceptionally large messages - assume the debugger is
76
+ // well-behaved and the device is prepared to handle large messages.
77
+ maxPayload: 0
78
+ });
79
+ wss.on("connection", async (socket, req)=>{
80
+ try {
81
+ const query = _url.default.parse(req.url || "", true).query || {};
82
+ const deviceId = asString(query.device);
83
+ const pageId = asString(query.page);
84
+ // FIX: Determine the user agent from query paramter or header
85
+ const userAgent = asString(query.userAgent) || req.headers["user-agent"] || null;
86
+ if (deviceId == null || pageId == null) {
87
+ throw new Error("Incorrect URL - must provide device and page IDs");
88
+ }
89
+ const device = this._devices.get(deviceId);
90
+ if (device == null) {
91
+ throw new Error("Unknown device with ID " + deviceId);
92
+ }
93
+ device.handleDebuggerConnection(socket, pageId, {
94
+ userAgent
95
+ });
96
+ } catch (e) {
97
+ var ref;
98
+ console.error(e);
99
+ var ref2;
100
+ socket.close(INTERNAL_ERROR_CODE, (ref2 = e == null ? void 0 : e.toString()) != null ? ref2 : "Unknown error");
101
+ (ref = this._eventReporter) == null ? void 0 : ref.logEvent({
102
+ type: "connect_debugger_frontend",
103
+ status: "error",
104
+ error: e
105
+ });
106
+ }
107
+ });
108
+ return wss;
109
+ }
110
+ };
111
+ }
112
+ /** Convert the query paramters to plain string */ function asString(value = "") {
113
+ return Array.isArray(value) ? value.join() : value;
114
+ }
115
+
116
+ //# sourceMappingURL=InspectorProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/InspectorProxy.ts"],"sourcesContent":["import type { unstable_InspectorProxy, unstable_Device } from '@react-native/dev-middleware';\nimport url from 'url';\nimport WS from 'ws';\n\nconst debug = require('debug')('expo:metro:inspector-proxy:proxy') as typeof console.log;\n\n/** Web socket error code for unknown internal errors */\nconst INTERNAL_ERROR_CODE = 1011;\n\n/**\n * Create a new Expo proxy inspector class that uses the feature-extended device class.\n * Everything else is reused from the original class.\n *\n * @see https://github.com/facebook/react-native/blob/f1df4ceb8479a6fc9c30f7571f5aeec255b116d2/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js\n */\nexport function createInspectorProxyClass(\n MetroInspectorProxyClass: typeof unstable_InspectorProxy,\n MetroDeviceClass: typeof unstable_Device\n): typeof unstable_InspectorProxy {\n return class ExpoInspectorProxy extends MetroInspectorProxyClass {\n /**\n * This method is overwritten to inject our own device class.\n * @see https://github.com/facebook/react-native/blob/f1df4ceb8479a6fc9c30f7571f5aeec255b116d2/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js#L179-L227\n */\n _createDeviceConnectionWSServer() {\n const wss = new WS.Server({\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', async (socket: WS, req) => {\n try {\n const fallbackDeviceId = String(this._deviceCounter++);\n\n const query = url.parse(req.url || '', true).query || {};\n const deviceId = asString(query.device) || fallbackDeviceId;\n const deviceName = asString(query.name) || 'Unknown';\n const appName = asString(query.app) || 'Unknown';\n\n const oldDevice = this._devices.get(deviceId);\n // FIX: Create a new device instance using our own extended class\n const newDevice = new MetroDeviceClass(\n deviceId,\n deviceName,\n appName,\n socket,\n this._projectRoot,\n this._eventReporter\n );\n\n if (oldDevice) {\n oldDevice.handleDuplicateDeviceConnection(newDevice);\n }\n\n this._devices.set(deviceId, newDevice);\n\n debug(`Got new connection: name=${deviceName}, app=${appName}, device=${deviceId}`);\n\n socket.on('close', () => {\n // FIX: Only clean up the device reference, if not replaced by new device\n if (this._devices.get(deviceId) === newDevice) {\n this._devices.delete(deviceId);\n debug(`Device ${deviceName} disconnected.`);\n } else {\n debug(`Device ${deviceName} reconnected.`);\n }\n });\n } catch (e) {\n console.error('error', e);\n socket.close(INTERNAL_ERROR_CODE, e?.toString() ?? 'Unknown error');\n // FIX: add missing event reporter\n this._eventReporter?.logEvent({\n type: 'connect_debugger_app',\n status: 'error',\n error: e,\n });\n }\n });\n\n return wss;\n }\n\n /**\n * This method is overwritten to allow user agents to be passed as query parameter.\n * The built-in debugger in vscode does not add any user agent headers.\n * @see https://github.com/facebook/react-native/blob/f1df4ceb8479a6fc9c30f7571f5aeec255b116d2/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js#L234-L272\n */\n _createDebuggerConnectionWSServer() {\n const wss = new WS.Server({\n noServer: true,\n perMessageDeflate: false,\n // Don't crash on exceptionally large messages - assume the debugger is\n // well-behaved and the device is prepared to handle large messages.\n maxPayload: 0,\n });\n\n wss.on('connection', async (socket: WS, req) => {\n try {\n const query = url.parse(req.url || '', true).query || {};\n const deviceId = asString(query.device);\n const pageId = asString(query.page);\n // FIX: Determine the user agent from query paramter or header\n const userAgent = asString(query.userAgent) || req.headers['user-agent'] || null;\n\n if (deviceId == null || pageId == null) {\n throw new Error('Incorrect URL - must provide device and page IDs');\n }\n\n const device = this._devices.get(deviceId);\n if (device == null) {\n throw new Error('Unknown device with ID ' + deviceId);\n }\n\n device.handleDebuggerConnection(socket, pageId, { userAgent });\n } catch (e) {\n console.error(e);\n socket.close(INTERNAL_ERROR_CODE, e?.toString() ?? 'Unknown error');\n this._eventReporter?.logEvent({\n type: 'connect_debugger_frontend',\n status: 'error',\n error: e,\n });\n }\n });\n\n return wss;\n }\n };\n}\n\n/** Convert the query paramters to plain string */\nfunction asString(value: string | string[] = ''): string {\n return Array.isArray(value) ? value.join() : value;\n}\n"],"names":["createInspectorProxyClass","debug","require","INTERNAL_ERROR_CODE","MetroInspectorProxyClass","MetroDeviceClass","ExpoInspectorProxy","_createDeviceConnectionWSServer","wss","WS","Server","noServer","perMessageDeflate","maxPayload","on","socket","req","fallbackDeviceId","String","_deviceCounter","query","url","parse","deviceId","asString","device","deviceName","name","appName","app","oldDevice","_devices","get","newDevice","_projectRoot","_eventReporter","handleDuplicateDeviceConnection","set","delete","e","console","error","close","toString","logEvent","type","status","_createDebuggerConnectionWSServer","pageId","page","userAgent","headers","Error","handleDebuggerConnection","value","Array","isArray","join"],"mappings":"AAAA;;;;QAegBA,yBAAyB,GAAzBA,yBAAyB;AAdzB,IAAA,IAAK,kCAAL,KAAK,EAAA;AACN,IAAA,GAAI,kCAAJ,IAAI,EAAA;;;;;;AAEnB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,kCAAkC,CAAC,AAAsB,AAAC;AAEzF,wDAAwD,CACxD,MAAMC,mBAAmB,GAAG,IAAI,AAAC;AAQ1B,SAASH,yBAAyB,CACvCI,wBAAwD,EACxDC,gBAAwC,EACR;IAChC,OAAO,MAAMC,kBAAkB,SAASF,wBAAwB;QAC9D;;;OAGG,CACHG,+BAA+B,GAAG;YAChC,MAAMC,GAAG,GAAG,IAAIC,GAAE,QAAA,CAACC,MAAM,CAAC;gBACxBC,QAAQ,EAAE,IAAI;gBACdC,iBAAiB,EAAE,IAAI;gBACvB,qEAAqE;gBACrE,sEAAsE;gBACtEC,UAAU,EAAE,CAAC;aACd,CAAC,AAAC;YAEHL,GAAG,CAACM,EAAE,CAAC,YAAY,EAAE,OAAOC,MAAU,EAAEC,GAAG,GAAK;gBAC9C,IAAI;oBACF,MAAMC,gBAAgB,GAAGC,MAAM,CAAC,IAAI,CAACC,cAAc,EAAE,CAAC,AAAC;oBAEvD,MAAMC,KAAK,GAAGC,IAAG,QAAA,CAACC,KAAK,CAACN,GAAG,CAACK,GAAG,IAAI,EAAE,EAAE,IAAI,CAAC,CAACD,KAAK,IAAI,EAAE,AAAC;oBACzD,MAAMG,QAAQ,GAAGC,QAAQ,CAACJ,KAAK,CAACK,MAAM,CAAC,IAAIR,gBAAgB,AAAC;oBAC5D,MAAMS,UAAU,GAAGF,QAAQ,CAACJ,KAAK,CAACO,IAAI,CAAC,IAAI,SAAS,AAAC;oBACrD,MAAMC,OAAO,GA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AAK,CAAC,kDAAkD,CAAC,CAAC;qBACrE;oBAED,MAAM3B,MAAM,GAAG,IAAI,CAACM,QAAQ,CAACC,GAAG,CAACT,QAAQ,CAAC,AAAC;oBAC3C,IAAIE,MAAM,IAAI,IAAI,EAAE;wBAClB,MAAM,IAAI2B,KAAK,CAAC,yBAAyB,GAAG7B,QAAQ,CAAC,CAAC;qBACvD;oBAEDE,MAAM,CAAC4B,wBAAwB,CAACtC,MAAM,EAAEiC,MAAM,EAAE;wBAAEE,SAAS;qBAAE,CAAC,CAAC;iBAChE,CAAC,OAAOX,CAAC,EAAE;wBAGV,GAAmB;oBAFnBC,OAAO,CAACC,KAAK,CAACF,CAAC,CAAC,CAAC;wBACiBA,IAAa;oBAA/CxB,MAAM,CAAC2B,KAAK,CAACvC,mBAAmB,EAAEoC,CAAAA,IAAa,GAAbA,CAAC,QAAU,GAAXA,KAAAA,CAAW,GAAXA,CAAC,CAAEI,QAAQ,EAAE,YAAbJ,IAAa,GAAI,eAAe,CAAC,CAAC;oBACpE,CAAA,GAAmB,GAAnB,IAAI,CAACJ,cAAc,SAAU,GAA7B,KAAA,CAA6B,GAA7B,GAAmB,CAAES,QAAQ,CAAC;wBAC5BC,IAAI,EAAE,2BAA2B;wBACjCC,MAAM,EAAE,OAAO;wBACfL,KAAK,EAAEF,CAAC;qBACT,CAAC,AA5HZ,CA4Ha;iBACJ;aACF,CAAC,CAAC;YAEH,OAAO/B,GAAG,CAAC;SACZ;KACF,CAAC;CACH;AAED,kDAAkD,CAClD,SAASgB,QAAQ,CAAC8B,KAAwB,GAAG,EAAE,EAAU;IACvD,OAAOC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,GAAGA,KAAK,CAACG,IAAI,EAAE,GAAGH,KAAK,CAAC;CACpD"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.createDebugMiddleware = createDebugMiddleware;
6
+ var _chalk = _interopRequireDefault(require("chalk"));
7
+ var _inspectorDevice = require("./InspectorDevice");
8
+ var _inspectorProxy = require("./InspectorProxy");
9
+ var _log = require("../../../../log");
10
+ function _interopRequireDefault(obj) {
11
+ return obj && obj.__esModule ? obj : {
12
+ default: obj
13
+ };
14
+ }
15
+ function createDebugMiddleware(metroBundler) {
16
+ // Load the React Native debugging tools from project
17
+ // TODO: check if this works with isolated modules
18
+ const { createDevMiddleware , unstable_Device , unstable_InspectorProxy } = require("@react-native/dev-middleware");
19
+ // Create the extended inspector proxy, using our own device class
20
+ const ExpoInspectorProxy = (0, _inspectorProxy).createInspectorProxyClass(unstable_InspectorProxy, (0, _inspectorDevice).createInspectorDeviceClass(metroBundler, unstable_Device));
21
+ const { middleware , websocketEndpoints } = createDevMiddleware({
22
+ projectRoot: metroBundler.projectRoot,
23
+ serverBaseUrl: metroBundler.getJsInspectorBaseUrl(),
24
+ logger: createLogger(_chalk.default.bold("Debug:")),
25
+ unstable_InspectorProxy: ExpoInspectorProxy,
26
+ unstable_experiments: {
27
+ enableNewDebugger: true
28
+ }
29
+ });
30
+ return {
31
+ debugMiddleware: middleware,
32
+ debugWebsocketEndpoints: websocketEndpoints
33
+ };
34
+ }
35
+ function createLogger(logPrefix) {
36
+ return {
37
+ info: (...args)=>_log.Log.log(logPrefix, ...args)
38
+ ,
39
+ warn: (...args)=>_log.Log.warn(logPrefix, ...args)
40
+ ,
41
+ error: (...args)=>_log.Log.error(logPrefix, ...args)
42
+ };
43
+ }
44
+
45
+ //# sourceMappingURL=createDebugMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/createDebugMiddleware.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { createInspectorDeviceClass } from './InspectorDevice';\nimport { createInspectorProxyClass } from './InspectorProxy';\nimport { Log } from '../../../../log';\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, unstable_Device, unstable_InspectorProxy } =\n require('@react-native/dev-middleware') as typeof import('@react-native/dev-middleware');\n\n // Create the extended inspector proxy, using our own device class\n const ExpoInspectorProxy = createInspectorProxyClass(\n unstable_InspectorProxy,\n createInspectorDeviceClass(metroBundler, unstable_Device)\n );\n\n const { middleware, websocketEndpoints } = createDevMiddleware({\n projectRoot: metroBundler.projectRoot,\n serverBaseUrl: metroBundler.getJsInspectorBaseUrl(),\n logger: createLogger(chalk.bold('Debug:')),\n unstable_InspectorProxy: ExpoInspectorProxy,\n unstable_experiments: {\n enableNewDebugger: true,\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","unstable_Device","unstable_InspectorProxy","require","ExpoInspectorProxy","createInspectorProxyClass","createInspectorDeviceClass","middleware","websocketEndpoints","projectRoot","serverBaseUrl","getJsInspectorBaseUrl","logger","createLogger","chalk","bold","unstable_experiments","enableNewDebugger","debugMiddleware","debugWebsocketEndpoints","logPrefix","info","args","Log","log","warn","error"],"mappings":"AAAA;;;;QAOgBA,qBAAqB,GAArBA,qBAAqB;AAPnB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEkB,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AACpB,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AACxC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;;;;;;AAG9B,SAASA,qBAAqB,CAACC,YAAmC,EAAE;IACzE,qDAAqD;IACrD,kDAAkD;IAClD,MAAM,EAAEC,mBAAmB,CAAA,EAAEC,eAAe,CAAA,EAAEC,uBAAuB,CAAA,EAAE,GACrEC,OAAO,CAAC,8BAA8B,CAAC,AAAiD,AAAC;IAE3F,kEAAkE;IAClE,MAAMC,kBAAkB,GAAGC,CAAAA,GAAAA,eAAyB,AAGnD,CAAA,0BAHmD,CAClDH,uBAAuB,EACvBI,CAAAA,GAAAA,gBAA0B,AAA+B,CAAA,2BAA/B,CAACP,YAAY,EAAEE,eAAe,CAAC,CAC1D,AAAC;IAEF,MAAM,EAAEM,UAAU,CAAA,EAAEC,kBAAkB,CAAA,EAAE,GAAGR,mBAAmB,CAAC;QAC7DS,WAAW,EAAEV,YAAY,CAACU,WAAW;QACrCC,aAAa,EAAEX,YAAY,CAACY,qBAAqB,EAAE;QACnDC,MAAM,EAAEC,YAAY,CAACC,MAAK,QAAA,CAACC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1Cb,uBAAuB,EAAEE,kBAAkB;QAC3CY,oBAAoB,EAAE;YACpBC,iBAAiB,EAAE,IAAI;SACxB;KACF,CAAC,AAAC;IAEH,OAAO;QACLC,eAAe,EAAEX,UAAU;QAC3BY,uBAAuB,EAAEX,kBAAkB;KAC5C,CAAC;CACH;AAED,SAASK,YAAY,CACnBO,SAAiB,EAC2E;IAC5F,OAAO;QACLC,IAAI,EAAE,CAAIC,GAAAA,IAAI,GAAKC,IAAG,IAAA,CAACC,GAAG,CAACJ,SAAS,KAAKE,IAAI,CAAC;QAAA;QAC9CG,IAAI,EAAE,CAAIH,GAAAA,IAAI,GAAKC,IAAG,IAAA,CAACE,IAAI,CAACL,SAAS,KAAKE,IAAI,CAAC;QAAA;QAC/CI,KAAK,EAAE,CAAIJ,GAAAA,IAAI,GAAKC,IAAG,IAAA,CAACG,KAAK,CAACN,SAAS,KAAKE,IAAI,CAAC;KAClD,CAAC;CACH"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ var _utils = require("./utils");
5
6
  class NetworkResponseHandler {
6
7
  /** All known responses, mapped by request id */ storage = new Map();
7
8
  onDeviceMessage(message) {
@@ -14,12 +15,10 @@ class NetworkResponseHandler {
14
15
  }
15
16
  onDebuggerMessage(message, { socket }) {
16
17
  if (message.method === "Network.getResponseBody" && this.storage.has(message.params.requestId)) {
17
- const response = {
18
+ return (0, _utils).respond(socket, {
18
19
  id: message.id,
19
20
  result: this.storage.get(message.params.requestId)
20
- };
21
- socket.send(JSON.stringify(response));
22
- return true;
21
+ });
23
22
  }
24
23
  return false;
25
24
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/NetworkResponse.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport {\n CdpMessage,\n InspectorHandler,\n DebuggerMetadata,\n DeviceRequest,\n DebuggerRequest,\n DebuggerResponse,\n DeviceResponse,\n} from './types';\nimport { respond } from './utils';\n\nexport class NetworkResponseHandler implements InspectorHandler {\n /** All known responses, mapped by request id */\n storage = new Map<string, DebuggerResponse<NetworkGetResponseBody>['result']>();\n\n onDeviceMessage(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 onDebuggerMessage(\n message: DebuggerRequest<NetworkGetResponseBody>,\n { socket }: DebuggerMetadata\n ) {\n if (\n message.method === 'Network.getResponseBody' &&\n this.storage.has(message.params.requestId)\n ) {\n return respond<DeviceResponse<NetworkGetResponseBody>>(socket, {\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","storage","Map","onDeviceMessage","message","method","requestId","requestInfo","params","set","onDebuggerMessage","socket","has","respond","id","result","get"],"mappings":"AAAA;;;;AAWwB,IAAA,MAAS,WAAT,SAAS,CAAA;AAE1B,MAAMA,sBAAsB;IACjC,gDAAgD,CAChDC,OAAO,GAAG,IAAIC,GAAG,EAA8D,CAAC;IAEhFC,eAAe,CAACC,OAAmD,EAAE;QACnE,IAAIA,OAAO,CAACC,MAAM,KAAK,oCAAoC,EAAE;YAC3D,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGC,WAAW,EAAE,GAAGH,OAAO,CAACI,MAAM,AAAC;YACrD,IAAI,CAACP,OAAO,CAACQ,GAAG,CAACH,SAAS,EAAEC,WAAW,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;KACd;IAEDG,iBAAiB,CACfN,OAAgD,EAChD,EAAEO,MAAM,CAAA,EAAoB,EAC5B;QACA,IACEP,OAAO,CAACC,MAAM,KAAK,yBAAyB,IAC5C,IAAI,CAACJ,OAAO,CAACW,GAAG,CAACR,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC,EAC1C;YACA,OAAOO,CAAAA,GAAAA,MAAO,AAGZ,CAAA,QAHY,CAAyCF,MAAM,EAAE;gBAC7DG,EAAE,EAAEV,OAAO,CAACU,EAAE;gBACdC,MAAM,EAAE,IAAI,CAACd,OAAO,CAACe,GAAG,CAACZ,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC;aACnD,CAAC,CAAC;SACJ;QAED,OAAO,KAAK,CAAC;KACd;CACF;QA9BYN,sBAAsB,GAAtBA,sBAAsB"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/PageReload.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport { CdpMessage, DebuggerMetadata, DebuggerRequest, InspectorHandler } from './types';\nimport { MetroBundlerDevServer } from '../../MetroBundlerDevServer';\n\nexport class PageReloadHandler implements InspectorHandler {\n constructor(private readonly metroBundler: MetroBundlerDevServer) {}\n\n onDebuggerMessage(message: DebuggerRequest<PageReload>, { socket }: DebuggerMetadata) {\n if (message.method === 'Page.reload') {\n this.metroBundler.broadcastMessage('reload');\n socket.send(JSON.stringify({ id: message.id }));\n return true;\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","constructor","metroBundler","onDebuggerMessage","message","socket","method","broadcastMessage","send","JSON","stringify","id"],"mappings":"AAAA;;;;AAKO,MAAMA,iBAAiB;IAC5BC,YAA6BC,YAAmC,CAAE;aAArCA,YAAmC,GAAnCA,YAAmC;KAAI;IAEpEC,iBAAiB,CAACC,OAAoC,EAAE,EAAEC,MAAM,CAAA,EAAoB,EAAE;QACpF,IAAID,OAAO,CAACE,MAAM,KAAK,aAAa,EAAE;YACpC,IAAI,CAACJ,YAAY,CAACK,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC7CF,MAAM,CAACG,IAAI,CAACC,IAAI,CAACC,SAAS,CAAC;gBAAEC,EAAE,EAAEP,OAAO,CAACO,EAAE;aAAE,CAAC,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;KACd;CACF;QAZYX,iBAAiB,GAAjBA,iBAAiB"}
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  var _utils = require("./utils");
6
6
  class VscodeDebuggerGetPossibleBreakpointsHandler {
7
- onDebuggerMessage(message, { socket , debuggerType }) {
8
- if (debuggerType === "vscode" && message.method === "Debugger.getPossibleBreakpoints") {
7
+ onDebuggerMessage(message, { socket , userAgent }) {
8
+ if ((0, _utils).getDebuggerType(userAgent) === "vscode" && message.method === "Debugger.getPossibleBreakpoints") {
9
9
  return (0, _utils).respond(socket, {
10
10
  id: message.id,
11
11
  result: {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerGetPossibleBreakpoints.ts"],"sourcesContent":["import Protocol from 'devtools-protocol';\n\nimport {\n CdpMessage,\n DebuggerMetadata,\n DebuggerRequest,\n DeviceResponse,\n InspectorHandler,\n} from './types';\nimport { getDebuggerType, respond } from './utils';\n\n/**\n * Hermes doesn't seem to handle this request, but `locations` have to be returned.\n * Respond with an empty location to make it \"spec compliant\" with Chrome DevTools.\n */\nexport class VscodeDebuggerGetPossibleBreakpointsHandler implements InspectorHandler {\n onDebuggerMessage(\n message: DebuggerRequest<DebuggerGetPossibleBreakpoints>,\n { socket, userAgent }: DebuggerMetadata\n ): boolean {\n if (\n getDebuggerType(userAgent) === 'vscode' &&\n message.method === 'Debugger.getPossibleBreakpoints'\n ) {\n return respond<DeviceResponse<DebuggerGetPossibleBreakpoints>>(socket, {\n id: message.id,\n result: { locations: [] },\n });\n }\n\n return false;\n }\n}\n\n/** @see https://chromedevtools.github.io/devtools-protocol/v8/Debugger/#method-getPossibleBreakpoints */\nexport type DebuggerGetPossibleBreakpoints = CdpMessage<\n 'Debugger.getPossibleBreakpoints',\n Protocol.Debugger.GetPossibleBreakpointsRequest,\n Protocol.Debugger.GetPossibleBreakpointsResponse\n>;\n"],"names":["VscodeDebuggerGetPossibleBreakpointsHandler","onDebuggerMessage","message","socket","userAgent","getDebuggerType","method","respond","id","result","locations"],"mappings":"AAAA;;;;AASyC,IAAA,MAAS,WAAT,SAAS,CAAA;AAM3C,MAAMA,2CAA2C;IACtDC,iBAAiB,CACfC,OAAwD,EACxD,EAAEC,MAAM,CAAA,EAAEC,SAAS,CAAA,EAAoB,EAC9B;QACT,IACEC,CAAAA,GAAAA,MAAe,AAAW,CAAA,gBAAX,CAACD,SAAS,CAAC,KAAK,QAAQ,IACvCF,OAAO,CAACI,MAAM,KAAK,iCAAiC,EACpD;YACA,OAAOC,CAAAA,GAAAA,MAAO,AAGZ,CAAA,QAHY,CAAiDJ,MAAM,EAAE;gBACrEK,EAAE,EAAEN,OAAO,CAACM,EAAE;gBACdC,MAAM,EAAE;oBAAEC,SAAS,EAAE,EAAE;iBAAE;aAC1B,CAAC,CAAC;SACJ;QAED,OAAO,KAAK,CAAC;KACd;CACF;QAjBYV,2CAA2C,GAA3CA,2CAA2C"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ var _utils = require("./utils");
5
6
  /** Android's stock emulator and other emulators such as genymotion use a standard localhost alias. */ const EMULATOR_LOCALHOST_ADDRESSES = [
6
7
  "10.0.2.2",
7
8
  "10.0.3.2"
@@ -12,7 +13,7 @@ class VscodeDebuggerScriptParsedHandler {
12
13
  this.device = device;
13
14
  }
14
15
  onDeviceMessage(message, debuggerInfo) {
15
- if (debuggerInfo.debuggerType !== "vscode" || message.method !== "Debugger.scriptParsed") {
16
+ if ((0, _utils).getDebuggerType(debuggerInfo.userAgent) !== "vscode" || message.method !== "Debugger.scriptParsed") {
16
17
  return false;
17
18
  }
18
19
  // See: https://github.com/facebook/metro/blob/f43caa371a813b257cb0b42028079645a1e85e0e/packages/metro-inspector-proxy/src/Device.js#L401-L410
@@ -46,7 +47,7 @@ class VscodeDebuggerScriptParsedHandler {
46
47
  this.device._scriptIdToSourcePathMapping.set(message.params.scriptId, message.params.url);
47
48
  }
48
49
  }
49
- // Block `metro-inspector-proxy`'s default source map inlining
50
+ // Block `@react-native/dev-middleware`'s default source map inlining
50
51
  return true;
51
52
  }
52
53
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerScriptParsed.ts"],"sourcesContent":["import { unstable_Device as MetroDevice } from '@react-native/dev-middleware';\nimport Protocol from 'devtools-protocol';\n\nimport { CdpMessage, DebuggerMetadata, DeviceRequest, InspectorHandler } from './types';\nimport { getDebuggerType } from './utils';\n\n/** Android's stock emulator and other emulators such as genymotion use a standard localhost alias. */\nconst EMULATOR_LOCALHOST_ADDRESSES: Readonly<string[]> = ['10.0.2.2', '10.0.3.2'];\n/** Prefix for script URLs that are alphanumeric IDs. */\nconst FILE_PREFIX = 'file://';\n\n/**\n * Some debug clients does not support fetching source maps by URL.\n * By default, the `@react-native/dev-middleware` inlines the source map as base64 string.\n * Unfortunately, that causes a multi-second delay in VS Code (±5s).\n * This handler disables inlining the source maps for VS Code only.\n */\nexport class VscodeDebuggerScriptParsedHandler implements InspectorHandler {\n constructor(private readonly device: MetroDevice) {}\n\n onDeviceMessage(message: DeviceRequest<DebuggerScriptParsed>, debuggerInfo: DebuggerMetadata) {\n if (\n getDebuggerType(debuggerInfo.userAgent) !== 'vscode' ||\n message.method !== 'Debugger.scriptParsed'\n ) {\n return false;\n }\n\n // See: https://github.com/facebook/metro/blob/f43caa371a813b257cb0b42028079645a1e85e0e/packages/metro-inspector-proxy/src/Device.js#L401-L410\n if (message.params.sourceMapURL) {\n for (let i = 0; i < EMULATOR_LOCALHOST_ADDRESSES.length; ++i) {\n const address = EMULATOR_LOCALHOST_ADDRESSES[i];\n if (message.params.sourceMapURL.indexOf(address) >= 0) {\n message.params.sourceMapURL = message.params.sourceMapURL.replace(address, 'localhost');\n debuggerInfo.originalSourceURLAddress = address;\n }\n }\n }\n\n // See: https://github.com/facebook/metro/blob/f43caa371a813b257cb0b42028079645a1e85e0e/packages/metro-inspector-proxy/src/Device.js#L431-L453\n if (message.params.url) {\n for (let i = 0; i < EMULATOR_LOCALHOST_ADDRESSES.length; ++i) {\n const address = EMULATOR_LOCALHOST_ADDRESSES[i];\n if (message.params.url.indexOf(address) >= 0) {\n message.params.url = message.params.url.replace(address, 'localhost');\n debuggerInfo.originalSourceURLAddress = address;\n }\n }\n\n // Chrome doesn't download source maps if URL param is not a valid\n // URL. Some frameworks pass alphanumeric script ID instead of URL which causes\n // Chrome to not download source maps. In this case we want to prepend script ID\n // with 'file://' prefix.\n if (message.params.url.match(/^[0-9a-z]+$/)) {\n message.params.url = FILE_PREFIX + message.params.url;\n debuggerInfo.prependedFilePrefix = true;\n }\n\n if (message.params.scriptId != null) {\n this.device._scriptIdToSourcePathMapping.set(message.params.scriptId, message.params.url);\n }\n }\n\n // Block `@react-native/dev-middleware`'s default source map inlining\n return true;\n }\n}\n\n/** @see https://chromedevtools.github.io/devtools-protocol/v8/Debugger/#event-scriptParsed */\nexport type DebuggerScriptParsed = CdpMessage<\n 'Debugger.scriptParsed',\n Protocol.Debugger.ScriptParsedEvent,\n never\n>;\n"],"names":["EMULATOR_LOCALHOST_ADDRESSES","FILE_PREFIX","VscodeDebuggerScriptParsedHandler","constructor","device","onDeviceMessage","message","debuggerInfo","getDebuggerType","userAgent","method","params","sourceMapURL","i","length","address","indexOf","replace","originalSourceURLAddress","url","match","prependedFilePrefix","scriptId","_scriptIdToSourcePathMapping","set"],"mappings":"AAAA;;;;AAIgC,IAAA,MAAS,WAAT,SAAS,CAAA;AAEzC,sGAAsG,CACtG,MAAMA,4BAA4B,GAAuB;IAAC,UAAU;IAAE,UAAU;CAAC,AAAC;AAClF,wDAAwD,CACxD,MAAMC,WAAW,GAAG,SAAS,AAAC;AAQvB,MAAMC,iCAAiC;IAC5CC,YAA6BC,MAAmB,CAAE;aAArBA,MAAmB,GAAnBA,MAAmB;KAAI;IAEpDC,eAAe,CAACC,OAA4C,EAAEC,YAA8B,EAAE;QAC5F,IACEC,CAAAA,GAAAA,MAAe,AAAwB,CAAA,gBAAxB,CAACD,YAAY,CAACE,SAAS,CAAC,KAAK,QAAQ,IACpDH,OAAO,CAACI,MAAM,KAAK,uBAAuB,EAC1C;YACA,OAAO,KAAK,CAAC;SACd;QAED,8IAA8I;QAC9I,IAAIJ,OAAO,CAACK,MAAM,CAACC,YAAY,EAAE;YA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YAED,IAAIf,OAAO,CAACK,MAAM,CAACW,QAAQ,IAAI,IAAI,EAAE;gBACnC,IAAI,CAAClB,MAAM,CAACmB,4BAA4B,CAACC,GAAG,CAAClB,OAAO,CAACK,MAAM,CAACW,QAAQ,EAAEhB,OAAO,CAACK,MAAM,CAACQ,GAAG,CAAC,CAAC;aAC3F;SACF;QAED,qEAAqE;QACrE,OAAO,IAAI,CAAC;KACb;CACF;QAjDYjB,iCAAiC,GAAjCA,iCAAiC"}
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ var _utils = require("./utils");
5
6
  class VscodeDebuggerSetBreakpointByUrlHandler {
6
- onDebuggerMessage(message, { debuggerType }) {
7
- if (debuggerType === "vscode" && message.method === "Debugger.setBreakpointByUrl" && message.params.urlRegex) {
7
+ onDebuggerMessage(message, { userAgent }) {
8
+ if ((0, _utils).getDebuggerType(userAgent) === "vscode" && message.method === "Debugger.setBreakpointByUrl" && message.params.urlRegex) {
8
9
  // Explicitly force the breakpoint to be unbounded
9
10
  message.params.url = "file://__invalid_url__";
10
11
  delete message.params.urlRegex;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerSetBreakpointByUrl.ts"],"sourcesContent":["import Protocol from 'devtools-protocol';\n\nimport { CdpMessage, DebuggerMetadata, DebuggerRequest, InspectorHandler } from './types';\nimport { getDebuggerType } from './utils';\n\n/**\n * Hermes and vscode have trouble setting breakpoints by `urlRegex` through `Debugger.setBreakpointByUrl`.\n * Vscode adds `file://` to a URL containing `http://`, which confuses Hermes and sets it to the wrong location.\n * Hermes needs to create the breakpoint to get the proper ID, but it must be unbounded.\n * Once the sourcemap is loaded, vscode will rebind the unbounded breakpoint to the correct location (using `Debugger.setBreakpoint`).\n */\nexport class VscodeDebuggerSetBreakpointByUrlHandler implements InspectorHandler {\n onDebuggerMessage(\n message: DebuggerRequest<DebuggerSetBreakpointByUrl>,\n { userAgent }: DebuggerMetadata\n ): boolean {\n if (\n getDebuggerType(userAgent) === 'vscode' &&\n message.method === 'Debugger.setBreakpointByUrl' &&\n message.params.urlRegex\n ) {\n // Explicitly force the breakpoint to be unbounded\n message.params.url = 'file://__invalid_url__';\n delete message.params.urlRegex;\n }\n\n return false;\n }\n}\n\n/** @see https://chromedevtools.github.io/devtools-protocol/v8/Debugger/#method-setBreakpointByUrl */\nexport type DebuggerSetBreakpointByUrl = CdpMessage<\n 'Debugger.setBreakpointByUrl',\n Protocol.Debugger.SetBreakpointByUrlRequest,\n Protocol.Debugger.SetBreakpointByUrlResponse\n>;\n"],"names":["VscodeDebuggerSetBreakpointByUrlHandler","onDebuggerMessage","message","userAgent","getDebuggerType","method","params","urlRegex","url"],"mappings":"AAAA;;;;AAGgC,IAAA,MAAS,WAAT,SAAS,CAAA;AAQlC,MAAMA,uCAAuC;IAClDC,iBAAiB,CACfC,OAAoD,EACpD,EAAEC,SAAS,CAAA,EAAoB,EACtB;QACT,IACEC,CAAAA,GAAAA,MAAe,AAAW,CAAA,gBAAX,CAACD,SAAS,CAAC,KAAK,QAAQ,IACvCD,OAAO,CAACG,MAAM,KAAK,6BAA6B,IAChDH,OAAO,CAACI,MAAM,CAACC,QAAQ,EACvB;YACA,kDAAkD;YAClDL,OAAO,CAACI,MAAM,CAACE,GAAG,GAAG,wBAAwB,CAAC;YAC9C,OAAON,OAAO,CAACI,MAAM,CAACC,QAAQ,CAAC;SAChC;QAED,OAAO,KAAK,CAAC;KACd;CACF;QAjBYP,uCAAuC,GAAvCA,uCAAuC"}
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  var _utils = require("./utils");
6
6
  class VscodeRuntimeCallFunctionOnHandler {
7
- onDebuggerMessage(message, { socket , debuggerType }) {
8
- if (debuggerType === "vscode" && message.method === "Runtime.callFunctionOn") {
7
+ onDebuggerMessage(message, { socket , userAgent }) {
8
+ if ((0, _utils).getDebuggerType(userAgent) === "vscode" && message.method === "Runtime.callFunctionOn") {
9
9
  return (0, _utils).respond(socket, {
10
10
  id: message.id,
11
11
  result: {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeCallFunctionOn.ts"],"sourcesContent":["import Protocol from 'devtools-protocol';\n\nimport {\n CdpMessage,\n DebuggerMetadata,\n DebuggerRequest,\n DeviceResponse,\n InspectorHandler,\n} from './types';\nimport { getDebuggerType, respond } from './utils';\n\n/**\n * Vscode is trying to inject a script to fetch information about \"Stringy\" variables.\n * Unfortunately, this script causes a Hermes exception and crashes the app.\n *\n * @see https://github.com/expo/vscode-expo/issues/231\n * @see https://github.com/microsoft/vscode-js-debug/blob/dcccaf3972d675cc1e5c776450bb4c3dc8c178c1/src/adapter/stackTrace.ts#L319-L324\n */\nexport class VscodeRuntimeCallFunctionOnHandler implements InspectorHandler {\n onDebuggerMessage(\n message: DebuggerRequest<RuntimeCallFunctionOn>,\n { socket, userAgent }: DebuggerMetadata\n ): boolean {\n if (getDebuggerType(userAgent) === 'vscode' && message.method === 'Runtime.callFunctionOn') {\n return respond<DeviceResponse<RuntimeCallFunctionOn>>(socket, {\n id: message.id,\n result: {\n // We don't know the `type` and vscode allows `type: undefined`\n result: { objectId: message.params.objectId } as any,\n },\n });\n }\n\n return false;\n }\n}\n\n/** @see https://chromedevtools.github.io/devtools-protocol/v8/Runtime/#method-callFunctionOn */\nexport type RuntimeCallFunctionOn = CdpMessage<\n 'Runtime.callFunctionOn',\n Protocol.Runtime.CallFunctionOnRequest,\n Protocol.Runtime.CallFunctionOnResponse\n>;\n"],"names":["VscodeRuntimeCallFunctionOnHandler","onDebuggerMessage","message","socket","userAgent","getDebuggerType","method","respond","id","result","objectId","params"],"mappings":"AAAA;;;;AASyC,IAAA,MAAS,WAAT,SAAS,CAAA;AAS3C,MAAMA,kCAAkC;IAC7CC,iBAAiB,CACfC,OAA+C,EAC/C,EAAEC,MAAM,CAAA,EAAEC,SAAS,CAAA,EAAoB,EAC9B;QACT,IAAIC,CAAAA,GAAAA,MAAe,AAAW,CAAA,gBAAX,CAACD,SAAS,CAAC,KAAK,QAAQ,IAAIF,OAAO,CAACI,MAAM,KAAK,wBAAwB,EAAE;YAC1F,OAAOC,CAAAA,GAAAA,MAAO,AAMZ,CAAA,QANY,CAAwCJ,MAAM,EAAE;gBAC5DK,EAAE,EAAEN,OAAO,CAACM,EAAE;gBACdC,MAAM,EAAE;oBACN,+DAA+D;oBAC/DA,MAAM,EAAE;wBAAEC,QAAQ,EAAER,OAAO,CAACS,MAAM,CAACD,QAAQ;qBAAE;iBAC9C;aACF,CAAC,CAAC;SACJ;QAED,OAAO,KAAK,CAAC;KACd;CACF;QAjBYV,kCAAkC,GAAlCA,kCAAkC"}
@@ -2,17 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ var _utils = require("./utils");
5
6
  class VscodeRuntimeGetPropertiesHandler {
6
7
  /** Keep track of `Runtime.getProperties` responses to intercept, by request id */ interceptGetProperties = new Set();
7
- onDebuggerMessage(message, { debuggerType }) {
8
- if (debuggerType === "vscode" && message.method === "Runtime.getProperties") {
8
+ onDebuggerMessage(message, { userAgent }) {
9
+ if ((0, _utils).getDebuggerType(userAgent) === "vscode" && message.method === "Runtime.getProperties") {
9
10
  this.interceptGetProperties.add(message.id);
10
11
  }
11
12
  // Do not block propagation of this message
12
13
  return false;
13
14
  }
14
- onDeviceMessage(message, { debuggerType }) {
15
- if (debuggerType === "vscode" && "id" in message && this.interceptGetProperties.has(message.id)) {
15
+ onDeviceMessage(message, { userAgent }) {
16
+ if ((0, _utils).getDebuggerType(userAgent) === "vscode" && "id" in message && this.interceptGetProperties.has(message.id)) {
16
17
  this.interceptGetProperties.delete(message.id);
17
18
  var _result;
18
19
  for (const item of (_result = message.result.result) != null ? _result : []){
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeGetProperties.ts"],"sourcesContent":["import Protocol from 'devtools-protocol';\n\nimport {\n CdpMessage,\n DebuggerMetadata,\n DebuggerRequest,\n DeviceResponse,\n InspectorHandler,\n} from './types';\nimport { getDebuggerType } from './utils';\n\n/**\n * Vscode doesn't seem to work nicely with missing `description` fields on `RemoteObject` instances.\n * It also tries to invoke `Runtime.callFunctionOn` on `Symbol` types, which crashes Hermes.\n * This handler tries to compensate for these two separate issues.\n *\n * @see https://github.com/facebook/hermes/issues/114\n * @see https://github.com/microsoft/vscode-js-debug/issues/1583\n */\nexport class VscodeRuntimeGetPropertiesHandler implements InspectorHandler {\n /** Keep track of `Runtime.getProperties` responses to intercept, by request id */\n interceptGetProperties = new Set<number>();\n\n onDebuggerMessage(\n message: DebuggerRequest<RuntimeGetProperties>,\n { userAgent }: DebuggerMetadata\n ): boolean {\n if (getDebuggerType(userAgent) === 'vscode' && message.method === 'Runtime.getProperties') {\n this.interceptGetProperties.add(message.id);\n }\n\n // Do not block propagation of this message\n return false;\n }\n\n onDeviceMessage(message: DeviceResponse<RuntimeGetProperties>, { userAgent }: DebuggerMetadata) {\n if (\n getDebuggerType(userAgent) === 'vscode' &&\n 'id' in message &&\n this.interceptGetProperties.has(message.id)\n ) {\n this.interceptGetProperties.delete(message.id);\n\n for (const item of message.result.result ?? []) {\n // Force-fully format the properties description to be an empty string\n if (item.value) {\n item.value.description = item.value.description ?? '';\n }\n\n // Avoid passing the `objectId` for symbol types.\n // When collapsing in vscode, it will fetch information about the symbol using the `objectId`.\n // The `Runtime.getProperties` request of the symbol hard-crashes Hermes.\n if (item.value?.type === 'symbol' && item.value.objectId) {\n delete item.value.objectId;\n }\n }\n }\n\n // Do not block propagation of this message\n return false;\n }\n}\n\n/** @see https://chromedevtools.github.io/devtools-protocol/v8/Runtime/#method-getProperties */\nexport type RuntimeGetProperties = CdpMessage<\n 'Runtime.getProperties',\n Protocol.Runtime.GetPropertiesRequest,\n Protocol.Runtime.GetPropertiesResponse\n>;\n"],"names":["VscodeRuntimeGetPropertiesHandler","interceptGetProperties","Set","onDebuggerMessage","message","userAgent","getDebuggerType","method","add","id","onDeviceMessage","has","delete","item","result","value","description","type","objectId"],"mappings":"AAAA;;;;AASgC,IAAA,MAAS,WAAT,SAAS,CAAA;AAUlC,MAAMA,iCAAiC;IAC5C,kFAAkF,CAClFC,sBAAsB,GAAG,IAAIC,GAAG,EAAU,CAAC;IAE3CC,iBAAiB,CACfC,OAA8C,EAC9C,EAAEC,SAAS,CAAA,EAAoB,EACtB;QACT,IAAIC,CAAAA,GAAAA,MAAe,AAAW,CAAA,gBAAX,CAACD,SAAS,CAAC,KAAK,QAAQ,IAAID,OAAO,CAACG,MAAM,KAAK,uBAAuB,EAAE;YACzF,IAAI,CAACN,sBAAsB,CAACO,GAAG,CAACJ,OAAO,CAACK,EAAE,CAAC,CAAC;SAC7C;QAED,2CAA2C;QAC3C,OAAO,KAAK,CAAC;KACd;IAEDC,eAAe,CAACN,OAA6C,EAAE,EAAEC,SAAS,CAAA,EAAoB,EAAE;QAC9F,IACEC,CAAAA,GAAAA,MAAe,AAAW,CAAA,gBAAX,CAACD,SAAS,CAAC,KAAK,QAAQ,IACvC,IAAI,IAAID,OAAO,IACf,IAAI,CAACH,sBAAsB,CAACU,GAAG,CAACP,OAAO,CAACK,EAAE,CAAC,EAC3C;YACA,IAAI,CAACR,sBAAsB,CAACW,MAAM,CAACR,OAAO,CAACK,EAAE,CAAC,CAAC;gBAE5BL,OAAqB;YAAxC,KAAK,MAAMS,IAAI,IAAIT,CAAAA,OAAqB,GAArBA,OAAO,CAACU,MAAM,CAACA,MAAM,YAArBV,OAAqB,GAAI,EAAE,CAAE;oBAS1CS,GAAU;gBARd,sEAAsE;gBACtE,IAAIA,IAAI,CAACE,KAAK,EAAE;wBACWF,YAAsB;oBAA/CA,IAAI,CAACE,KAAK,CAACC,WAAW,GAAGH,CAAAA,YAAsB,GAAtBA,IAAI,CAACE,KAAK,CAACC,WAAW,YAAtBH,YAAsB,GAAI,EAAE,CAAC;iBACvD;gBAED,iDAAiD;gBACjD,8FAA8F;gBAC9F,yEAAyE;gBACzE,IAAIA,CAAAA,CAAAA,GAAU,GAAVA,IAAI,CAACE,KAAK,SAAM,GAAhBF,KAAAA,CAAgB,GAAhBA,GAAU,CAAEI,IAAI,CAAA,KAAK,QAAQ,IAAIJ,IAAI,CAACE,KAAK,CAACG,QAAQ,EAAE;oBACxD,OAAOL,IAAI,CAACE,KAAK,CAACG,QAAQ,CAAC;iBAC5B;aACF;SACF;QAED,2CAA2C;QAC3C,OAAO,KAAK,CAAC;KACd;CACF;QA1CYlB,iCAAiC,GAAjCA,iCAAiC"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/types.ts"],"sourcesContent":["import type { unstable_Device } from '@react-native/dev-middleware';\n\nexport type DebuggerMetadata = NonNullable<unstable_Device['_debuggerConnection']>;\n\nexport interface InspectorHandler {\n /**\n * Intercept a message coming from the device, modify or respond to it through `this._sendMessageToDevice`.\n * Return `true` if the message was handled, this will stop the message propagation.\n */\n onDeviceMessage?(message: DeviceRequest | DeviceResponse, info: DebuggerMetadata): boolean;\n\n /**\n * Intercept a message coming from the debugger, modify or respond to it through `socket.send`.\n * Return `true` if the message was handled, this will stop the message propagation.\n */\n onDebuggerMessage?(message: DebuggerRequest, info: DebuggerMetadata): boolean;\n}\n\n/**\n * The outline of a basic Chrome DevTools Protocol request, either from device or debugger.\n * Both the request and response parameters could be optional, use `never` to enforce these fields.\n */\nexport type CdpMessage<\n Method extends string = string,\n Request extends object = object,\n Response extends object = object,\n> = {\n id: number;\n method: Method;\n params: Request;\n result: Response;\n};\n\nexport type DeviceRequest<M extends CdpMessage = CdpMessage> = Pick<M, 'method' | 'params'>;\nexport type DeviceResponse<M extends CdpMessage = CdpMessage> = Pick<M, 'id' | 'result'>;\n\nexport type DebuggerRequest<M extends CdpMessage = CdpMessage> = Pick<\n M,\n 'id' | 'method' | 'params'\n>;\nexport type DebuggerResponse<M extends CdpMessage = CdpMessage> = Pick<M, 'result'>;\n"],"names":[],"mappings":"AAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.respond = respond;
6
+ exports.getDebuggerType = getDebuggerType;
7
+ function respond(socket, message) {
8
+ socket.send(JSON.stringify(message));
9
+ return true;
10
+ }
11
+ // Patterns to test against user agents
12
+ const CHROME_USER_AGENT = /chrome/i;
13
+ const VSCODE_USER_AGENT = /vscode/i;
14
+ function getDebuggerType(userAgent) {
15
+ if (userAgent && CHROME_USER_AGENT.test(userAgent)) return "chrome";
16
+ if (userAgent && VSCODE_USER_AGENT.test(userAgent)) return "vscode";
17
+ return "unknown";
18
+ }
19
+
20
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../src/start/server/metro/debugging/inspectorHandlers/utils.ts"],"sourcesContent":["import type WS from 'ws';\n\nimport { DebuggerResponse, DeviceResponse } from './types';\n\n/**\n * Helper function to respond to a message from the debugger or device.\n * The return value is used to stop the message propagation, \"canceling\" further handling.\n *\n * @example ```\n * return respond<DeviceResponse<CDP>>(socket, { id: message.id, result: {} });\n * ```\n */\nexport function respond<T = DeviceResponse | DebuggerResponse>(socket: WS, message: T) {\n socket.send(JSON.stringify(message));\n return true;\n}\n\n/** Known compatible debuggers that require specific workarounds */\nexport type DebuggerType = 'chrome' | 'vscode' | 'unknown';\n\n// Patterns to test against user agents\nconst CHROME_USER_AGENT = /chrome/i;\nconst VSCODE_USER_AGENT = /vscode/i;\n\n/**\n * Determine the debugger type based on the known user agent.\n */\nexport function getDebuggerType(userAgent?: string | null): DebuggerType {\n if (userAgent && CHROME_USER_AGENT.test(userAgent)) return 'chrome';\n if (userAgent && VSCODE_USER_AGENT.test(userAgent)) return 'vscode';\n return 'unknown';\n}\n"],"names":["respond","getDebuggerType","socket","message","send","JSON","stringify","CHROME_USER_AGENT","VSCODE_USER_AGENT","userAgent","test"],"mappings":"AAAA;;;;QAYgBA,OAAO,GAAPA,OAAO;QAePC,eAAe,GAAfA,eAAe;AAfxB,SAASD,OAAO,CAAwCE,MAAU,EAAEC,OAAU,EAAE;IACrFD,MAAM,CAACE,IAAI,CAACC,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC;CACb;AAKD,uCAAuC;AACvC,MAAMI,iBAAiB,YAAY,AAAC;AACpC,MAAMC,iBAAiB,YAAY,AAAC;AAK7B,SAASP,eAAe,CAACQ,SAAyB,EAAgB;IACvE,IAAIA,SAAS,IAAIF,iBAAiB,CAACG,IAAI,CAACD,SAAS,CAAC,EAAE,OAAO,QAAQ,CAAC;IACpE,IAAIA,SAAS,IAAID,iBAAiB,CAACE,IAAI,CAACD,SAAS,CAAC,EAAE,OAAO,QAAQ,CAAC;IACpE,OAAO,SAAS,CAAC;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/getCssModulesFromBundler.ts"],"sourcesContent":["import { MetroConfig } from '@expo/metro-config';\nimport crypto from 'crypto';\nimport type { Module } from 'metro';\nimport { getJsOutput, isJsModule } from 'metro/src/DeltaBundler/Serializers/helpers/js';\nimport type { ReadOnlyDependencies } from 'metro/src/DeltaBundler/types';\nimport type IncrementalBundler from 'metro/src/IncrementalBundler';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport path from 'path';\n\n// import { getAssetData } from 'metro/src/Assets';\n\ntype Options = {\n processModuleFilter: (modules: Module) => boolean;\n assetPlugins: readonly string[];\n platform?: string | null;\n projectRoot: string;\n publicPath: string;\n};\n\ntype MetroModuleCSSMetadata = {\n code: string;\n lineCount: number;\n map: any[];\n};\n\nexport type CSSAsset = {\n // 'styles.css'\n originFilename: string;\n // '_expo/static/css/bc6aa0a69dcebf8e8cac1faa76705756.css'\n filename: string;\n // '\\ndiv {\\n background: cyan;\\n}\\n\\n'\n source: string;\n};\n\n// s = static\nconst STATIC_EXPORT_DIRECTORY = '_expo/static/css';\n\n/** @returns the static CSS assets used in a given bundle. CSS assets are only enabled if the `@expo/metro-config` `transformerPath` is used. */\nexport async function getCssModulesFromBundler(\n config: MetroConfig,\n incrementalBundler: IncrementalBundler,\n options: any\n): Promise<CSSAsset[]> {\n // Static CSS is a web-only feature.\n if (options.platform !== 'web') {\n return [];\n }\n\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions(options);\n\n const dependencies = await incrementalBundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false }\n );\n\n return getCssModules(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform,\n projectRoot: config.server.unstable_serverRoot ?? config.projectRoot,\n publicPath: config.transformer.publicPath,\n });\n}\n\nfunction hashString(str: string) {\n return crypto.createHash('md5').update(str).digest('hex');\n}\n\nfunction getCssModules(\n dependencies: ReadOnlyDependencies,\n { processModuleFilter, projectRoot }: Options\n) {\n const promises = [];\n\n for (const module of dependencies.values()) {\n if (\n isJsModule(module) &&\n processModuleFilter(module) &&\n getJsOutput(module).type === 'js/module' &&\n path.relative(projectRoot, module.path) !== 'package.json'\n ) {\n const cssMetadata = getCssMetadata(module);\n if (cssMetadata) {\n const contents = cssMetadata.code;\n const filename = path.join(\n // Consistent location\n STATIC_EXPORT_DIRECTORY,\n // Hashed file contents + name for caching\n getFileName(module.path) + '-' + hashString(module.path + contents) + '.css'\n );\n promises.push({\n originFilename: path.relative(projectRoot, module.path),\n filename,\n source: contents,\n });\n }\n }\n }\n\n return promises;\n}\n\nfunction getCssMetadata(module: Module): MetroModuleCSSMetadata | null {\n const data = module.output[0]?.data;\n if (data && typeof data === 'object' && 'css' in data) {\n if (typeof data.css !== 'object' || !('code' in (data as any).css)) {\n throw new Error(\n `Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`\n );\n }\n return data.css as MetroModuleCSSMetadata;\n }\n return null;\n}\n\nexport function getFileName(module: string) {\n return path.basename(module).replace(/\\.[^.]+$/, '');\n}\n"],"names":["getCssModulesFromBundler","getFileName","STATIC_EXPORT_DIRECTORY","config","incrementalBundler","options","platform","entryFile","onProgress","resolverOptions","transformOptions","splitBundleOptions","dependencies","getDependencies","shallow","getCssModules","processModuleFilter","serializer","assetPlugins","transformer","projectRoot","server","unstable_serverRoot","publicPath","hashString","str","crypto","createHash","update","digest","promises","module","values","isJsModule","getJsOutput","type","path","relative","cssMetadata","getCssMetadata","contents","code","filename","join","push","originFilename","source","data","output","css","Error","JSON","stringify","basename","replace"],"mappings":"AAAA;;;;QAsCsBA,wBAAwB,GAAxBA,wBAAwB;QA+E9BC,WAAW,GAAXA,WAAW;AApHR,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEa,IAAA,GAA+C,WAA/C,+CAA+C,CAAA;AAGxD,IAAA,mBAAkC,kCAAlC,kCAAkC,EAAA;AAChD,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AA2BvB,aAAa;AACb,MAAMC,uBAAuB,GAAG,kBAAkB,AAAC;AAG5C,eAAeF,wBAAwB,CAC5CG,MAAmB,EACnBC,kBAAsC,EACtCC,OAAY,EACS;IACrB,oCAAoC;IACpC,IAAIA,OAAO,CAACC,QAAQ,KAAK,KAAK,EAAE;QAC9B,OAAO,EAAE,CAAC;KACX;IAED,MAAM,EAAEC,SAAS,CAAA,EAAEC,UAAU,CAAA,EAAEC,eAAe,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGC,CAAAA,GAAAA,mBAAkB,AAAS,CAAA,QAAT,CAACN,OAAO,CAAC,AAAC;IAEjG,MAAMO,YAAY,GAAG,MAAMR,kBAAkB,CAACS,eAAe,CAC3D;QAACN,SAAS;KAAC,EACXG,gBAAgB,EAChBD,eAAe,EACf;QAAED,UAAU;QAAEM,OAAO,EAAE,KAAK;KAAE,CAC/B,AAAC;Q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"version":3,"sources":["../../../../../src/start/server/metro/getCssModulesFromBundler.ts"],"sourcesContent":["import { MetroConfig } from '@expo/metro-config';\nimport crypto from 'crypto';\nimport type { Module } from 'metro';\nimport { getJsOutput, isJsModule } from 'metro/src/DeltaBundler/Serializers/helpers/js';\nimport type { ReadOnlyDependencies } from 'metro/src/DeltaBundler/types';\nimport type IncrementalBundler from 'metro/src/IncrementalBundler';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport path from 'path';\n\ntype Options = {\n processModuleFilter: (modules: Module) => boolean;\n assetPlugins: readonly string[];\n platform?: string | null;\n projectRoot: string;\n publicPath: string;\n};\n\ntype MetroModuleCSSMetadata = {\n code: string;\n lineCount: number;\n map: any[];\n};\n\nexport type CSSAsset = {\n // 'styles.css'\n originFilename: string;\n // '_expo/static/css/bc6aa0a69dcebf8e8cac1faa76705756.css'\n filename: string;\n // '\\ndiv {\\n background: cyan;\\n}\\n\\n'\n source: string;\n};\n\n// s = static\nconst STATIC_EXPORT_DIRECTORY = '_expo/static/css';\n\n/** @returns the static CSS assets used in a given bundle. CSS assets are only enabled if the `@expo/metro-config` `transformerPath` is used. */\nexport async function getCssModulesFromBundler(\n config: MetroConfig,\n incrementalBundler: IncrementalBundler,\n options: any\n): Promise<CSSAsset[]> {\n // Static CSS is a web-only feature.\n if (options.platform !== 'web') {\n return [];\n }\n\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions(options);\n\n const dependencies = await incrementalBundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false }\n );\n\n return getCssModules(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform,\n projectRoot: config.server.unstable_serverRoot ?? config.projectRoot,\n publicPath: config.transformer.publicPath,\n });\n}\n\nfunction hashString(str: string) {\n return crypto.createHash('md5').update(str).digest('hex');\n}\n\nfunction getCssModules(\n dependencies: ReadOnlyDependencies,\n { processModuleFilter, projectRoot }: Options\n) {\n const promises = [];\n\n for (const module of dependencies.values()) {\n if (\n isJsModule(module) &&\n processModuleFilter(module) &&\n getJsOutput(module).type === 'js/module' &&\n path.relative(projectRoot, module.path) !== 'package.json'\n ) {\n const cssMetadata = getCssMetadata(module);\n if (cssMetadata) {\n const contents = cssMetadata.code;\n const filename = path.join(\n // Consistent location\n STATIC_EXPORT_DIRECTORY,\n // Hashed file contents + name for caching\n getFileName(module.path) + '-' + hashString(module.path + contents) + '.css'\n );\n promises.push({\n originFilename: path.relative(projectRoot, module.path),\n filename,\n source: contents,\n });\n }\n }\n }\n\n return promises;\n}\n\nfunction getCssMetadata(module: Module): MetroModuleCSSMetadata | null {\n const data = module.output[0]?.data;\n if (data && typeof data === 'object' && 'css' in data) {\n if (typeof data.css !== 'object' || !('code' in (data as any).css)) {\n throw new Error(\n `Unexpected CSS metadata in Metro module (${module.path}): ${JSON.stringify(data.css)}`\n );\n }\n return data.css as MetroModuleCSSMetadata;\n }\n return null;\n}\n\nexport function getFileName(module: string) {\n return path.basename(module).replace(/\\.[^.]+$/, '');\n}\n"],"names":["getCssModulesFromBundler","getFileName","STATIC_EXPORT_DIRECTORY","config","incrementalBundler","options","platform","entryFile","onProgress","resolverOptions","transformOptions","splitBundleOptions","dependencies","getDependencies","shallow","getCssModules","processModuleFilter","serializer","assetPlugins","transformer","projectRoot","server","unstable_serverRoot","publicPath","hashString","str","crypto","createHash","update","digest","promises","module","values","isJsModule","getJsOutput","type","path","relative","cssMetadata","getCssMetadata","contents","code","filename","join","push","originFilename","source","data","output","css","Error","JSON","stringify","basename","replace"],"mappings":"AAAA;;;;QAoCsBA,wBAAwB,GAAxBA,wBAAwB;QA+E9BC,WAAW,GAAXA,WAAW;AAlHR,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEa,IAAA,GAA+C,WAA/C,+CAA+C,CAAA;AAGxD,IAAA,mBAAkC,kCAAlC,kCAAkC,EAAA;AAChD,IAAA,KAAM,kCAAN,MAAM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I,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAIA,IAAI,EAAE;QACrD,IAAI,OAAOA,IAAI,CAACE,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,AAACF,IAAI,CAASE,GAAG,CAAC,EAAE;YAClE,MAAM,IAAIC,KAAK,CACb,CAAC,yCAAyC,EAAEnB,MAAM,CAACK,IAAI,CAAC,GAAG,EAAEe,IAAI,CAACC,SAAS,CAACL,IAAI,CAACE,GAAG,CAAC,CAAC,CAAC,CACxF,CAAC;SACH;QACD,OAAOF,IAAI,CAACE,GAAG,CAA2B;KAC3C;IACD,OAAO,IAAI,CAAC;CACb;AAEM,SAAShD,WAAW,CAAC8B,MAAc,EAAE;IAC1C,OAAOK,KAAI,QAAA,CAACiB,QAAQ,CAACtB,MAAM,CAAC,CAACuB,OAAO,aAAa,EAAE,CAAC,CAAC;CACtD"}
@@ -12,7 +12,7 @@ var _metroCore = require("metro-core");
12
12
  var _semver = _interopRequireDefault(require("semver"));
13
13
  var _url = require("url");
14
14
  var _metroTerminalReporter = require("./MetroTerminalReporter");
15
- var _router = require("./router");
15
+ var _createDebugMiddleware = require("./debugging/createDebugMiddleware");
16
16
  var _runServerFork = require("./runServer-fork");
17
17
  var _withMetroMultiPlatform = require("./withMetroMultiPlatform");
18
18
  var _log = require("../../../log");
@@ -21,7 +21,6 @@ var _metroDebuggerMiddleware = require("../../../utils/analytics/metroDebuggerMi
21
21
  var _rudderstackClient = require("../../../utils/analytics/rudderstackClient");
22
22
  var _env = require("../../../utils/env");
23
23
  var _manifestMiddleware = require("../middleware/ManifestMiddleware");
24
- var _createJsInspectorMiddleware = _interopRequireDefault(require("../middleware/inspector/createJsInspectorMiddleware"));
25
24
  var _mutations = require("../middleware/mutations");
26
25
  var _remoteDevtoolsCorsMiddleware = require("../middleware/remoteDevtoolsCorsMiddleware");
27
26
  var _remoteDevtoolsSecurityHeadersMiddleware = require("../middleware/remoteDevtoolsSecurityHeadersMiddleware");
@@ -110,7 +109,6 @@ async function loadMetroConfigAsync(projectRoot, options, { exp =(0, _config).ge
110
109
  const platformBundlers = (0, _platformBundlers).getPlatformBundlers(exp);
111
110
  var ref6, ref7;
112
111
  config = await (0, _withMetroMultiPlatform).withMetroMultiPlatformAsync(projectRoot, {
113
- routerDirectory: (0, _router).getRouterDirectoryModuleIdWithManifest(projectRoot, exp),
114
112
  config,
115
113
  platformBundlers,
116
114
  isTsconfigPathsEnabled: (ref6 = (ref = exp.experiments) == null ? void 0 : ref.tsconfigPaths) != null ? ref6 : true,
@@ -148,7 +146,6 @@ async function instantiateMetroAsync(metroBundler, options, { isExporting }) {
148
146
  (0, _mutations).replaceMiddlewareWith(middleware, securityHeadersMiddleware, _remoteDevtoolsSecurityHeadersMiddleware.remoteDevtoolsSecurityHeadersMiddleware);
149
147
  middleware.use(_remoteDevtoolsCorsMiddleware.remoteDevtoolsCorsMiddleware);
150
148
  (0, _mutations).prependMiddleware(middleware, _suppressErrorMiddleware.suppressRemoteDebuggingErrorMiddleware);
151
- middleware.use("/inspector", (0, _createJsInspectorMiddleware).default());
152
149
  // TODO: We can probably drop this now.
153
150
  const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;
154
151
  // @ts-expect-error: can't mutate readonly config
@@ -159,9 +156,15 @@ async function instantiateMetroAsync(metroBundler, options, { isExporting }) {
159
156
  return middleware.use(metroMiddleware);
160
157
  };
161
158
  middleware.use((0, _metroDebuggerMiddleware).createDebuggerTelemetryMiddleware(projectRoot, exp));
159
+ // Initialize all React Native debug features
160
+ const { debugMiddleware , debugWebsocketEndpoints } = (0, _createDebugMiddleware).createDebugMiddleware(metroBundler);
161
+ (0, _mutations).prependMiddleware(middleware, debugMiddleware);
162
162
  const { server: server1 , metro } = await (0, _runServerFork).runServer(metroBundler, metroConfig, {
163
163
  // @ts-expect-error: Inconsistent `websocketEndpoints` type between metro and @react-native-community/cli-server-api
164
- websocketEndpoints,
164
+ websocketEndpoints: {
165
+ ...websocketEndpoints,
166
+ ...debugWebsocketEndpoints
167
+ },
165
168
  watch: !isExporting && isWatchEnabled()
166
169
  });
167
170
  (0, _mutations).prependMiddleware(middleware, (req, res, next)=>{