@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 CHANGED
@@ -25,12 +25,7 @@ __export(index_exports, {
25
25
  GigaPdfEngine: () => GigaPdfEngine
26
26
  });
27
27
  module.exports = __toCommonJS(index_exports);
28
-
29
- // node_modules/.pnpm/tsup@8.5.1_postcss@8.5.15_typescript@6.0.3/node_modules/tsup/assets/cjs_shims.js
30
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
31
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
32
-
33
- // src/index.ts
28
+ var import_node_fs = require("./node-fs.js");
34
29
  var enc = new TextEncoder();
35
30
  var dec = new TextDecoder();
36
31
  var OCR_MODEL_FILES = {
@@ -97,15 +92,7 @@ var GigaPdfEngine = class _GigaPdfEngine {
97
92
  * for the consuming route so the `.wasm` is copied into the standalone bundle.
98
93
  */
99
94
  static async loadDefault() {
100
- const nodeImport = (m) => import(
101
- /* webpackIgnore: true */
102
- /* @vite-ignore */
103
- m
104
- );
105
- const { readFile } = await nodeImport("node:fs/promises");
106
- const { fileURLToPath } = await nodeImport("node:url");
107
- const wasmPath = fileURLToPath(new URL("../gigapdf.wasm", importMetaUrl));
108
- return _GigaPdfEngine.load(await readFile(wasmPath));
95
+ return _GigaPdfEngine.load(await (0, import_node_fs.loadDefaultWasmBytes)());
109
96
  }
110
97
  // ── linear-memory ABI helpers (internal) ─────────────────────────────────
111
98
  u8() {
@@ -427,17 +414,7 @@ var GigaPdfEngine = class _GigaPdfEngine {
427
414
  * Bengali, Tamil) or to upgrade Latin/Cyrillic/Greek to the CRNN (`alpha`).
428
415
  */
429
416
  async loadBundledOcrModel(script) {
430
- const nodeImport = (m) => import(
431
- /* webpackIgnore: true */
432
- /* @vite-ignore */
433
- m
434
- );
435
- const { readFile } = await nodeImport("node:fs/promises");
436
- const { fileURLToPath } = await nodeImport("node:url");
437
- const path = fileURLToPath(
438
- new URL(`../models/${OCR_MODEL_FILES[script]}`, importMetaUrl)
439
- );
440
- return this.loadOcrModel(await readFile(path));
417
+ return this.loadOcrModel(await (0, import_node_fs.readModelFile)(OCR_MODEL_FILES[script]));
441
418
  }
442
419
  /**
443
420
  * Load several bundled OCR models (idempotent per call). Returns the scripts
@@ -460,25 +437,9 @@ var GigaPdfEngine = class _GigaPdfEngine {
460
437
  * any model added later — with no code change. Returns the number loaded.
461
438
  */
462
439
  async loadAllBundledOcrModels() {
463
- const nodeImport = (m) => import(
464
- /* webpackIgnore: true */
465
- /* @vite-ignore */
466
- m
467
- );
468
- const { readFile, readdir } = await nodeImport("node:fs/promises");
469
- const { fileURLToPath } = await nodeImport("node:url");
470
- let entries;
471
- try {
472
- entries = await readdir(fileURLToPath(new URL("../models/", importMetaUrl)));
473
- } catch {
474
- return 0;
475
- }
440
+ const models = await (0, import_node_fs.readModelsDir)();
476
441
  let count = 0;
477
- for (const name of entries) {
478
- if (!name.endsWith(".gpocr")) continue;
479
- const bytes = await readFile(
480
- fileURLToPath(new URL(`../models/${name}`, importMetaUrl))
481
- );
442
+ for (const { bytes } of models) {
482
443
  if (this.loadOcrModel(bytes)) count += 1;
483
444
  }
484
445
  return count;