kordoc 4.25.19 → 4.25.21
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 +3 -3
- package/dist/{chunk-CZFY7JGT.js → chunk-24LB25LZ.js} +2 -2
- package/dist/{chunk-HKO6HWYM.js → chunk-3AYNFK6J.js} +2 -2
- package/dist/{chunk-74QGGXVH.js → chunk-5MDRUEHP.js} +14 -4
- package/dist/chunk-5MDRUEHP.js.map +1 -0
- package/dist/{chunk-PCOKS4ZE.js → chunk-5PEMTYTM.js} +37 -10
- package/dist/chunk-5PEMTYTM.js.map +7 -0
- package/dist/{chunk-LQGZ3PBZ.js → chunk-5ULHNZ3P.js} +3 -3
- package/dist/{chunk-EFBIMFVT.js → chunk-6I3X54AQ.js} +2 -2
- package/dist/{chunk-HH5IOQTP.js → chunk-6MCJHRSM.js} +2 -2
- package/dist/{chunk-NCO7BAS7.js → chunk-COJYQKGH.js} +6 -4
- package/dist/{chunk-NCO7BAS7.js.map → chunk-COJYQKGH.js.map} +2 -2
- package/dist/{chunk-TPPL3OVT.js → chunk-DHXKCDAU.js} +50 -6
- package/dist/chunk-DHXKCDAU.js.map +7 -0
- package/dist/{chunk-UTLVAA7X.js → chunk-DZOA5N5W.js} +2 -2
- package/dist/{chunk-HCHWG3HO.js → chunk-FDSFXE2L.js} +3 -3
- package/dist/{chunk-ZCDTZZ3C.js → chunk-GJORKM42.js} +2 -2
- package/dist/{chunk-VOK3R4WW.js → chunk-HQILGS2O.js} +2 -2
- package/dist/{chunk-FCWPQZYU.js → chunk-KW4JO5CV.js} +3 -3
- package/dist/{chunk-EI4PBZW2.js → chunk-LSUTK3DH.js} +2 -2
- package/dist/{chunk-FZ7XCPHO.js → chunk-MWCJYIJC.js} +20 -20
- package/dist/{chunk-6YQ2LARO.js → chunk-PFNZQ3XI.js} +2 -2
- package/dist/{chunk-XCD6WLTU.js → chunk-PVOLFVXE.js} +3 -3
- package/dist/{chunk-FNMJ2DK4.js → chunk-QNJ2LMUO.js} +8 -8
- package/dist/{chunk-VVR2ZSFZ.js → chunk-QOCUFTT4.js} +4 -4
- package/dist/{chunk-3DX4GW75.js → chunk-S553BW45.js} +6 -6
- package/dist/{chunk-IUD535LX.js → chunk-TI6S3KZF.js} +2 -2
- package/dist/{chunk-RECWLRRB.js → chunk-TYJSNW4Z.js} +55 -46
- package/dist/chunk-TYJSNW4Z.js.map +7 -0
- package/dist/{chunk-LEWJRIVZ.js → chunk-W5AHXAUP.js} +6 -6
- package/dist/{chunk-TW6WYJD6.js → chunk-XUBBFY3H.js} +6 -6
- package/dist/{chunk-LXPFTU3C.js → chunk-ZCMMU34Z.js} +2 -2
- package/dist/{chunk-IVNUMREN.js → chunk-ZO4P735U.js} +2 -2
- package/dist/chunks-XX7RHVQF.js +10 -0
- package/dist/cli.js +38 -38
- package/dist/{formula-U2RXOOE4.js → formula-HMKT4BZL.js} +4 -4
- package/dist/{generator-K6I6IYOH.js → generator-HOY4SZ26.js} +7 -7
- package/dist/{hancom-ARDTLWD5.js → hancom-QWJBWOOE.js} +2 -2
- package/dist/{image-ocr-RDWOEEQ2.js → image-ocr-P5AIZNT3.js} +12 -12
- package/dist/index.cjs +211 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -22
- package/dist/mcp.js +34 -34
- package/dist/memo-Q7772VJD.js +15 -0
- package/dist/{model-bundle-A6C5PVSS.js → model-bundle-5CXCIZHZ.js} +5 -5
- package/dist/{models-KTY3IZU2.js → models-PS4L7NLP.js} +5 -5
- package/dist/{page-images-PVXQYU7Z.js → page-images-QW7IUTUB.js} +3 -3
- package/dist/{parse-worker-v2-E4T4427H.js → parse-worker-v2-PRH6KVKP.js} +24 -24
- package/dist/{parser-3F66AQAA.js → parser-OQIR5ZMI.js} +97 -58
- package/dist/{parser-3F66AQAA.js.map → parser-OQIR5ZMI.js.map} +2 -2
- package/dist/{pdf-ocr-C6DYPI2Q.js → pdf-ocr-ZH4JAUTR.js} +9 -9
- package/dist/{profile-io-LZ5YPCIW.js → profile-io-JFRAM2VE.js} +3 -3
- package/dist/{rasterize-K2VVPUGE.js → rasterize-JJOMUTYX.js} +3 -3
- package/dist/{redact-doc-A3M2YEXE.js → redact-doc-A7TW4MNF.js} +23 -23
- package/dist/{render-HS2YWRJE.js → render-VAOMAQV2.js} +11 -11
- package/dist/{rewrite-fallback-3YVRWPRM.js → rewrite-fallback-7PR7V3AZ.js} +13 -13
- package/dist/seal-RZZNRJFL.js +14 -0
- package/dist/{setup-YK2SCVLP.js → setup-6DXZJQCT.js} +3 -3
- package/dist/to-hwpx-A56R6H27.js +20 -0
- package/dist/visual-25RY7EFI.js +42 -0
- package/dist/{watch-CQX4TSVQ.js → watch-7W6CKGX7.js} +23 -23
- package/package.json +1 -1
- package/dist/chunk-74QGGXVH.js.map +0 -1
- package/dist/chunk-PCOKS4ZE.js.map +0 -7
- package/dist/chunk-RECWLRRB.js.map +0 -7
- package/dist/chunk-TPPL3OVT.js.map +0 -7
- package/dist/chunks-IDWF6IOZ.js +0 -10
- package/dist/memo-RND3VIEW.js +0 -15
- package/dist/seal-DYLPFEC6.js +0 -14
- package/dist/to-hwpx-XNBAWVNY.js +0 -20
- package/dist/visual-SQORG4IC.js +0 -42
- /package/dist/{chunk-CZFY7JGT.js.map → chunk-24LB25LZ.js.map} +0 -0
- /package/dist/{chunk-HKO6HWYM.js.map → chunk-3AYNFK6J.js.map} +0 -0
- /package/dist/{chunk-LQGZ3PBZ.js.map → chunk-5ULHNZ3P.js.map} +0 -0
- /package/dist/{chunk-EFBIMFVT.js.map → chunk-6I3X54AQ.js.map} +0 -0
- /package/dist/{chunk-HH5IOQTP.js.map → chunk-6MCJHRSM.js.map} +0 -0
- /package/dist/{chunk-UTLVAA7X.js.map → chunk-DZOA5N5W.js.map} +0 -0
- /package/dist/{chunk-HCHWG3HO.js.map → chunk-FDSFXE2L.js.map} +0 -0
- /package/dist/{chunk-ZCDTZZ3C.js.map → chunk-GJORKM42.js.map} +0 -0
- /package/dist/{chunk-VOK3R4WW.js.map → chunk-HQILGS2O.js.map} +0 -0
- /package/dist/{chunk-FCWPQZYU.js.map → chunk-KW4JO5CV.js.map} +0 -0
- /package/dist/{chunk-EI4PBZW2.js.map → chunk-LSUTK3DH.js.map} +0 -0
- /package/dist/{chunk-FZ7XCPHO.js.map → chunk-MWCJYIJC.js.map} +0 -0
- /package/dist/{chunk-6YQ2LARO.js.map → chunk-PFNZQ3XI.js.map} +0 -0
- /package/dist/{chunk-XCD6WLTU.js.map → chunk-PVOLFVXE.js.map} +0 -0
- /package/dist/{chunk-FNMJ2DK4.js.map → chunk-QNJ2LMUO.js.map} +0 -0
- /package/dist/{chunk-VVR2ZSFZ.js.map → chunk-QOCUFTT4.js.map} +0 -0
- /package/dist/{chunk-3DX4GW75.js.map → chunk-S553BW45.js.map} +0 -0
- /package/dist/{chunk-IUD535LX.js.map → chunk-TI6S3KZF.js.map} +0 -0
- /package/dist/{chunk-LEWJRIVZ.js.map → chunk-W5AHXAUP.js.map} +0 -0
- /package/dist/{chunk-TW6WYJD6.js.map → chunk-XUBBFY3H.js.map} +0 -0
- /package/dist/{chunk-LXPFTU3C.js.map → chunk-ZCMMU34Z.js.map} +0 -0
- /package/dist/{chunk-IVNUMREN.js.map → chunk-ZO4P735U.js.map} +0 -0
- /package/dist/{chunks-IDWF6IOZ.js.map → chunks-XX7RHVQF.js.map} +0 -0
- /package/dist/{formula-U2RXOOE4.js.map → formula-HMKT4BZL.js.map} +0 -0
- /package/dist/{generator-K6I6IYOH.js.map → generator-HOY4SZ26.js.map} +0 -0
- /package/dist/{hancom-ARDTLWD5.js.map → hancom-QWJBWOOE.js.map} +0 -0
- /package/dist/{image-ocr-RDWOEEQ2.js.map → image-ocr-P5AIZNT3.js.map} +0 -0
- /package/dist/{memo-RND3VIEW.js.map → memo-Q7772VJD.js.map} +0 -0
- /package/dist/{model-bundle-A6C5PVSS.js.map → model-bundle-5CXCIZHZ.js.map} +0 -0
- /package/dist/{models-KTY3IZU2.js.map → models-PS4L7NLP.js.map} +0 -0
- /package/dist/{page-images-PVXQYU7Z.js.map → page-images-QW7IUTUB.js.map} +0 -0
- /package/dist/{parse-worker-v2-E4T4427H.js.map → parse-worker-v2-PRH6KVKP.js.map} +0 -0
- /package/dist/{pdf-ocr-C6DYPI2Q.js.map → pdf-ocr-ZH4JAUTR.js.map} +0 -0
- /package/dist/{profile-io-LZ5YPCIW.js.map → profile-io-JFRAM2VE.js.map} +0 -0
- /package/dist/{rasterize-K2VVPUGE.js.map → rasterize-JJOMUTYX.js.map} +0 -0
- /package/dist/{redact-doc-A3M2YEXE.js.map → redact-doc-A7TW4MNF.js.map} +0 -0
- /package/dist/{render-HS2YWRJE.js.map → render-VAOMAQV2.js.map} +0 -0
- /package/dist/{rewrite-fallback-3YVRWPRM.js.map → rewrite-fallback-7PR7V3AZ.js.map} +0 -0
- /package/dist/{seal-DYLPFEC6.js.map → seal-RZZNRJFL.js.map} +0 -0
- /package/dist/{setup-YK2SCVLP.js.map → setup-6DXZJQCT.js.map} +0 -0
- /package/dist/{to-hwpx-XNBAWVNY.js.map → to-hwpx-A56R6H27.js.map} +0 -0
- /package/dist/{visual-SQORG4IC.js.map → visual-25RY7EFI.js.map} +0 -0
- /package/dist/{watch-CQX4TSVQ.js.map → watch-7W6CKGX7.js.map} +0 -0
|
@@ -16,14 +16,16 @@ import {
|
|
|
16
16
|
restoreUnmappedCidSpaces,
|
|
17
17
|
restoreUnmappedGlyphs,
|
|
18
18
|
spaceMappedDots
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-PVOLFVXE.js";
|
|
20
20
|
import {
|
|
21
21
|
WEBP_UNAVAILABLE,
|
|
22
22
|
loadWebpEncoder
|
|
23
23
|
} from "./chunk-YVFNHYJK.js";
|
|
24
24
|
import {
|
|
25
|
-
encodePng
|
|
26
|
-
|
|
25
|
+
encodePng,
|
|
26
|
+
encodePngAsync,
|
|
27
|
+
pngScanlineBytes
|
|
28
|
+
} from "./chunk-5PEMTYTM.js";
|
|
27
29
|
import {
|
|
28
30
|
hasRequestedPagesAfter,
|
|
29
31
|
parsePageRange
|
|
@@ -81,7 +83,7 @@ import {
|
|
|
81
83
|
stripAbsorbedRunningLines,
|
|
82
84
|
trimTrailingEmptyTableCols,
|
|
83
85
|
wrapJoiner
|
|
84
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-5MDRUEHP.js";
|
|
85
87
|
import {
|
|
86
88
|
ImageKind,
|
|
87
89
|
OPS,
|
|
@@ -99,12 +101,12 @@ import {
|
|
|
99
101
|
stripScriptTags,
|
|
100
102
|
toTex,
|
|
101
103
|
unframeLayoutTables
|
|
102
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-GJORKM42.js";
|
|
103
105
|
import {
|
|
104
106
|
assignTableIds,
|
|
105
107
|
blocksToMarkdown,
|
|
106
108
|
escapeLiteralDollar
|
|
107
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-3AYNFK6J.js";
|
|
108
110
|
import {
|
|
109
111
|
WINGDINGS,
|
|
110
112
|
enclosedNumber
|
|
@@ -113,13 +115,13 @@ import {
|
|
|
113
115
|
handwritingFallbackModels,
|
|
114
116
|
ocrModelsCached,
|
|
115
117
|
resolveOcrModels
|
|
116
|
-
} from "./chunk-
|
|
117
|
-
import "./chunk-
|
|
118
|
-
import "./chunk-
|
|
118
|
+
} from "./chunk-ZCMMU34Z.js";
|
|
119
|
+
import "./chunk-ZO4P735U.js";
|
|
120
|
+
import "./chunk-TI6S3KZF.js";
|
|
119
121
|
import {
|
|
120
122
|
KordocError,
|
|
121
123
|
sanitizeHref
|
|
122
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-24LB25LZ.js";
|
|
123
125
|
|
|
124
126
|
// src/pdf/image-extract.ts
|
|
125
127
|
import { createHash } from "node:crypto";
|
|
@@ -156,8 +158,10 @@ var MAX_PIXELS = 36e6;
|
|
|
156
158
|
var MAX_IMAGES_PER_DOC = 200;
|
|
157
159
|
var MAX_TOTAL_IMAGE_BYTES = 128 * 1024 * 1024;
|
|
158
160
|
var MAX_PENDING_RAW_BYTES = 64 * 1024 * 1024;
|
|
161
|
+
var MAX_PENDING_PNG_IMAGES = 4;
|
|
162
|
+
var MIN_ASYNC_PNG_BYTES = 64 * 1024;
|
|
159
163
|
function createPdfImageState(webp, placement = false, dropBlank = false) {
|
|
160
|
-
return { imageIndex: 0, totalBytes: 0, seen: /* @__PURE__ */ new Map(), globalKeys: /* @__PURE__ */ new Map(), capWarned: false, webp, pending: [], pendingRaw: 0, renamed: /* @__PURE__ */ new Map(), oversize: 0, placement, dropBlank };
|
|
164
|
+
return { imageIndex: 0, totalBytes: 0, seen: /* @__PURE__ */ new Map(), globalKeys: /* @__PURE__ */ new Map(), capWarned: false, webp, pending: [], pendingRaw: 0, renamed: /* @__PURE__ */ new Map(), oversize: 0, failed: /* @__PURE__ */ new Set(), placement, dropBlank };
|
|
161
165
|
}
|
|
162
166
|
function contentHash(data) {
|
|
163
167
|
return createHash("sha1").update(data).digest("hex");
|
|
@@ -237,7 +241,7 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
237
241
|
imgData = argsArray[i]?.[0];
|
|
238
242
|
}
|
|
239
243
|
if (!imgData?.data || !imgData.width || !imgData.height) continue;
|
|
240
|
-
const { width: w, height: h } = imgData;
|
|
244
|
+
const { width: w, height: h, kind, data } = imgData;
|
|
241
245
|
if (w < MIN_DIM || h < MIN_DIM) continue;
|
|
242
246
|
if (w * h > MAX_PIXELS) {
|
|
243
247
|
warnings.push({ page: pageNumber, message: `이미지 크기 초과로 추출 생략 (${w}×${h})`, code: "SKIPPED_IMAGE" });
|
|
@@ -246,21 +250,29 @@ async function extractPageImages(page, fnArray, argsArray, pageNumber, state, wa
|
|
|
246
250
|
const globalId = dedupeId?.startsWith("g_") ? dedupeId : void 0;
|
|
247
251
|
let hash = globalId ? state.globalKeys.get(globalId) : void 0;
|
|
248
252
|
if (hash === void 0) {
|
|
249
|
-
hash = `${w}x${h}k${
|
|
253
|
+
hash = `${w}x${h}k${kind ?? "?"}h${contentHash(data)}${dedupeId ? "" : "inline"}`;
|
|
250
254
|
if (globalId) state.globalKeys.set(globalId, hash);
|
|
251
255
|
}
|
|
252
256
|
if (state.seen.has(hash)) continue;
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
if (state.dropBlank &&
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
const channels = kind === ImageKind.RGB_24BPP ? 3 : kind === ImageKind.RGBA_32BPP ? 4 : void 0;
|
|
258
|
+
let pixels;
|
|
259
|
+
if (channels && withBytes && !state.webp && !readQr && !state.dropBlank && pngScanlineBytes(w, h) >= MIN_ASYNC_PNG_BYTES) {
|
|
260
|
+
if (data.length < w * h * channels) continue;
|
|
261
|
+
pixels = { data, channels };
|
|
262
|
+
} else {
|
|
263
|
+
const rgba = toRgba(imgData, withBytes || !!readQr || state.dropBlank);
|
|
264
|
+
if (!rgba) continue;
|
|
265
|
+
if (state.dropBlank && isBlankRgba(rgba)) {
|
|
266
|
+
state.seen.set(hash, "");
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
pixels = { data: rgba };
|
|
258
270
|
}
|
|
259
271
|
state.imageIndex++;
|
|
260
272
|
const filename = imageFilename(state, w, h);
|
|
261
273
|
state.seen.set(hash, filename);
|
|
262
|
-
if (withBytes) await pushImage(state, filename, w, h,
|
|
263
|
-
const qr = readQr ? await readQr({ data:
|
|
274
|
+
if (withBytes) await pushImage(state, filename, w, h, pixels, images);
|
|
275
|
+
const qr = readQr && pixels.channels === void 0 ? await readQr({ data: pixels.data, width: w, height: h }) : [];
|
|
264
276
|
blocks.push(placed({ type: "image", text: filename, pageNumber, ...qr.length ? { qr } : {} }, i));
|
|
265
277
|
}
|
|
266
278
|
return { blocks, images };
|
|
@@ -274,47 +286,74 @@ async function capReached(state, pageNumber, warnings) {
|
|
|
274
286
|
}
|
|
275
287
|
return true;
|
|
276
288
|
}
|
|
277
|
-
async function pushImage(state, filename, w, h,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
289
|
+
async function pushImage(state, filename, w, h, pixels, images) {
|
|
290
|
+
const webp = webpable(state, w, h) ? state.webp : void 0;
|
|
291
|
+
const raw = webp ? pixels.data.length : pngScanlineBytes(w, h);
|
|
292
|
+
const image = { filename, data: NO_BYTES, mimeType: webp ? "image/webp" : "image/png" };
|
|
293
|
+
const save = (data) => {
|
|
294
|
+
image.data = data;
|
|
295
|
+
state.totalBytes += data.length;
|
|
296
|
+
if (!webp && state.webp) state.oversize++;
|
|
297
|
+
};
|
|
298
|
+
const fail = () => {
|
|
299
|
+
state.failed.add(filename);
|
|
300
|
+
};
|
|
301
|
+
if (pixels.channels === void 0 && !webp && raw < MIN_ASYNC_PNG_BYTES) {
|
|
302
|
+
try {
|
|
303
|
+
save(encodePng(w, h, pixels.data));
|
|
304
|
+
images.push(image);
|
|
305
|
+
} catch {
|
|
306
|
+
fail();
|
|
307
|
+
}
|
|
283
308
|
return;
|
|
284
309
|
}
|
|
285
|
-
await drain(state, MAX_PENDING_RAW_BYTES -
|
|
286
|
-
const image = { filename, data: NO_BYTES, mimeType: "image/webp" };
|
|
310
|
+
await drain(state, MAX_PENDING_RAW_BYTES - raw, webp ? void 0 : MAX_PENDING_PNG_IMAGES - 1);
|
|
287
311
|
images.push(image);
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
312
|
+
const encoded = pixels.channels === void 0 && webp ? encodeWebpImage(webp, state, image, w, h, pixels.data) : encodePngAsync(w, h, pixels.data, pixels.channels);
|
|
313
|
+
const done = encoded.then(save, fail);
|
|
314
|
+
if (!webp && raw > MAX_PENDING_RAW_BYTES) {
|
|
315
|
+
await done;
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
state.pending.push({ done, raw });
|
|
319
|
+
state.pendingRaw += raw;
|
|
320
|
+
}
|
|
321
|
+
async function encodeWebpImage(webp, state, image, w, h, rgba) {
|
|
322
|
+
try {
|
|
323
|
+
return await webp(rgba, w, h);
|
|
324
|
+
} catch {
|
|
325
|
+
const png = encodePng(w, h, rgba);
|
|
326
|
+
const filename = image.filename.replace(/\.webp$/, ".png");
|
|
327
|
+
state.renamed.set(image.filename, filename);
|
|
328
|
+
image.filename = filename;
|
|
329
|
+
image.mimeType = "image/png";
|
|
330
|
+
return png;
|
|
331
|
+
}
|
|
304
332
|
}
|
|
305
|
-
async function drain(state,
|
|
306
|
-
while (state.
|
|
333
|
+
async function drain(state, keepRaw, keepCount = Infinity) {
|
|
334
|
+
while (state.pendingRaw > keepRaw || state.pending.length > keepCount) {
|
|
307
335
|
const p = state.pending.shift();
|
|
308
|
-
|
|
336
|
+
if (!p) break;
|
|
309
337
|
await p.done;
|
|
338
|
+
state.pendingRaw -= p.raw;
|
|
310
339
|
}
|
|
311
340
|
}
|
|
312
|
-
async function flushPdfImages(state, warnings, pageImages) {
|
|
341
|
+
async function flushPdfImages(state, warnings, pageImages, images) {
|
|
313
342
|
await drain(state, 0);
|
|
314
343
|
if (state.oversize) warnings.push({ message: `WebP 한도(가로·세로 16,383px)를 넘는 그림 ${state.oversize}개를 PNG 로 냈습니다`, code: "SKIPPED_IMAGE" });
|
|
315
|
-
if (
|
|
316
|
-
|
|
317
|
-
|
|
344
|
+
if (state.renamed.size) {
|
|
345
|
+
for (const list of pageImages.values()) for (const b of list) if (b.text) b.text = state.renamed.get(b.text) ?? b.text;
|
|
346
|
+
warnings.push({ message: `WebP 인코딩 실패로 그림 ${state.renamed.size}개를 PNG 로 냈습니다`, code: "SKIPPED_IMAGE" });
|
|
347
|
+
}
|
|
348
|
+
if (state.failed.size) {
|
|
349
|
+
for (let i = images.length - 1; i >= 0; i--) if (state.failed.has(images[i].filename)) images.splice(i, 1);
|
|
350
|
+
for (const [page, list] of pageImages) {
|
|
351
|
+
const kept = list.filter((b) => !b.text || !state.failed.has(b.text));
|
|
352
|
+
if (kept.length) pageImages.set(page, kept);
|
|
353
|
+
else pageImages.delete(page);
|
|
354
|
+
}
|
|
355
|
+
warnings.push({ message: `PNG 인코딩 실패로 그림 ${state.failed.size}개를 추출하지 못했습니다`, code: "SKIPPED_IMAGE" });
|
|
356
|
+
}
|
|
318
357
|
}
|
|
319
358
|
var WEBP_MAX_DIM = 16383;
|
|
320
359
|
var webpable = (state, w, h) => !!state.webp && w <= WEBP_MAX_DIM && h <= WEBP_MAX_DIM;
|
|
@@ -3639,7 +3678,7 @@ function mergeLinkRuns(markdown) {
|
|
|
3639
3678
|
|
|
3640
3679
|
// src/pdf/formula-ocr.ts
|
|
3641
3680
|
async function applyFormulaOcr(buffer, blocks, pageFilter, effectivePageCount, warnings, _onProgress) {
|
|
3642
|
-
const formulaMod = await import("./formula-
|
|
3681
|
+
const formulaMod = await import("./formula-HMKT4BZL.js");
|
|
3643
3682
|
const { FormulaPipeline, ensureFormulaModels } = formulaMod;
|
|
3644
3683
|
await ensureFormulaModels((p) => {
|
|
3645
3684
|
if (p.phase === "download" && p.total) {
|
|
@@ -4006,7 +4045,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4006
4045
|
const isImageBased = pageFilter?.size !== 0 && totalChars / Math.max(parsedPageCount, 1) < 10;
|
|
4007
4046
|
const ocrDone = /* @__PURE__ */ new Set();
|
|
4008
4047
|
const ocrLinesOut = /* @__PURE__ */ new Map();
|
|
4009
|
-
const pageRasters = options?.pageImages ? new (await import("./page-images-
|
|
4048
|
+
const pageRasters = options?.pageImages ? new (await import("./page-images-QW7IUTUB.js")).PageImageSink(options.pageImages) : null;
|
|
4010
4049
|
const allRegions = options?.ocr === true || typeof options?.ocr === "function";
|
|
4011
4050
|
const ocrRegions = allRegions || autoOcr ? ocrImageRegions(uncoveredImageRegions, largeImageRegions, allRegions) : /* @__PURE__ */ new Map();
|
|
4012
4051
|
if (ocrBuffer) {
|
|
@@ -4025,10 +4064,10 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4025
4064
|
}
|
|
4026
4065
|
if (targets.size > 0) {
|
|
4027
4066
|
try {
|
|
4028
|
-
const { runPdfOcr } = await import("./pdf-ocr-
|
|
4067
|
+
const { runPdfOcr } = await import("./pdf-ocr-ZH4JAUTR.js");
|
|
4029
4068
|
const mode = typeof options?.ocr === "function" ? options.ocr : "builtin";
|
|
4030
4069
|
const regionPages = new Map([...ocrRegions].filter(([p]) => options?.ocr !== "force" && !isImageBased && !pageQuality.find((q) => q.page === p)?.needsOcr));
|
|
4031
|
-
const { builtinOcrConfig } = await import("./pdf-ocr-
|
|
4070
|
+
const { builtinOcrConfig } = await import("./pdf-ocr-ZH4JAUTR.js");
|
|
4032
4071
|
const ocrPageBlocks = await runPdfOcr(ocrBuffer, targets, mode, warnings, options?.onProgress, options?.tables !== false, vectorPageOps, regionPages, builtinOcrConfig(options), ocrLinesOut, pageRasters ?? void 0);
|
|
4033
4072
|
for (const obs of ocrPageBlocks.values()) stripScriptTags({ blocks: obs });
|
|
4034
4073
|
if (ocrPageBlocks.size > 0) {
|
|
@@ -4070,7 +4109,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4070
4109
|
const rest = [];
|
|
4071
4110
|
for (let i = 1; i <= effectivePageCount; i++) if ((!pageFilter || pageFilter.has(i)) && !pageRasters.has(i)) rest.push(i);
|
|
4072
4111
|
try {
|
|
4073
|
-
const { renderPdfPageImages } = await import("./pdf-ocr-
|
|
4112
|
+
const { renderPdfPageImages } = await import("./pdf-ocr-ZH4JAUTR.js");
|
|
4074
4113
|
await renderPdfPageImages(buffer, rest, pageRasters, warnings);
|
|
4075
4114
|
} catch (e) {
|
|
4076
4115
|
warnings.push({ message: `pageImages 실행 불가: ${e instanceof Error ? e.message : String(e)}`, code: "SKIPPED_IMAGE" });
|
|
@@ -4130,7 +4169,7 @@ async function parsePdfDocument(buffer, options) {
|
|
|
4130
4169
|
splitContactTables(blocks);
|
|
4131
4170
|
if (!options?.keepTrailingEmptyCols) trimTrailingEmptyTableCols(blocks);
|
|
4132
4171
|
joinPageBreakWraps(blocks, wrapLexicon);
|
|
4133
|
-
await flushPdfImages(imageState, warnings, pageImageBlocks);
|
|
4172
|
+
await flushPdfImages(imageState, warnings, pageImageBlocks, extractedImages);
|
|
4134
4173
|
injectPageImageBlocks(blocks, pageImageBlocks);
|
|
4135
4174
|
if (options?.formulaOcr && formulaBuffer) {
|
|
4136
4175
|
try {
|
|
@@ -4277,4 +4316,4 @@ export {
|
|
|
4277
4316
|
parsePdfDocument,
|
|
4278
4317
|
removeHeaderFooterBlocks
|
|
4279
4318
|
};
|
|
4280
|
-
//# sourceMappingURL=parser-
|
|
4319
|
+
//# sourceMappingURL=parser-OQIR5ZMI.js.map
|