dreaction-react-native 1.3.1 → 1.3.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/lib/dreaction.d.ts +3 -3
- package/lib/dreaction.d.ts.map +1 -1
- package/lib/dreaction.js +1 -1
- package/lib/plugins/asyncStorage.d.ts +1 -1
- package/lib/plugins/asyncStorage.d.ts.map +1 -1
- package/lib/plugins/asyncStorage.js +54 -54
- package/lib/plugins/networking.d.ts +1 -1
- package/lib/plugins/networking.d.ts.map +1 -1
- package/lib/plugins/networking.js +9 -9
- package/lib/plugins/trackGlobalErrors.d.ts +2 -2
- package/lib/plugins/trackGlobalErrors.d.ts.map +1 -1
- package/lib/plugins/trackGlobalErrors.js +6 -6
- package/lib/plugins/trackGlobalLogs.d.ts +2 -2
- package/lib/plugins/trackGlobalLogs.d.ts.map +1 -1
- package/lib/plugins/trackGlobalLogs.js +4 -4
- package/package.json +3 -3
- package/src/dreaction.ts +6 -6
- package/src/plugins/asyncStorage.ts +54 -54
- package/src/plugins/networking.ts +9 -9
- package/src/plugins/trackGlobalErrors.ts +6 -6
- package/src/plugins/trackGlobalLogs.ts +4 -4
package/lib/dreaction.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientOptions, InferFeaturesFromPlugins,
|
|
1
|
+
import type { ClientOptions, InferFeaturesFromPlugins, DReaction, DReactionCore } from 'dreaction-client-core';
|
|
2
2
|
import type { AsyncStorageStatic } from '@react-native-async-storage/async-storage';
|
|
3
3
|
import { AsyncStorageOptions } from './plugins/asyncStorage';
|
|
4
4
|
import { OpenInEditorOptions } from './plugins/openInEditor';
|
|
@@ -16,7 +16,7 @@ export interface UseReactNativeOptions {
|
|
|
16
16
|
devTools?: boolean;
|
|
17
17
|
}
|
|
18
18
|
type ReactNativePluginFeatures = InferFeaturesFromPlugins<DReactionCore, typeof reactNativeCorePlugins>;
|
|
19
|
-
export interface
|
|
19
|
+
export interface DReactionReactNative extends DReaction, ReactNativePluginFeatures {
|
|
20
20
|
useReactNative: (options?: UseReactNativeOptions) => this;
|
|
21
21
|
asyncStorageHandler?: AsyncStorageStatic;
|
|
22
22
|
setAsyncStorageHandler: (asyncStorage: AsyncStorageStatic) => this;
|
|
@@ -31,5 +31,5 @@ export interface ReactotronReactNative extends Reactotron, ReactNativePluginFeat
|
|
|
31
31
|
useDebugDataWatch: (target: unknown) => void;
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
export declare const dreaction:
|
|
34
|
+
export declare const dreaction: DReactionReactNative;
|
|
35
35
|
//# sourceMappingURL=dreaction.d.ts.map
|
package/lib/dreaction.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dreaction.d.ts","sourceRoot":"","sources":["../src/dreaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EAExB,
|
|
1
|
+
{"version":3,"file":"dreaction.d.ts","sourceRoot":"","sources":["../src/dreaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EAExB,SAAS,EACT,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAGpF,OAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAA0B,EACxB,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,YAAY,EAAE,aAAa,EAAE,CAAC;AAM9B,eAAO,MAAM,sBAAsB,OAOO,CAAC;AAE3C,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC;IACvC,YAAY,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC;IAC7C,UAAU,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,KAAK,yBAAyB,GAAG,wBAAwB,CACvD,aAAa,EACb,OAAO,sBAAsB,CAC9B,CAAC;AAEF,MAAM,WAAW,oBACf,SAAQ,SAAS,EAEf,yBAAyB;IAC3B,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC1D,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;IACzC,sBAAsB,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnE,mBAAmB,EAAE,CAAC,CAAC,GAAG,OAAO,EAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC9B,OAAO,CAAC,EAAE;QACR;;WAEG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,KACE;QACH,iBAAiB,EAAE,CAAC,GAAG,SAAS,CAAC;QACjC,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;QAC1C,iBAAiB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;KAC9C,CAAC;CACH;AAkFD,eAAO,MAAM,SAAS,sBAA+C,CAAC"}
|
package/lib/dreaction.js
CHANGED
|
@@ -17,7 +17,7 @@ const trackGlobalLogs_1 = __importDefault(require("./plugins/trackGlobalLogs"));
|
|
|
17
17
|
const getReactNativePlatformConstants_1 = __importDefault(require("./helpers/getReactNativePlatformConstants"));
|
|
18
18
|
const react_1 = require("react");
|
|
19
19
|
const getHost_1 = require("./helpers/getHost");
|
|
20
|
-
const DREACTION_ASYNC_CLIENT_ID = '@
|
|
20
|
+
const DREACTION_ASYNC_CLIENT_ID = '@DREACTION/clientId';
|
|
21
21
|
let tempClientId = null;
|
|
22
22
|
exports.reactNativeCorePlugins = [
|
|
23
23
|
(0, asyncStorage_1.default)(),
|
|
@@ -2,7 +2,7 @@ import type { DReactionCore } from 'dreaction-client-core';
|
|
|
2
2
|
export interface AsyncStorageOptions {
|
|
3
3
|
ignore?: string[];
|
|
4
4
|
}
|
|
5
|
-
declare const asyncStorage: (options?: AsyncStorageOptions) => (
|
|
5
|
+
declare const asyncStorage: (options?: AsyncStorageOptions) => (dreaction: DReactionCore) => {
|
|
6
6
|
features: {
|
|
7
7
|
trackAsyncStorage: () => void;
|
|
8
8
|
untrackAsyncStorage: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncStorage.d.ts","sourceRoot":"","sources":["../../src/plugins/asyncStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAU,MAAM,uBAAuB,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAMD,QAAA,MAAM,YAAY,aACL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"asyncStorage.d.ts","sourceRoot":"","sources":["../../src/plugins/asyncStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAU,MAAM,uBAAuB,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAMD,QAAA,MAAM,YAAY,aACL,mBAAmB,iBAAiB,aAAa;;;;;CA+M3D,CAAC;AAEJ,eAAe,YAAY,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const PLUGIN_DEFAULTS = {
|
|
4
4
|
ignore: [],
|
|
5
5
|
};
|
|
6
|
-
const asyncStorage = (options) => (
|
|
6
|
+
const asyncStorage = (options) => (dreaction) => {
|
|
7
7
|
// setup configuration
|
|
8
8
|
const config = Object.assign({}, PLUGIN_DEFAULTS, options || {});
|
|
9
9
|
const ignore = config.ignore || PLUGIN_DEFAULTS.ignore;
|
|
@@ -15,13 +15,13 @@ const asyncStorage = (options) => (reactotron) => {
|
|
|
15
15
|
let swizzMultiRemove;
|
|
16
16
|
let swizzMultiMerge;
|
|
17
17
|
let isSwizzled = false;
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const sendToDReaction = (action, data) => {
|
|
19
|
+
dreaction.send('asyncStorage.mutation', { action, data });
|
|
20
20
|
};
|
|
21
21
|
const setItem = async (key, value, callback) => {
|
|
22
22
|
try {
|
|
23
23
|
if (ignore.indexOf(key) < 0) {
|
|
24
|
-
|
|
24
|
+
sendToDReaction('setItem', { key, value });
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
catch (e) { }
|
|
@@ -30,7 +30,7 @@ const asyncStorage = (options) => (reactotron) => {
|
|
|
30
30
|
const removeItem = async (key, callback) => {
|
|
31
31
|
try {
|
|
32
32
|
if (ignore.indexOf(key) < 0) {
|
|
33
|
-
|
|
33
|
+
sendToDReaction('removeItem', { key });
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
catch (e) { }
|
|
@@ -39,7 +39,7 @@ const asyncStorage = (options) => (reactotron) => {
|
|
|
39
39
|
const mergeItem = async (key, value, callback) => {
|
|
40
40
|
try {
|
|
41
41
|
if (ignore.indexOf(key) < 0) {
|
|
42
|
-
|
|
42
|
+
sendToDReaction('mergeItem', { key, value });
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
catch (e) { }
|
|
@@ -47,7 +47,7 @@ const asyncStorage = (options) => (reactotron) => {
|
|
|
47
47
|
};
|
|
48
48
|
const clear = async (callback) => {
|
|
49
49
|
try {
|
|
50
|
-
|
|
50
|
+
sendToDReaction('clear');
|
|
51
51
|
}
|
|
52
52
|
catch (e) { }
|
|
53
53
|
return swizzClear(callback);
|
|
@@ -56,7 +56,7 @@ const asyncStorage = (options) => (reactotron) => {
|
|
|
56
56
|
try {
|
|
57
57
|
const shippablePairs = (pairs || []).filter((pair) => pair && pair[0] && ignore.indexOf(pair[0]) < 0);
|
|
58
58
|
if (shippablePairs.length > 0) {
|
|
59
|
-
|
|
59
|
+
sendToDReaction('multiSet', { pairs: shippablePairs });
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
catch (e) { }
|
|
@@ -66,7 +66,7 @@ const asyncStorage = (options) => (reactotron) => {
|
|
|
66
66
|
try {
|
|
67
67
|
const shippableKeys = (keys || []).filter((key) => ignore.indexOf(key) < 0);
|
|
68
68
|
if (shippableKeys.length > 0) {
|
|
69
|
-
|
|
69
|
+
sendToDReaction('multiRemove', { keys: shippableKeys });
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
catch (e) { }
|
|
@@ -76,7 +76,7 @@ const asyncStorage = (options) => (reactotron) => {
|
|
|
76
76
|
try {
|
|
77
77
|
const shippablePairs = (pairs || []).filter((pair) => pair && pair[0] && ignore.indexOf(pair[0]) < 0);
|
|
78
78
|
if (shippablePairs.length > 0) {
|
|
79
|
-
|
|
79
|
+
sendToDReaction('multiMerge', { pairs: shippablePairs });
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
catch (e) { }
|
|
@@ -89,78 +89,78 @@ const asyncStorage = (options) => (reactotron) => {
|
|
|
89
89
|
if (isSwizzled)
|
|
90
90
|
return;
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
92
|
-
// @ts-ignore:
|
|
93
|
-
swizzSetItem =
|
|
92
|
+
// @ts-ignore: dreaction-apis
|
|
93
|
+
swizzSetItem = dreaction.asyncStorageHandler.setItem;
|
|
94
94
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
95
|
-
// @ts-ignore:
|
|
96
|
-
|
|
95
|
+
// @ts-ignore: dreaction-apis
|
|
96
|
+
dreaction.asyncStorageHandler.setItem = setItem;
|
|
97
97
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
98
|
-
// @ts-ignore:
|
|
99
|
-
swizzRemoveItem =
|
|
98
|
+
// @ts-ignore: dreaction-apis
|
|
99
|
+
swizzRemoveItem = dreaction.asyncStorageHandler.removeItem;
|
|
100
100
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
101
|
-
// @ts-ignore:
|
|
102
|
-
|
|
101
|
+
// @ts-ignore: dreaction-apis
|
|
102
|
+
dreaction.asyncStorageHandler.removeItem = removeItem;
|
|
103
103
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
104
|
-
// @ts-ignore:
|
|
105
|
-
swizzMergeItem =
|
|
104
|
+
// @ts-ignore: dreaction-apis
|
|
105
|
+
swizzMergeItem = dreaction.asyncStorageHandler.mergeItem;
|
|
106
106
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
107
|
-
// @ts-ignore:
|
|
108
|
-
|
|
107
|
+
// @ts-ignore: dreaction-apis
|
|
108
|
+
dreaction.asyncStorageHandler.mergeItem = mergeItem;
|
|
109
109
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
110
|
-
// @ts-ignore:
|
|
111
|
-
swizzClear =
|
|
110
|
+
// @ts-ignore: dreaction-apis
|
|
111
|
+
swizzClear = dreaction.asyncStorageHandler.clear;
|
|
112
112
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
113
|
-
// @ts-ignore:
|
|
114
|
-
|
|
113
|
+
// @ts-ignore: dreaction-apis
|
|
114
|
+
dreaction.asyncStorageHandler.clear = clear;
|
|
115
115
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
116
|
-
// @ts-ignore:
|
|
117
|
-
swizzMultiSet =
|
|
116
|
+
// @ts-ignore: dreaction-apis
|
|
117
|
+
swizzMultiSet = dreaction.asyncStorageHandler.multiSet;
|
|
118
118
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
119
|
-
// @ts-ignore:
|
|
120
|
-
|
|
119
|
+
// @ts-ignore: dreaction-apis
|
|
120
|
+
dreaction.asyncStorageHandler.multiSet = multiSet;
|
|
121
121
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
122
|
-
// @ts-ignore:
|
|
123
|
-
swizzMultiRemove =
|
|
122
|
+
// @ts-ignore: dreaction-apis
|
|
123
|
+
swizzMultiRemove = dreaction.asyncStorageHandler.multiRemove;
|
|
124
124
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
125
|
-
// @ts-ignore:
|
|
126
|
-
|
|
125
|
+
// @ts-ignore: dreaction-apis
|
|
126
|
+
dreaction.asyncStorageHandler.multiRemove = multiRemove;
|
|
127
127
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
128
|
-
// @ts-ignore:
|
|
129
|
-
swizzMultiMerge =
|
|
128
|
+
// @ts-ignore: dreaction-apis
|
|
129
|
+
swizzMultiMerge = dreaction.asyncStorageHandler.multiMerge;
|
|
130
130
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
131
|
-
// @ts-ignore:
|
|
132
|
-
|
|
131
|
+
// @ts-ignore: dreaction-apis
|
|
132
|
+
dreaction.asyncStorageHandler.multiMerge = multiMerge;
|
|
133
133
|
isSwizzled = true;
|
|
134
134
|
};
|
|
135
135
|
const untrackAsyncStorage = () => {
|
|
136
136
|
if (!isSwizzled)
|
|
137
137
|
return;
|
|
138
138
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
139
|
-
// @ts-ignore:
|
|
140
|
-
|
|
139
|
+
// @ts-ignore: dreaction-apis
|
|
140
|
+
dreaction.asyncStorageHandler.setItem = swizzSetItem;
|
|
141
141
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
142
|
-
// @ts-ignore:
|
|
143
|
-
|
|
142
|
+
// @ts-ignore: dreaction-apis
|
|
143
|
+
dreaction.asyncStorageHandler.removeItem = swizzRemoveItem;
|
|
144
144
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
145
|
-
// @ts-ignore:
|
|
146
|
-
|
|
145
|
+
// @ts-ignore: dreaction-apis
|
|
146
|
+
dreaction.asyncStorageHandler.mergeItem = swizzMergeItem;
|
|
147
147
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
148
|
-
// @ts-ignore:
|
|
149
|
-
|
|
148
|
+
// @ts-ignore: dreaction-apis
|
|
149
|
+
dreaction.asyncStorageHandler.clear = swizzClear;
|
|
150
150
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
151
|
-
// @ts-ignore:
|
|
152
|
-
|
|
151
|
+
// @ts-ignore: dreaction-apis
|
|
152
|
+
dreaction.asyncStorageHandler.multiSet = swizzMultiSet;
|
|
153
153
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
154
|
-
// @ts-ignore:
|
|
155
|
-
|
|
154
|
+
// @ts-ignore: dreaction-apis
|
|
155
|
+
dreaction.asyncStorageHandler.multiRemove = swizzMultiRemove;
|
|
156
156
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
157
|
-
// @ts-ignore:
|
|
158
|
-
|
|
157
|
+
// @ts-ignore: dreaction-apis
|
|
158
|
+
dreaction.asyncStorageHandler.multiMerge = swizzMultiMerge;
|
|
159
159
|
isSwizzled = false;
|
|
160
160
|
};
|
|
161
161
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
162
|
-
// @ts-ignore:
|
|
163
|
-
if (
|
|
162
|
+
// @ts-ignore: dreaction-apis
|
|
163
|
+
if (dreaction.asyncStorageHandler) {
|
|
164
164
|
trackAsyncStorage();
|
|
165
165
|
}
|
|
166
166
|
return {
|
|
@@ -3,7 +3,7 @@ export interface NetworkingOptions {
|
|
|
3
3
|
ignoreContentTypes?: RegExp;
|
|
4
4
|
ignoreUrls?: RegExp;
|
|
5
5
|
}
|
|
6
|
-
declare const networking: (pluginConfig?: NetworkingOptions) => (
|
|
6
|
+
declare const networking: (pluginConfig?: NetworkingOptions) => (dreaction: DReactionCore) => {
|
|
7
7
|
onConnect: () => void;
|
|
8
8
|
};
|
|
9
9
|
export default networking;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networking.d.ts","sourceRoot":"","sources":["../../src/plugins/networking.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAU,MAAM,uBAAuB,CAAC;AAOnE,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAMD,QAAA,MAAM,UAAU,kBACC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"networking.d.ts","sourceRoot":"","sources":["../../src/plugins/networking.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAU,MAAM,uBAAuB,CAAC;AAOnE,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAMD,QAAA,MAAM,UAAU,kBACC,iBAAiB,iBACpB,aAAa;;CAwJxB,CAAC;AACJ,eAAe,UAAU,CAAC"}
|
|
@@ -12,12 +12,12 @@ const DEFAULT_CONTENT_TYPES_RX = /^(image)\/.*$/i;
|
|
|
12
12
|
const DEFAULTS = {
|
|
13
13
|
ignoreUrls: /symbolicate/,
|
|
14
14
|
};
|
|
15
|
-
const networking = (pluginConfig = {}) => (
|
|
15
|
+
const networking = (pluginConfig = {}) => (dreaction) => {
|
|
16
16
|
const options = Object.assign({}, DEFAULTS, pluginConfig);
|
|
17
17
|
// a RegExp to suppress adding the body cuz it costs a lot to serialize
|
|
18
18
|
const ignoreContentTypes = options.ignoreContentTypes || DEFAULT_CONTENT_TYPES_RX;
|
|
19
19
|
// a XHR call tracker
|
|
20
|
-
let
|
|
20
|
+
let dreactionCounter = 1000;
|
|
21
21
|
// a temporary cache to hold requests so we can match up the data
|
|
22
22
|
const requestCache = {};
|
|
23
23
|
/**
|
|
@@ -28,18 +28,18 @@ const networking = (pluginConfig = {}) => (reactotron) => {
|
|
|
28
28
|
*/
|
|
29
29
|
function onSend(data, xhr) {
|
|
30
30
|
if (options.ignoreUrls && options.ignoreUrls.test(xhr._url)) {
|
|
31
|
-
xhr.
|
|
31
|
+
xhr._skipDReaction = true;
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
// bump the counter
|
|
35
|
-
|
|
35
|
+
dreactionCounter++;
|
|
36
36
|
// tag
|
|
37
|
-
xhr._trackingName =
|
|
37
|
+
xhr._trackingName = dreactionCounter;
|
|
38
38
|
// cache
|
|
39
|
-
requestCache[
|
|
39
|
+
requestCache[dreactionCounter] = {
|
|
40
40
|
data,
|
|
41
41
|
xhr,
|
|
42
|
-
stopTimer:
|
|
42
|
+
stopTimer: dreaction.startTimer(),
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -53,7 +53,7 @@ const networking = (pluginConfig = {}) => (reactotron) => {
|
|
|
53
53
|
* @param {*} xhr - The XMLHttpRequest instance.
|
|
54
54
|
*/
|
|
55
55
|
function onResponse(status, timeout, response, url, type, xhr) {
|
|
56
|
-
if (xhr.
|
|
56
|
+
if (xhr._skipDReaction) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
let params = null;
|
|
@@ -103,7 +103,7 @@ const networking = (pluginConfig = {}) => (reactotron) => {
|
|
|
103
103
|
status,
|
|
104
104
|
headers: xhr.responseHeaders || null,
|
|
105
105
|
};
|
|
106
|
-
|
|
106
|
+
dreaction.apiResponse(tronRequest, tronResponse, stopTimer ? stopTimer() : null); // TODO: Fix
|
|
107
107
|
};
|
|
108
108
|
// can we use the real response?
|
|
109
109
|
const useRealResponse = (typeof response === 'string' || typeof response === 'object') &&
|
|
@@ -20,9 +20,9 @@ export interface TrackGlobalErrorsOptions {
|
|
|
20
20
|
veto?: (frame: ErrorStackFrame) => boolean;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Track global errors and send them to
|
|
23
|
+
* Track global errors and send them to DReaction logger.
|
|
24
24
|
*/
|
|
25
|
-
declare const trackGlobalErrors: (options?: TrackGlobalErrorsOptions) => (
|
|
25
|
+
declare const trackGlobalErrors: (options?: TrackGlobalErrorsOptions) => (dreaction: DReactionCore) => {
|
|
26
26
|
onConnect: () => void;
|
|
27
27
|
features: {
|
|
28
28
|
reportError: (error: Parameters<typeof LogBox.addException>[0]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackGlobalErrors.d.ts","sourceRoot":"","sources":["../../src/plugins/trackGlobalErrors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGL,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAC/B,OAAgB,EACd,YAAY,IAAI,kBAAkB,EAEnC,MAAM,sCAAsC,CAAC;AAM9C,UAAU,mBAAoB,SAAQ,kBAAkB;IACtD;;OAEG;IAEH,YAAY,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACpC;AAED,QAAA,MAAM,MAAM,EAAyB,mBAAmB,CAAC;AAOzD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC;CAC5C;AAiBD;;GAEG;AACH,QAAA,MAAM,iBAAiB,aACV,wBAAwB,
|
|
1
|
+
{"version":3,"file":"trackGlobalErrors.d.ts","sourceRoot":"","sources":["../../src/plugins/trackGlobalErrors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGL,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAC/B,OAAgB,EACd,YAAY,IAAI,kBAAkB,EAEnC,MAAM,sCAAsC,CAAC;AAM9C,UAAU,mBAAoB,SAAQ,kBAAkB;IACtD;;OAEG;IAEH,YAAY,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACpC;AAED,QAAA,MAAM,MAAM,EAAyB,mBAAmB,CAAC;AAOzD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC;CAC5C;AAiBD;;GAEG;AACH,QAAA,MAAM,iBAAiB,aACV,wBAAwB,iBAAiB,aAAa;;;6BAUnC,UAAU,CAAC,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;;CA+EtE,CAAC;AAEJ,eAAe,iBAAiB,CAAC"}
|
|
@@ -26,12 +26,12 @@ const objectifyError = (error) => {
|
|
|
26
26
|
};
|
|
27
27
|
// const reactNativeFrameFinder = frame => contains('/node_modules/react-native/', frame.fileName)
|
|
28
28
|
/**
|
|
29
|
-
* Track global errors and send them to
|
|
29
|
+
* Track global errors and send them to DReaction logger.
|
|
30
30
|
*/
|
|
31
|
-
const trackGlobalErrors = (options) => (
|
|
31
|
+
const trackGlobalErrors = (options) => (dreaction) => {
|
|
32
32
|
// make sure we have the logger plugin
|
|
33
|
-
(0, dreaction_client_core_1.assertHasLoggerPlugin)(
|
|
34
|
-
const client =
|
|
33
|
+
(0, dreaction_client_core_1.assertHasLoggerPlugin)(dreaction);
|
|
34
|
+
const client = dreaction;
|
|
35
35
|
// setup configuration
|
|
36
36
|
const config = Object.assign({}, PLUGIN_DEFAULTS, options || {});
|
|
37
37
|
// manually fire an error
|
|
@@ -80,7 +80,7 @@ const trackGlobalErrors = (options) => (reactotron) => {
|
|
|
80
80
|
client.debug(objectifyError(e));
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
// the
|
|
83
|
+
// the dreaction plugin interface
|
|
84
84
|
return {
|
|
85
85
|
onConnect: () => {
|
|
86
86
|
LogBox.addException = new Proxy(LogBox.addException, {
|
|
@@ -91,7 +91,7 @@ const trackGlobalErrors = (options) => (reactotron) => {
|
|
|
91
91
|
},
|
|
92
92
|
});
|
|
93
93
|
},
|
|
94
|
-
// attach these functions to the
|
|
94
|
+
// attach these functions to the DReaction
|
|
95
95
|
features: {
|
|
96
96
|
reportError,
|
|
97
97
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DReactionCore } from 'dreaction-client-core';
|
|
2
2
|
/**
|
|
3
|
-
* Track calls to console.log, console.warn, and console.debug and send them to
|
|
3
|
+
* Track calls to console.log, console.warn, and console.debug and send them to DReaction logger
|
|
4
4
|
*/
|
|
5
|
-
declare const trackGlobalLogs: () => (
|
|
5
|
+
declare const trackGlobalLogs: () => (dreaction: DReactionCore) => {
|
|
6
6
|
onConnect: () => void;
|
|
7
7
|
};
|
|
8
8
|
export default trackGlobalLogs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trackGlobalLogs.d.ts","sourceRoot":"","sources":["../../src/plugins/trackGlobalLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,QAAA,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"trackGlobalLogs.d.ts","sourceRoot":"","sources":["../../src/plugins/trackGlobalLogs.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,QAAA,MAAM,eAAe,oBAAqB,aAAa;;CA4BtD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const dreaction_client_core_1 = require("dreaction-client-core");
|
|
4
4
|
/**
|
|
5
|
-
* Track calls to console.log, console.warn, and console.debug and send them to
|
|
5
|
+
* Track calls to console.log, console.warn, and console.debug and send them to DReaction logger
|
|
6
6
|
*/
|
|
7
|
-
const trackGlobalLogs = () => (
|
|
8
|
-
(0, dreaction_client_core_1.assertHasLoggerPlugin)(
|
|
9
|
-
const client =
|
|
7
|
+
const trackGlobalLogs = () => (dreaction) => {
|
|
8
|
+
(0, dreaction_client_core_1.assertHasLoggerPlugin)(dreaction);
|
|
9
|
+
const client = dreaction;
|
|
10
10
|
return {
|
|
11
11
|
onConnect: () => {
|
|
12
12
|
const originalConsoleLog = console.log;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dreaction-react-native",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"author": "moonrailgun <moonrailgun@gmail.com>",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"dreaction-
|
|
19
|
-
"dreaction-
|
|
18
|
+
"dreaction-protocol": "1.0.1",
|
|
19
|
+
"dreaction-client-core": "1.1.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/react-native": "^0.73.0",
|
package/src/dreaction.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
ClientOptions,
|
|
5
5
|
InferFeaturesFromPlugins,
|
|
6
6
|
PluginCreator,
|
|
7
|
-
|
|
7
|
+
DReaction,
|
|
8
8
|
DReactionCore,
|
|
9
9
|
} from 'dreaction-client-core';
|
|
10
10
|
// @ts-ignore
|
|
@@ -26,7 +26,7 @@ import { getHost } from './helpers/getHost';
|
|
|
26
26
|
|
|
27
27
|
export type { ClientOptions };
|
|
28
28
|
|
|
29
|
-
const DREACTION_ASYNC_CLIENT_ID = '@
|
|
29
|
+
const DREACTION_ASYNC_CLIENT_ID = '@DREACTION/clientId';
|
|
30
30
|
|
|
31
31
|
let tempClientId: string | null = null;
|
|
32
32
|
|
|
@@ -53,8 +53,8 @@ type ReactNativePluginFeatures = InferFeaturesFromPlugins<
|
|
|
53
53
|
typeof reactNativeCorePlugins
|
|
54
54
|
>;
|
|
55
55
|
|
|
56
|
-
export interface
|
|
57
|
-
extends
|
|
56
|
+
export interface DReactionReactNative
|
|
57
|
+
extends DReaction,
|
|
58
58
|
// @ts-ignore
|
|
59
59
|
ReactNativePluginFeatures {
|
|
60
60
|
useReactNative: (options?: UseReactNativeOptions) => this;
|
|
@@ -87,7 +87,7 @@ const {
|
|
|
87
87
|
serial,
|
|
88
88
|
} = getReactNativePlatformConstants();
|
|
89
89
|
|
|
90
|
-
const DEFAULTS: ClientOptions<
|
|
90
|
+
const DEFAULTS: ClientOptions<DReactionReactNative> = {
|
|
91
91
|
createSocket: (path: string) => new WebSocket(path), // eslint-disable-line
|
|
92
92
|
host: getHost('localhost'),
|
|
93
93
|
port: 9600,
|
|
@@ -156,7 +156,7 @@ const DEFAULTS: ClientOptions<ReactotronReactNative> = {
|
|
|
156
156
|
proxyHack: true,
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
-
export const dreaction = createClient<
|
|
159
|
+
export const dreaction = createClient<DReactionReactNative>(DEFAULTS);
|
|
160
160
|
|
|
161
161
|
function getPluginOptions<T>(options?: T | boolean): T | null {
|
|
162
162
|
return typeof options === 'object' ? options : null;
|
|
@@ -10,7 +10,7 @@ const PLUGIN_DEFAULTS: AsyncStorageOptions = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
const asyncStorage =
|
|
13
|
-
(options?: AsyncStorageOptions) => (
|
|
13
|
+
(options?: AsyncStorageOptions) => (dreaction: DReactionCore) => {
|
|
14
14
|
// setup configuration
|
|
15
15
|
const config = Object.assign({}, PLUGIN_DEFAULTS, options || {});
|
|
16
16
|
const ignore = config.ignore || PLUGIN_DEFAULTS.ignore;
|
|
@@ -24,8 +24,8 @@ const asyncStorage =
|
|
|
24
24
|
let swizzMultiMerge: AsyncStorageStatic['multiMerge'];
|
|
25
25
|
let isSwizzled = false;
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const sendToDReaction = (action: string, data?: any) => {
|
|
28
|
+
dreaction.send('asyncStorage.mutation', { action, data });
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const setItem: AsyncStorageStatic['setItem'] = async (
|
|
@@ -35,7 +35,7 @@ const asyncStorage =
|
|
|
35
35
|
) => {
|
|
36
36
|
try {
|
|
37
37
|
if (ignore!.indexOf(key) < 0) {
|
|
38
|
-
|
|
38
|
+
sendToDReaction('setItem', { key, value });
|
|
39
39
|
}
|
|
40
40
|
} catch (e) {}
|
|
41
41
|
return swizzSetItem(key, value, callback);
|
|
@@ -47,7 +47,7 @@ const asyncStorage =
|
|
|
47
47
|
) => {
|
|
48
48
|
try {
|
|
49
49
|
if (ignore!.indexOf(key) < 0) {
|
|
50
|
-
|
|
50
|
+
sendToDReaction('removeItem', { key });
|
|
51
51
|
}
|
|
52
52
|
} catch (e) {}
|
|
53
53
|
return swizzRemoveItem(key, callback);
|
|
@@ -60,7 +60,7 @@ const asyncStorage =
|
|
|
60
60
|
) => {
|
|
61
61
|
try {
|
|
62
62
|
if (ignore!.indexOf(key) < 0) {
|
|
63
|
-
|
|
63
|
+
sendToDReaction('mergeItem', { key, value });
|
|
64
64
|
}
|
|
65
65
|
} catch (e) {}
|
|
66
66
|
return swizzMergeItem(key, value, callback);
|
|
@@ -68,7 +68,7 @@ const asyncStorage =
|
|
|
68
68
|
|
|
69
69
|
const clear: AsyncStorageStatic['clear'] = async (callback: any) => {
|
|
70
70
|
try {
|
|
71
|
-
|
|
71
|
+
sendToDReaction('clear');
|
|
72
72
|
} catch (e) {}
|
|
73
73
|
return swizzClear(callback);
|
|
74
74
|
};
|
|
@@ -82,7 +82,7 @@ const asyncStorage =
|
|
|
82
82
|
(pair: any) => pair && pair[0] && ignore!.indexOf(pair[0]) < 0
|
|
83
83
|
);
|
|
84
84
|
if (shippablePairs.length > 0) {
|
|
85
|
-
|
|
85
|
+
sendToDReaction('multiSet', { pairs: shippablePairs });
|
|
86
86
|
}
|
|
87
87
|
} catch (e) {}
|
|
88
88
|
return swizzMultiSet(pairs, callback);
|
|
@@ -97,7 +97,7 @@ const asyncStorage =
|
|
|
97
97
|
(key: any) => ignore!.indexOf(key) < 0
|
|
98
98
|
);
|
|
99
99
|
if (shippableKeys.length > 0) {
|
|
100
|
-
|
|
100
|
+
sendToDReaction('multiRemove', { keys: shippableKeys });
|
|
101
101
|
}
|
|
102
102
|
} catch (e) {}
|
|
103
103
|
return swizzMultiRemove(keys, callback);
|
|
@@ -112,7 +112,7 @@ const asyncStorage =
|
|
|
112
112
|
(pair: any) => pair && pair[0] && ignore!.indexOf(pair[0]) < 0
|
|
113
113
|
);
|
|
114
114
|
if (shippablePairs.length > 0) {
|
|
115
|
-
|
|
115
|
+
sendToDReaction('multiMerge', { pairs: shippablePairs });
|
|
116
116
|
}
|
|
117
117
|
} catch (e) {}
|
|
118
118
|
return swizzMultiMerge(pairs, callback);
|
|
@@ -125,54 +125,54 @@ const asyncStorage =
|
|
|
125
125
|
if (isSwizzled) return;
|
|
126
126
|
|
|
127
127
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
128
|
-
// @ts-ignore:
|
|
129
|
-
swizzSetItem =
|
|
128
|
+
// @ts-ignore: dreaction-apis
|
|
129
|
+
swizzSetItem = dreaction.asyncStorageHandler.setItem;
|
|
130
130
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
131
|
-
// @ts-ignore:
|
|
132
|
-
|
|
131
|
+
// @ts-ignore: dreaction-apis
|
|
132
|
+
dreaction.asyncStorageHandler.setItem = setItem;
|
|
133
133
|
|
|
134
134
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
135
|
-
// @ts-ignore:
|
|
136
|
-
swizzRemoveItem =
|
|
135
|
+
// @ts-ignore: dreaction-apis
|
|
136
|
+
swizzRemoveItem = dreaction.asyncStorageHandler.removeItem;
|
|
137
137
|
|
|
138
138
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
139
|
-
// @ts-ignore:
|
|
140
|
-
|
|
139
|
+
// @ts-ignore: dreaction-apis
|
|
140
|
+
dreaction.asyncStorageHandler.removeItem = removeItem;
|
|
141
141
|
|
|
142
142
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
143
|
-
// @ts-ignore:
|
|
144
|
-
swizzMergeItem =
|
|
143
|
+
// @ts-ignore: dreaction-apis
|
|
144
|
+
swizzMergeItem = dreaction.asyncStorageHandler.mergeItem;
|
|
145
145
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
146
|
-
// @ts-ignore:
|
|
147
|
-
|
|
146
|
+
// @ts-ignore: dreaction-apis
|
|
147
|
+
dreaction.asyncStorageHandler.mergeItem = mergeItem;
|
|
148
148
|
|
|
149
149
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
150
|
-
// @ts-ignore:
|
|
151
|
-
swizzClear =
|
|
150
|
+
// @ts-ignore: dreaction-apis
|
|
151
|
+
swizzClear = dreaction.asyncStorageHandler.clear;
|
|
152
152
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
153
|
-
// @ts-ignore:
|
|
154
|
-
|
|
153
|
+
// @ts-ignore: dreaction-apis
|
|
154
|
+
dreaction.asyncStorageHandler.clear = clear;
|
|
155
155
|
|
|
156
156
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
157
|
-
// @ts-ignore:
|
|
158
|
-
swizzMultiSet =
|
|
157
|
+
// @ts-ignore: dreaction-apis
|
|
158
|
+
swizzMultiSet = dreaction.asyncStorageHandler.multiSet;
|
|
159
159
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
160
|
-
// @ts-ignore:
|
|
161
|
-
|
|
160
|
+
// @ts-ignore: dreaction-apis
|
|
161
|
+
dreaction.asyncStorageHandler.multiSet = multiSet;
|
|
162
162
|
|
|
163
163
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
164
|
-
// @ts-ignore:
|
|
165
|
-
swizzMultiRemove =
|
|
164
|
+
// @ts-ignore: dreaction-apis
|
|
165
|
+
swizzMultiRemove = dreaction.asyncStorageHandler.multiRemove;
|
|
166
166
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
167
|
-
// @ts-ignore:
|
|
168
|
-
|
|
167
|
+
// @ts-ignore: dreaction-apis
|
|
168
|
+
dreaction.asyncStorageHandler.multiRemove = multiRemove;
|
|
169
169
|
|
|
170
170
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
171
|
-
// @ts-ignore:
|
|
172
|
-
swizzMultiMerge =
|
|
171
|
+
// @ts-ignore: dreaction-apis
|
|
172
|
+
swizzMultiMerge = dreaction.asyncStorageHandler.multiMerge;
|
|
173
173
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
174
|
-
// @ts-ignore:
|
|
175
|
-
|
|
174
|
+
// @ts-ignore: dreaction-apis
|
|
175
|
+
dreaction.asyncStorageHandler.multiMerge = multiMerge;
|
|
176
176
|
|
|
177
177
|
isSwizzled = true;
|
|
178
178
|
};
|
|
@@ -181,33 +181,33 @@ const asyncStorage =
|
|
|
181
181
|
if (!isSwizzled) return;
|
|
182
182
|
|
|
183
183
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
184
|
-
// @ts-ignore:
|
|
185
|
-
|
|
184
|
+
// @ts-ignore: dreaction-apis
|
|
185
|
+
dreaction.asyncStorageHandler.setItem = swizzSetItem;
|
|
186
186
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
187
|
-
// @ts-ignore:
|
|
188
|
-
|
|
187
|
+
// @ts-ignore: dreaction-apis
|
|
188
|
+
dreaction.asyncStorageHandler.removeItem = swizzRemoveItem;
|
|
189
189
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
190
|
-
// @ts-ignore:
|
|
191
|
-
|
|
190
|
+
// @ts-ignore: dreaction-apis
|
|
191
|
+
dreaction.asyncStorageHandler.mergeItem = swizzMergeItem;
|
|
192
192
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
193
|
-
// @ts-ignore:
|
|
194
|
-
|
|
193
|
+
// @ts-ignore: dreaction-apis
|
|
194
|
+
dreaction.asyncStorageHandler.clear = swizzClear;
|
|
195
195
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
196
|
-
// @ts-ignore:
|
|
197
|
-
|
|
196
|
+
// @ts-ignore: dreaction-apis
|
|
197
|
+
dreaction.asyncStorageHandler.multiSet = swizzMultiSet;
|
|
198
198
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
199
|
-
// @ts-ignore:
|
|
200
|
-
|
|
199
|
+
// @ts-ignore: dreaction-apis
|
|
200
|
+
dreaction.asyncStorageHandler.multiRemove = swizzMultiRemove;
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
202
|
-
// @ts-ignore:
|
|
203
|
-
|
|
202
|
+
// @ts-ignore: dreaction-apis
|
|
203
|
+
dreaction.asyncStorageHandler.multiMerge = swizzMultiMerge;
|
|
204
204
|
|
|
205
205
|
isSwizzled = false;
|
|
206
206
|
};
|
|
207
207
|
|
|
208
208
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
209
|
-
// @ts-ignore:
|
|
210
|
-
if (
|
|
209
|
+
// @ts-ignore: dreaction-apis
|
|
210
|
+
if (dreaction.asyncStorageHandler) {
|
|
211
211
|
trackAsyncStorage();
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -18,7 +18,7 @@ const DEFAULTS: NetworkingOptions = {
|
|
|
18
18
|
|
|
19
19
|
const networking =
|
|
20
20
|
(pluginConfig: NetworkingOptions = {}) =>
|
|
21
|
-
(
|
|
21
|
+
(dreaction: DReactionCore) => {
|
|
22
22
|
const options = Object.assign({}, DEFAULTS, pluginConfig);
|
|
23
23
|
|
|
24
24
|
// a RegExp to suppress adding the body cuz it costs a lot to serialize
|
|
@@ -26,7 +26,7 @@ const networking =
|
|
|
26
26
|
options.ignoreContentTypes || DEFAULT_CONTENT_TYPES_RX;
|
|
27
27
|
|
|
28
28
|
// a XHR call tracker
|
|
29
|
-
let
|
|
29
|
+
let dreactionCounter = 1000;
|
|
30
30
|
|
|
31
31
|
// a temporary cache to hold requests so we can match up the data
|
|
32
32
|
const requestCache = {};
|
|
@@ -39,21 +39,21 @@ const networking =
|
|
|
39
39
|
*/
|
|
40
40
|
function onSend(data: any, xhr: any) {
|
|
41
41
|
if (options.ignoreUrls && options.ignoreUrls.test(xhr._url)) {
|
|
42
|
-
xhr.
|
|
42
|
+
xhr._skipDReaction = true;
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// bump the counter
|
|
47
|
-
|
|
47
|
+
dreactionCounter++;
|
|
48
48
|
|
|
49
49
|
// tag
|
|
50
|
-
xhr._trackingName =
|
|
50
|
+
xhr._trackingName = dreactionCounter;
|
|
51
51
|
|
|
52
52
|
// cache
|
|
53
|
-
(requestCache as any)[
|
|
53
|
+
(requestCache as any)[dreactionCounter] = {
|
|
54
54
|
data,
|
|
55
55
|
xhr,
|
|
56
|
-
stopTimer:
|
|
56
|
+
stopTimer: dreaction.startTimer(),
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -75,7 +75,7 @@ const networking =
|
|
|
75
75
|
type: any,
|
|
76
76
|
xhr: any
|
|
77
77
|
) {
|
|
78
|
-
if (xhr.
|
|
78
|
+
if (xhr._skipDReaction) {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -130,7 +130,7 @@ const networking =
|
|
|
130
130
|
status,
|
|
131
131
|
headers: xhr.responseHeaders || null,
|
|
132
132
|
};
|
|
133
|
-
(
|
|
133
|
+
(dreaction as any).apiResponse(
|
|
134
134
|
tronRequest,
|
|
135
135
|
tronResponse,
|
|
136
136
|
stopTimer ? stopTimer() : null
|
|
@@ -59,13 +59,13 @@ const objectifyError = (error: Error) => {
|
|
|
59
59
|
// const reactNativeFrameFinder = frame => contains('/node_modules/react-native/', frame.fileName)
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Track global errors and send them to
|
|
62
|
+
* Track global errors and send them to DReaction logger.
|
|
63
63
|
*/
|
|
64
64
|
const trackGlobalErrors =
|
|
65
|
-
(options?: TrackGlobalErrorsOptions) => (
|
|
65
|
+
(options?: TrackGlobalErrorsOptions) => (dreaction: DReactionCore) => {
|
|
66
66
|
// make sure we have the logger plugin
|
|
67
|
-
assertHasLoggerPlugin(
|
|
68
|
-
const client =
|
|
67
|
+
assertHasLoggerPlugin(dreaction);
|
|
68
|
+
const client = dreaction as DReactionCore &
|
|
69
69
|
InferFeatures<DReactionCore, LoggerPlugin>;
|
|
70
70
|
|
|
71
71
|
// setup configuration
|
|
@@ -130,7 +130,7 @@ const trackGlobalErrors =
|
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
// the
|
|
133
|
+
// the dreaction plugin interface
|
|
134
134
|
return {
|
|
135
135
|
onConnect: () => {
|
|
136
136
|
LogBox.addException = new Proxy(LogBox.addException, {
|
|
@@ -146,7 +146,7 @@ const trackGlobalErrors =
|
|
|
146
146
|
});
|
|
147
147
|
},
|
|
148
148
|
|
|
149
|
-
// attach these functions to the
|
|
149
|
+
// attach these functions to the DReaction
|
|
150
150
|
features: {
|
|
151
151
|
reportError,
|
|
152
152
|
},
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
} from 'dreaction-client-core';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Track calls to console.log, console.warn, and console.debug and send them to
|
|
10
|
+
* Track calls to console.log, console.warn, and console.debug and send them to DReaction logger
|
|
11
11
|
*/
|
|
12
|
-
const trackGlobalLogs = () => (
|
|
13
|
-
assertHasLoggerPlugin(
|
|
14
|
-
const client =
|
|
12
|
+
const trackGlobalLogs = () => (dreaction: DReactionCore) => {
|
|
13
|
+
assertHasLoggerPlugin(dreaction);
|
|
14
|
+
const client = dreaction as DReactionCore &
|
|
15
15
|
InferFeatures<DReactionCore, LoggerPlugin>;
|
|
16
16
|
|
|
17
17
|
return {
|