@teardown/cli 1.2.20 → 1.2.22
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/bin/teardown.js +3 -0
- package/dist/commands/dev/dev.d.ts +22 -0
- package/dist/commands/dev/dev.js +55 -0
- package/dist/commands/dev/types.d.ts +64 -0
- package/dist/commands/dev/types.js +2 -0
- package/dist/index.js +11 -32
- package/dist/modules/dev/dev-menu/keyboard-handler.d.ts +20 -0
- package/dist/modules/dev/dev-menu/keyboard-handler.js +126 -0
- package/dist/modules/dev/dev-menu/open-debugger-keyboard-handler.d.ts +18 -0
- package/dist/modules/dev/dev-menu/open-debugger-keyboard-handler.js +105 -0
- package/dist/modules/dev/dev-server/dev-server-checker.d.ts +22 -0
- package/dist/modules/dev/dev-server/dev-server-checker.js +72 -0
- package/dist/modules/dev/dev-server/dev-server.d.ts +68 -0
- package/dist/modules/dev/dev-server/dev-server.js +220 -0
- package/dist/modules/dev/dev-server/plugins/devtools.plugin.d.ts +10 -0
- package/dist/modules/dev/dev-server/plugins/devtools.plugin.js +50 -0
- package/dist/modules/dev/dev-server/plugins/favicon.plugin.d.ts +1 -0
- package/dist/modules/dev/dev-server/plugins/favicon.plugin.js +19 -0
- package/dist/modules/dev/dev-server/plugins/multipart.plugin.d.ts +1 -0
- package/dist/modules/dev/dev-server/plugins/multipart.plugin.js +62 -0
- package/dist/modules/dev/dev-server/plugins/symbolicate/index.d.ts +2 -0
- package/dist/modules/dev/dev-server/plugins/symbolicate/index.js +18 -0
- package/dist/modules/dev/dev-server/plugins/symbolicate/sybmolicatePlugin.d.ts +1 -0
- package/dist/modules/dev/dev-server/plugins/symbolicate/sybmolicatePlugin.js +24 -0
- package/dist/modules/dev/dev-server/plugins/symbolicate/types.d.ts +64 -0
- package/dist/modules/dev/dev-server/plugins/symbolicate/types.js +2 -0
- package/dist/modules/dev/dev-server/plugins/types.d.ts +11 -0
- package/dist/modules/dev/dev-server/plugins/types.js +2 -0
- package/dist/modules/dev/dev-server/plugins/wss/index.d.ts +3 -0
- package/dist/modules/dev/dev-server/plugins/wss/index.js +19 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-api.server.d.ts +32 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-api.server.js +61 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-debugger.server.d.ts +63 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-debugger.server.js +128 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-dev-client.server.d.ts +32 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-dev-client.server.js +75 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-events.server.d.ts +75 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-events.server.js +190 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-hmr.server.d.ts +44 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-hmr.server.js +112 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-message.server.d.ts +139 -0
- package/dist/modules/dev/dev-server/plugins/wss/servers/web-socket-message.server.js +352 -0
- package/dist/modules/dev/dev-server/plugins/wss/types.d.ts +6 -0
- package/dist/modules/dev/dev-server/plugins/wss/types.js +2 -0
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-router.d.ts +32 -0
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-router.js +59 -0
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-server-adapter.d.ts +13 -0
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-server-adapter.js +26 -0
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-server.d.ts +39 -0
- package/dist/modules/dev/dev-server/plugins/wss/web-socket-server.js +46 -0
- package/dist/modules/dev/dev-server/plugins/wss/wss.plugin.d.ts +46 -0
- package/dist/modules/dev/dev-server/plugins/wss/wss.plugin.js +57 -0
- package/dist/modules/dev/dev-server/types.d.ts +27 -0
- package/dist/modules/dev/dev-server/types.js +17 -0
- package/dist/modules/dev/terminal/base.terminal.reporter.d.ts +25 -0
- package/dist/modules/dev/terminal/base.terminal.reporter.js +78 -0
- package/dist/modules/dev/terminal/terminal.reporter.d.ts +12 -0
- package/dist/modules/dev/terminal/terminal.reporter.js +71 -0
- package/dist/modules/dev/types.d.ts +20 -0
- package/dist/modules/dev/types.js +2 -0
- package/dist/modules/dev/utils/log.d.ts +23 -0
- package/dist/modules/dev/utils/log.js +73 -0
- package/package.json +40 -17
- /package/dist/{init-teardown.d.ts → commands/init/init-teardown.d.ts} +0 -0
- /package/dist/{init-teardown.js → commands/init/init-teardown.js} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebSocketRouter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Class for creating a WebSocket router to forward connections to the
|
|
6
|
+
* respective {@link WebSocketServer} as long as the connection is accepted for the upgrade by the
|
|
7
|
+
* server.
|
|
8
|
+
*
|
|
9
|
+
* If the connection is not accepted by any `WebSocketServer`, it will be destroyed to avoid
|
|
10
|
+
* creating handling connections and potentially throwing `ECONNRESET` errors.
|
|
11
|
+
*
|
|
12
|
+
* @category Development server
|
|
13
|
+
*/
|
|
14
|
+
class WebSocketRouter {
|
|
15
|
+
fastify;
|
|
16
|
+
/** The list of all register WebSocket servers. */
|
|
17
|
+
servers = [];
|
|
18
|
+
/**
|
|
19
|
+
* Create new instance of `WebSocketRouter` and attach it to the given Fastify instance.
|
|
20
|
+
* Any logging information, will be passed through standard `fastify.log` API.
|
|
21
|
+
*
|
|
22
|
+
* @param fastify Fastify instance to attach the WebSocket router to.
|
|
23
|
+
*/
|
|
24
|
+
constructor(fastify) {
|
|
25
|
+
this.fastify = fastify;
|
|
26
|
+
this.fastify.server.on("upgrade", (request, socket, head) => {
|
|
27
|
+
// console.log("WebSocketRouter upgrade", request.url);
|
|
28
|
+
const { pathname } = new URL(request.url || "", "http://localhost");
|
|
29
|
+
let matched = false;
|
|
30
|
+
for (const server of this.servers) {
|
|
31
|
+
if (server.shouldUpgrade(pathname)) {
|
|
32
|
+
// console.log("WebSocketRouter upgrade matched", pathname);
|
|
33
|
+
matched = true;
|
|
34
|
+
server.upgrade(request, socket, head);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!matched) {
|
|
39
|
+
this.fastify.log.debug({
|
|
40
|
+
msg: "Destroying socket connection as no server was matched",
|
|
41
|
+
pathname,
|
|
42
|
+
});
|
|
43
|
+
socket.destroy();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Register a new {@link WebSocketServer}. New connection will now
|
|
49
|
+
* check if the given server will accept them and forward them.
|
|
50
|
+
*
|
|
51
|
+
* @param server WebSocket server to register.
|
|
52
|
+
* @returns The same instance of the WebSocket server after it's been registered.
|
|
53
|
+
*/
|
|
54
|
+
registerServer(server) {
|
|
55
|
+
this.servers.push(server);
|
|
56
|
+
return server;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.WebSocketRouter = WebSocketRouter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IncomingMessage } from "node:http";
|
|
2
|
+
import type { Socket } from "node:net";
|
|
3
|
+
import type { FastifyInstance } from "fastify";
|
|
4
|
+
import type { WebSocketServer } from "ws";
|
|
5
|
+
import type { WebSocketServerInterface } from "./types";
|
|
6
|
+
export declare class WebSocketServerAdapter implements WebSocketServerInterface {
|
|
7
|
+
private fastify;
|
|
8
|
+
private path;
|
|
9
|
+
private server?;
|
|
10
|
+
constructor(fastify: FastifyInstance, path: string, server?: WebSocketServer | undefined);
|
|
11
|
+
shouldUpgrade(pathname: string): boolean;
|
|
12
|
+
upgrade(request: IncomingMessage, socket: Socket, head: Buffer): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebSocketServerAdapter = void 0;
|
|
4
|
+
class WebSocketServerAdapter {
|
|
5
|
+
fastify;
|
|
6
|
+
path;
|
|
7
|
+
server;
|
|
8
|
+
constructor(fastify, path, server) {
|
|
9
|
+
this.fastify = fastify;
|
|
10
|
+
this.path = path;
|
|
11
|
+
this.server = server;
|
|
12
|
+
}
|
|
13
|
+
shouldUpgrade(pathname) {
|
|
14
|
+
if (!this.server) {
|
|
15
|
+
this.fastify.log.warn({ msg: `No handler active for ${this.path}` });
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return this.path === pathname;
|
|
19
|
+
}
|
|
20
|
+
upgrade(request, socket, head) {
|
|
21
|
+
this.server?.handleUpgrade(request, socket, head, (webSocket) => {
|
|
22
|
+
this.server?.emit("connection", webSocket, request);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.WebSocketServerAdapter = WebSocketServerAdapter;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { IncomingMessage } from "node:http";
|
|
2
|
+
import type { Socket } from "node:net";
|
|
3
|
+
import type { FastifyInstance } from "fastify";
|
|
4
|
+
import { type ServerOptions, type WebSocket, WebSocketServer as WebSocketServerImpl } from "ws";
|
|
5
|
+
import type { WebSocketServerInterface } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
/**
|
|
8
|
+
* Abstract class for providing common logic (eg routing) for all WebSocket servers.
|
|
9
|
+
*
|
|
10
|
+
* @category Development server
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class WebSocketServer implements WebSocketServerInterface {
|
|
13
|
+
/** An instance of the underlying WebSocket server. */
|
|
14
|
+
protected server: WebSocketServerImpl;
|
|
15
|
+
/** Fastify instance from which {@link server} will receive upgrade connections. */
|
|
16
|
+
protected fastify: FastifyInstance;
|
|
17
|
+
protected paths: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of the WebSocketServer.
|
|
20
|
+
* Any logging information, will be passed through standard `fastify.log` API.
|
|
21
|
+
*
|
|
22
|
+
* @param fastify Fastify instance to which the WebSocket will be attached to.
|
|
23
|
+
* @param path Path on which this WebSocketServer will be accepting connections.
|
|
24
|
+
* @param wssOptions WebSocket Server options.
|
|
25
|
+
*/
|
|
26
|
+
constructor(fastify: FastifyInstance, path: string | string[], wssOptions?: Omit<ServerOptions, "noServer" | "server" | "host" | "port" | "path">);
|
|
27
|
+
shouldUpgrade(pathname: string): boolean;
|
|
28
|
+
upgrade(request: IncomingMessage, socket: Socket, head: Buffer): void;
|
|
29
|
+
/**
|
|
30
|
+
* Process incoming WebSocket connection.
|
|
31
|
+
*
|
|
32
|
+
* @param socket Incoming WebSocket connection.
|
|
33
|
+
* @param request Upgrade request for the connection.
|
|
34
|
+
*/
|
|
35
|
+
abstract onConnection(socket: WebSocket, request: IncomingMessage): void;
|
|
36
|
+
onError(error: Error): void;
|
|
37
|
+
onMessage(message: string): void;
|
|
38
|
+
onClose(socket: WebSocket): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebSocketServer = void 0;
|
|
4
|
+
const ws_1 = require("ws");
|
|
5
|
+
/**
|
|
6
|
+
/**
|
|
7
|
+
* Abstract class for providing common logic (eg routing) for all WebSocket servers.
|
|
8
|
+
*
|
|
9
|
+
* @category Development server
|
|
10
|
+
*/
|
|
11
|
+
class WebSocketServer {
|
|
12
|
+
/** An instance of the underlying WebSocket server. */
|
|
13
|
+
server;
|
|
14
|
+
/** Fastify instance from which {@link server} will receive upgrade connections. */
|
|
15
|
+
fastify;
|
|
16
|
+
paths;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new instance of the WebSocketServer.
|
|
19
|
+
* Any logging information, will be passed through standard `fastify.log` API.
|
|
20
|
+
*
|
|
21
|
+
* @param fastify Fastify instance to which the WebSocket will be attached to.
|
|
22
|
+
* @param path Path on which this WebSocketServer will be accepting connections.
|
|
23
|
+
* @param wssOptions WebSocket Server options.
|
|
24
|
+
*/
|
|
25
|
+
constructor(fastify, path, wssOptions = {}) {
|
|
26
|
+
this.fastify = fastify;
|
|
27
|
+
this.server = new ws_1.WebSocketServer({ noServer: true, ...wssOptions });
|
|
28
|
+
this.server.on("connection", this.onConnection.bind(this));
|
|
29
|
+
this.server.on("error", this.onError.bind(this));
|
|
30
|
+
this.server.on("message", this.onMessage.bind(this));
|
|
31
|
+
this.server.on("close", this.onClose.bind(this));
|
|
32
|
+
this.paths = Array.isArray(path) ? path : [path];
|
|
33
|
+
}
|
|
34
|
+
shouldUpgrade(pathname) {
|
|
35
|
+
return this.paths.includes(pathname);
|
|
36
|
+
}
|
|
37
|
+
upgrade(request, socket, head) {
|
|
38
|
+
this.server.handleUpgrade(request, socket, head, (webSocket) => {
|
|
39
|
+
this.server.emit("connection", webSocket, request);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
onError(error) { }
|
|
43
|
+
onMessage(message) { }
|
|
44
|
+
onClose(socket) { }
|
|
45
|
+
}
|
|
46
|
+
exports.WebSocketServer = WebSocketServer;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ConfigT } from "metro-config";
|
|
2
|
+
import type MetroServer from "metro/src/Server";
|
|
3
|
+
import type { WebSocketServer } from "ws";
|
|
4
|
+
import { WebSocketApiServer } from "./servers/web-socket-api.server";
|
|
5
|
+
import { WebSocketDebuggerServer } from "./servers/web-socket-debugger.server";
|
|
6
|
+
import { WebSocketDevClientServer } from "./servers/web-socket-dev-client.server";
|
|
7
|
+
import type { WebSocketEventsServer } from "./servers/web-socket-events.server";
|
|
8
|
+
import { WebSocketHMRServer } from "./servers/web-socket-hmr.server";
|
|
9
|
+
import type { WebSocketMessageServer } from "./servers/web-socket-message.server";
|
|
10
|
+
import { WebSocketRouter } from "./web-socket-router";
|
|
11
|
+
import { WebSocketServerAdapter } from "./web-socket-server-adapter";
|
|
12
|
+
declare module "fastify" {
|
|
13
|
+
interface FastifyInstance {
|
|
14
|
+
wss: {
|
|
15
|
+
debuggerServer: WebSocketDebuggerServer;
|
|
16
|
+
devClientServer: WebSocketDevClientServer;
|
|
17
|
+
messageServer: WebSocketMessageServer;
|
|
18
|
+
eventsServer: WebSocketEventsServer;
|
|
19
|
+
apiServer: WebSocketApiServer;
|
|
20
|
+
hmrServer: WebSocketHMRServer;
|
|
21
|
+
deviceConnectionServer: WebSocketServerAdapter;
|
|
22
|
+
debuggerConnectionServer: WebSocketServerAdapter;
|
|
23
|
+
router: WebSocketRouter;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Defined in @react-native/dev-middleware
|
|
29
|
+
* Reference: https://github.com/facebook/react-native/blob/main/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js
|
|
30
|
+
*/
|
|
31
|
+
declare const WS_DEVICE_URL = "/inspector/device";
|
|
32
|
+
declare const WS_DEBUGGER_URL = "/inspector/debug";
|
|
33
|
+
declare const WS_NETWORK_URL = "/inspector/network";
|
|
34
|
+
export declare const wssPlugin: import("fastify").FastifyPluginCallback<{
|
|
35
|
+
metroConfig: ConfigT;
|
|
36
|
+
metroServer: MetroServer;
|
|
37
|
+
onClientConnected: (platform: string, clientId: string) => void;
|
|
38
|
+
messageServer: WebSocketMessageServer;
|
|
39
|
+
eventsServer: WebSocketEventsServer;
|
|
40
|
+
endpoints: {
|
|
41
|
+
[WS_DEVICE_URL]: WebSocketServer;
|
|
42
|
+
[WS_DEBUGGER_URL]: WebSocketServer;
|
|
43
|
+
[WS_NETWORK_URL]: WebSocketServer;
|
|
44
|
+
};
|
|
45
|
+
}, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.wssPlugin = void 0;
|
|
7
|
+
const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
|
|
8
|
+
const web_socket_api_server_1 = require("./servers/web-socket-api.server");
|
|
9
|
+
const web_socket_debugger_server_1 = require("./servers/web-socket-debugger.server");
|
|
10
|
+
const web_socket_dev_client_server_1 = require("./servers/web-socket-dev-client.server");
|
|
11
|
+
const web_socket_hmr_server_1 = require("./servers/web-socket-hmr.server");
|
|
12
|
+
const web_socket_router_1 = require("./web-socket-router");
|
|
13
|
+
const web_socket_server_adapter_1 = require("./web-socket-server-adapter");
|
|
14
|
+
/**
|
|
15
|
+
* Defined in @react-native/dev-middleware
|
|
16
|
+
* Reference: https://github.com/facebook/react-native/blob/main/packages/dev-middleware/src/inspector-proxy/InspectorProxy.js
|
|
17
|
+
*/
|
|
18
|
+
const WS_DEVICE_URL = "/inspector/device";
|
|
19
|
+
const WS_DEBUGGER_URL = "/inspector/debug";
|
|
20
|
+
const WS_NETWORK_URL = "/inspector/network";
|
|
21
|
+
exports.wssPlugin = (0, fastify_plugin_1.default)(async (instance, { metroConfig, metroServer, onClientConnected, endpoints, messageServer, eventsServer, }) => {
|
|
22
|
+
const router = new web_socket_router_1.WebSocketRouter(instance);
|
|
23
|
+
const debuggerServer = new web_socket_debugger_server_1.WebSocketDebuggerServer(instance);
|
|
24
|
+
const devClientServer = new web_socket_dev_client_server_1.WebSocketDevClientServer(instance);
|
|
25
|
+
const apiServer = new web_socket_api_server_1.WebSocketApiServer(instance);
|
|
26
|
+
const hmrServer = new web_socket_hmr_server_1.WebSocketHMRServer(instance, {
|
|
27
|
+
metroConfig,
|
|
28
|
+
metroServer,
|
|
29
|
+
onClientConnected,
|
|
30
|
+
});
|
|
31
|
+
// @react-native/dev-middleware servers
|
|
32
|
+
const deviceConnectionServer = new web_socket_server_adapter_1.WebSocketServerAdapter(instance, WS_DEVICE_URL, endpoints[WS_DEVICE_URL]);
|
|
33
|
+
const debuggerConnectionServer = new web_socket_server_adapter_1.WebSocketServerAdapter(instance, WS_DEBUGGER_URL, endpoints[WS_DEBUGGER_URL]);
|
|
34
|
+
const networkConnectionServer = new web_socket_server_adapter_1.WebSocketServerAdapter(instance, WS_NETWORK_URL, endpoints[WS_NETWORK_URL]);
|
|
35
|
+
router.registerServer(debuggerServer);
|
|
36
|
+
router.registerServer(devClientServer);
|
|
37
|
+
router.registerServer(messageServer);
|
|
38
|
+
router.registerServer(eventsServer);
|
|
39
|
+
router.registerServer(apiServer);
|
|
40
|
+
router.registerServer(hmrServer);
|
|
41
|
+
router.registerServer(deviceConnectionServer);
|
|
42
|
+
router.registerServer(debuggerConnectionServer);
|
|
43
|
+
router.registerServer(networkConnectionServer);
|
|
44
|
+
instance.decorate("wss", {
|
|
45
|
+
debuggerServer,
|
|
46
|
+
devClientServer,
|
|
47
|
+
messageServer,
|
|
48
|
+
eventsServer,
|
|
49
|
+
apiServer,
|
|
50
|
+
hmrServer,
|
|
51
|
+
deviceConnectionServer,
|
|
52
|
+
debuggerConnectionServer,
|
|
53
|
+
router,
|
|
54
|
+
});
|
|
55
|
+
}, {
|
|
56
|
+
name: "wss-plugin",
|
|
57
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type { SymbolicatorDelegate, ReactNativeStackFrame, InputStackFrame, StackFrame, CodeFrame, SymbolicatorResults, } from './plugins/symbolicate';
|
|
2
|
+
/** Representation of the compilation progress. */
|
|
3
|
+
export interface ProgressData {
|
|
4
|
+
/** Number of modules built. */
|
|
5
|
+
completed: number;
|
|
6
|
+
/** Total number of modules detect as part of compilation. */
|
|
7
|
+
total: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Type representing a function to send the progress.
|
|
11
|
+
*
|
|
12
|
+
* Used by {@link CompilerDelegate} in `getAsset` function to send the compilation
|
|
13
|
+
* progress to the client who requested the asset.
|
|
14
|
+
*/
|
|
15
|
+
export type SendProgress = (data: ProgressData) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Internal types. Do not use.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare namespace Internal {
|
|
22
|
+
enum EventTypes {
|
|
23
|
+
BuildStart = "BuildStart",
|
|
24
|
+
BuildEnd = "BuildEnd",
|
|
25
|
+
HmrEvent = "HmrEvent"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Internal = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Internal types. Do not use.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
var Internal;
|
|
10
|
+
(function (Internal) {
|
|
11
|
+
let EventTypes;
|
|
12
|
+
(function (EventTypes) {
|
|
13
|
+
EventTypes["BuildStart"] = "BuildStart";
|
|
14
|
+
EventTypes["BuildEnd"] = "BuildEnd";
|
|
15
|
+
EventTypes["HmrEvent"] = "HmrEvent";
|
|
16
|
+
})(EventTypes = Internal.EventTypes || (Internal.EventTypes = {}));
|
|
17
|
+
})(Internal || (exports.Internal = Internal = {}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TerminalReporter as MetroTerminalReporter } from "metro";
|
|
2
|
+
import type { TerminalReportableEvent } from "metro/src/lib/TerminalReporter";
|
|
3
|
+
export declare class BaseTerminalReporter extends MetroTerminalReporter {
|
|
4
|
+
update(event: TerminalReportableEvent): void;
|
|
5
|
+
_getElapsedTime(startTime: bigint): bigint;
|
|
6
|
+
_log(event: TerminalReportableEvent): void;
|
|
7
|
+
_logInitializing(port: number, hasReducedPerformance: boolean): void;
|
|
8
|
+
_logInitializingFailed(port: number, error: Error): void;
|
|
9
|
+
_logBundleBuildDone(buildID: string): void;
|
|
10
|
+
_logBundleBuildFailed(buildID: string): void;
|
|
11
|
+
_logBundlingError(error: Error): void;
|
|
12
|
+
_logWorkerChunk(origin: string, chunk: string): void;
|
|
13
|
+
_logHmrClientError(error: Error): void;
|
|
14
|
+
_logWarning(message: string): void;
|
|
15
|
+
_logWatcherHealthCheckResult(result: any): void;
|
|
16
|
+
_logWatcherStatus(status: any): void;
|
|
17
|
+
_getBundleStatusMessage(progress: any, phase: "done" | "failed" | "in_progress"): string;
|
|
18
|
+
_updateBundleProgress(data: {
|
|
19
|
+
buildID: string;
|
|
20
|
+
transformedFileCount: number;
|
|
21
|
+
totalFileCount: number;
|
|
22
|
+
}): void;
|
|
23
|
+
_updateState(event: TerminalReportableEvent): void;
|
|
24
|
+
_getStatusMessage(): string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseTerminalReporter = void 0;
|
|
4
|
+
const metro_1 = require("metro");
|
|
5
|
+
class BaseTerminalReporter extends metro_1.TerminalReporter {
|
|
6
|
+
// constructor(terminal: Terminal) {
|
|
7
|
+
// super(terminal);
|
|
8
|
+
// }
|
|
9
|
+
update(event) {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
super.update(event);
|
|
12
|
+
}
|
|
13
|
+
_getElapsedTime(startTime) {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
return super._getElapsedTime(startTime);
|
|
16
|
+
}
|
|
17
|
+
_log(event) {
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
super._log(event);
|
|
20
|
+
}
|
|
21
|
+
_logInitializing(port, hasReducedPerformance) {
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
super._logInitializing(port, hasReducedPerformance);
|
|
24
|
+
}
|
|
25
|
+
_logInitializingFailed(port, error) {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
super._logInitializingFailed(port, error);
|
|
28
|
+
}
|
|
29
|
+
_logBundleBuildDone(buildID) {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
super._logBundleBuildDone(buildID);
|
|
32
|
+
}
|
|
33
|
+
_logBundleBuildFailed(buildID) {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
super._logBundleBuildFailed(buildID);
|
|
36
|
+
}
|
|
37
|
+
_logBundlingError(error) {
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
super._logBundlingError(error);
|
|
40
|
+
}
|
|
41
|
+
_logWorkerChunk(origin, chunk) {
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
super._logWorkerChunk(origin, chunk);
|
|
44
|
+
}
|
|
45
|
+
_logHmrClientError(error) {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
super._logHmrClientError(error);
|
|
48
|
+
}
|
|
49
|
+
_logWarning(message) {
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
super._logWarning(message);
|
|
52
|
+
}
|
|
53
|
+
_logWatcherHealthCheckResult(result) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
super._logWatcherHealthCheckResult(result);
|
|
56
|
+
}
|
|
57
|
+
_logWatcherStatus(status) {
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
super._logWatcherStatus(status);
|
|
60
|
+
}
|
|
61
|
+
_getBundleStatusMessage(progress, phase) {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
return super._getBundleStatusMessage(progress, phase);
|
|
64
|
+
}
|
|
65
|
+
_updateBundleProgress(data) {
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
super._updateBundleProgress(data);
|
|
68
|
+
}
|
|
69
|
+
_updateState(event) {
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
super._updateState(event);
|
|
72
|
+
}
|
|
73
|
+
_getStatusMessage() {
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
return super._getStatusMessage();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.BaseTerminalReporter = BaseTerminalReporter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TerminalReportableEvent } from "metro/src/lib/TerminalReporter";
|
|
2
|
+
import type { DevServer } from "../dev-server/dev-server";
|
|
3
|
+
import { BaseTerminalReporter } from "./base.terminal.reporter";
|
|
4
|
+
export declare class TeardownTerminalReporter extends BaseTerminalReporter {
|
|
5
|
+
readonly devServer: DevServer;
|
|
6
|
+
constructor(devServer: DevServer);
|
|
7
|
+
_log(event: TerminalReportableEvent): void;
|
|
8
|
+
_logInitializing(port: number, hasReducedPerformance: boolean): void;
|
|
9
|
+
dependencyGraphLoading(hasReducedPerformance: boolean): void;
|
|
10
|
+
_logWorkerChunk(origin: "stdout" | "stderr", chunk: string): void;
|
|
11
|
+
update(event: TerminalReportableEvent): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TeardownTerminalReporter = void 0;
|
|
7
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
8
|
+
const metro_core_1 = require("metro-core");
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const base_terminal_reporter_1 = require("./base.terminal.reporter");
|
|
12
|
+
class LogRespectingTerminal extends metro_core_1.Terminal {
|
|
13
|
+
constructor(stream) {
|
|
14
|
+
super(stream);
|
|
15
|
+
const sendLog = (...args) => {
|
|
16
|
+
// @ts-expect-error
|
|
17
|
+
this._logLines.push(
|
|
18
|
+
// format args like console.log
|
|
19
|
+
node_util_1.default.format(...args));
|
|
20
|
+
// @ts-expect-error
|
|
21
|
+
this._scheduleUpdate();
|
|
22
|
+
// Flush the logs to the terminal immediately so logs at the end of the process are not lost.
|
|
23
|
+
this.flush();
|
|
24
|
+
};
|
|
25
|
+
console.log = sendLog;
|
|
26
|
+
console.info = sendLog;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const terminal = new LogRespectingTerminal(process.stdout);
|
|
30
|
+
class TeardownTerminalReporter extends base_terminal_reporter_1.BaseTerminalReporter {
|
|
31
|
+
devServer;
|
|
32
|
+
constructor(devServer) {
|
|
33
|
+
super(terminal);
|
|
34
|
+
this.devServer = devServer;
|
|
35
|
+
}
|
|
36
|
+
_log(event) {
|
|
37
|
+
switch (event.type) {
|
|
38
|
+
// Handle specific cases if needed
|
|
39
|
+
case "dep_graph_loading":
|
|
40
|
+
this.dependencyGraphLoading(event.hasReducedPerformance);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
super._log(event);
|
|
44
|
+
}
|
|
45
|
+
_logInitializing(port, hasReducedPerformance) {
|
|
46
|
+
this.terminal.log(chalk_1.default.dim("Starting Bundler on port"), chalk_1.default.dim(`${port}`));
|
|
47
|
+
}
|
|
48
|
+
dependencyGraphLoading(hasReducedPerformance) {
|
|
49
|
+
this.terminal.log(chalk_1.default.dim("Loading dependency graph"), chalk_1.default.dim(`${hasReducedPerformance ? "with reduced performance" : ""}`));
|
|
50
|
+
}
|
|
51
|
+
_logWorkerChunk(origin, chunk) {
|
|
52
|
+
const lines = chunk.split("\n");
|
|
53
|
+
if (lines.length >= 1 && lines[lines.length - 1] === "") {
|
|
54
|
+
lines.splice(lines.length - 1, 1);
|
|
55
|
+
}
|
|
56
|
+
const originTag = origin === "stdout" ? chalk_1.default.dim("|") : chalk_1.default.yellow("|");
|
|
57
|
+
lines.forEach((line) => {
|
|
58
|
+
this.terminal.log(originTag, line);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
update(event) {
|
|
62
|
+
super.update(event);
|
|
63
|
+
this.devServer?.reportMetroEvent(event);
|
|
64
|
+
switch (event.type) {
|
|
65
|
+
case "initialize_done":
|
|
66
|
+
this.devServer.onInitializeDone?.();
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.TeardownTerminalReporter = TeardownTerminalReporter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CustomMessageHandlerConnection } from '@react-native/dev-middleware';
|
|
2
|
+
export type Connection = CustomMessageHandlerConnection;
|
|
3
|
+
export type DeviceMetadata = Connection['device'];
|
|
4
|
+
export type DebuggerMetadata = Connection['debugger'];
|
|
5
|
+
export type Page = Connection['page'];
|
|
6
|
+
export type TargetCapabilityFlags = Page['capabilities'];
|
|
7
|
+
/**
|
|
8
|
+
* The outline of a basic Chrome DevTools Protocol request, either from device or debugger.
|
|
9
|
+
* Both the request and response parameters could be optional, use `never` to enforce these fields.
|
|
10
|
+
*/
|
|
11
|
+
export type CdpMessage<Method extends string = string, Request extends object = object, Response extends object = object> = {
|
|
12
|
+
id: number;
|
|
13
|
+
method: Method;
|
|
14
|
+
params: Request;
|
|
15
|
+
result: Response;
|
|
16
|
+
};
|
|
17
|
+
export type DeviceRequest<M extends CdpMessage = CdpMessage> = Pick<M, 'method' | 'params'>;
|
|
18
|
+
export type DeviceResponse<M extends CdpMessage = CdpMessage> = Pick<M, 'id' | 'result'>;
|
|
19
|
+
export type DebuggerRequest<M extends CdpMessage = CdpMessage> = Pick<M, 'id' | 'method' | 'params'>;
|
|
20
|
+
export type DebuggerResponse<M extends CdpMessage = CdpMessage> = Pick<M, 'result'>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function time(label?: string): void;
|
|
2
|
+
export declare function timeEnd(label?: string): void;
|
|
3
|
+
export declare function error(...message: string[]): void;
|
|
4
|
+
/** Print an error and provide additional info (the stack trace) in debug mode. */
|
|
5
|
+
export declare function exception(e: Error): void;
|
|
6
|
+
export declare function warn(...message: string[]): void;
|
|
7
|
+
export declare function log(...message: string[]): void;
|
|
8
|
+
export declare function debug(...message: any[]): void;
|
|
9
|
+
/** Clear the terminal of all text. */
|
|
10
|
+
export declare function clear(): void;
|
|
11
|
+
/** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */
|
|
12
|
+
export declare function exit(message: string | Error, code?: number): never;
|
|
13
|
+
export declare const Log: {
|
|
14
|
+
time: typeof time;
|
|
15
|
+
timeEnd: typeof timeEnd;
|
|
16
|
+
error: typeof error;
|
|
17
|
+
exception: typeof exception;
|
|
18
|
+
warn: typeof warn;
|
|
19
|
+
log: typeof log;
|
|
20
|
+
debug: typeof debug;
|
|
21
|
+
clear: typeof clear;
|
|
22
|
+
exit: typeof exit;
|
|
23
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Log = void 0;
|
|
7
|
+
exports.time = time;
|
|
8
|
+
exports.timeEnd = timeEnd;
|
|
9
|
+
exports.error = error;
|
|
10
|
+
exports.exception = exception;
|
|
11
|
+
exports.warn = warn;
|
|
12
|
+
exports.log = log;
|
|
13
|
+
exports.debug = debug;
|
|
14
|
+
exports.clear = clear;
|
|
15
|
+
exports.exit = exit;
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
function time(label) {
|
|
19
|
+
console.time(label);
|
|
20
|
+
}
|
|
21
|
+
function timeEnd(label) {
|
|
22
|
+
console.timeEnd(label);
|
|
23
|
+
}
|
|
24
|
+
function error(...message) {
|
|
25
|
+
console.error(...message);
|
|
26
|
+
}
|
|
27
|
+
/** Print an error and provide additional info (the stack trace) in debug mode. */
|
|
28
|
+
function exception(e) {
|
|
29
|
+
const { env } = require('./utils/env');
|
|
30
|
+
error(chalk_1.default.red(e.toString()) + (env.EXPO_DEBUG ? `\n${chalk_1.default.gray(e.stack)}` : ''));
|
|
31
|
+
}
|
|
32
|
+
function warn(...message) {
|
|
33
|
+
console.warn(...message.map((value) => chalk_1.default.yellow(value)));
|
|
34
|
+
}
|
|
35
|
+
function log(...message) {
|
|
36
|
+
console.log(...message);
|
|
37
|
+
}
|
|
38
|
+
function debug(...message) {
|
|
39
|
+
const debug = require('debug')('teardown');
|
|
40
|
+
debug(...message);
|
|
41
|
+
}
|
|
42
|
+
/** Clear the terminal of all text. */
|
|
43
|
+
function clear() {
|
|
44
|
+
process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
|
|
45
|
+
}
|
|
46
|
+
/** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */
|
|
47
|
+
function exit(message, code = 1) {
|
|
48
|
+
if (message instanceof Error) {
|
|
49
|
+
exception(message);
|
|
50
|
+
process.exit(code);
|
|
51
|
+
}
|
|
52
|
+
if (message) {
|
|
53
|
+
if (code === 0) {
|
|
54
|
+
log(message);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
error(message);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
process.exit(code);
|
|
61
|
+
}
|
|
62
|
+
// The re-export makes auto importing easier.
|
|
63
|
+
exports.Log = {
|
|
64
|
+
time,
|
|
65
|
+
timeEnd,
|
|
66
|
+
error,
|
|
67
|
+
exception,
|
|
68
|
+
warn,
|
|
69
|
+
log,
|
|
70
|
+
debug,
|
|
71
|
+
clear,
|
|
72
|
+
exit,
|
|
73
|
+
};
|