@qrcommunication/gigapdf-lib 0.52.4 → 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/CHANGELOG.md CHANGED
@@ -4,6 +4,17 @@ All notable changes to `@qrcommunication/gigapdf-lib` are documented here.
4
4
  The format follows [Keep a Changelog](https://keepachangelog.com/) and the
5
5
  project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.52.5] - 2026-06-19
8
+
9
+ ### Added
10
+
11
+ - **Arrow line annotations — `addLineAnnotation(page, x1, y1, x2, y2, rgb, lineWidth, endArrow?)`.**
12
+ The new `endArrow` flag draws an open arrowhead at the `(x2,y2)` end and records
13
+ `/LE [/None /OpenArrow]` on the `/Line` annotation, so the arrowhead survives in
14
+ any conforming reader (Adobe Reader, Preview, Chrome) — and stays editable, not
15
+ baked. The `/Rect` is padded around the arrowhead so it is never clipped. Ideal
16
+ for callouts that point at content. Backward compatible: `endArrow` defaults to `false`.
17
+
7
18
  ## [0.52.4] - 2026-06-19
8
19
 
9
20
  ### Added
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;
@@ -1541,8 +1502,14 @@ var GigaPdfDoc = class {
1541
1502
  addHighlight(page, x0, y0, x1, y1, rgb = 16776960) {
1542
1503
  return this.ex().gp_add_highlight(this.h, page, x0, y0, x1, y1, RGB(rgb)) === 0;
1543
1504
  }
1544
- addLineAnnotation(page, x1, y1, x2, y2, rgb = 0, lineWidth = 1) {
1545
- return this.ex().gp_add_line(this.h, page, x1, y1, x2, y2, RGB(rgb), lineWidth) === 0;
1505
+ /**
1506
+ * Add a `/Line` annotation from `(x1,y1)` to `(x2,y2)`. When `endArrow` is
1507
+ * `true`, an open arrowhead (`/LE [/None /OpenArrow]`) is drawn at the
1508
+ * `(x2,y2)` end — a real, editable annotation in conforming readers, ideal
1509
+ * for callouts that point at content.
1510
+ */
1511
+ addLineAnnotation(page, x1, y1, x2, y2, rgb = 0, lineWidth = 1, endArrow = false) {
1512
+ return this.ex().gp_add_line(this.h, page, x1, y1, x2, y2, RGB(rgb), lineWidth, endArrow ? 1 : 0) === 0;
1546
1513
  }
1547
1514
  addFreeText(page, x0, y0, x1, y1, text, fontSize = 12, rgb = 0) {
1548
1515
  return this.g._withStr(