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.
Files changed (98) hide show
  1. package/lib/components/ConfigDialog.d.ts +9 -0
  2. package/lib/components/ConfigDialog.d.ts.map +1 -0
  3. package/lib/components/ConfigDialog.js +83 -0
  4. package/lib/components/DraggableBall.d.ts +3 -0
  5. package/lib/components/DraggableBall.d.ts.map +1 -0
  6. package/lib/components/DraggableBall.js +136 -0
  7. package/lib/dreaction.d.ts +29 -0
  8. package/lib/dreaction.d.ts.map +1 -0
  9. package/lib/dreaction.js +134 -0
  10. package/lib/helpers/getHost.d.ts +9 -0
  11. package/lib/helpers/getHost.d.ts.map +1 -0
  12. package/lib/helpers/getHost.js +31 -0
  13. package/lib/helpers/getReactNativeDimensions.d.ts +3 -0
  14. package/lib/helpers/getReactNativeDimensions.d.ts.map +1 -0
  15. package/lib/helpers/getReactNativeDimensions.js +18 -0
  16. package/lib/helpers/getReactNativeDimensions.test.d.ts +2 -0
  17. package/lib/helpers/getReactNativeDimensions.test.d.ts.map +1 -0
  18. package/lib/helpers/getReactNativeDimensions.test.js +20 -0
  19. package/lib/helpers/getReactNativeDimensionsWithDimensions.d.ts +12 -0
  20. package/lib/helpers/getReactNativeDimensionsWithDimensions.d.ts.map +1 -0
  21. package/lib/helpers/getReactNativeDimensionsWithDimensions.js +31 -0
  22. package/lib/helpers/getReactNativePlatformConstants.d.ts +13 -0
  23. package/lib/helpers/getReactNativePlatformConstants.d.ts.map +1 -0
  24. package/lib/helpers/getReactNativePlatformConstants.js +37 -0
  25. package/lib/helpers/getReactNativeVersion.d.ts +2 -0
  26. package/lib/helpers/getReactNativeVersion.d.ts.map +1 -0
  27. package/lib/helpers/getReactNativeVersion.js +8 -0
  28. package/lib/helpers/getReactNativeVersion.test.d.ts +2 -0
  29. package/lib/helpers/getReactNativeVersion.test.d.ts.map +1 -0
  30. package/lib/helpers/getReactNativeVersion.test.js +19 -0
  31. package/lib/helpers/getReactNativeVersionWithModules.d.ts +3 -0
  32. package/lib/helpers/getReactNativeVersionWithModules.d.ts.map +1 -0
  33. package/lib/helpers/getReactNativeVersionWithModules.js +32 -0
  34. package/lib/helpers/parseErrorStack.d.ts +5 -0
  35. package/lib/helpers/parseErrorStack.d.ts.map +1 -0
  36. package/lib/helpers/parseErrorStack.js +2 -0
  37. package/lib/helpers/parseURL.d.ts +9 -0
  38. package/lib/helpers/parseURL.d.ts.map +1 -0
  39. package/lib/helpers/parseURL.js +21 -0
  40. package/lib/helpers/parseURL.test.d.ts +2 -0
  41. package/lib/helpers/parseURL.test.d.ts.map +1 -0
  42. package/lib/helpers/parseURL.test.js +61 -0
  43. package/lib/helpers/symbolicateStackTrace.d.ts +18 -0
  44. package/lib/helpers/symbolicateStackTrace.d.ts.map +1 -0
  45. package/lib/helpers/symbolicateStackTrace.js +2 -0
  46. package/lib/index.d.ts +5 -0
  47. package/lib/index.d.ts.map +1 -0
  48. package/lib/index.js +20 -0
  49. package/lib/plugins/asyncStorage.d.ts +12 -0
  50. package/lib/plugins/asyncStorage.d.ts.map +1 -0
  51. package/lib/plugins/asyncStorage.js +173 -0
  52. package/lib/plugins/devTools.d.ts +3 -0
  53. package/lib/plugins/devTools.d.ts.map +1 -0
  54. package/lib/plugins/devTools.js +24 -0
  55. package/lib/plugins/networking.d.ts +10 -0
  56. package/lib/plugins/networking.d.ts.map +1 -0
  57. package/lib/plugins/networking.js +139 -0
  58. package/lib/plugins/openInEditor.d.ts +9 -0
  59. package/lib/plugins/openInEditor.d.ts.map +1 -0
  60. package/lib/plugins/openInEditor.js +21 -0
  61. package/lib/plugins/overlay/index.d.ts +3 -0
  62. package/lib/plugins/overlay/index.d.ts.map +1 -0
  63. package/lib/plugins/overlay/index.js +29 -0
  64. package/lib/plugins/overlay/overlay.d.ts +161 -0
  65. package/lib/plugins/overlay/overlay.d.ts.map +1 -0
  66. package/lib/plugins/overlay/overlay.js +99 -0
  67. package/lib/plugins/storybook/index.d.ts +6 -0
  68. package/lib/plugins/storybook/index.d.ts.map +1 -0
  69. package/lib/plugins/storybook/index.js +27 -0
  70. package/lib/plugins/storybook/storybook.d.ts +22 -0
  71. package/lib/plugins/storybook/storybook.d.ts.map +1 -0
  72. package/lib/plugins/storybook/storybook.js +31 -0
  73. package/lib/plugins/trackGlobalErrors.d.ts +32 -0
  74. package/lib/plugins/trackGlobalErrors.d.ts.map +1 -0
  75. package/lib/plugins/trackGlobalErrors.js +100 -0
  76. package/lib/plugins/trackGlobalLogs.d.ts +9 -0
  77. package/lib/plugins/trackGlobalLogs.d.ts.map +1 -0
  78. package/lib/plugins/trackGlobalLogs.js +31 -0
  79. package/package.json +29 -0
  80. package/src/components/ConfigDialog.tsx +79 -0
  81. package/src/components/DraggableBall.tsx +139 -0
  82. package/src/dreaction.ts +221 -0
  83. package/src/helpers/getHost.ts +30 -0
  84. package/src/helpers/getReactNativeDimensions.ts +20 -0
  85. package/src/helpers/getReactNativeDimensionsWithDimensions.ts +45 -0
  86. package/src/helpers/getReactNativePlatformConstants.ts +52 -0
  87. package/src/helpers/getReactNativeVersion.ts +6 -0
  88. package/src/helpers/getReactNativeVersionWithModules.ts +37 -0
  89. package/src/helpers/parseErrorStack.ts +13 -0
  90. package/src/helpers/parseURL.ts +19 -0
  91. package/src/helpers/symbolicateStackTrace.ts +28 -0
  92. package/src/index.ts +6 -0
  93. package/src/plugins/asyncStorage.ts +222 -0
  94. package/src/plugins/devTools.ts +30 -0
  95. package/src/plugins/networking.ts +172 -0
  96. package/src/plugins/openInEditor.ts +30 -0
  97. package/src/plugins/trackGlobalErrors.ts +156 -0
  98. package/src/plugins/trackGlobalLogs.ts +42 -0
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const DEFAULTS = {
4
+ url: 'http://localhost:8081',
5
+ };
6
+ const openInEditor = (pluginConfig = {}) => () => {
7
+ const options = Object.assign({}, DEFAULTS, pluginConfig);
8
+ return {
9
+ onCommand: (command) => {
10
+ if (command.type !== 'editor.open')
11
+ return;
12
+ const { payload } = command;
13
+ const { file, lineNumber } = payload;
14
+ const url = `${options.url}/open-stack-frame`;
15
+ const body = { file, lineNumber: lineNumber || 1 };
16
+ const method = 'POST';
17
+ fetch(url, { method, body: JSON.stringify(body) });
18
+ },
19
+ };
20
+ };
21
+ exports.default = openInEditor;
@@ -0,0 +1,3 @@
1
+ export default function OverlayCreator(): () => Plugin<ReactotronCore>;
2
+ export type OverlayFeatures = ReturnType<ReturnType<typeof OverlayCreator>>["features"];
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/overlay/index.tsx"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,cAAc,iCA2BrC;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA"}
@@ -0,0 +1,29 @@
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.default = OverlayCreator;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_native_1 = require("react-native");
9
+ const mitt_1 = __importDefault(require("mitt"));
10
+ const overlay_1 = __importDefault(require("./overlay"));
11
+ function OverlayCreator() {
12
+ return function overlay() {
13
+ const emitter = (0, mitt_1.default)();
14
+ return {
15
+ /**
16
+ * Fires when any Reactotron message arrives.
17
+ */
18
+ onCommand: (command) => {
19
+ if (command.type !== "overlay")
20
+ return;
21
+ // relay this payload on to the emitter
22
+ emitter.emit("overlay", command.payload);
23
+ },
24
+ features: {
25
+ overlay: (WrappedComponent) => (props = {}) => ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(WrappedComponent, { ...props }), (0, jsx_runtime_1.jsx)(overlay_1.default, { emitter: emitter })] })),
26
+ },
27
+ };
28
+ };
29
+ }
@@ -0,0 +1,161 @@
1
+ import { Component } from "react";
2
+ import { ImageResizeMode, FlexAlignType, AnimatableNumericValue } from "react-native";
3
+ interface Props {
4
+ emitter: any;
5
+ }
6
+ interface State {
7
+ opacity: AnimatableNumericValue;
8
+ uri: string;
9
+ justifyContent: "flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly";
10
+ alignItems: FlexAlignType;
11
+ width?: number;
12
+ height?: number;
13
+ growToWindow?: boolean;
14
+ resizeMode?: ImageResizeMode;
15
+ marginLeft?: number;
16
+ marginRight?: number;
17
+ marginTop?: number;
18
+ marginBottom?: number;
19
+ showDebug?: boolean;
20
+ }
21
+ /** An overlay for showing an image to help with layout.
22
+ *
23
+ * @class FullScreenOverlay
24
+ * @extends {Component}
25
+ */
26
+ declare class FullScreenOverlay extends Component<Props, State> {
27
+ constructor(props: Props);
28
+ createContainerStyle(): {
29
+ opacity: AnimatableNumericValue;
30
+ width: number;
31
+ height: number;
32
+ justifyContent: "center" | "flex-start" | "flex-end" | "space-between" | "space-around" | "space-evenly";
33
+ alignItems: FlexAlignType;
34
+ backfaceVisibility?: "visible" | "hidden" | undefined;
35
+ backgroundColor?: import("react-native").ColorValue | undefined;
36
+ borderBlockColor?: import("react-native").ColorValue | undefined;
37
+ borderBlockEndColor?: import("react-native").ColorValue | undefined;
38
+ borderBlockStartColor?: import("react-native").ColorValue | undefined;
39
+ borderBottomColor?: import("react-native").ColorValue | undefined;
40
+ borderBottomEndRadius?: AnimatableNumericValue | string | undefined;
41
+ borderBottomLeftRadius?: AnimatableNumericValue | string | undefined;
42
+ borderBottomRightRadius?: AnimatableNumericValue | string | undefined;
43
+ borderBottomStartRadius?: AnimatableNumericValue | string | undefined;
44
+ borderColor?: import("react-native").ColorValue | undefined;
45
+ borderCurve?: "circular" | "continuous" | undefined;
46
+ borderEndColor?: import("react-native").ColorValue | undefined;
47
+ borderEndEndRadius?: AnimatableNumericValue | string | undefined;
48
+ borderEndStartRadius?: AnimatableNumericValue | string | undefined;
49
+ borderLeftColor?: import("react-native").ColorValue | undefined;
50
+ borderRadius?: AnimatableNumericValue | string | undefined;
51
+ borderRightColor?: import("react-native").ColorValue | undefined;
52
+ borderStartColor?: import("react-native").ColorValue | undefined;
53
+ borderStartEndRadius?: AnimatableNumericValue | string | undefined;
54
+ borderStartStartRadius?: AnimatableNumericValue | string | undefined;
55
+ borderStyle?: "solid" | "dotted" | "dashed" | undefined;
56
+ borderTopColor?: import("react-native").ColorValue | undefined;
57
+ borderTopEndRadius?: AnimatableNumericValue | string | undefined;
58
+ borderTopLeftRadius?: AnimatableNumericValue | string | undefined;
59
+ borderTopRightRadius?: AnimatableNumericValue | string | undefined;
60
+ borderTopStartRadius?: AnimatableNumericValue | string | undefined;
61
+ elevation?: number | undefined;
62
+ pointerEvents?: "box-none" | "none" | "box-only" | "auto" | undefined;
63
+ isolation?: "auto" | "isolate" | undefined;
64
+ cursor?: import("react-native").CursorValue | undefined;
65
+ boxShadow?: ReadonlyArray<import("react-native").BoxShadowValue> | string | undefined;
66
+ filter?: ReadonlyArray<import("react-native").FilterFunction> | string | undefined;
67
+ alignContent?: "flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-around" | "space-evenly" | undefined;
68
+ alignSelf?: "auto" | FlexAlignType | undefined;
69
+ aspectRatio?: number | string | undefined;
70
+ borderBottomWidth?: number | undefined;
71
+ borderEndWidth?: number | undefined;
72
+ borderLeftWidth?: number | undefined;
73
+ borderRightWidth?: number | undefined;
74
+ borderStartWidth?: number | undefined;
75
+ borderTopWidth?: number | undefined;
76
+ borderWidth?: number | undefined;
77
+ bottom?: import("react-native").DimensionValue | undefined;
78
+ display?: "none" | "flex" | undefined;
79
+ end?: import("react-native").DimensionValue | undefined;
80
+ flex?: number | undefined;
81
+ flexBasis?: import("react-native").DimensionValue | undefined;
82
+ flexDirection?: "row" | "column" | "row-reverse" | "column-reverse" | undefined;
83
+ rowGap?: number | string | undefined;
84
+ gap?: number | string | undefined;
85
+ columnGap?: number | string | undefined;
86
+ flexGrow?: number | undefined;
87
+ flexShrink?: number | undefined;
88
+ flexWrap?: "wrap" | "nowrap" | "wrap-reverse" | undefined;
89
+ left?: import("react-native").DimensionValue | undefined;
90
+ margin?: import("react-native").DimensionValue | undefined;
91
+ marginBottom?: import("react-native").DimensionValue | undefined;
92
+ marginEnd?: import("react-native").DimensionValue | undefined;
93
+ marginHorizontal?: import("react-native").DimensionValue | undefined;
94
+ marginLeft?: import("react-native").DimensionValue | undefined;
95
+ marginRight?: import("react-native").DimensionValue | undefined;
96
+ marginStart?: import("react-native").DimensionValue | undefined;
97
+ marginTop?: import("react-native").DimensionValue | undefined;
98
+ marginVertical?: import("react-native").DimensionValue | undefined;
99
+ maxHeight?: import("react-native").DimensionValue | undefined;
100
+ maxWidth?: import("react-native").DimensionValue | undefined;
101
+ minHeight?: import("react-native").DimensionValue | undefined;
102
+ minWidth?: import("react-native").DimensionValue | undefined;
103
+ overflow?: "visible" | "hidden" | "scroll" | undefined;
104
+ padding?: import("react-native").DimensionValue | undefined;
105
+ paddingBottom?: import("react-native").DimensionValue | undefined;
106
+ paddingEnd?: import("react-native").DimensionValue | undefined;
107
+ paddingHorizontal?: import("react-native").DimensionValue | undefined;
108
+ paddingLeft?: import("react-native").DimensionValue | undefined;
109
+ paddingRight?: import("react-native").DimensionValue | undefined;
110
+ paddingStart?: import("react-native").DimensionValue | undefined;
111
+ paddingTop?: import("react-native").DimensionValue | undefined;
112
+ paddingVertical?: import("react-native").DimensionValue | undefined;
113
+ position?: "absolute" | "relative" | "static" | undefined;
114
+ right?: import("react-native").DimensionValue | undefined;
115
+ start?: import("react-native").DimensionValue | undefined;
116
+ top?: import("react-native").DimensionValue | undefined;
117
+ zIndex?: number | undefined;
118
+ direction?: "inherit" | "ltr" | "rtl" | undefined;
119
+ inset?: import("react-native").DimensionValue | undefined;
120
+ insetBlock?: import("react-native").DimensionValue | undefined;
121
+ insetBlockEnd?: import("react-native").DimensionValue | undefined;
122
+ insetBlockStart?: import("react-native").DimensionValue | undefined;
123
+ insetInline?: import("react-native").DimensionValue | undefined;
124
+ insetInlineEnd?: import("react-native").DimensionValue | undefined;
125
+ insetInlineStart?: import("react-native").DimensionValue | undefined;
126
+ marginBlock?: import("react-native").DimensionValue | undefined;
127
+ marginBlockEnd?: import("react-native").DimensionValue | undefined;
128
+ marginBlockStart?: import("react-native").DimensionValue | undefined;
129
+ marginInline?: import("react-native").DimensionValue | undefined;
130
+ marginInlineEnd?: import("react-native").DimensionValue | undefined;
131
+ marginInlineStart?: import("react-native").DimensionValue | undefined;
132
+ paddingBlock?: import("react-native").DimensionValue | undefined;
133
+ paddingBlockEnd?: import("react-native").DimensionValue | undefined;
134
+ paddingBlockStart?: import("react-native").DimensionValue | undefined;
135
+ paddingInline?: import("react-native").DimensionValue | undefined;
136
+ paddingInlineEnd?: import("react-native").DimensionValue | undefined;
137
+ paddingInlineStart?: import("react-native").DimensionValue | undefined;
138
+ shadowColor?: import("react-native").ColorValue | undefined;
139
+ shadowOffset?: Readonly<{
140
+ width: number;
141
+ height: number;
142
+ }> | undefined;
143
+ shadowOpacity?: AnimatableNumericValue | undefined;
144
+ shadowRadius?: number | undefined;
145
+ transform?: Readonly<import("react-native").MaximumOneOf<import("react-native").PerspectiveTransform & import("react-native").RotateTransform & import("react-native").RotateXTransform & import("react-native").RotateYTransform & import("react-native").RotateZTransform & import("react-native").ScaleTransform & import("react-native").ScaleXTransform & import("react-native").ScaleYTransform & import("react-native").TranslateXTransform & import("react-native").TranslateYTransform & import("react-native").SkewXTransform & import("react-native").SkewYTransform & import("react-native").MatrixTransform>[]> | string | undefined;
146
+ transformOrigin?: Array<string | number> | string | undefined;
147
+ transformMatrix?: Array<number> | undefined;
148
+ rotation?: AnimatableNumericValue | undefined;
149
+ scaleX?: AnimatableNumericValue | undefined;
150
+ scaleY?: AnimatableNumericValue | undefined;
151
+ translateX?: AnimatableNumericValue | undefined;
152
+ translateY?: AnimatableNumericValue | undefined;
153
+ };
154
+ renderDebug(): import("react/jsx-runtime").JSX.Element | null;
155
+ /**
156
+ * Draw.
157
+ */
158
+ render(): import("react/jsx-runtime").JSX.Element;
159
+ }
160
+ export default FullScreenOverlay;
161
+ //# sourceMappingURL=overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/plugins/overlay/overlay.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAIL,eAAe,EACf,aAAa,EAIb,sBAAsB,EACvB,MAAM,cAAc,CAAA;AAwCrB,UAAU,KAAK;IACb,OAAO,EAAE,GAAG,CAAA;CACb;AAED,UAAU,KAAK;IACb,OAAO,EAAE,sBAAsB,CAAA;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EACV,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,eAAe,GACf,cAAc,GACd,cAAc,CAAA;IAClB,UAAU,EAAE,aAAa,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,eAAe,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,cAAM,iBAAkB,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBACzC,KAAK,EAAE,KAAK;IAgBxB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAepB,WAAW;IAyBX;;OAEG;IACH,MAAM;CAiCP;AAED,eAAe,iBAAiB,CAAA"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
5
+ const react_native_1 = require("react-native");
6
+ const Styles = {
7
+ container: {
8
+ position: "absolute",
9
+ left: 0,
10
+ top: 0,
11
+ right: 0,
12
+ bottom: 0,
13
+ zIndex: 1000,
14
+ opacity: 0.25,
15
+ },
16
+ debugContainer: {
17
+ position: "absolute",
18
+ top: 0,
19
+ left: 0,
20
+ right: 0,
21
+ bottom: 0,
22
+ justifyContent: "center",
23
+ alignItems: "center",
24
+ backgroundColor: "transparent",
25
+ zIndex: 2000,
26
+ },
27
+ debugTextContainer: {
28
+ backgroundColor: "lightgray",
29
+ margin: 50,
30
+ padding: 20,
31
+ },
32
+ debugText: {
33
+ color: "red",
34
+ fontSize: 16,
35
+ marginBottom: 10,
36
+ },
37
+ };
38
+ /** An overlay for showing an image to help with layout.
39
+ *
40
+ * @class FullScreenOverlay
41
+ * @extends {Component}
42
+ */
43
+ class FullScreenOverlay extends react_1.Component {
44
+ constructor(props) {
45
+ super(props);
46
+ this.state = {
47
+ opacity: Styles.container.opacity,
48
+ uri: null,
49
+ justifyContent: "center",
50
+ alignItems: "center",
51
+ };
52
+ // when the server sends stuff
53
+ props.emitter.on("overlay", (payload) => {
54
+ this.setState({ ...this.state, ...payload });
55
+ });
56
+ }
57
+ createContainerStyle() {
58
+ const { opacity, justifyContent, alignItems } = this.state;
59
+ const { width, height } = react_native_1.Dimensions.get("window");
60
+ const containerStyle = {
61
+ ...Styles.container,
62
+ opacity,
63
+ width,
64
+ height,
65
+ justifyContent,
66
+ alignItems,
67
+ };
68
+ return containerStyle;
69
+ }
70
+ renderDebug() {
71
+ const { showDebug } = this.state;
72
+ // If Reactotron is configured properly it should be disabled in production.
73
+ // We'll throw a __DEV__ check in here just in case it get's feisty.
74
+ if (!__DEV__ || !showDebug)
75
+ return null;
76
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: Styles.debugContainer, pointerEvents: "none", children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: Styles.debugTextContainer, children: Object.keys(this.state).map((key) => {
77
+ if (key === "showDebug")
78
+ return null;
79
+ const keyName = key === "uri" ? "have image" : key;
80
+ const value = key === "uri" ? !!this.state[key] : this.state[key];
81
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: Styles.debugText, children: `${keyName}: ${value}` }, key));
82
+ }) }) }));
83
+ }
84
+ /**
85
+ * Draw.
86
+ */
87
+ render() {
88
+ const { uri, width, height, growToWindow, resizeMode, marginLeft = 0, marginRight = 0, marginTop = 0, marginBottom = 0, } = this.state;
89
+ const imageStyle = { width, height, marginTop, marginRight, marginBottom, marginLeft };
90
+ if (growToWindow) {
91
+ const windowSize = react_native_1.Dimensions.get("window");
92
+ imageStyle.width = windowSize.width;
93
+ imageStyle.height = windowSize.height;
94
+ }
95
+ const image = uri ? ((0, jsx_runtime_1.jsx)(react_native_1.Image, { source: { uri }, style: imageStyle, resizeMode: growToWindow ? resizeMode : null })) : ((0, jsx_runtime_1.jsx)(react_native_1.View, {}));
96
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: this.createContainerStyle(), pointerEvents: "none", children: image }), this.renderDebug()] }));
97
+ }
98
+ }
99
+ exports.default = FullScreenOverlay;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A plugin which provides .storybookSwitcher() on Reactotron.
3
+ */
4
+ declare const _default: () => () => Plugin<ReactotronCore>;
5
+ export default _default;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/storybook/index.tsx"],"names":[],"mappings":"AAMA;;GAEG;;AACH,wBAuBC"}
@@ -0,0 +1,27 @@
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
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const mitt_1 = __importDefault(require("mitt"));
8
+ const storybook_1 = __importDefault(require("./storybook"));
9
+ /**
10
+ * A plugin which provides .storybookSwitcher() on Reactotron.
11
+ */
12
+ exports.default = () => () => {
13
+ const emitter = (0, mitt_1.default)();
14
+ return {
15
+ onCommand: (command) => {
16
+ if (command.type !== "storybook")
17
+ return;
18
+ // relay this payload on to the emitter
19
+ emitter.emit("storybook", command.payload);
20
+ },
21
+ features: {
22
+ storybookSwitcher: (storybookUi) => (WrappedComponent) => function StorybookSwitcherContainer(props) {
23
+ return ((0, jsx_runtime_1.jsx)(storybook_1.default, { storybookUi: storybookUi, emitter: emitter, children: (0, jsx_runtime_1.jsx)(WrappedComponent, { ...props }) }));
24
+ },
25
+ },
26
+ };
27
+ };
@@ -0,0 +1,22 @@
1
+ import React, { Component } from "react";
2
+ interface Props {
3
+ storybookUi: React.ComponentType;
4
+ emitter: any;
5
+ }
6
+ interface State {
7
+ showStorybook: boolean;
8
+ }
9
+ declare class StorybookSwitcher extends Component<React.PropsWithChildren<Props>, State> {
10
+ /**
11
+ * Creates an instance of FullScreenOverlay.
12
+ *
13
+ * @memberOf FullScreenOverlay
14
+ */
15
+ constructor(props: Props);
16
+ /**
17
+ * Draw.
18
+ */
19
+ render(): import("react/jsx-runtime").JSX.Element;
20
+ }
21
+ export default StorybookSwitcher;
22
+ //# sourceMappingURL=storybook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook.d.ts","sourceRoot":"","sources":["../../../src/plugins/storybook/storybook.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGxC,UAAU,KAAK;IACb,WAAW,EAAE,KAAK,CAAC,aAAa,CAAA;IAChC,OAAO,EAAE,GAAG,CAAA;CACb;AAED,UAAU,KAAK;IACb,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,cAAM,iBAAkB,SAAQ,SAAS,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IAC9E;;;;OAIG;gBACS,KAAK,EAAE,KAAK;IAaxB;;OAEG;IACH,MAAM;CAMP;AAED,eAAe,iBAAiB,CAAA"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
5
+ const react_native_1 = require("react-native");
6
+ class StorybookSwitcher extends react_1.Component {
7
+ /**
8
+ * Creates an instance of FullScreenOverlay.
9
+ *
10
+ * @memberOf FullScreenOverlay
11
+ */
12
+ constructor(props) {
13
+ super(props);
14
+ this.state = {
15
+ showStorybook: false,
16
+ };
17
+ // when the server sends stuff
18
+ props.emitter.on("storybook", (payload) => {
19
+ this.setState({ showStorybook: payload });
20
+ });
21
+ }
22
+ /**
23
+ * Draw.
24
+ */
25
+ render() {
26
+ const { showStorybook } = this.state;
27
+ const { storybookUi: StorybookUi, children } = this.props;
28
+ return (0, jsx_runtime_1.jsx)(react_native_1.View, { style: { flex: 1 }, children: showStorybook ? (0, jsx_runtime_1.jsx)(StorybookUi, {}) : children });
29
+ }
30
+ }
31
+ exports.default = StorybookSwitcher;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Provides a global error handler to report errors..
3
+ */
4
+ import { DReactionCore } from 'dreaction-client-core';
5
+ import { LogBoxStatic as LogBoxStaticPublic } from 'react-native/Libraries/LogBox/LogBox';
6
+ interface LogBoxStaticPrivate extends LogBoxStaticPublic {
7
+ /**
8
+ * @see https://github.com/facebook/react-native/blob/v0.72.1/packages/react-native/Libraries/LogBox/LogBox.js#L29
9
+ */
10
+ addException: (error: any) => void;
11
+ }
12
+ declare const LogBox: LogBoxStaticPrivate;
13
+ export interface ErrorStackFrame {
14
+ fileName: string;
15
+ functionName: string;
16
+ lineNumber: number;
17
+ columnNumber?: number | null;
18
+ }
19
+ export interface TrackGlobalErrorsOptions {
20
+ veto?: (frame: ErrorStackFrame) => boolean;
21
+ }
22
+ /**
23
+ * Track global errors and send them to Reactotron logger.
24
+ */
25
+ declare const trackGlobalErrors: (options?: TrackGlobalErrorsOptions) => (reactotron: DReactionCore) => {
26
+ onConnect: () => void;
27
+ features: {
28
+ reportError: (error: Parameters<typeof LogBox.addException>[0]) => void;
29
+ };
30
+ };
31
+ export default trackGlobalErrors;
32
+ //# sourceMappingURL=trackGlobalErrors.d.ts.map
@@ -0,0 +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,kBAAkB,aAAa;;;6BAUpC,UAAU,CAAC,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;;CA+EtE,CAAC;AAEJ,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,100 @@
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
+ /**
7
+ * Provides a global error handler to report errors..
8
+ */
9
+ const dreaction_client_core_1 = require("dreaction-client-core");
10
+ const LogBox_1 = __importDefault(require("react-native/Libraries/LogBox/LogBox"));
11
+ const LogBox = LogBox_1.default;
12
+ // a few functions to help source map errors -- these seem to be not available immediately
13
+ // so we're lazy loading.
14
+ let parseErrorStack;
15
+ let symbolicateStackTrace;
16
+ // defaults
17
+ const PLUGIN_DEFAULTS = {
18
+ veto: undefined,
19
+ };
20
+ const objectifyError = (error) => {
21
+ const objectifiedError = {};
22
+ Object.getOwnPropertyNames(error).forEach((key) => {
23
+ objectifiedError[key] = error[key];
24
+ });
25
+ return objectifiedError;
26
+ };
27
+ // const reactNativeFrameFinder = frame => contains('/node_modules/react-native/', frame.fileName)
28
+ /**
29
+ * Track global errors and send them to Reactotron logger.
30
+ */
31
+ const trackGlobalErrors = (options) => (reactotron) => {
32
+ // make sure we have the logger plugin
33
+ (0, dreaction_client_core_1.assertHasLoggerPlugin)(reactotron);
34
+ const client = reactotron;
35
+ // setup configuration
36
+ const config = Object.assign({}, PLUGIN_DEFAULTS, options || {});
37
+ // manually fire an error
38
+ function reportError(error) {
39
+ try {
40
+ parseErrorStack =
41
+ parseErrorStack ||
42
+ require('react-native/Libraries/Core/Devtools/parseErrorStack');
43
+ symbolicateStackTrace =
44
+ symbolicateStackTrace ||
45
+ require('react-native/Libraries/Core/Devtools/symbolicateStackTrace');
46
+ }
47
+ catch (e) {
48
+ client.error('Unable to load "react-native/Libraries/Core/Devtools/parseErrorStack" or "react-native/Libraries/Core/Devtools/symbolicateStackTrace"', []);
49
+ client.debug(objectifyError(e));
50
+ return;
51
+ }
52
+ if (!parseErrorStack || !symbolicateStackTrace) {
53
+ return;
54
+ }
55
+ let parsedStacktrace;
56
+ try {
57
+ // parseErrorStack arg type is wrong, it's expecting an array, a string, or a hermes error data, https://github.com/facebook/react-native/blob/v0.72.1/packages/react-native/Libraries/Core/Devtools/parseErrorStack.js#L41
58
+ parsedStacktrace = parseErrorStack(error.stack);
59
+ }
60
+ catch (e) {
61
+ client.error('Unable to parse stack trace from error object', []);
62
+ client.debug(objectifyError(e));
63
+ return;
64
+ }
65
+ symbolicateStackTrace(parsedStacktrace)
66
+ .then((symbolicatedStackTrace) => {
67
+ let prettyStackFrames = symbolicatedStackTrace.stack.map((stackFrame) => ({
68
+ fileName: stackFrame.file,
69
+ functionName: stackFrame.methodName,
70
+ lineNumber: stackFrame.lineNumber,
71
+ }));
72
+ // does the dev want us to keep each frame?
73
+ if (config.veto) {
74
+ prettyStackFrames = prettyStackFrames.filter((frame) => config?.veto?.(frame));
75
+ }
76
+ client.error(error.message, prettyStackFrames); // TODO: Fix this.
77
+ })
78
+ .catch((e) => {
79
+ client.error('Unable to symbolicate stack trace from error object', []);
80
+ client.debug(objectifyError(e));
81
+ });
82
+ }
83
+ // the reactotron plugin interface
84
+ return {
85
+ onConnect: () => {
86
+ LogBox.addException = new Proxy(LogBox.addException, {
87
+ apply: function (target, thisArg, argumentsList) {
88
+ const error = argumentsList[0];
89
+ reportError(error);
90
+ return target.apply(thisArg, argumentsList);
91
+ },
92
+ });
93
+ },
94
+ // attach these functions to the Reactotron
95
+ features: {
96
+ reportError,
97
+ },
98
+ };
99
+ };
100
+ exports.default = trackGlobalErrors;
@@ -0,0 +1,9 @@
1
+ import { DReactionCore } from 'dreaction-client-core';
2
+ /**
3
+ * Track calls to console.log, console.warn, and console.debug and send them to Reactotron logger
4
+ */
5
+ declare const trackGlobalLogs: () => (reactotron: DReactionCore) => {
6
+ onConnect: () => void;
7
+ };
8
+ export default trackGlobalLogs;
9
+ //# sourceMappingURL=trackGlobalLogs.d.ts.map
@@ -0,0 +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,qBAAsB,aAAa;;CA4BvD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dreaction_client_core_1 = require("dreaction-client-core");
4
+ /**
5
+ * Track calls to console.log, console.warn, and console.debug and send them to Reactotron logger
6
+ */
7
+ const trackGlobalLogs = () => (reactotron) => {
8
+ (0, dreaction_client_core_1.assertHasLoggerPlugin)(reactotron);
9
+ const client = reactotron;
10
+ return {
11
+ onConnect: () => {
12
+ const originalConsoleLog = console.log;
13
+ console.log = (...args) => {
14
+ originalConsoleLog(...args);
15
+ client.log(...args);
16
+ };
17
+ const originalConsoleWarn = console.warn;
18
+ console.warn = (...args) => {
19
+ originalConsoleWarn(...args);
20
+ client.warn(args[0]);
21
+ };
22
+ const originalConsoleDebug = console.debug;
23
+ console.debug = (...args) => {
24
+ originalConsoleDebug(...args);
25
+ client.debug(args[0]);
26
+ };
27
+ // console.error is taken care of by ./trackGlobalErrors.ts
28
+ },
29
+ };
30
+ };
31
+ exports.default = trackGlobalLogs;
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "dreaction-react-native",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "",
6
+ "main": "lib/index.js",
7
+ "files": [
8
+ "lib",
9
+ "src"
10
+ ],
11
+ "keywords": [
12
+ "dreaction"
13
+ ],
14
+ "author": "moonrailgun <moonrailgun@gmail.com>",
15
+ "license": "MIT",
16
+ "dependencies": {
17
+ "dreaction-client-core": "1.0.0",
18
+ "dreaction-protocol": "1.0.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/react-native": "^0.73.0",
22
+ "typescript": "^5.4.5"
23
+ },
24
+ "scripts": {
25
+ "dev": "tsc --watch",
26
+ "build": "tsc",
27
+ "test": "vitest"
28
+ }
29
+ }