@luii/node-tesseract-ocr 2.1.0 → 2.4.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.
@@ -13,6 +13,15 @@
13
13
  * or implied. See the License for the specific language governing
14
14
  * permissions and limitations under the License.
15
15
  */
16
+ import { existsSync, createWriteStream } from "node:fs";
17
+ import { mkdir, rename, rm, copyFile } from "node:fs/promises";
18
+ import os from "node:os";
19
+ import path from "node:path";
20
+ import { Readable, Transform } from "node:stream";
21
+ import { pipeline } from "node:stream/promises";
22
+ import { createGunzip } from "node:zlib";
23
+ import { lock } from "proper-lockfile";
24
+ import { isValidTraineddata } from "./utils";
16
25
  /**
17
26
  * All available languages for tesseract
18
27
  * @readonly
@@ -227,15 +236,6 @@ export const LogLevels = {
227
236
  FATAL: "50000",
228
237
  OFF: "2147483647",
229
238
  };
230
- import { existsSync, createWriteStream } from "node:fs";
231
- import { mkdir, rename, rm, copyFile } from "node:fs/promises";
232
- import os from "node:os";
233
- import path from "node:path";
234
- import { Readable, Transform } from "node:stream";
235
- import { pipeline } from "node:stream/promises";
236
- import { createGunzip } from "node:zlib";
237
- import { lock } from "proper-lockfile";
238
- import { isValidTraineddata } from "./utils";
239
239
  const TESSDATA4_BEST = (lang) => `https://cdn.jsdelivr.net/npm/@tesseract.js-data/${lang}/4.0.0_best_int/`;
240
240
  const TESSDATA4 = (lang) => `https://cdn.jsdelivr.net/npm/@tesseract.js-data/${lang}/4.0.0/`;
241
241
  const DEFAULT_CACHE_DIR = path.join(os.homedir(), ".cache", "node-tesseract-ocr", "tessdata");
@@ -249,6 +249,13 @@ const prebuildRoot = existsSync(bindingOptionsFromSource)
249
249
  : process.cwd();
250
250
  const { Tesseract: NativeTesseract } = require("pkg-prebuilds")(prebuildRoot, require(bindingOptionsPath));
251
251
  class Tesseract extends NativeTesseract {
252
+ document = {
253
+ begin: this.beginProcessPages.bind(this),
254
+ addPage: this.addProcessPage.bind(this),
255
+ finish: this.finishProcessPages.bind(this),
256
+ abort: this.abortProcessPages.bind(this),
257
+ status: this.getProcessPagesStatus.bind(this),
258
+ };
252
259
  constructor() {
253
260
  super();
254
261
  }