kordoc 4.2.4 → 4.2.5
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/dist/{-2M56QRNH.js → -G2JOUAZU.js} +8 -8
- package/dist/{chunk-YFSYLEXO.cjs → chunk-4VRGN6MO.cjs} +3 -3
- package/dist/{chunk-YFSYLEXO.cjs.map → chunk-4VRGN6MO.cjs.map} +1 -1
- package/dist/{chunk-GFTAPAJS.js → chunk-6AJGCOCS.js} +2 -2
- package/dist/{chunk-I53FOXZR.js → chunk-CB3HDP4O.js} +2 -2
- package/dist/{chunk-7Z3NHIRR.js → chunk-JZIPR2PJ.js} +2 -2
- package/dist/{chunk-CAA6DVEE.js → chunk-L7KFGFDA.js} +17 -11
- package/dist/chunk-L7KFGFDA.js.map +1 -0
- package/dist/{chunk-BLNOGMIM.cjs → chunk-LHH7AT6J.cjs} +2 -2
- package/dist/{chunk-BLNOGMIM.cjs.map → chunk-LHH7AT6J.cjs.map} +1 -1
- package/dist/{chunk-SCJLAOY3.cjs → chunk-M4BQRAOM.cjs} +4 -4
- package/dist/{chunk-SCJLAOY3.cjs.map → chunk-M4BQRAOM.cjs.map} +1 -1
- package/dist/{chunk-ZHRYLT3N.js → chunk-NTK7B6EU.js} +3 -3
- package/dist/{chunk-7KRCQE3P.js → chunk-PEKWJZDQ.js} +2 -2
- package/dist/{chunk-E2K4SNMD.js → chunk-PPRJ3TVL.js} +2 -2
- package/dist/{chunk-DOLK5KIS.js → chunk-R5DVJNXY.js} +2 -2
- package/dist/{chunk-LWNFAIYG.js → chunk-SPY7ZVBB.js} +3 -3
- package/dist/{chunk-OBX3VSIZ.js → chunk-TH4YAOOG.js} +2 -2
- package/dist/{chunk-WMM6XVQX.js → chunk-VKVFHF5E.js} +2 -2
- package/dist/{chunk-PQ46DC6Y.js → chunk-VSTUPUNH.js} +2 -2
- package/dist/{chunk-LXUZUUUG.cjs → chunk-VUU26FTT.cjs} +9 -9
- package/dist/{chunk-LXUZUUUG.cjs.map → chunk-VUU26FTT.cjs.map} +1 -1
- package/dist/{chunk-PMBWFYZQ.js → chunk-WHCDNDDG.js} +2 -2
- package/dist/{chunk-H6O65EPK.js → chunk-XOOQ46DQ.js} +2 -2
- package/dist/chunk-XOOQ46DQ.js.map +1 -0
- package/dist/chunks-ASAY2R5Q.js +10 -0
- package/dist/cli.js +16 -16
- package/dist/{image-ocr-HY42AVXC.js → image-ocr-C2VYH6L7.js} +4 -4
- package/dist/{image-ocr-WCIDB6RY.js → image-ocr-ILTRLOCF.js} +4 -4
- package/dist/{image-ocr-JWAX5EOB.cjs → image-ocr-RN77CC5P.cjs} +9 -9
- package/dist/{image-ocr-JWAX5EOB.cjs.map → image-ocr-RN77CC5P.cjs.map} +1 -1
- package/dist/index.cjs +160 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +14 -14
- package/dist/{parser-6RDEBLSB.cjs → parser-5TEQ6EFF.cjs} +24 -24
- package/dist/{parser-6RDEBLSB.cjs.map → parser-5TEQ6EFF.cjs.map} +1 -1
- package/dist/{parser-WRNS6MX2.js → parser-7XDK53L6.js} +5 -5
- package/dist/{parser-SVZPCCRG.js → parser-FDOR727T.js} +5 -5
- package/dist/{pdf-ocr-WM3RZMZY.js → pdf-ocr-4LO224RJ.js} +4 -4
- package/dist/pdf-ocr-5XGZH6D4.cjs +13 -0
- package/dist/{pdf-ocr-4SGVLUNL.cjs.map → pdf-ocr-5XGZH6D4.cjs.map} +1 -1
- package/dist/pdf-ocr-ZEKXX54R.js +12 -0
- package/dist/{profile-io-SWGUQSCL.js → profile-io-6SYG2B2L.js} +3 -3
- package/dist/{rasterize-QA7W6QUF.js → rasterize-PV7NU33W.js} +2 -2
- package/dist/render-ORPFUHVA.js +10 -0
- package/dist/seal-3AEDWS4F.js +10 -0
- package/dist/{watch-SFQNFU7Q.js → watch-ZXCJZTSN.js} +8 -8
- package/package.json +1 -1
- package/dist/chunk-CAA6DVEE.js.map +0 -1
- package/dist/chunk-H6O65EPK.js.map +0 -1
- package/dist/chunks-GT45ALC5.js +0 -10
- package/dist/pdf-ocr-4SGVLUNL.cjs +0 -13
- package/dist/pdf-ocr-7AAHJOXQ.js +0 -12
- package/dist/render-DRUIPV77.js +0 -10
- package/dist/seal-3M4ZSW66.js +0 -10
- /package/dist/{-2M56QRNH.js.map → -G2JOUAZU.js.map} +0 -0
- /package/dist/{chunk-GFTAPAJS.js.map → chunk-6AJGCOCS.js.map} +0 -0
- /package/dist/{chunk-I53FOXZR.js.map → chunk-CB3HDP4O.js.map} +0 -0
- /package/dist/{chunk-7Z3NHIRR.js.map → chunk-JZIPR2PJ.js.map} +0 -0
- /package/dist/{chunk-ZHRYLT3N.js.map → chunk-NTK7B6EU.js.map} +0 -0
- /package/dist/{chunk-7KRCQE3P.js.map → chunk-PEKWJZDQ.js.map} +0 -0
- /package/dist/{chunk-E2K4SNMD.js.map → chunk-PPRJ3TVL.js.map} +0 -0
- /package/dist/{chunk-DOLK5KIS.js.map → chunk-R5DVJNXY.js.map} +0 -0
- /package/dist/{chunk-LWNFAIYG.js.map → chunk-SPY7ZVBB.js.map} +0 -0
- /package/dist/{chunk-OBX3VSIZ.js.map → chunk-TH4YAOOG.js.map} +0 -0
- /package/dist/{chunk-WMM6XVQX.js.map → chunk-VKVFHF5E.js.map} +0 -0
- /package/dist/{chunk-PQ46DC6Y.js.map → chunk-VSTUPUNH.js.map} +0 -0
- /package/dist/{chunk-PMBWFYZQ.js.map → chunk-WHCDNDDG.js.map} +0 -0
- /package/dist/{chunks-GT45ALC5.js.map → chunks-ASAY2R5Q.js.map} +0 -0
- /package/dist/{image-ocr-HY42AVXC.js.map → image-ocr-C2VYH6L7.js.map} +0 -0
- /package/dist/{image-ocr-WCIDB6RY.js.map → image-ocr-ILTRLOCF.js.map} +0 -0
- /package/dist/{parser-WRNS6MX2.js.map → parser-7XDK53L6.js.map} +0 -0
- /package/dist/{parser-SVZPCCRG.js.map → parser-FDOR727T.js.map} +0 -0
- /package/dist/{pdf-ocr-7AAHJOXQ.js.map → pdf-ocr-4LO224RJ.js.map} +0 -0
- /package/dist/{pdf-ocr-WM3RZMZY.js.map → pdf-ocr-ZEKXX54R.js.map} +0 -0
- /package/dist/{profile-io-SWGUQSCL.js.map → profile-io-6SYG2B2L.js.map} +0 -0
- /package/dist/{rasterize-QA7W6QUF.js.map → rasterize-PV7NU33W.js.map} +0 -0
- /package/dist/{render-DRUIPV77.js.map → render-ORPFUHVA.js.map} +0 -0
- /package/dist/{seal-3M4ZSW66.js.map → seal-3AEDWS4F.js.map} +0 -0
- /package/dist/{watch-SFQNFU7Q.js.map → watch-ZXCJZTSN.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkM4BQRAOMcjs = require('./chunk-M4BQRAOM.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 _chunkLHH7AT6Jcjs = require('./chunk-LHH7AT6J.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -413,7 +413,7 @@ function comResultToParseResult(pages, pageCount, warnings) {
|
|
|
413
413
|
var _xmldom = require('@xmldom/xmldom');
|
|
414
414
|
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
415
415
|
var MAX_ZIP_ENTRIES = 500;
|
|
416
|
-
var ZipBombError = class extends
|
|
416
|
+
var ZipBombError = class extends _chunkLHH7AT6Jcjs.KordocError {
|
|
417
417
|
constructor(message) {
|
|
418
418
|
super(message);
|
|
419
419
|
this.name = "ZipBombError";
|
|
@@ -429,7 +429,7 @@ function createSectionShared() {
|
|
|
429
429
|
function createXmlParser(warnings) {
|
|
430
430
|
return new (0, _xmldom.DOMParser)({
|
|
431
431
|
onError(level, msg2) {
|
|
432
|
-
if (level === "fatalError") throw new (0,
|
|
432
|
+
if (level === "fatalError") throw new (0, _chunkLHH7AT6Jcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
433
433
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -506,10 +506,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
506
506
|
const xml = await file.async("text");
|
|
507
507
|
if (decompressed) {
|
|
508
508
|
decompressed.total += xml.length * 2;
|
|
509
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
509
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
510
510
|
}
|
|
511
511
|
const parser = createXmlParser();
|
|
512
|
-
const doc = parser.parseFromString(
|
|
512
|
+
const doc = parser.parseFromString(_chunkLHH7AT6Jcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
513
513
|
if (!doc.documentElement) continue;
|
|
514
514
|
const domDoc = doc;
|
|
515
515
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -696,9 +696,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
696
696
|
let level = 0;
|
|
697
697
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _11 => _11.style, 'optionalAccess', _12 => _12.fontSize])) {
|
|
698
698
|
const ratio = block.style.fontSize / baseFontSize;
|
|
699
|
-
if (ratio >=
|
|
700
|
-
else if (ratio >=
|
|
701
|
-
else if (ratio >=
|
|
699
|
+
if (ratio >= _chunkLHH7AT6Jcjs.HEADING_RATIO_H1) level = 1;
|
|
700
|
+
else if (ratio >= _chunkLHH7AT6Jcjs.HEADING_RATIO_H2) level = 2;
|
|
701
|
+
else if (ratio >= _chunkLHH7AT6Jcjs.HEADING_RATIO_H3) level = 3;
|
|
702
702
|
}
|
|
703
703
|
const compactText = text.replace(/\s+/g, "");
|
|
704
704
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1623,7 +1623,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
function assertFiniteRange(name, value, min, max) {
|
|
1625
1625
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
1626
|
-
throw new (0,
|
|
1626
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
1627
1627
|
}
|
|
1628
1628
|
}
|
|
1629
1629
|
function validateGongmunOptions(opts) {
|
|
@@ -1638,10 +1638,10 @@ function validateGongmunOptions(opts) {
|
|
|
1638
1638
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
1639
1639
|
}
|
|
1640
1640
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
1641
|
-
throw new (0,
|
|
1641
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
1642
1642
|
}
|
|
1643
1643
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
1644
|
-
throw new (0,
|
|
1644
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
1645
1645
|
}
|
|
1646
1646
|
}
|
|
1647
1647
|
if (opts.sizes) {
|
|
@@ -1650,7 +1650,7 @@ function validateGongmunOptions(opts) {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
}
|
|
1652
1652
|
if (opts.approval && opts.approval.length > 6) {
|
|
1653
|
-
throw new (0,
|
|
1653
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("approval must contain at most 6 labels");
|
|
1654
1654
|
}
|
|
1655
1655
|
}
|
|
1656
1656
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -1915,7 +1915,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1915
1915
|
|
|
1916
1916
|
// src/hwpx/table-build.ts
|
|
1917
1917
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
|
|
1918
|
-
const table2 =
|
|
1918
|
+
const table2 = _chunkM4BQRAOMcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols });
|
|
1919
1919
|
if (state.caption) table2.caption = state.caption;
|
|
1920
1920
|
const anchors = [];
|
|
1921
1921
|
{
|
|
@@ -1985,9 +1985,13 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1985
1985
|
const cell2 = parentTable.cell;
|
|
1986
1986
|
(cell2.blocks ??= []).push(block);
|
|
1987
1987
|
cell2.hasStructure = true;
|
|
1988
|
-
let flat =
|
|
1988
|
+
let flat = _chunkM4BQRAOMcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1989
1989
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1990
|
-
if (flat)
|
|
1990
|
+
if (flat) {
|
|
1991
|
+
const inlineJoin = newTable.inline === true && cell2.lineOpen === true;
|
|
1992
|
+
cell2.text += (cell2.text ? inlineJoin ? " " : "\n" : "") + flat;
|
|
1993
|
+
cell2.lineOpen = newTable.inline === true;
|
|
1994
|
+
}
|
|
1991
1995
|
} else {
|
|
1992
1996
|
blocks.push(block);
|
|
1993
1997
|
}
|
|
@@ -1997,7 +2001,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1997
2001
|
// src/hwpx/section-walker.ts
|
|
1998
2002
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1999
2003
|
const parser = createXmlParser(warnings);
|
|
2000
|
-
const doc = parser.parseFromString(
|
|
2004
|
+
const doc = parser.parseFromString(_chunkLHH7AT6Jcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
2001
2005
|
if (!doc.documentElement) return [];
|
|
2002
2006
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
2003
2007
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -2103,8 +2107,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2103
2107
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
2104
2108
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
2105
2109
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
2106
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
2107
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
2110
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkM4BQRAOMcjs.MAX_COLS);
|
|
2111
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkM4BQRAOMcjs.MAX_ROWS);
|
|
2108
2112
|
}
|
|
2109
2113
|
break;
|
|
2110
2114
|
case "p": {
|
|
@@ -2118,6 +2122,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2118
2122
|
}
|
|
2119
2123
|
if (segments) {
|
|
2120
2124
|
const cell2 = _nullishCoalesce(_optionalChain([tableCtx, 'optionalAccess', _36 => _36.cell]), () => ( null));
|
|
2125
|
+
if (cell2) cell2.lineOpen = false;
|
|
2121
2126
|
const segs = [...segments];
|
|
2122
2127
|
if (_optionalChain([ph, 'optionalAccess', _37 => _37.prefix])) {
|
|
2123
2128
|
const fi = segs.findIndex((s) => s);
|
|
@@ -2136,7 +2141,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2136
2141
|
if (footnote) block.footnoteText = footnote;
|
|
2137
2142
|
}
|
|
2138
2143
|
if (cell2) {
|
|
2139
|
-
cell2.text += (cell2.text ? "\n" : "") + s;
|
|
2144
|
+
cell2.text += (cell2.text ? cell2.lineOpen ? " " : "\n" : "") + s;
|
|
2145
|
+
cell2.lineOpen = true;
|
|
2140
2146
|
(cell2.blocks ??= []).push(block);
|
|
2141
2147
|
} else blocks.push(block);
|
|
2142
2148
|
};
|
|
@@ -2344,7 +2350,7 @@ function flattenSubListTable(el, ctx, depth) {
|
|
|
2344
2350
|
const sink = [];
|
|
2345
2351
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2346
2352
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2347
|
-
let flat =
|
|
2353
|
+
let flat = _chunkM4BQRAOMcjs.convertTableToText.call(void 0, st.rows);
|
|
2348
2354
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2349
2355
|
return flat;
|
|
2350
2356
|
}
|
|
@@ -2388,7 +2394,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2388
2394
|
}
|
|
2389
2395
|
}
|
|
2390
2396
|
if (tableCtx) tableStack.push(tableCtx);
|
|
2391
|
-
const newTable = { rows: [], currentRow: [], cell: null };
|
|
2397
|
+
const newTable = { rows: [], currentRow: [], cell: null, inline: isInlineTbl(el) };
|
|
2392
2398
|
walkSection(el, blocks, newTable, tableStack, ctx, d + 1);
|
|
2393
2399
|
tableCtx = completeTable(newTable, tableStack, blocks, ctx);
|
|
2394
2400
|
} else if (localTag === "caption" && !inShape) {
|
|
@@ -2481,7 +2487,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2481
2487
|
let url = (ch.textContent || "").trim();
|
|
2482
2488
|
if (!url) continue;
|
|
2483
2489
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2484
|
-
const safe =
|
|
2490
|
+
const safe = _chunkLHH7AT6Jcjs.sanitizeHref.call(void 0, url);
|
|
2485
2491
|
if (safe) return safe;
|
|
2486
2492
|
}
|
|
2487
2493
|
return void 0;
|
|
@@ -2641,7 +2647,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2641
2647
|
case "hyperlink": {
|
|
2642
2648
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2643
2649
|
if (url) {
|
|
2644
|
-
const safe =
|
|
2650
|
+
const safe = _chunkLHH7AT6Jcjs.sanitizeHref.call(void 0, url);
|
|
2645
2651
|
if (safe) href = safe;
|
|
2646
2652
|
}
|
|
2647
2653
|
walk(child, depth + 1);
|
|
@@ -2915,7 +2921,7 @@ function decompressStream(data) {
|
|
|
2915
2921
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2916
2922
|
}
|
|
2917
2923
|
function parseFileHeader(data) {
|
|
2918
|
-
if (data.length < 40) throw new (0,
|
|
2924
|
+
if (data.length < 40) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2919
2925
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2920
2926
|
return {
|
|
2921
2927
|
signature: sig,
|
|
@@ -3364,13 +3370,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3364
3370
|
}
|
|
3365
3371
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3366
3372
|
for (const path of allCandidates) {
|
|
3367
|
-
if (
|
|
3373
|
+
if (_chunkLHH7AT6Jcjs.isPathTraversal.call(void 0, path)) continue;
|
|
3368
3374
|
const file = zip.file(path);
|
|
3369
3375
|
if (!file) continue;
|
|
3370
3376
|
try {
|
|
3371
3377
|
const data = await file.async("uint8array");
|
|
3372
3378
|
decompressed.total += data.length;
|
|
3373
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3379
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3374
3380
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3375
3381
|
const mimeType = imageExtToMime(ext);
|
|
3376
3382
|
imageIndex++;
|
|
@@ -3380,7 +3386,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3380
3386
|
usedPaths.add(path);
|
|
3381
3387
|
break;
|
|
3382
3388
|
} catch (err) {
|
|
3383
|
-
if (err instanceof
|
|
3389
|
+
if (err instanceof _chunkLHH7AT6Jcjs.KordocError) throw err;
|
|
3384
3390
|
}
|
|
3385
3391
|
}
|
|
3386
3392
|
if (!img) _optionalChain([warnings, 'optionalAccess', _78 => _78.push, 'call', _79 => _79({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -3400,11 +3406,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3400
3406
|
if (sweepUnreferenced) {
|
|
3401
3407
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3402
3408
|
for (const file of binEntries) {
|
|
3403
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3409
|
+
if (file.dir || usedPaths.has(file.name) || _chunkLHH7AT6Jcjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3404
3410
|
try {
|
|
3405
3411
|
const data = await file.async("uint8array");
|
|
3406
3412
|
decompressed.total += data.length;
|
|
3407
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3413
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3408
3414
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3409
3415
|
let mimeType = imageExtToMime(ext);
|
|
3410
3416
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3418,7 +3424,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3418
3424
|
images.push(img);
|
|
3419
3425
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3420
3426
|
} catch (err) {
|
|
3421
|
-
if (err instanceof
|
|
3427
|
+
if (err instanceof _chunkLHH7AT6Jcjs.KordocError) throw err;
|
|
3422
3428
|
_optionalChain([warnings, 'optionalAccess', _80 => _80.push, 'call', _81 => _81({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3423
3429
|
}
|
|
3424
3430
|
}
|
|
@@ -3469,7 +3475,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3469
3475
|
}
|
|
3470
3476
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3471
3477
|
const name = new TextDecoder().decode(nameBytes);
|
|
3472
|
-
if (
|
|
3478
|
+
if (_chunkLHH7AT6Jcjs.isPathTraversal.call(void 0, name)) {
|
|
3473
3479
|
pos = fileStart + compSize;
|
|
3474
3480
|
continue;
|
|
3475
3481
|
}
|
|
@@ -3487,16 +3493,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
3487
3493
|
continue;
|
|
3488
3494
|
}
|
|
3489
3495
|
totalDecompressed += content.length * 2;
|
|
3490
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3496
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3491
3497
|
sectionNum++;
|
|
3492
3498
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
3493
3499
|
} catch (e16) {
|
|
3494
3500
|
continue;
|
|
3495
3501
|
}
|
|
3496
3502
|
}
|
|
3497
|
-
if (blocks.length === 0) throw new (0,
|
|
3503
|
+
if (blocks.length === 0) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3498
3504
|
applyPageText(blocks, shared);
|
|
3499
|
-
const markdown =
|
|
3505
|
+
const markdown = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3500
3506
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3501
3507
|
}
|
|
3502
3508
|
async function readKordocLayout(zip) {
|
|
@@ -3521,18 +3527,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3521
3527
|
if (paths.length > 0) return paths;
|
|
3522
3528
|
}
|
|
3523
3529
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3524
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3530
|
+
return sectionFiles.map((f) => f.name).sort(_chunkLHH7AT6Jcjs.compareSectionPaths);
|
|
3525
3531
|
}
|
|
3526
3532
|
function parseSectionPathsFromManifest(xml) {
|
|
3527
3533
|
const parser = createXmlParser();
|
|
3528
|
-
const doc = parser.parseFromString(
|
|
3534
|
+
const doc = parser.parseFromString(_chunkLHH7AT6Jcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3529
3535
|
const items = doc.getElementsByTagName("opf:item");
|
|
3530
3536
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3531
3537
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3532
3538
|
for (let i = 0; i < items.length; i++) {
|
|
3533
3539
|
const item = items[i];
|
|
3534
3540
|
const id = item.getAttribute("id") || "";
|
|
3535
|
-
const href =
|
|
3541
|
+
const href = _chunkLHH7AT6Jcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3536
3542
|
if (id && href) idToHref.set(id, href);
|
|
3537
3543
|
}
|
|
3538
3544
|
if (spine.length > 0) {
|
|
@@ -3543,7 +3549,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3543
3549
|
}
|
|
3544
3550
|
if (ordered.length > 0) return ordered;
|
|
3545
3551
|
}
|
|
3546
|
-
return Array.from(idToHref.values()).sort(
|
|
3552
|
+
return Array.from(idToHref.values()).sort(_chunkLHH7AT6Jcjs.compareSectionPaths);
|
|
3547
3553
|
}
|
|
3548
3554
|
|
|
3549
3555
|
// src/hwpx/metadata.ts
|
|
@@ -3556,7 +3562,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3556
3562
|
const xml = await file.async("text");
|
|
3557
3563
|
if (decompressed) {
|
|
3558
3564
|
decompressed.total += xml.length * 2;
|
|
3559
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3565
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3560
3566
|
}
|
|
3561
3567
|
parseDublinCoreMetadata(xml, metadata);
|
|
3562
3568
|
if (metadata.title || metadata.author) return;
|
|
@@ -3566,7 +3572,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3566
3572
|
}
|
|
3567
3573
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3568
3574
|
const parser = createXmlParser();
|
|
3569
|
-
const doc = parser.parseFromString(
|
|
3575
|
+
const doc = parser.parseFromString(_chunkLHH7AT6Jcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3570
3576
|
if (!doc.documentElement) return;
|
|
3571
3577
|
const getText = (tagNames) => {
|
|
3572
3578
|
for (const tag of tagNames) {
|
|
@@ -3591,7 +3597,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3591
3597
|
|
|
3592
3598
|
// src/hwpx/parser.ts
|
|
3593
3599
|
async function parseHwpxDocument(buffer, options) {
|
|
3594
|
-
|
|
3600
|
+
_chunkLHH7AT6Jcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3595
3601
|
let zip;
|
|
3596
3602
|
try {
|
|
3597
3603
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3600,7 +3606,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3600
3606
|
}
|
|
3601
3607
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3602
3608
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3603
|
-
throw new (0,
|
|
3609
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3604
3610
|
}
|
|
3605
3611
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3606
3612
|
if (manifestFile) {
|
|
@@ -3612,7 +3618,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3612
3618
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3613
3619
|
}
|
|
3614
3620
|
}
|
|
3615
|
-
throw new (0,
|
|
3621
|
+
throw new (0, _chunkLHH7AT6Jcjs.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.");
|
|
3616
3622
|
}
|
|
3617
3623
|
}
|
|
3618
3624
|
const decompressed = { total: 0 };
|
|
@@ -3621,7 +3627,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3621
3627
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3622
3628
|
const warnings = [];
|
|
3623
3629
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3624
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3630
|
+
if (sectionPaths.length === 0) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3625
3631
|
metadata.pageCount = sectionPaths.length;
|
|
3626
3632
|
const pageFilter = _optionalChain([options, 'optionalAccess', _90 => _90.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
3627
3633
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
@@ -3650,7 +3656,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3650
3656
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !pageFilter);
|
|
3651
3657
|
detectHwpxHeadings(blocks, styleMap);
|
|
3652
3658
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3653
|
-
const markdown =
|
|
3659
|
+
const markdown = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3654
3660
|
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 };
|
|
3655
3661
|
}
|
|
3656
3662
|
|
|
@@ -4829,7 +4835,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4829
4835
|
lenientCfb = parseLenientCfb(buffer);
|
|
4830
4836
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4831
4837
|
} catch (e22) {
|
|
4832
|
-
throw new (0,
|
|
4838
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4833
4839
|
}
|
|
4834
4840
|
}
|
|
4835
4841
|
const findStream = (path) => {
|
|
@@ -4840,11 +4846,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
4840
4846
|
return lenientCfb.findStream(path);
|
|
4841
4847
|
};
|
|
4842
4848
|
const headerData = findStream("/FileHeader");
|
|
4843
|
-
if (!headerData) throw new (0,
|
|
4849
|
+
if (!headerData) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4844
4850
|
const header = parseFileHeader(headerData);
|
|
4845
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4846
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
4847
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4851
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkLHH7AT6Jcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4852
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4853
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4848
4854
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
4849
4855
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
4850
4856
|
const metadata = {
|
|
@@ -4853,7 +4859,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4853
4859
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4854
4860
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4855
4861
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4856
|
-
if (sections.length === 0) throw new (0,
|
|
4862
|
+
if (sections.length === 0) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4857
4863
|
metadata.pageCount = sections.length;
|
|
4858
4864
|
const pageFilter = _optionalChain([options, 'optionalAccess', _95 => _95.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
4859
4865
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
@@ -4868,22 +4874,22 @@ function parseHwp5Document(buffer, options) {
|
|
|
4868
4874
|
const sectionData = sections[si];
|
|
4869
4875
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
4870
4876
|
totalDecompressed += data.length;
|
|
4871
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4877
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4872
4878
|
const records = readRecords(data);
|
|
4873
4879
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
4874
4880
|
bodyBlocks.push(...sectionBlocks);
|
|
4875
4881
|
parsedSections++;
|
|
4876
4882
|
_optionalChain([options, 'optionalAccess', _97 => _97.onProgress, 'optionalCall', _98 => _98(parsedSections, totalTarget)]);
|
|
4877
4883
|
} catch (secErr) {
|
|
4878
|
-
if (secErr instanceof
|
|
4884
|
+
if (secErr instanceof _chunkLHH7AT6Jcjs.KordocError) throw secErr;
|
|
4879
4885
|
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" });
|
|
4880
4886
|
}
|
|
4881
4887
|
}
|
|
4882
4888
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4883
4889
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4884
|
-
let flatBlocks =
|
|
4890
|
+
let flatBlocks = _chunkM4BQRAOMcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4885
4891
|
if (_optionalChain([options, 'optionalAccess', _99 => _99.dedupeRunningHeaders])) {
|
|
4886
|
-
const deduped =
|
|
4892
|
+
const deduped = _chunkM4BQRAOMcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4887
4893
|
const removed = flatBlocks.length - deduped.length;
|
|
4888
4894
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4889
4895
|
flatBlocks = deduped;
|
|
@@ -4892,10 +4898,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4892
4898
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4893
4899
|
}
|
|
4894
4900
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4895
|
-
let markdown =
|
|
4901
|
+
let markdown = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4896
4902
|
if (_optionalChain([options, 'optionalAccess', _100 => _100.inlineImages]) && images.length > 0) {
|
|
4897
4903
|
try {
|
|
4898
|
-
markdown =
|
|
4904
|
+
markdown = _chunkM4BQRAOMcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4899
4905
|
} catch (inlineErr) {
|
|
4900
4906
|
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" });
|
|
4901
4907
|
}
|
|
@@ -4959,9 +4965,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4959
4965
|
let level = 0;
|
|
4960
4966
|
if (_optionalChain([block, 'access', _105 => _105.style, 'optionalAccess', _106 => _106.fontSize]) && baseFontSize > 0) {
|
|
4961
4967
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4962
|
-
if (ratio >=
|
|
4963
|
-
else if (ratio >=
|
|
4964
|
-
else if (ratio >=
|
|
4968
|
+
if (ratio >= _chunkLHH7AT6Jcjs.HEADING_RATIO_H1) level = 1;
|
|
4969
|
+
else if (ratio >= _chunkLHH7AT6Jcjs.HEADING_RATIO_H2) level = 2;
|
|
4970
|
+
else if (ratio >= _chunkLHH7AT6Jcjs.HEADING_RATIO_H3) level = 3;
|
|
4965
4971
|
}
|
|
4966
4972
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4967
4973
|
if (level === 0) level = 2;
|
|
@@ -5046,7 +5052,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5046
5052
|
if (!raw) break;
|
|
5047
5053
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5048
5054
|
totalDecompressed += content.length;
|
|
5049
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5055
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5050
5056
|
sections.push({ idx: i, content });
|
|
5051
5057
|
}
|
|
5052
5058
|
if (sections.length === 0) {
|
|
@@ -5058,7 +5064,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
5058
5064
|
if (raw) {
|
|
5059
5065
|
const content = compressed ? decompressStream(raw) : raw;
|
|
5060
5066
|
totalDecompressed += content.length;
|
|
5061
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5067
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5062
5068
|
sections.push({ idx, content });
|
|
5063
5069
|
}
|
|
5064
5070
|
}
|
|
@@ -5075,7 +5081,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
5075
5081
|
try {
|
|
5076
5082
|
const content = decryptViewText(raw, compressed);
|
|
5077
5083
|
totalDecompressed += content.length;
|
|
5078
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
5084
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
5079
5085
|
sections.push({ idx: i, content });
|
|
5080
5086
|
} catch (e27) {
|
|
5081
5087
|
break;
|
|
@@ -5178,7 +5184,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5178
5184
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5179
5185
|
if (!_optionalChain([ctrl, 'optionalAccess', _113 => _113.href]) || r.end <= r.start) continue;
|
|
5180
5186
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5181
|
-
const href =
|
|
5187
|
+
const href = _chunkLHH7AT6Jcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5182
5188
|
if (!href) continue;
|
|
5183
5189
|
const anchor = text.slice(r.start, r.end);
|
|
5184
5190
|
if (!anchor.trim()) continue;
|
|
@@ -5414,8 +5420,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5414
5420
|
let tableIdx = -1;
|
|
5415
5421
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5416
5422
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5417
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5418
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5423
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkM4BQRAOMcjs.MAX_ROWS);
|
|
5424
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkM4BQRAOMcjs.MAX_COLS);
|
|
5419
5425
|
tableIdx = i2;
|
|
5420
5426
|
break;
|
|
5421
5427
|
}
|
|
@@ -5464,7 +5470,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5464
5470
|
return table3;
|
|
5465
5471
|
}
|
|
5466
5472
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5467
|
-
const table2 =
|
|
5473
|
+
const table2 = _chunkM4BQRAOMcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5468
5474
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5469
5475
|
return table2.rows > 0 ? table2 : null;
|
|
5470
5476
|
}
|
|
@@ -5481,8 +5487,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5481
5487
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5482
5488
|
const cs = rec.data.readUInt16LE(12);
|
|
5483
5489
|
const rs = rec.data.readUInt16LE(14);
|
|
5484
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5485
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5490
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkM4BQRAOMcjs.MAX_COLS);
|
|
5491
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkM4BQRAOMcjs.MAX_ROWS);
|
|
5486
5492
|
}
|
|
5487
5493
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5488
5494
|
const parts = [];
|
|
@@ -5492,7 +5498,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5492
5498
|
parts.push(``);
|
|
5493
5499
|
hasStructure = true;
|
|
5494
5500
|
} else if (b.type === "table" && b.table) {
|
|
5495
|
-
const flat =
|
|
5501
|
+
const flat = _chunkM4BQRAOMcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5496
5502
|
if (flat) parts.push(flat);
|
|
5497
5503
|
hasStructure = true;
|
|
5498
5504
|
} else if (b.text) {
|
|
@@ -17987,7 +17993,7 @@ function getTextContent(el) {
|
|
|
17987
17993
|
return _nullishCoalesce(_optionalChain([el, 'access', _129 => _129.textContent, 'optionalAccess', _130 => _130.trim, 'call', _131 => _131()]), () => ( ""));
|
|
17988
17994
|
}
|
|
17989
17995
|
function parseXml(text) {
|
|
17990
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
17996
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkLHH7AT6Jcjs.stripDtd.call(void 0, text), "text/xml");
|
|
17991
17997
|
}
|
|
17992
17998
|
function collectRichText(root) {
|
|
17993
17999
|
let out = "";
|
|
@@ -18222,7 +18228,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18222
18228
|
cellRows.push(row);
|
|
18223
18229
|
}
|
|
18224
18230
|
if (cellRows.length > 0) {
|
|
18225
|
-
const table2 =
|
|
18231
|
+
const table2 = _chunkM4BQRAOMcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18226
18232
|
if (table2.rows > 0) {
|
|
18227
18233
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18228
18234
|
}
|
|
@@ -18230,12 +18236,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18230
18236
|
return blocks;
|
|
18231
18237
|
}
|
|
18232
18238
|
async function parseXlsxDocument(buffer, options) {
|
|
18233
|
-
|
|
18239
|
+
_chunkLHH7AT6Jcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18234
18240
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18235
18241
|
const warnings = [];
|
|
18236
18242
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18237
18243
|
if (!workbookFile) {
|
|
18238
|
-
throw new (0,
|
|
18244
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18239
18245
|
}
|
|
18240
18246
|
let sharedStrings = [];
|
|
18241
18247
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18244,7 +18250,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18244
18250
|
}
|
|
18245
18251
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18246
18252
|
if (sheets.length === 0) {
|
|
18247
|
-
throw new (0,
|
|
18253
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18248
18254
|
}
|
|
18249
18255
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18250
18256
|
const stylesFile = zip.file("xl/styles.xml");
|
|
@@ -18324,7 +18330,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18324
18330
|
} catch (e29) {
|
|
18325
18331
|
}
|
|
18326
18332
|
}
|
|
18327
|
-
const markdown =
|
|
18333
|
+
const markdown = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18328
18334
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18329
18335
|
}
|
|
18330
18336
|
|
|
@@ -18775,11 +18781,11 @@ function processGlobals(records) {
|
|
|
18775
18781
|
const xfFmtIds = [];
|
|
18776
18782
|
const firstBof = records[0];
|
|
18777
18783
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18778
|
-
throw new (0,
|
|
18784
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18779
18785
|
}
|
|
18780
18786
|
const bof = decodeBof(firstBof.data);
|
|
18781
18787
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18782
|
-
throw new (0,
|
|
18788
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18783
18789
|
}
|
|
18784
18790
|
let i = 1;
|
|
18785
18791
|
while (i < records.length) {
|
|
@@ -18914,7 +18920,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18914
18920
|
cellRows.push(row);
|
|
18915
18921
|
}
|
|
18916
18922
|
if (cellRows.length > 0) {
|
|
18917
|
-
const table2 =
|
|
18923
|
+
const table2 = _chunkM4BQRAOMcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18918
18924
|
if (table2.rows > 0) {
|
|
18919
18925
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18920
18926
|
}
|
|
@@ -18927,21 +18933,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18927
18933
|
try {
|
|
18928
18934
|
cfb = parseLenientCfb(buf);
|
|
18929
18935
|
} catch (e) {
|
|
18930
|
-
throw new (0,
|
|
18936
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(
|
|
18931
18937
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18932
18938
|
);
|
|
18933
18939
|
}
|
|
18934
18940
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18935
18941
|
if (!wb) {
|
|
18936
|
-
throw new (0,
|
|
18942
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18937
18943
|
}
|
|
18938
18944
|
const records = readRecords2(wb);
|
|
18939
18945
|
if (records.length === 0) {
|
|
18940
|
-
throw new (0,
|
|
18946
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18941
18947
|
}
|
|
18942
18948
|
const firstBof = decodeBof(records[0].data);
|
|
18943
18949
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18944
|
-
throw new (0,
|
|
18950
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(
|
|
18945
18951
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18946
18952
|
);
|
|
18947
18953
|
}
|
|
@@ -19009,7 +19015,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
19009
19015
|
pageCount: totalSheets
|
|
19010
19016
|
};
|
|
19011
19017
|
return {
|
|
19012
|
-
markdown:
|
|
19018
|
+
markdown: _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
19013
19019
|
blocks: allBlocks,
|
|
19014
19020
|
metadata,
|
|
19015
19021
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19465,7 +19471,7 @@ function getAttr(el, localName2) {
|
|
|
19465
19471
|
return null;
|
|
19466
19472
|
}
|
|
19467
19473
|
function parseXml2(text) {
|
|
19468
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19474
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkLHH7AT6Jcjs.stripDtd.call(void 0, text), "text/xml");
|
|
19469
19475
|
}
|
|
19470
19476
|
function parseStyles(xml) {
|
|
19471
19477
|
const doc = parseXml2(xml);
|
|
@@ -19623,7 +19629,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19623
19629
|
function makeLink(text, rawHref) {
|
|
19624
19630
|
if (!text) return "";
|
|
19625
19631
|
if (!rawHref) return text;
|
|
19626
|
-
const href =
|
|
19632
|
+
const href = _chunkLHH7AT6Jcjs.sanitizeHref.call(void 0, rawHref);
|
|
19627
19633
|
return href ? `[${text}](${href})` : text;
|
|
19628
19634
|
}
|
|
19629
19635
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19817,7 +19823,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19817
19823
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19818
19824
|
})
|
|
19819
19825
|
);
|
|
19820
|
-
const table2 =
|
|
19826
|
+
const table2 = _chunkM4BQRAOMcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19821
19827
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19822
19828
|
return { type: "table", table: table2 };
|
|
19823
19829
|
}
|
|
@@ -19919,12 +19925,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19919
19925
|
}
|
|
19920
19926
|
}
|
|
19921
19927
|
async function parseDocxDocument(buffer, options) {
|
|
19922
|
-
|
|
19928
|
+
_chunkLHH7AT6Jcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19923
19929
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19924
19930
|
const warnings = [];
|
|
19925
19931
|
const docFile = zip.file("word/document.xml");
|
|
19926
19932
|
if (!docFile) {
|
|
19927
|
-
throw new (0,
|
|
19933
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19928
19934
|
}
|
|
19929
19935
|
let rels = /* @__PURE__ */ new Map();
|
|
19930
19936
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19971,7 +19977,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19971
19977
|
const doc = parseXml2(docXml);
|
|
19972
19978
|
const body = findElements(doc, "body");
|
|
19973
19979
|
if (body.length === 0) {
|
|
19974
|
-
throw new (0,
|
|
19980
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19975
19981
|
}
|
|
19976
19982
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19977
19983
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -20022,7 +20028,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
20022
20028
|
}
|
|
20023
20029
|
}
|
|
20024
20030
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
20025
|
-
const markdown =
|
|
20031
|
+
const markdown = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20026
20032
|
return {
|
|
20027
20033
|
markdown,
|
|
20028
20034
|
blocks,
|
|
@@ -20045,7 +20051,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20045
20051
|
}
|
|
20046
20052
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
20047
20053
|
const normalized = text.replace(/ /g, " ");
|
|
20048
|
-
const xml =
|
|
20054
|
+
const xml = _chunkLHH7AT6Jcjs.stripDtd.call(void 0, normalized);
|
|
20049
20055
|
const warnings = [];
|
|
20050
20056
|
const parser = new (0, _xmldom.DOMParser)({
|
|
20051
20057
|
onError: (_level, msg2) => {
|
|
@@ -20085,7 +20091,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20085
20091
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _178 => _178.keepTrailingEmptyCols]), () => ( false)));
|
|
20086
20092
|
}
|
|
20087
20093
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
20088
|
-
const markdown =
|
|
20094
|
+
const markdown = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20089
20095
|
return {
|
|
20090
20096
|
markdown,
|
|
20091
20097
|
blocks,
|
|
@@ -20230,7 +20236,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
|
|
|
20230
20236
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20231
20237
|
cellRows[r].push(cell2);
|
|
20232
20238
|
}
|
|
20233
|
-
const table2 =
|
|
20239
|
+
const table2 = _chunkM4BQRAOMcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20234
20240
|
const caption = extractShapeCaption(el);
|
|
20235
20241
|
if (caption.text && caption.before) {
|
|
20236
20242
|
blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
|
|
@@ -21612,19 +21618,19 @@ function parseCentralDirectory(buf) {
|
|
|
21612
21618
|
}
|
|
21613
21619
|
}
|
|
21614
21620
|
}
|
|
21615
|
-
if (eocdOffset < 0) throw new (0,
|
|
21621
|
+
if (eocdOffset < 0) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21616
21622
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21617
21623
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21618
21624
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21619
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21625
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21620
21626
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21621
|
-
throw new (0,
|
|
21627
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21622
21628
|
}
|
|
21623
21629
|
const decoder = new TextDecoder("utf-8");
|
|
21624
21630
|
const entries = [];
|
|
21625
21631
|
let pos = cdOffset;
|
|
21626
21632
|
for (let i = 0; i < totalEntries; i++) {
|
|
21627
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21633
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21628
21634
|
const flags = view.getUint16(pos + 8, true);
|
|
21629
21635
|
const method = view.getUint16(pos + 10, true);
|
|
21630
21636
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21635,7 +21641,7 @@ function parseCentralDirectory(buf) {
|
|
|
21635
21641
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21636
21642
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21637
21643
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21638
|
-
throw new (0,
|
|
21644
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21639
21645
|
}
|
|
21640
21646
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21641
21647
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21664,11 +21670,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21664
21670
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21665
21671
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21666
21672
|
for (const name of replacements.keys()) {
|
|
21667
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21673
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkLHH7AT6Jcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21668
21674
|
}
|
|
21669
21675
|
if (additions) {
|
|
21670
21676
|
for (const name of additions.keys()) {
|
|
21671
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21677
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkLHH7AT6Jcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21672
21678
|
}
|
|
21673
21679
|
}
|
|
21674
21680
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21687,7 +21693,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21687
21693
|
offset += seg.length;
|
|
21688
21694
|
continue;
|
|
21689
21695
|
}
|
|
21690
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21696
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21691
21697
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21692
21698
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21693
21699
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21695,7 +21701,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21695
21701
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21696
21702
|
const method = e.method;
|
|
21697
21703
|
if (method !== 0 && method !== 8) {
|
|
21698
|
-
throw new (0,
|
|
21704
|
+
throw new (0, _chunkLHH7AT6Jcjs.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`);
|
|
21699
21705
|
}
|
|
21700
21706
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21701
21707
|
const crc = crc32(newData);
|
|
@@ -21796,7 +21802,7 @@ async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
|
21796
21802
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21797
21803
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21798
21804
|
if (sectionPaths.length === 0) {
|
|
21799
|
-
throw new (0,
|
|
21805
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21800
21806
|
}
|
|
21801
21807
|
const warnings = [];
|
|
21802
21808
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -22533,7 +22539,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
22533
22539
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
22534
22540
|
const got = m ? Number(m[1]) : NaN;
|
|
22535
22541
|
if (got !== startId + i) {
|
|
22536
|
-
throw new (0,
|
|
22542
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(
|
|
22537
22543
|
`\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)`
|
|
22538
22544
|
);
|
|
22539
22545
|
}
|
|
@@ -22617,7 +22623,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
22617
22623
|
}
|
|
22618
22624
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
22619
22625
|
if (rows.length !== expectedBase) {
|
|
22620
|
-
throw new (0,
|
|
22626
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(
|
|
22621
22627
|
`\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`
|
|
22622
22628
|
);
|
|
22623
22629
|
}
|
|
@@ -23512,7 +23518,7 @@ function escapeGfm(text) {
|
|
|
23512
23518
|
}
|
|
23513
23519
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
23514
23520
|
function sanitizeText(text) {
|
|
23515
|
-
let result =
|
|
23521
|
+
let result = _chunkM4BQRAOMcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
23516
23522
|
if (result.length <= 30 && result.includes(" ")) {
|
|
23517
23523
|
const tokens = result.split(" ");
|
|
23518
23524
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -23684,7 +23690,7 @@ function parseHtmlTable(raw) {
|
|
|
23684
23690
|
const cs = parseInt(_optionalChain([attrs, 'access', _285 => _285.match, 'call', _286 => _286(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _287 => _287[1]]) || "1", 10);
|
|
23685
23691
|
const rs = parseInt(_optionalChain([attrs, 'access', _288 => _288.match, 'call', _289 => _289(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _290 => _290[1]]) || "1", 10);
|
|
23686
23692
|
cellStart = m.index + m[0].length;
|
|
23687
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
23693
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkM4BQRAOMcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkM4BQRAOMcjs.MAX_ROWS) };
|
|
23688
23694
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
23689
23695
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
23690
23696
|
cellStart = -1;
|
|
@@ -24340,8 +24346,8 @@ function layoutHtmlRows(rows) {
|
|
|
24340
24346
|
let c = 0;
|
|
24341
24347
|
for (const cell2 of rows[r].cells) {
|
|
24342
24348
|
while (occupied.has(`${r},${c}`)) c++;
|
|
24343
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
24344
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
24349
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkM4BQRAOMcjs.MAX_COLS);
|
|
24350
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkM4BQRAOMcjs.MAX_ROWS);
|
|
24345
24351
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
24346
24352
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
24347
24353
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -25938,11 +25944,11 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
25938
25944
|
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>`;
|
|
25939
25945
|
}
|
|
25940
25946
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
25941
|
-
if (ops.length === 0) throw new (0,
|
|
25947
|
+
if (ops.length === 0) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25942
25948
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
25943
25949
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
25944
25950
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _392 => _392.match, 'call', _393 => _393(/(\d+)\.xml$/i), 'optionalAccess', _394 => _394[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _395 => _395.match, 'call', _396 => _396(/(\d+)\.xml$/i), 'optionalAccess', _397 => _397[1]]), () => ( 0))));
|
|
25945
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
25951
|
+
if (sectionPaths.length === 0) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
25946
25952
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
25947
25953
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
25948
25954
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -25983,11 +25989,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
25983
25989
|
const manifestItems = [];
|
|
25984
25990
|
const placed = [];
|
|
25985
25991
|
for (const op of ops) {
|
|
25986
|
-
if (!op.anchor) throw new (0,
|
|
25987
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
25992
|
+
if (!op.anchor) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25993
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
25988
25994
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
25989
|
-
if (!MIME[ext]) throw new (0,
|
|
25990
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
25995
|
+
if (!MIME[ext]) throw new (0, _chunkLHH7AT6Jcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
25996
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkLHH7AT6Jcjs.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)`);
|
|
25991
25997
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
25992
25998
|
let found = null;
|
|
25993
25999
|
let total = 0;
|
|
@@ -26020,7 +26026,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26020
26026
|
}
|
|
26021
26027
|
}
|
|
26022
26028
|
}
|
|
26023
|
-
throw new (0,
|
|
26029
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(
|
|
26024
26030
|
`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)})`
|
|
26025
26031
|
);
|
|
26026
26032
|
}
|
|
@@ -26028,7 +26034,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
26028
26034
|
const xml = sectionXmls[si];
|
|
26029
26035
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
26030
26036
|
if (!run) {
|
|
26031
|
-
throw new (0,
|
|
26037
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
26032
26038
|
}
|
|
26033
26039
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _398 => _398.charPr, 'access', _399 => _399.get, 'call', _400 => _400(run.charPr), 'optionalAccess', _401 => _401.height]), () => ( 1e3));
|
|
26034
26040
|
const fontPt = charPrHeight / 100;
|
|
@@ -26306,7 +26312,7 @@ function pick(map, keys) {
|
|
|
26306
26312
|
return out;
|
|
26307
26313
|
}
|
|
26308
26314
|
async function hwpxToProfile(input) {
|
|
26309
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
26315
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkLHH7AT6Jcjs.toArrayBuffer.call(void 0, input);
|
|
26310
26316
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
26311
26317
|
const parser = createXmlParser();
|
|
26312
26318
|
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _423 => _423.file, 'call', _424 => _424(/[Hh]eader\.xml$/), 'optionalAccess', _425 => _425[0]])));
|
|
@@ -27225,7 +27231,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
27225
27231
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
27226
27232
|
if (paths.length > 0) return paths;
|
|
27227
27233
|
}
|
|
27228
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
27234
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkLHH7AT6Jcjs.compareSectionPaths);
|
|
27229
27235
|
}
|
|
27230
27236
|
function sectionPathsFromManifest(xml) {
|
|
27231
27237
|
const attr = (tag, name) => {
|
|
@@ -27235,7 +27241,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27235
27241
|
const idToHref = /* @__PURE__ */ new Map();
|
|
27236
27242
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
27237
27243
|
const id = attr(m[1], "id");
|
|
27238
|
-
const href =
|
|
27244
|
+
const href = _chunkLHH7AT6Jcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
27239
27245
|
if (id && href) idToHref.set(id, href);
|
|
27240
27246
|
}
|
|
27241
27247
|
const ordered = [];
|
|
@@ -27244,7 +27250,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
27244
27250
|
if (href) ordered.push(href);
|
|
27245
27251
|
}
|
|
27246
27252
|
if (ordered.length > 0) return ordered;
|
|
27247
|
-
return Array.from(idToHref.values()).sort(
|
|
27253
|
+
return Array.from(idToHref.values()).sort(_chunkLHH7AT6Jcjs.compareSectionPaths);
|
|
27248
27254
|
}
|
|
27249
27255
|
|
|
27250
27256
|
// src/roundtrip/patcher.ts
|
|
@@ -27355,9 +27361,9 @@ function buildOrigUnits(blocks) {
|
|
|
27355
27361
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
27356
27362
|
const next = blocks[i + 1];
|
|
27357
27363
|
if (_optionalChain([next, 'optionalAccess', _458 => _458.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
27358
|
-
chunk =
|
|
27364
|
+
chunk = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
27359
27365
|
} else {
|
|
27360
|
-
chunk =
|
|
27366
|
+
chunk = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, [block]);
|
|
27361
27367
|
}
|
|
27362
27368
|
if (chunk) {
|
|
27363
27369
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -28960,12 +28966,12 @@ function blocksToChunks(blocks, options) {
|
|
|
28960
28966
|
let run = null;
|
|
28961
28967
|
const flushRun = () => {
|
|
28962
28968
|
if (!run) return;
|
|
28963
|
-
push("text", run.breadcrumb,
|
|
28969
|
+
push("text", run.breadcrumb, _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
28964
28970
|
run = null;
|
|
28965
28971
|
};
|
|
28966
28972
|
for (let i = 0; i < blocks.length; i++) {
|
|
28967
28973
|
const block = blocks[i];
|
|
28968
|
-
const md2 =
|
|
28974
|
+
const md2 = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28969
28975
|
if (!md2) continue;
|
|
28970
28976
|
if (block.type === "heading") {
|
|
28971
28977
|
flushRun();
|
|
@@ -29435,13 +29441,13 @@ async function htmlToPdf(html, options) {
|
|
|
29435
29441
|
try {
|
|
29436
29442
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
29437
29443
|
} catch (e32) {
|
|
29438
|
-
throw new (0,
|
|
29444
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(
|
|
29439
29445
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
29440
29446
|
);
|
|
29441
29447
|
}
|
|
29442
29448
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
29443
29449
|
if (!executablePath) {
|
|
29444
|
-
throw new (0,
|
|
29450
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)(
|
|
29445
29451
|
"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."
|
|
29446
29452
|
);
|
|
29447
29453
|
}
|
|
@@ -29500,7 +29506,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
29500
29506
|
return htmlToPdf(html, options);
|
|
29501
29507
|
}
|
|
29502
29508
|
async function blocksToPdf(blocks, options) {
|
|
29503
|
-
const markdown =
|
|
29509
|
+
const markdown = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, blocks);
|
|
29504
29510
|
return markdownToPdf(markdown, options);
|
|
29505
29511
|
}
|
|
29506
29512
|
|
|
@@ -30394,15 +30400,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
30394
30400
|
async function renderHwpxToSvg(input, options) {
|
|
30395
30401
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _555 => _555.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
30396
30402
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
30397
|
-
|
|
30403
|
+
_chunkLHH7AT6Jcjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
30398
30404
|
let zip;
|
|
30399
30405
|
try {
|
|
30400
30406
|
zip = await _jszip2.default.loadAsync(input);
|
|
30401
30407
|
} catch (e33) {
|
|
30402
|
-
throw new (0,
|
|
30408
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
30403
30409
|
}
|
|
30404
30410
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
30405
|
-
if (secFiles.length === 0) throw new (0,
|
|
30411
|
+
if (secFiles.length === 0) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
30406
30412
|
const warnings = [];
|
|
30407
30413
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
30408
30414
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -30410,7 +30416,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30410
30416
|
const secXmls = [];
|
|
30411
30417
|
for (const f of secFiles) {
|
|
30412
30418
|
const xml = await f.async("string");
|
|
30413
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
30419
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
30414
30420
|
secXmls.push(xml);
|
|
30415
30421
|
}
|
|
30416
30422
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -30483,9 +30489,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
30483
30489
|
}
|
|
30484
30490
|
if (rendered.length === 0) {
|
|
30485
30491
|
if (noCacheSkipped) {
|
|
30486
|
-
throw new (0,
|
|
30492
|
+
throw new (0, _chunkLHH7AT6Jcjs.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)");
|
|
30487
30493
|
}
|
|
30488
|
-
throw new (0,
|
|
30494
|
+
throw new (0, _chunkLHH7AT6Jcjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
30489
30495
|
}
|
|
30490
30496
|
const GAP = 2400;
|
|
30491
30497
|
const clipDefs = [];
|
|
@@ -30521,13 +30527,13 @@ async function parse(input, options) {
|
|
|
30521
30527
|
if (typeof input === "string") {
|
|
30522
30528
|
try {
|
|
30523
30529
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30524
|
-
buffer =
|
|
30530
|
+
buffer = _chunkLHH7AT6Jcjs.toArrayBuffer.call(void 0, buf);
|
|
30525
30531
|
} catch (err) {
|
|
30526
30532
|
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}`;
|
|
30527
30533
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
30528
30534
|
}
|
|
30529
30535
|
} else if (Buffer.isBuffer(input)) {
|
|
30530
|
-
buffer =
|
|
30536
|
+
buffer = _chunkLHH7AT6Jcjs.toArrayBuffer.call(void 0, input);
|
|
30531
30537
|
} else {
|
|
30532
30538
|
buffer = input;
|
|
30533
30539
|
}
|
|
@@ -30561,18 +30567,18 @@ async function parse(input, options) {
|
|
|
30561
30567
|
}
|
|
30562
30568
|
async function parseImage(buffer, options) {
|
|
30563
30569
|
try {
|
|
30564
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
30570
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-RN77CC5P.cjs")));
|
|
30565
30571
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
30566
30572
|
return {
|
|
30567
30573
|
success: true,
|
|
30568
30574
|
fileType: "image",
|
|
30569
|
-
markdown:
|
|
30575
|
+
markdown: _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, blocks),
|
|
30570
30576
|
blocks,
|
|
30571
30577
|
warnings: warnings.length ? warnings : void 0,
|
|
30572
30578
|
pageCount: 1
|
|
30573
30579
|
};
|
|
30574
30580
|
} catch (err) {
|
|
30575
|
-
return { success: false, fileType: "image", error:
|
|
30581
|
+
return { success: false, fileType: "image", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err) };
|
|
30576
30582
|
}
|
|
30577
30583
|
}
|
|
30578
30584
|
async function parseHwp3(buffer, options) {
|
|
@@ -30580,7 +30586,7 @@ async function parseHwp3(buffer, options) {
|
|
|
30580
30586
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
30581
30587
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
30582
30588
|
} catch (err) {
|
|
30583
|
-
return { success: false, fileType: "hwp3", error:
|
|
30589
|
+
return { success: false, fileType: "hwp3", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err) };
|
|
30584
30590
|
}
|
|
30585
30591
|
}
|
|
30586
30592
|
async function parseHwpx(buffer, options) {
|
|
@@ -30588,7 +30594,7 @@ async function parseHwpx(buffer, options) {
|
|
|
30588
30594
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
30589
30595
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _562 => _562.length]) ? images : void 0 };
|
|
30590
30596
|
} catch (err) {
|
|
30591
|
-
return { success: false, fileType: "hwpx", error:
|
|
30597
|
+
return { success: false, fileType: "hwpx", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err) };
|
|
30592
30598
|
}
|
|
30593
30599
|
}
|
|
30594
30600
|
async function parseHwp(buffer, options) {
|
|
@@ -30613,13 +30619,13 @@ async function parseHwp(buffer, options) {
|
|
|
30613
30619
|
}
|
|
30614
30620
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _564 => _564.length]) ? images : void 0 };
|
|
30615
30621
|
} catch (err) {
|
|
30616
|
-
return { success: false, fileType: "hwp", error:
|
|
30622
|
+
return { success: false, fileType: "hwp", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err) };
|
|
30617
30623
|
}
|
|
30618
30624
|
}
|
|
30619
30625
|
async function parsePdf(buffer, options) {
|
|
30620
30626
|
let parsePdfDocument;
|
|
30621
30627
|
try {
|
|
30622
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
30628
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-5TEQ6EFF.cjs")));
|
|
30623
30629
|
parsePdfDocument = mod.parsePdfDocument;
|
|
30624
30630
|
} catch (e35) {
|
|
30625
30631
|
return {
|
|
@@ -30634,7 +30640,7 @@ async function parsePdf(buffer, options) {
|
|
|
30634
30640
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images };
|
|
30635
30641
|
} catch (err) {
|
|
30636
30642
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
30637
|
-
return { success: false, fileType: "pdf", error:
|
|
30643
|
+
return { success: false, fileType: "pdf", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err), isImageBased };
|
|
30638
30644
|
}
|
|
30639
30645
|
}
|
|
30640
30646
|
async function parseXlsx(buffer, options) {
|
|
@@ -30642,7 +30648,7 @@ async function parseXlsx(buffer, options) {
|
|
|
30642
30648
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
30643
30649
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
30644
30650
|
} catch (err) {
|
|
30645
|
-
return { success: false, fileType: "xlsx", error:
|
|
30651
|
+
return { success: false, fileType: "xlsx", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err) };
|
|
30646
30652
|
}
|
|
30647
30653
|
}
|
|
30648
30654
|
async function parseXls(buffer, options) {
|
|
@@ -30650,7 +30656,7 @@ async function parseXls(buffer, options) {
|
|
|
30650
30656
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
30651
30657
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
30652
30658
|
} catch (err) {
|
|
30653
|
-
return { success: false, fileType: "xls", error:
|
|
30659
|
+
return { success: false, fileType: "xls", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err) };
|
|
30654
30660
|
}
|
|
30655
30661
|
}
|
|
30656
30662
|
async function parseDocx(buffer, options) {
|
|
@@ -30658,7 +30664,7 @@ async function parseDocx(buffer, options) {
|
|
|
30658
30664
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
30659
30665
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _565 => _565.length]) ? images : void 0 };
|
|
30660
30666
|
} catch (err) {
|
|
30661
|
-
return { success: false, fileType: "docx", error:
|
|
30667
|
+
return { success: false, fileType: "docx", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err) };
|
|
30662
30668
|
}
|
|
30663
30669
|
}
|
|
30664
30670
|
async function parseHwpml(buffer, options) {
|
|
@@ -30666,16 +30672,16 @@ async function parseHwpml(buffer, options) {
|
|
|
30666
30672
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
30667
30673
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
30668
30674
|
} catch (err) {
|
|
30669
|
-
return { success: false, fileType: "hwpml", error:
|
|
30675
|
+
return { success: false, fileType: "hwpml", error: _chunkLHH7AT6Jcjs.sanitizeError.call(void 0, err), code: _chunkLHH7AT6Jcjs.classifyError.call(void 0, err) };
|
|
30670
30676
|
}
|
|
30671
30677
|
}
|
|
30672
30678
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
30673
30679
|
let buffer;
|
|
30674
30680
|
if (typeof input === "string") {
|
|
30675
30681
|
const buf = await _promises.readFile.call(void 0, input);
|
|
30676
|
-
buffer =
|
|
30682
|
+
buffer = _chunkLHH7AT6Jcjs.toArrayBuffer.call(void 0, buf);
|
|
30677
30683
|
} else if (Buffer.isBuffer(input)) {
|
|
30678
|
-
buffer =
|
|
30684
|
+
buffer = _chunkLHH7AT6Jcjs.toArrayBuffer.call(void 0, input);
|
|
30679
30685
|
} else {
|
|
30680
30686
|
buffer = input;
|
|
30681
30687
|
}
|
|
@@ -30701,7 +30707,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30701
30707
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
30702
30708
|
}
|
|
30703
30709
|
const fill = fillFormFields(parsed.blocks, values);
|
|
30704
|
-
const markdown =
|
|
30710
|
+
const markdown = _chunkM4BQRAOMcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
30705
30711
|
if (outputFormat === "hwpx") {
|
|
30706
30712
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
30707
30713
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -30775,5 +30781,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
30775
30781
|
|
|
30776
30782
|
|
|
30777
30783
|
|
|
30778
|
-
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 =
|
|
30784
|
+
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 = _chunkLHH7AT6Jcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkM4BQRAOMcjs.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;
|
|
30779
30785
|
//# sourceMappingURL=index.cjs.map
|