kordoc 3.5.4 → 3.8.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/README.md +23 -1
- package/dist/{-KX7VLNW5.js → -ATVQYFSW.js} +21 -5
- package/dist/{chunk-WEAP42T3.js → chunk-3R3YK7EM.js} +2 -2
- package/dist/chunk-3R3YK7EM.js.map +1 -0
- package/dist/{chunk-XZTDYOZV.cjs → chunk-ITJIALN5.cjs} +2 -2
- package/dist/{chunk-XZTDYOZV.cjs.map → chunk-ITJIALN5.cjs.map} +1 -1
- package/dist/{chunk-VEB43O2L.js → chunk-QV25HMU7.js} +2 -2
- package/dist/chunk-QV25HMU7.js.map +1 -0
- package/dist/{chunk-DK2IE43H.js → chunk-SLKF72QF.js} +1682 -718
- package/dist/chunk-SLKF72QF.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +1908 -944
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +130 -8
- package/dist/index.d.ts +130 -8
- package/dist/index.js +1681 -717
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{parser-W5TBEAVX.js → parser-7G5F7PT2.js} +2 -2
- package/dist/{parser-XT65AEDJ.js → parser-DCK42RMA.js} +2 -2
- package/dist/{parser-CPTBEGQP.cjs → parser-GUSJH44K.cjs} +14 -14
- package/dist/{parser-CPTBEGQP.cjs.map → parser-GUSJH44K.cjs.map} +1 -1
- package/dist/{watch-VOSNRZAY.js → watch-GVZESOCE.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-DK2IE43H.js.map +0 -1
- package/dist/chunk-VEB43O2L.js.map +0 -1
- package/dist/chunk-WEAP42T3.js.map +0 -1
- /package/dist/{-KX7VLNW5.js.map → -ATVQYFSW.js.map} +0 -0
- /package/dist/{parser-W5TBEAVX.js.map → parser-7G5F7PT2.js.map} +0 -0
- /package/dist/{parser-XT65AEDJ.js.map → parser-DCK42RMA.js.map} +0 -0
- /package/dist/{watch-VOSNRZAY.js.map → watch-GVZESOCE.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-
|
|
13
|
+
} from "./chunk-SLKF72QF.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-
|
|
24
|
+
} from "./chunk-3R3YK7EM.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-
|
|
196
|
+
const { extractPdfMetadataOnly } = await import("./parser-7G5F7PT2.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-
|
|
10
|
+
} from "./chunk-3R3YK7EM.js";
|
|
11
11
|
import {
|
|
12
12
|
parsePageRange
|
|
13
13
|
} from "./chunk-MOL7MDBG.js";
|
|
@@ -3144,4 +3144,4 @@ export {
|
|
|
3144
3144
|
parsePdfDocument,
|
|
3145
3145
|
removeHeaderFooterBlocks
|
|
3146
3146
|
};
|
|
3147
|
-
//# sourceMappingURL=parser-
|
|
3147
|
+
//# sourceMappingURL=parser-7G5F7PT2.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
blocksToMarkdown,
|
|
7
7
|
safeMax,
|
|
8
8
|
safeMin
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QV25HMU7.js";
|
|
10
10
|
import {
|
|
11
11
|
parsePageRange
|
|
12
12
|
} from "./chunk-GE43BE46.js";
|
|
@@ -3143,4 +3143,4 @@ export {
|
|
|
3143
3143
|
parsePdfDocument,
|
|
3144
3144
|
removeHeaderFooterBlocks
|
|
3145
3145
|
};
|
|
3146
|
-
//# sourceMappingURL=parser-
|
|
3146
|
+
//# sourceMappingURL=parser-DCK42RMA.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkITJIALN5cjs = require('./chunk-ITJIALN5.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -1496,7 +1496,7 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
1496
1496
|
new Promise((_, reject) => {
|
|
1497
1497
|
timer = setTimeout(() => {
|
|
1498
1498
|
loadingTask.destroy();
|
|
1499
|
-
reject(new (0,
|
|
1499
|
+
reject(new (0, _chunkITJIALN5cjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
1500
1500
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
1501
1501
|
})
|
|
1502
1502
|
]);
|
|
@@ -1509,7 +1509,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1509
1509
|
const doc = await loadPdfWithTimeout(buffer);
|
|
1510
1510
|
try {
|
|
1511
1511
|
const pageCount = doc.numPages;
|
|
1512
|
-
if (pageCount === 0) throw new (0,
|
|
1512
|
+
if (pageCount === 0) throw new (0, _chunkITJIALN5cjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
1513
1513
|
const metadata = { pageCount };
|
|
1514
1514
|
await extractPdfMetadata(doc, metadata);
|
|
1515
1515
|
const blocks = [];
|
|
@@ -1569,11 +1569,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1569
1569
|
pageText += pageText ? "\n" + t : t;
|
|
1570
1570
|
}
|
|
1571
1571
|
pageQuality.push(computePageQuality(i, pageText));
|
|
1572
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
1572
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkITJIALN5cjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
1573
1573
|
parsedPages++;
|
|
1574
1574
|
_optionalChain([options, 'optionalAccess', _12 => _12.onProgress, 'optionalCall', _13 => _13(parsedPages, totalTarget)]);
|
|
1575
1575
|
} catch (pageErr) {
|
|
1576
|
-
if (pageErr instanceof
|
|
1576
|
+
if (pageErr instanceof _chunkITJIALN5cjs.KordocError) throw pageErr;
|
|
1577
1577
|
warnings.push({ page: i, message: `\uD398\uC774\uC9C0 ${i} \uD30C\uC2F1 \uC2E4\uD328: ${pageErr instanceof Error ? pageErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
1578
1578
|
}
|
|
1579
1579
|
}
|
|
@@ -1641,7 +1641,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1641
1641
|
detectKoreanListBlocks(blocks);
|
|
1642
1642
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
1643
1643
|
sanitizeBlockControlChars(blocks);
|
|
1644
|
-
let markdown = cleanPdfText(
|
|
1644
|
+
let markdown = cleanPdfText(_chunkITJIALN5cjs.blocksToMarkdown.call(void 0, blocks));
|
|
1645
1645
|
return {
|
|
1646
1646
|
markdown,
|
|
1647
1647
|
blocks,
|
|
@@ -1729,9 +1729,9 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
1729
1729
|
if (/^\d+$/.test(text)) continue;
|
|
1730
1730
|
const ratio = block.style.fontSize / medianFontSize;
|
|
1731
1731
|
let level = 0;
|
|
1732
|
-
if (ratio >=
|
|
1733
|
-
else if (ratio >=
|
|
1734
|
-
else if (ratio >=
|
|
1732
|
+
if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H1) level = 1;
|
|
1733
|
+
else if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H2) level = 2;
|
|
1734
|
+
else if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H3) level = 3;
|
|
1735
1735
|
if (level > 0) {
|
|
1736
1736
|
block.type = "heading";
|
|
1737
1737
|
block.level = level;
|
|
@@ -2136,7 +2136,7 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
|
|
|
2136
2136
|
}
|
|
2137
2137
|
if (remaining.length > 0) {
|
|
2138
2138
|
const allY = remaining.map((i) => i.y);
|
|
2139
|
-
const pageH =
|
|
2139
|
+
const pageH = _chunkITJIALN5cjs.safeMax.call(void 0, allY) - _chunkITJIALN5cjs.safeMin.call(void 0, allY);
|
|
2140
2140
|
const groups = xyCutOrder(remaining, Math.max(15, pageH * 0.03));
|
|
2141
2141
|
const textBlocks = [];
|
|
2142
2142
|
for (const group of groups) {
|
|
@@ -2265,7 +2265,7 @@ function extractPageBlocksFallback(items, pageNum) {
|
|
|
2265
2265
|
blocks.push({ type: "paragraph", text: tableText, pageNumber: pageNum, bbox, style: dominantStyle(items) });
|
|
2266
2266
|
} else {
|
|
2267
2267
|
const allY = items.map((i) => i.y);
|
|
2268
|
-
const pageHeight =
|
|
2268
|
+
const pageHeight = _chunkITJIALN5cjs.safeMax.call(void 0, allY) - _chunkITJIALN5cjs.safeMin.call(void 0, allY);
|
|
2269
2269
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
2270
2270
|
const orderedGroups = xyCutOrder(items, gapThreshold);
|
|
2271
2271
|
for (const group of orderedGroups) {
|
|
@@ -2441,14 +2441,14 @@ function isProseSpread(items) {
|
|
|
2441
2441
|
for (let i = 1; i < sorted.length; i++) {
|
|
2442
2442
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
2443
2443
|
}
|
|
2444
|
-
const maxGap =
|
|
2444
|
+
const maxGap = _chunkITJIALN5cjs.safeMax.call(void 0, gaps);
|
|
2445
2445
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
2446
2446
|
return maxGap < 40 && avgLen < 5;
|
|
2447
2447
|
}
|
|
2448
2448
|
function detectColumns(yLines) {
|
|
2449
2449
|
const allItems = yLines.flat();
|
|
2450
2450
|
if (allItems.length === 0) return null;
|
|
2451
|
-
const pageWidth =
|
|
2451
|
+
const pageWidth = _chunkITJIALN5cjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkITJIALN5cjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
2452
2452
|
if (pageWidth < 100) return null;
|
|
2453
2453
|
let bigoLineIdx = -1;
|
|
2454
2454
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -3144,4 +3144,4 @@ function formatMb(bytes) {
|
|
|
3144
3144
|
|
|
3145
3145
|
|
|
3146
3146
|
exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.detectTableCaptions = detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks;
|
|
3147
|
-
//# sourceMappingURL=parser-
|
|
3147
|
+
//# sourceMappingURL=parser-GUSJH44K.cjs.map
|