@multiplayer-app/session-recorder-react-native 0.0.1 → 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 (228) hide show
  1. package/README.md +708 -83
  2. package/SessionRecorderNative.podspec +26 -0
  3. package/android/build.gradle +34 -0
  4. package/copy-react-native-dist.sh +34 -16
  5. package/dist/components/ScreenRecorderView/ScreenRecorderView.js +1 -1
  6. package/dist/components/ScreenRecorderView/ScreenRecorderView.js.map +1 -1
  7. package/dist/components/SessionRecorderWidget/ErrorBanner.d.ts +7 -0
  8. package/dist/components/SessionRecorderWidget/ErrorBanner.js +1 -0
  9. package/dist/components/SessionRecorderWidget/ErrorBanner.js.map +1 -0
  10. package/dist/components/SessionRecorderWidget/FinalPopover.d.ts +12 -0
  11. package/dist/components/SessionRecorderWidget/FinalPopover.js +1 -0
  12. package/dist/components/SessionRecorderWidget/FinalPopover.js.map +1 -0
  13. package/dist/components/SessionRecorderWidget/FloatingButton.d.ts +8 -0
  14. package/dist/components/SessionRecorderWidget/FloatingButton.js +1 -0
  15. package/dist/components/SessionRecorderWidget/FloatingButton.js.map +1 -0
  16. package/dist/components/SessionRecorderWidget/InitialPopover.d.ts +16 -0
  17. package/dist/components/SessionRecorderWidget/InitialPopover.js +1 -0
  18. package/dist/components/SessionRecorderWidget/InitialPopover.js.map +1 -0
  19. package/dist/components/SessionRecorderWidget/ModalContainer.d.ts +8 -0
  20. package/dist/components/SessionRecorderWidget/ModalContainer.js +1 -0
  21. package/dist/components/SessionRecorderWidget/ModalContainer.js.map +1 -0
  22. package/dist/components/SessionRecorderWidget/ModalHeader.d.ts +6 -0
  23. package/dist/components/SessionRecorderWidget/ModalHeader.js +1 -0
  24. package/dist/components/SessionRecorderWidget/ModalHeader.js.map +1 -0
  25. package/dist/components/SessionRecorderWidget/SessionRecorderWidget.d.ts +5 -0
  26. package/dist/components/SessionRecorderWidget/SessionRecorderWidget.js +1 -0
  27. package/dist/components/SessionRecorderWidget/SessionRecorderWidget.js.map +1 -0
  28. package/dist/components/SessionRecorderWidget/icons.d.ts +11 -0
  29. package/dist/components/SessionRecorderWidget/icons.js +1 -0
  30. package/dist/components/SessionRecorderWidget/icons.js.map +1 -0
  31. package/dist/components/SessionRecorderWidget/index.d.ts +2 -0
  32. package/dist/components/SessionRecorderWidget/index.js +1 -0
  33. package/dist/components/SessionRecorderWidget/index.js.map +1 -0
  34. package/dist/components/SessionRecorderWidget/styles.d.ts +165 -0
  35. package/dist/components/SessionRecorderWidget/styles.js +1 -0
  36. package/dist/components/SessionRecorderWidget/styles.js.map +1 -0
  37. package/dist/components/index.d.ts +2 -1
  38. package/dist/components/index.js +1 -1
  39. package/dist/components/index.js.map +1 -1
  40. package/dist/config/constants.js +1 -1
  41. package/dist/config/constants.js.map +1 -1
  42. package/dist/config/defaults.d.ts +4 -4
  43. package/dist/config/defaults.js +1 -1
  44. package/dist/config/defaults.js.map +1 -1
  45. package/dist/config/masking.d.ts +2 -2
  46. package/dist/config/masking.js +1 -1
  47. package/dist/config/masking.js.map +1 -1
  48. package/dist/config/session-recorder.js +1 -1
  49. package/dist/config/session-recorder.js.map +1 -1
  50. package/dist/config/validators.d.ts +1 -1
  51. package/dist/config/validators.js +1 -1
  52. package/dist/config/validators.js.map +1 -1
  53. package/dist/config/widget.d.ts +9 -0
  54. package/dist/config/widget.js +1 -0
  55. package/dist/config/widget.js.map +1 -0
  56. package/dist/context/SessionRecorderContext.d.ts +12 -3
  57. package/dist/context/SessionRecorderContext.js +1 -1
  58. package/dist/context/SessionRecorderContext.js.map +1 -1
  59. package/dist/context/SessionRecorderStore.d.ts +12 -0
  60. package/dist/context/SessionRecorderStore.js +1 -0
  61. package/dist/context/SessionRecorderStore.js.map +1 -0
  62. package/dist/context/useSessionRecorderStore.d.ts +8 -0
  63. package/dist/context/useSessionRecorderStore.js +1 -0
  64. package/dist/context/useSessionRecorderStore.js.map +1 -0
  65. package/dist/context/useStoreSelector.d.ts +4 -0
  66. package/dist/context/useStoreSelector.js +1 -0
  67. package/dist/context/useStoreSelector.js.map +1 -0
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.js +1 -1
  70. package/dist/index.js.map +1 -1
  71. package/dist/native/GestureRecorderNative.d.ts +57 -0
  72. package/dist/native/GestureRecorderNative.js +1 -0
  73. package/dist/native/GestureRecorderNative.js.map +1 -0
  74. package/dist/native/SessionRecorderNative.d.ts +33 -0
  75. package/dist/native/SessionRecorderNative.js +1 -0
  76. package/dist/native/SessionRecorderNative.js.map +1 -0
  77. package/dist/native/index.d.ts +2 -0
  78. package/dist/native/index.js +1 -0
  79. package/dist/native/index.js.map +1 -0
  80. package/dist/otel/index.js +1 -1
  81. package/dist/otel/index.js.map +1 -1
  82. package/dist/patch/xhr.js +1 -1
  83. package/dist/patch/xhr.js.map +1 -1
  84. package/dist/recorder/eventExporter.d.ts +4 -1
  85. package/dist/recorder/eventExporter.js +1 -1
  86. package/dist/recorder/eventExporter.js.map +1 -1
  87. package/dist/recorder/gestureRecorder.d.ts +28 -62
  88. package/dist/recorder/gestureRecorder.js +1 -1
  89. package/dist/recorder/gestureRecorder.js.map +1 -1
  90. package/dist/recorder/index.d.ts +2 -0
  91. package/dist/recorder/index.js +1 -1
  92. package/dist/recorder/index.js.map +1 -1
  93. package/dist/recorder/navigationTracker.d.ts +4 -19
  94. package/dist/recorder/navigationTracker.js +1 -1
  95. package/dist/recorder/navigationTracker.js.map +1 -1
  96. package/dist/recorder/screenRecorder.d.ts +11 -5
  97. package/dist/recorder/screenRecorder.js +1 -1
  98. package/dist/recorder/screenRecorder.js.map +1 -1
  99. package/dist/services/api.service.d.ts +12 -3
  100. package/dist/services/api.service.js +1 -1
  101. package/dist/services/api.service.js.map +1 -1
  102. package/dist/services/network.service.d.ts +46 -0
  103. package/dist/services/network.service.js +1 -0
  104. package/dist/services/network.service.js.map +1 -0
  105. package/dist/services/screenMaskingService.d.ts +47 -0
  106. package/dist/services/screenMaskingService.js +1 -0
  107. package/dist/services/screenMaskingService.js.map +1 -0
  108. package/dist/services/storage.service.d.ts +18 -2
  109. package/dist/services/storage.service.js +1 -1
  110. package/dist/services/storage.service.js.map +1 -1
  111. package/dist/session-recorder.d.ts +18 -33
  112. package/dist/session-recorder.js +1 -1
  113. package/dist/session-recorder.js.map +1 -1
  114. package/dist/types/configs.d.ts +85 -0
  115. package/dist/types/configs.js +1 -0
  116. package/dist/types/configs.js.map +1 -0
  117. package/dist/types/index.d.ts +1 -0
  118. package/dist/types/index.js +1 -1
  119. package/dist/types/index.js.map +1 -1
  120. package/dist/types/session-recorder.d.ts +105 -132
  121. package/dist/types/session-recorder.js +1 -1
  122. package/dist/types/session-recorder.js.map +1 -1
  123. package/dist/utils/constants.optional.d.ts +21 -0
  124. package/dist/utils/constants.optional.expo.d.ts +3 -0
  125. package/dist/utils/constants.optional.expo.js +1 -0
  126. package/dist/utils/constants.optional.expo.js.map +1 -0
  127. package/dist/utils/constants.optional.js +1 -0
  128. package/dist/utils/constants.optional.js.map +1 -0
  129. package/dist/utils/createStore.d.ts +8 -0
  130. package/dist/utils/createStore.js +1 -0
  131. package/dist/utils/createStore.js.map +1 -0
  132. package/dist/utils/logger.d.ts +2 -7
  133. package/dist/utils/logger.js +1 -1
  134. package/dist/utils/logger.js.map +1 -1
  135. package/dist/utils/platform.d.ts +11 -0
  136. package/dist/utils/platform.js +1 -1
  137. package/dist/utils/platform.js.map +1 -1
  138. package/dist/utils/rrweb-events.d.ts +4 -3
  139. package/dist/utils/rrweb-events.js +1 -1
  140. package/dist/utils/rrweb-events.js.map +1 -1
  141. package/dist/utils/session.d.ts +2 -1
  142. package/dist/utils/session.js +1 -1
  143. package/dist/utils/session.js.map +1 -1
  144. package/dist/utils/shallowEqual.d.ts +1 -0
  145. package/dist/utils/shallowEqual.js +1 -0
  146. package/dist/utils/shallowEqual.js.map +1 -0
  147. package/dist/version.d.ts +1 -1
  148. package/dist/version.js +1 -1
  149. package/ios/GestureRecorderNative.m +21 -0
  150. package/ios/GestureRecorderNative.swift +316 -0
  151. package/ios/SessionRecorderNative.m +17 -0
  152. package/ios/SessionRecorderNative.podspec +26 -0
  153. package/ios/SessionRecorderNative.swift +599 -0
  154. package/package.json +15 -16
  155. package/react-native.config.js +12 -0
  156. package/RRWEB_INTEGRATION.md +0 -336
  157. package/VIEWSHOT_INTEGRATION_TEST.md +0 -123
  158. package/babel.config.js +0 -13
  159. package/dist/components/GestureCaptureWrapper/GestureCaptureWrapper.d.ts +0 -6
  160. package/dist/components/GestureCaptureWrapper/GestureCaptureWrapper.js +0 -1
  161. package/dist/components/GestureCaptureWrapper/GestureCaptureWrapper.js.map +0 -1
  162. package/dist/components/GestureCaptureWrapper/index.d.ts +0 -1
  163. package/dist/components/GestureCaptureWrapper/index.js +0 -1
  164. package/dist/components/GestureCaptureWrapper/index.js.map +0 -1
  165. package/dist/components/GestureCaptureWrapper.d.ts +0 -6
  166. package/dist/components/GestureCaptureWrapper.js +0 -1
  167. package/dist/components/GestureCaptureWrapper.js.map +0 -1
  168. package/dist/expo.d.ts +0 -7
  169. package/dist/expo.js +0 -1
  170. package/dist/expo.js.map +0 -1
  171. package/dist/otel/instrumentations/gestureInstrumentation.d.ts +0 -15
  172. package/dist/otel/instrumentations/gestureInstrumentation.js +0 -1
  173. package/dist/otel/instrumentations/gestureInstrumentation.js.map +0 -1
  174. package/dist/otel/instrumentations/reactNativeInstrumentation.d.ts +0 -8
  175. package/dist/otel/instrumentations/reactNativeInstrumentation.js +0 -1
  176. package/dist/otel/instrumentations/reactNativeInstrumentation.js.map +0 -1
  177. package/dist/otel/instrumentations/reactNavigationInstrumentation.d.ts +0 -13
  178. package/dist/otel/instrumentations/reactNavigationInstrumentation.js +0 -1
  179. package/dist/otel/instrumentations/reactNavigationInstrumentation.js.map +0 -1
  180. package/dist/recorder/gestureHandlerRecorder.d.ts +0 -19
  181. package/dist/recorder/gestureHandlerRecorder.js +0 -1
  182. package/dist/recorder/gestureHandlerRecorder.js.map +0 -1
  183. package/dist/types/rrweb.d.ts +0 -118
  184. package/dist/types/rrweb.js +0 -1
  185. package/dist/types/rrweb.js.map +0 -1
  186. package/scripts/generate-app-metadata.js +0 -173
  187. package/src/components/GestureCaptureWrapper/GestureCaptureWrapper.tsx +0 -86
  188. package/src/components/GestureCaptureWrapper/index.ts +0 -1
  189. package/src/components/ScreenRecorderView/ScreenRecorderView.tsx +0 -72
  190. package/src/components/ScreenRecorderView/index.ts +0 -1
  191. package/src/components/index.ts +0 -1
  192. package/src/config/constants.ts +0 -60
  193. package/src/config/defaults.ts +0 -82
  194. package/src/config/index.ts +0 -6
  195. package/src/config/masking.ts +0 -27
  196. package/src/config/session-recorder.ts +0 -55
  197. package/src/config/validators.ts +0 -31
  198. package/src/context/SessionRecorderContext.tsx +0 -75
  199. package/src/expo.ts +0 -11
  200. package/src/index.ts +0 -17
  201. package/src/otel/helpers.ts +0 -275
  202. package/src/otel/index.ts +0 -138
  203. package/src/otel/instrumentations/index.ts +0 -115
  204. package/src/patch/index.ts +0 -1
  205. package/src/patch/xhr.ts +0 -142
  206. package/src/recorder/eventExporter.ts +0 -141
  207. package/src/recorder/gestureRecorder.ts +0 -498
  208. package/src/recorder/index.ts +0 -179
  209. package/src/recorder/navigationTracker.ts +0 -449
  210. package/src/recorder/screenRecorder.ts +0 -498
  211. package/src/services/api.service.ts +0 -203
  212. package/src/services/storage.service.ts +0 -158
  213. package/src/session-recorder.ts +0 -600
  214. package/src/types/expo.d.ts +0 -23
  215. package/src/types/index.ts +0 -28
  216. package/src/types/session-recorder.ts +0 -423
  217. package/src/types/session.ts +0 -65
  218. package/src/utils/app-metadata.ts +0 -31
  219. package/src/utils/index.ts +0 -8
  220. package/src/utils/logger.ts +0 -225
  221. package/src/utils/platform.ts +0 -384
  222. package/src/utils/request-utils.ts +0 -61
  223. package/src/utils/rrweb-events.ts +0 -309
  224. package/src/utils/session.ts +0 -18
  225. package/src/utils/time.ts +0 -17
  226. package/src/utils/type-utils.ts +0 -75
  227. package/src/version.ts +0 -1
  228. package/tsconfig.json +0 -24
@@ -1,309 +0,0 @@
1
- import { Dimensions } from 'react-native'
2
- import { EventType, eventWithTime, NodeType, serializedNodeWithId, IncrementalSource, mutationData } from '@rrweb/types'
3
-
4
- /**
5
- * Creates a meta event to mark the start of recording
6
- * @param sessionId - The session ID
7
- * @param sessionType - The type of session (PLAIN or CONTINUOUS)
8
- * @param additionalData - Additional data to include in the meta event
9
- * @returns MetaEvent object
10
- */
11
- export function createRecordingMetaEvent(): eventWithTime {
12
- const screenDimensions = Dimensions.get('window')
13
-
14
- return {
15
- type: EventType.Meta,
16
- data: {
17
- href: 'https://go.multiplayer.app/session-recorder-react-native',
18
- width: screenDimensions.width,
19
- height: screenDimensions.height,
20
- },
21
- timestamp: Date.now(),
22
- }
23
- }
24
-
25
- /**
26
- * Create a full snapshot event with the given base64 image
27
- * @param base64Image - Base64 encoded image data
28
- * @param width - Screen width
29
- * @param height - Screen height
30
- * @param captureFormat - Image format (png, jpg, etc.)
31
- * @param nodeIdCounter - Starting node ID counter (will be modified)
32
- * @returns Full snapshot event
33
- */
34
- export function createFullSnapshotEvent(
35
- base64Image: string,
36
- width: number,
37
- height: number,
38
- captureFormat: string = 'jpg',
39
- nodeIdCounter: { current: number },
40
- ): eventWithTime {
41
- // Create a virtual DOM node representing the screen as an image
42
- const imageNode: serializedNodeWithId = {
43
- type: NodeType.Element,
44
- id: 0,
45
- tagName: 'img',
46
- attributes: {
47
- src: `data:image/${captureFormat};base64,${base64Image}`,
48
- width: width.toString(),
49
- height: height.toString(),
50
- style: `width: ${width}px; height: ${height}px;`,
51
- },
52
- childNodes: [],
53
- }
54
-
55
- // Create the root container
56
- const rootNode: serializedNodeWithId = {
57
- type: NodeType.Element,
58
- id: nodeIdCounter.current++,
59
- tagName: 'div',
60
- attributes: {
61
- style: `width: ${width}px; height: ${height}px; position: relative;`,
62
- },
63
- childNodes: [imageNode],
64
- }
65
-
66
- const domNode: serializedNodeWithId = {
67
- type: NodeType.Document,
68
- childNodes: [
69
- {
70
- type: NodeType.DocumentType,
71
- name: 'html',
72
- publicId: '',
73
- systemId: '',
74
- id: nodeIdCounter.current++,
75
- },
76
- {
77
- type: NodeType.Element,
78
- tagName: 'html',
79
- attributes: {},
80
- childNodes: [
81
- {
82
- type: NodeType.Element,
83
- tagName: 'head',
84
- attributes: {},
85
- childNodes: [
86
- {
87
- type: NodeType.Element,
88
- tagName: 'meta',
89
- attributes: { charset: 'utf-8' },
90
- childNodes: [],
91
- id: nodeIdCounter.current++,
92
- },
93
- {
94
- type: NodeType.Element,
95
- tagName: 'meta',
96
- attributes: {
97
- name: 'viewport',
98
- content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
99
- },
100
- childNodes: [],
101
- id: nodeIdCounter.current++,
102
- },
103
- ],
104
- id: nodeIdCounter.current++,
105
- },
106
- {
107
- type: NodeType.Element,
108
- tagName: 'body',
109
- attributes: {},
110
- childNodes: [rootNode],
111
- id: nodeIdCounter.current++,
112
- },
113
- ],
114
- id: nodeIdCounter.current++,
115
- },
116
- ],
117
- id: nodeIdCounter.current++,
118
- }
119
-
120
- return {
121
- type: EventType.FullSnapshot,
122
- data: {
123
- node: domNode,
124
- initialOffset: { left: 0, top: 0 },
125
- },
126
- timestamp: Date.now(),
127
- }
128
- }
129
-
130
- /**
131
- * Create an incremental snapshot event with mutation data to update image src
132
- * @param base64Image - New base64 encoded image data
133
- * @param imageNodeId - ID of the image node to update
134
- * @param captureFormat - Image format (png, jpg, etc.)
135
- * @returns Incremental snapshot event with mutation data
136
- */
137
- export function createIncrementalSnapshotWithImageUpdate(
138
- base64Image: string,
139
- captureFormat: string = 'jpg',
140
- ): eventWithTime {
141
- const mutationData: mutationData = {
142
- source: IncrementalSource.Mutation,
143
- texts: [],
144
- attributes: [
145
- {
146
- id: 0,
147
- attributes: {
148
- src: `data:image/${captureFormat};base64,${base64Image}`,
149
- },
150
- },
151
- ],
152
- removes: [],
153
- adds: [],
154
- }
155
-
156
- return {
157
- type: EventType.IncrementalSnapshot,
158
- data: mutationData,
159
- timestamp: Date.now(),
160
- }
161
- }
162
-
163
- /**
164
- * Create a simple image node for React Native screen capture
165
- * @param base64Image - Base64 encoded image data
166
- * @param width - Image width
167
- * @param height - Image height
168
- * @param captureFormat - Image format (png, jpg, etc.)
169
- * @param nodeId - Node ID for the image
170
- * @returns Serialized node with ID
171
- */
172
- export function createImageNode(
173
- base64Image: string,
174
- width: number,
175
- height: number,
176
- captureFormat: string = 'jpg',
177
- nodeId: number,
178
- ): serializedNodeWithId {
179
- return {
180
- type: NodeType.Element,
181
- id: nodeId,
182
- tagName: 'img',
183
- attributes: {
184
- src: `data:image/${captureFormat};base64,${base64Image}`,
185
- width: width.toString(),
186
- height: height.toString(),
187
- style: `width: ${width}px; height: ${height}px;`,
188
- },
189
- childNodes: [],
190
- }
191
- }
192
-
193
- /**
194
- * Create a document node for React Native screen capture
195
- * @param imageNode - The image node to include
196
- * @param width - Screen width
197
- * @param height - Screen height
198
- * @param nodeIdCounter - Node ID counter (will be modified)
199
- * @returns Document node
200
- */
201
- export function createDocumentNode(
202
- imageNode: serializedNodeWithId,
203
- width: number,
204
- height: number,
205
- nodeIdCounter: { current: number },
206
- ): serializedNodeWithId {
207
- // Create the root container
208
- const rootNode: serializedNodeWithId = {
209
- type: NodeType.Element,
210
- id: nodeIdCounter.current++,
211
- tagName: 'div',
212
- attributes: {
213
- style: `width: ${width}px; height: ${height}px; position: relative;`,
214
- },
215
- childNodes: [imageNode],
216
- }
217
-
218
- return {
219
- type: NodeType.Document,
220
- childNodes: [
221
- {
222
- type: NodeType.DocumentType,
223
- name: 'html',
224
- publicId: '',
225
- systemId: '',
226
- id: nodeIdCounter.current++,
227
- },
228
- {
229
- type: NodeType.Element,
230
- tagName: 'html',
231
- attributes: {},
232
- childNodes: [
233
- {
234
- type: NodeType.Element,
235
- tagName: 'head',
236
- attributes: {},
237
- childNodes: [
238
- {
239
- type: NodeType.Element,
240
- tagName: 'meta',
241
- attributes: { charset: 'utf-8' },
242
- childNodes: [],
243
- id: nodeIdCounter.current++,
244
- },
245
- {
246
- type: NodeType.Element,
247
- tagName: 'meta',
248
- attributes: {
249
- name: 'viewport',
250
- content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
251
- },
252
- childNodes: [],
253
- id: nodeIdCounter.current++,
254
- },
255
- ],
256
- id: nodeIdCounter.current++,
257
- },
258
- {
259
- type: NodeType.Element,
260
- tagName: 'body',
261
- attributes: {},
262
- childNodes: [rootNode],
263
- id: nodeIdCounter.current++,
264
- },
265
- ],
266
- id: nodeIdCounter.current++,
267
- },
268
- ],
269
- id: nodeIdCounter.current++,
270
- }
271
- }
272
-
273
- /**
274
- * Generate a simple hash for screen comparison
275
- * This is a lightweight hash that focuses on the beginning and end of the base64 string
276
- * to detect changes without doing a full comparison
277
- * @param base64Image - Base64 encoded image
278
- * @param sampleSize - Number of characters to sample from each part
279
- * @returns Hash string for comparison
280
- */
281
- export function generateScreenHash(base64Image: string, sampleSize: number = 100): string {
282
- // Use a simple hash that samples the beginning, middle, and end of the base64 string
283
- // This is much faster than comparing the entire string
284
- const start = base64Image.substring(0, sampleSize)
285
- const middle = base64Image.substring(
286
- Math.floor(base64Image.length / 2) - sampleSize / 2,
287
- Math.floor(base64Image.length / 2) + sampleSize / 2,
288
- )
289
- const end = base64Image.substring(base64Image.length - sampleSize)
290
-
291
- // Combine samples and create a simple hash
292
- const combined = start + middle + end
293
- return simpleHash(combined)
294
- }
295
-
296
- /**
297
- * Simple hash function for string comparison
298
- * @param str - String to hash
299
- * @returns Hash value as string
300
- */
301
- export function simpleHash(str: string): string {
302
- let hash = 0
303
- for (let i = 0; i < str.length; i++) {
304
- const char = str.charCodeAt(i)
305
- hash = (hash << 5) - hash + char
306
- hash = hash & hash // Convert to 32-bit integer
307
- }
308
- return Math.abs(hash).toString(36)
309
- }
@@ -1,18 +0,0 @@
1
- import { DEBUG_SESSION_MAX_DURATION_SECONDS } from '../config/constants'
2
-
3
- /**
4
- * Session-related utility functions for React Native
5
- */
6
-
7
- export const isSessionActive = (session: any, continuousRecording: boolean): boolean => {
8
- if (!session) return false
9
- if (continuousRecording) return true
10
- const startedAt = new Date(session.startedAt || session.createdAt)
11
- const now = new Date()
12
- const diff = now.getTime() - startedAt.getTime()
13
- return diff < DEBUG_SESSION_MAX_DURATION_SECONDS * 1000
14
- }
15
-
16
- export const isConsoleEvent = (event: any): boolean => {
17
- return event.type === 'Plugin' && event.data?.plugin === 'rrweb/console@1'
18
- }
package/src/utils/time.ts DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Time and date utility functions for React Native
3
- */
4
-
5
- export const getFormattedDate = (date: number | Date, options?: any): string => {
6
- return new Date(date).toLocaleDateString(
7
- 'en-US',
8
- options || {
9
- month: 'short',
10
- year: 'numeric',
11
- day: 'numeric',
12
- hour: 'numeric',
13
- minute: '2-digit',
14
- second: '2-digit',
15
- },
16
- )
17
- }
@@ -1,75 +0,0 @@
1
- const nativeIsArray = Array.isArray
2
- const ObjProto = Object.prototype
3
- export const hasOwnProperty = ObjProto.hasOwnProperty
4
- const toString = ObjProto.toString
5
-
6
- export const isArray =
7
- nativeIsArray ||
8
- function (obj: any): obj is any[] {
9
- return toString.call(obj) === '[object Array]'
10
- }
11
- export const isUint8Array = function (x: unknown): x is Uint8Array {
12
- return toString.call(x) === '[object Uint8Array]'
13
- }
14
- // from a comment on http://dbj.org/dbj/?p=286
15
- // fails on only one very rare and deliberate custom object:
16
- // let bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
17
- export const isFunction = function (f: any): f is (...args: any[]) => any {
18
- return typeof f === 'function'
19
- }
20
- // Underscore Addons
21
- export const isObject = function (x: unknown): x is Record<string, any> {
22
- return x === Object(x) && !isArray(x)
23
- }
24
- export const isEmptyObject = function (x: unknown): x is Record<string, any> {
25
- if (isObject(x)) {
26
- for (const key in x) {
27
- if (hasOwnProperty.call(x, key)) {
28
- return false
29
- }
30
- }
31
- return true
32
- }
33
- return false
34
- }
35
- export const isUndefined = function (x: unknown): x is undefined {
36
- return x === void 0
37
- }
38
-
39
- export const isString = function (x: unknown): x is string {
40
- return toString.call(x) == '[object String]'
41
- }
42
-
43
- export const isEmptyString = function (x: unknown): boolean {
44
- return isString(x) && x.trim().length === 0
45
- }
46
-
47
- export const isNull = function (x: unknown): x is null {
48
- return x === null
49
- }
50
-
51
- /*
52
- sometimes you want to check if something is null or undefined
53
- that's what this is for
54
- */
55
- export const isNullish = function (x: unknown): x is null | undefined {
56
- return isUndefined(x) || isNull(x)
57
- }
58
-
59
- export const isDate = function (x: unknown): x is Date {
60
- return toString.call(x) == '[object Date]'
61
- }
62
- export const isNumber = function (x: unknown): x is number {
63
- return toString.call(x) == '[object Number]'
64
- }
65
- export const isBoolean = function (x: unknown): x is boolean {
66
- return toString.call(x) === '[object Boolean]'
67
- }
68
-
69
- export const isFormData = (x: unknown): x is FormData => {
70
- return x instanceof FormData
71
- }
72
-
73
- export const isFile = (x: unknown): x is File => {
74
- return x instanceof File
75
- }
package/src/version.ts DELETED
@@ -1 +0,0 @@
1
- export const version = "0.0.1"
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDir": "./src",
4
- "declaration": true,
5
- "esModuleInterop": true,
6
- "jsx": "react-native",
7
- "incremental": false,
8
- "lib": ["ESNext"],
9
- "module": "ES2015",
10
- "moduleResolution": "bundler",
11
- "noEmitOnError": true,
12
- "outDir": "./dist",
13
- "skipLibCheck": true,
14
- "sourceMap": true,
15
- "strict": true,
16
- "target": "ES2018",
17
- "allowSyntheticDefaultImports": true,
18
- "resolveJsonModule": true,
19
- "isolatedModules": true
20
- },
21
- "include": ["src/**/*.ts", "src/**/*.tsx"],
22
- "exclude": ["node_modules", "dist", "examples"],
23
- "files": ["src/index.ts", "src/expo.ts"]
24
- }