@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.
- package/android/build.gradle.kts +135 -0
- package/android/consumer-rules.pro +10 -0
- package/android/proguard-rules.pro +1 -0
- package/android/src/main/AndroidManifest.xml +15 -0
- package/android/src/main/java/com/rejourney/RejourneyModuleImpl.kt +2981 -0
- package/android/src/main/java/com/rejourney/capture/ANRHandler.kt +206 -0
- package/android/src/main/java/com/rejourney/capture/ActivityTracker.kt +98 -0
- package/android/src/main/java/com/rejourney/capture/CaptureEngine.kt +1553 -0
- package/android/src/main/java/com/rejourney/capture/CaptureHeuristics.kt +375 -0
- package/android/src/main/java/com/rejourney/capture/CrashHandler.kt +153 -0
- package/android/src/main/java/com/rejourney/capture/MotionEvent.kt +215 -0
- package/android/src/main/java/com/rejourney/capture/SegmentUploader.kt +512 -0
- package/android/src/main/java/com/rejourney/capture/VideoEncoder.kt +773 -0
- package/android/src/main/java/com/rejourney/capture/ViewHierarchyScanner.kt +633 -0
- package/android/src/main/java/com/rejourney/capture/ViewSerializer.kt +286 -0
- package/android/src/main/java/com/rejourney/core/Constants.kt +117 -0
- package/android/src/main/java/com/rejourney/core/Logger.kt +93 -0
- package/android/src/main/java/com/rejourney/core/Types.kt +124 -0
- package/android/src/main/java/com/rejourney/lifecycle/SessionLifecycleService.kt +162 -0
- package/android/src/main/java/com/rejourney/network/DeviceAuthManager.kt +747 -0
- package/android/src/main/java/com/rejourney/network/HttpClientProvider.kt +16 -0
- package/android/src/main/java/com/rejourney/network/NetworkMonitor.kt +272 -0
- package/android/src/main/java/com/rejourney/network/UploadManager.kt +1363 -0
- package/android/src/main/java/com/rejourney/network/UploadWorker.kt +492 -0
- package/android/src/main/java/com/rejourney/privacy/PrivacyMask.kt +645 -0
- package/android/src/main/java/com/rejourney/touch/GestureClassifier.kt +233 -0
- package/android/src/main/java/com/rejourney/touch/KeyboardTracker.kt +158 -0
- package/android/src/main/java/com/rejourney/touch/TextInputTracker.kt +181 -0
- package/android/src/main/java/com/rejourney/touch/TouchInterceptor.kt +591 -0
- package/android/src/main/java/com/rejourney/utils/EventBuffer.kt +284 -0
- package/android/src/main/java/com/rejourney/utils/OEMDetector.kt +154 -0
- package/android/src/main/java/com/rejourney/utils/PerfTiming.kt +235 -0
- package/android/src/main/java/com/rejourney/utils/Telemetry.kt +297 -0
- package/android/src/main/java/com/rejourney/utils/WindowUtils.kt +84 -0
- package/android/src/newarch/java/com/rejourney/RejourneyModule.kt +187 -0
- package/android/src/newarch/java/com/rejourney/RejourneyPackage.kt +40 -0
- package/android/src/oldarch/java/com/rejourney/RejourneyModule.kt +218 -0
- package/android/src/oldarch/java/com/rejourney/RejourneyPackage.kt +23 -0
- package/ios/Capture/RJANRHandler.h +42 -0
- package/ios/Capture/RJANRHandler.m +328 -0
- package/ios/Capture/RJCaptureEngine.h +275 -0
- package/ios/Capture/RJCaptureEngine.m +2062 -0
- package/ios/Capture/RJCaptureHeuristics.h +80 -0
- package/ios/Capture/RJCaptureHeuristics.m +903 -0
- package/ios/Capture/RJCrashHandler.h +46 -0
- package/ios/Capture/RJCrashHandler.m +313 -0
- package/ios/Capture/RJMotionEvent.h +183 -0
- package/ios/Capture/RJMotionEvent.m +183 -0
- package/ios/Capture/RJPerformanceManager.h +100 -0
- package/ios/Capture/RJPerformanceManager.m +373 -0
- package/ios/Capture/RJPixelBufferDownscaler.h +42 -0
- package/ios/Capture/RJPixelBufferDownscaler.m +85 -0
- package/ios/Capture/RJSegmentUploader.h +146 -0
- package/ios/Capture/RJSegmentUploader.m +778 -0
- package/ios/Capture/RJVideoEncoder.h +247 -0
- package/ios/Capture/RJVideoEncoder.m +1036 -0
- package/ios/Capture/RJViewControllerTracker.h +73 -0
- package/ios/Capture/RJViewControllerTracker.m +508 -0
- package/ios/Capture/RJViewHierarchyScanner.h +215 -0
- package/ios/Capture/RJViewHierarchyScanner.m +1464 -0
- package/ios/Capture/RJViewSerializer.h +119 -0
- package/ios/Capture/RJViewSerializer.m +498 -0
- package/ios/Core/RJConstants.h +124 -0
- package/ios/Core/RJConstants.m +88 -0
- package/ios/Core/RJLifecycleManager.h +85 -0
- package/ios/Core/RJLifecycleManager.m +308 -0
- package/ios/Core/RJLogger.h +61 -0
- package/ios/Core/RJLogger.m +211 -0
- package/ios/Core/RJTypes.h +176 -0
- package/ios/Core/RJTypes.m +66 -0
- package/ios/Core/Rejourney.h +64 -0
- package/ios/Core/Rejourney.mm +2495 -0
- package/ios/Network/RJDeviceAuthManager.h +94 -0
- package/ios/Network/RJDeviceAuthManager.m +967 -0
- package/ios/Network/RJNetworkMonitor.h +68 -0
- package/ios/Network/RJNetworkMonitor.m +267 -0
- package/ios/Network/RJRetryManager.h +73 -0
- package/ios/Network/RJRetryManager.m +325 -0
- package/ios/Network/RJUploadManager.h +267 -0
- package/ios/Network/RJUploadManager.m +2296 -0
- package/ios/Privacy/RJPrivacyMask.h +163 -0
- package/ios/Privacy/RJPrivacyMask.m +922 -0
- package/ios/Rejourney.h +63 -0
- package/ios/Touch/RJGestureClassifier.h +130 -0
- package/ios/Touch/RJGestureClassifier.m +333 -0
- package/ios/Touch/RJTouchInterceptor.h +169 -0
- package/ios/Touch/RJTouchInterceptor.m +772 -0
- package/ios/Utils/RJEventBuffer.h +112 -0
- package/ios/Utils/RJEventBuffer.m +358 -0
- package/ios/Utils/RJGzipUtils.h +33 -0
- package/ios/Utils/RJGzipUtils.m +89 -0
- package/ios/Utils/RJKeychainManager.h +48 -0
- package/ios/Utils/RJKeychainManager.m +111 -0
- package/ios/Utils/RJPerfTiming.h +209 -0
- package/ios/Utils/RJPerfTiming.m +264 -0
- package/ios/Utils/RJTelemetry.h +92 -0
- package/ios/Utils/RJTelemetry.m +320 -0
- package/ios/Utils/RJWindowUtils.h +66 -0
- package/ios/Utils/RJWindowUtils.m +133 -0
- package/lib/commonjs/NativeRejourney.js +40 -0
- package/lib/commonjs/components/Mask.js +79 -0
- package/lib/commonjs/index.js +1381 -0
- package/lib/commonjs/sdk/autoTracking.js +1259 -0
- package/lib/commonjs/sdk/constants.js +151 -0
- package/lib/commonjs/sdk/errorTracking.js +199 -0
- package/lib/commonjs/sdk/index.js +50 -0
- package/lib/commonjs/sdk/metricsTracking.js +204 -0
- package/lib/commonjs/sdk/navigation.js +151 -0
- package/lib/commonjs/sdk/networkInterceptor.js +412 -0
- package/lib/commonjs/sdk/utils.js +363 -0
- package/lib/commonjs/types/expo-router.d.js +2 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/module/NativeRejourney.js +38 -0
- package/lib/module/components/Mask.js +72 -0
- package/lib/module/index.js +1284 -0
- package/lib/module/sdk/autoTracking.js +1233 -0
- package/lib/module/sdk/constants.js +145 -0
- package/lib/module/sdk/errorTracking.js +189 -0
- package/lib/module/sdk/index.js +12 -0
- package/lib/module/sdk/metricsTracking.js +187 -0
- package/lib/module/sdk/navigation.js +143 -0
- package/lib/module/sdk/networkInterceptor.js +401 -0
- package/lib/module/sdk/utils.js +342 -0
- package/lib/module/types/expo-router.d.js +2 -0
- package/lib/module/types/index.js +2 -0
- package/lib/typescript/NativeRejourney.d.ts +147 -0
- package/lib/typescript/components/Mask.d.ts +39 -0
- package/lib/typescript/index.d.ts +117 -0
- package/lib/typescript/sdk/autoTracking.d.ts +204 -0
- package/lib/typescript/sdk/constants.d.ts +120 -0
- package/lib/typescript/sdk/errorTracking.d.ts +32 -0
- package/lib/typescript/sdk/index.d.ts +9 -0
- package/lib/typescript/sdk/metricsTracking.d.ts +58 -0
- package/lib/typescript/sdk/navigation.d.ts +33 -0
- package/lib/typescript/sdk/networkInterceptor.d.ts +47 -0
- package/lib/typescript/sdk/utils.d.ts +148 -0
- package/lib/typescript/types/index.d.ts +624 -0
- package/package.json +102 -0
- package/rejourney.podspec +21 -0
- package/src/NativeRejourney.ts +165 -0
- package/src/components/Mask.tsx +80 -0
- package/src/index.ts +1459 -0
- package/src/sdk/autoTracking.ts +1373 -0
- package/src/sdk/constants.ts +134 -0
- package/src/sdk/errorTracking.ts +231 -0
- package/src/sdk/index.ts +11 -0
- package/src/sdk/metricsTracking.ts +232 -0
- package/src/sdk/navigation.ts +157 -0
- package/src/sdk/networkInterceptor.ts +440 -0
- package/src/sdk/utils.ts +369 -0
- package/src/types/expo-router.d.ts +7 -0
- package/src/types/index.ts +739 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RJVideoEncoder.h
|
|
3
|
+
// Rejourney
|
|
4
|
+
//
|
|
5
|
+
// H.264 video segment encoder using AVFoundation/VideoToolbox.
|
|
6
|
+
// Provides continuous 1 FPS video capture with predictable CPU usage.
|
|
7
|
+
//
|
|
8
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
// you may not use this file except in compliance with the License.
|
|
10
|
+
// You may obtain a copy of the License at
|
|
11
|
+
//
|
|
12
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
//
|
|
14
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
// See the License for the specific language governing permissions and
|
|
18
|
+
// limitations under the License.
|
|
19
|
+
//
|
|
20
|
+
// Copyright (c) 2026 Rejourney
|
|
21
|
+
//
|
|
22
|
+
|
|
23
|
+
#import <AVFoundation/AVFoundation.h>
|
|
24
|
+
#import <Foundation/Foundation.h>
|
|
25
|
+
#import <UIKit/UIKit.h>
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
#import <AVFoundation/AVFoundation.h>
|
|
29
|
+
#import <Foundation/Foundation.h>
|
|
30
|
+
#import <UIKit/UIKit.h>
|
|
31
|
+
|
|
32
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Delegate protocol for receiving completed video segment notifications.
|
|
36
|
+
*/
|
|
37
|
+
@protocol RJVideoEncoderDelegate <NSObject>
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Called when a video segment has been finalized and is ready for upload.
|
|
41
|
+
*
|
|
42
|
+
* @param segmentURL Local file URL of the completed .mp4 segment.
|
|
43
|
+
* @param sessionId Session ID for this segment.
|
|
44
|
+
* @param startTime Segment start time in epoch milliseconds.
|
|
45
|
+
* @param endTime Segment end time in epoch milliseconds.
|
|
46
|
+
* @param frameCount Number of frames encoded in this segment.
|
|
47
|
+
*/
|
|
48
|
+
- (void)videoEncoderDidFinishSegment:(NSURL *)segmentURL
|
|
49
|
+
sessionId:(NSString *)sessionId
|
|
50
|
+
startTime:(NSTimeInterval)startTime
|
|
51
|
+
endTime:(NSTimeInterval)endTime
|
|
52
|
+
frameCount:(NSInteger)frameCount;
|
|
53
|
+
|
|
54
|
+
@optional
|
|
55
|
+
/**
|
|
56
|
+
* Called when encoding fails.
|
|
57
|
+
*
|
|
58
|
+
* @param error The error that occurred during encoding.
|
|
59
|
+
*/
|
|
60
|
+
- (void)videoEncoderDidFailWithError:(NSError *)error;
|
|
61
|
+
|
|
62
|
+
@end
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* H.264 video segment encoder for session recording.
|
|
66
|
+
*
|
|
67
|
+
* Encodes UIImage frames into H.264 video segments using AVAssetWriter.
|
|
68
|
+
* Each segment is a self-contained .mp4 file that can be uploaded
|
|
69
|
+
* independently.
|
|
70
|
+
*
|
|
71
|
+
* ## Features
|
|
72
|
+
* - H.264 Baseline profile for maximum compatibility
|
|
73
|
+
* - Configurable bitrate (default 600 kbps for 1 FPS)
|
|
74
|
+
* - Automatic segment rotation after N frames
|
|
75
|
+
* - Thread-safe frame appending
|
|
76
|
+
*
|
|
77
|
+
* ## Usage
|
|
78
|
+
* ```objc
|
|
79
|
+
* RJVideoEncoder *encoder = [[RJVideoEncoder alloc] init];
|
|
80
|
+
* encoder.delegate = self;
|
|
81
|
+
* encoder.fps = 1;
|
|
82
|
+
* encoder.framesPerSegment = 60; // 60 second segments
|
|
83
|
+
*
|
|
84
|
+
* [encoder startSegmentWithSize:CGSizeMake(375, 812)];
|
|
85
|
+
* [encoder appendFrame:screenshotImage timestamp:currentTimeMs];
|
|
86
|
+
* // ... encoder auto-rotates segments
|
|
87
|
+
* [encoder finishSegment]; // On session end
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @note This class is designed to be used from the main thread.
|
|
91
|
+
*/
|
|
92
|
+
@interface RJVideoEncoder : NSObject
|
|
93
|
+
|
|
94
|
+
#pragma mark - Configuration
|
|
95
|
+
|
|
96
|
+
/// Delegate for receiving segment completion notifications.
|
|
97
|
+
@property(nonatomic, weak, nullable) id<RJVideoEncoderDelegate> delegate;
|
|
98
|
+
|
|
99
|
+
/// Target video bitrate in bits per second. Default: 600000 (600 kbps).
|
|
100
|
+
/// Lower values = smaller files but reduced quality.
|
|
101
|
+
@property(nonatomic, assign) NSInteger targetBitrate;
|
|
102
|
+
|
|
103
|
+
/// Number of frames per segment before auto-rotation. Default: 60.
|
|
104
|
+
/// At 1 FPS, this equals 60 second segments.
|
|
105
|
+
@property(nonatomic, assign) NSInteger framesPerSegment;
|
|
106
|
+
|
|
107
|
+
/// Target frames per second for video timing. Default: 1.
|
|
108
|
+
@property(nonatomic, assign) NSInteger fps;
|
|
109
|
+
|
|
110
|
+
/// Capture scale factor as a fraction of device screen scale (0.0-1.0).
|
|
111
|
+
/// Default: 0.35. Example: on a 3x device, 0.35 -> ~1.0 px/pt. Lower values
|
|
112
|
+
/// reduce file size and CPU but also quality.
|
|
113
|
+
@property(nonatomic, assign) CGFloat captureScale;
|
|
114
|
+
|
|
115
|
+
#pragma mark - State
|
|
116
|
+
|
|
117
|
+
/// Whether the encoder is currently recording a segment.
|
|
118
|
+
@property(nonatomic, readonly) BOOL isRecording;
|
|
119
|
+
|
|
120
|
+
/// Current segment's frame count.
|
|
121
|
+
@property(nonatomic, readonly) NSInteger currentFrameCount;
|
|
122
|
+
|
|
123
|
+
/// Current session ID being recorded.
|
|
124
|
+
@property(nonatomic, copy, readonly, nullable) NSString *sessionId;
|
|
125
|
+
|
|
126
|
+
#pragma mark - Lifecycle
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Sets the session ID for the current recording session.
|
|
130
|
+
* Should be called before starting segments.
|
|
131
|
+
*
|
|
132
|
+
* @param sessionId The unique session identifier.
|
|
133
|
+
*/
|
|
134
|
+
- (void)setSessionId:(NSString *)sessionId;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Starts a new video segment with the specified frame size.
|
|
138
|
+
* If a segment is already in progress, it will be finished first.
|
|
139
|
+
*
|
|
140
|
+
* @param size The frame size in points (converted to pixels using device scale,
|
|
141
|
+
* then multiplied by captureScale).
|
|
142
|
+
* @return YES if segment started successfully, NO otherwise.
|
|
143
|
+
*/
|
|
144
|
+
- (BOOL)startSegmentWithSize:(CGSize)size;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Appends a frame to the current video segment.
|
|
148
|
+
* If the segment reaches framesPerSegment, it auto-rotates to a new segment.
|
|
149
|
+
*
|
|
150
|
+
* @param frame The UIImage screenshot to encode.
|
|
151
|
+
* @param timestamp The capture timestamp in epoch milliseconds.
|
|
152
|
+
* @return YES if frame was appended successfully, NO otherwise.
|
|
153
|
+
*/
|
|
154
|
+
- (BOOL)appendFrame:(UIImage *)frame timestamp:(NSTimeInterval)timestamp;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Appends a CVPixelBuffer directly to the current video segment.
|
|
158
|
+
* Best performance: avoids internal buffer creation and copying.
|
|
159
|
+
*
|
|
160
|
+
* @param pixelBuffer The CVPixelBufferRef containing the frame
|
|
161
|
+
* (kCVPixelFormatType_32BGRA)
|
|
162
|
+
* @param timestamp The capture timestamp in epoch milliseconds.
|
|
163
|
+
* @return YES if frame was appended successfully, NO otherwise.
|
|
164
|
+
*/
|
|
165
|
+
- (BOOL)appendPixelBuffer:(CVPixelBufferRef)pixelBuffer
|
|
166
|
+
timestamp:(NSTimeInterval)timestamp;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Finishes the current segment and notifies the delegate.
|
|
170
|
+
* Call this when the session ends or app backgrounds.
|
|
171
|
+
*/
|
|
172
|
+
- (void)finishSegment;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Finishes the current segment SYNCHRONOUSLY.
|
|
176
|
+
* Use during app termination/background when async completion may not fire.
|
|
177
|
+
* Blocks until segment is written and delegate is called.
|
|
178
|
+
* Has a 5 second timeout to prevent app freeze.
|
|
179
|
+
*/
|
|
180
|
+
- (void)finishSegmentSync;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Cancels the current segment without saving.
|
|
184
|
+
* Use when the session is aborted.
|
|
185
|
+
*/
|
|
186
|
+
- (void)cancelSegment;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Cleans up encoder resources and pending segments.
|
|
190
|
+
* Call when the capture engine is destroyed.
|
|
191
|
+
*/
|
|
192
|
+
- (void)cleanup;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Emergency synchronous flush for crash handling.
|
|
196
|
+
*
|
|
197
|
+
* When a crash occurs, this method attempts to synchronously finalize
|
|
198
|
+
* the current video segment so it can be recovered on next launch.
|
|
199
|
+
*
|
|
200
|
+
* This is a best-effort operation that:
|
|
201
|
+
* 1. Marks the video input as finished
|
|
202
|
+
* 2. Attempts to finalize the asset writer with a short timeout
|
|
203
|
+
* 3. Saves segment metadata to disk for recovery
|
|
204
|
+
*
|
|
205
|
+
* @warning This method should ONLY be called from a crash handler.
|
|
206
|
+
* It may block for a short time and is not suitable for normal use.
|
|
207
|
+
*
|
|
208
|
+
* @return YES if segment was successfully finalized, NO otherwise.
|
|
209
|
+
*/
|
|
210
|
+
- (BOOL)emergencyFlushSync;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Checks if there is a pending video segment from a crash.
|
|
214
|
+
* Call this on app launch to recover any incomplete segments.
|
|
215
|
+
*
|
|
216
|
+
* @return Segment metadata dictionary if a pending segment exists, nil
|
|
217
|
+
* otherwise.
|
|
218
|
+
*/
|
|
219
|
+
+ (nullable NSDictionary *)pendingCrashSegmentMetadata;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Clears the pending crash segment metadata after recovery.
|
|
223
|
+
*/
|
|
224
|
+
+ (void)clearPendingCrashSegmentMetadata;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Pre-warms the H.264 encoder asynchronously to reduce first-frame latency.
|
|
228
|
+
*
|
|
229
|
+
* This method initializes the VideoToolbox hardware encoder by encoding a
|
|
230
|
+
* minimal dummy frame. Call this early (e.g., during CaptureEngine init)
|
|
231
|
+
* to front-load the ~50-100ms encoder initialization overhead.
|
|
232
|
+
*
|
|
233
|
+
* @note Safe to call multiple times - subsequent calls are no-ops.
|
|
234
|
+
* @note Runs on a background queue and returns immediately.
|
|
235
|
+
*/
|
|
236
|
+
- (void)prewarmEncoderAsync;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Prepares the encoder with the expected frame size.
|
|
240
|
+
* Creates the AVAssetWriter and inputs ahead of time to avoid first-frame
|
|
241
|
+
* latency.
|
|
242
|
+
*/
|
|
243
|
+
- (void)prepareEncoderWithSize:(CGSize)size;
|
|
244
|
+
|
|
245
|
+
@end
|
|
246
|
+
|
|
247
|
+
NS_ASSUME_NONNULL_END
|