dreaction-react-native 1.0.0
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/components/ConfigDialog.d.ts +9 -0
- package/lib/components/ConfigDialog.d.ts.map +1 -0
- package/lib/components/ConfigDialog.js +83 -0
- package/lib/components/DraggableBall.d.ts +3 -0
- package/lib/components/DraggableBall.d.ts.map +1 -0
- package/lib/components/DraggableBall.js +136 -0
- package/lib/dreaction.d.ts +29 -0
- package/lib/dreaction.d.ts.map +1 -0
- package/lib/dreaction.js +134 -0
- package/lib/helpers/getHost.d.ts +9 -0
- package/lib/helpers/getHost.d.ts.map +1 -0
- package/lib/helpers/getHost.js +31 -0
- package/lib/helpers/getReactNativeDimensions.d.ts +3 -0
- package/lib/helpers/getReactNativeDimensions.d.ts.map +1 -0
- package/lib/helpers/getReactNativeDimensions.js +18 -0
- package/lib/helpers/getReactNativeDimensions.test.d.ts +2 -0
- package/lib/helpers/getReactNativeDimensions.test.d.ts.map +1 -0
- package/lib/helpers/getReactNativeDimensions.test.js +20 -0
- package/lib/helpers/getReactNativeDimensionsWithDimensions.d.ts +12 -0
- package/lib/helpers/getReactNativeDimensionsWithDimensions.d.ts.map +1 -0
- package/lib/helpers/getReactNativeDimensionsWithDimensions.js +31 -0
- package/lib/helpers/getReactNativePlatformConstants.d.ts +13 -0
- package/lib/helpers/getReactNativePlatformConstants.d.ts.map +1 -0
- package/lib/helpers/getReactNativePlatformConstants.js +37 -0
- package/lib/helpers/getReactNativeVersion.d.ts +2 -0
- package/lib/helpers/getReactNativeVersion.d.ts.map +1 -0
- package/lib/helpers/getReactNativeVersion.js +8 -0
- package/lib/helpers/getReactNativeVersion.test.d.ts +2 -0
- package/lib/helpers/getReactNativeVersion.test.d.ts.map +1 -0
- package/lib/helpers/getReactNativeVersion.test.js +19 -0
- package/lib/helpers/getReactNativeVersionWithModules.d.ts +3 -0
- package/lib/helpers/getReactNativeVersionWithModules.d.ts.map +1 -0
- package/lib/helpers/getReactNativeVersionWithModules.js +32 -0
- package/lib/helpers/parseErrorStack.d.ts +5 -0
- package/lib/helpers/parseErrorStack.d.ts.map +1 -0
- package/lib/helpers/parseErrorStack.js +2 -0
- package/lib/helpers/parseURL.d.ts +9 -0
- package/lib/helpers/parseURL.d.ts.map +1 -0
- package/lib/helpers/parseURL.js +21 -0
- package/lib/helpers/parseURL.test.d.ts +2 -0
- package/lib/helpers/parseURL.test.d.ts.map +1 -0
- package/lib/helpers/parseURL.test.js +61 -0
- package/lib/helpers/symbolicateStackTrace.d.ts +18 -0
- package/lib/helpers/symbolicateStackTrace.d.ts.map +1 -0
- package/lib/helpers/symbolicateStackTrace.js +2 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +20 -0
- package/lib/plugins/asyncStorage.d.ts +12 -0
- package/lib/plugins/asyncStorage.d.ts.map +1 -0
- package/lib/plugins/asyncStorage.js +173 -0
- package/lib/plugins/devTools.d.ts +3 -0
- package/lib/plugins/devTools.d.ts.map +1 -0
- package/lib/plugins/devTools.js +24 -0
- package/lib/plugins/networking.d.ts +10 -0
- package/lib/plugins/networking.d.ts.map +1 -0
- package/lib/plugins/networking.js +139 -0
- package/lib/plugins/openInEditor.d.ts +9 -0
- package/lib/plugins/openInEditor.d.ts.map +1 -0
- package/lib/plugins/openInEditor.js +21 -0
- package/lib/plugins/overlay/index.d.ts +3 -0
- package/lib/plugins/overlay/index.d.ts.map +1 -0
- package/lib/plugins/overlay/index.js +29 -0
- package/lib/plugins/overlay/overlay.d.ts +161 -0
- package/lib/plugins/overlay/overlay.d.ts.map +1 -0
- package/lib/plugins/overlay/overlay.js +99 -0
- package/lib/plugins/storybook/index.d.ts +6 -0
- package/lib/plugins/storybook/index.d.ts.map +1 -0
- package/lib/plugins/storybook/index.js +27 -0
- package/lib/plugins/storybook/storybook.d.ts +22 -0
- package/lib/plugins/storybook/storybook.d.ts.map +1 -0
- package/lib/plugins/storybook/storybook.js +31 -0
- package/lib/plugins/trackGlobalErrors.d.ts +32 -0
- package/lib/plugins/trackGlobalErrors.d.ts.map +1 -0
- package/lib/plugins/trackGlobalErrors.js +100 -0
- package/lib/plugins/trackGlobalLogs.d.ts +9 -0
- package/lib/plugins/trackGlobalLogs.d.ts.map +1 -0
- package/lib/plugins/trackGlobalLogs.js +31 -0
- package/package.json +29 -0
- package/src/components/ConfigDialog.tsx +79 -0
- package/src/components/DraggableBall.tsx +139 -0
- package/src/dreaction.ts +221 -0
- package/src/helpers/getHost.ts +30 -0
- package/src/helpers/getReactNativeDimensions.ts +20 -0
- package/src/helpers/getReactNativeDimensionsWithDimensions.ts +45 -0
- package/src/helpers/getReactNativePlatformConstants.ts +52 -0
- package/src/helpers/getReactNativeVersion.ts +6 -0
- package/src/helpers/getReactNativeVersionWithModules.ts +37 -0
- package/src/helpers/parseErrorStack.ts +13 -0
- package/src/helpers/parseURL.ts +19 -0
- package/src/helpers/symbolicateStackTrace.ts +28 -0
- package/src/index.ts +6 -0
- package/src/plugins/asyncStorage.ts +222 -0
- package/src/plugins/devTools.ts +30 -0
- package/src/plugins/networking.ts +172 -0
- package/src/plugins/openInEditor.ts +30 -0
- package/src/plugins/trackGlobalErrors.ts +156 -0
- package/src/plugins/trackGlobalLogs.ts +42 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getReactNativeVersionWithModules_1 = require("./getReactNativeVersionWithModules");
|
|
4
|
+
describe("getReactNativeVersion", () => {
|
|
5
|
+
it("should return null if platform constants is null", () => {
|
|
6
|
+
const result = (0, getReactNativeVersionWithModules_1.getReactNativeVersionWithModules)({});
|
|
7
|
+
expect(result).toBe(null);
|
|
8
|
+
});
|
|
9
|
+
it("should return null if the major version is not a number", () => {
|
|
10
|
+
const result = (0, getReactNativeVersionWithModules_1.getReactNativeVersionWithModules)({ reactNativeVersion: { major: "Hello" } });
|
|
11
|
+
expect(result).toBe(null);
|
|
12
|
+
});
|
|
13
|
+
it("should return a version", () => {
|
|
14
|
+
const result = (0, getReactNativeVersionWithModules_1.getReactNativeVersionWithModules)({
|
|
15
|
+
reactNativeVersion: { major: 0, minor: 59, patch: 8, prerelease: 5 },
|
|
16
|
+
});
|
|
17
|
+
expect(result).toEqual("0.59.8-5");
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReactNativeVersionWithModules.d.ts","sourceRoot":"","sources":["../../src/helpers/getReactNativeVersionWithModules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,iBAAiB,GAC3B,MAAM,GAAG,IAAI,CAgCf"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReactNativeVersionWithModules = getReactNativeVersionWithModules;
|
|
4
|
+
function getReactNativeVersionWithModules(constants) {
|
|
5
|
+
try {
|
|
6
|
+
// dodge some bullets
|
|
7
|
+
if (!constants) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
if (!constants.reactNativeVersion) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
// grab the raw numbers
|
|
14
|
+
const major = constants.reactNativeVersion.major;
|
|
15
|
+
const minor = constants.reactNativeVersion.minor;
|
|
16
|
+
const patch = constants.reactNativeVersion.patch;
|
|
17
|
+
const prerelease = constants.reactNativeVersion.prerelease;
|
|
18
|
+
// check the major or jet
|
|
19
|
+
if (typeof major !== 'number') {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
// assemble!
|
|
23
|
+
const vParts = [];
|
|
24
|
+
vParts.push(`${major}.${minor}.${patch}`);
|
|
25
|
+
if (prerelease) {
|
|
26
|
+
vParts.push(`-${prerelease}`);
|
|
27
|
+
}
|
|
28
|
+
return vParts.join('');
|
|
29
|
+
}
|
|
30
|
+
catch { }
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StackFrame } from 'react-native/Libraries/Core/NativeExceptionsManager';
|
|
2
|
+
import type { HermesParsedStack } from 'react-native/Libraries/Core/Devtools/parseHermesStack';
|
|
3
|
+
/** @see https://github.com/facebook/react-native/blob/v0.72.1/packages/react-native/Libraries/Core/Devtools/parseErrorStack.js#L41-L57 */
|
|
4
|
+
export type ParseErrorStackFn = <T extends any[]>(errorStack?: string | T | HermesParsedStack) => Array<StackFrame>;
|
|
5
|
+
//# sourceMappingURL=parseErrorStack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseErrorStack.d.ts","sourceRoot":"","sources":["../../src/helpers/parseErrorStack.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qDAAqD,CAAC;AAEtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAK/F,0IAA0I;AAC1I,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,EAC9C,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,iBAAiB,KACxC,KAAK,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a valid http(s) URL, the host for the given URL
|
|
3
|
+
* is returned.
|
|
4
|
+
*
|
|
5
|
+
* @param url {string} URL to extract the host from
|
|
6
|
+
* @returns {string} host of given URL or throws
|
|
7
|
+
*/
|
|
8
|
+
export declare function getHostFromUrl(url: string): string;
|
|
9
|
+
//# sourceMappingURL=parseURL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseURL.d.ts","sourceRoot":"","sources":["../../src/helpers/parseURL.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAUzC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHostFromUrl = getHostFromUrl;
|
|
4
|
+
/**
|
|
5
|
+
* Given a valid http(s) URL, the host for the given URL
|
|
6
|
+
* is returned.
|
|
7
|
+
*
|
|
8
|
+
* @param url {string} URL to extract the host from
|
|
9
|
+
* @returns {string} host of given URL or throws
|
|
10
|
+
*/
|
|
11
|
+
// Using a capture group to extract the hostname from a URL
|
|
12
|
+
function getHostFromUrl(url) {
|
|
13
|
+
// Group 1: http(s)://
|
|
14
|
+
// Group 2: host
|
|
15
|
+
// Group 3: port
|
|
16
|
+
// Group 4: rest
|
|
17
|
+
const host = url.match(/^(?:https?:\/\/)?(\[[^\]]+\]|[^/:\s]+)(?::\d+)?(?:[/?#]|$)/)?.[1];
|
|
18
|
+
if (typeof host !== "string")
|
|
19
|
+
throw new Error("Invalid URL - host not found");
|
|
20
|
+
return host;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseURL.test.d.ts","sourceRoot":"","sources":["../../src/helpers/parseURL.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const parseURL_1 = require("./parseURL");
|
|
4
|
+
describe("getHostFromUrl", () => {
|
|
5
|
+
it("should throw when no host is found", () => {
|
|
6
|
+
expect(() => {
|
|
7
|
+
(0, parseURL_1.getHostFromUrl)("");
|
|
8
|
+
}).toThrow();
|
|
9
|
+
});
|
|
10
|
+
it("should get host from URL without scheme", () => {
|
|
11
|
+
Object.entries({
|
|
12
|
+
localhost: "localhost",
|
|
13
|
+
"127.0.0.1": "127.0.0.1",
|
|
14
|
+
"[::1]": "[::1]",
|
|
15
|
+
}).forEach(([host, url]) => {
|
|
16
|
+
expect((0, parseURL_1.getHostFromUrl)(url)).toEqual(host);
|
|
17
|
+
});
|
|
18
|
+
expect((0, parseURL_1.getHostFromUrl)("localhost")).toEqual("localhost");
|
|
19
|
+
expect((0, parseURL_1.getHostFromUrl)("127.0.0.1")).toEqual("127.0.0.1");
|
|
20
|
+
});
|
|
21
|
+
it("should get the host from URL with http scheme", () => {
|
|
22
|
+
Object.entries({
|
|
23
|
+
localhost: "http://localhost",
|
|
24
|
+
"example.com": "http://example.com",
|
|
25
|
+
}).forEach(([host, url]) => {
|
|
26
|
+
expect((0, parseURL_1.getHostFromUrl)(url)).toEqual(host);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it("should get the host from URL with https scheme", () => {
|
|
30
|
+
Object.entries({
|
|
31
|
+
localhost: "https://localhost",
|
|
32
|
+
"example.com": "https://example.com",
|
|
33
|
+
}).forEach(([host, url]) => {
|
|
34
|
+
expect((0, parseURL_1.getHostFromUrl)(url)).toEqual(host);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
it("should get the host from URL and ignore path, port, and query params", () => {
|
|
38
|
+
Object.entries({
|
|
39
|
+
localhost: "http://localhost:8081/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.reactotronapp",
|
|
40
|
+
"192.168.1.141": "https://192.168.1.141:8081/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.reactotronapp",
|
|
41
|
+
}).forEach(([host, url]) => {
|
|
42
|
+
expect((0, parseURL_1.getHostFromUrl)(url)).toEqual(host);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
it("should get the host from an IPv6 URL and ignore path, port, and query params", () => {
|
|
46
|
+
Object.entries({
|
|
47
|
+
"[::1]": "http://[::1]:8081/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.reactotronapp",
|
|
48
|
+
"[2001:0db8:85a3:0000:0000:8a2e:0370:7334]": "https://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:8081/.expo/.virtual-metro-entry.bundle?platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.reactotronapp",
|
|
49
|
+
}).forEach(([host, url]) => {
|
|
50
|
+
expect((0, parseURL_1.getHostFromUrl)(url)).toEqual(host);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
it("should get the host from URL with hyphens", () => {
|
|
54
|
+
expect((0, parseURL_1.getHostFromUrl)("https://example-app.com")).toEqual("example-app.com");
|
|
55
|
+
});
|
|
56
|
+
it("should throw when the URL is an unsupported scheme", () => {
|
|
57
|
+
expect(() => {
|
|
58
|
+
(0, parseURL_1.getHostFromUrl)("file:///Users/tron");
|
|
59
|
+
}).toThrow();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StackFrame } from 'react-native/Libraries/Core/NativeExceptionsManager';
|
|
2
|
+
/** @see https://github.com/facebook/react-native/blob/v0.72.1/packages/react-native/Libraries/Core/Devtools/symbolicateStackTrace.js#L17-L25 */
|
|
3
|
+
export type CodeFrame = Readonly<{
|
|
4
|
+
content: string;
|
|
5
|
+
location: {
|
|
6
|
+
row: number;
|
|
7
|
+
column: number;
|
|
8
|
+
} | null | undefined;
|
|
9
|
+
fileName: string;
|
|
10
|
+
}>;
|
|
11
|
+
/** @see https://github.com/facebook/react-native/blob/v0.72.1/packages/react-native/Libraries/Core/Devtools/symbolicateStackTrace.js#L27-L30 */
|
|
12
|
+
export type SymbolicatedStackTrace = Readonly<{
|
|
13
|
+
stack: Array<StackFrame>;
|
|
14
|
+
codeFrame: CodeFrame | null | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
/** @see https://github.com/facebook/react-native/blob/v0.72.1/packages/react-native/Libraries/Core/Devtools/symbolicateStackTrace.js#L32-L34 */
|
|
17
|
+
export type SymbolicateStackTraceFn = (stack: Array<StackFrame>) => Promise<SymbolicatedStackTrace>;
|
|
18
|
+
//# sourceMappingURL=symbolicateStackTrace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbolicateStackTrace.d.ts","sourceRoot":"","sources":["../../src/helpers/symbolicateStackTrace.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qDAAqD,CAAC;AAEtF,gJAAgJ;AAChJ,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EACJ;QACE,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;KAChB,GACD,IAAI,GACJ,SAAS,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,gJAAgJ;AAChJ,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IACzB,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;CACzC,CAAC,CAAC;AAEH,gJAAgJ;AAChJ,MAAM,MAAM,uBAAuB,GAAG,CACpC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,KACrB,OAAO,CAAC,sBAAsB,CAAC,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,aAAa,IAAI,sBAAsB,EAAE,CAAC;AAEnD,cAAc,aAAa,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
exports.DReactionDraggableBall = void 0;
|
|
18
|
+
const DraggableBall_1 = require("./components/DraggableBall");
|
|
19
|
+
Object.defineProperty(exports, "DReactionDraggableBall", { enumerable: true, get: function () { return DraggableBall_1.DraggableBall; } });
|
|
20
|
+
__exportStar(require("./dreaction"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DReactionCore } from 'dreaction-client-core';
|
|
2
|
+
export interface AsyncStorageOptions {
|
|
3
|
+
ignore?: string[];
|
|
4
|
+
}
|
|
5
|
+
declare const asyncStorage: (options?: AsyncStorageOptions) => (reactotron: DReactionCore) => {
|
|
6
|
+
features: {
|
|
7
|
+
trackAsyncStorage: () => void;
|
|
8
|
+
untrackAsyncStorage: () => void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export default asyncStorage;
|
|
12
|
+
//# sourceMappingURL=asyncStorage.d.ts.map
|
|
@@ -0,0 +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,kBAAkB,aAAa;;;;;CA+M5D,CAAC;AAEJ,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const PLUGIN_DEFAULTS = {
|
|
4
|
+
ignore: [],
|
|
5
|
+
};
|
|
6
|
+
const asyncStorage = (options) => (reactotron) => {
|
|
7
|
+
// setup configuration
|
|
8
|
+
const config = Object.assign({}, PLUGIN_DEFAULTS, options || {});
|
|
9
|
+
const ignore = config.ignore || PLUGIN_DEFAULTS.ignore;
|
|
10
|
+
let swizzSetItem;
|
|
11
|
+
let swizzRemoveItem;
|
|
12
|
+
let swizzMergeItem;
|
|
13
|
+
let swizzClear;
|
|
14
|
+
let swizzMultiSet;
|
|
15
|
+
let swizzMultiRemove;
|
|
16
|
+
let swizzMultiMerge;
|
|
17
|
+
let isSwizzled = false;
|
|
18
|
+
const sendToReactotron = (action, data) => {
|
|
19
|
+
reactotron.send('asyncStorage.mutation', { action, data });
|
|
20
|
+
};
|
|
21
|
+
const setItem = async (key, value, callback) => {
|
|
22
|
+
try {
|
|
23
|
+
if (ignore.indexOf(key) < 0) {
|
|
24
|
+
sendToReactotron('setItem', { key, value });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (e) { }
|
|
28
|
+
return swizzSetItem(key, value, callback);
|
|
29
|
+
};
|
|
30
|
+
const removeItem = async (key, callback) => {
|
|
31
|
+
try {
|
|
32
|
+
if (ignore.indexOf(key) < 0) {
|
|
33
|
+
sendToReactotron('removeItem', { key });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (e) { }
|
|
37
|
+
return swizzRemoveItem(key, callback);
|
|
38
|
+
};
|
|
39
|
+
const mergeItem = async (key, value, callback) => {
|
|
40
|
+
try {
|
|
41
|
+
if (ignore.indexOf(key) < 0) {
|
|
42
|
+
sendToReactotron('mergeItem', { key, value });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e) { }
|
|
46
|
+
return swizzMergeItem(key, value, callback);
|
|
47
|
+
};
|
|
48
|
+
const clear = async (callback) => {
|
|
49
|
+
try {
|
|
50
|
+
sendToReactotron('clear');
|
|
51
|
+
}
|
|
52
|
+
catch (e) { }
|
|
53
|
+
return swizzClear(callback);
|
|
54
|
+
};
|
|
55
|
+
const multiSet = async (pairs, callback) => {
|
|
56
|
+
try {
|
|
57
|
+
const shippablePairs = (pairs || []).filter((pair) => pair && pair[0] && ignore.indexOf(pair[0]) < 0);
|
|
58
|
+
if (shippablePairs.length > 0) {
|
|
59
|
+
sendToReactotron('multiSet', { pairs: shippablePairs });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (e) { }
|
|
63
|
+
return swizzMultiSet(pairs, callback);
|
|
64
|
+
};
|
|
65
|
+
const multiRemove = async (keys, callback) => {
|
|
66
|
+
try {
|
|
67
|
+
const shippableKeys = (keys || []).filter((key) => ignore.indexOf(key) < 0);
|
|
68
|
+
if (shippableKeys.length > 0) {
|
|
69
|
+
sendToReactotron('multiRemove', { keys: shippableKeys });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (e) { }
|
|
73
|
+
return swizzMultiRemove(keys, callback);
|
|
74
|
+
};
|
|
75
|
+
const multiMerge = async (pairs, callback) => {
|
|
76
|
+
try {
|
|
77
|
+
const shippablePairs = (pairs || []).filter((pair) => pair && pair[0] && ignore.indexOf(pair[0]) < 0);
|
|
78
|
+
if (shippablePairs.length > 0) {
|
|
79
|
+
sendToReactotron('multiMerge', { pairs: shippablePairs });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (e) { }
|
|
83
|
+
return swizzMultiMerge(pairs, callback);
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Hijacks the AsyncStorage API.
|
|
87
|
+
*/
|
|
88
|
+
const trackAsyncStorage = () => {
|
|
89
|
+
if (isSwizzled)
|
|
90
|
+
return;
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
92
|
+
// @ts-ignore: reactotron-apis
|
|
93
|
+
swizzSetItem = reactotron.asyncStorageHandler.setItem;
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
95
|
+
// @ts-ignore: reactotron-apis
|
|
96
|
+
reactotron.asyncStorageHandler.setItem = setItem;
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
98
|
+
// @ts-ignore: reactotron-apis
|
|
99
|
+
swizzRemoveItem = reactotron.asyncStorageHandler.removeItem;
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
101
|
+
// @ts-ignore: reactotron-apis
|
|
102
|
+
reactotron.asyncStorageHandler.removeItem = removeItem;
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
104
|
+
// @ts-ignore: reactotron-apis
|
|
105
|
+
swizzMergeItem = reactotron.asyncStorageHandler.mergeItem;
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
107
|
+
// @ts-ignore: reactotron-apis
|
|
108
|
+
reactotron.asyncStorageHandler.mergeItem = mergeItem;
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
110
|
+
// @ts-ignore: reactotron-apis
|
|
111
|
+
swizzClear = reactotron.asyncStorageHandler.clear;
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
113
|
+
// @ts-ignore: reactotron-apis
|
|
114
|
+
reactotron.asyncStorageHandler.clear = clear;
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
116
|
+
// @ts-ignore: reactotron-apis
|
|
117
|
+
swizzMultiSet = reactotron.asyncStorageHandler.multiSet;
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
119
|
+
// @ts-ignore: reactotron-apis
|
|
120
|
+
reactotron.asyncStorageHandler.multiSet = multiSet;
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
122
|
+
// @ts-ignore: reactotron-apis
|
|
123
|
+
swizzMultiRemove = reactotron.asyncStorageHandler.multiRemove;
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
125
|
+
// @ts-ignore: reactotron-apis
|
|
126
|
+
reactotron.asyncStorageHandler.multiRemove = multiRemove;
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
128
|
+
// @ts-ignore: reactotron-apis
|
|
129
|
+
swizzMultiMerge = reactotron.asyncStorageHandler.multiMerge;
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
131
|
+
// @ts-ignore: reactotron-apis
|
|
132
|
+
reactotron.asyncStorageHandler.multiMerge = multiMerge;
|
|
133
|
+
isSwizzled = true;
|
|
134
|
+
};
|
|
135
|
+
const untrackAsyncStorage = () => {
|
|
136
|
+
if (!isSwizzled)
|
|
137
|
+
return;
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
139
|
+
// @ts-ignore: reactotron-apis
|
|
140
|
+
reactotron.asyncStorageHandler.setItem = swizzSetItem;
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
142
|
+
// @ts-ignore: reactotron-apis
|
|
143
|
+
reactotron.asyncStorageHandler.removeItem = swizzRemoveItem;
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
145
|
+
// @ts-ignore: reactotron-apis
|
|
146
|
+
reactotron.asyncStorageHandler.mergeItem = swizzMergeItem;
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
148
|
+
// @ts-ignore: reactotron-apis
|
|
149
|
+
reactotron.asyncStorageHandler.clear = swizzClear;
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
151
|
+
// @ts-ignore: reactotron-apis
|
|
152
|
+
reactotron.asyncStorageHandler.multiSet = swizzMultiSet;
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
154
|
+
// @ts-ignore: reactotron-apis
|
|
155
|
+
reactotron.asyncStorageHandler.multiRemove = swizzMultiRemove;
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
157
|
+
// @ts-ignore: reactotron-apis
|
|
158
|
+
reactotron.asyncStorageHandler.multiMerge = swizzMultiMerge;
|
|
159
|
+
isSwizzled = false;
|
|
160
|
+
};
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
162
|
+
// @ts-ignore: reactotron-apis
|
|
163
|
+
if (reactotron.asyncStorageHandler) {
|
|
164
|
+
trackAsyncStorage();
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
features: {
|
|
168
|
+
trackAsyncStorage,
|
|
169
|
+
untrackAsyncStorage,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
exports.default = asyncStorage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devTools.d.ts","sourceRoot":"","sources":["../../src/plugins/devTools.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,QAAQ,EAAE,GAmBf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_native_1 = require("react-native");
|
|
4
|
+
let DevMenu = { show: () => { }, reload: () => { } };
|
|
5
|
+
if (react_native_1.Platform.OS === 'ios') {
|
|
6
|
+
DevMenu = require('react-native/Libraries/NativeModules/specs/NativeDevMenu');
|
|
7
|
+
}
|
|
8
|
+
const devTools = () => () => {
|
|
9
|
+
return {
|
|
10
|
+
onCommand: (command) => {
|
|
11
|
+
if (command.type !== 'devtools.open' &&
|
|
12
|
+
command.type !== 'devtools.reload') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (command.type === 'devtools.open') {
|
|
16
|
+
DevMenu.show();
|
|
17
|
+
}
|
|
18
|
+
if (command.type === 'devtools.reload') {
|
|
19
|
+
DevMenu.reload();
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.default = devTools;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DReactionCore } from 'dreaction-client-core';
|
|
2
|
+
export interface NetworkingOptions {
|
|
3
|
+
ignoreContentTypes?: RegExp;
|
|
4
|
+
ignoreUrls?: RegExp;
|
|
5
|
+
}
|
|
6
|
+
declare const networking: (pluginConfig?: NetworkingOptions) => (reactotron: DReactionCore) => {
|
|
7
|
+
onConnect: () => void;
|
|
8
|
+
};
|
|
9
|
+
export default networking;
|
|
10
|
+
//# sourceMappingURL=networking.d.ts.map
|
|
@@ -0,0 +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;AAID,QAAA,MAAM,UAAU,kBACC,iBAAiB,kBACnB,aAAa;;CAwJzB,CAAC;AACJ,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
// @ts-ignore
|
|
7
|
+
const XHRInterceptor_1 = __importDefault(require("react-native/Libraries/Network/XHRInterceptor"));
|
|
8
|
+
/**
|
|
9
|
+
* Don't include the response bodies for images by default.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_CONTENT_TYPES_RX = /^(image)\/.*$/i;
|
|
12
|
+
const DEFAULTS = {};
|
|
13
|
+
const networking = (pluginConfig = {}) => (reactotron) => {
|
|
14
|
+
const options = Object.assign({}, DEFAULTS, pluginConfig);
|
|
15
|
+
// a RegExp to suppress adding the body cuz it costs a lot to serialize
|
|
16
|
+
const ignoreContentTypes = options.ignoreContentTypes || DEFAULT_CONTENT_TYPES_RX;
|
|
17
|
+
// a XHR call tracker
|
|
18
|
+
let reactotronCounter = 1000;
|
|
19
|
+
// a temporary cache to hold requests so we can match up the data
|
|
20
|
+
const requestCache = {};
|
|
21
|
+
/**
|
|
22
|
+
* Fires when we talk to the server.
|
|
23
|
+
*
|
|
24
|
+
* @param {*} data - The data sent to the server.
|
|
25
|
+
* @param {*} instance - The XMLHTTPRequest instance.
|
|
26
|
+
*/
|
|
27
|
+
function onSend(data, xhr) {
|
|
28
|
+
if (options.ignoreUrls && options.ignoreUrls.test(xhr._url)) {
|
|
29
|
+
xhr._skipReactotron = true;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// bump the counter
|
|
33
|
+
reactotronCounter++;
|
|
34
|
+
// tag
|
|
35
|
+
xhr._trackingName = reactotronCounter;
|
|
36
|
+
// cache
|
|
37
|
+
requestCache[reactotronCounter] = {
|
|
38
|
+
data,
|
|
39
|
+
xhr,
|
|
40
|
+
stopTimer: reactotron.startTimer(),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Fires when the server gives us a response.
|
|
45
|
+
*
|
|
46
|
+
* @param {number} status - The HTTP response status.
|
|
47
|
+
* @param {boolean} timeout - Did we timeout?
|
|
48
|
+
* @param {*} response - The response data.
|
|
49
|
+
* @param {string} url - The URL we talked to.
|
|
50
|
+
* @param {*} type - Not sure.
|
|
51
|
+
* @param {*} xhr - The XMLHttpRequest instance.
|
|
52
|
+
*/
|
|
53
|
+
function onResponse(status, timeout, response, url, type, xhr) {
|
|
54
|
+
if (xhr._skipReactotron) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let params = null;
|
|
58
|
+
const queryParamIdx = url ? url.indexOf('?') : -1;
|
|
59
|
+
if (queryParamIdx > -1) {
|
|
60
|
+
params = {};
|
|
61
|
+
url
|
|
62
|
+
.substr(queryParamIdx + 1)
|
|
63
|
+
.split('&')
|
|
64
|
+
.forEach((pair) => {
|
|
65
|
+
const [key, value] = pair.split('=');
|
|
66
|
+
if (key && value !== undefined) {
|
|
67
|
+
params[key] = decodeURIComponent(value.replace(/\+/g, ' '));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// fetch and clear the request data from the cache
|
|
72
|
+
const rid = xhr._trackingName;
|
|
73
|
+
const cachedRequest = requestCache[rid] || { xhr };
|
|
74
|
+
requestCache[rid] = null;
|
|
75
|
+
// assemble the request object
|
|
76
|
+
const { data, stopTimer } = cachedRequest;
|
|
77
|
+
const tronRequest = {
|
|
78
|
+
url: url || cachedRequest.xhr._url,
|
|
79
|
+
method: xhr._method || null,
|
|
80
|
+
data,
|
|
81
|
+
headers: xhr._headers || null,
|
|
82
|
+
params,
|
|
83
|
+
};
|
|
84
|
+
// what type of content is this?
|
|
85
|
+
const contentType = (xhr.responseHeaders && xhr.responseHeaders['content-type']) ||
|
|
86
|
+
(xhr.responseHeaders && xhr.responseHeaders['Content-Type']) ||
|
|
87
|
+
'';
|
|
88
|
+
const sendResponse = (responseBodyText) => {
|
|
89
|
+
let body = `~~~ skipped ~~~`;
|
|
90
|
+
if (responseBodyText) {
|
|
91
|
+
try {
|
|
92
|
+
// all i am saying, is give JSON a chance...
|
|
93
|
+
body = JSON.parse(responseBodyText);
|
|
94
|
+
}
|
|
95
|
+
catch (boom) {
|
|
96
|
+
body = response;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const tronResponse = {
|
|
100
|
+
body,
|
|
101
|
+
status,
|
|
102
|
+
headers: xhr.responseHeaders || null,
|
|
103
|
+
};
|
|
104
|
+
reactotron.apiResponse(tronRequest, tronResponse, stopTimer ? stopTimer() : null); // TODO: Fix
|
|
105
|
+
};
|
|
106
|
+
// can we use the real response?
|
|
107
|
+
const useRealResponse = (typeof response === 'string' || typeof response === 'object') &&
|
|
108
|
+
!ignoreContentTypes.test(contentType || '');
|
|
109
|
+
// prepare the right body to send
|
|
110
|
+
if (useRealResponse) {
|
|
111
|
+
if (type === 'blob' && typeof FileReader !== 'undefined' && response) {
|
|
112
|
+
// Disable reason: FileReader should be in global scope since RN 0.54
|
|
113
|
+
// eslint-disable-next-line no-undef
|
|
114
|
+
const bReader = new FileReader();
|
|
115
|
+
const brListener = () => {
|
|
116
|
+
sendResponse(String(bReader.result));
|
|
117
|
+
bReader.removeEventListener('loadend', brListener);
|
|
118
|
+
};
|
|
119
|
+
bReader.addEventListener('loadend', brListener);
|
|
120
|
+
bReader.readAsText(response);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
sendResponse(response);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
sendResponse('');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
onConnect: () => {
|
|
132
|
+
// register our monkey-patch
|
|
133
|
+
XHRInterceptor_1.default.setSendCallback(onSend);
|
|
134
|
+
XHRInterceptor_1.default.setResponseCallback(onResponse);
|
|
135
|
+
XHRInterceptor_1.default.enableInterception();
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
exports.default = networking;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from 'dreaction-protocol';
|
|
2
|
+
export interface OpenInEditorOptions {
|
|
3
|
+
url?: string;
|
|
4
|
+
}
|
|
5
|
+
declare const openInEditor: (pluginConfig?: OpenInEditorOptions) => () => {
|
|
6
|
+
onCommand: (command: Command) => void;
|
|
7
|
+
};
|
|
8
|
+
export default openInEditor;
|
|
9
|
+
//# sourceMappingURL=openInEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openInEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/openInEditor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAMD,QAAA,MAAM,YAAY,kBACD,mBAAmB;yBAKT,OAAO;CAW/B,CAAC;AACJ,eAAe,YAAY,CAAC"}
|