@wutiange/log-listener-plugin 1.3.1 → 2.0.1-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/README.md +155 -2
  2. package/dist/src/HTTPInterceptor.d.ts +1 -0
  3. package/dist/src/HTTPInterceptor.js +12 -9
  4. package/dist/src/HTTPInterceptor.js.map +1 -1
  5. package/dist/src/Server.d.ts +13 -6
  6. package/dist/src/Server.js +119 -41
  7. package/dist/src/Server.js.map +1 -1
  8. package/dist/src/__mocks__/react-native/Libraries/Blob/FileReader.js +0 -1
  9. package/dist/src/__mocks__/react-native/Libraries/Blob/FileReader.js.map +1 -1
  10. package/dist/src/__mocks__/react-native/Libraries/Network/XHRInterceptor.js +0 -1
  11. package/dist/src/__mocks__/react-native/Libraries/Network/XHRInterceptor.js.map +1 -1
  12. package/dist/src/__tests__/Server.test.js +89 -114
  13. package/dist/src/__tests__/Server.test.js.map +1 -1
  14. package/dist/src/common.d.ts +19 -10
  15. package/dist/src/common.js +63 -4
  16. package/dist/src/common.js.map +1 -1
  17. package/dist/src/logPlugin.d.ts +12 -9
  18. package/dist/src/logPlugin.js +87 -82
  19. package/dist/src/logPlugin.js.map +1 -1
  20. package/dist/src/logger.d.ts +6 -0
  21. package/dist/src/logger.js +16 -0
  22. package/dist/src/logger.js.map +1 -0
  23. package/dist/src/utils.js +12 -7
  24. package/dist/src/utils.js.map +1 -1
  25. package/index.ts +3 -0
  26. package/package.json +18 -12
  27. package/src/HTTPInterceptor.ts +339 -0
  28. package/src/Server.ts +166 -0
  29. package/src/__mocks__/react-native/Libraries/Blob/FileReader.js +45 -0
  30. package/src/__mocks__/react-native/Libraries/Network/XHRInterceptor.js +39 -0
  31. package/src/__tests__/HTTPInterceptor.test.ts +322 -0
  32. package/src/__tests__/Server.test.ts +175 -0
  33. package/src/__tests__/utils.test.ts +113 -0
  34. package/src/common.ts +70 -0
  35. package/src/logPlugin.ts +224 -0
  36. package/src/logger.ts +15 -0
  37. package/src/utils.ts +112 -0
  38. package/tsconfig.json +27 -0
@@ -16,18 +16,48 @@ exports.SafeLogPlugin = void 0;
16
16
  const Server_1 = __importDefault(require("./Server"));
17
17
  const utils_1 = require("./utils");
18
18
  const HTTPInterceptor_1 = require("./HTTPInterceptor");
19
+ const common_1 = require("./common");
20
+ const logger_1 = __importDefault(require("./logger"));
19
21
  class LogPlugin {
20
22
  constructor() {
21
23
  this.server = null;
22
- this.baseData = {};
23
24
  this.timeout = null;
24
- this.host = '';
25
25
  this.isAuto = false;
26
- this.auto = () => {
27
- if (this.host) {
28
- this.startRecordNetwork();
29
- this.startRecordLog();
26
+ this.storage = (0, common_1.getDefaultStorage)();
27
+ this.init = () => __awaiter(this, void 0, void 0, function* () {
28
+ this.server = new Server_1.default();
29
+ if (!this.storage) {
30
+ logger_1.default.warn(common_1.LOG_KEY, '你并没有设置 storage ,这会导致 App 杀死后可能需要重新加入日志系统才能收集日志数据,建议你设置 storage 。');
31
+ }
32
+ else {
33
+ const urlsStr = yield this.storage.getItem(common_1.URLS_KEY);
34
+ if (urlsStr) {
35
+ const urls = JSON.parse(urlsStr);
36
+ this.server.setBaseUrlObj(urls);
37
+ }
30
38
  }
39
+ this.server.addUrlsListener((_, urlsObj) => {
40
+ if (this.storage) {
41
+ this.storage.setItem(common_1.URLS_KEY, JSON.stringify(urlsObj));
42
+ }
43
+ HTTPInterceptor_1.httpInterceptor.setIgnoredUrls(this.handleIgnoredUrls());
44
+ });
45
+ });
46
+ this.config = ({ storage, timeout, testUrl, isAuto, baseData = {} }) => {
47
+ if (isAuto) {
48
+ this.auto();
49
+ }
50
+ else {
51
+ this.unAuto();
52
+ }
53
+ this.storage = storage !== null && storage !== void 0 ? storage : (0, common_1.getDefaultStorage)();
54
+ this.setTimeout(timeout !== null && timeout !== void 0 ? timeout : common_1.DEFAULT_TIMEOUT);
55
+ this.setBaseUrl(testUrl);
56
+ this.setBaseData(baseData);
57
+ };
58
+ this.auto = () => {
59
+ this.startRecordNetwork();
60
+ this.startRecordLog();
31
61
  this.isAuto = true;
32
62
  };
33
63
  this.unAuto = () => {
@@ -37,56 +67,69 @@ class LogPlugin {
37
67
  this.isAuto = false;
38
68
  };
39
69
  this.startRecordLog = () => {
40
- const common = require('./common');
41
70
  console.log = (...data) => {
71
+ logger_1.default.log(...data);
42
72
  this.log(...data);
43
- common.log(...data);
44
73
  };
45
74
  console.warn = (...data) => {
75
+ logger_1.default.warn(...data);
46
76
  this.warn(...data);
47
- common.warn(...data);
48
77
  };
49
78
  console.error = (...data) => {
79
+ logger_1.default.error(...data);
50
80
  this.error(...data);
51
- common.error(...data);
52
81
  };
53
82
  };
54
83
  this.stopRecordLog = () => {
55
- const common = require('./common');
56
- console.log = common.log;
57
- console.warn = common.warn;
58
- console.error = common.error;
84
+ console.log = logger_1.default.log;
85
+ console.warn = logger_1.default.warn;
86
+ console.error = logger_1.default.error;
59
87
  };
60
- this.startRecordNetwork = () => {
88
+ this.handleIgnoredUrls = () => {
61
89
  var _a, _b;
90
+ const urls = (_b = (_a = this.server) === null || _a === void 0 ? void 0 : _a.getUrls) === null || _b === void 0 ? void 0 : _b.call(_a);
91
+ let ignoredUrls = [];
92
+ if (urls === null || urls === void 0 ? void 0 : urls.length) {
93
+ ignoredUrls = urls.reduce((acc, url) => {
94
+ acc.push(`${url}/log`, `${url}/network`, `${url}/join`);
95
+ return acc;
96
+ }, []);
97
+ }
98
+ return ignoredUrls;
99
+ };
100
+ this.startRecordNetwork = () => {
62
101
  HTTPInterceptor_1.httpInterceptor.addListener("send", (data) => {
63
102
  var _a;
64
- (_a = this.server) === null || _a === void 0 ? void 0 : _a.network(Object.assign(Object.assign({}, this.baseData), { url: data.url, id: data.id, method: data.method, headers: data.requestHeaders, body: data.requestData, createTime: data.startTime }));
103
+ (_a = this.server) === null || _a === void 0 ? void 0 : _a.network({
104
+ url: data.url,
105
+ id: data.id,
106
+ method: data.method,
107
+ headers: data.requestHeaders,
108
+ body: data.requestData,
109
+ createTime: data.startTime
110
+ });
65
111
  });
66
112
  HTTPInterceptor_1.httpInterceptor.addListener("response", (data) => {
67
113
  var _a;
68
- (_a = this.server) === null || _a === void 0 ? void 0 : _a.network(Object.assign(Object.assign({}, this.baseData), { headers: data.responseHeaders, body: data.responseData, requestId: data.id, statusCode: data.status, endTime: data.endTime }));
114
+ (_a = this.server) === null || _a === void 0 ? void 0 : _a.network({
115
+ headers: data.responseHeaders,
116
+ body: data.responseData,
117
+ requestId: data.id,
118
+ statusCode: data.status,
119
+ endTime: data.endTime
120
+ });
69
121
  });
70
- const url = (_b = (_a = this.server) === null || _a === void 0 ? void 0 : _a.getUrl) === null || _b === void 0 ? void 0 : _b.call(_a);
71
- let ignoredUrls = [];
72
- if (url) {
73
- ignoredUrls = [`${url}/log`, `${url}/network`];
74
- }
75
- HTTPInterceptor_1.httpInterceptor.enable({ ignoredUrls });
122
+ HTTPInterceptor_1.httpInterceptor.enable({ ignoredUrls: this.handleIgnoredUrls() });
76
123
  };
77
124
  this.setBaseUrl = (url) => {
78
- if (!(url === null || url === void 0 ? void 0 : url.trim())) {
79
- HTTPInterceptor_1.httpInterceptor.disable();
80
- this.stopRecordLog();
81
- return;
82
- }
83
- this.host = url.includes("http") ? url : `http://${url}`;
125
+ const tempUrl = url === null || url === void 0 ? void 0 : url.trim();
84
126
  if (this.server) {
85
- this.server.updateUrl(url);
127
+ this.server.updateUrl(tempUrl);
86
128
  }
87
129
  else {
88
- this.server = new Server_1.default(url);
130
+ this.server = new Server_1.default(tempUrl);
89
131
  }
132
+ HTTPInterceptor_1.httpInterceptor.setIgnoredUrls(this.handleIgnoredUrls());
90
133
  if (this.isAuto) {
91
134
  this.startRecordNetwork();
92
135
  this.startRecordLog();
@@ -106,69 +149,31 @@ class LogPlugin {
106
149
  return null;
107
150
  };
108
151
  this.setBaseData = (data = {}) => {
109
- this.baseData = data;
152
+ this.server.updateBaseData(data);
110
153
  };
111
154
  this._log = (level, tag, ...data) => {
112
155
  var _a;
113
- const sendData = Object.assign(Object.assign({}, this.baseData), { message: data, tag, level: level !== null && level !== void 0 ? level : 'log', createTime: Date.now() });
156
+ const sendData = {
157
+ message: data,
158
+ tag,
159
+ level: level !== null && level !== void 0 ? level : 'log',
160
+ createTime: Date.now(),
161
+ };
114
162
  (_a = this.server) === null || _a === void 0 ? void 0 : _a.log(sendData);
115
163
  };
116
164
  this.tag = (tag, ...data) => {
117
- this._log('log', tag, ...data);
165
+ this._log(common_1.Level.LOG, tag, ...data);
118
166
  };
119
167
  this.log = (...data) => {
120
- this._log('log', 'default', ...data);
168
+ this._log(common_1.Level.LOG, common_1.Tag.DEFAULT, ...data);
121
169
  };
122
170
  this.warn = (...data) => {
123
- this._log('warn', 'default', ...data);
171
+ this._log(common_1.Level.WARN, common_1.Tag.DEFAULT, ...data);
124
172
  };
125
173
  this.error = (...data) => {
126
- this._log('error', 'default', ...data);
127
- };
128
- this.uniqueReq = (uniqueId, input, init) => __awaiter(this, void 0, void 0, function* () {
129
- var _a, _b, _c;
130
- let url = null;
131
- let method = (_a = init === null || init === void 0 ? void 0 : init.method) !== null && _a !== void 0 ? _a : 'get';
132
- let headers = init === null || init === void 0 ? void 0 : init.headers;
133
- let body = init === null || init === void 0 ? void 0 : init.body;
134
- if (input instanceof Request) {
135
- url = input.url;
136
- method = (_b = input.method) !== null && _b !== void 0 ? _b : 'get';
137
- headers = input.headers.map;
138
- body = input.body;
139
- }
140
- else if (input instanceof URL) {
141
- url = input.href;
142
- }
143
- else {
144
- url = input;
145
- }
146
- return (_c = this.server) === null || _c === void 0 ? void 0 : _c.network(Object.assign(Object.assign({}, this.baseData), { url, id: uniqueId, method,
147
- headers,
148
- body, createTime: Date.now() }));
149
- });
150
- this._res = (uniqueId, id, response) => __awaiter(this, void 0, void 0, function* () {
151
- var _d;
152
- const body = yield (response === null || response === void 0 ? void 0 : response.text());
153
- return (_d = this.server) === null || _d === void 0 ? void 0 : _d.network(Object.assign(Object.assign({}, this.baseData), { headers: (response === null || response === void 0 ? void 0 : response.headers).map, body, requestId: uniqueId !== null && uniqueId !== void 0 ? uniqueId : Number(id), statusCode: response === null || response === void 0 ? void 0 : response.status, endTime: Date.now() }));
154
- });
155
- this.resTimeout = (uniqueId) => __awaiter(this, void 0, void 0, function* () {
156
- var _e;
157
- return (_e = this.server) === null || _e === void 0 ? void 0 : _e.network(Object.assign(Object.assign({}, this.baseData), { isTimeout: true, requestId: uniqueId }));
158
- });
159
- this.resResponseError = (uniqueId) => __awaiter(this, void 0, void 0, function* () {
160
- var _f;
161
- return (_f = this.server) === null || _f === void 0 ? void 0 : _f.network(Object.assign(Object.assign({}, this.baseData), { isResponseError: true, requestId: uniqueId }));
162
- });
163
- this.uniqueRes = (uniqueId, response) => __awaiter(this, void 0, void 0, function* () {
164
- return this._res(uniqueId, undefined, response);
165
- });
166
- this.req = (input, init) => __awaiter(this, void 0, void 0, function* () {
167
- return this.uniqueReq(undefined, input, init);
168
- });
169
- this.res = (id, response) => __awaiter(this, void 0, void 0, function* () {
170
- return this._res(undefined, id, response);
171
- });
174
+ this._log(common_1.Level.ERROR, common_1.Tag.DEFAULT, ...data);
175
+ };
176
+ this.init();
172
177
  }
173
178
  }
174
179
  const SafeLogPlugin = (0, utils_1.createClassWithErrorHandling)(LogPlugin);
@@ -1 +1 @@
1
- {"version":3,"file":"logPlugin.js","sourceRoot":"","sources":["../../src/logPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,mCAAuD;AACvD,uDAAoD;AAEpD,MAAM,SAAS;IAAf;QACU,WAAM,GAAkB,IAAI,CAAC;QAC7B,aAAQ,GAAwB,EAAE,CAAC;QACnC,YAAO,GAAkB,IAAI,CAAC;QAC9B,SAAI,GAAG,EAAE,CAAC;QACV,WAAM,GAAG,KAAK,CAAA;QAEtB,SAAI,GAAG,GAAG,EAAE;YACV,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC1B,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,CAAC;Y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AAG,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAA;QAlLC,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;CAmLF;AACD,MAAM,aAAa,GAAG,IAAA,oCAA4B,EAAC,SAAS,CAAC,CAAA;AAEpD,sCAAa;AADtB,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;AAEtC,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ declare const logger: {
2
+ log: (...data: any[]) => void;
3
+ warn: (...data: any[]) => void;
4
+ error: (...data: any[]) => void;
5
+ };
6
+ export default logger;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const [log, warn, error] = [console.log, console.warn, console.error];
4
+ const logger = {
5
+ log: (...data) => {
6
+ log(...data);
7
+ },
8
+ warn: (...data) => {
9
+ warn(...data);
10
+ },
11
+ error: (...data) => {
12
+ error(...data);
13
+ },
14
+ };
15
+ exports.default = logger;
16
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;AAAA,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAEtE,MAAM,MAAM,GAAG;IACb,GAAG,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;QACtB,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IACd,CAAC;IACD,IAAI,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;QACvB,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;IACf,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;IAChB,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
package/dist/src/utils.js CHANGED
@@ -1,29 +1,36 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formDataToString = exports.createClassWithErrorHandling = exports.hasPort = exports.sleep = void 0;
6
+ exports.sleep = sleep;
7
+ exports.hasPort = hasPort;
8
+ exports.createClassWithErrorHandling = createClassWithErrorHandling;
9
+ exports.formDataToString = formDataToString;
10
+ const url_parse_1 = __importDefault(require("url-parse"));
11
+ const logger_1 = __importDefault(require("./logger"));
4
12
  function sleep(ms, isReject = false) {
5
13
  return new Promise((resolve, reject) => {
6
14
  setTimeout(isReject ? () => reject({
7
15
  code: 11001,
8
16
  key: '@wutiange/log-listener-plugin%%timeout',
9
- msg: 'Timeout'
17
+ message: 'Timeout'
10
18
  }) : resolve, ms);
11
19
  });
12
20
  }
13
- exports.sleep = sleep;
14
21
  function hasPort(url) {
15
22
  if (!url || typeof url !== 'string') {
16
23
  return false;
17
24
  }
18
25
  try {
19
- const parsedUrl = new URL(url);
26
+ const parsedUrl = new url_parse_1.default(url);
20
27
  return parsedUrl.port !== '';
21
28
  }
22
29
  catch (error) {
30
+ logger_1.default.error(error);
23
31
  return false;
24
32
  }
25
33
  }
26
- exports.hasPort = hasPort;
27
34
  function createClassWithErrorHandling(BaseClass) {
28
35
  return new Proxy(BaseClass, {
29
36
  construct(target, args) {
@@ -79,7 +86,6 @@ function createClassWithErrorHandling(BaseClass) {
79
86
  }
80
87
  });
81
88
  }
82
- exports.createClassWithErrorHandling = createClassWithErrorHandling;
83
89
  function formDataToString(formData) {
84
90
  const boundary = '----WebKitFormBoundary' + Math.random().toString(36).substr(2);
85
91
  let result = '';
@@ -97,5 +103,4 @@ function formDataToString(formData) {
97
103
  result += `--${boundary}--\r\n`;
98
104
  return result;
99
105
  }
100
- exports.formDataToString = formDataToString;
101
106
  //# sourceMappingURL=utils.js.map
@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CAAC;AAChB,CAAC"}
package/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ import logPlugin from './src/logPlugin';
2
+
3
+ export default logPlugin;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@wutiange/log-listener-plugin",
3
- "version": "1.3.1",
3
+ "version": "2.0.1-alpha.1",
4
4
  "description": "log-record 客户端对应的的插件\r\nLog-record client corresponding plugin",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "source": "index.ts",
8
+ "react-native": "index.ts",
8
9
  "repository": {
9
10
  "type": "git",
10
11
  "url": "https://github.com/wutiange/log-listener-plugin.git"
@@ -18,14 +19,6 @@
18
19
  "charles"
19
20
  ],
20
21
  "private": false,
21
- "exports": {
22
- "console": {
23
- "default": "./dist/console.js"
24
- },
25
- "fetch": {
26
- "default": "./dist/fetch.js"
27
- }
28
- },
29
22
  "scripts": {
30
23
  "build": "npm run test && tsc",
31
24
  "dev": "ts-node ./index.ts",
@@ -35,19 +28,32 @@
35
28
  },
36
29
  "devDependencies": {
37
30
  "@jest/globals": "^29.7.0",
31
+ "@types/crypto-js": "^4.2.2",
38
32
  "@types/jest": "^29.5.12",
33
+ "@types/react-native-zeroconf": "^0.13.1",
34
+ "@types/url-parse": "^1.4.11",
39
35
  "jest": "^29.7.0",
40
36
  "ts-jest": "^29.1.2",
41
37
  "ts-node": "^10.9.2",
42
38
  "typescript": "^5.3.3"
43
39
  },
44
40
  "peerDependencies": {
45
- "react-native": "*"
41
+ "react-native": "*",
42
+ "react-native-device-info": "^14.0.0",
43
+ "react-native-zeroconf": "^0.13.8",
44
+ "@react-native-async-storage/async-storage": "*"
46
45
  },
47
46
  "files": [
48
47
  "package.json",
49
48
  "README.md",
50
49
  "LICENSE",
51
- "dist"
52
- ]
50
+ "dist",
51
+ "src",
52
+ "index.ts",
53
+ "tsconfig.json"
54
+ ],
55
+ "dependencies": {
56
+ "crypto-js": "^4.2.0",
57
+ "url-parse": "^1.5.10"
58
+ }
53
59
  }