kordoc 4.2.0 → 4.2.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 +15 -8
- package/dist/{-SXQIZHYA.js → -BSO3CDQQ.js} +12 -10
- package/dist/{pdf-ocr-2Z7VZIFI.cjs → chunk-35U3MVA2.cjs} +129 -8
- package/dist/chunk-35U3MVA2.cjs.map +1 -0
- package/dist/{chunk-4VNLZ2GZ.js → chunk-54WVWWT4.js} +1 -1
- package/dist/{chunk-4VNLZ2GZ.js.map → chunk-54WVWWT4.js.map} +1 -1
- package/dist/{chunk-WF2E5P2G.js → chunk-7IMNZ2BL.js} +2 -2
- package/dist/{chunk-V6U6YS5B.js → chunk-BHILWIE6.js} +2 -2
- package/dist/{chunk-PLIY23LY.js → chunk-BKBYTPSL.js} +2 -2
- package/dist/{chunk-4JPPLIIV.js → chunk-EZHWPKCH.js} +8 -3
- package/dist/{chunk-4JPPLIIV.js.map → chunk-EZHWPKCH.js.map} +1 -1
- package/dist/{pdf-ocr-VYE4DHD4.js → chunk-F5ECB53I.js} +128 -9
- package/dist/chunk-F5ECB53I.js.map +1 -0
- package/dist/{chunk-JP5YH3Z4.js → chunk-HTCKGSSW.js} +2 -2
- package/dist/{chunk-JP5YH3Z4.js.map → chunk-HTCKGSSW.js.map} +1 -1
- package/dist/{pdf-ocr-FJFXFADQ.js → chunk-KRAYUNFM.js} +129 -7
- package/dist/chunk-KRAYUNFM.js.map +1 -0
- package/dist/{chunk-26AJJCFF.js → chunk-L5JWKIOT.js} +9 -4
- package/dist/{chunk-26AJJCFF.js.map → chunk-L5JWKIOT.js.map} +1 -1
- package/dist/{chunk-XTCT6KQ5.cjs → chunk-LSXXGUWA.cjs} +4 -4
- package/dist/{chunk-XTCT6KQ5.cjs.map → chunk-LSXXGUWA.cjs.map} +1 -1
- package/dist/{chunk-6SHO3BNV.js → chunk-PLTG6ZRF.js} +3 -3
- package/dist/{chunk-ELOV2GIJ.js → chunk-QOC7S5VE.js} +2 -2
- package/dist/{chunk-CMN3SYZ3.js → chunk-QSB2RTX5.js} +2 -2
- package/dist/{chunk-LHROM2BO.cjs → chunk-R22KDUKW.cjs} +15 -10
- package/dist/chunk-R22KDUKW.cjs.map +1 -0
- package/dist/{chunk-F2HYH62H.cjs → chunk-RBUBZ2TA.cjs} +2 -2
- package/dist/{chunk-F2HYH62H.cjs.map → chunk-RBUBZ2TA.cjs.map} +1 -1
- package/dist/{chunk-YOO6ET6M.js → chunk-TCJRGFYY.js} +11 -1
- package/dist/chunk-TCJRGFYY.js.map +1 -0
- package/dist/{chunk-WQLHPOMJ.js → chunk-WJSGYVFD.js} +3 -3
- package/dist/{chunk-IGGRLWT5.js → chunk-WWYAYZ5U.js} +28 -9
- package/dist/chunk-WWYAYZ5U.js.map +1 -0
- package/dist/{chunk-FSXLSHCW.js → chunk-Z6LPEWIX.js} +2 -2
- package/dist/chunks-LRFS5NJE.js +10 -0
- package/dist/cli.js +19 -19
- package/dist/cli.js.map +1 -1
- package/dist/{detect-YEZX2XCF.js → detect-FX2ZHKZP.js} +4 -2
- package/dist/image-ocr-DALT7PFQ.js +65 -0
- package/dist/image-ocr-DALT7PFQ.js.map +1 -0
- package/dist/image-ocr-N5Z32R4U.cjs +66 -0
- package/dist/image-ocr-N5Z32R4U.cjs.map +1 -0
- package/dist/image-ocr-SLUEM3FA.js +69 -0
- package/dist/image-ocr-SLUEM3FA.js.map +1 -0
- package/dist/index.cjs +176 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +31 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +19 -19
- package/dist/mcp.js.map +1 -1
- package/dist/{parser-ND2YGQZR.js → parser-33TK5SMH.js} +5 -5
- package/dist/{parser-RBZHA6SY.js → parser-F5KY3YSD.js} +6 -6
- package/dist/{parser-WDZOMDG4.cjs → parser-R4CXIXRN.cjs} +24 -24
- package/dist/{parser-WDZOMDG4.cjs.map → parser-R4CXIXRN.cjs.map} +1 -1
- package/dist/pdf-ocr-34F5AQKK.js +12 -0
- package/dist/pdf-ocr-BXQZKU3N.js +15 -0
- package/dist/pdf-ocr-WGWZDHMV.cjs +13 -0
- package/dist/pdf-ocr-WGWZDHMV.cjs.map +1 -0
- package/dist/{profile-io-TWHDIVPL.js → profile-io-CBYHKLFU.js} +3 -3
- package/dist/{rasterize-W2NEZUSW.js → rasterize-AWMM2CSW.js} +2 -2
- package/dist/render-Y3IE2FIK.js +10 -0
- package/dist/render-Y3IE2FIK.js.map +1 -0
- package/dist/seal-7RXFCRMT.js +10 -0
- package/dist/seal-7RXFCRMT.js.map +1 -0
- package/dist/{watch-VWXJZT2R.js → watch-HKXCISVO.js} +10 -10
- package/package.json +1 -1
- package/dist/chunk-IGGRLWT5.js.map +0 -1
- package/dist/chunk-LHROM2BO.cjs.map +0 -1
- package/dist/chunk-YOO6ET6M.js.map +0 -1
- package/dist/chunks-ZQEFAZNC.js +0 -10
- package/dist/pdf-ocr-2Z7VZIFI.cjs.map +0 -1
- package/dist/pdf-ocr-FJFXFADQ.js.map +0 -1
- package/dist/pdf-ocr-VYE4DHD4.js.map +0 -1
- package/dist/render-4MG5QUDG.js +0 -10
- package/dist/seal-D2QNXJVO.js +0 -10
- /package/dist/{-SXQIZHYA.js.map → -BSO3CDQQ.js.map} +0 -0
- /package/dist/{chunk-WF2E5P2G.js.map → chunk-7IMNZ2BL.js.map} +0 -0
- /package/dist/{chunk-V6U6YS5B.js.map → chunk-BHILWIE6.js.map} +0 -0
- /package/dist/{chunk-PLIY23LY.js.map → chunk-BKBYTPSL.js.map} +0 -0
- /package/dist/{chunk-6SHO3BNV.js.map → chunk-PLTG6ZRF.js.map} +0 -0
- /package/dist/{chunk-ELOV2GIJ.js.map → chunk-QOC7S5VE.js.map} +0 -0
- /package/dist/{chunk-CMN3SYZ3.js.map → chunk-QSB2RTX5.js.map} +0 -0
- /package/dist/{chunk-WQLHPOMJ.js.map → chunk-WJSGYVFD.js.map} +0 -0
- /package/dist/{chunk-FSXLSHCW.js.map → chunk-Z6LPEWIX.js.map} +0 -0
- /package/dist/{chunks-ZQEFAZNC.js.map → chunks-LRFS5NJE.js.map} +0 -0
- /package/dist/{detect-YEZX2XCF.js.map → detect-FX2ZHKZP.js.map} +0 -0
- /package/dist/{parser-ND2YGQZR.js.map → parser-33TK5SMH.js.map} +0 -0
- /package/dist/{parser-RBZHA6SY.js.map → parser-F5KY3YSD.js.map} +0 -0
- /package/dist/{profile-io-TWHDIVPL.js.map → pdf-ocr-34F5AQKK.js.map} +0 -0
- /package/dist/{render-4MG5QUDG.js.map → pdf-ocr-BXQZKU3N.js.map} +0 -0
- /package/dist/{seal-D2QNXJVO.js.map → profile-io-CBYHKLFU.js.map} +0 -0
- /package/dist/{rasterize-W2NEZUSW.js.map → rasterize-AWMM2CSW.js.map} +0 -0
- /package/dist/{watch-VWXJZT2R.js.map → watch-HKXCISVO.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkLSXXGUWAcjs = require('./chunk-LSXXGUWA.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 _chunkRBUBZ2TAcjs = require('./chunk-RBUBZ2TA.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -250,6 +250,14 @@ function isPdfFile(buffer) {
|
|
|
250
250
|
const b = magicBytes(buffer);
|
|
251
251
|
return b[0] === 37 && b[1] === 80 && b[2] === 68 && b[3] === 70;
|
|
252
252
|
}
|
|
253
|
+
function isImageFile(buffer) {
|
|
254
|
+
if (buffer.byteLength < 12) return false;
|
|
255
|
+
const b = new Uint8Array(buffer, 0, 12);
|
|
256
|
+
if (b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71) return true;
|
|
257
|
+
if (b[0] === 255 && b[1] === 216 && b[2] === 255) return true;
|
|
258
|
+
if (b[0] === 82 && b[1] === 73 && b[2] === 70 && b[3] === 70 && b[8] === 87 && b[9] === 69 && b[10] === 66 && b[11] === 80) return true;
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
253
261
|
function isHwpmlFile(buffer) {
|
|
254
262
|
const bytes = new Uint8Array(buffer, 0, Math.min(512, buffer.byteLength));
|
|
255
263
|
const head = new TextDecoder("utf-8", { fatal: false }).decode(bytes).replace(/^\uFEFF/, "");
|
|
@@ -262,6 +270,7 @@ function detectFormat(buffer) {
|
|
|
262
270
|
if (isOldHwpFile(buffer)) return "hwp";
|
|
263
271
|
if (isPdfFile(buffer)) return "pdf";
|
|
264
272
|
if (isHwpmlFile(buffer)) return "hwpml";
|
|
273
|
+
if (isImageFile(buffer)) return "image";
|
|
265
274
|
return "unknown";
|
|
266
275
|
}
|
|
267
276
|
function detectOle2Format(buffer) {
|
|
@@ -404,7 +413,7 @@ function comResultToParseResult(pages, pageCount, warnings) {
|
|
|
404
413
|
var _xmldom = require('@xmldom/xmldom');
|
|
405
414
|
var MAX_DECOMPRESS_SIZE = 100 * 1024 * 1024;
|
|
406
415
|
var MAX_ZIP_ENTRIES = 500;
|
|
407
|
-
var ZipBombError = class extends
|
|
416
|
+
var ZipBombError = class extends _chunkRBUBZ2TAcjs.KordocError {
|
|
408
417
|
constructor(message) {
|
|
409
418
|
super(message);
|
|
410
419
|
this.name = "ZipBombError";
|
|
@@ -420,7 +429,7 @@ function createSectionShared() {
|
|
|
420
429
|
function createXmlParser(warnings) {
|
|
421
430
|
return new (0, _xmldom.DOMParser)({
|
|
422
431
|
onError(level, msg2) {
|
|
423
|
-
if (level === "fatalError") throw new (0,
|
|
432
|
+
if (level === "fatalError") throw new (0, _chunkRBUBZ2TAcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
424
433
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
425
434
|
}
|
|
426
435
|
});
|
|
@@ -477,10 +486,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
477
486
|
const xml = await file.async("text");
|
|
478
487
|
if (decompressed) {
|
|
479
488
|
decompressed.total += xml.length * 2;
|
|
480
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
489
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
481
490
|
}
|
|
482
491
|
const parser = createXmlParser();
|
|
483
|
-
const doc = parser.parseFromString(
|
|
492
|
+
const doc = parser.parseFromString(_chunkRBUBZ2TAcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
484
493
|
if (!doc.documentElement) continue;
|
|
485
494
|
const domDoc = doc;
|
|
486
495
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -663,9 +672,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
663
672
|
let level = 0;
|
|
664
673
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
665
674
|
const ratio = block.style.fontSize / baseFontSize;
|
|
666
|
-
if (ratio >=
|
|
667
|
-
else if (ratio >=
|
|
668
|
-
else if (ratio >=
|
|
675
|
+
if (ratio >= _chunkRBUBZ2TAcjs.HEADING_RATIO_H1) level = 1;
|
|
676
|
+
else if (ratio >= _chunkRBUBZ2TAcjs.HEADING_RATIO_H2) level = 2;
|
|
677
|
+
else if (ratio >= _chunkRBUBZ2TAcjs.HEADING_RATIO_H3) level = 3;
|
|
669
678
|
}
|
|
670
679
|
const compactText = text.replace(/\s+/g, "");
|
|
671
680
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1590,7 +1599,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1590
1599
|
}
|
|
1591
1600
|
function assertFiniteRange(name, value, min, max) {
|
|
1592
1601
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1593
|
-
throw new (0,
|
|
1602
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1594
1603
|
}
|
|
1595
1604
|
}
|
|
1596
1605
|
function validateGongmunOptions(opts) {
|
|
@@ -1605,10 +1614,10 @@ function validateGongmunOptions(opts) {
|
|
|
1605
1614
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1606
1615
|
}
|
|
1607
1616
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1608
|
-
throw new (0,
|
|
1617
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1609
1618
|
}
|
|
1610
1619
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1611
|
-
throw new (0,
|
|
1620
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1612
1621
|
}
|
|
1613
1622
|
}
|
|
1614
1623
|
if (opts.sizes) {
|
|
@@ -1617,7 +1626,7 @@ function validateGongmunOptions(opts) {
|
|
|
1617
1626
|
}
|
|
1618
1627
|
}
|
|
1619
1628
|
if (opts.approval && opts.approval.length > 6) {
|
|
1620
|
-
throw new (0,
|
|
1629
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("approval must contain at most 6 labels");
|
|
1621
1630
|
}
|
|
1622
1631
|
}
|
|
1623
1632
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1882,7 +1891,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1882
1891
|
|
|
1883
1892
|
// src/hwpx/table-build.ts
|
|
1884
1893
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
|
|
1885
|
-
const table2 =
|
|
1894
|
+
const table2 = _chunkLSXXGUWAcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols });
|
|
1886
1895
|
if (state.caption) table2.caption = state.caption;
|
|
1887
1896
|
const anchors = [];
|
|
1888
1897
|
{
|
|
@@ -1952,7 +1961,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1952
1961
|
const cell2 = parentTable.cell;
|
|
1953
1962
|
(cell2.blocks ??= []).push(block);
|
|
1954
1963
|
cell2.hasStructure = true;
|
|
1955
|
-
let flat =
|
|
1964
|
+
let flat = _chunkLSXXGUWAcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1956
1965
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1957
1966
|
if (flat) cell2.text += (cell2.text ? "\n" : "") + flat;
|
|
1958
1967
|
} else {
|
|
@@ -1964,7 +1973,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1964
1973
|
// src/hwpx/section-walker.ts
|
|
1965
1974
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1966
1975
|
const parser = createXmlParser(warnings);
|
|
1967
|
-
const doc = parser.parseFromString(
|
|
1976
|
+
const doc = parser.parseFromString(_chunkRBUBZ2TAcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1968
1977
|
if (!doc.documentElement) return [];
|
|
1969
1978
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1970
1979
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2070,8 +2079,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2070
2079
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2071
2080
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2072
2081
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2073
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2074
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2082
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkLSXXGUWAcjs.MAX_COLS);
|
|
2083
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkLSXXGUWAcjs.MAX_ROWS);
|
|
2075
2084
|
}
|
|
2076
2085
|
break;
|
|
2077
2086
|
case "p": {
|
|
@@ -2282,7 +2291,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2282
2291
|
const sink = [];
|
|
2283
2292
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2284
2293
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2285
|
-
let flat =
|
|
2294
|
+
let flat = _chunkLSXXGUWAcjs.convertTableToText.call(void 0, st.rows);
|
|
2286
2295
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2287
2296
|
return flat;
|
|
2288
2297
|
}
|
|
@@ -2415,7 +2424,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2415
2424
|
let url = (ch.textContent || "").trim();
|
|
2416
2425
|
if (!url) continue;
|
|
2417
2426
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2418
|
-
const safe =
|
|
2427
|
+
const safe = _chunkRBUBZ2TAcjs.sanitizeHref.call(void 0, url);
|
|
2419
2428
|
if (safe) return safe;
|
|
2420
2429
|
}
|
|
2421
2430
|
return void 0;
|
|
@@ -2572,7 +2581,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2572
2581
|
case "hyperlink": {
|
|
2573
2582
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2574
2583
|
if (url) {
|
|
2575
|
-
const safe =
|
|
2584
|
+
const safe = _chunkRBUBZ2TAcjs.sanitizeHref.call(void 0, url);
|
|
2576
2585
|
if (safe) href = safe;
|
|
2577
2586
|
}
|
|
2578
2587
|
walk(child, depth + 1);
|
|
@@ -2837,7 +2846,7 @@ function decompressStream(data) {
|
|
|
2837
2846
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2838
2847
|
}
|
|
2839
2848
|
function parseFileHeader(data) {
|
|
2840
|
-
if (data.length < 40) throw new (0,
|
|
2849
|
+
if (data.length < 40) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2841
2850
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2842
2851
|
return {
|
|
2843
2852
|
signature: sig,
|
|
@@ -3286,13 +3295,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3286
3295
|
}
|
|
3287
3296
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3288
3297
|
for (const path of allCandidates) {
|
|
3289
|
-
if (
|
|
3298
|
+
if (_chunkRBUBZ2TAcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3290
3299
|
const file = zip.file(path);
|
|
3291
3300
|
if (!file) continue;
|
|
3292
3301
|
try {
|
|
3293
3302
|
const data = await file.async("uint8array");
|
|
3294
3303
|
decompressed.total += data.length;
|
|
3295
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3304
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3296
3305
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3297
3306
|
const mimeType = imageExtToMime(ext);
|
|
3298
3307
|
imageIndex++;
|
|
@@ -3302,7 +3311,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3302
3311
|
usedPaths.add(path);
|
|
3303
3312
|
break;
|
|
3304
3313
|
} catch (err) {
|
|
3305
|
-
if (err instanceof
|
|
3314
|
+
if (err instanceof _chunkRBUBZ2TAcjs.KordocError) throw err;
|
|
3306
3315
|
}
|
|
3307
3316
|
}
|
|
3308
3317
|
if (!img) _optionalChain([warnings, 'optionalAccess', _72 => _72.push, 'call', _73 => _73({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -3322,11 +3331,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3322
3331
|
if (sweepUnreferenced) {
|
|
3323
3332
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3324
3333
|
for (const file of binEntries) {
|
|
3325
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3334
|
+
if (file.dir || usedPaths.has(file.name) || _chunkRBUBZ2TAcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3326
3335
|
try {
|
|
3327
3336
|
const data = await file.async("uint8array");
|
|
3328
3337
|
decompressed.total += data.length;
|
|
3329
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3338
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3330
3339
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3331
3340
|
let mimeType = imageExtToMime(ext);
|
|
3332
3341
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3340,7 +3349,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3340
3349
|
images.push(img);
|
|
3341
3350
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3342
3351
|
} catch (err) {
|
|
3343
|
-
if (err instanceof
|
|
3352
|
+
if (err instanceof _chunkRBUBZ2TAcjs.KordocError) throw err;
|
|
3344
3353
|
_optionalChain([warnings, 'optionalAccess', _74 => _74.push, 'call', _75 => _75({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3345
3354
|
}
|
|
3346
3355
|
}
|
|
@@ -3391,7 +3400,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3391
3400
|
}
|
|
3392
3401
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3393
3402
|
const name = new TextDecoder().decode(nameBytes);
|
|
3394
|
-
if (
|
|
3403
|
+
if (_chunkRBUBZ2TAcjs.isPathTraversal.call(void 0, name)) {
|
|
3395
3404
|
pos = fileStart + compSize;
|
|
3396
3405
|
continue;
|
|
3397
3406
|
}
|
|
@@ -3409,16 +3418,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3409
3418
|
continue;
|
|
3410
3419
|
}
|
|
3411
3420
|
totalDecompressed += content.length * 2;
|
|
3412
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3421
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3413
3422
|
sectionNum++;
|
|
3414
3423
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3415
3424
|
} catch (e16) {
|
|
3416
3425
|
continue;
|
|
3417
3426
|
}
|
|
3418
3427
|
}
|
|
3419
|
-
if (blocks.length === 0) throw new (0,
|
|
3428
|
+
if (blocks.length === 0) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3420
3429
|
applyPageText(blocks, shared);
|
|
3421
|
-
const markdown =
|
|
3430
|
+
const markdown = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3422
3431
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3423
3432
|
}
|
|
3424
3433
|
async function readKordocLayout(zip) {
|
|
@@ -3443,18 +3452,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3443
3452
|
if (paths.length > 0) return paths;
|
|
3444
3453
|
}
|
|
3445
3454
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3446
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3455
|
+
return sectionFiles.map((f) => f.name).sort(_chunkRBUBZ2TAcjs.compareSectionPaths);
|
|
3447
3456
|
}
|
|
3448
3457
|
function parseSectionPathsFromManifest(xml) {
|
|
3449
3458
|
const parser = createXmlParser();
|
|
3450
|
-
const doc = parser.parseFromString(
|
|
3459
|
+
const doc = parser.parseFromString(_chunkRBUBZ2TAcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3451
3460
|
const items = doc.getElementsByTagName("opf:item");
|
|
3452
3461
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3453
3462
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3454
3463
|
for (let i = 0; i < items.length; i++) {
|
|
3455
3464
|
const item = items[i];
|
|
3456
3465
|
const id = item.getAttribute("id") || "";
|
|
3457
|
-
const href =
|
|
3466
|
+
const href = _chunkRBUBZ2TAcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3458
3467
|
if (id && href) idToHref.set(id, href);
|
|
3459
3468
|
}
|
|
3460
3469
|
if (spine.length > 0) {
|
|
@@ -3465,7 +3474,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3465
3474
|
}
|
|
3466
3475
|
if (ordered.length > 0) return ordered;
|
|
3467
3476
|
}
|
|
3468
|
-
return Array.from(idToHref.values()).sort(
|
|
3477
|
+
return Array.from(idToHref.values()).sort(_chunkRBUBZ2TAcjs.compareSectionPaths);
|
|
3469
3478
|
}
|
|
3470
3479
|
|
|
3471
3480
|
// src/hwpx/metadata.ts
|
|
@@ -3478,7 +3487,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3478
3487
|
const xml = await file.async("text");
|
|
3479
3488
|
if (decompressed) {
|
|
3480
3489
|
decompressed.total += xml.length * 2;
|
|
3481
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3490
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3482
3491
|
}
|
|
3483
3492
|
parseDublinCoreMetadata(xml, metadata);
|
|
3484
3493
|
if (metadata.title || metadata.author) return;
|
|
@@ -3488,7 +3497,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3488
3497
|
}
|
|
3489
3498
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3490
3499
|
const parser = createXmlParser();
|
|
3491
|
-
const doc = parser.parseFromString(
|
|
3500
|
+
const doc = parser.parseFromString(_chunkRBUBZ2TAcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3492
3501
|
if (!doc.documentElement) return;
|
|
3493
3502
|
const getText = (tagNames) => {
|
|
3494
3503
|
for (const tag of tagNames) {
|
|
@@ -3513,7 +3522,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3513
3522
|
|
|
3514
3523
|
// src/hwpx/parser.ts
|
|
3515
3524
|
async function parseHwpxDocument(buffer, options) {
|
|
3516
|
-
|
|
3525
|
+
_chunkRBUBZ2TAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3517
3526
|
let zip;
|
|
3518
3527
|
try {
|
|
3519
3528
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3522,7 +3531,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3522
3531
|
}
|
|
3523
3532
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3524
3533
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3525
|
-
throw new (0,
|
|
3534
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3526
3535
|
}
|
|
3527
3536
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3528
3537
|
if (manifestFile) {
|
|
@@ -3534,7 +3543,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3534
3543
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3535
3544
|
}
|
|
3536
3545
|
}
|
|
3537
|
-
throw new (0,
|
|
3546
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
|
|
3538
3547
|
}
|
|
3539
3548
|
}
|
|
3540
3549
|
const decompressed = { total: 0 };
|
|
@@ -3543,7 +3552,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3543
3552
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3544
3553
|
const warnings = [];
|
|
3545
3554
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3546
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3555
|
+
if (sectionPaths.length === 0) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3547
3556
|
metadata.pageCount = sectionPaths.length;
|
|
3548
3557
|
const pageFilter = _optionalChain([options, 'optionalAccess', _84 => _84.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3549
3558
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -3572,7 +3581,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3572
3581
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3573
3582
|
detectHwpxHeadings(blocks, styleMap);
|
|
3574
3583
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3575
|
-
const markdown =
|
|
3584
|
+
const markdown = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3576
3585
|
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 };
|
|
3577
3586
|
}
|
|
3578
3587
|
|
|
@@ -4751,7 +4760,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4751
4760
|
lenientCfb = parseLenientCfb(buffer);
|
|
4752
4761
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4753
4762
|
} catch (e22) {
|
|
4754
|
-
throw new (0,
|
|
4763
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4755
4764
|
}
|
|
4756
4765
|
}
|
|
4757
4766
|
const findStream = (path) => {
|
|
@@ -4762,11 +4771,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
4762
4771
|
return lenientCfb.findStream(path);
|
|
4763
4772
|
};
|
|
4764
4773
|
const headerData = findStream("/FileHeader");
|
|
4765
|
-
if (!headerData) throw new (0,
|
|
4774
|
+
if (!headerData) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4766
4775
|
const header = parseFileHeader(headerData);
|
|
4767
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4768
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4769
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4776
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkRBUBZ2TAcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4777
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4778
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4770
4779
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4771
4780
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4772
4781
|
const metadata = {
|
|
@@ -4775,7 +4784,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4775
4784
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4776
4785
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4777
4786
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4778
|
-
if (sections.length === 0) throw new (0,
|
|
4787
|
+
if (sections.length === 0) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4779
4788
|
metadata.pageCount = sections.length;
|
|
4780
4789
|
const pageFilter = _optionalChain([options, 'optionalAccess', _89 => _89.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4781
4790
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -4790,22 +4799,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4790
4799
|
const sectionData = sections[si];
|
|
4791
4800
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4792
4801
|
totalDecompressed += data.length;
|
|
4793
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4802
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4794
4803
|
const records = readRecords(data);
|
|
4795
4804
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4796
4805
|
bodyBlocks.push(...sectionBlocks);
|
|
4797
4806
|
parsedSections++;
|
|
4798
4807
|
_optionalChain([options, 'optionalAccess', _91 => _91.onProgress, 'optionalCall', _92 => _92(parsedSections, totalTarget)]);
|
|
4799
4808
|
} catch (secErr) {
|
|
4800
|
-
if (secErr instanceof
|
|
4809
|
+
if (secErr instanceof _chunkRBUBZ2TAcjs.KordocError) throw secErr;
|
|
4801
4810
|
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" });
|
|
4802
4811
|
}
|
|
4803
4812
|
}
|
|
4804
4813
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4805
4814
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4806
|
-
let flatBlocks =
|
|
4815
|
+
let flatBlocks = _chunkLSXXGUWAcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4807
4816
|
if (_optionalChain([options, 'optionalAccess', _93 => _93.dedupeRunningHeaders])) {
|
|
4808
|
-
const deduped =
|
|
4817
|
+
const deduped = _chunkLSXXGUWAcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4809
4818
|
const removed = flatBlocks.length - deduped.length;
|
|
4810
4819
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4811
4820
|
flatBlocks = deduped;
|
|
@@ -4814,10 +4823,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4814
4823
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4815
4824
|
}
|
|
4816
4825
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4817
|
-
let markdown =
|
|
4826
|
+
let markdown = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4818
4827
|
if (_optionalChain([options, 'optionalAccess', _94 => _94.inlineImages]) && images.length > 0) {
|
|
4819
4828
|
try {
|
|
4820
|
-
markdown =
|
|
4829
|
+
markdown = _chunkLSXXGUWAcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4821
4830
|
} catch (inlineErr) {
|
|
4822
4831
|
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" });
|
|
4823
4832
|
}
|
|
@@ -4881,9 +4890,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4881
4890
|
let level = 0;
|
|
4882
4891
|
if (_optionalChain([block, 'access', _99 => _99.style, 'optionalAccess', _100 => _100.fontSize]) && baseFontSize > 0) {
|
|
4883
4892
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4884
|
-
if (ratio >=
|
|
4885
|
-
else if (ratio >=
|
|
4886
|
-
else if (ratio >=
|
|
4893
|
+
if (ratio >= _chunkRBUBZ2TAcjs.HEADING_RATIO_H1) level = 1;
|
|
4894
|
+
else if (ratio >= _chunkRBUBZ2TAcjs.HEADING_RATIO_H2) level = 2;
|
|
4895
|
+
else if (ratio >= _chunkRBUBZ2TAcjs.HEADING_RATIO_H3) level = 3;
|
|
4887
4896
|
}
|
|
4888
4897
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4889
4898
|
if (level === 0) level = 2;
|
|
@@ -4968,7 +4977,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4968
4977
|
if (!raw) break;
|
|
4969
4978
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4970
4979
|
totalDecompressed += content.length;
|
|
4971
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4980
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4972
4981
|
sections.push({ idx: i, content });
|
|
4973
4982
|
}
|
|
4974
4983
|
if (sections.length === 0) {
|
|
@@ -4980,7 +4989,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4980
4989
|
if (raw) {
|
|
4981
4990
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4982
4991
|
totalDecompressed += content.length;
|
|
4983
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4992
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4984
4993
|
sections.push({ idx, content });
|
|
4985
4994
|
}
|
|
4986
4995
|
}
|
|
@@ -4997,7 +5006,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4997
5006
|
try {
|
|
4998
5007
|
const content = decryptViewText(raw, compressed);
|
|
4999
5008
|
totalDecompressed += content.length;
|
|
5000
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5009
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5001
5010
|
sections.push({ idx: i, content });
|
|
5002
5011
|
} catch (e27) {
|
|
5003
5012
|
break;
|
|
@@ -5100,7 +5109,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5100
5109
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5101
5110
|
if (!_optionalChain([ctrl, 'optionalAccess', _107 => _107.href]) || r.end <= r.start) continue;
|
|
5102
5111
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5103
|
-
const href =
|
|
5112
|
+
const href = _chunkRBUBZ2TAcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5104
5113
|
if (!href) continue;
|
|
5105
5114
|
const anchor = text.slice(r.start, r.end);
|
|
5106
5115
|
if (!anchor.trim()) continue;
|
|
@@ -5333,8 +5342,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5333
5342
|
let tableIdx = -1;
|
|
5334
5343
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5335
5344
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5336
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5337
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5345
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkLSXXGUWAcjs.MAX_ROWS);
|
|
5346
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkLSXXGUWAcjs.MAX_COLS);
|
|
5338
5347
|
tableIdx = i2;
|
|
5339
5348
|
break;
|
|
5340
5349
|
}
|
|
@@ -5383,7 +5392,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5383
5392
|
return table3;
|
|
5384
5393
|
}
|
|
5385
5394
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5386
|
-
const table2 =
|
|
5395
|
+
const table2 = _chunkLSXXGUWAcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5387
5396
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5388
5397
|
return table2.rows > 0 ? table2 : null;
|
|
5389
5398
|
}
|
|
@@ -5400,8 +5409,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5400
5409
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5401
5410
|
const cs = rec.data.readUInt16LE(12);
|
|
5402
5411
|
const rs = rec.data.readUInt16LE(14);
|
|
5403
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5404
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5412
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkLSXXGUWAcjs.MAX_COLS);
|
|
5413
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkLSXXGUWAcjs.MAX_ROWS);
|
|
5405
5414
|
}
|
|
5406
5415
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5407
5416
|
const parts = [];
|
|
@@ -5411,7 +5420,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5411
5420
|
parts.push(``);
|
|
5412
5421
|
hasStructure = true;
|
|
5413
5422
|
} else if (b.type === "table" && b.table) {
|
|
5414
|
-
const flat =
|
|
5423
|
+
const flat = _chunkLSXXGUWAcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5415
5424
|
if (flat) parts.push(flat);
|
|
5416
5425
|
hasStructure = true;
|
|
5417
5426
|
} else if (b.text) {
|
|
@@ -17900,7 +17909,7 @@ function getTextContent(el) {
|
|
|
17900
17909
|
return _nullishCoalesce(_optionalChain([el, 'access', _123 => _123.textContent, 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()]), () => ( ""));
|
|
17901
17910
|
}
|
|
17902
17911
|
function parseXml(text) {
|
|
17903
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17912
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkRBUBZ2TAcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17904
17913
|
}
|
|
17905
17914
|
function collectRichText(root) {
|
|
17906
17915
|
let out = "";
|
|
@@ -18135,7 +18144,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18135
18144
|
cellRows.push(row);
|
|
18136
18145
|
}
|
|
18137
18146
|
if (cellRows.length > 0) {
|
|
18138
|
-
const table2 =
|
|
18147
|
+
const table2 = _chunkLSXXGUWAcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18139
18148
|
if (table2.rows > 0) {
|
|
18140
18149
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18141
18150
|
}
|
|
@@ -18143,12 +18152,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18143
18152
|
return blocks;
|
|
18144
18153
|
}
|
|
18145
18154
|
async function parseXlsxDocument(buffer, options) {
|
|
18146
|
-
|
|
18155
|
+
_chunkRBUBZ2TAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18147
18156
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18148
18157
|
const warnings = [];
|
|
18149
18158
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18150
18159
|
if (!workbookFile) {
|
|
18151
|
-
throw new (0,
|
|
18160
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18152
18161
|
}
|
|
18153
18162
|
let sharedStrings = [];
|
|
18154
18163
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18157,7 +18166,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18157
18166
|
}
|
|
18158
18167
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18159
18168
|
if (sheets.length === 0) {
|
|
18160
|
-
throw new (0,
|
|
18169
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18161
18170
|
}
|
|
18162
18171
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18163
18172
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -18237,7 +18246,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18237
18246
|
} catch (e29) {
|
|
18238
18247
|
}
|
|
18239
18248
|
}
|
|
18240
|
-
const markdown =
|
|
18249
|
+
const markdown = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18241
18250
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18242
18251
|
}
|
|
18243
18252
|
|
|
@@ -18688,11 +18697,11 @@ function processGlobals(records) {
|
|
|
18688
18697
|
const xfFmtIds = [];
|
|
18689
18698
|
const firstBof = records[0];
|
|
18690
18699
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18691
|
-
throw new (0,
|
|
18700
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18692
18701
|
}
|
|
18693
18702
|
const bof = decodeBof(firstBof.data);
|
|
18694
18703
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18695
|
-
throw new (0,
|
|
18704
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18696
18705
|
}
|
|
18697
18706
|
let i = 1;
|
|
18698
18707
|
while (i < records.length) {
|
|
@@ -18827,7 +18836,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18827
18836
|
cellRows.push(row);
|
|
18828
18837
|
}
|
|
18829
18838
|
if (cellRows.length > 0) {
|
|
18830
|
-
const table2 =
|
|
18839
|
+
const table2 = _chunkLSXXGUWAcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18831
18840
|
if (table2.rows > 0) {
|
|
18832
18841
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18833
18842
|
}
|
|
@@ -18840,21 +18849,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18840
18849
|
try {
|
|
18841
18850
|
cfb = parseLenientCfb(buf);
|
|
18842
18851
|
} catch (e) {
|
|
18843
|
-
throw new (0,
|
|
18852
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(
|
|
18844
18853
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18845
18854
|
);
|
|
18846
18855
|
}
|
|
18847
18856
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18848
18857
|
if (!wb) {
|
|
18849
|
-
throw new (0,
|
|
18858
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18850
18859
|
}
|
|
18851
18860
|
const records = readRecords2(wb);
|
|
18852
18861
|
if (records.length === 0) {
|
|
18853
|
-
throw new (0,
|
|
18862
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18854
18863
|
}
|
|
18855
18864
|
const firstBof = decodeBof(records[0].data);
|
|
18856
18865
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18857
|
-
throw new (0,
|
|
18866
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(
|
|
18858
18867
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18859
18868
|
);
|
|
18860
18869
|
}
|
|
@@ -18922,7 +18931,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18922
18931
|
pageCount: totalSheets
|
|
18923
18932
|
};
|
|
18924
18933
|
return {
|
|
18925
|
-
markdown:
|
|
18934
|
+
markdown: _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18926
18935
|
blocks: allBlocks,
|
|
18927
18936
|
metadata,
|
|
18928
18937
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19378,7 +19387,7 @@ function getAttr(el, localName2) {
|
|
|
19378
19387
|
return null;
|
|
19379
19388
|
}
|
|
19380
19389
|
function parseXml2(text) {
|
|
19381
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19390
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkRBUBZ2TAcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19382
19391
|
}
|
|
19383
19392
|
function parseStyles(xml) {
|
|
19384
19393
|
const doc = parseXml2(xml);
|
|
@@ -19536,7 +19545,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19536
19545
|
function makeLink(text, rawHref) {
|
|
19537
19546
|
if (!text) return "";
|
|
19538
19547
|
if (!rawHref) return text;
|
|
19539
|
-
const href =
|
|
19548
|
+
const href = _chunkRBUBZ2TAcjs.sanitizeHref.call(void 0, rawHref);
|
|
19540
19549
|
return href ? `[${text}](${href})` : text;
|
|
19541
19550
|
}
|
|
19542
19551
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19730,7 +19739,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19730
19739
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19731
19740
|
})
|
|
19732
19741
|
);
|
|
19733
|
-
const table2 =
|
|
19742
|
+
const table2 = _chunkLSXXGUWAcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19734
19743
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19735
19744
|
return { type: "table", table: table2 };
|
|
19736
19745
|
}
|
|
@@ -19832,12 +19841,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19832
19841
|
}
|
|
19833
19842
|
}
|
|
19834
19843
|
async function parseDocxDocument(buffer, options) {
|
|
19835
|
-
|
|
19844
|
+
_chunkRBUBZ2TAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19836
19845
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19837
19846
|
const warnings = [];
|
|
19838
19847
|
const docFile = zip.file("word/document.xml");
|
|
19839
19848
|
if (!docFile) {
|
|
19840
|
-
throw new (0,
|
|
19849
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19841
19850
|
}
|
|
19842
19851
|
let rels = /* @__PURE__ */ new Map();
|
|
19843
19852
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19884,7 +19893,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19884
19893
|
const doc = parseXml2(docXml);
|
|
19885
19894
|
const body = findElements(doc, "body");
|
|
19886
19895
|
if (body.length === 0) {
|
|
19887
|
-
throw new (0,
|
|
19896
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19888
19897
|
}
|
|
19889
19898
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19890
19899
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19935,7 +19944,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19935
19944
|
}
|
|
19936
19945
|
}
|
|
19937
19946
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19938
|
-
const markdown =
|
|
19947
|
+
const markdown = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19939
19948
|
return {
|
|
19940
19949
|
markdown,
|
|
19941
19950
|
blocks,
|
|
@@ -19958,7 +19967,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19958
19967
|
}
|
|
19959
19968
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19960
19969
|
const normalized = text.replace(/ /g, " ");
|
|
19961
|
-
const xml =
|
|
19970
|
+
const xml = _chunkRBUBZ2TAcjs.stripDtd.call(void 0, normalized);
|
|
19962
19971
|
const warnings = [];
|
|
19963
19972
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19964
19973
|
onError: (_level, msg2) => {
|
|
@@ -19998,7 +20007,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
19998
20007
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _172 => _172.keepTrailingEmptyCols]), () => ( false)));
|
|
19999
20008
|
}
|
|
20000
20009
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
20001
|
-
const markdown =
|
|
20010
|
+
const markdown = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20002
20011
|
return {
|
|
20003
20012
|
markdown,
|
|
20004
20013
|
blocks,
|
|
@@ -20143,7 +20152,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
|
|
|
20143
20152
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20144
20153
|
cellRows[r].push(cell2);
|
|
20145
20154
|
}
|
|
20146
|
-
const table2 =
|
|
20155
|
+
const table2 = _chunkLSXXGUWAcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20147
20156
|
const caption = extractShapeCaption(el);
|
|
20148
20157
|
if (caption.text && caption.before) {
|
|
20149
20158
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -21525,19 +21534,19 @@ function parseCentralDirectory(buf) {
|
|
|
21525
21534
|
}
|
|
21526
21535
|
}
|
|
21527
21536
|
}
|
|
21528
|
-
if (eocdOffset < 0) throw new (0,
|
|
21537
|
+
if (eocdOffset < 0) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21529
21538
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21530
21539
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21531
21540
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21532
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21541
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21533
21542
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21534
|
-
throw new (0,
|
|
21543
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21535
21544
|
}
|
|
21536
21545
|
const decoder = new TextDecoder("utf-8");
|
|
21537
21546
|
const entries = [];
|
|
21538
21547
|
let pos = cdOffset;
|
|
21539
21548
|
for (let i = 0; i < totalEntries; i++) {
|
|
21540
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21549
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21541
21550
|
const flags = view.getUint16(pos + 8, true);
|
|
21542
21551
|
const method = view.getUint16(pos + 10, true);
|
|
21543
21552
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21548,7 +21557,7 @@ function parseCentralDirectory(buf) {
|
|
|
21548
21557
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21549
21558
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21550
21559
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21551
|
-
throw new (0,
|
|
21560
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21552
21561
|
}
|
|
21553
21562
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21554
21563
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21577,11 +21586,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21577
21586
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21578
21587
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21579
21588
|
for (const name of replacements.keys()) {
|
|
21580
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21589
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkRBUBZ2TAcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21581
21590
|
}
|
|
21582
21591
|
if (additions) {
|
|
21583
21592
|
for (const name of additions.keys()) {
|
|
21584
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21593
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkRBUBZ2TAcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21585
21594
|
}
|
|
21586
21595
|
}
|
|
21587
21596
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21600,7 +21609,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21600
21609
|
offset += seg.length;
|
|
21601
21610
|
continue;
|
|
21602
21611
|
}
|
|
21603
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21612
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21604
21613
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21605
21614
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21606
21615
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21608,7 +21617,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21608
21617
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21609
21618
|
const method = e.method;
|
|
21610
21619
|
if (method !== 0 && method !== 8) {
|
|
21611
|
-
throw new (0,
|
|
21620
|
+
throw new (0, _chunkRBUBZ2TAcjs.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`);
|
|
21612
21621
|
}
|
|
21613
21622
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21614
21623
|
const crc = crc32(newData);
|
|
@@ -21709,7 +21718,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21709
21718
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21710
21719
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21711
21720
|
if (sectionPaths.length === 0) {
|
|
21712
|
-
throw new (0,
|
|
21721
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21713
21722
|
}
|
|
21714
21723
|
const warnings = [];
|
|
21715
21724
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -22446,7 +22455,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22446
22455
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22447
22456
|
const got = m ? Number(m[1]) : NaN;
|
|
22448
22457
|
if (got !== startId + i) {
|
|
22449
|
-
throw new (0,
|
|
22458
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(
|
|
22450
22459
|
`\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)`
|
|
22451
22460
|
);
|
|
22452
22461
|
}
|
|
@@ -22530,7 +22539,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22530
22539
|
}
|
|
22531
22540
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22532
22541
|
if (rows.length !== expectedBase) {
|
|
22533
|
-
throw new (0,
|
|
22542
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(
|
|
22534
22543
|
`\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`
|
|
22535
22544
|
);
|
|
22536
22545
|
}
|
|
@@ -23425,7 +23434,7 @@ function escapeGfm(text) {
|
|
|
23425
23434
|
}
|
|
23426
23435
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23427
23436
|
function sanitizeText(text) {
|
|
23428
|
-
let result =
|
|
23437
|
+
let result = _chunkLSXXGUWAcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23429
23438
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23430
23439
|
const tokens = result.split(" ");
|
|
23431
23440
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23597,7 +23606,7 @@ function parseHtmlTable(raw) {
|
|
|
23597
23606
|
const cs = parseInt(_optionalChain([attrs, 'access', _279 => _279.match, 'call', _280 => _280(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _281 => _281[1]]) || "1", 10);
|
|
23598
23607
|
const rs = parseInt(_optionalChain([attrs, 'access', _282 => _282.match, 'call', _283 => _283(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _284 => _284[1]]) || "1", 10);
|
|
23599
23608
|
cellStart = m.index + m[0].length;
|
|
23600
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
23609
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkLSXXGUWAcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkLSXXGUWAcjs.MAX_ROWS) };
|
|
23601
23610
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
23602
23611
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
23603
23612
|
cellStart = -1;
|
|
@@ -24241,8 +24250,8 @@ function layoutHtmlRows(rows) {
|
|
|
24241
24250
|
let c = 0;
|
|
24242
24251
|
for (const cell2 of rows[r].cells) {
|
|
24243
24252
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24244
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24245
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24253
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkLSXXGUWAcjs.MAX_COLS);
|
|
24254
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkLSXXGUWAcjs.MAX_ROWS);
|
|
24246
24255
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24247
24256
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24248
24257
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -25834,11 +25843,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25834
25843
|
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>`;
|
|
25835
25844
|
}
|
|
25836
25845
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25837
|
-
if (ops.length === 0) throw new (0,
|
|
25846
|
+
if (ops.length === 0) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25838
25847
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25839
25848
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25840
25849
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _386 => _386.match, 'call', _387 => _387(/(\d+)\.xml$/i), 'optionalAccess', _388 => _388[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _389 => _389.match, 'call', _390 => _390(/(\d+)\.xml$/i), 'optionalAccess', _391 => _391[1]]), () => ( 0))));
|
|
25841
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25850
|
+
if (sectionPaths.length === 0) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25842
25851
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25843
25852
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25844
25853
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25879,11 +25888,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25879
25888
|
const manifestItems = [];
|
|
25880
25889
|
const placed = [];
|
|
25881
25890
|
for (const op of ops) {
|
|
25882
|
-
if (!op.anchor) throw new (0,
|
|
25883
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25891
|
+
if (!op.anchor) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25892
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25884
25893
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25885
|
-
if (!MIME[ext]) throw new (0,
|
|
25886
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25894
|
+
if (!MIME[ext]) throw new (0, _chunkRBUBZ2TAcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25895
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkRBUBZ2TAcjs.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)`);
|
|
25887
25896
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25888
25897
|
let found = null;
|
|
25889
25898
|
let total = 0;
|
|
@@ -25916,7 +25925,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25916
25925
|
}
|
|
25917
25926
|
}
|
|
25918
25927
|
}
|
|
25919
|
-
throw new (0,
|
|
25928
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(
|
|
25920
25929
|
`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)})`
|
|
25921
25930
|
);
|
|
25922
25931
|
}
|
|
@@ -25924,7 +25933,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25924
25933
|
const xml = sectionXmls[si];
|
|
25925
25934
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
25926
25935
|
if (!run) {
|
|
25927
|
-
throw new (0,
|
|
25936
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
25928
25937
|
}
|
|
25929
25938
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _392 => _392.charPr, 'access', _393 => _393.get, 'call', _394 => _394(run.charPr), 'optionalAccess', _395 => _395.height]), () => ( 1e3));
|
|
25930
25939
|
const fontPt = charPrHeight / 100;
|
|
@@ -26202,7 +26211,7 @@ function pick(map, keys) {
|
|
|
26202
26211
|
return out;
|
|
26203
26212
|
}
|
|
26204
26213
|
async function hwpxToProfile(input) {
|
|
26205
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26214
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkRBUBZ2TAcjs.toArrayBuffer.call(void 0, input);
|
|
26206
26215
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26207
26216
|
const parser = createXmlParser();
|
|
26208
26217
|
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _417 => _417.file, 'call', _418 => _418(/[Hh]eader\.xml$/), 'optionalAccess', _419 => _419[0]])));
|
|
@@ -27121,7 +27130,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27121
27130
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27122
27131
|
if (paths.length > 0) return paths;
|
|
27123
27132
|
}
|
|
27124
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27133
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkRBUBZ2TAcjs.compareSectionPaths);
|
|
27125
27134
|
}
|
|
27126
27135
|
function sectionPathsFromManifest(xml) {
|
|
27127
27136
|
const attr = (tag, name) => {
|
|
@@ -27131,7 +27140,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27131
27140
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27132
27141
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27133
27142
|
const id = attr(m[1], "id");
|
|
27134
|
-
const href =
|
|
27143
|
+
const href = _chunkRBUBZ2TAcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27135
27144
|
if (id && href) idToHref.set(id, href);
|
|
27136
27145
|
}
|
|
27137
27146
|
const ordered = [];
|
|
@@ -27140,7 +27149,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27140
27149
|
if (href) ordered.push(href);
|
|
27141
27150
|
}
|
|
27142
27151
|
if (ordered.length > 0) return ordered;
|
|
27143
|
-
return Array.from(idToHref.values()).sort(
|
|
27152
|
+
return Array.from(idToHref.values()).sort(_chunkRBUBZ2TAcjs.compareSectionPaths);
|
|
27144
27153
|
}
|
|
27145
27154
|
|
|
27146
27155
|
// src/roundtrip/patcher.ts
|
|
@@ -27251,9 +27260,9 @@ function buildOrigUnits(blocks) {
|
|
|
27251
27260
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27252
27261
|
const next = blocks[i + 1];
|
|
27253
27262
|
if (_optionalChain([next, 'optionalAccess', _452 => _452.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
27254
|
-
chunk =
|
|
27263
|
+
chunk = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27255
27264
|
} else {
|
|
27256
|
-
chunk =
|
|
27265
|
+
chunk = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27257
27266
|
}
|
|
27258
27267
|
if (chunk) {
|
|
27259
27268
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -28856,12 +28865,12 @@ function blocksToChunks(blocks, options) {
|
|
|
28856
28865
|
let run = null;
|
|
28857
28866
|
const flushRun = () => {
|
|
28858
28867
|
if (!run) return;
|
|
28859
|
-
push("text", run.breadcrumb,
|
|
28868
|
+
push("text", run.breadcrumb, _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
28860
28869
|
run = null;
|
|
28861
28870
|
};
|
|
28862
28871
|
for (let i = 0; i < blocks.length; i++) {
|
|
28863
28872
|
const block = blocks[i];
|
|
28864
|
-
const md2 =
|
|
28873
|
+
const md2 = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28865
28874
|
if (!md2) continue;
|
|
28866
28875
|
if (block.type === "heading") {
|
|
28867
28876
|
flushRun();
|
|
@@ -29331,13 +29340,13 @@ async function htmlToPdf(html, options) {
|
|
|
29331
29340
|
try {
|
|
29332
29341
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29333
29342
|
} catch (e32) {
|
|
29334
|
-
throw new (0,
|
|
29343
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(
|
|
29335
29344
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29336
29345
|
);
|
|
29337
29346
|
}
|
|
29338
29347
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29339
29348
|
if (!executablePath) {
|
|
29340
|
-
throw new (0,
|
|
29349
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)(
|
|
29341
29350
|
"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."
|
|
29342
29351
|
);
|
|
29343
29352
|
}
|
|
@@ -29396,7 +29405,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
29396
29405
|
return htmlToPdf(html, options);
|
|
29397
29406
|
}
|
|
29398
29407
|
async function blocksToPdf(blocks, options) {
|
|
29399
|
-
const markdown =
|
|
29408
|
+
const markdown = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
29400
29409
|
return markdownToPdf(markdown, options);
|
|
29401
29410
|
}
|
|
29402
29411
|
|
|
@@ -30290,15 +30299,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30290
30299
|
async function renderHwpxToSvg(input, options) {
|
|
30291
30300
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _549 => _549.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30292
30301
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30293
|
-
|
|
30302
|
+
_chunkRBUBZ2TAcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30294
30303
|
let zip;
|
|
30295
30304
|
try {
|
|
30296
30305
|
zip = await _jszip2.default.loadAsync(input);
|
|
30297
30306
|
} catch (e33) {
|
|
30298
|
-
throw new (0,
|
|
30307
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30299
30308
|
}
|
|
30300
30309
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30301
|
-
if (secFiles.length === 0) throw new (0,
|
|
30310
|
+
if (secFiles.length === 0) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30302
30311
|
const warnings = [];
|
|
30303
30312
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30304
30313
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -30306,7 +30315,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30306
30315
|
const secXmls = [];
|
|
30307
30316
|
for (const f of secFiles) {
|
|
30308
30317
|
const xml = await f.async("string");
|
|
30309
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
30318
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30310
30319
|
secXmls.push(xml);
|
|
30311
30320
|
}
|
|
30312
30321
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30379,9 +30388,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30379
30388
|
}
|
|
30380
30389
|
if (rendered.length === 0) {
|
|
30381
30390
|
if (noCacheSkipped) {
|
|
30382
|
-
throw new (0,
|
|
30391
|
+
throw new (0, _chunkRBUBZ2TAcjs.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)");
|
|
30383
30392
|
}
|
|
30384
|
-
throw new (0,
|
|
30393
|
+
throw new (0, _chunkRBUBZ2TAcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
30385
30394
|
}
|
|
30386
30395
|
const GAP = 2400;
|
|
30387
30396
|
const clipDefs = [];
|
|
@@ -30417,13 +30426,13 @@ async function parse(input, options) {
|
|
|
30417
30426
|
if (typeof input === "string") {
|
|
30418
30427
|
try {
|
|
30419
30428
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30420
|
-
buffer =
|
|
30429
|
+
buffer = _chunkRBUBZ2TAcjs.toArrayBuffer.call(void 0, buf);
|
|
30421
30430
|
} catch (err) {
|
|
30422
30431
|
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}`;
|
|
30423
30432
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
30424
30433
|
}
|
|
30425
30434
|
} else if (Buffer.isBuffer(input)) {
|
|
30426
|
-
buffer =
|
|
30435
|
+
buffer = _chunkRBUBZ2TAcjs.toArrayBuffer.call(void 0, input);
|
|
30427
30436
|
} else {
|
|
30428
30437
|
buffer = input;
|
|
30429
30438
|
}
|
|
@@ -30449,16 +30458,34 @@ async function parse(input, options) {
|
|
|
30449
30458
|
return parseHwpml(buffer, opts);
|
|
30450
30459
|
case "pdf":
|
|
30451
30460
|
return parsePdf(buffer, opts);
|
|
30461
|
+
case "image":
|
|
30462
|
+
return parseImage(buffer, opts);
|
|
30452
30463
|
default:
|
|
30453
30464
|
return { success: false, fileType: "unknown", error: "\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uD30C\uC77C \uD615\uC2DD\uC785\uB2C8\uB2E4.", code: "UNSUPPORTED_FORMAT" };
|
|
30454
30465
|
}
|
|
30455
30466
|
}
|
|
30467
|
+
async function parseImage(buffer, options) {
|
|
30468
|
+
try {
|
|
30469
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-N5Z32R4U.cjs")));
|
|
30470
|
+
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
30471
|
+
return {
|
|
30472
|
+
success: true,
|
|
30473
|
+
fileType: "image",
|
|
30474
|
+
markdown: _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, blocks),
|
|
30475
|
+
blocks,
|
|
30476
|
+
warnings: warnings.length ? warnings : void 0,
|
|
30477
|
+
pageCount: 1
|
|
30478
|
+
};
|
|
30479
|
+
} catch (err) {
|
|
30480
|
+
return { success: false, fileType: "image", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err) };
|
|
30481
|
+
}
|
|
30482
|
+
}
|
|
30456
30483
|
async function parseHwp3(buffer, options) {
|
|
30457
30484
|
try {
|
|
30458
30485
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
30459
30486
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
30460
30487
|
} catch (err) {
|
|
30461
|
-
return { success: false, fileType: "hwp3", error:
|
|
30488
|
+
return { success: false, fileType: "hwp3", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err) };
|
|
30462
30489
|
}
|
|
30463
30490
|
}
|
|
30464
30491
|
async function parseHwpx(buffer, options) {
|
|
@@ -30466,7 +30493,7 @@ async function parseHwpx(buffer, options) {
|
|
|
30466
30493
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
30467
30494
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _556 => _556.length]) ? images : void 0 };
|
|
30468
30495
|
} catch (err) {
|
|
30469
|
-
return { success: false, fileType: "hwpx", error:
|
|
30496
|
+
return { success: false, fileType: "hwpx", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err) };
|
|
30470
30497
|
}
|
|
30471
30498
|
}
|
|
30472
30499
|
async function parseHwp(buffer, options) {
|
|
@@ -30491,13 +30518,13 @@ async function parseHwp(buffer, options) {
|
|
|
30491
30518
|
}
|
|
30492
30519
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _558 => _558.length]) ? images : void 0 };
|
|
30493
30520
|
} catch (err) {
|
|
30494
|
-
return { success: false, fileType: "hwp", error:
|
|
30521
|
+
return { success: false, fileType: "hwp", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err) };
|
|
30495
30522
|
}
|
|
30496
30523
|
}
|
|
30497
30524
|
async function parsePdf(buffer, options) {
|
|
30498
30525
|
let parsePdfDocument;
|
|
30499
30526
|
try {
|
|
30500
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
30527
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-R4CXIXRN.cjs")));
|
|
30501
30528
|
parsePdfDocument = mod.parsePdfDocument;
|
|
30502
30529
|
} catch (e35) {
|
|
30503
30530
|
return {
|
|
@@ -30512,7 +30539,7 @@ async function parsePdf(buffer, options) {
|
|
|
30512
30539
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
30513
30540
|
} catch (err) {
|
|
30514
30541
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
30515
|
-
return { success: false, fileType: "pdf", error:
|
|
30542
|
+
return { success: false, fileType: "pdf", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err), isImageBased };
|
|
30516
30543
|
}
|
|
30517
30544
|
}
|
|
30518
30545
|
async function parseXlsx(buffer, options) {
|
|
@@ -30520,7 +30547,7 @@ async function parseXlsx(buffer, options) {
|
|
|
30520
30547
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
30521
30548
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
30522
30549
|
} catch (err) {
|
|
30523
|
-
return { success: false, fileType: "xlsx", error:
|
|
30550
|
+
return { success: false, fileType: "xlsx", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err) };
|
|
30524
30551
|
}
|
|
30525
30552
|
}
|
|
30526
30553
|
async function parseXls(buffer, options) {
|
|
@@ -30528,7 +30555,7 @@ async function parseXls(buffer, options) {
|
|
|
30528
30555
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
30529
30556
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
30530
30557
|
} catch (err) {
|
|
30531
|
-
return { success: false, fileType: "xls", error:
|
|
30558
|
+
return { success: false, fileType: "xls", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err) };
|
|
30532
30559
|
}
|
|
30533
30560
|
}
|
|
30534
30561
|
async function parseDocx(buffer, options) {
|
|
@@ -30536,7 +30563,7 @@ async function parseDocx(buffer, options) {
|
|
|
30536
30563
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
30537
30564
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _559 => _559.length]) ? images : void 0 };
|
|
30538
30565
|
} catch (err) {
|
|
30539
|
-
return { success: false, fileType: "docx", error:
|
|
30566
|
+
return { success: false, fileType: "docx", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err) };
|
|
30540
30567
|
}
|
|
30541
30568
|
}
|
|
30542
30569
|
async function parseHwpml(buffer, options) {
|
|
@@ -30544,16 +30571,16 @@ async function parseHwpml(buffer, options) {
|
|
|
30544
30571
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
30545
30572
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
30546
30573
|
} catch (err) {
|
|
30547
|
-
return { success: false, fileType: "hwpml", error:
|
|
30574
|
+
return { success: false, fileType: "hwpml", error: _chunkRBUBZ2TAcjs.sanitizeError.call(void 0, err), code: _chunkRBUBZ2TAcjs.classifyError.call(void 0, err) };
|
|
30548
30575
|
}
|
|
30549
30576
|
}
|
|
30550
30577
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
30551
30578
|
let buffer;
|
|
30552
30579
|
if (typeof input === "string") {
|
|
30553
30580
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30554
|
-
buffer =
|
|
30581
|
+
buffer = _chunkRBUBZ2TAcjs.toArrayBuffer.call(void 0, buf);
|
|
30555
30582
|
} else if (Buffer.isBuffer(input)) {
|
|
30556
|
-
buffer =
|
|
30583
|
+
buffer = _chunkRBUBZ2TAcjs.toArrayBuffer.call(void 0, input);
|
|
30557
30584
|
} else {
|
|
30558
30585
|
buffer = input;
|
|
30559
30586
|
}
|
|
@@ -30579,7 +30606,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30579
30606
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
30580
30607
|
}
|
|
30581
30608
|
const fill = fillFormFields(parsed.blocks, values);
|
|
30582
|
-
const markdown =
|
|
30609
|
+
const markdown = _chunkLSXXGUWAcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
30583
30610
|
if (outputFormat === "hwpx") {
|
|
30584
30611
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
30585
30612
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30652,5 +30679,6 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30652
30679
|
|
|
30653
30680
|
|
|
30654
30681
|
|
|
30655
|
-
|
|
30682
|
+
|
|
30683
|
+
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 = _chunkRBUBZ2TAcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkLSXXGUWAcjs.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.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.redactMarkdown = redactMarkdown; exports.redactText = redactText; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.validateHwpx = validateHwpx;
|
|
30656
30684
|
//# sourceMappingURL=index.cjs.map
|