kordoc 1.6.0 → 1.7.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/dist/index.d.cts CHANGED
@@ -3,6 +3,10 @@ interface CellContext {
3
3
  text: string;
4
4
  colSpan: number;
5
5
  rowSpan: number;
6
+ /** HWP5 셀 열 주소 (0-based) — 병합 테이블 배치용 */
7
+ colAddr?: number;
8
+ /** HWP5 셀 행 주소 (0-based) — 병합 테이블 배치용 */
9
+ rowAddr?: number;
6
10
  }
7
11
  /** 블록 타입 — v2.0에서 heading, list, image, separator 추가 */
8
12
  type IRBlockType = "paragraph" | "table" | "heading" | "list" | "image" | "separator";
@@ -26,6 +30,17 @@ interface IRBlock {
26
30
  href?: string;
27
31
  /** 각주/미주 텍스트 (인라인 삽입용) */
28
32
  footnoteText?: string;
33
+ /** 이미지 데이터 (type="image"일 때) */
34
+ imageData?: ImageData;
35
+ }
36
+ /** 추출된 이미지 바이너리 데이터 */
37
+ interface ImageData {
38
+ /** 이미지 바이너리 */
39
+ data: Uint8Array;
40
+ /** MIME 타입 (image/png, image/jpeg, image/gif, image/bmp, image/wmf, image/emf) */
41
+ mimeType: string;
42
+ /** 원본 파일명 (있는 경우) */
43
+ filename?: string;
29
44
  }
30
45
  /** 바운딩 박스 — PDF 포인트 단위 (72pt = 1인치) */
31
46
  interface BoundingBox {
@@ -86,6 +101,10 @@ interface ParseOptions {
86
101
  pages?: number[] | string;
87
102
  /** 이미지 기반 PDF용 OCR 프로바이더 (선택) */
88
103
  ocr?: OcrProvider;
104
+ /** 진행률 콜백 — current: 현재 페이지/섹션, total: 전체 수 */
105
+ onProgress?: (current: number, total: number) => void;
106
+ /** PDF 머리글/바닥글 자동 제거 */
107
+ removeHeaderFooter?: boolean;
89
108
  }
90
109
  /** 파싱 중 스킵/실패한 요소 보고 */
91
110
  interface ParseWarning {
@@ -96,7 +115,7 @@ interface ParseWarning {
96
115
  /** 구조화된 경고 코드 */
97
116
  code: WarningCode;
98
117
  }
99
- type WarningCode = "SKIPPED_IMAGE" | "SKIPPED_OLE" | "TRUNCATED_TABLE" | "OCR_FALLBACK" | "UNSUPPORTED_ELEMENT" | "BROKEN_ZIP_RECOVERY" | "HIDDEN_TEXT_FILTERED";
118
+ type WarningCode = "SKIPPED_IMAGE" | "SKIPPED_OLE" | "TRUNCATED_TABLE" | "OCR_FALLBACK" | "UNSUPPORTED_ELEMENT" | "BROKEN_ZIP_RECOVERY" | "HIDDEN_TEXT_FILTERED" | "MALFORMED_XML" | "PARTIAL_PARSE";
100
119
  /** 문서 구조 (헤딩 트리) */
101
120
  interface OutlineItem {
102
121
  level: number;
@@ -125,6 +144,17 @@ interface ParseSuccess extends ParseResultBase {
125
144
  outline?: OutlineItem[];
126
145
  /** 파싱 중 발생한 경고 — v2.0 */
127
146
  warnings?: ParseWarning[];
147
+ /** 추출된 이미지 목록 — 마크다운에서 파일명으로 참조됨 */
148
+ images?: ExtractedImage[];
149
+ }
150
+ /** 추출된 이미지 — ParseSuccess.images에 포함 */
151
+ interface ExtractedImage {
152
+ /** 마크다운에서 참조되는 파일명 (예: image_001.png) */
153
+ filename: string;
154
+ /** 이미지 바이너리 */
155
+ data: Uint8Array;
156
+ /** MIME 타입 */
157
+ mimeType: string;
128
158
  }
129
159
  interface ParseFailure extends ParseResultBase {
130
160
  success: false;
@@ -250,15 +280,13 @@ declare const VERSION: string;
250
280
  * @example
251
281
  * ```ts
252
282
  * import { parse } from "kordoc"
283
+ * // 파일 경로로 파싱
284
+ * const result = await parse("document.hwp")
285
+ * // 또는 Buffer로 파싱
253
286
  * const result = await parse(buffer)
254
- * if (result.success) {
255
- * console.log(result.markdown) // 마크다운 텍스트
256
- * console.log(result.blocks) // IRBlock[] 구조화 데이터
257
- * console.log(result.metadata) // 문서 메타데이터
258
- * }
259
287
  * ```
260
288
  */
261
- declare function parse(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
289
+ declare function parse(input: string | ArrayBuffer | Buffer, options?: ParseOptions): Promise<ParseResult>;
262
290
  /** HWPX 파일을 Markdown으로 변환 */
263
291
  declare function parseHwpx(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
264
292
  /** HWP 5.x 바이너리 파일을 Markdown으로 변환 */
@@ -266,4 +294,4 @@ declare function parseHwp(buffer: ArrayBuffer, options?: ParseOptions): Promise<
266
294
  /** PDF 파일에서 텍스트를 추출하여 Markdown으로 변환 */
267
295
  declare function parsePdf(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
268
296
 
269
- export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type InlineStyle, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, markdownToHwpx, parse, parseHwp, parseHwpx, parsePdf };
297
+ export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, markdownToHwpx, parse, parseHwp, parseHwpx, parsePdf };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,10 @@ interface CellContext {
3
3
  text: string;
4
4
  colSpan: number;
5
5
  rowSpan: number;
6
+ /** HWP5 셀 열 주소 (0-based) — 병합 테이블 배치용 */
7
+ colAddr?: number;
8
+ /** HWP5 셀 행 주소 (0-based) — 병합 테이블 배치용 */
9
+ rowAddr?: number;
6
10
  }
7
11
  /** 블록 타입 — v2.0에서 heading, list, image, separator 추가 */
8
12
  type IRBlockType = "paragraph" | "table" | "heading" | "list" | "image" | "separator";
@@ -26,6 +30,17 @@ interface IRBlock {
26
30
  href?: string;
27
31
  /** 각주/미주 텍스트 (인라인 삽입용) */
28
32
  footnoteText?: string;
33
+ /** 이미지 데이터 (type="image"일 때) */
34
+ imageData?: ImageData;
35
+ }
36
+ /** 추출된 이미지 바이너리 데이터 */
37
+ interface ImageData {
38
+ /** 이미지 바이너리 */
39
+ data: Uint8Array;
40
+ /** MIME 타입 (image/png, image/jpeg, image/gif, image/bmp, image/wmf, image/emf) */
41
+ mimeType: string;
42
+ /** 원본 파일명 (있는 경우) */
43
+ filename?: string;
29
44
  }
30
45
  /** 바운딩 박스 — PDF 포인트 단위 (72pt = 1인치) */
31
46
  interface BoundingBox {
@@ -86,6 +101,10 @@ interface ParseOptions {
86
101
  pages?: number[] | string;
87
102
  /** 이미지 기반 PDF용 OCR 프로바이더 (선택) */
88
103
  ocr?: OcrProvider;
104
+ /** 진행률 콜백 — current: 현재 페이지/섹션, total: 전체 수 */
105
+ onProgress?: (current: number, total: number) => void;
106
+ /** PDF 머리글/바닥글 자동 제거 */
107
+ removeHeaderFooter?: boolean;
89
108
  }
90
109
  /** 파싱 중 스킵/실패한 요소 보고 */
91
110
  interface ParseWarning {
@@ -96,7 +115,7 @@ interface ParseWarning {
96
115
  /** 구조화된 경고 코드 */
97
116
  code: WarningCode;
98
117
  }
99
- type WarningCode = "SKIPPED_IMAGE" | "SKIPPED_OLE" | "TRUNCATED_TABLE" | "OCR_FALLBACK" | "UNSUPPORTED_ELEMENT" | "BROKEN_ZIP_RECOVERY" | "HIDDEN_TEXT_FILTERED";
118
+ type WarningCode = "SKIPPED_IMAGE" | "SKIPPED_OLE" | "TRUNCATED_TABLE" | "OCR_FALLBACK" | "UNSUPPORTED_ELEMENT" | "BROKEN_ZIP_RECOVERY" | "HIDDEN_TEXT_FILTERED" | "MALFORMED_XML" | "PARTIAL_PARSE";
100
119
  /** 문서 구조 (헤딩 트리) */
101
120
  interface OutlineItem {
102
121
  level: number;
@@ -125,6 +144,17 @@ interface ParseSuccess extends ParseResultBase {
125
144
  outline?: OutlineItem[];
126
145
  /** 파싱 중 발생한 경고 — v2.0 */
127
146
  warnings?: ParseWarning[];
147
+ /** 추출된 이미지 목록 — 마크다운에서 파일명으로 참조됨 */
148
+ images?: ExtractedImage[];
149
+ }
150
+ /** 추출된 이미지 — ParseSuccess.images에 포함 */
151
+ interface ExtractedImage {
152
+ /** 마크다운에서 참조되는 파일명 (예: image_001.png) */
153
+ filename: string;
154
+ /** 이미지 바이너리 */
155
+ data: Uint8Array;
156
+ /** MIME 타입 */
157
+ mimeType: string;
128
158
  }
129
159
  interface ParseFailure extends ParseResultBase {
130
160
  success: false;
@@ -250,15 +280,13 @@ declare const VERSION: string;
250
280
  * @example
251
281
  * ```ts
252
282
  * import { parse } from "kordoc"
283
+ * // 파일 경로로 파싱
284
+ * const result = await parse("document.hwp")
285
+ * // 또는 Buffer로 파싱
253
286
  * const result = await parse(buffer)
254
- * if (result.success) {
255
- * console.log(result.markdown) // 마크다운 텍스트
256
- * console.log(result.blocks) // IRBlock[] 구조화 데이터
257
- * console.log(result.metadata) // 문서 메타데이터
258
- * }
259
287
  * ```
260
288
  */
261
- declare function parse(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
289
+ declare function parse(input: string | ArrayBuffer | Buffer, options?: ParseOptions): Promise<ParseResult>;
262
290
  /** HWPX 파일을 Markdown으로 변환 */
263
291
  declare function parseHwpx(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
264
292
  /** HWP 5.x 바이너리 파일을 Markdown으로 변환 */
@@ -266,4 +294,4 @@ declare function parseHwp(buffer: ArrayBuffer, options?: ParseOptions): Promise<
266
294
  /** PDF 파일에서 텍스트를 추출하여 Markdown으로 변환 */
267
295
  declare function parsePdf(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
268
296
 
269
- export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type InlineStyle, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, markdownToHwpx, parse, parseHwp, parseHwpx, parsePdf };
297
+ export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, markdownToHwpx, parse, parseHwp, parseHwpx, parsePdf };