capacitor-camera-multicapture 0.12.2
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/CameraMultiCapture.podspec +17 -0
- package/LICENSE +21 -0
- package/Package.swift +28 -0
- package/README.md +551 -0
- package/android/build.gradle +69 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/CameraConfig.java +45 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/CameraConfigMapper.java +98 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/CameraMultiCapture.java +10 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/CameraMultiCapturePlugin.java +1340 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/ExifWrapper.java +108 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/GenericUploadWorker.java +173 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/ImageUtils.java +215 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/PluginVersion.java +6 -0
- package/android/src/main/java/dev/hemang/cameramulticapture/ThumbnailGenerator.java +48 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/esm/controllers/camera-controller.d.ts +127 -0
- package/dist/esm/controllers/camera-controller.js +388 -0
- package/dist/esm/controllers/camera-controller.js.map +1 -0
- package/dist/esm/controllers/gallery-controller.d.ts +66 -0
- package/dist/esm/controllers/gallery-controller.js +333 -0
- package/dist/esm/controllers/gallery-controller.js.map +1 -0
- package/dist/esm/definitions.d.ts +372 -0
- package/dist/esm/definitions.js +6 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/overlay-manager.d.ts +124 -0
- package/dist/esm/overlay-manager.js +732 -0
- package/dist/esm/overlay-manager.js.map +1 -0
- package/dist/esm/overlay.d.ts +2 -0
- package/dist/esm/overlay.js +39 -0
- package/dist/esm/overlay.js.map +1 -0
- package/dist/esm/registration.d.ts +5 -0
- package/dist/esm/registration.js +8 -0
- package/dist/esm/registration.js.map +1 -0
- package/dist/esm/types/ui-types.d.ts +78 -0
- package/dist/esm/types/ui-types.js +2 -0
- package/dist/esm/types/ui-types.js.map +1 -0
- package/dist/esm/ui/capture-gesture-handler.d.ts +15 -0
- package/dist/esm/ui/capture-gesture-handler.js +87 -0
- package/dist/esm/ui/capture-gesture-handler.js.map +1 -0
- package/dist/esm/ui/default-styles.d.ts +27 -0
- package/dist/esm/ui/default-styles.js +134 -0
- package/dist/esm/ui/default-styles.js.map +1 -0
- package/dist/esm/ui/image-editor.d.ts +10 -0
- package/dist/esm/ui/image-editor.js +103 -0
- package/dist/esm/ui/image-editor.js.map +1 -0
- package/dist/esm/ui/layout-manager.d.ts +42 -0
- package/dist/esm/ui/layout-manager.js +199 -0
- package/dist/esm/ui/layout-manager.js.map +1 -0
- package/dist/esm/ui/media-viewer.d.ts +2 -0
- package/dist/esm/ui/media-viewer.js +267 -0
- package/dist/esm/ui/media-viewer.js.map +1 -0
- package/dist/esm/ui/pinch-zoom-handler.d.ts +37 -0
- package/dist/esm/ui/pinch-zoom-handler.js +118 -0
- package/dist/esm/ui/pinch-zoom-handler.js.map +1 -0
- package/dist/esm/ui/ui-factory.d.ts +39 -0
- package/dist/esm/ui/ui-factory.js +272 -0
- package/dist/esm/ui/ui-factory.js.map +1 -0
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/esm/web.d.ts +69 -0
- package/dist/esm/web.js +122 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +6274 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +6276 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/CameraMultiCapturePlugin/CameraMultiCapture.swift +8 -0
- package/ios/Sources/CameraMultiCapturePlugin/CameraMultiCapturePlugin.swift +1551 -0
- package/ios/Sources/CameraMultiCapturePlugin/PluginVersion.swift +2 -0
- package/ios/Tests/CameraMultiCapturePluginTests/CameraMultiCapturePluginTests.swift +15 -0
- package/package.json +93 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import type { PermissionState } from '@capacitor/core';
|
|
2
|
+
export interface ThumbnailStyle {
|
|
3
|
+
width?: string;
|
|
4
|
+
height?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare enum TorchState {
|
|
7
|
+
Off = 0,
|
|
8
|
+
On = 1
|
|
9
|
+
}
|
|
10
|
+
export type CameraDirection = 'front' | 'back';
|
|
11
|
+
export type CaptureMode = 'minimizeLatency' | 'maxQuality';
|
|
12
|
+
export interface Resolution {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ButtonStyle {
|
|
17
|
+
radius?: number;
|
|
18
|
+
color?: string;
|
|
19
|
+
backgroundColor?: string;
|
|
20
|
+
padding?: string;
|
|
21
|
+
size?: number;
|
|
22
|
+
activeColor?: string;
|
|
23
|
+
border?: string;
|
|
24
|
+
opacity?: number;
|
|
25
|
+
boxShadow?: string;
|
|
26
|
+
filter?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CameraOverlayButtons {
|
|
29
|
+
capture?: {
|
|
30
|
+
icon?: string;
|
|
31
|
+
style?: ButtonStyle;
|
|
32
|
+
position?: 'center' | 'left' | 'right' | 'custom';
|
|
33
|
+
};
|
|
34
|
+
done?: {
|
|
35
|
+
icon?: string;
|
|
36
|
+
style?: ButtonStyle;
|
|
37
|
+
text?: string;
|
|
38
|
+
};
|
|
39
|
+
cancel?: {
|
|
40
|
+
icon?: string;
|
|
41
|
+
style?: ButtonStyle;
|
|
42
|
+
text?: string;
|
|
43
|
+
};
|
|
44
|
+
switchCamera?: {
|
|
45
|
+
icon?: string;
|
|
46
|
+
style?: ButtonStyle;
|
|
47
|
+
position?: 'topLeft' | 'topRight' | 'custom';
|
|
48
|
+
};
|
|
49
|
+
zoom?: {
|
|
50
|
+
icon?: string;
|
|
51
|
+
style?: ButtonStyle;
|
|
52
|
+
levels?: number[];
|
|
53
|
+
};
|
|
54
|
+
flash?: {
|
|
55
|
+
onIcon?: string;
|
|
56
|
+
offIcon?: string;
|
|
57
|
+
autoIcon?: string;
|
|
58
|
+
style?: ButtonStyle;
|
|
59
|
+
position?: 'topLeft' | 'topRight' | 'custom';
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Torch (continuous flashlight) toggle button.
|
|
63
|
+
* Independent of capture flash and typically shown below switchCamera.
|
|
64
|
+
*/
|
|
65
|
+
torch?: {
|
|
66
|
+
onIcon?: string;
|
|
67
|
+
offIcon?: string;
|
|
68
|
+
style?: ButtonStyle;
|
|
69
|
+
position?: 'topLeft' | 'topRight' | 'custom';
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export interface CameraPreviewRect {
|
|
73
|
+
width?: number;
|
|
74
|
+
height?: number;
|
|
75
|
+
x?: number;
|
|
76
|
+
y?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface PinchToZoomOptions {
|
|
79
|
+
/**
|
|
80
|
+
* Enable pinch-to-zoom gesture control
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
enabled?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Lock zoom to nearest preset level when gesture ends.
|
|
86
|
+
* If false, allows continuous/nonstandard zoom factors
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
lockToNearestStep?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export interface CameraOverlayOptions {
|
|
92
|
+
buttons?: CameraOverlayButtons;
|
|
93
|
+
thumbnailStyle?: {
|
|
94
|
+
width: string;
|
|
95
|
+
height: string;
|
|
96
|
+
};
|
|
97
|
+
quality?: number;
|
|
98
|
+
containerId: string;
|
|
99
|
+
previewRect?: CameraPreviewRect;
|
|
100
|
+
direction?: CameraDirection;
|
|
101
|
+
captureMode?: CaptureMode;
|
|
102
|
+
resolution?: Resolution;
|
|
103
|
+
zoom?: number;
|
|
104
|
+
autoFocus?: boolean;
|
|
105
|
+
flash?: 'on' | 'off' | 'auto';
|
|
106
|
+
maxCaptures?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Maximum video recording duration in seconds.
|
|
109
|
+
* If omitted, recording duration is unlimited until user releases.
|
|
110
|
+
*/
|
|
111
|
+
maxRecordingDuration?: number;
|
|
112
|
+
flashAutoModeEnabled?: boolean;
|
|
113
|
+
showShotCounter?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Pinch-to-zoom configuration for physical camera zoom control
|
|
116
|
+
*/
|
|
117
|
+
pinchToZoom?: PinchToZoomOptions;
|
|
118
|
+
/**
|
|
119
|
+
* Whether to show the edit (annotate) button on photo previews.
|
|
120
|
+
* When false, markerjs2 is never loaded.
|
|
121
|
+
* Pass an object with `licenseKey` to activate marker.js 2 licensed mode.
|
|
122
|
+
* @default false
|
|
123
|
+
*/
|
|
124
|
+
enableEditing?: boolean | {
|
|
125
|
+
markerJsLicenseKey?: string;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Save captured photos and videos to the device gallery.
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
enableSaving?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Album name for saved media in the device gallery.
|
|
134
|
+
* @default "Camera"
|
|
135
|
+
*/
|
|
136
|
+
galleryAlbumName?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Interface for captured images
|
|
140
|
+
*/
|
|
141
|
+
export interface CapturedImage {
|
|
142
|
+
id: string;
|
|
143
|
+
data: CameraImageData;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Structure for image data returned by the camera
|
|
147
|
+
*/
|
|
148
|
+
export interface CameraImageData {
|
|
149
|
+
uri: string;
|
|
150
|
+
thumbnail: string;
|
|
151
|
+
webPath?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Original native file URI before any annotation was applied.
|
|
154
|
+
* Present only on images that were edited; gives access to the
|
|
155
|
+
* unannotated source while `uri` / `webPath` hold the annotated render.
|
|
156
|
+
*/
|
|
157
|
+
sourceUri?: string;
|
|
158
|
+
/**
|
|
159
|
+
* markerjs2 editor state, present only when `enableEditing` is true
|
|
160
|
+
* and the image was annotated.
|
|
161
|
+
* Pass to `MarkerArea.restoreState()` to continue editing in the parent app.
|
|
162
|
+
*/
|
|
163
|
+
editorState?: unknown;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Structure for video data returned by the camera
|
|
167
|
+
*/
|
|
168
|
+
export interface CameraVideoData {
|
|
169
|
+
uri: string;
|
|
170
|
+
thumbnail: string;
|
|
171
|
+
webPath?: string;
|
|
172
|
+
duration: number;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Interface for captured videos
|
|
176
|
+
*/
|
|
177
|
+
export interface CapturedVideo {
|
|
178
|
+
id: string;
|
|
179
|
+
data: CameraVideoData;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Event data for photo added event
|
|
183
|
+
*/
|
|
184
|
+
export interface PhotoAddedEvent {
|
|
185
|
+
imageId: string;
|
|
186
|
+
image: CameraImageData;
|
|
187
|
+
totalCount: number;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Event data for photo updated event (e.g. after annotation)
|
|
191
|
+
*/
|
|
192
|
+
export interface PhotoUpdatedEvent {
|
|
193
|
+
imageId: string;
|
|
194
|
+
image: CameraImageData;
|
|
195
|
+
totalCount: number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Event data for photo removed event
|
|
199
|
+
*/
|
|
200
|
+
export interface PhotoRemovedEvent {
|
|
201
|
+
imageId: string;
|
|
202
|
+
totalCount: number;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Event data for video added to gallery event
|
|
206
|
+
*/
|
|
207
|
+
export interface VideoAddedEvent {
|
|
208
|
+
videoId: string;
|
|
209
|
+
video: CameraVideoData;
|
|
210
|
+
totalCount: number;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Event data for video removed from gallery event
|
|
214
|
+
*/
|
|
215
|
+
export interface VideoRemovedEvent {
|
|
216
|
+
videoId: string;
|
|
217
|
+
totalCount: number;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Event data for video recording started event
|
|
221
|
+
*/
|
|
222
|
+
export interface VideoRecordingStartedEvent {
|
|
223
|
+
timestamp: number;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Event data for video recording stopped event
|
|
227
|
+
*/
|
|
228
|
+
export interface VideoRecordingStoppedEvent {
|
|
229
|
+
video: CameraVideoData;
|
|
230
|
+
totalCount: number;
|
|
231
|
+
}
|
|
232
|
+
export interface CameraOverlayResult {
|
|
233
|
+
images: CameraImageData[];
|
|
234
|
+
videos: CameraVideoData[];
|
|
235
|
+
cancelled: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Permission status for the camera multi-capture plugin
|
|
239
|
+
*/
|
|
240
|
+
export interface PermissionStatus {
|
|
241
|
+
camera: PermissionState;
|
|
242
|
+
audio: PermissionState;
|
|
243
|
+
}
|
|
244
|
+
export interface CameraMultiCapturePlugin {
|
|
245
|
+
/**
|
|
246
|
+
* Starts the camera overlay session.
|
|
247
|
+
*/
|
|
248
|
+
start(options?: CameraOverlayOptions): Promise<CameraOverlayResult>;
|
|
249
|
+
/**
|
|
250
|
+
* Captures a single frame.
|
|
251
|
+
*/
|
|
252
|
+
capture(): Promise<{
|
|
253
|
+
value: CameraImageData;
|
|
254
|
+
}>;
|
|
255
|
+
/**
|
|
256
|
+
* Starts recording video.
|
|
257
|
+
*/
|
|
258
|
+
startVideoRecording(): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Stops recording video and returns video metadata.
|
|
261
|
+
*/
|
|
262
|
+
stopVideoRecording(): Promise<{
|
|
263
|
+
value: CameraVideoData;
|
|
264
|
+
}>;
|
|
265
|
+
/**
|
|
266
|
+
* Stops and tears down the camera session.
|
|
267
|
+
*/
|
|
268
|
+
stop(): Promise<void>;
|
|
269
|
+
/**
|
|
270
|
+
* Switches the camera between front and back.
|
|
271
|
+
*/
|
|
272
|
+
switchCamera(): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* Sets the zoom level of the camera.
|
|
275
|
+
*/
|
|
276
|
+
setZoom(options: {
|
|
277
|
+
zoom: number;
|
|
278
|
+
}): Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* Gets the available zoom levels supported by the current camera.
|
|
281
|
+
* Returns minimum and maximum zoom ratios, and suggested preset levels.
|
|
282
|
+
*/
|
|
283
|
+
getAvailableZoomLevels(): Promise<{
|
|
284
|
+
minZoom: number;
|
|
285
|
+
maxZoom: number;
|
|
286
|
+
presetLevels: number[];
|
|
287
|
+
}>;
|
|
288
|
+
/**
|
|
289
|
+
* Gets information about available physical cameras
|
|
290
|
+
*/
|
|
291
|
+
getAvailableCameras(): Promise<{
|
|
292
|
+
hasUltrawide: boolean;
|
|
293
|
+
hasWide: boolean;
|
|
294
|
+
hasTelephoto: boolean;
|
|
295
|
+
ultrawideZoomFactor?: number;
|
|
296
|
+
wideZoomFactor: number;
|
|
297
|
+
telephotoZoomFactor?: number;
|
|
298
|
+
}>;
|
|
299
|
+
/**
|
|
300
|
+
* Switches to a specific physical camera based on zoom factor
|
|
301
|
+
* @param zoomFactor The target zoom factor (e.g., 0.5 for ultrawide, 1.0 for wide, 2.0+ for telephoto)
|
|
302
|
+
*/
|
|
303
|
+
switchToPhysicalCamera(options: {
|
|
304
|
+
zoomFactor: number;
|
|
305
|
+
}): Promise<void>;
|
|
306
|
+
/**
|
|
307
|
+
* Updates the camera preview rectangle dimensions.
|
|
308
|
+
* Call this when the container size changes (e.g., orientation change).
|
|
309
|
+
*/
|
|
310
|
+
updatePreviewRect(options: CameraPreviewRect): Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Sets the flash mode of the camera.
|
|
313
|
+
*/
|
|
314
|
+
setFlash(options: {
|
|
315
|
+
flashMode: 'on' | 'off' | 'auto';
|
|
316
|
+
}): Promise<void>;
|
|
317
|
+
/**
|
|
318
|
+
* Gets the current flash mode.
|
|
319
|
+
*/
|
|
320
|
+
getFlash(): Promise<{
|
|
321
|
+
flashMode: 'on' | 'off' | 'auto';
|
|
322
|
+
}>;
|
|
323
|
+
/**
|
|
324
|
+
* Sets the torch (continuous flashlight) on or off.
|
|
325
|
+
* Torch is independent of the capture flash setting.
|
|
326
|
+
*/
|
|
327
|
+
setTorch(options: {
|
|
328
|
+
enabled: boolean;
|
|
329
|
+
}): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Gets whether the torch is currently enabled.
|
|
332
|
+
*/
|
|
333
|
+
getTorch(): Promise<{
|
|
334
|
+
enabled: boolean;
|
|
335
|
+
}>;
|
|
336
|
+
/**
|
|
337
|
+
* Check camera and photo library permissions
|
|
338
|
+
*/
|
|
339
|
+
checkPermissions(): Promise<PermissionStatus>;
|
|
340
|
+
/**
|
|
341
|
+
* Request camera and photo library permissions
|
|
342
|
+
*/
|
|
343
|
+
requestPermissions(): Promise<PermissionStatus>;
|
|
344
|
+
/**
|
|
345
|
+
* Generic background upload - works with any backend
|
|
346
|
+
*/
|
|
347
|
+
queueBackgroundUpload(options: {
|
|
348
|
+
imageUri: string;
|
|
349
|
+
uploadEndpoint: string;
|
|
350
|
+
headers: Record<string, string>;
|
|
351
|
+
formData?: Record<string, string>;
|
|
352
|
+
method?: 'POST' | 'PUT';
|
|
353
|
+
deleteAfterUpload?: boolean;
|
|
354
|
+
}): Promise<{
|
|
355
|
+
jobId: string;
|
|
356
|
+
}>;
|
|
357
|
+
/**
|
|
358
|
+
* Check upload job status
|
|
359
|
+
*/
|
|
360
|
+
getUploadStatus(options: {
|
|
361
|
+
jobId: string;
|
|
362
|
+
}): Promise<{
|
|
363
|
+
status: 'pending' | 'uploading' | 'completed' | 'failed';
|
|
364
|
+
error?: string;
|
|
365
|
+
}>;
|
|
366
|
+
/**
|
|
367
|
+
* Returns the current plugin version string.
|
|
368
|
+
*/
|
|
369
|
+
getVersion(): Promise<{
|
|
370
|
+
version: string;
|
|
371
|
+
}>;
|
|
372
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAOA,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,yCAAO,CAAA;IACP,uCAAM,CAAA;AACR,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\nexport interface ThumbnailStyle {\n width?: string;\n height?: string;\n}\n\nexport enum TorchState {\n Off = 0,\n On = 1,\n}\n\nexport type CameraDirection = 'front' | 'back';\n\nexport type CaptureMode = 'minimizeLatency' | 'maxQuality';\n\nexport interface Resolution {\n width: number;\n height: number;\n}\n\nexport interface ButtonStyle {\n radius?: number;\n color?: string;\n backgroundColor?: string;\n padding?: string;\n size?: number;\n activeColor?: string;\n border?: string;\n opacity?: number;\n boxShadow?: string;\n filter?: string; // CSS filter property (e.g., blur, brightness, contrast, etc.)\n}\n\nexport interface CameraOverlayButtons {\n capture?: {\n icon?: string;\n style?: ButtonStyle;\n position?: 'center' | 'left' | 'right' | 'custom';\n };\n done?: {\n icon?: string;\n style?: ButtonStyle;\n text?: string;\n };\n cancel?: {\n icon?: string;\n style?: ButtonStyle;\n text?: string;\n };\n switchCamera?: {\n icon?: string;\n style?: ButtonStyle;\n position?: 'topLeft' | 'topRight' | 'custom';\n };\n zoom?: {\n icon?: string;\n style?: ButtonStyle;\n levels?: number[];\n };\n flash?: {\n onIcon?: string;\n offIcon?: string;\n autoIcon?: string;\n style?: ButtonStyle;\n position?: 'topLeft' | 'topRight' | 'custom';\n };\n /**\n * Torch (continuous flashlight) toggle button.\n * Independent of capture flash and typically shown below switchCamera.\n */\n torch?: {\n onIcon?: string;\n offIcon?: string;\n style?: ButtonStyle;\n position?: 'topLeft' | 'topRight' | 'custom';\n };\n}\n\nexport interface CameraPreviewRect {\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n}\n\nexport interface PinchToZoomOptions {\n /**\n * Enable pinch-to-zoom gesture control\n * @default false\n */\n enabled?: boolean;\n /**\n * Lock zoom to nearest preset level when gesture ends.\n * If false, allows continuous/nonstandard zoom factors\n * @default false\n */\n lockToNearestStep?: boolean;\n}\n\nexport interface CameraOverlayOptions {\n buttons?: CameraOverlayButtons;\n thumbnailStyle?: { width: string; height: string };\n quality?: number;\n containerId: string;\n previewRect?: CameraPreviewRect;\n direction?: CameraDirection;\n captureMode?: CaptureMode;\n resolution?: Resolution;\n zoom?: number;\n autoFocus?: boolean;\n flash?: 'on' | 'off' | 'auto';\n maxCaptures?: number;\n /**\n * Maximum video recording duration in seconds.\n * If omitted, recording duration is unlimited until user releases.\n */\n maxRecordingDuration?: number;\n flashAutoModeEnabled?: boolean;\n showShotCounter?: boolean;\n /**\n * Pinch-to-zoom configuration for physical camera zoom control\n */\n pinchToZoom?: PinchToZoomOptions;\n /**\n * Whether to show the edit (annotate) button on photo previews.\n * When false, markerjs2 is never loaded.\n * Pass an object with `licenseKey` to activate marker.js 2 licensed mode.\n * @default false\n */\n enableEditing?: boolean | { markerJsLicenseKey?: string };\n /**\n * Save captured photos and videos to the device gallery.\n * @default false\n */\n enableSaving?: boolean;\n /**\n * Album name for saved media in the device gallery.\n * @default \"Camera\"\n */\n galleryAlbumName?: string;\n}\n\n\n/**\n * Interface for captured images\n */\nexport interface CapturedImage {\n id: string;\n data: CameraImageData;\n}\n\n/**\n * Structure for image data returned by the camera\n */\nexport interface CameraImageData {\n uri: string;\n thumbnail: string;\n webPath?: string;\n /**\n * Original native file URI before any annotation was applied.\n * Present only on images that were edited; gives access to the\n * unannotated source while `uri` / `webPath` hold the annotated render.\n */\n sourceUri?: string;\n /**\n * markerjs2 editor state, present only when `enableEditing` is true\n * and the image was annotated.\n * Pass to `MarkerArea.restoreState()` to continue editing in the parent app.\n */\n editorState?: unknown;\n}\n\n/**\n * Structure for video data returned by the camera\n */\nexport interface CameraVideoData {\n uri: string;\n thumbnail: string; // Optimized thumbnail as Base64 data URI\n webPath?: string;\n duration: number; // Duration in seconds\n}\n\n/**\n * Interface for captured videos\n */\nexport interface CapturedVideo {\n id: string;\n data: CameraVideoData;\n}\n\n/**\n * Event data for photo added event\n */\nexport interface PhotoAddedEvent {\n imageId: string;\n image: CameraImageData;\n totalCount: number;\n}\n\n/**\n * Event data for photo updated event (e.g. after annotation)\n */\nexport interface PhotoUpdatedEvent {\n imageId: string;\n image: CameraImageData;\n totalCount: number;\n}\n\n/**\n * Event data for photo removed event\n */\nexport interface PhotoRemovedEvent {\n imageId: string;\n totalCount: number;\n}\n\n/**\n * Event data for video added to gallery event\n */\nexport interface VideoAddedEvent {\n videoId: string;\n video: CameraVideoData;\n totalCount: number;\n}\n\n/**\n * Event data for video removed from gallery event\n */\nexport interface VideoRemovedEvent {\n videoId: string;\n totalCount: number;\n}\n\n/**\n * Event data for video recording started event\n */\nexport interface VideoRecordingStartedEvent {\n timestamp: number;\n}\n\n/**\n * Event data for video recording stopped event\n */\nexport interface VideoRecordingStoppedEvent {\n video: CameraVideoData;\n totalCount: number;\n}\n\nexport interface CameraOverlayResult {\n images: CameraImageData[];\n videos: CameraVideoData[];\n cancelled: boolean;\n}\n\n/**\n * Permission status for the camera multi-capture plugin\n */\nexport interface PermissionStatus {\n camera: PermissionState;\n audio: PermissionState;\n}\n\nexport interface CameraMultiCapturePlugin {\n /**\n * Starts the camera overlay session.\n */\n start(options?: CameraOverlayOptions): Promise<CameraOverlayResult>;\n\n /**\n * Captures a single frame.\n */\n capture(): Promise<{ value: CameraImageData }>;\n\n /**\n * Starts recording video.\n */\n startVideoRecording(): Promise<void>;\n\n /**\n * Stops recording video and returns video metadata.\n */\n stopVideoRecording(): Promise<{ value: CameraVideoData }>;\n\n /**\n * Stops and tears down the camera session.\n */\n stop(): Promise<void>;\n\n /**\n * Switches the camera between front and back.\n */\n switchCamera(): Promise<void>;\n\n /**\n * Sets the zoom level of the camera.\n */\n setZoom(options: { zoom: number }): Promise<void>;\n\n /**\n * Gets the available zoom levels supported by the current camera.\n * Returns minimum and maximum zoom ratios, and suggested preset levels.\n */\n getAvailableZoomLevels(): Promise<{\n minZoom: number;\n maxZoom: number;\n presetLevels: number[];\n }>;\n\n /**\n * Gets information about available physical cameras\n */\n getAvailableCameras(): Promise<{\n hasUltrawide: boolean;\n hasWide: boolean;\n hasTelephoto: boolean;\n ultrawideZoomFactor?: number;\n wideZoomFactor: number;\n telephotoZoomFactor?: number;\n }>;\n\n /**\n * Switches to a specific physical camera based on zoom factor\n * @param zoomFactor The target zoom factor (e.g., 0.5 for ultrawide, 1.0 for wide, 2.0+ for telephoto)\n */\n switchToPhysicalCamera(options: { zoomFactor: number }): Promise<void>;\n\n /**\n * Updates the camera preview rectangle dimensions.\n * Call this when the container size changes (e.g., orientation change).\n */\n updatePreviewRect(options: CameraPreviewRect): Promise<void>;\n\n /**\n * Sets the flash mode of the camera.\n */\n setFlash(options: { flashMode: 'on' | 'off' | 'auto' }): Promise<void>;\n\n /**\n * Gets the current flash mode.\n */\n getFlash(): Promise<{ flashMode: 'on' | 'off' | 'auto' }>;\n\n /**\n * Sets the torch (continuous flashlight) on or off.\n * Torch is independent of the capture flash setting.\n */\n setTorch(options: { enabled: boolean }): Promise<void>;\n\n /**\n * Gets whether the torch is currently enabled.\n */\n getTorch(): Promise<{ enabled: boolean }>;\n\n /**\n * Check camera and photo library permissions\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera and photo library permissions\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Generic background upload - works with any backend\n */\n queueBackgroundUpload(options: {\n imageUri: string;\n uploadEndpoint: string;\n headers: Record<string, string>;\n formData?: Record<string, string>;\n method?: 'POST' | 'PUT';\n deleteAfterUpload?: boolean; // Default: true\n }): Promise<{ jobId: string }>;\n\n /**\n * Check upload job status\n */\n getUploadStatus(options: { jobId: string }): Promise<{\n status: 'pending' | 'uploading' | 'completed' | 'failed';\n error?: string;\n }>;\n\n /**\n * Returns the current plugin version string.\n */\n getVersion(): Promise<{ version: string }>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { initialize } from './overlay';\nimport { CameraMultiCapture } from './registration';\n\nexport * from './definitions';\nexport { initialize };\nexport { CameraMultiCapture };\n"]}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { CameraMultiCapturePlugin, CameraOverlayResult } from './definitions';
|
|
2
|
+
import type { CameraOverlayUIOptions } from './types/ui-types';
|
|
3
|
+
/**
|
|
4
|
+
* Main class to manage camera overlay UI
|
|
5
|
+
*/
|
|
6
|
+
export declare class OverlayManager {
|
|
7
|
+
private options;
|
|
8
|
+
private overlayElement;
|
|
9
|
+
private cameraController;
|
|
10
|
+
private galleryController;
|
|
11
|
+
private isActive;
|
|
12
|
+
private resolvePromise;
|
|
13
|
+
private bodyBackgroundColor;
|
|
14
|
+
private zoomContainer;
|
|
15
|
+
private zoomConfig;
|
|
16
|
+
private zoomButtonsList;
|
|
17
|
+
private zoomButtonLevels;
|
|
18
|
+
private shotCounter;
|
|
19
|
+
private shotCount;
|
|
20
|
+
private torchButton;
|
|
21
|
+
private torchConfig;
|
|
22
|
+
private pinchHandler;
|
|
23
|
+
private isRecordingVideo;
|
|
24
|
+
private captureButton;
|
|
25
|
+
private captureGestureBinding;
|
|
26
|
+
private recordingIndicator;
|
|
27
|
+
private recordingTimerText;
|
|
28
|
+
private recordingStartedAt;
|
|
29
|
+
private recordingIntervalId;
|
|
30
|
+
private boundOrientationHandler;
|
|
31
|
+
constructor(plugin: CameraMultiCapturePlugin, options: CameraOverlayUIOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Emits photoAdded event using pure JavaScript events
|
|
34
|
+
*/
|
|
35
|
+
private emitPhotoAddedEvent;
|
|
36
|
+
/**
|
|
37
|
+
* Emits photoUpdated event using pure JavaScript events
|
|
38
|
+
*/
|
|
39
|
+
private emitPhotoUpdatedEvent;
|
|
40
|
+
/**
|
|
41
|
+
* Emits photoRemoved event using pure JavaScript events
|
|
42
|
+
*/
|
|
43
|
+
private emitPhotoRemovedEvent;
|
|
44
|
+
/**
|
|
45
|
+
* Emits videoRecordingStarted event using pure JavaScript events.
|
|
46
|
+
*/
|
|
47
|
+
private emitVideoRecordingStartedEvent;
|
|
48
|
+
/**
|
|
49
|
+
* Emits videoRecordingStopped event using pure JavaScript events.
|
|
50
|
+
*/
|
|
51
|
+
private emitVideoRecordingStoppedEvent;
|
|
52
|
+
/**
|
|
53
|
+
* Emits videoAdded event using pure JavaScript events.
|
|
54
|
+
*/
|
|
55
|
+
private emitVideoAddedEvent;
|
|
56
|
+
/**
|
|
57
|
+
* Emits videoRemoved event using pure JavaScript events.
|
|
58
|
+
*/
|
|
59
|
+
private emitVideoRemovedEvent;
|
|
60
|
+
/**
|
|
61
|
+
* Shows the camera overlay and returns captured images
|
|
62
|
+
*/
|
|
63
|
+
setup(): Promise<CameraOverlayResult>;
|
|
64
|
+
refresh(): Promise<void>;
|
|
65
|
+
private handleOrientationChange;
|
|
66
|
+
/**
|
|
67
|
+
* Creates the overlay UI
|
|
68
|
+
*/
|
|
69
|
+
private createOverlayUI;
|
|
70
|
+
/**
|
|
71
|
+
* Creates the switch camera button
|
|
72
|
+
*/
|
|
73
|
+
private createSwitchCameraButton;
|
|
74
|
+
/**
|
|
75
|
+
* Creates the torch (flashlight) toggle button, stacked below the switch camera button.
|
|
76
|
+
*/
|
|
77
|
+
private createTorchButton;
|
|
78
|
+
/**
|
|
79
|
+
* Refreshes the torch icon based on current native torch state.
|
|
80
|
+
*/
|
|
81
|
+
private refreshTorchIconFromState;
|
|
82
|
+
/**
|
|
83
|
+
* Creates zoom buttons after camera initialization
|
|
84
|
+
*/
|
|
85
|
+
private createZoomButtonsAfterInit;
|
|
86
|
+
/**
|
|
87
|
+
* Creates smart zoom buttons with physical camera indication
|
|
88
|
+
*/
|
|
89
|
+
private createZoomButtons;
|
|
90
|
+
/**
|
|
91
|
+
* Updates zoom button styles so the button closest to currentZoom is highlighted.
|
|
92
|
+
*/
|
|
93
|
+
private updateZoomButtonSelection;
|
|
94
|
+
/**
|
|
95
|
+
* Creates the flash toggle button
|
|
96
|
+
*/
|
|
97
|
+
private createFlashButton;
|
|
98
|
+
/**
|
|
99
|
+
* Handles quick tap capture for still images.
|
|
100
|
+
*/
|
|
101
|
+
private handleCaptureTap;
|
|
102
|
+
/**
|
|
103
|
+
* Handles long press start to begin video recording.
|
|
104
|
+
*/
|
|
105
|
+
private handleCaptureHoldStart;
|
|
106
|
+
/**
|
|
107
|
+
* Handles pointer release for either tap photo or stop video recording.
|
|
108
|
+
*/
|
|
109
|
+
private handleCaptureRelease;
|
|
110
|
+
private ensureRecordingGlowStyles;
|
|
111
|
+
private setCaptureGlow;
|
|
112
|
+
private createRecordingIndicator;
|
|
113
|
+
private showRecordingIndicator;
|
|
114
|
+
private startRecordingTimer;
|
|
115
|
+
private stopRecordingTimer;
|
|
116
|
+
/**
|
|
117
|
+
* Completes the capture process
|
|
118
|
+
*/
|
|
119
|
+
private completeCapture;
|
|
120
|
+
/**
|
|
121
|
+
* Cleans up resources
|
|
122
|
+
*/
|
|
123
|
+
private cleanup;
|
|
124
|
+
}
|