@clazic/kordoc 2.6.0 → 2.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
@@ -251,6 +251,61 @@ interface WatchOptions {
251
251
  pages?: string;
252
252
  silent?: boolean;
253
253
  }
254
+ /** 포맷 감지 단계 이벤트 */
255
+ interface ConvertDetectEvent {
256
+ type: "detect";
257
+ stage: "reading" | "format_detected" | "size_check";
258
+ message: string;
259
+ fileSize?: number;
260
+ format?: "hwp" | "hwpx";
261
+ }
262
+ /** 환경 검증 단계 이벤트 */
263
+ interface ConvertValidateEvent {
264
+ type: "validate";
265
+ stage: "soffice_check" | "soffice_found" | "soffice_not_found";
266
+ message: string;
267
+ sofficePath?: string;
268
+ }
269
+ /** 설치 단계 이벤트 */
270
+ interface ConvertInstallEvent {
271
+ type: "install";
272
+ stage: "install_start" | "download_progress" | "extract_progress" | "install_complete" | "install_failed";
273
+ message: string;
274
+ percent?: number;
275
+ downloadedBytes?: number;
276
+ totalBytes?: number;
277
+ installedPath?: string;
278
+ error?: string;
279
+ }
280
+ /** 변환 진행 이벤트 */
281
+ interface ConvertProgressEvent {
282
+ type: "convert";
283
+ stage: "convert_start" | "convert_progress" | "convert_done";
284
+ message: string;
285
+ percent: number;
286
+ }
287
+ /** 변환 완료 이벤트 */
288
+ interface ConvertCompleteEvent {
289
+ type: "complete";
290
+ stage: "success";
291
+ message: string;
292
+ result: {
293
+ sourceFormat: "hwp" | "hwpx";
294
+ pdfSize: number;
295
+ pageCount?: number;
296
+ };
297
+ }
298
+ /** 에러 이벤트 */
299
+ interface ConvertErrorEvent {
300
+ type: "error";
301
+ stage: "detect" | "validate" | "install" | "convert";
302
+ message: string;
303
+ code: ErrorCode;
304
+ recoverable: boolean;
305
+ suggestion?: string;
306
+ }
307
+ /** convertToPdf()에서 발생하는 모든 이벤트 */
308
+ type ConvertEvent = ConvertDetectEvent | ConvertValidateEvent | ConvertInstallEvent | ConvertProgressEvent | ConvertCompleteEvent | ConvertErrorEvent;
254
309
  /** HWP/HWPX → PDF 변환 옵션 */
255
310
  interface ConvertToPdfOptions {
256
311
  /** 페이지 범위 ("1-3,5,7-10") — LibreOffice 필터가 지원하는 경우 */
@@ -259,8 +314,15 @@ interface ConvertToPdfOptions {
259
314
  quality?: "low" | "medium" | "high";
260
315
  /** 타임아웃 (ms, 기본 60000) */
261
316
  timeoutMs?: number;
262
- /** 진행 상황 콜백 */
317
+ /**
318
+ * 진행 상황 콜백 (deprecated — onEvent 사용 권장)
319
+ * @deprecated onEvent를 사용하세요
320
+ */
263
321
  onProgress?: (percent: number, stage: string) => void;
322
+ /**
323
+ * 이벤트 콜백 — 모든 진행 상황을 이벤트로 전달
324
+ */
325
+ onEvent?: (event: ConvertEvent) => void;
264
326
  /** LibreOffice 자동 설치 허용 (기본 true) */
265
327
  autoInstallLibreOffice?: boolean;
266
328
  /** LibreOffice 바이너리 직접 지정 */
@@ -362,16 +424,10 @@ declare function markdownToXlsx(markdown: string, options?: MarkdownToXlsxOption
362
424
  declare function convertToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
363
425
  /**
364
426
  * HWP 5.x 파일을 PDF로 변환 (포맷 감지 생략).
365
- * 내부적으로 convertToPdf와 동일하지만 강제로 "hwp"로 처리.
366
- *
367
- * @deprecated convertToPdf()에 Buffer를 직접 전달하는 것과 동일
368
427
  */
369
428
  declare function convertHwpToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
370
429
  /**
371
430
  * HWPX 파일을 PDF로 변환 (포맷 감지 생략).
372
- * 내부적으로 convertToPdf와 동일하지만 강제로 "hwpx"로 처리.
373
- *
374
- * @deprecated convertToPdf()에 Buffer를 직접 전달하는 것과 동일
375
431
  */
376
432
  declare function convertHwpxToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
377
433
 
@@ -493,12 +549,14 @@ interface UnifiedOcrProgressEvent {
493
549
  pageNumber?: number;
494
550
  workerCount?: number;
495
551
  }
552
+ /** unified-ocr에서 onEvent로 전달되는 보조 이벤트 — LibreOffice 설치/검증/에러 */
553
+ type UnifiedOcrAuxEvent = ConvertInstallEvent | ConvertValidateEvent | ConvertErrorEvent;
496
554
  interface UnifiedOcrOptions {
497
555
  workspaceDir?: string;
498
556
  outputPath?: string;
499
557
  dpi?: number;
500
558
  baseUrl?: string;
501
- onEvent?: (event: UnifiedOcrProgressEvent) => void;
559
+ onEvent?: (event: UnifiedOcrProgressEvent | UnifiedOcrAuxEvent) => void;
502
560
  modelCandidates?: string[];
503
561
  modelMaxTokens?: Record<string, number>;
504
562
  stageWeights?: Partial<Record<UnifiedStage, number>>;
@@ -508,6 +566,10 @@ interface UnifiedOcrOptions {
508
566
  logger?: Logger;
509
567
  runId?: string;
510
568
  concurrencyPerKey?: number;
569
+ /** LibreOffice 자동 설치 허용 (기본 false) — convert 단계에서 install/validate 이벤트가 onEvent로 전달됨 */
570
+ autoInstallLibreOffice?: boolean;
571
+ /** LibreOffice 바이너리 직접 지정 (선택) — 지정 시 자동 탐색/설치 건너뜀 */
572
+ sofficePath?: string;
511
573
  }
512
574
  interface UnifiedOcrResult {
513
575
  outputPath: string;
@@ -546,4 +608,4 @@ declare function parseXlsx(buffer: ArrayBuffer, options?: ParseOptions, zip?: JS
546
608
  /** DOCX 파일을 Markdown으로 변환 */
547
609
  declare function parseDocx(buffer: ArrayBuffer, options?: ParseOptions, zip?: JSZip): Promise<ParseResult>;
548
610
 
549
- export { type AcquireResult, AllKeysCoolingDownError, type ApiKeyRotationOptions, ApiKeyRotationPool, type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type ConvertToPdfFailure, type ConvertToPdfOptions, type ConvertToPdfResult, type ConvertToPdfSuccess, 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 KeyHealthSnapshot, type MarkdownToXlsxOptions, type OcrMode, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type StructuredOcrResult, type UnifiedOcrOptions, type UnifiedOcrProgressEvent, type UnifiedOcrResult, type UnifiedStage, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, convertHwpToPdf, convertHwpxToPdf, convertToPdf, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToXlsx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx, runUnifiedOcrPipeline };
611
+ export { type AcquireResult, AllKeysCoolingDownError, type ApiKeyRotationOptions, ApiKeyRotationPool, type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type ConvertErrorEvent, type ConvertInstallEvent, type ConvertToPdfFailure, type ConvertToPdfOptions, type ConvertToPdfResult, type ConvertToPdfSuccess, type ConvertValidateEvent, 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 KeyHealthSnapshot, type MarkdownToXlsxOptions, type OcrMode, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type StructuredOcrResult, type UnifiedOcrAuxEvent, type UnifiedOcrOptions, type UnifiedOcrProgressEvent, type UnifiedOcrResult, type UnifiedStage, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, convertHwpToPdf, convertHwpxToPdf, convertToPdf, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToXlsx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx, runUnifiedOcrPipeline };
package/dist/index.d.ts CHANGED
@@ -251,6 +251,61 @@ interface WatchOptions {
251
251
  pages?: string;
252
252
  silent?: boolean;
253
253
  }
254
+ /** 포맷 감지 단계 이벤트 */
255
+ interface ConvertDetectEvent {
256
+ type: "detect";
257
+ stage: "reading" | "format_detected" | "size_check";
258
+ message: string;
259
+ fileSize?: number;
260
+ format?: "hwp" | "hwpx";
261
+ }
262
+ /** 환경 검증 단계 이벤트 */
263
+ interface ConvertValidateEvent {
264
+ type: "validate";
265
+ stage: "soffice_check" | "soffice_found" | "soffice_not_found";
266
+ message: string;
267
+ sofficePath?: string;
268
+ }
269
+ /** 설치 단계 이벤트 */
270
+ interface ConvertInstallEvent {
271
+ type: "install";
272
+ stage: "install_start" | "download_progress" | "extract_progress" | "install_complete" | "install_failed";
273
+ message: string;
274
+ percent?: number;
275
+ downloadedBytes?: number;
276
+ totalBytes?: number;
277
+ installedPath?: string;
278
+ error?: string;
279
+ }
280
+ /** 변환 진행 이벤트 */
281
+ interface ConvertProgressEvent {
282
+ type: "convert";
283
+ stage: "convert_start" | "convert_progress" | "convert_done";
284
+ message: string;
285
+ percent: number;
286
+ }
287
+ /** 변환 완료 이벤트 */
288
+ interface ConvertCompleteEvent {
289
+ type: "complete";
290
+ stage: "success";
291
+ message: string;
292
+ result: {
293
+ sourceFormat: "hwp" | "hwpx";
294
+ pdfSize: number;
295
+ pageCount?: number;
296
+ };
297
+ }
298
+ /** 에러 이벤트 */
299
+ interface ConvertErrorEvent {
300
+ type: "error";
301
+ stage: "detect" | "validate" | "install" | "convert";
302
+ message: string;
303
+ code: ErrorCode;
304
+ recoverable: boolean;
305
+ suggestion?: string;
306
+ }
307
+ /** convertToPdf()에서 발생하는 모든 이벤트 */
308
+ type ConvertEvent = ConvertDetectEvent | ConvertValidateEvent | ConvertInstallEvent | ConvertProgressEvent | ConvertCompleteEvent | ConvertErrorEvent;
254
309
  /** HWP/HWPX → PDF 변환 옵션 */
255
310
  interface ConvertToPdfOptions {
256
311
  /** 페이지 범위 ("1-3,5,7-10") — LibreOffice 필터가 지원하는 경우 */
@@ -259,8 +314,15 @@ interface ConvertToPdfOptions {
259
314
  quality?: "low" | "medium" | "high";
260
315
  /** 타임아웃 (ms, 기본 60000) */
261
316
  timeoutMs?: number;
262
- /** 진행 상황 콜백 */
317
+ /**
318
+ * 진행 상황 콜백 (deprecated — onEvent 사용 권장)
319
+ * @deprecated onEvent를 사용하세요
320
+ */
263
321
  onProgress?: (percent: number, stage: string) => void;
322
+ /**
323
+ * 이벤트 콜백 — 모든 진행 상황을 이벤트로 전달
324
+ */
325
+ onEvent?: (event: ConvertEvent) => void;
264
326
  /** LibreOffice 자동 설치 허용 (기본 true) */
265
327
  autoInstallLibreOffice?: boolean;
266
328
  /** LibreOffice 바이너리 직접 지정 */
@@ -362,16 +424,10 @@ declare function markdownToXlsx(markdown: string, options?: MarkdownToXlsxOption
362
424
  declare function convertToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
363
425
  /**
364
426
  * HWP 5.x 파일을 PDF로 변환 (포맷 감지 생략).
365
- * 내부적으로 convertToPdf와 동일하지만 강제로 "hwp"로 처리.
366
- *
367
- * @deprecated convertToPdf()에 Buffer를 직접 전달하는 것과 동일
368
427
  */
369
428
  declare function convertHwpToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
370
429
  /**
371
430
  * HWPX 파일을 PDF로 변환 (포맷 감지 생략).
372
- * 내부적으로 convertToPdf와 동일하지만 강제로 "hwpx"로 처리.
373
- *
374
- * @deprecated convertToPdf()에 Buffer를 직접 전달하는 것과 동일
375
431
  */
376
432
  declare function convertHwpxToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
377
433
 
@@ -493,12 +549,14 @@ interface UnifiedOcrProgressEvent {
493
549
  pageNumber?: number;
494
550
  workerCount?: number;
495
551
  }
552
+ /** unified-ocr에서 onEvent로 전달되는 보조 이벤트 — LibreOffice 설치/검증/에러 */
553
+ type UnifiedOcrAuxEvent = ConvertInstallEvent | ConvertValidateEvent | ConvertErrorEvent;
496
554
  interface UnifiedOcrOptions {
497
555
  workspaceDir?: string;
498
556
  outputPath?: string;
499
557
  dpi?: number;
500
558
  baseUrl?: string;
501
- onEvent?: (event: UnifiedOcrProgressEvent) => void;
559
+ onEvent?: (event: UnifiedOcrProgressEvent | UnifiedOcrAuxEvent) => void;
502
560
  modelCandidates?: string[];
503
561
  modelMaxTokens?: Record<string, number>;
504
562
  stageWeights?: Partial<Record<UnifiedStage, number>>;
@@ -508,6 +566,10 @@ interface UnifiedOcrOptions {
508
566
  logger?: Logger;
509
567
  runId?: string;
510
568
  concurrencyPerKey?: number;
569
+ /** LibreOffice 자동 설치 허용 (기본 false) — convert 단계에서 install/validate 이벤트가 onEvent로 전달됨 */
570
+ autoInstallLibreOffice?: boolean;
571
+ /** LibreOffice 바이너리 직접 지정 (선택) — 지정 시 자동 탐색/설치 건너뜀 */
572
+ sofficePath?: string;
511
573
  }
512
574
  interface UnifiedOcrResult {
513
575
  outputPath: string;
@@ -546,4 +608,4 @@ declare function parseXlsx(buffer: ArrayBuffer, options?: ParseOptions, zip?: JS
546
608
  /** DOCX 파일을 Markdown으로 변환 */
547
609
  declare function parseDocx(buffer: ArrayBuffer, options?: ParseOptions, zip?: JSZip): Promise<ParseResult>;
548
610
 
549
- export { type AcquireResult, AllKeysCoolingDownError, type ApiKeyRotationOptions, ApiKeyRotationPool, type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type ConvertToPdfFailure, type ConvertToPdfOptions, type ConvertToPdfResult, type ConvertToPdfSuccess, 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 KeyHealthSnapshot, type MarkdownToXlsxOptions, type OcrMode, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type StructuredOcrResult, type UnifiedOcrOptions, type UnifiedOcrProgressEvent, type UnifiedOcrResult, type UnifiedStage, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, convertHwpToPdf, convertHwpxToPdf, convertToPdf, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToXlsx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx, runUnifiedOcrPipeline };
611
+ export { type AcquireResult, AllKeysCoolingDownError, type ApiKeyRotationOptions, ApiKeyRotationPool, type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type ConvertErrorEvent, type ConvertInstallEvent, type ConvertToPdfFailure, type ConvertToPdfOptions, type ConvertToPdfResult, type ConvertToPdfSuccess, type ConvertValidateEvent, 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 KeyHealthSnapshot, type MarkdownToXlsxOptions, type OcrMode, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type StructuredOcrResult, type UnifiedOcrAuxEvent, type UnifiedOcrOptions, type UnifiedOcrProgressEvent, type UnifiedOcrResult, type UnifiedStage, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, convertHwpToPdf, convertHwpxToPdf, convertToPdf, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToXlsx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx, runUnifiedOcrPipeline };