kordoc 4.9.2 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/{-Z4LCTGQR.js → -LFHXUYGZ.js} +9 -9
- package/dist/{chunk-PIUPP3FL.js → chunk-3P6XONHY.js} +3 -3
- package/dist/{chunk-NOEYLJGJ.js → chunk-476CF3WL.js} +3 -3
- package/dist/{chunk-LREEDIEF.js → chunk-4F4PZQTW.js} +2 -2
- package/dist/{chunk-VYGNPB2X.js → chunk-7XDCXPWC.js} +52 -8
- package/dist/chunk-7XDCXPWC.js.map +1 -0
- package/dist/{chunk-NIBRVLGS.js → chunk-B6IA745V.js} +3 -3
- package/dist/{chunk-5ZPXRDS2.js → chunk-CF2FQBVN.js} +2 -2
- package/dist/{chunk-5ZPXRDS2.js.map → chunk-CF2FQBVN.js.map} +1 -1
- package/dist/chunk-DCZVOIEO.cjs.map +1 -1
- package/dist/{chunk-BAJVZXC7.cjs → chunk-FN6NBZ34.cjs} +3 -3
- package/dist/chunk-FN6NBZ34.cjs.map +1 -0
- package/dist/{chunk-LUY46O7O.js → chunk-FNNOBF36.js} +52 -8
- package/dist/chunk-FNNOBF36.js.map +1 -0
- package/dist/{chunk-V3Q6I2AQ.cjs → chunk-FQTPFGVG.cjs} +54 -10
- package/dist/chunk-FQTPFGVG.cjs.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-Y7QB4IB6.js → chunk-HXR7TSXU.js} +2 -2
- package/dist/{chunk-KATZTHWA.cjs → chunk-JO3W54E5.cjs} +2 -2
- package/dist/chunk-JO3W54E5.cjs.map +1 -0
- package/dist/{chunk-OYQL3D4B.js → chunk-LM5A4DOY.js} +2 -2
- package/dist/{chunk-JHPEDWJX.js → chunk-LXMQUWGU.js} +3 -3
- package/dist/{chunk-TK7WUS47.js → chunk-LYTFBD6P.js} +2 -2
- package/dist/{chunk-XINP35F4.js → chunk-N3DLQ2YH.js} +1 -1
- package/dist/{chunk-XINP35F4.js.map → chunk-N3DLQ2YH.js.map} +1 -1
- package/dist/{chunk-BN33O25L.js → chunk-ONQHGZTS.js} +1 -1
- package/dist/{chunk-BN33O25L.js.map → chunk-ONQHGZTS.js.map} +1 -1
- package/dist/{chunk-SHBVD23C.cjs → chunk-RSATURJN.cjs} +11 -11
- package/dist/chunk-RSATURJN.cjs.map +1 -0
- package/dist/{chunk-LKZQ4564.js → chunk-SD3ITJLU.js} +2 -2
- package/dist/{chunk-L5CDTOC3.cjs → chunk-T7GRHAIW.cjs} +1 -1
- package/dist/chunk-T7GRHAIW.cjs.map +1 -0
- package/dist/{chunk-WLZX2HTC.js → chunk-V2TMM6OD.js} +3 -3
- package/dist/{chunk-6WYMV73J.js → chunk-W4DVZN5M.js} +229 -19
- package/dist/chunk-W4DVZN5M.js.map +1 -0
- package/dist/{chunk-LJP3PK2S.js → chunk-W6537QWB.js} +2 -2
- package/dist/{chunk-GL6BCNJV.js → chunk-X25PKMMD.js} +3 -3
- package/dist/{chunk-NIQ4JCQF.cjs → chunk-YBTTQQBH.cjs} +6 -6
- package/dist/chunk-YBTTQQBH.cjs.map +1 -0
- package/dist/{chunk-PKCDYIIJ.js → chunk-Z37BVIRF.js} +2 -2
- package/dist/{chunk-OOT54JF2.js → chunk-Z6NFU6DA.js} +2 -2
- package/dist/{chunk-OOT54JF2.js.map → chunk-Z6NFU6DA.js.map} +1 -1
- package/dist/chunks-Y32RX6IF.js +10 -0
- package/dist/cli.js +37 -33
- package/dist/cli.js.map +1 -1
- package/dist/{formula-LFWZG7T7.js → formula-2ORTZGRU.js} +4 -4
- package/dist/{formula-JVBJ6QRG.cjs → formula-KFSWOSCF.cjs} +9 -9
- package/dist/formula-KFSWOSCF.cjs.map +1 -0
- package/dist/{formula-77TJPACH.js → formula-YCFGCLUF.js} +3 -3
- package/dist/{image-ocr-6SY623KL.js → image-ocr-2B7NVDRS.js} +8 -8
- package/dist/{image-ocr-YZ56O63S.js → image-ocr-JCKC4QWU.js} +6 -6
- package/dist/{image-ocr-YTGAUHEP.cjs → image-ocr-ZV4AP2I6.cjs} +12 -12
- package/dist/image-ocr-ZV4AP2I6.cjs.map +1 -0
- package/dist/index.cjs +411 -202
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +224 -15
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +16 -16
- package/dist/{model-bundle-W7B3BIYS.js → model-bundle-EX75CSEI.js} +5 -5
- package/dist/{models-FUKPEVPE.js → models-KJCNM77P.js} +5 -5
- package/dist/page-range-P7SDW6LR.cjs.map +1 -1
- package/dist/{parser-6UL2HLDH.js → parser-2KFORGOT.js} +7 -7
- package/dist/{parser-GDYZDBZI.js → parser-TXBQATM7.js} +7 -7
- package/dist/{parser-WIRWVN5E.cjs → parser-WY5PY5V4.cjs} +27 -27
- package/dist/parser-WY5PY5V4.cjs.map +1 -0
- package/dist/pdf-ocr-GD6KYSH7.js +16 -0
- package/dist/pdf-ocr-JXYOCUGR.cjs +14 -0
- package/dist/pdf-ocr-JXYOCUGR.cjs.map +1 -0
- package/dist/pdf-ocr-MNCYWT4Z.js +13 -0
- package/dist/{profile-io-4EE64K6Y.js → profile-io-Z5NKKNGW.js} +3 -3
- package/dist/{rasterize-QW7SSKHB.js → rasterize-66QIXE2S.js} +2 -2
- package/dist/render-ILBFLY3A.js +10 -0
- package/dist/seal-AKUPO4YT.js +10 -0
- package/dist/{setup-JS7E2HFM.js → setup-L2LYDZ6N.js} +3 -3
- package/dist/{watch-YISVPGW3.js → watch-HJAEDIKZ.js} +10 -10
- package/package.json +1 -1
- package/dist/chunk-6WYMV73J.js.map +0 -1
- package/dist/chunk-BAJVZXC7.cjs.map +0 -1
- package/dist/chunk-KATZTHWA.cjs.map +0 -1
- package/dist/chunk-L5CDTOC3.cjs.map +0 -1
- package/dist/chunk-LUY46O7O.js.map +0 -1
- package/dist/chunk-NIQ4JCQF.cjs.map +0 -1
- package/dist/chunk-SHBVD23C.cjs.map +0 -1
- package/dist/chunk-V3Q6I2AQ.cjs.map +0 -1
- package/dist/chunk-VYGNPB2X.js.map +0 -1
- package/dist/chunks-TRJGNO4N.js +0 -10
- package/dist/formula-JVBJ6QRG.cjs.map +0 -1
- package/dist/image-ocr-YTGAUHEP.cjs.map +0 -1
- package/dist/parser-WIRWVN5E.cjs.map +0 -1
- package/dist/pdf-ocr-O373AAN6.cjs +0 -14
- package/dist/pdf-ocr-O373AAN6.cjs.map +0 -1
- package/dist/pdf-ocr-OHUAQQMN.js +0 -16
- package/dist/pdf-ocr-XTE234WC.js +0 -13
- package/dist/render-2NID54BX.js +0 -10
- package/dist/seal-PTP4TWYR.js +0 -10
- /package/dist/{-Z4LCTGQR.js.map → -LFHXUYGZ.js.map} +0 -0
- /package/dist/{chunk-PIUPP3FL.js.map → chunk-3P6XONHY.js.map} +0 -0
- /package/dist/{chunk-NOEYLJGJ.js.map → chunk-476CF3WL.js.map} +0 -0
- /package/dist/{chunk-LREEDIEF.js.map → chunk-4F4PZQTW.js.map} +0 -0
- /package/dist/{chunk-NIBRVLGS.js.map → chunk-B6IA745V.js.map} +0 -0
- /package/dist/{chunk-Y7QB4IB6.js.map → chunk-HXR7TSXU.js.map} +0 -0
- /package/dist/{chunk-OYQL3D4B.js.map → chunk-LM5A4DOY.js.map} +0 -0
- /package/dist/{chunk-JHPEDWJX.js.map → chunk-LXMQUWGU.js.map} +0 -0
- /package/dist/{chunk-TK7WUS47.js.map → chunk-LYTFBD6P.js.map} +0 -0
- /package/dist/{chunk-LKZQ4564.js.map → chunk-SD3ITJLU.js.map} +0 -0
- /package/dist/{chunk-WLZX2HTC.js.map → chunk-V2TMM6OD.js.map} +0 -0
- /package/dist/{chunk-LJP3PK2S.js.map → chunk-W6537QWB.js.map} +0 -0
- /package/dist/{chunk-GL6BCNJV.js.map → chunk-X25PKMMD.js.map} +0 -0
- /package/dist/{chunk-PKCDYIIJ.js.map → chunk-Z37BVIRF.js.map} +0 -0
- /package/dist/{chunks-TRJGNO4N.js.map → chunks-Y32RX6IF.js.map} +0 -0
- /package/dist/{formula-LFWZG7T7.js.map → formula-2ORTZGRU.js.map} +0 -0
- /package/dist/{formula-77TJPACH.js.map → formula-YCFGCLUF.js.map} +0 -0
- /package/dist/{image-ocr-6SY623KL.js.map → image-ocr-2B7NVDRS.js.map} +0 -0
- /package/dist/{image-ocr-YZ56O63S.js.map → image-ocr-JCKC4QWU.js.map} +0 -0
- /package/dist/{model-bundle-W7B3BIYS.js.map → model-bundle-EX75CSEI.js.map} +0 -0
- /package/dist/{models-FUKPEVPE.js.map → models-KJCNM77P.js.map} +0 -0
- /package/dist/{parser-6UL2HLDH.js.map → parser-2KFORGOT.js.map} +0 -0
- /package/dist/{parser-GDYZDBZI.js.map → parser-TXBQATM7.js.map} +0 -0
- /package/dist/{pdf-ocr-OHUAQQMN.js.map → pdf-ocr-GD6KYSH7.js.map} +0 -0
- /package/dist/{pdf-ocr-XTE234WC.js.map → pdf-ocr-MNCYWT4Z.js.map} +0 -0
- /package/dist/{profile-io-4EE64K6Y.js.map → profile-io-Z5NKKNGW.js.map} +0 -0
- /package/dist/{rasterize-QW7SSKHB.js.map → rasterize-66QIXE2S.js.map} +0 -0
- /package/dist/{render-2NID54BX.js.map → render-ILBFLY3A.js.map} +0 -0
- /package/dist/{seal-PTP4TWYR.js.map → seal-AKUPO4YT.js.map} +0 -0
- /package/dist/{setup-JS7E2HFM.js.map → setup-L2LYDZ6N.js.map} +0 -0
- /package/dist/{watch-YISVPGW3.js.map → watch-HJAEDIKZ.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkFQTPFGVGcjs = require('./chunk-FQTPFGVG.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
@@ -16,7 +16,7 @@ var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkT7GRHAIWcjs = require('./chunk-T7GRHAIW.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -29,7 +29,7 @@ var _chunkL5CDTOC3cjs = require('./chunk-L5CDTOC3.cjs');
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunkJO3W54E5cjs = require('./chunk-JO3W54E5.cjs');
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -484,7 +484,7 @@ function rawTextContent(node, depth = 0) {
|
|
|
484
484
|
// src/hwpx/parser-shared.ts
|
|
485
485
|
var MAX_DECOMPRESS_SIZE = 256 * 1024 * 1024;
|
|
486
486
|
var MAX_ZIP_ENTRIES = 500;
|
|
487
|
-
var ZipBombError = class extends
|
|
487
|
+
var ZipBombError = class extends _chunkJO3W54E5cjs.KordocError {
|
|
488
488
|
constructor(message) {
|
|
489
489
|
super(message);
|
|
490
490
|
this.name = "ZipBombError";
|
|
@@ -504,7 +504,7 @@ function createSectionShared() {
|
|
|
504
504
|
function createXmlParser(warnings) {
|
|
505
505
|
return new (0, _xmldom.DOMParser)({
|
|
506
506
|
onError(level, msg2) {
|
|
507
|
-
if (level === "fatalError") throw new (0,
|
|
507
|
+
if (level === "fatalError") throw new (0, _chunkJO3W54E5cjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
508
508
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warning" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
509
509
|
}
|
|
510
510
|
});
|
|
@@ -539,13 +539,13 @@ function parseEncryptionManifest(manifestXml) {
|
|
|
539
539
|
const startKey = attrOf(inner, "start-key-generation-name");
|
|
540
540
|
const checksumType = attrOf(inner, "checksum-type");
|
|
541
541
|
if (algorithm !== AES256_CBC) {
|
|
542
|
-
throw new (0,
|
|
542
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uC554\uD638\uD654 \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(algorithm, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
543
543
|
}
|
|
544
544
|
if (startKey !== START_KEY_SHA256) {
|
|
545
|
-
throw new (0,
|
|
545
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uC2DC\uC791\uD0A4 \uC0DD\uC131 \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(startKey, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
546
546
|
}
|
|
547
547
|
if (!_optionalChain([checksumType, 'optionalAccess', _8 => _8.endsWith, 'call', _9 => _9(CHECKSUM_SHA256_1K)])) {
|
|
548
|
-
throw new (0,
|
|
548
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWPX \uCCB4\uD06C\uC12C \uBC29\uC2DD\uC785\uB2C8\uB2E4: ${_nullishCoalesce(checksumType, () => ( "(\uBBF8\uC0C1)"))}`);
|
|
549
549
|
}
|
|
550
550
|
const iterations = parseInt(_nullishCoalesce(attrOf(inner, "iteration-count"), () => ( "")), 10);
|
|
551
551
|
const keySize = parseInt(_nullishCoalesce(attrOf(inner, "key-size"), () => ( "")), 10);
|
|
@@ -553,10 +553,10 @@ function parseEncryptionManifest(manifestXml) {
|
|
|
553
553
|
const salt = Buffer.from(_nullishCoalesce(attrOf(inner, "salt"), () => ( "")), "base64");
|
|
554
554
|
const checksum = Buffer.from(_nullishCoalesce(attrOf(inner, "checksum"), () => ( "")), "base64");
|
|
555
555
|
if (!(iterations > 0 && iterations <= MAX_ITERATION_COUNT)) {
|
|
556
|
-
throw new (0,
|
|
556
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`HWPX \uC554\uD638\uD654 \uBC18\uBCF5 \uD69F\uC218\uAC00 \uD5C8\uC6A9 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0AC\uC2B5\uB2C8\uB2E4: ${iterations}`);
|
|
557
557
|
}
|
|
558
558
|
if (keySize !== 32 || iv.length !== 16 || salt.length === 0 || checksum.length !== 32) {
|
|
559
|
-
throw new (0,
|
|
559
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`HWPX \uC554\uD638\uD654 \uD30C\uB77C\uBBF8\uD130\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4 (${path})`);
|
|
560
560
|
}
|
|
561
561
|
entries.push({ path, checksum, iv, salt, iterations, keySize });
|
|
562
562
|
}
|
|
@@ -589,11 +589,11 @@ async function decryptHwpxInPlace(zip, manifestXml, password) {
|
|
|
589
589
|
for (const entry of entries) {
|
|
590
590
|
const file = zip.file(entry.path);
|
|
591
591
|
if (!file) {
|
|
592
|
-
throw new (0,
|
|
592
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`\uC554\uD638 \uBAA9\uB85D\uC5D0 \uC788\uB294 \uD30C\uC77C\uC774 \uBB38\uC11C\uC5D0 \uC5C6\uC2B5\uB2C8\uB2E4: ${entry.path}`);
|
|
593
593
|
}
|
|
594
594
|
const plain2 = decryptEntry(await file.async("nodebuffer"), entry, startKey);
|
|
595
595
|
if (!plain2) {
|
|
596
|
-
throw new (0,
|
|
596
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
597
597
|
}
|
|
598
598
|
decrypted.push({ path: entry.path, plain: plain2 });
|
|
599
599
|
}
|
|
@@ -641,10 +641,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
641
641
|
const xml = await file.async("text");
|
|
642
642
|
if (decompressed) {
|
|
643
643
|
decompressed.total += xml.length * 2;
|
|
644
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
644
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
645
645
|
}
|
|
646
646
|
const parser = createXmlParser();
|
|
647
|
-
const doc = parser.parseFromString(
|
|
647
|
+
const doc = parser.parseFromString(_chunkJO3W54E5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
648
648
|
if (!doc.documentElement) continue;
|
|
649
649
|
const domDoc = doc;
|
|
650
650
|
parseCharProperties(domDoc, result.charProperties);
|
|
@@ -833,9 +833,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
833
833
|
let level = 0;
|
|
834
834
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _16 => _16.style, 'optionalAccess', _17 => _17.fontSize])) {
|
|
835
835
|
const ratio = block.style.fontSize / baseFontSize;
|
|
836
|
-
if (ratio >=
|
|
837
|
-
else if (ratio >=
|
|
838
|
-
else if (ratio >=
|
|
836
|
+
if (ratio >= _chunkT7GRHAIWcjs.HEADING_RATIO_H1) level = 1;
|
|
837
|
+
else if (ratio >= _chunkT7GRHAIWcjs.HEADING_RATIO_H2) level = 2;
|
|
838
|
+
else if (ratio >= _chunkT7GRHAIWcjs.HEADING_RATIO_H3) level = 3;
|
|
839
839
|
}
|
|
840
840
|
const compactText = text.replace(/\s+/g, "");
|
|
841
841
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1428,7 +1428,7 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1428
1428
|
|
|
1429
1429
|
// src/hwpx/table-build.ts
|
|
1430
1430
|
function buildTableWithCellMeta(state, keepAnchoredEmptyCols, keepEmptyParagraphs) {
|
|
1431
|
-
const table2 =
|
|
1431
|
+
const table2 = _chunkFQTPFGVGcjs.buildTable.call(void 0, state.rows, { keepAnchoredEmptyCols, keepEmptyParagraphs });
|
|
1432
1432
|
if (state.caption) table2.caption = state.caption;
|
|
1433
1433
|
if (_optionalChain([state, 'access', _21 => _21.captionBlocks, 'optionalAccess', _22 => _22.length])) table2.captionBlocks = state.captionBlocks;
|
|
1434
1434
|
const anchors = [];
|
|
@@ -1499,7 +1499,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1499
1499
|
const cell2 = parentTable.cell;
|
|
1500
1500
|
(cell2.blocks ??= []).push(block);
|
|
1501
1501
|
cell2.hasStructure = true;
|
|
1502
|
-
let flat =
|
|
1502
|
+
let flat = _chunkFQTPFGVGcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1503
1503
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1504
1504
|
if (flat) {
|
|
1505
1505
|
const inlineJoin = newTable.inline === true && cell2.lineOpen === true;
|
|
@@ -1642,7 +1642,7 @@ function detectHwpxSectionPages(root) {
|
|
|
1642
1642
|
// src/hwpx/section-walker.ts
|
|
1643
1643
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1644
1644
|
const parser = createXmlParser(warnings);
|
|
1645
|
-
const doc = parser.parseFromString(
|
|
1645
|
+
const doc = parser.parseFromString(_chunkJO3W54E5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1646
1646
|
if (!doc.documentElement) return [];
|
|
1647
1647
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1648
1648
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1756,8 +1756,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1756
1756
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1757
1757
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1758
1758
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1759
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1760
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1759
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkFQTPFGVGcjs.MAX_COLS);
|
|
1760
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkFQTPFGVGcjs.MAX_ROWS);
|
|
1761
1761
|
}
|
|
1762
1762
|
break;
|
|
1763
1763
|
case "p": {
|
|
@@ -2030,7 +2030,7 @@ function buildSubListTable(el, ctx, depth) {
|
|
|
2030
2030
|
const sink = [];
|
|
2031
2031
|
const st = { rows: [], currentRow: [], cell: null };
|
|
2032
2032
|
walkSection(el, sink, st, [], ctx, depth + 1);
|
|
2033
|
-
let flat =
|
|
2033
|
+
let flat = _chunkFQTPFGVGcjs.convertTableToText.call(void 0, st.rows);
|
|
2034
2034
|
if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
|
|
2035
2035
|
const built = [];
|
|
2036
2036
|
completeTable(st, [], built, ctx);
|
|
@@ -2185,7 +2185,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
2185
2185
|
let url = (ch.textContent || "").trim();
|
|
2186
2186
|
if (!url) continue;
|
|
2187
2187
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
2188
|
-
const safe =
|
|
2188
|
+
const safe = _chunkJO3W54E5cjs.sanitizeHref.call(void 0, url);
|
|
2189
2189
|
if (safe) return safe;
|
|
2190
2190
|
}
|
|
2191
2191
|
return void 0;
|
|
@@ -2345,7 +2345,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2345
2345
|
case "hyperlink": {
|
|
2346
2346
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
2347
2347
|
if (url) {
|
|
2348
|
-
const safe =
|
|
2348
|
+
const safe = _chunkJO3W54E5cjs.sanitizeHref.call(void 0, url);
|
|
2349
2349
|
if (safe) href = safe;
|
|
2350
2350
|
}
|
|
2351
2351
|
walk(child, depth + 1);
|
|
@@ -2628,7 +2628,7 @@ function decompressStream(data) {
|
|
|
2628
2628
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2629
2629
|
}
|
|
2630
2630
|
function parseFileHeader(data) {
|
|
2631
|
-
if (data.length < 40) throw new (0,
|
|
2631
|
+
if (data.length < 40) throw new (0, _chunkJO3W54E5cjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2632
2632
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2633
2633
|
return {
|
|
2634
2634
|
signature: sig,
|
|
@@ -2930,7 +2930,7 @@ function resolveImageBlocks(binDataMap, blocks, warnings, sweepUnreferenced) {
|
|
|
2930
2930
|
const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
|
|
2931
2931
|
img = { filename: `image_${String(imageIndex).padStart(3, "0")}.${ext}`, data: new Uint8Array(bin.data), mime };
|
|
2932
2932
|
resolved.set(storageId, img);
|
|
2933
|
-
images.push({ filename: img.filename, data: img.data, mimeType: img.mime });
|
|
2933
|
+
images.push({ filename: img.filename, data: img.data, mimeType: img.mime, source: bin.name });
|
|
2934
2934
|
renamed.set(storageId, img.filename);
|
|
2935
2935
|
}
|
|
2936
2936
|
}
|
|
@@ -2954,7 +2954,7 @@ function resolveImageBlocks(binDataMap, blocks, warnings, sweepUnreferenced) {
|
|
|
2954
2954
|
const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
|
|
2955
2955
|
const filename = `image_${String(imageIndex).padStart(3, "0")}.${ext}`;
|
|
2956
2956
|
const data = new Uint8Array(bin.data);
|
|
2957
|
-
images.push({ filename, data, mimeType: mime });
|
|
2957
|
+
images.push({ filename, data, mimeType: mime, source: bin.name });
|
|
2958
2958
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType: mime, filename: bin.name } });
|
|
2959
2959
|
}
|
|
2960
2960
|
}
|
|
@@ -3080,23 +3080,23 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3080
3080
|
}
|
|
3081
3081
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
3082
3082
|
for (const path of allCandidates) {
|
|
3083
|
-
if (
|
|
3083
|
+
if (_chunkJO3W54E5cjs.isPathTraversal.call(void 0, path)) continue;
|
|
3084
3084
|
const file = zip.file(path);
|
|
3085
3085
|
if (!file) continue;
|
|
3086
3086
|
try {
|
|
3087
3087
|
const data = await file.async("uint8array");
|
|
3088
3088
|
decompressed.total += data.length;
|
|
3089
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3089
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3090
3090
|
const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
|
|
3091
3091
|
const mimeType = imageExtToMime(ext);
|
|
3092
3092
|
imageIndex++;
|
|
3093
3093
|
const filename2 = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
|
|
3094
|
-
img = { filename: filename2, data, mimeType };
|
|
3094
|
+
img = { filename: filename2, data, mimeType, source: path };
|
|
3095
3095
|
images.push(img);
|
|
3096
3096
|
usedPaths.add(path);
|
|
3097
3097
|
break;
|
|
3098
3098
|
} catch (err) {
|
|
3099
|
-
if (err instanceof
|
|
3099
|
+
if (err instanceof _chunkJO3W54E5cjs.KordocError) throw err;
|
|
3100
3100
|
}
|
|
3101
3101
|
}
|
|
3102
3102
|
if (!img) _optionalChain([warnings, 'optionalAccess', _84 => _84.push, 'call', _85 => _85({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
|
|
@@ -3116,11 +3116,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3116
3116
|
if (sweepUnreferenced) {
|
|
3117
3117
|
const binEntries = zip.file(/(?:^|\/)BinData\//i);
|
|
3118
3118
|
for (const file of binEntries) {
|
|
3119
|
-
if (file.dir || usedPaths.has(file.name) ||
|
|
3119
|
+
if (file.dir || usedPaths.has(file.name) || _chunkJO3W54E5cjs.isPathTraversal.call(void 0, file.name)) continue;
|
|
3120
3120
|
try {
|
|
3121
3121
|
const data = await file.async("uint8array");
|
|
3122
3122
|
decompressed.total += data.length;
|
|
3123
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3123
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3124
3124
|
const ext = file.name.includes(".") ? file.name.split(".").pop() || "" : "";
|
|
3125
3125
|
let mimeType = imageExtToMime(ext);
|
|
3126
3126
|
if (mimeType === "application/octet-stream") {
|
|
@@ -3130,11 +3130,11 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings, sweepUn
|
|
|
3130
3130
|
}
|
|
3131
3131
|
imageIndex++;
|
|
3132
3132
|
const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
|
|
3133
|
-
const img = { filename, data, mimeType };
|
|
3133
|
+
const img = { filename, data, mimeType, source: file.name };
|
|
3134
3134
|
images.push(img);
|
|
3135
3135
|
blocks.push({ type: "image", text: filename, imageData: { data, mimeType, filename: file.name } });
|
|
3136
3136
|
} catch (err) {
|
|
3137
|
-
if (err instanceof
|
|
3137
|
+
if (err instanceof _chunkJO3W54E5cjs.KordocError) throw err;
|
|
3138
3138
|
_optionalChain([warnings, 'optionalAccess', _86 => _86.push, 'call', _87 => _87({ message: `\uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328: ${file.name}`, code: "SKIPPED_IMAGE" })]);
|
|
3139
3139
|
}
|
|
3140
3140
|
}
|
|
@@ -3185,7 +3185,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3185
3185
|
}
|
|
3186
3186
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
3187
3187
|
const name = new TextDecoder().decode(nameBytes);
|
|
3188
|
-
if (
|
|
3188
|
+
if (_chunkJO3W54E5cjs.isPathTraversal.call(void 0, name)) {
|
|
3189
3189
|
pos = fileStart + compSize;
|
|
3190
3190
|
continue;
|
|
3191
3191
|
}
|
|
@@ -3203,7 +3203,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
3203
3203
|
continue;
|
|
3204
3204
|
}
|
|
3205
3205
|
totalDecompressed += content.length * 2;
|
|
3206
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3206
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkJO3W54E5cjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
3207
3207
|
sectionNum++;
|
|
3208
3208
|
const secBlocks = parseSectionXml(content, void 0, warnings, sectionNum, shared);
|
|
3209
3209
|
for (const b of secBlocks) b.pageNumber = sectionNum;
|
|
@@ -3212,9 +3212,9 @@ function extractFromBrokenZip(buffer) {
|
|
|
3212
3212
|
continue;
|
|
3213
3213
|
}
|
|
3214
3214
|
}
|
|
3215
|
-
if (blocks.length === 0) throw new (0,
|
|
3215
|
+
if (blocks.length === 0) throw new (0, _chunkJO3W54E5cjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3216
3216
|
applyPageText(blocks, shared);
|
|
3217
|
-
const markdown =
|
|
3217
|
+
const markdown = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3218
3218
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
3219
3219
|
}
|
|
3220
3220
|
async function readKordocLayout(zip) {
|
|
@@ -3239,18 +3239,18 @@ async function resolveSectionPaths(zip) {
|
|
|
3239
3239
|
if (paths.length > 0) return paths;
|
|
3240
3240
|
}
|
|
3241
3241
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
3242
|
-
return sectionFiles.map((f) => f.name).sort(
|
|
3242
|
+
return sectionFiles.map((f) => f.name).sort(_chunkJO3W54E5cjs.compareSectionPaths);
|
|
3243
3243
|
}
|
|
3244
3244
|
function parseSectionPathsFromManifest(xml) {
|
|
3245
3245
|
const parser = createXmlParser();
|
|
3246
|
-
const doc = parser.parseFromString(
|
|
3246
|
+
const doc = parser.parseFromString(_chunkJO3W54E5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3247
3247
|
const items = doc.getElementsByTagName("opf:item");
|
|
3248
3248
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
3249
3249
|
const idToHref = /* @__PURE__ */ new Map();
|
|
3250
3250
|
for (let i = 0; i < items.length; i++) {
|
|
3251
3251
|
const item = items[i];
|
|
3252
3252
|
const id = item.getAttribute("id") || "";
|
|
3253
|
-
const href =
|
|
3253
|
+
const href = _chunkJO3W54E5cjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
3254
3254
|
if (id && href) idToHref.set(id, href);
|
|
3255
3255
|
}
|
|
3256
3256
|
if (spine.length > 0) {
|
|
@@ -3261,7 +3261,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
3261
3261
|
}
|
|
3262
3262
|
if (ordered.length > 0) return ordered;
|
|
3263
3263
|
}
|
|
3264
|
-
return Array.from(idToHref.values()).sort(
|
|
3264
|
+
return Array.from(idToHref.values()).sort(_chunkJO3W54E5cjs.compareSectionPaths);
|
|
3265
3265
|
}
|
|
3266
3266
|
|
|
3267
3267
|
// src/hwpx/metadata.ts
|
|
@@ -3274,7 +3274,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3274
3274
|
const xml = await file.async("text");
|
|
3275
3275
|
if (decompressed) {
|
|
3276
3276
|
decompressed.total += xml.length * 2;
|
|
3277
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
3277
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3278
3278
|
}
|
|
3279
3279
|
parseDublinCoreMetadata(xml, metadata);
|
|
3280
3280
|
if (metadata.title || metadata.author) return;
|
|
@@ -3284,7 +3284,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
3284
3284
|
}
|
|
3285
3285
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
3286
3286
|
const parser = createXmlParser();
|
|
3287
|
-
const doc = parser.parseFromString(
|
|
3287
|
+
const doc = parser.parseFromString(_chunkJO3W54E5cjs.stripDtd.call(void 0, xml), "text/xml");
|
|
3288
3288
|
if (!doc.documentElement) return;
|
|
3289
3289
|
const getText = (tagNames) => {
|
|
3290
3290
|
for (const tag of tagNames) {
|
|
@@ -3309,7 +3309,7 @@ function parseDublinCoreMetadata(xml, metadata) {
|
|
|
3309
3309
|
|
|
3310
3310
|
// src/hwpx/parser.ts
|
|
3311
3311
|
async function parseHwpxDocument(buffer, options) {
|
|
3312
|
-
|
|
3312
|
+
_chunkJO3W54E5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
3313
3313
|
let zip;
|
|
3314
3314
|
try {
|
|
3315
3315
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
@@ -3318,7 +3318,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3318
3318
|
}
|
|
3319
3319
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
3320
3320
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
3321
|
-
throw new (0,
|
|
3321
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
3322
3322
|
}
|
|
3323
3323
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
3324
3324
|
if (manifestFile) {
|
|
@@ -3333,7 +3333,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3333
3333
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
3334
3334
|
}
|
|
3335
3335
|
}
|
|
3336
|
-
throw new (0,
|
|
3336
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
3337
3337
|
"\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694."
|
|
3338
3338
|
);
|
|
3339
3339
|
}
|
|
@@ -3345,7 +3345,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3345
3345
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
3346
3346
|
const warnings = [];
|
|
3347
3347
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
3348
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
3348
|
+
if (sectionPaths.length === 0) throw new (0, _chunkJO3W54E5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3349
3349
|
let allBlocks = [];
|
|
3350
3350
|
const shared = createSectionShared();
|
|
3351
3351
|
shared.kordocLayout = await readKordocLayout(zip);
|
|
@@ -3390,7 +3390,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3390
3390
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !_optionalChain([options, 'optionalAccess', _102 => _102.pages]));
|
|
3391
3391
|
detectHwpxHeadings(blocks, styleMap);
|
|
3392
3392
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3393
|
-
const markdown =
|
|
3393
|
+
const markdown = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, blocks);
|
|
3394
3394
|
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 };
|
|
3395
3395
|
}
|
|
3396
3396
|
|
|
@@ -4390,7 +4390,7 @@ function decryptPasswordStream(raw, password) {
|
|
|
4390
4390
|
var TAG_DOCUMENT_PROPERTIES = 16;
|
|
4391
4391
|
var TAG_ID_MAPPINGS = 17;
|
|
4392
4392
|
function assertDecryptedDocInfo(data, readRecords3) {
|
|
4393
|
-
const wrong = () => new (0,
|
|
4393
|
+
const wrong = () => new (0, _chunkJO3W54E5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
4394
4394
|
let records;
|
|
4395
4395
|
try {
|
|
4396
4396
|
records = readRecords3(data);
|
|
@@ -4402,7 +4402,7 @@ function assertDecryptedDocInfo(data, readRecords3) {
|
|
|
4402
4402
|
}
|
|
4403
4403
|
function assertSupportedEncryptVersion(version) {
|
|
4404
4404
|
if (version !== SUPPORTED_ENCRYPT_VERSION) {
|
|
4405
|
-
throw new (0,
|
|
4405
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
4406
4406
|
`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWP \uC554\uD638\uD654 \uBC84\uC804\uC785\uB2C8\uB2E4 (EncryptVersion=${version}, \uC9C0\uC6D0: ${SUPPORTED_ENCRYPT_VERSION})`
|
|
4407
4407
|
);
|
|
4408
4408
|
}
|
|
@@ -4591,7 +4591,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4591
4591
|
lenientCfb = parseLenientCfb(buffer);
|
|
4592
4592
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
4593
4593
|
} catch (e24) {
|
|
4594
|
-
throw new (0,
|
|
4594
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
4595
4595
|
}
|
|
4596
4596
|
}
|
|
4597
4597
|
const readRawStream = (path) => {
|
|
@@ -4602,14 +4602,14 @@ function parseHwp5Document(buffer, options) {
|
|
|
4602
4602
|
return lenientCfb.findStream(path);
|
|
4603
4603
|
};
|
|
4604
4604
|
const headerData = readRawStream("/FileHeader");
|
|
4605
|
-
if (!headerData) throw new (0,
|
|
4605
|
+
if (!headerData) throw new (0, _chunkJO3W54E5cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4606
4606
|
const header = parseFileHeader(headerData);
|
|
4607
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
4608
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
4607
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkJO3W54E5cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
4608
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkJO3W54E5cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
4609
4609
|
const encrypted = (header.flags & FLAG_ENCRYPTED) !== 0;
|
|
4610
4610
|
if (encrypted) {
|
|
4611
4611
|
if (!_optionalChain([options, 'optionalAccess', _106 => _106.password])) {
|
|
4612
|
-
throw new (0,
|
|
4612
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWP \uBB38\uC11C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694.");
|
|
4613
4613
|
}
|
|
4614
4614
|
assertSupportedEncryptVersion(readEncryptVersion(headerData));
|
|
4615
4615
|
}
|
|
@@ -4627,18 +4627,18 @@ function parseHwp5Document(buffer, options) {
|
|
|
4627
4627
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
4628
4628
|
if (encrypted) {
|
|
4629
4629
|
const rawDocInfo = findStream("/DocInfo");
|
|
4630
|
-
if (!rawDocInfo) throw new (0,
|
|
4630
|
+
if (!rawDocInfo) throw new (0, _chunkJO3W54E5cjs.KordocError)("DocInfo \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
4631
4631
|
let docInfoData;
|
|
4632
4632
|
try {
|
|
4633
4633
|
docInfoData = compressed ? decompressStream(rawDocInfo) : rawDocInfo;
|
|
4634
4634
|
} catch (e25) {
|
|
4635
|
-
throw new (0,
|
|
4635
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
4636
4636
|
}
|
|
4637
4637
|
assertDecryptedDocInfo(docInfoData, readRecords);
|
|
4638
4638
|
}
|
|
4639
4639
|
const docInfo = cfb && !encrypted ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
4640
4640
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : encrypted ? findSectionsVia(findStream) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
4641
|
-
if (sections.length === 0) throw new (0,
|
|
4641
|
+
if (sections.length === 0) throw new (0, _chunkJO3W54E5cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
4642
4642
|
const sectionRecords = [];
|
|
4643
4643
|
const sectionDetects = [];
|
|
4644
4644
|
let totalDecompressed = 0;
|
|
@@ -4646,12 +4646,12 @@ function parseHwp5Document(buffer, options) {
|
|
|
4646
4646
|
try {
|
|
4647
4647
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sections[si])) : Buffer.from(sections[si]);
|
|
4648
4648
|
totalDecompressed += data.length;
|
|
4649
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4649
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkJO3W54E5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4650
4650
|
const records = readRecords(data);
|
|
4651
4651
|
sectionRecords.push(records);
|
|
4652
4652
|
sectionDetects.push(detectHwp5SectionPages(records));
|
|
4653
4653
|
} catch (secErr) {
|
|
4654
|
-
if (secErr instanceof
|
|
4654
|
+
if (secErr instanceof _chunkJO3W54E5cjs.KordocError) throw secErr;
|
|
4655
4655
|
sectionRecords.push(null);
|
|
4656
4656
|
sectionDetects.push(null);
|
|
4657
4657
|
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" });
|
|
@@ -4687,7 +4687,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
4687
4687
|
parsedSections++;
|
|
4688
4688
|
_optionalChain([options, 'optionalAccess', _110 => _110.onProgress, 'optionalCall', _111 => _111(parsedSections, sections.length)]);
|
|
4689
4689
|
} catch (secErr) {
|
|
4690
|
-
if (secErr instanceof
|
|
4690
|
+
if (secErr instanceof _chunkJO3W54E5cjs.KordocError) throw secErr;
|
|
4691
4691
|
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" });
|
|
4692
4692
|
} finally {
|
|
4693
4693
|
pageBase += detect.pages;
|
|
@@ -4698,9 +4698,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
4698
4698
|
}
|
|
4699
4699
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
4700
4700
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings, !pageFilter) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings, !pageFilter);
|
|
4701
|
-
let flatBlocks =
|
|
4701
|
+
let flatBlocks = _chunkFQTPFGVGcjs.flattenLayoutTables.call(void 0, blocks);
|
|
4702
4702
|
if (_optionalChain([options, 'optionalAccess', _112 => _112.dedupeRunningHeaders])) {
|
|
4703
|
-
const deduped =
|
|
4703
|
+
const deduped = _chunkFQTPFGVGcjs.dedupeRunningHeaders.call(void 0, flatBlocks);
|
|
4704
4704
|
const removed = flatBlocks.length - deduped.length;
|
|
4705
4705
|
if (removed > 0) warnings.push({ message: `\uBC18\uBCF5 \uB7EC\uB2DD \uD5E4\uB354 ${removed}\uAC1C \uC81C\uAC70`, code: "HIDDEN_TEXT_FILTERED" });
|
|
4706
4706
|
flatBlocks = deduped;
|
|
@@ -4709,10 +4709,10 @@ function parseHwp5Document(buffer, options) {
|
|
|
4709
4709
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
4710
4710
|
}
|
|
4711
4711
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
4712
|
-
let markdown =
|
|
4712
|
+
let markdown = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
4713
4713
|
if (_optionalChain([options, 'optionalAccess', _113 => _113.inlineImages]) && images.length > 0) {
|
|
4714
4714
|
try {
|
|
4715
|
-
markdown =
|
|
4715
|
+
markdown = _chunkFQTPFGVGcjs.inlineImagesIntoMarkdown.call(void 0, markdown, images, { compress: true });
|
|
4716
4716
|
} catch (inlineErr) {
|
|
4717
4717
|
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" });
|
|
4718
4718
|
}
|
|
@@ -4776,9 +4776,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
4776
4776
|
let level = 0;
|
|
4777
4777
|
if (_optionalChain([block, 'access', _118 => _118.style, 'optionalAccess', _119 => _119.fontSize]) && baseFontSize > 0) {
|
|
4778
4778
|
const ratio = block.style.fontSize / baseFontSize;
|
|
4779
|
-
if (ratio >=
|
|
4780
|
-
else if (ratio >=
|
|
4781
|
-
else if (ratio >=
|
|
4779
|
+
if (ratio >= _chunkT7GRHAIWcjs.HEADING_RATIO_H1) level = 1;
|
|
4780
|
+
else if (ratio >= _chunkT7GRHAIWcjs.HEADING_RATIO_H2) level = 2;
|
|
4781
|
+
else if (ratio >= _chunkT7GRHAIWcjs.HEADING_RATIO_H3) level = 3;
|
|
4782
4782
|
}
|
|
4783
4783
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
4784
4784
|
if (level === 0) level = 2;
|
|
@@ -4872,7 +4872,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4872
4872
|
if (!raw) break;
|
|
4873
4873
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4874
4874
|
totalDecompressed += content.length;
|
|
4875
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4875
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkJO3W54E5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4876
4876
|
sections.push({ idx: i, content });
|
|
4877
4877
|
}
|
|
4878
4878
|
if (sections.length === 0) {
|
|
@@ -4884,7 +4884,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
4884
4884
|
if (raw) {
|
|
4885
4885
|
const content = compressed ? decompressStream(raw) : raw;
|
|
4886
4886
|
totalDecompressed += content.length;
|
|
4887
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4887
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkJO3W54E5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4888
4888
|
sections.push({ idx, content });
|
|
4889
4889
|
}
|
|
4890
4890
|
}
|
|
@@ -4901,7 +4901,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
4901
4901
|
try {
|
|
4902
4902
|
const content = decryptViewText(raw, compressed);
|
|
4903
4903
|
totalDecompressed += content.length;
|
|
4904
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
4904
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkJO3W54E5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
4905
4905
|
sections.push({ idx: i, content });
|
|
4906
4906
|
} catch (e30) {
|
|
4907
4907
|
break;
|
|
@@ -5018,7 +5018,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5018
5018
|
const ctrl = ctrls[r.ctrlIdx];
|
|
5019
5019
|
if (!_optionalChain([ctrl, 'optionalAccess', _126 => _126.href]) || r.end <= r.start) continue;
|
|
5020
5020
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
5021
|
-
const href =
|
|
5021
|
+
const href = _chunkJO3W54E5cjs.sanitizeHref.call(void 0, ctrl.href);
|
|
5022
5022
|
if (!href) continue;
|
|
5023
5023
|
const anchor = text.slice(r.start, r.end);
|
|
5024
5024
|
if (!anchor.trim()) continue;
|
|
@@ -5258,8 +5258,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5258
5258
|
let tableIdx = -1;
|
|
5259
5259
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
5260
5260
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
5261
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
5262
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
5261
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkFQTPFGVGcjs.MAX_ROWS);
|
|
5262
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkFQTPFGVGcjs.MAX_COLS);
|
|
5263
5263
|
tableIdx = i2;
|
|
5264
5264
|
break;
|
|
5265
5265
|
}
|
|
@@ -5308,7 +5308,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
5308
5308
|
return table3;
|
|
5309
5309
|
}
|
|
5310
5310
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
5311
|
-
const table2 =
|
|
5311
|
+
const table2 = _chunkFQTPFGVGcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: ctx.doc.keepTrailingEmptyCols });
|
|
5312
5312
|
if (caption && table2.rows > 0) table2.caption = caption;
|
|
5313
5313
|
return table2.rows > 0 ? table2 : null;
|
|
5314
5314
|
}
|
|
@@ -5325,8 +5325,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5325
5325
|
rowAddr = rec.data.readUInt16LE(10);
|
|
5326
5326
|
const cs = rec.data.readUInt16LE(12);
|
|
5327
5327
|
const rs = rec.data.readUInt16LE(14);
|
|
5328
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
5329
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
5328
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkFQTPFGVGcjs.MAX_COLS);
|
|
5329
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkFQTPFGVGcjs.MAX_ROWS);
|
|
5330
5330
|
}
|
|
5331
5331
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
5332
5332
|
const parts = [];
|
|
@@ -5336,7 +5336,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
5336
5336
|
parts.push(``);
|
|
5337
5337
|
hasStructure = true;
|
|
5338
5338
|
} else if (b.type === "table" && b.table) {
|
|
5339
|
-
const flat =
|
|
5339
|
+
const flat = _chunkFQTPFGVGcjs.convertTableToText.call(void 0, b.table.cells);
|
|
5340
5340
|
if (flat) parts.push(flat);
|
|
5341
5341
|
hasStructure = true;
|
|
5342
5342
|
} else if (b.text) {
|
|
@@ -17386,9 +17386,15 @@ var ARAEA_JAMO = 4510;
|
|
|
17386
17386
|
function decodeAraeaSyllable(ch) {
|
|
17387
17387
|
if (ch < 32768) return null;
|
|
17388
17388
|
if ((ch >> 5 & 31) !== JUNG_ARAEA) return null;
|
|
17389
|
-
const
|
|
17389
|
+
const choIdx = ch >> 10 & 31;
|
|
17390
|
+
const cho = CHO_MAP[choIdx];
|
|
17390
17391
|
const jong = JONG_MAP[ch & 31];
|
|
17391
|
-
if (
|
|
17392
|
+
if (jong === -1) return null;
|
|
17393
|
+
if (cho === -1) {
|
|
17394
|
+
if (choIdx !== 1) return null;
|
|
17395
|
+
const bare = String.fromCodePoint(ARAEA_JAMO);
|
|
17396
|
+
return jong === 0 ? bare : bare + String.fromCodePoint(4519 + jong);
|
|
17397
|
+
}
|
|
17392
17398
|
const out = String.fromCodePoint(4352 + cho) + String.fromCodePoint(ARAEA_JAMO);
|
|
17393
17399
|
return jong === 0 ? out : out + String.fromCodePoint(4519 + jong);
|
|
17394
17400
|
}
|
|
@@ -17416,7 +17422,44 @@ function decodeJohab(ch) {
|
|
|
17416
17422
|
}
|
|
17417
17423
|
return decodeHwp3Extra(ch);
|
|
17418
17424
|
}
|
|
17425
|
+
var eucKrDecoder;
|
|
17426
|
+
function kscChar(row, cell2) {
|
|
17427
|
+
if (eucKrDecoder === void 0) {
|
|
17428
|
+
try {
|
|
17429
|
+
eucKrDecoder = new TextDecoder("euc-kr", { fatal: false });
|
|
17430
|
+
} catch (e31) {
|
|
17431
|
+
eucKrDecoder = null;
|
|
17432
|
+
}
|
|
17433
|
+
}
|
|
17434
|
+
if (!eucKrDecoder) return null;
|
|
17435
|
+
if (row < 161 || row > 254 || cell2 < 161 || cell2 > 254) return null;
|
|
17436
|
+
const text = eucKrDecoder.decode(Uint8Array.of(row, cell2));
|
|
17437
|
+
if (text.length !== 1) return null;
|
|
17438
|
+
const cp = text.codePointAt(0);
|
|
17439
|
+
if (cp === 65533) return null;
|
|
17440
|
+
return hancomVariant(cp);
|
|
17441
|
+
}
|
|
17442
|
+
function hancomVariant(cp) {
|
|
17443
|
+
if (cp === 8764) return 65374;
|
|
17444
|
+
if (cp === 8857) return 9673;
|
|
17445
|
+
return cp;
|
|
17446
|
+
}
|
|
17447
|
+
function decodeHwp3KscSymbol(ch) {
|
|
17448
|
+
if (ch < 13313) return null;
|
|
17449
|
+
const idx = ch - 13313;
|
|
17450
|
+
const row = 161 + Math.floor(idx / 96);
|
|
17451
|
+
if (row > 172) return null;
|
|
17452
|
+
return kscChar(row, 161 + idx % 96);
|
|
17453
|
+
}
|
|
17454
|
+
function decodeHwp3KscHanja(ch) {
|
|
17455
|
+
if (ch < 16384) return null;
|
|
17456
|
+
const idx = ch - 16384;
|
|
17457
|
+
const row = 202 + Math.floor(idx / 94);
|
|
17458
|
+
if (row > 253) return null;
|
|
17459
|
+
return kscChar(row, 161 + idx % 94);
|
|
17460
|
+
}
|
|
17419
17461
|
function decodeHwp3Extra(ch) {
|
|
17462
|
+
if (ch >= 160 && ch <= 255) return ch;
|
|
17420
17463
|
if (ch >= 13712 && ch <= 13721) return 8544 + (ch - 13712);
|
|
17421
17464
|
if (ch >= 14055 && ch <= 14064) return 9312 + (ch - 14055);
|
|
17422
17465
|
if (ch >= 14272 && ch <= 14277) return "\uD55C\uAE00\uACFC\uCEF4\uD4E8\uD130".codePointAt(ch - 14272);
|
|
@@ -17430,6 +17473,28 @@ function decodeHwp3Extra(ch) {
|
|
|
17430
17473
|
case 12316:
|
|
17431
17474
|
return 9473;
|
|
17432
17475
|
// ━ 굵은 가로선 (rhwp: U+F080F, 표시값 직행)
|
|
17476
|
+
// 텍스트 다이어그램 괘선 조각 — 한컴은 U+F0806~F0810 으로 보존하고 rhwp 검증표가
|
|
17477
|
+
// ┌┬┐└┘│ 로 편다. HWP3 코드는 그 PUA 에서 상수 오프셋(0xC07F3)만큼 떨어져 있고
|
|
17478
|
+
// (0x301C→F080F 가 이미 그 관계), hwp3-sample11 ↔ 변환본 개수도 그대로 맞는다
|
|
17479
|
+
// (0x3013×3↔┌, 0x3014×1↔┬, 0x3015×10↔┐, 0x3019×6↔└, 0x301B×9↔┘, 0x301D×17↔│).
|
|
17480
|
+
case 12307:
|
|
17481
|
+
return 9484;
|
|
17482
|
+
// ┌
|
|
17483
|
+
case 12308:
|
|
17484
|
+
return 9516;
|
|
17485
|
+
// ┬
|
|
17486
|
+
case 12309:
|
|
17487
|
+
return 9488;
|
|
17488
|
+
// ┐
|
|
17489
|
+
case 12313:
|
|
17490
|
+
return 9492;
|
|
17491
|
+
// └
|
|
17492
|
+
case 12315:
|
|
17493
|
+
return 9496;
|
|
17494
|
+
// ┘
|
|
17495
|
+
case 12317:
|
|
17496
|
+
return 9474;
|
|
17497
|
+
// │
|
|
17433
17498
|
case 12349:
|
|
17434
17499
|
return 9632;
|
|
17435
17500
|
// ■ (rhwp: U+F0827, 표시값 직행)
|
|
@@ -17457,8 +17522,119 @@ function decodeHwp3Extra(ch) {
|
|
|
17457
17522
|
case 12135:
|
|
17458
17523
|
return 9656;
|
|
17459
17524
|
// ▸ 표 셀 글머리표 (rhwp 16db8260 — HWP5 변환본·한컴 PDF 대조)
|
|
17525
|
+
// 아래 항등 코드들은 rhwp #5860 실측표(한글 2022 오라클 위치 정렬) 이식.
|
|
17526
|
+
// 같은 0x20xx 대에 항등과 비항등이 섞여 있어 구간 통과는 하지 않는다.
|
|
17527
|
+
case 8208:
|
|
17528
|
+
return 8208;
|
|
17529
|
+
// ‐
|
|
17530
|
+
case 8211:
|
|
17531
|
+
return 8211;
|
|
17532
|
+
// –
|
|
17533
|
+
case 8451:
|
|
17534
|
+
return 8451;
|
|
17535
|
+
// ℃
|
|
17536
|
+
case 8467:
|
|
17537
|
+
return 8467;
|
|
17538
|
+
// ℓ
|
|
17539
|
+
case 8592:
|
|
17540
|
+
return 8592;
|
|
17541
|
+
// ←
|
|
17542
|
+
case 8594:
|
|
17543
|
+
return 8594;
|
|
17544
|
+
// →
|
|
17545
|
+
case 8595:
|
|
17546
|
+
return 8595;
|
|
17547
|
+
// ↓
|
|
17548
|
+
case 8729:
|
|
17549
|
+
return 8729;
|
|
17550
|
+
// ∙ (sample11 실측 11건)
|
|
17551
|
+
case 8901:
|
|
17552
|
+
return 8901;
|
|
17553
|
+
// ⋅
|
|
17554
|
+
case 8251:
|
|
17555
|
+
return 8251;
|
|
17556
|
+
// ※ — 한자를 완성형 좌표로 담으면서 ※ 만 유니코드 값으로 담은 문서가 있다
|
|
17557
|
+
// 비항등 — 유니코드로 읽으면 ⁚·․·⁘ 같은 다른 글자가 된다 (rhwp #5860)
|
|
17558
|
+
case 8228:
|
|
17559
|
+
return 12539;
|
|
17560
|
+
// ・
|
|
17561
|
+
case 8280:
|
|
17562
|
+
return 9651;
|
|
17563
|
+
// △
|
|
17564
|
+
case 8282:
|
|
17565
|
+
return 9675;
|
|
17566
|
+
// ○
|
|
17567
|
+
case 12040:
|
|
17568
|
+
return 9642;
|
|
17569
|
+
// ▪
|
|
17570
|
+
case 12049:
|
|
17571
|
+
return 9702;
|
|
17572
|
+
// ◦ (sample16 실측 332건)
|
|
17573
|
+
case 12052:
|
|
17574
|
+
return 9702;
|
|
17575
|
+
// ◦
|
|
17576
|
+
case 12631:
|
|
17577
|
+
return 8231;
|
|
17578
|
+
// ‧
|
|
17579
|
+
case 1152:
|
|
17580
|
+
return 720;
|
|
17581
|
+
// ː
|
|
17582
|
+
case 7982:
|
|
17583
|
+
return 12398;
|
|
17584
|
+
// の
|
|
17585
|
+
case 12976:
|
|
17586
|
+
return 65392;
|
|
17587
|
+
// ー (반각)
|
|
17588
|
+
case 12391:
|
|
17589
|
+
return 8216;
|
|
17590
|
+
// ‘
|
|
17591
|
+
case 12392:
|
|
17592
|
+
return 8217;
|
|
17593
|
+
// ’
|
|
17594
|
+
case 12443:
|
|
17595
|
+
return 65378;
|
|
17596
|
+
// 「
|
|
17597
|
+
case 12445:
|
|
17598
|
+
return 65379;
|
|
17599
|
+
// 」
|
|
17600
|
+
case 131:
|
|
17601
|
+
return 8216;
|
|
17602
|
+
// ‘ — 큰따옴표(0x0081/0x0082) 바로 다음 코드 (sample11/14 실측 18건)
|
|
17603
|
+
case 132:
|
|
17604
|
+
return 8217;
|
|
17605
|
+
// ’
|
|
17606
|
+
// 아래 셋은 rhwp 표에 없는 값 — kordoc 이 rhwp 샘플 ↔ 한컴 변환본 문맥 정렬로 실측했다.
|
|
17607
|
+
case 8226:
|
|
17608
|
+
return 8226;
|
|
17609
|
+
// • hwp3-sample 글머리표 4건 (항등)
|
|
17610
|
+
case 12055:
|
|
17611
|
+
return 8226;
|
|
17612
|
+
// • hwp3-sample10 글머리표 3건
|
|
17613
|
+
case 12038:
|
|
17614
|
+
return 9632;
|
|
17615
|
+
// ■ hwp3-sample10 "제목차례" 좌우 장식 2건
|
|
17616
|
+
// 관인·서명란 도장 기호. rhwp 는 U+F012B 로 보존하고 렌더러가 `(인)` 으로 편다 —
|
|
17617
|
+
// kordoc 도 PUA 를 그대로 내보내면 shared/pua.ts 의 검증표가 같은 문자열로 편다.
|
|
17618
|
+
case 11214:
|
|
17619
|
+
return 983339;
|
|
17620
|
+
// ═ 겹줄. rhwp 는 0x3048 을 U+F0832(렌더 표시값 `═`)로 보존한다. 0x37ED 는 기호
|
|
17621
|
+
// 규칙으로는 가타카나 `ネ` 가 되는 사적 graphic 코드로, sample10(42건)·sample11(12건)
|
|
17622
|
+
// 두 문서에서 한컴 변환본의 `═` 개수와 정확히 일치해 표시값 직행으로 싣는다.
|
|
17623
|
+
case 12360:
|
|
17624
|
+
return 9552;
|
|
17625
|
+
case 14317:
|
|
17626
|
+
return 9552;
|
|
17627
|
+
// 사적 원문자·괄호문자 계열. 사적 코드는 일반식이 없어 실측 문서에서 연속으로
|
|
17628
|
+
// 확인된 구간만 싣는다 (sample11 ↔ hwp3-sample11-hwpx 문맥 정렬).
|
|
17629
|
+
// 0x2E01~0x2E07 → ①~⑦ 7코드 연속 일치, 0x2C21~0x2C26 → ⓐ~ⓕ (ⓒ~ⓕ 개수 일치),
|
|
17630
|
+
// 0x2C40~0x2C42 → ㉠~㉢
|
|
17460
17631
|
default:
|
|
17461
|
-
return
|
|
17632
|
+
if (ch >= 11777 && ch <= 11783) return 9312 + (ch - 11777);
|
|
17633
|
+
if (ch === 11776) return 9450;
|
|
17634
|
+
if (ch >= 11786 && ch <= 11794) return 9312 + (ch - 11786);
|
|
17635
|
+
if (ch >= 11297 && ch <= 11302) return 9424 + (ch - 11297);
|
|
17636
|
+
if (ch >= 11328 && ch <= 11330) return 12896 + (ch - 11328);
|
|
17637
|
+
return _nullishCoalesce(_nullishCoalesce(decodeHwp3KscSymbol(ch), () => ( decodeHwp3KscHanja(ch))), () => ( JOHAB_UNMAPPED));
|
|
17462
17638
|
}
|
|
17463
17639
|
}
|
|
17464
17640
|
function decodeHcharString(bytes) {
|
|
@@ -17611,25 +17787,25 @@ function desEcbDecrypt(data, key) {
|
|
|
17611
17787
|
}
|
|
17612
17788
|
function readLayout(data) {
|
|
17613
17789
|
if (data.length < FIXED_HEADER_BYTES) {
|
|
17614
|
-
throw new (0,
|
|
17790
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uD5E4\uB354\uAC00 \uC798\uB838\uC2B5\uB2C8\uB2E4");
|
|
17615
17791
|
}
|
|
17616
17792
|
const infoBlockLength = data[INFO_BLOCK_LENGTH_OFFSET] | data[INFO_BLOCK_LENGTH_OFFSET + 1] << 8;
|
|
17617
17793
|
const payloadOffset = FIXED_HEADER_BYTES + infoBlockLength;
|
|
17618
17794
|
if (payloadOffset >= data.length) {
|
|
17619
|
-
throw new (0,
|
|
17795
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uBCF8\uBB38\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
17620
17796
|
}
|
|
17621
17797
|
return { payloadOffset, compressed: data[COMPRESSION_FLAG_OFFSET] !== 0 };
|
|
17622
17798
|
}
|
|
17623
17799
|
function decryptHwp3Document(input, password) {
|
|
17624
17800
|
const { payloadOffset, compressed } = readLayout(input);
|
|
17625
17801
|
if (!compressed) {
|
|
17626
|
-
throw new (0,
|
|
17802
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 HWP3 \uC554\uD638\uD654 \uBC29\uC2DD\uC785\uB2C8\uB2E4 (\uC555\uCD95\uB418\uC9C0 \uC54A\uC740 \uC554\uD638 \uBCF8\uBB38)");
|
|
17627
17803
|
}
|
|
17628
17804
|
const source = Buffer.from(input);
|
|
17629
17805
|
const payload = source.subarray(payloadOffset);
|
|
17630
17806
|
const aligned = payload.subarray(0, payload.length - payload.length % 8);
|
|
17631
17807
|
if (aligned.length === 0) {
|
|
17632
|
-
throw new (0,
|
|
17808
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("HWP3 \uC554\uD638 \uBB38\uC11C: \uBCF8\uBB38\uC774 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4");
|
|
17633
17809
|
}
|
|
17634
17810
|
const decrypted = desEcbDecrypt(aligned, deriveDesKey(password));
|
|
17635
17811
|
let inflated;
|
|
@@ -17637,14 +17813,14 @@ function decryptHwp3Document(input, password) {
|
|
|
17637
17813
|
inflated = _zlib.inflateRawSync.call(void 0, decrypted, { maxOutputLength: MAX_DECOMPRESSED_BYTES });
|
|
17638
17814
|
} catch (err) {
|
|
17639
17815
|
if (_optionalChain([err, 'optionalAccess', _139 => _139.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17640
|
-
throw new (0,
|
|
17816
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
17641
17817
|
`HWP3 \uC554\uD638 \uBCF8\uBB38\uC758 \uC555\uCD95 \uD574\uC81C \uACB0\uACFC\uAC00 \uCD5C\uB300 \uD5C8\uC6A9 \uD06C\uAE30(${MAX_DECOMPRESSED_BYTES / 1024 / 1024}MB)\uB97C \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4`
|
|
17642
17818
|
);
|
|
17643
17819
|
}
|
|
17644
|
-
throw new (0,
|
|
17820
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
17645
17821
|
}
|
|
17646
17822
|
if (inflated.length <= PASSWORD_PREFIX_BYTES) {
|
|
17647
|
-
throw new (0,
|
|
17823
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uAC70\uB098 \uC554\uD638\uD654 \uB370\uC774\uD130\uAC00 \uC190\uC0C1\uB418\uC5C8\uC2B5\uB2C8\uB2E4.");
|
|
17648
17824
|
}
|
|
17649
17825
|
const body = inflated.subarray(PASSWORD_PREFIX_BYTES);
|
|
17650
17826
|
const out = Buffer.concat([source.subarray(0, payloadOffset), body]);
|
|
@@ -17679,7 +17855,7 @@ function parseHwp3Document(buffer, options) {
|
|
|
17679
17855
|
let source = Buffer.from(buffer);
|
|
17680
17856
|
if (isEncryptedHwp3(source)) {
|
|
17681
17857
|
if (!_optionalChain([options, 'optionalAccess', _140 => _140.password])) {
|
|
17682
|
-
throw new (0,
|
|
17858
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
17683
17859
|
"\uC554\uD638\uB85C \uBCF4\uD638\uB41C HWP3 \uBB38\uC11C\uC785\uB2C8\uB2E4. password \uC635\uC158\uC5D0 \uC5F4\uAE30 \uC554\uD638\uB97C \uC9C0\uC815\uD558\uC138\uC694."
|
|
17684
17860
|
);
|
|
17685
17861
|
}
|
|
@@ -17696,10 +17872,10 @@ function parseHwp3Document(buffer, options) {
|
|
|
17696
17872
|
body = _zlib.inflateRawSync.call(void 0, tail, { maxOutputLength: MAX_DECOMPRESS_SIZE3 });
|
|
17697
17873
|
} catch (err) {
|
|
17698
17874
|
if (_optionalChain([err, 'optionalAccess', _141 => _141.code]) === "ERR_BUFFER_TOO_LARGE") {
|
|
17699
|
-
throw new (0,
|
|
17875
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`HWP3 \uC555\uCD95 \uD574\uC81C \uACB0\uACFC\uAC00 \uCD5C\uB300 \uD5C8\uC6A9 \uD06C\uAE30(${MAX_DECOMPRESS_SIZE3 / 1024 / 1024}MB)\uB97C \uCD08\uACFC\uD588\uC2B5\uB2C8\uB2E4`);
|
|
17700
17876
|
}
|
|
17701
17877
|
const msg2 = err instanceof Error ? err.message : String(err);
|
|
17702
|
-
throw new (0,
|
|
17878
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`HWP3 \uC555\uCD95 \uD574\uC81C \uC2E4\uD328: ${msg2}`);
|
|
17703
17879
|
}
|
|
17704
17880
|
} else {
|
|
17705
17881
|
body = tail;
|
|
@@ -17941,7 +18117,7 @@ function getTextContent(el) {
|
|
|
17941
18117
|
return _nullishCoalesce(_optionalChain([el, 'access', _144 => _144.textContent, 'optionalAccess', _145 => _145.trim, 'call', _146 => _146()]), () => ( ""));
|
|
17942
18118
|
}
|
|
17943
18119
|
function parseXml(text) {
|
|
17944
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18120
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkJO3W54E5cjs.stripDtd.call(void 0, text), "text/xml");
|
|
17945
18121
|
}
|
|
17946
18122
|
function collectRichText(root) {
|
|
17947
18123
|
let out = "";
|
|
@@ -18176,7 +18352,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18176
18352
|
cellRows.push(row);
|
|
18177
18353
|
}
|
|
18178
18354
|
if (cellRows.length > 0) {
|
|
18179
|
-
const table2 =
|
|
18355
|
+
const table2 = _chunkFQTPFGVGcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18180
18356
|
if (table2.rows > 0) {
|
|
18181
18357
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18182
18358
|
}
|
|
@@ -18184,12 +18360,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keep
|
|
|
18184
18360
|
return blocks;
|
|
18185
18361
|
}
|
|
18186
18362
|
async function parseXlsxDocument(buffer, options) {
|
|
18187
|
-
|
|
18363
|
+
_chunkJO3W54E5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18188
18364
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18189
18365
|
const warnings = [];
|
|
18190
18366
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
18191
18367
|
if (!workbookFile) {
|
|
18192
|
-
throw new (0,
|
|
18368
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18193
18369
|
}
|
|
18194
18370
|
let sharedStrings = [];
|
|
18195
18371
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -18198,14 +18374,14 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18198
18374
|
}
|
|
18199
18375
|
const { sheets, date1904 } = parseWorkbook(await workbookFile.async("text"));
|
|
18200
18376
|
if (sheets.length === 0) {
|
|
18201
|
-
throw new (0,
|
|
18377
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18202
18378
|
}
|
|
18203
18379
|
let dateXfs = /* @__PURE__ */ new Map();
|
|
18204
18380
|
const stylesFile = zip.file("xl/styles.xml");
|
|
18205
18381
|
if (stylesFile) {
|
|
18206
18382
|
try {
|
|
18207
18383
|
dateXfs = parseStyleDateXfs(await stylesFile.async("text"));
|
|
18208
|
-
} catch (
|
|
18384
|
+
} catch (e32) {
|
|
18209
18385
|
warnings.push({
|
|
18210
18386
|
code: "PARTIAL_PARSE",
|
|
18211
18387
|
message: "xl/styles.xml \uB0A0\uC9DC \uC11C\uC2DD \uD310\uC815 \uC2E4\uD328 \u2014 \uB0A0\uC9DC \uC140\uC774 \uC2DC\uB9AC\uC5BC \uC22B\uC790\uB85C \uCD9C\uB825\uB420 \uC218 \uC788\uC2B5\uB2C8\uB2E4"
|
|
@@ -18279,10 +18455,10 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
18279
18455
|
if (created) metadata.createdAt = created;
|
|
18280
18456
|
const modified = getFirst("dcterms:modified");
|
|
18281
18457
|
if (modified) metadata.modifiedAt = modified;
|
|
18282
|
-
} catch (
|
|
18458
|
+
} catch (e33) {
|
|
18283
18459
|
}
|
|
18284
18460
|
}
|
|
18285
|
-
const markdown =
|
|
18461
|
+
const markdown = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18286
18462
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
18287
18463
|
}
|
|
18288
18464
|
|
|
@@ -18733,11 +18909,11 @@ function processGlobals(records) {
|
|
|
18733
18909
|
const xfFmtIds = [];
|
|
18734
18910
|
const firstBof = records[0];
|
|
18735
18911
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
18736
|
-
throw new (0,
|
|
18912
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
18737
18913
|
}
|
|
18738
18914
|
const bof = decodeBof(firstBof.data);
|
|
18739
18915
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
18740
|
-
throw new (0,
|
|
18916
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
18741
18917
|
}
|
|
18742
18918
|
let i = 1;
|
|
18743
18919
|
while (i < records.length) {
|
|
@@ -18872,7 +19048,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
|
|
|
18872
19048
|
cellRows.push(row);
|
|
18873
19049
|
}
|
|
18874
19050
|
if (cellRows.length > 0) {
|
|
18875
|
-
const table2 =
|
|
19051
|
+
const table2 = _chunkFQTPFGVGcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols });
|
|
18876
19052
|
if (table2.rows > 0) {
|
|
18877
19053
|
blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
|
|
18878
19054
|
}
|
|
@@ -18885,28 +19061,28 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18885
19061
|
try {
|
|
18886
19062
|
cfb = parseLenientCfb(buf);
|
|
18887
19063
|
} catch (e) {
|
|
18888
|
-
throw new (0,
|
|
19064
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
18889
19065
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
18890
19066
|
);
|
|
18891
19067
|
}
|
|
18892
19068
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
18893
19069
|
if (!wb) {
|
|
18894
|
-
throw new (0,
|
|
19070
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
18895
19071
|
}
|
|
18896
19072
|
const records = readRecords2(wb);
|
|
18897
19073
|
if (records.length === 0) {
|
|
18898
|
-
throw new (0,
|
|
19074
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
18899
19075
|
}
|
|
18900
19076
|
const firstBof = decodeBof(records[0].data);
|
|
18901
19077
|
if (firstBof && firstBof.vers !== 1536) {
|
|
18902
|
-
throw new (0,
|
|
19078
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
18903
19079
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
18904
19080
|
);
|
|
18905
19081
|
}
|
|
18906
19082
|
const globals = processGlobals(records);
|
|
18907
19083
|
const warnings = [];
|
|
18908
19084
|
if (globals.encrypted) {
|
|
18909
|
-
throw new (0,
|
|
19085
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("XLS \uD30C\uC77C\uC774 \uC554\uD638\uD654\uB418\uC5B4 \uC788\uC5B4 \uD30C\uC2F1\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18910
19086
|
}
|
|
18911
19087
|
const convertNum = globals.dateXfs.size > 0 ? (n, ixfe) => {
|
|
18912
19088
|
const kind = globals.dateXfs.get(ixfe);
|
|
@@ -18957,7 +19133,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18957
19133
|
pageCount: totalSheets
|
|
18958
19134
|
};
|
|
18959
19135
|
return {
|
|
18960
|
-
markdown:
|
|
19136
|
+
markdown: _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
18961
19137
|
blocks: allBlocks,
|
|
18962
19138
|
metadata,
|
|
18963
19139
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -19385,7 +19561,7 @@ function getAttr(el, localName3) {
|
|
|
19385
19561
|
return null;
|
|
19386
19562
|
}
|
|
19387
19563
|
function parseXml2(text) {
|
|
19388
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
19564
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkJO3W54E5cjs.stripDtd.call(void 0, text), "text/xml");
|
|
19389
19565
|
}
|
|
19390
19566
|
function parseStyles(xml) {
|
|
19391
19567
|
const doc = parseXml2(xml);
|
|
@@ -19543,7 +19719,7 @@ function fieldUrlFromInstr(instr) {
|
|
|
19543
19719
|
function makeLink(text, rawHref) {
|
|
19544
19720
|
if (!text) return "";
|
|
19545
19721
|
if (!rawHref) return text;
|
|
19546
|
-
const href =
|
|
19722
|
+
const href = _chunkJO3W54E5cjs.sanitizeHref.call(void 0, rawHref);
|
|
19547
19723
|
return href ? `[${text}](${href})` : text;
|
|
19548
19724
|
}
|
|
19549
19725
|
function collectInline(p, footnotes, rels) {
|
|
@@ -19737,7 +19913,7 @@ ${cell2.text}` : cell2.text;
|
|
|
19737
19913
|
return { text: cell2.text, colSpan: cell2.colSpan, rowSpan, colAddr: cell2.col, rowAddr: r };
|
|
19738
19914
|
})
|
|
19739
19915
|
);
|
|
19740
|
-
const table2 =
|
|
19916
|
+
const table2 = _chunkFQTPFGVGcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keepEmptyCols });
|
|
19741
19917
|
if (table2.rows === 0 || table2.cols === 0) return null;
|
|
19742
19918
|
return { type: "table", table: table2 };
|
|
19743
19919
|
}
|
|
@@ -19793,10 +19969,14 @@ async function buildImageMap(zip, rels, doc, warnings) {
|
|
|
19793
19969
|
gif: "image/gif",
|
|
19794
19970
|
bmp: "image/bmp",
|
|
19795
19971
|
wmf: "image/wmf",
|
|
19796
|
-
emf: "image/emf"
|
|
19972
|
+
emf: "image/emf",
|
|
19973
|
+
tif: "image/tiff",
|
|
19974
|
+
tiff: "image/tiff",
|
|
19975
|
+
svg: "image/svg+xml"
|
|
19797
19976
|
};
|
|
19798
19977
|
const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
|
|
19799
|
-
|
|
19978
|
+
const mimeType = _nullishCoalesce(_nullishCoalesce(mimeMap[ext], () => ( detectImageMime(data))), () => ( "application/octet-stream"));
|
|
19979
|
+
images.push({ filename, data, mimeType, source: imgPath });
|
|
19800
19980
|
imageMap.set(embedId, filename);
|
|
19801
19981
|
} catch (err) {
|
|
19802
19982
|
warnings.push({
|
|
@@ -19839,12 +20019,12 @@ function emitParagraphImages(p, imageMap, linked, out) {
|
|
|
19839
20019
|
}
|
|
19840
20020
|
}
|
|
19841
20021
|
async function parseDocxDocument(buffer, options) {
|
|
19842
|
-
|
|
20022
|
+
_chunkJO3W54E5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE5);
|
|
19843
20023
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
19844
20024
|
const warnings = [];
|
|
19845
20025
|
const docFile = zip.file("word/document.xml");
|
|
19846
20026
|
if (!docFile) {
|
|
19847
|
-
throw new (0,
|
|
20027
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19848
20028
|
}
|
|
19849
20029
|
let rels = /* @__PURE__ */ new Map();
|
|
19850
20030
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -19891,7 +20071,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19891
20071
|
const doc = parseXml2(docXml);
|
|
19892
20072
|
const body = findElements(doc, "body");
|
|
19893
20073
|
if (body.length === 0) {
|
|
19894
|
-
throw new (0,
|
|
20074
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19895
20075
|
}
|
|
19896
20076
|
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19897
20077
|
const linkedImages = /* @__PURE__ */ new Set();
|
|
@@ -19942,7 +20122,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19942
20122
|
}
|
|
19943
20123
|
}
|
|
19944
20124
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
19945
|
-
const markdown =
|
|
20125
|
+
const markdown = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, blocks);
|
|
19946
20126
|
return {
|
|
19947
20127
|
markdown,
|
|
19948
20128
|
blocks,
|
|
@@ -19960,11 +20140,11 @@ var MAX_TABLE_COLS = 500;
|
|
|
19960
20140
|
var MAX_HWPML_BYTES = 50 * 1024 * 1024;
|
|
19961
20141
|
function parseHwpmlDocument(buffer, options) {
|
|
19962
20142
|
if (buffer.byteLength > MAX_HWPML_BYTES) {
|
|
19963
|
-
throw new (0,
|
|
20143
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`HWPML \uD30C\uC77C \uD06C\uAE30 \uCD08\uACFC (${(buffer.byteLength / 1024 / 1024).toFixed(1)}MB > 50MB)`);
|
|
19964
20144
|
}
|
|
19965
20145
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
19966
20146
|
const normalized = text.replace(/ /g, " ");
|
|
19967
|
-
const xml =
|
|
20147
|
+
const xml = _chunkJO3W54E5cjs.stripDtd.call(void 0, normalized);
|
|
19968
20148
|
const warnings = [];
|
|
19969
20149
|
const parser = new (0, _xmldom.DOMParser)({
|
|
19970
20150
|
onError: (_level, msg2) => {
|
|
@@ -20004,7 +20184,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
20004
20184
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _190 => _190.keepTrailingEmptyCols]), () => ( false)));
|
|
20005
20185
|
}
|
|
20006
20186
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
20007
|
-
const markdown =
|
|
20187
|
+
const markdown = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, blocks);
|
|
20008
20188
|
return {
|
|
20009
20189
|
markdown,
|
|
20010
20190
|
blocks,
|
|
@@ -20169,7 +20349,7 @@ function buildHmlTable(el, warnings, keep, tableDepth) {
|
|
|
20169
20349
|
const r = Math.min(Math.max(_nullishCoalesce(cell2.rowAddr, () => ( 0)), 0), rowCount - 1);
|
|
20170
20350
|
cellRows[r].push(cell2);
|
|
20171
20351
|
}
|
|
20172
|
-
const table2 =
|
|
20352
|
+
const table2 = _chunkFQTPFGVGcjs.buildTable.call(void 0, cellRows, { keepAnchoredEmptyCols: keep });
|
|
20173
20353
|
if (structured.length > 0) {
|
|
20174
20354
|
const claimed = /* @__PURE__ */ new Set();
|
|
20175
20355
|
for (const { ctx, cellBlocks } of structured) {
|
|
@@ -21075,7 +21255,7 @@ function decodeXmlEntities(text) {
|
|
|
21075
21255
|
try {
|
|
21076
21256
|
const code = ent[1] === "x" || ent[1] === "X" ? parseInt(ent.slice(2), 16) : parseInt(ent.slice(1), 10);
|
|
21077
21257
|
if (!isNaN(code) && code >= 0 && code <= 1114111) return String.fromCodePoint(code);
|
|
21078
|
-
} catch (
|
|
21258
|
+
} catch (e34) {
|
|
21079
21259
|
}
|
|
21080
21260
|
return m;
|
|
21081
21261
|
});
|
|
@@ -21680,7 +21860,7 @@ function fillClickHereInXml(xml, cursor, blockedLabels) {
|
|
|
21680
21860
|
};
|
|
21681
21861
|
}
|
|
21682
21862
|
async function extractClickHereFields(hwpxBuffer) {
|
|
21683
|
-
|
|
21863
|
+
_chunkJO3W54E5cjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
21684
21864
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21685
21865
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21686
21866
|
const fields = [];
|
|
@@ -21728,19 +21908,19 @@ function parseCentralDirectory(buf) {
|
|
|
21728
21908
|
}
|
|
21729
21909
|
}
|
|
21730
21910
|
}
|
|
21731
|
-
if (eocdOffset < 0) throw new (0,
|
|
21911
|
+
if (eocdOffset < 0) throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21732
21912
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
21733
21913
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
21734
21914
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
21735
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
21915
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21736
21916
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
21737
|
-
throw new (0,
|
|
21917
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21738
21918
|
}
|
|
21739
21919
|
const decoder = new TextDecoder("utf-8");
|
|
21740
21920
|
const entries = [];
|
|
21741
21921
|
let pos = cdOffset;
|
|
21742
21922
|
for (let i = 0; i < totalEntries; i++) {
|
|
21743
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
21923
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
21744
21924
|
const flags = view.getUint16(pos + 8, true);
|
|
21745
21925
|
const method = view.getUint16(pos + 10, true);
|
|
21746
21926
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -21751,7 +21931,7 @@ function parseCentralDirectory(buf) {
|
|
|
21751
21931
|
const commentLen = view.getUint16(pos + 32, true);
|
|
21752
21932
|
const localOffset = view.getUint32(pos + 42, true);
|
|
21753
21933
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
21754
|
-
throw new (0,
|
|
21934
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
21755
21935
|
}
|
|
21756
21936
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
21757
21937
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -21780,11 +21960,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21780
21960
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
21781
21961
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
21782
21962
|
for (const name of replacements.keys()) {
|
|
21783
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
21963
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkJO3W54E5cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21784
21964
|
}
|
|
21785
21965
|
if (additions) {
|
|
21786
21966
|
for (const name of additions.keys()) {
|
|
21787
|
-
if (entries.some((e) => e.name === name)) throw new (0,
|
|
21967
|
+
if (entries.some((e) => e.name === name)) throw new (0, _chunkJO3W54E5cjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
21788
21968
|
}
|
|
21789
21969
|
}
|
|
21790
21970
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
@@ -21803,7 +21983,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21803
21983
|
offset += seg.length;
|
|
21804
21984
|
continue;
|
|
21805
21985
|
}
|
|
21806
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
21986
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkJO3W54E5cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
21807
21987
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
21808
21988
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
21809
21989
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -21811,7 +21991,7 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21811
21991
|
const hview = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
21812
21992
|
const method = e.method;
|
|
21813
21993
|
if (method !== 0 && method !== 8) {
|
|
21814
|
-
throw new (0,
|
|
21994
|
+
throw new (0, _chunkJO3W54E5cjs.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`);
|
|
21815
21995
|
}
|
|
21816
21996
|
const compData = method === 0 ? newData : new Uint8Array(_zlib.deflateRawSync.call(void 0, newData));
|
|
21817
21997
|
const crc = crc32(newData);
|
|
@@ -21909,11 +22089,11 @@ function patchZipEntries(original, replacements, additions) {
|
|
|
21909
22089
|
// src/form/filler-hwpx.ts
|
|
21910
22090
|
async function fillHwpx(hwpxBuffer, values, blockedLabels) {
|
|
21911
22091
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
21912
|
-
|
|
22092
|
+
_chunkJO3W54E5cjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
21913
22093
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
21914
22094
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
21915
22095
|
if (sectionPaths.length === 0) {
|
|
21916
|
-
throw new (0,
|
|
22096
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
21917
22097
|
}
|
|
21918
22098
|
const warnings = [];
|
|
21919
22099
|
const normalizedValues = normalizeValues(values, warnings);
|
|
@@ -22226,7 +22406,7 @@ function blocksToPages(blocks) {
|
|
|
22226
22406
|
const pages = [];
|
|
22227
22407
|
for (let pageNumber = min; pageNumber <= max; pageNumber++) {
|
|
22228
22408
|
const pageBlocks = byPage.get(pageNumber);
|
|
22229
|
-
pages.push({ pageNumber, markdown: pageBlocks ?
|
|
22409
|
+
pages.push({ pageNumber, markdown: pageBlocks ? _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, pageBlocks) : "" });
|
|
22230
22410
|
}
|
|
22231
22411
|
return pages;
|
|
22232
22412
|
}
|
|
@@ -22678,7 +22858,7 @@ function needsGaejosikAssets(gongmun) {
|
|
|
22678
22858
|
}
|
|
22679
22859
|
function assertFiniteRange(name, value, min, max) {
|
|
22680
22860
|
if (!Number.isFinite(value) || value < min || value > max) {
|
|
22681
|
-
throw new (0,
|
|
22861
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`${name} must be a finite number between ${min} and ${max}`);
|
|
22682
22862
|
}
|
|
22683
22863
|
}
|
|
22684
22864
|
function validateGongmunOptions(opts) {
|
|
@@ -22693,10 +22873,10 @@ function validateGongmunOptions(opts) {
|
|
|
22693
22873
|
assertFiniteRange(`margins.${side}`, value, 0, 200);
|
|
22694
22874
|
}
|
|
22695
22875
|
if (opts.margins.left + opts.margins.right >= 210) {
|
|
22696
|
-
throw new (0,
|
|
22876
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("margins.left + margins.right must be less than 210");
|
|
22697
22877
|
}
|
|
22698
22878
|
if (opts.margins.top + opts.margins.bottom >= 297) {
|
|
22699
|
-
throw new (0,
|
|
22879
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("margins.top + margins.bottom must be less than 297");
|
|
22700
22880
|
}
|
|
22701
22881
|
}
|
|
22702
22882
|
if (opts.sizes) {
|
|
@@ -22705,7 +22885,7 @@ function validateGongmunOptions(opts) {
|
|
|
22705
22885
|
}
|
|
22706
22886
|
}
|
|
22707
22887
|
if (opts.approval && opts.approval.length > 6) {
|
|
22708
|
-
throw new (0,
|
|
22888
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("approval must contain at most 6 labels");
|
|
22709
22889
|
}
|
|
22710
22890
|
}
|
|
22711
22891
|
function incompatibleGongmunWarnings(opts) {
|
|
@@ -23267,7 +23447,7 @@ function parseInlineMarkdown(text) {
|
|
|
23267
23447
|
else spans.push(...emphasisSpans(m[0]));
|
|
23268
23448
|
} else {
|
|
23269
23449
|
const anchor = m[2] || m[3];
|
|
23270
|
-
const href = _nullishCoalesce(
|
|
23450
|
+
const href = _nullishCoalesce(_chunkJO3W54E5cjs.sanitizeHref.call(void 0, m[3].trim()), () => ( void 0));
|
|
23271
23451
|
const sub = emphasisSpans(anchor);
|
|
23272
23452
|
if (href) for (const s of sub) s.href = href;
|
|
23273
23453
|
spans.push(...sub);
|
|
@@ -23481,7 +23661,7 @@ function assertSequentialIds(rows, label, startId) {
|
|
|
23481
23661
|
const m = rows[i].match(/\bid="(\d+)"/);
|
|
23482
23662
|
const got = m ? Number(m[1]) : NaN;
|
|
23483
23663
|
if (got !== startId + i) {
|
|
23484
|
-
throw new (0,
|
|
23664
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
23485
23665
|
`\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)`
|
|
23486
23666
|
);
|
|
23487
23667
|
}
|
|
@@ -23572,7 +23752,7 @@ function buildCharProperties(theme, gongmun, ratioVariants = [], extraCharPrXmls
|
|
|
23572
23752
|
}
|
|
23573
23753
|
const expectedBase = charVariantBase(richAssets, !!gongmun);
|
|
23574
23754
|
if (rows.length !== expectedBase) {
|
|
23575
|
-
throw new (0,
|
|
23755
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
23576
23756
|
`\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`
|
|
23577
23757
|
);
|
|
23578
23758
|
}
|
|
@@ -24474,7 +24654,7 @@ function escapeGfm(text) {
|
|
|
24474
24654
|
}
|
|
24475
24655
|
var HWP_SHAPE_ALT_TEXT_RE = /^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?$/gm;
|
|
24476
24656
|
function sanitizeText(text) {
|
|
24477
|
-
let result =
|
|
24657
|
+
let result = _chunkFQTPFGVGcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
24478
24658
|
if (result.length <= 30 && result.includes(" ")) {
|
|
24479
24659
|
const tokens = result.split(" ");
|
|
24480
24660
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -24646,7 +24826,7 @@ function parseHtmlTable(raw) {
|
|
|
24646
24826
|
const cs = parseInt(_optionalChain([attrs, 'access', _318 => _318.match, 'call', _319 => _319(/colspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _320 => _320[1]]) || "1", 10);
|
|
24647
24827
|
const rs = parseInt(_optionalChain([attrs, 'access', _321 => _321.match, 'call', _322 => _322(/rowspan\s*=\s*["']?(\d+)/i), 'optionalAccess', _323 => _323[1]]) || "1", 10);
|
|
24648
24828
|
cellStart = m.index + m[0].length;
|
|
24649
|
-
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs,
|
|
24829
|
+
cellInfo = { colSpan: clampSpan(isNaN(cs) ? 1 : cs, _chunkFQTPFGVGcjs.MAX_COLS), rowSpan: clampSpan(isNaN(rs) ? 1 : rs, _chunkFQTPFGVGcjs.MAX_ROWS) };
|
|
24650
24830
|
} else if (cellStart >= 0 && cellInfo && currentRow) {
|
|
24651
24831
|
currentRow.push({ inner: raw.slice(cellStart, m.index), colSpan: cellInfo.colSpan, rowSpan: cellInfo.rowSpan });
|
|
24652
24832
|
cellStart = -1;
|
|
@@ -25083,7 +25263,7 @@ function probeImageSize(b) {
|
|
|
25083
25263
|
if (b[0] === 66 && b[1] === 77) {
|
|
25084
25264
|
return { w: dv.getUint32(18, true), h: Math.abs(dv.getInt32(22, true)) };
|
|
25085
25265
|
}
|
|
25086
|
-
} catch (
|
|
25266
|
+
} catch (e35) {
|
|
25087
25267
|
}
|
|
25088
25268
|
return null;
|
|
25089
25269
|
}
|
|
@@ -25135,7 +25315,7 @@ var ImageRegistry = (_class5 = class {
|
|
|
25135
25315
|
if (m) {
|
|
25136
25316
|
try {
|
|
25137
25317
|
bytes = new Uint8Array(Buffer.from(m[1].replace(/\s+/g, ""), "base64"));
|
|
25138
|
-
} catch (
|
|
25318
|
+
} catch (e36) {
|
|
25139
25319
|
}
|
|
25140
25320
|
}
|
|
25141
25321
|
}
|
|
@@ -25388,8 +25568,8 @@ function layoutHtmlRows(rows) {
|
|
|
25388
25568
|
let c = 0;
|
|
25389
25569
|
for (const cell2 of rows[r].cells) {
|
|
25390
25570
|
while (occupied.has(`${r},${c}`)) c++;
|
|
25391
|
-
const colSpan = clampSpan(cell2.colSpan,
|
|
25392
|
-
const rowSpan = clampSpan(cell2.rowSpan,
|
|
25571
|
+
const colSpan = clampSpan(cell2.colSpan, _chunkFQTPFGVGcjs.MAX_COLS);
|
|
25572
|
+
const rowSpan = clampSpan(cell2.rowSpan, _chunkFQTPFGVGcjs.MAX_ROWS);
|
|
25393
25573
|
placed.push({ r, c, colSpan, rowSpan, inner: cell2.inner, isHeader: rows[r].tag === "th" });
|
|
25394
25574
|
for (let dr = 0; dr < rowSpan; dr++) {
|
|
25395
25575
|
for (let dc = 0; dc < colSpan; dc++) occupied.add(`${r + dr},${c + dc}`);
|
|
@@ -26710,7 +26890,7 @@ function builtinTemplateDir() {
|
|
|
26710
26890
|
for (const c of candidates) {
|
|
26711
26891
|
if (_fs.existsSync.call(void 0, _path.join.call(void 0, c, BUILTIN_TEMPLATES[0].file))) return c;
|
|
26712
26892
|
}
|
|
26713
|
-
throw new (0,
|
|
26893
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uB0B4\uC7A5 templates \uB514\uB809\uD1A0\uB9AC\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 (\uD328\uD0A4\uC9C0 \uC124\uCE58\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4)");
|
|
26714
26894
|
}
|
|
26715
26895
|
function readBuiltinTemplate(t) {
|
|
26716
26896
|
const buf = _fs.readFileSync.call(void 0, _path.join.call(void 0, builtinTemplateDir(), t.file));
|
|
@@ -27053,12 +27233,12 @@ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
|
|
|
27053
27233
|
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>`;
|
|
27054
27234
|
}
|
|
27055
27235
|
async function placeSealHwpx(hwpxBuffer, ops) {
|
|
27056
|
-
if (ops.length === 0) throw new (0,
|
|
27236
|
+
if (ops.length === 0) throw new (0, _chunkJO3W54E5cjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
27057
27237
|
const u8 = new Uint8Array(hwpxBuffer);
|
|
27058
|
-
|
|
27238
|
+
_chunkJO3W54E5cjs.precheckZipSize.call(void 0, hwpxBuffer);
|
|
27059
27239
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
27060
27240
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort((a, b) => Number(_nullishCoalesce(_optionalChain([a, 'access', _436 => _436.match, 'call', _437 => _437(/(\d+)\.xml$/i), 'optionalAccess', _438 => _438[1]]), () => ( 0))) - Number(_nullishCoalesce(_optionalChain([b, 'access', _439 => _439.match, 'call', _440 => _440(/(\d+)\.xml$/i), 'optionalAccess', _441 => _441[1]]), () => ( 0))));
|
|
27061
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
27241
|
+
if (sectionPaths.length === 0) throw new (0, _chunkJO3W54E5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
27062
27242
|
const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
|
|
27063
27243
|
const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
|
|
27064
27244
|
const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
|
|
@@ -27099,11 +27279,11 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
27099
27279
|
const manifestItems = [];
|
|
27100
27280
|
const placed = [];
|
|
27101
27281
|
for (const op of ops) {
|
|
27102
|
-
if (!op.anchor) throw new (0,
|
|
27103
|
-
if (!op.image || op.image.length === 0) throw new (0,
|
|
27282
|
+
if (!op.anchor) throw new (0, _chunkJO3W54E5cjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
27283
|
+
if (!op.image || op.image.length === 0) throw new (0, _chunkJO3W54E5cjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
|
|
27104
27284
|
const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
|
|
27105
|
-
if (!MIME[ext]) throw new (0,
|
|
27106
|
-
if (!imageMagicMatches(op.image, ext)) throw new (0,
|
|
27285
|
+
if (!MIME[ext]) throw new (0, _chunkJO3W54E5cjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
|
|
27286
|
+
if (!imageMagicMatches(op.image, ext)) throw new (0, _chunkJO3W54E5cjs.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)`);
|
|
27107
27287
|
const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
|
|
27108
27288
|
let found = null;
|
|
27109
27289
|
let total = 0;
|
|
@@ -27136,7 +27316,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
27136
27316
|
}
|
|
27137
27317
|
}
|
|
27138
27318
|
}
|
|
27139
|
-
throw new (0,
|
|
27319
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
27140
27320
|
`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)})`
|
|
27141
27321
|
);
|
|
27142
27322
|
}
|
|
@@ -27144,7 +27324,7 @@ async function placeSealHwpx(hwpxBuffer, ops) {
|
|
|
27144
27324
|
const xml = sectionXmls[si];
|
|
27145
27325
|
const run = anchorRunInfo(xml, site.para, op.anchor);
|
|
27146
27326
|
if (!run) {
|
|
27147
|
-
throw new (0,
|
|
27327
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
|
|
27148
27328
|
}
|
|
27149
27329
|
const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _442 => _442.charPr, 'access', _443 => _443.get, 'call', _444 => _444(run.charPr), 'optionalAccess', _445 => _445.height]), () => ( 1e3));
|
|
27150
27330
|
const fontPt = charPrHeight / 100;
|
|
@@ -27422,7 +27602,7 @@ function pick(map, keys) {
|
|
|
27422
27602
|
return out;
|
|
27423
27603
|
}
|
|
27424
27604
|
async function hwpxToProfile(input) {
|
|
27425
|
-
const buf = input instanceof ArrayBuffer ? input :
|
|
27605
|
+
const buf = input instanceof ArrayBuffer ? input : _chunkJO3W54E5cjs.toArrayBuffer.call(void 0, input);
|
|
27426
27606
|
const zip = await _jszip2.default.loadAsync(buf);
|
|
27427
27607
|
const parser = createXmlParser();
|
|
27428
27608
|
const headerFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( _optionalChain([zip, 'access', _467 => _467.file, 'call', _468 => _468(/[Hh]eader\.xml$/), 'optionalAccess', _469 => _469[0]])));
|
|
@@ -28596,7 +28776,7 @@ async function resolveSectionEntryNames(zip) {
|
|
|
28596
28776
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
28597
28777
|
if (paths.length > 0) return paths;
|
|
28598
28778
|
}
|
|
28599
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(
|
|
28779
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkJO3W54E5cjs.compareSectionPaths);
|
|
28600
28780
|
}
|
|
28601
28781
|
function sectionPathsFromManifest(xml) {
|
|
28602
28782
|
const attr = (tag, name) => {
|
|
@@ -28606,7 +28786,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
28606
28786
|
const idToHref = /* @__PURE__ */ new Map();
|
|
28607
28787
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
28608
28788
|
const id = attr(m[1], "id");
|
|
28609
|
-
const href =
|
|
28789
|
+
const href = _chunkJO3W54E5cjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
28610
28790
|
if (id && href) idToHref.set(id, href);
|
|
28611
28791
|
}
|
|
28612
28792
|
const ordered = [];
|
|
@@ -28615,7 +28795,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
28615
28795
|
if (href) ordered.push(href);
|
|
28616
28796
|
}
|
|
28617
28797
|
if (ordered.length > 0) return ordered;
|
|
28618
|
-
return Array.from(idToHref.values()).sort(
|
|
28798
|
+
return Array.from(idToHref.values()).sort(_chunkJO3W54E5cjs.compareSectionPaths);
|
|
28619
28799
|
}
|
|
28620
28800
|
|
|
28621
28801
|
// src/roundtrip/patcher.ts
|
|
@@ -28632,7 +28812,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
28632
28812
|
let zip;
|
|
28633
28813
|
try {
|
|
28634
28814
|
zip = await _jszip2.default.loadAsync(original);
|
|
28635
|
-
} catch (
|
|
28815
|
+
} catch (e37) {
|
|
28636
28816
|
return { success: false, applied: 0, skipped, error: "ZIP \uB85C\uB4DC \uC2E4\uD328" };
|
|
28637
28817
|
}
|
|
28638
28818
|
const sectionPaths = await resolveSectionEntryNames(zip);
|
|
@@ -28726,9 +28906,9 @@ function buildOrigUnits(blocks) {
|
|
|
28726
28906
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
28727
28907
|
const next = blocks[i + 1];
|
|
28728
28908
|
if (_optionalChain([next, 'optionalAccess', _502 => _502.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
28729
|
-
chunk =
|
|
28909
|
+
chunk = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
28730
28910
|
} else {
|
|
28731
|
-
chunk =
|
|
28911
|
+
chunk = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, [block]);
|
|
28732
28912
|
}
|
|
28733
28913
|
if (chunk) {
|
|
28734
28914
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -29533,7 +29713,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
29533
29713
|
for (let i = 0; i < scans.length; i++) {
|
|
29534
29714
|
if (scans[i].repl.size === 0 && scans[i].inserts.size === 0) continue;
|
|
29535
29715
|
const newStream = serializeRecords(scans[i].records, scans[i].repl, scans[i].inserts);
|
|
29536
|
-
const content = compressed ?
|
|
29716
|
+
const content = compressed ? compressWithTail(newStream) : newStream;
|
|
29537
29717
|
out = replaceOleStream(out, sectionPaths[i], content);
|
|
29538
29718
|
}
|
|
29539
29719
|
data = new Uint8Array(out);
|
|
@@ -30016,6 +30196,26 @@ function rebuildCharShape(csData, coreStartUnit) {
|
|
|
30016
30196
|
});
|
|
30017
30197
|
return { buf, count: kept.length };
|
|
30018
30198
|
}
|
|
30199
|
+
var CRC_TABLE2 = (() => {
|
|
30200
|
+
const t = new Uint32Array(256);
|
|
30201
|
+
for (let n = 0; n < 256; n++) {
|
|
30202
|
+
let c = n;
|
|
30203
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
30204
|
+
t[n] = c >>> 0;
|
|
30205
|
+
}
|
|
30206
|
+
return t;
|
|
30207
|
+
})();
|
|
30208
|
+
function crc322(buf) {
|
|
30209
|
+
let c = 4294967295;
|
|
30210
|
+
for (let i = 0; i < buf.length; i++) c = CRC_TABLE2[(c ^ buf[i]) & 255] ^ c >>> 8;
|
|
30211
|
+
return (c ^ 4294967295) >>> 0;
|
|
30212
|
+
}
|
|
30213
|
+
function compressWithTail(raw) {
|
|
30214
|
+
const tail = Buffer.alloc(8);
|
|
30215
|
+
tail.writeUInt32LE(crc322(raw), 0);
|
|
30216
|
+
tail.writeUInt32LE(raw.length >>> 0, 4);
|
|
30217
|
+
return Buffer.concat([_zlib.deflateRawSync.call(void 0, raw), tail]);
|
|
30218
|
+
}
|
|
30019
30219
|
function synthesizeLineSegs(lineSegData, newRaw, startUnits) {
|
|
30020
30220
|
if (lineSegData.length < 36) return null;
|
|
30021
30221
|
const seg0 = lineSegData.subarray(0, 36);
|
|
@@ -30093,6 +30293,15 @@ function stageParaPatch(scan, para2, newPlain, skip) {
|
|
|
30093
30293
|
scan.repl.set(para2.lineSegIdx, synth.buf);
|
|
30094
30294
|
newHeader.writeUInt16LE(synth.count, 16);
|
|
30095
30295
|
}
|
|
30296
|
+
} else {
|
|
30297
|
+
const lineSegData = records[para2.lineSegIdx].data;
|
|
30298
|
+
const segCount = Math.floor(lineSegData.length / 36);
|
|
30299
|
+
let keep = 1;
|
|
30300
|
+
while (keep < segCount && lineSegData.readUInt32LE(keep * 36) < nChars) keep++;
|
|
30301
|
+
if (keep < segCount) {
|
|
30302
|
+
scan.repl.set(para2.lineSegIdx, Buffer.from(lineSegData.subarray(0, keep * 36)));
|
|
30303
|
+
newHeader.writeUInt16LE(keep, 16);
|
|
30304
|
+
}
|
|
30096
30305
|
}
|
|
30097
30306
|
scan.repl.set(para2.headerIdx, newHeader);
|
|
30098
30307
|
return 1;
|
|
@@ -30348,12 +30557,12 @@ function blocksToChunks(blocks, options) {
|
|
|
30348
30557
|
let run = null;
|
|
30349
30558
|
const flushRun = () => {
|
|
30350
30559
|
if (!run) return;
|
|
30351
|
-
push("text", run.breadcrumb,
|
|
30560
|
+
push("text", run.breadcrumb, _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, run.blocks), [run.start, run.end], run.page);
|
|
30352
30561
|
run = null;
|
|
30353
30562
|
};
|
|
30354
30563
|
for (let i = 0; i < blocks.length; i++) {
|
|
30355
30564
|
const block = blocks[i];
|
|
30356
|
-
const md2 =
|
|
30565
|
+
const md2 = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, [block]);
|
|
30357
30566
|
if (!md2) continue;
|
|
30358
30567
|
if (block.type === "heading") {
|
|
30359
30568
|
flushRun();
|
|
@@ -30822,14 +31031,14 @@ async function htmlToPdf(html, options) {
|
|
|
30822
31031
|
let puppeteer;
|
|
30823
31032
|
try {
|
|
30824
31033
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
30825
|
-
} catch (
|
|
30826
|
-
throw new (0,
|
|
31034
|
+
} catch (e38) {
|
|
31035
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
30827
31036
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
30828
31037
|
);
|
|
30829
31038
|
}
|
|
30830
31039
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
30831
31040
|
if (!executablePath) {
|
|
30832
|
-
throw new (0,
|
|
31041
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)(
|
|
30833
31042
|
"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."
|
|
30834
31043
|
);
|
|
30835
31044
|
}
|
|
@@ -30888,7 +31097,7 @@ async function markdownToPdf(markdown, options) {
|
|
|
30888
31097
|
return htmlToPdf(html, options);
|
|
30889
31098
|
}
|
|
30890
31099
|
async function blocksToPdf(blocks, options) {
|
|
30891
|
-
const markdown =
|
|
31100
|
+
const markdown = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, blocks);
|
|
30892
31101
|
return markdownToPdf(markdown, options);
|
|
30893
31102
|
}
|
|
30894
31103
|
|
|
@@ -31787,15 +31996,15 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode) {
|
|
|
31787
31996
|
async function renderHwpxToSvg(input, options) {
|
|
31788
31997
|
const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _599 => _599.maxImageBytes]), () => ( 40 * 1024 * 1024));
|
|
31789
31998
|
const ab = input instanceof Uint8Array ? input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength) : input;
|
|
31790
|
-
|
|
31999
|
+
_chunkJO3W54E5cjs.precheckZipSize.call(void 0, ab, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
31791
32000
|
let zip;
|
|
31792
32001
|
try {
|
|
31793
32002
|
zip = await _jszip2.default.loadAsync(input);
|
|
31794
|
-
} catch (
|
|
31795
|
-
throw new (0,
|
|
32003
|
+
} catch (e39) {
|
|
32004
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
|
|
31796
32005
|
}
|
|
31797
32006
|
const secFiles = zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name));
|
|
31798
|
-
if (secFiles.length === 0) throw new (0,
|
|
32007
|
+
if (secFiles.length === 0) throw new (0, _chunkJO3W54E5cjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
|
|
31799
32008
|
const warnings = [];
|
|
31800
32009
|
const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
|
|
31801
32010
|
const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
|
|
@@ -31803,7 +32012,7 @@ async function renderHwpxToSvg(input, options) {
|
|
|
31803
32012
|
const secXmls = [];
|
|
31804
32013
|
for (const f of secFiles) {
|
|
31805
32014
|
const xml = await f.async("string");
|
|
31806
|
-
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
32015
|
+
if (xml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkJO3W54E5cjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
|
|
31807
32016
|
secXmls.push(xml);
|
|
31808
32017
|
}
|
|
31809
32018
|
const binmap = /* @__PURE__ */ new Map();
|
|
@@ -31876,9 +32085,9 @@ async function renderHwpxToSvg(input, options) {
|
|
|
31876
32085
|
}
|
|
31877
32086
|
if (rendered.length === 0) {
|
|
31878
32087
|
if (noCacheSkipped) {
|
|
31879
|
-
throw new (0,
|
|
32088
|
+
throw new (0, _chunkJO3W54E5cjs.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)");
|
|
31880
32089
|
}
|
|
31881
|
-
throw new (0,
|
|
32090
|
+
throw new (0, _chunkJO3W54E5cjs.KordocError)("\uB80C\uB354\uD560 \uAD6C\uC5ED\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWPX\uAC00 \uC190\uC0C1\uB418\uC5C8\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4");
|
|
31882
32091
|
}
|
|
31883
32092
|
const GAP = 2400;
|
|
31884
32093
|
const clipDefs = [];
|
|
@@ -31914,13 +32123,13 @@ async function parse(input, options) {
|
|
|
31914
32123
|
if (typeof input === "string") {
|
|
31915
32124
|
try {
|
|
31916
32125
|
const buf = await _promises.readFile.call(void 0, input);
|
|
31917
|
-
buffer =
|
|
32126
|
+
buffer = _chunkJO3W54E5cjs.toArrayBuffer.call(void 0, buf);
|
|
31918
32127
|
} catch (err) {
|
|
31919
32128
|
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}`;
|
|
31920
32129
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
31921
32130
|
}
|
|
31922
32131
|
} else if (Buffer.isBuffer(input)) {
|
|
31923
|
-
buffer =
|
|
32132
|
+
buffer = _chunkJO3W54E5cjs.toArrayBuffer.call(void 0, input);
|
|
31924
32133
|
} else {
|
|
31925
32134
|
buffer = input;
|
|
31926
32135
|
}
|
|
@@ -31962,18 +32171,18 @@ async function dispatch(format, buffer, opts) {
|
|
|
31962
32171
|
}
|
|
31963
32172
|
async function parseImage(buffer, options) {
|
|
31964
32173
|
try {
|
|
31965
|
-
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-
|
|
32174
|
+
const { parseImageDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("./image-ocr-ZV4AP2I6.cjs")));
|
|
31966
32175
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
31967
32176
|
return {
|
|
31968
32177
|
success: true,
|
|
31969
32178
|
fileType: "image",
|
|
31970
|
-
markdown:
|
|
32179
|
+
markdown: _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, blocks),
|
|
31971
32180
|
blocks,
|
|
31972
32181
|
warnings: warnings.length ? warnings : void 0,
|
|
31973
32182
|
pageCount: 1
|
|
31974
32183
|
};
|
|
31975
32184
|
} catch (err) {
|
|
31976
|
-
return { success: false, fileType: "image", error:
|
|
32185
|
+
return { success: false, fileType: "image", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err) };
|
|
31977
32186
|
}
|
|
31978
32187
|
}
|
|
31979
32188
|
async function parseHwp3(buffer, options) {
|
|
@@ -31981,7 +32190,7 @@ async function parseHwp3(buffer, options) {
|
|
|
31981
32190
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
31982
32191
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _606 => _606.pageCount]) };
|
|
31983
32192
|
} catch (err) {
|
|
31984
|
-
return { success: false, fileType: "hwp3", error:
|
|
32193
|
+
return { success: false, fileType: "hwp3", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err) };
|
|
31985
32194
|
}
|
|
31986
32195
|
}
|
|
31987
32196
|
async function parseHwpx(buffer, options) {
|
|
@@ -31989,7 +32198,7 @@ async function parseHwpx(buffer, options) {
|
|
|
31989
32198
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
31990
32199
|
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _607 => _607.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _608 => _608.pageCount]) };
|
|
31991
32200
|
} catch (err) {
|
|
31992
|
-
return { success: false, fileType: "hwpx", error:
|
|
32201
|
+
return { success: false, fileType: "hwpx", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err) };
|
|
31993
32202
|
}
|
|
31994
32203
|
}
|
|
31995
32204
|
async function parseHwp(buffer, options) {
|
|
@@ -32010,20 +32219,20 @@ async function parseHwp(buffer, options) {
|
|
|
32010
32219
|
pageCount
|
|
32011
32220
|
};
|
|
32012
32221
|
}
|
|
32013
|
-
} catch (
|
|
32222
|
+
} catch (e40) {
|
|
32014
32223
|
}
|
|
32015
32224
|
}
|
|
32016
32225
|
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _610 => _610.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _611 => _611.pageCount]) };
|
|
32017
32226
|
} catch (err) {
|
|
32018
|
-
return { success: false, fileType: "hwp", error:
|
|
32227
|
+
return { success: false, fileType: "hwp", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err) };
|
|
32019
32228
|
}
|
|
32020
32229
|
}
|
|
32021
32230
|
async function parsePdf(buffer, options) {
|
|
32022
32231
|
let parsePdfDocument;
|
|
32023
32232
|
try {
|
|
32024
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
32233
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-WY5PY5V4.cjs")));
|
|
32025
32234
|
parsePdfDocument = mod.parsePdfDocument;
|
|
32026
|
-
} catch (
|
|
32235
|
+
} catch (e41) {
|
|
32027
32236
|
return {
|
|
32028
32237
|
success: false,
|
|
32029
32238
|
fileType: "pdf",
|
|
@@ -32036,7 +32245,7 @@ async function parsePdf(buffer, options) {
|
|
|
32036
32245
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary, images, pageCount: _optionalChain([metadata, 'optionalAccess', _612 => _612.pageCount]) };
|
|
32037
32246
|
} catch (err) {
|
|
32038
32247
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
32039
|
-
return { success: false, fileType: "pdf", error:
|
|
32248
|
+
return { success: false, fileType: "pdf", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err), isImageBased };
|
|
32040
32249
|
}
|
|
32041
32250
|
}
|
|
32042
32251
|
async function parseXlsx(buffer, options) {
|
|
@@ -32044,7 +32253,7 @@ async function parseXlsx(buffer, options) {
|
|
|
32044
32253
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
32045
32254
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _613 => _613.pageCount]) };
|
|
32046
32255
|
} catch (err) {
|
|
32047
|
-
return { success: false, fileType: "xlsx", error:
|
|
32256
|
+
return { success: false, fileType: "xlsx", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err) };
|
|
32048
32257
|
}
|
|
32049
32258
|
}
|
|
32050
32259
|
async function parseXls(buffer, options) {
|
|
@@ -32052,7 +32261,7 @@ async function parseXls(buffer, options) {
|
|
|
32052
32261
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
32053
32262
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _614 => _614.pageCount]) };
|
|
32054
32263
|
} catch (err) {
|
|
32055
|
-
return { success: false, fileType: "xls", error:
|
|
32264
|
+
return { success: false, fileType: "xls", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err) };
|
|
32056
32265
|
}
|
|
32057
32266
|
}
|
|
32058
32267
|
async function parseDocx(buffer, options) {
|
|
@@ -32060,7 +32269,7 @@ async function parseDocx(buffer, options) {
|
|
|
32060
32269
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
32061
32270
|
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _615 => _615.length]) ? images : void 0, pageCount: _optionalChain([metadata, 'optionalAccess', _616 => _616.pageCount]) };
|
|
32062
32271
|
} catch (err) {
|
|
32063
|
-
return { success: false, fileType: "docx", error:
|
|
32272
|
+
return { success: false, fileType: "docx", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err) };
|
|
32064
32273
|
}
|
|
32065
32274
|
}
|
|
32066
32275
|
async function parseHwpml(buffer, options) {
|
|
@@ -32068,16 +32277,16 @@ async function parseHwpml(buffer, options) {
|
|
|
32068
32277
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
32069
32278
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings, pageCount: _optionalChain([metadata, 'optionalAccess', _617 => _617.pageCount]) };
|
|
32070
32279
|
} catch (err) {
|
|
32071
|
-
return { success: false, fileType: "hwpml", error:
|
|
32280
|
+
return { success: false, fileType: "hwpml", error: _chunkJO3W54E5cjs.sanitizeError.call(void 0, err), code: _chunkJO3W54E5cjs.classifyError.call(void 0, err) };
|
|
32072
32281
|
}
|
|
32073
32282
|
}
|
|
32074
32283
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
32075
32284
|
let buffer;
|
|
32076
32285
|
if (typeof input === "string") {
|
|
32077
32286
|
const buf = await _promises.readFile.call(void 0, input);
|
|
32078
|
-
buffer =
|
|
32287
|
+
buffer = _chunkJO3W54E5cjs.toArrayBuffer.call(void 0, buf);
|
|
32079
32288
|
} else if (Buffer.isBuffer(input)) {
|
|
32080
|
-
buffer =
|
|
32289
|
+
buffer = _chunkJO3W54E5cjs.toArrayBuffer.call(void 0, input);
|
|
32081
32290
|
} else {
|
|
32082
32291
|
buffer = input;
|
|
32083
32292
|
}
|
|
@@ -32103,7 +32312,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
32103
32312
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
32104
32313
|
}
|
|
32105
32314
|
const fill = fillFormFields(parsed.blocks, values);
|
|
32106
|
-
const markdown =
|
|
32315
|
+
const markdown = _chunkFQTPFGVGcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
32107
32316
|
if (outputFormat === "hwpx") {
|
|
32108
32317
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
32109
32318
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -32186,5 +32395,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
32186
32395
|
|
|
32187
32396
|
|
|
32188
32397
|
|
|
32189
|
-
exports.BUILTIN_TEMPLATES = BUILTIN_TEMPLATES; exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION =
|
|
32398
|
+
exports.BUILTIN_TEMPLATES = BUILTIN_TEMPLATES; exports.DEFAULT_REDACT_RULES = DEFAULT_REDACT_RULES; exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkJO3W54E5cjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToChunks = blocksToChunks; exports.blocksToMarkdown = _chunkFQTPFGVGcjs.blocksToMarkdown; exports.blocksToPages = blocksToPages; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractClickHereFields = extractClickHereFields; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.gongmunLintWarnings = gongmunLintWarnings; exports.hwpxToProfile = hwpxToProfile; exports.incompatibleGongmunWarnings = incompatibleGongmunWarnings; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isKnownFont = isKnownFont; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.lintGongmunText = lintGongmunText; exports.lintMuncheText = lintMuncheText; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.muncheLintWarnings = muncheLintWarnings; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parseImage = parseImage; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.readBuiltinTemplate = readBuiltinTemplate; exports.readBuiltinTemplateSample = readBuiltinTemplateSample; exports.redactMarkdown = redactMarkdown; exports.redactText = redactText; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.resolveBuiltinTemplate = resolveBuiltinTemplate; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.unknownFontWarnings = unknownFontWarnings; exports.usesGaejosikMunche = usesGaejosikMunche; exports.validateHwpx = validateHwpx;
|
|
32190
32399
|
//# sourceMappingURL=index.cjs.map
|