@masumdev/rn-camera-ai-mlkit 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +250 -2
  3. package/lib/commonjs/detector/MLKitTextRecognizer.js +387 -0
  4. package/lib/commonjs/detector/MLKitTextRecognizer.js.map +1 -0
  5. package/lib/commonjs/detector/index.js +17 -0
  6. package/lib/commonjs/detector/index.js.map +1 -0
  7. package/lib/commonjs/index.js +39 -0
  8. package/lib/commonjs/index.js.map +1 -0
  9. package/lib/commonjs/package.json +1 -0
  10. package/lib/commonjs/parser/documentFraming.js +279 -0
  11. package/lib/commonjs/parser/documentFraming.js.map +1 -0
  12. package/lib/commonjs/parser/index.js +28 -0
  13. package/lib/commonjs/parser/index.js.map +1 -0
  14. package/lib/commonjs/parser/mlkitTextParser.js +287 -0
  15. package/lib/commonjs/parser/mlkitTextParser.js.map +1 -0
  16. package/lib/commonjs/types/index.js +17 -0
  17. package/lib/commonjs/types/index.js.map +1 -0
  18. package/lib/commonjs/types/mlkit.js +6 -0
  19. package/lib/commonjs/types/mlkit.js.map +1 -0
  20. package/lib/module/detector/MLKitTextRecognizer.js +380 -0
  21. package/lib/module/detector/MLKitTextRecognizer.js.map +1 -0
  22. package/lib/module/detector/index.js +4 -0
  23. package/lib/module/detector/index.js.map +1 -0
  24. package/lib/module/index.js +6 -0
  25. package/lib/module/index.js.map +1 -0
  26. package/lib/module/package.json +1 -0
  27. package/lib/module/parser/documentFraming.js +272 -0
  28. package/lib/module/parser/documentFraming.js.map +1 -0
  29. package/lib/module/parser/index.js +5 -0
  30. package/lib/module/parser/index.js.map +1 -0
  31. package/lib/module/parser/mlkitTextParser.js +281 -0
  32. package/lib/module/parser/mlkitTextParser.js.map +1 -0
  33. package/lib/module/types/index.js +4 -0
  34. package/lib/module/types/index.js.map +1 -0
  35. package/lib/module/types/mlkit.js +4 -0
  36. package/lib/module/types/mlkit.js.map +1 -0
  37. package/lib/typescript/commonjs/detector/MLKitTextRecognizer.d.ts +59 -0
  38. package/lib/typescript/commonjs/detector/MLKitTextRecognizer.d.ts.map +1 -0
  39. package/lib/typescript/commonjs/detector/index.d.ts +2 -0
  40. package/lib/typescript/commonjs/detector/index.d.ts.map +1 -0
  41. package/lib/typescript/commonjs/index.d.ts +4 -0
  42. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  43. package/lib/typescript/commonjs/package.json +1 -0
  44. package/lib/typescript/commonjs/parser/documentFraming.d.ts +66 -0
  45. package/lib/typescript/commonjs/parser/documentFraming.d.ts.map +1 -0
  46. package/lib/typescript/commonjs/parser/index.d.ts +3 -0
  47. package/lib/typescript/commonjs/parser/index.d.ts.map +1 -0
  48. package/lib/typescript/commonjs/parser/mlkitTextParser.d.ts +18 -0
  49. package/lib/typescript/commonjs/parser/mlkitTextParser.d.ts.map +1 -0
  50. package/lib/typescript/commonjs/types/index.d.ts +2 -0
  51. package/lib/typescript/commonjs/types/index.d.ts.map +1 -0
  52. package/lib/typescript/commonjs/types/mlkit.d.ts +241 -0
  53. package/lib/typescript/commonjs/types/mlkit.d.ts.map +1 -0
  54. package/lib/typescript/module/detector/MLKitTextRecognizer.d.ts +59 -0
  55. package/lib/typescript/module/detector/MLKitTextRecognizer.d.ts.map +1 -0
  56. package/lib/typescript/module/detector/index.d.ts +2 -0
  57. package/lib/typescript/module/detector/index.d.ts.map +1 -0
  58. package/lib/typescript/module/index.d.ts +4 -0
  59. package/lib/typescript/module/index.d.ts.map +1 -0
  60. package/lib/typescript/module/package.json +1 -0
  61. package/lib/typescript/module/parser/documentFraming.d.ts +66 -0
  62. package/lib/typescript/module/parser/documentFraming.d.ts.map +1 -0
  63. package/lib/typescript/module/parser/index.d.ts +3 -0
  64. package/lib/typescript/module/parser/index.d.ts.map +1 -0
  65. package/lib/typescript/module/parser/mlkitTextParser.d.ts +18 -0
  66. package/lib/typescript/module/parser/mlkitTextParser.d.ts.map +1 -0
  67. package/lib/typescript/module/types/index.d.ts +2 -0
  68. package/lib/typescript/module/types/index.d.ts.map +1 -0
  69. package/lib/typescript/module/types/mlkit.d.ts +241 -0
  70. package/lib/typescript/module/types/mlkit.d.ts.map +1 -0
  71. package/package.json +110 -4
@@ -0,0 +1,59 @@
1
+ import { type CameraPixelFormatPreference, type DetectionResult, type ModelStatus, type OcrGranularity, type WorkletBoolSync } from '@masumdev/rn-camera-ai';
2
+ import type { MLKitOcrDocumentResult, MLKitTextRecognizer, MLKitTextRecognizerConfig, MLKitTextRecognizerNative, OcrEntityFilter, RecognizeTextFromUriOptions, StructuredOcrEntities, TextRecognitionLanguage } from '../types/mlkit';
3
+ /**
4
+ * Concrete CameraProcessor implementation adapting Google ML Kit Text Recognition v2.
5
+ */
6
+ export declare class MLKitTextRecognizerImpl implements MLKitTextRecognizer {
7
+ readonly id: string;
8
+ readonly name = "MLKitTextRecognizer";
9
+ readonly preferredPixelFormat: CameraPixelFormatPreference;
10
+ readonly processFrameWorklet: (frame: unknown) => DetectionResult[];
11
+ readonly wasThrottledSync: WorkletBoolSync;
12
+ private _status;
13
+ private _language;
14
+ private _granularity;
15
+ private _entityFilter;
16
+ private _invertColors;
17
+ private _minConfidence;
18
+ private _minTextLength;
19
+ private _maxResults;
20
+ private _config;
21
+ private _disposedSync;
22
+ private _readySync;
23
+ private _recognizerSync;
24
+ private _granularitySync;
25
+ private _entityFilterSync;
26
+ private _minTextLengthSync;
27
+ private _minConfidenceSync;
28
+ private _maxResultsSync;
29
+ private _lastFrameTimeSync;
30
+ private _lastFullTextSync;
31
+ constructor(config: MLKitTextRecognizerConfig, nativeRecognizer: MLKitTextRecognizerNative);
32
+ get status(): ModelStatus;
33
+ get targetFps(): number | undefined;
34
+ get language(): TextRecognitionLanguage;
35
+ get granularity(): OcrGranularity;
36
+ get entityFilter(): OcrEntityFilter;
37
+ get invertColors(): boolean;
38
+ get minConfidence(): number;
39
+ setGranularity(granularity: OcrGranularity): void;
40
+ setEntityFilter(filter: OcrEntityFilter): void;
41
+ setMinConfidence(confidence: number): void;
42
+ setMaxResults(maxResults: number): void;
43
+ setInvertColors(invert: boolean): Promise<void>;
44
+ getLastFullText(): string;
45
+ getLastStructuredEntities(): StructuredOcrEntities;
46
+ processFrame(frame: unknown): DetectionResult[];
47
+ recognizeImage(uri: string, options?: Pick<RecognizeTextFromUriOptions, 'imageWidth' | 'imageHeight'>): Promise<MLKitOcrDocumentResult>;
48
+ initialize(): Promise<void>;
49
+ dispose(): void;
50
+ }
51
+ /**
52
+ * Creates and initializes a worklet-capable Google ML Kit OCR processor for CameraAI.
53
+ */
54
+ export declare function createMLKitTextRecognizer(config?: MLKitTextRecognizerConfig): Promise<MLKitTextRecognizer>;
55
+ /**
56
+ * Performs asynchronous Google ML Kit OCR on a static photo URI or local image path.
57
+ */
58
+ export declare function recognizeTextFromUri(uri: string, options?: RecognizeTextFromUriOptions): Promise<MLKitOcrDocumentResult>;
59
+ //# sourceMappingURL=MLKitTextRecognizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MLKitTextRecognizer.d.ts","sourceRoot":"","sources":["../../../../src/detector/MLKitTextRecognizer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,eAAe,EAEpB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,eAAe,EAGrB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAGV,sBAAsB,EAEtB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AAsLxB;;GAEG;AACH,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,yBAAyB;IAC7C,SAAgB,oBAAoB,EAAE,2BAA2B,CAAC;IAClE,SAAgB,mBAAmB,EAAE,CA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eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBrD,eAAe,IAAI,MAAM;IAIzB,yBAAyB,IAAI,qBAAqB;IAIlD,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE;IAYzC,cAAc,CAClB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,IAAI,CAAC,2BAA2B,EAAE,YAAY,GAAG,aAAa,CAAC,GACxE,OAAO,CAAC,sBAAsB,CAAC;IA8B5B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBjC,OAAO,IAAI,IAAI;CAUhB;AAoED;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,GAAE,yBAA8B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CA0B9B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,sBAAsB,CAAC,CAwCjC"}
@@ -0,0 +1,2 @@
1
+ export * from './MLKitTextRecognizer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/detector/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './parser';
3
+ export * from './detector';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,66 @@
1
+ import type { BoundingBox, DetectionResult, OcrPoint } from '@masumdev/rn-camera-ai';
2
+ /**
3
+ * Alignment & scan-readiness verdict emitted by `evaluateDocumentFraming`.
4
+ */
5
+ export type DocumentFramingStatus = 'searching' | 'too_far' | 'too_close' | 'off_center' | 'clipped' | 'tilted' | 'low_clarity' | 'optimal';
6
+ /**
7
+ * Normalized paper corner bounds and scan-readiness evaluation produced from preview OCR detections.
8
+ */
9
+ export interface DocumentFramingAssessment {
10
+ /** Granular geometric and OCR clarity status */
11
+ status: DocumentFramingStatus;
12
+ /** Probability score (0-100) that capturing right now will yield clean OCR */
13
+ optimalityScore: number;
14
+ /** True when status === 'optimal' and score meets minimum threshold */
15
+ isOptimal: boolean;
16
+ /** Concise status headline suitable for UI status pills */
17
+ headline: string;
18
+ /** Actionable positioning instruction for the user */
19
+ hint: string;
20
+ /** True when at least one valid text/document region was detected */
21
+ hasDocument: boolean;
22
+ /** Normalized [0..1] estimated paper bounding box hugging outer document margins */
23
+ paperBox: BoundingBox;
24
+ /** Normalized [0..1] 4 corner coordinates [topLeft, topRight, bottomRight, bottomLeft] */
25
+ paperCorners: readonly [OcrPoint, OcrPoint, OcrPoint, OcrPoint];
26
+ /** Mean document baseline skew angle in degrees */
27
+ skewAngleDeg: number;
28
+ /** Normalized viewport area fraction covered by the estimated paper box (0..1) */
29
+ coverageRatio: number;
30
+ /** Number of detected boxes contributing to the paper envelope */
31
+ blockCount: number;
32
+ /** Detected line/box count */
33
+ lineCount: number;
34
+ /** Mean ML Kit confidence score [0..1] when reported by native recognizer */
35
+ averageConfidence: number;
36
+ }
37
+ /**
38
+ * Tuning options for `evaluateDocumentFraming`.
39
+ */
40
+ export interface EvaluateDocumentFramingOptions {
41
+ /** Baseline target guide box when searching for a document */
42
+ guideBox?: BoundingBox;
43
+ /** Minimum optimality score (0-100) required to report `isOptimal: true` (default: 75) */
44
+ minOptimalityScore?: number;
45
+ /** Maximum permitted tilt angle in degrees before flagging `'tilted'` (default: 10) */
46
+ maxSkewDeg?: number;
47
+ }
48
+ /**
49
+ * Default normalized paper viewfinder guide rectangle matching portrait document aspect.
50
+ */
51
+ export declare const DEFAULT_DOCUMENT_GUIDE_BOX: BoundingBox;
52
+ /**
53
+ * Smoothly interpolates between consecutive detected paper rectangles with a small deadzone
54
+ * so UI-thread corner brackets glide onto paper corners without micro-jitter.
55
+ */
56
+ export declare function smoothPaperBox(previousBox: BoundingBox, nextBox: BoundingBox, alpha?: number, deadzone?: number): BoundingBox;
57
+ /**
58
+ * Evaluates detected OCR blocks/lines to fit outer paper corners, classify positioning
59
+ * alignment, and predict capture OCR optimality (0-100%).
60
+ */
61
+ export declare function evaluateDocumentFraming(detections: readonly DetectionResult[], options?: EvaluateDocumentFramingOptions): DocumentFramingAssessment;
62
+ /**
63
+ * Helper mapping `DocumentFramingAssessment` into `<DocumentGuideOverlay />` input shape.
64
+ */
65
+ export declare function toDocumentGuideReadiness(assessment: DocumentFramingAssessment): 'searching' | 'adjusting' | 'optimal';
66
+ //# sourceMappingURL=documentFraming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentFraming.d.ts","sourceRoot":"","sources":["../../../../src/parser/documentFraming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,QAAQ,EACT,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,SAAS,GACT,WAAW,GACX,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,aAAa,GACb,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,gDAAgD;IAChD,MAAM,EAAE,qBAAqB,CAAC;IAC9B,8EAA8E;IAC9E,eAAe,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,WAAW,EAAE,OAAO,CAAC;IACrB,oFAAoF;IACpF,QAAQ,EAAE,WAAW,CAAC;IACtB,0FAA0F;IAC1F,YAAY,EAAE,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChE,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,0FAA0F;IAC1F,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAKxC,CAAC;AAkCF;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,WAAW,EACpB,KAAK,SAAO,EACZ,QAAQ,SAAQ,GACf,WAAW,CAkBb;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,SAAS,eAAe,EAAE,EACtC,OAAO,GAAE,8BAAmC,GAC3C,yBAAyB,CAsN3B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,yBAAyB,GACpC,WAAW,GAAG,WAAW,GAAG,SAAS,CAMvC"}
@@ -0,0 +1,3 @@
1
+ export * from './documentFraming';
2
+ export * from './mlkitTextParser';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type DetectionResult, type OcrEntityCategory } from '@masumdev/rn-camera-ai';
2
+ import type { MLKitTextRecognitionResult, ParseMLKitTextOptions, StructuredOcrEntities } from '../types/mlkit';
3
+ /**
4
+ * Classifies a recognized OCR text snippet into semantic categories inside worklets
5
+ * without depending on heavy regex allocations or non-serializable globals.
6
+ */
7
+ export declare function classifyOcrEntity(rawText: string): OcrEntityCategory;
8
+ /**
9
+ * Worklet-safe parser translating raw Google ML Kit TextRecognitionResult objects
10
+ * into normalized [0..1] @masumdev/rn-camera-ai DetectionResult arrays.
11
+ */
12
+ export declare function parseMLKitTextResult(rawResult: MLKitTextRecognitionResult | null | undefined, frameWidth: number, frameHeight: number, options?: ParseMLKitTextOptions): DetectionResult[];
13
+ /**
14
+ * Extracts structured entities (NIK/KTP, Emails, Phone numbers, URLs, Currencies)
15
+ * from raw recognized document transcript text.
16
+ */
17
+ export declare function extractStructuredOcrData(fullText: string): StructuredOcrEntities;
18
+ //# sourceMappingURL=mlkitTextParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mlkitTextParser.d.ts","sourceRoot":"","sources":["../../../../src/parser/mlkitTextParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAIvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAGV,0BAA0B,EAE1B,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAoBxB;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CA8GpE;AAmED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,0BAA0B,GAAG,IAAI,GAAG,SAAS,EACxD,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,qBAA0B,GAClC,eAAe,EAAE,CAsKnB;AAeD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CA6ChF"}
@@ -0,0 +1,2 @@
1
+ export * from './mlkit';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,241 @@
1
+ import type { CameraPixelFormatPreference, CameraProcessor, DetectionResult, FrameOrientation, OcrEntityCategory, OcrGranularity } from '@masumdev/rn-camera-ai';
2
+ /**
3
+ * Supported on-device Google ML Kit text recognition scripts.
4
+ */
5
+ export type TextRecognitionLanguage = 'LATIN' | 'CHINESE' | 'DEVANAGARI' | 'JAPANESE' | 'KOREAN';
6
+ /**
7
+ * Filter restricting emitted OCR detections to a specific semantic entity class.
8
+ */
9
+ export type OcrEntityFilter = 'all' | OcrEntityCategory;
10
+ /**
11
+ * Region of interest crop specification matching react-native-vision-camera-mlkit.
12
+ */
13
+ export interface MLKitRegionOfInterest {
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ unit?: 'percentage' | 'pixel';
19
+ }
20
+ /**
21
+ * Raw bounding box returned by ML Kit Nitro TextRecognizer.
22
+ * Note: bounds.left / bounds.top represent top-left pixel coordinates, while
23
+ * bounds.x / bounds.y represent center coordinates in MLKitTextAdapter.
24
+ */
25
+ export interface MLKitBoundingBox {
26
+ x: number;
27
+ y: number;
28
+ centerX?: number;
29
+ centerY?: number;
30
+ width: number;
31
+ height: number;
32
+ top?: number;
33
+ left?: number;
34
+ bottom?: number;
35
+ right?: number;
36
+ }
37
+ /**
38
+ * 2D pixel corner point emitted by ML Kit OCR elements and lines.
39
+ */
40
+ export interface MLKitCorner {
41
+ x: number;
42
+ y: number;
43
+ }
44
+ /**
45
+ * Character symbol prediction emitted by Google ML Kit on Android.
46
+ */
47
+ export interface MLKitTextSymbol {
48
+ text: string;
49
+ bounds?: MLKitBoundingBox | null;
50
+ corners?: MLKitCorner[] | null;
51
+ confidence?: number | null;
52
+ angle?: number | null;
53
+ languages?: string[];
54
+ }
55
+ /**
56
+ * Word/token element emitted by Google ML Kit text recognition.
57
+ */
58
+ export interface MLKitTextElement {
59
+ text: string;
60
+ bounds?: MLKitBoundingBox | null;
61
+ corners?: MLKitCorner[] | null;
62
+ confidence?: number | null;
63
+ angle?: number | null;
64
+ languages?: string[];
65
+ symbols?: MLKitTextSymbol[];
66
+ }
67
+ /**
68
+ * Single text line emitted by Google ML Kit text recognition.
69
+ */
70
+ export interface MLKitTextLine {
71
+ text: string;
72
+ bounds?: MLKitBoundingBox | null;
73
+ corners?: MLKitCorner[] | null;
74
+ confidence?: number | null;
75
+ angle?: number | null;
76
+ languages?: string[];
77
+ elements?: MLKitTextElement[];
78
+ }
79
+ /**
80
+ * Paragraph or block emitted by Google ML Kit text recognition.
81
+ */
82
+ export interface MLKitTextBlock {
83
+ text: string;
84
+ bounds?: MLKitBoundingBox | null;
85
+ corners?: MLKitCorner[] | null;
86
+ languages?: string[];
87
+ lines?: MLKitTextLine[];
88
+ }
89
+ /**
90
+ * Root result returned by native ML Kit TextRecognizer.recognize(frame).
91
+ */
92
+ export interface MLKitTextRecognitionResult {
93
+ text: string | null | undefined;
94
+ blocks: MLKitTextBlock[];
95
+ }
96
+ /**
97
+ * Native options forwarded to VisionCameraMLKit.createTextRecognizer.
98
+ */
99
+ export interface MLKitNativeRecognizerOptions {
100
+ language?: TextRecognitionLanguage;
101
+ scaleFactor?: number;
102
+ invertColors?: boolean;
103
+ frameProcessInterval?: number;
104
+ roi?: MLKitRegionOfInterest;
105
+ orientation?: FrameOrientation;
106
+ }
107
+ /**
108
+ * Structural Nitro HybridObject interface compatible with react-native-vision-camera-mlkit TextRecognizer.
109
+ */
110
+ export interface MLKitTextRecognizerNative {
111
+ recognize(frame: unknown, args?: {
112
+ orientation?: FrameOrientation;
113
+ }): MLKitTextRecognitionResult;
114
+ recognizeImage?(uri: string): Promise<MLKitTextRecognitionResult>;
115
+ dispose?(): void;
116
+ }
117
+ /**
118
+ * Native module shape resolved at runtime from react-native-vision-camera-mlkit.
119
+ */
120
+ export interface MLKitNativeModuleLike {
121
+ VisionCameraMLKit?: {
122
+ isFeatureAvailable?: (feature: string) => boolean;
123
+ createTextRecognizer?: (options: MLKitNativeRecognizerOptions) => MLKitTextRecognizerNative;
124
+ };
125
+ PluginFactory?: {
126
+ initPlugin?: (feature: string, options: MLKitNativeRecognizerOptions) => MLKitTextRecognizerNative;
127
+ isFeatureAvailable?: (feature: string) => boolean;
128
+ };
129
+ isFeatureAvailable?: (feature: string) => boolean;
130
+ processImageTextRecognition?: (uri: string, options?: MLKitNativeRecognizerOptions & {
131
+ language?: TextRecognitionLanguage;
132
+ }) => Promise<MLKitTextRecognitionResult>;
133
+ }
134
+ /**
135
+ * Options controlling worklet normalization and entity filtering of raw ML Kit OCR results.
136
+ */
137
+ export interface ParseMLKitTextOptions {
138
+ /** Hierarchy granularity for emitted DetectionResult bounding boxes (default: 'line') */
139
+ granularity?: OcrGranularity;
140
+ /** Semantic entity filter ('all', 'nik', 'email', 'phone', 'url', 'currency', 'number') */
141
+ entityFilter?: OcrEntityFilter;
142
+ /** Minimum trimmed character count required per item (default: 1) */
143
+ minTextLength?: number;
144
+ /** Minimum recognition confidence in [0, 1] when reported by Android ML Kit (default: 0) */
145
+ minConfidence?: number;
146
+ /** Maximum number of detections to emit per frame (default: 30) */
147
+ maxResults?: number;
148
+ /** Fallback default confidence when platform (e.g. iOS Vision) omits per-line confidence (default: 0.92) */
149
+ defaultConfidence?: number;
150
+ }
151
+ /**
152
+ * Deduplicated structured entities extracted from recognized OCR transcript text.
153
+ */
154
+ export interface StructuredOcrEntities {
155
+ niks: string[];
156
+ emails: string[];
157
+ phones: string[];
158
+ urls: string[];
159
+ currencies: string[];
160
+ }
161
+ /**
162
+ * Combined static/live OCR document result with normalized detections and structured entities.
163
+ */
164
+ export interface MLKitOcrDocumentResult {
165
+ fullText: string;
166
+ detections: DetectionResult[];
167
+ entities: StructuredOcrEntities;
168
+ rawResult: MLKitTextRecognitionResult;
169
+ }
170
+ /**
171
+ * Configuration options for initializing createMLKitTextRecognizer.
172
+ */
173
+ export interface MLKitTextRecognizerConfig {
174
+ /** Text recognition script model (default: 'LATIN') */
175
+ language?: TextRecognitionLanguage;
176
+ /** Hierarchy level emitted as overlay bounding boxes: 'block' | 'line' | 'element' (default: 'line') */
177
+ granularity?: OcrGranularity;
178
+ /** Semantic entity filter (default: 'all') */
179
+ entityFilter?: OcrEntityFilter;
180
+ /** Optional downscale factor in [0.9, 1.0] before OCR processing (default: 1.0) */
181
+ scaleFactor?: number;
182
+ /** Invert image colors for light text on dark backgrounds (default: false) */
183
+ invertColors?: boolean;
184
+ /** Optional Region of Interest crop before running OCR */
185
+ roi?: MLKitRegionOfInterest;
186
+ /** Target OCR execution rate in FPS (default: 10) */
187
+ targetFps?: number;
188
+ /** Minimum trimmed character length per recognized segment (default: 1) */
189
+ minTextLength?: number;
190
+ /** Minimum confidence score in [0, 1] (default: 0) */
191
+ minConfidence?: number;
192
+ /** Maximum number of OCR boxes returned per frame (default: 30) */
193
+ maxResults?: number;
194
+ /** Preferred camera pixel format: 'yuv' (zero-copy ML Kit fast path on Android) or 'rgb' (default: 'yuv') */
195
+ preferredPixelFormat?: CameraPixelFormatPreference;
196
+ /** Optional dependency injection override returning an initialized native ML Kit recognizer */
197
+ createRecognizer?: (options: MLKitNativeRecognizerOptions) => MLKitTextRecognizerNative | Promise<MLKitTextRecognizerNative>;
198
+ }
199
+ /**
200
+ * Configuration options for one-shot recognizeTextFromUri static photo OCR.
201
+ */
202
+ export interface RecognizeTextFromUriOptions extends ParseMLKitTextOptions {
203
+ language?: TextRecognitionLanguage;
204
+ scaleFactor?: number;
205
+ invertColors?: boolean;
206
+ roi?: MLKitRegionOfInterest;
207
+ orientation?: FrameOrientation;
208
+ /** Known pixel width of the static image for normalized [0..1] box coordinates */
209
+ imageWidth?: number;
210
+ /** Known pixel height of the static image for normalized [0..1] box coordinates */
211
+ imageHeight?: number;
212
+ /** Optional DI override for testing static OCR */
213
+ processImage?: (uri: string, options?: MLKitNativeRecognizerOptions) => Promise<MLKitTextRecognitionResult>;
214
+ }
215
+ /**
216
+ * Worklet-capable Google ML Kit OCR CameraProcessor returned by createMLKitTextRecognizer.
217
+ */
218
+ export interface MLKitTextRecognizer extends CameraProcessor {
219
+ readonly language: TextRecognitionLanguage;
220
+ readonly granularity: OcrGranularity;
221
+ readonly entityFilter: OcrEntityFilter;
222
+ readonly invertColors: boolean;
223
+ readonly minConfidence: number;
224
+ /** Dynamically switch OCR box granularity ('block' | 'line' | 'element') at runtime */
225
+ setGranularity(granularity: OcrGranularity): void;
226
+ /** Dynamically switch semantic entity filter ('all' | 'nik' | 'email' | 'phone' | 'url' | 'currency' | 'number') */
227
+ setEntityFilter(filter: OcrEntityFilter): void;
228
+ /** Dynamically update color inversion for dark-background text */
229
+ setInvertColors(invert: boolean): Promise<void> | void;
230
+ /** Dynamically update minimum confidence cutoff [0, 1] */
231
+ setMinConfidence(confidence: number): void;
232
+ /** Dynamically update maximum emitted boxes per frame */
233
+ setMaxResults(maxResults: number): void;
234
+ /** Returns the full multi-line transcript recognized in the most recent active frame */
235
+ getLastFullText(): string;
236
+ /** Returns deduplicated structured entities extracted from the most recent frame */
237
+ getLastStructuredEntities(): StructuredOcrEntities;
238
+ /** Runs Google ML Kit text recognition on a static photo URI or local file path */
239
+ recognizeImage(uri: string, options?: Pick<RecognizeTextFromUriOptions, 'imageWidth' | 'imageHeight'>): Promise<MLKitOcrDocumentResult>;
240
+ }
241
+ //# sourceMappingURL=mlkit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mlkit.d.ts","sourceRoot":"","sources":["../../../../src/types/mlkit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACf,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAC/B,OAAO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;IACpF,yBAAyB,IAAI,qBAAqB,CAAC;IACnD,mFAAmF;IACnF,cAAc,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,IAAI,CAAC,2BAA2B,EAAE,YAAY,GAAG,aAAa,CAAC,GACxE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACpC"}
@@ -0,0 +1,59 @@
1
+ import { type CameraPixelFormatPreference, type DetectionResult, type ModelStatus, type OcrGranularity, type WorkletBoolSync } from '@masumdev/rn-camera-ai';
2
+ import type { MLKitOcrDocumentResult, MLKitTextRecognizer, MLKitTextRecognizerConfig, MLKitTextRecognizerNative, OcrEntityFilter, RecognizeTextFromUriOptions, StructuredOcrEntities, TextRecognitionLanguage } from '../types/mlkit.js';
3
+ /**
4
+ * Concrete CameraProcessor implementation adapting Google ML Kit Text Recognition v2.
5
+ */
6
+ export declare class MLKitTextRecognizerImpl implements MLKitTextRecognizer {
7
+ readonly id: string;
8
+ readonly name = "MLKitTextRecognizer";
9
+ readonly preferredPixelFormat: CameraPixelFormatPreference;
10
+ readonly processFrameWorklet: (frame: unknown) => DetectionResult[];
11
+ readonly wasThrottledSync: WorkletBoolSync;
12
+ private _status;
13
+ private _language;
14
+ private _granularity;
15
+ private _entityFilter;
16
+ private _invertColors;
17
+ private _minConfidence;
18
+ private _minTextLength;
19
+ private _maxResults;
20
+ private _config;
21
+ private _disposedSync;
22
+ private _readySync;
23
+ private _recognizerSync;
24
+ private _granularitySync;
25
+ private _entityFilterSync;
26
+ private _minTextLengthSync;
27
+ private _minConfidenceSync;
28
+ private _maxResultsSync;
29
+ private _lastFrameTimeSync;
30
+ private _lastFullTextSync;
31
+ constructor(config: MLKitTextRecognizerConfig, nativeRecognizer: MLKitTextRecognizerNative);
32
+ get status(): ModelStatus;
33
+ get targetFps(): number | undefined;
34
+ get language(): TextRecognitionLanguage;
35
+ get granularity(): OcrGranularity;
36
+ get entityFilter(): OcrEntityFilter;
37
+ get invertColors(): boolean;
38
+ get minConfidence(): number;
39
+ setGranularity(granularity: OcrGranularity): void;
40
+ setEntityFilter(filter: OcrEntityFilter): void;
41
+ setMinConfidence(confidence: number): void;
42
+ setMaxResults(maxResults: number): void;
43
+ setInvertColors(invert: boolean): Promise<void>;
44
+ getLastFullText(): string;
45
+ getLastStructuredEntities(): StructuredOcrEntities;
46
+ processFrame(frame: unknown): DetectionResult[];
47
+ recognizeImage(uri: string, options?: Pick<RecognizeTextFromUriOptions, 'imageWidth' | 'imageHeight'>): Promise<MLKitOcrDocumentResult>;
48
+ initialize(): Promise<void>;
49
+ dispose(): void;
50
+ }
51
+ /**
52
+ * Creates and initializes a worklet-capable Google ML Kit OCR processor for CameraAI.
53
+ */
54
+ export declare function createMLKitTextRecognizer(config?: MLKitTextRecognizerConfig): Promise<MLKitTextRecognizer>;
55
+ /**
56
+ * Performs asynchronous Google ML Kit OCR on a static photo URI or local image path.
57
+ */
58
+ export declare function recognizeTextFromUri(uri: string, options?: RecognizeTextFromUriOptions): Promise<MLKitOcrDocumentResult>;
59
+ //# sourceMappingURL=MLKitTextRecognizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MLKitTextRecognizer.d.ts","sourceRoot":"","sources":["../../../../src/detector/MLKitTextRecognizer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,eAAe,EAEpB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,eAAe,EAGrB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,KAAK,EAGV,sBAAsB,EAEtB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,mBAAgB,CAAC;AAsLxB;;GAEG;AACH,qBAAa,uBAAwB,YAAW,mBAAmB;IACjE,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,yBAAyB;IAC7C,SAAgB,oBAAoB,EAAE,2BAA2B,CA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U,EAAE,MAAM,GAAG,IAAI;IAOjC,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBrD,eAAe,IAAI,MAAM;IAIzB,yBAAyB,IAAI,qBAAqB;IAIlD,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE;IAYzC,cAAc,CAClB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,IAAI,CAAC,2BAA2B,EAAE,YAAY,GAAG,aAAa,CAAC,GACxE,OAAO,CAAC,sBAAsB,CAAC;IA8B5B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBjC,OAAO,IAAI,IAAI;CAUhB;AAoED;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,GAAE,yBAA8B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CA0B9B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,sBAAsB,CAAC,CAwCjC"}
@@ -0,0 +1,2 @@
1
+ export * from './MLKitTextRecognizer.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/detector/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './types/index.js';
2
+ export * from './parser/index.js';
3
+ export * from './detector/index.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAS,CAAC;AACxB,cAAc,mBAAU,CAAC;AACzB,cAAc,qBAAY,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,66 @@
1
+ import type { BoundingBox, DetectionResult, OcrPoint } from '@masumdev/rn-camera-ai';
2
+ /**
3
+ * Alignment & scan-readiness verdict emitted by `evaluateDocumentFraming`.
4
+ */
5
+ export type DocumentFramingStatus = 'searching' | 'too_far' | 'too_close' | 'off_center' | 'clipped' | 'tilted' | 'low_clarity' | 'optimal';
6
+ /**
7
+ * Normalized paper corner bounds and scan-readiness evaluation produced from preview OCR detections.
8
+ */
9
+ export interface DocumentFramingAssessment {
10
+ /** Granular geometric and OCR clarity status */
11
+ status: DocumentFramingStatus;
12
+ /** Probability score (0-100) that capturing right now will yield clean OCR */
13
+ optimalityScore: number;
14
+ /** True when status === 'optimal' and score meets minimum threshold */
15
+ isOptimal: boolean;
16
+ /** Concise status headline suitable for UI status pills */
17
+ headline: string;
18
+ /** Actionable positioning instruction for the user */
19
+ hint: string;
20
+ /** True when at least one valid text/document region was detected */
21
+ hasDocument: boolean;
22
+ /** Normalized [0..1] estimated paper bounding box hugging outer document margins */
23
+ paperBox: BoundingBox;
24
+ /** Normalized [0..1] 4 corner coordinates [topLeft, topRight, bottomRight, bottomLeft] */
25
+ paperCorners: readonly [OcrPoint, OcrPoint, OcrPoint, OcrPoint];
26
+ /** Mean document baseline skew angle in degrees */
27
+ skewAngleDeg: number;
28
+ /** Normalized viewport area fraction covered by the estimated paper box (0..1) */
29
+ coverageRatio: number;
30
+ /** Number of detected boxes contributing to the paper envelope */
31
+ blockCount: number;
32
+ /** Detected line/box count */
33
+ lineCount: number;
34
+ /** Mean ML Kit confidence score [0..1] when reported by native recognizer */
35
+ averageConfidence: number;
36
+ }
37
+ /**
38
+ * Tuning options for `evaluateDocumentFraming`.
39
+ */
40
+ export interface EvaluateDocumentFramingOptions {
41
+ /** Baseline target guide box when searching for a document */
42
+ guideBox?: BoundingBox;
43
+ /** Minimum optimality score (0-100) required to report `isOptimal: true` (default: 75) */
44
+ minOptimalityScore?: number;
45
+ /** Maximum permitted tilt angle in degrees before flagging `'tilted'` (default: 10) */
46
+ maxSkewDeg?: number;
47
+ }
48
+ /**
49
+ * Default normalized paper viewfinder guide rectangle matching portrait document aspect.
50
+ */
51
+ export declare const DEFAULT_DOCUMENT_GUIDE_BOX: BoundingBox;
52
+ /**
53
+ * Smoothly interpolates between consecutive detected paper rectangles with a small deadzone
54
+ * so UI-thread corner brackets glide onto paper corners without micro-jitter.
55
+ */
56
+ export declare function smoothPaperBox(previousBox: BoundingBox, nextBox: BoundingBox, alpha?: number, deadzone?: number): BoundingBox;
57
+ /**
58
+ * Evaluates detected OCR blocks/lines to fit outer paper corners, classify positioning
59
+ * alignment, and predict capture OCR optimality (0-100%).
60
+ */
61
+ export declare function evaluateDocumentFraming(detections: readonly DetectionResult[], options?: EvaluateDocumentFramingOptions): DocumentFramingAssessment;
62
+ /**
63
+ * Helper mapping `DocumentFramingAssessment` into `<DocumentGuideOverlay />` input shape.
64
+ */
65
+ export declare function toDocumentGuideReadiness(assessment: DocumentFramingAssessment): 'searching' | 'adjusting' | 'optimal';
66
+ //# sourceMappingURL=documentFraming.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentFraming.d.ts","sourceRoot":"","sources":["../../../../src/parser/documentFraming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,QAAQ,EACT,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,SAAS,GACT,WAAW,GACX,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,aAAa,GACb,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,gDAAgD;IAChD,MAAM,EAAE,qBAAqB,CAAC;IAC9B,8EAA8E;IAC9E,eAAe,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,WAAW,EAAE,OAAO,CAAC;IACrB,oFAAoF;IACpF,QAAQ,EAAE,WAAW,CAAC;IACtB,0FAA0F;IAC1F,YAAY,EAAE,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChE,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,0FAA0F;IAC1F,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAKxC,CAAC;AAkCF;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,WAAW,EACpB,KAAK,SAAO,EACZ,QAAQ,SAAQ,GACf,WAAW,CAkBb;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,SAAS,eAAe,EAAE,EACtC,OAAO,GAAE,8BAAmC,GAC3C,yBAAyB,CAsN3B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,yBAAyB,GACpC,WAAW,GAAG,WAAW,GAAG,SAAS,CAMvC"}
@@ -0,0 +1,3 @@
1
+ export * from './documentFraming.js';
2
+ export * from './mlkitTextParser.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAmB,CAAC;AAClC,cAAc,sBAAmB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type DetectionResult, type OcrEntityCategory } from '@masumdev/rn-camera-ai';
2
+ import type { MLKitTextRecognitionResult, ParseMLKitTextOptions, StructuredOcrEntities } from '../types/mlkit.js';
3
+ /**
4
+ * Classifies a recognized OCR text snippet into semantic categories inside worklets
5
+ * without depending on heavy regex allocations or non-serializable globals.
6
+ */
7
+ export declare function classifyOcrEntity(rawText: string): OcrEntityCategory;
8
+ /**
9
+ * Worklet-safe parser translating raw Google ML Kit TextRecognitionResult objects
10
+ * into normalized [0..1] @masumdev/rn-camera-ai DetectionResult arrays.
11
+ */
12
+ export declare function parseMLKitTextResult(rawResult: MLKitTextRecognitionResult | null | undefined, frameWidth: number, frameHeight: number, options?: ParseMLKitTextOptions): DetectionResult[];
13
+ /**
14
+ * Extracts structured entities (NIK/KTP, Emails, Phone numbers, URLs, Currencies)
15
+ * from raw recognized document transcript text.
16
+ */
17
+ export declare function extractStructuredOcrData(fullText: string): StructuredOcrEntities;
18
+ //# sourceMappingURL=mlkitTextParser.d.ts.map