@qrcommunication/gigapdf-lib 0.52.5 → 0.53.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/dist/index.cjs +5 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -38
- package/dist/index.js.map +1 -1
- package/dist/node-fs.browser.cjs +44 -0
- package/dist/node-fs.browser.cjs.map +1 -0
- package/dist/node-fs.browser.d.cts +20 -0
- package/dist/node-fs.browser.d.ts +20 -0
- package/dist/node-fs.browser.js +17 -0
- package/dist/node-fs.browser.js.map +1 -0
- package/dist/node-fs.cjs +89 -0
- package/dist/node-fs.cjs.map +1 -0
- package/dist/node-fs.d.cts +26 -0
- package/dist/node-fs.d.ts +26 -0
- package/dist/node-fs.js +56 -0
- package/dist/node-fs.js.map +1 -0
- package/gigapdf.wasm +0 -0
- package/models/ocr_alpha_hw.gpocr +0 -0
- package/models/ocr_alpha_photo.gpocr +0 -0
- package/models/ocr_arabic.gpocr +0 -0
- package/models/ocr_beng.gpocr +0 -0
- package/models/ocr_cjk.gpocr +0 -0
- package/models/ocr_deva.gpocr +0 -0
- package/models/ocr_taml.gpocr +0 -0
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
loadDefaultWasmBytes,
|
|
4
|
+
readModelFile,
|
|
5
|
+
readModelsDir
|
|
6
|
+
} from "./node-fs.js";
|
|
2
7
|
var enc = new TextEncoder();
|
|
3
8
|
var dec = new TextDecoder();
|
|
4
9
|
var OCR_MODEL_FILES = {
|
|
@@ -65,15 +70,7 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
65
70
|
* for the consuming route so the `.wasm` is copied into the standalone bundle.
|
|
66
71
|
*/
|
|
67
72
|
static async loadDefault() {
|
|
68
|
-
|
|
69
|
-
/* webpackIgnore: true */
|
|
70
|
-
/* @vite-ignore */
|
|
71
|
-
m
|
|
72
|
-
);
|
|
73
|
-
const { readFile } = await nodeImport("node:fs/promises");
|
|
74
|
-
const { fileURLToPath } = await nodeImport("node:url");
|
|
75
|
-
const wasmPath = fileURLToPath(new URL("../gigapdf.wasm", import.meta.url));
|
|
76
|
-
return _GigaPdfEngine.load(await readFile(wasmPath));
|
|
73
|
+
return _GigaPdfEngine.load(await loadDefaultWasmBytes());
|
|
77
74
|
}
|
|
78
75
|
// ── linear-memory ABI helpers (internal) ─────────────────────────────────
|
|
79
76
|
u8() {
|
|
@@ -395,17 +392,7 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
395
392
|
* Bengali, Tamil) or to upgrade Latin/Cyrillic/Greek to the CRNN (`alpha`).
|
|
396
393
|
*/
|
|
397
394
|
async loadBundledOcrModel(script) {
|
|
398
|
-
|
|
399
|
-
/* webpackIgnore: true */
|
|
400
|
-
/* @vite-ignore */
|
|
401
|
-
m
|
|
402
|
-
);
|
|
403
|
-
const { readFile } = await nodeImport("node:fs/promises");
|
|
404
|
-
const { fileURLToPath } = await nodeImport("node:url");
|
|
405
|
-
const path = fileURLToPath(
|
|
406
|
-
new URL(`../models/${OCR_MODEL_FILES[script]}`, import.meta.url)
|
|
407
|
-
);
|
|
408
|
-
return this.loadOcrModel(await readFile(path));
|
|
395
|
+
return this.loadOcrModel(await readModelFile(OCR_MODEL_FILES[script]));
|
|
409
396
|
}
|
|
410
397
|
/**
|
|
411
398
|
* Load several bundled OCR models (idempotent per call). Returns the scripts
|
|
@@ -428,25 +415,9 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
428
415
|
* any model added later — with no code change. Returns the number loaded.
|
|
429
416
|
*/
|
|
430
417
|
async loadAllBundledOcrModels() {
|
|
431
|
-
const
|
|
432
|
-
/* webpackIgnore: true */
|
|
433
|
-
/* @vite-ignore */
|
|
434
|
-
m
|
|
435
|
-
);
|
|
436
|
-
const { readFile, readdir } = await nodeImport("node:fs/promises");
|
|
437
|
-
const { fileURLToPath } = await nodeImport("node:url");
|
|
438
|
-
let entries;
|
|
439
|
-
try {
|
|
440
|
-
entries = await readdir(fileURLToPath(new URL("../models/", import.meta.url)));
|
|
441
|
-
} catch {
|
|
442
|
-
return 0;
|
|
443
|
-
}
|
|
418
|
+
const models = await readModelsDir();
|
|
444
419
|
let count = 0;
|
|
445
|
-
for (const
|
|
446
|
-
if (!name.endsWith(".gpocr")) continue;
|
|
447
|
-
const bytes = await readFile(
|
|
448
|
-
fileURLToPath(new URL(`../models/${name}`, import.meta.url))
|
|
449
|
-
);
|
|
420
|
+
for (const { bytes } of models) {
|
|
450
421
|
if (this.loadOcrModel(bytes)) count += 1;
|
|
451
422
|
}
|
|
452
423
|
return count;
|