hwpx2f 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +124 -2
- package/THIRD_PARTY_NOTICES.md +75 -0
- package/dist/cli.js +76 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +32 -0
- package/dist/lib/chunk-36PRCVPO.js +131 -0
- package/dist/lib/chunk-45BAITEX.js +9749 -0
- package/dist/lib/chunk-4NRZ6MWV.js +133 -0
- package/dist/lib/chunk-6CFXTS7A.js +11971 -0
- package/dist/lib/chunk-6CPCDYOD.js +104 -0
- package/dist/lib/chunk-B6MTS4XP.js +313 -0
- package/dist/lib/chunk-BX24E7EG.js +1427 -0
- package/dist/lib/chunk-C64I2SU4.js +82 -0
- package/dist/lib/chunk-CEKQASS3.js +258 -0
- package/dist/lib/chunk-CMWTKXM2.js +204 -0
- package/dist/lib/chunk-E6KSYRHG.js +2189 -0
- package/dist/lib/chunk-IZDWVMTV.js +28786 -0
- package/dist/lib/chunk-JK6YR5NT.js +4276 -0
- package/dist/lib/chunk-O6FSHPNE.js +111 -0
- package/dist/lib/chunk-OYXOOP2U.js +199 -0
- package/dist/lib/chunk-PM4KBWF4.js +49 -0
- package/dist/lib/chunk-R5F3GHLO.js +290 -0
- package/dist/lib/chunk-R76DWHJR.js +1596 -0
- package/dist/lib/chunk-RFS3RTSR.js +6876 -0
- package/dist/lib/chunk-RYJRNK5Z.js +47 -0
- package/dist/lib/chunk-UOXPGSFH.js +43 -0
- package/dist/lib/chunk-UZH4UBMX.js +44 -0
- package/dist/lib/chunk-VZTE4GKI.js +52 -0
- package/dist/lib/chunk-WEOKEO6L.js +35291 -0
- package/dist/lib/detect-4XZNNYZA-O7IPA4XQ.js +32 -0
- package/dist/lib/dist-HVSOXNCJ.js +263 -0
- package/dist/lib/formula-LC62GV4D-K3VFC5GV.js +1173 -0
- package/dist/lib/generator-KYTTL4OS-TRAQ66QE.js +14 -0
- package/dist/lib/hancom-EM62ZVDM-WZKVI7XB.js +91 -0
- package/dist/lib/image-ocr-ZUZQXLYS-U66LBMRA.js +293 -0
- package/dist/lib/page-images-VCIFZAXK-KJLWQDRH.js +95 -0
- package/dist/lib/page-range-7R3JU6SQ-MDDQRZVK.js +10 -0
- package/dist/lib/parser-JQNH5QMM-HFFI4HYK.js +4310 -0
- package/dist/lib/pdf-ocr-C3MBR6J2-J3UGJKWT.js +46 -0
- package/dist/lib/to-hwpx-JUT2SOTT-MOPPK6OW.js +17 -0
- package/dist/notices/core-util-is/LICENSE +19 -0
- package/dist/notices/entities/LICENSE +11 -0
- package/dist/notices/immediate/LICENSE.txt +20 -0
- package/dist/notices/inherits/LICENSE +16 -0
- package/dist/notices/jszip/LICENSE.markdown +651 -0
- package/dist/notices/kordoc/LICENSE +21 -0
- package/dist/notices/kordoc/NOTICE +376 -0
- package/dist/notices/kordoc/THIRD_PARTY/apache-2.0.LICENSE +201 -0
- package/dist/notices/kordoc/THIRD_PARTY/claw-hwp.LICENSE +21 -0
- package/dist/notices/kordoc/THIRD_PARTY/hayro-pdf.txt +361 -0
- package/dist/notices/kordoc/THIRD_PARTY/hml-equation-parser.LICENSE +201 -0
- package/dist/notices/kordoc/THIRD_PARTY/hml-equation-parser.txt +35 -0
- package/dist/notices/kordoc/THIRD_PARTY/korean-report-hwpx.LICENSE +21 -0
- package/dist/notices/kordoc/THIRD_PARTY/memchr.LICENSE +21 -0
- package/dist/notices/kordoc/THIRD_PARTY/opendataloader-pdf.txt +32 -0
- package/dist/notices/kordoc/THIRD_PARTY/pix2text.txt +17 -0
- package/dist/notices/kordoc/THIRD_PARTY/quick-xml.LICENSE +23 -0
- package/dist/notices/kordoc/THIRD_PARTY/rhwp-forms.txt +35 -0
- package/dist/notices/lie/license.md +7 -0
- package/dist/notices/linkify-it/LICENSE +22 -0
- package/dist/notices/markdown-it/LICENSE +22 -0
- package/dist/notices/mdurl/LICENSE +45 -0
- package/dist/notices/pako/LICENSE +21 -0
- package/dist/notices/process-nextick-args/license.md +19 -0
- package/dist/notices/punycode.js/LICENSE-MIT.txt +20 -0
- package/dist/notices/readable-stream/LICENSE +47 -0
- package/dist/notices/safe-buffer/LICENSE +21 -0
- package/dist/notices/setimmediate/LICENSE.txt +20 -0
- package/dist/notices/string_decoder/LICENSE +48 -0
- package/dist/notices/uc.micro/LICENSE.txt +20 -0
- package/dist/notices/util-deprecate/LICENSE +24 -0
- package/package.json +66 -4
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { createRequire as __hwpx2fRequire } from 'node:module'; const require = __hwpx2fRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
parseLenientCfb
|
|
4
|
+
} from "./chunk-CMWTKXM2.js";
|
|
5
|
+
import {
|
|
6
|
+
require_lib
|
|
7
|
+
} from "./chunk-45BAITEX.js";
|
|
8
|
+
import {
|
|
9
|
+
__toESM
|
|
10
|
+
} from "./chunk-RYJRNK5Z.js";
|
|
11
|
+
|
|
12
|
+
// node_modules/kordoc/dist/chunk-5TS72XT2.js
|
|
13
|
+
var import_jszip = __toESM(require_lib(), 1);
|
|
14
|
+
function magicBytes(buffer) {
|
|
15
|
+
return new Uint8Array(buffer, 0, Math.min(4, buffer.byteLength));
|
|
16
|
+
}
|
|
17
|
+
function isZipFile(buffer) {
|
|
18
|
+
const b = magicBytes(buffer);
|
|
19
|
+
return b[0] === 80 && b[1] === 75 && b[2] === 3 && b[3] === 4;
|
|
20
|
+
}
|
|
21
|
+
function isHwpxFile(buffer) {
|
|
22
|
+
return isZipFile(buffer);
|
|
23
|
+
}
|
|
24
|
+
function isOldHwpFile(buffer) {
|
|
25
|
+
const b = magicBytes(buffer);
|
|
26
|
+
return b[0] === 208 && b[1] === 207 && b[2] === 17 && b[3] === 224;
|
|
27
|
+
}
|
|
28
|
+
var HWP3_PREFIX = new TextEncoder().encode("HWP Document File V3.00");
|
|
29
|
+
function isHwp3File(buffer) {
|
|
30
|
+
if (buffer.byteLength < HWP3_PREFIX.length) return false;
|
|
31
|
+
const head = new Uint8Array(buffer, 0, HWP3_PREFIX.length);
|
|
32
|
+
for (let i = 0; i < HWP3_PREFIX.length; i++) {
|
|
33
|
+
if (head[i] !== HWP3_PREFIX[i]) return false;
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
function isPdfFile(buffer) {
|
|
38
|
+
const b = magicBytes(buffer);
|
|
39
|
+
return b[0] === 37 && b[1] === 80 && b[2] === 68 && b[3] === 70;
|
|
40
|
+
}
|
|
41
|
+
var BMP_HEADER_SIZES = /* @__PURE__ */ new Set([12, 40, 52, 56, 64, 108, 124]);
|
|
42
|
+
function imageFormat(buffer) {
|
|
43
|
+
if (buffer.byteLength < 12) return null;
|
|
44
|
+
const b = new Uint8Array(buffer, 0, Math.min(128, buffer.byteLength));
|
|
45
|
+
const at = (o, s) => o + s.length <= b.length && [...s].every((c, i) => b[o + i] === c.charCodeAt(0));
|
|
46
|
+
if (b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71) return "png";
|
|
47
|
+
if (b[0] === 255 && b[1] === 216 && b[2] === 255) return "jpeg";
|
|
48
|
+
if (at(0, "RIFF") && at(8, "WEBP")) return "webp";
|
|
49
|
+
if (at(0, "II*\0") || at(0, "MM\0*") || at(0, "II+\0") || at(0, "MM\0+")) return "tiff";
|
|
50
|
+
if (at(0, "GIF87a") || at(0, "GIF89a")) return "gif";
|
|
51
|
+
if (at(0, "BM") && buffer.byteLength >= 26 && BMP_HEADER_SIZES.has(new DataView(buffer).getUint32(14, true))) return "bmp";
|
|
52
|
+
if (b[0] === 177 && b[1] === 104 && b[2] === 222 && b[3] === 58) return "dcx";
|
|
53
|
+
if (b.length >= 128 && b[0] === 10 && [0, 2, 3, 4, 5].includes(b[1]) && b[2] === 1 && [1, 2, 4, 8].includes(b[3]) && b[64] === 0 && [1, 2, 3, 4].includes(b[65])) return "pcx";
|
|
54
|
+
if (at(4, "ftyp")) {
|
|
55
|
+
const size = Math.min(new DataView(buffer).getUint32(0), b.length);
|
|
56
|
+
const brands = [];
|
|
57
|
+
for (let o = 8; o + 4 <= size; o += o === 8 ? 8 : 4) brands.push(String.fromCharCode(...b.subarray(o, o + 4)));
|
|
58
|
+
if (brands.some((x) => x === "avif" || x === "avis")) return "avif";
|
|
59
|
+
if (brands.some((x) => /^(?:hei[cxms]|hev[cxms]|mif1|msf1)$/.test(x))) return "heic";
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function isImageFile(buffer) {
|
|
64
|
+
return imageFormat(buffer) !== null;
|
|
65
|
+
}
|
|
66
|
+
function unsupportedImageName(buffer) {
|
|
67
|
+
const b = new Uint8Array(buffer, 0, Math.min(48, buffer.byteLength));
|
|
68
|
+
const at = (o, s) => o + s.length <= b.length && [...s].every((c, i) => b[o + i] === c.charCodeAt(0));
|
|
69
|
+
if (at(0, "\0\0\0\fjP \r\n\x87\n") || b[0] === 255 && b[1] === 79 && b[2] === 255 && b[3] === 81) return "JPEG 2000";
|
|
70
|
+
if (at(0, "\0\0\0\fJXL \r\n\x87\n") || b[0] === 255 && b[1] === 10) return "JPEG XL";
|
|
71
|
+
if (at(0, "8BPS")) return "PSD";
|
|
72
|
+
if (b[0] === 215 && b[1] === 205 && b[2] === 198 && b[3] === 154) return "WMF";
|
|
73
|
+
if (b[0] === 1 && b[1] === 0 && b[2] === 0 && b[3] === 0 && at(40, " EMF")) return "EMF";
|
|
74
|
+
if (at(0, "%!PS") || b[0] === 197 && b[1] === 208 && b[2] === 211 && b[3] === 198) return "PostScript\xB7EPS";
|
|
75
|
+
if (at(0, "AT&TFORM")) return "DjVu";
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function isHwpmlFile(buffer) {
|
|
79
|
+
const bytes = new Uint8Array(buffer, 0, Math.min(512, buffer.byteLength));
|
|
80
|
+
const head = new TextDecoder("utf-8", { fatal: false }).decode(bytes).replace(/^\uFEFF/, "");
|
|
81
|
+
return head.trimStart().startsWith("<?xml") && head.includes("<HWPML");
|
|
82
|
+
}
|
|
83
|
+
function detectFormat(buffer) {
|
|
84
|
+
if (buffer.byteLength < 4) return "unknown";
|
|
85
|
+
if (isHwp3File(buffer)) return "hwp3";
|
|
86
|
+
if (isZipFile(buffer)) return "hwpx";
|
|
87
|
+
if (isOldHwpFile(buffer)) return "hwp";
|
|
88
|
+
if (isPdfFile(buffer)) return "pdf";
|
|
89
|
+
if (isHwpmlFile(buffer)) return "hwpml";
|
|
90
|
+
if (isImageFile(buffer)) return "image";
|
|
91
|
+
return "unknown";
|
|
92
|
+
}
|
|
93
|
+
function detectOle2Format(buffer) {
|
|
94
|
+
try {
|
|
95
|
+
const cfb = parseLenientCfb(Buffer.from(buffer));
|
|
96
|
+
const names = cfb.entries().map((e) => e.name);
|
|
97
|
+
if (names.includes("Workbook") || names.includes("Book")) return "xls";
|
|
98
|
+
if (names.includes("FileHeader")) return "hwp";
|
|
99
|
+
if (names.some((n) => n === "DocInfo" || n.startsWith("Section"))) return "hwp";
|
|
100
|
+
return "unknown";
|
|
101
|
+
} catch {
|
|
102
|
+
return "unknown";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function detectZipFormat(buffer) {
|
|
106
|
+
try {
|
|
107
|
+
const zip = await import_jszip.default.loadAsync(buffer);
|
|
108
|
+
if (zip.file("xl/workbook.xml")) return "xlsx";
|
|
109
|
+
if (zip.file("word/document.xml")) return "docx";
|
|
110
|
+
if (zip.file("ppt/presentation.xml")) return "pptx";
|
|
111
|
+
if (zip.file("Contents/content.hpf") || zip.file("mimetype")) return "hwpx";
|
|
112
|
+
const hasSection = Object.keys(zip.files).some((f) => f.startsWith("Contents/"));
|
|
113
|
+
if (hasSection) return "hwpx";
|
|
114
|
+
return "unknown";
|
|
115
|
+
} catch {
|
|
116
|
+
return "unknown";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
isZipFile,
|
|
122
|
+
isHwpxFile,
|
|
123
|
+
isOldHwpFile,
|
|
124
|
+
isHwp3File,
|
|
125
|
+
isPdfFile,
|
|
126
|
+
imageFormat,
|
|
127
|
+
isImageFile,
|
|
128
|
+
unsupportedImageName,
|
|
129
|
+
isHwpmlFile,
|
|
130
|
+
detectFormat,
|
|
131
|
+
detectOle2Format,
|
|
132
|
+
detectZipFormat
|
|
133
|
+
};
|