@expo/cli 0.10.7 → 0.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +2 -2
- package/build/src/start/server/metro/inspector-proxy/device.js +21 -2
- package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/DebuggerScriptSource.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/NetworkResponse.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/PageReload.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js +22 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js +55 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js +17 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js +39 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/types.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/proxy.js +14 -6
- package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +2 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
- package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js +38 -0
- package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -0
- package/build/src/start/server/type-generation/__typetests__/generateFixtures.js +38 -0
- package/build/src/start/server/type-generation/__typetests__/generateFixtures.js.map +1 -0
- package/build/src/start/server/type-generation/__typetests__/route.test.js +165 -0
- package/build/src/start/server/type-generation/__typetests__/route.test.js.map +1 -0
- package/build/src/start/server/type-generation/routes.js +175 -62
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/package.json +10 -8
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeCompat.js +0 -63
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeCompat.js.map +0 -1
package/build/bin/cli
CHANGED
|
@@ -132,7 +132,7 @@ const args = (0, _arg).default({
|
|
|
132
132
|
});
|
|
133
133
|
if (args["--version"]) {
|
|
134
134
|
// Version is added in the build script.
|
|
135
|
-
console.log("0.10.
|
|
135
|
+
console.log("0.10.8");
|
|
136
136
|
process.exit(0);
|
|
137
137
|
}
|
|
138
138
|
if (args["--non-interactive"]) {
|
|
@@ -262,7 +262,7 @@ commands[command]().then((exec)=>{
|
|
|
262
262
|
logEventAsync("action", {
|
|
263
263
|
action: `expo ${command}`,
|
|
264
264
|
source: "expo/cli",
|
|
265
|
-
source_version: "0.10.
|
|
265
|
+
source_version: "0.10.8"
|
|
266
266
|
});
|
|
267
267
|
});
|
|
268
268
|
|
|
@@ -7,7 +7,10 @@ var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
|
7
7
|
var _debuggerScriptSource = require("./handlers/DebuggerScriptSource");
|
|
8
8
|
var _networkResponse = require("./handlers/NetworkResponse");
|
|
9
9
|
var _pageReload = require("./handlers/PageReload");
|
|
10
|
-
var
|
|
10
|
+
var _vscodeDebuggerGetPossibleBreakpoints = require("./handlers/VscodeDebuggerGetPossibleBreakpoints");
|
|
11
|
+
var _vscodeDebuggerScriptParsed = require("./handlers/VscodeDebuggerScriptParsed");
|
|
12
|
+
var _vscodeDebuggerSetBreakpointByUrl = require("./handlers/VscodeDebuggerSetBreakpointByUrl");
|
|
13
|
+
var _vscodeRuntimeGetProperties = require("./handlers/VscodeRuntimeGetProperties");
|
|
11
14
|
function _interopRequireDefault(obj) {
|
|
12
15
|
return obj && obj.__esModule ? obj : {
|
|
13
16
|
default: obj
|
|
@@ -15,11 +18,17 @@ function _interopRequireDefault(obj) {
|
|
|
15
18
|
}
|
|
16
19
|
function createInspectorDeviceClass(metroBundler, MetroDeviceClass) {
|
|
17
20
|
return class ExpoInspectorDevice extends MetroDeviceClass {
|
|
21
|
+
/** Stores information about currently connected debugger (if any). */ _debuggerConnection = null;
|
|
18
22
|
/** All handlers that should be used to intercept or reply to CDP events */ handlers = [
|
|
23
|
+
// Generic handlers
|
|
19
24
|
new _networkResponse.NetworkResponseHandler(),
|
|
20
25
|
new _debuggerScriptSource.DebuggerScriptSourceHandler(this),
|
|
21
26
|
new _pageReload.PageReloadHandler(metroBundler),
|
|
22
|
-
|
|
27
|
+
// Vscode-specific handlers
|
|
28
|
+
new _vscodeDebuggerGetPossibleBreakpoints.VscodeDebuggerGetPossibleBreakpointsHandler(),
|
|
29
|
+
new _vscodeDebuggerScriptParsed.VscodeDebuggerScriptParsedHandler(this),
|
|
30
|
+
new _vscodeDebuggerSetBreakpointByUrl.VscodeDebuggerSetBreakpointByUrlHandler(),
|
|
31
|
+
new _vscodeRuntimeGetProperties.VscodeRuntimeGetPropertiesHandler(),
|
|
23
32
|
];
|
|
24
33
|
onDeviceMessage(message, info) {
|
|
25
34
|
var ref;
|
|
@@ -52,6 +61,16 @@ function createInspectorDeviceClass(metroBundler, MetroDeviceClass) {
|
|
|
52
61
|
newDevice.handleDebuggerConnection(oldDebugger.socket, oldDebugger.pageId);
|
|
53
62
|
}
|
|
54
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Handle a new debugger connection to this device.
|
|
66
|
+
* This adds the `debuggerType` property to the `DebuggerInfo` object.
|
|
67
|
+
* With that information, we can enable or disable debugger-specific handlers.
|
|
68
|
+
*/ handleDebuggerConnectionWithType(socket, pageId, debuggerType) {
|
|
69
|
+
this.handleDebuggerConnection(socket, pageId);
|
|
70
|
+
if (this._debuggerConnection) {
|
|
71
|
+
this._debuggerConnection.debuggerType = debuggerType;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
55
74
|
/** Hook into the message life cycle to answer more complex CDP messages */ async _processMessageFromDevice(message, info) {
|
|
56
75
|
if (!this.onDeviceMessage(message, info)) {
|
|
57
76
|
await super._processMessageFromDevice(message, info);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/metro/inspector-proxy/device.ts"],"sourcesContent":["import type { DebuggerInfo, Device as MetroDevice } from 'metro-inspector-proxy';\nimport fetch from 'node-fetch';\nimport type WS from 'ws';\n\nimport { MetroBundlerDevServer } from '../MetroBundlerDevServer';\nimport { DebuggerScriptSourceHandler } from './handlers/DebuggerScriptSource';\nimport { NetworkResponseHandler } from './handlers/NetworkResponse';\nimport { PageReloadHandler } from './handlers/PageReload';\nimport { VscodeCompatHandler } from './handlers/VscodeCompat';\nimport { DeviceRequest, InspectorHandler, DebuggerRequest } from './handlers/types';\n\nexport function createInspectorDeviceClass(\n metroBundler: MetroBundlerDevServer,\n MetroDeviceClass: typeof MetroDevice\n) {\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 new NetworkResponseHandler(),\n new DebuggerScriptSourceHandler(this),\n new PageReloadHandler(metroBundler),\n new VscodeCompatHandler(),\n ];\n\n onDeviceMessage(message: any, info: DebuggerInfo): boolean {\n return this.handlers.some((handler) => handler.onDeviceMessage?.(message, info) ?? false);\n }\n\n onDebuggerMessage(message: any, info: DebuggerInfo): boolean {\n return this.handlers.some((handler) => handler.onDebuggerMessage?.(message, info) ?? false);\n }\n\n /**\n * Handle a new device connection with the same device identifier.\n * When the app and device name matches, we can reuse the debugger connection.\n * Else, we have to shut the debugger connection down.\n */\n handleDuplicateDeviceConnection(newDevice: InstanceType<typeof MetroDeviceClass>) {\n if (this._app !== newDevice._app || this._name !== newDevice._name) {\n this._deviceSocket.close();\n this._debuggerConnection?.socket.close();\n return;\n }\n\n const oldDebugger = this._debuggerConnection;\n this._debuggerConnection = null;\n\n if (oldDebugger) {\n oldDebugger.socket.removeAllListeners();\n this._deviceSocket.close();\n newDevice.handleDebuggerConnection(oldDebugger.socket, oldDebugger.pageId);\n }\n }\n\n /** Hook into the message life cycle to answer more complex CDP messages */\n async _processMessageFromDevice(message: DeviceRequest<any>, info: DebuggerInfo) {\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: DebuggerRequest,\n info: DebuggerInfo,\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","DebuggerScriptSourceHandler","PageReloadHandler","VscodeCompatHandler","onDeviceMessage","message","info","handler","some","onDebuggerMessage","handleDuplicateDeviceConnection","newDevice","_app","_name","_deviceSocket","close","_debuggerConnection","socket","oldDebugger","removeAllListeners","handleDebuggerConnection","pageId","_processMessageFromDevice","_interceptMessageFromDebugger","request","_fetchText","url","LENGTH_LIMIT_BYTES","response","fetch","ok","Error","status","contentLength","headers","get","Number","text","Buffer","byteLength"],"mappings":"AAAA;;;;QAWgBA,0BAA0B,GAA1BA,0BAA0B;AAVxB,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAIc,IAAA,qBAAiC,WAAjC,iCAAiC,CAAA;AACtC,IAAA,gBAA4B,WAA5B,4BAA4B,CAAA;AACjC,IAAA,WAAuB,WAAvB,uBAAuB,CAAA;AACrB,IAAA,aAAyB,WAAzB,yBAAyB,CAAA;;;;;;AAGtD,SAASA,0BAA0B,CACxCC,YAAmC,EACnCC,gBAAoC,EACpC;IACA,OAAO,MAAMC,mBAAmB,SAASD,gBAAgB;QACvD,2EAA2E,CAC3E,AAAOE,QAAQ,GAAuB;YACpC,IAAIC,gBAAsB,uBAAA,EAAE;YAC5B,IAAIC,qBAA2B,4BAAA,CAAC,IAAI,CAAC;YACrC,IAAIC,WAAiB,kBAAA,CAACN,YAAY,CAAC;YACnC,IAAIO,aAAmB,oBAAA,EAAE;SAC1B,CAAC;QAEFC,eAAe,CAACC,OAAY,EAAEC,IAAkB,EAAW;gBAClBC,GAAwC;YAA/E,OAAO,IAAI,CAACR,QAAQ,CAACS,IAAI,CAAC,CAACD,OAAO;gBAAKA,OAAAA,CAAAA,GAAwC,GAAxCA,OAAO,CAACH,eAAe,QAAiB,GAAxCG,KAAAA,CAAwC,GAAxCA,OAAO,CAACH,eAAe,CAAGC,OAAO,EAAEC,IAAI,CAAC,YAAxCC,GAAwC,GAAI,KAAK,CAAA;aAAA,CAAC,CAAC;SAC3F;QAEDE,iBAAiB,CAACJ,OAAY,EAAE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QAED,2EAA2E,CAC3EiB,6BAA6B,CAC3BC,OAAwB,EACxBlB,IAAkB,EAClBW,MAAU,EACD;YACT,oDAAoD;YACpD,IAAI,IAAI,CAACR,iBAAiB,CAACe,OAAO,EAAElB,IAAI,CAAC,EAAE;gBACzC,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAACiB,6BAA6B,CAACC,OAAO,EAAElB,IAAI,EAAEW,MAAM,CAAC,CAAC;SACnE;QAED;;;;;OAKG,CACH,MAAMQ,UAAU,CAACC,GAAQ,EAAmB;YAC1C,MAAMC,kBAAkB,GAAG,SAAW,AAAC,EAAC,QAAQ;YAEhD,MAAMC,QAAQ,GAAG,MAAMC,CAAAA,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"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/metro/inspector-proxy/device.ts"],"sourcesContent":["import type { DebuggerInfo, Device as MetroDevice } from 'metro-inspector-proxy';\nimport fetch from 'node-fetch';\nimport type WS from 'ws';\n\nimport { MetroBundlerDevServer } from '../MetroBundlerDevServer';\nimport { DebuggerScriptSourceHandler } from './handlers/DebuggerScriptSource';\nimport { NetworkResponseHandler } from './handlers/NetworkResponse';\nimport { PageReloadHandler } from './handlers/PageReload';\nimport { VscodeDebuggerGetPossibleBreakpointsHandler } from './handlers/VscodeDebuggerGetPossibleBreakpoints';\nimport { VscodeDebuggerScriptParsedHandler } from './handlers/VscodeDebuggerScriptParsed';\nimport { VscodeDebuggerSetBreakpointByUrlHandler } from './handlers/VscodeDebuggerSetBreakpointByUrl';\nimport { VscodeRuntimeGetPropertiesHandler } from './handlers/VscodeRuntimeGetProperties';\nimport { DeviceRequest, InspectorHandler, DebuggerRequest } from './handlers/types';\n\n/** Export the supported debugger types this inspector proxy can handle */\nexport type DebuggerType = 'vscode' | 'generic';\n\n/** The debugger information being tracked by this device class */\nexport type ExpoDebuggerInfo = DebuggerInfo & { debuggerType?: DebuggerType };\n\nexport function createInspectorDeviceClass(\n metroBundler: MetroBundlerDevServer,\n MetroDeviceClass: typeof MetroDevice\n) {\n return class ExpoInspectorDevice extends MetroDeviceClass implements InspectorHandler {\n /** Stores information about currently connected debugger (if any). */\n _debuggerConnection: ExpoDebuggerInfo | null = null;\n\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 DebuggerScriptSourceHandler(this),\n new PageReloadHandler(metroBundler),\n // Vscode-specific handlers\n new VscodeDebuggerGetPossibleBreakpointsHandler(),\n new VscodeDebuggerScriptParsedHandler(this),\n new VscodeDebuggerSetBreakpointByUrlHandler(),\n new VscodeRuntimeGetPropertiesHandler(),\n ];\n\n onDeviceMessage(message: any, info: DebuggerInfo): boolean {\n return this.handlers.some((handler) => handler.onDeviceMessage?.(message, info) ?? false);\n }\n\n onDebuggerMessage(message: any, info: DebuggerInfo): boolean {\n return this.handlers.some((handler) => handler.onDebuggerMessage?.(message, info) ?? false);\n }\n\n /**\n * Handle a new device connection with the same device identifier.\n * When the app and device name matches, we can reuse the debugger connection.\n * Else, we have to shut the debugger connection down.\n */\n handleDuplicateDeviceConnection(newDevice: InstanceType<typeof MetroDeviceClass>) {\n if (this._app !== newDevice._app || this._name !== newDevice._name) {\n this._deviceSocket.close();\n this._debuggerConnection?.socket.close();\n return;\n }\n\n const oldDebugger = this._debuggerConnection;\n this._debuggerConnection = null;\n\n if (oldDebugger) {\n oldDebugger.socket.removeAllListeners();\n this._deviceSocket.close();\n newDevice.handleDebuggerConnection(oldDebugger.socket, oldDebugger.pageId);\n }\n }\n\n /**\n * Handle a new debugger connection to this device.\n * This adds the `debuggerType` property to the `DebuggerInfo` object.\n * With that information, we can enable or disable debugger-specific handlers.\n */\n handleDebuggerConnectionWithType(socket: WS, pageId: string, debuggerType: DebuggerType): void {\n this.handleDebuggerConnection(socket, pageId);\n\n if (this._debuggerConnection) {\n this._debuggerConnection.debuggerType = debuggerType;\n }\n }\n\n /** Hook into the message life cycle to answer more complex CDP messages */\n async _processMessageFromDevice(message: DeviceRequest<any>, info: DebuggerInfo) {\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: DebuggerRequest,\n info: DebuggerInfo,\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","_debuggerConnection","handlers","NetworkResponseHandler","DebuggerScriptSourceHandler","PageReloadHandler","VscodeDebuggerGetPossibleBreakpointsHandler","VscodeDebuggerScriptParsedHandler","VscodeDebuggerSetBreakpointByUrlHandler","VscodeRuntimeGetPropertiesHandler","onDeviceMessage","message","info","handler","some","onDebuggerMessage","handleDuplicateDeviceConnection","newDevice","_app","_name","_deviceSocket","close","socket","oldDebugger","removeAllListeners","handleDebuggerConnection","pageId","handleDebuggerConnectionWithType","debuggerType","_processMessageFromDevice","_interceptMessageFromDebugger","request","_fetchText","url","LENGTH_LIMIT_BYTES","response","fetch","ok","Error","status","contentLength","headers","get","Number","text","Buffer","byteLength"],"mappings":"AAAA;;;;QAoBgBA,0BAA0B,GAA1BA,0BAA0B;AAnBxB,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAIc,IAAA,qBAAiC,WAAjC,iCAAiC,CAAA;AACtC,IAAA,gBAA4B,WAA5B,4BAA4B,CAAA;AACjC,IAAA,WAAuB,WAAvB,uBAAuB,CAAA;AACG,IAAA,qCAAiD,WAAjD,iDAAiD,CAAA;AAC3D,IAAA,2BAAuC,WAAvC,uCAAuC,CAAA;AACjC,IAAA,iCAA6C,WAA7C,6CAA6C,CAAA;AACnD,IAAA,2BAAuC,WAAvC,uCAAuC,CAAA;;;;;;AASlF,SAASA,0BAA0B,CACxCC,YAAmC,EACnCC,gBAAoC,EAC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nB,IAAI,CAAC,EAAE;gBACzC,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAACkB,6BAA6B,CAACC,OAAO,EAAEnB,IAAI,EAAEU,MAAM,CAAC,CAAC;SACnE;QAED;;;;;OAKG,CACH,MAAMU,UAAU,CAACC,GAAQ,EAAmB;YAC1C,MAAMC,kBAAkB,GAAG,SAAW,AAAC,EAAC,QAAQ;YAEhD,MAAMC,QAAQ,GAAG,MAAMC,CAAAA,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/DebuggerScriptSource.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\nimport fs from 'fs';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/DebuggerScriptSource.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\nimport fs from 'fs';\nimport type { Device as MetroDevice } from 'metro-inspector-proxy';\nimport fetch from 'node-fetch';\nimport path from 'path';\nimport type WS from 'ws';\n\nimport { ExpoDebuggerInfo } from '../device';\nimport { CdpMessage, DebuggerRequest, DebuggerResponse, InspectorHandler } from './types';\n\n// TODO(cedric): remove this custom handler when fully switching over to `metro@>=0.75.1`\nexport class DebuggerScriptSourceHandler implements InspectorHandler {\n constructor(private readonly device: MetroDevice) {}\n\n onDebuggerMessage(\n message: DebuggerRequest<DebuggerGetScriptSource>,\n { socket }: ExpoDebuggerInfo\n ) {\n // See: https://github.com/facebook/metro/blob/65d801cb60c06c1b17f428ca79491db73c53ef87/packages/metro-inspector-proxy/src/Device.js#L488-L544\n if (message.method === 'Debugger.getScriptSource') {\n const { scriptId } = message.params;\n const pathOrUrl = this.device._scriptIdToSourcePathMapping.get(scriptId);\n\n // Unkown scriptId provided, can't reply\n if (!pathOrUrl) {\n return false;\n }\n\n // Fetch the source from URL, if the path is a bundle URL\n if (isUrl(pathOrUrl)) {\n fetch(pathOrUrl)\n .then((response) =>\n response.ok\n ? response.text()\n : respond(socket, message, {\n error: `Received status ${response.status} while fetching: ${pathOrUrl}`,\n })\n )\n .then((scriptSource) => {\n if (scriptSource !== null) {\n respond(socket, message, { scriptSource });\n }\n });\n\n return true;\n }\n\n // Fetch the source from file directly, using the project root as starting directory\n try {\n const relativePath = path.resolve(this.device._projectRoot, pathOrUrl);\n respond(socket, message, { scriptSource: fs.readFileSync(relativePath, 'utf8') });\n } catch (error: unknown) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n respond(socket, message, {\n error: `Failed to load \"${pathOrUrl}\": ${errorMessage}`,\n });\n }\n\n return true;\n }\n\n return false;\n }\n}\n\n/** @see https://chromedevtools.github.io/devtools-protocol/v8/Debugger/#method-getScriptSource */\nexport type DebuggerGetScriptSource = CdpMessage<\n 'Debugger.getScriptSource',\n Protocol.Debugger.GetScriptSourceRequest,\n Protocol.Debugger.GetScriptSourceResponse\n>;\n\nfunction respond<T extends CdpMessage>(\n socket: WS,\n request: DebuggerRequest<T>,\n response: DebuggerResponse<T>['result'] | { error: string }\n) {\n if ('error' in response) {\n socket.send(JSON.stringify({ id: request.id, error: { message: response.error } }));\n } else {\n socket.send(JSON.stringify({ id: request.id, result: response }));\n }\n\n return null;\n}\n\nfunction isUrl(pathOrUrl: string) {\n try {\n const url = new URL(pathOrUrl);\n return ['http', 'https'].some((protocol) => url.protocol.toLowerCase().startsWith(protocol));\n } catch {\n return false;\n }\n}\n"],"names":["DebuggerScriptSourceHandler","constructor","device","onDebuggerMessage","message","socket","method","scriptId","params","pathOrUrl","_scriptIdToSourcePathMapping","get","isUrl","fetch","then","response","ok","text","respond","error","status","scriptSource","relativePath","path","resolve","_projectRoot","fs","readFileSync","errorMessage","Error","String","request","send","JSON","stringify","id","result","url","URL","some","protocol","toLowerCase","startsWith"],"mappings":"AAAA;;;;AACe,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAED,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACb,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAOhB,MAAMA,2BAA2B;IACtCC,YAA6BC,MAAmB,CAAE;aAArBA,MAAmB,GAAnBA,MAAmB;KAAI;IAEpDC,iBAAiB,CACfC,OAAiD,EACjD,EAAEC,MAAM,CAAA,EAAoB,EAC5B;QACA,8IAA8I;QAC9I,IAAID,OAAO,CAACE,MAAM,KAAK,0BAA0B,EAAE;YACjD,MAAM,EAAEC,QAAQ,CAAA,EAAE,GAAGH,OAAO,CAACI,MAAM,AAAC;YACpC,MAAMC,SAAS,GAAG,IAAI,CAACP,MAAM,CAACQ,4BAA4B,CAACC,GAAG,CAACJ,QAAQ,CAAC,AAAC;YAEzE,wCAAwC;YACxC,IAAI,CAACE,SAAS,EAAE;gBACd,OAAO,KAAK,CAAC;aACd;YAED,yDAAyD;YACzD,IAAIG,KAAK,CAACH,SAAS,CAAC,EAAE;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db,MAAU,EACV0B,OAA2B,EAC3BhB,QAA2D,EAC3D;IACA,IAAI,OAAO,IAAIA,QAAQ,EAAE;QACvBV,MAAM,CAAC2B,IAAI,CAACC,IAAI,CAACC,SAAS,CAAC;YAAEC,EAAE,EAAEJ,OAAO,CAACI,EAAE;YAAEhB,KAAK,EAAE;gBAAEf,OAAO,EAAEW,QAAQ,CAACI,KAAK;aAAE;SAAE,CAAC,CAAC,CAAC;KACrF,MAAM;QACLd,MAAM,CAAC2B,IAAI,CAACC,IAAI,CAACC,SAAS,CAAC;YAAEC,EAAE,EAAEJ,OAAO,CAACI,EAAE;YAAEC,MAAM,EAAErB,QAAQ;SAAE,CAAC,CAAC,CAAC;KACnE;IAED,OAAO,IAAI,CAAC;CACb;AAED,SAASH,KAAK,CAACH,SAAiB,EAAE;IAChC,IAAI;QACF,MAAM4B,GAAG,GAAG,IAAIC,GAAG,CAAC7B,SAAS,CAAC,AAAC;QAC/B,OAAO;YAAC,MAAM;YAAE,OAAO;SAAC,CAAC8B,IAAI,CAAC,CAACC,QAAQ,GAAKH,GAAG,CAACG,QAAQ,CAACC,WAAW,EAAE,CAACC,UAAU,CAACF,QAAQ,CAAC;QAAA,CAAC,CAAC;KAC9F,CAAC,OAAM;QACN,OAAO,KAAK,CAAC;KACd;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/NetworkResponse.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/NetworkResponse.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport { ExpoDebuggerInfo } from '../device';\nimport {\n CdpMessage,\n InspectorHandler,\n DeviceRequest,\n DebuggerRequest,\n DebuggerResponse,\n DeviceResponse,\n} from './types';\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 }: ExpoDebuggerInfo\n ) {\n if (\n message.method === 'Network.getResponseBody' &&\n this.storage.has(message.params.requestId)\n ) {\n const response: DeviceResponse<NetworkGetResponseBody> = {\n id: message.id,\n result: this.storage.get(message.params.requestId)!,\n };\n\n socket.send(JSON.stringify(response));\n return true;\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","response","id","result","get","send","JSON","stringify"],"mappings":"AAAA;;;;AAYO,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,MAAMO,QAAQ,GAA2C;gBACvDC,EAAE,EAAEV,OAAO,CAACU,EAAE;gBACdC,MAAM,EAAE,IAAI,CAACd,OAAO,CAACe,GAAG,CAACZ,OAAO,CAACI,MAAM,CAACF,SAAS,CAAC;aACnD,AAAC;YAEFK,MAAM,CAACM,IAAI,CAACC,IAAI,CAACC,SAAS,CAACN,QAAQ,CAAC,CAAC,CAAC;YACtC,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;KACd;CACF;QAjCYb,sBAAsB,GAAtBA,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/PageReload.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/PageReload.ts"],"sourcesContent":["import type { Protocol } from 'devtools-protocol';\n\nimport { MetroBundlerDevServer } from '../../MetroBundlerDevServer';\nimport { ExpoDebuggerInfo } from '../device';\nimport { CdpMessage, DebuggerRequest, InspectorHandler } from './types';\n\nexport class PageReloadHandler implements InspectorHandler {\n constructor(private readonly metroBundler: MetroBundlerDevServer) {}\n\n onDebuggerMessage(message: DebuggerRequest<PageReload>, { socket }: ExpoDebuggerInfo) {\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;;;;AAMO,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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
class VscodeDebuggerGetPossibleBreakpointsHandler {
|
|
6
|
+
onDebuggerMessage(message, { socket , debuggerType }) {
|
|
7
|
+
if (debuggerType === "vscode" && message.method === "Debugger.getPossibleBreakpoints") {
|
|
8
|
+
const response = {
|
|
9
|
+
id: message.id,
|
|
10
|
+
result: {
|
|
11
|
+
locations: []
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
socket.send(JSON.stringify(response));
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.VscodeDebuggerGetPossibleBreakpointsHandler = VscodeDebuggerGetPossibleBreakpointsHandler;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=VscodeDebuggerGetPossibleBreakpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.ts"],"sourcesContent":["import Protocol from 'devtools-protocol';\n\nimport { ExpoDebuggerInfo } from '../device';\nimport { CdpMessage, DebuggerRequest, DeviceResponse, InspectorHandler } from './types';\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, debuggerType }: ExpoDebuggerInfo\n ): boolean {\n if (debuggerType === 'vscode' && message.method === 'Debugger.getPossibleBreakpoints') {\n const response: DeviceResponse<DebuggerGetPossibleBreakpoints> = {\n id: message.id,\n result: { locations: [] },\n };\n socket.send(JSON.stringify(response));\n return true;\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","debuggerType","method","response","id","result","locations","send","JSON","stringify"],"mappings":"AAAA;;;;AASO,MAAMA,2CAA2C;IACtDC,iBAAiB,CACfC,OAAwD,EACxD,EAAEC,MAAM,CAAA,EAAEC,YAAY,CAAA,EAAoB,EACjC;QACT,IAAIA,YAAY,KAAK,QAAQ,IAAIF,OAAO,CAACG,MAAM,KAAK,iCAAiC,EAAE;YACrF,MAAMC,QAAQ,GAAmD;gBAC/DC,EAAE,EAAEL,OAAO,CAACK,EAAE;gBACdC,MAAM,EAAE;oBAAEC,SAAS,EAAE,EAAE;iBAAE;aAC1B,AAAC;YACFN,MAAM,CAACO,IAAI,CAACC,IAAI,CAACC,SAAS,CAACN,QAAQ,CAAC,CAAC,CAAC;YACtC,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;KACd;CACF;QAhBYN,2CAA2C,GAA3CA,2CAA2C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
/** Android's stock emulator and other emulators such as genymotion use a standard localhost alias. */ const EMULATOR_LOCALHOST_ADDRESSES = [
|
|
6
|
+
"10.0.2.2",
|
|
7
|
+
"10.0.3.2"
|
|
8
|
+
];
|
|
9
|
+
/** Prefix for script URLs that are alphanumeric IDs. */ const FILE_PREFIX = "file://";
|
|
10
|
+
class VscodeDebuggerScriptParsedHandler {
|
|
11
|
+
constructor(device){
|
|
12
|
+
this.device = device;
|
|
13
|
+
}
|
|
14
|
+
onDeviceMessage(message, debuggerInfo) {
|
|
15
|
+
if (debuggerInfo.debuggerType !== "vscode" || message.method !== "Debugger.scriptParsed") {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
// See: https://github.com/facebook/metro/blob/f43caa371a813b257cb0b42028079645a1e85e0e/packages/metro-inspector-proxy/src/Device.js#L401-L410
|
|
19
|
+
if (message.params.sourceMapURL) {
|
|
20
|
+
for(let i = 0; i < EMULATOR_LOCALHOST_ADDRESSES.length; ++i){
|
|
21
|
+
const address = EMULATOR_LOCALHOST_ADDRESSES[i];
|
|
22
|
+
if (message.params.sourceMapURL.indexOf(address) >= 0) {
|
|
23
|
+
message.params.sourceMapURL = message.params.sourceMapURL.replace(address, "localhost");
|
|
24
|
+
debuggerInfo.originalSourceURLAddress = address;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// See: https://github.com/facebook/metro/blob/f43caa371a813b257cb0b42028079645a1e85e0e/packages/metro-inspector-proxy/src/Device.js#L431-L453
|
|
29
|
+
if (message.params.url) {
|
|
30
|
+
for(let i = 0; i < EMULATOR_LOCALHOST_ADDRESSES.length; ++i){
|
|
31
|
+
const address = EMULATOR_LOCALHOST_ADDRESSES[i];
|
|
32
|
+
if (message.params.url.indexOf(address) >= 0) {
|
|
33
|
+
message.params.url = message.params.url.replace(address, "localhost");
|
|
34
|
+
debuggerInfo.originalSourceURLAddress = address;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Chrome doesn't download source maps if URL param is not a valid
|
|
38
|
+
// URL. Some frameworks pass alphanumeric script ID instead of URL which causes
|
|
39
|
+
// Chrome to not download source maps. In this case we want to prepend script ID
|
|
40
|
+
// with 'file://' prefix.
|
|
41
|
+
if (message.params.url.match(/^[0-9a-z]+$/)) {
|
|
42
|
+
message.params.url = FILE_PREFIX + message.params.url;
|
|
43
|
+
debuggerInfo.prependedFilePrefix = true;
|
|
44
|
+
}
|
|
45
|
+
if (message.params.scriptId != null) {
|
|
46
|
+
this.device._scriptIdToSourcePathMapping.set(message.params.scriptId, message.params.url);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Block `metro-inspector-proxy`'s default source map inlining
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.VscodeDebuggerScriptParsedHandler = VscodeDebuggerScriptParsedHandler;
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=VscodeDebuggerScriptParsed.js.map
|
package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.ts"],"sourcesContent":["import Protocol from 'devtools-protocol';\nimport { Device as MetroDevice } from 'metro-inspector-proxy';\n\nimport { ExpoDebuggerInfo } from '../device';\nimport { CdpMessage, DeviceRequest, InspectorHandler } from './types';\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 `metro-inspector-proxy` 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: ExpoDebuggerInfo) {\n if (debuggerInfo.debuggerType !== 'vscode' || message.method !== 'Debugger.scriptParsed') {\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 `metro-inspector-proxy`'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","debuggerType","method","params","sourceMapURL","i","length","address","indexOf","replace","originalSourceURLAddress","url","match","prependedFilePrefix","scriptId","_scriptIdToSourcePathMapping","set"],"mappings":"AAAA;;;;AAMA,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,IAAIA,YAAY,CAACC,YAAY,KAAK,QAAQ,IAAIF,OAAO,CAACG,MAAM,KAAK,uBAAuB,EAAE;YACxF,OAAO,KAAK,CAAC;SACd;QAED,8IAA8I;QAC9I,IAAIH,OAAO,CAACI,MAAM,CAACC,YAAY,EAAE;YAC/B,IAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGZ,4BAA4B,CAACa,MAAM,EAAE,EAAED,CAAC,CAAE;gBAC5D,MAAME,OAAO,GAAGd,4BAA4B,CAACY,CAAC,CAAC,AAAC;gBAChD,IAAIN,OAAO,CAACI,MAAM,CAACC,YAAY,CAACI,OAAO,CAACD,OAAO,CAAC,IAAI,CAAC,EAAE;oBACrDR,OAAO,CAACI,MAAM,CAACC,YAAY,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iCAAiC"}
|
package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
class VscodeDebuggerSetBreakpointByUrlHandler {
|
|
6
|
+
onDebuggerMessage(message, { debuggerType }) {
|
|
7
|
+
if (debuggerType === "vscode" && message.method === "Debugger.setBreakpointByUrl" && message.params.urlRegex) {
|
|
8
|
+
// Explicitly force the breakpoint to be unbounded
|
|
9
|
+
message.params.url = "file://__invalid_url__";
|
|
10
|
+
delete message.params.urlRegex;
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.VscodeDebuggerSetBreakpointByUrlHandler = VscodeDebuggerSetBreakpointByUrlHandler;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=VscodeDebuggerSetBreakpointByUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.ts"],"sourcesContent":["import Protocol from 'devtools-protocol';\n\nimport { ExpoDebuggerInfo } from '../device';\nimport { CdpMessage, DebuggerRequest, InspectorHandler } from './types';\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 { debuggerType }: ExpoDebuggerInfo\n ): boolean {\n if (\n debuggerType === '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","debuggerType","method","params","urlRegex","url"],"mappings":"AAAA;;;;AAWO,MAAMA,uCAAuC;IAClDC,iBAAiB,CACfC,OAAoD,EACpD,EAAEC,YAAY,CAAA,EAAoB,EACzB;QACT,IACEA,YAAY,KAAK,QAAQ,IACzBD,OAAO,CAACE,MAAM,KAAK,6BAA6B,IAChDF,OAAO,CAACG,MAAM,CAACC,QAAQ,EACvB;YACA,kDAAkD;YAClDJ,OAAO,CAACG,MAAM,CAACE,GAAG,GAAG,wBAAwB,CAAC;YAC9C,OAAOL,OAAO,CAACG,MAAM,CAACC,QAAQ,CAAC;SAChC;QAED,OAAO,KAAK,CAAC;KACd;CACF;QAjBYN,uCAAuC,GAAvCA,uCAAuC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
class VscodeRuntimeGetPropertiesHandler {
|
|
6
|
+
/** 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") {
|
|
9
|
+
this.interceptGetProperties.add(message.id);
|
|
10
|
+
}
|
|
11
|
+
// Do not block propagation of this message
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
onDeviceMessage(message, { debuggerType }) {
|
|
15
|
+
if (debuggerType === "vscode" && "id" in message && this.interceptGetProperties.has(message.id)) {
|
|
16
|
+
this.interceptGetProperties.delete(message.id);
|
|
17
|
+
var _result;
|
|
18
|
+
for (const item of (_result = message.result.result) != null ? _result : []){
|
|
19
|
+
var ref;
|
|
20
|
+
// Force-fully format the properties description to be an empty string
|
|
21
|
+
if (item.value) {
|
|
22
|
+
var _description;
|
|
23
|
+
item.value.description = (_description = item.value.description) != null ? _description : "";
|
|
24
|
+
}
|
|
25
|
+
// Avoid passing the `objectId` for symbol types.
|
|
26
|
+
// When collapsing in vscode, it will fetch information about the symbol using the `objectId`.
|
|
27
|
+
// The `Runtime.getProperties` request of the symbol hard-crashes Hermes.
|
|
28
|
+
if (((ref = item.value) == null ? void 0 : ref.type) === "symbol" && item.value.objectId) {
|
|
29
|
+
delete item.value.objectId;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Do not block propagation of this message
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.VscodeRuntimeGetPropertiesHandler = VscodeRuntimeGetPropertiesHandler;
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=VscodeRuntimeGetProperties.js.map
|
package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.ts"],"sourcesContent":["import Protocol from 'devtools-protocol';\n\nimport { ExpoDebuggerInfo } from '../device';\nimport { CdpMessage, DebuggerRequest, DeviceResponse, InspectorHandler } from './types';\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 { debuggerType }: ExpoDebuggerInfo\n ): boolean {\n if (debuggerType === '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(\n message: DeviceResponse<RuntimeGetProperties>,\n { debuggerType }: ExpoDebuggerInfo\n ) {\n if (\n debuggerType === '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","debuggerType","method","add","id","onDeviceMessage","has","delete","item","result","value","description","type","objectId"],"mappings":"AAAA;;;;AAaO,MAAMA,iCAAiC;IAC5C,kFAAkF,CAClFC,sBAAsB,GAAG,IAAIC,GAAG,EAAU,CAAC;IAE3CC,iBAAiB,CACfC,OAA8C,EAC9C,EAAEC,YAAY,CAAA,EAAoB,EACzB;QACT,IAAIA,YAAY,KAA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":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/types.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/start/server/metro/inspector-proxy/handlers/types.ts"],"sourcesContent":["import { ExpoDebuggerInfo } from '../device';\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: ExpoDebuggerInfo): 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: ExpoDebuggerInfo): 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"}
|
|
@@ -62,7 +62,7 @@ class ExpoInspectorProxy {
|
|
|
62
62
|
wss.on("connection", (socket, request)=>{
|
|
63
63
|
try {
|
|
64
64
|
const fallbackDeviceId = String(this.metroProxy._deviceCounter++);
|
|
65
|
-
const { deviceId: newDeviceId , deviceName , appName } =
|
|
65
|
+
const { deviceId: newDeviceId , deviceName , appName } = getDeviceInfo(request.url);
|
|
66
66
|
const deviceId = newDeviceId != null ? newDeviceId : fallbackDeviceId;
|
|
67
67
|
const oldDevice = this.devices.get(deviceId);
|
|
68
68
|
const newDevice = new this.DeviceClass(deviceId, deviceName, appName, socket, this.metroProxy._projectRoot);
|
|
@@ -104,7 +104,7 @@ class ExpoInspectorProxy {
|
|
|
104
104
|
// See: https://github.com/facebook/metro/blob/eeb211fdcfdcb9e7f8a51721bd0f48bc7d0d211f/packages/metro-inspector-proxy/src/InspectorProxy.js#L193
|
|
105
105
|
wss.on("connection", (socket, request)=>{
|
|
106
106
|
try {
|
|
107
|
-
const { deviceId , pageId } =
|
|
107
|
+
const { deviceId , pageId , debuggerType } = getDebuggerInfo(request.url);
|
|
108
108
|
if (!deviceId || !pageId) {
|
|
109
109
|
// TODO(cedric): change these errors to proper error types
|
|
110
110
|
throw new Error(`Missing "device" and/or "page" IDs in query parameters`);
|
|
@@ -115,7 +115,13 @@ class ExpoInspectorProxy {
|
|
|
115
115
|
throw new Error(`Device with ID "${deviceId}" not found.`);
|
|
116
116
|
}
|
|
117
117
|
debug("New debugger connected: device=%s, app=%s", device._name, device._app);
|
|
118
|
-
device
|
|
118
|
+
// @ts-expect-error The `handleDebuggerConnectionWithType` is part of our device implementation, not Metro's device
|
|
119
|
+
if (debuggerType && typeof device.handleDebuggerConnectionWithType === "function") {
|
|
120
|
+
// @ts-expect-error The `handleDebuggerConnectionWithType` is part of our device implementation, not Metro's device
|
|
121
|
+
device.handleDebuggerConnectionWithType(socket, pageId, debuggerType);
|
|
122
|
+
} else {
|
|
123
|
+
device.handleDebuggerConnection(socket, pageId);
|
|
124
|
+
}
|
|
119
125
|
socket.on("close", ()=>{
|
|
120
126
|
debug("Debugger disconnected: device=%s, app=%s", device._name, device._app);
|
|
121
127
|
});
|
|
@@ -139,7 +145,7 @@ exports.ExpoInspectorProxy = ExpoInspectorProxy;
|
|
|
139
145
|
function asString(value = "") {
|
|
140
146
|
return Array.isArray(value) ? value.join() : value;
|
|
141
147
|
}
|
|
142
|
-
function
|
|
148
|
+
function getDeviceInfo(url) {
|
|
143
149
|
const { query } = (0, _url).parse(url != null ? url : "", true);
|
|
144
150
|
return {
|
|
145
151
|
deviceId: asString(query.device) || undefined,
|
|
@@ -147,11 +153,13 @@ function getNewDeviceInfo(url) {
|
|
|
147
153
|
appName: asString(query.app) || "Unknown app name"
|
|
148
154
|
};
|
|
149
155
|
}
|
|
150
|
-
function
|
|
156
|
+
function getDebuggerInfo(url) {
|
|
151
157
|
const { query } = (0, _url).parse(url != null ? url : "", true);
|
|
158
|
+
var ref;
|
|
152
159
|
return {
|
|
153
160
|
deviceId: asString(query.device),
|
|
154
|
-
pageId: asString(query.page)
|
|
161
|
+
pageId: asString(query.page),
|
|
162
|
+
debuggerType: (ref = asString(query.type)) != null ? ref : undefined
|
|
155
163
|
};
|
|
156
164
|
}
|
|
157
165
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/metro/inspector-proxy/proxy.ts"],"sourcesContent":["import type { Server as HttpServer, IncomingMessage, ServerResponse } from 'http';\nimport type { Server as HttpsServer } from 'https';\nimport type { InspectorProxy as MetroProxy, Device as MetroDevice } from 'metro-inspector-proxy';\nimport { parse } from 'url';\nimport WS, { Server as WSServer } from 'ws';\n\nimport { Log } from '../../../../log';\n\nconst WS_DEVICE_URL = '/inspector/device';\nconst WS_DEBUGGER_URL = '/inspector/debug';\nconst WS_GENERIC_ERROR_STATUS = 1011;\n\nconst debug = require('debug')('expo:metro:inspector-proxy:proxy') as typeof console.log;\n\n// This is a workaround for `ConstructorType` not working on dynamically generated classes\ntype Instantiatable<Instance> = new (...args: any) => Instance;\n\nexport class ExpoInspectorProxy<D extends MetroDevice = MetroDevice> {\n constructor(\n public readonly metroProxy: MetroProxy,\n private DeviceClass: Instantiatable<D>,\n public readonly devices: Map<string, D> = new Map()\n ) {\n // monkey-patch the device list to expose it within the metro inspector\n // See https://github.com/facebook/metro/pull/991\n // @ts-expect-error - Device ID is changing from `number` to `string`\n this.metroProxy._devices = this.devices;\n\n // force httpEndpointMiddleware to be bound to this proxy instance\n this.processRequest = this.processRequest.bind(this);\n }\n\n /**\n * Initialize the server address from the metro server.\n * This is required to properly reference sourcemaps for the debugger.\n */\n private setServerAddress(server: HttpServer | HttpsServer) {\n const addressInfo = server.address();\n\n if (typeof addressInfo === 'string') {\n throw new Error(`Inspector proxy could not resolve the server address, got \"${addressInfo}\"`);\n } else if (addressInfo === null) {\n throw new Error(`Inspector proxy could not resolve the server address, got \"null\"`);\n }\n\n const { address, port, family } = addressInfo;\n\n if (family === 'IPv6') {\n this.metroProxy._serverAddressWithPort = `[${address ?? '::1'}]:${port}`;\n } else {\n this.metroProxy._serverAddressWithPort = `${address ?? 'localhost'}:${port}`;\n }\n }\n\n /** @see https://chromedevtools.github.io/devtools-protocol/#endpoints */\n public processRequest(req: IncomingMessage, res: ServerResponse, next: (error?: Error) => any) {\n this.metroProxy.processRequest(req, res, next);\n }\n\n public createWebSocketListeners(server: HttpServer | HttpsServer): Record<string, WSServer> {\n this.setServerAddress(server);\n\n return {\n [WS_DEVICE_URL]: this.createDeviceWebSocketServer(),\n [WS_DEBUGGER_URL]: this.createDebuggerWebSocketServer(),\n };\n }\n\n private createDeviceWebSocketServer() {\n const wss = new WS.Server({\n noServer: true,\n perMessageDeflate: false,\n });\n\n // See: https://github.com/facebook/metro/blob/eeb211fdcfdcb9e7f8a51721bd0f48bc7d0d211f/packages/metro-inspector-proxy/src/InspectorProxy.js#L157\n wss.on('connection', (socket, request) => {\n try {\n const fallbackDeviceId = String(this.metroProxy._deviceCounter++);\n const { deviceId: newDeviceId, deviceName, appName } = getNewDeviceInfo(request.url);\n\n const deviceId = newDeviceId ?? fallbackDeviceId;\n\n const oldDevice = this.devices.get(deviceId);\n const newDevice = new this.DeviceClass(\n deviceId,\n deviceName,\n appName,\n socket,\n this.metroProxy._projectRoot\n );\n\n if (oldDevice) {\n debug('Device reconnected: device=%s, app=%s, id=%s', deviceName, appName, deviceId);\n // See: https://github.com/facebook/metro/pull/991\n // @ts-expect-error - Newly introduced method coming to metro-inspector-proxy soon\n oldDevice.handleDuplicateDeviceConnection(newDevice);\n } else {\n debug('New device connected: device=%s, app=%s, id=%s', deviceName, appName, deviceId);\n }\n\n this.devices.set(deviceId, newDevice);\n\n socket.on('close', () => {\n if (this.devices.get(deviceId) === newDevice) {\n this.devices.delete(deviceId);\n debug('Device disconnected: device=%s, app=%s, id=%s', deviceName, appName, deviceId);\n }\n });\n } catch (error: unknown) {\n let message = '';\n\n debug('Could not establish a connection to on-device debugger:', error);\n\n if (error instanceof Error) {\n message = error.toString();\n Log.error('Failed to create a socket connection to on-device debugger (Hermes engine).');\n Log.exception(error);\n } else {\n Log.error(\n 'Failed to create a socket connection to on-device debugger (Hermes engine), unknown error.'\n );\n }\n\n socket.close(WS_GENERIC_ERROR_STATUS, message || 'Unknown error');\n }\n });\n\n return wss;\n }\n\n private createDebuggerWebSocketServer() {\n const wss = new WS.Server({\n noServer: true,\n perMessageDeflate: false,\n });\n\n // See: https://github.com/facebook/metro/blob/eeb211fdcfdcb9e7f8a51721bd0f48bc7d0d211f/packages/metro-inspector-proxy/src/InspectorProxy.js#L193\n wss.on('connection', (socket, request) => {\n try {\n const { deviceId, pageId } = getExistingDeviceInfo(request.url);\n if (!deviceId || !pageId) {\n // TODO(cedric): change these errors to proper error types\n throw new Error(`Missing \"device\" and/or \"page\" IDs in query parameters`);\n }\n\n const device = this.devices.get(deviceId);\n if (!device) {\n // TODO(cedric): change these errors to proper error types\n throw new Error(`Device with ID \"${deviceId}\" not found.`);\n }\n\n debug('New debugger connected: device=%s, app=%s', device._name, device._app);\n\n device.handleDebuggerConnection(socket, pageId);\n\n socket.on('close', () => {\n debug('Debugger disconnected: device=%s, app=%s', device._name, device._app);\n });\n } catch (error: unknown) {\n let message = '';\n\n debug('Could not establish a connection to debugger:', error);\n\n if (error instanceof Error) {\n message = error.toString();\n Log.error('Failed to create a socket connection to the debugger.');\n Log.exception(error);\n } else {\n Log.error('Failed to create a socket connection to the debugger, unkown error.');\n }\n\n socket.close(WS_GENERIC_ERROR_STATUS, message || 'Unknown error');\n }\n });\n\n return wss;\n }\n}\n\nfunction asString(value: string | string[] = ''): string {\n return Array.isArray(value) ? value.join() : value;\n}\n\nfunction getNewDeviceInfo(url: IncomingMessage['url']) {\n const { query } = parse(url ?? '', true);\n return {\n deviceId: asString(query.device) || undefined,\n deviceName: asString(query.name) || 'Unknown device name',\n appName: asString(query.app) || 'Unknown app name',\n };\n}\n\nfunction getExistingDeviceInfo(url: IncomingMessage['url']) {\n const { query } = parse(url ?? '', true);\n return {\n deviceId: asString(query.device),\n pageId: asString(query.page),\n };\n}\n"],"names":["WS_DEVICE_URL","WS_DEBUGGER_URL","WS_GENERIC_ERROR_STATUS","debug","require","ExpoInspectorProxy","constructor","metroProxy","DeviceClass","devices","Map","_devices","processRequest","bind","setServerAddress","server","addressInfo","address","Error","port","family","_serverAddressWithPort","req","res","next","createWebSocketListeners","createDeviceWebSocketServer","createDebuggerWebSocketServer","wss","WS","Server","noServer","perMessageDeflate","on","socket","request","fallbackDeviceId","String","_deviceCounter","deviceId","newDeviceId","deviceName","appName","getNewDeviceInfo","url","oldDevice","get","newDevice","_projectRoot","handleDuplicateDeviceConnection","set","delete","error","message","toString","Log","exception","close","pageId","getExistingDeviceInfo","device","_name","_app","handleDebuggerConnection","asString","value","Array","isArray","join","query","parse","undefined","name","app","page"],"mappings":"AAAA;;;;AAGsB,IAAA,IAAK,WAAL,KAAK,CAAA;AACY,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEvB,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;;;;;;AAErC,MAAMA,aAAa,GAAG,mBAAmB,AAAC;AAC1C,MAAMC,eAAe,GAAG,kBAAkB,AAAC;AAC3C,MAAMC,uBAAuB,GAAG,IAAI,AAAC;AAErC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,kCAAkC,CAAC,AAAsB,AAAC;AAKlF,MAAMC,kBAAkB;IAC7BC,YACkBC,UAAsB,EAC9BC,WAA8B,EACtBC,O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QAChCF,MAAM,EAAEM,QAAQ,CAACK,KAAK,CAACK,IAAI,CAAC;KAC7B,CAAC;CACH"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/metro/inspector-proxy/proxy.ts"],"sourcesContent":["import type { Server as HttpServer, IncomingMessage, ServerResponse } from 'http';\nimport type { Server as HttpsServer } from 'https';\nimport type { InspectorProxy as MetroProxy, Device as MetroDevice } from 'metro-inspector-proxy';\nimport { parse } from 'url';\nimport WS, { Server as WSServer } from 'ws';\n\nimport { Log } from '../../../../log';\n\nconst WS_DEVICE_URL = '/inspector/device';\nconst WS_DEBUGGER_URL = '/inspector/debug';\nconst WS_GENERIC_ERROR_STATUS = 1011;\n\nconst debug = require('debug')('expo:metro:inspector-proxy:proxy') as typeof console.log;\n\n// This is a workaround for `ConstructorType` not working on dynamically generated classes\ntype Instantiatable<Instance> = new (...args: any) => Instance;\n\nexport class ExpoInspectorProxy<D extends MetroDevice = MetroDevice> {\n constructor(\n public readonly metroProxy: MetroProxy,\n private DeviceClass: Instantiatable<D>,\n public readonly devices: Map<string, D> = new Map()\n ) {\n // monkey-patch the device list to expose it within the metro inspector\n // See https://github.com/facebook/metro/pull/991\n // @ts-expect-error - Device ID is changing from `number` to `string`\n this.metroProxy._devices = this.devices;\n\n // force httpEndpointMiddleware to be bound to this proxy instance\n this.processRequest = this.processRequest.bind(this);\n }\n\n /**\n * Initialize the server address from the metro server.\n * This is required to properly reference sourcemaps for the debugger.\n */\n private setServerAddress(server: HttpServer | HttpsServer) {\n const addressInfo = server.address();\n\n if (typeof addressInfo === 'string') {\n throw new Error(`Inspector proxy could not resolve the server address, got \"${addressInfo}\"`);\n } else if (addressInfo === null) {\n throw new Error(`Inspector proxy could not resolve the server address, got \"null\"`);\n }\n\n const { address, port, family } = addressInfo;\n\n if (family === 'IPv6') {\n this.metroProxy._serverAddressWithPort = `[${address ?? '::1'}]:${port}`;\n } else {\n this.metroProxy._serverAddressWithPort = `${address ?? 'localhost'}:${port}`;\n }\n }\n\n /** @see https://chromedevtools.github.io/devtools-protocol/#endpoints */\n public processRequest(req: IncomingMessage, res: ServerResponse, next: (error?: Error) => any) {\n this.metroProxy.processRequest(req, res, next);\n }\n\n public createWebSocketListeners(server: HttpServer | HttpsServer): Record<string, WSServer> {\n this.setServerAddress(server);\n\n return {\n [WS_DEVICE_URL]: this.createDeviceWebSocketServer(),\n [WS_DEBUGGER_URL]: this.createDebuggerWebSocketServer(),\n };\n }\n\n private createDeviceWebSocketServer() {\n const wss = new WS.Server({\n noServer: true,\n perMessageDeflate: false,\n });\n\n // See: https://github.com/facebook/metro/blob/eeb211fdcfdcb9e7f8a51721bd0f48bc7d0d211f/packages/metro-inspector-proxy/src/InspectorProxy.js#L157\n wss.on('connection', (socket, request) => {\n try {\n const fallbackDeviceId = String(this.metroProxy._deviceCounter++);\n const { deviceId: newDeviceId, deviceName, appName } = getDeviceInfo(request.url);\n\n const deviceId = newDeviceId ?? fallbackDeviceId;\n\n const oldDevice = this.devices.get(deviceId);\n const newDevice = new this.DeviceClass(\n deviceId,\n deviceName,\n appName,\n socket,\n this.metroProxy._projectRoot\n );\n\n if (oldDevice) {\n debug('Device reconnected: device=%s, app=%s, id=%s', deviceName, appName, deviceId);\n // See: https://github.com/facebook/metro/pull/991\n // @ts-expect-error - Newly introduced method coming to metro-inspector-proxy soon\n oldDevice.handleDuplicateDeviceConnection(newDevice);\n } else {\n debug('New device connected: device=%s, app=%s, id=%s', deviceName, appName, deviceId);\n }\n\n this.devices.set(deviceId, newDevice);\n\n socket.on('close', () => {\n if (this.devices.get(deviceId) === newDevice) {\n this.devices.delete(deviceId);\n debug('Device disconnected: device=%s, app=%s, id=%s', deviceName, appName, deviceId);\n }\n });\n } catch (error: unknown) {\n let message = '';\n\n debug('Could not establish a connection to on-device debugger:', error);\n\n if (error instanceof Error) {\n message = error.toString();\n Log.error('Failed to create a socket connection to on-device debugger (Hermes engine).');\n Log.exception(error);\n } else {\n Log.error(\n 'Failed to create a socket connection to on-device debugger (Hermes engine), unknown error.'\n );\n }\n\n socket.close(WS_GENERIC_ERROR_STATUS, message || 'Unknown error');\n }\n });\n\n return wss;\n }\n\n private createDebuggerWebSocketServer() {\n const wss = new WS.Server({\n noServer: true,\n perMessageDeflate: false,\n });\n\n // See: https://github.com/facebook/metro/blob/eeb211fdcfdcb9e7f8a51721bd0f48bc7d0d211f/packages/metro-inspector-proxy/src/InspectorProxy.js#L193\n wss.on('connection', (socket, request) => {\n try {\n const { deviceId, pageId, debuggerType } = getDebuggerInfo(request.url);\n if (!deviceId || !pageId) {\n // TODO(cedric): change these errors to proper error types\n throw new Error(`Missing \"device\" and/or \"page\" IDs in query parameters`);\n }\n\n const device = this.devices.get(deviceId);\n if (!device) {\n // TODO(cedric): change these errors to proper error types\n throw new Error(`Device with ID \"${deviceId}\" not found.`);\n }\n\n debug('New debugger connected: device=%s, app=%s', device._name, device._app);\n\n // @ts-expect-error The `handleDebuggerConnectionWithType` is part of our device implementation, not Metro's device\n if (debuggerType && typeof device.handleDebuggerConnectionWithType === 'function') {\n // @ts-expect-error The `handleDebuggerConnectionWithType` is part of our device implementation, not Metro's device\n device.handleDebuggerConnectionWithType(socket, pageId, debuggerType);\n } else {\n device.handleDebuggerConnection(socket, pageId);\n }\n\n socket.on('close', () => {\n debug('Debugger disconnected: device=%s, app=%s', device._name, device._app);\n });\n } catch (error: unknown) {\n let message = '';\n\n debug('Could not establish a connection to debugger:', error);\n\n if (error instanceof Error) {\n message = error.toString();\n Log.error('Failed to create a socket connection to the debugger.');\n Log.exception(error);\n } else {\n Log.error('Failed to create a socket connection to the debugger, unkown error.');\n }\n\n socket.close(WS_GENERIC_ERROR_STATUS, message || 'Unknown error');\n }\n });\n\n return wss;\n }\n}\n\nfunction asString(value: string | string[] = ''): string {\n return Array.isArray(value) ? value.join() : value;\n}\n\nfunction getDeviceInfo(url: IncomingMessage['url']) {\n const { query } = parse(url ?? '', true);\n return {\n deviceId: asString(query.device) || undefined,\n deviceName: asString(query.name) || 'Unknown device name',\n appName: asString(query.app) || 'Unknown app name',\n };\n}\n\nfunction getDebuggerInfo(url: IncomingMessage['url']) {\n const { query } = parse(url ?? '', true);\n return {\n deviceId: asString(query.device),\n pageId: asString(query.page),\n debuggerType: asString(query.type) ?? undefined,\n };\n}\n"],"names":["WS_DEVICE_URL","WS_DEBUGGER_URL","WS_GENERIC_ERROR_STATUS","debug","require","ExpoInspectorProxy","constructor","metroProxy","DeviceClass","devices","Map","_devices","processRequest","bind","setServerAddress","server","addressInfo","address","Error","port","family","_serverAddressWithPort","req","res","next","createWebSocketListeners","createDeviceWebSocketServer","createDebuggerWebSocketServer","wss","WS","Server","noServer","perMessageDeflate","on","socket","request","fallbackDeviceId","String","_deviceCounter","deviceId","newDeviceId","deviceName","appName","getDeviceInfo","url","oldDevice","get","newDevice","_projectRoot","handleDuplicateDeviceConnection","set","delete","error","message","toString","Log","exception","close","pageId","debuggerType","getDebuggerInfo","device","_name","_app","handleDebuggerConnectionWithType","handleDebuggerConnection","asString","value","Array","isArray","join","query","parse","undefined","name","app","page","type"],"mappings":"AAAA;;;;AAGsB,IAAA,IAAK,WAAL,KAAK,CAAA;AACY,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEvB,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;;;;;;AAErC,MAAMA,aAAa,GAAG,mBAAmB,AAAC;AAC1C,MAAMC,eAAe,GAAG,kBAAkB,AAAC;AAC3C,MAAMC,uBAAuB,GAAG,IAAI,AAAC;AAErC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,kCAAkC,CAAC,AAAsB,AAAC;AAKlF,MAAMC,kBAAkB;IAC7BC,YACkBC,UAAsB,EAC9BC,WAA8B,EACtBC,OAAuB,GAAG,IAAIC,GAAG,EAAE,CACnD;aAHgBH,UAAsB,GAAtBA,UAAsB;aAC9BC,WAA8B,GAA9BA,WAA8B;aACtBC,OAAuB,GAAvBA,OAAuB;QAEvC,uEAAuE;QACvE,iDAAiD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B;IAHpC,OAAO;QACL3B,QAAQ,EAAE2B,QAAQ,CAACK,KAAK,CAACV,MAAM,CAAC;QAChCH,MAAM,EAAEQ,QAAQ,CAACK,KAAK,CAACK,IAAI,CAAC;QAC5BjB,YAAY,EAAEO,CAAAA,GAAoB,GAApBA,QAAQ,CAACK,KAAK,CAACM,IAAI,CAAC,YAApBX,GAAoB,GAAIO,SAAS;KAChD,CAAC;CACH"}
|
|
@@ -13,6 +13,7 @@ var _log = require("../../../log");
|
|
|
13
13
|
var _fileNotifier = require("../../../utils/FileNotifier");
|
|
14
14
|
var _env = require("../../../utils/env");
|
|
15
15
|
var _exit = require("../../../utils/exit");
|
|
16
|
+
var _interactive = require("../../../utils/interactive");
|
|
16
17
|
var _link = require("../../../utils/link");
|
|
17
18
|
var _loadTsConfigPaths = require("../../../utils/tsconfig/loadTsConfigPaths");
|
|
18
19
|
var _resolveWithTsConfigPaths = require("../../../utils/tsconfig/resolveWithTsConfigPaths");
|
|
@@ -91,7 +92,7 @@ function withExtendedResolver(config, { projectRoot , tsconfig , platforms , isT
|
|
|
91
92
|
paths: (_paths1 = tsconfig.paths) != null ? _paths1 : {},
|
|
92
93
|
baseUrl: tsconfig.baseUrl
|
|
93
94
|
}) : null;
|
|
94
|
-
if (isTsconfigPathsEnabled &&
|
|
95
|
+
if (isTsconfigPathsEnabled && (0, _interactive).isInteractive()) {
|
|
95
96
|
// TODO: We should track all the files that used imports and invalidate them
|
|
96
97
|
// currently the user will need to save all the files that use imports to
|
|
97
98
|
// use the new aliases.
|