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