@hoshomoh/react-native-document-scanner 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DocumentScanner.podspec +22 -0
- package/LICENSE +20 -0
- package/README.md +384 -0
- package/android/build.gradle +72 -0
- package/android/gradle.properties +17 -0
- package/android/local.properties +8 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/com/documentscanner/DocumentScannerModule.kt +217 -0
- package/android/src/main/java/com/documentscanner/DocumentScannerPackage.kt +39 -0
- package/android/src/main/java/com/documentscanner/ImageProcessor.kt +325 -0
- package/android/src/main/java/com/documentscanner/Logger.kt +36 -0
- package/android/src/main/java/com/documentscanner/OCRConfiguration.kt +56 -0
- package/android/src/main/java/com/documentscanner/Options.kt +109 -0
- package/android/src/main/java/com/documentscanner/ScannerError.kt +18 -0
- package/android/src/main/java/com/documentscanner/TextRecognizer.kt +56 -0
- package/android/src/main/java/com/documentscanner/TextRecognizerV1.kt +68 -0
- package/android/src/main/java/com/documentscanner/TextRecognizerV2.kt +244 -0
- package/ios/DocumentScanner.h +5 -0
- package/ios/DocumentScanner.mm +113 -0
- package/ios/DocumentScannerManager.swift +148 -0
- package/ios/Errors.swift +33 -0
- package/ios/ImageProcessor.swift +78 -0
- package/ios/ImageUtil.swift +279 -0
- package/ios/Logger.swift +43 -0
- package/ios/OCRConfiguration.swift +60 -0
- package/ios/Options.swift +109 -0
- package/ios/ResponseUtil.swift +25 -0
- package/ios/ScanModels.swift +84 -0
- package/ios/TextRecognizer.swift +134 -0
- package/ios/TextRecognizerV1.swift +56 -0
- package/ios/TextRecognizerV2.swift +169 -0
- package/lib/module/NativeDocumentScanner.js +51 -0
- package/lib/module/NativeDocumentScanner.js.map +1 -0
- package/lib/module/index.js +40 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/textReconstructor.js +147 -0
- package/lib/module/textReconstructor.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeDocumentScanner.d.ts +191 -0
- package/lib/typescript/src/NativeDocumentScanner.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +34 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/textReconstructor.d.ts +60 -0
- package/lib/typescript/src/textReconstructor.d.ts.map +1 -0
- package/package.json +137 -0
- package/src/NativeDocumentScanner.ts +205 -0
- package/src/index.ts +61 -0
- package/src/textReconstructor.ts +212 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Internal — not part of the public API.
|
|
4
|
+
|
|
5
|
+
const MODE_FACTOR = {
|
|
6
|
+
paragraphs: 0.5,
|
|
7
|
+
clustered: 0.4
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Reconstructs a visually-aligned plain-text document from a `ScanResult`.
|
|
11
|
+
*
|
|
12
|
+
* Automatically selects the right strategy based on the OCR engine recorded
|
|
13
|
+
* in `metadata` — no manual mode selection needed:
|
|
14
|
+
*
|
|
15
|
+
* | Engine | Strategy |
|
|
16
|
+
* |---------------------------------|-----------------------------------------|
|
|
17
|
+
* | V2 · MLKit or VNRecognizeText | Returns `text` directly — the native |
|
|
18
|
+
* | | clustering already produced column- |
|
|
19
|
+
* | | aligned output. |
|
|
20
|
+
* | iOS 26+ RecognizeDocumentsReq. | Spatially reconstructs from paragraph- |
|
|
21
|
+
* | | level blocks. |
|
|
22
|
+
* | V1 · either platform | Spatially reconstructs from line-level |
|
|
23
|
+
* | | blocks. |
|
|
24
|
+
*
|
|
25
|
+
* @param scanResult A `ScanResult` (or any object with `text`, `blocks`, `metadata`).
|
|
26
|
+
* @param options Optional output tuning.
|
|
27
|
+
* @returns A plain-text string with column-aligned rows.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const results = await scanDocuments({ includeText: true });
|
|
31
|
+
* const text = reconstructText(results[0]);
|
|
32
|
+
*/
|
|
33
|
+
export function reconstructText(scanResult, options = {}) {
|
|
34
|
+
const {
|
|
35
|
+
metadata,
|
|
36
|
+
blocks = [],
|
|
37
|
+
text = ''
|
|
38
|
+
} = scanResult;
|
|
39
|
+
|
|
40
|
+
// V2 via VNRecognizeTextRequest or MLKit: the native adaptive clustering
|
|
41
|
+
// already produced column-aligned text — return it directly.
|
|
42
|
+
// If text is absent (caller omitted it), fall back to block reconstruction
|
|
43
|
+
// using the line-level cluster blocks rather than returning empty.
|
|
44
|
+
if (metadata?.textVersion === 2 && metadata.ocrEngine !== 'RecognizeDocumentsRequest') {
|
|
45
|
+
if (text) {
|
|
46
|
+
return text.trimEnd();
|
|
47
|
+
}
|
|
48
|
+
return reconstructFromBlocks(blocks, 'clustered', options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// iOS 26+ RecognizeDocumentsRequest returns paragraph-level blocks;
|
|
52
|
+
// V1 on any platform returns line-level blocks.
|
|
53
|
+
// Both paths use the spatial block reconstruction algorithm.
|
|
54
|
+
const mode = metadata?.ocrEngine === 'RecognizeDocumentsRequest' ? 'paragraphs' : 'clustered';
|
|
55
|
+
return reconstructFromBlocks(blocks, mode, options);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ─── Internal block reconstruction algorithm ─────────────────────────────────
|
|
59
|
+
|
|
60
|
+
function reconstructFromBlocks(blocks, mode, options) {
|
|
61
|
+
const {
|
|
62
|
+
lineWidth = 56,
|
|
63
|
+
minConfidence
|
|
64
|
+
} = options;
|
|
65
|
+
const rowGroupingFactor = options.rowGroupingFactor ?? MODE_FACTOR[mode];
|
|
66
|
+
|
|
67
|
+
// Step 1: Filter by confidence when requested.
|
|
68
|
+
const filtered = minConfidence !== undefined ? blocks.filter(b => b.confidence === undefined || b.confidence >= minConfidence) : blocks;
|
|
69
|
+
if (filtered.length === 0) {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Step 2: Compute the median block height (= reference line height).
|
|
74
|
+
const heights = filtered.map(b => b.frame.height).sort((a, b) => a - b);
|
|
75
|
+
const hMid = Math.floor(heights.length / 2);
|
|
76
|
+
const typicalHeight = heights.length % 2 === 0 ? (heights[hMid - 1] + heights[hMid]) / 2 : heights[hMid];
|
|
77
|
+
const threshold = rowGroupingFactor * (typicalHeight > 0 ? typicalHeight : 0.02);
|
|
78
|
+
|
|
79
|
+
// Step 3: Sort all blocks by midY ascending (top of page first).
|
|
80
|
+
const sorted = [...filtered].sort((a, b) => {
|
|
81
|
+
const midA = a.frame.y + a.frame.height / 2;
|
|
82
|
+
const midB = b.frame.y + b.frame.height / 2;
|
|
83
|
+
return midA - midB;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Step 4: Greedy row grouping by midY proximity.
|
|
87
|
+
// Each row tracks a running median centerY so that adding blocks to one
|
|
88
|
+
// side of a long line doesn't pull the reference point away from the others.
|
|
89
|
+
|
|
90
|
+
function computeMedian(values) {
|
|
91
|
+
const s = [...values].sort((a, b) => a - b);
|
|
92
|
+
const m = Math.floor(s.length / 2);
|
|
93
|
+
return s.length % 2 === 0 ? (s[m - 1] + s[m]) / 2 : s[m];
|
|
94
|
+
}
|
|
95
|
+
const rows = [];
|
|
96
|
+
for (const block of sorted) {
|
|
97
|
+
const blockMidY = block.frame.y + block.frame.height / 2;
|
|
98
|
+
let bestRow = null;
|
|
99
|
+
let bestDist = Infinity;
|
|
100
|
+
for (const row of rows) {
|
|
101
|
+
const dist = Math.abs(row.medianMidY - blockMidY);
|
|
102
|
+
if (dist < threshold && dist < bestDist) {
|
|
103
|
+
bestDist = dist;
|
|
104
|
+
bestRow = row;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (bestRow !== null) {
|
|
108
|
+
bestRow.blocks.push(block);
|
|
109
|
+
bestRow.midYs.push(blockMidY);
|
|
110
|
+
bestRow.medianMidY = computeMedian(bestRow.midYs);
|
|
111
|
+
} else {
|
|
112
|
+
rows.push({
|
|
113
|
+
blocks: [block],
|
|
114
|
+
midYs: [blockMidY],
|
|
115
|
+
medianMidY: blockMidY
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Step 5: Sort rows top-to-bottom.
|
|
121
|
+
rows.sort((a, b) => a.medianMidY - b.medianMidY);
|
|
122
|
+
|
|
123
|
+
// Step 6: Render each row into a fixed-width character buffer.
|
|
124
|
+
const lines = [];
|
|
125
|
+
for (const row of rows) {
|
|
126
|
+
// Sort blocks left-to-right within the row.
|
|
127
|
+
const rowBlocks = [...row.blocks].sort((a, b) => a.frame.x - b.frame.x);
|
|
128
|
+
const buf = new Array(lineWidth).fill(' ');
|
|
129
|
+
let cursor = 0;
|
|
130
|
+
for (const block of rowBlocks) {
|
|
131
|
+
// Map normalized X to a character column, but never retreat behind cursor.
|
|
132
|
+
const col = Math.max(Math.round(block.frame.x * lineWidth), cursor);
|
|
133
|
+
for (let i = 0; i < block.text.length; i++) {
|
|
134
|
+
const pos = col + i;
|
|
135
|
+
if (pos < lineWidth) {
|
|
136
|
+
buf[pos] = block.text[i];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Advance cursor past this block + a minimum single-space gap.
|
|
141
|
+
cursor = col + block.text.length + 1;
|
|
142
|
+
}
|
|
143
|
+
lines.push(buf.join('').trimEnd());
|
|
144
|
+
}
|
|
145
|
+
return lines.join('\n');
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=textReconstructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MODE_FACTOR","paragraphs","clustered","reconstructText","scanResult","options","metadata","blocks","text","textVersion","ocrEngine","trimEnd","reconstructFromBlocks","mode","lineWidth","minConfidence","rowGroupingFactor","filtered","undefined","filter","b","confidence","length","heights","map","frame","height","sort","a","hMid","Math","floor","typicalHeight","threshold","sorted","midA","y","midB","computeMedian","values","s","m","rows","block","blockMidY","bestRow","bestDist","Infinity","row","dist","abs","medianMidY","push","midYs","lines","rowBlocks","x","buf","Array","fill","cursor","col","max","round","i","pos","join"],"sourceRoot":"../../src","sources":["textReconstructor.ts"],"mappings":";;AAEA;;AAGA,MAAMA,WAA4C,GAAG;EACnDC,UAAU,EAAE,GAAG;EACfC,SAAS,EAAE;AACb,CAAC;AAgCD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,UAA4E,EAC5EC,OAA2B,GAAG,CAAC,CAAC,EACxB;EACR,MAAM;IAAEC,QAAQ;IAAEC,MAAM,GAAG,EAAE;IAAEC,IAAI,GAAG;EAAG,CAAC,GAAGJ,UAAU;;EAEvD;EACA;EACA;EACA;EACA,IACEE,QAAQ,EAAEG,WAAW,KAAK,CAAC,IAC3BH,QAAQ,CAACI,SAAS,KAAK,2BAA2B,EAClD;IACA,IAAIF,IAAI,EAAE;MACR,OAAOA,IAAI,CAACG,OAAO,CAAC,CAAC;IACvB;IACA,OAAOC,qBAAqB,CAACL,MAAM,EAAE,WAAW,EAAEF,OAAO,CAAC;EAC5D;;EAEA;EACA;EACA;EACA,MAAMQ,IAAqB,GACzBP,QAAQ,EAAEI,SAAS,KAAK,2BAA2B,GAC/C,YAAY,GACZ,WAAW;EAEjB,OAAOE,qBAAqB,CAACL,MAAM,EAAEM,IAAI,EAAER,OAAO,CAAC;AACrD;;AAEA;;AAEA,SAASO,qBAAqBA,CAC5BL,MAAmB,EACnBM,IAAqB,EACrBR,OAA2B,EACnB;EACR,MAAM;IAAES,SAAS,GAAG,EAAE;IAAEC;EAAc,CAAC,GAAGV,OAAO;EACjD,MAAMW,iBAAiB,GAAGX,OAAO,CAACW,iBAAiB,IAAIhB,WAAW,CAACa,IAAI,CAAC;;EAExE;EACA,MAAMI,QAAQ,GACZF,aAAa,KAAKG,SAAS,GACvBX,MAAM,CAACY,MAAM,CACVC,CAAC,IA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C,CAAC,CAAC;EACpC;EAEA,OAAO2C,KAAK,CAACY,IAAI,CAAC,IAAI,CAAC;AACzB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { type TurboModule } from 'react-native';
|
|
2
|
+
/**
|
|
3
|
+
* Type union of all available filter values.
|
|
4
|
+
* Required for React Native Codegen compatibility.
|
|
5
|
+
*/
|
|
6
|
+
export type FilterType = 'color' | 'grayscale' | 'monochrome' | 'denoise' | 'sharpen' | 'ocrOptimized';
|
|
7
|
+
/**
|
|
8
|
+
* Type union of all available format values.
|
|
9
|
+
* Required for React Native Codegen compatibility.
|
|
10
|
+
*/
|
|
11
|
+
export type FormatType = 'jpg' | 'png';
|
|
12
|
+
/**
|
|
13
|
+
* Represents a discrete block of text recognized by the OCR engine.
|
|
14
|
+
* Useful for mapping text to specific regions on the image.
|
|
15
|
+
*/
|
|
16
|
+
export interface TextBlock {
|
|
17
|
+
/** The text content within the block. */
|
|
18
|
+
text: string;
|
|
19
|
+
/**
|
|
20
|
+
* The normalized bounding box of the text.
|
|
21
|
+
* Coordinates (x, y, width, height) are in the range [0, 1].
|
|
22
|
+
* (0,0) is usually top-left.
|
|
23
|
+
*/
|
|
24
|
+
frame: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* OCR confidence score (0.0 to 1.0).
|
|
32
|
+
* Higher values indicate more reliable recognition.
|
|
33
|
+
* Useful for LLM post-processing to weight or filter results.
|
|
34
|
+
*/
|
|
35
|
+
confidence?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Describes the OCR engine and configuration used to produce a ScanResult.
|
|
39
|
+
* Pass the parent `ScanResult` directly to `reconstructText` — it reads
|
|
40
|
+
* `metadata` internally to select the right reconstruction strategy.
|
|
41
|
+
*/
|
|
42
|
+
export interface ScanMetadata {
|
|
43
|
+
/** Platform that generated this result. */
|
|
44
|
+
platform: 'ios' | 'android';
|
|
45
|
+
/** OCR engine version that was requested (1 = Raw, 2 = Heuristic). */
|
|
46
|
+
textVersion: 1 | 2;
|
|
47
|
+
/** Image filter applied before OCR. */
|
|
48
|
+
filter: FilterType;
|
|
49
|
+
/**
|
|
50
|
+
* The specific OCR engine used:
|
|
51
|
+
* - `"RecognizeDocumentsRequest"`: iOS 26+ native document understanding (V2).
|
|
52
|
+
* - `"VNRecognizeTextRequest"`: Apple Vision text request (V1 or V2 on iOS < 26).
|
|
53
|
+
* - `"MLKit"`: Android ML Kit Text Recognition (V1 or V2).
|
|
54
|
+
* - `"none"`: OCR was not performed (`includeText` was false).
|
|
55
|
+
*/
|
|
56
|
+
ocrEngine: 'RecognizeDocumentsRequest' | 'VNRecognizeTextRequest' | 'MLKit' | 'none';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The result of a single scanned page.
|
|
60
|
+
*/
|
|
61
|
+
export interface ScanResult {
|
|
62
|
+
/** The local file URI of the scanned image (e.g., file:///...). */
|
|
63
|
+
uri?: string;
|
|
64
|
+
/** The Base64 encoded string of the image (if requested). */
|
|
65
|
+
base64?: string;
|
|
66
|
+
/** The full text extracted from the page, preserving layout. */
|
|
67
|
+
text?: string;
|
|
68
|
+
/** Array of structured text blocks with metadata. */
|
|
69
|
+
blocks?: TextBlock[];
|
|
70
|
+
/** Configuration and engine metadata for this result. */
|
|
71
|
+
metadata?: ScanMetadata;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Base configuration options shared by scan and process operations.
|
|
75
|
+
*/
|
|
76
|
+
export interface BaseOptions {
|
|
77
|
+
/** Compression quality (0.0 to 1.0) for JPEG. Default is 1.0. */
|
|
78
|
+
quality?: number;
|
|
79
|
+
/** Output image format. Use the `Format` constant for type-safe values. Default is 'jpg'. */
|
|
80
|
+
format?: FormatType;
|
|
81
|
+
/**
|
|
82
|
+
* Post-processing filter to apply.
|
|
83
|
+
* - `color`: No filter (default).
|
|
84
|
+
* - `grayscale`: Desaturates the image.
|
|
85
|
+
* - `monochrome`: High-contrast black & white (best for OCR).
|
|
86
|
+
* - `denoise`: Reduces image noise (improves OCR on noisy photos).
|
|
87
|
+
* - `sharpen`: Enhances edge clarity (improves OCR on blurry text).
|
|
88
|
+
* - `ocrOptimized`: Full pipeline: denoise → sharpen → monochrome (best accuracy).
|
|
89
|
+
*/
|
|
90
|
+
filter?: FilterType;
|
|
91
|
+
/** Whether to include the base64 string in the result. Default is false. */
|
|
92
|
+
includeBase64?: boolean;
|
|
93
|
+
/** Whether to perform OCR and include text/blocks. */
|
|
94
|
+
includeText?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Version of the text recognizer to use.
|
|
97
|
+
* - 1: Raw output (standard Vision/ML Kit behavior).
|
|
98
|
+
* - 2: Heuristic enhanced (Adaptive Clustering for layout preservation). Default.
|
|
99
|
+
*/
|
|
100
|
+
textVersion?: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Configuration options for the Document Scanner.
|
|
104
|
+
* Fields are listed explicitly (not via extends) for React Native Codegen compatibility —
|
|
105
|
+
* Codegen only generates struct fields declared directly on the interface.
|
|
106
|
+
*/
|
|
107
|
+
export interface ScanOptions {
|
|
108
|
+
/** Maximum number of pages to scan. Default is unlimited (or hardware limit). */
|
|
109
|
+
maxPageCount?: number;
|
|
110
|
+
/** Compression quality (0.0 to 1.0) for JPEG. Default is 1.0. */
|
|
111
|
+
quality?: number;
|
|
112
|
+
/** Output image format. Use the `Format` constant for type-safe values. Default is 'jpg'. */
|
|
113
|
+
format?: FormatType;
|
|
114
|
+
/**
|
|
115
|
+
* Post-processing filter to apply.
|
|
116
|
+
* - `color`: No filter (default).
|
|
117
|
+
* - `grayscale`: Desaturates the image.
|
|
118
|
+
* - `monochrome`: High-contrast black & white (best for OCR).
|
|
119
|
+
* - `denoise`: Reduces image noise (improves OCR on noisy photos).
|
|
120
|
+
* - `sharpen`: Enhances edge clarity (improves OCR on blurry text).
|
|
121
|
+
* - `ocrOptimized`: Full pipeline: denoise → sharpen → monochrome (best accuracy).
|
|
122
|
+
*/
|
|
123
|
+
filter?: FilterType;
|
|
124
|
+
/** Whether to include the base64 string in the result. Default is false. */
|
|
125
|
+
includeBase64?: boolean;
|
|
126
|
+
/** Whether to perform OCR and include text/blocks. */
|
|
127
|
+
includeText?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Version of the text recognizer to use.
|
|
130
|
+
* - 1: Raw output (standard Vision/ML Kit behavior).
|
|
131
|
+
* - 2: Heuristic enhanced (Adaptive Clustering for layout preservation). Default.
|
|
132
|
+
*/
|
|
133
|
+
textVersion?: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Configuration options for processing existing images.
|
|
137
|
+
* Fields are listed explicitly (not via extends) for React Native Codegen compatibility —
|
|
138
|
+
* Codegen only generates struct fields declared directly on the interface.
|
|
139
|
+
*/
|
|
140
|
+
export interface ProcessOptions {
|
|
141
|
+
/**
|
|
142
|
+
* Array of image sources. Each can be:
|
|
143
|
+
* - A file URI (e.g., "file:///path/to/image.jpg")
|
|
144
|
+
* - A base64-encoded string (with or without data URI prefix)
|
|
145
|
+
*/
|
|
146
|
+
images: string[];
|
|
147
|
+
/** Compression quality (0.0 to 1.0) for JPEG. Default is 1.0. */
|
|
148
|
+
quality?: number;
|
|
149
|
+
/** Output image format. Use the `Format` constant for type-safe values. Default is 'jpg'. */
|
|
150
|
+
format?: FormatType;
|
|
151
|
+
/**
|
|
152
|
+
* Post-processing filter to apply.
|
|
153
|
+
* - `color`: No filter (default).
|
|
154
|
+
* - `grayscale`: Desaturates the image.
|
|
155
|
+
* - `monochrome`: High-contrast black & white (best for OCR).
|
|
156
|
+
* - `denoise`: Reduces image noise (improves OCR on noisy photos).
|
|
157
|
+
* - `sharpen`: Enhances edge clarity (improves OCR on blurry text).
|
|
158
|
+
* - `ocrOptimized`: Full pipeline: denoise → sharpen → monochrome (best accuracy).
|
|
159
|
+
*/
|
|
160
|
+
filter?: FilterType;
|
|
161
|
+
/** Whether to include the base64 string in the result. Default is false. */
|
|
162
|
+
includeBase64?: boolean;
|
|
163
|
+
/** Whether to perform OCR and include text/blocks. */
|
|
164
|
+
includeText?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Version of the text recognizer to use.
|
|
167
|
+
* - 1: Raw output (standard Vision/ML Kit behavior).
|
|
168
|
+
* - 2: Heuristic enhanced (Adaptive Clustering for layout preservation). Default.
|
|
169
|
+
*/
|
|
170
|
+
textVersion?: number;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* TurboModule Specification for the Document Scanner.
|
|
174
|
+
*/
|
|
175
|
+
export interface Spec extends TurboModule {
|
|
176
|
+
/**
|
|
177
|
+
* Opens the native document scanner UI.
|
|
178
|
+
* @param options Configuration options.
|
|
179
|
+
* @returns A Promise resolving to an array of ScanResults.
|
|
180
|
+
*/
|
|
181
|
+
scanDocuments(options?: ScanOptions): Promise<ScanResult[]>;
|
|
182
|
+
/**
|
|
183
|
+
* Processes existing images without opening the camera UI.
|
|
184
|
+
* @param options Configuration including image sources.
|
|
185
|
+
* @returns A Promise resolving to an array of ScanResults.
|
|
186
|
+
*/
|
|
187
|
+
processDocuments(options: ProcessOptions): Promise<ScanResult[]>;
|
|
188
|
+
}
|
|
189
|
+
declare const _default: Spec;
|
|
190
|
+
export default _default;
|
|
191
|
+
//# sourceMappingURL=NativeDocumentScanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeDocumentScanner.d.ts","sourceRoot":"","sources":["../../../src/NativeDocumentScanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB,OAAO,GACP,WAAW,GACX,YAAY,GACZ,SAAS,GACT,SAAS,GACT,cAAc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anMetadata, type TextBlock, type ProcessOptions, type FilterType, type FormatType } from './NativeDocumentScanner';
|
|
2
|
+
/**
|
|
3
|
+
* Available image filters.
|
|
4
|
+
* Use these constants instead of raw strings for type safety.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Filter: {
|
|
7
|
+
/** No filter (original colors) */
|
|
8
|
+
readonly COLOR: "color";
|
|
9
|
+
/** Desaturated image */
|
|
10
|
+
readonly GRAYSCALE: "grayscale";
|
|
11
|
+
/** High-contrast black & white */
|
|
12
|
+
readonly MONOCHROME: "monochrome";
|
|
13
|
+
/** Noise reduction (for noisy photos) */
|
|
14
|
+
readonly DENOISE: "denoise";
|
|
15
|
+
/** Edge enhancement (for blurry text) */
|
|
16
|
+
readonly SHARPEN: "sharpen";
|
|
17
|
+
/** Full OCR pipeline: denoise → sharpen → monochrome */
|
|
18
|
+
readonly OCR_OPTIMIZED: "ocrOptimized";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Available output formats.
|
|
22
|
+
*/
|
|
23
|
+
export declare const Format: {
|
|
24
|
+
/** JPEG format (smaller file size) */
|
|
25
|
+
readonly JPG: "jpg";
|
|
26
|
+
/** PNG format (lossless) */
|
|
27
|
+
readonly PNG: "png";
|
|
28
|
+
};
|
|
29
|
+
export declare function scanDocuments(options?: ScanOptions): Promise<ScanResult[]>;
|
|
30
|
+
export declare function processDocuments(options: ProcessOptions): Promise<ScanResult[]>;
|
|
31
|
+
export { reconstructText } from './textReconstructor';
|
|
32
|
+
export type { ReconstructOptions } from './textReconstructor';
|
|
33
|
+
export type { ScanOptions, ScanResult, ScanMetadata, TextBlock, ProcessOptions, FilterType, FormatType, };
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAwB,EACtB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB,kCAAkC;;IAElC,wBAAwB;;IAExB,kCAAkC;;IAElC,yCAAyC;;IAEzC,yCAAyC;;IAEzC,wDAAwD;;CAEhD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,MAAM;IACjB,sCAAsC;;IAEtC,4BAA4B;;CAEpB,CAAC;AAEX,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAE1E;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,EAAE,CAAC,CAEvB;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,YAAY,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACV,UAAU,GACX,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { TextBlock, ScanMetadata } from './NativeDocumentScanner';
|
|
2
|
+
export interface ReconstructOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Width of the output in characters.
|
|
5
|
+
* Default: 56. Use 48 for narrow thermal receipts, 64+ for wide documents.
|
|
6
|
+
*/
|
|
7
|
+
lineWidth?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Discard blocks whose `confidence` is below this value before
|
|
10
|
+
* reconstruction. Useful when scan quality is poor and low-confidence
|
|
11
|
+
* blocks produce garbage characters that disrupt the output.
|
|
12
|
+
*
|
|
13
|
+
* Only applies to V1 on any platform. Has no effect on V2 paths (native
|
|
14
|
+
* text is returned directly) or on iOS 26+ RecognizeDocumentsRequest
|
|
15
|
+
* (paragraph confidence is not exposed by the API — blocks always pass).
|
|
16
|
+
*
|
|
17
|
+
* Suggested values: `0.3` (aggressive), `0.5` (moderate).
|
|
18
|
+
* Default: `undefined` (no filtering).
|
|
19
|
+
*/
|
|
20
|
+
minConfidence?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Fine-tune the Y-proximity threshold directly. The threshold is
|
|
23
|
+
* `rowGroupingFactor × medianLineHeight`. Increase if blocks on the same
|
|
24
|
+
* visual line are being split into separate rows. Decrease if adjacent
|
|
25
|
+
* lines are being merged.
|
|
26
|
+
*
|
|
27
|
+
* Only applies to the block-based reconstruction path (V1 and iOS 26+).
|
|
28
|
+
*/
|
|
29
|
+
rowGroupingFactor?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reconstructs a visually-aligned plain-text document from a `ScanResult`.
|
|
33
|
+
*
|
|
34
|
+
* Automatically selects the right strategy based on the OCR engine recorded
|
|
35
|
+
* in `metadata` — no manual mode selection needed:
|
|
36
|
+
*
|
|
37
|
+
* | Engine | Strategy |
|
|
38
|
+
* |---------------------------------|-----------------------------------------|
|
|
39
|
+
* | V2 · MLKit or VNRecognizeText | Returns `text` directly — the native |
|
|
40
|
+
* | | clustering already produced column- |
|
|
41
|
+
* | | aligned output. |
|
|
42
|
+
* | iOS 26+ RecognizeDocumentsReq. | Spatially reconstructs from paragraph- |
|
|
43
|
+
* | | level blocks. |
|
|
44
|
+
* | V1 · either platform | Spatially reconstructs from line-level |
|
|
45
|
+
* | | blocks. |
|
|
46
|
+
*
|
|
47
|
+
* @param scanResult A `ScanResult` (or any object with `text`, `blocks`, `metadata`).
|
|
48
|
+
* @param options Optional output tuning.
|
|
49
|
+
* @returns A plain-text string with column-aligned rows.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const results = await scanDocuments({ includeText: true });
|
|
53
|
+
* const text = reconstructText(results[0]);
|
|
54
|
+
*/
|
|
55
|
+
export declare function reconstructText(scanResult: {
|
|
56
|
+
text?: string;
|
|
57
|
+
blocks?: TextBlock[];
|
|
58
|
+
metadata?: ScanMetadata;
|
|
59
|
+
}, options?: ReconstructOptions): string;
|
|
60
|
+
//# sourceMappingURL=textReconstructor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textReconstructor.d.ts","sourceRoot":"","sources":["../../../src/textReconstructor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAUvE,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,YAAY,CAAA;CAAE,EAC5E,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CA0BR"}
|
package/package.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hoshomoh/react-native-document-scanner",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "A React Native library for scanning documents.",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.ts",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"ios",
|
|
19
|
+
"android",
|
|
20
|
+
"*.podspec",
|
|
21
|
+
"!ios/build",
|
|
22
|
+
"!android/build",
|
|
23
|
+
"!**/__tests__",
|
|
24
|
+
"!**/__fixtures__",
|
|
25
|
+
"!**/__mocks__",
|
|
26
|
+
"!**/.*"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"example": "yarn workspace react-native-document-scanner-example",
|
|
30
|
+
"clean": "del-cli example/ios/build lib",
|
|
31
|
+
"prepare": "lefthook install",
|
|
32
|
+
"build": "bob build",
|
|
33
|
+
"typecheck": "tsc",
|
|
34
|
+
"prepack": "bob build",
|
|
35
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
36
|
+
"lint:fix": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
|
37
|
+
"lint:staged": "eslint --max-warnings=0",
|
|
38
|
+
"prettier": "prettier \"**/*.{js,ts,tsx,md}\" --check",
|
|
39
|
+
"prettier:fix": "prettier \"**/*.{js,ts,tsx,md}\" --write",
|
|
40
|
+
"prettier:staged": "prettier --write",
|
|
41
|
+
"test": "jest"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"react-native",
|
|
45
|
+
"ios"
|
|
46
|
+
],
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/hoshomoh/react-native-document-scanner.git"
|
|
50
|
+
},
|
|
51
|
+
"author": "Oshomo Oforomeh <hello@oshomo.oforomeh.com> (https://github.com/hoshomoh)",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/hoshomoh/react-native-document-scanner/issues"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/hoshomoh/react-native-document-scanner#readme",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public",
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/config-conventional": "^20.2.0",
|
|
63
|
+
"@eslint/compat": "^2.0.0",
|
|
64
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
65
|
+
"@eslint/js": "^9.39.2",
|
|
66
|
+
"@react-native/babel-preset": "0.83.1",
|
|
67
|
+
"@react-native/eslint-config": "0.83.1",
|
|
68
|
+
"@types/jest": "^30.0.0",
|
|
69
|
+
"@types/react": "^19.2.7",
|
|
70
|
+
"commitlint": "^20.2.0",
|
|
71
|
+
"del-cli": "^7.0.0",
|
|
72
|
+
"eslint": "^9.39.2",
|
|
73
|
+
"eslint-config-prettier": "^10.1.8",
|
|
74
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
75
|
+
"jest": "^30.2.0",
|
|
76
|
+
"lefthook": "^2.0.13",
|
|
77
|
+
"prettier": "^3.7.4",
|
|
78
|
+
"react": "19.2.3",
|
|
79
|
+
"react-native": "0.83.1",
|
|
80
|
+
"react-native-builder-bob": "^0.40.17",
|
|
81
|
+
"turbo": "^2.7.2",
|
|
82
|
+
"typescript": "^5.9.3"
|
|
83
|
+
},
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"react": "*",
|
|
86
|
+
"react-native": "*"
|
|
87
|
+
},
|
|
88
|
+
"workspaces": [
|
|
89
|
+
"example"
|
|
90
|
+
],
|
|
91
|
+
"packageManager": "yarn@4.11.0",
|
|
92
|
+
"react-native-builder-bob": {
|
|
93
|
+
"source": "src",
|
|
94
|
+
"output": "lib",
|
|
95
|
+
"targets": [
|
|
96
|
+
[
|
|
97
|
+
"module",
|
|
98
|
+
{
|
|
99
|
+
"esm": true
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
"typescript",
|
|
104
|
+
{
|
|
105
|
+
"project": "tsconfig.build.json"
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
"codegenConfig": {
|
|
111
|
+
"name": "DocumentScannerSpec",
|
|
112
|
+
"type": "modules",
|
|
113
|
+
"jsSrcsDir": "src",
|
|
114
|
+
"android": {
|
|
115
|
+
"javaPackageName": "com.documentscanner"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"prettier": {
|
|
119
|
+
"quoteProps": "consistent",
|
|
120
|
+
"singleQuote": true,
|
|
121
|
+
"tabWidth": 2,
|
|
122
|
+
"trailingComma": "es5",
|
|
123
|
+
"useTabs": false
|
|
124
|
+
},
|
|
125
|
+
"jest": {
|
|
126
|
+
"preset": "react-native",
|
|
127
|
+
"modulePathIgnorePatterns": [
|
|
128
|
+
"<rootDir>/example/node_modules",
|
|
129
|
+
"<rootDir>/lib/"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
"commitlint": {
|
|
133
|
+
"extends": [
|
|
134
|
+
"@commitlint/config-conventional"
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
}
|