@teardown/react-native 1.2.34 → 1.2.35
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.js +2 -0
- package/dist/components/teardown-logo.js +34 -0
- package/dist/containers/index.js +17 -0
- package/dist/containers/teardown.container.js +25 -0
- package/dist/index.js +21 -0
- package/dist/plugins/http.plugin.js +144 -0
- package/dist/plugins/index.js +19 -0
- package/dist/plugins/logging.plugin.js +35 -0
- package/dist/plugins/websocket.plugin.js +107 -0
- package/dist/services/index.js +17 -0
- package/dist/services/teardown.service.js +21 -0
- package/dist/teardown.client.js +59 -0
- package/dist/utils/log.js +8 -0
- package/package.json +5 -5
|
@@ -0,0 +1,34 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.TeardownLogo = void 0;
|
|
27
|
+
const react_native_svg_1 = __importStar(require("react-native-svg"));
|
|
28
|
+
const TeardownLogo = (props) => {
|
|
29
|
+
const {} = props;
|
|
30
|
+
return (<react_native_svg_1.default width="350" height="350" viewBox="0 0 350 350" fill="none" {...props}>
|
|
31
|
+
<react_native_svg_1.Path fillRule="evenodd" clipRule="evenodd" d="M175.09 345L300 218.574L256.859 174.909L299.821 131.426L174.91 5.00001L50 131.426L93.141 175.091L50.179 218.574L175.09 345ZM114.879 197.093L93.656 218.574L175.09 300.995L256.523 218.574L235.12 196.911L174.91 257.853L114.879 197.093ZM213.382 174.909L174.91 213.848L136.618 175.091L175.09 136.152L213.382 174.909ZM235.12 152.907L175.09 92.147L114.879 153.089L93.477 131.426L174.91 49.005L256.344 131.426L235.12 152.907Z" fill="white"/>
|
|
32
|
+
</react_native_svg_1.default>);
|
|
33
|
+
};
|
|
34
|
+
exports.TeardownLogo = TeardownLogo;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./teardown.container"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
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.TeardownContainer = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const services_1 = require("../services");
|
|
9
|
+
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
10
|
+
const react_native_gesture_handler_1 = require("react-native-gesture-handler");
|
|
11
|
+
const TeardownContainer = (props) => {
|
|
12
|
+
const { children, client, options } = props;
|
|
13
|
+
const providedState = services_1.TeardownService.useProvidedState(client);
|
|
14
|
+
return (<react_native_safe_area_context_1.SafeAreaProvider>
|
|
15
|
+
<react_native_gesture_handler_1.GestureHandlerRootView>
|
|
16
|
+
{/* <BottomSheetModalProvider> TODO: Move this into a theme provider/package */}
|
|
17
|
+
{/* <TeardownService.Provider value={providedState}>*/}
|
|
18
|
+
{children}
|
|
19
|
+
{/* <DebuggerUi {...options?.debugger} />*/}
|
|
20
|
+
{/* </TeardownService.Provider>*/}
|
|
21
|
+
{/* </BottomSheetModalProvider> */}
|
|
22
|
+
</react_native_gesture_handler_1.GestureHandlerRootView>
|
|
23
|
+
</react_native_safe_area_context_1.SafeAreaProvider>);
|
|
24
|
+
};
|
|
25
|
+
exports.TeardownContainer = TeardownContainer;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// export * from './components';
|
|
18
|
+
__exportStar(require("./containers"), exports);
|
|
19
|
+
// export * from './services';
|
|
20
|
+
// export * from "./teardown.client";
|
|
21
|
+
__exportStar(require("./plugins"), exports);
|
|
@@ -0,0 +1,144 @@
|
|
|
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.HTTPPlugin = void 0;
|
|
7
|
+
const util_1 = require("@teardown/util");
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
const XHRInterceptor_1 = __importDefault(require("react-native/Libraries/Network/XHRInterceptor"));
|
|
10
|
+
const teardown_client_1 = require("../teardown.client");
|
|
11
|
+
class HTTPPlugin extends teardown_client_1.Plugin {
|
|
12
|
+
client = null;
|
|
13
|
+
requests = new Map();
|
|
14
|
+
ignoreURLs;
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
super({
|
|
17
|
+
...options,
|
|
18
|
+
key: "HTTPPlugin",
|
|
19
|
+
});
|
|
20
|
+
this.ignoreURLs = options.ignoreURLs || [];
|
|
21
|
+
}
|
|
22
|
+
install(client) {
|
|
23
|
+
this.client = client;
|
|
24
|
+
this.enableXHRInterceptor();
|
|
25
|
+
}
|
|
26
|
+
enableXHRInterceptor() {
|
|
27
|
+
// noinspection TypeScriptUnresolvedReference
|
|
28
|
+
if (XHRInterceptor_1.default.isInterceptorEnabled()) {
|
|
29
|
+
// this.logger.info(
|
|
30
|
+
// 'XHRInterceptor is already enabled by another library. Disable it or run this plugin first when your app loads.',
|
|
31
|
+
// );
|
|
32
|
+
this.logger.info("XHRInterceptor is already enabled. Teardown overrides the existing interceptor - other plugins may not work as expected.");
|
|
33
|
+
this.disableInterception();
|
|
34
|
+
}
|
|
35
|
+
this.logger.info("Enabling XHRInterceptor");
|
|
36
|
+
// noinspection TypeScriptUnresolvedReference
|
|
37
|
+
XHRInterceptor_1.default.setOpenCallback(this.xhrOpenCallback);
|
|
38
|
+
// noinspection TypeScriptUnresolvedReference
|
|
39
|
+
XHRInterceptor_1.default.setRequestHeaderCallback(this.xhrRequestHeaderCallback);
|
|
40
|
+
// noinspection TypeScriptUnresolvedReference
|
|
41
|
+
XHRInterceptor_1.default.setSendCallback(this.xhrSendCallback);
|
|
42
|
+
// noinspection TypeScriptUnresolvedReference
|
|
43
|
+
XHRInterceptor_1.default.setResponseCallback(this.xhrResponseCallback);
|
|
44
|
+
// noinspection TypeScriptUnresolvedReference
|
|
45
|
+
XHRInterceptor_1.default.enableInterception();
|
|
46
|
+
this.logger.info("XHRInterceptor enabled");
|
|
47
|
+
}
|
|
48
|
+
disableInterception() {
|
|
49
|
+
this.logger.info("Disabling XHRInterceptor");
|
|
50
|
+
XHRInterceptor_1.default.disableInterception();
|
|
51
|
+
this.requests.clear();
|
|
52
|
+
this.logger.info("XHRInterceptor disabled");
|
|
53
|
+
}
|
|
54
|
+
shouldIgnoreURL(url) {
|
|
55
|
+
return this.ignoreURLs.some((ignoreRegex) => ignoreRegex.test(url));
|
|
56
|
+
}
|
|
57
|
+
xhrOpenCallback = (method, url, xhr) => {
|
|
58
|
+
if (this.shouldIgnoreURL(url)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const requestId = util_1.Util.generateUUID();
|
|
62
|
+
const HTTPRequestInfo = {
|
|
63
|
+
id: requestId,
|
|
64
|
+
type: "XMLHttpRequest",
|
|
65
|
+
url,
|
|
66
|
+
method: method,
|
|
67
|
+
requestHeaders: { "TD-Request-ID": requestId },
|
|
68
|
+
startTime: performance.now(),
|
|
69
|
+
updatedAt: performance.now(),
|
|
70
|
+
};
|
|
71
|
+
this.requests.set(xhr._id, HTTPRequestInfo);
|
|
72
|
+
};
|
|
73
|
+
xhrRequestHeaderCallback = (header, value, xhr) => {
|
|
74
|
+
const request = this.requests.get(xhr._id);
|
|
75
|
+
if (request) {
|
|
76
|
+
request.requestHeaders[header] = value;
|
|
77
|
+
request.updatedAt = performance.now();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
xhrSendCallback = (data, xhr) => {
|
|
81
|
+
const request = this.requests.get(xhr._id);
|
|
82
|
+
if (request) {
|
|
83
|
+
xhr.setRequestHeader("TD-Request-ID", request.id);
|
|
84
|
+
request.dataSent = this.serializeRequestBody(data);
|
|
85
|
+
request.updatedAt = performance.now();
|
|
86
|
+
this.sendHTTPEvent(request);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
serializeRequestBody(data) {
|
|
90
|
+
if (typeof data === "string") {
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
return JSON.stringify(data);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
this.logger.warn("Failed to stringify request body", error);
|
|
98
|
+
return "[Unable to serialize request body]";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
xhrResponseCallback = (status, timeout, response, responseURL, responseType, xhr) => {
|
|
102
|
+
const request = this.requests.get(xhr._id);
|
|
103
|
+
if (request) {
|
|
104
|
+
request.status = status;
|
|
105
|
+
request.responseHeaders = this.parseResponseHeaders(xhr.getAllResponseHeaders());
|
|
106
|
+
request.response = this.parseResponseBody(response, responseType);
|
|
107
|
+
request.responseURL = responseURL;
|
|
108
|
+
request.responseType = responseType;
|
|
109
|
+
request.timeout = timeout;
|
|
110
|
+
request.endTime = performance.now();
|
|
111
|
+
request.updatedAt = performance.now();
|
|
112
|
+
this.sendHTTPEvent(request);
|
|
113
|
+
this.requests.delete(xhr._id);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
parseResponseHeaders(headersString) {
|
|
117
|
+
const headersObject = {};
|
|
118
|
+
if (headersString) {
|
|
119
|
+
const headerPairs = headersString.trim().split(/[\r\n]+/);
|
|
120
|
+
headerPairs.forEach((headerPair) => {
|
|
121
|
+
const [key, value] = headerPair.split(": ");
|
|
122
|
+
headersObject[key] = value;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return headersObject;
|
|
126
|
+
}
|
|
127
|
+
parseResponseBody(response, responseType) {
|
|
128
|
+
if (responseType === "json") {
|
|
129
|
+
try {
|
|
130
|
+
return JSON.stringify(JSON.parse(response), null, 2);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
this.logger.warn("Failed to parse JSON response", error);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return response;
|
|
137
|
+
}
|
|
138
|
+
sendHTTPEvent(httpRequestInfo) {
|
|
139
|
+
// if (this.client?.debugger) {
|
|
140
|
+
// this.client.debugger.send("NETWORK_HTTP_REQUEST", httpRequestInfo);
|
|
141
|
+
// }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.HTTPPlugin = HTTPPlugin;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./http.plugin"), exports);
|
|
18
|
+
// export * from './websocket.plugin';
|
|
19
|
+
__exportStar(require("./logging.plugin"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggingPlugin = void 0;
|
|
4
|
+
const methods = ["log", "warn", "error", "debug", "info"];
|
|
5
|
+
class LoggingPlugin {
|
|
6
|
+
client = null;
|
|
7
|
+
originalConsoleMethods = {};
|
|
8
|
+
createConsoleProxy(method) {
|
|
9
|
+
const original = console[method];
|
|
10
|
+
return new Proxy(original, {
|
|
11
|
+
apply: (target, thisArg, args) => {
|
|
12
|
+
target.apply(thisArg, args);
|
|
13
|
+
// this.client?.debugger?.send("CONSOLE_LOG", {
|
|
14
|
+
// type: method,
|
|
15
|
+
// args,
|
|
16
|
+
// });
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
constructor() {
|
|
21
|
+
methods.forEach((method) => {
|
|
22
|
+
this.originalConsoleMethods[method] = console[method];
|
|
23
|
+
console[method] = this.createConsoleProxy(method);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
install(client) {
|
|
27
|
+
this.client = client;
|
|
28
|
+
}
|
|
29
|
+
uninstall() {
|
|
30
|
+
methods.forEach((method) => {
|
|
31
|
+
console[method] = this.originalConsoleMethods[method];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.LoggingPlugin = LoggingPlugin;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-ignore
|
|
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,17 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./teardown.service"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TeardownService = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const Context = (0, react_1.createContext)(null);
|
|
6
|
+
exports.TeardownService = {
|
|
7
|
+
Context,
|
|
8
|
+
Provider: Context.Provider,
|
|
9
|
+
useState() {
|
|
10
|
+
const state = (0, react_1.useContext)(Context);
|
|
11
|
+
if (state == null) {
|
|
12
|
+
throw new Error("TeardownService not found");
|
|
13
|
+
}
|
|
14
|
+
return state;
|
|
15
|
+
},
|
|
16
|
+
useProvidedState(client) {
|
|
17
|
+
return {
|
|
18
|
+
client
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTeardownClient = exports.TeardownClient = exports.Plugin = void 0;
|
|
4
|
+
const logger_1 = require("@teardown/logger");
|
|
5
|
+
class Plugin {
|
|
6
|
+
logger;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.logger = new logger_1.Logger(options.key, options.debug ?? false);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.Plugin = Plugin;
|
|
12
|
+
class TeardownClient {
|
|
13
|
+
options;
|
|
14
|
+
logger;
|
|
15
|
+
plugins = new Map();
|
|
16
|
+
api = {};
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.logger = new logger_1.Logger("TeardownClient", options?.loggingEnabled ?? false);
|
|
20
|
+
// options?.plugins?.forEach(([key, plugin]) => {
|
|
21
|
+
// this.plugins.set(key, plugin);
|
|
22
|
+
// });
|
|
23
|
+
this.installPlugin();
|
|
24
|
+
}
|
|
25
|
+
installPlugin() {
|
|
26
|
+
this.logger.log("Installing plugins");
|
|
27
|
+
this.plugins.forEach((plugin, key) => {
|
|
28
|
+
plugin.install?.(this);
|
|
29
|
+
this.api[key] = plugin;
|
|
30
|
+
});
|
|
31
|
+
this.logger.log("Plugins installed");
|
|
32
|
+
}
|
|
33
|
+
uninstallPlugin(key) {
|
|
34
|
+
const plugin = this.plugins.get(key);
|
|
35
|
+
if (plugin) {
|
|
36
|
+
plugin.uninstall?.();
|
|
37
|
+
this.plugins.delete(key);
|
|
38
|
+
delete this.api[key];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
uninstallAllPlugins() {
|
|
42
|
+
this.plugins.forEach((_, key) => this.uninstallPlugin(key));
|
|
43
|
+
}
|
|
44
|
+
reinstallPlugins() {
|
|
45
|
+
this.uninstallAllPlugins();
|
|
46
|
+
this.installPlugin();
|
|
47
|
+
}
|
|
48
|
+
shutdown() {
|
|
49
|
+
this.uninstallAllPlugins();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.TeardownClient = TeardownClient;
|
|
53
|
+
const createTeardownClient = (plugins) => {
|
|
54
|
+
return new TeardownClient({
|
|
55
|
+
loggingEnabled: true,
|
|
56
|
+
plugins,
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
exports.createTeardownClient = createTeardownClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teardown/react-native",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@react-native/dev-middleware": "^0.76.1",
|
|
18
18
|
"@teardown/cli": "^1.2.20",
|
|
19
|
-
"@teardown/logger": "1.2.
|
|
20
|
-
"@teardown/util": "1.2.
|
|
21
|
-
"@teardown/websocket": "1.2.
|
|
19
|
+
"@teardown/logger": "1.2.35",
|
|
20
|
+
"@teardown/util": "1.2.35",
|
|
21
|
+
"@teardown/websocket": "1.2.35",
|
|
22
22
|
"async-mutex": "^0.5.0",
|
|
23
23
|
"chalk": "^5.3.0",
|
|
24
24
|
"compression": "^1.7.5",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"ws": "^8.18.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@teardown/config": "1.2.
|
|
31
|
+
"@teardown/config": "1.2.35",
|
|
32
32
|
"@types/compression": "^1.7.5",
|
|
33
33
|
"@types/connect": "^3.4.38",
|
|
34
34
|
"@types/react": "^18.3.12",
|