kordoc 2.9.1 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +37 -0
  2. package/dist/-5BWAV4ZY.js +73 -0
  3. package/dist/-5BWAV4ZY.js.map +1 -0
  4. package/dist/chunk-MUOQXDZ4.cjs.map +1 -1
  5. package/dist/{chunk-FWAXCTSX.cjs → chunk-NBJB6TJB.cjs} +185 -16
  6. package/dist/chunk-NBJB6TJB.cjs.map +1 -0
  7. package/dist/{chunk-ODF24QXC.js → chunk-O5P6EG5L.js} +182 -13
  8. package/dist/chunk-O5P6EG5L.js.map +1 -0
  9. package/dist/{chunk-Z6TLTWYK.js → chunk-X3SCCO5Q.js} +182 -13
  10. package/dist/chunk-X3SCCO5Q.js.map +1 -0
  11. package/dist/{chunk-GQQNAYZA.js → chunk-X7VQVMXQ.js} +7453 -3997
  12. package/dist/chunk-X7VQVMXQ.js.map +1 -0
  13. package/dist/cli.js +44 -3
  14. package/dist/cli.js.map +1 -1
  15. package/dist/formula-XGG6ZP42.cjs.map +1 -1
  16. package/dist/index.cjs +4087 -829
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +87 -2
  19. package/dist/index.d.ts +87 -2
  20. package/dist/index.js +3867 -609
  21. package/dist/index.js.map +1 -1
  22. package/dist/mcp.js +3 -3
  23. package/dist/page-range-3C7UGGEK.cjs.map +1 -1
  24. package/dist/{parser-FJNQEW7K.js → parser-3N6FZSKU.js} +677 -85
  25. package/dist/parser-3N6FZSKU.js.map +1 -0
  26. package/dist/{parser-BTIPAEDZ.cjs → parser-5FZJVLQL.cjs} +689 -97
  27. package/dist/parser-5FZJVLQL.cjs.map +1 -0
  28. package/dist/{parser-BKYM3LKN.js → parser-LZH7ZELV.js} +677 -85
  29. package/dist/parser-LZH7ZELV.js.map +1 -0
  30. package/dist/provider-SNONEZNW.cjs.map +1 -1
  31. package/dist/{watch-SBLSWHL7.js → watch-4FMRS7QU.js} +3 -3
  32. package/package.json +1 -1
  33. package/dist/chunk-FWAXCTSX.cjs.map +0 -1
  34. package/dist/chunk-GQQNAYZA.js.map +0 -1
  35. package/dist/chunk-ODF24QXC.js.map +0 -1
  36. package/dist/chunk-Z6TLTWYK.js.map +0 -1
  37. package/dist/parser-BKYM3LKN.js.map +0 -1
  38. package/dist/parser-BTIPAEDZ.cjs.map +0 -1
  39. package/dist/parser-FJNQEW7K.js.map +0 -1
  40. /package/dist/{watch-SBLSWHL7.js.map → watch-4FMRS7QU.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -63,11 +63,21 @@ interface IRTable {
63
63
  cells: IRCell[][];
64
64
  /** 첫 행을 헤더로 렌더링할지 여부 (현재: rows > 1이면 true — 의미적 감지가 아닌 레이아웃 힌트) */
65
65
  hasHeader: boolean;
66
+ /** 표 캡션 (예: "표 1. 부서별 예산") — v3.0 */
67
+ caption?: string;
66
68
  }
67
69
  interface IRCell {
68
70
  text: string;
69
71
  colSpan: number;
70
72
  rowSpan: number;
73
+ /**
74
+ * 셀 내부 블록 콘텐츠 — v3.0.
75
+ * 중첩 표·이미지·다중 문단을 구조 그대로 보존한다.
76
+ * blocks가 있으면 text는 blocks의 평탄화 텍스트(하위 호환용)다.
77
+ */
78
+ blocks?: IRBlock[];
79
+ /** 제목 셀 여부 (HWP5 width_ref bit2 / HWPX header 속성) — v3.0 */
80
+ isHeader?: boolean;
71
81
  }
72
82
  /** 문서 메타데이터 — 각 포맷에서 추출 가능한 필드만 채워짐 */
73
83
  interface DocumentMetadata {
@@ -133,7 +143,7 @@ interface ParseWarning {
133
143
  /** 구조화된 경고 코드 */
134
144
  code: WarningCode;
135
145
  }
136
- type WarningCode = "SKIPPED_IMAGE" | "SKIPPED_OLE" | "TRUNCATED_TABLE" | "OCR_FALLBACK" | "UNSUPPORTED_ELEMENT" | "BROKEN_ZIP_RECOVERY" | "HIDDEN_TEXT_FILTERED" | "MALFORMED_XML" | "PARTIAL_PARSE" | "LENIENT_CFB_RECOVERY";
146
+ type WarningCode = "SKIPPED_IMAGE" | "SKIPPED_OLE" | "TRUNCATED_TABLE" | "OCR_FALLBACK" | "UNSUPPORTED_ELEMENT" | "BROKEN_ZIP_RECOVERY" | "HIDDEN_TEXT_FILTERED" | "MALFORMED_XML" | "PARTIAL_PARSE" | "LENIENT_CFB_RECOVERY" | "NEEDS_OCR";
137
147
  /** 문서 구조 (헤딩 트리) */
138
148
  interface OutlineItem {
139
149
  level: number;
@@ -236,6 +246,34 @@ interface DiffResult {
236
246
  };
237
247
  diffs: BlockDiff[];
238
248
  }
249
+ /** 패치 중 매핑 실패/미지원으로 건너뛴 항목 — silent 실패 금지 */
250
+ interface PatchSkip {
251
+ /** 건너뛴 사유 */
252
+ reason: string;
253
+ /** 원본 쪽 내용 요약 (최대 80자) */
254
+ before?: string;
255
+ /** 편집 쪽 내용 요약 (최대 80자) */
256
+ after?: string;
257
+ }
258
+ /** patchHwpx 옵션 */
259
+ interface PatchOptions {
260
+ /** 패치 후 재파싱 자동 검증 (기본 true) */
261
+ verify?: boolean;
262
+ }
263
+ /** patchHwpx 결과 */
264
+ interface PatchResult {
265
+ success: boolean;
266
+ /** 패치된 HWPX (success=true) */
267
+ data?: Uint8Array;
268
+ /** 적용된 변경 수 */
269
+ applied: number;
270
+ /** 매핑 실패 항목 (이유 포함) */
271
+ skipped: PatchSkip[];
272
+ /** 자동 검증: 패치본 재파싱 vs 편집 마크다운 diff */
273
+ verification?: DiffResult;
274
+ /** 실패 사유 (success=false) */
275
+ error?: string;
276
+ }
239
277
  interface FormField {
240
278
  label: string;
241
279
  value: string;
@@ -374,6 +412,53 @@ interface MarkdownToHwpxOptions {
374
412
  */
375
413
  declare function markdownToHwpx(markdown: string, options?: MarkdownToHwpxOptions): Promise<ArrayBuffer>;
376
414
 
415
+ /**
416
+ * HWPX 서식 보존 무손실 라운드트립 패치 — v3.0 킬러기능.
417
+ *
418
+ * parse()로 얻은 마크다운을 편집한 뒤 patchHwpx()에 넘기면, 원본 HWPX의
419
+ * ZIP/XML 구조를 그대로 두고 변경된 문단/셀의 텍스트만 in-place 치환한다.
420
+ * 스타일·이미지·표 구조·설정은 1바이트도 건드리지 않는다 (section XML 외
421
+ * ZIP 엔트리는 원본 바이트 그대로, 변경 문단도 run 구조·charPr 보존).
422
+ *
423
+ * 지원: 문단/헤딩 텍스트 수정, 표 셀 텍스트 수정 (GFM·HTML·1x1·1열 표).
424
+ * 미지원(graceful skip): 블록 추가/삭제/순서 변경, 표 구조 변경, 캡션·각주·
425
+ * 머리말/꼬리말·이미지 변경. skipped[]에 사유와 함께 보고된다.
426
+ */
427
+
428
+ /**
429
+ * 원본 HWPX와 편집된 마크다운으로 서식 보존 패치본을 만든다.
430
+ *
431
+ * @param original 원본 HWPX 바이트
432
+ * @param editedMarkdown parse(original).markdown을 편집한 마크다운
433
+ */
434
+ declare function patchHwpx(original: Uint8Array, editedMarkdown: string, options?: PatchOptions): Promise<PatchResult>;
435
+
436
+ /**
437
+ * HWP 5.x 바이너리 서식 보존 무손실 라운드트립 패치 — patchHwpx의 HWP5 대응.
438
+ *
439
+ * parse()로 얻은 마크다운을 편집한 뒤 patchHwp()에 넘기면, 원본 HWP의
440
+ * CFB/레코드 구조를 그대로 두고 변경된 문단/표 셀의 PARA_TEXT만 치환한다.
441
+ * 연쇄 갱신: PARA_HEADER nChars, CHAR_SHAPE 위치, LINE_SEG 재구성, 레코드
442
+ * 크기 재계산 → 섹션 스트림 재직렬화 → deflate 재압축 → CFB 재조립.
443
+ *
444
+ * 안전 게이트 (하나라도 깨지면 해당 수정은 graceful skip — 파일 무결성 우선):
445
+ * - 섹션 레코드 재직렬화가 원본과 바이트 동일해야 패치 허용
446
+ * - ctrlMask=0(순수 텍스트) + PARA_TEXT 1개 + 레코드 텍스트 재구성 일치 문단만 수정
447
+ * - 배포용/암호화/DRM 문서는 전체 거부
448
+ *
449
+ * 지원: 본문 문단/헤딩 텍스트 수정, GFM 표 셀 텍스트 수정 (좌표 기반).
450
+ * 미지원(graceful skip): 블록 추가/삭제, 표 구조 변경, HTML 표 셀, 캡션·각주·
451
+ * 머리말/꼬리말, 컨트롤(탭/개체/필드) 포함 문단. skipped[]에 사유 보고.
452
+ */
453
+
454
+ /**
455
+ * 원본 HWP 5.x와 편집된 마크다운으로 서식 보존 패치본을 만든다.
456
+ *
457
+ * @param original 원본 HWP 바이트 (OLE2/CFB)
458
+ * @param editedMarkdown parse(original).markdown을 편집한 마크다운
459
+ */
460
+ declare function patchHwp(original: Uint8Array, editedMarkdown: string, options?: PatchOptions): Promise<PatchResult>;
461
+
377
462
  /**
378
463
  * Print Renderer — Markdown / IRBlock[] → PDF (puppeteer-core 기반).
379
464
  *
@@ -519,4 +604,4 @@ interface FillFormOutput {
519
604
  */
520
605
  declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string, string>, outputFormat?: FillOutputFormat): Promise<FillFormOutput>;
521
606
 
522
- export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormResult, type HwpxFillResult, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PrintOptions, type PrintPreset, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, blocksToPdf, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, fillForm, fillFormFields, fillHwpx, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, renderHtml };
607
+ export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormResult, type HwpxFillResult, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, blocksToPdf, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, fillForm, fillFormFields, fillHwpx, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, renderHtml };
package/dist/index.d.ts CHANGED
@@ -63,11 +63,21 @@ interface IRTable {
63
63
  cells: IRCell[][];
64
64
  /** 첫 행을 헤더로 렌더링할지 여부 (현재: rows > 1이면 true — 의미적 감지가 아닌 레이아웃 힌트) */
65
65
  hasHeader: boolean;
66
+ /** 표 캡션 (예: "표 1. 부서별 예산") — v3.0 */
67
+ caption?: string;
66
68
  }
67
69
  interface IRCell {
68
70
  text: string;
69
71
  colSpan: number;
70
72
  rowSpan: number;
73
+ /**
74
+ * 셀 내부 블록 콘텐츠 — v3.0.
75
+ * 중첩 표·이미지·다중 문단을 구조 그대로 보존한다.
76
+ * blocks가 있으면 text는 blocks의 평탄화 텍스트(하위 호환용)다.
77
+ */
78
+ blocks?: IRBlock[];
79
+ /** 제목 셀 여부 (HWP5 width_ref bit2 / HWPX header 속성) — v3.0 */
80
+ isHeader?: boolean;
71
81
  }
72
82
  /** 문서 메타데이터 — 각 포맷에서 추출 가능한 필드만 채워짐 */
73
83
  interface DocumentMetadata {
@@ -133,7 +143,7 @@ interface ParseWarning {
133
143
  /** 구조화된 경고 코드 */
134
144
  code: WarningCode;
135
145
  }
136
- type WarningCode = "SKIPPED_IMAGE" | "SKIPPED_OLE" | "TRUNCATED_TABLE" | "OCR_FALLBACK" | "UNSUPPORTED_ELEMENT" | "BROKEN_ZIP_RECOVERY" | "HIDDEN_TEXT_FILTERED" | "MALFORMED_XML" | "PARTIAL_PARSE" | "LENIENT_CFB_RECOVERY";
146
+ type WarningCode = "SKIPPED_IMAGE" | "SKIPPED_OLE" | "TRUNCATED_TABLE" | "OCR_FALLBACK" | "UNSUPPORTED_ELEMENT" | "BROKEN_ZIP_RECOVERY" | "HIDDEN_TEXT_FILTERED" | "MALFORMED_XML" | "PARTIAL_PARSE" | "LENIENT_CFB_RECOVERY" | "NEEDS_OCR";
137
147
  /** 문서 구조 (헤딩 트리) */
138
148
  interface OutlineItem {
139
149
  level: number;
@@ -236,6 +246,34 @@ interface DiffResult {
236
246
  };
237
247
  diffs: BlockDiff[];
238
248
  }
249
+ /** 패치 중 매핑 실패/미지원으로 건너뛴 항목 — silent 실패 금지 */
250
+ interface PatchSkip {
251
+ /** 건너뛴 사유 */
252
+ reason: string;
253
+ /** 원본 쪽 내용 요약 (최대 80자) */
254
+ before?: string;
255
+ /** 편집 쪽 내용 요약 (최대 80자) */
256
+ after?: string;
257
+ }
258
+ /** patchHwpx 옵션 */
259
+ interface PatchOptions {
260
+ /** 패치 후 재파싱 자동 검증 (기본 true) */
261
+ verify?: boolean;
262
+ }
263
+ /** patchHwpx 결과 */
264
+ interface PatchResult {
265
+ success: boolean;
266
+ /** 패치된 HWPX (success=true) */
267
+ data?: Uint8Array;
268
+ /** 적용된 변경 수 */
269
+ applied: number;
270
+ /** 매핑 실패 항목 (이유 포함) */
271
+ skipped: PatchSkip[];
272
+ /** 자동 검증: 패치본 재파싱 vs 편집 마크다운 diff */
273
+ verification?: DiffResult;
274
+ /** 실패 사유 (success=false) */
275
+ error?: string;
276
+ }
239
277
  interface FormField {
240
278
  label: string;
241
279
  value: string;
@@ -374,6 +412,53 @@ interface MarkdownToHwpxOptions {
374
412
  */
375
413
  declare function markdownToHwpx(markdown: string, options?: MarkdownToHwpxOptions): Promise<ArrayBuffer>;
376
414
 
415
+ /**
416
+ * HWPX 서식 보존 무손실 라운드트립 패치 — v3.0 킬러기능.
417
+ *
418
+ * parse()로 얻은 마크다운을 편집한 뒤 patchHwpx()에 넘기면, 원본 HWPX의
419
+ * ZIP/XML 구조를 그대로 두고 변경된 문단/셀의 텍스트만 in-place 치환한다.
420
+ * 스타일·이미지·표 구조·설정은 1바이트도 건드리지 않는다 (section XML 외
421
+ * ZIP 엔트리는 원본 바이트 그대로, 변경 문단도 run 구조·charPr 보존).
422
+ *
423
+ * 지원: 문단/헤딩 텍스트 수정, 표 셀 텍스트 수정 (GFM·HTML·1x1·1열 표).
424
+ * 미지원(graceful skip): 블록 추가/삭제/순서 변경, 표 구조 변경, 캡션·각주·
425
+ * 머리말/꼬리말·이미지 변경. skipped[]에 사유와 함께 보고된다.
426
+ */
427
+
428
+ /**
429
+ * 원본 HWPX와 편집된 마크다운으로 서식 보존 패치본을 만든다.
430
+ *
431
+ * @param original 원본 HWPX 바이트
432
+ * @param editedMarkdown parse(original).markdown을 편집한 마크다운
433
+ */
434
+ declare function patchHwpx(original: Uint8Array, editedMarkdown: string, options?: PatchOptions): Promise<PatchResult>;
435
+
436
+ /**
437
+ * HWP 5.x 바이너리 서식 보존 무손실 라운드트립 패치 — patchHwpx의 HWP5 대응.
438
+ *
439
+ * parse()로 얻은 마크다운을 편집한 뒤 patchHwp()에 넘기면, 원본 HWP의
440
+ * CFB/레코드 구조를 그대로 두고 변경된 문단/표 셀의 PARA_TEXT만 치환한다.
441
+ * 연쇄 갱신: PARA_HEADER nChars, CHAR_SHAPE 위치, LINE_SEG 재구성, 레코드
442
+ * 크기 재계산 → 섹션 스트림 재직렬화 → deflate 재압축 → CFB 재조립.
443
+ *
444
+ * 안전 게이트 (하나라도 깨지면 해당 수정은 graceful skip — 파일 무결성 우선):
445
+ * - 섹션 레코드 재직렬화가 원본과 바이트 동일해야 패치 허용
446
+ * - ctrlMask=0(순수 텍스트) + PARA_TEXT 1개 + 레코드 텍스트 재구성 일치 문단만 수정
447
+ * - 배포용/암호화/DRM 문서는 전체 거부
448
+ *
449
+ * 지원: 본문 문단/헤딩 텍스트 수정, GFM 표 셀 텍스트 수정 (좌표 기반).
450
+ * 미지원(graceful skip): 블록 추가/삭제, 표 구조 변경, HTML 표 셀, 캡션·각주·
451
+ * 머리말/꼬리말, 컨트롤(탭/개체/필드) 포함 문단. skipped[]에 사유 보고.
452
+ */
453
+
454
+ /**
455
+ * 원본 HWP 5.x와 편집된 마크다운으로 서식 보존 패치본을 만든다.
456
+ *
457
+ * @param original 원본 HWP 바이트 (OLE2/CFB)
458
+ * @param editedMarkdown parse(original).markdown을 편집한 마크다운
459
+ */
460
+ declare function patchHwp(original: Uint8Array, editedMarkdown: string, options?: PatchOptions): Promise<PatchResult>;
461
+
377
462
  /**
378
463
  * Print Renderer — Markdown / IRBlock[] → PDF (puppeteer-core 기반).
379
464
  *
@@ -519,4 +604,4 @@ interface FillFormOutput {
519
604
  */
520
605
  declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string, string>, outputFormat?: FillOutputFormat): Promise<FillFormOutput>;
521
606
 
522
- export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormResult, type HwpxFillResult, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PrintOptions, type PrintPreset, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, blocksToPdf, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, fillForm, fillFormFields, fillHwpx, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, renderHtml };
607
+ export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormResult, type HwpxFillResult, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, blocksToPdf, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, fillForm, fillFormFields, fillHwpx, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, renderHtml };