@qrcommunication/gigapdf-lib 0.53.0 → 0.54.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.d.cts CHANGED
@@ -21,12 +21,19 @@ type Exports = {
21
21
  /**
22
22
  * A trained per-script OCR model bundled with the package. `alpha` covers
23
23
  * Latin, Cyrillic and Greek; `arabic` is the **RTL group** (Arabic, Urdu,
24
- * Hebrew); the rest are dedicated scripts. The matching `.gpocr` CRNN blob
25
- * ships under `models/` and is host-loaded on demand. To recognize any shipped
26
- * language at once (including models added later), prefer
24
+ * Hebrew); `cjk` is Chinese (2401-class); `japanese` / `korean` are their own
25
+ * groups (kana+kanji / Hangul, each + full ASCII for mixed alphanumerics); the
26
+ * rest are dedicated Indic scripts. The matching `.gpocr` CRNN blob ships under
27
+ * `models/` and is host-loaded on demand. To recognize any shipped language at
28
+ * once (including models added later), prefer
27
29
  * {@link GigaPdfEngine.loadAllBundledOcrModels}.
30
+ *
31
+ * Some models may not be bundled in every release (a script can still be
32
+ * training upstream) — {@link GigaPdfEngine.loadBundledOcrModel} returns `false`
33
+ * for an absent blob instead of throwing, so listing them in
34
+ * {@link ALL_OCR_SCRIPTS} stays safe.
28
35
  */
29
- type OcrScript = "alpha" | "arabic" | "devanagari" | "bengali" | "tamil";
36
+ type OcrScript = "alpha" | "arabic" | "devanagari" | "bengali" | "tamil" | "cjk" | "japanese" | "korean";
30
37
  /** Every trained script — load all for "recognize text in any language". */
31
38
  declare const ALL_OCR_SCRIPTS: readonly OcrScript[];
32
39
  /** Loaded engine module. Create documents with {@link open} / {@link openEncrypted}. */
@@ -185,7 +192,10 @@ declare class GigaPdfEngine {
185
192
  * the engine via {@link loadOcrModel}. **Node hosts only** — it reads the blob
186
193
  * from disk the same way {@link loadDefault} resolves the wasm. Returns `true`
187
194
  * on success. Use this to recognize non-Latin scripts (Arabic, Devanagari,
188
- * Bengali, Tamil) or to upgrade Latin/Cyrillic/Greek to the CRNN (`alpha`).
195
+ * Bengali, Tamil, Chinese `cjk`, Japanese, Korean) or to upgrade
196
+ * Latin/Cyrillic/Greek to the CRNN (`alpha`). Returns `false` (rather than
197
+ * throwing) when the blob isn't bundled in this release — e.g. a script still
198
+ * training upstream — so loading a set stays resilient.
189
199
  */
190
200
  loadBundledOcrModel(script: OcrScript): Promise<boolean>;
191
201
  /**
package/dist/index.d.ts CHANGED
@@ -21,12 +21,19 @@ type Exports = {
21
21
  /**
22
22
  * A trained per-script OCR model bundled with the package. `alpha` covers
23
23
  * Latin, Cyrillic and Greek; `arabic` is the **RTL group** (Arabic, Urdu,
24
- * Hebrew); the rest are dedicated scripts. The matching `.gpocr` CRNN blob
25
- * ships under `models/` and is host-loaded on demand. To recognize any shipped
26
- * language at once (including models added later), prefer
24
+ * Hebrew); `cjk` is Chinese (2401-class); `japanese` / `korean` are their own
25
+ * groups (kana+kanji / Hangul, each + full ASCII for mixed alphanumerics); the
26
+ * rest are dedicated Indic scripts. The matching `.gpocr` CRNN blob ships under
27
+ * `models/` and is host-loaded on demand. To recognize any shipped language at
28
+ * once (including models added later), prefer
27
29
  * {@link GigaPdfEngine.loadAllBundledOcrModels}.
30
+ *
31
+ * Some models may not be bundled in every release (a script can still be
32
+ * training upstream) — {@link GigaPdfEngine.loadBundledOcrModel} returns `false`
33
+ * for an absent blob instead of throwing, so listing them in
34
+ * {@link ALL_OCR_SCRIPTS} stays safe.
28
35
  */
29
- type OcrScript = "alpha" | "arabic" | "devanagari" | "bengali" | "tamil";
36
+ type OcrScript = "alpha" | "arabic" | "devanagari" | "bengali" | "tamil" | "cjk" | "japanese" | "korean";
30
37
  /** Every trained script — load all for "recognize text in any language". */
31
38
  declare const ALL_OCR_SCRIPTS: readonly OcrScript[];
32
39
  /** Loaded engine module. Create documents with {@link open} / {@link openEncrypted}. */
@@ -185,7 +192,10 @@ declare class GigaPdfEngine {
185
192
  * the engine via {@link loadOcrModel}. **Node hosts only** — it reads the blob
186
193
  * from disk the same way {@link loadDefault} resolves the wasm. Returns `true`
187
194
  * on success. Use this to recognize non-Latin scripts (Arabic, Devanagari,
188
- * Bengali, Tamil) or to upgrade Latin/Cyrillic/Greek to the CRNN (`alpha`).
195
+ * Bengali, Tamil, Chinese `cjk`, Japanese, Korean) or to upgrade
196
+ * Latin/Cyrillic/Greek to the CRNN (`alpha`). Returns `false` (rather than
197
+ * throwing) when the blob isn't bundled in this release — e.g. a script still
198
+ * training upstream — so loading a set stays resilient.
189
199
  */
190
200
  loadBundledOcrModel(script: OcrScript): Promise<boolean>;
191
201
  /**
package/dist/index.js CHANGED
@@ -11,14 +11,20 @@ var OCR_MODEL_FILES = {
11
11
  arabic: "ocr_arabic.gpocr",
12
12
  devanagari: "ocr_deva.gpocr",
13
13
  bengali: "ocr_beng.gpocr",
14
- tamil: "ocr_taml.gpocr"
14
+ tamil: "ocr_taml.gpocr",
15
+ cjk: "ocr_cjk.gpocr",
16
+ japanese: "ocr_jpn.gpocr",
17
+ korean: "ocr_kor.gpocr"
15
18
  };
16
19
  var ALL_OCR_SCRIPTS = [
17
20
  "alpha",
18
21
  "arabic",
19
22
  "devanagari",
20
23
  "bengali",
21
- "tamil"
24
+ "tamil",
25
+ "cjk",
26
+ "japanese",
27
+ "korean"
22
28
  ];
23
29
  var GigaPdfEngine = class _GigaPdfEngine {
24
30
  constructor(ex) {
@@ -389,10 +395,17 @@ var GigaPdfEngine = class _GigaPdfEngine {
389
395
  * the engine via {@link loadOcrModel}. **Node hosts only** — it reads the blob
390
396
  * from disk the same way {@link loadDefault} resolves the wasm. Returns `true`
391
397
  * on success. Use this to recognize non-Latin scripts (Arabic, Devanagari,
392
- * Bengali, Tamil) or to upgrade Latin/Cyrillic/Greek to the CRNN (`alpha`).
398
+ * Bengali, Tamil, Chinese `cjk`, Japanese, Korean) or to upgrade
399
+ * Latin/Cyrillic/Greek to the CRNN (`alpha`). Returns `false` (rather than
400
+ * throwing) when the blob isn't bundled in this release — e.g. a script still
401
+ * training upstream — so loading a set stays resilient.
393
402
  */
394
403
  async loadBundledOcrModel(script) {
395
- return this.loadOcrModel(await readModelFile(OCR_MODEL_FILES[script]));
404
+ try {
405
+ return this.loadOcrModel(await readModelFile(OCR_MODEL_FILES[script]));
406
+ } catch {
407
+ return false;
408
+ }
396
409
  }
397
410
  /**
398
411
  * Load several bundled OCR models (idempotent per call). Returns the scripts