@wutiange/log-listener-plugin 2.0.2-alpha.1 → 2.0.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -163
- package/dist/index.cjs.js +7 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +34 -2
- package/dist/index.esm.js +5 -0
- package/dist/index.esm.js.map +1 -0
- package/index.ts +3 -3
- package/package.json +52 -59
- package/src/HTTPInterceptor.ts +340 -340
- package/src/Server.ts +174 -178
- package/src/__mocks__/react-native/Libraries/Blob/FileReader.js +44 -44
- package/src/__mocks__/react-native/Libraries/Network/XHRInterceptor.js +39 -39
- package/src/__tests__/HTTPInterceptor.test.ts +322 -322
- package/src/__tests__/Server.test.ts +150 -150
- package/src/__tests__/utils.test.ts +114 -114
- package/src/common.ts +57 -57
- package/src/logPlugin.ts +238 -231
- package/src/logger.ts +15 -15
- package/src/utils.ts +135 -112
- package/LICENSE +0 -201
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/src/HTTPInterceptor.d.ts +0 -50
- package/dist/src/HTTPInterceptor.js +0 -227
- package/dist/src/HTTPInterceptor.js.map +0 -1
- package/dist/src/Server.d.ts +0 -21
- package/dist/src/Server.js +0 -178
- package/dist/src/Server.js.map +0 -1
- package/dist/src/__mocks__/react-native/Libraries/Blob/FileReader.d.ts +0 -14
- package/dist/src/__mocks__/react-native/Libraries/Blob/FileReader.js +0 -41
- package/dist/src/__mocks__/react-native/Libraries/Blob/FileReader.js.map +0 -1
- package/dist/src/__mocks__/react-native/Libraries/Network/XHRInterceptor.d.ts +0 -17
- package/dist/src/__mocks__/react-native/Libraries/Network/XHRInterceptor.js +0 -34
- package/dist/src/__mocks__/react-native/Libraries/Network/XHRInterceptor.js.map +0 -1
- package/dist/src/__tests__/HTTPInterceptor.test.d.ts +0 -9
- package/dist/src/__tests__/HTTPInterceptor.test.js +0 -281
- package/dist/src/__tests__/HTTPInterceptor.test.js.map +0 -1
- package/dist/src/__tests__/Server.test.d.ts +0 -1
- package/dist/src/__tests__/Server.test.js +0 -116
- package/dist/src/__tests__/Server.test.js.map +0 -1
- package/dist/src/__tests__/utils.test.d.ts +0 -1
- package/dist/src/__tests__/utils.test.js +0 -112
- package/dist/src/__tests__/utils.test.js.map +0 -1
- package/dist/src/common.d.ts +0 -14
- package/dist/src/common.js +0 -54
- package/dist/src/common.js.map +0 -1
- package/dist/src/logPlugin.d.ts +0 -35
- package/dist/src/logPlugin.js +0 -188
- package/dist/src/logPlugin.js.map +0 -1
- package/dist/src/logger.d.ts +0 -6
- package/dist/src/logger.js +0 -16
- package/dist/src/logger.js.map +0 -1
- package/dist/src/utils.d.ts +0 -6
- package/dist/src/utils.js +0 -106
- package/dist/src/utils.js.map +0 -1
- package/tsconfig.json +0 -27
package/dist/src/logPlugin.d.ts
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
type Options = {
|
2
|
-
storage?: Storage;
|
3
|
-
timeout?: number;
|
4
|
-
testUrl?: string;
|
5
|
-
isAuto?: boolean;
|
6
|
-
baseData?: Record<string, any>;
|
7
|
-
};
|
8
|
-
declare class LogPlugin {
|
9
|
-
private server;
|
10
|
-
private timeout;
|
11
|
-
private isAuto;
|
12
|
-
private storage;
|
13
|
-
constructor();
|
14
|
-
private init;
|
15
|
-
config: ({ storage, timeout, testUrl, isAuto, baseData }: Options) => void;
|
16
|
-
auto: () => void;
|
17
|
-
unAuto: () => void;
|
18
|
-
startRecordLog: () => void;
|
19
|
-
stopRecordLog: () => void;
|
20
|
-
private handleIgnoredUrls;
|
21
|
-
startRecordNetwork: () => void;
|
22
|
-
setBaseUrl: (url: string) => void;
|
23
|
-
setTimeout: (timeout: number) => void;
|
24
|
-
getTimeout: () => number;
|
25
|
-
setBaseData: (data?: Record<string, any>) => void;
|
26
|
-
private _log;
|
27
|
-
tag: (tag: string, ...data: any[]) => void;
|
28
|
-
log: (...data: any[]) => void;
|
29
|
-
warn: (...data: any[]) => void;
|
30
|
-
error: (...data: any[]) => void;
|
31
|
-
}
|
32
|
-
declare const SafeLogPlugin: typeof LogPlugin;
|
33
|
-
declare const logPlugin: LogPlugin;
|
34
|
-
export { SafeLogPlugin };
|
35
|
-
export default logPlugin;
|
package/dist/src/logPlugin.js
DELETED
@@ -1,188 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.SafeLogPlugin = void 0;
|
16
|
-
const Server_1 = __importDefault(require("./Server"));
|
17
|
-
const utils_1 = require("./utils");
|
18
|
-
const HTTPInterceptor_1 = require("./HTTPInterceptor");
|
19
|
-
const common_1 = require("./common");
|
20
|
-
const logger_1 = __importDefault(require("./logger"));
|
21
|
-
class LogPlugin {
|
22
|
-
constructor() {
|
23
|
-
this.server = null;
|
24
|
-
this.timeout = null;
|
25
|
-
this.isAuto = false;
|
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
|
-
const urlsStr = yield this.storage.getItem(common_1.URLS_KEY);
|
31
|
-
if (urlsStr) {
|
32
|
-
const urls = JSON.parse(urlsStr);
|
33
|
-
this.server.setBaseUrlArr(new Set(urls));
|
34
|
-
}
|
35
|
-
}
|
36
|
-
this.server.addUrlsListener((urlArr) => {
|
37
|
-
if (this.storage) {
|
38
|
-
this.storage.setItem(common_1.URLS_KEY, JSON.stringify(urlArr));
|
39
|
-
}
|
40
|
-
HTTPInterceptor_1.httpInterceptor.setIgnoredUrls(this.handleIgnoredUrls());
|
41
|
-
});
|
42
|
-
});
|
43
|
-
this.config = ({ storage, timeout, testUrl, isAuto, baseData = {} }) => {
|
44
|
-
if (isAuto) {
|
45
|
-
this.auto();
|
46
|
-
}
|
47
|
-
else {
|
48
|
-
this.unAuto();
|
49
|
-
}
|
50
|
-
this.storage = storage !== null && storage !== void 0 ? storage : (0, common_1.getDefaultStorage)();
|
51
|
-
this.setTimeout(timeout !== null && timeout !== void 0 ? timeout : common_1.DEFAULT_TIMEOUT);
|
52
|
-
this.setBaseUrl(testUrl);
|
53
|
-
this.setBaseData(baseData);
|
54
|
-
};
|
55
|
-
this.auto = () => {
|
56
|
-
this.startRecordNetwork();
|
57
|
-
this.startRecordLog();
|
58
|
-
this.isAuto = true;
|
59
|
-
};
|
60
|
-
this.unAuto = () => {
|
61
|
-
this.stopRecordLog();
|
62
|
-
HTTPInterceptor_1.httpInterceptor.disable();
|
63
|
-
HTTPInterceptor_1.httpInterceptor.removeAllListener();
|
64
|
-
this.isAuto = false;
|
65
|
-
};
|
66
|
-
this.startRecordLog = () => {
|
67
|
-
console.log = (...data) => {
|
68
|
-
this.log(...data);
|
69
|
-
if (!__DEV__) {
|
70
|
-
return;
|
71
|
-
}
|
72
|
-
logger_1.default.log(...data);
|
73
|
-
};
|
74
|
-
console.warn = (...data) => {
|
75
|
-
this.warn(...data);
|
76
|
-
if (!__DEV__) {
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
logger_1.default.warn(...data);
|
80
|
-
};
|
81
|
-
console.error = (...data) => {
|
82
|
-
this.error(...data);
|
83
|
-
if (!__DEV__) {
|
84
|
-
return;
|
85
|
-
}
|
86
|
-
logger_1.default.error(...data);
|
87
|
-
};
|
88
|
-
};
|
89
|
-
this.stopRecordLog = () => {
|
90
|
-
console.log = logger_1.default.log;
|
91
|
-
console.warn = logger_1.default.warn;
|
92
|
-
console.error = logger_1.default.error;
|
93
|
-
};
|
94
|
-
this.handleIgnoredUrls = () => {
|
95
|
-
var _a, _b;
|
96
|
-
const urls = (_b = (_a = this.server) === null || _a === void 0 ? void 0 : _a.getBaseUrlArr) === null || _b === void 0 ? void 0 : _b.call(_a);
|
97
|
-
const ignoredUrls = [];
|
98
|
-
if (urls === null || urls === void 0 ? void 0 : urls.size) {
|
99
|
-
urls.forEach((url) => {
|
100
|
-
ignoredUrls.push(`${url}/log`, `${url}/network`, `${url}/join`);
|
101
|
-
});
|
102
|
-
}
|
103
|
-
return ignoredUrls;
|
104
|
-
};
|
105
|
-
this.startRecordNetwork = () => {
|
106
|
-
HTTPInterceptor_1.httpInterceptor.addListener("send", (data) => {
|
107
|
-
var _a;
|
108
|
-
(_a = this.server) === null || _a === void 0 ? void 0 : _a.network({
|
109
|
-
url: data.url,
|
110
|
-
id: data.id,
|
111
|
-
method: data.method,
|
112
|
-
headers: data.requestHeaders,
|
113
|
-
body: data.requestData,
|
114
|
-
createTime: data.startTime
|
115
|
-
});
|
116
|
-
});
|
117
|
-
HTTPInterceptor_1.httpInterceptor.addListener("response", (data) => {
|
118
|
-
var _a;
|
119
|
-
(_a = this.server) === null || _a === void 0 ? void 0 : _a.network({
|
120
|
-
headers: data.responseHeaders,
|
121
|
-
body: data.responseData,
|
122
|
-
requestId: data.id,
|
123
|
-
statusCode: data.status,
|
124
|
-
endTime: data.endTime
|
125
|
-
});
|
126
|
-
});
|
127
|
-
HTTPInterceptor_1.httpInterceptor.enable({ ignoredUrls: this.handleIgnoredUrls() });
|
128
|
-
};
|
129
|
-
this.setBaseUrl = (url) => {
|
130
|
-
const tempUrl = url === null || url === void 0 ? void 0 : url.trim();
|
131
|
-
if (this.server) {
|
132
|
-
this.server.updateUrl(tempUrl);
|
133
|
-
}
|
134
|
-
else {
|
135
|
-
this.server = new Server_1.default(tempUrl);
|
136
|
-
}
|
137
|
-
HTTPInterceptor_1.httpInterceptor.setIgnoredUrls(this.handleIgnoredUrls());
|
138
|
-
if (this.isAuto) {
|
139
|
-
this.startRecordNetwork();
|
140
|
-
this.startRecordLog();
|
141
|
-
}
|
142
|
-
};
|
143
|
-
this.setTimeout = (timeout) => {
|
144
|
-
var _a;
|
145
|
-
if (typeof timeout === 'number') {
|
146
|
-
this.timeout = timeout;
|
147
|
-
(_a = this.server) === null || _a === void 0 ? void 0 : _a.updateTimeout(this.timeout);
|
148
|
-
}
|
149
|
-
};
|
150
|
-
this.getTimeout = () => {
|
151
|
-
if (typeof this.timeout === 'number') {
|
152
|
-
return this.timeout;
|
153
|
-
}
|
154
|
-
return null;
|
155
|
-
};
|
156
|
-
this.setBaseData = (data = {}) => {
|
157
|
-
this.server.updateBaseData(data);
|
158
|
-
};
|
159
|
-
this._log = (level, tag, ...data) => {
|
160
|
-
var _a;
|
161
|
-
const sendData = {
|
162
|
-
message: data,
|
163
|
-
tag,
|
164
|
-
level: level !== null && level !== void 0 ? level : 'log',
|
165
|
-
createTime: Date.now(),
|
166
|
-
};
|
167
|
-
(_a = this.server) === null || _a === void 0 ? void 0 : _a.log(sendData);
|
168
|
-
};
|
169
|
-
this.tag = (tag, ...data) => {
|
170
|
-
this._log(common_1.Level.LOG, tag, ...data);
|
171
|
-
};
|
172
|
-
this.log = (...data) => {
|
173
|
-
this._log(common_1.Level.LOG, common_1.Tag.DEFAULT, ...data);
|
174
|
-
};
|
175
|
-
this.warn = (...data) => {
|
176
|
-
this._log(common_1.Level.WARN, common_1.Tag.DEFAULT, ...data);
|
177
|
-
};
|
178
|
-
this.error = (...data) => {
|
179
|
-
this._log(common_1.Level.ERROR, common_1.Tag.DEFAULT, ...data);
|
180
|
-
};
|
181
|
-
this.init();
|
182
|
-
}
|
183
|
-
}
|
184
|
-
const SafeLogPlugin = (0, utils_1.createClassWithErrorHandling)(LogPlugin);
|
185
|
-
exports.SafeLogPlugin = SafeLogPlugin;
|
186
|
-
const logPlugin = new SafeLogPlugin();
|
187
|
-
exports.default = logPlugin;
|
188
|
-
//# sourceMappingURL=logPlugin.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"logPlugin.js","sourceRoot":"","sources":["../../src/logPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,mCAAuD;AACvD,uDAAoD;AACpD,qCAA6F;AAC7F,sDAA8B;AA4B9B,MAAM,SAAS;IAMb;QALQ,WAAM,GAAkB,IAAI,CAAC;QAC7B,YAAO,GAAkB,IAAI,CAAC;QAC9B,WAAM,GAAG,KAAK,CAAA;QACd,YAAO,GAAmB,IAAA,0BAAiB,GAAE,CAAC;QAM9C,SAAI,GAAG,GAAS,EAAE;YACxB,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,EAAE,CAAC;YAE3B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAQ,CAAC,CAAA;gBACpD,IAAI,OAAO,EAAE,CAAC;oBACZ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;oBAChC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;gBAC1C,CAAC;YACH,CAAC;YAGD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,EAAE,EAAE;gBACrC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;gBACxD,CAAC;gBACD,iCAAe,CA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AG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QACrC,CAAC,CAAA;QAED,QAAG,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,cAAK,CAAC,GAAG,EAAE,YAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC7C,CAAC,CAAA;QAED,SAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,cAAK,CAAC,IAAI,EAAE,YAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAA;QAED,UAAK,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;YACzB,IAAI,CAAC,IAAI,CAAC,cAAK,CAAC,KAAK,EAAE,YAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAA;QAzLC,IAAI,CAAC,IAAI,EAAE,CAAA;IACb,CAAC;CA0LF;AACD,MAAM,aAAa,GAAG,IAAA,oCAA4B,EAAC,SAAS,CAAC,CAAA;AAEpD,sCAAa;AADtB,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;AAEtC,kBAAe,SAAS,CAAC"}
|
package/dist/src/logger.d.ts
DELETED
package/dist/src/logger.js
DELETED
@@ -1,16 +0,0 @@
|
|
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
|
package/dist/src/logger.js.map
DELETED
@@ -1 +0,0 @@
|
|
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.d.ts
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
export declare function sleep(ms: number, isReject?: boolean): Promise<unknown>;
|
2
|
-
export declare function hasPort(url: string): boolean;
|
3
|
-
type Constructor<T = {}> = new (...args: any[]) => T;
|
4
|
-
export declare function createClassWithErrorHandling<T extends Constructor>(BaseClass: T): T;
|
5
|
-
export declare function formDataToString(formData: FormData): string;
|
6
|
-
export {};
|
package/dist/src/utils.js
DELETED
@@ -1,106 +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.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"));
|
12
|
-
function sleep(ms, isReject = false) {
|
13
|
-
return new Promise((resolve, reject) => {
|
14
|
-
setTimeout(isReject ? () => reject({
|
15
|
-
code: 11001,
|
16
|
-
key: '@wutiange/log-listener-plugin%%timeout',
|
17
|
-
message: 'Timeout'
|
18
|
-
}) : resolve, ms);
|
19
|
-
});
|
20
|
-
}
|
21
|
-
function hasPort(url) {
|
22
|
-
if (!url || typeof url !== 'string') {
|
23
|
-
return false;
|
24
|
-
}
|
25
|
-
try {
|
26
|
-
const parsedUrl = new url_parse_1.default(url);
|
27
|
-
return parsedUrl.port !== '';
|
28
|
-
}
|
29
|
-
catch (error) {
|
30
|
-
logger_1.default.error(error);
|
31
|
-
return false;
|
32
|
-
}
|
33
|
-
}
|
34
|
-
function createClassWithErrorHandling(BaseClass) {
|
35
|
-
return new Proxy(BaseClass, {
|
36
|
-
construct(target, args) {
|
37
|
-
const instance = new target(...args);
|
38
|
-
return new Proxy(instance, {
|
39
|
-
get(target, prop) {
|
40
|
-
const value = target[prop];
|
41
|
-
if (typeof value === 'function') {
|
42
|
-
return function (...args) {
|
43
|
-
try {
|
44
|
-
const result = value.apply(this, args);
|
45
|
-
if (result instanceof Promise) {
|
46
|
-
return result.catch((error) => {
|
47
|
-
logger_1.default.error(`Error in ${String(prop)}:`, error);
|
48
|
-
throw error;
|
49
|
-
});
|
50
|
-
}
|
51
|
-
return result;
|
52
|
-
}
|
53
|
-
catch (error) {
|
54
|
-
logger_1.default.error(`Error in ${String(prop)}:`, error);
|
55
|
-
throw error;
|
56
|
-
}
|
57
|
-
};
|
58
|
-
}
|
59
|
-
return value;
|
60
|
-
},
|
61
|
-
set(target, prop, value) {
|
62
|
-
if (typeof value === 'function') {
|
63
|
-
target[prop] = function (...args) {
|
64
|
-
try {
|
65
|
-
const result = value.apply(this, args);
|
66
|
-
if (result instanceof Promise) {
|
67
|
-
return result.catch((error) => {
|
68
|
-
logger_1.default.error(`Error in ${String(prop)}:`, error);
|
69
|
-
throw error;
|
70
|
-
});
|
71
|
-
}
|
72
|
-
return result;
|
73
|
-
}
|
74
|
-
catch (error) {
|
75
|
-
logger_1.default.error(`Error in ${String(prop)}:`, error);
|
76
|
-
throw error;
|
77
|
-
}
|
78
|
-
};
|
79
|
-
}
|
80
|
-
else {
|
81
|
-
target[prop] = value;
|
82
|
-
}
|
83
|
-
return true;
|
84
|
-
}
|
85
|
-
});
|
86
|
-
}
|
87
|
-
});
|
88
|
-
}
|
89
|
-
function formDataToString(formData) {
|
90
|
-
const boundary = '----WebKitFormBoundary' + Math.random().toString(36).substr(2);
|
91
|
-
let result = '';
|
92
|
-
const parts = formData.getParts();
|
93
|
-
for (const part of parts) {
|
94
|
-
result += `--${boundary}\r\n`;
|
95
|
-
result += `Content-Disposition: ${part.headers['content-disposition']}\r\n`;
|
96
|
-
if (part.headers['content-type']) {
|
97
|
-
result += `Content-Type: ${part.headers['content-type']}\r\n`;
|
98
|
-
}
|
99
|
-
const value = 'string' in part ? part.string : part.uri;
|
100
|
-
result += `Content-Length: ${value.length}\r\n\r\n`;
|
101
|
-
result += `${value}\r\n`;
|
102
|
-
}
|
103
|
-
result += `--${boundary}--\r\n`;
|
104
|
-
return result;
|
105
|
-
}
|
106
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/src/utils.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;AAGA,sBAQC;AAGD,0BAkBC;AAKD,oEAmDC;AAGD,4CAkBC;AA7GD,0DAA4B;AAC5B,sDAA8B;AAE9B,SAAgB,KAAK,CAAC,EAAU,EAAE,WAAoB,KAAK;IACzD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;YACjC,IAAI,EAAE,KAAK;YACX,GAAG,EAAE,wCAAwC;YAC7C,OAAO,EAAE,SA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AAkB;IACjD,MAAM,QAAQ,GACZ,wBAAwB,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,MAAM,KAAK,GAAI,QAAgB,CAAC,QAAQ,EAAE,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,QAAQ,MAAM,CAAC;QAC9B,MAAM,IAAI,wBAAwB,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC;QAC5E,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,iBAAiB,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC;QAChE,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACxD,MAAM,IAAI,mBAAmB,KAAK,CAAC,MAAM,UAAU,CAAC;QACpD,MAAM,IAAI,GAAG,KAAK,MAAM,CAAC;IAC3B,CAAC;IACD,MAAM,IAAI,KAAK,QAAQ,QAAQ,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/tsconfig.json
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"module": "NodeNext",
|
4
|
-
"declaration": true,
|
5
|
-
"noImplicitAny": true,
|
6
|
-
"removeComments": true,
|
7
|
-
"preserveConstEnums": true,
|
8
|
-
"outDir": "dist",
|
9
|
-
"sourceMap": true,
|
10
|
-
"target": "es6",
|
11
|
-
"moduleResolution": "NodeNext",
|
12
|
-
"allowJs": true,
|
13
|
-
"esModuleInterop": true,
|
14
|
-
"skipLibCheck": true,
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
16
|
-
"resolveJsonModule": true,
|
17
|
-
"allowSyntheticDefaultImports": true
|
18
|
-
},
|
19
|
-
"exclude": ["node_modules", "**/*.spec.ts"],
|
20
|
-
"include": [
|
21
|
-
"src/**/*",
|
22
|
-
"console.ts",
|
23
|
-
"fetch.ts",
|
24
|
-
"index.ts",
|
25
|
-
"react-native-extensions.d.ts"
|
26
|
-
]
|
27
|
-
}
|