@teardown/react-native 1.2.15 → 1.2.21
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/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +0 -15
- package/dist/components/teardown-logo.d.ts +4 -0
- package/dist/containers/index.d.ts +1 -0
- package/dist/containers/teardown.container.d.ts +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/plugins/http.plugin.d.ts +23 -0
- package/dist/plugins/http.plugin.js +3 -3
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/logging.plugin.d.ts +9 -0
- package/dist/plugins/logging.plugin.js +4 -4
- package/dist/plugins/websocket.plugin.d.ts +1 -0
- package/dist/plugins/websocket.plugin.js +105 -100
- package/dist/services/index.d.ts +1 -0
- package/dist/services/teardown.service.d.ts +10 -0
- package/dist/teardown.client.d.ts +41 -0
- package/dist/teardown.client.js +3 -9
- package/dist/utils/log.d.ts +5 -0
- package/dist/utils/log.js +8 -0
- package/package.json +21 -12
- package/dist/components/debugger-ui.js +0 -147
- package/dist/debugger.js +0 -75
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/components/index.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./debugger-ui"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './teardown.container';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent, PropsWithChildren } from "react";
|
|
2
|
+
import type { PluginTuple, TeardownClient } from "../teardown.client";
|
|
3
|
+
export type TeardownContainerOptions = {};
|
|
4
|
+
export type TeardownContainerProps<T extends readonly PluginTuple[]> = PropsWithChildren<{
|
|
5
|
+
client: TeardownClient<T>;
|
|
6
|
+
options?: TeardownContainerOptions;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const TeardownContainer: FunctionComponent<TeardownContainerProps<any>>;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -17,5 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
// export * from './components';
|
|
18
18
|
__exportStar(require("./containers"), exports);
|
|
19
19
|
// export * from './services';
|
|
20
|
-
|
|
20
|
+
// export * from "./teardown.client";
|
|
21
21
|
__exportStar(require("./plugins"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TeardownClient } from "../teardown.client";
|
|
2
|
+
import { type DefaultPluginOptions, Plugin } from "../teardown.client";
|
|
3
|
+
export type HTTPPluginOptions = DefaultPluginOptions<{
|
|
4
|
+
ignoreURLs?: RegExp[];
|
|
5
|
+
}>;
|
|
6
|
+
export declare class HTTPPlugin extends Plugin {
|
|
7
|
+
private client;
|
|
8
|
+
private requests;
|
|
9
|
+
private ignoreURLs;
|
|
10
|
+
constructor(options?: HTTPPluginOptions);
|
|
11
|
+
install(client: TeardownClient<any>): void;
|
|
12
|
+
enableXHRInterceptor(): void;
|
|
13
|
+
disableInterception(): void;
|
|
14
|
+
private shouldIgnoreURL;
|
|
15
|
+
private xhrOpenCallback;
|
|
16
|
+
private xhrRequestHeaderCallback;
|
|
17
|
+
private xhrSendCallback;
|
|
18
|
+
private serializeRequestBody;
|
|
19
|
+
private xhrResponseCallback;
|
|
20
|
+
private parseResponseHeaders;
|
|
21
|
+
private parseResponseBody;
|
|
22
|
+
private sendHTTPEvent;
|
|
23
|
+
}
|
|
@@ -136,9 +136,9 @@ class HTTPPlugin extends teardown_client_1.Plugin {
|
|
|
136
136
|
return response;
|
|
137
137
|
}
|
|
138
138
|
sendHTTPEvent(httpRequestInfo) {
|
|
139
|
-
if (this.client?.debugger) {
|
|
140
|
-
|
|
141
|
-
}
|
|
139
|
+
// if (this.client?.debugger) {
|
|
140
|
+
// this.client.debugger.send("NETWORK_HTTP_REQUEST", httpRequestInfo);
|
|
141
|
+
// }
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
exports.HTTPPlugin = HTTPPlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IPlugin, TeardownClient } from "../teardown.client";
|
|
2
|
+
export declare class LoggingPlugin implements IPlugin {
|
|
3
|
+
private client;
|
|
4
|
+
private originalConsoleMethods;
|
|
5
|
+
private createConsoleProxy;
|
|
6
|
+
constructor();
|
|
7
|
+
install(client: TeardownClient<any>): void;
|
|
8
|
+
uninstall(): void;
|
|
9
|
+
}
|
|
@@ -10,10 +10,10 @@ class LoggingPlugin {
|
|
|
10
10
|
return new Proxy(original, {
|
|
11
11
|
apply: (target, thisArg, args) => {
|
|
12
12
|
target.apply(thisArg, args);
|
|
13
|
-
this.client?.debugger?.send("CONSOLE_LOG", {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
13
|
+
// this.client?.debugger?.send("CONSOLE_LOG", {
|
|
14
|
+
// type: method,
|
|
15
|
+
// args,
|
|
16
|
+
// });
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,102 +1,107 @@
|
|
|
1
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.WebSocketPlugin = void 0;
|
|
7
2
|
// @ts-ignore
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
// export class WebSocketPlugin implements IPlugin {
|
|
5
|
+
// private logger = new Logger("WebSocketPlugin");
|
|
6
|
+
// private client: TeardownClient<any> | null = null;
|
|
7
|
+
// private sockets: Map<string, WebSocketInfo> = new Map();
|
|
8
|
+
// constructor() {
|
|
9
|
+
// this.setupWebSocketInterceptor();
|
|
10
|
+
// }
|
|
11
|
+
// install(client: TeardownClient<any>): void {
|
|
12
|
+
// this.client = client;
|
|
13
|
+
// }
|
|
14
|
+
// private setupWebSocketInterceptor(): void {
|
|
15
|
+
// if (WebSocketInterceptor.isInterceptorEnabled()) {
|
|
16
|
+
// this.logger.warn(
|
|
17
|
+
// "WebSocketInterceptor is already enabled by another library, disable it or run this first when your app loads",
|
|
18
|
+
// );
|
|
19
|
+
// this.disableInterception();
|
|
20
|
+
// }
|
|
21
|
+
// WebSocketInterceptor.setConnectCallback(this.wsConnectCallback);
|
|
22
|
+
// WebSocketInterceptor.setSendCallback(this.wsSendCallback);
|
|
23
|
+
// WebSocketInterceptor.setOnMessageCallback(this.wsOnMessageCallback);
|
|
24
|
+
// WebSocketInterceptor.setOnCloseCallback(this.wsOnCloseCallback);
|
|
25
|
+
// WebSocketInterceptor.enableInterception();
|
|
26
|
+
// this.logger.log("WebSocketInterceptor enabled");
|
|
27
|
+
// }
|
|
28
|
+
// private wsConnectCallback = (
|
|
29
|
+
// url: string,
|
|
30
|
+
// protocols: string | string[] | undefined,
|
|
31
|
+
// options: Object,
|
|
32
|
+
// socketId: string,
|
|
33
|
+
// ): void => {
|
|
34
|
+
// const requestId = Util.generateUUID();
|
|
35
|
+
// const socketInfo: WebSocketInfo = {
|
|
36
|
+
// id: requestId,
|
|
37
|
+
// url,
|
|
38
|
+
// protocols,
|
|
39
|
+
// timestamp: performance.now(),
|
|
40
|
+
// };
|
|
41
|
+
// this.sockets.set(socketId, socketInfo);
|
|
42
|
+
// this.sendOpenEvent(socketInfo);
|
|
43
|
+
// };
|
|
44
|
+
// private wsSendCallback = (
|
|
45
|
+
// data: string | ArrayBuffer | ArrayBufferView,
|
|
46
|
+
// socketId: string,
|
|
47
|
+
// ): void => {
|
|
48
|
+
// const socket = this.sockets.get(socketId);
|
|
49
|
+
// if (socket) {
|
|
50
|
+
// const messageInfo: WebSocketMessageInfo = {
|
|
51
|
+
// id: socket.id,
|
|
52
|
+
// data: "", // TODO: Currently getting array buffer length errors here when sending data
|
|
53
|
+
// timestamp: performance.now(),
|
|
54
|
+
// direction: "sent",
|
|
55
|
+
// };
|
|
56
|
+
// console.log("messageInfo", messageInfo);
|
|
57
|
+
// // this.sendMessageEvent(messageInfo);
|
|
58
|
+
// }
|
|
59
|
+
// };
|
|
60
|
+
// private wsOnMessageCallback = (
|
|
61
|
+
// socketId: string,
|
|
62
|
+
// message: WebSocketMessageEvent,
|
|
63
|
+
// ): void => {
|
|
64
|
+
// const socket = this.sockets.get(socketId);
|
|
65
|
+
// if (socket) {
|
|
66
|
+
// const messageInfo: WebSocketMessageInfo = {
|
|
67
|
+
// id: socket.id,
|
|
68
|
+
// data: "", // TODO: Currently getting array buffer length errors here when sending data
|
|
69
|
+
// timestamp: performance.now(),
|
|
70
|
+
// direction: "received",
|
|
71
|
+
// };
|
|
72
|
+
// this.sendMessageEvent(messageInfo);
|
|
73
|
+
// }
|
|
74
|
+
// };
|
|
75
|
+
// private wsOnCloseCallback = (socketId: string, event: any): void => {
|
|
76
|
+
// const socket = this.sockets.get(socketId);
|
|
77
|
+
// if (socket) {
|
|
78
|
+
// const closeInfo: WebSocketCloseInfo = {
|
|
79
|
+
// id: socket.id,
|
|
80
|
+
// code: event.code,
|
|
81
|
+
// reason: event.reason,
|
|
82
|
+
// timestamp: performance.now(),
|
|
83
|
+
// };
|
|
84
|
+
// this.sendCloseEvent(closeInfo);
|
|
85
|
+
// this.sockets.delete(socketId);
|
|
86
|
+
// }
|
|
87
|
+
// };
|
|
88
|
+
// private sendOpenEvent(info: WebSocketInfo): void {
|
|
89
|
+
// // if (this.client && this.client.debugger) {
|
|
90
|
+
// // this.client.debugger.send("NETWORK_WEBSOCKET_OPEN", info);
|
|
91
|
+
// // }
|
|
92
|
+
// }
|
|
93
|
+
// private sendMessageEvent(info: WebSocketMessageInfo): void {
|
|
94
|
+
// // if (this.client && this.client.debugger) {
|
|
95
|
+
// // this.client.debugger.send("NETWORK_WEBSOCKET_MESSAGE", info);
|
|
96
|
+
// // }
|
|
97
|
+
// }
|
|
98
|
+
// private sendCloseEvent(info: WebSocketCloseInfo): void {
|
|
99
|
+
// // if (this.client && this.client.debugger) {
|
|
100
|
+
// // this.client.debugger.send("NETWORK_WEBSOCKET_CLOSE", info);
|
|
101
|
+
// // }
|
|
102
|
+
// }
|
|
103
|
+
// disableInterception(): void {
|
|
104
|
+
// WebSocketInterceptor.disableInterception();
|
|
105
|
+
// this.sockets.clear();
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './teardown.service';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PluginTuple, TeardownClient } from "../teardown.client";
|
|
2
|
+
export type TeardownServiceContextType<T extends readonly PluginTuple[]> = {
|
|
3
|
+
client: TeardownClient<T>;
|
|
4
|
+
};
|
|
5
|
+
export declare const TeardownService: {
|
|
6
|
+
Context: import("react").Context<TeardownServiceContextType<any> | null>;
|
|
7
|
+
Provider: import("react").Provider<TeardownServiceContextType<any> | null>;
|
|
8
|
+
useState<T extends readonly PluginTuple[]>(): TeardownServiceContextType<T>;
|
|
9
|
+
useProvidedState<T extends readonly PluginTuple[]>(client: TeardownClient<T>): TeardownServiceContextType<T>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Logger } from "@teardown/logger";
|
|
2
|
+
export interface IPlugin {
|
|
3
|
+
install?(client: TeardownClient<any>): void;
|
|
4
|
+
uninstall?(): void;
|
|
5
|
+
}
|
|
6
|
+
export type DefaultPluginOptions<T> = {
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
} & T;
|
|
9
|
+
export type PluginOptions<T> = DefaultPluginOptions<{
|
|
10
|
+
key: string;
|
|
11
|
+
}> & T;
|
|
12
|
+
export declare abstract class Plugin<T = any> {
|
|
13
|
+
protected logger: Logger;
|
|
14
|
+
protected constructor(options: PluginOptions<T>);
|
|
15
|
+
install?(client: TeardownClient<any>): void;
|
|
16
|
+
uninstall?(): void;
|
|
17
|
+
}
|
|
18
|
+
export type PluginTuple = readonly [string, IPlugin];
|
|
19
|
+
type InferPluginFromTuple<T extends PluginTuple> = {
|
|
20
|
+
[K in T[0]]: Omit<T[1], "install" | "uninstall">;
|
|
21
|
+
};
|
|
22
|
+
type InferPluginsFromArray<T extends readonly PluginTuple[]> = UnionToIntersection<InferPluginFromTuple<T[number]>>;
|
|
23
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
24
|
+
export type TeardownClientOptions<T extends readonly PluginTuple[]> = {
|
|
25
|
+
plugins?: T;
|
|
26
|
+
loggingEnabled?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare class TeardownClient<T extends readonly PluginTuple[]> {
|
|
29
|
+
readonly options?: TeardownClientOptions<T> | undefined;
|
|
30
|
+
logger: Logger;
|
|
31
|
+
private readonly plugins;
|
|
32
|
+
api: InferPluginsFromArray<T>;
|
|
33
|
+
constructor(options?: TeardownClientOptions<T> | undefined);
|
|
34
|
+
private installPlugin;
|
|
35
|
+
private uninstallPlugin;
|
|
36
|
+
private uninstallAllPlugins;
|
|
37
|
+
private reinstallPlugins;
|
|
38
|
+
shutdown(): void;
|
|
39
|
+
}
|
|
40
|
+
export declare const createTeardownClient: <Plugins extends readonly PluginTuple[]>(plugins: Plugins) => TeardownClient<Plugins>;
|
|
41
|
+
export {};
|
package/dist/teardown.client.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTeardownClient = exports.TeardownClient = exports.Plugin = void 0;
|
|
4
4
|
const logger_1 = require("@teardown/logger");
|
|
5
|
-
const debugger_1 = require("./debugger");
|
|
6
5
|
class Plugin {
|
|
7
6
|
logger;
|
|
8
7
|
constructor(options) {
|
|
@@ -13,17 +12,14 @@ exports.Plugin = Plugin;
|
|
|
13
12
|
class TeardownClient {
|
|
14
13
|
options;
|
|
15
14
|
logger;
|
|
16
|
-
debugger;
|
|
17
15
|
plugins = new Map();
|
|
18
16
|
api = {};
|
|
19
17
|
constructor(options) {
|
|
20
18
|
this.options = options;
|
|
21
19
|
this.logger = new logger_1.Logger("TeardownClient", options?.loggingEnabled ?? false);
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
this.plugins.set(key, plugin);
|
|
26
|
-
});
|
|
20
|
+
// options?.plugins?.forEach(([key, plugin]) => {
|
|
21
|
+
// this.plugins.set(key, plugin);
|
|
22
|
+
// });
|
|
27
23
|
this.installPlugin();
|
|
28
24
|
}
|
|
29
25
|
installPlugin() {
|
|
@@ -51,14 +47,12 @@ class TeardownClient {
|
|
|
51
47
|
}
|
|
52
48
|
shutdown() {
|
|
53
49
|
this.uninstallAllPlugins();
|
|
54
|
-
this.debugger?.shutdown();
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
52
|
exports.TeardownClient = TeardownClient;
|
|
58
53
|
const createTeardownClient = (plugins) => {
|
|
59
54
|
return new TeardownClient({
|
|
60
55
|
loggingEnabled: true,
|
|
61
|
-
debuggerEnabled: true,
|
|
62
56
|
plugins,
|
|
63
57
|
});
|
|
64
58
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teardown/react-native",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.21",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
|
-
"build": "tsc",
|
|
8
|
-
"dev": "tsc --
|
|
7
|
+
"build": "tsc ",
|
|
8
|
+
"dev": "tsc --watch"
|
|
9
9
|
},
|
|
10
10
|
"main": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
@@ -14,27 +14,36 @@
|
|
|
14
14
|
"dist/**/*"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@teardown/
|
|
19
|
-
"@teardown/
|
|
17
|
+
"@react-native/dev-middleware": "^0.76.1",
|
|
18
|
+
"@teardown/cli": "^1.2.20",
|
|
19
|
+
"@teardown/logger": "1.2.21",
|
|
20
|
+
"@teardown/util": "1.2.21",
|
|
21
|
+
"@teardown/websocket": "1.2.21",
|
|
22
|
+
"async-mutex": "^0.5.0",
|
|
23
|
+
"chalk": "^5.3.0",
|
|
24
|
+
"compression": "^1.7.5",
|
|
25
|
+
"connect": "^3.7.0",
|
|
26
|
+
"debug": "^4.3.7",
|
|
27
|
+
"pretty-format": "^29.7.0",
|
|
28
|
+
"ws": "^8.18.0"
|
|
20
29
|
},
|
|
21
30
|
"devDependencies": {
|
|
22
|
-
"@teardown/config": "1.2.
|
|
23
|
-
"@
|
|
24
|
-
"@types/
|
|
31
|
+
"@teardown/config": "1.2.21",
|
|
32
|
+
"@types/compression": "^1.7.5",
|
|
33
|
+
"@types/connect": "^3.4.38",
|
|
34
|
+
"@types/react": "^18.3.12",
|
|
25
35
|
"@types/react-native": "^0.73.0",
|
|
26
36
|
"metro-config": "^0.81.0",
|
|
27
37
|
"react": "^18.3.1",
|
|
28
38
|
"react-native": "^0.75.4",
|
|
29
39
|
"react-native-device-info": "^14.0.0",
|
|
30
|
-
"react-native-gesture-handler": "^2.20.
|
|
40
|
+
"react-native-gesture-handler": "^2.20.2",
|
|
31
41
|
"typescript": "^5.6.3"
|
|
32
42
|
},
|
|
33
43
|
"peerDependencies": {
|
|
34
44
|
"react": "^18",
|
|
35
45
|
"react-native": "^0.75",
|
|
36
46
|
"react-native-device-info": "^14",
|
|
37
|
-
"react-native-gesture-handler": "^2"
|
|
38
|
-
"@teardown/react-native-ui": "^1"
|
|
47
|
+
"react-native-gesture-handler": "^2"
|
|
39
48
|
}
|
|
40
49
|
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DebuggerUi = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const react_native_1 = require("react-native");
|
|
7
|
-
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
8
|
-
const teardown_logo_1 = require("./teardown-logo");
|
|
9
|
-
const react_native_gesture_handler_1 = require("react-native-gesture-handler");
|
|
10
|
-
const react_native_ui_1 = require("@teardown/react-native-ui");
|
|
11
|
-
const teardown_service_1 = require("../services/teardown.service");
|
|
12
|
-
const DebuggerUi = props => {
|
|
13
|
-
const { enabled = true } = props;
|
|
14
|
-
return null;
|
|
15
|
-
if (!__DEV__) {
|
|
16
|
-
// never render the debugger ui in any mode apart from __DEV__ == true "development"
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const isNotEnabled = !enabled;
|
|
20
|
-
if (isNotEnabled) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return (0, jsx_runtime_1.jsx)(DebuggerUiEnabled, { ...props });
|
|
24
|
-
};
|
|
25
|
-
exports.DebuggerUi = DebuggerUi;
|
|
26
|
-
const DebuggerUiEnabled = props => {
|
|
27
|
-
const { position } = props;
|
|
28
|
-
const safeAreaInsets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
|
|
29
|
-
const bottomSheetRef = (0, react_1.useRef)(null);
|
|
30
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.container, pointerEvents: 'box-none', children: (0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.GestureHandlerRootView, { children: (0, jsx_runtime_1.jsxs)(react_native_ui_1.BottomSheetModalProvider, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onPress: () => {
|
|
31
|
-
// bottomSheetRef.current?.snapToIndex(0);
|
|
32
|
-
}, style: [
|
|
33
|
-
styles.orb,
|
|
34
|
-
getOrbPosition(safeAreaInsets, position ?? 'center-right'),
|
|
35
|
-
], children: (0, jsx_runtime_1.jsx)(teardown_logo_1.TeardownLogo, { height: 20, width: 20 }) }), (0, jsx_runtime_1.jsxs)(react_native_ui_1.BottomSheet, { sheetRef: bottomSheetRef, handleComponent: handleProps => ((0, jsx_runtime_1.jsx)(DebuggerStatusHandleComponent, { ...handleProps })), children: [(0, jsx_runtime_1.jsx)(react_native_ui_1.BottomSheetCloseIcon, {}), (0, jsx_runtime_1.jsxs)(react_native_ui_1.BottomSheetView, { style: {
|
|
36
|
-
paddingBottom: safeAreaInsets.bottom + 16,
|
|
37
|
-
}, children: [(0, jsx_runtime_1.jsx)(react_native_ui_1.BottomSheetHeader, { children: (0, jsx_runtime_1.jsx)(react_native_ui_1.BottomSheetTitle, { children: "Debugger" }) }), (0, jsx_runtime_1.jsx)(react_native_ui_1.BottomSheetContent, { children: (0, jsx_runtime_1.jsx)(react_native_ui_1.Button, { onPress: () => {
|
|
38
|
-
react_native_1.DevSettings.reload('Teardown reconnect');
|
|
39
|
-
}, children: "Reconnect debugger" }) })] })] })] }) }) }) }));
|
|
40
|
-
};
|
|
41
|
-
const DebuggerStatusHandleComponent = () => {
|
|
42
|
-
const { client } = teardown_service_1.TeardownService.useState();
|
|
43
|
-
const [debuggerStatus, setDebuggerStatus] = (0, react_1.useState)(client.debugger?.getStatus() ?? null);
|
|
44
|
-
(0, react_1.useEffect)(() => {
|
|
45
|
-
const listener = client.debugger?.emitter.on("CONNECTION_STATUS_CHANGED", (event) => {
|
|
46
|
-
const { payload } = event;
|
|
47
|
-
setDebuggerStatus(event.payload.status);
|
|
48
|
-
});
|
|
49
|
-
return () => {
|
|
50
|
-
listener?.remove();
|
|
51
|
-
};
|
|
52
|
-
}, [client]);
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: [
|
|
54
|
-
{
|
|
55
|
-
backgroundColor: getColorForDebuggerStatus(debuggerStatus),
|
|
56
|
-
},
|
|
57
|
-
styles.debugger_status,
|
|
58
|
-
], children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.debugger_status_text, children: debuggerStatus }) }));
|
|
59
|
-
};
|
|
60
|
-
const styles = react_native_1.StyleSheet.create({
|
|
61
|
-
debugger_status: {
|
|
62
|
-
flex: 1,
|
|
63
|
-
borderTopLeftRadius: 15,
|
|
64
|
-
borderTopRightRadius: 15,
|
|
65
|
-
padding: 4,
|
|
66
|
-
},
|
|
67
|
-
debugger_status_text: {
|
|
68
|
-
color: 'white',
|
|
69
|
-
fontSize: 12,
|
|
70
|
-
textAlign: 'center',
|
|
71
|
-
fontWeight: 'bold',
|
|
72
|
-
},
|
|
73
|
-
container: {
|
|
74
|
-
...react_native_1.StyleSheet.absoluteFillObject,
|
|
75
|
-
backgroundColor: 'white',
|
|
76
|
-
},
|
|
77
|
-
orb: {
|
|
78
|
-
height: 40,
|
|
79
|
-
width: 40,
|
|
80
|
-
backgroundColor: 'hsl(240 5% 6%)',
|
|
81
|
-
borderRadius: 40,
|
|
82
|
-
position: 'absolute',
|
|
83
|
-
justifyContent: 'center',
|
|
84
|
-
alignItems: 'center',
|
|
85
|
-
},
|
|
86
|
-
half_height: {
|
|
87
|
-
height: '50%',
|
|
88
|
-
backgroundColor: '#e1e1e1',
|
|
89
|
-
position: 'absolute',
|
|
90
|
-
left: 0,
|
|
91
|
-
right: 0,
|
|
92
|
-
bottom: 0,
|
|
93
|
-
},
|
|
94
|
-
logo: {
|
|
95
|
-
height: 20,
|
|
96
|
-
width: 20,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
const getColorForDebuggerStatus = (status) => {
|
|
100
|
-
switch (status) {
|
|
101
|
-
case 'CONNECTING':
|
|
102
|
-
return 'yellow';
|
|
103
|
-
case 'CONNECTED':
|
|
104
|
-
return 'green';
|
|
105
|
-
case 'DISCONNECTED':
|
|
106
|
-
return 'red';
|
|
107
|
-
case 'FAILED':
|
|
108
|
-
return 'red';
|
|
109
|
-
default:
|
|
110
|
-
return 'gray';
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const getOrbPosition = (edgeInsets, position) => {
|
|
114
|
-
const DEFAULT_PADDING = 16;
|
|
115
|
-
switch (position) {
|
|
116
|
-
case 'top-left':
|
|
117
|
-
return {
|
|
118
|
-
top: DEFAULT_PADDING + edgeInsets.top,
|
|
119
|
-
left: DEFAULT_PADDING,
|
|
120
|
-
};
|
|
121
|
-
case 'top-right':
|
|
122
|
-
return {
|
|
123
|
-
top: DEFAULT_PADDING + edgeInsets.top,
|
|
124
|
-
right: DEFAULT_PADDING,
|
|
125
|
-
};
|
|
126
|
-
case 'bottom-left':
|
|
127
|
-
return {
|
|
128
|
-
bottom: DEFAULT_PADDING + edgeInsets.bottom,
|
|
129
|
-
left: DEFAULT_PADDING,
|
|
130
|
-
};
|
|
131
|
-
case 'bottom-right':
|
|
132
|
-
return {
|
|
133
|
-
bottom: DEFAULT_PADDING + edgeInsets.bottom,
|
|
134
|
-
right: DEFAULT_PADDING,
|
|
135
|
-
};
|
|
136
|
-
case 'center-left':
|
|
137
|
-
return {
|
|
138
|
-
top: '50%',
|
|
139
|
-
left: DEFAULT_PADDING,
|
|
140
|
-
};
|
|
141
|
-
case 'center-right':
|
|
142
|
-
return {
|
|
143
|
-
top: '50%',
|
|
144
|
-
right: DEFAULT_PADDING,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
};
|
package/dist/debugger.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
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.Debugger = void 0;
|
|
7
|
-
const logger_1 = require("@teardown/logger");
|
|
8
|
-
const websocket_1 = require("@teardown/websocket");
|
|
9
|
-
const react_native_1 = require("react-native");
|
|
10
|
-
const react_native_device_info_1 = __importDefault(require("react-native-device-info"));
|
|
11
|
-
class Debugger extends websocket_1.WebsocketClient {
|
|
12
|
-
customDeviceName;
|
|
13
|
-
constructor(options) {
|
|
14
|
-
super({
|
|
15
|
-
logger: new logger_1.Logger("Debugger"),
|
|
16
|
-
...options,
|
|
17
|
-
});
|
|
18
|
-
this.customDeviceName = options?.deviceName;
|
|
19
|
-
}
|
|
20
|
-
async getDeviceName() {
|
|
21
|
-
if (this.customDeviceName) {
|
|
22
|
-
return this.customDeviceName;
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
return await react_native_device_info_1.default.getDeviceName();
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
return react_native_1.Platform.select({
|
|
29
|
-
ios: "iPhone",
|
|
30
|
-
android: "Android",
|
|
31
|
-
default: "Unknown Device",
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async onConnectionEstablished(event) {
|
|
36
|
-
const [deviceId, deviceName] = await Promise.all([
|
|
37
|
-
react_native_device_info_1.default.getUniqueId(),
|
|
38
|
-
this.getDeviceName(),
|
|
39
|
-
]);
|
|
40
|
-
this.send("DEVICE_CONNECTION_ESTABLISHED", {
|
|
41
|
-
deviceId,
|
|
42
|
-
deviceName,
|
|
43
|
-
platform: react_native_1.Platform.OS,
|
|
44
|
-
platformVersion: react_native_1.Platform.Version,
|
|
45
|
-
reactNativeVersion: react_native_1.Platform.constants.reactNativeVersion,
|
|
46
|
-
isDisableAnimations: react_native_1.Platform.constants.isDisableAnimations ?? false,
|
|
47
|
-
isTesting: react_native_1.Platform.constants.isTesting,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
getHostFromUrl(url) {
|
|
51
|
-
const host = url.match(/^(?:https?:\/\/)?(\[[^\]]+\]|[^/:\s]+)(?::\d+)?(?:[/?#]|$)/)?.[1];
|
|
52
|
-
if (typeof host !== "string") {
|
|
53
|
-
throw new Error("Invalid URL - host not found");
|
|
54
|
-
}
|
|
55
|
-
return host;
|
|
56
|
-
}
|
|
57
|
-
getHost() {
|
|
58
|
-
try {
|
|
59
|
-
// https://github.com/facebook/react-native/blob/2a7f969500cef73b621269299619ee1f0ee9521a/packages/react-native/src/private/specs/modules/NativeSourceCode.js#L16
|
|
60
|
-
const scriptURL = react_native_1.NativeModules?.SourceCode?.getConstants().scriptURL;
|
|
61
|
-
if (typeof scriptURL !== "string")
|
|
62
|
-
throw new Error("Invalid non-string URL");
|
|
63
|
-
return this.getHostFromUrl(scriptURL);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
const superHost = super.getHost();
|
|
67
|
-
const errorMessage = typeof error === "object" && error !== null && "message" in error
|
|
68
|
-
? error.message
|
|
69
|
-
: String(error);
|
|
70
|
-
this.logger.warn(`Failed to get host: "${errorMessage}" - Falling back to ${superHost}`);
|
|
71
|
-
return superHost;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.Debugger = Debugger;
|