@capgo/capacitor-document-scanner 8.3.18 → 8.3.23
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/README.md +10 -9
- package/android/src/main/java/app/capgo/plugin/document_scanner/DocumentScannerPlugin.java +341 -26
- package/dist/docs.json +15 -3
- package/dist/esm/definitions.d.ts +17 -5
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js +1 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/DocumentScannerPlugin/DocScanner.swift +900 -124
- package/ios/Sources/DocumentScannerPlugin/DocumentScannerPlugin.swift +4 -2
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -101,15 +101,16 @@ Opens the device camera and starts the document scanning experience.
|
|
|
101
101
|
|
|
102
102
|
#### ScanDocumentOptions
|
|
103
103
|
|
|
104
|
-
| Prop
|
|
105
|
-
|
|
|
106
|
-
| **`croppedImageQuality`**
|
|
107
|
-
| **`letUserAdjustCrop`**
|
|
108
|
-
| **`
|
|
109
|
-
| **`
|
|
110
|
-
| **`
|
|
111
|
-
| **`
|
|
112
|
-
| **`
|
|
104
|
+
| Prop | Type | Description | Default |
|
|
105
|
+
| ---------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
|
|
106
|
+
| **`croppedImageQuality`** | <code>number</code> | Android only: quality of the cropped image from 0 - 100 (100 is best). | <code>100</code> |
|
|
107
|
+
| **`letUserAdjustCrop`** | <code>boolean</code> | Allow the user to adjust the detected crop before saving. On iOS this forces the native VisionKit preview/editor after each capture using the private VisionKit navigation hooks needed to keep the scanner flow alive. On Android this enables ML Kit's crop adjustment flow. | <code>true</code> |
|
|
108
|
+
| **`reviewCapturedDocument`** | <code>boolean</code> | When enabled, shows the current scanned page before continuing so the user can review it and explicitly continue or finish the flow. On iOS this forces the native VisionKit preview/editor between captures. On Android this switches to a one-page-at-a-time flow between ML Kit sessions. The review/editor screen is still shown automatically when the scan limit is reached. | <code>false</code> |
|
|
109
|
+
| **`maxNumDocuments`** | <code>number</code> | Maximum number of documents to scan. On iOS: VisionKit caps scans at 24 pages (system limit), and the hacked native flow can still stop earlier when you pass a smaller limit. On Android: customizable limit; defaults to 20 for performance (clamped 1-24). Set to 1 for single-scan mode where the scanner stops after one document. | <code>20 on Android, 24 on iOS</code> |
|
|
110
|
+
| **`responseType`** | <code><a href="#responsetype">ResponseType</a></code> | Format to return scanned images in (file paths or base64 strings). | <code>ResponseType.ImageFilePath</code> |
|
|
111
|
+
| **`brightness`** | <code>number</code> | Brightness adjustment applied to scanned images. Range: -255 to 255 (0 = no change, positive = brighter, negative = darker) Useful for compensating low-light scans. | <code>0</code> |
|
|
112
|
+
| **`contrast`** | <code>number</code> | Contrast adjustment applied to scanned images. Range: 0.0 to 10.0 (1.0 = no change, >1 = more contrast, <1 = less contrast) Helps improve text clarity in poorly lit scans. | <code>1.0</code> |
|
|
113
|
+
| **`scannerMode`** | <code><a href="#scannermode">ScannerMode</a></code> | Android only: scanner mode that controls ML Kit features and filters. - 'base': Basic scan with crop/rotate, no filters or ML cleaning - 'base_with_filter': Adds grayscale and auto-enhancement filters - 'full': All features including ML-based image cleaning (erases stains, fingers, etc.) | <code>ScannerMode.Full</code> |
|
|
113
114
|
|
|
114
115
|
|
|
115
116
|
### Type Aliases
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package app.capgo.plugin.documentscanner;
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
|
+
import android.app.AlertDialog;
|
|
4
5
|
import android.content.Context;
|
|
5
6
|
import android.content.Intent;
|
|
6
7
|
import android.graphics.Bitmap;
|
|
@@ -12,6 +13,11 @@ import android.graphics.Paint;
|
|
|
12
13
|
import android.net.Uri;
|
|
13
14
|
import android.os.Build;
|
|
14
15
|
import android.util.Base64;
|
|
16
|
+
import android.util.TypedValue;
|
|
17
|
+
import android.view.View;
|
|
18
|
+
import android.widget.ImageView;
|
|
19
|
+
import android.widget.LinearLayout;
|
|
20
|
+
import android.widget.TextView;
|
|
15
21
|
import androidx.activity.result.ActivityResult;
|
|
16
22
|
import androidx.activity.result.ActivityResultLauncher;
|
|
17
23
|
import androidx.activity.result.IntentSenderRequest;
|
|
@@ -64,13 +70,29 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
64
70
|
private final int quality;
|
|
65
71
|
private final float brightness;
|
|
66
72
|
private final float contrast;
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
private final int requestedPageLimit;
|
|
74
|
+
private final int scannerMode;
|
|
75
|
+
private final boolean reviewCapturedDocument;
|
|
76
|
+
private final List<File> acceptedPageFiles = new ArrayList<>();
|
|
77
|
+
|
|
78
|
+
PendingScan(
|
|
79
|
+
String callId,
|
|
80
|
+
String responseType,
|
|
81
|
+
int quality,
|
|
82
|
+
float brightness,
|
|
83
|
+
float contrast,
|
|
84
|
+
int requestedPageLimit,
|
|
85
|
+
int scannerMode,
|
|
86
|
+
boolean reviewCapturedDocument
|
|
87
|
+
) {
|
|
69
88
|
this.callId = callId;
|
|
70
89
|
this.responseType = responseType;
|
|
71
90
|
this.quality = quality;
|
|
72
91
|
this.brightness = brightness;
|
|
73
92
|
this.contrast = contrast;
|
|
93
|
+
this.requestedPageLimit = requestedPageLimit;
|
|
94
|
+
this.scannerMode = scannerMode;
|
|
95
|
+
this.reviewCapturedDocument = reviewCapturedDocument;
|
|
74
96
|
}
|
|
75
97
|
}
|
|
76
98
|
|
|
@@ -129,29 +151,93 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
129
151
|
|
|
130
152
|
int quality = clamp(call.getInt("croppedImageQuality", 100), 0, 100);
|
|
131
153
|
String responseType = normalizeResponseType(call.getString("responseType"));
|
|
132
|
-
int pageLimit = clamp(call.getInt("maxNumDocuments",
|
|
154
|
+
int pageLimit = clamp(call.getInt("maxNumDocuments", 20), 1, 24);
|
|
133
155
|
float brightness = clampFloat(call.getFloat("brightness", 0f), -255f, 255f);
|
|
134
156
|
float contrast = clampFloat(call.getFloat("contrast", 1f), 0f, 10f);
|
|
135
157
|
String scannerMode = normalizeScannerMode(call.getString("scannerMode"));
|
|
158
|
+
boolean reviewCapturedDocument = call.getBoolean("reviewCapturedDocument", false);
|
|
136
159
|
// Only default letUserAdjustCrop to true if scannerMode is FULL
|
|
137
160
|
// This ensures scannerMode takes precedence when explicitly set
|
|
138
161
|
boolean defaultAllowCrop = SCANNER_MODE_FULL.equals(scannerMode);
|
|
139
162
|
boolean allowAdjustCrop = call.getBoolean("letUserAdjustCrop", defaultAllowCrop);
|
|
140
163
|
|
|
141
|
-
GmsDocumentScannerOptions.Builder optionsBuilder = new GmsDocumentScannerOptions.Builder()
|
|
142
|
-
.setGalleryImportAllowed(false)
|
|
143
|
-
.setResultFormats(GmsDocumentScannerOptions.RESULT_FORMAT_JPEG)
|
|
144
|
-
.setPageLimit(pageLimit);
|
|
145
|
-
|
|
146
164
|
// Determine scanner mode based on scannerMode parameter and letUserAdjustCrop
|
|
147
165
|
int mlKitScannerMode = determineScannerMode(scannerMode, allowAdjustCrop);
|
|
148
|
-
optionsBuilder.setScannerMode(mlKitScannerMode);
|
|
149
|
-
|
|
150
|
-
GmsDocumentScanner scanner = GmsDocumentScanning.getClient(optionsBuilder.build());
|
|
151
166
|
|
|
152
167
|
bridge.saveCall(call);
|
|
153
|
-
pendingScan = new PendingScan(
|
|
168
|
+
pendingScan = new PendingScan(
|
|
169
|
+
call.getCallbackId(),
|
|
170
|
+
responseType,
|
|
171
|
+
quality,
|
|
172
|
+
brightness,
|
|
173
|
+
contrast,
|
|
174
|
+
pageLimit,
|
|
175
|
+
mlKitScannerMode,
|
|
176
|
+
reviewCapturedDocument
|
|
177
|
+
);
|
|
154
178
|
|
|
179
|
+
startScanner(activity, call);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
private void handleScanResult(ActivityResult result) {
|
|
183
|
+
PluginCall call = getPendingCall();
|
|
184
|
+
if (call == null) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (result.getResultCode() != Activity.RESULT_OK) {
|
|
189
|
+
handleScanCanceled(call);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
Intent data = result.getData();
|
|
194
|
+
if (data == null) {
|
|
195
|
+
call.reject("Document scanner returned no data.");
|
|
196
|
+
releasePendingCall(call);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
GmsDocumentScanningResult scanningResult = GmsDocumentScanningResult.fromActivityResultIntent(data);
|
|
201
|
+
if (scanningResult == null) {
|
|
202
|
+
call.reject("Unable to parse document scan result.");
|
|
203
|
+
releasePendingCall(call);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
if (pendingScan != null && pendingScan.reviewCapturedDocument) {
|
|
209
|
+
handleReviewedCaptureResult(call, scanningResult);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
List<String> scannedImages = processScanResult(scanningResult);
|
|
214
|
+
JSObject response = new JSObject();
|
|
215
|
+
response.put("status", "success");
|
|
216
|
+
response.put("scannedImages", new JSArray(scannedImages));
|
|
217
|
+
call.resolve(response);
|
|
218
|
+
releasePendingCall(call);
|
|
219
|
+
} catch (IOException ioException) {
|
|
220
|
+
call.reject("Failed to process scanned images: " + ioException.getLocalizedMessage(), ioException);
|
|
221
|
+
releasePendingCall(call);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private void startScanner(Activity activity, PluginCall call) {
|
|
226
|
+
PendingScan scan = pendingScan;
|
|
227
|
+
if (scan == null) {
|
|
228
|
+
call.reject("Document scanner is not ready.");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
int effectivePageLimit = scan.reviewCapturedDocument ? 1 : scan.requestedPageLimit;
|
|
233
|
+
GmsDocumentScannerOptions options = new GmsDocumentScannerOptions.Builder()
|
|
234
|
+
.setGalleryImportAllowed(false)
|
|
235
|
+
.setResultFormats(GmsDocumentScannerOptions.RESULT_FORMAT_JPEG)
|
|
236
|
+
.setPageLimit(effectivePageLimit)
|
|
237
|
+
.setScannerMode(scan.scannerMode)
|
|
238
|
+
.build();
|
|
239
|
+
|
|
240
|
+
GmsDocumentScanner scanner = GmsDocumentScanning.getClient(options);
|
|
155
241
|
scanner
|
|
156
242
|
.getStartScanIntent(activity)
|
|
157
243
|
.addOnSuccessListener((intentSender) -> {
|
|
@@ -172,36 +258,205 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
172
258
|
});
|
|
173
259
|
}
|
|
174
260
|
|
|
175
|
-
private void
|
|
176
|
-
|
|
177
|
-
if (
|
|
261
|
+
private void handleScanCanceled(PluginCall call) {
|
|
262
|
+
PendingScan scan = pendingScan;
|
|
263
|
+
if (scan != null && scan.reviewCapturedDocument && !scan.acceptedPageFiles.isEmpty()) {
|
|
264
|
+
resolveAcceptedPages(call);
|
|
178
265
|
return;
|
|
179
266
|
}
|
|
180
267
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
268
|
+
JSObject response = new JSObject();
|
|
269
|
+
response.put("status", "cancel");
|
|
270
|
+
call.resolve(response);
|
|
271
|
+
releasePendingCall(call);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private void handleReviewedCaptureResult(PluginCall call, GmsDocumentScanningResult scanningResult) throws IOException {
|
|
275
|
+
PendingScan scan = pendingScan;
|
|
276
|
+
if (scan == null) {
|
|
277
|
+
throw new IOException("No active scan.");
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
List<Page> pages = scanningResult.getPages();
|
|
281
|
+
if (pages == null || pages.isEmpty()) {
|
|
282
|
+
throw new IOException("Document scanner returned no scanned pages.");
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
File pageFile = cacheAcceptedPage(pages.get(0), scan.acceptedPageFiles.size());
|
|
286
|
+
scan.acceptedPageFiles.add(pageFile);
|
|
287
|
+
showAcceptedPageDialog(call, scan, pageFile);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private File cacheAcceptedPage(Page page, int pageIndex) throws IOException {
|
|
291
|
+
Uri imageUri = page.getImageUri();
|
|
292
|
+
if (imageUri == null) {
|
|
293
|
+
throw new IOException("Missing image URI for scanned page.");
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
byte[] imageBytes = readBytesFromUri(imageUri);
|
|
297
|
+
Context context = getContext();
|
|
298
|
+
if (context == null) {
|
|
299
|
+
throw new IOException("Context unavailable for writing image.");
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
File directory = new File(context.getCacheDir(), "document_scanner_review");
|
|
303
|
+
if (!directory.exists() && !directory.mkdirs()) {
|
|
304
|
+
throw new IOException("Unable to create review cache directory.");
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
String fileName = String.format(Locale.US, "REVIEW_SCAN_%d_%d.jpg", pageIndex, System.currentTimeMillis());
|
|
308
|
+
File outputFile = new File(directory, fileName);
|
|
309
|
+
try (FileOutputStream outputStream = new FileOutputStream(outputFile)) {
|
|
310
|
+
outputStream.write(imageBytes);
|
|
311
|
+
}
|
|
312
|
+
return outputFile;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
private void showAcceptedPageDialog(PluginCall call, PendingScan scan, File pageFile) {
|
|
316
|
+
Activity activity = getActivity();
|
|
317
|
+
if (activity == null) {
|
|
318
|
+
call.reject("Activity reference is unavailable.");
|
|
185
319
|
releasePendingCall(call);
|
|
186
320
|
return;
|
|
187
321
|
}
|
|
188
322
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
323
|
+
activity.runOnUiThread(() -> {
|
|
324
|
+
Bitmap previewBitmap = decodePreviewBitmap(pageFile, 1800);
|
|
325
|
+
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
|
326
|
+
builder.setTitle(buildReviewDialogTitle(scan));
|
|
327
|
+
builder.setMessage(buildReviewDialogMessage(scan));
|
|
328
|
+
builder.setView(buildReviewDialogView(activity, previewBitmap, scan));
|
|
329
|
+
builder.setCancelable(false);
|
|
330
|
+
|
|
331
|
+
boolean canContinue = scan.acceptedPageFiles.size() < scan.requestedPageLimit;
|
|
332
|
+
|
|
333
|
+
if (canContinue) {
|
|
334
|
+
builder.setPositiveButton("Continue", (dialog, which) -> relaunchScanner(call));
|
|
335
|
+
builder.setNeutralButton("Done", (dialog, which) -> resolveAcceptedPages(call));
|
|
336
|
+
} else {
|
|
337
|
+
builder.setPositiveButton("Done", (dialog, which) -> resolveAcceptedPages(call));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
builder.setNegativeButton("Retake", (dialog, which) -> {
|
|
341
|
+
removeLastAcceptedPage(scan);
|
|
342
|
+
relaunchScanner(call);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
AlertDialog dialog = builder.create();
|
|
346
|
+
dialog.setOnDismissListener((dismissedDialog) -> {
|
|
347
|
+
if (previewBitmap != null && !previewBitmap.isRecycled()) {
|
|
348
|
+
previewBitmap.recycle();
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
dialog.show();
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private String buildReviewDialogTitle(PendingScan scan) {
|
|
356
|
+
if (scan.requestedPageLimit > 1) {
|
|
357
|
+
return String.format(Locale.US, "Page %d of %d", scan.acceptedPageFiles.size(), scan.requestedPageLimit);
|
|
358
|
+
}
|
|
359
|
+
return "Review scanned page";
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private String buildReviewDialogMessage(PendingScan scan) {
|
|
363
|
+
if (scan.acceptedPageFiles.size() >= scan.requestedPageLimit) {
|
|
364
|
+
return "The scan limit has been reached. Review the current page and finish when ready.";
|
|
365
|
+
}
|
|
366
|
+
return "Review the current page, then continue scanning or finish the flow.";
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
private View buildReviewDialogView(Context context, Bitmap previewBitmap, PendingScan scan) {
|
|
370
|
+
LinearLayout container = new LinearLayout(context);
|
|
371
|
+
container.setOrientation(LinearLayout.VERTICAL);
|
|
372
|
+
int padding = dpToPx(context, 12);
|
|
373
|
+
container.setPadding(0, padding, 0, 0);
|
|
374
|
+
|
|
375
|
+
ImageView imageView = new ImageView(context);
|
|
376
|
+
imageView.setAdjustViewBounds(true);
|
|
377
|
+
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
|
378
|
+
imageView.setImageBitmap(previewBitmap);
|
|
379
|
+
container.addView(
|
|
380
|
+
imageView,
|
|
381
|
+
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
TextView subtitle = new TextView(context);
|
|
385
|
+
subtitle.setTextColor(0xFF444444);
|
|
386
|
+
subtitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
|
387
|
+
subtitle.setPadding(0, padding, 0, 0);
|
|
388
|
+
subtitle.setText(
|
|
389
|
+
scan.acceptedPageFiles.size() >= scan.requestedPageLimit
|
|
390
|
+
? "Use Done to keep this page, or Retake to scan it again."
|
|
391
|
+
: "Use Continue to scan another page, Done to finish, or Retake to replace this page."
|
|
392
|
+
);
|
|
393
|
+
container.addView(
|
|
394
|
+
subtitle,
|
|
395
|
+
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
return container;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
private Bitmap decodePreviewBitmap(File imageFile, int maxDimension) {
|
|
402
|
+
BitmapFactory.Options boundsOptions = new BitmapFactory.Options();
|
|
403
|
+
boundsOptions.inJustDecodeBounds = true;
|
|
404
|
+
BitmapFactory.decodeFile(imageFile.getAbsolutePath(), boundsOptions);
|
|
405
|
+
|
|
406
|
+
BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
|
|
407
|
+
decodeOptions.inSampleSize = calculateInSampleSize(boundsOptions, maxDimension, maxDimension);
|
|
408
|
+
return BitmapFactory.decodeFile(imageFile.getAbsolutePath(), decodeOptions);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
private int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
|
|
412
|
+
int height = options.outHeight;
|
|
413
|
+
int width = options.outWidth;
|
|
414
|
+
int inSampleSize = 1;
|
|
415
|
+
|
|
416
|
+
while ((height / inSampleSize) > reqHeight || (width / inSampleSize) > reqWidth) {
|
|
417
|
+
inSampleSize *= 2;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return Math.max(1, inSampleSize);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
private int dpToPx(Context context, int dp) {
|
|
424
|
+
return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()));
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
private void removeLastAcceptedPage(PendingScan scan) {
|
|
428
|
+
if (scan.acceptedPageFiles.isEmpty()) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
File file = scan.acceptedPageFiles.remove(scan.acceptedPageFiles.size() - 1);
|
|
433
|
+
if (file.exists()) {
|
|
434
|
+
//noinspection ResultOfMethodCallIgnored
|
|
435
|
+
file.delete();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
private void relaunchScanner(PluginCall call) {
|
|
440
|
+
Activity activity = getActivity();
|
|
441
|
+
if (activity == null) {
|
|
442
|
+
call.reject("Activity reference is unavailable.");
|
|
192
443
|
releasePendingCall(call);
|
|
193
444
|
return;
|
|
194
445
|
}
|
|
195
446
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
447
|
+
startScanner(activity, call);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
private void resolveAcceptedPages(PluginCall call) {
|
|
451
|
+
PendingScan scan = pendingScan;
|
|
452
|
+
if (scan == null) {
|
|
453
|
+
call.reject("No active scan.");
|
|
199
454
|
releasePendingCall(call);
|
|
200
455
|
return;
|
|
201
456
|
}
|
|
202
457
|
|
|
203
458
|
try {
|
|
204
|
-
List<String> scannedImages =
|
|
459
|
+
List<String> scannedImages = processAcceptedPages(scan);
|
|
205
460
|
JSObject response = new JSObject();
|
|
206
461
|
response.put("status", "success");
|
|
207
462
|
response.put("scannedImages", new JSArray(scannedImages));
|
|
@@ -209,6 +464,7 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
209
464
|
} catch (IOException ioException) {
|
|
210
465
|
call.reject("Failed to process scanned images: " + ioException.getLocalizedMessage(), ioException);
|
|
211
466
|
} finally {
|
|
467
|
+
cleanupAcceptedPageFiles(scan);
|
|
212
468
|
releasePendingCall(call);
|
|
213
469
|
}
|
|
214
470
|
}
|
|
@@ -229,6 +485,17 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
229
485
|
return results;
|
|
230
486
|
}
|
|
231
487
|
|
|
488
|
+
private List<String> processAcceptedPages(PendingScan scan) throws IOException {
|
|
489
|
+
List<String> results = new ArrayList<>();
|
|
490
|
+
for (int index = 0; index < scan.acceptedPageFiles.size(); index++) {
|
|
491
|
+
String processed = handleAcceptedPage(scan.acceptedPageFiles.get(index), index, scan);
|
|
492
|
+
if (processed != null) {
|
|
493
|
+
results.add(processed);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return results;
|
|
497
|
+
}
|
|
498
|
+
|
|
232
499
|
private String handlePage(Page page, int pageIndex) throws IOException {
|
|
233
500
|
PendingScan scan = pendingScan;
|
|
234
501
|
if (scan == null) {
|
|
@@ -255,6 +522,26 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
255
522
|
return writeImageFile(imageBytes, pageIndex);
|
|
256
523
|
}
|
|
257
524
|
|
|
525
|
+
private String handleAcceptedPage(File imageFile, int pageIndex, PendingScan scan) throws IOException {
|
|
526
|
+
byte[] imageBytes = readBytesFromFile(imageFile);
|
|
527
|
+
boolean needsAdjustment = scan.brightness != 0f || scan.contrast != 1f;
|
|
528
|
+
boolean needsProcessing = needsAdjustment || scan.quality < 100;
|
|
529
|
+
|
|
530
|
+
if (needsProcessing) {
|
|
531
|
+
imageBytes = processImage(imageBytes, scan.quality, scan.brightness, scan.contrast);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (RESPONSE_TYPE_BASE64.equals(scan.responseType)) {
|
|
535
|
+
return Base64.encodeToString(imageBytes, Base64.NO_WRAP);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (!needsProcessing) {
|
|
539
|
+
return imageFile.getAbsolutePath();
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return writeImageFile(imageBytes, pageIndex);
|
|
543
|
+
}
|
|
544
|
+
|
|
258
545
|
private byte[] readBytesFromUri(Uri uri) throws IOException {
|
|
259
546
|
Context context = getContext();
|
|
260
547
|
if (context == null) {
|
|
@@ -275,6 +562,18 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
275
562
|
}
|
|
276
563
|
}
|
|
277
564
|
|
|
565
|
+
private byte[] readBytesFromFile(File file) throws IOException {
|
|
566
|
+
try (InputStream inputStream = new java.io.FileInputStream(file)) {
|
|
567
|
+
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
568
|
+
byte[] data = new byte[8192];
|
|
569
|
+
int nRead;
|
|
570
|
+
while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
|
|
571
|
+
buffer.write(data, 0, nRead);
|
|
572
|
+
}
|
|
573
|
+
return buffer.toByteArray();
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
278
577
|
private byte[] processImage(byte[] source, int quality, float brightness, float contrast) throws IOException {
|
|
279
578
|
Bitmap bitmap = BitmapFactory.decodeByteArray(source, 0, source.length);
|
|
280
579
|
if (bitmap == null) {
|
|
@@ -358,6 +657,22 @@ public class DocumentScannerPlugin extends Plugin {
|
|
|
358
657
|
}
|
|
359
658
|
}
|
|
360
659
|
|
|
660
|
+
private void cleanupAcceptedPageFiles(PendingScan scan) {
|
|
661
|
+
boolean keepTempFiles =
|
|
662
|
+
RESPONSE_TYPE_FILE_PATH.equals(scan.responseType) && scan.quality >= 100 && scan.brightness == 0f && scan.contrast == 1f;
|
|
663
|
+
if (keepTempFiles) {
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
for (File file : scan.acceptedPageFiles) {
|
|
668
|
+
if (file.exists()) {
|
|
669
|
+
//noinspection ResultOfMethodCallIgnored
|
|
670
|
+
file.delete();
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
scan.acceptedPageFiles.clear();
|
|
674
|
+
}
|
|
675
|
+
|
|
361
676
|
private int clamp(Integer value, int min, int max) {
|
|
362
677
|
if (value == null) {
|
|
363
678
|
return max;
|
package/dist/docs.json
CHANGED
|
@@ -100,7 +100,19 @@
|
|
|
100
100
|
"name": "default"
|
|
101
101
|
}
|
|
102
102
|
],
|
|
103
|
-
"docs": "
|
|
103
|
+
"docs": "Allow the user to adjust the detected crop before saving.\nOn iOS this forces the native VisionKit preview/editor after each capture using\nthe private VisionKit navigation hooks needed to keep the scanner flow alive.\nOn Android this enables ML Kit's crop adjustment flow.",
|
|
104
|
+
"complexTypes": [],
|
|
105
|
+
"type": "boolean | undefined"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "reviewCapturedDocument",
|
|
109
|
+
"tags": [
|
|
110
|
+
{
|
|
111
|
+
"text": "false",
|
|
112
|
+
"name": "default"
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"docs": "When enabled, shows the current scanned page before continuing so the user can\nreview it and explicitly continue or finish the flow.\nOn iOS this forces the native VisionKit preview/editor between captures.\nOn Android this switches to a one-page-at-a-time flow between ML Kit sessions.\nThe review/editor screen is still shown automatically when the scan limit is reached.",
|
|
104
116
|
"complexTypes": [],
|
|
105
117
|
"type": "boolean | undefined"
|
|
106
118
|
},
|
|
@@ -108,11 +120,11 @@
|
|
|
108
120
|
"name": "maxNumDocuments",
|
|
109
121
|
"tags": [
|
|
110
122
|
{
|
|
111
|
-
"text": "
|
|
123
|
+
"text": "20 on Android, 24 on iOS",
|
|
112
124
|
"name": "default"
|
|
113
125
|
}
|
|
114
126
|
],
|
|
115
|
-
"docs": "Maximum number of documents to scan.\nOn
|
|
127
|
+
"docs": "Maximum number of documents to scan.\nOn iOS: VisionKit caps scans at 24 pages (system limit), and the hacked native flow\ncan still stop earlier when you pass a smaller limit.\nOn Android: customizable limit; defaults to 20 for performance (clamped 1-24).\nSet to 1 for single-scan mode where the scanner stops after one document.",
|
|
116
128
|
"complexTypes": [],
|
|
117
129
|
"type": "number | undefined"
|
|
118
130
|
},
|
|
@@ -11,17 +11,29 @@ export interface ScanDocumentOptions {
|
|
|
11
11
|
*/
|
|
12
12
|
croppedImageQuality?: number;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Allow the user to adjust the detected crop before saving.
|
|
15
|
+
* On iOS this forces the native VisionKit preview/editor after each capture using
|
|
16
|
+
* the private VisionKit navigation hooks needed to keep the scanner flow alive.
|
|
17
|
+
* On Android this enables ML Kit's crop adjustment flow.
|
|
16
18
|
* @default true
|
|
17
19
|
*/
|
|
18
20
|
letUserAdjustCrop?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* When enabled, shows the current scanned page before continuing so the user can
|
|
23
|
+
* review it and explicitly continue or finish the flow.
|
|
24
|
+
* On iOS this forces the native VisionKit preview/editor between captures.
|
|
25
|
+
* On Android this switches to a one-page-at-a-time flow between ML Kit sessions.
|
|
26
|
+
* The review/editor screen is still shown automatically when the scan limit is reached.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
reviewCapturedDocument?: boolean;
|
|
19
30
|
/**
|
|
20
31
|
* Maximum number of documents to scan.
|
|
21
|
-
* On
|
|
22
|
-
*
|
|
32
|
+
* On iOS: VisionKit caps scans at 24 pages (system limit), and the hacked native flow
|
|
33
|
+
* can still stop earlier when you pass a smaller limit.
|
|
34
|
+
* On Android: customizable limit; defaults to 20 for performance (clamped 1-24).
|
|
23
35
|
* Set to 1 for single-scan mode where the scanner stops after one document.
|
|
24
|
-
* @default
|
|
36
|
+
* @default 20 on Android, 24 on iOS
|
|
25
37
|
*/
|
|
26
38
|
maxNumDocuments?: number;
|
|
27
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA2EA,MAAM,CAAN,IAAY,WAiBX;AAjBD,WAAY,WAAW;IACrB;;;OAGG;IACH,4BAAa,CAAA;IAEb;;OAEG;IACH,kDAAmC,CAAA;IAEnC;;;OAGG;IACH,4BAAa,CAAA;AACf,CAAC,EAjBW,WAAW,KAAX,WAAW,QAiBtB;AAED,MAAM,CAAN,IAAY,YAUX;AAVD,WAAY,YAAY;IACtB;;OAEG;IACH,iCAAiB,CAAA;IAEjB;;OAEG;IACH,+CAA+B,CAAA;AACjC,CAAC,EAVW,YAAY,KAAZ,YAAY,QAUvB;AAsBD,MAAM,CAAN,IAAY,0BAUX;AAVD,WAAY,0BAA0B;IACpC;;OAEG;IACH,iDAAmB,CAAA;IAEnB;;OAEG;IACH,+CAAiB,CAAA;AACnB,CAAC,EAVW,0BAA0B,KAA1B,0BAA0B,QAUrC","sourcesContent":["export interface DocumentScannerPlugin {\n /**\n * Opens the device camera and starts the document scanning experience.\n */\n scanDocument(options?: ScanDocumentOptions): Promise<ScanDocumentResponse>;\n}\n\nexport interface ScanDocumentOptions {\n /**\n * Android only: quality of the cropped image from 0 - 100 (100 is best).\n * @default 100\n */\n croppedImageQuality?: number;\n\n /**\n * Allow the user to adjust the detected crop before saving.\n * On iOS this forces the native VisionKit preview/editor after each capture using\n * the private VisionKit navigation hooks needed to keep the scanner flow alive.\n * On Android this enables ML Kit's crop adjustment flow.\n * @default true\n */\n letUserAdjustCrop?: boolean;\n\n /**\n * When enabled, shows the current scanned page before continuing so the user can\n * review it and explicitly continue or finish the flow.\n * On iOS this forces the native VisionKit preview/editor between captures.\n * On Android this switches to a one-page-at-a-time flow between ML Kit sessions.\n * The review/editor screen is still shown automatically when the scan limit is reached.\n * @default false\n */\n reviewCapturedDocument?: boolean;\n\n /**\n * Maximum number of documents to scan.\n * On iOS: VisionKit caps scans at 24 pages (system limit), and the hacked native flow\n * can still stop earlier when you pass a smaller limit.\n * On Android: customizable limit; defaults to 20 for performance (clamped 1-24).\n * Set to 1 for single-scan mode where the scanner stops after one document.\n * @default 20 on Android, 24 on iOS\n */\n maxNumDocuments?: number;\n\n /**\n * Format to return scanned images in (file paths or base64 strings).\n * @default ResponseType.ImageFilePath\n */\n responseType?: ResponseType;\n\n /**\n * Brightness adjustment applied to scanned images.\n * Range: -255 to 255 (0 = no change, positive = brighter, negative = darker)\n * Useful for compensating low-light scans.\n * @default 0\n */\n brightness?: number;\n\n /**\n * Contrast adjustment applied to scanned images.\n * Range: 0.0 to 10.0 (1.0 = no change, >1 = more contrast, <1 = less contrast)\n * Helps improve text clarity in poorly lit scans.\n * @default 1.0\n */\n contrast?: number;\n\n /**\n * Android only: scanner mode that controls ML Kit features and filters.\n * - 'base': Basic scan with crop/rotate, no filters or ML cleaning\n * - 'base_with_filter': Adds grayscale and auto-enhancement filters\n * - 'full': All features including ML-based image cleaning (erases stains, fingers, etc.)\n * @default ScannerMode.Full\n */\n scannerMode?: ScannerMode;\n}\n\nexport enum ScannerMode {\n /**\n * Basic document scanning with crop and rotate features only.\n * No filters or ML-based enhancements.\n */\n Base = 'base',\n\n /**\n * Basic features plus automatic filters (grayscale, auto-enhancement).\n */\n BaseWithFilter = 'base_with_filter',\n\n /**\n * Full feature set including ML-based image cleaning.\n * Automatically removes stains, fingers, and other artifacts.\n */\n Full = 'full',\n}\n\nexport enum ResponseType {\n /**\n * Return scanned images as base64-encoded strings.\n */\n Base64 = 'base64',\n\n /**\n * Return scanned images as file paths on disk.\n */\n ImageFilePath = 'imageFilePath',\n}\n\nexport interface ScanDocumentResponse {\n /**\n * Scanned images in the requested response format.\n */\n scannedImages?: string[];\n\n /**\n * Indicates whether the scan completed or was cancelled.\n */\n status?: ScanDocumentResponseStatus;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n\nexport enum ScanDocumentResponseStatus {\n /**\n * The scan completed successfully.\n */\n Success = 'success',\n\n /**\n * The user cancelled the scan flow.\n */\n Cancel = 'cancel',\n}\n"]}
|
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,KAAK,CAAC,YAAY,CAAC,QAA8B;QAC/C,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { DocumentScannerPlugin, ScanDocumentOptions, ScanDocumentResponse } from './definitions';\n\nexport class DocumentScannerWeb extends WebPlugin implements DocumentScannerPlugin {\n async scanDocument(_options?: ScanDocumentOptions): Promise<ScanDocumentResponse> {\n throw this.unimplemented('Document scanning is not supported on the web.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,KAAK,CAAC,YAAY,CAAC,QAA8B;QAC/C,KAAK,QAAQ,CAAC;QACd,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { DocumentScannerPlugin, ScanDocumentOptions, ScanDocumentResponse } from './definitions';\n\nexport class DocumentScannerWeb extends WebPlugin implements DocumentScannerPlugin {\n async scanDocument(_options?: ScanDocumentOptions): Promise<ScanDocumentResponse> {\n void _options;\n throw this.unimplemented('Document scanning is not supported on the web.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ScannerMode;\n(function (ScannerMode) {\n /**\n * Basic document scanning with crop and rotate features only.\n * No filters or ML-based enhancements.\n */\n ScannerMode[\"Base\"] = \"base\";\n /**\n * Basic features plus automatic filters (grayscale, auto-enhancement).\n */\n ScannerMode[\"BaseWithFilter\"] = \"base_with_filter\";\n /**\n * Full feature set including ML-based image cleaning.\n * Automatically removes stains, fingers, and other artifacts.\n */\n ScannerMode[\"Full\"] = \"full\";\n})(ScannerMode || (ScannerMode = {}));\nexport var ResponseType;\n(function (ResponseType) {\n /**\n * Return scanned images as base64-encoded strings.\n */\n ResponseType[\"Base64\"] = \"base64\";\n /**\n * Return scanned images as file paths on disk.\n */\n ResponseType[\"ImageFilePath\"] = \"imageFilePath\";\n})(ResponseType || (ResponseType = {}));\nexport var ScanDocumentResponseStatus;\n(function (ScanDocumentResponseStatus) {\n /**\n * The scan completed successfully.\n */\n ScanDocumentResponseStatus[\"Success\"] = \"success\";\n /**\n * The user cancelled the scan flow.\n */\n ScanDocumentResponseStatus[\"Cancel\"] = \"cancel\";\n})(ScanDocumentResponseStatus || (ScanDocumentResponseStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst DocumentScanner = registerPlugin('DocumentScanner', {\n web: () => import('./web').then((m) => new m.DocumentScannerWeb()),\n});\nexport * from './definitions';\nexport { DocumentScanner };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class DocumentScannerWeb extends WebPlugin {\n async scanDocument(_options) {\n throw this.unimplemented('Document scanning is not supported on the web.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ScannerMode","ResponseType","ScanDocumentResponseStatus","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,WAAW,EAAE;AACxB;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM;AAChC;AACA;AACA;AACA,IAAI,WAAW,CAAC,gBAAgB,CAAC,GAAG,kBAAkB;AACtD;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM;AAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;AAC1BC;AACX,CAAC,UAAU,YAAY,EAAE;AACzB;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACrC;AACA;AACA;AACA,IAAI,YAAY,CAAC,eAAe,CAAC,GAAG,eAAe;AACnD,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;AAC5BC;AACX,CAAC,UAAU,0BAA0B,EAAE;AACvC;AACA;AACA;AACA,IAAI,0BAA0B,CAAC,SAAS,CAAC,GAAG,SAAS;AACrD;AACA;AACA;AACA,IAAI,0BAA0B,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACnD,CAAC,EAAEA,kCAA0B,KAAKA,kCAA0B,GAAG,EAAE,CAAC,CAAC;;ACrC9D,MAAC,eAAe,GAAGC,mBAAc,CAAC,iBAAiB,EAAE;AAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACtE,CAAC;;ACFM,MAAM,kBAAkB,SAASC,cAAS,CAAC;AAClD,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ScannerMode;\n(function (ScannerMode) {\n /**\n * Basic document scanning with crop and rotate features only.\n * No filters or ML-based enhancements.\n */\n ScannerMode[\"Base\"] = \"base\";\n /**\n * Basic features plus automatic filters (grayscale, auto-enhancement).\n */\n ScannerMode[\"BaseWithFilter\"] = \"base_with_filter\";\n /**\n * Full feature set including ML-based image cleaning.\n * Automatically removes stains, fingers, and other artifacts.\n */\n ScannerMode[\"Full\"] = \"full\";\n})(ScannerMode || (ScannerMode = {}));\nexport var ResponseType;\n(function (ResponseType) {\n /**\n * Return scanned images as base64-encoded strings.\n */\n ResponseType[\"Base64\"] = \"base64\";\n /**\n * Return scanned images as file paths on disk.\n */\n ResponseType[\"ImageFilePath\"] = \"imageFilePath\";\n})(ResponseType || (ResponseType = {}));\nexport var ScanDocumentResponseStatus;\n(function (ScanDocumentResponseStatus) {\n /**\n * The scan completed successfully.\n */\n ScanDocumentResponseStatus[\"Success\"] = \"success\";\n /**\n * The user cancelled the scan flow.\n */\n ScanDocumentResponseStatus[\"Cancel\"] = \"cancel\";\n})(ScanDocumentResponseStatus || (ScanDocumentResponseStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst DocumentScanner = registerPlugin('DocumentScanner', {\n web: () => import('./web').then((m) => new m.DocumentScannerWeb()),\n});\nexport * from './definitions';\nexport { DocumentScanner };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class DocumentScannerWeb extends WebPlugin {\n async scanDocument(_options) {\n void _options;\n throw this.unimplemented('Document scanning is not supported on the web.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ScannerMode","ResponseType","ScanDocumentResponseStatus","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,WAAW,EAAE;AACxB;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM;AAChC;AACA;AACA;AACA,IAAI,WAAW,CAAC,gBAAgB,CAAC,GAAG,kBAAkB;AACtD;AACA;AACA;AACA;AACA,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM;AAChC,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;AAC1BC;AACX,CAAC,UAAU,YAAY,EAAE;AACzB;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACrC;AACA;AACA;AACA,IAAI,YAAY,CAAC,eAAe,CAAC,GAAG,eAAe;AACnD,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;AAC5BC;AACX,CAAC,UAAU,0BAA0B,EAAE;AACvC;AACA;AACA;AACA,IAAI,0BAA0B,CAAC,SAAS,CAAC,GAAG,SAAS;AACrD;AACA;AACA;AACA,IAAI,0BAA0B,CAAC,QAAQ,CAAC,GAAG,QAAQ;AACnD,CAAC,EAAEA,kCAA0B,KAAKA,kCAA0B,GAAG,EAAE,CAAC,CAAC;;ACrC9D,MAAC,eAAe,GAAGC,mBAAc,CAAC,iBAAiB,EAAE;AAC1D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACtE,CAAC;;ACFM,MAAM,kBAAkB,SAASC,cAAS,CAAC;AAClD,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;AAEjC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC;AAClF,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
|