kordoc 4.4.0 → 4.4.1
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 +9 -3
- package/dist/{-R6NUMPRV.js → -7X4H77Z7.js} +8 -8
- package/dist/{chunk-YOZ7ZRCD.js → chunk-2352RXHG.js} +8 -8
- package/dist/{chunk-SKM6KZUH.cjs → chunk-3DX6VJGH.cjs} +9 -9
- package/dist/{chunk-SKM6KZUH.cjs.map → chunk-3DX6VJGH.cjs.map} +1 -1
- package/dist/{chunk-GHGZU2LQ.js → chunk-5A2TGIN7.js} +2 -2
- package/dist/{chunk-65DYCXGC.js → chunk-5PXCA3DN.js} +3 -3
- package/dist/{chunk-H2KMJOB6.cjs → chunk-7BIVNIK5.cjs} +2 -2
- package/dist/{chunk-H2KMJOB6.cjs.map → chunk-7BIVNIK5.cjs.map} +1 -1
- package/dist/{chunk-HNRULYUH.js → chunk-7MDLAKVO.js} +2 -2
- package/dist/{chunk-YVYU267E.js → chunk-AYM6UHFX.js} +2 -2
- package/dist/chunk-AYM6UHFX.js.map +1 -0
- package/dist/{chunk-AB322K3O.cjs → chunk-FR65WNLF.cjs} +3 -3
- package/dist/{chunk-AB322K3O.cjs.map → chunk-FR65WNLF.cjs.map} +1 -1
- package/dist/{chunk-UDGPM5R5.cjs → chunk-GC7WBHAN.cjs} +4 -4
- package/dist/{chunk-UDGPM5R5.cjs.map → chunk-GC7WBHAN.cjs.map} +1 -1
- package/dist/{chunk-W6CUD7V3.js → chunk-HGSO2H44.js} +2 -2
- package/dist/{chunk-RZURSA4N.js → chunk-IPOVUGXD.js} +3 -3
- package/dist/{chunk-5KLE3U23.js → chunk-JGHQFUKI.js} +2 -2
- package/dist/{chunk-V35DRUJC.js → chunk-NUGTEPKT.js} +2 -2
- package/dist/{chunk-QXYB74QF.js → chunk-SMPEZINI.js} +2 -2
- package/dist/{chunk-ONS7JKVA.js → chunk-T25FBUMN.js} +2 -2
- package/dist/{chunk-HFJF477F.js → chunk-TGAWXMXB.js} +2 -2
- package/dist/chunk-TGAWXMXB.js.map +1 -0
- package/dist/{chunk-XCIC7U6Y.js → chunk-UA53AA7R.js} +2 -2
- package/dist/{chunk-P7YPCK7C.js → chunk-WA7XLWZW.js} +2 -2
- package/dist/chunks-FMZK4QHL.js +10 -0
- package/dist/cli.js +16 -16
- package/dist/{image-ocr-U2DRRFL3.js → image-ocr-AHHY42OI.js} +4 -4
- package/dist/{image-ocr-XC52AQDV.js → image-ocr-K4XCRBTY.js} +4 -4
- package/dist/{image-ocr-F2BQA26V.cjs → image-ocr-VCXLT5Q6.cjs} +10 -10
- package/dist/{image-ocr-F2BQA26V.cjs.map → image-ocr-VCXLT5Q6.cjs.map} +1 -1
- package/dist/index.cjs +178 -178
- package/dist/index.js +4 -4
- package/dist/mcp.js +26 -24
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-FFQN67O6.cjs → parser-ABYM2MVN.cjs} +24 -24
- package/dist/{parser-FFQN67O6.cjs.map → parser-ABYM2MVN.cjs.map} +1 -1
- package/dist/{parser-ESGFWWCT.js → parser-I3ELUUOG.js} +5 -5
- package/dist/{parser-TFPGQWCC.js → parser-IPVY56U3.js} +5 -5
- package/dist/pdf-ocr-EL3VSWWY.js +12 -0
- package/dist/{pdf-ocr-WE5TMRFU.js → pdf-ocr-FVLKQNAT.js} +4 -4
- package/dist/pdf-ocr-VQ3QWXGE.cjs +13 -0
- package/dist/{pdf-ocr-UQBZH3HE.cjs.map → pdf-ocr-VQ3QWXGE.cjs.map} +1 -1
- package/dist/{profile-io-O6BDCUJN.js → profile-io-YADU6SKH.js} +3 -3
- package/dist/{rasterize-V22VCCE7.js → rasterize-YV5VDSQX.js} +2 -2
- package/dist/render-K6M3P24X.js +10 -0
- package/dist/seal-YW3U5BCY.js +10 -0
- package/dist/{watch-HGKBICED.js → watch-5K2ZERXI.js} +8 -8
- package/package.json +1 -1
- package/dist/chunk-HFJF477F.js.map +0 -1
- package/dist/chunk-YVYU267E.js.map +0 -1
- package/dist/chunks-QMGCI5DG.js +0 -10
- package/dist/pdf-ocr-4R646OO6.js +0 -12
- package/dist/pdf-ocr-UQBZH3HE.cjs +0 -13
- package/dist/render-3BSVTTZE.js +0 -10
- package/dist/seal-6ZSEJVOD.js +0 -10
- /package/dist/{-R6NUMPRV.js.map → -7X4H77Z7.js.map} +0 -0
- /package/dist/{chunk-YOZ7ZRCD.js.map → chunk-2352RXHG.js.map} +0 -0
- /package/dist/{chunk-GHGZU2LQ.js.map → chunk-5A2TGIN7.js.map} +0 -0
- /package/dist/{chunk-65DYCXGC.js.map → chunk-5PXCA3DN.js.map} +0 -0
- /package/dist/{chunk-HNRULYUH.js.map → chunk-7MDLAKVO.js.map} +0 -0
- /package/dist/{chunk-W6CUD7V3.js.map → chunk-HGSO2H44.js.map} +0 -0
- /package/dist/{chunk-RZURSA4N.js.map → chunk-IPOVUGXD.js.map} +0 -0
- /package/dist/{chunk-5KLE3U23.js.map → chunk-JGHQFUKI.js.map} +0 -0
- /package/dist/{chunk-V35DRUJC.js.map → chunk-NUGTEPKT.js.map} +0 -0
- /package/dist/{chunk-QXYB74QF.js.map → chunk-SMPEZINI.js.map} +0 -0
- /package/dist/{chunk-ONS7JKVA.js.map → chunk-T25FBUMN.js.map} +0 -0
- /package/dist/{chunk-XCIC7U6Y.js.map → chunk-UA53AA7R.js.map} +0 -0
- /package/dist/{chunk-P7YPCK7C.js.map → chunk-WA7XLWZW.js.map} +0 -0
- /package/dist/{chunks-QMGCI5DG.js.map → chunks-FMZK4QHL.js.map} +0 -0
- /package/dist/{image-ocr-U2DRRFL3.js.map → image-ocr-AHHY42OI.js.map} +0 -0
- /package/dist/{image-ocr-XC52AQDV.js.map → image-ocr-K4XCRBTY.js.map} +0 -0
- /package/dist/{parser-ESGFWWCT.js.map → parser-I3ELUUOG.js.map} +0 -0
- /package/dist/{parser-TFPGQWCC.js.map → parser-IPVY56U3.js.map} +0 -0
- /package/dist/{pdf-ocr-4R646OO6.js.map → pdf-ocr-EL3VSWWY.js.map} +0 -0
- /package/dist/{pdf-ocr-WE5TMRFU.js.map → pdf-ocr-FVLKQNAT.js.map} +0 -0
- /package/dist/{profile-io-O6BDCUJN.js.map → profile-io-YADU6SKH.js.map} +0 -0
- /package/dist/{rasterize-V22VCCE7.js.map → rasterize-YV5VDSQX.js.map} +0 -0
- /package/dist/{render-3BSVTTZE.js.map → render-K6M3P24X.js.map} +0 -0
- /package/dist/{seal-6ZSEJVOD.js.map → seal-YW3U5BCY.js.map} +0 -0
- /package/dist/{watch-HGKBICED.js.map → watch-5K2ZERXI.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkGC7WBHANcjs = require('./chunk-GC7WBHAN.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -27,7 +27,7 @@ var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunk7BIVNIK5cjs = require('./chunk-7BIVNIK5.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -482,7 +482,7 @@ function rawTextContent(node, depth = 0) {
|
|
|
482
482
|
// src/hwpx/parser-shared.ts
|
|
483
483
|
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
484
484
|
var MAX_ZIP_ENTRIES = 500;
|
|
485
|
-
var ZipBombError = class extends
|
|
485
|
+
var ZipBombError = class extends _chunk7BIVNIK5cjs.KordocError {
|
|
486
486
|
constructor(message) {
|
|
487
487
|
super(message);
|
|
488
488
|
this.name = "ZipBombError";
|
|
@@ -497,7 +497,7 @@ function createSectionShared() {
|
|
|
497
497
|
function createXmlParser(warnings) {
|
|
498
498
|
return new (0, _xmldom.DOMParser)({
|
|
499
499
|
onError(level, msg2) {
|
|
500
|
-
if (level === "fatalError") throw new (0,
|
|
500
|
+
if (level === "fatalError") throw new (0, _chunk7BIVNIK5cjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
501
501
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
502
502
|
}
|
|
503
503
|
});
|
|
@@ -532,13 +532,13 @@ function parseEncryptionManifest(manifestXml) {
|
|
|
532
532
|
const startKey = attrOf(inner, "start-key-generation-name");
|
|
533
533
|
const checksumType = attrOf(inner, "checksum-type");
|
|
534
534
|
if (algorithm !== AES256_CBC) {
|
|
535
|
-
throw new (0,
|
|
535
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uC554\uD638\uD654 \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(algorithm, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
536
536
|
}
|
|
537
537
|
if (startKey !== START_KEY_SHA256) {
|
|
538
|
-
throw new (0,
|
|
538
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uC2DC\uC791\uD0A4 \uC0DD\uC131 \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(startKey, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
539
539
|
}
|
|
540
540
|
if (!_optionalChain([checksumType, 'optionalAccess', _8 => _8.endsWith, 'call', _9 => _9(CHECKSUM_SHA256_1K)])) {
|
|
541
|
-
throw new (0,
|
|
541
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uCCB4\uD06C\uC12C \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(checksumType, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
542
542
|
}
|
|
543
543
|
const iterations = parseInt(_nullishCoalesce(attrOf(inner, "iteration-count"), () => ( "")), 10);
|
|
544
544
|
const keySize = parseInt(_nullishCoalesce(attrOf(inner, "key-size"), () => ( "")), 10);
|
|
@@ -546,10 +546,10 @@ function parseEncryptionManifest(manifestXml) {
|
|
|
546
546
|
const salt = Buffer.from(_nullishCoalesce(attrOf(inner, "salt"), () => ( "")), "base64");
|
|
547
547
|
const checksum = Buffer.from(_nullishCoalesce(attrOf(inner, "checksum"), () => ( "")), "base64");
|
|
548
548
|
if (!(iterations > 0 && iterations <= MAX_ITERATION_COUNT)) {
|
|
549
|
-
throw new (0,
|
|
549
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`HWPX \uC554\uD638\uD654 \uBC18\uBCF5 \uD69F\uC218\uAC00 \uD5C8\uC6A9 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0AC\uC2B5\uB2C8\uB2E4: ${iterations}`);
|
|
550
550
|
}
|
|
551
551
|
if (keySize !== 32 || iv.length !== 16 || salt.length === 0 || checksum.length !== 32) {
|
|
552
|
-
throw new (0,
|
|
552
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`HWPX \uC554\uD638\uD654 \uD30C\uB77C\uBBF8\uD130\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4 (${path})`);
|
|
553
553
|
}
|
|
554
554
|
entries.push({ path, checksum, iv, salt, iterations, keySize });
|
|
555
555
|
}
|
|
@@ -582,11 +582,11 @@ async function decryptHwpxInPlace(zip, manifestXml, password) {
|
|
|
582
582
|
for (const entry of entries) {
|
|
583
583
|
const file = zip.file(entry.path);
|
|
584
584
|
if (!file) {
|
|
585
|
-
throw new (0,
|
|
585
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`\uC554\uD638 \uBAA9\uB85D\uC5D0 \uC788\uB294 \uD30C\uC77C\uC774 \uBB38\uC11C\uC5D0 \uC5C6\uC2B5\uB2C8\uB2E4: ${entry.path}`);
|
|
586
586
|
}
|
|
587
587
|
const plain = decryptEntry(await file.async("nodebuffer"), entry, startKey);
|
|
588
588
|
if (!plain) {
|
|
589
|
-
throw new (0,
|
|
589
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
590
590
|
}
|
|
591
591
|
decrypted.push({ path: entry.path, plain });
|
|
592
592
|
}
|
|
@@ -634,10 +634,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
634
634
|
const xml = await file.async("text");
|
|
635
635
|
if (decompressed) {
|
|
636
636
|
decompressed.total += xml.length * 2;
|
|
637
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
637
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
638
638
|
}
|
|
639
639
|
const parser = createXmlParser();
|
|
640
|
-
const doc = parser.parseFromString(
|
|
640
|
+
const doc = parser.parseFromString(_chunk7BIVNIK5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
641
641
|
if (!doc.documentElement) continue;
|
|
642
642
|
const domDoc = doc;
|
|
643
643
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -824,9 +824,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
824
824
|
let level = 0;
|
|
825
825
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _16 => _16.style, 'optionalAccess', _17 => _17.fontSize])) {
|
|
826
826
|
const ratio = block.style.fontSize / baseFontSize;
|
|
827
|
-
if (ratio >=
|
|
828
|
-
else if (ratio >=
|
|
829
|
-
else if (ratio >=
|
|
827
|
+
if (ratio >= _chunk7BIVNIK5cjs.HEADING_RATIO_H1) level = 1;
|
|
828
|
+
else if (ratio >= _chunk7BIVNIK5cjs.HEADING_RATIO_H2) level = 2;
|
|
829
|
+
else if (ratio >= _chunk7BIVNIK5cjs.HEADING_RATIO_H3) level = 3;
|
|
830
830
|
}
|
|
831
831
|
const compactText = text.replace(/\s+/g, "");
|
|
832
832
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1419,7 +1419,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1419
1419
|
|
|
1420
1420
|
// src/hwpx/table-build.ts
|
|
1421
1421
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols, keepEmptyParagraphs) {
|
|
1422
|
-
const table2 =
|
|
1422
|
+
const table2 = _chunkGC7WBHANcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols, keepEmptyParagraphs });
|
|
1423
1423
|
if (state.caption) table2.caption = state.caption;
|
|
1424
1424
|
if (_optionalChain([state, 'access', _21 => _21.captionBlocks, 'optionalAccess', _22 => _22.length])) table2.captionBlocks = state.captionBlocks;
|
|
1425
1425
|
const anchors = [];
|
|
@@ -1490,7 +1490,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1490
1490
|
const cell2 = parentTable.cell;
|
|
1491
1491
|
(cell2.blocks ??= []).push(block);
|
|
1492
1492
|
cell2.hasStructure = true;
|
|
1493
|
-
let flat =
|
|
1493
|
+
let flat = _chunkGC7WBHANcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1494
1494
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1495
1495
|
if (flat) {
|
|
1496
1496
|
const inlineJoin = newTable.inline === true && cell2.lineOpen === true;
|
|
@@ -1506,7 +1506,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1506
1506
|
// src/hwpx/section-walker.ts
|
|
1507
1507
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1508
1508
|
const parser = createXmlParser(warnings);
|
|
1509
|
-
const doc = parser.parseFromString(
|
|
1509
|
+
const doc = parser.parseFromString(_chunk7BIVNIK5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1510
1510
|
if (!doc.documentElement) return [];
|
|
1511
1511
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1512
1512
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1613,8 +1613,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1613
1613
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1614
1614
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1615
1615
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1616
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1617
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1616
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkGC7WBHANcjs.MAX_COLS);
|
|
1617
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkGC7WBHANcjs.MAX_ROWS);
|
|
1618
1618
|
}
|
|
1619
1619
|
break;
|
|
1620
1620
|
case "p": {
|
|
@@ -1885,7 +1885,7 @@ function buildSubListTable(el, ctx, depth) {
|
|
|
1885
1885
|
const sink = [];
|
|
1886
1886
|
const st = { rows: [], currentRow: [], cell: null };
|
|
1887
1887
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
1888
|
-
let flat =
|
|
1888
|
+
let flat = _chunkGC7WBHANcjs.convertTableToText.call(void 0, st.rows);
|
|
1889
1889
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
1890
1890
|
const built = [];
|
|
1891
1891
|
completeTable(st, [], built, ctx);
|
|
@@ -2040,7 +2040,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2040
2040
|
let url = (ch.textContent || "").trim();
|
|
2041
2041
|
if (!url) continue;
|
|
2042
2042
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2043
|
-
const safe =
|
|
2043
|
+
const safe = _chunk7BIVNIK5cjs.sanitizeHref.call(void 0, url);
|
|
2044
2044
|
if (safe) return safe;
|
|
2045
2045
|
}
|
|
2046
2046
|
return void 0;
|
|
@@ -2200,7 +2200,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2200
2200
|
case "hyperlink": {
|
|
2201
2201
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2202
2202
|
if (url) {
|
|
2203
|
-
const safe =
|
|
2203
|
+
const safe = _chunk7BIVNIK5cjs.sanitizeHref.call(void 0, url);
|
|
2204
2204
|
if (safe) href = safe;
|
|
2205
2205
|
}
|
|
2206
2206
|
walk(child, depth + 1);
|
|
@@ -2481,7 +2481,7 @@ function decompressStream(data) {
|
|
|
2481
2481
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2482
2482
|
}
|
|
2483
2483
|
function parseFileHeader(data) {
|
|
2484
|
-
if (data.length < 40) throw new (0,
|
|
2484
|
+
if (data.length < 40) throw new (0, _chunk7BIVNIK5cjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2485
2485
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2486
2486
|
return {
|
|
2487
2487
|
signature: sig,
|
|
@@ -2933,13 +2933,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2933
2933
|
}
|
|
2934
2934
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
2935
2935
|
for (const path of allCandidates) {
|
|
2936
|
-
if (
|
|
2936
|
+
if (_chunk7BIVNIK5cjs.isPathTraversal.call(void 0, path)) continue;
|
|
2937
2937
|
const file = zip.file(path);
|
|
2938
2938
|
if (!file) continue;
|
|
2939
2939
|
try {
|
|
2940
2940
|
const data = await file.async("uint8array");
|
|
2941
2941
|
decompressed.total += data.length;
|
|
2942
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2942
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2943
2943
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
2944
2944
|
const mimeType = imageExtToMime(ext);
|
|
2945
2945
|
imageIndex++;
|
|
@@ -2949,7 +2949,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2949
2949
|
usedPaths.add(path);
|
|
2950
2950
|
break;
|
|
2951
2951
|
} catch (err) {
|
|
2952
|
-
if (err instanceof
|
|
2952
|
+
if (err instanceof _chunk7BIVNIK5cjs.KordocError) throw err;
|
|
2953
2953
|
}
|
|
2954
2954
|
}
|
|
2955
2955
|
if (!img) _optionalChain([warnings, 'optionalAccess', _80 => _80.push, 'call', _81 => _81({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -2969,11 +2969,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2969
2969
|
if (sweepUnreferenced) {
|
|
2970
2970
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
2971
2971
|
for (const file of binEntries) {
|
|
2972
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
2972
|
+
if (file.dir || usedPaths.has(file.name) || _chunk7BIVNIK5cjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
2973
2973
|
try {
|
|
2974
2974
|
const data = await file.async("uint8array");
|
|
2975
2975
|
decompressed.total += data.length;
|
|
2976
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
2976
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
2977
2977
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
2978
2978
|
let mimeType = imageExtToMime(ext);
|
|
2979
2979
|
if (mimeType === "application/octet-stream") {
|
|
@@ -2987,7 +2987,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
2987
2987
|
images.push(img);
|
|
2988
2988
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
2989
2989
|
} catch (err) {
|
|
2990
|
-
if (err instanceof
|
|
2990
|
+
if (err instanceof _chunk7BIVNIK5cjs.KordocError) throw err;
|
|
2991
2991
|
_optionalChain([warnings, 'optionalAccess', _82 => _82.push, 'call', _83 => _83({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
2992
2992
|
}
|
|
2993
2993
|
}
|
|
@@ -3038,7 +3038,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3038
3038
|
}
|
|
3039
3039
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3040
3040
|
const name = new TextDecoder().decode(nameBytes);
|
|
3041
|
-
if (
|
|
3041
|
+
if (_chunk7BIVNIK5cjs.isPathTraversal.call(void 0, name)) {
|
|
3042
3042
|
pos = fileStart + compSize;
|
|
3043
3043
|
continue;
|
|
3044
3044
|
}
|
|
@@ -3056,16 +3056,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3056
3056
|
continue;
|
|
3057
3057
|
}
|
|
3058
3058
|
totalDecompressed += content.length * 2;
|
|
3059
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3059
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3060
3060
|
sectionNum++;
|
|
3061
3061
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3062
3062
|
} catch (e17) {
|
|
3063
3063
|
continue;
|
|
3064
3064
|
}
|
|
3065
3065
|
}
|
|
3066
|
-
if (blocks.length === 0) throw new (0,
|
|
3066
|
+
if (blocks.length === 0) throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3067
3067
|
applyPageText(blocks, shared);
|
|
3068
|
-
const markdown =
|
|
3068
|
+
const markdown = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3069
3069
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3070
3070
|
}
|
|
3071
3071
|
async function readKordocLayout(zip) {
|
|
@@ -3090,18 +3090,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3090
3090
|
if (paths.length > 0) return paths;
|
|
3091
3091
|
}
|
|
3092
3092
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3093
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3093
|
+
return sectionFiles.map((f) => f.name).sort(_chunk7BIVNIK5cjs.compareSectionPaths);
|
|
3094
3094
|
}
|
|
3095
3095
|
function parseSectionPathsFromManifest(xml) {
|
|
3096
3096
|
const parser = createXmlParser();
|
|
3097
|
-
const doc = parser.parseFromString(
|
|
3097
|
+
const doc = parser.parseFromString(_chunk7BIVNIK5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3098
3098
|
const items = doc.getElementsByTagName("opf:item");
|
|
3099
3099
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3100
3100
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3101
3101
|
for (let i = 0; i < items.length; i++) {
|
|
3102
3102
|
const item = items[i];
|
|
3103
3103
|
const id = item.getAttribute("id") || "";
|
|
3104
|
-
const href =
|
|
3104
|
+
const href = _chunk7BIVNIK5cjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3105
3105
|
if (id && href) idToHref.set(id, href);
|
|
3106
3106
|
}
|
|
3107
3107
|
if (spine.length > 0) {
|
|
@@ -3112,7 +3112,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3112
3112
|
}
|
|
3113
3113
|
if (ordered.length > 0) return ordered;
|
|
3114
3114
|
}
|
|
3115
|
-
return Array.from(idToHref.values()).sort(
|
|
3115
|
+
return Array.from(idToHref.values()).sort(_chunk7BIVNIK5cjs.compareSectionPaths);
|
|
3116
3116
|
}
|
|
3117
3117
|
|
|
3118
3118
|
// src/hwpx/metadata.ts
|
|
@@ -3125,7 +3125,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3125
3125
|
const xml = await file.async("text");
|
|
3126
3126
|
if (decompressed) {
|
|
3127
3127
|
decompressed.total += xml.length * 2;
|
|
3128
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3128
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3129
3129
|
}
|
|
3130
3130
|
parseDublinCoreMetadata(xml, metadata);
|
|
3131
3131
|
if (metadata.title || metadata.author) return;
|
|
@@ -3135,7 +3135,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3135
3135
|
}
|
|
3136
3136
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3137
3137
|
const parser = createXmlParser();
|
|
3138
|
-
const doc = parser.parseFromString(
|
|
3138
|
+
const doc = parser.parseFromString(_chunk7BIVNIK5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3139
3139
|
if (!doc.documentElement) return;
|
|
3140
3140
|
const getText = (tagNames) => {
|
|
3141
3141
|
for (const tag of tagNames) {
|
|
@@ -3160,7 +3160,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3160
3160
|
|
|
3161
3161
|
// src/hwpx/parser.ts
|
|
3162
3162
|
async function parseHwpxDocument(buffer, options) {
|
|
3163
|
-
|
|
3163
|
+
_chunk7BIVNIK5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3164
3164
|
let zip;
|
|
3165
3165
|
try {
|
|
3166
3166
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3169,7 +3169,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3169
3169
|
}
|
|
3170
3170
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3171
3171
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3172
|
-
throw new (0,
|
|
3172
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3173
3173
|
}
|
|
3174
3174
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3175
3175
|
if (manifestFile) {
|
|
@@ -3184,7 +3184,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3184
3184
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3185
3185
|
}
|
|
3186
3186
|
}
|
|
3187
|
-
throw new (0,
|
|
3187
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
3188
3188
|
"\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694."
|
|
3189
3189
|
);
|
|
3190
3190
|
}
|
|
@@ -3196,7 +3196,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3196
3196
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3197
3197
|
const warnings = [];
|
|
3198
3198
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3199
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3199
|
+
if (sectionPaths.length === 0) throw new (0, _chunk7BIVNIK5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3200
3200
|
metadata.pageCount = sectionPaths.length;
|
|
3201
3201
|
const pageFilter = _optionalChain([options, 'optionalAccess', _93 => _93.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3202
3202
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -3226,7 +3226,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3226
3226
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3227
3227
|
detectHwpxHeadings(blocks, styleMap);
|
|
3228
3228
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3229
|
-
const markdown =
|
|
3229
|
+
const markdown = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3230
3230
|
return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
3231
3231
|
}
|
|
3232
3232
|
|
|
@@ -4226,7 +4226,7 @@ function decryptPasswordStream(raw, password) {
|
|
|
4226
4226
|
var TAG_DOCUMENT_PROPERTIES = 16;
|
|
4227
4227
|
var TAG_ID_MAPPINGS = 17;
|
|
4228
4228
|
function assertDecryptedDocInfo(data, readRecords3) {
|
|
4229
|
-
const wrong = () => new (0,
|
|
4229
|
+
const wrong = () => new (0, _chunk7BIVNIK5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
4230
4230
|
let records;
|
|
4231
4231
|
try {
|
|
4232
4232
|
records = readRecords3(data);
|
|
@@ -4238,7 +4238,7 @@ function assertDecryptedDocInfo(data, readRecords3) {
|
|
|
4238
4238
|
}
|
|
4239
4239
|
function assertSupportedEncryptVersion(version) {
|
|
4240
4240
|
if (version !== SUPPORTED_ENCRYPT_VERSION) {
|
|
4241
|
-
throw new (0,
|
|
4241
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
4242
4242
|
`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWP \uC554\uD638\uD654 \uBC84\uC804\uC785\uB2C8\uB2E4 (EncryptVersion=${version}, \uC9C0\uC6D0: ${SUPPORTED_ENCRYPT_VERSION})`
|
|
4243
4243
|
);
|
|
4244
4244
|
}
|
|
@@ -4321,7 +4321,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4321
4321
|
lenientCfb = parseLenientCfb(buffer);
|
|
4322
4322
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4323
4323
|
} catch (e24) {
|
|
4324
|
-
throw new (0,
|
|
4324
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4325
4325
|
}
|
|
4326
4326
|
}
|
|
4327
4327
|
const readRawStream = (path) => {
|
|
@@ -4332,14 +4332,14 @@ function parseHwp5Document(buffer, options) {
|
|
|
4332
4332
|
return lenientCfb.findStream(path);
|
|
4333
4333
|
};
|
|
4334
4334
|
const headerData = readRawStream("/FileHeader");
|
|
4335
|
-
if (!headerData) throw new (0,
|
|
4335
|
+
if (!headerData) throw new (0, _chunk7BIVNIK5cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4336
4336
|
const header = parseFileHeader(headerData);
|
|
4337
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4338
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4337
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunk7BIVNIK5cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4338
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunk7BIVNIK5cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4339
4339
|
const encrypted = (header.flags & FLAG_ENCRYPTED) !== 0;
|
|
4340
4340
|
if (encrypted) {
|
|
4341
4341
|
if (!_optionalChain([options, 'optionalAccess', _101 => _101.password])) {
|
|
4342
|
-
throw new (0,
|
|
4342
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWP \uBB38\uC11C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694.");
|
|
4343
4343
|
}
|
|
4344
4344
|
assertSupportedEncryptVersion(readEncryptVersion(headerData));
|
|
4345
4345
|
}
|
|
@@ -4357,18 +4357,18 @@ function parseHwp5Document(buffer, options) {
|
|
|
4357
4357
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4358
4358
|
if (encrypted) {
|
|
4359
4359
|
const rawDocInfo = findStream("/DocInfo");
|
|
4360
|
-
if (!rawDocInfo) throw new (0,
|
|
4360
|
+
if (!rawDocInfo) throw new (0, _chunk7BIVNIK5cjs.KordocError)("DocInfo \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4361
4361
|
let docInfoData;
|
|
4362
4362
|
try {
|
|
4363
4363
|
docInfoData = compressed ? decompressStream(rawDocInfo) : rawDocInfo;
|
|
4364
4364
|
} catch (e25) {
|
|
4365
|
-
throw new (0,
|
|
4365
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
4366
4366
|
}
|
|
4367
4367
|
assertDecryptedDocInfo(docInfoData, readRecords);
|
|
4368
4368
|
}
|
|
4369
4369
|
const docInfo = cfb && !encrypted ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4370
4370
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : encrypted ? findSectionsVia(findStream) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4371
|
-
if (sections.length === 0) throw new (0,
|
|
4371
|
+
if (sections.length === 0) throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4372
4372
|
metadata.pageCount = sections.length;
|
|
4373
4373
|
const pageFilter = _optionalChain([options, 'optionalAccess', _102 => _102.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4374
4374
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -4383,22 +4383,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4383
4383
|
const sectionData = sections[si];
|
|
4384
4384
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4385
4385
|
totalDecompressed += data.length;
|
|
4386
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4386
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4387
4387
|
const records = readRecords(data);
|
|
4388
4388
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4389
4389
|
bodyBlocks.push(...sectionBlocks);
|
|
4390
4390
|
parsedSections++;
|
|
4391
4391
|
_optionalChain([options, 'optionalAccess', _104 => _104.onProgress, 'optionalCall', _105 => _105(parsedSections, totalTarget)]);
|
|
4392
4392
|
} catch (secErr) {
|
|
4393
|
-
if (secErr instanceof
|
|
4393
|
+
if (secErr instanceof _chunk7BIVNIK5cjs.KordocError) throw secErr;
|
|
4394
4394
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
4395
4395
|
}
|
|
4396
4396
|
}
|
|
4397
4397
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4398
4398
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4399
|
-
let flatBlocks =
|
|
4399
|
+
let flatBlocks = _chunkGC7WBHANcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4400
4400
|
if (_optionalChain([options, 'optionalAccess', _106 => _106.dedupeRunningHeaders])) {
|
|
4401
|
-
const deduped =
|
|
4401
|
+
const deduped = _chunkGC7WBHANcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4402
4402
|
const removed = flatBlocks.length - deduped.length;
|
|
4403
4403
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4404
4404
|
flatBlocks = deduped;
|
|
@@ -4407,10 +4407,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4407
4407
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4408
4408
|
}
|
|
4409
4409
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4410
|
-
let markdown =
|
|
4410
|
+
let markdown = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4411
4411
|
if (_optionalChain([options, 'optionalAccess', _107 => _107.inlineImages]) && images.length > 0) {
|
|
4412
4412
|
try {
|
|
4413
|
-
markdown =
|
|
4413
|
+
markdown = _chunkGC7WBHANcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4414
4414
|
} catch (inlineErr) {
|
|
4415
4415
|
warnings.push({ message: `\uC774\uBBF8\uC9C0 \uC778\uB77C\uC778 \uC2E4\uD328 \u2014 \uC6D0\uBCF8 \uD30C\uC77C \uCC38\uC870\uB85C \uD3F4\uBC31: ${inlineErr instanceof Error ? inlineErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "SKIPPED_IMAGE" });
|
|
4416
4416
|
}
|
|
@@ -4474,9 +4474,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4474
4474
|
let level = 0;
|
|
4475
4475
|
if (_optionalChain([block, 'access', _112 => _112.style, 'optionalAccess', _113 => _113.fontSize]) && baseFontSize > 0) {
|
|
4476
4476
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4477
|
-
if (ratio >=
|
|
4478
|
-
else if (ratio >=
|
|
4479
|
-
else if (ratio >=
|
|
4477
|
+
if (ratio >= _chunk7BIVNIK5cjs.HEADING_RATIO_H1) level = 1;
|
|
4478
|
+
else if (ratio >= _chunk7BIVNIK5cjs.HEADING_RATIO_H2) level = 2;
|
|
4479
|
+
else if (ratio >= _chunk7BIVNIK5cjs.HEADING_RATIO_H3) level = 3;
|
|
4480
4480
|
}
|
|
4481
4481
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4482
4482
|
if (level === 0) level = 2;
|
|
@@ -4570,7 +4570,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4570
4570
|
if (!raw) break;
|
|
4571
4571
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4572
4572
|
totalDecompressed += content.length;
|
|
4573
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4573
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4574
4574
|
sections.push({ idx: i, content });
|
|
4575
4575
|
}
|
|
4576
4576
|
if (sections.length === 0) {
|
|
@@ -4582,7 +4582,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4582
4582
|
if (raw) {
|
|
4583
4583
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4584
4584
|
totalDecompressed += content.length;
|
|
4585
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4585
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4586
4586
|
sections.push({ idx, content });
|
|
4587
4587
|
}
|
|
4588
4588
|
}
|
|
@@ -4599,7 +4599,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4599
4599
|
try {
|
|
4600
4600
|
const content = decryptViewText(raw, compressed);
|
|
4601
4601
|
totalDecompressed += content.length;
|
|
4602
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4602
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4603
4603
|
sections.push({ idx: i, content });
|
|
4604
4604
|
} catch (e30) {
|
|
4605
4605
|
break;
|
|
@@ -4702,7 +4702,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
4702
4702
|
const ctrl = ctrls[r.ctrlIdx];
|
|
4703
4703
|
if (!_optionalChain([ctrl, 'optionalAccess', _120 => _120.href]) || r.end <= r.start) continue;
|
|
4704
4704
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
4705
|
-
const href =
|
|
4705
|
+
const href = _chunk7BIVNIK5cjs.sanitizeHref.call(void 0, ctrl.href);
|
|
4706
4706
|
if (!href) continue;
|
|
4707
4707
|
const anchor = text.slice(r.start, r.end);
|
|
4708
4708
|
if (!anchor.trim()) continue;
|
|
@@ -4938,8 +4938,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4938
4938
|
let tableIdx = -1;
|
|
4939
4939
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4940
4940
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4941
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4942
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4941
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkGC7WBHANcjs.MAX_ROWS);
|
|
4942
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkGC7WBHANcjs.MAX_COLS);
|
|
4943
4943
|
tableIdx = i2;
|
|
4944
4944
|
break;
|
|
4945
4945
|
}
|
|
@@ -4988,7 +4988,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4988
4988
|
return table3;
|
|
4989
4989
|
}
|
|
4990
4990
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4991
|
-
const table2 =
|
|
4991
|
+
const table2 = _chunkGC7WBHANcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
4992
4992
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
4993
4993
|
return table2.rows > 0 ? table2 : null;
|
|
4994
4994
|
}
|
|
@@ -5005,8 +5005,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5005
5005
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5006
5006
|
const cs = rec.data.readUInt16LE(12);
|
|
5007
5007
|
const rs = rec.data.readUInt16LE(14);
|
|
5008
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5009
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5008
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkGC7WBHANcjs.MAX_COLS);
|
|
5009
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkGC7WBHANcjs.MAX_ROWS);
|
|
5010
5010
|
}
|
|
5011
5011
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5012
5012
|
const parts = [];
|
|
@@ -5016,7 +5016,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5016
5016
|
parts.push(``);
|
|
5017
5017
|
hasStructure = true;
|
|
5018
5018
|
} else if (b.type === "table" && b.table) {
|
|
5019
|
-
const flat =
|
|
5019
|
+
const flat = _chunkGC7WBHANcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5020
5020
|
if (flat) parts.push(flat);
|
|
5021
5021
|
hasStructure = true;
|
|
5022
5022
|
} else if (b.text) {
|
|
@@ -17287,25 +17287,25 @@ function desEcbDecrypt(data, key) {
|
|
|
17287
17287
|
}
|
|
17288
17288
|
function readLayout(data) {
|
|
17289
17289
|
if (data.length < FIXED_HEADER_BYTES) {
|
|
17290
|
-
throw new (0,
|
|
17290
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uD5E4\uB354\uAC00 \uC798\uB838\uC2B5\uB2C8\uB2E4");
|
|
17291
17291
|
}
|
|
17292
17292
|
const infoBlockLength = data[INFO_BLOCK_LENGTH_OFFSET] | data[INFO_BLOCK_LENGTH_OFFSET + 1] << 8;
|
|
17293
17293
|
const payloadOffset = FIXED_HEADER_BYTES + infoBlockLength;
|
|
17294
17294
|
if (payloadOffset >= data.length) {
|
|
17295
|
-
throw new (0,
|
|
17295
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uBCF8\uBB38\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17296
17296
|
}
|
|
17297
17297
|
return { payloadOffset, compressed: data[COMPRESSION_FLAG_OFFSET] !== 0 };
|
|
17298
17298
|
}
|
|
17299
17299
|
function decryptHwp3Document(input, password) {
|
|
17300
17300
|
const { payloadOffset, compressed } = readLayout(input);
|
|
17301
17301
|
if (!compressed) {
|
|
17302
|
-
throw new (0,
|
|
17302
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWP3 \uC554\uD638\uD654 \uBC29\uC2DD\uC785\uB2C8\uB2E4 (\uC555\uCD95\uB418\uC9C0 \uC54A\uC740 \uC554\uD638 \uBCF8\uBB38)");
|
|
17303
17303
|
}
|
|
17304
17304
|
const source = Buffer.from(input);
|
|
17305
17305
|
const payload = source.subarray(payloadOffset);
|
|
17306
17306
|
const aligned = payload.subarray(0, payload.length - payload.length % 8);
|
|
17307
17307
|
if (aligned.length === 0) {
|
|
17308
|
-
throw new (0,
|
|
17308
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uBCF8\uBB38\uC774 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4");
|
|
17309
17309
|
}
|
|
17310
17310
|
const decrypted = desEcbDecrypt(aligned, deriveDesKey(password));
|
|
17311
17311
|
let inflated;
|
|
@@ -17313,14 +17313,14 @@ function decryptHwp3Document(input, password) {
|
|
|
17313
17313
|
inflated = _zlib.inflateRawSync.call(void 0, decrypted, { maxOutputLength: MAX_DECOMPRESSED_BYTES });
|
|
17314
17314
|
} catch (err) {
|
|
17315
17315
|
if (_optionalChain([err, 'optionalAccess', _133 => _133.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17316
|
-
throw new (0,
|
|
17316
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
17317
17317
|
`HWP3 \uC554\uD638 \uBCF8\uBB38\uC758 \uC555\uCD95 \uD574\uC81C \uACB0\uACFC\uAC00 \uCD5C\uB300 \uD5C8\uC6A9 \uD06C\uAE30(${MAX_DECOMPRESSED_BYTES / 1024 / 1024}MB)\uB97C \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4`
|
|
17318
17318
|
);
|
|
17319
17319
|
}
|
|
17320
|
-
throw new (0,
|
|
17320
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
17321
17321
|
}
|
|
17322
17322
|
if (inflated.length <= PASSWORD_PREFIX_BYTES) {
|
|
17323
|
-
throw new (0,
|
|
17323
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
17324
17324
|
}
|
|
17325
17325
|
const body = inflated.subarray(PASSWORD_PREFIX_BYTES);
|
|
17326
17326
|
const out = Buffer.concat([source.subarray(0, payloadOffset), body]);
|
|
@@ -17355,7 +17355,7 @@ function parseHwp3Document(buffer, options) {
|
|
|
17355
17355
|
let source = Buffer.from(buffer);
|
|
17356
17356
|
if (isEncryptedHwp3(source)) {
|
|
17357
17357
|
if (!_optionalChain([options, 'optionalAccess', _134 => _134.password])) {
|
|
17358
|
-
throw new (0,
|
|
17358
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
17359
17359
|
"\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWP3 \uBB38\uC11C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694."
|
|
17360
17360
|
);
|
|
17361
17361
|
}
|
|
@@ -17372,10 +17372,10 @@ function parseHwp3Document(buffer, options) {
|
|
|
17372
17372
|
body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
|
|
17373
17373
|
} catch (err) {
|
|
17374
17374
|
if (_optionalChain([err, 'optionalAccess', _135 => _135.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17375
|
-
throw new (0,
|
|
17375
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`HWP3 \uC555\uCD95 \uD574\uC81C \uACB0\uACFC\uAC00 \uCD5C\uB300 \uD5C8\uC6A9 \uD06C\uAE30(${MAX_DECOMPRESS_SIZE3 / 1024 / 1024}MB)\uB97C \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4`);
|
|
17376
17376
|
}
|
|
17377
17377
|
const msg2 = err instanceof Error ? err.message : String(err);
|
|
17378
|
-
throw new (0,
|
|
17378
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`HWP3 \uC555\uCD95 \uD574\uC81C \uC2E4\uD328: ${msg2}`);
|
|
17379
17379
|
}
|
|
17380
17380
|
} else {
|
|
17381
17381
|
body = tail;
|
|
@@ -17617,7 +17617,7 @@ function getTextContent(el) {
|
|
|
17617
17617
|
return _nullishCoalesce(_optionalChain([el, 'access', _138 => _138.textContent, 'optionalAccess', _139 => _139.trim, 'call', _140 => _140()]), () => ( ""));
|
|
17618
17618
|
}
|
|
17619
17619
|
function parseXml(text) {
|
|
17620
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17620
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk7BIVNIK5cjs.stripDtd.call(void 0, text), "text/xml");
|
|
17621
17621
|
}
|
|
17622
17622
|
function collectRichText(root) {
|
|
17623
17623
|
let out = "";
|
|
@@ -17852,7 +17852,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
17852
17852
|
cellRows.push(row);
|
|
17853
17853
|
}
|
|
17854
17854
|
if (cellRows.length > 0) {
|
|
17855
|
-
const table2 =
|
|
17855
|
+
const table2 = _chunkGC7WBHANcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
17856
17856
|
if (table2.rows > 0) {
|
|
17857
17857
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
17858
17858
|
}
|
|
@@ -17860,12 +17860,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
17860
17860
|
return blocks;
|
|
17861
17861
|
}
|
|
17862
17862
|
async function parseXlsxDocument(buffer, options) {
|
|
17863
|
-
|
|
17863
|
+
_chunk7BIVNIK5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
17864
17864
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
17865
17865
|
const warnings = [];
|
|
17866
17866
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
17867
17867
|
if (!workbookFile) {
|
|
17868
|
-
throw new (0,
|
|
17868
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17869
17869
|
}
|
|
17870
17870
|
let sharedStrings = [];
|
|
17871
17871
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -17874,7 +17874,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17874
17874
|
}
|
|
17875
17875
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
17876
17876
|
if (sheets.length === 0) {
|
|
17877
|
-
throw new (0,
|
|
17877
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17878
17878
|
}
|
|
17879
17879
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
17880
17880
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -17958,7 +17958,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17958
17958
|
} catch (e32) {
|
|
17959
17959
|
}
|
|
17960
17960
|
}
|
|
17961
|
-
const markdown =
|
|
17961
|
+
const markdown = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, blocks);
|
|
17962
17962
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
17963
17963
|
}
|
|
17964
17964
|
|
|
@@ -18409,11 +18409,11 @@ function processGlobals(records) {
|
|
|
18409
18409
|
const xfFmtIds = [];
|
|
18410
18410
|
const firstBof = records[0];
|
|
18411
18411
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18412
|
-
throw new (0,
|
|
18412
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18413
18413
|
}
|
|
18414
18414
|
const bof = decodeBof(firstBof.data);
|
|
18415
18415
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18416
|
-
throw new (0,
|
|
18416
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18417
18417
|
}
|
|
18418
18418
|
let i = 1;
|
|
18419
18419
|
while (i < records.length) {
|
|
@@ -18548,7 +18548,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18548
18548
|
cellRows.push(row);
|
|
18549
18549
|
}
|
|
18550
18550
|
if (cellRows.length > 0) {
|
|
18551
|
-
const table2 =
|
|
18551
|
+
const table2 = _chunkGC7WBHANcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18552
18552
|
if (table2.rows > 0) {
|
|
18553
18553
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18554
18554
|
}
|
|
@@ -18561,28 +18561,28 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18561
18561
|
try {
|
|
18562
18562
|
cfb = parseLenientCfb(buf);
|
|
18563
18563
|
} catch (e) {
|
|
18564
|
-
throw new (0,
|
|
18564
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
18565
18565
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18566
18566
|
);
|
|
18567
18567
|
}
|
|
18568
18568
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18569
18569
|
if (!wb) {
|
|
18570
|
-
throw new (0,
|
|
18570
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18571
18571
|
}
|
|
18572
18572
|
const records = readRecords2(wb);
|
|
18573
18573
|
if (records.length === 0) {
|
|
18574
|
-
throw new (0,
|
|
18574
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18575
18575
|
}
|
|
18576
18576
|
const firstBof = decodeBof(records[0].data);
|
|
18577
18577
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18578
|
-
throw new (0,
|
|
18578
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
18579
18579
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18580
18580
|
);
|
|
18581
18581
|
}
|
|
18582
18582
|
const globals = processGlobals(records);
|
|
18583
18583
|
const warnings = [];
|
|
18584
18584
|
if (globals.encrypted) {
|
|
18585
|
-
throw new (0,
|
|
18585
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("XLS \uD30C\uC77C\uC774 \uC554\uD638\uD654\uB418\uC5B4 \uC788\uC5B4 \uD30C\uC2F1\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18586
18586
|
}
|
|
18587
18587
|
const convertNum = globals.dateXfs.size > 0 ? (n, ixfe) => {
|
|
18588
18588
|
const kind = globals.dateXfs.get(ixfe);
|
|
@@ -18633,7 +18633,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18633
18633
|
pageCount: totalSheets
|
|
18634
18634
|
};
|
|
18635
18635
|
return {
|
|
18636
|
-
markdown:
|
|
18636
|
+
markdown: _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18637
18637
|
blocks: allBlocks,
|
|
18638
18638
|
metadata,
|
|
18639
18639
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19061,7 +19061,7 @@ function getAttr(el, localName2) {
|
|
|
19061
19061
|
return null;
|
|
19062
19062
|
}
|
|
19063
19063
|
function parseXml2(text) {
|
|
19064
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19064
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunk7BIVNIK5cjs.stripDtd.call(void 0, text), "text/xml");
|
|
19065
19065
|
}
|
|
19066
19066
|
function parseStyles(xml) {
|
|
19067
19067
|
const doc = parseXml2(xml);
|
|
@@ -19219,7 +19219,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19219
19219
|
function makeLink(text, rawHref) {
|
|
19220
19220
|
if (!text) return "";
|
|
19221
19221
|
if (!rawHref) return text;
|
|
19222
|
-
const href =
|
|
19222
|
+
const href = _chunk7BIVNIK5cjs.sanitizeHref.call(void 0, rawHref);
|
|
19223
19223
|
return href ? `[${text}](${href})` : text;
|
|
19224
19224
|
}
|
|
19225
19225
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19413,7 +19413,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19413
19413
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19414
19414
|
})
|
|
19415
19415
|
);
|
|
19416
|
-
const table2 =
|
|
19416
|
+
const table2 = _chunkGC7WBHANcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19417
19417
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19418
19418
|
return { type: "table", table: table2 };
|
|
19419
19419
|
}
|
|
@@ -19515,12 +19515,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19515
19515
|
}
|
|
19516
19516
|
}
|
|
19517
19517
|
async function parseDocxDocument(buffer, options) {
|
|
19518
|
-
|
|
19518
|
+
_chunk7BIVNIK5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19519
19519
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19520
19520
|
const warnings = [];
|
|
19521
19521
|
const docFile = zip.file("word/document.xml");
|
|
19522
19522
|
if (!docFile) {
|
|
19523
|
-
throw new (0,
|
|
19523
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19524
19524
|
}
|
|
19525
19525
|
let rels = /* @__PURE__ */ new Map();
|
|
19526
19526
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19567,7 +19567,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19567
19567
|
const doc = parseXml2(docXml);
|
|
19568
19568
|
const body = findElements(doc, "body");
|
|
19569
19569
|
if (body.length === 0) {
|
|
19570
|
-
throw new (0,
|
|
19570
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19571
19571
|
}
|
|
19572
19572
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19573
19573
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19618,7 +19618,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19618
19618
|
}
|
|
19619
19619
|
}
|
|
19620
19620
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19621
|
-
const markdown =
|
|
19621
|
+
const markdown = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19622
19622
|
return {
|
|
19623
19623
|
markdown,
|
|
19624
19624
|
blocks,
|
|
@@ -19636,11 +19636,11 @@ var MAX_TABLE_COLS = 500;
|
|
|
19636
19636
|
var MAX_HWPML_BYTES = 50 * 1024 * 1024;
|
|
19637
19637
|
function parseHwpmlDocument(buffer, options) {
|
|
19638
19638
|
if (buffer.byteLength > MAX_HWPML_BYTES) {
|
|
19639
|
-
throw new (0,
|
|
19639
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`HWPML \uD30C\uC77C \uD06C\uAE30 \uCD08\uACFC (${(buffer.byteLength / 1024 / 1024).toFixed(1)}MB > 50MB)`);
|
|
19640
19640
|
}
|
|
19641
19641
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19642
19642
|
const normalized = text.replace(/ /g, " ");
|
|
19643
|
-
const xml =
|
|
19643
|
+
const xml = _chunk7BIVNIK5cjs.stripDtd.call(void 0, normalized);
|
|
19644
19644
|
const warnings = [];
|
|
19645
19645
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19646
19646
|
onError: (_level, msg2) => {
|
|
@@ -19680,7 +19680,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19680
19680
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _184 => _184.keepTrailingEmptyCols]), () => ( false)));
|
|
19681
19681
|
}
|
|
19682
19682
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
19683
|
-
const markdown =
|
|
19683
|
+
const markdown = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19684
19684
|
return {
|
|
19685
19685
|
markdown,
|
|
19686
19686
|
blocks,
|
|
@@ -19845,7 +19845,7 @@ function buildHmlTable(el, warnings, keep, tableDepth) {
|
|
|
19845
19845
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
19846
19846
|
cellRows[r].push(cell2);
|
|
19847
19847
|
}
|
|
19848
|
-
const table2 =
|
|
19848
|
+
const table2 = _chunkGC7WBHANcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
19849
19849
|
if (structured.length > 0) {
|
|
19850
19850
|
const claimed = /* @__PURE__ */ new Set();
|
|
19851
19851
|
for (const { ctx, cellBlocks } of structured) {
|
|
@@ -21356,7 +21356,7 @@ function fillClickHereInXml(xml, cursor, blockedLabels) {
|
|
|
21356
21356
|
};
|
|
21357
21357
|
}
|
|
21358
21358
|
async function extractClickHereFields(hwpxBuffer) {
|
|
21359
|
-
|
|
21359
|
+
_chunk7BIVNIK5cjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
21360
21360
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21361
21361
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21362
21362
|
const fields = [];
|
|
@@ -21404,19 +21404,19 @@ function parseCentralDirectory(buf) {
|
|
|
21404
21404
|
}
|
|
21405
21405
|
}
|
|
21406
21406
|
}
|
|
21407
|
-
if (eocdOffset < 0) throw new (0,
|
|
21407
|
+
if (eocdOffset < 0) throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21408
21408
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21409
21409
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21410
21410
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21411
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21411
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21412
21412
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21413
|
-
throw new (0,
|
|
21413
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21414
21414
|
}
|
|
21415
21415
|
const decoder = new TextDecoder("utf-8");
|
|
21416
21416
|
const entries = [];
|
|
21417
21417
|
let pos = cdOffset;
|
|
21418
21418
|
for (let i = 0; i < totalEntries; i++) {
|
|
21419
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21419
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21420
21420
|
const flags = view.getUint16(pos + 8, true);
|
|
21421
21421
|
const method = view.getUint16(pos + 10, true);
|
|
21422
21422
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21427,7 +21427,7 @@ function parseCentralDirectory(buf) {
|
|
|
21427
21427
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21428
21428
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21429
21429
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21430
|
-
throw new (0,
|
|
21430
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21431
21431
|
}
|
|
21432
21432
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21433
21433
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21456,11 +21456,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21456
21456
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21457
21457
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21458
21458
|
for (const name of replacements.keys()) {
|
|
21459
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21459
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunk7BIVNIK5cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21460
21460
|
}
|
|
21461
21461
|
if (additions) {
|
|
21462
21462
|
for (const name of additions.keys()) {
|
|
21463
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21463
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunk7BIVNIK5cjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21464
21464
|
}
|
|
21465
21465
|
}
|
|
21466
21466
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21479,7 +21479,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21479
21479
|
offset += seg.length;
|
|
21480
21480
|
continue;
|
|
21481
21481
|
}
|
|
21482
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21482
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunk7BIVNIK5cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21483
21483
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21484
21484
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21485
21485
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21487,7 +21487,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21487
21487
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21488
21488
|
const method = e.method;
|
|
21489
21489
|
if (method !== 0 && method !== 8) {
|
|
21490
|
-
throw new (0,
|
|
21490
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 ZIP \uC555\uCD95 \uBC29\uC2DD(method=${method}): ${e.name} \u2014 STORE(0)/DEFLATE(8)\uB9CC \uAD50\uCCB4 \uAC00\uB2A5`);
|
|
21491
21491
|
}
|
|
21492
21492
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21493
21493
|
const crc = crc32(newData);
|
|
@@ -21585,11 +21585,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21585
21585
|
// src/form/filler-hwpx.ts
|
|
21586
21586
|
async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
21587
21587
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
21588
|
-
|
|
21588
|
+
_chunk7BIVNIK5cjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
21589
21589
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21590
21590
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21591
21591
|
if (sectionPaths.length === 0) {
|
|
21592
|
-
throw new (0,
|
|
21592
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21593
21593
|
}
|
|
21594
21594
|
const warnings = [];
|
|
21595
21595
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -22331,7 +22331,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
22331
22331
|
}
|
|
22332
22332
|
function assertFiniteRange(name, value, min, max) {
|
|
22333
22333
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
22334
|
-
throw new (0,
|
|
22334
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
22335
22335
|
}
|
|
22336
22336
|
}
|
|
22337
22337
|
function validateGongmunOptions(opts) {
|
|
@@ -22346,10 +22346,10 @@ function validateGongmunOptions(opts) {
|
|
|
22346
22346
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
22347
22347
|
}
|
|
22348
22348
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
22349
|
-
throw new (0,
|
|
22349
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
22350
22350
|
}
|
|
22351
22351
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
22352
|
-
throw new (0,
|
|
22352
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
22353
22353
|
}
|
|
22354
22354
|
}
|
|
22355
22355
|
if (opts.sizes) {
|
|
@@ -22358,7 +22358,7 @@ function validateGongmunOptions(opts) {
|
|
|
22358
22358
|
}
|
|
22359
22359
|
}
|
|
22360
22360
|
if (opts.approval && opts.approval.length > 6) {
|
|
22361
|
-
throw new (0,
|
|
22361
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("approval must contain at most 6 labels");
|
|
22362
22362
|
}
|
|
22363
22363
|
}
|
|
22364
22364
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -22955,7 +22955,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22955
22955
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22956
22956
|
const got = m ? Number(m[1]) : NaN;
|
|
22957
22957
|
if (got !== startId + i) {
|
|
22958
|
-
throw new (0,
|
|
22958
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
22959
22959
|
`\uB0B4\uBD80 \uC624\uB958: ${label} id \uD30C\uD2F0\uC158 \uB4DC\uB9AC\uD504\uD2B8 \u2014 ${startId + i} \uC704\uCE58\uC5D0 id=${m ? m[1] : "?"} \uBC29\uCD9C. id \uC0C1\uC218(gen-ids)\uC640 \uC2E4\uC81C \uBC29\uCD9C \uC218\uAC00 \uC5B4\uAE0B\uB0AC\uB2E4 (GJ_CHAR_COUNT\uB958 \uCE74\uC6B4\uD2B8\xB7base \uC0B0\uC220 \uD655\uC778)`
|
|
22960
22960
|
);
|
|
22961
22961
|
}
|
|
@@ -23039,7 +23039,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
23039
23039
|
}
|
|
23040
23040
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
23041
23041
|
if (rows.length !== expectedBase) {
|
|
23042
|
-
throw new (0,
|
|
23042
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
23043
23043
|
`\uB0B4\uBD80 \uC624\uB958: charPr \uAE30\uBCF8 \uBE14\uB85D \uBC29\uCD9C \uC218(${rows.length}) \u2260 charVariantBase(${expectedBase}) \u2014 gen-header \uBC29\uCD9C \uD589\uACFC gen-ids \uCE74\uC6B4\uD2B8 \uC0C1\uC218\uAC00 \uC5B4\uAE0B\uB0AC\uB2E4`
|
|
23044
23044
|
);
|
|
23045
23045
|
}
|
|
@@ -23935,7 +23935,7 @@ function escapeGfm(text) {
|
|
|
23935
23935
|
}
|
|
23936
23936
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23937
23937
|
function sanitizeText(text) {
|
|
23938
|
-
let result =
|
|
23938
|
+
let result = _chunkGC7WBHANcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23939
23939
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23940
23940
|
const tokens = result.split(" ");
|
|
23941
23941
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -24107,7 +24107,7 @@ function parseHtmlTable(raw) {
|
|
|
24107
24107
|
const cs = parseInt(_optionalChain([attrs, 'access', _305 => _305.match, 'call', _306 => _306(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _307 => _307[1]]) || "1", 10);
|
|
24108
24108
|
const rs = parseInt(_optionalChain([attrs, 'access', _308 => _308.match, 'call', _309 => _309(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _310 => _310[1]]) || "1", 10);
|
|
24109
24109
|
cellStart = m.index + m[0].length;
|
|
24110
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
24110
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkGC7WBHANcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkGC7WBHANcjs.MAX_ROWS) };
|
|
24111
24111
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
24112
24112
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
24113
24113
|
cellStart = -1;
|
|
@@ -24763,8 +24763,8 @@ function layoutHtmlRows(rows) {
|
|
|
24763
24763
|
let c = 0;
|
|
24764
24764
|
for (const cell2 of rows[r].cells) {
|
|
24765
24765
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24766
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24767
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24766
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkGC7WBHANcjs.MAX_COLS);
|
|
24767
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkGC7WBHANcjs.MAX_ROWS);
|
|
24768
24768
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24769
24769
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24770
24770
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -26065,7 +26065,7 @@ function builtinTemplateDir() {
|
|
|
26065
26065
|
for (const c of candidates) {
|
|
26066
26066
|
if (_fs.existsSync.call(void 0, _path.join.call(void 0, c, BUILTIN_TEMPLATES[0].file))) return c;
|
|
26067
26067
|
}
|
|
26068
|
-
throw new (0,
|
|
26068
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uB0B4\uC7A5 templates \uB514\uB809\uD1A0\uB9AC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 (\uD328\uD0A4\uC9C0 \uC124\uCE58\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4)");
|
|
26069
26069
|
}
|
|
26070
26070
|
function readBuiltinTemplate(t) {
|
|
26071
26071
|
const buf = _fs.readFileSync.call(void 0, _path.join.call(void 0, builtinTemplateDir(), t.file));
|
|
@@ -26408,12 +26408,12 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
26408
26408
|
return `<hp:pic xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core" id="${ids.id}" zOrder="0" numberingType="PICTURE" textWrap="IN_FRONT_OF_TEXT" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${ids.instid}" reverse="0"><hp:offset x="0" y="0"/><hp:orgSz width="${w}" height="${h}"/><hp:curSz width="${w}" height="${h}"/><hp:flip horizontal="0" vertical="0"/><hp:rotationInfo angle="0" centerX="${Math.round(w / 2)}" centerY="${Math.round(h / 2)}" rotateimage="1"/><hp:renderingInfo><hc:transMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:scaMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:rotMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/></hp:renderingInfo><hp:imgRect><hc:pt0 x="0" y="0"/><hc:pt1 x="${w}" y="0"/><hc:pt2 x="${w}" y="${h}"/><hc:pt3 x="0" y="${h}"/></hp:imgRect><hp:imgClip left="0" right="${w}" top="0" bottom="${h}"/><hp:inMargin left="0" right="0" top="0" bottom="0"/><hp:imgDim dimwidth="${w}" dimheight="${h}"/><hc:img binaryItemIDRef="${itemId}" bright="0" contrast="0" effect="REAL_PIC" alpha="0"/><hp:effects/><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="0" affectLSpacing="0" flowWithText="0" allowOverlap="1" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="COLUMN" vertAlign="TOP" horzAlign="LEFT" vertOffset="${posYHu}" horzOffset="${posXHu}"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:shapeComment>kordoc seal</hp:shapeComment></hp:pic>`;
|
|
26409
26409
|
}
|
|
26410
26410
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
26411
|
-
if (ops.length === 0) throw new (0,
|
|
26411
|
+
if (ops.length === 0) throw new (0, _chunk7BIVNIK5cjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
26412
26412
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
26413
|
-
|
|
26413
|
+
_chunk7BIVNIK5cjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
26414
26414
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
26415
26415
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _412 => _412.match, 'call', _413 => _413(/(\d+)\.xml$/i), 'optionalAccess', _414 => _414[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _415 => _415.match, 'call', _416 => _416(/(\d+)\.xml$/i), 'optionalAccess', _417 => _417[1]]), () => ( 0))));
|
|
26416
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
26416
|
+
if (sectionPaths.length === 0) throw new (0, _chunk7BIVNIK5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
26417
26417
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
26418
26418
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
26419
26419
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -26454,11 +26454,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26454
26454
|
const manifestItems = [];
|
|
26455
26455
|
const placed = [];
|
|
26456
26456
|
for (const op of ops) {
|
|
26457
|
-
if (!op.anchor) throw new (0,
|
|
26458
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
26457
|
+
if (!op.anchor) throw new (0, _chunk7BIVNIK5cjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
26458
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunk7BIVNIK5cjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
26459
26459
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
26460
|
-
if (!MIME[ext]) throw new (0,
|
|
26461
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
26460
|
+
if (!MIME[ext]) throw new (0, _chunk7BIVNIK5cjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
26461
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunk7BIVNIK5cjs.KordocError)(`place_seal: \uC774\uBBF8\uC9C0 \uB0B4\uC6A9\uC774 .${ext} \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 (\uB9E4\uC9C1\uBC14\uC774\uD2B8 \uBD88\uC77C\uCE58)`);
|
|
26462
26462
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
26463
26463
|
let found = null;
|
|
26464
26464
|
let total = 0;
|
|
@@ -26491,7 +26491,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26491
26491
|
}
|
|
26492
26492
|
}
|
|
26493
26493
|
}
|
|
26494
|
-
throw new (0,
|
|
26494
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
26495
26495
|
`place_seal: \uC575\uCEE4 "${op.anchor}" ${wantOcc}\uBC88\uC9F8 \uB4F1\uC7A5\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (\uBCF8\uBB38 \uB0B4 ${total}\uD68C \uB4F1\uC7A5 \u2014 occurrence 0..${Math.max(0, total - 1)})`
|
|
26496
26496
|
);
|
|
26497
26497
|
}
|
|
@@ -26499,7 +26499,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26499
26499
|
const xml = sectionXmls[si];
|
|
26500
26500
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
26501
26501
|
if (!run) {
|
|
26502
|
-
throw new (0,
|
|
26502
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
26503
26503
|
}
|
|
26504
26504
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _418 => _418.charPr, 'access', _419 => _419.get, 'call', _420 => _420(run.charPr), 'optionalAccess', _421 => _421.height]), () => ( 1e3));
|
|
26505
26505
|
const fontPt = charPrHeight / 100;
|
|
@@ -26777,7 +26777,7 @@ function pick(map, keys) {
|
|
|
26777
26777
|
return out;
|
|
26778
26778
|
}
|
|
26779
26779
|
async function hwpxToProfile(input) {
|
|
26780
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26780
|
+
const buf = input instanceof ArrayBuffer ? input : _chunk7BIVNIK5cjs.toArrayBuffer.call(void 0, input);
|
|
26781
26781
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26782
26782
|
const parser = createXmlParser();
|
|
26783
26783
|
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _443 => _443.file, 'call', _444 => _444(/[Hh]eader\.xml$/), 'optionalAccess', _445 => _445[0]])));
|
|
@@ -27708,7 +27708,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27708
27708
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27709
27709
|
if (paths.length > 0) return paths;
|
|
27710
27710
|
}
|
|
27711
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27711
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunk7BIVNIK5cjs.compareSectionPaths);
|
|
27712
27712
|
}
|
|
27713
27713
|
function sectionPathsFromManifest(xml) {
|
|
27714
27714
|
const attr = (tag, name) => {
|
|
@@ -27718,7 +27718,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27718
27718
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27719
27719
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27720
27720
|
const id = attr(m[1], "id");
|
|
27721
|
-
const href =
|
|
27721
|
+
const href = _chunk7BIVNIK5cjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27722
27722
|
if (id && href) idToHref.set(id, href);
|
|
27723
27723
|
}
|
|
27724
27724
|
const ordered = [];
|
|
@@ -27727,7 +27727,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27727
27727
|
if (href) ordered.push(href);
|
|
27728
27728
|
}
|
|
27729
27729
|
if (ordered.length > 0) return ordered;
|
|
27730
|
-
return Array.from(idToHref.values()).sort(
|
|
27730
|
+
return Array.from(idToHref.values()).sort(_chunk7BIVNIK5cjs.compareSectionPaths);
|
|
27731
27731
|
}
|
|
27732
27732
|
|
|
27733
27733
|
// src/roundtrip/patcher.ts
|
|
@@ -27838,9 +27838,9 @@ function buildOrigUnits(blocks) {
|
|
|
27838
27838
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27839
27839
|
const next = blocks[i + 1];
|
|
27840
27840
|
if (_optionalChain([next, 'optionalAccess', _478 => _478.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
27841
|
-
chunk =
|
|
27841
|
+
chunk = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27842
27842
|
} else {
|
|
27843
|
-
chunk =
|
|
27843
|
+
chunk = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27844
27844
|
}
|
|
27845
27845
|
if (chunk) {
|
|
27846
27846
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -29460,12 +29460,12 @@ function blocksToChunks(blocks, options) {
|
|
|
29460
29460
|
let run = null;
|
|
29461
29461
|
const flushRun = () => {
|
|
29462
29462
|
if (!run) return;
|
|
29463
|
-
push("text", run.breadcrumb,
|
|
29463
|
+
push("text", run.breadcrumb, _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
29464
29464
|
run = null;
|
|
29465
29465
|
};
|
|
29466
29466
|
for (let i = 0; i < blocks.length; i++) {
|
|
29467
29467
|
const block = blocks[i];
|
|
29468
|
-
const md2 =
|
|
29468
|
+
const md2 = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, [block]);
|
|
29469
29469
|
if (!md2) continue;
|
|
29470
29470
|
if (block.type === "heading") {
|
|
29471
29471
|
flushRun();
|
|
@@ -29935,13 +29935,13 @@ async function htmlToPdf(html, options) {
|
|
|
29935
29935
|
try {
|
|
29936
29936
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29937
29937
|
} catch (e35) {
|
|
29938
|
-
throw new (0,
|
|
29938
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
29939
29939
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29940
29940
|
);
|
|
29941
29941
|
}
|
|
29942
29942
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29943
29943
|
if (!executablePath) {
|
|
29944
|
-
throw new (0,
|
|
29944
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)(
|
|
29945
29945
|
"Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
|
|
29946
29946
|
);
|
|
29947
29947
|
}
|
|
@@ -30000,7 +30000,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
30000
30000
|
return htmlToPdf(html, options);
|
|
30001
30001
|
}
|
|
30002
30002
|
async function blocksToPdf(blocks, options) {
|
|
30003
|
-
const markdown =
|
|
30003
|
+
const markdown = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, blocks);
|
|
30004
30004
|
return markdownToPdf(markdown, options);
|
|
30005
30005
|
}
|
|
30006
30006
|
|
|
@@ -30898,15 +30898,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30898
30898
|
async function renderHwpxToSvg(input, options) {
|
|
30899
30899
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _575 => _575.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30900
30900
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30901
|
-
|
|
30901
|
+
_chunk7BIVNIK5cjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30902
30902
|
let zip;
|
|
30903
30903
|
try {
|
|
30904
30904
|
zip = await _jszip2.default.loadAsync(input);
|
|
30905
30905
|
} catch (e36) {
|
|
30906
|
-
throw new (0,
|
|
30906
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30907
30907
|
}
|
|
30908
30908
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30909
|
-
if (secFiles.length === 0) throw new (0,
|
|
30909
|
+
if (secFiles.length === 0) throw new (0, _chunk7BIVNIK5cjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30910
30910
|
const warnings = [];
|
|
30911
30911
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30912
30912
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -30914,7 +30914,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30914
30914
|
const secXmls = [];
|
|
30915
30915
|
for (const f of secFiles) {
|
|
30916
30916
|
const xml = await f.async("string");
|
|
30917
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
30917
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30918
30918
|
secXmls.push(xml);
|
|
30919
30919
|
}
|
|
30920
30920
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30987,9 +30987,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30987
30987
|
}
|
|
30988
30988
|
if (rendered.length === 0) {
|
|
30989
30989
|
if (noCacheSkipped) {
|
|
30990
|
-
throw new (0,
|
|
30990
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
|
|
30991
30991
|
}
|
|
30992
|
-
throw new (0,
|
|
30992
|
+
throw new (0, _chunk7BIVNIK5cjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
30993
30993
|
}
|
|
30994
30994
|
const GAP = 2400;
|
|
30995
30995
|
const clipDefs = [];
|
|
@@ -31025,13 +31025,13 @@ async function parse(input, options) {
|
|
|
31025
31025
|
if (typeof input === "string") {
|
|
31026
31026
|
try {
|
|
31027
31027
|
const buf = await _promises.readFile.call(void 0, input);
|
|
31028
|
-
buffer =
|
|
31028
|
+
buffer = _chunk7BIVNIK5cjs.toArrayBuffer.call(void 0, buf);
|
|
31029
31029
|
} catch (err) {
|
|
31030
31030
|
const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
|
|
31031
31031
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
31032
31032
|
}
|
|
31033
31033
|
} else if (Buffer.isBuffer(input)) {
|
|
31034
|
-
buffer =
|
|
31034
|
+
buffer = _chunk7BIVNIK5cjs.toArrayBuffer.call(void 0, input);
|
|
31035
31035
|
} else {
|
|
31036
31036
|
buffer = input;
|
|
31037
31037
|
}
|
|
@@ -31065,18 +31065,18 @@ async function parse(input, options) {
|
|
|
31065
31065
|
}
|
|
31066
31066
|
async function parseImage(buffer, options) {
|
|
31067
31067
|
try {
|
|
31068
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
31068
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-VCXLT5Q6.cjs")));
|
|
31069
31069
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
31070
31070
|
return {
|
|
31071
31071
|
success: true,
|
|
31072
31072
|
fileType: "image",
|
|
31073
|
-
markdown:
|
|
31073
|
+
markdown: _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, blocks),
|
|
31074
31074
|
blocks,
|
|
31075
31075
|
warnings: warnings.length ? warnings : void 0,
|
|
31076
31076
|
pageCount: 1
|
|
31077
31077
|
};
|
|
31078
31078
|
} catch (err) {
|
|
31079
|
-
return { success: false, fileType: "image", error:
|
|
31079
|
+
return { success: false, fileType: "image", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err) };
|
|
31080
31080
|
}
|
|
31081
31081
|
}
|
|
31082
31082
|
async function parseHwp3(buffer, options) {
|
|
@@ -31084,7 +31084,7 @@ async function parseHwp3(buffer, options) {
|
|
|
31084
31084
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
31085
31085
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _582 => _582.pageCount]) };
|
|
31086
31086
|
} catch (err) {
|
|
31087
|
-
return { success: false, fileType: "hwp3", error:
|
|
31087
|
+
return { success: false, fileType: "hwp3", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err) };
|
|
31088
31088
|
}
|
|
31089
31089
|
}
|
|
31090
31090
|
async function parseHwpx(buffer, options) {
|
|
@@ -31092,7 +31092,7 @@ async function parseHwpx(buffer, options) {
|
|
|
31092
31092
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
31093
31093
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _583 => _583.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _584 => _584.pageCount]) };
|
|
31094
31094
|
} catch (err) {
|
|
31095
|
-
return { success: false, fileType: "hwpx", error:
|
|
31095
|
+
return { success: false, fileType: "hwpx", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err) };
|
|
31096
31096
|
}
|
|
31097
31097
|
}
|
|
31098
31098
|
async function parseHwp(buffer, options) {
|
|
@@ -31118,13 +31118,13 @@ async function parseHwp(buffer, options) {
|
|
|
31118
31118
|
}
|
|
31119
31119
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _586 => _586.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _587 => _587.pageCount]) };
|
|
31120
31120
|
} catch (err) {
|
|
31121
|
-
return { success: false, fileType: "hwp", error:
|
|
31121
|
+
return { success: false, fileType: "hwp", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err) };
|
|
31122
31122
|
}
|
|
31123
31123
|
}
|
|
31124
31124
|
async function parsePdf(buffer, options) {
|
|
31125
31125
|
let parsePdfDocument;
|
|
31126
31126
|
try {
|
|
31127
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
31127
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-ABYM2MVN.cjs")));
|
|
31128
31128
|
parsePdfDocument = mod.parsePdfDocument;
|
|
31129
31129
|
} catch (e38) {
|
|
31130
31130
|
return {
|
|
@@ -31139,7 +31139,7 @@ async function parsePdf(buffer, options) {
|
|
|
31139
31139
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images, pageCount: _optionalChain([metadata, 'optionalAccess', _588 => _588.pageCount]) };
|
|
31140
31140
|
} catch (err) {
|
|
31141
31141
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
31142
|
-
return { success: false, fileType: "pdf", error:
|
|
31142
|
+
return { success: false, fileType: "pdf", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err), isImageBased };
|
|
31143
31143
|
}
|
|
31144
31144
|
}
|
|
31145
31145
|
async function parseXlsx(buffer, options) {
|
|
@@ -31147,7 +31147,7 @@ async function parseXlsx(buffer, options) {
|
|
|
31147
31147
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
31148
31148
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _589 => _589.pageCount]) };
|
|
31149
31149
|
} catch (err) {
|
|
31150
|
-
return { success: false, fileType: "xlsx", error:
|
|
31150
|
+
return { success: false, fileType: "xlsx", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err) };
|
|
31151
31151
|
}
|
|
31152
31152
|
}
|
|
31153
31153
|
async function parseXls(buffer, options) {
|
|
@@ -31155,7 +31155,7 @@ async function parseXls(buffer, options) {
|
|
|
31155
31155
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
31156
31156
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _590 => _590.pageCount]) };
|
|
31157
31157
|
} catch (err) {
|
|
31158
|
-
return { success: false, fileType: "xls", error:
|
|
31158
|
+
return { success: false, fileType: "xls", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err) };
|
|
31159
31159
|
}
|
|
31160
31160
|
}
|
|
31161
31161
|
async function parseDocx(buffer, options) {
|
|
@@ -31163,7 +31163,7 @@ async function parseDocx(buffer, options) {
|
|
|
31163
31163
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
31164
31164
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _591 => _591.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _592 => _592.pageCount]) };
|
|
31165
31165
|
} catch (err) {
|
|
31166
|
-
return { success: false, fileType: "docx", error:
|
|
31166
|
+
return { success: false, fileType: "docx", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err) };
|
|
31167
31167
|
}
|
|
31168
31168
|
}
|
|
31169
31169
|
async function parseHwpml(buffer, options) {
|
|
@@ -31171,16 +31171,16 @@ async function parseHwpml(buffer, options) {
|
|
|
31171
31171
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
31172
31172
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _593 => _593.pageCount]) };
|
|
31173
31173
|
} catch (err) {
|
|
31174
|
-
return { success: false, fileType: "hwpml", error:
|
|
31174
|
+
return { success: false, fileType: "hwpml", error: _chunk7BIVNIK5cjs.sanitizeError.call(void 0, err), code: _chunk7BIVNIK5cjs.classifyError.call(void 0, err) };
|
|
31175
31175
|
}
|
|
31176
31176
|
}
|
|
31177
31177
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
31178
31178
|
let buffer;
|
|
31179
31179
|
if (typeof input === "string") {
|
|
31180
31180
|
const buf = await _promises.readFile.call(void 0, input);
|
|
31181
|
-
buffer =
|
|
31181
|
+
buffer = _chunk7BIVNIK5cjs.toArrayBuffer.call(void 0, buf);
|
|
31182
31182
|
} else if (Buffer.isBuffer(input)) {
|
|
31183
|
-
buffer =
|
|
31183
|
+
buffer = _chunk7BIVNIK5cjs.toArrayBuffer.call(void 0, input);
|
|
31184
31184
|
} else {
|
|
31185
31185
|
buffer = input;
|
|
31186
31186
|
}
|
|
@@ -31206,7 +31206,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
31206
31206
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
31207
31207
|
}
|
|
31208
31208
|
const fill = fillFormFields(parsed.blocks, values);
|
|
31209
|
-
const markdown =
|
|
31209
|
+
const markdown = _chunkGC7WBHANcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
31210
31210
|
if (outputFormat === "hwpx") {
|
|
31211
31211
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
31212
31212
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -31285,5 +31285,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
31285
31285
|
|
|
31286
31286
|
|
|
31287
31287
|
|
|
31288
|
-
exports.BUILTIN_TEMPLATES = BUILTIN_TEMPLATES; exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
31288
|
+
exports.BUILTIN_TEMPLATES = BUILTIN_TEMPLATES; exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunk7BIVNIK5cjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkGC7WBHANcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractClickHereFields = extractClickHereFields; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.incompatibleGongmunWarnings = incompatibleGongmunWarnings; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parseImage = parseImage; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.readBuiltinTemplate = readBuiltinTemplate; exports.readBuiltinTemplateSample = readBuiltinTemplateSample; exports.redactMarkdown = redactMarkdown; exports.redactText = redactText; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.resolveBuiltinTemplate = resolveBuiltinTemplate; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
31289
31289
|
//# sourceMappingURL=index.cjs.map
|