@depup/react-native__dev-middleware 0.84.1-depup.1
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/README.md +38 -0
- package/changes.json +38 -0
- package/dist/createDevMiddleware.d.ts +62 -0
- package/dist/createDevMiddleware.js +140 -0
- package/dist/createDevMiddleware.js.flow +72 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +26 -0
- package/dist/index.js.flow +24 -0
- package/dist/inspector-proxy/CdpDebugLogging.d.ts +20 -0
- package/dist/inspector-proxy/CdpDebugLogging.js +117 -0
- package/dist/inspector-proxy/CdpDebugLogging.js.flow +20 -0
- package/dist/inspector-proxy/CustomMessageHandler.d.ts +48 -0
- package/dist/inspector-proxy/CustomMessageHandler.js +1 -0
- package/dist/inspector-proxy/CustomMessageHandler.js.flow +54 -0
- package/dist/inspector-proxy/Device.d.ts +62 -0
- package/dist/inspector-proxy/Device.js +810 -0
- package/dist/inspector-proxy/Device.js.flow +70 -0
- package/dist/inspector-proxy/DeviceEventReporter.d.ts +54 -0
- package/dist/inspector-proxy/DeviceEventReporter.js +194 -0
- package/dist/inspector-proxy/DeviceEventReporter.js.flow +62 -0
- package/dist/inspector-proxy/EventLoopPerfTracker.d.ts +31 -0
- package/dist/inspector-proxy/EventLoopPerfTracker.js +50 -0
- package/dist/inspector-proxy/EventLoopPerfTracker.js.flow +34 -0
- package/dist/inspector-proxy/InspectorProxy.d.ts +53 -0
- package/dist/inspector-proxy/InspectorProxy.js +477 -0
- package/dist/inspector-proxy/InspectorProxy.js.flow +62 -0
- package/dist/inspector-proxy/InspectorProxyHeartbeat.d.ts +24 -0
- package/dist/inspector-proxy/InspectorProxyHeartbeat.js +64 -0
- package/dist/inspector-proxy/InspectorProxyHeartbeat.js.flow +25 -0
- package/dist/inspector-proxy/cdp-types/messages.d.ts +41 -0
- package/dist/inspector-proxy/cdp-types/messages.js +1 -0
- package/dist/inspector-proxy/cdp-types/messages.js.flow +54 -0
- package/dist/inspector-proxy/cdp-types/protocol.d.ts +106 -0
- package/dist/inspector-proxy/cdp-types/protocol.js +1 -0
- package/dist/inspector-proxy/cdp-types/protocol.js.flow +124 -0
- package/dist/inspector-proxy/types.d.ts +115 -0
- package/dist/inspector-proxy/types.js +1 -0
- package/dist/inspector-proxy/types.js.flow +152 -0
- package/dist/middleware/openDebuggerMiddleware.d.ts +36 -0
- package/dist/middleware/openDebuggerMiddleware.js +216 -0
- package/dist/middleware/openDebuggerMiddleware.js.flow +36 -0
- package/dist/types/BrowserLauncher.d.ts +62 -0
- package/dist/types/BrowserLauncher.js +1 -0
- package/dist/types/BrowserLauncher.js.flow +66 -0
- package/dist/types/EventReporter.d.ts +124 -0
- package/dist/types/EventReporter.js +1 -0
- package/dist/types/EventReporter.js.flow +151 -0
- package/dist/types/Experiments.d.ts +30 -0
- package/dist/types/Experiments.js +1 -0
- package/dist/types/Experiments.js.flow +34 -0
- package/dist/types/Logger.d.ts +15 -0
- package/dist/types/Logger.js +1 -0
- package/dist/types/Logger.js.flow +16 -0
- package/dist/utils/DefaultBrowserLauncher.d.ts +30 -0
- package/dist/utils/DefaultBrowserLauncher.js +57 -0
- package/dist/utils/DefaultBrowserLauncher.js.flow +29 -0
- package/dist/utils/getBaseUrlFromRequest.d.ts +14 -0
- package/dist/utils/getBaseUrlFromRequest.js +19 -0
- package/dist/utils/getBaseUrlFromRequest.js.flow +17 -0
- package/dist/utils/getDevToolsFrontendUrl.d.ts +29 -0
- package/dist/utils/getDevToolsFrontendUrl.js +58 -0
- package/dist/utils/getDevToolsFrontendUrl.js.flow +29 -0
- package/package.json +97 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @depup/react-native__dev-middleware
|
|
2
|
+
|
|
3
|
+
> Dependency-bumped version of [@react-native/dev-middleware](https://www.npmjs.com/package/@react-native/dev-middleware)
|
|
4
|
+
|
|
5
|
+
Generated by [DepUp](https://github.com/depup/npm) -- all production
|
|
6
|
+
dependencies bumped to latest versions.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @depup/react-native__dev-middleware
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Field | Value |
|
|
15
|
+
|-------|-------|
|
|
16
|
+
| Original | [@react-native/dev-middleware](https://www.npmjs.com/package/@react-native/dev-middleware) @ 0.84.1 |
|
|
17
|
+
| Processed | 2026-03-21 |
|
|
18
|
+
| Smoke test | failed |
|
|
19
|
+
| Deps updated | 8 |
|
|
20
|
+
|
|
21
|
+
## Dependency Changes
|
|
22
|
+
|
|
23
|
+
| Dependency | From | To |
|
|
24
|
+
|------------|------|-----|
|
|
25
|
+
| @isaacs/ttlcache | ^1.4.1 | ^2.1.4 |
|
|
26
|
+
| chrome-launcher | ^0.15.2 | ^1.2.1 |
|
|
27
|
+
| chromium-edge-launcher | ^0.2.0 | ^0.3.0 |
|
|
28
|
+
| connect | ^3.6.5 | ^3.7.0 |
|
|
29
|
+
| debug | ^4.4.0 | ^4.4.3 |
|
|
30
|
+
| open | ^7.0.3 | ^11.0.0 |
|
|
31
|
+
| serve-static | ^1.16.2 | ^2.2.1 |
|
|
32
|
+
| ws | ^7.5.10 | ^8.20.0 |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/@react-native/dev-middleware
|
|
37
|
+
|
|
38
|
+
License inherited from the original package.
|
package/changes.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bumped": {
|
|
3
|
+
"@isaacs/ttlcache": {
|
|
4
|
+
"from": "^1.4.1",
|
|
5
|
+
"to": "^2.1.4"
|
|
6
|
+
},
|
|
7
|
+
"chrome-launcher": {
|
|
8
|
+
"from": "^0.15.2",
|
|
9
|
+
"to": "^1.2.1"
|
|
10
|
+
},
|
|
11
|
+
"chromium-edge-launcher": {
|
|
12
|
+
"from": "^0.2.0",
|
|
13
|
+
"to": "^0.3.0"
|
|
14
|
+
},
|
|
15
|
+
"connect": {
|
|
16
|
+
"from": "^3.6.5",
|
|
17
|
+
"to": "^3.7.0"
|
|
18
|
+
},
|
|
19
|
+
"debug": {
|
|
20
|
+
"from": "^4.4.0",
|
|
21
|
+
"to": "^4.4.3"
|
|
22
|
+
},
|
|
23
|
+
"open": {
|
|
24
|
+
"from": "^7.0.3",
|
|
25
|
+
"to": "^11.0.0"
|
|
26
|
+
},
|
|
27
|
+
"serve-static": {
|
|
28
|
+
"from": "^1.16.2",
|
|
29
|
+
"to": "^2.2.1"
|
|
30
|
+
},
|
|
31
|
+
"ws": {
|
|
32
|
+
"from": "^7.5.10",
|
|
33
|
+
"to": "^8.20.0"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"timestamp": "2026-03-21T20:09:16.980Z",
|
|
37
|
+
"totalUpdated": 8
|
|
38
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { CreateCustomMessageHandlerFn } from "./inspector-proxy/CustomMessageHandler";
|
|
12
|
+
import type { BrowserLauncher } from "./types/BrowserLauncher";
|
|
13
|
+
import type { EventReporter } from "./types/EventReporter";
|
|
14
|
+
import type { ExperimentsConfig } from "./types/Experiments";
|
|
15
|
+
import type { Logger } from "./types/Logger";
|
|
16
|
+
import type { NextHandleFunction } from "connect";
|
|
17
|
+
type Options = Readonly<{
|
|
18
|
+
/**
|
|
19
|
+
* The base URL to the dev server, as reachable from the machine on which
|
|
20
|
+
* dev-middleware is hosted. Typically `http://localhost:${metroPort}`.
|
|
21
|
+
*/
|
|
22
|
+
serverBaseUrl: string;
|
|
23
|
+
logger?: Logger;
|
|
24
|
+
/**
|
|
25
|
+
* An interface for integrators to provide a custom implementation for
|
|
26
|
+
* opening URLs in a web browser.
|
|
27
|
+
*
|
|
28
|
+
* This is an unstable API with no semver guarantees.
|
|
29
|
+
*/
|
|
30
|
+
unstable_browserLauncher?: BrowserLauncher;
|
|
31
|
+
/**
|
|
32
|
+
* An interface for logging events.
|
|
33
|
+
*
|
|
34
|
+
* This is an unstable API with no semver guarantees.
|
|
35
|
+
*/
|
|
36
|
+
unstable_eventReporter?: EventReporter;
|
|
37
|
+
/**
|
|
38
|
+
* The set of experimental features to enable.
|
|
39
|
+
*
|
|
40
|
+
* This is an unstable API with no semver guarantees.
|
|
41
|
+
*/
|
|
42
|
+
unstable_experiments?: ExperimentsConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Create custom handler to add support for unsupported CDP events, or debuggers.
|
|
45
|
+
* This handler is instantiated per logical device and debugger pair.
|
|
46
|
+
*
|
|
47
|
+
* This is an unstable API with no semver guarantees.
|
|
48
|
+
*/
|
|
49
|
+
unstable_customInspectorMessageHandler?: CreateCustomMessageHandlerFn;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to measure the event loop performance of inspector proxy and log report it via the event reporter.
|
|
52
|
+
*
|
|
53
|
+
* This is an unstable API with no semver guarantees.
|
|
54
|
+
*/
|
|
55
|
+
unstable_trackInspectorProxyEventLoopPerf?: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
type DevMiddlewareAPI = Readonly<{
|
|
58
|
+
middleware: NextHandleFunction;
|
|
59
|
+
websocketEndpoints: { [path: string]: ws$WebSocketServer };
|
|
60
|
+
}>;
|
|
61
|
+
declare function createDevMiddleware($$PARAM_0$$: Options): DevMiddlewareAPI;
|
|
62
|
+
export default createDevMiddleware;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = createDevMiddleware;
|
|
7
|
+
var _InspectorProxy = _interopRequireDefault(
|
|
8
|
+
require("./inspector-proxy/InspectorProxy"),
|
|
9
|
+
);
|
|
10
|
+
var _openDebuggerMiddleware = _interopRequireDefault(
|
|
11
|
+
require("./middleware/openDebuggerMiddleware"),
|
|
12
|
+
);
|
|
13
|
+
var _DefaultBrowserLauncher = _interopRequireDefault(
|
|
14
|
+
require("./utils/DefaultBrowserLauncher"),
|
|
15
|
+
);
|
|
16
|
+
var _debuggerFrontend = _interopRequireDefault(
|
|
17
|
+
require("@react-native/debugger-frontend"),
|
|
18
|
+
);
|
|
19
|
+
var _connect = _interopRequireDefault(require("connect"));
|
|
20
|
+
var _path = _interopRequireDefault(require("path"));
|
|
21
|
+
var _serveStatic = _interopRequireDefault(require("serve-static"));
|
|
22
|
+
function _interopRequireDefault(e) {
|
|
23
|
+
return e && e.__esModule ? e : { default: e };
|
|
24
|
+
}
|
|
25
|
+
function createDevMiddleware({
|
|
26
|
+
serverBaseUrl,
|
|
27
|
+
logger,
|
|
28
|
+
unstable_browserLauncher = _DefaultBrowserLauncher.default,
|
|
29
|
+
unstable_eventReporter,
|
|
30
|
+
unstable_experiments: experimentConfig = {},
|
|
31
|
+
unstable_customInspectorMessageHandler,
|
|
32
|
+
unstable_trackInspectorProxyEventLoopPerf = false,
|
|
33
|
+
}) {
|
|
34
|
+
const experiments = getExperiments(experimentConfig);
|
|
35
|
+
const eventReporter = createWrappedEventReporter(
|
|
36
|
+
unstable_eventReporter,
|
|
37
|
+
logger,
|
|
38
|
+
experiments,
|
|
39
|
+
);
|
|
40
|
+
const inspectorProxy = new _InspectorProxy.default(
|
|
41
|
+
serverBaseUrl,
|
|
42
|
+
eventReporter,
|
|
43
|
+
experiments,
|
|
44
|
+
logger,
|
|
45
|
+
unstable_customInspectorMessageHandler,
|
|
46
|
+
unstable_trackInspectorProxyEventLoopPerf,
|
|
47
|
+
);
|
|
48
|
+
const middleware = (0, _connect.default)()
|
|
49
|
+
.use(
|
|
50
|
+
"/open-debugger",
|
|
51
|
+
(0, _openDebuggerMiddleware.default)({
|
|
52
|
+
serverBaseUrl,
|
|
53
|
+
inspectorProxy,
|
|
54
|
+
browserLauncher: unstable_browserLauncher,
|
|
55
|
+
eventReporter,
|
|
56
|
+
experiments,
|
|
57
|
+
logger,
|
|
58
|
+
}),
|
|
59
|
+
)
|
|
60
|
+
.use(
|
|
61
|
+
"/debugger-frontend/embedder-static/embedderScript.js",
|
|
62
|
+
(_req, res) => {
|
|
63
|
+
res.setHeader("Content-Type", "application/javascript");
|
|
64
|
+
res.end("");
|
|
65
|
+
},
|
|
66
|
+
)
|
|
67
|
+
.use(
|
|
68
|
+
"/debugger-frontend",
|
|
69
|
+
(0, _serveStatic.default)(_path.default.join(_debuggerFrontend.default), {
|
|
70
|
+
fallthrough: false,
|
|
71
|
+
}),
|
|
72
|
+
)
|
|
73
|
+
.use((...args) => inspectorProxy.processRequest(...args));
|
|
74
|
+
return {
|
|
75
|
+
middleware,
|
|
76
|
+
websocketEndpoints: inspectorProxy.createWebSocketListeners(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function getExperiments(config) {
|
|
80
|
+
return {
|
|
81
|
+
enableOpenDebuggerRedirect: config.enableOpenDebuggerRedirect ?? false,
|
|
82
|
+
enableNetworkInspector: config.enableNetworkInspector ?? false,
|
|
83
|
+
enableStandaloneFuseboxShell: config.enableStandaloneFuseboxShell ?? true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function createWrappedEventReporter(reporter, logger, experiments) {
|
|
87
|
+
return {
|
|
88
|
+
logEvent(event) {
|
|
89
|
+
switch (event.type) {
|
|
90
|
+
case "profiling_target_registered":
|
|
91
|
+
logger?.info(
|
|
92
|
+
"Profiling build target '%s' registered for debugging",
|
|
93
|
+
event.appId ?? "unknown",
|
|
94
|
+
);
|
|
95
|
+
break;
|
|
96
|
+
case "fusebox_console_notice":
|
|
97
|
+
logger?.info(
|
|
98
|
+
"\u001B[1m\u001B[7m💡 JavaScript logs have moved!\u001B[22m They can now be " +
|
|
99
|
+
"viewed in React Native DevTools. Tip: Type \u001B[1mj\u001B[22m in " +
|
|
100
|
+
"the terminal to open" +
|
|
101
|
+
(experiments.enableStandaloneFuseboxShell
|
|
102
|
+
? ""
|
|
103
|
+
: " (requires Google Chrome or Microsoft Edge)") +
|
|
104
|
+
".\u001B[27m",
|
|
105
|
+
);
|
|
106
|
+
break;
|
|
107
|
+
case "fusebox_shell_preparation_attempt":
|
|
108
|
+
switch (event.result.code) {
|
|
109
|
+
case "success":
|
|
110
|
+
case "not_implemented":
|
|
111
|
+
break;
|
|
112
|
+
case "unexpected_error": {
|
|
113
|
+
let message =
|
|
114
|
+
event.result.humanReadableMessage ??
|
|
115
|
+
"An unknown error occurred while installing React Native DevTools.";
|
|
116
|
+
if (event.result.verboseInfo != null) {
|
|
117
|
+
message += ` Details:\n\n${event.result.verboseInfo}`;
|
|
118
|
+
} else {
|
|
119
|
+
message += ".";
|
|
120
|
+
}
|
|
121
|
+
logger?.error(message);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case "possible_corruption":
|
|
125
|
+
case "platform_not_supported":
|
|
126
|
+
case "likely_offline":
|
|
127
|
+
logger?.warn(
|
|
128
|
+
event.result.humanReadableMessage ??
|
|
129
|
+
`An error of type ${event.result.code} occurred while installing React Native DevTools.`,
|
|
130
|
+
);
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
event.result.code;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
reporter?.logEvent(event);
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { CreateCustomMessageHandlerFn } from "./inspector-proxy/CustomMessageHandler";
|
|
12
|
+
import type { BrowserLauncher } from "./types/BrowserLauncher";
|
|
13
|
+
import type { EventReporter } from "./types/EventReporter";
|
|
14
|
+
import type { ExperimentsConfig } from "./types/Experiments";
|
|
15
|
+
import type { Logger } from "./types/Logger";
|
|
16
|
+
import type { NextHandleFunction } from "connect";
|
|
17
|
+
|
|
18
|
+
type Options = $ReadOnly<{
|
|
19
|
+
/**
|
|
20
|
+
* The base URL to the dev server, as reachable from the machine on which
|
|
21
|
+
* dev-middleware is hosted. Typically `http://localhost:${metroPort}`.
|
|
22
|
+
*/
|
|
23
|
+
serverBaseUrl: string,
|
|
24
|
+
|
|
25
|
+
logger?: Logger,
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An interface for integrators to provide a custom implementation for
|
|
29
|
+
* opening URLs in a web browser.
|
|
30
|
+
*
|
|
31
|
+
* This is an unstable API with no semver guarantees.
|
|
32
|
+
*/
|
|
33
|
+
unstable_browserLauncher?: BrowserLauncher,
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* An interface for logging events.
|
|
37
|
+
*
|
|
38
|
+
* This is an unstable API with no semver guarantees.
|
|
39
|
+
*/
|
|
40
|
+
unstable_eventReporter?: EventReporter,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The set of experimental features to enable.
|
|
44
|
+
*
|
|
45
|
+
* This is an unstable API with no semver guarantees.
|
|
46
|
+
*/
|
|
47
|
+
unstable_experiments?: ExperimentsConfig,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Create custom handler to add support for unsupported CDP events, or debuggers.
|
|
51
|
+
* This handler is instantiated per logical device and debugger pair.
|
|
52
|
+
*
|
|
53
|
+
* This is an unstable API with no semver guarantees.
|
|
54
|
+
*/
|
|
55
|
+
unstable_customInspectorMessageHandler?: CreateCustomMessageHandlerFn,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether to measure the event loop performance of inspector proxy and log report it via the event reporter.
|
|
59
|
+
*
|
|
60
|
+
* This is an unstable API with no semver guarantees.
|
|
61
|
+
*/
|
|
62
|
+
unstable_trackInspectorProxyEventLoopPerf?: boolean,
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
type DevMiddlewareAPI = $ReadOnly<{
|
|
66
|
+
middleware: NextHandleFunction,
|
|
67
|
+
websocketEndpoints: { [path: string]: ws$WebSocketServer },
|
|
68
|
+
}>;
|
|
69
|
+
|
|
70
|
+
declare export default function createDevMiddleware(
|
|
71
|
+
$$PARAM_0$$: Options,
|
|
72
|
+
): DevMiddlewareAPI;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type {
|
|
12
|
+
BrowserLauncher,
|
|
13
|
+
DebuggerShellPreparationResult,
|
|
14
|
+
} from "./types/BrowserLauncher";
|
|
15
|
+
export type { EventReporter, ReportableEvent } from "./types/EventReporter";
|
|
16
|
+
export type {
|
|
17
|
+
CustomMessageHandler,
|
|
18
|
+
CustomMessageHandlerConnection,
|
|
19
|
+
CreateCustomMessageHandlerFn,
|
|
20
|
+
} from "./inspector-proxy/CustomMessageHandler";
|
|
21
|
+
export type { Logger } from "./types/Logger";
|
|
22
|
+
export { default as unstable_DefaultBrowserLauncher } from "./utils/DefaultBrowserLauncher";
|
|
23
|
+
export { default as createDevMiddleware } from "./createDevMiddleware";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "createDevMiddleware", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _createDevMiddleware.default;
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "unstable_DefaultBrowserLauncher", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _DefaultBrowserLauncher.default;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
var _DefaultBrowserLauncher = _interopRequireDefault(
|
|
19
|
+
require("./utils/DefaultBrowserLauncher"),
|
|
20
|
+
);
|
|
21
|
+
var _createDevMiddleware = _interopRequireDefault(
|
|
22
|
+
require("./createDevMiddleware"),
|
|
23
|
+
);
|
|
24
|
+
function _interopRequireDefault(e) {
|
|
25
|
+
return e && e.__esModule ? e : { default: e };
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type {
|
|
12
|
+
BrowserLauncher,
|
|
13
|
+
DebuggerShellPreparationResult,
|
|
14
|
+
} from "./types/BrowserLauncher";
|
|
15
|
+
export type { EventReporter, ReportableEvent } from "./types/EventReporter";
|
|
16
|
+
export type {
|
|
17
|
+
CustomMessageHandler,
|
|
18
|
+
CustomMessageHandlerConnection,
|
|
19
|
+
CreateCustomMessageHandlerFn,
|
|
20
|
+
} from "./inspector-proxy/CustomMessageHandler";
|
|
21
|
+
export type { Logger } from "./types/Logger";
|
|
22
|
+
|
|
23
|
+
export { default as unstable_DefaultBrowserLauncher } from "./utils/DefaultBrowserLauncher";
|
|
24
|
+
export { default as createDevMiddleware } from "./createDevMiddleware";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type CDPMessageDestination =
|
|
12
|
+
| "DebuggerToProxy"
|
|
13
|
+
| "ProxyToDebugger"
|
|
14
|
+
| "DeviceToProxy"
|
|
15
|
+
| "ProxyToDevice";
|
|
16
|
+
declare class CdpDebugLogging {
|
|
17
|
+
constructor();
|
|
18
|
+
log(destination: CDPMessageDestination, message: string): void;
|
|
19
|
+
}
|
|
20
|
+
export default CdpDebugLogging;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _timers = require("timers");
|
|
8
|
+
var _util = _interopRequireDefault(require("util"));
|
|
9
|
+
function _interopRequireDefault(e) {
|
|
10
|
+
return e && e.__esModule ? e : { default: e };
|
|
11
|
+
}
|
|
12
|
+
const debug = require("debug")("Metro:InspectorProxy");
|
|
13
|
+
const debugCDPMessages = require("debug")("Metro:InspectorProxyCDPMessages");
|
|
14
|
+
const CDP_MESSAGES_BATCH_DEBUGGING_THROTTLE_MS = 5000;
|
|
15
|
+
function getCDPLogPrefix(destination) {
|
|
16
|
+
return _util.default.format(
|
|
17
|
+
"[(Debugger) %s (Proxy) %s (Device)]",
|
|
18
|
+
destination === "DebuggerToProxy"
|
|
19
|
+
? "->"
|
|
20
|
+
: destination === "ProxyToDebugger"
|
|
21
|
+
? "<-"
|
|
22
|
+
: " ",
|
|
23
|
+
destination === "ProxyToDevice"
|
|
24
|
+
? "->"
|
|
25
|
+
: destination === "DeviceToProxy"
|
|
26
|
+
? "<-"
|
|
27
|
+
: " ",
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
class CdpDebugLogging {
|
|
31
|
+
#cdpMessagesLoggingBatchingFn = {
|
|
32
|
+
DebuggerToProxy: () => {},
|
|
33
|
+
ProxyToDebugger: () => {},
|
|
34
|
+
DeviceToProxy: () => {},
|
|
35
|
+
ProxyToDevice: () => {},
|
|
36
|
+
};
|
|
37
|
+
constructor() {
|
|
38
|
+
if (debug.enabled) {
|
|
39
|
+
this.#initializeThrottledCDPMessageLogging();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
#initializeThrottledCDPMessageLogging() {
|
|
43
|
+
const batchingCounters = {
|
|
44
|
+
DebuggerToProxy: {
|
|
45
|
+
count: 0,
|
|
46
|
+
size: 0,
|
|
47
|
+
},
|
|
48
|
+
ProxyToDebugger: {
|
|
49
|
+
count: 0,
|
|
50
|
+
size: 0,
|
|
51
|
+
},
|
|
52
|
+
DeviceToProxy: {
|
|
53
|
+
count: 0,
|
|
54
|
+
size: 0,
|
|
55
|
+
},
|
|
56
|
+
ProxyToDevice: {
|
|
57
|
+
count: 0,
|
|
58
|
+
size: 0,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
Object.keys(batchingCounters).forEach((destination) => {
|
|
62
|
+
let timeout = null;
|
|
63
|
+
this.#cdpMessagesLoggingBatchingFn[destination] = (message) => {
|
|
64
|
+
if (message.length > 1024 * 100) {
|
|
65
|
+
const messagePreview = JSON.stringify(
|
|
66
|
+
JSON.parse(message, (key, value) => {
|
|
67
|
+
if (Array.isArray(value)) {
|
|
68
|
+
return "[ARRAY]";
|
|
69
|
+
}
|
|
70
|
+
if (typeof value === "string" && value.length > 50) {
|
|
71
|
+
return value.slice(0, 50) + "...";
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}),
|
|
75
|
+
null,
|
|
76
|
+
2,
|
|
77
|
+
);
|
|
78
|
+
debug(
|
|
79
|
+
"%s A large message (%s MB) was %s- %s",
|
|
80
|
+
getCDPLogPrefix(destination),
|
|
81
|
+
(message.length / (1024 * 1024)).toFixed(2),
|
|
82
|
+
destination.startsWith("Proxy") ? " sent " : "received",
|
|
83
|
+
messagePreview,
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
if (timeout == null) {
|
|
87
|
+
timeout = (0, _timers.setTimeout)(() => {
|
|
88
|
+
debug(
|
|
89
|
+
"%s %s CDP messages of size %s MB %s in the last %ss.",
|
|
90
|
+
getCDPLogPrefix(destination),
|
|
91
|
+
String(batchingCounters[destination].count).padStart(4),
|
|
92
|
+
String(
|
|
93
|
+
(batchingCounters[destination].size / (1024 * 1024)).toFixed(2),
|
|
94
|
+
).padStart(6),
|
|
95
|
+
destination.startsWith("Proxy") ? " sent " : "received",
|
|
96
|
+
CDP_MESSAGES_BATCH_DEBUGGING_THROTTLE_MS / 1000,
|
|
97
|
+
);
|
|
98
|
+
batchingCounters[destination].count = 0;
|
|
99
|
+
batchingCounters[destination].size = 0;
|
|
100
|
+
timeout = null;
|
|
101
|
+
}, CDP_MESSAGES_BATCH_DEBUGGING_THROTTLE_MS).unref();
|
|
102
|
+
}
|
|
103
|
+
batchingCounters[destination].count++;
|
|
104
|
+
batchingCounters[destination].size += message.length;
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
log(destination, message) {
|
|
109
|
+
if (debugCDPMessages.enabled) {
|
|
110
|
+
debugCDPMessages("%s message: %s", getCDPLogPrefix(destination), message);
|
|
111
|
+
}
|
|
112
|
+
if (debug.enabled) {
|
|
113
|
+
this.#cdpMessagesLoggingBatchingFn[destination](message);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.default = CdpDebugLogging;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type CDPMessageDestination =
|
|
12
|
+
| "DebuggerToProxy"
|
|
13
|
+
| "ProxyToDebugger"
|
|
14
|
+
| "DeviceToProxy"
|
|
15
|
+
| "ProxyToDevice";
|
|
16
|
+
|
|
17
|
+
declare export default class CdpDebugLogging {
|
|
18
|
+
constructor(): void;
|
|
19
|
+
log(destination: CDPMessageDestination, message: string): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { JSONSerializable, Page } from "./types";
|
|
12
|
+
type ExposedDevice = Readonly<{
|
|
13
|
+
appId: string;
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
sendMessage: (message: JSONSerializable) => void;
|
|
17
|
+
}>;
|
|
18
|
+
type ExposedDebugger = Readonly<{
|
|
19
|
+
userAgent: string | null;
|
|
20
|
+
sendMessage: (message: JSONSerializable) => void;
|
|
21
|
+
}>;
|
|
22
|
+
export type CustomMessageHandlerConnection = Readonly<{
|
|
23
|
+
page: Page;
|
|
24
|
+
device: ExposedDevice;
|
|
25
|
+
debugger: ExposedDebugger;
|
|
26
|
+
}>;
|
|
27
|
+
export type CreateCustomMessageHandlerFn = (
|
|
28
|
+
connection: CustomMessageHandlerConnection,
|
|
29
|
+
) => null | undefined | CustomMessageHandler;
|
|
30
|
+
/**
|
|
31
|
+
* The device message middleware allows implementers to handle unsupported CDP messages.
|
|
32
|
+
* It is instantiated per device and may contain state that is specific to that device.
|
|
33
|
+
* The middleware can also mark messages from the device or debugger as handled, which stops propagating.
|
|
34
|
+
*/
|
|
35
|
+
export interface CustomMessageHandler {
|
|
36
|
+
/**
|
|
37
|
+
* Handle a CDP message coming from the device.
|
|
38
|
+
* This is invoked before the message is sent to the debugger.
|
|
39
|
+
* When returning true, the message is considered handled and will not be sent to the debugger.
|
|
40
|
+
*/
|
|
41
|
+
handleDeviceMessage(message: JSONSerializable): true | void;
|
|
42
|
+
/**
|
|
43
|
+
* Handle a CDP message coming from the debugger.
|
|
44
|
+
* This is invoked before the message is sent to the device.
|
|
45
|
+
* When returning true, the message is considered handled and will not be sent to the device.
|
|
46
|
+
*/
|
|
47
|
+
handleDebuggerMessage(message: JSONSerializable): true | void;
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { JSONSerializable, Page } from "./types";
|
|
12
|
+
|
|
13
|
+
type ExposedDevice = $ReadOnly<{
|
|
14
|
+
appId: string,
|
|
15
|
+
id: string,
|
|
16
|
+
name: string,
|
|
17
|
+
sendMessage: (message: JSONSerializable) => void,
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
type ExposedDebugger = $ReadOnly<{
|
|
21
|
+
userAgent: string | null,
|
|
22
|
+
sendMessage: (message: JSONSerializable) => void,
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export type CustomMessageHandlerConnection = $ReadOnly<{
|
|
26
|
+
page: Page,
|
|
27
|
+
device: ExposedDevice,
|
|
28
|
+
debugger: ExposedDebugger,
|
|
29
|
+
}>;
|
|
30
|
+
|
|
31
|
+
export type CreateCustomMessageHandlerFn = (
|
|
32
|
+
connection: CustomMessageHandlerConnection,
|
|
33
|
+
) => ?CustomMessageHandler;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The device message middleware allows implementers to handle unsupported CDP messages.
|
|
37
|
+
* It is instantiated per device and may contain state that is specific to that device.
|
|
38
|
+
* The middleware can also mark messages from the device or debugger as handled, which stops propagating.
|
|
39
|
+
*/
|
|
40
|
+
export interface CustomMessageHandler {
|
|
41
|
+
/**
|
|
42
|
+
* Handle a CDP message coming from the device.
|
|
43
|
+
* This is invoked before the message is sent to the debugger.
|
|
44
|
+
* When returning true, the message is considered handled and will not be sent to the debugger.
|
|
45
|
+
*/
|
|
46
|
+
handleDeviceMessage(message: JSONSerializable): true | void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Handle a CDP message coming from the debugger.
|
|
50
|
+
* This is invoked before the message is sent to the device.
|
|
51
|
+
* When returning true, the message is considered handled and will not be sent to the device.
|
|
52
|
+
*/
|
|
53
|
+
handleDebuggerMessage(message: JSONSerializable): true | void;
|
|
54
|
+
}
|