kordoc 3.0.1 → 3.2.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 +48 -0
- package/dist/{-5BWAV4ZY.js → -MSRLLJNM.js} +23 -5
- package/dist/{chunk-X3SCCO5Q.js → chunk-7KFBGOXZ.js} +2 -2
- package/dist/{chunk-X3SCCO5Q.js.map → chunk-7KFBGOXZ.js.map} +1 -1
- package/dist/{chunk-X7VQVMXQ.js → chunk-CYLOXVYY.js} +2245 -1604
- package/dist/chunk-CYLOXVYY.js.map +1 -0
- package/dist/{chunk-MUOQXDZ4.cjs → chunk-DCZVOIEO.cjs} +1 -1
- package/dist/{chunk-MUOQXDZ4.cjs.map → chunk-DCZVOIEO.cjs.map} +1 -1
- package/dist/{chunk-SBVRCJFH.js → chunk-GE43BE46.js} +1 -1
- package/dist/chunk-GS7T56RP.cjs +8 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -0
- package/dist/{chunk-NBJB6TJB.cjs → chunk-SWEBVX5K.cjs} +2 -2
- package/dist/{chunk-NBJB6TJB.cjs.map → chunk-SWEBVX5K.cjs.map} +1 -1
- package/dist/{chunk-O5P6EG5L.js → chunk-ZWVTR2HQ.js} +2 -2
- package/dist/{chunk-O5P6EG5L.js.map → chunk-ZWVTR2HQ.js.map} +1 -1
- package/dist/cli.js +71 -4
- package/dist/cli.js.map +1 -1
- package/dist/{formula-XGG6ZP42.cjs → formula-5NKVS2LR.cjs} +4 -2
- package/dist/formula-5NKVS2LR.cjs.map +1 -0
- package/dist/{formula-3AQUUIRF.js → formula-RXVSQPXI.js} +1 -1
- package/dist/index.cjs +2400 -1756
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +306 -6
- package/dist/index.d.ts +306 -6
- package/dist/index.js +2248 -1607
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/page-range-LNMXJU6W.js +7 -0
- package/dist/page-range-P7SDW6LR.cjs +8 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -0
- package/dist/{parser-LZH7ZELV.js → parser-HAWIRFS4.js} +5 -5
- package/dist/{parser-5FZJVLQL.cjs → parser-LKIUKZJV.cjs} +19 -18
- package/dist/parser-LKIUKZJV.cjs.map +1 -0
- package/dist/{parser-3N6FZSKU.js → parser-U6KRTEB7.js} +2 -2
- package/dist/{provider-2SEHU2FM.js → provider-4ZJKV3DC.js} +1 -1
- package/dist/{provider-SNONEZNW.cjs → provider-G4C2V2PD.cjs} +4 -2
- package/dist/provider-G4C2V2PD.cjs.map +1 -0
- package/dist/{watch-4FMRS7QU.js → watch-OKZAU3I5.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-X7VQVMXQ.js.map +0 -1
- package/dist/formula-XGG6ZP42.cjs.map +0 -1
- package/dist/page-range-3C7UGGEK.cjs +0 -7
- package/dist/page-range-3C7UGGEK.cjs.map +0 -1
- package/dist/page-range-H35FN3OQ.js +0 -7
- package/dist/parser-5FZJVLQL.cjs.map +0 -1
- package/dist/provider-SNONEZNW.cjs.map +0 -1
- /package/dist/{-5BWAV4ZY.js.map → -MSRLLJNM.js.map} +0 -0
- /package/dist/{chunk-SBVRCJFH.js.map → chunk-GE43BE46.js.map} +0 -0
- /package/dist/{formula-3AQUUIRF.js.map → formula-RXVSQPXI.js.map} +0 -0
- /package/dist/{page-range-H35FN3OQ.js.map → page-range-LNMXJU6W.js.map} +0 -0
- /package/dist/{parser-LZH7ZELV.js.map → parser-HAWIRFS4.js.map} +0 -0
- /package/dist/{parser-3N6FZSKU.js.map → parser-U6KRTEB7.js.map} +0 -0
- /package/dist/{provider-2SEHU2FM.js.map → provider-4ZJKV3DC.js.map} +0 -0
- /package/dist/{watch-4FMRS7QU.js.map → watch-OKZAU3I5.js.map} +0 -0
package/dist/mcp.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
fillHwpx,
|
|
9
9
|
markdownToHwpx,
|
|
10
10
|
parse
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-CYLOXVYY.js";
|
|
12
12
|
import {
|
|
13
13
|
detectFormat,
|
|
14
14
|
detectZipFormat
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
blocksToMarkdown,
|
|
20
20
|
sanitizeError,
|
|
21
21
|
toArrayBuffer
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ZWVTR2HQ.js";
|
|
23
23
|
import "./chunk-MOL7MDBG.js";
|
|
24
24
|
|
|
25
25
|
// src/mcp.ts
|
|
@@ -191,7 +191,7 @@ server.tool(
|
|
|
191
191
|
break;
|
|
192
192
|
case "pdf":
|
|
193
193
|
try {
|
|
194
|
-
const { extractPdfMetadataOnly } = await import("./parser-
|
|
194
|
+
const { extractPdfMetadataOnly } = await import("./parser-U6KRTEB7.js");
|
|
195
195
|
metadata = await extractPdfMetadataOnly(buffer);
|
|
196
196
|
} catch {
|
|
197
197
|
metadata = void 0;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
4
|
+
require('./chunk-GS7T56RP.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.parsePageRange = _chunkDCZVOIEOcjs.parsePageRange;
|
|
8
|
+
//# sourceMappingURL=page-range-P7SDW6LR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/chris_gomdori/workspace/kordoc/dist/page-range-P7SDW6LR.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,0DAAC","file":"/Users/chris_gomdori/workspace/kordoc/dist/page-range-P7SDW6LR.cjs"}
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
blocksToMarkdown,
|
|
7
7
|
safeMax,
|
|
8
8
|
safeMin
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7KFBGOXZ.js";
|
|
10
10
|
import {
|
|
11
11
|
parsePageRange
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GE43BE46.js";
|
|
13
13
|
|
|
14
14
|
// src/pdf/line-detector.ts
|
|
15
15
|
import { OPS } from "pdfjs-dist/legacy/build/pdf.mjs";
|
|
@@ -1581,7 +1581,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1581
1581
|
if (totalChars / Math.max(parsedPageCount, 1) < 10) {
|
|
1582
1582
|
if (options?.ocr) {
|
|
1583
1583
|
try {
|
|
1584
|
-
const { ocrPages } = await import("./provider-
|
|
1584
|
+
const { ocrPages } = await import("./provider-4ZJKV3DC.js");
|
|
1585
1585
|
const ocrBlocks = await ocrPages(doc, options.ocr, pageFilter, effectivePageCount);
|
|
1586
1586
|
if (ocrBlocks.length > 0) {
|
|
1587
1587
|
const ocrMarkdown = ocrBlocks.map((b) => b.text || "").filter(Boolean).join("\n\n");
|
|
@@ -3017,7 +3017,7 @@ function mergeKoreanLines(text) {
|
|
|
3017
3017
|
return result.join("\n");
|
|
3018
3018
|
}
|
|
3019
3019
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3020
|
-
const formulaMod = await import("./formula-
|
|
3020
|
+
const formulaMod = await import("./formula-RXVSQPXI.js");
|
|
3021
3021
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3022
3022
|
await ensureFormulaModels((p) => {
|
|
3023
3023
|
if (p.phase === "download" && p.total) {
|
|
@@ -3143,4 +3143,4 @@ export {
|
|
|
3143
3143
|
parsePdfDocument,
|
|
3144
3144
|
removeHeaderFooterBlocks
|
|
3145
3145
|
};
|
|
3146
|
-
//# sourceMappingURL=parser-
|
|
3146
|
+
//# sourceMappingURL=parser-HAWIRFS4.js.map
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkSWEBVX5Kcjs = require('./chunk-SWEBVX5K.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
13
|
+
require('./chunk-GS7T56RP.cjs');
|
|
13
14
|
|
|
14
15
|
// src/pdf/line-detector.ts
|
|
15
16
|
var _pdfmjs = require('pdfjs-dist/legacy/build/pdf.mjs');
|
|
@@ -1495,7 +1496,7 @@ async function loadPdfWithTimeout(buffer) {
|
|
|
1495
1496
|
new Promise((_, reject) => {
|
|
1496
1497
|
timer = setTimeout(() => {
|
|
1497
1498
|
loadingTask.destroy();
|
|
1498
|
-
reject(new (0,
|
|
1499
|
+
reject(new (0, _chunkSWEBVX5Kcjs.KordocError)("PDF \uB85C\uB529 \uD0C0\uC784\uC544\uC6C3 (30\uCD08 \uCD08\uACFC)"));
|
|
1499
1500
|
}, PDF_LOAD_TIMEOUT_MS);
|
|
1500
1501
|
})
|
|
1501
1502
|
]);
|
|
@@ -1508,7 +1509,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1508
1509
|
const doc = await loadPdfWithTimeout(buffer);
|
|
1509
1510
|
try {
|
|
1510
1511
|
const pageCount = doc.numPages;
|
|
1511
|
-
if (pageCount === 0) throw new (0,
|
|
1512
|
+
if (pageCount === 0) throw new (0, _chunkSWEBVX5Kcjs.KordocError)("PDF\uC5D0 \uD398\uC774\uC9C0\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
1512
1513
|
const metadata = { pageCount };
|
|
1513
1514
|
await extractPdfMetadata(doc, metadata);
|
|
1514
1515
|
const blocks = [];
|
|
@@ -1517,7 +1518,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1517
1518
|
let totalChars = 0;
|
|
1518
1519
|
let totalTextBytes = 0;
|
|
1519
1520
|
const effectivePageCount = Math.min(pageCount, MAX_PAGES);
|
|
1520
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _11 => _11.pages]) ?
|
|
1521
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _11 => _11.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, effectivePageCount) : null;
|
|
1521
1522
|
const totalTarget = pageFilter ? pageFilter.size : effectivePageCount;
|
|
1522
1523
|
const fontSizeFreq = /* @__PURE__ */ new Map();
|
|
1523
1524
|
const pageHeights = /* @__PURE__ */ new Map();
|
|
@@ -1568,11 +1569,11 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1568
1569
|
pageText += pageText ? "\n" + t : t;
|
|
1569
1570
|
}
|
|
1570
1571
|
pageQuality.push(computePageQuality(i, pageText));
|
|
1571
|
-
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0,
|
|
1572
|
+
if (totalTextBytes > MAX_TOTAL_TEXT) throw new (0, _chunkSWEBVX5Kcjs.KordocError)("\uD14D\uC2A4\uD2B8 \uCD94\uCD9C \uD06C\uAE30 \uCD08\uACFC");
|
|
1572
1573
|
parsedPages++;
|
|
1573
1574
|
_optionalChain([options, 'optionalAccess', _12 => _12.onProgress, 'optionalCall', _13 => _13(parsedPages, totalTarget)]);
|
|
1574
1575
|
} catch (pageErr) {
|
|
1575
|
-
if (pageErr instanceof
|
|
1576
|
+
if (pageErr instanceof _chunkSWEBVX5Kcjs.KordocError) throw pageErr;
|
|
1576
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" });
|
|
1577
1578
|
}
|
|
1578
1579
|
}
|
|
@@ -1581,7 +1582,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1581
1582
|
if (totalChars / Math.max(parsedPageCount, 1) < 10) {
|
|
1582
1583
|
if (_optionalChain([options, 'optionalAccess', _14 => _14.ocr])) {
|
|
1583
1584
|
try {
|
|
1584
|
-
const { ocrPages } = await Promise.resolve().then(() => _interopRequireWildcard(require("./provider-
|
|
1585
|
+
const { ocrPages } = await Promise.resolve().then(() => _interopRequireWildcard(require("./provider-G4C2V2PD.cjs")));
|
|
1585
1586
|
const ocrBlocks = await ocrPages(doc, options.ocr, pageFilter, effectivePageCount);
|
|
1586
1587
|
if (ocrBlocks.length > 0) {
|
|
1587
1588
|
const ocrMarkdown = ocrBlocks.map((b) => b.text || "").filter(Boolean).join("\n\n");
|
|
@@ -1640,7 +1641,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
1640
1641
|
detectKoreanListBlocks(blocks);
|
|
1641
1642
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
1642
1643
|
sanitizeBlockControlChars(blocks);
|
|
1643
|
-
let markdown = cleanPdfText(
|
|
1644
|
+
let markdown = cleanPdfText(_chunkSWEBVX5Kcjs.blocksToMarkdown.call(void 0, blocks));
|
|
1644
1645
|
return {
|
|
1645
1646
|
markdown,
|
|
1646
1647
|
blocks,
|
|
@@ -1728,9 +1729,9 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
1728
1729
|
if (/^\d+$/.test(text)) continue;
|
|
1729
1730
|
const ratio = block.style.fontSize / medianFontSize;
|
|
1730
1731
|
let level = 0;
|
|
1731
|
-
if (ratio >=
|
|
1732
|
-
else if (ratio >=
|
|
1733
|
-
else if (ratio >=
|
|
1732
|
+
if (ratio >= _chunkSWEBVX5Kcjs.HEADING_RATIO_H1) level = 1;
|
|
1733
|
+
else if (ratio >= _chunkSWEBVX5Kcjs.HEADING_RATIO_H2) level = 2;
|
|
1734
|
+
else if (ratio >= _chunkSWEBVX5Kcjs.HEADING_RATIO_H3) level = 3;
|
|
1734
1735
|
if (level > 0) {
|
|
1735
1736
|
block.type = "heading";
|
|
1736
1737
|
block.level = level;
|
|
@@ -2135,7 +2136,7 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
|
|
|
2135
2136
|
}
|
|
2136
2137
|
if (remaining.length > 0) {
|
|
2137
2138
|
const allY = remaining.map((i) => i.y);
|
|
2138
|
-
const pageH =
|
|
2139
|
+
const pageH = _chunkSWEBVX5Kcjs.safeMax.call(void 0, allY) - _chunkSWEBVX5Kcjs.safeMin.call(void 0, allY);
|
|
2139
2140
|
const groups = xyCutOrder(remaining, Math.max(15, pageH * 0.03));
|
|
2140
2141
|
const textBlocks = [];
|
|
2141
2142
|
for (const group of groups) {
|
|
@@ -2264,7 +2265,7 @@ function extractPageBlocksFallback(items, pageNum) {
|
|
|
2264
2265
|
blocks.push({ type: "paragraph", text: tableText, pageNumber: pageNum, bbox, style: dominantStyle(items) });
|
|
2265
2266
|
} else {
|
|
2266
2267
|
const allY = items.map((i) => i.y);
|
|
2267
|
-
const pageHeight =
|
|
2268
|
+
const pageHeight = _chunkSWEBVX5Kcjs.safeMax.call(void 0, allY) - _chunkSWEBVX5Kcjs.safeMin.call(void 0, allY);
|
|
2268
2269
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
2269
2270
|
const orderedGroups = xyCutOrder(items, gapThreshold);
|
|
2270
2271
|
for (const group of orderedGroups) {
|
|
@@ -2440,14 +2441,14 @@ function isProseSpread(items) {
|
|
|
2440
2441
|
for (let i = 1; i < sorted.length; i++) {
|
|
2441
2442
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
2442
2443
|
}
|
|
2443
|
-
const maxGap =
|
|
2444
|
+
const maxGap = _chunkSWEBVX5Kcjs.safeMax.call(void 0, gaps);
|
|
2444
2445
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
2445
2446
|
return maxGap < 40 && avgLen < 5;
|
|
2446
2447
|
}
|
|
2447
2448
|
function detectColumns(yLines) {
|
|
2448
2449
|
const allItems = yLines.flat();
|
|
2449
2450
|
if (allItems.length === 0) return null;
|
|
2450
|
-
const pageWidth =
|
|
2451
|
+
const pageWidth = _chunkSWEBVX5Kcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkSWEBVX5Kcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
2451
2452
|
if (pageWidth < 100) return null;
|
|
2452
2453
|
let bigoLineIdx = -1;
|
|
2453
2454
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -3017,7 +3018,7 @@ function mergeKoreanLines(text) {
|
|
|
3017
3018
|
return result.join("\n");
|
|
3018
3019
|
}
|
|
3019
3020
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3020
|
-
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-
|
|
3021
|
+
const formulaMod = await Promise.resolve().then(() => _interopRequireWildcard(require("./formula-5NKVS2LR.cjs")));
|
|
3021
3022
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3022
3023
|
await ensureFormulaModels((p) => {
|
|
3023
3024
|
if (p.phase === "download" && p.total) {
|
|
@@ -3143,4 +3144,4 @@ function formatMb(bytes) {
|
|
|
3143
3144
|
|
|
3144
3145
|
|
|
3145
3146
|
exports.cleanPdfText = cleanPdfText; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.detectTableCaptions = detectTableCaptions; exports.extractPdfMetadataOnly = extractPdfMetadataOnly; exports.mergeCrossPageTables = mergeCrossPageTables; exports.parsePdfDocument = parsePdfDocument; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks;
|
|
3146
|
-
//# sourceMappingURL=parser-
|
|
3147
|
+
//# sourceMappingURL=parser-LKIUKZJV.cjs.map
|