noibu-react-native 0.2.12 → 0.2.13

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 (37) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +69 -0
  3. package/dist/api/ClientConfig.d.ts +3 -0
  4. package/dist/api/ClientConfig.js +3 -0
  5. package/dist/api/MetroplexSocket.d.ts +1 -1
  6. package/dist/api/MetroplexSocket.js +11 -5
  7. package/dist/constants.js +1 -1
  8. package/dist/mobileTransformer/mobile-replay/index.d.ts +10 -0
  9. package/dist/mobileTransformer/mobile-replay/index.js +57 -0
  10. package/dist/mobileTransformer/mobile-replay/mobile.types.d.ts +312 -0
  11. package/dist/mobileTransformer/mobile-replay/mobile.types.js +11 -0
  12. package/dist/mobileTransformer/mobile-replay/rrweb.d.ts +573 -0
  13. package/dist/mobileTransformer/mobile-replay/rrweb.js +39 -0
  14. package/dist/mobileTransformer/mobile-replay/schema/mobile/rr-mobile-schema.json.js +1559 -0
  15. package/dist/mobileTransformer/mobile-replay/schema/web/rr-web-schema.json.js +1183 -0
  16. package/dist/mobileTransformer/mobile-replay/transformer/colors.d.ts +1 -0
  17. package/dist/mobileTransformer/mobile-replay/transformer/colors.js +43 -0
  18. package/dist/mobileTransformer/mobile-replay/transformer/screen-chrome.d.ts +13 -0
  19. package/dist/mobileTransformer/mobile-replay/transformer/screen-chrome.js +142 -0
  20. package/dist/mobileTransformer/mobile-replay/transformer/transformers.d.ts +59 -0
  21. package/dist/mobileTransformer/mobile-replay/transformer/transformers.js +1160 -0
  22. package/dist/mobileTransformer/mobile-replay/transformer/types.d.ts +40 -0
  23. package/dist/mobileTransformer/mobile-replay/transformer/wireframeStyle.d.ts +16 -0
  24. package/dist/mobileTransformer/mobile-replay/transformer/wireframeStyle.js +197 -0
  25. package/dist/mobileTransformer/utils.d.ts +1 -0
  26. package/dist/mobileTransformer/utils.js +5 -0
  27. package/dist/monitors/http-tools/GqlErrorValidator.js +4 -3
  28. package/dist/sessionRecorder/SessionRecorder.js +7 -4
  29. package/dist/sessionRecorder/nativeSessionRecorderSubscription.js +23 -3
  30. package/dist/sessionRecorder/types.d.ts +1 -1
  31. package/dist/utils/piiRedactor.js +15 -2
  32. package/dist/utils/piiRedactor.test.d.ts +1 -0
  33. package/ios/IOSPocEmitter.h +7 -0
  34. package/ios/IOSPocEmitter.m +33 -0
  35. package/noibu-react-native.podspec +50 -0
  36. package/package.json +17 -4
  37. package/android/.gitignore +0 -13
@@ -0,0 +1 @@
1
+ export declare const isLight: (hexColor: string) => boolean;
@@ -0,0 +1,43 @@
1
+ // from https://gist.github.com/t1grok/a0f6d04db569890bcb57
2
+ function hexToRgb(hexColor) {
3
+ const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
4
+ hexColor = hexColor.replace(shorthandRegex, function (_, r, g, b) {
5
+ return r + r + g + g + b + b;
6
+ });
7
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hexColor);
8
+ return result
9
+ ? {
10
+ r: parseInt(result[1], 16),
11
+ g: parseInt(result[2], 16),
12
+ b: parseInt(result[3], 16),
13
+ }
14
+ : null;
15
+ }
16
+ function rgbToYuv(rgbColor) {
17
+ let y, u, v;
18
+ y = rgbColor.r * 0.299 + rgbColor.g * 0.587 + rgbColor.b * 0.114;
19
+ u =
20
+ rgbColor.r * -0.168736 +
21
+ rgbColor.g * -0.331264 +
22
+ rgbColor.b * 0.5 +
23
+ 128;
24
+ v =
25
+ rgbColor.r * 0.5 +
26
+ rgbColor.g * -0.418688 +
27
+ rgbColor.b * -0.081312 +
28
+ 128;
29
+ y = Math.floor(y);
30
+ u = Math.floor(u);
31
+ v = Math.floor(v);
32
+ return { y: y, u: u, v: v };
33
+ }
34
+ const isLight = (hexColor) => {
35
+ const rgbColor = hexToRgb(hexColor);
36
+ if (!rgbColor) {
37
+ return false;
38
+ }
39
+ const yuvColor = rgbToYuv(rgbColor);
40
+ return yuvColor.y > 128;
41
+ };
42
+
43
+ export { isLight };
@@ -0,0 +1,13 @@
1
+ import { keyboardEvent, serializedNodeWithId, wireframeNavigationBar, wireframeStatusBar } from '../mobile.types';
2
+ import { ConversionContext, ConversionResult } from './types';
3
+ export declare let navigationBackgroundColor: string | undefined;
4
+ export declare let navigationColor: string | undefined;
5
+ export declare function makeNavigationBar(wireframe: wireframeNavigationBar, _children: serializedNodeWithId[], context: ConversionContext): ConversionResult<serializedNodeWithId> | null;
6
+ /**
7
+ * tricky: we need to accept children because that's the interface of converters, but we don't use them
8
+ */
9
+ export declare function makeStatusBar(wireframe: wireframeStatusBar, _children: serializedNodeWithId[], context: ConversionContext): ConversionResult<serializedNodeWithId>;
10
+ export declare function makeOpenKeyboardPlaceholder(mobileCustomEvent: keyboardEvent & {
11
+ timestamp: number;
12
+ delay?: number;
13
+ }, context: ConversionContext): ConversionResult<serializedNodeWithId> | null;
@@ -0,0 +1,142 @@
1
+ import { NodeType } from '../mobile.types.js';
2
+ import { isLight } from './colors.js';
3
+ import { _isPositiveInteger, makePlaceholderElement, KEYBOARD_ID, NAVIGATION_BAR_ID, STATUS_BAR_ID, BACKGROUND } from './transformers.js';
4
+ import { asStyleString, makeStylesString } from './wireframeStyle.js';
5
+
6
+ let navigationBackgroundColor = undefined;
7
+ let navigationColor = undefined;
8
+ function spacerDiv(idSequence) {
9
+ const spacerId = idSequence.next().value;
10
+ return {
11
+ type: NodeType.Element,
12
+ tagName: 'div',
13
+ attributes: {
14
+ style: 'width: 5px;',
15
+ 'data-rrweb-id': spacerId,
16
+ },
17
+ id: spacerId,
18
+ childNodes: [],
19
+ };
20
+ }
21
+ function makeFakeNavButton(icon, context) {
22
+ return {
23
+ type: NodeType.Element,
24
+ tagName: 'div',
25
+ attributes: {},
26
+ id: context.idSequence.next().value,
27
+ childNodes: [
28
+ {
29
+ type: NodeType.Text,
30
+ textContent: icon,
31
+ id: context.idSequence.next().value,
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ function makeNavigationBar(wireframe, _children, context) {
37
+ var _a;
38
+ const _id = wireframe.id || NAVIGATION_BAR_ID;
39
+ const backArrowTriangle = makeFakeNavButton('◀', context);
40
+ const homeCircle = makeFakeNavButton('⚪', context);
41
+ const screenButton = makeFakeNavButton('⬜️', context);
42
+ navigationBackgroundColor = (_a = wireframe.style) === null || _a === void 0 ? void 0 : _a.backgroundColor;
43
+ navigationColor = isLight(navigationBackgroundColor || BACKGROUND)
44
+ ? 'black'
45
+ : 'white';
46
+ return {
47
+ result: {
48
+ type: NodeType.Element,
49
+ tagName: 'div',
50
+ attributes: {
51
+ style: asStyleString([
52
+ makeStylesString(wireframe),
53
+ 'display:flex',
54
+ 'flex-direction:row',
55
+ 'align-items:center',
56
+ 'justify-content:space-around',
57
+ 'color:' + navigationColor,
58
+ ]),
59
+ 'data-rrweb-id': _id,
60
+ },
61
+ id: _id,
62
+ childNodes: [backArrowTriangle, homeCircle, screenButton],
63
+ },
64
+ context,
65
+ };
66
+ }
67
+ /**
68
+ * tricky: we need to accept children because that's the interface of converters, but we don't use them
69
+ */
70
+ function makeStatusBar(wireframe, _children, context) {
71
+ var _a;
72
+ const clockId = context.idSequence.next().value;
73
+ // convert the wireframe timestamp to a date time, then get just the hour and minute of the time from that
74
+ const clockTime = context.timestamp
75
+ ? new Date(context.timestamp).toLocaleTimeString([], {
76
+ hour: '2-digit',
77
+ minute: '2-digit',
78
+ })
79
+ : '';
80
+ const clockFontColor = isLight(((_a = wireframe.style) === null || _a === void 0 ? void 0 : _a.backgroundColor) || '#ffffff')
81
+ ? 'black'
82
+ : 'white';
83
+ const clock = {
84
+ type: NodeType.Element,
85
+ tagName: 'div',
86
+ attributes: {
87
+ 'data-rrweb-id': clockId,
88
+ },
89
+ id: clockId,
90
+ childNodes: [
91
+ {
92
+ type: NodeType.Text,
93
+ textContent: clockTime,
94
+ id: context.idSequence.next().value,
95
+ },
96
+ ],
97
+ };
98
+ return {
99
+ result: {
100
+ type: NodeType.Element,
101
+ tagName: 'div',
102
+ attributes: {
103
+ style: asStyleString([
104
+ makeStylesString(wireframe, { color: clockFontColor }),
105
+ 'display:flex',
106
+ 'flex-direction:row',
107
+ 'align-items:center',
108
+ ]),
109
+ 'data-rrweb-id': STATUS_BAR_ID,
110
+ },
111
+ id: STATUS_BAR_ID,
112
+ childNodes: [spacerDiv(context.idSequence), clock],
113
+ },
114
+ context,
115
+ };
116
+ }
117
+ function makeOpenKeyboardPlaceholder(mobileCustomEvent, context) {
118
+ if (!mobileCustomEvent.data.payload.open) {
119
+ return null;
120
+ }
121
+ const shouldAbsolutelyPosition = _isPositiveInteger(mobileCustomEvent.data.payload.x) ||
122
+ _isPositiveInteger(mobileCustomEvent.data.payload.y);
123
+ return makePlaceholderElement({
124
+ id: KEYBOARD_ID,
125
+ type: 'placeholder',
126
+ label: 'keyboard',
127
+ height: mobileCustomEvent.data.payload.height,
128
+ width: _isPositiveInteger(mobileCustomEvent.data.payload.width)
129
+ ? mobileCustomEvent.data.payload.width
130
+ : '100vw',
131
+ style: {
132
+ backgroundColor: navigationBackgroundColor,
133
+ color: navigationBackgroundColor ? navigationColor : undefined,
134
+ },
135
+ }, [], {
136
+ timestamp: context.timestamp,
137
+ idSequence: context.idSequence,
138
+ styleOverride: Object.assign({}, (shouldAbsolutelyPosition ? {} : { bottom: true })),
139
+ });
140
+ }
141
+
142
+ export { makeNavigationBar, makeOpenKeyboardPlaceholder, makeStatusBar, navigationBackgroundColor, navigationColor };
@@ -0,0 +1,59 @@
1
+ import { customEvent, fullSnapshotEvent, incrementalSnapshotEvent, metaEvent } from '../rrweb';
2
+ import { fullSnapshotEvent as MobileFullSnapshotEvent, keyboardEvent, metaEvent as MobileMetaEvent, MobileIncrementalSnapshotEvent, serializedNodeWithId, wireframe, wireframeDiv, wireframeNavigationBar, wireframeStatusBar } from '../mobile.types';
3
+ import { ConversionContext, ConversionResult } from './types';
4
+ export declare const BACKGROUND = "#f3f4ef";
5
+ export declare const NAVIGATION_BAR_ID = 8;
6
+ export declare const KEYBOARD_ID = 10;
7
+ export declare const STATUS_BAR_PARENT_ID = 11;
8
+ export declare const STATUS_BAR_ID = 12;
9
+ export declare function _isPositiveInteger(id: unknown): id is number;
10
+ export declare const makeCustomEvent: (mobileCustomEvent: (customEvent | keyboardEvent) & {
11
+ timestamp: number;
12
+ delay?: number;
13
+ }) => (customEvent | incrementalSnapshotEvent) & {
14
+ timestamp: number;
15
+ delay?: number;
16
+ };
17
+ export declare const makeMetaEvent: (mobileMetaEvent: MobileMetaEvent & {
18
+ timestamp: number;
19
+ }) => metaEvent & {
20
+ timestamp: number;
21
+ delay?: number;
22
+ };
23
+ export declare function makeDivElement(wireframe: wireframeDiv, children: serializedNodeWithId[], context: ConversionContext): ConversionResult<serializedNodeWithId> | null;
24
+ export declare function makePlaceholderElement(wireframe: wireframe, children: serializedNodeWithId[], context: ConversionContext): ConversionResult<serializedNodeWithId> | null;
25
+ export declare function dataURIOrPNG(src: string): string;
26
+ /**
27
+ * We want to ensure that any events don't use id = 0.
28
+ * They must always represent a valid ID from the dom, so we swap in the body id when the id = 0.
29
+ *
30
+ * For "removes", we don't need to do anything, the id of the element to be removed remains valid. We won't try and remove other elements that we added during transformation in order to show that element.
31
+ *
32
+ * "adds" are converted from wireframes to nodes and converted to `incrementalSnapshotEvent.adds`
33
+ *
34
+ * "updates" are converted to a remove and an add.
35
+ *
36
+ */
37
+ export declare const makeIncrementalEvent: (mobileEvent: (MobileIncrementalSnapshotEvent | incrementalSnapshotEvent) & {
38
+ timestamp: number;
39
+ delay?: number;
40
+ }) => incrementalSnapshotEvent & {
41
+ timestamp: number;
42
+ delay?: number;
43
+ };
44
+ /**
45
+ * We want to be able to place the status bar and navigation bar in the correct stacking order.
46
+ * So, we lift them out of the tree, and return them separately.
47
+ */
48
+ export declare function stripBarsFromWireframes(wireframes: wireframe[]): {
49
+ statusBar: wireframeStatusBar | undefined;
50
+ navigationBar: wireframeNavigationBar | undefined;
51
+ appNodes: wireframe[];
52
+ };
53
+ export declare const makeFullEvent: (mobileEvent: MobileFullSnapshotEvent & {
54
+ timestamp: number;
55
+ delay?: number;
56
+ }) => fullSnapshotEvent & {
57
+ timestamp: number;
58
+ delay?: number;
59
+ };