react-native-frame-capture 1.0.1
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/FrameCapture.podspec +21 -0
- package/LICENSE +20 -0
- package/README.md +158 -0
- package/android/build.gradle +77 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +20 -0
- package/android/src/main/java/com/framecapture/CaptureManager.kt +831 -0
- package/android/src/main/java/com/framecapture/Constants.kt +196 -0
- package/android/src/main/java/com/framecapture/ErrorHandler.kt +165 -0
- package/android/src/main/java/com/framecapture/FrameCaptureModule.kt +653 -0
- package/android/src/main/java/com/framecapture/FrameCapturePackage.kt +32 -0
- package/android/src/main/java/com/framecapture/OverlayRenderer.kt +423 -0
- package/android/src/main/java/com/framecapture/PermissionHandler.kt +150 -0
- package/android/src/main/java/com/framecapture/ScreenCaptureService.kt +366 -0
- package/android/src/main/java/com/framecapture/StorageManager.kt +221 -0
- package/android/src/main/java/com/framecapture/capture/BitmapProcessor.kt +157 -0
- package/android/src/main/java/com/framecapture/capture/CaptureEventEmitter.kt +120 -0
- package/android/src/main/java/com/framecapture/models/CaptureModels.kt +302 -0
- package/android/src/main/java/com/framecapture/models/EnumsAndExtensions.kt +60 -0
- package/android/src/main/java/com/framecapture/models/OverlayModels.kt +154 -0
- package/android/src/main/java/com/framecapture/service/CaptureNotificationManager.kt +286 -0
- package/android/src/main/java/com/framecapture/storage/StorageStrategies.kt +317 -0
- package/android/src/main/java/com/framecapture/utils/ValidationUtils.kt +379 -0
- package/app.plugin.js +1 -0
- package/ios/FrameCapture.h +5 -0
- package/ios/FrameCapture.mm +21 -0
- package/lib/module/NativeFrameCapture.js +24 -0
- package/lib/module/NativeFrameCapture.js.map +1 -0
- package/lib/module/api.js +146 -0
- package/lib/module/api.js.map +1 -0
- package/lib/module/constants.js +67 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/errors.js +19 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/events.js +58 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/index.js +24 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/normalize.js +51 -0
- package/lib/module/normalize.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +165 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/validation.js +190 -0
- package/lib/module/validation.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/plugin/src/index.d.ts +4 -0
- package/lib/typescript/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/src/NativeFrameCapture.d.ts +75 -0
- package/lib/typescript/src/NativeFrameCapture.d.ts.map +1 -0
- package/lib/typescript/src/api.d.ts +66 -0
- package/lib/typescript/src/api.d.ts.map +1 -0
- package/lib/typescript/src/constants.d.ts +41 -0
- package/lib/typescript/src/constants.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +14 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +30 -0
- package/lib/typescript/src/events.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +12 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/normalize.d.ts +43 -0
- package/lib/typescript/src/normalize.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +247 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/validation.d.ts +15 -0
- package/lib/typescript/src/validation.d.ts.map +1 -0
- package/package.json +196 -0
- package/plugin/build/index.js +48 -0
- package/src/NativeFrameCapture.ts +86 -0
- package/src/api.ts +189 -0
- package/src/constants.ts +69 -0
- package/src/errors.ts +21 -0
- package/src/events.ts +61 -0
- package/src/index.tsx +31 -0
- package/src/normalize.ts +81 -0
- package/src/types.ts +327 -0
- package/src/validation.ts +321 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for React Native Frame Capture
|
|
3
|
+
* @module types
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Capture state values
|
|
7
|
+
*/
|
|
8
|
+
export declare enum CaptureState {
|
|
9
|
+
IDLE = "idle",
|
|
10
|
+
CAPTURING = "capturing",
|
|
11
|
+
PAUSED = "paused",
|
|
12
|
+
STOPPING = "stopping"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Permission status values
|
|
16
|
+
*/
|
|
17
|
+
export declare enum PermissionStatus {
|
|
18
|
+
GRANTED = "granted",
|
|
19
|
+
DENIED = "denied",
|
|
20
|
+
NOT_DETERMINED = "not_determined"
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Error codes for capture operations
|
|
24
|
+
*/
|
|
25
|
+
export declare enum CaptureErrorCode {
|
|
26
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
27
|
+
ALREADY_CAPTURING = "ALREADY_CAPTURING",
|
|
28
|
+
INVALID_OPTIONS = "INVALID_OPTIONS",
|
|
29
|
+
STORAGE_ERROR = "STORAGE_ERROR",
|
|
30
|
+
SYSTEM_ERROR = "SYSTEM_ERROR",
|
|
31
|
+
NOT_SUPPORTED = "NOT_SUPPORTED"
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Event types emitted by the capture system
|
|
35
|
+
*/
|
|
36
|
+
export declare enum CaptureEventType {
|
|
37
|
+
FRAME_CAPTURED = "onFrameCaptured",
|
|
38
|
+
CAPTURE_ERROR = "onCaptureError",
|
|
39
|
+
CAPTURE_STOP = "onCaptureStop",
|
|
40
|
+
CAPTURE_START = "onCaptureStart",
|
|
41
|
+
STORAGE_WARNING = "onStorageWarning",
|
|
42
|
+
CAPTURE_PAUSE = "onCapturePause",
|
|
43
|
+
CAPTURE_RESUME = "onCaptureResume",
|
|
44
|
+
OVERLAY_ERROR = "onOverlayError"
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Unit type for capture region coordinates
|
|
48
|
+
*/
|
|
49
|
+
export type CaptureRegionUnit = 'pixels' | 'percentage';
|
|
50
|
+
/**
|
|
51
|
+
* Position preset for overlay placement
|
|
52
|
+
*/
|
|
53
|
+
export type PositionPreset = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
|
|
54
|
+
/**
|
|
55
|
+
* Custom capture region specification
|
|
56
|
+
*/
|
|
57
|
+
export interface CaptureRegion {
|
|
58
|
+
/** Left position (pixels or 0-1 for percentage) */
|
|
59
|
+
x: number;
|
|
60
|
+
/** Top position (pixels or 0-1 for percentage) */
|
|
61
|
+
y: number;
|
|
62
|
+
/** Width (pixels or 0-1 for percentage) */
|
|
63
|
+
width: number;
|
|
64
|
+
/** Height (pixels or 0-1 for percentage) */
|
|
65
|
+
height: number;
|
|
66
|
+
/** Unit type for coordinates (default: 'percentage') */
|
|
67
|
+
unit?: CaptureRegionUnit;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* File naming configuration
|
|
71
|
+
*/
|
|
72
|
+
export interface FileNamingConfig {
|
|
73
|
+
/** Filename prefix (default: "capture_") */
|
|
74
|
+
prefix?: string;
|
|
75
|
+
/** Date format pattern (default: "yyyyMMdd_HHmmss_SSS") */
|
|
76
|
+
dateFormat?: string;
|
|
77
|
+
/** Frame number padding digits (default: 5) */
|
|
78
|
+
framePadding?: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Notification customization options for the foreground service
|
|
82
|
+
*/
|
|
83
|
+
export interface NotificationOptions {
|
|
84
|
+
title?: string;
|
|
85
|
+
description?: string;
|
|
86
|
+
icon?: string;
|
|
87
|
+
smallIcon?: string;
|
|
88
|
+
color?: string;
|
|
89
|
+
channelName?: string;
|
|
90
|
+
channelDescription?: string;
|
|
91
|
+
priority?: 'low' | 'default' | 'high';
|
|
92
|
+
showFrameCount?: boolean;
|
|
93
|
+
updateInterval?: number;
|
|
94
|
+
pausedTitle?: string;
|
|
95
|
+
pausedDescription?: string;
|
|
96
|
+
showStopAction?: boolean;
|
|
97
|
+
showPauseAction?: boolean;
|
|
98
|
+
showResumeAction?: boolean;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Capture behavior configuration
|
|
102
|
+
*/
|
|
103
|
+
export interface CaptureConfig {
|
|
104
|
+
/** Milliseconds between captures (100-60000) */
|
|
105
|
+
interval: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Image processing configuration
|
|
109
|
+
*/
|
|
110
|
+
export interface ImageConfig {
|
|
111
|
+
/** Image quality 0-100 */
|
|
112
|
+
quality: number;
|
|
113
|
+
/** Output format */
|
|
114
|
+
format: 'png' | 'jpeg';
|
|
115
|
+
/** Resolution scale factor 0.1-1.0 */
|
|
116
|
+
scaleResolution?: number;
|
|
117
|
+
/** Custom capture region */
|
|
118
|
+
region?: CaptureRegion;
|
|
119
|
+
/** Exclude status bar from capture */
|
|
120
|
+
excludeStatusBar?: boolean;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Storage configuration
|
|
124
|
+
*/
|
|
125
|
+
export interface StorageOptions {
|
|
126
|
+
/** Whether to save captured frames to device storage */
|
|
127
|
+
saveFrames?: boolean;
|
|
128
|
+
/** Storage location for captured frames */
|
|
129
|
+
location?: 'private' | 'public';
|
|
130
|
+
/** Custom output directory */
|
|
131
|
+
outputDirectory?: string;
|
|
132
|
+
/** Storage warning threshold in bytes (default: 100MB, set to 0 to disable) */
|
|
133
|
+
warningThreshold?: number;
|
|
134
|
+
/** File naming configuration */
|
|
135
|
+
fileNaming?: FileNamingConfig;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Performance tuning configuration
|
|
139
|
+
*/
|
|
140
|
+
export interface PerformanceOptions {
|
|
141
|
+
/** Overlay image cache size in bytes (default: 10MB) */
|
|
142
|
+
overlayCacheSize?: number;
|
|
143
|
+
/** ImageReader buffer count (default: 2) */
|
|
144
|
+
imageReaderBuffers?: number;
|
|
145
|
+
/** Executor shutdown timeout in milliseconds (default: 5000ms) */
|
|
146
|
+
executorShutdownTimeout?: number;
|
|
147
|
+
/** Forced executor shutdown timeout in milliseconds (default: 1000ms) */
|
|
148
|
+
executorForcedShutdownTimeout?: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Configuration options for screen capture
|
|
152
|
+
*/
|
|
153
|
+
export interface CaptureOptions {
|
|
154
|
+
/** Capture behavior configuration */
|
|
155
|
+
capture: CaptureConfig;
|
|
156
|
+
/** Image processing configuration */
|
|
157
|
+
image: ImageConfig;
|
|
158
|
+
/** Storage configuration */
|
|
159
|
+
storage?: StorageOptions;
|
|
160
|
+
/** Performance tuning configuration */
|
|
161
|
+
performance?: PerformanceOptions;
|
|
162
|
+
/** Notification customization options */
|
|
163
|
+
notification?: NotificationOptions;
|
|
164
|
+
/** Array of overlays to render on captured frames */
|
|
165
|
+
overlays?: OverlayConfig[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Custom position coordinates for overlay placement
|
|
169
|
+
*/
|
|
170
|
+
export interface PositionCoordinates {
|
|
171
|
+
x: number;
|
|
172
|
+
y: number;
|
|
173
|
+
unit?: 'pixels' | 'percentage';
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Overlay position - either a preset string or custom coordinates
|
|
177
|
+
*/
|
|
178
|
+
export type OverlayPosition = PositionPreset | PositionCoordinates;
|
|
179
|
+
/**
|
|
180
|
+
* Text overlay style configuration
|
|
181
|
+
*/
|
|
182
|
+
export interface TextStyle {
|
|
183
|
+
fontSize?: number;
|
|
184
|
+
color?: string;
|
|
185
|
+
backgroundColor?: string;
|
|
186
|
+
padding?: number;
|
|
187
|
+
fontWeight?: 'normal' | 'bold';
|
|
188
|
+
textAlign?: 'left' | 'center' | 'right';
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Text overlay configuration
|
|
192
|
+
*/
|
|
193
|
+
export interface TextOverlay {
|
|
194
|
+
type: 'text';
|
|
195
|
+
content: string;
|
|
196
|
+
position: OverlayPosition;
|
|
197
|
+
style?: TextStyle;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Image size configuration
|
|
201
|
+
*/
|
|
202
|
+
export interface ImageSize {
|
|
203
|
+
width: number;
|
|
204
|
+
height: number;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Image overlay configuration
|
|
208
|
+
*/
|
|
209
|
+
export interface ImageOverlay {
|
|
210
|
+
type: 'image';
|
|
211
|
+
source: string;
|
|
212
|
+
position: OverlayPosition;
|
|
213
|
+
size?: ImageSize;
|
|
214
|
+
opacity?: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Union type for all overlay configurations
|
|
218
|
+
*/
|
|
219
|
+
export type OverlayConfig = TextOverlay | ImageOverlay;
|
|
220
|
+
/**
|
|
221
|
+
* Information about an active capture session
|
|
222
|
+
*/
|
|
223
|
+
export interface CaptureSession {
|
|
224
|
+
id: string;
|
|
225
|
+
startTime: number;
|
|
226
|
+
frameCount: number;
|
|
227
|
+
options: CaptureOptions;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Current capture status
|
|
231
|
+
*/
|
|
232
|
+
export interface CaptureStatus {
|
|
233
|
+
state: CaptureState;
|
|
234
|
+
session: CaptureSession | null;
|
|
235
|
+
isPaused: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Re-export event types from NativeFrameCapture for consistency
|
|
239
|
+
* These are defined in NativeFrameCapture.ts for codegen compatibility
|
|
240
|
+
*/
|
|
241
|
+
import type { FrameCapturedEvent, CaptureErrorEvent, CaptureStopEvent, CaptureStartEvent, StorageWarningEvent, CapturePauseEvent, CaptureResumeEvent, OverlayErrorEvent } from './NativeFrameCapture';
|
|
242
|
+
export type { FrameCapturedEvent, CaptureErrorEvent, CaptureStopEvent, CaptureStartEvent, StorageWarningEvent, CapturePauseEvent, CaptureResumeEvent, OverlayErrorEvent, };
|
|
243
|
+
/**
|
|
244
|
+
* Union type for all event callbacks
|
|
245
|
+
*/
|
|
246
|
+
export type CaptureEventCallback = ((event: FrameCapturedEvent) => void) | ((event: CaptureErrorEvent) => void) | ((event: CaptureStopEvent) => void) | ((event: CaptureStartEvent) => void) | ((event: StorageWarningEvent) => void) | ((event: CapturePauseEvent) => void) | ((event: CaptureResumeEvent) => void) | ((event: OverlayErrorEvent) => void);
|
|
247
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,cAAc,mBAAmB;CAClC;AAED;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,iBAAiB,sBAAsB;IACvC,iBAAiB,sBAAsB;IACvC,eAAe,oBAAoB;IACnC,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;CAChC;AAED;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,aAAa,mBAAmB;IAChC,YAAY,kBAAkB;IAC9B,aAAa,mBAAmB;IAChC,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,cAAc,oBAAoB;IAClC,aAAa,mBAAmB;CACjC;AAMD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,YAAY,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,WAAW,GACX,aAAa,GACb,cAAc,GACd,QAAQ,CAAC;AAMb;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,CAAC,EAAE,MAAM,CAAC;IACV,kDAAkD;IAClD,CAAC,EAAE,MAAM,CAAC;IACV,2CAA2C;IAC3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gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,CAAC,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC,GACrC,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC,GACpC,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC,GACnC,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC,GACpC,CAAC,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC,GACtC,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC,GACpC,CAAC,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC,GACrC,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input validation utilities
|
|
3
|
+
* @module validation
|
|
4
|
+
*/
|
|
5
|
+
import type { CaptureOptions } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Validates capture options
|
|
8
|
+
* @throws {CaptureError} if validation fails
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateOptions(options: Partial<CaptureOptions>): void;
|
|
11
|
+
/**
|
|
12
|
+
* Merges user options with defaults
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergeOptions(options?: Partial<CaptureOptions>): CaptureOptions;
|
|
15
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAkItE;AAsJD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAChC,cAAc,CAgBhB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-frame-capture",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Reliable screen capture for React Native Android. Capture frames at intervals with customizable overlays and storage options.",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./app.plugin.js": "./app.plugin.js",
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"lib",
|
|
19
|
+
"android",
|
|
20
|
+
"ios",
|
|
21
|
+
"cpp",
|
|
22
|
+
"plugin/build",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"app.plugin.js",
|
|
26
|
+
"!ios/build",
|
|
27
|
+
"!android/build",
|
|
28
|
+
"!android/gradle",
|
|
29
|
+
"!android/gradlew",
|
|
30
|
+
"!android/gradlew.bat",
|
|
31
|
+
"!android/local.properties",
|
|
32
|
+
"!**/__tests__",
|
|
33
|
+
"!**/__fixtures__",
|
|
34
|
+
"!**/__mocks__",
|
|
35
|
+
"!**/.*"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"example": "yarn workspace react-native-frame-capture-example",
|
|
39
|
+
"test": "jest --passWithNoTests",
|
|
40
|
+
"typecheck": "tsc",
|
|
41
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
42
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
43
|
+
"prepare": "bob build",
|
|
44
|
+
"release": "release-it --only-version",
|
|
45
|
+
"run-dev": "cd example/android && gradlew clean && cd ../../ && yarn prepare && yarn example android"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"react-native",
|
|
49
|
+
"android",
|
|
50
|
+
"screen-capture",
|
|
51
|
+
"frame-capture",
|
|
52
|
+
"screenshot",
|
|
53
|
+
"screen-recording",
|
|
54
|
+
"interval-capture",
|
|
55
|
+
"media-projection",
|
|
56
|
+
"turbo-module",
|
|
57
|
+
"expo",
|
|
58
|
+
"capture",
|
|
59
|
+
"frame",
|
|
60
|
+
"screen",
|
|
61
|
+
"recording",
|
|
62
|
+
"fps",
|
|
63
|
+
"foreground-service",
|
|
64
|
+
"overlay",
|
|
65
|
+
"watermark",
|
|
66
|
+
"image-overlay",
|
|
67
|
+
"text-overlay",
|
|
68
|
+
"kotlin",
|
|
69
|
+
"typescript",
|
|
70
|
+
"background-capture",
|
|
71
|
+
"periodic-capture"
|
|
72
|
+
],
|
|
73
|
+
"repository": {
|
|
74
|
+
"type": "git",
|
|
75
|
+
"url": "git+https://github.com/nasyx-rakeeb/react-native-frame-capture.git"
|
|
76
|
+
},
|
|
77
|
+
"author": "Nasyx Rakeeb <nasyxrakeeb2@gmail.com> (https://github.com/nasyx-rakeeb)",
|
|
78
|
+
"license": "MIT",
|
|
79
|
+
"bugs": {
|
|
80
|
+
"url": "https://github.com/nasyx-rakeeb/react-native-frame-capture/issues"
|
|
81
|
+
},
|
|
82
|
+
"homepage": "https://github.com/nasyx-rakeeb/react-native-frame-capture#readme",
|
|
83
|
+
"publishConfig": {
|
|
84
|
+
"registry": "https://registry.npmjs.org/"
|
|
85
|
+
},
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
88
|
+
"@eslint/compat": "^1.3.2",
|
|
89
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
90
|
+
"@eslint/js": "^9.35.0",
|
|
91
|
+
"@evilmartians/lefthook": "^1.12.3",
|
|
92
|
+
"@expo/config-plugins": "^9.0.0",
|
|
93
|
+
"@react-native-community/cli": "20.0.1",
|
|
94
|
+
"@react-native/babel-preset": "0.81.1",
|
|
95
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
96
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
97
|
+
"@types/jest": "^29.5.14",
|
|
98
|
+
"@types/react": "^19.1.0",
|
|
99
|
+
"commitlint": "^19.8.1",
|
|
100
|
+
"del-cli": "^6.0.0",
|
|
101
|
+
"eslint": "^9.35.0",
|
|
102
|
+
"eslint-config-prettier": "^10.1.8",
|
|
103
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
104
|
+
"jest": "^29.7.0",
|
|
105
|
+
"prettier": "^3.6.2",
|
|
106
|
+
"react": "19.1.0",
|
|
107
|
+
"react-native": "0.81.1",
|
|
108
|
+
"react-native-builder-bob": "^0.40.13",
|
|
109
|
+
"release-it": "^19.0.4",
|
|
110
|
+
"turbo": "^2.5.6",
|
|
111
|
+
"typescript": "^5.9.2"
|
|
112
|
+
},
|
|
113
|
+
"peerDependencies": {
|
|
114
|
+
"expo": "*",
|
|
115
|
+
"react": "*",
|
|
116
|
+
"react-native": "*"
|
|
117
|
+
},
|
|
118
|
+
"peerDependenciesMeta": {
|
|
119
|
+
"expo": {
|
|
120
|
+
"optional": true
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"workspaces": [
|
|
124
|
+
"example"
|
|
125
|
+
],
|
|
126
|
+
"packageManager": "yarn@3.6.1",
|
|
127
|
+
"jest": {
|
|
128
|
+
"preset": "react-native",
|
|
129
|
+
"modulePathIgnorePatterns": [
|
|
130
|
+
"<rootDir>/example/node_modules",
|
|
131
|
+
"<rootDir>/lib/"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
"commitlint": {
|
|
135
|
+
"extends": [
|
|
136
|
+
"@commitlint/config-conventional"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"release-it": {
|
|
140
|
+
"git": {
|
|
141
|
+
"commitMessage": "chore: release ${version}",
|
|
142
|
+
"tagName": "v${version}"
|
|
143
|
+
},
|
|
144
|
+
"npm": {
|
|
145
|
+
"publish": true
|
|
146
|
+
},
|
|
147
|
+
"github": {
|
|
148
|
+
"release": true
|
|
149
|
+
},
|
|
150
|
+
"plugins": {
|
|
151
|
+
"@release-it/conventional-changelog": {
|
|
152
|
+
"preset": {
|
|
153
|
+
"name": "angular"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"prettier": {
|
|
159
|
+
"quoteProps": "consistent",
|
|
160
|
+
"singleQuote": true,
|
|
161
|
+
"tabWidth": 2,
|
|
162
|
+
"trailingComma": "es5",
|
|
163
|
+
"useTabs": false
|
|
164
|
+
},
|
|
165
|
+
"react-native-builder-bob": {
|
|
166
|
+
"source": "src",
|
|
167
|
+
"output": "lib",
|
|
168
|
+
"targets": [
|
|
169
|
+
[
|
|
170
|
+
"module",
|
|
171
|
+
{
|
|
172
|
+
"esm": true
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
"typescript",
|
|
177
|
+
{
|
|
178
|
+
"project": "tsconfig.build.json"
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
"codegenConfig": {
|
|
184
|
+
"name": "FrameCaptureSpec",
|
|
185
|
+
"type": "modules",
|
|
186
|
+
"jsSrcsDir": "src",
|
|
187
|
+
"android": {
|
|
188
|
+
"javaPackageName": "com.framecapture"
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"create-react-native-library": {
|
|
192
|
+
"languages": "kotlin-objc",
|
|
193
|
+
"type": "turbo-module",
|
|
194
|
+
"version": "0.54.8"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
const config_plugins_1 = require('@expo/config-plugins');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Expo Config Plugin for react-native-frame-capture
|
|
7
|
+
*
|
|
8
|
+
* This plugin ensures the library is properly configured for Expo projects.
|
|
9
|
+
* The native Android configuration (permissions, service) is already defined
|
|
10
|
+
* in the library's AndroidManifest.xml and will be merged automatically
|
|
11
|
+
* during the Expo prebuild process.
|
|
12
|
+
*
|
|
13
|
+
* This plugin serves as:
|
|
14
|
+
* 1. A marker that the library supports Expo
|
|
15
|
+
* 2. A placeholder for future configuration options
|
|
16
|
+
* 3. Documentation for Expo users
|
|
17
|
+
*/
|
|
18
|
+
const withFrameCapture = (config) => {
|
|
19
|
+
// The library's AndroidManifest.xml already contains:
|
|
20
|
+
// - FOREGROUND_SERVICE permission
|
|
21
|
+
// - FOREGROUND_SERVICE_MEDIA_PROJECTION permission (API 34+)
|
|
22
|
+
// - POST_NOTIFICATIONS permission (API 33+)
|
|
23
|
+
// - ScreenCaptureService with proper foregroundServiceType
|
|
24
|
+
//
|
|
25
|
+
// These will be automatically merged by Expo's manifest merger.
|
|
26
|
+
// No additional modifications needed at this time.
|
|
27
|
+
|
|
28
|
+
return config;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Read package.json to get the actual version
|
|
32
|
+
let pkg = {
|
|
33
|
+
name: 'react-native-frame-capture',
|
|
34
|
+
version: '1.0.0',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
pkg = require('react-native-frame-capture/package.json');
|
|
39
|
+
} catch {
|
|
40
|
+
// Fallback to hardcoded values if package.json can't be found
|
|
41
|
+
// This shouldn't happen in normal usage
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)(
|
|
45
|
+
withFrameCapture,
|
|
46
|
+
pkg.name,
|
|
47
|
+
pkg.version
|
|
48
|
+
);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native TurboModule bridge for React Native Frame Capture
|
|
3
|
+
* @module NativeFrameCapture
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* EventEmitter type for TurboModule events
|
|
10
|
+
*/
|
|
11
|
+
type EventEmitter<T> = (callback: (event: T) => void) => { remove: () => void };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Event payload types (defined inline for codegen compatibility)
|
|
15
|
+
*/
|
|
16
|
+
export type FrameCapturedEvent = {
|
|
17
|
+
filePath: string;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
frameNumber: number;
|
|
20
|
+
fileSize: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type CaptureErrorEvent = {
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
details?: Object;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type CaptureStopEvent = {
|
|
30
|
+
sessionId: string;
|
|
31
|
+
totalFrames: number;
|
|
32
|
+
duration: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type CaptureStartEvent = {
|
|
36
|
+
sessionId: string;
|
|
37
|
+
options: Object;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type StorageWarningEvent = {
|
|
41
|
+
availableSpace: number;
|
|
42
|
+
threshold: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type CapturePauseEvent = {
|
|
46
|
+
sessionId: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type CaptureResumeEvent = {
|
|
50
|
+
sessionId: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type OverlayErrorEvent = {
|
|
54
|
+
overlayIndex: number;
|
|
55
|
+
overlayType: string;
|
|
56
|
+
message: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* TurboModule specification for FrameCapture
|
|
61
|
+
* Defines the native methods implemented in Kotlin
|
|
62
|
+
*/
|
|
63
|
+
export interface Spec extends TurboModule {
|
|
64
|
+
// Event Emitters
|
|
65
|
+
readonly onFrameCaptured: EventEmitter<FrameCapturedEvent>;
|
|
66
|
+
readonly onCaptureError: EventEmitter<CaptureErrorEvent>;
|
|
67
|
+
readonly onCaptureStop: EventEmitter<CaptureStopEvent>;
|
|
68
|
+
readonly onCaptureStart: EventEmitter<CaptureStartEvent>;
|
|
69
|
+
readonly onStorageWarning: EventEmitter<StorageWarningEvent>;
|
|
70
|
+
readonly onCapturePause: EventEmitter<CapturePauseEvent>;
|
|
71
|
+
readonly onCaptureResume: EventEmitter<CaptureResumeEvent>;
|
|
72
|
+
readonly onOverlayError: EventEmitter<OverlayErrorEvent>;
|
|
73
|
+
|
|
74
|
+
// Methods
|
|
75
|
+
requestPermission(): Promise<string>;
|
|
76
|
+
checkPermission(): Promise<string>;
|
|
77
|
+
startCapture(options: Object): Promise<Object>;
|
|
78
|
+
stopCapture(): Promise<void>;
|
|
79
|
+
pauseCapture(): Promise<void>;
|
|
80
|
+
resumeCapture(): Promise<void>;
|
|
81
|
+
getCaptureStatus(): Promise<Object>;
|
|
82
|
+
checkNotificationPermission(): Promise<string>;
|
|
83
|
+
cleanupTempFrames(): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('FrameCapture');
|