kordoc 3.8.1 → 3.8.2

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.
Files changed (32) hide show
  1. package/README.md +5 -0
  2. package/dist/{-LD4BZDDJ.js → -FEHSMPVO.js} +3 -3
  3. package/dist/{chunk-PELBIL4K.js → chunk-553VTUVP.js} +2 -2
  4. package/dist/{chunk-KT2BCHXI.js → chunk-DP37KF2X.js} +834 -822
  5. package/dist/chunk-DP37KF2X.js.map +1 -0
  6. package/dist/{chunk-IFYJFWD2.js → chunk-JHZUFBUV.js} +2 -2
  7. package/dist/{chunk-LFCS3UVG.cjs → chunk-YBPNKFJW.cjs} +2 -2
  8. package/dist/{chunk-LFCS3UVG.cjs.map → chunk-YBPNKFJW.cjs.map} +1 -1
  9. package/dist/cli.js +4 -4
  10. package/dist/index.cjs +946 -934
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +17 -8
  13. package/dist/index.d.ts +17 -8
  14. package/dist/index.js +833 -821
  15. package/dist/index.js.map +1 -1
  16. package/dist/mcp.js +3 -3
  17. package/dist/{parser-FFEBMLSH.js → parser-KNQDRLZQ.js} +60 -20
  18. package/dist/parser-KNQDRLZQ.js.map +1 -0
  19. package/dist/{parser-XEDROIM7.js → parser-NR2TYGO3.js} +60 -20
  20. package/dist/parser-NR2TYGO3.js.map +1 -0
  21. package/dist/{parser-IXK5V7YG.cjs → parser-NS4ZPD7B.cjs} +77 -35
  22. package/dist/parser-NS4ZPD7B.cjs.map +1 -0
  23. package/dist/{watch-MAWCDNFI.js → watch-XCWADLPU.js} +3 -3
  24. package/package.json +1 -1
  25. package/dist/chunk-KT2BCHXI.js.map +0 -1
  26. package/dist/parser-FFEBMLSH.js.map +0 -1
  27. package/dist/parser-IXK5V7YG.cjs.map +0 -1
  28. package/dist/parser-XEDROIM7.js.map +0 -1
  29. /package/dist/{-LD4BZDDJ.js.map → -FEHSMPVO.js.map} +0 -0
  30. /package/dist/{chunk-PELBIL4K.js.map → chunk-553VTUVP.js.map} +0 -0
  31. /package/dist/{chunk-IFYJFWD2.js.map → chunk-JHZUFBUV.js.map} +0 -0
  32. /package/dist/{watch-MAWCDNFI.js.map → watch-XCWADLPU.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  blocksToMarkdown,
7
7
  safeMax,
8
8
  safeMin
9
- } from "./chunk-PELBIL4K.js";
9
+ } from "./chunk-553VTUVP.js";
10
10
  import {
11
11
  parsePageRange
12
12
  } from "./chunk-GE43BE46.js";
@@ -20,21 +20,30 @@ function extractLines(fnArray, argsArray) {
20
20
  const horizontals = [];
21
21
  const verticals = [];
22
22
  let lineWidth = 1;
23
+ let ctm = [1, 0, 0, 1, 0, 0];
24
+ const ctmStack = [];
25
+ const applyCtm = (x, y) => [ctm[0] * x + ctm[2] * y + ctm[4], ctm[1] * x + ctm[3] * y + ctm[5]];
26
+ const ctmScale = () => (Math.hypot(ctm[0], ctm[1]) + Math.hypot(ctm[2], ctm[3])) / 2;
23
27
  let currentPath = [];
24
28
  let pathStartX = 0, pathStartY = 0;
25
29
  let curX = 0, curY = 0;
26
- function pushRectangle(path, rx, ry, rw, rh) {
27
- if (Math.abs(rh) < ORIENTATION_TOL * 2) {
28
- path.push({ x1: rx, y1: ry + rh / 2, x2: rx + rw, y2: ry + rh / 2 });
29
- } else if (Math.abs(rw) < ORIENTATION_TOL * 2) {
30
- path.push({ x1: rx + rw / 2, y1: ry, x2: rx + rw / 2, y2: ry + rh });
30
+ function pushSeg(x1, y1, x2, y2) {
31
+ const [tx1, ty1] = applyCtm(x1, y1);
32
+ const [tx2, ty2] = applyCtm(x2, y2);
33
+ currentPath.push({ x1: tx1, y1: ty1, x2: tx2, y2: ty2 });
34
+ }
35
+ function pushRectangle(rx, ry, rw, rh) {
36
+ const effH = Math.abs(rh) * Math.hypot(ctm[2], ctm[3]);
37
+ const effW = Math.abs(rw) * Math.hypot(ctm[0], ctm[1]);
38
+ if (effH < ORIENTATION_TOL * 2) {
39
+ pushSeg(rx, ry + rh / 2, rx + rw, ry + rh / 2);
40
+ } else if (effW < ORIENTATION_TOL * 2) {
41
+ pushSeg(rx + rw / 2, ry, rx + rw / 2, ry + rh);
31
42
  } else {
32
- path.push(
33
- { x1: rx, y1: ry, x2: rx + rw, y2: ry },
34
- { x1: rx + rw, y1: ry, x2: rx + rw, y2: ry + rh },
35
- { x1: rx + rw, y1: ry + rh, x2: rx, y2: ry + rh },
36
- { x1: rx, y1: ry + rh, x2: rx, y2: ry }
37
- );
43
+ pushSeg(rx, ry, rx + rw, ry);
44
+ pushSeg(rx + rw, ry, rx + rw, ry + rh);
45
+ pushSeg(rx + rw, ry + rh, rx, ry + rh);
46
+ pushSeg(rx, ry + rh, rx, ry);
38
47
  }
39
48
  }
40
49
  function flushPath(isStroke) {
@@ -42,8 +51,9 @@ function extractLines(fnArray, argsArray) {
42
51
  currentPath = [];
43
52
  return;
44
53
  }
54
+ const effWidth = lineWidth * ctmScale();
45
55
  for (const seg of currentPath) {
46
- classifyAndAdd(seg, lineWidth, horizontals, verticals);
56
+ classifyAndAdd(seg, effWidth, horizontals, verticals);
47
57
  }
48
58
  currentPath = [];
49
59
  }
@@ -54,6 +64,24 @@ function extractLines(fnArray, argsArray) {
54
64
  case OPS.setLineWidth:
55
65
  lineWidth = args[0] || 1;
56
66
  break;
67
+ case OPS.save:
68
+ ctmStack.push(ctm.slice());
69
+ break;
70
+ case OPS.restore:
71
+ ctm = ctmStack.pop() ?? [1, 0, 0, 1, 0, 0];
72
+ break;
73
+ case OPS.transform: {
74
+ const t = args;
75
+ ctm = [
76
+ ctm[0] * t[0] + ctm[2] * t[1],
77
+ ctm[1] * t[0] + ctm[3] * t[1],
78
+ ctm[0] * t[2] + ctm[2] * t[3],
79
+ ctm[1] * t[2] + ctm[3] * t[3],
80
+ ctm[0] * t[4] + ctm[2] * t[5] + ctm[4],
81
+ ctm[1] * t[4] + ctm[3] * t[5] + ctm[5]
82
+ ];
83
+ break;
84
+ }
57
85
  case OPS.constructPath: {
58
86
  const arg0 = args[0];
59
87
  if (Array.isArray(arg0)) {
@@ -68,16 +96,16 @@ function extractLines(fnArray, argsArray) {
68
96
  pathStartY = curY;
69
97
  } else if (subOp === OPS.lineTo) {
70
98
  const x2 = coords[ci++], y2 = coords[ci++];
71
- currentPath.push({ x1: curX, y1: curY, x2, y2 });
99
+ pushSeg(curX, curY, x2, y2);
72
100
  curX = x2;
73
101
  curY = y2;
74
102
  } else if (subOp === OPS.rectangle) {
75
103
  const rx = coords[ci++], ry = coords[ci++];
76
104
  const rw = coords[ci++], rh = coords[ci++];
77
- pushRectangle(currentPath, rx, ry, rw, rh);
105
+ pushRectangle(rx, ry, rw, rh);
78
106
  } else if (subOp === OPS.closePath) {
79
107
  if (curX !== pathStartX || curY !== pathStartY) {
80
- currentPath.push({ x1: curX, y1: curY, x2: pathStartX, y2: pathStartY });
108
+ pushSeg(curX, curY, pathStartX, pathStartY);
81
109
  }
82
110
  curX = pathStartX;
83
111
  curY = pathStartY;
@@ -103,7 +131,7 @@ function extractLines(fnArray, argsArray) {
103
131
  pathStartY = curY;
104
132
  } else if (drawOp === 1 /* lineTo */) {
105
133
  const x2 = pathData[di++], y2 = pathData[di++];
106
- currentPath.push({ x1: curX, y1: curY, x2, y2 });
134
+ pushSeg(curX, curY, x2, y2);
107
135
  curX = x2;
108
136
  curY = y2;
109
137
  } else if (drawOp === 2 /* curveTo */) {
@@ -112,7 +140,7 @@ function extractLines(fnArray, argsArray) {
112
140
  di += 4;
113
141
  } else if (drawOp === 4 /* closePath */) {
114
142
  if (curX !== pathStartX || curY !== pathStartY) {
115
- currentPath.push({ x1: curX, y1: curY, x2: pathStartX, y2: pathStartY });
143
+ pushSeg(curX, curY, pathStartX, pathStartY);
116
144
  }
117
145
  curX = pathStartX;
118
146
  curY = pathStartY;
@@ -2948,16 +2976,28 @@ g.pdfjsWorker = pdfjsWorker;
2948
2976
 
2949
2977
  // src/pdf/parser.ts
2950
2978
  import { getDocument, GlobalWorkerOptions } from "pdfjs-dist/legacy/build/pdf.mjs";
2979
+ import { createRequire } from "module";
2980
+ import { dirname, join } from "path";
2951
2981
  GlobalWorkerOptions.workerSrc = "";
2952
2982
  var MAX_PAGES = 5e3;
2953
2983
  var MAX_TOTAL_TEXT = 100 * 1024 * 1024;
2954
2984
  var PDF_LOAD_TIMEOUT_MS = 3e4;
2985
+ var pdfjsAssets = {};
2986
+ try {
2987
+ const _require = createRequire(import.meta.url);
2988
+ const pkgDir = dirname(_require.resolve("pdfjs-dist/package.json"));
2989
+ pdfjsAssets.cMapUrl = join(pkgDir, "cmaps") + "/";
2990
+ pdfjsAssets.cMapPacked = true;
2991
+ pdfjsAssets.standardFontDataUrl = join(pkgDir, "standard_fonts") + "/";
2992
+ } catch {
2993
+ }
2955
2994
  async function loadPdfWithTimeout(buffer) {
2956
2995
  const loadingTask = getDocument({
2957
2996
  data: new Uint8Array(buffer),
2958
2997
  useSystemFonts: true,
2959
2998
  disableFontFace: true,
2960
- isEvalSupported: false
2999
+ isEvalSupported: false,
3000
+ ...pdfjsAssets
2961
3001
  });
2962
3002
  let timer;
2963
3003
  try {
@@ -3170,4 +3210,4 @@ export {
3170
3210
  parsePdfDocument,
3171
3211
  removeHeaderFooterBlocks
3172
3212
  };
3173
- //# sourceMappingURL=parser-XEDROIM7.js.map
3213
+ //# sourceMappingURL=parser-NR2TYGO3.js.map