@rejourneyco/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 (152) hide show
  1. package/android/build.gradle.kts +135 -0
  2. package/android/consumer-rules.pro +10 -0
  3. package/android/proguard-rules.pro +1 -0
  4. package/android/src/main/AndroidManifest.xml +15 -0
  5. package/android/src/main/java/com/rejourney/RejourneyModuleImpl.kt +2981 -0
  6. package/android/src/main/java/com/rejourney/capture/ANRHandler.kt +206 -0
  7. package/android/src/main/java/com/rejourney/capture/ActivityTracker.kt +98 -0
  8. package/android/src/main/java/com/rejourney/capture/CaptureEngine.kt +1553 -0
  9. package/android/src/main/java/com/rejourney/capture/CaptureHeuristics.kt +375 -0
  10. package/android/src/main/java/com/rejourney/capture/CrashHandler.kt +153 -0
  11. package/android/src/main/java/com/rejourney/capture/MotionEvent.kt +215 -0
  12. package/android/src/main/java/com/rejourney/capture/SegmentUploader.kt +512 -0
  13. package/android/src/main/java/com/rejourney/capture/VideoEncoder.kt +773 -0
  14. package/android/src/main/java/com/rejourney/capture/ViewHierarchyScanner.kt +633 -0
  15. package/android/src/main/java/com/rejourney/capture/ViewSerializer.kt +286 -0
  16. package/android/src/main/java/com/rejourney/core/Constants.kt +117 -0
  17. package/android/src/main/java/com/rejourney/core/Logger.kt +93 -0
  18. package/android/src/main/java/com/rejourney/core/Types.kt +124 -0
  19. package/android/src/main/java/com/rejourney/lifecycle/SessionLifecycleService.kt +162 -0
  20. package/android/src/main/java/com/rejourney/network/DeviceAuthManager.kt +747 -0
  21. package/android/src/main/java/com/rejourney/network/HttpClientProvider.kt +16 -0
  22. package/android/src/main/java/com/rejourney/network/NetworkMonitor.kt +272 -0
  23. package/android/src/main/java/com/rejourney/network/UploadManager.kt +1363 -0
  24. package/android/src/main/java/com/rejourney/network/UploadWorker.kt +492 -0
  25. package/android/src/main/java/com/rejourney/privacy/PrivacyMask.kt +645 -0
  26. package/android/src/main/java/com/rejourney/touch/GestureClassifier.kt +233 -0
  27. package/android/src/main/java/com/rejourney/touch/KeyboardTracker.kt +158 -0
  28. package/android/src/main/java/com/rejourney/touch/TextInputTracker.kt +181 -0
  29. package/android/src/main/java/com/rejourney/touch/TouchInterceptor.kt +591 -0
  30. package/android/src/main/java/com/rejourney/utils/EventBuffer.kt +284 -0
  31. package/android/src/main/java/com/rejourney/utils/OEMDetector.kt +154 -0
  32. package/android/src/main/java/com/rejourney/utils/PerfTiming.kt +235 -0
  33. package/android/src/main/java/com/rejourney/utils/Telemetry.kt +297 -0
  34. package/android/src/main/java/com/rejourney/utils/WindowUtils.kt +84 -0
  35. package/android/src/newarch/java/com/rejourney/RejourneyModule.kt +187 -0
  36. package/android/src/newarch/java/com/rejourney/RejourneyPackage.kt +40 -0
  37. package/android/src/oldarch/java/com/rejourney/RejourneyModule.kt +218 -0
  38. package/android/src/oldarch/java/com/rejourney/RejourneyPackage.kt +23 -0
  39. package/ios/Capture/RJANRHandler.h +42 -0
  40. package/ios/Capture/RJANRHandler.m +328 -0
  41. package/ios/Capture/RJCaptureEngine.h +275 -0
  42. package/ios/Capture/RJCaptureEngine.m +2062 -0
  43. package/ios/Capture/RJCaptureHeuristics.h +80 -0
  44. package/ios/Capture/RJCaptureHeuristics.m +903 -0
  45. package/ios/Capture/RJCrashHandler.h +46 -0
  46. package/ios/Capture/RJCrashHandler.m +313 -0
  47. package/ios/Capture/RJMotionEvent.h +183 -0
  48. package/ios/Capture/RJMotionEvent.m +183 -0
  49. package/ios/Capture/RJPerformanceManager.h +100 -0
  50. package/ios/Capture/RJPerformanceManager.m +373 -0
  51. package/ios/Capture/RJPixelBufferDownscaler.h +42 -0
  52. package/ios/Capture/RJPixelBufferDownscaler.m +85 -0
  53. package/ios/Capture/RJSegmentUploader.h +146 -0
  54. package/ios/Capture/RJSegmentUploader.m +778 -0
  55. package/ios/Capture/RJVideoEncoder.h +247 -0
  56. package/ios/Capture/RJVideoEncoder.m +1036 -0
  57. package/ios/Capture/RJViewControllerTracker.h +73 -0
  58. package/ios/Capture/RJViewControllerTracker.m +508 -0
  59. package/ios/Capture/RJViewHierarchyScanner.h +215 -0
  60. package/ios/Capture/RJViewHierarchyScanner.m +1464 -0
  61. package/ios/Capture/RJViewSerializer.h +119 -0
  62. package/ios/Capture/RJViewSerializer.m +498 -0
  63. package/ios/Core/RJConstants.h +124 -0
  64. package/ios/Core/RJConstants.m +88 -0
  65. package/ios/Core/RJLifecycleManager.h +85 -0
  66. package/ios/Core/RJLifecycleManager.m +308 -0
  67. package/ios/Core/RJLogger.h +61 -0
  68. package/ios/Core/RJLogger.m +211 -0
  69. package/ios/Core/RJTypes.h +176 -0
  70. package/ios/Core/RJTypes.m +66 -0
  71. package/ios/Core/Rejourney.h +64 -0
  72. package/ios/Core/Rejourney.mm +2495 -0
  73. package/ios/Network/RJDeviceAuthManager.h +94 -0
  74. package/ios/Network/RJDeviceAuthManager.m +967 -0
  75. package/ios/Network/RJNetworkMonitor.h +68 -0
  76. package/ios/Network/RJNetworkMonitor.m +267 -0
  77. package/ios/Network/RJRetryManager.h +73 -0
  78. package/ios/Network/RJRetryManager.m +325 -0
  79. package/ios/Network/RJUploadManager.h +267 -0
  80. package/ios/Network/RJUploadManager.m +2296 -0
  81. package/ios/Privacy/RJPrivacyMask.h +163 -0
  82. package/ios/Privacy/RJPrivacyMask.m +922 -0
  83. package/ios/Rejourney.h +63 -0
  84. package/ios/Touch/RJGestureClassifier.h +130 -0
  85. package/ios/Touch/RJGestureClassifier.m +333 -0
  86. package/ios/Touch/RJTouchInterceptor.h +169 -0
  87. package/ios/Touch/RJTouchInterceptor.m +772 -0
  88. package/ios/Utils/RJEventBuffer.h +112 -0
  89. package/ios/Utils/RJEventBuffer.m +358 -0
  90. package/ios/Utils/RJGzipUtils.h +33 -0
  91. package/ios/Utils/RJGzipUtils.m +89 -0
  92. package/ios/Utils/RJKeychainManager.h +48 -0
  93. package/ios/Utils/RJKeychainManager.m +111 -0
  94. package/ios/Utils/RJPerfTiming.h +209 -0
  95. package/ios/Utils/RJPerfTiming.m +264 -0
  96. package/ios/Utils/RJTelemetry.h +92 -0
  97. package/ios/Utils/RJTelemetry.m +320 -0
  98. package/ios/Utils/RJWindowUtils.h +66 -0
  99. package/ios/Utils/RJWindowUtils.m +133 -0
  100. package/lib/commonjs/NativeRejourney.js +40 -0
  101. package/lib/commonjs/components/Mask.js +79 -0
  102. package/lib/commonjs/index.js +1381 -0
  103. package/lib/commonjs/sdk/autoTracking.js +1259 -0
  104. package/lib/commonjs/sdk/constants.js +151 -0
  105. package/lib/commonjs/sdk/errorTracking.js +199 -0
  106. package/lib/commonjs/sdk/index.js +50 -0
  107. package/lib/commonjs/sdk/metricsTracking.js +204 -0
  108. package/lib/commonjs/sdk/navigation.js +151 -0
  109. package/lib/commonjs/sdk/networkInterceptor.js +412 -0
  110. package/lib/commonjs/sdk/utils.js +363 -0
  111. package/lib/commonjs/types/expo-router.d.js +2 -0
  112. package/lib/commonjs/types/index.js +2 -0
  113. package/lib/module/NativeRejourney.js +38 -0
  114. package/lib/module/components/Mask.js +72 -0
  115. package/lib/module/index.js +1284 -0
  116. package/lib/module/sdk/autoTracking.js +1233 -0
  117. package/lib/module/sdk/constants.js +145 -0
  118. package/lib/module/sdk/errorTracking.js +189 -0
  119. package/lib/module/sdk/index.js +12 -0
  120. package/lib/module/sdk/metricsTracking.js +187 -0
  121. package/lib/module/sdk/navigation.js +143 -0
  122. package/lib/module/sdk/networkInterceptor.js +401 -0
  123. package/lib/module/sdk/utils.js +342 -0
  124. package/lib/module/types/expo-router.d.js +2 -0
  125. package/lib/module/types/index.js +2 -0
  126. package/lib/typescript/NativeRejourney.d.ts +147 -0
  127. package/lib/typescript/components/Mask.d.ts +39 -0
  128. package/lib/typescript/index.d.ts +117 -0
  129. package/lib/typescript/sdk/autoTracking.d.ts +204 -0
  130. package/lib/typescript/sdk/constants.d.ts +120 -0
  131. package/lib/typescript/sdk/errorTracking.d.ts +32 -0
  132. package/lib/typescript/sdk/index.d.ts +9 -0
  133. package/lib/typescript/sdk/metricsTracking.d.ts +58 -0
  134. package/lib/typescript/sdk/navigation.d.ts +33 -0
  135. package/lib/typescript/sdk/networkInterceptor.d.ts +47 -0
  136. package/lib/typescript/sdk/utils.d.ts +148 -0
  137. package/lib/typescript/types/index.d.ts +624 -0
  138. package/package.json +102 -0
  139. package/rejourney.podspec +21 -0
  140. package/src/NativeRejourney.ts +165 -0
  141. package/src/components/Mask.tsx +80 -0
  142. package/src/index.ts +1459 -0
  143. package/src/sdk/autoTracking.ts +1373 -0
  144. package/src/sdk/constants.ts +134 -0
  145. package/src/sdk/errorTracking.ts +231 -0
  146. package/src/sdk/index.ts +11 -0
  147. package/src/sdk/metricsTracking.ts +232 -0
  148. package/src/sdk/navigation.ts +157 -0
  149. package/src/sdk/networkInterceptor.ts +440 -0
  150. package/src/sdk/utils.ts +369 -0
  151. package/src/types/expo-router.d.ts +7 -0
  152. package/src/types/index.ts +739 -0
@@ -0,0 +1,215 @@
1
+ //
2
+ // RJViewHierarchyScanner.h
3
+ // Rejourney
4
+ //
5
+ // Unified view hierarchy scanner that combines layout signature generation
6
+ // and privacy rect detection into a single traversal pass for optimal
7
+ // performance.
8
+ //
9
+ // Licensed under the Apache License, Version 2.0 (the "License").
10
+ // Copyright (c) 2026 Rejourney
11
+ //
12
+
13
+ #import <Foundation/Foundation.h>
14
+ #import <UIKit/UIKit.h>
15
+
16
+ NS_ASSUME_NONNULL_BEGIN
17
+
18
+ #pragma mark - Scan Result
19
+
20
+ /**
21
+ * Result of a unified view hierarchy scan.
22
+ * Contains all data collected in a single traversal pass.
23
+ */
24
+ @interface RJViewHierarchyScanResult : NSObject
25
+
26
+ /// Layout signature hash (MD5) for change detection
27
+ @property(nonatomic, copy, nullable) NSString *layoutSignature;
28
+
29
+ /// Frames of text input views in window coordinates
30
+ @property(nonatomic, strong) NSArray<NSValue *> *textInputFrames;
31
+
32
+ /// Frames of camera preview views in window coordinates
33
+ @property(nonatomic, strong) NSArray<NSValue *> *cameraFrames;
34
+
35
+ /// Frames of video layer views in window coordinates
36
+ @property(nonatomic, strong) NSArray<NSValue *> *videoFrames;
37
+
38
+ /// Whether any text inputs were found
39
+ @property(nonatomic, readonly) BOOL hasTextInputs;
40
+
41
+ /// Whether any camera views were found
42
+ @property(nonatomic, readonly) BOOL hasCameraViews;
43
+
44
+ /// Whether a MapView (MKMapView or react-native-maps) was found
45
+ /// When true, frame caching should be disabled since map tiles load async
46
+ @property(nonatomic, assign) BOOL hasMapView;
47
+
48
+ /// Frames of MapView instances in window coordinates (for hybrid capture)
49
+ /// These views need special handling with drawViewHierarchyInRect
50
+ @property(nonatomic, strong) NSArray<NSValue *> *mapViewFrames;
51
+
52
+ /// Pointers to MapView instances for direct snapshot capture
53
+ /// Stored as NSValue wrapping UIView pointers
54
+ @property(nonatomic, strong) NSArray<NSValue *> *mapViewPointers;
55
+
56
+ /// Total number of views scanned
57
+ @property(nonatomic, assign) NSUInteger totalViewsScanned;
58
+
59
+ /// Timestamp of when scan was performed
60
+ @property(nonatomic, assign) NSTimeInterval scanTimestamp;
61
+
62
+ /// Frames of WebView instances in window coordinates
63
+ @property(nonatomic, strong) NSArray<NSValue *> *webViewFrames;
64
+
65
+ /// Whether any WebView instances were found
66
+ @property(nonatomic, readonly) BOOL hasWebViews;
67
+
68
+ /// Whether scroll or deceleration motion is active
69
+ @property(nonatomic, assign) BOOL scrollActive;
70
+
71
+ /// Whether rubber-band bounce or inset settling is active
72
+ @property(nonatomic, assign) BOOL bounceActive;
73
+
74
+ /// Whether pull-to-refresh is active or settling
75
+ @property(nonatomic, assign) BOOL refreshActive;
76
+
77
+ /// Whether map camera/region motion is active
78
+ @property(nonatomic, assign) BOOL mapActive;
79
+
80
+ /// Whether any CA animations were detected in the hierarchy
81
+ @property(nonatomic, assign) BOOL hasAnyAnimations;
82
+
83
+ /// Approximate animated area ratio (0..1) relative to the screen
84
+ @property(nonatomic, assign) CGFloat animationAreaRatio;
85
+
86
+ /// Scroll view pointers (non-retained) for stability probes
87
+ @property(nonatomic, strong) NSArray<NSValue *> *scrollViewPointers;
88
+
89
+ /// Animated view pointers (non-retained) for stability probes
90
+ @property(nonatomic, strong) NSArray<NSValue *> *animatedViewPointers;
91
+
92
+ /// Whether the scan bailed out early (depth/view/time limits)
93
+ @property(nonatomic, assign) BOOL didBailOutEarly;
94
+
95
+ @end
96
+
97
+ #pragma mark - Scanner Configuration
98
+
99
+ /**
100
+ * Configuration options for the view hierarchy scanner.
101
+ */
102
+ @interface RJViewHierarchyScannerConfig : NSObject
103
+
104
+ /// Whether to detect text input views. Default: YES
105
+ @property(nonatomic, assign) BOOL detectTextInputs;
106
+
107
+ /// Whether to detect camera preview views. Default: YES
108
+ @property(nonatomic, assign) BOOL detectCameraViews;
109
+
110
+ /// Whether to detect WebView instances. Default: YES
111
+ @property(nonatomic, assign) BOOL detectWebViews;
112
+
113
+ /// Whether to detect video layer views. Default: YES
114
+ @property(nonatomic, assign) BOOL detectVideoLayers;
115
+
116
+ /// Set of nativeIDs to manually mask
117
+ @property(nonatomic, strong) NSSet<NSString *> *maskedNativeIDs;
118
+
119
+ /// Maximum traversal depth. Default: 15
120
+ @property(nonatomic, assign) NSInteger maxDepth;
121
+
122
+ /// Maximum number of views to scan before stopping. Default: 500
123
+ /// Prevents runaway scans on extremely complex view hierarchies.
124
+ @property(nonatomic, assign) NSUInteger maxViewCount;
125
+
126
+ /// Default configuration instance
127
+ + (instancetype)defaultConfig;
128
+
129
+ @end
130
+
131
+ #pragma mark - Scanner
132
+
133
+ /**
134
+ * Unified view hierarchy scanner that performs a single traversal to collect:
135
+ * - Layout signature data for change detection
136
+ * - Privacy-sensitive view locations (text inputs, cameras)
137
+ *
138
+ * This optimization reduces main thread blocking by 20-50% compared to
139
+ * performing separate traversals for layout and privacy scanning.
140
+ *
141
+ * @note This class is not thread-safe. Call from the main thread only.
142
+ */
143
+ @interface RJViewHierarchyScanner : NSObject
144
+
145
+ /// Scanner configuration
146
+ @property(nonatomic, strong) RJViewHierarchyScannerConfig *config;
147
+
148
+ /// Initialize with default configuration
149
+ - (instancetype)init;
150
+
151
+ /// Initialize with custom configuration
152
+ - (instancetype)initWithConfig:(RJViewHierarchyScannerConfig *)config;
153
+
154
+ /**
155
+ * Performs a unified scan of the window's view hierarchy.
156
+ *
157
+ * This single traversal collects:
158
+ * - Layout signature for change detection
159
+ * - Text input view frames for privacy masking
160
+ * - Camera preview frames for privacy masking
161
+ *
162
+ * @param window The window to scan.
163
+ * @return Scan result containing all collected data, or nil on failure.
164
+ */
165
+ - (nullable RJViewHierarchyScanResult *)scanWindow:(UIWindow *)window;
166
+
167
+ /**
168
+ * Scans ALL visible windows in the app for sensitive views.
169
+ *
170
+ * This is critical for proper privacy masking when text inputs appear
171
+ * in modal windows, overlay windows, or React Native navigation modals
172
+ * which create separate UIWindow instances.
173
+ *
174
+ * Frames are converted to the primary capture window's coordinate space.
175
+ *
176
+ * @param primaryWindow The primary window being captured (for coordinate
177
+ * conversion).
178
+ * @return Scan result with frames from ALL windows, converted to primaryWindow
179
+ * coordinates.
180
+ */
181
+ - (nullable RJViewHierarchyScanResult *)scanAllWindowsRelativeTo:
182
+ (UIWindow *)primaryWindow;
183
+
184
+ /**
185
+ * Scans a specific list of windows relative to a primary window.
186
+ * Use this when the caller maintains a cached list of windows to improved
187
+ * performance.
188
+ */
189
+ - (nullable RJViewHierarchyScanResult *)scanWindows:
190
+ (NSArray<UIWindow *> *)windows
191
+ relativeToWindow:(UIWindow *)primaryWindow;
192
+
193
+ /**
194
+ * Check if a view is visible (optimization for early skip).
195
+ *
196
+ * @param view The view to check.
197
+ * @return YES if view is visible and should be scanned.
198
+ */
199
+ - (BOOL)isViewVisible:(UIView *)view;
200
+
201
+ /**
202
+ * Pre-warm internal class caches to eliminate cold-cache penalties on first
203
+ * scan.
204
+ *
205
+ * Call this during app initialization or before first recording session
206
+ * to front-load the ~10-15ms of class lookup overhead that would otherwise
207
+ * occur on the first frame capture.
208
+ *
209
+ * @note Safe to call multiple times - subsequent calls are no-ops.
210
+ */
211
+ - (void)prewarmClassCaches;
212
+
213
+ @end
214
+
215
+ NS_ASSUME_NONNULL_END