react-native-text-reader 0.4.0 → 0.5.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.
@@ -120,11 +120,13 @@ class TextReaderModule(reactContext: ReactApplicationContext) :
120
120
  }
121
121
 
122
122
  @ReactMethod
123
- fun read(url: String, script: ReadableMap?, promise: Promise) {
123
+ fun read(url: String, options: ReadableMap?, promise: Promise) {
124
124
  try {
125
+ val script = options?.getString("script")
126
+
125
127
  val image = getInputImage(reactApplicationContext, url)
126
128
 
127
- val options = getScriptTextRecognizerOptions(script.toString())
129
+ val options = getScriptTextRecognizerOptions(script)
128
130
 
129
131
  val recognizer: TextRecognizer = TextRecognition.getClient(options)
130
132
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.ScriptOptions = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  const LINKING_ERROR = `The package 'react-native-text-reader' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
9
9
  ios: "- You have run 'pod install'\n",
@@ -14,15 +14,25 @@ const TextReader = _reactNative.NativeModules.TextReader ? _reactNative.NativeMo
14
14
  throw new Error(LINKING_ERROR);
15
15
  }
16
16
  });
17
+ let ScriptOptions = exports.ScriptOptions = /*#__PURE__*/function (ScriptOptions) {
18
+ ScriptOptions["LATIN"] = "Latin";
19
+ ScriptOptions["CHINESE"] = "Chinese";
20
+ ScriptOptions["DEVANAGARI"] = "Devanagari";
21
+ ScriptOptions["JAPANESE"] = "Japanese";
22
+ ScriptOptions["KOREAN"] = "Korean";
23
+ return ScriptOptions;
24
+ }({}); // Options
17
25
  /**
18
- * Extrae texto de una imagen.
19
- * @param imagePath - La URI de la imagen de la que se extraerá el texto.
20
- * @param options - Opciones adicionales.
21
- * @param options.visionIgnoreThreshold - Umbral de ignoración de la visión.
22
- * @returns Una promesa que se resuelve con el texto extraído.
26
+ * Extracts text from an image.
27
+ * @param imagePath - Image path
28
+ * @param options - Additional options
29
+ * @param options.visionIgnoreThreshold - Vision ignore threshold(iOS)
30
+ * @param options.script - Language script (Android)
23
31
  */
24
32
  async function read(imagePath, options) {
25
- return await TextReader.read(imagePath, options || {});
33
+ return await TextReader.read(imagePath, options || {
34
+ script: ScriptOptions.LATIN
35
+ });
26
36
  }
27
37
  var _default = exports.default = {
28
38
  read
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","TextReader","NativeModules","Proxy","get","Error","read","imagePath","options","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,mFAAmF,GACnFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,UAAU,GAAGC,0BAAa,CAACD,UAAU,GACvCC,0BAAa,CAACD,UAAU,GACxB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAUL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeU,IAAIA,CACjBC,SAAiB,EACjBC,OAA2B,EACR;EACnB,OAAO,MAAMP,UAAU,CAACK,IAAI,CAACC,SAAS,EAAEC,OAAO,IAAI,CAAC,CAAC,CAAC;AACxD;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAV,OAAA,GAEc;EAAEM;AAAK,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","TextReader","NativeModules","Proxy","get","Error","ScriptOptions","exports","read","imagePath","options","script","LATIN","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,mFAAmF,GACnFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,UAAU,GAAGC,0BAAa,CAACD,UAAU,GACvCC,0BAAa,CAACD,UAAU,GACxB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAAC,IAEMU,aAAa,GAAAC,OAAA,CAAAD,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA,OAQzB;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeE,IAAIA,CAACC,SAAiB,EAAEC,OAAgB,EAAqB;EAC1E,OAAO,MAAMT,UAAU,CAACO,IAAI,CAC1BC,SAAS,EACTC,OAAO,IAAI;IACTC,MAAM,EAAEL,aAAa,CAACM;EACxB,CACF,CAAC;AACH;AAAC,IAAAC,QAAA,GAAAN,OAAA,CAAAP,OAAA,GAEc;EAAEQ;AAAK,CAAC","ignoreList":[]}
@@ -10,15 +10,28 @@ const TextReader = NativeModules.TextReader ? NativeModules.TextReader : new Pro
10
10
  throw new Error(LINKING_ERROR);
11
11
  }
12
12
  });
13
+ export let ScriptOptions = /*#__PURE__*/function (ScriptOptions) {
14
+ ScriptOptions["LATIN"] = "Latin";
15
+ ScriptOptions["CHINESE"] = "Chinese";
16
+ ScriptOptions["DEVANAGARI"] = "Devanagari";
17
+ ScriptOptions["JAPANESE"] = "Japanese";
18
+ ScriptOptions["KOREAN"] = "Korean";
19
+ return ScriptOptions;
20
+ }({});
21
+
22
+ // Options
23
+
13
24
  /**
14
- * Extrae texto de una imagen.
15
- * @param imagePath - La URI de la imagen de la que se extraerá el texto.
16
- * @param options - Opciones adicionales.
17
- * @param options.visionIgnoreThreshold - Umbral de ignoración de la visión.
18
- * @returns Una promesa que se resuelve con el texto extraído.
25
+ * Extracts text from an image.
26
+ * @param imagePath - Image path
27
+ * @param options - Additional options
28
+ * @param options.visionIgnoreThreshold - Vision ignore threshold(iOS)
29
+ * @param options.script - Language script (Android)
19
30
  */
20
31
  async function read(imagePath, options) {
21
- return await TextReader.read(imagePath, options || {});
32
+ return await TextReader.read(imagePath, options || {
33
+ script: ScriptOptions.LATIN
34
+ });
22
35
  }
23
36
  export default {
24
37
  read
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","TextReader","Proxy","get","Error","read","imagePath","options"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,mFAAmF,GACnFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,UAAU,GAAGN,aAAa,CAACM,UAAU,GACvCN,aAAa,CAACM,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAUL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeQ,IAAIA,CACjBC,SAAiB,EACjBC,OAA2B,EACR;EACnB,OAAO,MAAMN,UAAU,CAACI,IAAI,CAACC,SAAS,EAAEC,OAAO,IAAI,CAAC,CAAC,CAAC;AACxD;AAEA,eAAe;EAAEF;AAAK,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","TextReader","Proxy","get","Error","ScriptOptions","read","imagePath","options","script","LATIN"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,mFAAmF,GACnFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,UAAU,GAAGN,aAAa,CAACM,UAAU,GACvCN,aAAa,CAACM,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,WAAYQ,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;;AAQzB;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,IAAIA,CAACC,SAAiB,EAAEC,OAAgB,EAAqB;EAC1E,OAAO,MAAMP,UAAU,CAACK,IAAI,CAC1BC,SAAS,EACTC,OAAO,IAAI;IACTC,MAAM,EAAEJ,aAAa,CAACK;EACxB,CACF,CAAC;AACH;AAEA,eAAe;EAAEJ;AAAK,CAAC","ignoreList":[]}
@@ -1,8 +1,16 @@
1
- export type TextReaderOptions = {
1
+ export declare enum ScriptOptions {
2
+ LATIN = "Latin",
3
+ CHINESE = "Chinese",
4
+ DEVANAGARI = "Devanagari",
5
+ JAPANESE = "Japanese",
6
+ KOREAN = "Korean"
7
+ }
8
+ export type Options = {
2
9
  visionIgnoreThreshold?: number;
10
+ script?: ScriptOptions;
3
11
  };
4
12
  type TextReaderType = {
5
- read(imagePath: string, options?: TextReaderOptions): Promise<string[]>;
13
+ read(imagePath: string, options?: Options): Promise<string[]>;
6
14
  };
7
15
  declare const _default: TextReaderType;
8
16
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAmBA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACzE,CAAC;wBAgByB,cAAc;AAAzC,wBAA0C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAmBA,oBAAY,aAAa;IACvB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAGD,MAAM,MAAM,OAAO,GAAG;IACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC/D,CAAC;wBAkByB,cAAc;AAAzC,wBAA0C"}
@@ -1,8 +1,16 @@
1
- export type TextReaderOptions = {
1
+ export declare enum ScriptOptions {
2
+ LATIN = "Latin",
3
+ CHINESE = "Chinese",
4
+ DEVANAGARI = "Devanagari",
5
+ JAPANESE = "Japanese",
6
+ KOREAN = "Korean"
7
+ }
8
+ export type Options = {
2
9
  visionIgnoreThreshold?: number;
10
+ script?: ScriptOptions;
3
11
  };
4
12
  type TextReaderType = {
5
- read(imagePath: string, options?: TextReaderOptions): Promise<string[]>;
13
+ read(imagePath: string, options?: Options): Promise<string[]>;
6
14
  };
7
15
  declare const _default: TextReaderType;
8
16
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAmBA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACzE,CAAC;wBAgByB,cAAc;AAAzC,wBAA0C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAmBA,oBAAY,aAAa;IACvB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAGD,MAAM,MAAM,OAAO,GAAG;IACpB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC/D,CAAC;wBAkByB,cAAc;AAAzC,wBAA0C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-text-reader",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "A React Native library for OCR (Optical Character Recognition) using Vision Framework on iOS and Firebase ML Kit on Android.",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
package/src/index.tsx CHANGED
@@ -17,26 +17,38 @@ const TextReader = NativeModules.TextReader
17
17
  }
18
18
  );
19
19
 
20
- export type TextReaderOptions = {
21
- visionIgnoreThreshold?: number;
20
+ export enum ScriptOptions {
21
+ LATIN = 'Latin',
22
+ CHINESE = 'Chinese',
23
+ DEVANAGARI = 'Devanagari',
24
+ JAPANESE = 'Japanese',
25
+ KOREAN = 'Korean',
26
+ }
27
+
28
+ // Options
29
+ export type Options = {
30
+ visionIgnoreThreshold?: number; // only iOS
31
+ script?: ScriptOptions; // only Android
22
32
  };
23
33
 
24
34
  type TextReaderType = {
25
- read(imagePath: string, options?: TextReaderOptions): Promise<string[]>;
35
+ read(imagePath: string, options?: Options): Promise<string[]>;
26
36
  };
27
37
 
28
38
  /**
29
- * Extrae texto de una imagen.
30
- * @param imagePath - La URI de la imagen de la que se extraerá el texto.
31
- * @param options - Opciones adicionales.
32
- * @param options.visionIgnoreThreshold - Umbral de ignoración de la visión.
33
- * @returns Una promesa que se resuelve con el texto extraído.
39
+ * Extracts text from an image.
40
+ * @param imagePath - Image path
41
+ * @param options - Additional options
42
+ * @param options.visionIgnoreThreshold - Vision ignore threshold(iOS)
43
+ * @param options.script - Language script (Android)
34
44
  */
35
- async function read(
36
- imagePath: string,
37
- options?: TextReaderOptions
38
- ): Promise<string[]> {
39
- return await TextReader.read(imagePath, options || {});
45
+ async function read(imagePath: string, options: Options): Promise<string[]> {
46
+ return await TextReader.read(
47
+ imagePath,
48
+ options || {
49
+ script: ScriptOptions.LATIN,
50
+ }
51
+ );
40
52
  }
41
53
 
42
54
  export default { read } as TextReaderType;