@capgo/capacitor-document-scanner 8.4.1 → 8.4.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/README.md CHANGED
@@ -115,16 +115,16 @@ Opens the device camera and starts the document scanning experience.
115
115
 
116
116
  #### ScanDocumentOptions
117
117
 
118
- | Prop | Type | Description | Default |
119
- | ---------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
120
- | **`croppedImageQuality`** | <code>number</code> | Android only: quality of the cropped image from 0 - 100 (100 is best). | <code>100</code> |
121
- | **`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> |
122
- | **`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> |
123
- | **`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> |
124
- | **`responseType`** | <code><a href="#responsetype">ResponseType</a></code> | Format to return scanned images in (file paths or base64 strings). | <code>ResponseType.ImageFilePath</code> |
125
- | **`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> |
126
- | **`contrast`** | <code>number</code> | Contrast adjustment applied to scanned images. Range: 0.0 to 10.0 (1.0 = no change, &gt;1 = more contrast, &lt;1 = less contrast) Helps improve text clarity in poorly lit scans. | <code>1.0</code> |
127
- | **`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> |
118
+ | Prop | Type | Description | Default |
119
+ | ---------------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
120
+ | **`croppedImageQuality`** | <code>number</code> | Android only: quality of the cropped image from 0 - 100 (100 is best). | <code>100</code> |
121
+ | **`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, crop/rotate is always part of the ML Kit UI in every <a href="#scannermode">ScannerMode</a>; use `scannerMode` to control filters and ML cleaning instead. | <code>true</code> |
122
+ | **`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> |
123
+ | **`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> |
124
+ | **`responseType`** | <code><a href="#responsetype">ResponseType</a></code> | Format to return scanned images in (file paths or base64 strings). | <code>ResponseType.ImageFilePath</code> |
125
+ | **`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> |
126
+ | **`contrast`** | <code>number</code> | Contrast adjustment applied to scanned images. Range: 0.0 to 10.0 (1.0 = no change, &gt;1 = more contrast, &lt;1 = less contrast) Helps improve text clarity in poorly lit scans. | <code>1.0</code> |
127
+ | **`scannerMode`** | <code><a href="#scannermode">ScannerMode</a></code> | Android only: scanner mode that controls ML Kit features and filters. Independent of `letUserAdjustCrop` (crop/rotate is available in all modes). - '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> |
128
128
 
129
129
 
130
130
  ### Type Aliases
@@ -156,13 +156,9 @@ public class DocumentScannerPlugin extends Plugin {
156
156
  float contrast = clampFloat(call.getFloat("contrast", 1f), 0f, 10f);
157
157
  String scannerMode = normalizeScannerMode(call.getString("scannerMode"));
158
158
  boolean reviewCapturedDocument = call.getBoolean("reviewCapturedDocument", false);
159
- // Only default letUserAdjustCrop to true if scannerMode is FULL
160
- // This ensures scannerMode takes precedence when explicitly set
161
- boolean defaultAllowCrop = SCANNER_MODE_FULL.equals(scannerMode);
162
- boolean allowAdjustCrop = call.getBoolean("letUserAdjustCrop", defaultAllowCrop);
163
-
164
- // Determine scanner mode based on scannerMode parameter and letUserAdjustCrop
165
- int mlKitScannerMode = determineScannerMode(scannerMode, allowAdjustCrop);
159
+ // Crop/rotate is available in all ML Kit scanner modes (including BASE).
160
+ // Respect scannerMode as-is; do not upgrade to FULL for letUserAdjustCrop.
161
+ int mlKitScannerMode = determineScannerMode(scannerMode);
166
162
 
167
163
  bridge.saveCall(call);
168
164
  pendingScan = new PendingScan(
@@ -712,20 +708,12 @@ public class DocumentScannerPlugin extends Plugin {
712
708
  }
713
709
 
714
710
  /**
715
- * Determines the ML Kit scanner mode based on scannerMode and letUserAdjustCrop settings.
716
- * Note: letUserAdjustCrop requires SCANNER_MODE_FULL, so it takes precedence over scannerMode.
711
+ * Maps the requested scannerMode string to the ML Kit scanner mode constant.
712
+ * Crop and rotate are available in every mode; mode only controls filters / ML cleaning.
717
713
  * @param scannerMode The requested scanner mode (base, base_with_filter, full)
718
- * @param allowAdjustCrop Whether to allow manual crop adjustment
719
714
  * @return The ML Kit scanner mode constant
720
715
  */
721
- private int determineScannerMode(String scannerMode, boolean allowAdjustCrop) {
722
- // If letUserAdjustCrop is true, we must use SCANNER_MODE_FULL
723
- // because only FULL mode supports manual crop adjustment
724
- if (allowAdjustCrop) {
725
- return GmsDocumentScannerOptions.SCANNER_MODE_FULL;
726
- }
727
-
728
- // Otherwise, use the requested scanner mode
716
+ private int determineScannerMode(String scannerMode) {
729
717
  switch (scannerMode) {
730
718
  case SCANNER_MODE_BASE:
731
719
  return GmsDocumentScannerOptions.SCANNER_MODE_BASE;
package/dist/docs.json CHANGED
@@ -100,7 +100,7 @@
100
100
  "name": "default"
101
101
  }
102
102
  ],
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.",
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, crop/rotate is always part of the ML Kit UI in every ScannerMode;\nuse `scannerMode` to control filters and ML cleaning instead.",
104
104
  "complexTypes": [],
105
105
  "type": "boolean | undefined"
106
106
  },
@@ -174,7 +174,7 @@
174
174
  "name": "default"
175
175
  }
176
176
  ],
177
- "docs": "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.)",
177
+ "docs": "Android only: scanner mode that controls ML Kit features and filters.\nIndependent of `letUserAdjustCrop` (crop/rotate is available in all modes).\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.)",
178
178
  "complexTypes": [
179
179
  "ScannerMode"
180
180
  ],
@@ -14,7 +14,8 @@ export interface ScanDocumentOptions {
14
14
  * Allow the user to adjust the detected crop before saving.
15
15
  * On iOS this forces the native VisionKit preview/editor after each capture using
16
16
  * the private VisionKit navigation hooks needed to keep the scanner flow alive.
17
- * On Android this enables ML Kit's crop adjustment flow.
17
+ * On Android, crop/rotate is always part of the ML Kit UI in every ScannerMode;
18
+ * use `scannerMode` to control filters and ML cleaning instead.
18
19
  * @default true
19
20
  */
20
21
  letUserAdjustCrop?: boolean;
@@ -57,6 +58,7 @@ export interface ScanDocumentOptions {
57
58
  contrast?: number;
58
59
  /**
59
60
  * Android only: scanner mode that controls ML Kit features and filters.
61
+ * Independent of `letUserAdjustCrop` (crop/rotate is available in all modes).
60
62
  * - 'base': Basic scan with crop/rotate, no filters or ML cleaning
61
63
  * - 'base_with_filter': Adds grayscale and auto-enhancement filters
62
64
  * - 'full': All features including ML-based image cleaning (erases stains, fingers, etc.)
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA6EA,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, crop/rotate is always part of the ML Kit UI in every ScannerMode;\n * use `scannerMode` to control filters and ML cleaning instead.\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 * Independent of `letUserAdjustCrop` (crop/rotate is available in all modes).\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"]}
@@ -3,7 +3,7 @@ import Foundation
3
3
 
4
4
  @objc(DocumentScannerPlugin)
5
5
  public class DocumentScannerPlugin: CAPPlugin, CAPBridgedPlugin {
6
- private let pluginVersion: String = "8.4.1"
6
+ private let pluginVersion: String = "8.4.2"
7
7
  public let identifier = "DocumentScannerPlugin"
8
8
  public let jsName = "DocumentScanner"
9
9
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-document-scanner",
3
- "version": "8.4.1",
3
+ "version": "8.4.2",
4
4
  "description": "Capacitor plugin to scan document iOS and Android",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",