Socket
Socket
Sign inDemoInstall

metro-inspector-proxy

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-inspector-proxy - npm Package Compare versions

Comparing version 0.66.2 to 0.67.0

4

package.json
{
"name": "metro-inspector-proxy",
"version": "0.66.2",
"version": "0.67.0",
"description": "🚇 Inspector proxy for React Native and dev tools integration.",

@@ -22,5 +22,5 @@ "main": "src/index.js",

"debug": "^2.2.0",
"ws": "^1.1.5",
"ws": "^7.5.1",
"yargs": "^15.3.1"
}
}
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,6 +12,6 @@ * This source code is licensed under the MIT license found in the

const { runInspectorProxy } = require("./index");
const yargs = require("yargs");
const { runInspectorProxy } = require("./index");
const argv = yargs

@@ -22,3 +22,3 @@ .option("port", {

type: "number",
default: 8081
default: 8081,
})

@@ -29,4 +29,4 @@ .option("root", {

type: "string",
default: ""
default: "",
}).argv;
runInspectorProxy(argv.port, argv.root);

@@ -17,3 +17,3 @@ "use strict";

var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return (_getRequireWildcardCache = function (nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;

@@ -57,3 +57,3 @@ })(nodeInterop);

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -66,5 +66,5 @@ * This source code is licensed under the MIT license found in the

*/
const PAGES_POLLING_INTERVAL = 1000;
const debug = require("debug")("Metro:InspectorProxy");
const debug = require("debug")("Metro:InspectorProxy"); // Android's stock emulator and other emulators such as genymotion use a standard localhost alias.
const PAGES_POLLING_INTERVAL = 1000; // Android's stock emulator and other emulators such as genymotion use a standard localhost alias.

@@ -108,3 +108,3 @@ const EMULATOR_LOCALHOST_ADDRESSES = ["10.0.2.2", "10.0.3.2"]; // Prefix for script URLs that are alphanumeric IDs. See comment in _processMessageFromDevice method for

this._deviceSocket.on("message", message => {
this._deviceSocket.on("message", (message) => {
const parsedMessage = JSON.parse(message);

@@ -150,3 +150,3 @@

vm: "don't use",
app: this._app
app: this._app,
};

@@ -173,3 +173,3 @@ return this._pages.concat(reactNativeReloadablePage);

prependedFilePrefix: false,
pageId
pageId,
};

@@ -182,7 +182,7 @@ this._debuggerConnection = debuggerInfo;

payload: {
pageId: this._mapToDevicePageId(pageId)
}
pageId: this._mapToDevicePageId(pageId),
},
});
socket.on("message", message => {
socket.on("message", (message) => {
debug("(Debugger) -> (Proxy) (Device): " + message);

@@ -203,4 +203,4 @@ const debuggerRequest = JSON.parse(message);

pageId: this._mapToDevicePageId(pageId),
wrappedEvent: JSON.stringify(debuggerRequest)
}
wrappedEvent: JSON.stringify(debuggerRequest),
},
});

@@ -215,4 +215,4 @@ }

payload: {
pageId: this._mapToDevicePageId(pageId)
}
pageId: this._mapToDevicePageId(pageId),
},
});

@@ -224,3 +224,3 @@

socket.send = function(message) {
socket.send = function (message) {
debug("(Debugger) <- (Proxy) (Device): " + message);

@@ -278,3 +278,3 @@ return sendFunc.call(socket, message);

JSON.stringify({
method: "reload"
method: "reload",
})

@@ -326,3 +326,3 @@ );

this._sendMessageToDevice({
event: "getPages"
event: "getPages",
}),

@@ -364,4 +364,4 @@ PAGES_POLLING_INTERVAL

payload: {
pageId: oldPageId
}
pageId: oldPageId,
},
});

@@ -373,4 +373,4 @@ }

payload: {
pageId: page.id
}
pageId: page.id,
},
});

@@ -381,8 +381,8 @@

method: "Runtime.enable",
id: 1e9
id: 1e9,
},
{
method: "Debugger.enable",
id: 1e9
}
id: 1e9,
},
];

@@ -395,4 +395,4 @@

pageId: this._mapToDevicePageId(page.id),
wrappedEvent: JSON.stringify(message)
}
wrappedEvent: JSON.stringify(message),
},
});

@@ -467,3 +467,3 @@ }

JSON.stringify({
method: "Runtime.executionContextsCleared"
method: "Runtime.executionContextsCleared",
})

@@ -484,5 +484,5 @@ ); // The VM starts in a paused mode. Ask it to resume.

method: "Debugger.resume",
id: 0
})
}
id: 0,
}),
},
});

@@ -502,3 +502,3 @@

id: req.id,
result: this._processDebuggerGetScriptSource(req)
result: this._processDebuggerGetScriptSource(req),
};

@@ -557,3 +557,3 @@ }

return {
scriptSource
scriptSource,
};

@@ -560,0 +560,0 @@ }

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -12,3 +12,5 @@ * This source code is licensed under the MIT license found in the

const InspectorProxy = require("./InspectorProxy"); // Runs new HTTP Server and attaches Inspector Proxy to it.
const InspectorProxy = require("./InspectorProxy");
const { parse } = require("url"); // Runs new HTTP Server and attaches Inspector Proxy to it.
// Requires are inlined here because we don't want to import them

@@ -28,3 +30,20 @@ // when someone needs only InspectorProxy instance (without starting

httpServer.listen(port, "127.0.0.1", () => {
inspectorProxy.addWebSocketListener(httpServer);
const websocketEndpoints =
inspectorProxy.createWebSocketListeners(httpServer);
httpServer.on("upgrade", (request, socket, head) => {
const { pathname } = parse(request.url);
if (pathname != null && websocketEndpoints[pathname]) {
websocketEndpoints[pathname].handleUpgrade(
request,
socket,
head,
(ws) => {
websocketEndpoints[pathname].emit("connection", ws, request);
}
);
} else {
socket.destroy();
}
});
});

@@ -35,3 +54,3 @@ }

InspectorProxy,
runInspectorProxy
runInspectorProxy,
};
/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -14,4 +14,2 @@ * This source code is licensed under the MIT license found in the

const WS = require("ws");
const debug = require("debug")("Metro:InspectorProxy");

@@ -21,2 +19,4 @@

const WS = require("ws");
const WS_DEVICE_URL = "/inspector/device";

@@ -61,3 +61,3 @@ const WS_DEBUGGER_URL = "/inspector/debug";

.getPagesList()
.map(page => this._buildPageDescription(deviceId, device, page))
.map((page) => this._buildPageDescription(deviceId, device, page))
);

@@ -70,3 +70,3 @@ });

Browser: "Mobile JavaScript",
"Protocol-Version": "1.1"
"Protocol-Version": "1.1",
});

@@ -78,3 +78,3 @@ } else {

addWebSocketListener(server) {
createWebSocketListeners(server) {
const { port } = server.address();

@@ -88,5 +88,6 @@

this._addDeviceConnectionHandler(server);
this._addDebuggerConnectionHandler(server);
return {
[WS_DEVICE_URL]: this._createDeviceConnectionWSServer(),
[WS_DEBUGGER_URL]: this._createDebuggerConnectionWSServer(),
};
} // Converts page information received from device into PageDescription object

@@ -109,3 +110,3 @@ // that is sent to debugger.

webSocketDebuggerUrl,
vm: page.vm
vm: page.vm,
};

@@ -121,3 +122,3 @@ } // Sends object as response to HTTP request.

"Content-Length": data.length.toString(),
Connection: "close"
Connection: "close",
});

@@ -131,12 +132,11 @@ response.end(data);

_addDeviceConnectionHandler(server) {
_createDeviceConnectionWSServer() {
const wss = new WS.Server({
server,
path: WS_DEVICE_URL,
perMessageDeflate: true
noServer: true,
perMessageDeflate: true,
}); // $FlowFixMe[value-as-type]
wss.on("connection", async socket => {
wss.on("connection", async (socket, req) => {
try {
const query = url.parse(socket.upgradeReq.url || "", true).query || {};
const query = url.parse(req.url || "", true).query || {};
const deviceName = query.name || "Unknown";

@@ -162,3 +162,4 @@ const appName = query.app || "Unknown";

});
} // Adds websocket handler for debugger connections.
return wss;
} // Returns websocket handler for debugger connections.
// Debugger connects to webSocketDebuggerUrl that we return as part of page description

@@ -169,12 +170,11 @@ // in /json response.

_addDebuggerConnectionHandler(server) {
_createDebuggerConnectionWSServer() {
const wss = new WS.Server({
server,
path: WS_DEBUGGER_URL,
perMessageDeflate: false
noServer: true,
perMessageDeflate: false,
}); // $FlowFixMe[value-as-type]
wss.on("connection", async socket => {
wss.on("connection", async (socket, req) => {
try {
const query = url.parse(socket.upgradeReq.url || "", true).query || {};
const query = url.parse(req.url || "", true).query || {};
const deviceId = query.device;

@@ -199,2 +199,3 @@ const pageId = query.page;

});
return wss;
}

@@ -201,0 +202,0 @@ }

/**
* Copyright (c) Facebook, Inc. and its affiliates.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*

@@ -4,0 +4,0 @@ * This source code is licensed under the MIT license found in the

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc